solve

Solve Ax = b directly using LUP decomposition

void
solve
(
T
size_t N
)
(
Matrix!(T, N) a
,
ref Vector!(T, N) x
,
Vector!(T, N) b
)

Examples

bool isConsiderZeroTolerant(T) (T f) nothrow
{
    return (abs(f) < 0.0001f);
}

Matrix3f a = matrixf(
    1, 3, -2,
    3, 5,  6,
    2, 4,  3
);
Vector3f b = Vector3f(5, 7, 8);
Vector3f x = Vector3f(0, 0, 0);

solve(a, x, b);

assert(isConsiderZeroTolerant(-15 - x[0]));
assert(isConsiderZeroTolerant(8 - x[1]));
assert(isConsiderZeroTolerant(2 - x[2]));

Meta