Open elect86 opened 5 months ago
I'm porting some code from Python to Kotlin and I'm using Ejml, specifically this
np.linalg.pinv(cell)
which "Compute the (Moore-Penrose) pseudo-inverse of a matrix." and where cell is a 3x3 float64 matrix
cell
[[2.259825867767797, 0.0, 0.0], [-1.1299129338838985, 1.9570656971336065, 0.0], [0.0, 0.0, 3.5698785608749377]]
my float counterpart is
float
[0.44251198, -8.326673E-17, 0.0] [0.25548452, 0.51096904, 0.0] [0.0, 0.0, 0.28012156]
on Python I do get
[[4.42511972e-01 2.83417670e-17 0.00000000e+00], [2.55484525e-01 5.10969050e-01 0.00000000e+00], [0.00000000e+00 0.00000000e+00 2.80121574e-01]]
on Ejml, with SimpleMatrix::pseudoInverse
SimpleMatrix::pseudoInverse
[0.44251198, -2.9802322E-8, 0.0] [0.25548458, 0.5109691, 0.0] [0.0, 0.0, 0.28012162]
You can see that there is just one problematic value, at [0, 1]
if I hardcode the float64 values of Python into Kotlin, I do get a closer value but still not quite the same
Any idea how I could improve this?
Python code is here
I'm porting some code from Python to Kotlin and I'm using Ejml, specifically this
np.linalg.pinv(cell)
which "Compute the (Moore-Penrose) pseudo-inverse of a matrix." and where
cell
is a 3x3 float64 matrixmy
float
counterpart ison Python I do get
on Ejml, with
SimpleMatrix::pseudoInverse
You can see that there is just one problematic value, at [0, 1]
if I hardcode the float64 values of Python into Kotlin, I do get a closer value but still not quite the same
Any idea how I could improve this?
Python code is here