enhancedmath
Version:
This package contains some enhanced mathematical operations
71 lines (70 loc) • 2.07 kB
JavaScript
import { test, describe, expect } from 'vitest';
import cofactorMatrix from '../Matrix/cofactor';
describe('Matrix Co-factor', () => {
test('should return correct cofactor matrix for 2x2 matrix', () => {
const matrix = [
[ ],
[ ],
];
const expected = [
[ ],
[-2, 1],
];
const result = cofactorMatrix(matrix);
expect(result).toEqual(expected);
});
test('should return correct cofactor matrix for 3x3 matrix', () => {
const matrix = [
[ ],
[ ],
[ ],
];
const expected = [
[-3, 6, -3],
[ ],
[-3, 6, -3],
];
const result = cofactorMatrix(matrix);
expect(result).toEqual(expected);
});
test('should return correct cofactor matrix for 4x4 matrix', () => {
const matrix = [
[ ],
[ ],
[ ],
[ ],
];
const expected = [
[ ],
[ ],
[ ],
[ ],
];
const result = cofactorMatrix(matrix);
expect(result).toEqual(expected);
});
test('should return correct cofactor matrix for 4x4 matrix', () => {
const matrix = [
[ ],
[ ],
[ ],
[ ],
];
const expected = [
[ ],
[ ],
[-6391, 2792, 1971, -222],
[ ],
];
const result = cofactorMatrix(matrix);
expect(result).toEqual(expected);
});
test('should return undefined when input matrix is not square', () => {
const matrix = [
[ ],
[ ],
];
const result = cofactorMatrix(matrix);
expect(result).toBeUndefined();
});
});