UNPKG

xen-dev-utils

Version:

Utility functions used by the Scale Workshop ecosystem

89 lines 2.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const vitest_1 = require("vitest"); const hnf_1 = require("../hnf"); (0, vitest_1.describe)('Hermite normal form', () => { (0, vitest_1.it)('works on a small matrix', () => { const A = [ [2, 3, 6, 2], [5, 6, 1, 6], [8, 3, 1, 1], ]; const H = (0, hnf_1.hnf)(A); (0, vitest_1.expect)(H).toEqual([ [1, 0, 50, -11], [0, 3, 28, -2], [0, 0, 61, -13], ]); }); (0, vitest_1.it)('works on a small matrix (bigint)', () => { const A = [ [2n, 3n, 6n, 2n], [5n, 6n, 1n, 6n], [8n, 3n, 1n, 1n], ]; const H = (0, hnf_1.hnf)(A); (0, vitest_1.expect)(H).toEqual([ [1n, 0n, 50n, -11n], [0n, 3n, 28n, -2n], [0n, 0n, 61n, -13n], ]); }); }); (0, vitest_1.describe)('Integer determinant', () => { (0, vitest_1.it)('works on a small matrix', () => { const mat = [ [-2, -1, 2], [2, 1, 4], [-3, 3, -1], ]; const determinant = (0, hnf_1.integerDet)(mat); (0, vitest_1.expect)(determinant).toBe(54); }); (0, vitest_1.it)('works on a small matrix (bigint)', () => { const mat = [ [-2n, -1n, 2n], [2n, 1n, 4n], [-3n, 3n, -1n], ]; const determinant = (0, hnf_1.integerDet)(mat); (0, vitest_1.expect)(determinant).toBe(54n); }); }); (0, vitest_1.describe)('Transpose', () => { (0, vitest_1.it)('transposes a 3x2 matrix', () => { const mat = [[1, 2], [3], [4, 5]]; (0, vitest_1.expect)((0, hnf_1.transpose)(mat)).toEqual([ [1, 3, 4], [2, 0, 5], ]); }); }); (0, vitest_1.describe)('Anti-transpose', () => { (0, vitest_1.it)('anti-transposes a 3x2 matrix', () => { const mat = [ [1, 2], [3, 4], [5, 6], ]; (0, vitest_1.expect)((0, hnf_1.antitranspose)(mat)).toEqual([ [6, 4, 2], [5, 3, 1], ]); }); }); (0, vitest_1.describe)('Preimage', () => { (0, vitest_1.it)('obtains the preimage associated with 5-limit meantone', () => { const map = [ [1, 0, -4], [0, 1, 4], ]; const gensT = (0, hnf_1.preimage)(map); (0, vitest_1.expect)(gensT).toEqual([ [1, 0], [0, 1], [0, 0], ]); }); }); //# sourceMappingURL=hnf.spec.js.map