DualMatrixTools.jl

A little Julia module to allow factorization and backslash to work with dual-valued arrays and sparse arrays.
Author briochemc
Popularity
2 Stars
Updated Last
4 Years Ago
Started In
November 2018

DualMatrixTools.jl

License: MIT

This package provides an overloaded factorize and \ that work with dual-valued arrays.

It uses the dual type defined by the DualNumbers.jl package. The idea is that for a dual-valued matrix

M = A + ε B

its inverse is

M-1 = (I - ε A-1 B) A-1

Therefore, only the inverse of A is required to evaluate the inverse of M. This package makes available a DualFactors type which containts (i) the factors of A and (ii) the non-real part, B. It also overloads factorize to create an instance of DualFactors (when invoked with a dual-valued matrix), which can then be called with \ to efficiently solve dual-valued linear systems of the type M x = b.

This package should be useful for autodifferentiation of functions that use \. Note the same idea extends to hyper dual numbers (see the HyperDualMatrixTools.jl package).

Usage

  1. Create your dual-valued matrix M:

    julia> M = A + ε * B
  2. Apply \ to solve systems of the type M * x = b

    • without factorization:

      julia> x = M \ b
    • or better, with prior factorization:

      julia> Mf = factorize(M)
      
      julia> x = Mf \ b

      (This is better in case you want to solve for another b!)

Advanced usage

In the context of iterative processes with multiple factorizations and forward and back substitutions, you may want to propagate dual-valued numbers while leveraging (potentially) the fact the real part of the matrices to be factorized remains the same throughout. This package provides an in-place factorize, with a flag to update (or not) the factors. Usage is straightforward. By default, factorize does not update the factors

julia> factorize(Mf, M) # only Mf.B is updated

If you want to update the real-valued factors too, use

julia> factorize(Mf, M, update_factors=true) # Mf.B and Mf.Af are updated

Citation

If you use this package, please cite it! You can either directly use the bibtex entry, CITATION.bib, or go to the Zenodo record of the package and export the citation from there (the "Export" box at the bottom of that page).

Used By Packages

No packages found.