AX=B
auto a = [ 1, -1, 1, 2, 2, -4, -1, 5, 0].sliced(3, 3); auto b = [ 2.0, 0, -6 , -6, 9 , 1].sliced(3, 2); auto t = [ 1.0, -1, 2 , 0, 3 , 1].sliced(3, 2); auto x = mldivide(a, b); assert(x == t);
Ax=B
auto a = [ 1, -1, 1, 2, 2, -4, -1, 5, 0].sliced(3, 3); auto b = [ 2.0, -6 , 9 ].sliced(3); auto t = [ 1.0, 2 , 3 ].sliced(3); auto x = mldivide(a, b); assert(x == t);
Least-Squares Solution of Underdetermined System
auto a = [ -0.57, -1.28, -0.39, 0.25, -1.93, 1.08, -0.31, -2.14, 2.30, 0.24, 0.40, -0.35, -1.93, 0.64, -0.66, 0.08, 0.15, 0.30, 0.15, -2.13, -0.02, 1.03, -1.43, 0.50, ].sliced(6, 4); auto b = [ -2.67, -0.55, 3.34, -0.77, 0.48, 4.10, ].sliced; auto x = [ 1.5339, 1.8707, -1.5241, 0.0392].sliced; import std.math: approxEqual; assert(a.mldivide(b).approxEqual(x));
Solve systems of linear equations AX = B for X. Computes minimum-norm solution to a linear least squares problem if A is not a square matrix.