Skip to content

Incorrect inversion of (complex) matrices #183

@ajlawren

Description

@ajlawren

Hello,
This is an amazing package, I am thoroughly impressed. Thank you for all the time and effort!

I am trying to inv a square matrix A composed of Particle objects:

Using MonteCarloMeasurements
A_bar = randn(5,5)
A_std = abs.(randn(5,5))
A = A_bar .± A_std 

Calculating the inverse of this with MonteCarloMeasurements (with the @unsafe mode) yields

@unsafe pmean.(inv(A))
5×5 Matrix{Float64}:
  0.991553    1.16502     -1.94536   -1.50509    0.439208
  0.232711   -0.00783246   0.414581  -0.0993158  0.409937
  1.1345      0.741083    -1.54862   -0.970953   0.749576
 -0.794642   -0.256104     0.906283   0.706037   0.0634964
  0.0174808   0.666404    -2.28201   -1.68       0.617051

while calculating the inverse of the mean yields

inv(A_bar)
5×5 Matrix{Float64}:
 -0.0441282    0.207341    0.382708   0.243892   -0.160185
 -0.137243    -0.0641063   0.438657  -0.0528539   0.617828
 -0.00204959  -0.114085    0.484008   0.742596    0.079385
  0.178726     0.340945   -0.502247  -0.466079    0.238289
 -0.934811    -0.156226   -0.208956  -0.0631625   0.273484

Is this a result of the @unsafe mode? Or is this impossible with Monte Carlo methods?

This operation is handled fine with Measurements, interestingly enough. I am ultimately interested in using inv on complex uncertain matrices, but this is the more fundamental issue.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions