import { GaussianElimination, Matrix } from "../matrix"; let A = new Matrix( [1, 2, 3], [4, 5, 6] ); let B = new Matrix( [1, 4], [2, 5], [3, 6] ); let C = new Matrix( [ 14, 32 ], [ 32, 77 ] ); test('A = B.transpose', () => { expect(A.eq(B.transpose())).toBe(true); }); test('B = A.transpose', () => { expect(B.eq(A.transpose())).toBe(true); }); test('A * B = C', () => { expect(A.mul(B).eq(C)).toBe(true); }); test('B * A != C', () => { expect(B.mul(A).eq(C)).toBe(false); }); let D = new GaussianElimination( new Matrix( [1, 2, -1, 1, 2], [2, 5, 0, 1, 5], [3, 7, -1, 3, 9], [1, 3, 1, 1, 5] ) ); let D_solved = new Matrix( [1, 2, -1, 1, 2], [0, 1, 2, -1, 1], [0, 0, 0, 1, 2], [0, 0, 0, 0, 0] ); test('D - Gaussian elimination', () => { expect(D.solve().eq(D_solved)).toBe(true); }); let E = new GaussianElimination( new Matrix( [1, 1, 3], [2, -1, 4] ) ); let E_solved = new Matrix( [1, 1, 3], [0, -3, -2] ); test('E - Gaussian elimination', () => { expect(E.solve().eq(E_solved)).toBe(true); });