Chi2fit.Matrix.inverse

You're seeing just the function inverse, go back to Chi2fit.Matrix module for more information.
Link to this function

inverse(matrix, options \\ [])

View Source

Specs

inverse(matrix(), options :: Keyword.t()) ::
  {:ok, inverse :: matrix()}
  | :failed_to_find_v0
  | :no_inverse
  | {:failed_to_reach_tolerance, inverse :: matrix(), error :: float()}

Returns the matrix inverse of the argument.

Options

`:tolerance` - Iterate until the `norm_1/1` of I-AV is less than this value
`:algorithm` - Four algorithms are supported: `:hotelling_bodewig` (second order), `:lie` (third order),
    `:krishnamurthy_sen` (sixth order), and `:soleymani` (seventh order); defaults to `:lie`
`:max_iterations` - Maximum number of iterations to perform; defaults to 500
`:range` - Range of values from -range to +range as a multiple of the unit matrix to try as an estimate
    of the inverse matric; defaults to 100
`:size` - Number of tries to estimate initial inverse; defautls to 100

Examples

iex> inverse [[3]]
{:ok,[[0.3333333333333333]]}

iex> inverse [[1,2],[3,4]]
{:ok,[[-2.0, 1.0], [1.5, -0.5]]}

iex> inverse([[3,2,0],[0,0,1],[2,-2,1]]) |> elem(1) |> Enum.map(fn row -> Enum.map(row, & Float.round(&1,10)) end)
[[0.2, -0.2, 0.2], [0.2, 0.3, -0.3], [0.0, 1.0, 0.0]]

iex> inverse([[3,2,0],[0,0,1],[2,-2,1]], algorithm: :soleymani) |> elem(1) |> Enum.map(fn row -> Enum.map(row, & Float.round(&1,14)) end)
[[0.2, -0.2, 0.2], [0.2, 0.3, -0.3], [0.0, 1.0, 0.0]]

iex> inverse([[3,2,0],[0,0,1],[2,-2,1]], tolerance: 1.0e-15) |> elem(1) |> Enum.map(fn row -> Enum.map(row, & Float.round(&1,14)) end)
[[0.2, -0.2, 0.2], [0.2, 0.3, -0.3], [0.0, 1.0, 0.0]]

For matrices that have no inverse:

iex> try do inverse [[1,2,3],[4,5,6],[7,8,9]] catch x->x end
:no_inverse