flag to delete the source matrix.
factorization of matrix 'A', A = P * L * U.
the pivot indices from luDecomp.
the right hand side matrix B.
specifies the form of the system of equations: = 'N': A * X = B (No transpose) = 'T': A**T * X = B (Transpose) = 'C': A**T * X = B (Conjugate transpose = Transpose)
Return solve of the system linear equations.
auto A = [ 1, 4, -3, 5, 6, -2, 8, 5, 7, 8, 3, 4, 7, 9, 1, 2, 4, 6, 3, 2, 6, 8, 3, 5, 2 ] .sliced(5, 5) .as!double.slice .canonical; import mir.random.variable; import mir.random.algorithm; auto B = randomSlice!double(uniformVar(-100, 100), 5, 100); auto LU = A.luDecomp(); auto X = LU.solve(B); import mir.ndslice.algorithm: equal; assert(equal!((a, b) => fabs(a - b) < 1e-12)(mtimes(A, X), B));
auto B = [ 3, -7, -2, 2, -3, 5, 1, 0, 6, -4, 0, -5, -9, 5, -5, 12 ] .sliced(4, 4) .as!double.slice .canonical; auto C = B.transposed.slice; auto LU = B.transposed.luDecomp!(Yes.allowDestroy)(); auto res = mtimes(LU.l, LU.u); moveRows(res, LU.ipiv); import mir.ndslice.algorithm: equal; import std.math: approxEqual; assert(res.equal!approxEqual(C));
Solves a system of linear equations \A * X = B, or \A**T * X = B with a general 'N x N' matrix 'A' using the LU factorization computed by luDecomp.