enhancedmath
Version:
This package contains some enhanced mathematical operations
65 lines (64 loc) • 1.68 kB
JavaScript
import { describe, test, expect } from 'vitest';
import matrix_product from '../Matrix/matrix_product';
describe('Matrix: Product', () => {
test("should return undefined if dimensions aren't lining up", () => {
const A = [
[ ],
[ ],
];
const B = [[5, 6, 3]];
const C = [[7], [8], [4]];
let result = matrix_product(A, B);
expect(result).toBeUndefined();
result = matrix_product(A, C);
expect(result).toBeUndefined();
});
test('should return 2x2 for 2 2x2 matrices', () => {
const A = [
[ ],
[ ],
];
const B = [
[ ],
[ ],
];
const result = matrix_product(A, B);
expect(result).toEqual([
[ ],
[ ],
]);
});
test('should return 2x4 for a 2x3 and a 3x4 matrices', () => {
const A = [
[ ],
[ ],
];
const B = [
[ ],
[ ],
[ ],
];
const result = matrix_product(A, B);
expect(result).toEqual([
[ ],
[ ],
]);
});
test('should return 3x3 for a 3x2 and a 2x3 matrices', () => {
const A = [
[ ],
[ ],
[ ],
];
const B = [
[ ],
[ ],
];
const result = matrix_product(A, B);
expect(result).toEqual([
[ ],
[ ],
[ ],
]);
});
});