mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 00:27:55 +00:00
11 lines
377 B
JavaScript
11 lines
377 B
JavaScript
let mathLib;
|
|
|
|
async function calculateDeterminant(m) {
|
|
if (!Array.isArray(m) || !m.length || m.some(r => !Array.isArray(r) || r.length !== m.length)) {
|
|
throw new TypeError('Invalid square matrix');
|
|
}
|
|
|
|
const {det} = await (mathLib ||= import('https://cdn.jsdelivr.net/npm/mathjs@11.11.0/lib/browser/math.js'));
|
|
return det(m);
|
|
}
|
|
export default calculateDeterminant; |