42681 lines
1.2 MiB
42681 lines
1.2 MiB
/*
|
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
|
if you want to view the source, please visit the github repository of this plugin
|
|
*/
|
|
|
|
var __create = Object.create;
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __getProtoOf = Object.getPrototypeOf;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __commonJS = (cb, mod3) => function __require() {
|
|
return mod3 || (0, cb[__getOwnPropNames(cb)[0]])((mod3 = { exports: {} }).exports, mod3), mod3.exports;
|
|
};
|
|
var __export = (target, all) => {
|
|
for (var name302 in all)
|
|
__defProp(target, name302, { get: all[name302], enumerable: true });
|
|
};
|
|
var __copyProps = (to2, from, except, desc) => {
|
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
for (let key of __getOwnPropNames(from))
|
|
if (!__hasOwnProp.call(to2, key) && key !== except)
|
|
__defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
}
|
|
return to2;
|
|
};
|
|
var __toESM = (mod3, isNodeMode, target) => (target = mod3 != null ? __create(__getProtoOf(mod3)) : {}, __copyProps(isNodeMode || !mod3 || !mod3.__esModule ? __defProp(target, "default", { value: mod3, enumerable: true }) : target, mod3));
|
|
var __toCommonJS = (mod3) => __copyProps(__defProp({}, "__esModule", { value: true }), mod3);
|
|
|
|
// node_modules/typed-function/lib/umd/typed-function.js
|
|
var require_typed_function = __commonJS({
|
|
"node_modules/typed-function/lib/umd/typed-function.js"(exports, module2) {
|
|
(function(global, factory2) {
|
|
typeof exports === "object" && typeof module2 !== "undefined" ? module2.exports = factory2() : typeof define === "function" && define.amd ? define(factory2) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, global.typed = factory2());
|
|
})(exports, function() {
|
|
"use strict";
|
|
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
if (!it) {
|
|
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
if (it)
|
|
o = it;
|
|
var i2 = 0;
|
|
var F = function F2() {
|
|
};
|
|
return { s: F, n: function n() {
|
|
if (i2 >= o.length)
|
|
return { done: true };
|
|
return { done: false, value: o[i2++] };
|
|
}, e: function e3(_e) {
|
|
throw _e;
|
|
}, f: F };
|
|
}
|
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
}
|
|
var normalCompletion = true, didErr = false, err;
|
|
return { s: function s() {
|
|
it = it.call(o);
|
|
}, n: function n() {
|
|
var step = it.next();
|
|
normalCompletion = step.done;
|
|
return step;
|
|
}, e: function e3(_e2) {
|
|
didErr = true;
|
|
err = _e2;
|
|
}, f: function f() {
|
|
try {
|
|
if (!normalCompletion && it.return != null)
|
|
it.return();
|
|
} finally {
|
|
if (didErr)
|
|
throw err;
|
|
}
|
|
} };
|
|
}
|
|
function _unsupportedIterableToArray(o, minLen) {
|
|
if (!o)
|
|
return;
|
|
if (typeof o === "string")
|
|
return _arrayLikeToArray(o, minLen);
|
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
if (n === "Object" && o.constructor)
|
|
n = o.constructor.name;
|
|
if (n === "Map" || n === "Set")
|
|
return Array.from(o);
|
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
return _arrayLikeToArray(o, minLen);
|
|
}
|
|
function _arrayLikeToArray(arr, len) {
|
|
if (len == null || len > arr.length)
|
|
len = arr.length;
|
|
for (var i2 = 0, arr2 = new Array(len); i2 < len; i2++) {
|
|
arr2[i2] = arr[i2];
|
|
}
|
|
return arr2;
|
|
}
|
|
function _typeof2(obj) {
|
|
"@babel/helpers - typeof";
|
|
return _typeof2 = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(obj2) {
|
|
return typeof obj2;
|
|
} : function(obj2) {
|
|
return obj2 && typeof Symbol == "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
}, _typeof2(obj);
|
|
}
|
|
function ok() {
|
|
return true;
|
|
}
|
|
function notOk() {
|
|
return false;
|
|
}
|
|
function undef() {
|
|
return void 0;
|
|
}
|
|
var NOT_TYPED_FUNCTION = "Argument is not a typed-function.";
|
|
function create() {
|
|
function isPlainObject2(x) {
|
|
return _typeof2(x) === "object" && x !== null && x.constructor === Object;
|
|
}
|
|
var _types = [{
|
|
name: "number",
|
|
test: function test(x) {
|
|
return typeof x === "number";
|
|
}
|
|
}, {
|
|
name: "string",
|
|
test: function test(x) {
|
|
return typeof x === "string";
|
|
}
|
|
}, {
|
|
name: "boolean",
|
|
test: function test(x) {
|
|
return typeof x === "boolean";
|
|
}
|
|
}, {
|
|
name: "Function",
|
|
test: function test(x) {
|
|
return typeof x === "function";
|
|
}
|
|
}, {
|
|
name: "Array",
|
|
test: Array.isArray
|
|
}, {
|
|
name: "Date",
|
|
test: function test(x) {
|
|
return x instanceof Date;
|
|
}
|
|
}, {
|
|
name: "RegExp",
|
|
test: function test(x) {
|
|
return x instanceof RegExp;
|
|
}
|
|
}, {
|
|
name: "Object",
|
|
test: isPlainObject2
|
|
}, {
|
|
name: "null",
|
|
test: function test(x) {
|
|
return x === null;
|
|
}
|
|
}, {
|
|
name: "undefined",
|
|
test: function test(x) {
|
|
return x === void 0;
|
|
}
|
|
}];
|
|
var anyType = {
|
|
name: "any",
|
|
test: ok,
|
|
isAny: true
|
|
};
|
|
var typeMap;
|
|
var typeList;
|
|
var nConversions = 0;
|
|
var typed2 = {
|
|
createCount: 0
|
|
};
|
|
function findType(typeName) {
|
|
var type = typeMap.get(typeName);
|
|
if (type) {
|
|
return type;
|
|
}
|
|
var message = 'Unknown type "' + typeName + '"';
|
|
var name302 = typeName.toLowerCase();
|
|
var otherName;
|
|
var _iterator = _createForOfIteratorHelper(typeList), _step;
|
|
try {
|
|
for (_iterator.s(); !(_step = _iterator.n()).done; ) {
|
|
otherName = _step.value;
|
|
if (otherName.toLowerCase() === name302) {
|
|
message += '. Did you mean "' + otherName + '" ?';
|
|
break;
|
|
}
|
|
}
|
|
} catch (err) {
|
|
_iterator.e(err);
|
|
} finally {
|
|
_iterator.f();
|
|
}
|
|
throw new TypeError(message);
|
|
}
|
|
function addTypes(types) {
|
|
var beforeSpec = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "any";
|
|
var beforeIndex = beforeSpec ? findType(beforeSpec).index : typeList.length;
|
|
var newTypes = [];
|
|
for (var i2 = 0; i2 < types.length; ++i2) {
|
|
if (!types[i2] || typeof types[i2].name !== "string" || typeof types[i2].test !== "function") {
|
|
throw new TypeError("Object with properties {name: string, test: function} expected");
|
|
}
|
|
var typeName = types[i2].name;
|
|
if (typeMap.has(typeName)) {
|
|
throw new TypeError('Duplicate type name "' + typeName + '"');
|
|
}
|
|
newTypes.push(typeName);
|
|
typeMap.set(typeName, {
|
|
name: typeName,
|
|
test: types[i2].test,
|
|
isAny: types[i2].isAny,
|
|
index: beforeIndex + i2,
|
|
conversionsTo: []
|
|
});
|
|
}
|
|
var affectedTypes = typeList.slice(beforeIndex);
|
|
typeList = typeList.slice(0, beforeIndex).concat(newTypes).concat(affectedTypes);
|
|
for (var _i = beforeIndex + newTypes.length; _i < typeList.length; ++_i) {
|
|
typeMap.get(typeList[_i]).index = _i;
|
|
}
|
|
}
|
|
function clear() {
|
|
typeMap = /* @__PURE__ */ new Map();
|
|
typeList = [];
|
|
nConversions = 0;
|
|
addTypes([anyType], false);
|
|
}
|
|
clear();
|
|
addTypes(_types);
|
|
function clearConversions() {
|
|
var typeName;
|
|
var _iterator2 = _createForOfIteratorHelper(typeList), _step2;
|
|
try {
|
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
|
|
typeName = _step2.value;
|
|
typeMap.get(typeName).conversionsTo = [];
|
|
}
|
|
} catch (err) {
|
|
_iterator2.e(err);
|
|
} finally {
|
|
_iterator2.f();
|
|
}
|
|
nConversions = 0;
|
|
}
|
|
function findTypeNames(value) {
|
|
var matches = typeList.filter(function(name302) {
|
|
var type = typeMap.get(name302);
|
|
return !type.isAny && type.test(value);
|
|
});
|
|
if (matches.length) {
|
|
return matches;
|
|
}
|
|
return ["any"];
|
|
}
|
|
function isTypedFunction(entity) {
|
|
return entity && typeof entity === "function" && "_typedFunctionData" in entity;
|
|
}
|
|
function findSignature(fn, signature, options) {
|
|
if (!isTypedFunction(fn)) {
|
|
throw new TypeError(NOT_TYPED_FUNCTION);
|
|
}
|
|
var exact = options && options.exact;
|
|
var stringSignature = Array.isArray(signature) ? signature.join(",") : signature;
|
|
var params = parseSignature(stringSignature);
|
|
var canonicalSignature = stringifyParams(params);
|
|
if (!exact || canonicalSignature in fn.signatures) {
|
|
var match = fn._typedFunctionData.signatureMap.get(canonicalSignature);
|
|
if (match) {
|
|
return match;
|
|
}
|
|
}
|
|
var nParams = params.length;
|
|
var remainingSignatures;
|
|
if (exact) {
|
|
remainingSignatures = [];
|
|
var name302;
|
|
for (name302 in fn.signatures) {
|
|
remainingSignatures.push(fn._typedFunctionData.signatureMap.get(name302));
|
|
}
|
|
} else {
|
|
remainingSignatures = fn._typedFunctionData.signatures;
|
|
}
|
|
for (var i2 = 0; i2 < nParams; ++i2) {
|
|
var want = params[i2];
|
|
var filteredSignatures = [];
|
|
var possibility = void 0;
|
|
var _iterator3 = _createForOfIteratorHelper(remainingSignatures), _step3;
|
|
try {
|
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done; ) {
|
|
possibility = _step3.value;
|
|
var have = getParamAtIndex(possibility.params, i2);
|
|
if (!have || want.restParam && !have.restParam) {
|
|
continue;
|
|
}
|
|
if (!have.hasAny) {
|
|
var _ret = function() {
|
|
var haveTypes = paramTypeSet(have);
|
|
if (want.types.some(function(wtype) {
|
|
return !haveTypes.has(wtype.name);
|
|
})) {
|
|
return "continue";
|
|
}
|
|
}();
|
|
if (_ret === "continue")
|
|
continue;
|
|
}
|
|
filteredSignatures.push(possibility);
|
|
}
|
|
} catch (err) {
|
|
_iterator3.e(err);
|
|
} finally {
|
|
_iterator3.f();
|
|
}
|
|
remainingSignatures = filteredSignatures;
|
|
if (remainingSignatures.length === 0)
|
|
break;
|
|
}
|
|
var candidate;
|
|
var _iterator4 = _createForOfIteratorHelper(remainingSignatures), _step4;
|
|
try {
|
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done; ) {
|
|
candidate = _step4.value;
|
|
if (candidate.params.length <= nParams) {
|
|
return candidate;
|
|
}
|
|
}
|
|
} catch (err) {
|
|
_iterator4.e(err);
|
|
} finally {
|
|
_iterator4.f();
|
|
}
|
|
throw new TypeError("Signature not found (signature: " + (fn.name || "unnamed") + "(" + stringifyParams(params, ", ") + "))");
|
|
}
|
|
function find(fn, signature, options) {
|
|
return findSignature(fn, signature, options).implementation;
|
|
}
|
|
function convert(value, typeName) {
|
|
var type = findType(typeName);
|
|
if (type.test(value)) {
|
|
return value;
|
|
}
|
|
var conversions = type.conversionsTo;
|
|
if (conversions.length === 0) {
|
|
throw new Error("There are no conversions to " + typeName + " defined.");
|
|
}
|
|
for (var i2 = 0; i2 < conversions.length; i2++) {
|
|
var fromType = findType(conversions[i2].from);
|
|
if (fromType.test(value)) {
|
|
return conversions[i2].convert(value);
|
|
}
|
|
}
|
|
throw new Error("Cannot convert " + value + " to " + typeName);
|
|
}
|
|
function stringifyParams(params) {
|
|
var separator = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ",";
|
|
return params.map(function(p) {
|
|
return p.name;
|
|
}).join(separator);
|
|
}
|
|
function parseParam(param) {
|
|
var restParam = param.indexOf("...") === 0;
|
|
var types = !restParam ? param : param.length > 3 ? param.slice(3) : "any";
|
|
var typeDefs = types.split("|").map(function(s) {
|
|
return findType(s.trim());
|
|
});
|
|
var hasAny = false;
|
|
var paramName = restParam ? "..." : "";
|
|
var exactTypes = typeDefs.map(function(type) {
|
|
hasAny = type.isAny || hasAny;
|
|
paramName += type.name + "|";
|
|
return {
|
|
name: type.name,
|
|
typeIndex: type.index,
|
|
test: type.test,
|
|
isAny: type.isAny,
|
|
conversion: null,
|
|
conversionIndex: -1
|
|
};
|
|
});
|
|
return {
|
|
types: exactTypes,
|
|
name: paramName.slice(0, -1),
|
|
hasAny,
|
|
hasConversion: false,
|
|
restParam
|
|
};
|
|
}
|
|
function expandParam(param) {
|
|
var typeNames = param.types.map(function(t) {
|
|
return t.name;
|
|
});
|
|
var matchingConversions = availableConversions(typeNames);
|
|
var hasAny = param.hasAny;
|
|
var newName = param.name;
|
|
var convertibleTypes = matchingConversions.map(function(conversion) {
|
|
var type = findType(conversion.from);
|
|
hasAny = type.isAny || hasAny;
|
|
newName += "|" + conversion.from;
|
|
return {
|
|
name: conversion.from,
|
|
typeIndex: type.index,
|
|
test: type.test,
|
|
isAny: type.isAny,
|
|
conversion,
|
|
conversionIndex: conversion.index
|
|
};
|
|
});
|
|
return {
|
|
types: param.types.concat(convertibleTypes),
|
|
name: newName,
|
|
hasAny,
|
|
hasConversion: convertibleTypes.length > 0,
|
|
restParam: param.restParam
|
|
};
|
|
}
|
|
function paramTypeSet(param) {
|
|
if (!param.typeSet) {
|
|
param.typeSet = /* @__PURE__ */ new Set();
|
|
param.types.forEach(function(type) {
|
|
return param.typeSet.add(type.name);
|
|
});
|
|
}
|
|
return param.typeSet;
|
|
}
|
|
function parseSignature(rawSignature) {
|
|
var params = [];
|
|
if (typeof rawSignature !== "string") {
|
|
throw new TypeError("Signatures must be strings");
|
|
}
|
|
var signature = rawSignature.trim();
|
|
if (signature === "") {
|
|
return params;
|
|
}
|
|
var rawParams = signature.split(",");
|
|
for (var i2 = 0; i2 < rawParams.length; ++i2) {
|
|
var parsedParam = parseParam(rawParams[i2].trim());
|
|
if (parsedParam.restParam && i2 !== rawParams.length - 1) {
|
|
throw new SyntaxError('Unexpected rest parameter "' + rawParams[i2] + '": only allowed for the last parameter');
|
|
}
|
|
if (parsedParam.types.length === 0) {
|
|
return null;
|
|
}
|
|
params.push(parsedParam);
|
|
}
|
|
return params;
|
|
}
|
|
function hasRestParam(params) {
|
|
var param = last(params);
|
|
return param ? param.restParam : false;
|
|
}
|
|
function compileTest(param) {
|
|
if (!param || param.types.length === 0) {
|
|
return ok;
|
|
} else if (param.types.length === 1) {
|
|
return findType(param.types[0].name).test;
|
|
} else if (param.types.length === 2) {
|
|
var test0 = findType(param.types[0].name).test;
|
|
var test1 = findType(param.types[1].name).test;
|
|
return function or2(x) {
|
|
return test0(x) || test1(x);
|
|
};
|
|
} else {
|
|
var tests = param.types.map(function(type) {
|
|
return findType(type.name).test;
|
|
});
|
|
return function or2(x) {
|
|
for (var i2 = 0; i2 < tests.length; i2++) {
|
|
if (tests[i2](x)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
}
|
|
}
|
|
function compileTests(params) {
|
|
var tests, test0, test1;
|
|
if (hasRestParam(params)) {
|
|
tests = initial(params).map(compileTest);
|
|
var varIndex = tests.length;
|
|
var lastTest = compileTest(last(params));
|
|
var testRestParam = function testRestParam2(args) {
|
|
for (var i2 = varIndex; i2 < args.length; i2++) {
|
|
if (!lastTest(args[i2])) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
return function testArgs(args) {
|
|
for (var i2 = 0; i2 < tests.length; i2++) {
|
|
if (!tests[i2](args[i2])) {
|
|
return false;
|
|
}
|
|
}
|
|
return testRestParam(args) && args.length >= varIndex + 1;
|
|
};
|
|
} else {
|
|
if (params.length === 0) {
|
|
return function testArgs(args) {
|
|
return args.length === 0;
|
|
};
|
|
} else if (params.length === 1) {
|
|
test0 = compileTest(params[0]);
|
|
return function testArgs(args) {
|
|
return test0(args[0]) && args.length === 1;
|
|
};
|
|
} else if (params.length === 2) {
|
|
test0 = compileTest(params[0]);
|
|
test1 = compileTest(params[1]);
|
|
return function testArgs(args) {
|
|
return test0(args[0]) && test1(args[1]) && args.length === 2;
|
|
};
|
|
} else {
|
|
tests = params.map(compileTest);
|
|
return function testArgs(args) {
|
|
for (var i2 = 0; i2 < tests.length; i2++) {
|
|
if (!tests[i2](args[i2])) {
|
|
return false;
|
|
}
|
|
}
|
|
return args.length === tests.length;
|
|
};
|
|
}
|
|
}
|
|
}
|
|
function getParamAtIndex(params, index2) {
|
|
return index2 < params.length ? params[index2] : hasRestParam(params) ? last(params) : null;
|
|
}
|
|
function getTypeSetAtIndex(params, index2) {
|
|
var param = getParamAtIndex(params, index2);
|
|
if (!param) {
|
|
return /* @__PURE__ */ new Set();
|
|
}
|
|
return paramTypeSet(param);
|
|
}
|
|
function isExactType(type) {
|
|
return type.conversion === null || type.conversion === void 0;
|
|
}
|
|
function mergeExpectedParams(signatures, index2) {
|
|
var typeSet = /* @__PURE__ */ new Set();
|
|
signatures.forEach(function(signature) {
|
|
var paramSet = getTypeSetAtIndex(signature.params, index2);
|
|
var name302;
|
|
var _iterator5 = _createForOfIteratorHelper(paramSet), _step5;
|
|
try {
|
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done; ) {
|
|
name302 = _step5.value;
|
|
typeSet.add(name302);
|
|
}
|
|
} catch (err) {
|
|
_iterator5.e(err);
|
|
} finally {
|
|
_iterator5.f();
|
|
}
|
|
});
|
|
return typeSet.has("any") ? ["any"] : Array.from(typeSet);
|
|
}
|
|
function createError(name302, args, signatures) {
|
|
var err, expected;
|
|
var _name = name302 || "unnamed";
|
|
var matchingSignatures = signatures;
|
|
var index2;
|
|
var _loop = function _loop2() {
|
|
var nextMatchingDefs = [];
|
|
matchingSignatures.forEach(function(signature) {
|
|
var param = getParamAtIndex(signature.params, index2);
|
|
var test = compileTest(param);
|
|
if ((index2 < signature.params.length || hasRestParam(signature.params)) && test(args[index2])) {
|
|
nextMatchingDefs.push(signature);
|
|
}
|
|
});
|
|
if (nextMatchingDefs.length === 0) {
|
|
expected = mergeExpectedParams(matchingSignatures, index2);
|
|
if (expected.length > 0) {
|
|
var actualTypes = findTypeNames(args[index2]);
|
|
err = new TypeError("Unexpected type of argument in function " + _name + " (expected: " + expected.join(" or ") + ", actual: " + actualTypes.join(" | ") + ", index: " + index2 + ")");
|
|
err.data = {
|
|
category: "wrongType",
|
|
fn: _name,
|
|
index: index2,
|
|
actual: actualTypes,
|
|
expected
|
|
};
|
|
return {
|
|
v: err
|
|
};
|
|
}
|
|
} else {
|
|
matchingSignatures = nextMatchingDefs;
|
|
}
|
|
};
|
|
for (index2 = 0; index2 < args.length; index2++) {
|
|
var _ret2 = _loop();
|
|
if (_typeof2(_ret2) === "object")
|
|
return _ret2.v;
|
|
}
|
|
var lengths = matchingSignatures.map(function(signature) {
|
|
return hasRestParam(signature.params) ? Infinity : signature.params.length;
|
|
});
|
|
if (args.length < Math.min.apply(null, lengths)) {
|
|
expected = mergeExpectedParams(matchingSignatures, index2);
|
|
err = new TypeError("Too few arguments in function " + _name + " (expected: " + expected.join(" or ") + ", index: " + args.length + ")");
|
|
err.data = {
|
|
category: "tooFewArgs",
|
|
fn: _name,
|
|
index: args.length,
|
|
expected
|
|
};
|
|
return err;
|
|
}
|
|
var maxLength = Math.max.apply(null, lengths);
|
|
if (args.length > maxLength) {
|
|
err = new TypeError("Too many arguments in function " + _name + " (expected: " + maxLength + ", actual: " + args.length + ")");
|
|
err.data = {
|
|
category: "tooManyArgs",
|
|
fn: _name,
|
|
index: args.length,
|
|
expectedLength: maxLength
|
|
};
|
|
return err;
|
|
}
|
|
var argTypes = [];
|
|
for (var i2 = 0; i2 < args.length; ++i2) {
|
|
argTypes.push(findTypeNames(args[i2]).join("|"));
|
|
}
|
|
err = new TypeError('Arguments of type "' + argTypes.join(", ") + '" do not match any of the defined signatures of function ' + _name + ".");
|
|
err.data = {
|
|
category: "mismatch",
|
|
actual: argTypes
|
|
};
|
|
return err;
|
|
}
|
|
function getLowestTypeIndex(param) {
|
|
var min3 = typeList.length + 1;
|
|
for (var i2 = 0; i2 < param.types.length; i2++) {
|
|
if (isExactType(param.types[i2])) {
|
|
min3 = Math.min(min3, param.types[i2].typeIndex);
|
|
}
|
|
}
|
|
return min3;
|
|
}
|
|
function getLowestConversionIndex(param) {
|
|
var min3 = nConversions + 1;
|
|
for (var i2 = 0; i2 < param.types.length; i2++) {
|
|
if (!isExactType(param.types[i2])) {
|
|
min3 = Math.min(min3, param.types[i2].conversionIndex);
|
|
}
|
|
}
|
|
return min3;
|
|
}
|
|
function compareParams(param1, param2) {
|
|
if (param1.hasAny) {
|
|
if (!param2.hasAny) {
|
|
return 1;
|
|
}
|
|
} else if (param2.hasAny) {
|
|
return -1;
|
|
}
|
|
if (param1.restParam) {
|
|
if (!param2.restParam) {
|
|
return 1;
|
|
}
|
|
} else if (param2.restParam) {
|
|
return -1;
|
|
}
|
|
if (param1.hasConversion) {
|
|
if (!param2.hasConversion) {
|
|
return 1;
|
|
}
|
|
} else if (param2.hasConversion) {
|
|
return -1;
|
|
}
|
|
var typeDiff = getLowestTypeIndex(param1) - getLowestTypeIndex(param2);
|
|
if (typeDiff < 0) {
|
|
return -1;
|
|
}
|
|
if (typeDiff > 0) {
|
|
return 1;
|
|
}
|
|
var convDiff = getLowestConversionIndex(param1) - getLowestConversionIndex(param2);
|
|
if (convDiff < 0) {
|
|
return -1;
|
|
}
|
|
if (convDiff > 0) {
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
function compareSignatures(signature1, signature2) {
|
|
var pars1 = signature1.params;
|
|
var pars2 = signature2.params;
|
|
var last1 = last(pars1);
|
|
var last2 = last(pars2);
|
|
var hasRest1 = hasRestParam(pars1);
|
|
var hasRest2 = hasRestParam(pars2);
|
|
if (hasRest1 && last1.hasAny) {
|
|
if (!hasRest2 || !last2.hasAny) {
|
|
return 1;
|
|
}
|
|
} else if (hasRest2 && last2.hasAny) {
|
|
return -1;
|
|
}
|
|
var any1 = 0;
|
|
var conv1 = 0;
|
|
var par;
|
|
var _iterator6 = _createForOfIteratorHelper(pars1), _step6;
|
|
try {
|
|
for (_iterator6.s(); !(_step6 = _iterator6.n()).done; ) {
|
|
par = _step6.value;
|
|
if (par.hasAny)
|
|
++any1;
|
|
if (par.hasConversion)
|
|
++conv1;
|
|
}
|
|
} catch (err) {
|
|
_iterator6.e(err);
|
|
} finally {
|
|
_iterator6.f();
|
|
}
|
|
var any2 = 0;
|
|
var conv2 = 0;
|
|
var _iterator7 = _createForOfIteratorHelper(pars2), _step7;
|
|
try {
|
|
for (_iterator7.s(); !(_step7 = _iterator7.n()).done; ) {
|
|
par = _step7.value;
|
|
if (par.hasAny)
|
|
++any2;
|
|
if (par.hasConversion)
|
|
++conv2;
|
|
}
|
|
} catch (err) {
|
|
_iterator7.e(err);
|
|
} finally {
|
|
_iterator7.f();
|
|
}
|
|
if (any1 !== any2) {
|
|
return any1 - any2;
|
|
}
|
|
if (hasRest1 && last1.hasConversion) {
|
|
if (!hasRest2 || !last2.hasConversion) {
|
|
return 1;
|
|
}
|
|
} else if (hasRest2 && last2.hasConversion) {
|
|
return -1;
|
|
}
|
|
if (conv1 !== conv2) {
|
|
return conv1 - conv2;
|
|
}
|
|
if (hasRest1) {
|
|
if (!hasRest2) {
|
|
return 1;
|
|
}
|
|
} else if (hasRest2) {
|
|
return -1;
|
|
}
|
|
var lengthCriterion = (pars1.length - pars2.length) * (hasRest1 ? -1 : 1);
|
|
if (lengthCriterion !== 0) {
|
|
return lengthCriterion;
|
|
}
|
|
var comparisons = [];
|
|
var tc = 0;
|
|
for (var i2 = 0; i2 < pars1.length; ++i2) {
|
|
var thisComparison = compareParams(pars1[i2], pars2[i2]);
|
|
comparisons.push(thisComparison);
|
|
tc += thisComparison;
|
|
}
|
|
if (tc !== 0) {
|
|
return tc;
|
|
}
|
|
var c;
|
|
for (var _i2 = 0, _comparisons = comparisons; _i2 < _comparisons.length; _i2++) {
|
|
c = _comparisons[_i2];
|
|
if (c !== 0) {
|
|
return c;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
function availableConversions(typeNames) {
|
|
if (typeNames.length === 0) {
|
|
return [];
|
|
}
|
|
var types = typeNames.map(findType);
|
|
if (typeNames.length > 1) {
|
|
types.sort(function(t1, t2) {
|
|
return t1.index - t2.index;
|
|
});
|
|
}
|
|
var matches = types[0].conversionsTo;
|
|
if (typeNames.length === 1) {
|
|
return matches;
|
|
}
|
|
matches = matches.concat([]);
|
|
var knownTypes = new Set(typeNames);
|
|
for (var i2 = 1; i2 < types.length; ++i2) {
|
|
var newMatch = void 0;
|
|
var _iterator8 = _createForOfIteratorHelper(types[i2].conversionsTo), _step8;
|
|
try {
|
|
for (_iterator8.s(); !(_step8 = _iterator8.n()).done; ) {
|
|
newMatch = _step8.value;
|
|
if (!knownTypes.has(newMatch.from)) {
|
|
matches.push(newMatch);
|
|
knownTypes.add(newMatch.from);
|
|
}
|
|
}
|
|
} catch (err) {
|
|
_iterator8.e(err);
|
|
} finally {
|
|
_iterator8.f();
|
|
}
|
|
}
|
|
return matches;
|
|
}
|
|
function compileArgsPreprocessing(params, fn) {
|
|
var fnConvert = fn;
|
|
if (params.some(function(p) {
|
|
return p.hasConversion;
|
|
})) {
|
|
var restParam = hasRestParam(params);
|
|
var compiledConversions = params.map(compileArgConversion);
|
|
fnConvert = function convertArgs() {
|
|
var args = [];
|
|
var last2 = restParam ? arguments.length - 1 : arguments.length;
|
|
for (var i2 = 0; i2 < last2; i2++) {
|
|
args[i2] = compiledConversions[i2](arguments[i2]);
|
|
}
|
|
if (restParam) {
|
|
args[last2] = arguments[last2].map(compiledConversions[last2]);
|
|
}
|
|
return fn.apply(this, args);
|
|
};
|
|
}
|
|
var fnPreprocess = fnConvert;
|
|
if (hasRestParam(params)) {
|
|
var offset = params.length - 1;
|
|
fnPreprocess = function preprocessRestParams() {
|
|
return fnConvert.apply(this, slice(arguments, 0, offset).concat([slice(arguments, offset)]));
|
|
};
|
|
}
|
|
return fnPreprocess;
|
|
}
|
|
function compileArgConversion(param) {
|
|
var test0, test1, conversion0, conversion1;
|
|
var tests = [];
|
|
var conversions = [];
|
|
param.types.forEach(function(type) {
|
|
if (type.conversion) {
|
|
tests.push(findType(type.conversion.from).test);
|
|
conversions.push(type.conversion.convert);
|
|
}
|
|
});
|
|
switch (conversions.length) {
|
|
case 0:
|
|
return function convertArg(arg2) {
|
|
return arg2;
|
|
};
|
|
case 1:
|
|
test0 = tests[0];
|
|
conversion0 = conversions[0];
|
|
return function convertArg(arg2) {
|
|
if (test0(arg2)) {
|
|
return conversion0(arg2);
|
|
}
|
|
return arg2;
|
|
};
|
|
case 2:
|
|
test0 = tests[0];
|
|
test1 = tests[1];
|
|
conversion0 = conversions[0];
|
|
conversion1 = conversions[1];
|
|
return function convertArg(arg2) {
|
|
if (test0(arg2)) {
|
|
return conversion0(arg2);
|
|
}
|
|
if (test1(arg2)) {
|
|
return conversion1(arg2);
|
|
}
|
|
return arg2;
|
|
};
|
|
default:
|
|
return function convertArg(arg2) {
|
|
for (var i2 = 0; i2 < conversions.length; i2++) {
|
|
if (tests[i2](arg2)) {
|
|
return conversions[i2](arg2);
|
|
}
|
|
}
|
|
return arg2;
|
|
};
|
|
}
|
|
}
|
|
function splitParams(params) {
|
|
function _splitParams(params2, index2, paramsSoFar) {
|
|
if (index2 < params2.length) {
|
|
var param = params2[index2];
|
|
var resultingParams = [];
|
|
if (param.restParam) {
|
|
var exactTypes = param.types.filter(isExactType);
|
|
if (exactTypes.length < param.types.length) {
|
|
resultingParams.push({
|
|
types: exactTypes,
|
|
name: "..." + exactTypes.map(function(t) {
|
|
return t.name;
|
|
}).join("|"),
|
|
hasAny: exactTypes.some(function(t) {
|
|
return t.isAny;
|
|
}),
|
|
hasConversion: false,
|
|
restParam: true
|
|
});
|
|
}
|
|
resultingParams.push(param);
|
|
} else {
|
|
resultingParams = param.types.map(function(type) {
|
|
return {
|
|
types: [type],
|
|
name: type.name,
|
|
hasAny: type.isAny,
|
|
hasConversion: type.conversion,
|
|
restParam: false
|
|
};
|
|
});
|
|
}
|
|
return flatMap(resultingParams, function(nextParam) {
|
|
return _splitParams(params2, index2 + 1, paramsSoFar.concat([nextParam]));
|
|
});
|
|
} else {
|
|
return [paramsSoFar];
|
|
}
|
|
}
|
|
return _splitParams(params, 0, []);
|
|
}
|
|
function conflicting(params1, params2) {
|
|
var ii = Math.max(params1.length, params2.length);
|
|
for (var i2 = 0; i2 < ii; i2++) {
|
|
var typeSet1 = getTypeSetAtIndex(params1, i2);
|
|
var typeSet2 = getTypeSetAtIndex(params2, i2);
|
|
var overlap = false;
|
|
var name302 = void 0;
|
|
var _iterator9 = _createForOfIteratorHelper(typeSet2), _step9;
|
|
try {
|
|
for (_iterator9.s(); !(_step9 = _iterator9.n()).done; ) {
|
|
name302 = _step9.value;
|
|
if (typeSet1.has(name302)) {
|
|
overlap = true;
|
|
break;
|
|
}
|
|
}
|
|
} catch (err) {
|
|
_iterator9.e(err);
|
|
} finally {
|
|
_iterator9.f();
|
|
}
|
|
if (!overlap) {
|
|
return false;
|
|
}
|
|
}
|
|
var len1 = params1.length;
|
|
var len2 = params2.length;
|
|
var restParam1 = hasRestParam(params1);
|
|
var restParam2 = hasRestParam(params2);
|
|
return restParam1 ? restParam2 ? len1 === len2 : len2 >= len1 : restParam2 ? len1 >= len2 : len1 === len2;
|
|
}
|
|
function clearResolutions(functionList) {
|
|
return functionList.map(function(fn) {
|
|
if (isReferToSelf(fn)) {
|
|
return referToSelf(fn.referToSelf.callback);
|
|
}
|
|
if (isReferTo(fn)) {
|
|
return makeReferTo(fn.referTo.references, fn.referTo.callback);
|
|
}
|
|
return fn;
|
|
});
|
|
}
|
|
function collectResolutions(references, functionList, signatureMap) {
|
|
var resolvedReferences = [];
|
|
var reference;
|
|
var _iterator10 = _createForOfIteratorHelper(references), _step10;
|
|
try {
|
|
for (_iterator10.s(); !(_step10 = _iterator10.n()).done; ) {
|
|
reference = _step10.value;
|
|
var resolution = signatureMap[reference];
|
|
if (typeof resolution !== "number") {
|
|
throw new TypeError('No definition for referenced signature "' + reference + '"');
|
|
}
|
|
resolution = functionList[resolution];
|
|
if (typeof resolution !== "function") {
|
|
return false;
|
|
}
|
|
resolvedReferences.push(resolution);
|
|
}
|
|
} catch (err) {
|
|
_iterator10.e(err);
|
|
} finally {
|
|
_iterator10.f();
|
|
}
|
|
return resolvedReferences;
|
|
}
|
|
function resolveReferences(functionList, signatureMap, self2) {
|
|
var resolvedFunctions = clearResolutions(functionList);
|
|
var isResolved = new Array(resolvedFunctions.length).fill(false);
|
|
var leftUnresolved = true;
|
|
while (leftUnresolved) {
|
|
leftUnresolved = false;
|
|
var nothingResolved = true;
|
|
for (var i2 = 0; i2 < resolvedFunctions.length; ++i2) {
|
|
if (isResolved[i2])
|
|
continue;
|
|
var fn = resolvedFunctions[i2];
|
|
if (isReferToSelf(fn)) {
|
|
resolvedFunctions[i2] = fn.referToSelf.callback(self2);
|
|
resolvedFunctions[i2].referToSelf = fn.referToSelf;
|
|
isResolved[i2] = true;
|
|
nothingResolved = false;
|
|
} else if (isReferTo(fn)) {
|
|
var resolvedReferences = collectResolutions(fn.referTo.references, resolvedFunctions, signatureMap);
|
|
if (resolvedReferences) {
|
|
resolvedFunctions[i2] = fn.referTo.callback.apply(this, resolvedReferences);
|
|
resolvedFunctions[i2].referTo = fn.referTo;
|
|
isResolved[i2] = true;
|
|
nothingResolved = false;
|
|
} else {
|
|
leftUnresolved = true;
|
|
}
|
|
}
|
|
}
|
|
if (nothingResolved && leftUnresolved) {
|
|
throw new SyntaxError("Circular reference detected in resolving typed.referTo");
|
|
}
|
|
}
|
|
return resolvedFunctions;
|
|
}
|
|
function validateDeprecatedThis(signaturesMap) {
|
|
var deprecatedThisRegex = /\bthis(\(|\.signatures\b)/;
|
|
Object.keys(signaturesMap).forEach(function(signature) {
|
|
var fn = signaturesMap[signature];
|
|
if (deprecatedThisRegex.test(fn.toString())) {
|
|
throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.");
|
|
}
|
|
});
|
|
}
|
|
function createTypedFunction(name302, rawSignaturesMap) {
|
|
typed2.createCount++;
|
|
if (Object.keys(rawSignaturesMap).length === 0) {
|
|
throw new SyntaxError("No signatures provided");
|
|
}
|
|
if (typed2.warnAgainstDeprecatedThis) {
|
|
validateDeprecatedThis(rawSignaturesMap);
|
|
}
|
|
var parsedParams = [];
|
|
var originalFunctions = [];
|
|
var signaturesMap = {};
|
|
var preliminarySignatures = [];
|
|
var signature;
|
|
var _loop2 = function _loop22() {
|
|
if (!Object.prototype.hasOwnProperty.call(rawSignaturesMap, signature)) {
|
|
return "continue";
|
|
}
|
|
var params = parseSignature(signature);
|
|
if (!params)
|
|
return "continue";
|
|
parsedParams.forEach(function(pp) {
|
|
if (conflicting(pp, params)) {
|
|
throw new TypeError('Conflicting signatures "' + stringifyParams(pp) + '" and "' + stringifyParams(params) + '".');
|
|
}
|
|
});
|
|
parsedParams.push(params);
|
|
var functionIndex = originalFunctions.length;
|
|
originalFunctions.push(rawSignaturesMap[signature]);
|
|
var conversionParams = params.map(expandParam);
|
|
var sp = void 0;
|
|
var _iterator11 = _createForOfIteratorHelper(splitParams(conversionParams)), _step11;
|
|
try {
|
|
for (_iterator11.s(); !(_step11 = _iterator11.n()).done; ) {
|
|
sp = _step11.value;
|
|
var spName = stringifyParams(sp);
|
|
preliminarySignatures.push({
|
|
params: sp,
|
|
name: spName,
|
|
fn: functionIndex
|
|
});
|
|
if (sp.every(function(p) {
|
|
return !p.hasConversion;
|
|
})) {
|
|
signaturesMap[spName] = functionIndex;
|
|
}
|
|
}
|
|
} catch (err) {
|
|
_iterator11.e(err);
|
|
} finally {
|
|
_iterator11.f();
|
|
}
|
|
};
|
|
for (signature in rawSignaturesMap) {
|
|
var _ret3 = _loop2();
|
|
if (_ret3 === "continue")
|
|
continue;
|
|
}
|
|
preliminarySignatures.sort(compareSignatures);
|
|
var resolvedFunctions = resolveReferences(originalFunctions, signaturesMap, theTypedFn);
|
|
var s;
|
|
for (s in signaturesMap) {
|
|
if (Object.prototype.hasOwnProperty.call(signaturesMap, s)) {
|
|
signaturesMap[s] = resolvedFunctions[signaturesMap[s]];
|
|
}
|
|
}
|
|
var signatures = [];
|
|
var internalSignatureMap = /* @__PURE__ */ new Map();
|
|
for (var _i3 = 0, _preliminarySignature = preliminarySignatures; _i3 < _preliminarySignature.length; _i3++) {
|
|
s = _preliminarySignature[_i3];
|
|
if (!internalSignatureMap.has(s.name)) {
|
|
s.fn = resolvedFunctions[s.fn];
|
|
signatures.push(s);
|
|
internalSignatureMap.set(s.name, s);
|
|
}
|
|
}
|
|
var ok0 = signatures[0] && signatures[0].params.length <= 2 && !hasRestParam(signatures[0].params);
|
|
var ok1 = signatures[1] && signatures[1].params.length <= 2 && !hasRestParam(signatures[1].params);
|
|
var ok2 = signatures[2] && signatures[2].params.length <= 2 && !hasRestParam(signatures[2].params);
|
|
var ok3 = signatures[3] && signatures[3].params.length <= 2 && !hasRestParam(signatures[3].params);
|
|
var ok4 = signatures[4] && signatures[4].params.length <= 2 && !hasRestParam(signatures[4].params);
|
|
var ok5 = signatures[5] && signatures[5].params.length <= 2 && !hasRestParam(signatures[5].params);
|
|
var allOk = ok0 && ok1 && ok2 && ok3 && ok4 && ok5;
|
|
for (var i2 = 0; i2 < signatures.length; ++i2) {
|
|
signatures[i2].test = compileTests(signatures[i2].params);
|
|
}
|
|
var test00 = ok0 ? compileTest(signatures[0].params[0]) : notOk;
|
|
var test10 = ok1 ? compileTest(signatures[1].params[0]) : notOk;
|
|
var test20 = ok2 ? compileTest(signatures[2].params[0]) : notOk;
|
|
var test30 = ok3 ? compileTest(signatures[3].params[0]) : notOk;
|
|
var test40 = ok4 ? compileTest(signatures[4].params[0]) : notOk;
|
|
var test50 = ok5 ? compileTest(signatures[5].params[0]) : notOk;
|
|
var test01 = ok0 ? compileTest(signatures[0].params[1]) : notOk;
|
|
var test11 = ok1 ? compileTest(signatures[1].params[1]) : notOk;
|
|
var test21 = ok2 ? compileTest(signatures[2].params[1]) : notOk;
|
|
var test31 = ok3 ? compileTest(signatures[3].params[1]) : notOk;
|
|
var test41 = ok4 ? compileTest(signatures[4].params[1]) : notOk;
|
|
var test51 = ok5 ? compileTest(signatures[5].params[1]) : notOk;
|
|
for (var _i4 = 0; _i4 < signatures.length; ++_i4) {
|
|
signatures[_i4].implementation = compileArgsPreprocessing(signatures[_i4].params, signatures[_i4].fn);
|
|
}
|
|
var fn0 = ok0 ? signatures[0].implementation : undef;
|
|
var fn1 = ok1 ? signatures[1].implementation : undef;
|
|
var fn2 = ok2 ? signatures[2].implementation : undef;
|
|
var fn3 = ok3 ? signatures[3].implementation : undef;
|
|
var fn4 = ok4 ? signatures[4].implementation : undef;
|
|
var fn5 = ok5 ? signatures[5].implementation : undef;
|
|
var len0 = ok0 ? signatures[0].params.length : -1;
|
|
var len1 = ok1 ? signatures[1].params.length : -1;
|
|
var len2 = ok2 ? signatures[2].params.length : -1;
|
|
var len3 = ok3 ? signatures[3].params.length : -1;
|
|
var len4 = ok4 ? signatures[4].params.length : -1;
|
|
var len5 = ok5 ? signatures[5].params.length : -1;
|
|
var iStart = allOk ? 6 : 0;
|
|
var iEnd = signatures.length;
|
|
var tests = signatures.map(function(s2) {
|
|
return s2.test;
|
|
});
|
|
var fns = signatures.map(function(s2) {
|
|
return s2.implementation;
|
|
});
|
|
var generic = function generic2() {
|
|
for (var _i5 = iStart; _i5 < iEnd; _i5++) {
|
|
if (tests[_i5](arguments)) {
|
|
return fns[_i5].apply(this, arguments);
|
|
}
|
|
}
|
|
return typed2.onMismatch(name302, arguments, signatures);
|
|
};
|
|
function theTypedFn(arg0, arg1) {
|
|
if (arguments.length === len0 && test00(arg0) && test01(arg1)) {
|
|
return fn0.apply(this, arguments);
|
|
}
|
|
if (arguments.length === len1 && test10(arg0) && test11(arg1)) {
|
|
return fn1.apply(this, arguments);
|
|
}
|
|
if (arguments.length === len2 && test20(arg0) && test21(arg1)) {
|
|
return fn2.apply(this, arguments);
|
|
}
|
|
if (arguments.length === len3 && test30(arg0) && test31(arg1)) {
|
|
return fn3.apply(this, arguments);
|
|
}
|
|
if (arguments.length === len4 && test40(arg0) && test41(arg1)) {
|
|
return fn4.apply(this, arguments);
|
|
}
|
|
if (arguments.length === len5 && test50(arg0) && test51(arg1)) {
|
|
return fn5.apply(this, arguments);
|
|
}
|
|
return generic.apply(this, arguments);
|
|
}
|
|
try {
|
|
Object.defineProperty(theTypedFn, "name", {
|
|
value: name302
|
|
});
|
|
} catch (err) {
|
|
}
|
|
theTypedFn.signatures = signaturesMap;
|
|
theTypedFn._typedFunctionData = {
|
|
signatures,
|
|
signatureMap: internalSignatureMap
|
|
};
|
|
return theTypedFn;
|
|
}
|
|
function _onMismatch(name302, args, signatures) {
|
|
throw createError(name302, args, signatures);
|
|
}
|
|
function initial(arr) {
|
|
return slice(arr, 0, arr.length - 1);
|
|
}
|
|
function last(arr) {
|
|
return arr[arr.length - 1];
|
|
}
|
|
function slice(arr, start, end) {
|
|
return Array.prototype.slice.call(arr, start, end);
|
|
}
|
|
function findInArray(arr, test) {
|
|
for (var i2 = 0; i2 < arr.length; i2++) {
|
|
if (test(arr[i2])) {
|
|
return arr[i2];
|
|
}
|
|
}
|
|
return void 0;
|
|
}
|
|
function flatMap(arr, callback) {
|
|
return Array.prototype.concat.apply([], arr.map(callback));
|
|
}
|
|
function referTo() {
|
|
var references = initial(arguments).map(function(s) {
|
|
return stringifyParams(parseSignature(s));
|
|
});
|
|
var callback = last(arguments);
|
|
if (typeof callback !== "function") {
|
|
throw new TypeError("Callback function expected as last argument");
|
|
}
|
|
return makeReferTo(references, callback);
|
|
}
|
|
function makeReferTo(references, callback) {
|
|
return {
|
|
referTo: {
|
|
references,
|
|
callback
|
|
}
|
|
};
|
|
}
|
|
function referToSelf(callback) {
|
|
if (typeof callback !== "function") {
|
|
throw new TypeError("Callback function expected as first argument");
|
|
}
|
|
return {
|
|
referToSelf: {
|
|
callback
|
|
}
|
|
};
|
|
}
|
|
function isReferTo(objectOrFn) {
|
|
return objectOrFn && _typeof2(objectOrFn.referTo) === "object" && Array.isArray(objectOrFn.referTo.references) && typeof objectOrFn.referTo.callback === "function";
|
|
}
|
|
function isReferToSelf(objectOrFn) {
|
|
return objectOrFn && _typeof2(objectOrFn.referToSelf) === "object" && typeof objectOrFn.referToSelf.callback === "function";
|
|
}
|
|
function checkName(nameSoFar, newName) {
|
|
if (!nameSoFar) {
|
|
return newName;
|
|
}
|
|
if (newName && newName !== nameSoFar) {
|
|
var err = new Error("Function names do not match (expected: " + nameSoFar + ", actual: " + newName + ")");
|
|
err.data = {
|
|
actual: newName,
|
|
expected: nameSoFar
|
|
};
|
|
throw err;
|
|
}
|
|
return nameSoFar;
|
|
}
|
|
function getObjectName(obj) {
|
|
var name302;
|
|
for (var key in obj) {
|
|
if (Object.prototype.hasOwnProperty.call(obj, key) && (isTypedFunction(obj[key]) || typeof obj[key].signature === "string")) {
|
|
name302 = checkName(name302, obj[key].name);
|
|
}
|
|
}
|
|
return name302;
|
|
}
|
|
function mergeSignatures(dest, source) {
|
|
var key;
|
|
for (key in source) {
|
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
if (key in dest) {
|
|
if (source[key] !== dest[key]) {
|
|
var err = new Error('Signature "' + key + '" is defined twice');
|
|
err.data = {
|
|
signature: key,
|
|
sourceFunction: source[key],
|
|
destFunction: dest[key]
|
|
};
|
|
throw err;
|
|
}
|
|
}
|
|
dest[key] = source[key];
|
|
}
|
|
}
|
|
}
|
|
var saveTyped = typed2;
|
|
typed2 = function typed3(maybeName) {
|
|
var named = typeof maybeName === "string";
|
|
var start = named ? 1 : 0;
|
|
var name302 = named ? maybeName : "";
|
|
var allSignatures = {};
|
|
for (var i2 = start; i2 < arguments.length; ++i2) {
|
|
var item = arguments[i2];
|
|
var theseSignatures = {};
|
|
var thisName = void 0;
|
|
if (typeof item === "function") {
|
|
thisName = item.name;
|
|
if (typeof item.signature === "string") {
|
|
theseSignatures[item.signature] = item;
|
|
} else if (isTypedFunction(item)) {
|
|
theseSignatures = item.signatures;
|
|
}
|
|
} else if (isPlainObject2(item)) {
|
|
theseSignatures = item;
|
|
if (!named) {
|
|
thisName = getObjectName(item);
|
|
}
|
|
}
|
|
if (Object.keys(theseSignatures).length === 0) {
|
|
var err = new TypeError("Argument to 'typed' at index " + i2 + " is not a (typed) function, nor an object with signatures as keys and functions as values.");
|
|
err.data = {
|
|
index: i2,
|
|
argument: item
|
|
};
|
|
throw err;
|
|
}
|
|
if (!named) {
|
|
name302 = checkName(name302, thisName);
|
|
}
|
|
mergeSignatures(allSignatures, theseSignatures);
|
|
}
|
|
return createTypedFunction(name302 || "", allSignatures);
|
|
};
|
|
typed2.create = create;
|
|
typed2.createCount = saveTyped.createCount;
|
|
typed2.onMismatch = _onMismatch;
|
|
typed2.throwMismatchError = _onMismatch;
|
|
typed2.createError = createError;
|
|
typed2.clear = clear;
|
|
typed2.clearConversions = clearConversions;
|
|
typed2.addTypes = addTypes;
|
|
typed2._findType = findType;
|
|
typed2.referTo = referTo;
|
|
typed2.referToSelf = referToSelf;
|
|
typed2.convert = convert;
|
|
typed2.findSignature = findSignature;
|
|
typed2.find = find;
|
|
typed2.isTypedFunction = isTypedFunction;
|
|
typed2.warnAgainstDeprecatedThis = true;
|
|
typed2.addType = function(type, beforeObjectTest) {
|
|
var before = "any";
|
|
if (beforeObjectTest !== false && typeMap.has("Object")) {
|
|
before = "Object";
|
|
}
|
|
typed2.addTypes([type], before);
|
|
};
|
|
function _validateConversion(conversion) {
|
|
if (!conversion || typeof conversion.from !== "string" || typeof conversion.to !== "string" || typeof conversion.convert !== "function") {
|
|
throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");
|
|
}
|
|
if (conversion.to === conversion.from) {
|
|
throw new SyntaxError('Illegal to define conversion from "' + conversion.from + '" to itself.');
|
|
}
|
|
}
|
|
typed2.addConversion = function(conversion) {
|
|
_validateConversion(conversion);
|
|
var to2 = findType(conversion.to);
|
|
if (to2.conversionsTo.every(function(other) {
|
|
return other.from !== conversion.from;
|
|
})) {
|
|
to2.conversionsTo.push({
|
|
from: conversion.from,
|
|
convert: conversion.convert,
|
|
index: nConversions++
|
|
});
|
|
} else {
|
|
throw new Error('There is already a conversion from "' + conversion.from + '" to "' + to2.name + '"');
|
|
}
|
|
};
|
|
typed2.addConversions = function(conversions) {
|
|
conversions.forEach(typed2.addConversion);
|
|
};
|
|
typed2.removeConversion = function(conversion) {
|
|
_validateConversion(conversion);
|
|
var to2 = findType(conversion.to);
|
|
var existingConversion = findInArray(to2.conversionsTo, function(c) {
|
|
return c.from === conversion.from;
|
|
});
|
|
if (!existingConversion) {
|
|
throw new Error("Attempt to remove nonexistent conversion from " + conversion.from + " to " + conversion.to);
|
|
}
|
|
if (existingConversion.convert !== conversion.convert) {
|
|
throw new Error("Conversion to remove does not match existing conversion");
|
|
}
|
|
var index2 = to2.conversionsTo.indexOf(existingConversion);
|
|
to2.conversionsTo.splice(index2, 1);
|
|
};
|
|
typed2.resolve = function(tf, argList) {
|
|
if (!isTypedFunction(tf)) {
|
|
throw new TypeError(NOT_TYPED_FUNCTION);
|
|
}
|
|
var sigs = tf._typedFunctionData.signatures;
|
|
for (var i2 = 0; i2 < sigs.length; ++i2) {
|
|
if (sigs[i2].test(argList)) {
|
|
return sigs[i2];
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
return typed2;
|
|
}
|
|
var typedFunction2 = create();
|
|
return typedFunction2;
|
|
});
|
|
}
|
|
});
|
|
|
|
// node_modules/complex.js/complex.js
|
|
var require_complex = __commonJS({
|
|
"node_modules/complex.js/complex.js"(exports, module2) {
|
|
(function(root) {
|
|
"use strict";
|
|
var cosh4 = Math.cosh || function(x) {
|
|
return Math.abs(x) < 1e-9 ? 1 - x : (Math.exp(x) + Math.exp(-x)) * 0.5;
|
|
};
|
|
var sinh4 = Math.sinh || function(x) {
|
|
return Math.abs(x) < 1e-9 ? x : (Math.exp(x) - Math.exp(-x)) * 0.5;
|
|
};
|
|
var cosm1 = function(x) {
|
|
var b = Math.PI / 4;
|
|
if (-b > x || x > b) {
|
|
return Math.cos(x) - 1;
|
|
}
|
|
var xx = x * x;
|
|
return xx * (xx * (xx * (xx * (xx * (xx * (xx * (xx / 20922789888e3 - 1 / 87178291200) + 1 / 479001600) - 1 / 3628800) + 1 / 40320) - 1 / 720) + 1 / 24) - 1 / 2);
|
|
};
|
|
var hypot3 = function(x, y) {
|
|
var a = Math.abs(x);
|
|
var b = Math.abs(y);
|
|
if (a < 3e3 && b < 3e3) {
|
|
return Math.sqrt(a * a + b * b);
|
|
}
|
|
if (a < b) {
|
|
a = b;
|
|
b = x / y;
|
|
} else {
|
|
b = y / x;
|
|
}
|
|
return a * Math.sqrt(1 + b * b);
|
|
};
|
|
var parser_exit = function() {
|
|
throw SyntaxError("Invalid Param");
|
|
};
|
|
function logHypot(a, b) {
|
|
var _a = Math.abs(a);
|
|
var _b = Math.abs(b);
|
|
if (a === 0) {
|
|
return Math.log(_b);
|
|
}
|
|
if (b === 0) {
|
|
return Math.log(_a);
|
|
}
|
|
if (_a < 3e3 && _b < 3e3) {
|
|
return Math.log(a * a + b * b) * 0.5;
|
|
}
|
|
a = a / 2;
|
|
b = b / 2;
|
|
return 0.5 * Math.log(a * a + b * b) + Math.LN2;
|
|
}
|
|
var parse2 = function(a, b) {
|
|
var z = { "re": 0, "im": 0 };
|
|
if (a === void 0 || a === null) {
|
|
z["re"] = z["im"] = 0;
|
|
} else if (b !== void 0) {
|
|
z["re"] = a;
|
|
z["im"] = b;
|
|
} else
|
|
switch (typeof a) {
|
|
case "object":
|
|
if ("im" in a && "re" in a) {
|
|
z["re"] = a["re"];
|
|
z["im"] = a["im"];
|
|
} else if ("abs" in a && "arg" in a) {
|
|
if (!Number.isFinite(a["abs"]) && Number.isFinite(a["arg"])) {
|
|
return Complex3["INFINITY"];
|
|
}
|
|
z["re"] = a["abs"] * Math.cos(a["arg"]);
|
|
z["im"] = a["abs"] * Math.sin(a["arg"]);
|
|
} else if ("r" in a && "phi" in a) {
|
|
if (!Number.isFinite(a["r"]) && Number.isFinite(a["phi"])) {
|
|
return Complex3["INFINITY"];
|
|
}
|
|
z["re"] = a["r"] * Math.cos(a["phi"]);
|
|
z["im"] = a["r"] * Math.sin(a["phi"]);
|
|
} else if (a.length === 2) {
|
|
z["re"] = a[0];
|
|
z["im"] = a[1];
|
|
} else {
|
|
parser_exit();
|
|
}
|
|
break;
|
|
case "string":
|
|
z["im"] = z["re"] = 0;
|
|
var tokens = a.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g);
|
|
var plus = 1;
|
|
var minus = 0;
|
|
if (tokens === null) {
|
|
parser_exit();
|
|
}
|
|
for (var i2 = 0; i2 < tokens.length; i2++) {
|
|
var c = tokens[i2];
|
|
if (c === " " || c === " " || c === "\n") {
|
|
} else if (c === "+") {
|
|
plus++;
|
|
} else if (c === "-") {
|
|
minus++;
|
|
} else if (c === "i" || c === "I") {
|
|
if (plus + minus === 0) {
|
|
parser_exit();
|
|
}
|
|
if (tokens[i2 + 1] !== " " && !isNaN(tokens[i2 + 1])) {
|
|
z["im"] += parseFloat((minus % 2 ? "-" : "") + tokens[i2 + 1]);
|
|
i2++;
|
|
} else {
|
|
z["im"] += parseFloat((minus % 2 ? "-" : "") + "1");
|
|
}
|
|
plus = minus = 0;
|
|
} else {
|
|
if (plus + minus === 0 || isNaN(c)) {
|
|
parser_exit();
|
|
}
|
|
if (tokens[i2 + 1] === "i" || tokens[i2 + 1] === "I") {
|
|
z["im"] += parseFloat((minus % 2 ? "-" : "") + c);
|
|
i2++;
|
|
} else {
|
|
z["re"] += parseFloat((minus % 2 ? "-" : "") + c);
|
|
}
|
|
plus = minus = 0;
|
|
}
|
|
}
|
|
if (plus + minus > 0) {
|
|
parser_exit();
|
|
}
|
|
break;
|
|
case "number":
|
|
z["im"] = 0;
|
|
z["re"] = a;
|
|
break;
|
|
default:
|
|
parser_exit();
|
|
}
|
|
if (isNaN(z["re"]) || isNaN(z["im"])) {
|
|
}
|
|
return z;
|
|
};
|
|
function Complex3(a, b) {
|
|
if (!(this instanceof Complex3)) {
|
|
return new Complex3(a, b);
|
|
}
|
|
var z = parse2(a, b);
|
|
this["re"] = z["re"];
|
|
this["im"] = z["im"];
|
|
}
|
|
Complex3.prototype = {
|
|
"re": 0,
|
|
"im": 0,
|
|
"sign": function() {
|
|
var abs3 = this["abs"]();
|
|
return new Complex3(this["re"] / abs3, this["im"] / abs3);
|
|
},
|
|
"add": function(a, b) {
|
|
var z = new Complex3(a, b);
|
|
if (this["isInfinite"]() && z["isInfinite"]()) {
|
|
return Complex3["NAN"];
|
|
}
|
|
if (this["isInfinite"]() || z["isInfinite"]()) {
|
|
return Complex3["INFINITY"];
|
|
}
|
|
return new Complex3(this["re"] + z["re"], this["im"] + z["im"]);
|
|
},
|
|
"sub": function(a, b) {
|
|
var z = new Complex3(a, b);
|
|
if (this["isInfinite"]() && z["isInfinite"]()) {
|
|
return Complex3["NAN"];
|
|
}
|
|
if (this["isInfinite"]() || z["isInfinite"]()) {
|
|
return Complex3["INFINITY"];
|
|
}
|
|
return new Complex3(this["re"] - z["re"], this["im"] - z["im"]);
|
|
},
|
|
"mul": function(a, b) {
|
|
var z = new Complex3(a, b);
|
|
if (this["isInfinite"]() && z["isZero"]() || this["isZero"]() && z["isInfinite"]()) {
|
|
return Complex3["NAN"];
|
|
}
|
|
if (this["isInfinite"]() || z["isInfinite"]()) {
|
|
return Complex3["INFINITY"];
|
|
}
|
|
if (z["im"] === 0 && this["im"] === 0) {
|
|
return new Complex3(this["re"] * z["re"], 0);
|
|
}
|
|
return new Complex3(this["re"] * z["re"] - this["im"] * z["im"], this["re"] * z["im"] + this["im"] * z["re"]);
|
|
},
|
|
"div": function(a, b) {
|
|
var z = new Complex3(a, b);
|
|
if (this["isZero"]() && z["isZero"]() || this["isInfinite"]() && z["isInfinite"]()) {
|
|
return Complex3["NAN"];
|
|
}
|
|
if (this["isInfinite"]() || z["isZero"]()) {
|
|
return Complex3["INFINITY"];
|
|
}
|
|
if (this["isZero"]() || z["isInfinite"]()) {
|
|
return Complex3["ZERO"];
|
|
}
|
|
a = this["re"];
|
|
b = this["im"];
|
|
var c = z["re"];
|
|
var d = z["im"];
|
|
var t, x;
|
|
if (d === 0) {
|
|
return new Complex3(a / c, b / c);
|
|
}
|
|
if (Math.abs(c) < Math.abs(d)) {
|
|
x = c / d;
|
|
t = c * x + d;
|
|
return new Complex3((a * x + b) / t, (b * x - a) / t);
|
|
} else {
|
|
x = d / c;
|
|
t = d * x + c;
|
|
return new Complex3((a + b * x) / t, (b - a * x) / t);
|
|
}
|
|
},
|
|
"pow": function(a, b) {
|
|
var z = new Complex3(a, b);
|
|
a = this["re"];
|
|
b = this["im"];
|
|
if (z["isZero"]()) {
|
|
return Complex3["ONE"];
|
|
}
|
|
if (z["im"] === 0) {
|
|
if (b === 0 && a > 0) {
|
|
return new Complex3(Math.pow(a, z["re"]), 0);
|
|
} else if (a === 0) {
|
|
switch ((z["re"] % 4 + 4) % 4) {
|
|
case 0:
|
|
return new Complex3(Math.pow(b, z["re"]), 0);
|
|
case 1:
|
|
return new Complex3(0, Math.pow(b, z["re"]));
|
|
case 2:
|
|
return new Complex3(-Math.pow(b, z["re"]), 0);
|
|
case 3:
|
|
return new Complex3(0, -Math.pow(b, z["re"]));
|
|
}
|
|
}
|
|
}
|
|
if (a === 0 && b === 0 && z["re"] > 0 && z["im"] >= 0) {
|
|
return Complex3["ZERO"];
|
|
}
|
|
var arg2 = Math.atan2(b, a);
|
|
var loh = logHypot(a, b);
|
|
a = Math.exp(z["re"] * loh - z["im"] * arg2);
|
|
b = z["im"] * loh + z["re"] * arg2;
|
|
return new Complex3(a * Math.cos(b), a * Math.sin(b));
|
|
},
|
|
"sqrt": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
var r = this["abs"]();
|
|
var re2, im2;
|
|
if (a >= 0) {
|
|
if (b === 0) {
|
|
return new Complex3(Math.sqrt(a), 0);
|
|
}
|
|
re2 = 0.5 * Math.sqrt(2 * (r + a));
|
|
} else {
|
|
re2 = Math.abs(b) / Math.sqrt(2 * (r - a));
|
|
}
|
|
if (a <= 0) {
|
|
im2 = 0.5 * Math.sqrt(2 * (r - a));
|
|
} else {
|
|
im2 = Math.abs(b) / Math.sqrt(2 * (r + a));
|
|
}
|
|
return new Complex3(re2, b < 0 ? -im2 : im2);
|
|
},
|
|
"exp": function() {
|
|
var tmp = Math.exp(this["re"]);
|
|
if (this["im"] === 0) {
|
|
}
|
|
return new Complex3(tmp * Math.cos(this["im"]), tmp * Math.sin(this["im"]));
|
|
},
|
|
"expm1": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
return new Complex3(Math.expm1(a) * Math.cos(b) + cosm1(b), Math.exp(a) * Math.sin(b));
|
|
},
|
|
"log": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
if (b === 0 && a > 0) {
|
|
}
|
|
return new Complex3(logHypot(a, b), Math.atan2(b, a));
|
|
},
|
|
"abs": function() {
|
|
return hypot3(this["re"], this["im"]);
|
|
},
|
|
"arg": function() {
|
|
return Math.atan2(this["im"], this["re"]);
|
|
},
|
|
"sin": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
return new Complex3(Math.sin(a) * cosh4(b), Math.cos(a) * sinh4(b));
|
|
},
|
|
"cos": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
return new Complex3(Math.cos(a) * cosh4(b), -Math.sin(a) * sinh4(b));
|
|
},
|
|
"tan": function() {
|
|
var a = 2 * this["re"];
|
|
var b = 2 * this["im"];
|
|
var d = Math.cos(a) + cosh4(b);
|
|
return new Complex3(Math.sin(a) / d, sinh4(b) / d);
|
|
},
|
|
"cot": function() {
|
|
var a = 2 * this["re"];
|
|
var b = 2 * this["im"];
|
|
var d = Math.cos(a) - cosh4(b);
|
|
return new Complex3(-Math.sin(a) / d, sinh4(b) / d);
|
|
},
|
|
"sec": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
var d = 0.5 * cosh4(2 * b) + 0.5 * Math.cos(2 * a);
|
|
return new Complex3(Math.cos(a) * cosh4(b) / d, Math.sin(a) * sinh4(b) / d);
|
|
},
|
|
"csc": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
var d = 0.5 * cosh4(2 * b) - 0.5 * Math.cos(2 * a);
|
|
return new Complex3(Math.sin(a) * cosh4(b) / d, -Math.cos(a) * sinh4(b) / d);
|
|
},
|
|
"asin": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
var t1 = new Complex3(b * b - a * a + 1, -2 * a * b)["sqrt"]();
|
|
var t2 = new Complex3(t1["re"] - b, t1["im"] + a)["log"]();
|
|
return new Complex3(t2["im"], -t2["re"]);
|
|
},
|
|
"acos": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
var t1 = new Complex3(b * b - a * a + 1, -2 * a * b)["sqrt"]();
|
|
var t2 = new Complex3(t1["re"] - b, t1["im"] + a)["log"]();
|
|
return new Complex3(Math.PI / 2 - t2["im"], t2["re"]);
|
|
},
|
|
"atan": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
if (a === 0) {
|
|
if (b === 1) {
|
|
return new Complex3(0, Infinity);
|
|
}
|
|
if (b === -1) {
|
|
return new Complex3(0, -Infinity);
|
|
}
|
|
}
|
|
var d = a * a + (1 - b) * (1 - b);
|
|
var t1 = new Complex3((1 - b * b - a * a) / d, -2 * a / d).log();
|
|
return new Complex3(-0.5 * t1["im"], 0.5 * t1["re"]);
|
|
},
|
|
"acot": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
if (b === 0) {
|
|
return new Complex3(Math.atan2(1, a), 0);
|
|
}
|
|
var d = a * a + b * b;
|
|
return d !== 0 ? new Complex3(a / d, -b / d).atan() : new Complex3(a !== 0 ? a / 0 : 0, b !== 0 ? -b / 0 : 0).atan();
|
|
},
|
|
"asec": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
if (a === 0 && b === 0) {
|
|
return new Complex3(0, Infinity);
|
|
}
|
|
var d = a * a + b * b;
|
|
return d !== 0 ? new Complex3(a / d, -b / d).acos() : new Complex3(a !== 0 ? a / 0 : 0, b !== 0 ? -b / 0 : 0).acos();
|
|
},
|
|
"acsc": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
if (a === 0 && b === 0) {
|
|
return new Complex3(Math.PI / 2, Infinity);
|
|
}
|
|
var d = a * a + b * b;
|
|
return d !== 0 ? new Complex3(a / d, -b / d).asin() : new Complex3(a !== 0 ? a / 0 : 0, b !== 0 ? -b / 0 : 0).asin();
|
|
},
|
|
"sinh": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
return new Complex3(sinh4(a) * Math.cos(b), cosh4(a) * Math.sin(b));
|
|
},
|
|
"cosh": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
return new Complex3(cosh4(a) * Math.cos(b), sinh4(a) * Math.sin(b));
|
|
},
|
|
"tanh": function() {
|
|
var a = 2 * this["re"];
|
|
var b = 2 * this["im"];
|
|
var d = cosh4(a) + Math.cos(b);
|
|
return new Complex3(sinh4(a) / d, Math.sin(b) / d);
|
|
},
|
|
"coth": function() {
|
|
var a = 2 * this["re"];
|
|
var b = 2 * this["im"];
|
|
var d = cosh4(a) - Math.cos(b);
|
|
return new Complex3(sinh4(a) / d, -Math.sin(b) / d);
|
|
},
|
|
"csch": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
var d = Math.cos(2 * b) - cosh4(2 * a);
|
|
return new Complex3(-2 * sinh4(a) * Math.cos(b) / d, 2 * cosh4(a) * Math.sin(b) / d);
|
|
},
|
|
"sech": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
var d = Math.cos(2 * b) + cosh4(2 * a);
|
|
return new Complex3(2 * cosh4(a) * Math.cos(b) / d, -2 * sinh4(a) * Math.sin(b) / d);
|
|
},
|
|
"asinh": function() {
|
|
var tmp = this["im"];
|
|
this["im"] = -this["re"];
|
|
this["re"] = tmp;
|
|
var res = this["asin"]();
|
|
this["re"] = -this["im"];
|
|
this["im"] = tmp;
|
|
tmp = res["re"];
|
|
res["re"] = -res["im"];
|
|
res["im"] = tmp;
|
|
return res;
|
|
},
|
|
"acosh": function() {
|
|
var res = this["acos"]();
|
|
if (res["im"] <= 0) {
|
|
var tmp = res["re"];
|
|
res["re"] = -res["im"];
|
|
res["im"] = tmp;
|
|
} else {
|
|
var tmp = res["im"];
|
|
res["im"] = -res["re"];
|
|
res["re"] = tmp;
|
|
}
|
|
return res;
|
|
},
|
|
"atanh": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
var noIM = a > 1 && b === 0;
|
|
var oneMinus = 1 - a;
|
|
var onePlus = 1 + a;
|
|
var d = oneMinus * oneMinus + b * b;
|
|
var x = d !== 0 ? new Complex3((onePlus * oneMinus - b * b) / d, (b * oneMinus + onePlus * b) / d) : new Complex3(a !== -1 ? a / 0 : 0, b !== 0 ? b / 0 : 0);
|
|
var temp = x["re"];
|
|
x["re"] = logHypot(x["re"], x["im"]) / 2;
|
|
x["im"] = Math.atan2(x["im"], temp) / 2;
|
|
if (noIM) {
|
|
x["im"] = -x["im"];
|
|
}
|
|
return x;
|
|
},
|
|
"acoth": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
if (a === 0 && b === 0) {
|
|
return new Complex3(0, Math.PI / 2);
|
|
}
|
|
var d = a * a + b * b;
|
|
return d !== 0 ? new Complex3(a / d, -b / d).atanh() : new Complex3(a !== 0 ? a / 0 : 0, b !== 0 ? -b / 0 : 0).atanh();
|
|
},
|
|
"acsch": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
if (b === 0) {
|
|
return new Complex3(a !== 0 ? Math.log(a + Math.sqrt(a * a + 1)) : Infinity, 0);
|
|
}
|
|
var d = a * a + b * b;
|
|
return d !== 0 ? new Complex3(a / d, -b / d).asinh() : new Complex3(a !== 0 ? a / 0 : 0, b !== 0 ? -b / 0 : 0).asinh();
|
|
},
|
|
"asech": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
if (this["isZero"]()) {
|
|
return Complex3["INFINITY"];
|
|
}
|
|
var d = a * a + b * b;
|
|
return d !== 0 ? new Complex3(a / d, -b / d).acosh() : new Complex3(a !== 0 ? a / 0 : 0, b !== 0 ? -b / 0 : 0).acosh();
|
|
},
|
|
"inverse": function() {
|
|
if (this["isZero"]()) {
|
|
return Complex3["INFINITY"];
|
|
}
|
|
if (this["isInfinite"]()) {
|
|
return Complex3["ZERO"];
|
|
}
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
var d = a * a + b * b;
|
|
return new Complex3(a / d, -b / d);
|
|
},
|
|
"conjugate": function() {
|
|
return new Complex3(this["re"], -this["im"]);
|
|
},
|
|
"neg": function() {
|
|
return new Complex3(-this["re"], -this["im"]);
|
|
},
|
|
"ceil": function(places) {
|
|
places = Math.pow(10, places || 0);
|
|
return new Complex3(Math.ceil(this["re"] * places) / places, Math.ceil(this["im"] * places) / places);
|
|
},
|
|
"floor": function(places) {
|
|
places = Math.pow(10, places || 0);
|
|
return new Complex3(Math.floor(this["re"] * places) / places, Math.floor(this["im"] * places) / places);
|
|
},
|
|
"round": function(places) {
|
|
places = Math.pow(10, places || 0);
|
|
return new Complex3(Math.round(this["re"] * places) / places, Math.round(this["im"] * places) / places);
|
|
},
|
|
"equals": function(a, b) {
|
|
var z = new Complex3(a, b);
|
|
return Math.abs(z["re"] - this["re"]) <= Complex3["EPSILON"] && Math.abs(z["im"] - this["im"]) <= Complex3["EPSILON"];
|
|
},
|
|
"clone": function() {
|
|
return new Complex3(this["re"], this["im"]);
|
|
},
|
|
"toString": function() {
|
|
var a = this["re"];
|
|
var b = this["im"];
|
|
var ret = "";
|
|
if (this["isNaN"]()) {
|
|
return "NaN";
|
|
}
|
|
if (this["isInfinite"]()) {
|
|
return "Infinity";
|
|
}
|
|
if (Math.abs(a) < Complex3["EPSILON"]) {
|
|
a = 0;
|
|
}
|
|
if (Math.abs(b) < Complex3["EPSILON"]) {
|
|
b = 0;
|
|
}
|
|
if (b === 0) {
|
|
return ret + a;
|
|
}
|
|
if (a !== 0) {
|
|
ret += a;
|
|
ret += " ";
|
|
if (b < 0) {
|
|
b = -b;
|
|
ret += "-";
|
|
} else {
|
|
ret += "+";
|
|
}
|
|
ret += " ";
|
|
} else if (b < 0) {
|
|
b = -b;
|
|
ret += "-";
|
|
}
|
|
if (b !== 1) {
|
|
ret += b;
|
|
}
|
|
return ret + "i";
|
|
},
|
|
"toVector": function() {
|
|
return [this["re"], this["im"]];
|
|
},
|
|
"valueOf": function() {
|
|
if (this["im"] === 0) {
|
|
return this["re"];
|
|
}
|
|
return null;
|
|
},
|
|
"isNaN": function() {
|
|
return isNaN(this["re"]) || isNaN(this["im"]);
|
|
},
|
|
"isZero": function() {
|
|
return this["im"] === 0 && this["re"] === 0;
|
|
},
|
|
"isFinite": function() {
|
|
return isFinite(this["re"]) && isFinite(this["im"]);
|
|
},
|
|
"isInfinite": function() {
|
|
return !(this["isNaN"]() || this["isFinite"]());
|
|
}
|
|
};
|
|
Complex3["ZERO"] = new Complex3(0, 0);
|
|
Complex3["ONE"] = new Complex3(1, 0);
|
|
Complex3["I"] = new Complex3(0, 1);
|
|
Complex3["PI"] = new Complex3(Math.PI, 0);
|
|
Complex3["E"] = new Complex3(Math.E, 0);
|
|
Complex3["INFINITY"] = new Complex3(Infinity, Infinity);
|
|
Complex3["NAN"] = new Complex3(NaN, NaN);
|
|
Complex3["EPSILON"] = 1e-15;
|
|
if (typeof define === "function" && define["amd"]) {
|
|
define([], function() {
|
|
return Complex3;
|
|
});
|
|
} else if (typeof exports === "object") {
|
|
Object.defineProperty(Complex3, "__esModule", { "value": true });
|
|
Complex3["default"] = Complex3;
|
|
Complex3["Complex"] = Complex3;
|
|
module2["exports"] = Complex3;
|
|
} else {
|
|
root["Complex"] = Complex3;
|
|
}
|
|
})(exports);
|
|
}
|
|
});
|
|
|
|
// node_modules/fraction.js/fraction.js
|
|
var require_fraction = __commonJS({
|
|
"node_modules/fraction.js/fraction.js"(exports, module2) {
|
|
(function(root) {
|
|
"use strict";
|
|
var MAX_CYCLE_LEN = 2e3;
|
|
var P3 = {
|
|
"s": 1,
|
|
"n": 0,
|
|
"d": 1
|
|
};
|
|
function assign2(n, s) {
|
|
if (isNaN(n = parseInt(n, 10))) {
|
|
throw Fraction3["InvalidParameter"];
|
|
}
|
|
return n * s;
|
|
}
|
|
function newFraction(n, d) {
|
|
if (d === 0) {
|
|
throw Fraction3["DivisionByZero"];
|
|
}
|
|
var f = Object.create(Fraction3.prototype);
|
|
f["s"] = n < 0 ? -1 : 1;
|
|
n = n < 0 ? -n : n;
|
|
var a = gcd2(n, d);
|
|
f["n"] = n / a;
|
|
f["d"] = d / a;
|
|
return f;
|
|
}
|
|
function factorize(num) {
|
|
var factors = {};
|
|
var n = num;
|
|
var i2 = 2;
|
|
var s = 4;
|
|
while (s <= n) {
|
|
while (n % i2 === 0) {
|
|
n /= i2;
|
|
factors[i2] = (factors[i2] || 0) + 1;
|
|
}
|
|
s += 1 + 2 * i2++;
|
|
}
|
|
if (n !== num) {
|
|
if (n > 1)
|
|
factors[n] = (factors[n] || 0) + 1;
|
|
} else {
|
|
factors[num] = (factors[num] || 0) + 1;
|
|
}
|
|
return factors;
|
|
}
|
|
var parse2 = function(p1, p2) {
|
|
var n = 0, d = 1, s = 1;
|
|
var v = 0, w = 0, x = 0, y = 1, z = 1;
|
|
var A = 0, B = 1;
|
|
var C = 1, D = 1;
|
|
var N = 1e7;
|
|
var M;
|
|
if (p1 === void 0 || p1 === null) {
|
|
} else if (p2 !== void 0) {
|
|
n = p1;
|
|
d = p2;
|
|
s = n * d;
|
|
if (n % 1 !== 0 || d % 1 !== 0) {
|
|
throw Fraction3["NonIntegerParameter"];
|
|
}
|
|
} else
|
|
switch (typeof p1) {
|
|
case "object": {
|
|
if ("d" in p1 && "n" in p1) {
|
|
n = p1["n"];
|
|
d = p1["d"];
|
|
if ("s" in p1)
|
|
n *= p1["s"];
|
|
} else if (0 in p1) {
|
|
n = p1[0];
|
|
if (1 in p1)
|
|
d = p1[1];
|
|
} else {
|
|
throw Fraction3["InvalidParameter"];
|
|
}
|
|
s = n * d;
|
|
break;
|
|
}
|
|
case "number": {
|
|
if (p1 < 0) {
|
|
s = p1;
|
|
p1 = -p1;
|
|
}
|
|
if (p1 % 1 === 0) {
|
|
n = p1;
|
|
} else if (p1 > 0) {
|
|
if (p1 >= 1) {
|
|
z = Math.pow(10, Math.floor(1 + Math.log(p1) / Math.LN10));
|
|
p1 /= z;
|
|
}
|
|
while (B <= N && D <= N) {
|
|
M = (A + C) / (B + D);
|
|
if (p1 === M) {
|
|
if (B + D <= N) {
|
|
n = A + C;
|
|
d = B + D;
|
|
} else if (D > B) {
|
|
n = C;
|
|
d = D;
|
|
} else {
|
|
n = A;
|
|
d = B;
|
|
}
|
|
break;
|
|
} else {
|
|
if (p1 > M) {
|
|
A += C;
|
|
B += D;
|
|
} else {
|
|
C += A;
|
|
D += B;
|
|
}
|
|
if (B > N) {
|
|
n = C;
|
|
d = D;
|
|
} else {
|
|
n = A;
|
|
d = B;
|
|
}
|
|
}
|
|
}
|
|
n *= z;
|
|
} else if (isNaN(p1) || isNaN(p2)) {
|
|
d = n = NaN;
|
|
}
|
|
break;
|
|
}
|
|
case "string": {
|
|
B = p1.match(/\d+|./g);
|
|
if (B === null)
|
|
throw Fraction3["InvalidParameter"];
|
|
if (B[A] === "-") {
|
|
s = -1;
|
|
A++;
|
|
} else if (B[A] === "+") {
|
|
A++;
|
|
}
|
|
if (B.length === A + 1) {
|
|
w = assign2(B[A++], s);
|
|
} else if (B[A + 1] === "." || B[A] === ".") {
|
|
if (B[A] !== ".") {
|
|
v = assign2(B[A++], s);
|
|
}
|
|
A++;
|
|
if (A + 1 === B.length || B[A + 1] === "(" && B[A + 3] === ")" || B[A + 1] === "'" && B[A + 3] === "'") {
|
|
w = assign2(B[A], s);
|
|
y = Math.pow(10, B[A].length);
|
|
A++;
|
|
}
|
|
if (B[A] === "(" && B[A + 2] === ")" || B[A] === "'" && B[A + 2] === "'") {
|
|
x = assign2(B[A + 1], s);
|
|
z = Math.pow(10, B[A + 1].length) - 1;
|
|
A += 3;
|
|
}
|
|
} else if (B[A + 1] === "/" || B[A + 1] === ":") {
|
|
w = assign2(B[A], s);
|
|
y = assign2(B[A + 2], 1);
|
|
A += 3;
|
|
} else if (B[A + 3] === "/" && B[A + 1] === " ") {
|
|
v = assign2(B[A], s);
|
|
w = assign2(B[A + 2], s);
|
|
y = assign2(B[A + 4], 1);
|
|
A += 5;
|
|
}
|
|
if (B.length <= A) {
|
|
d = y * z;
|
|
s = n = x + d * v + z * w;
|
|
break;
|
|
}
|
|
}
|
|
default:
|
|
throw Fraction3["InvalidParameter"];
|
|
}
|
|
if (d === 0) {
|
|
throw Fraction3["DivisionByZero"];
|
|
}
|
|
P3["s"] = s < 0 ? -1 : 1;
|
|
P3["n"] = Math.abs(n);
|
|
P3["d"] = Math.abs(d);
|
|
};
|
|
function modpow(b, e3, m) {
|
|
var r = 1;
|
|
for (; e3 > 0; b = b * b % m, e3 >>= 1) {
|
|
if (e3 & 1) {
|
|
r = r * b % m;
|
|
}
|
|
}
|
|
return r;
|
|
}
|
|
function cycleLen(n, d) {
|
|
for (; d % 2 === 0; d /= 2) {
|
|
}
|
|
for (; d % 5 === 0; d /= 5) {
|
|
}
|
|
if (d === 1)
|
|
return 0;
|
|
var rem = 10 % d;
|
|
var t = 1;
|
|
for (; rem !== 1; t++) {
|
|
rem = rem * 10 % d;
|
|
if (t > MAX_CYCLE_LEN)
|
|
return 0;
|
|
}
|
|
return t;
|
|
}
|
|
function cycleStart(n, d, len) {
|
|
var rem1 = 1;
|
|
var rem2 = modpow(10, len, d);
|
|
for (var t = 0; t < 300; t++) {
|
|
if (rem1 === rem2)
|
|
return t;
|
|
rem1 = rem1 * 10 % d;
|
|
rem2 = rem2 * 10 % d;
|
|
}
|
|
return 0;
|
|
}
|
|
function gcd2(a, b) {
|
|
if (!a)
|
|
return b;
|
|
if (!b)
|
|
return a;
|
|
while (1) {
|
|
a %= b;
|
|
if (!a)
|
|
return b;
|
|
b %= a;
|
|
if (!b)
|
|
return a;
|
|
}
|
|
}
|
|
;
|
|
function Fraction3(a, b) {
|
|
parse2(a, b);
|
|
if (this instanceof Fraction3) {
|
|
a = gcd2(P3["d"], P3["n"]);
|
|
this["s"] = P3["s"];
|
|
this["n"] = P3["n"] / a;
|
|
this["d"] = P3["d"] / a;
|
|
} else {
|
|
return newFraction(P3["s"] * P3["n"], P3["d"]);
|
|
}
|
|
}
|
|
Fraction3["DivisionByZero"] = new Error("Division by Zero");
|
|
Fraction3["InvalidParameter"] = new Error("Invalid argument");
|
|
Fraction3["NonIntegerParameter"] = new Error("Parameters must be integer");
|
|
Fraction3.prototype = {
|
|
"s": 1,
|
|
"n": 0,
|
|
"d": 1,
|
|
"abs": function() {
|
|
return newFraction(this["n"], this["d"]);
|
|
},
|
|
"neg": function() {
|
|
return newFraction(-this["s"] * this["n"], this["d"]);
|
|
},
|
|
"add": function(a, b) {
|
|
parse2(a, b);
|
|
return newFraction(this["s"] * this["n"] * P3["d"] + P3["s"] * this["d"] * P3["n"], this["d"] * P3["d"]);
|
|
},
|
|
"sub": function(a, b) {
|
|
parse2(a, b);
|
|
return newFraction(this["s"] * this["n"] * P3["d"] - P3["s"] * this["d"] * P3["n"], this["d"] * P3["d"]);
|
|
},
|
|
"mul": function(a, b) {
|
|
parse2(a, b);
|
|
return newFraction(this["s"] * P3["s"] * this["n"] * P3["n"], this["d"] * P3["d"]);
|
|
},
|
|
"div": function(a, b) {
|
|
parse2(a, b);
|
|
return newFraction(this["s"] * P3["s"] * this["n"] * P3["d"], this["d"] * P3["n"]);
|
|
},
|
|
"clone": function() {
|
|
return newFraction(this["s"] * this["n"], this["d"]);
|
|
},
|
|
"mod": function(a, b) {
|
|
if (isNaN(this["n"]) || isNaN(this["d"])) {
|
|
return new Fraction3(NaN);
|
|
}
|
|
if (a === void 0) {
|
|
return newFraction(this["s"] * this["n"] % this["d"], 1);
|
|
}
|
|
parse2(a, b);
|
|
if (P3["n"] === 0 && this["d"] === 0) {
|
|
throw Fraction3["DivisionByZero"];
|
|
}
|
|
return newFraction(this["s"] * (P3["d"] * this["n"]) % (P3["n"] * this["d"]), P3["d"] * this["d"]);
|
|
},
|
|
"gcd": function(a, b) {
|
|
parse2(a, b);
|
|
return newFraction(gcd2(P3["n"], this["n"]) * gcd2(P3["d"], this["d"]), P3["d"] * this["d"]);
|
|
},
|
|
"lcm": function(a, b) {
|
|
parse2(a, b);
|
|
if (P3["n"] === 0 && this["n"] === 0) {
|
|
return newFraction(0, 1);
|
|
}
|
|
return newFraction(P3["n"] * this["n"], gcd2(P3["n"], this["n"]) * gcd2(P3["d"], this["d"]));
|
|
},
|
|
"ceil": function(places) {
|
|
places = Math.pow(10, places || 0);
|
|
if (isNaN(this["n"]) || isNaN(this["d"])) {
|
|
return new Fraction3(NaN);
|
|
}
|
|
return newFraction(Math.ceil(places * this["s"] * this["n"] / this["d"]), places);
|
|
},
|
|
"floor": function(places) {
|
|
places = Math.pow(10, places || 0);
|
|
if (isNaN(this["n"]) || isNaN(this["d"])) {
|
|
return new Fraction3(NaN);
|
|
}
|
|
return newFraction(Math.floor(places * this["s"] * this["n"] / this["d"]), places);
|
|
},
|
|
"round": function(places) {
|
|
places = Math.pow(10, places || 0);
|
|
if (isNaN(this["n"]) || isNaN(this["d"])) {
|
|
return new Fraction3(NaN);
|
|
}
|
|
return newFraction(Math.round(places * this["s"] * this["n"] / this["d"]), places);
|
|
},
|
|
"inverse": function() {
|
|
return newFraction(this["s"] * this["d"], this["n"]);
|
|
},
|
|
"pow": function(a, b) {
|
|
parse2(a, b);
|
|
if (P3["d"] === 1) {
|
|
if (P3["s"] < 0) {
|
|
return newFraction(Math.pow(this["s"] * this["d"], P3["n"]), Math.pow(this["n"], P3["n"]));
|
|
} else {
|
|
return newFraction(Math.pow(this["s"] * this["n"], P3["n"]), Math.pow(this["d"], P3["n"]));
|
|
}
|
|
}
|
|
if (this["s"] < 0)
|
|
return null;
|
|
var N = factorize(this["n"]);
|
|
var D = factorize(this["d"]);
|
|
var n = 1;
|
|
var d = 1;
|
|
for (var k in N) {
|
|
if (k === "1")
|
|
continue;
|
|
if (k === "0") {
|
|
n = 0;
|
|
break;
|
|
}
|
|
N[k] *= P3["n"];
|
|
if (N[k] % P3["d"] === 0) {
|
|
N[k] /= P3["d"];
|
|
} else
|
|
return null;
|
|
n *= Math.pow(k, N[k]);
|
|
}
|
|
for (var k in D) {
|
|
if (k === "1")
|
|
continue;
|
|
D[k] *= P3["n"];
|
|
if (D[k] % P3["d"] === 0) {
|
|
D[k] /= P3["d"];
|
|
} else
|
|
return null;
|
|
d *= Math.pow(k, D[k]);
|
|
}
|
|
if (P3["s"] < 0) {
|
|
return newFraction(d, n);
|
|
}
|
|
return newFraction(n, d);
|
|
},
|
|
"equals": function(a, b) {
|
|
parse2(a, b);
|
|
return this["s"] * this["n"] * P3["d"] === P3["s"] * P3["n"] * this["d"];
|
|
},
|
|
"compare": function(a, b) {
|
|
parse2(a, b);
|
|
var t = this["s"] * this["n"] * P3["d"] - P3["s"] * P3["n"] * this["d"];
|
|
return (0 < t) - (t < 0);
|
|
},
|
|
"simplify": function(eps) {
|
|
if (isNaN(this["n"]) || isNaN(this["d"])) {
|
|
return this;
|
|
}
|
|
eps = eps || 1e-3;
|
|
var thisABS = this["abs"]();
|
|
var cont = thisABS["toContinued"]();
|
|
for (var i2 = 1; i2 < cont.length; i2++) {
|
|
var s = newFraction(cont[i2 - 1], 1);
|
|
for (var k = i2 - 2; k >= 0; k--) {
|
|
s = s["inverse"]()["add"](cont[k]);
|
|
}
|
|
if (s["sub"](thisABS)["abs"]().valueOf() < eps) {
|
|
return s["mul"](this["s"]);
|
|
}
|
|
}
|
|
return this;
|
|
},
|
|
"divisible": function(a, b) {
|
|
parse2(a, b);
|
|
return !(!(P3["n"] * this["d"]) || this["n"] * P3["d"] % (P3["n"] * this["d"]));
|
|
},
|
|
"valueOf": function() {
|
|
return this["s"] * this["n"] / this["d"];
|
|
},
|
|
"toFraction": function(excludeWhole) {
|
|
var whole, str = "";
|
|
var n = this["n"];
|
|
var d = this["d"];
|
|
if (this["s"] < 0) {
|
|
str += "-";
|
|
}
|
|
if (d === 1) {
|
|
str += n;
|
|
} else {
|
|
if (excludeWhole && (whole = Math.floor(n / d)) > 0) {
|
|
str += whole;
|
|
str += " ";
|
|
n %= d;
|
|
}
|
|
str += n;
|
|
str += "/";
|
|
str += d;
|
|
}
|
|
return str;
|
|
},
|
|
"toLatex": function(excludeWhole) {
|
|
var whole, str = "";
|
|
var n = this["n"];
|
|
var d = this["d"];
|
|
if (this["s"] < 0) {
|
|
str += "-";
|
|
}
|
|
if (d === 1) {
|
|
str += n;
|
|
} else {
|
|
if (excludeWhole && (whole = Math.floor(n / d)) > 0) {
|
|
str += whole;
|
|
n %= d;
|
|
}
|
|
str += "\\frac{";
|
|
str += n;
|
|
str += "}{";
|
|
str += d;
|
|
str += "}";
|
|
}
|
|
return str;
|
|
},
|
|
"toContinued": function() {
|
|
var t;
|
|
var a = this["n"];
|
|
var b = this["d"];
|
|
var res = [];
|
|
if (isNaN(a) || isNaN(b)) {
|
|
return res;
|
|
}
|
|
do {
|
|
res.push(Math.floor(a / b));
|
|
t = a % b;
|
|
a = b;
|
|
b = t;
|
|
} while (a !== 1);
|
|
return res;
|
|
},
|
|
"toString": function(dec) {
|
|
var N = this["n"];
|
|
var D = this["d"];
|
|
if (isNaN(N) || isNaN(D)) {
|
|
return "NaN";
|
|
}
|
|
dec = dec || 15;
|
|
var cycLen = cycleLen(N, D);
|
|
var cycOff = cycleStart(N, D, cycLen);
|
|
var str = this["s"] < 0 ? "-" : "";
|
|
str += N / D | 0;
|
|
N %= D;
|
|
N *= 10;
|
|
if (N)
|
|
str += ".";
|
|
if (cycLen) {
|
|
for (var i2 = cycOff; i2--; ) {
|
|
str += N / D | 0;
|
|
N %= D;
|
|
N *= 10;
|
|
}
|
|
str += "(";
|
|
for (var i2 = cycLen; i2--; ) {
|
|
str += N / D | 0;
|
|
N %= D;
|
|
N *= 10;
|
|
}
|
|
str += ")";
|
|
} else {
|
|
for (var i2 = dec; N && i2--; ) {
|
|
str += N / D | 0;
|
|
N %= D;
|
|
N *= 10;
|
|
}
|
|
}
|
|
return str;
|
|
}
|
|
};
|
|
if (typeof define === "function" && define["amd"]) {
|
|
define([], function() {
|
|
return Fraction3;
|
|
});
|
|
} else if (typeof exports === "object") {
|
|
Object.defineProperty(Fraction3, "__esModule", { "value": true });
|
|
Fraction3["default"] = Fraction3;
|
|
Fraction3["Fraction"] = Fraction3;
|
|
module2["exports"] = Fraction3;
|
|
} else {
|
|
root["Fraction"] = Fraction3;
|
|
}
|
|
})(exports);
|
|
}
|
|
});
|
|
|
|
// node_modules/javascript-natural-sort/naturalSort.js
|
|
var require_naturalSort = __commonJS({
|
|
"node_modules/javascript-natural-sort/naturalSort.js"(exports, module2) {
|
|
module2.exports = function naturalSort2(a, b) {
|
|
"use strict";
|
|
var re2 = /(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi, sre = /(^[ ]*|[ ]*$)/g, dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/, hre = /^0x[0-9a-f]+$/i, ore = /^0/, i2 = function(s) {
|
|
return naturalSort2.insensitive && ("" + s).toLowerCase() || "" + s;
|
|
}, x = i2(a).replace(sre, "") || "", y = i2(b).replace(sre, "") || "", xN = x.replace(re2, "\0$1\0").replace(/\0$/, "").replace(/^\0/, "").split("\0"), yN = y.replace(re2, "\0$1\0").replace(/\0$/, "").replace(/^\0/, "").split("\0"), xD = parseInt(x.match(hre), 16) || xN.length !== 1 && x.match(dre) && Date.parse(x), yD = parseInt(y.match(hre), 16) || xD && y.match(dre) && Date.parse(y) || null, oFxNcL, oFyNcL;
|
|
if (yD) {
|
|
if (xD < yD) {
|
|
return -1;
|
|
} else if (xD > yD) {
|
|
return 1;
|
|
}
|
|
}
|
|
for (var cLoc = 0, numS = Math.max(xN.length, yN.length); cLoc < numS; cLoc++) {
|
|
oFxNcL = !(xN[cLoc] || "").match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
|
|
oFyNcL = !(yN[cLoc] || "").match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
|
|
if (isNaN(oFxNcL) !== isNaN(oFyNcL)) {
|
|
return isNaN(oFxNcL) ? 1 : -1;
|
|
} else if (typeof oFxNcL !== typeof oFyNcL) {
|
|
oFxNcL += "";
|
|
oFyNcL += "";
|
|
}
|
|
if (oFxNcL < oFyNcL) {
|
|
return -1;
|
|
}
|
|
if (oFxNcL > oFyNcL) {
|
|
return 1;
|
|
}
|
|
}
|
|
return 0;
|
|
};
|
|
}
|
|
});
|
|
|
|
// node_modules/escape-latex/dist/index.js
|
|
var require_dist = __commonJS({
|
|
"node_modules/escape-latex/dist/index.js"(exports, module2) {
|
|
"use strict";
|
|
var _extends2 = Object.assign || function(target) {
|
|
for (var i2 = 1; i2 < arguments.length; i2++) {
|
|
var source = arguments[i2];
|
|
for (var key in source) {
|
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
target[key] = source[key];
|
|
}
|
|
}
|
|
}
|
|
return target;
|
|
};
|
|
var defaultEscapes = {
|
|
"{": "\\{",
|
|
"}": "\\}",
|
|
"\\": "\\textbackslash{}",
|
|
"#": "\\#",
|
|
$: "\\$",
|
|
"%": "\\%",
|
|
"&": "\\&",
|
|
"^": "\\textasciicircum{}",
|
|
_: "\\_",
|
|
"~": "\\textasciitilde{}"
|
|
};
|
|
var formatEscapes = {
|
|
"\u2013": "\\--",
|
|
"\u2014": "\\---",
|
|
" ": "~",
|
|
" ": "\\qquad{}",
|
|
"\r\n": "\\newline{}",
|
|
"\n": "\\newline{}"
|
|
};
|
|
var defaultEscapeMapFn = function defaultEscapeMapFn2(defaultEscapes2, formatEscapes2) {
|
|
return _extends2({}, defaultEscapes2, formatEscapes2);
|
|
};
|
|
module2.exports = function(str) {
|
|
var _ref = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, _ref$preserveFormatti = _ref.preserveFormatting, preserveFormatting = _ref$preserveFormatti === void 0 ? false : _ref$preserveFormatti, _ref$escapeMapFn = _ref.escapeMapFn, escapeMapFn = _ref$escapeMapFn === void 0 ? defaultEscapeMapFn : _ref$escapeMapFn;
|
|
var runningStr = String(str);
|
|
var result = "";
|
|
var escapes = escapeMapFn(_extends2({}, defaultEscapes), preserveFormatting ? _extends2({}, formatEscapes) : {});
|
|
var escapeKeys = Object.keys(escapes);
|
|
var _loop = function _loop2() {
|
|
var specialCharFound = false;
|
|
escapeKeys.forEach(function(key, index2) {
|
|
if (specialCharFound) {
|
|
return;
|
|
}
|
|
if (runningStr.length >= key.length && runningStr.slice(0, key.length) === key) {
|
|
result += escapes[escapeKeys[index2]];
|
|
runningStr = runningStr.slice(key.length, runningStr.length);
|
|
specialCharFound = true;
|
|
}
|
|
});
|
|
if (!specialCharFound) {
|
|
result += runningStr.slice(0, 1);
|
|
runningStr = runningStr.slice(1, runningStr.length);
|
|
}
|
|
};
|
|
while (runningStr) {
|
|
_loop();
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
});
|
|
|
|
// node_modules/seedrandom/lib/alea.js
|
|
var require_alea = __commonJS({
|
|
"node_modules/seedrandom/lib/alea.js"(exports, module2) {
|
|
(function(global, module3, define2) {
|
|
function Alea(seed) {
|
|
var me = this, mash = Mash();
|
|
me.next = function() {
|
|
var t = 2091639 * me.s0 + me.c * 23283064365386963e-26;
|
|
me.s0 = me.s1;
|
|
me.s1 = me.s2;
|
|
return me.s2 = t - (me.c = t | 0);
|
|
};
|
|
me.c = 1;
|
|
me.s0 = mash(" ");
|
|
me.s1 = mash(" ");
|
|
me.s2 = mash(" ");
|
|
me.s0 -= mash(seed);
|
|
if (me.s0 < 0) {
|
|
me.s0 += 1;
|
|
}
|
|
me.s1 -= mash(seed);
|
|
if (me.s1 < 0) {
|
|
me.s1 += 1;
|
|
}
|
|
me.s2 -= mash(seed);
|
|
if (me.s2 < 0) {
|
|
me.s2 += 1;
|
|
}
|
|
mash = null;
|
|
}
|
|
function copy(f, t) {
|
|
t.c = f.c;
|
|
t.s0 = f.s0;
|
|
t.s1 = f.s1;
|
|
t.s2 = f.s2;
|
|
return t;
|
|
}
|
|
function impl(seed, opts) {
|
|
var xg = new Alea(seed), state = opts && opts.state, prng = xg.next;
|
|
prng.int32 = function() {
|
|
return xg.next() * 4294967296 | 0;
|
|
};
|
|
prng.double = function() {
|
|
return prng() + (prng() * 2097152 | 0) * 11102230246251565e-32;
|
|
};
|
|
prng.quick = prng;
|
|
if (state) {
|
|
if (typeof state == "object")
|
|
copy(state, xg);
|
|
prng.state = function() {
|
|
return copy(xg, {});
|
|
};
|
|
}
|
|
return prng;
|
|
}
|
|
function Mash() {
|
|
var n = 4022871197;
|
|
var mash = function(data) {
|
|
data = String(data);
|
|
for (var i2 = 0; i2 < data.length; i2++) {
|
|
n += data.charCodeAt(i2);
|
|
var h = 0.02519603282416938 * n;
|
|
n = h >>> 0;
|
|
h -= n;
|
|
h *= n;
|
|
n = h >>> 0;
|
|
h -= n;
|
|
n += h * 4294967296;
|
|
}
|
|
return (n >>> 0) * 23283064365386963e-26;
|
|
};
|
|
return mash;
|
|
}
|
|
if (module3 && module3.exports) {
|
|
module3.exports = impl;
|
|
} else if (define2 && define2.amd) {
|
|
define2(function() {
|
|
return impl;
|
|
});
|
|
} else {
|
|
this.alea = impl;
|
|
}
|
|
})(exports, typeof module2 == "object" && module2, typeof define == "function" && define);
|
|
}
|
|
});
|
|
|
|
// node_modules/seedrandom/lib/xor128.js
|
|
var require_xor128 = __commonJS({
|
|
"node_modules/seedrandom/lib/xor128.js"(exports, module2) {
|
|
(function(global, module3, define2) {
|
|
function XorGen(seed) {
|
|
var me = this, strseed = "";
|
|
me.x = 0;
|
|
me.y = 0;
|
|
me.z = 0;
|
|
me.w = 0;
|
|
me.next = function() {
|
|
var t = me.x ^ me.x << 11;
|
|
me.x = me.y;
|
|
me.y = me.z;
|
|
me.z = me.w;
|
|
return me.w ^= me.w >>> 19 ^ t ^ t >>> 8;
|
|
};
|
|
if (seed === (seed | 0)) {
|
|
me.x = seed;
|
|
} else {
|
|
strseed += seed;
|
|
}
|
|
for (var k = 0; k < strseed.length + 64; k++) {
|
|
me.x ^= strseed.charCodeAt(k) | 0;
|
|
me.next();
|
|
}
|
|
}
|
|
function copy(f, t) {
|
|
t.x = f.x;
|
|
t.y = f.y;
|
|
t.z = f.z;
|
|
t.w = f.w;
|
|
return t;
|
|
}
|
|
function impl(seed, opts) {
|
|
var xg = new XorGen(seed), state = opts && opts.state, prng = function() {
|
|
return (xg.next() >>> 0) / 4294967296;
|
|
};
|
|
prng.double = function() {
|
|
do {
|
|
var top = xg.next() >>> 11, bot = (xg.next() >>> 0) / 4294967296, result = (top + bot) / (1 << 21);
|
|
} while (result === 0);
|
|
return result;
|
|
};
|
|
prng.int32 = xg.next;
|
|
prng.quick = prng;
|
|
if (state) {
|
|
if (typeof state == "object")
|
|
copy(state, xg);
|
|
prng.state = function() {
|
|
return copy(xg, {});
|
|
};
|
|
}
|
|
return prng;
|
|
}
|
|
if (module3 && module3.exports) {
|
|
module3.exports = impl;
|
|
} else if (define2 && define2.amd) {
|
|
define2(function() {
|
|
return impl;
|
|
});
|
|
} else {
|
|
this.xor128 = impl;
|
|
}
|
|
})(exports, typeof module2 == "object" && module2, typeof define == "function" && define);
|
|
}
|
|
});
|
|
|
|
// node_modules/seedrandom/lib/xorwow.js
|
|
var require_xorwow = __commonJS({
|
|
"node_modules/seedrandom/lib/xorwow.js"(exports, module2) {
|
|
(function(global, module3, define2) {
|
|
function XorGen(seed) {
|
|
var me = this, strseed = "";
|
|
me.next = function() {
|
|
var t = me.x ^ me.x >>> 2;
|
|
me.x = me.y;
|
|
me.y = me.z;
|
|
me.z = me.w;
|
|
me.w = me.v;
|
|
return (me.d = me.d + 362437 | 0) + (me.v = me.v ^ me.v << 4 ^ (t ^ t << 1)) | 0;
|
|
};
|
|
me.x = 0;
|
|
me.y = 0;
|
|
me.z = 0;
|
|
me.w = 0;
|
|
me.v = 0;
|
|
if (seed === (seed | 0)) {
|
|
me.x = seed;
|
|
} else {
|
|
strseed += seed;
|
|
}
|
|
for (var k = 0; k < strseed.length + 64; k++) {
|
|
me.x ^= strseed.charCodeAt(k) | 0;
|
|
if (k == strseed.length) {
|
|
me.d = me.x << 10 ^ me.x >>> 4;
|
|
}
|
|
me.next();
|
|
}
|
|
}
|
|
function copy(f, t) {
|
|
t.x = f.x;
|
|
t.y = f.y;
|
|
t.z = f.z;
|
|
t.w = f.w;
|
|
t.v = f.v;
|
|
t.d = f.d;
|
|
return t;
|
|
}
|
|
function impl(seed, opts) {
|
|
var xg = new XorGen(seed), state = opts && opts.state, prng = function() {
|
|
return (xg.next() >>> 0) / 4294967296;
|
|
};
|
|
prng.double = function() {
|
|
do {
|
|
var top = xg.next() >>> 11, bot = (xg.next() >>> 0) / 4294967296, result = (top + bot) / (1 << 21);
|
|
} while (result === 0);
|
|
return result;
|
|
};
|
|
prng.int32 = xg.next;
|
|
prng.quick = prng;
|
|
if (state) {
|
|
if (typeof state == "object")
|
|
copy(state, xg);
|
|
prng.state = function() {
|
|
return copy(xg, {});
|
|
};
|
|
}
|
|
return prng;
|
|
}
|
|
if (module3 && module3.exports) {
|
|
module3.exports = impl;
|
|
} else if (define2 && define2.amd) {
|
|
define2(function() {
|
|
return impl;
|
|
});
|
|
} else {
|
|
this.xorwow = impl;
|
|
}
|
|
})(exports, typeof module2 == "object" && module2, typeof define == "function" && define);
|
|
}
|
|
});
|
|
|
|
// node_modules/seedrandom/lib/xorshift7.js
|
|
var require_xorshift7 = __commonJS({
|
|
"node_modules/seedrandom/lib/xorshift7.js"(exports, module2) {
|
|
(function(global, module3, define2) {
|
|
function XorGen(seed) {
|
|
var me = this;
|
|
me.next = function() {
|
|
var X = me.x, i2 = me.i, t, v, w;
|
|
t = X[i2];
|
|
t ^= t >>> 7;
|
|
v = t ^ t << 24;
|
|
t = X[i2 + 1 & 7];
|
|
v ^= t ^ t >>> 10;
|
|
t = X[i2 + 3 & 7];
|
|
v ^= t ^ t >>> 3;
|
|
t = X[i2 + 4 & 7];
|
|
v ^= t ^ t << 7;
|
|
t = X[i2 + 7 & 7];
|
|
t = t ^ t << 13;
|
|
v ^= t ^ t << 9;
|
|
X[i2] = v;
|
|
me.i = i2 + 1 & 7;
|
|
return v;
|
|
};
|
|
function init(me2, seed2) {
|
|
var j, w, X = [];
|
|
if (seed2 === (seed2 | 0)) {
|
|
w = X[0] = seed2;
|
|
} else {
|
|
seed2 = "" + seed2;
|
|
for (j = 0; j < seed2.length; ++j) {
|
|
X[j & 7] = X[j & 7] << 15 ^ seed2.charCodeAt(j) + X[j + 1 & 7] << 13;
|
|
}
|
|
}
|
|
while (X.length < 8)
|
|
X.push(0);
|
|
for (j = 0; j < 8 && X[j] === 0; ++j)
|
|
;
|
|
if (j == 8)
|
|
w = X[7] = -1;
|
|
else
|
|
w = X[j];
|
|
me2.x = X;
|
|
me2.i = 0;
|
|
for (j = 256; j > 0; --j) {
|
|
me2.next();
|
|
}
|
|
}
|
|
init(me, seed);
|
|
}
|
|
function copy(f, t) {
|
|
t.x = f.x.slice();
|
|
t.i = f.i;
|
|
return t;
|
|
}
|
|
function impl(seed, opts) {
|
|
if (seed == null)
|
|
seed = +new Date();
|
|
var xg = new XorGen(seed), state = opts && opts.state, prng = function() {
|
|
return (xg.next() >>> 0) / 4294967296;
|
|
};
|
|
prng.double = function() {
|
|
do {
|
|
var top = xg.next() >>> 11, bot = (xg.next() >>> 0) / 4294967296, result = (top + bot) / (1 << 21);
|
|
} while (result === 0);
|
|
return result;
|
|
};
|
|
prng.int32 = xg.next;
|
|
prng.quick = prng;
|
|
if (state) {
|
|
if (state.x)
|
|
copy(state, xg);
|
|
prng.state = function() {
|
|
return copy(xg, {});
|
|
};
|
|
}
|
|
return prng;
|
|
}
|
|
if (module3 && module3.exports) {
|
|
module3.exports = impl;
|
|
} else if (define2 && define2.amd) {
|
|
define2(function() {
|
|
return impl;
|
|
});
|
|
} else {
|
|
this.xorshift7 = impl;
|
|
}
|
|
})(exports, typeof module2 == "object" && module2, typeof define == "function" && define);
|
|
}
|
|
});
|
|
|
|
// node_modules/seedrandom/lib/xor4096.js
|
|
var require_xor4096 = __commonJS({
|
|
"node_modules/seedrandom/lib/xor4096.js"(exports, module2) {
|
|
(function(global, module3, define2) {
|
|
function XorGen(seed) {
|
|
var me = this;
|
|
me.next = function() {
|
|
var w = me.w, X = me.X, i2 = me.i, t, v;
|
|
me.w = w = w + 1640531527 | 0;
|
|
v = X[i2 + 34 & 127];
|
|
t = X[i2 = i2 + 1 & 127];
|
|
v ^= v << 13;
|
|
t ^= t << 17;
|
|
v ^= v >>> 15;
|
|
t ^= t >>> 12;
|
|
v = X[i2] = v ^ t;
|
|
me.i = i2;
|
|
return v + (w ^ w >>> 16) | 0;
|
|
};
|
|
function init(me2, seed2) {
|
|
var t, v, i2, j, w, X = [], limit = 128;
|
|
if (seed2 === (seed2 | 0)) {
|
|
v = seed2;
|
|
seed2 = null;
|
|
} else {
|
|
seed2 = seed2 + "\0";
|
|
v = 0;
|
|
limit = Math.max(limit, seed2.length);
|
|
}
|
|
for (i2 = 0, j = -32; j < limit; ++j) {
|
|
if (seed2)
|
|
v ^= seed2.charCodeAt((j + 32) % seed2.length);
|
|
if (j === 0)
|
|
w = v;
|
|
v ^= v << 10;
|
|
v ^= v >>> 15;
|
|
v ^= v << 4;
|
|
v ^= v >>> 13;
|
|
if (j >= 0) {
|
|
w = w + 1640531527 | 0;
|
|
t = X[j & 127] ^= v + w;
|
|
i2 = t == 0 ? i2 + 1 : 0;
|
|
}
|
|
}
|
|
if (i2 >= 128) {
|
|
X[(seed2 && seed2.length || 0) & 127] = -1;
|
|
}
|
|
i2 = 127;
|
|
for (j = 4 * 128; j > 0; --j) {
|
|
v = X[i2 + 34 & 127];
|
|
t = X[i2 = i2 + 1 & 127];
|
|
v ^= v << 13;
|
|
t ^= t << 17;
|
|
v ^= v >>> 15;
|
|
t ^= t >>> 12;
|
|
X[i2] = v ^ t;
|
|
}
|
|
me2.w = w;
|
|
me2.X = X;
|
|
me2.i = i2;
|
|
}
|
|
init(me, seed);
|
|
}
|
|
function copy(f, t) {
|
|
t.i = f.i;
|
|
t.w = f.w;
|
|
t.X = f.X.slice();
|
|
return t;
|
|
}
|
|
;
|
|
function impl(seed, opts) {
|
|
if (seed == null)
|
|
seed = +new Date();
|
|
var xg = new XorGen(seed), state = opts && opts.state, prng = function() {
|
|
return (xg.next() >>> 0) / 4294967296;
|
|
};
|
|
prng.double = function() {
|
|
do {
|
|
var top = xg.next() >>> 11, bot = (xg.next() >>> 0) / 4294967296, result = (top + bot) / (1 << 21);
|
|
} while (result === 0);
|
|
return result;
|
|
};
|
|
prng.int32 = xg.next;
|
|
prng.quick = prng;
|
|
if (state) {
|
|
if (state.X)
|
|
copy(state, xg);
|
|
prng.state = function() {
|
|
return copy(xg, {});
|
|
};
|
|
}
|
|
return prng;
|
|
}
|
|
if (module3 && module3.exports) {
|
|
module3.exports = impl;
|
|
} else if (define2 && define2.amd) {
|
|
define2(function() {
|
|
return impl;
|
|
});
|
|
} else {
|
|
this.xor4096 = impl;
|
|
}
|
|
})(exports, typeof module2 == "object" && module2, typeof define == "function" && define);
|
|
}
|
|
});
|
|
|
|
// node_modules/seedrandom/lib/tychei.js
|
|
var require_tychei = __commonJS({
|
|
"node_modules/seedrandom/lib/tychei.js"(exports, module2) {
|
|
(function(global, module3, define2) {
|
|
function XorGen(seed) {
|
|
var me = this, strseed = "";
|
|
me.next = function() {
|
|
var b = me.b, c = me.c, d = me.d, a = me.a;
|
|
b = b << 25 ^ b >>> 7 ^ c;
|
|
c = c - d | 0;
|
|
d = d << 24 ^ d >>> 8 ^ a;
|
|
a = a - b | 0;
|
|
me.b = b = b << 20 ^ b >>> 12 ^ c;
|
|
me.c = c = c - d | 0;
|
|
me.d = d << 16 ^ c >>> 16 ^ a;
|
|
return me.a = a - b | 0;
|
|
};
|
|
me.a = 0;
|
|
me.b = 0;
|
|
me.c = 2654435769 | 0;
|
|
me.d = 1367130551;
|
|
if (seed === Math.floor(seed)) {
|
|
me.a = seed / 4294967296 | 0;
|
|
me.b = seed | 0;
|
|
} else {
|
|
strseed += seed;
|
|
}
|
|
for (var k = 0; k < strseed.length + 20; k++) {
|
|
me.b ^= strseed.charCodeAt(k) | 0;
|
|
me.next();
|
|
}
|
|
}
|
|
function copy(f, t) {
|
|
t.a = f.a;
|
|
t.b = f.b;
|
|
t.c = f.c;
|
|
t.d = f.d;
|
|
return t;
|
|
}
|
|
;
|
|
function impl(seed, opts) {
|
|
var xg = new XorGen(seed), state = opts && opts.state, prng = function() {
|
|
return (xg.next() >>> 0) / 4294967296;
|
|
};
|
|
prng.double = function() {
|
|
do {
|
|
var top = xg.next() >>> 11, bot = (xg.next() >>> 0) / 4294967296, result = (top + bot) / (1 << 21);
|
|
} while (result === 0);
|
|
return result;
|
|
};
|
|
prng.int32 = xg.next;
|
|
prng.quick = prng;
|
|
if (state) {
|
|
if (typeof state == "object")
|
|
copy(state, xg);
|
|
prng.state = function() {
|
|
return copy(xg, {});
|
|
};
|
|
}
|
|
return prng;
|
|
}
|
|
if (module3 && module3.exports) {
|
|
module3.exports = impl;
|
|
} else if (define2 && define2.amd) {
|
|
define2(function() {
|
|
return impl;
|
|
});
|
|
} else {
|
|
this.tychei = impl;
|
|
}
|
|
})(exports, typeof module2 == "object" && module2, typeof define == "function" && define);
|
|
}
|
|
});
|
|
|
|
// node_modules/seedrandom/seedrandom.js
|
|
var require_seedrandom = __commonJS({
|
|
"node_modules/seedrandom/seedrandom.js"(exports, module2) {
|
|
(function(global, pool, math2) {
|
|
var width = 256, chunks = 6, digits2 = 52, rngname = "random", startdenom = math2.pow(width, chunks), significance = math2.pow(2, digits2), overflow = significance * 2, mask = width - 1, nodecrypto;
|
|
function seedrandom2(seed, options, callback) {
|
|
var key = [];
|
|
options = options == true ? { entropy: true } : options || {};
|
|
var shortseed = mixkey(flatten3(options.entropy ? [seed, tostring(pool)] : seed == null ? autoseed() : seed, 3), key);
|
|
var arc4 = new ARC4(key);
|
|
var prng = function() {
|
|
var n = arc4.g(chunks), d = startdenom, x = 0;
|
|
while (n < significance) {
|
|
n = (n + x) * width;
|
|
d *= width;
|
|
x = arc4.g(1);
|
|
}
|
|
while (n >= overflow) {
|
|
n /= 2;
|
|
d /= 2;
|
|
x >>>= 1;
|
|
}
|
|
return (n + x) / d;
|
|
};
|
|
prng.int32 = function() {
|
|
return arc4.g(4) | 0;
|
|
};
|
|
prng.quick = function() {
|
|
return arc4.g(4) / 4294967296;
|
|
};
|
|
prng.double = prng;
|
|
mixkey(tostring(arc4.S), pool);
|
|
return (options.pass || callback || function(prng2, seed2, is_math_call, state) {
|
|
if (state) {
|
|
if (state.S) {
|
|
copy(state, arc4);
|
|
}
|
|
prng2.state = function() {
|
|
return copy(arc4, {});
|
|
};
|
|
}
|
|
if (is_math_call) {
|
|
math2[rngname] = prng2;
|
|
return seed2;
|
|
} else
|
|
return prng2;
|
|
})(prng, shortseed, "global" in options ? options.global : this == math2, options.state);
|
|
}
|
|
function ARC4(key) {
|
|
var t, keylen = key.length, me = this, i2 = 0, j = me.i = me.j = 0, s = me.S = [];
|
|
if (!keylen) {
|
|
key = [keylen++];
|
|
}
|
|
while (i2 < width) {
|
|
s[i2] = i2++;
|
|
}
|
|
for (i2 = 0; i2 < width; i2++) {
|
|
s[i2] = s[j = mask & j + key[i2 % keylen] + (t = s[i2])];
|
|
s[j] = t;
|
|
}
|
|
(me.g = function(count2) {
|
|
var t2, r = 0, i3 = me.i, j2 = me.j, s2 = me.S;
|
|
while (count2--) {
|
|
t2 = s2[i3 = mask & i3 + 1];
|
|
r = r * width + s2[mask & (s2[i3] = s2[j2 = mask & j2 + t2]) + (s2[j2] = t2)];
|
|
}
|
|
me.i = i3;
|
|
me.j = j2;
|
|
return r;
|
|
})(width);
|
|
}
|
|
function copy(f, t) {
|
|
t.i = f.i;
|
|
t.j = f.j;
|
|
t.S = f.S.slice();
|
|
return t;
|
|
}
|
|
;
|
|
function flatten3(obj, depth) {
|
|
var result = [], typ = typeof obj, prop;
|
|
if (depth && typ == "object") {
|
|
for (prop in obj) {
|
|
try {
|
|
result.push(flatten3(obj[prop], depth - 1));
|
|
} catch (e3) {
|
|
}
|
|
}
|
|
}
|
|
return result.length ? result : typ == "string" ? obj : obj + "\0";
|
|
}
|
|
function mixkey(seed, key) {
|
|
var stringseed = seed + "", smear, j = 0;
|
|
while (j < stringseed.length) {
|
|
key[mask & j] = mask & (smear ^= key[mask & j] * 19) + stringseed.charCodeAt(j++);
|
|
}
|
|
return tostring(key);
|
|
}
|
|
function autoseed() {
|
|
try {
|
|
var out;
|
|
if (nodecrypto && (out = nodecrypto.randomBytes)) {
|
|
out = out(width);
|
|
} else {
|
|
out = new Uint8Array(width);
|
|
(global.crypto || global.msCrypto).getRandomValues(out);
|
|
}
|
|
return tostring(out);
|
|
} catch (e3) {
|
|
var browser = global.navigator, plugins = browser && browser.plugins;
|
|
return [+new Date(), global, plugins, global.screen, tostring(pool)];
|
|
}
|
|
}
|
|
function tostring(a) {
|
|
return String.fromCharCode.apply(0, a);
|
|
}
|
|
mixkey(math2.random(), pool);
|
|
if (typeof module2 == "object" && module2.exports) {
|
|
module2.exports = seedrandom2;
|
|
try {
|
|
nodecrypto = require("crypto");
|
|
} catch (ex) {
|
|
}
|
|
} else if (typeof define == "function" && define.amd) {
|
|
define(function() {
|
|
return seedrandom2;
|
|
});
|
|
} else {
|
|
math2["seed" + rngname] = seedrandom2;
|
|
}
|
|
})(typeof self !== "undefined" ? self : exports, [], Math);
|
|
}
|
|
});
|
|
|
|
// node_modules/seedrandom/index.js
|
|
var require_seedrandom2 = __commonJS({
|
|
"node_modules/seedrandom/index.js"(exports, module2) {
|
|
var alea = require_alea();
|
|
var xor128 = require_xor128();
|
|
var xorwow = require_xorwow();
|
|
var xorshift7 = require_xorshift7();
|
|
var xor4096 = require_xor4096();
|
|
var tychei = require_tychei();
|
|
var sr = require_seedrandom();
|
|
sr.alea = alea;
|
|
sr.xor128 = xor128;
|
|
sr.xorwow = xorwow;
|
|
sr.xorshift7 = xorshift7;
|
|
sr.xor4096 = xor4096;
|
|
sr.tychei = tychei;
|
|
module2.exports = sr;
|
|
}
|
|
});
|
|
|
|
// main.ts
|
|
var main_exports = {};
|
|
__export(main_exports, {
|
|
default: () => NumeralsPlugin
|
|
});
|
|
module.exports = __toCommonJS(main_exports);
|
|
var import_obsidian = require("obsidian");
|
|
|
|
// node_modules/@babel/runtime/helpers/esm/extends.js
|
|
function _extends() {
|
|
_extends = Object.assign ? Object.assign.bind() : function(target) {
|
|
for (var i2 = 1; i2 < arguments.length; i2++) {
|
|
var source = arguments[i2];
|
|
for (var key in source) {
|
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
target[key] = source[key];
|
|
}
|
|
}
|
|
}
|
|
return target;
|
|
};
|
|
return _extends.apply(this, arguments);
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/core/config.js
|
|
var DEFAULT_CONFIG = {
|
|
epsilon: 1e-12,
|
|
matrix: "Matrix",
|
|
number: "number",
|
|
precision: 64,
|
|
predictable: false,
|
|
randomSeed: null
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/utils/is.js
|
|
function isNumber(x) {
|
|
return typeof x === "number";
|
|
}
|
|
function isBigNumber(x) {
|
|
if (!x || typeof x !== "object" || typeof x.constructor !== "function") {
|
|
return false;
|
|
}
|
|
if (x.isBigNumber === true && typeof x.constructor.prototype === "object" && x.constructor.prototype.isBigNumber === true) {
|
|
return true;
|
|
}
|
|
if (typeof x.constructor.isDecimal === "function" && x.constructor.isDecimal(x) === true) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
function isComplex(x) {
|
|
return x && typeof x === "object" && Object.getPrototypeOf(x).isComplex === true || false;
|
|
}
|
|
function isFraction(x) {
|
|
return x && typeof x === "object" && Object.getPrototypeOf(x).isFraction === true || false;
|
|
}
|
|
function isUnit(x) {
|
|
return x && x.constructor.prototype.isUnit === true || false;
|
|
}
|
|
function isString(x) {
|
|
return typeof x === "string";
|
|
}
|
|
var isArray = Array.isArray;
|
|
function isMatrix(x) {
|
|
return x && x.constructor.prototype.isMatrix === true || false;
|
|
}
|
|
function isCollection(x) {
|
|
return Array.isArray(x) || isMatrix(x);
|
|
}
|
|
function isDenseMatrix(x) {
|
|
return x && x.isDenseMatrix && x.constructor.prototype.isMatrix === true || false;
|
|
}
|
|
function isSparseMatrix(x) {
|
|
return x && x.isSparseMatrix && x.constructor.prototype.isMatrix === true || false;
|
|
}
|
|
function isRange(x) {
|
|
return x && x.constructor.prototype.isRange === true || false;
|
|
}
|
|
function isIndex(x) {
|
|
return x && x.constructor.prototype.isIndex === true || false;
|
|
}
|
|
function isBoolean(x) {
|
|
return typeof x === "boolean";
|
|
}
|
|
function isResultSet(x) {
|
|
return x && x.constructor.prototype.isResultSet === true || false;
|
|
}
|
|
function isHelp(x) {
|
|
return x && x.constructor.prototype.isHelp === true || false;
|
|
}
|
|
function isFunction(x) {
|
|
return typeof x === "function";
|
|
}
|
|
function isDate(x) {
|
|
return x instanceof Date;
|
|
}
|
|
function isRegExp(x) {
|
|
return x instanceof RegExp;
|
|
}
|
|
function isObject(x) {
|
|
return !!(x && typeof x === "object" && x.constructor === Object && !isComplex(x) && !isFraction(x));
|
|
}
|
|
function isNull(x) {
|
|
return x === null;
|
|
}
|
|
function isUndefined(x) {
|
|
return x === void 0;
|
|
}
|
|
function isAccessorNode(x) {
|
|
return x && x.isAccessorNode === true && x.constructor.prototype.isNode === true || false;
|
|
}
|
|
function isArrayNode(x) {
|
|
return x && x.isArrayNode === true && x.constructor.prototype.isNode === true || false;
|
|
}
|
|
function isAssignmentNode(x) {
|
|
return x && x.isAssignmentNode === true && x.constructor.prototype.isNode === true || false;
|
|
}
|
|
function isBlockNode(x) {
|
|
return x && x.isBlockNode === true && x.constructor.prototype.isNode === true || false;
|
|
}
|
|
function isConditionalNode(x) {
|
|
return x && x.isConditionalNode === true && x.constructor.prototype.isNode === true || false;
|
|
}
|
|
function isConstantNode(x) {
|
|
return x && x.isConstantNode === true && x.constructor.prototype.isNode === true || false;
|
|
}
|
|
function rule2Node(node) {
|
|
return isConstantNode(node) || isOperatorNode(node) && node.args.length === 1 && isConstantNode(node.args[0]) && "-+~".includes(node.op);
|
|
}
|
|
function isFunctionAssignmentNode(x) {
|
|
return x && x.isFunctionAssignmentNode === true && x.constructor.prototype.isNode === true || false;
|
|
}
|
|
function isFunctionNode(x) {
|
|
return x && x.isFunctionNode === true && x.constructor.prototype.isNode === true || false;
|
|
}
|
|
function isIndexNode(x) {
|
|
return x && x.isIndexNode === true && x.constructor.prototype.isNode === true || false;
|
|
}
|
|
function isNode(x) {
|
|
return x && x.isNode === true && x.constructor.prototype.isNode === true || false;
|
|
}
|
|
function isObjectNode(x) {
|
|
return x && x.isObjectNode === true && x.constructor.prototype.isNode === true || false;
|
|
}
|
|
function isOperatorNode(x) {
|
|
return x && x.isOperatorNode === true && x.constructor.prototype.isNode === true || false;
|
|
}
|
|
function isParenthesisNode(x) {
|
|
return x && x.isParenthesisNode === true && x.constructor.prototype.isNode === true || false;
|
|
}
|
|
function isRangeNode(x) {
|
|
return x && x.isRangeNode === true && x.constructor.prototype.isNode === true || false;
|
|
}
|
|
function isRelationalNode(x) {
|
|
return x && x.isRelationalNode === true && x.constructor.prototype.isNode === true || false;
|
|
}
|
|
function isSymbolNode(x) {
|
|
return x && x.isSymbolNode === true && x.constructor.prototype.isNode === true || false;
|
|
}
|
|
function isChain(x) {
|
|
return x && x.constructor.prototype.isChain === true || false;
|
|
}
|
|
function typeOf(x) {
|
|
var t = typeof x;
|
|
if (t === "object") {
|
|
if (x === null)
|
|
return "null";
|
|
if (isBigNumber(x))
|
|
return "BigNumber";
|
|
if (x.constructor && x.constructor.name)
|
|
return x.constructor.name;
|
|
return "Object";
|
|
}
|
|
return t;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/utils/object.js
|
|
function clone(x) {
|
|
var type = typeof x;
|
|
if (type === "number" || type === "string" || type === "boolean" || x === null || x === void 0) {
|
|
return x;
|
|
}
|
|
if (typeof x.clone === "function") {
|
|
return x.clone();
|
|
}
|
|
if (Array.isArray(x)) {
|
|
return x.map(function(value) {
|
|
return clone(value);
|
|
});
|
|
}
|
|
if (x instanceof Date)
|
|
return new Date(x.valueOf());
|
|
if (isBigNumber(x))
|
|
return x;
|
|
if (x instanceof RegExp)
|
|
throw new TypeError("Cannot clone " + x);
|
|
return mapObject(x, clone);
|
|
}
|
|
function mapObject(object, callback) {
|
|
var clone4 = {};
|
|
for (var key in object) {
|
|
if (hasOwnProperty2(object, key)) {
|
|
clone4[key] = callback(object[key]);
|
|
}
|
|
}
|
|
return clone4;
|
|
}
|
|
function extend(a, b) {
|
|
for (var prop in b) {
|
|
if (hasOwnProperty2(b, prop)) {
|
|
a[prop] = b[prop];
|
|
}
|
|
}
|
|
return a;
|
|
}
|
|
function deepStrictEqual(a, b) {
|
|
var prop, i2, len;
|
|
if (Array.isArray(a)) {
|
|
if (!Array.isArray(b)) {
|
|
return false;
|
|
}
|
|
if (a.length !== b.length) {
|
|
return false;
|
|
}
|
|
for (i2 = 0, len = a.length; i2 < len; i2++) {
|
|
if (!deepStrictEqual(a[i2], b[i2])) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
} else if (typeof a === "function") {
|
|
return a === b;
|
|
} else if (a instanceof Object) {
|
|
if (Array.isArray(b) || !(b instanceof Object)) {
|
|
return false;
|
|
}
|
|
for (prop in a) {
|
|
if (!(prop in b) || !deepStrictEqual(a[prop], b[prop])) {
|
|
return false;
|
|
}
|
|
}
|
|
for (prop in b) {
|
|
if (!(prop in a)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
} else {
|
|
return a === b;
|
|
}
|
|
}
|
|
function lazy(object, prop, valueResolver) {
|
|
var _uninitialized = true;
|
|
var _value;
|
|
Object.defineProperty(object, prop, {
|
|
get: function get() {
|
|
if (_uninitialized) {
|
|
_value = valueResolver();
|
|
_uninitialized = false;
|
|
}
|
|
return _value;
|
|
},
|
|
set: function set(value) {
|
|
_value = value;
|
|
_uninitialized = false;
|
|
},
|
|
configurable: true,
|
|
enumerable: true
|
|
});
|
|
}
|
|
function hasOwnProperty2(object, property) {
|
|
return object && Object.hasOwnProperty.call(object, property);
|
|
}
|
|
function pickShallow(object, properties2) {
|
|
var copy = {};
|
|
for (var i2 = 0; i2 < properties2.length; i2++) {
|
|
var key = properties2[i2];
|
|
var value = object[key];
|
|
if (value !== void 0) {
|
|
copy[key] = value;
|
|
}
|
|
}
|
|
return copy;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/core/function/config.js
|
|
var MATRIX_OPTIONS = ["Matrix", "Array"];
|
|
var NUMBER_OPTIONS = ["number", "BigNumber", "Fraction"];
|
|
|
|
// node_modules/mathjs/lib/esm/entry/configReadonly.js
|
|
var config = function config2(options) {
|
|
if (options) {
|
|
throw new Error("The global config is readonly. \nPlease create a mathjs instance if you want to change the default configuration. \nExample:\n\n import { create, all } from 'mathjs';\n const mathjs = create(all);\n mathjs.config({ number: 'BigNumber' });\n");
|
|
}
|
|
return Object.freeze(DEFAULT_CONFIG);
|
|
};
|
|
_extends(config, DEFAULT_CONFIG, {
|
|
MATRIX_OPTIONS,
|
|
NUMBER_OPTIONS
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/core/function/typed.js
|
|
var import_typed_function = __toESM(require_typed_function(), 1);
|
|
|
|
// node_modules/mathjs/lib/esm/utils/number.js
|
|
function isInteger(value) {
|
|
if (typeof value === "boolean") {
|
|
return true;
|
|
}
|
|
return isFinite(value) ? value === Math.round(value) : false;
|
|
}
|
|
var sign = Math.sign || function(x) {
|
|
if (x > 0) {
|
|
return 1;
|
|
} else if (x < 0) {
|
|
return -1;
|
|
} else {
|
|
return 0;
|
|
}
|
|
};
|
|
var log2 = Math.log2 || function log22(x) {
|
|
return Math.log(x) / Math.LN2;
|
|
};
|
|
var log10 = Math.log10 || function log102(x) {
|
|
return Math.log(x) / Math.LN10;
|
|
};
|
|
var log1p = Math.log1p || function(x) {
|
|
return Math.log(x + 1);
|
|
};
|
|
var cbrt = Math.cbrt || function cbrt2(x) {
|
|
if (x === 0) {
|
|
return x;
|
|
}
|
|
var negate = x < 0;
|
|
var result;
|
|
if (negate) {
|
|
x = -x;
|
|
}
|
|
if (isFinite(x)) {
|
|
result = Math.exp(Math.log(x) / 3);
|
|
result = (x / (result * result) + 2 * result) / 3;
|
|
} else {
|
|
result = x;
|
|
}
|
|
return negate ? -result : result;
|
|
};
|
|
var expm1 = Math.expm1 || function expm12(x) {
|
|
return x >= 2e-4 || x <= -2e-4 ? Math.exp(x) - 1 : x + x * x / 2 + x * x * x / 6;
|
|
};
|
|
function formatNumberToBase(n, base, size2) {
|
|
var prefixes = {
|
|
2: "0b",
|
|
8: "0o",
|
|
16: "0x"
|
|
};
|
|
var prefix = prefixes[base];
|
|
var suffix = "";
|
|
if (size2) {
|
|
if (size2 < 1) {
|
|
throw new Error("size must be in greater than 0");
|
|
}
|
|
if (!isInteger(size2)) {
|
|
throw new Error("size must be an integer");
|
|
}
|
|
if (n > 2 ** (size2 - 1) - 1 || n < -(2 ** (size2 - 1))) {
|
|
throw new Error("Value must be in range [-2^".concat(size2 - 1, ", 2^").concat(size2 - 1, "-1]"));
|
|
}
|
|
if (!isInteger(n)) {
|
|
throw new Error("Value must be an integer");
|
|
}
|
|
if (n < 0) {
|
|
n = n + 2 ** size2;
|
|
}
|
|
suffix = "i".concat(size2);
|
|
}
|
|
var sign4 = "";
|
|
if (n < 0) {
|
|
n = -n;
|
|
sign4 = "-";
|
|
}
|
|
return "".concat(sign4).concat(prefix).concat(n.toString(base)).concat(suffix);
|
|
}
|
|
function format(value, options) {
|
|
if (typeof options === "function") {
|
|
return options(value);
|
|
}
|
|
if (value === Infinity) {
|
|
return "Infinity";
|
|
} else if (value === -Infinity) {
|
|
return "-Infinity";
|
|
} else if (isNaN(value)) {
|
|
return "NaN";
|
|
}
|
|
var notation = "auto";
|
|
var precision;
|
|
var wordSize;
|
|
if (options) {
|
|
if (options.notation) {
|
|
notation = options.notation;
|
|
}
|
|
if (isNumber(options)) {
|
|
precision = options;
|
|
} else if (isNumber(options.precision)) {
|
|
precision = options.precision;
|
|
}
|
|
if (options.wordSize) {
|
|
wordSize = options.wordSize;
|
|
if (typeof wordSize !== "number") {
|
|
throw new Error('Option "wordSize" must be a number');
|
|
}
|
|
}
|
|
}
|
|
switch (notation) {
|
|
case "fixed":
|
|
return toFixed(value, precision);
|
|
case "exponential":
|
|
return toExponential(value, precision);
|
|
case "engineering":
|
|
return toEngineering(value, precision);
|
|
case "bin":
|
|
return formatNumberToBase(value, 2, wordSize);
|
|
case "oct":
|
|
return formatNumberToBase(value, 8, wordSize);
|
|
case "hex":
|
|
return formatNumberToBase(value, 16, wordSize);
|
|
case "auto":
|
|
return toPrecision(value, precision, options && options).replace(/((\.\d*?)(0+))($|e)/, function() {
|
|
var digits2 = arguments[2];
|
|
var e3 = arguments[4];
|
|
return digits2 !== "." ? digits2 + e3 : e3;
|
|
});
|
|
default:
|
|
throw new Error('Unknown notation "' + notation + '". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.');
|
|
}
|
|
}
|
|
function splitNumber(value) {
|
|
var match = String(value).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);
|
|
if (!match) {
|
|
throw new SyntaxError("Invalid number " + value);
|
|
}
|
|
var sign4 = match[1];
|
|
var digits2 = match[2];
|
|
var exponent = parseFloat(match[4] || "0");
|
|
var dot2 = digits2.indexOf(".");
|
|
exponent += dot2 !== -1 ? dot2 - 1 : digits2.length - 1;
|
|
var coefficients = digits2.replace(".", "").replace(/^0*/, function(zeros3) {
|
|
exponent -= zeros3.length;
|
|
return "";
|
|
}).replace(/0*$/, "").split("").map(function(d) {
|
|
return parseInt(d);
|
|
});
|
|
if (coefficients.length === 0) {
|
|
coefficients.push(0);
|
|
exponent++;
|
|
}
|
|
return {
|
|
sign: sign4,
|
|
coefficients,
|
|
exponent
|
|
};
|
|
}
|
|
function toEngineering(value, precision) {
|
|
if (isNaN(value) || !isFinite(value)) {
|
|
return String(value);
|
|
}
|
|
var split = splitNumber(value);
|
|
var rounded = roundDigits(split, precision);
|
|
var e3 = rounded.exponent;
|
|
var c = rounded.coefficients;
|
|
var newExp = e3 % 3 === 0 ? e3 : e3 < 0 ? e3 - 3 - e3 % 3 : e3 - e3 % 3;
|
|
if (isNumber(precision)) {
|
|
while (precision > c.length || e3 - newExp + 1 > c.length) {
|
|
c.push(0);
|
|
}
|
|
} else {
|
|
var missingZeros = Math.abs(e3 - newExp) - (c.length - 1);
|
|
for (var i2 = 0; i2 < missingZeros; i2++) {
|
|
c.push(0);
|
|
}
|
|
}
|
|
var expDiff = Math.abs(e3 - newExp);
|
|
var decimalIdx = 1;
|
|
while (expDiff > 0) {
|
|
decimalIdx++;
|
|
expDiff--;
|
|
}
|
|
var decimals = c.slice(decimalIdx).join("");
|
|
var decimalVal = isNumber(precision) && decimals.length || decimals.match(/[1-9]/) ? "." + decimals : "";
|
|
var str = c.slice(0, decimalIdx).join("") + decimalVal + "e" + (e3 >= 0 ? "+" : "") + newExp.toString();
|
|
return rounded.sign + str;
|
|
}
|
|
function toFixed(value, precision) {
|
|
if (isNaN(value) || !isFinite(value)) {
|
|
return String(value);
|
|
}
|
|
var splitValue = splitNumber(value);
|
|
var rounded = typeof precision === "number" ? roundDigits(splitValue, splitValue.exponent + 1 + precision) : splitValue;
|
|
var c = rounded.coefficients;
|
|
var p = rounded.exponent + 1;
|
|
var pp = p + (precision || 0);
|
|
if (c.length < pp) {
|
|
c = c.concat(zeros(pp - c.length));
|
|
}
|
|
if (p < 0) {
|
|
c = zeros(-p + 1).concat(c);
|
|
p = 1;
|
|
}
|
|
if (p < c.length) {
|
|
c.splice(p, 0, p === 0 ? "0." : ".");
|
|
}
|
|
return rounded.sign + c.join("");
|
|
}
|
|
function toExponential(value, precision) {
|
|
if (isNaN(value) || !isFinite(value)) {
|
|
return String(value);
|
|
}
|
|
var split = splitNumber(value);
|
|
var rounded = precision ? roundDigits(split, precision) : split;
|
|
var c = rounded.coefficients;
|
|
var e3 = rounded.exponent;
|
|
if (c.length < precision) {
|
|
c = c.concat(zeros(precision - c.length));
|
|
}
|
|
var first = c.shift();
|
|
return rounded.sign + first + (c.length > 0 ? "." + c.join("") : "") + "e" + (e3 >= 0 ? "+" : "") + e3;
|
|
}
|
|
function toPrecision(value, precision, options) {
|
|
if (isNaN(value) || !isFinite(value)) {
|
|
return String(value);
|
|
}
|
|
var lowerExp = options && options.lowerExp !== void 0 ? options.lowerExp : -3;
|
|
var upperExp = options && options.upperExp !== void 0 ? options.upperExp : 5;
|
|
var split = splitNumber(value);
|
|
var rounded = precision ? roundDigits(split, precision) : split;
|
|
if (rounded.exponent < lowerExp || rounded.exponent >= upperExp) {
|
|
return toExponential(value, precision);
|
|
} else {
|
|
var c = rounded.coefficients;
|
|
var e3 = rounded.exponent;
|
|
if (c.length < precision) {
|
|
c = c.concat(zeros(precision - c.length));
|
|
}
|
|
c = c.concat(zeros(e3 - c.length + 1 + (c.length < precision ? precision - c.length : 0)));
|
|
c = zeros(-e3).concat(c);
|
|
var dot2 = e3 > 0 ? e3 : 0;
|
|
if (dot2 < c.length - 1) {
|
|
c.splice(dot2 + 1, 0, ".");
|
|
}
|
|
return rounded.sign + c.join("");
|
|
}
|
|
}
|
|
function roundDigits(split, precision) {
|
|
var rounded = {
|
|
sign: split.sign,
|
|
coefficients: split.coefficients,
|
|
exponent: split.exponent
|
|
};
|
|
var c = rounded.coefficients;
|
|
while (precision <= 0) {
|
|
c.unshift(0);
|
|
rounded.exponent++;
|
|
precision++;
|
|
}
|
|
if (c.length > precision) {
|
|
var removed = c.splice(precision, c.length - precision);
|
|
if (removed[0] >= 5) {
|
|
var i2 = precision - 1;
|
|
c[i2]++;
|
|
while (c[i2] === 10) {
|
|
c.pop();
|
|
if (i2 === 0) {
|
|
c.unshift(0);
|
|
rounded.exponent++;
|
|
i2++;
|
|
}
|
|
i2--;
|
|
c[i2]++;
|
|
}
|
|
}
|
|
}
|
|
return rounded;
|
|
}
|
|
function zeros(length) {
|
|
var arr = [];
|
|
for (var i2 = 0; i2 < length; i2++) {
|
|
arr.push(0);
|
|
}
|
|
return arr;
|
|
}
|
|
function digits(value) {
|
|
return value.toExponential().replace(/e.*$/, "").replace(/^0\.?0*|\./, "").length;
|
|
}
|
|
var DBL_EPSILON = Number.EPSILON || 2220446049250313e-31;
|
|
function nearlyEqual(x, y, epsilon) {
|
|
if (epsilon === null || epsilon === void 0) {
|
|
return x === y;
|
|
}
|
|
if (x === y) {
|
|
return true;
|
|
}
|
|
if (isNaN(x) || isNaN(y)) {
|
|
return false;
|
|
}
|
|
if (isFinite(x) && isFinite(y)) {
|
|
var diff2 = Math.abs(x - y);
|
|
if (diff2 < DBL_EPSILON) {
|
|
return true;
|
|
} else {
|
|
return diff2 <= Math.max(Math.abs(x), Math.abs(y)) * epsilon;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
var acosh = Math.acosh || function(x) {
|
|
return Math.log(Math.sqrt(x * x - 1) + x);
|
|
};
|
|
var asinh = Math.asinh || function(x) {
|
|
return Math.log(Math.sqrt(x * x + 1) + x);
|
|
};
|
|
var atanh = Math.atanh || function(x) {
|
|
return Math.log((1 + x) / (1 - x)) / 2;
|
|
};
|
|
var cosh = Math.cosh || function(x) {
|
|
return (Math.exp(x) + Math.exp(-x)) / 2;
|
|
};
|
|
var sinh = Math.sinh || function(x) {
|
|
return (Math.exp(x) - Math.exp(-x)) / 2;
|
|
};
|
|
var tanh = Math.tanh || function(x) {
|
|
var e3 = Math.exp(2 * x);
|
|
return (e3 - 1) / (e3 + 1);
|
|
};
|
|
function copysign(x, y) {
|
|
var signx = x > 0 ? true : x < 0 ? false : 1 / x === Infinity;
|
|
var signy = y > 0 ? true : y < 0 ? false : 1 / y === Infinity;
|
|
return signx ^ signy ? -x : x;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/utils/bignumber/formatter.js
|
|
function formatBigNumberToBase(n, base, size2) {
|
|
var BigNumberCtor = n.constructor;
|
|
var big2 = new BigNumberCtor(2);
|
|
var suffix = "";
|
|
if (size2) {
|
|
if (size2 < 1) {
|
|
throw new Error("size must be in greater than 0");
|
|
}
|
|
if (!isInteger(size2)) {
|
|
throw new Error("size must be an integer");
|
|
}
|
|
if (n.greaterThan(big2.pow(size2 - 1).sub(1)) || n.lessThan(big2.pow(size2 - 1).mul(-1))) {
|
|
throw new Error("Value must be in range [-2^".concat(size2 - 1, ", 2^").concat(size2 - 1, "-1]"));
|
|
}
|
|
if (!n.isInteger()) {
|
|
throw new Error("Value must be an integer");
|
|
}
|
|
if (n.lessThan(0)) {
|
|
n = n.add(big2.pow(size2));
|
|
}
|
|
suffix = "i".concat(size2);
|
|
}
|
|
switch (base) {
|
|
case 2:
|
|
return "".concat(n.toBinary()).concat(suffix);
|
|
case 8:
|
|
return "".concat(n.toOctal()).concat(suffix);
|
|
case 16:
|
|
return "".concat(n.toHexadecimal()).concat(suffix);
|
|
default:
|
|
throw new Error("Base ".concat(base, " not supported "));
|
|
}
|
|
}
|
|
function format2(value, options) {
|
|
if (typeof options === "function") {
|
|
return options(value);
|
|
}
|
|
if (!value.isFinite()) {
|
|
return value.isNaN() ? "NaN" : value.gt(0) ? "Infinity" : "-Infinity";
|
|
}
|
|
var notation = "auto";
|
|
var precision;
|
|
var wordSize;
|
|
if (options !== void 0) {
|
|
if (options.notation) {
|
|
notation = options.notation;
|
|
}
|
|
if (typeof options === "number") {
|
|
precision = options;
|
|
} else if (options.precision) {
|
|
precision = options.precision;
|
|
}
|
|
if (options.wordSize) {
|
|
wordSize = options.wordSize;
|
|
if (typeof wordSize !== "number") {
|
|
throw new Error('Option "wordSize" must be a number');
|
|
}
|
|
}
|
|
}
|
|
switch (notation) {
|
|
case "fixed":
|
|
return toFixed2(value, precision);
|
|
case "exponential":
|
|
return toExponential2(value, precision);
|
|
case "engineering":
|
|
return toEngineering2(value, precision);
|
|
case "bin":
|
|
return formatBigNumberToBase(value, 2, wordSize);
|
|
case "oct":
|
|
return formatBigNumberToBase(value, 8, wordSize);
|
|
case "hex":
|
|
return formatBigNumberToBase(value, 16, wordSize);
|
|
case "auto": {
|
|
var lowerExp = options && options.lowerExp !== void 0 ? options.lowerExp : -3;
|
|
var upperExp = options && options.upperExp !== void 0 ? options.upperExp : 5;
|
|
if (value.isZero())
|
|
return "0";
|
|
var str;
|
|
var rounded = value.toSignificantDigits(precision);
|
|
var exp3 = rounded.e;
|
|
if (exp3 >= lowerExp && exp3 < upperExp) {
|
|
str = rounded.toFixed();
|
|
} else {
|
|
str = toExponential2(value, precision);
|
|
}
|
|
return str.replace(/((\.\d*?)(0+))($|e)/, function() {
|
|
var digits2 = arguments[2];
|
|
var e3 = arguments[4];
|
|
return digits2 !== "." ? digits2 + e3 : e3;
|
|
});
|
|
}
|
|
default:
|
|
throw new Error('Unknown notation "' + notation + '". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.');
|
|
}
|
|
}
|
|
function toEngineering2(value, precision) {
|
|
var e3 = value.e;
|
|
var newExp = e3 % 3 === 0 ? e3 : e3 < 0 ? e3 - 3 - e3 % 3 : e3 - e3 % 3;
|
|
var valueWithoutExp = value.mul(Math.pow(10, -newExp));
|
|
var valueStr = valueWithoutExp.toPrecision(precision);
|
|
if (valueStr.indexOf("e") !== -1) {
|
|
valueStr = valueWithoutExp.toString();
|
|
}
|
|
return valueStr + "e" + (e3 >= 0 ? "+" : "") + newExp.toString();
|
|
}
|
|
function toExponential2(value, precision) {
|
|
if (precision !== void 0) {
|
|
return value.toExponential(precision - 1);
|
|
} else {
|
|
return value.toExponential();
|
|
}
|
|
}
|
|
function toFixed2(value, precision) {
|
|
return value.toFixed(precision);
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/utils/string.js
|
|
function endsWith(text, search) {
|
|
var start = text.length - search.length;
|
|
var end = text.length;
|
|
return text.substring(start, end) === search;
|
|
}
|
|
function format3(value, options) {
|
|
var result = _format(value, options);
|
|
if (options && typeof options === "object" && "truncate" in options && result.length > options.truncate) {
|
|
return result.substring(0, options.truncate - 3) + "...";
|
|
}
|
|
return result;
|
|
}
|
|
function _format(value, options) {
|
|
if (typeof value === "number") {
|
|
return format(value, options);
|
|
}
|
|
if (isBigNumber(value)) {
|
|
return format2(value, options);
|
|
}
|
|
if (looksLikeFraction(value)) {
|
|
if (!options || options.fraction !== "decimal") {
|
|
return value.s * value.n + "/" + value.d;
|
|
} else {
|
|
return value.toString();
|
|
}
|
|
}
|
|
if (Array.isArray(value)) {
|
|
return formatArray(value, options);
|
|
}
|
|
if (isString(value)) {
|
|
return '"' + value + '"';
|
|
}
|
|
if (typeof value === "function") {
|
|
return value.syntax ? String(value.syntax) : "function";
|
|
}
|
|
if (value && typeof value === "object") {
|
|
if (typeof value.format === "function") {
|
|
return value.format(options);
|
|
} else if (value && value.toString(options) !== {}.toString()) {
|
|
return value.toString(options);
|
|
} else {
|
|
var entries = Object.keys(value).map((key) => {
|
|
return '"' + key + '": ' + format3(value[key], options);
|
|
});
|
|
return "{" + entries.join(", ") + "}";
|
|
}
|
|
}
|
|
return String(value);
|
|
}
|
|
function stringify(value) {
|
|
var text = String(value);
|
|
var escaped = "";
|
|
var i2 = 0;
|
|
while (i2 < text.length) {
|
|
var c = text.charAt(i2);
|
|
if (c === "\\") {
|
|
escaped += c;
|
|
i2++;
|
|
c = text.charAt(i2);
|
|
if (c === "" || '"\\/bfnrtu'.indexOf(c) === -1) {
|
|
escaped += "\\";
|
|
}
|
|
escaped += c;
|
|
} else if (c === '"') {
|
|
escaped += '\\"';
|
|
} else {
|
|
escaped += c;
|
|
}
|
|
i2++;
|
|
}
|
|
return '"' + escaped + '"';
|
|
}
|
|
function escape(value) {
|
|
var text = String(value);
|
|
text = text.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
|
return text;
|
|
}
|
|
function formatArray(array, options) {
|
|
if (Array.isArray(array)) {
|
|
var str = "[";
|
|
var len = array.length;
|
|
for (var i2 = 0; i2 < len; i2++) {
|
|
if (i2 !== 0) {
|
|
str += ", ";
|
|
}
|
|
str += formatArray(array[i2], options);
|
|
}
|
|
str += "]";
|
|
return str;
|
|
} else {
|
|
return format3(array, options);
|
|
}
|
|
}
|
|
function looksLikeFraction(value) {
|
|
return value && typeof value === "object" && typeof value.s === "number" && typeof value.n === "number" && typeof value.d === "number" || false;
|
|
}
|
|
function compareText(x, y) {
|
|
if (!isString(x)) {
|
|
throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: " + typeOf(x) + ", index: 0)");
|
|
}
|
|
if (!isString(y)) {
|
|
throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: " + typeOf(y) + ", index: 1)");
|
|
}
|
|
return x === y ? 0 : x > y ? 1 : -1;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/error/DimensionError.js
|
|
function DimensionError(actual, expected, relation) {
|
|
if (!(this instanceof DimensionError)) {
|
|
throw new SyntaxError("Constructor must be called with the new operator");
|
|
}
|
|
this.actual = actual;
|
|
this.expected = expected;
|
|
this.relation = relation;
|
|
this.message = "Dimension mismatch (" + (Array.isArray(actual) ? "[" + actual.join(", ") + "]" : actual) + " " + (this.relation || "!=") + " " + (Array.isArray(expected) ? "[" + expected.join(", ") + "]" : expected) + ")";
|
|
this.stack = new Error().stack;
|
|
}
|
|
DimensionError.prototype = new RangeError();
|
|
DimensionError.prototype.constructor = RangeError;
|
|
DimensionError.prototype.name = "DimensionError";
|
|
DimensionError.prototype.isDimensionError = true;
|
|
|
|
// node_modules/mathjs/lib/esm/error/IndexError.js
|
|
function IndexError(index2, min3, max3) {
|
|
if (!(this instanceof IndexError)) {
|
|
throw new SyntaxError("Constructor must be called with the new operator");
|
|
}
|
|
this.index = index2;
|
|
if (arguments.length < 3) {
|
|
this.min = 0;
|
|
this.max = min3;
|
|
} else {
|
|
this.min = min3;
|
|
this.max = max3;
|
|
}
|
|
if (this.min !== void 0 && this.index < this.min) {
|
|
this.message = "Index out of range (" + this.index + " < " + this.min + ")";
|
|
} else if (this.max !== void 0 && this.index >= this.max) {
|
|
this.message = "Index out of range (" + this.index + " > " + (this.max - 1) + ")";
|
|
} else {
|
|
this.message = "Index out of range (" + this.index + ")";
|
|
}
|
|
this.stack = new Error().stack;
|
|
}
|
|
IndexError.prototype = new RangeError();
|
|
IndexError.prototype.constructor = RangeError;
|
|
IndexError.prototype.name = "IndexError";
|
|
IndexError.prototype.isIndexError = true;
|
|
|
|
// node_modules/mathjs/lib/esm/utils/array.js
|
|
function arraySize(x) {
|
|
var s = [];
|
|
while (Array.isArray(x)) {
|
|
s.push(x.length);
|
|
x = x[0];
|
|
}
|
|
return s;
|
|
}
|
|
function _validate(array, size2, dim) {
|
|
var i2;
|
|
var len = array.length;
|
|
if (len !== size2[dim]) {
|
|
throw new DimensionError(len, size2[dim]);
|
|
}
|
|
if (dim < size2.length - 1) {
|
|
var dimNext = dim + 1;
|
|
for (i2 = 0; i2 < len; i2++) {
|
|
var child = array[i2];
|
|
if (!Array.isArray(child)) {
|
|
throw new DimensionError(size2.length - 1, size2.length, "<");
|
|
}
|
|
_validate(array[i2], size2, dimNext);
|
|
}
|
|
} else {
|
|
for (i2 = 0; i2 < len; i2++) {
|
|
if (Array.isArray(array[i2])) {
|
|
throw new DimensionError(size2.length + 1, size2.length, ">");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function validate(array, size2) {
|
|
var isScalar = size2.length === 0;
|
|
if (isScalar) {
|
|
if (Array.isArray(array)) {
|
|
throw new DimensionError(array.length, 0);
|
|
}
|
|
} else {
|
|
_validate(array, size2, 0);
|
|
}
|
|
}
|
|
function validateIndex(index2, length) {
|
|
if (!isNumber(index2) || !isInteger(index2)) {
|
|
throw new TypeError("Index must be an integer (value: " + index2 + ")");
|
|
}
|
|
if (index2 < 0 || typeof length === "number" && index2 >= length) {
|
|
throw new IndexError(index2, length);
|
|
}
|
|
}
|
|
function resize(array, size2, defaultValue) {
|
|
if (!Array.isArray(array) || !Array.isArray(size2)) {
|
|
throw new TypeError("Array expected");
|
|
}
|
|
if (size2.length === 0) {
|
|
throw new Error("Resizing to scalar is not supported");
|
|
}
|
|
size2.forEach(function(value) {
|
|
if (!isNumber(value) || !isInteger(value) || value < 0) {
|
|
throw new TypeError("Invalid size, must contain positive integers (size: " + format3(size2) + ")");
|
|
}
|
|
});
|
|
var _defaultValue = defaultValue !== void 0 ? defaultValue : 0;
|
|
_resize(array, size2, 0, _defaultValue);
|
|
return array;
|
|
}
|
|
function _resize(array, size2, dim, defaultValue) {
|
|
var i2;
|
|
var elem;
|
|
var oldLen = array.length;
|
|
var newLen = size2[dim];
|
|
var minLen = Math.min(oldLen, newLen);
|
|
array.length = newLen;
|
|
if (dim < size2.length - 1) {
|
|
var dimNext = dim + 1;
|
|
for (i2 = 0; i2 < minLen; i2++) {
|
|
elem = array[i2];
|
|
if (!Array.isArray(elem)) {
|
|
elem = [elem];
|
|
array[i2] = elem;
|
|
}
|
|
_resize(elem, size2, dimNext, defaultValue);
|
|
}
|
|
for (i2 = minLen; i2 < newLen; i2++) {
|
|
elem = [];
|
|
array[i2] = elem;
|
|
_resize(elem, size2, dimNext, defaultValue);
|
|
}
|
|
} else {
|
|
for (i2 = 0; i2 < minLen; i2++) {
|
|
while (Array.isArray(array[i2])) {
|
|
array[i2] = array[i2][0];
|
|
}
|
|
}
|
|
for (i2 = minLen; i2 < newLen; i2++) {
|
|
array[i2] = defaultValue;
|
|
}
|
|
}
|
|
}
|
|
function reshape(array, sizes) {
|
|
var flatArray = flatten(array);
|
|
var currentLength = flatArray.length;
|
|
if (!Array.isArray(array) || !Array.isArray(sizes)) {
|
|
throw new TypeError("Array expected");
|
|
}
|
|
if (sizes.length === 0) {
|
|
throw new DimensionError(0, currentLength, "!=");
|
|
}
|
|
sizes = processSizesWildcard(sizes, currentLength);
|
|
var newLength = product(sizes);
|
|
if (currentLength !== newLength) {
|
|
throw new DimensionError(newLength, currentLength, "!=");
|
|
}
|
|
try {
|
|
return _reshape(flatArray, sizes);
|
|
} catch (e3) {
|
|
if (e3 instanceof DimensionError) {
|
|
throw new DimensionError(newLength, currentLength, "!=");
|
|
}
|
|
throw e3;
|
|
}
|
|
}
|
|
function processSizesWildcard(sizes, currentLength) {
|
|
var newLength = product(sizes);
|
|
var processedSizes = sizes.slice();
|
|
var WILDCARD = -1;
|
|
var wildCardIndex = sizes.indexOf(WILDCARD);
|
|
var isMoreThanOneWildcard = sizes.indexOf(WILDCARD, wildCardIndex + 1) >= 0;
|
|
if (isMoreThanOneWildcard) {
|
|
throw new Error("More than one wildcard in sizes");
|
|
}
|
|
var hasWildcard = wildCardIndex >= 0;
|
|
var canReplaceWildcard = currentLength % newLength === 0;
|
|
if (hasWildcard) {
|
|
if (canReplaceWildcard) {
|
|
processedSizes[wildCardIndex] = -currentLength / newLength;
|
|
} else {
|
|
throw new Error("Could not replace wildcard, since " + currentLength + " is no multiple of " + -newLength);
|
|
}
|
|
}
|
|
return processedSizes;
|
|
}
|
|
function product(array) {
|
|
return array.reduce((prev, curr) => prev * curr, 1);
|
|
}
|
|
function _reshape(array, sizes) {
|
|
var tmpArray = array;
|
|
var tmpArray2;
|
|
for (var sizeIndex = sizes.length - 1; sizeIndex > 0; sizeIndex--) {
|
|
var size2 = sizes[sizeIndex];
|
|
tmpArray2 = [];
|
|
var length = tmpArray.length / size2;
|
|
for (var i2 = 0; i2 < length; i2++) {
|
|
tmpArray2.push(tmpArray.slice(i2 * size2, (i2 + 1) * size2));
|
|
}
|
|
tmpArray = tmpArray2;
|
|
}
|
|
return tmpArray;
|
|
}
|
|
function squeeze(array, size2) {
|
|
var s = size2 || arraySize(array);
|
|
while (Array.isArray(array) && array.length === 1) {
|
|
array = array[0];
|
|
s.shift();
|
|
}
|
|
var dims = s.length;
|
|
while (s[dims - 1] === 1) {
|
|
dims--;
|
|
}
|
|
if (dims < s.length) {
|
|
array = _squeeze(array, dims, 0);
|
|
s.length = dims;
|
|
}
|
|
return array;
|
|
}
|
|
function _squeeze(array, dims, dim) {
|
|
var i2, ii;
|
|
if (dim < dims) {
|
|
var next = dim + 1;
|
|
for (i2 = 0, ii = array.length; i2 < ii; i2++) {
|
|
array[i2] = _squeeze(array[i2], dims, next);
|
|
}
|
|
} else {
|
|
while (Array.isArray(array)) {
|
|
array = array[0];
|
|
}
|
|
}
|
|
return array;
|
|
}
|
|
function unsqueeze(array, dims, outer, size2) {
|
|
var s = size2 || arraySize(array);
|
|
if (outer) {
|
|
for (var i2 = 0; i2 < outer; i2++) {
|
|
array = [array];
|
|
s.unshift(1);
|
|
}
|
|
}
|
|
array = _unsqueeze(array, dims, 0);
|
|
while (s.length < dims) {
|
|
s.push(1);
|
|
}
|
|
return array;
|
|
}
|
|
function _unsqueeze(array, dims, dim) {
|
|
var i2, ii;
|
|
if (Array.isArray(array)) {
|
|
var next = dim + 1;
|
|
for (i2 = 0, ii = array.length; i2 < ii; i2++) {
|
|
array[i2] = _unsqueeze(array[i2], dims, next);
|
|
}
|
|
} else {
|
|
for (var d = dim; d < dims; d++) {
|
|
array = [array];
|
|
}
|
|
}
|
|
return array;
|
|
}
|
|
function flatten(array) {
|
|
if (!Array.isArray(array)) {
|
|
return array;
|
|
}
|
|
var flat = [];
|
|
array.forEach(function callback(value) {
|
|
if (Array.isArray(value)) {
|
|
value.forEach(callback);
|
|
} else {
|
|
flat.push(value);
|
|
}
|
|
});
|
|
return flat;
|
|
}
|
|
function map(array, callback) {
|
|
return Array.prototype.map.call(array, callback);
|
|
}
|
|
function forEach(array, callback) {
|
|
Array.prototype.forEach.call(array, callback);
|
|
}
|
|
function filter(array, callback) {
|
|
if (arraySize(array).length !== 1) {
|
|
throw new Error("Only one dimensional matrices supported");
|
|
}
|
|
return Array.prototype.filter.call(array, callback);
|
|
}
|
|
function filterRegExp(array, regexp) {
|
|
if (arraySize(array).length !== 1) {
|
|
throw new Error("Only one dimensional matrices supported");
|
|
}
|
|
return Array.prototype.filter.call(array, (entry) => regexp.test(entry));
|
|
}
|
|
function join(array, separator) {
|
|
return Array.prototype.join.call(array, separator);
|
|
}
|
|
function identify(a) {
|
|
if (!Array.isArray(a)) {
|
|
throw new TypeError("Array input expected");
|
|
}
|
|
if (a.length === 0) {
|
|
return a;
|
|
}
|
|
var b = [];
|
|
var count2 = 0;
|
|
b[0] = {
|
|
value: a[0],
|
|
identifier: 0
|
|
};
|
|
for (var i2 = 1; i2 < a.length; i2++) {
|
|
if (a[i2] === a[i2 - 1]) {
|
|
count2++;
|
|
} else {
|
|
count2 = 0;
|
|
}
|
|
b.push({
|
|
value: a[i2],
|
|
identifier: count2
|
|
});
|
|
}
|
|
return b;
|
|
}
|
|
function generalize(a) {
|
|
if (!Array.isArray(a)) {
|
|
throw new TypeError("Array input expected");
|
|
}
|
|
if (a.length === 0) {
|
|
return a;
|
|
}
|
|
var b = [];
|
|
for (var i2 = 0; i2 < a.length; i2++) {
|
|
b.push(a[i2].value);
|
|
}
|
|
return b;
|
|
}
|
|
function getArrayDataType(array, typeOf3) {
|
|
var type;
|
|
var length = 0;
|
|
for (var i2 = 0; i2 < array.length; i2++) {
|
|
var item = array[i2];
|
|
var isArray2 = Array.isArray(item);
|
|
if (i2 === 0 && isArray2) {
|
|
length = item.length;
|
|
}
|
|
if (isArray2 && item.length !== length) {
|
|
return void 0;
|
|
}
|
|
var itemType = isArray2 ? getArrayDataType(item, typeOf3) : typeOf3(item);
|
|
if (type === void 0) {
|
|
type = itemType;
|
|
} else if (type !== itemType) {
|
|
return "mixed";
|
|
} else {
|
|
}
|
|
}
|
|
return type;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/utils/factory.js
|
|
function factory(name302, dependencies302, create, meta) {
|
|
function assertAndCreate(scope) {
|
|
var deps = pickShallow(scope, dependencies302.map(stripOptionalNotation));
|
|
assertDependencies(name302, dependencies302, scope);
|
|
return create(deps);
|
|
}
|
|
assertAndCreate.isFactory = true;
|
|
assertAndCreate.fn = name302;
|
|
assertAndCreate.dependencies = dependencies302.slice().sort();
|
|
if (meta) {
|
|
assertAndCreate.meta = meta;
|
|
}
|
|
return assertAndCreate;
|
|
}
|
|
function assertDependencies(name302, dependencies302, scope) {
|
|
var allDefined = dependencies302.filter((dependency) => !isOptionalDependency(dependency)).every((dependency) => scope[dependency] !== void 0);
|
|
if (!allDefined) {
|
|
var missingDependencies = dependencies302.filter((dependency) => scope[dependency] === void 0);
|
|
throw new Error('Cannot create function "'.concat(name302, '", ') + "some dependencies are missing: ".concat(missingDependencies.map((d) => '"'.concat(d, '"')).join(", "), "."));
|
|
}
|
|
}
|
|
function isOptionalDependency(dependency) {
|
|
return dependency && dependency[0] === "?";
|
|
}
|
|
function stripOptionalNotation(dependency) {
|
|
return dependency && dependency[0] === "?" ? dependency.slice(1) : dependency;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/utils/customs.js
|
|
function getSafeProperty(object, prop) {
|
|
if (isPlainObject(object) && isSafeProperty(object, prop)) {
|
|
return object[prop];
|
|
}
|
|
if (typeof object[prop] === "function" && isSafeMethod(object, prop)) {
|
|
throw new Error('Cannot access method "' + prop + '" as a property');
|
|
}
|
|
throw new Error('No access to property "' + prop + '"');
|
|
}
|
|
function setSafeProperty(object, prop, value) {
|
|
if (isPlainObject(object) && isSafeProperty(object, prop)) {
|
|
object[prop] = value;
|
|
return value;
|
|
}
|
|
throw new Error('No access to property "' + prop + '"');
|
|
}
|
|
function hasSafeProperty(object, prop) {
|
|
return prop in object;
|
|
}
|
|
function isSafeProperty(object, prop) {
|
|
if (!object || typeof object !== "object") {
|
|
return false;
|
|
}
|
|
if (hasOwnProperty2(safeNativeProperties, prop)) {
|
|
return true;
|
|
}
|
|
if (prop in Object.prototype) {
|
|
return false;
|
|
}
|
|
if (prop in Function.prototype) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
function validateSafeMethod(object, method) {
|
|
if (!isSafeMethod(object, method)) {
|
|
throw new Error('No access to method "' + method + '"');
|
|
}
|
|
}
|
|
function isSafeMethod(object, method) {
|
|
if (object === null || object === void 0 || typeof object[method] !== "function") {
|
|
return false;
|
|
}
|
|
if (hasOwnProperty2(object, method) && Object.getPrototypeOf && method in Object.getPrototypeOf(object)) {
|
|
return false;
|
|
}
|
|
if (hasOwnProperty2(safeNativeMethods, method)) {
|
|
return true;
|
|
}
|
|
if (method in Object.prototype) {
|
|
return false;
|
|
}
|
|
if (method in Function.prototype) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
function isPlainObject(object) {
|
|
return typeof object === "object" && object && object.constructor === Object;
|
|
}
|
|
var safeNativeProperties = {
|
|
length: true,
|
|
name: true
|
|
};
|
|
var safeNativeMethods = {
|
|
toString: true,
|
|
valueOf: true,
|
|
toLocaleString: true
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/utils/map.js
|
|
var ObjectWrappingMap = class {
|
|
constructor(object) {
|
|
this.wrappedObject = object;
|
|
}
|
|
keys() {
|
|
return Object.keys(this.wrappedObject);
|
|
}
|
|
get(key) {
|
|
return getSafeProperty(this.wrappedObject, key);
|
|
}
|
|
set(key, value) {
|
|
setSafeProperty(this.wrappedObject, key, value);
|
|
return this;
|
|
}
|
|
has(key) {
|
|
return hasSafeProperty(this.wrappedObject, key);
|
|
}
|
|
};
|
|
function createEmptyMap() {
|
|
return /* @__PURE__ */ new Map();
|
|
}
|
|
function createMap(mapOrObject) {
|
|
if (!mapOrObject) {
|
|
return createEmptyMap();
|
|
}
|
|
if (isMap(mapOrObject)) {
|
|
return mapOrObject;
|
|
}
|
|
if (isObject(mapOrObject)) {
|
|
return new ObjectWrappingMap(mapOrObject);
|
|
}
|
|
throw new Error("createMap can create maps from objects or Maps");
|
|
}
|
|
function toObject(map3) {
|
|
if (map3 instanceof ObjectWrappingMap) {
|
|
return map3.wrappedObject;
|
|
}
|
|
var object = {};
|
|
for (var key of map3.keys()) {
|
|
var value = map3.get(key);
|
|
setSafeProperty(object, key, value);
|
|
}
|
|
return object;
|
|
}
|
|
function isMap(object) {
|
|
if (!object) {
|
|
return false;
|
|
}
|
|
return object instanceof Map || object instanceof ObjectWrappingMap || typeof object.set === "function" && typeof object.get === "function" && typeof object.keys === "function" && typeof object.has === "function";
|
|
}
|
|
function assign(map3) {
|
|
for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
objects[_key - 1] = arguments[_key];
|
|
}
|
|
for (var args of objects) {
|
|
if (!args) {
|
|
continue;
|
|
}
|
|
if (isMap(args)) {
|
|
for (var key of args.keys()) {
|
|
map3.set(key, args.get(key));
|
|
}
|
|
} else if (isObject(args)) {
|
|
for (var _key2 of Object.keys(args)) {
|
|
map3.set(_key2, args[_key2]);
|
|
}
|
|
}
|
|
}
|
|
return map3;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/core/function/typed.js
|
|
var _createTyped2 = function _createTyped() {
|
|
_createTyped2 = import_typed_function.default.create;
|
|
return import_typed_function.default;
|
|
};
|
|
var dependencies = ["?BigNumber", "?Complex", "?DenseMatrix", "?Fraction"];
|
|
var createTyped = /* @__PURE__ */ factory("typed", dependencies, function createTyped2(_ref) {
|
|
var {
|
|
BigNumber: BigNumber2,
|
|
Complex: Complex3,
|
|
DenseMatrix: DenseMatrix2,
|
|
Fraction: Fraction3
|
|
} = _ref;
|
|
var typed2 = _createTyped2();
|
|
typed2.clear();
|
|
typed2.addTypes([
|
|
{
|
|
name: "number",
|
|
test: isNumber
|
|
},
|
|
{
|
|
name: "Complex",
|
|
test: isComplex
|
|
},
|
|
{
|
|
name: "BigNumber",
|
|
test: isBigNumber
|
|
},
|
|
{
|
|
name: "Fraction",
|
|
test: isFraction
|
|
},
|
|
{
|
|
name: "Unit",
|
|
test: isUnit
|
|
},
|
|
{
|
|
name: "identifier",
|
|
test: (s) => isString && /^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])*$/.test(s)
|
|
},
|
|
{
|
|
name: "string",
|
|
test: isString
|
|
},
|
|
{
|
|
name: "Chain",
|
|
test: isChain
|
|
},
|
|
{
|
|
name: "Array",
|
|
test: isArray
|
|
},
|
|
{
|
|
name: "Matrix",
|
|
test: isMatrix
|
|
},
|
|
{
|
|
name: "DenseMatrix",
|
|
test: isDenseMatrix
|
|
},
|
|
{
|
|
name: "SparseMatrix",
|
|
test: isSparseMatrix
|
|
},
|
|
{
|
|
name: "Range",
|
|
test: isRange
|
|
},
|
|
{
|
|
name: "Index",
|
|
test: isIndex
|
|
},
|
|
{
|
|
name: "boolean",
|
|
test: isBoolean
|
|
},
|
|
{
|
|
name: "ResultSet",
|
|
test: isResultSet
|
|
},
|
|
{
|
|
name: "Help",
|
|
test: isHelp
|
|
},
|
|
{
|
|
name: "function",
|
|
test: isFunction
|
|
},
|
|
{
|
|
name: "Date",
|
|
test: isDate
|
|
},
|
|
{
|
|
name: "RegExp",
|
|
test: isRegExp
|
|
},
|
|
{
|
|
name: "null",
|
|
test: isNull
|
|
},
|
|
{
|
|
name: "undefined",
|
|
test: isUndefined
|
|
},
|
|
{
|
|
name: "AccessorNode",
|
|
test: isAccessorNode
|
|
},
|
|
{
|
|
name: "ArrayNode",
|
|
test: isArrayNode
|
|
},
|
|
{
|
|
name: "AssignmentNode",
|
|
test: isAssignmentNode
|
|
},
|
|
{
|
|
name: "BlockNode",
|
|
test: isBlockNode
|
|
},
|
|
{
|
|
name: "ConditionalNode",
|
|
test: isConditionalNode
|
|
},
|
|
{
|
|
name: "ConstantNode",
|
|
test: isConstantNode
|
|
},
|
|
{
|
|
name: "FunctionNode",
|
|
test: isFunctionNode
|
|
},
|
|
{
|
|
name: "FunctionAssignmentNode",
|
|
test: isFunctionAssignmentNode
|
|
},
|
|
{
|
|
name: "IndexNode",
|
|
test: isIndexNode
|
|
},
|
|
{
|
|
name: "Node",
|
|
test: isNode
|
|
},
|
|
{
|
|
name: "ObjectNode",
|
|
test: isObjectNode
|
|
},
|
|
{
|
|
name: "OperatorNode",
|
|
test: isOperatorNode
|
|
},
|
|
{
|
|
name: "ParenthesisNode",
|
|
test: isParenthesisNode
|
|
},
|
|
{
|
|
name: "RangeNode",
|
|
test: isRangeNode
|
|
},
|
|
{
|
|
name: "RelationalNode",
|
|
test: isRelationalNode
|
|
},
|
|
{
|
|
name: "SymbolNode",
|
|
test: isSymbolNode
|
|
},
|
|
{
|
|
name: "Map",
|
|
test: isMap
|
|
},
|
|
{
|
|
name: "Object",
|
|
test: isObject
|
|
}
|
|
]);
|
|
typed2.addConversions([{
|
|
from: "number",
|
|
to: "BigNumber",
|
|
convert: function convert(x) {
|
|
if (!BigNumber2) {
|
|
throwNoBignumber(x);
|
|
}
|
|
if (digits(x) > 15) {
|
|
throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: " + x + "). Use function bignumber(x) to convert to BigNumber.");
|
|
}
|
|
return new BigNumber2(x);
|
|
}
|
|
}, {
|
|
from: "number",
|
|
to: "Complex",
|
|
convert: function convert(x) {
|
|
if (!Complex3) {
|
|
throwNoComplex(x);
|
|
}
|
|
return new Complex3(x, 0);
|
|
}
|
|
}, {
|
|
from: "BigNumber",
|
|
to: "Complex",
|
|
convert: function convert(x) {
|
|
if (!Complex3) {
|
|
throwNoComplex(x);
|
|
}
|
|
return new Complex3(x.toNumber(), 0);
|
|
}
|
|
}, {
|
|
from: "Fraction",
|
|
to: "BigNumber",
|
|
convert: function convert(x) {
|
|
throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.");
|
|
}
|
|
}, {
|
|
from: "Fraction",
|
|
to: "Complex",
|
|
convert: function convert(x) {
|
|
if (!Complex3) {
|
|
throwNoComplex(x);
|
|
}
|
|
return new Complex3(x.valueOf(), 0);
|
|
}
|
|
}, {
|
|
from: "number",
|
|
to: "Fraction",
|
|
convert: function convert(x) {
|
|
if (!Fraction3) {
|
|
throwNoFraction(x);
|
|
}
|
|
var f = new Fraction3(x);
|
|
if (f.valueOf() !== x) {
|
|
throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: " + x + "). Use function fraction(x) to convert to Fraction.");
|
|
}
|
|
return f;
|
|
}
|
|
}, {
|
|
from: "string",
|
|
to: "number",
|
|
convert: function convert(x) {
|
|
var n = Number(x);
|
|
if (isNaN(n)) {
|
|
throw new Error('Cannot convert "' + x + '" to a number');
|
|
}
|
|
return n;
|
|
}
|
|
}, {
|
|
from: "string",
|
|
to: "BigNumber",
|
|
convert: function convert(x) {
|
|
if (!BigNumber2) {
|
|
throwNoBignumber(x);
|
|
}
|
|
try {
|
|
return new BigNumber2(x);
|
|
} catch (err) {
|
|
throw new Error('Cannot convert "' + x + '" to BigNumber');
|
|
}
|
|
}
|
|
}, {
|
|
from: "string",
|
|
to: "Fraction",
|
|
convert: function convert(x) {
|
|
if (!Fraction3) {
|
|
throwNoFraction(x);
|
|
}
|
|
try {
|
|
return new Fraction3(x);
|
|
} catch (err) {
|
|
throw new Error('Cannot convert "' + x + '" to Fraction');
|
|
}
|
|
}
|
|
}, {
|
|
from: "string",
|
|
to: "Complex",
|
|
convert: function convert(x) {
|
|
if (!Complex3) {
|
|
throwNoComplex(x);
|
|
}
|
|
try {
|
|
return new Complex3(x);
|
|
} catch (err) {
|
|
throw new Error('Cannot convert "' + x + '" to Complex');
|
|
}
|
|
}
|
|
}, {
|
|
from: "boolean",
|
|
to: "number",
|
|
convert: function convert(x) {
|
|
return +x;
|
|
}
|
|
}, {
|
|
from: "boolean",
|
|
to: "BigNumber",
|
|
convert: function convert(x) {
|
|
if (!BigNumber2) {
|
|
throwNoBignumber(x);
|
|
}
|
|
return new BigNumber2(+x);
|
|
}
|
|
}, {
|
|
from: "boolean",
|
|
to: "Fraction",
|
|
convert: function convert(x) {
|
|
if (!Fraction3) {
|
|
throwNoFraction(x);
|
|
}
|
|
return new Fraction3(+x);
|
|
}
|
|
}, {
|
|
from: "boolean",
|
|
to: "string",
|
|
convert: function convert(x) {
|
|
return String(x);
|
|
}
|
|
}, {
|
|
from: "Array",
|
|
to: "Matrix",
|
|
convert: function convert(array) {
|
|
if (!DenseMatrix2) {
|
|
throwNoMatrix();
|
|
}
|
|
return new DenseMatrix2(array);
|
|
}
|
|
}, {
|
|
from: "Matrix",
|
|
to: "Array",
|
|
convert: function convert(matrix2) {
|
|
return matrix2.valueOf();
|
|
}
|
|
}]);
|
|
typed2.onMismatch = (name302, args, signatures) => {
|
|
var usualError = typed2.createError(name302, args, signatures);
|
|
if (["wrongType", "mismatch"].includes(usualError.data.category) && args.length === 1 && isCollection(args[0]) && signatures.some((sig) => !sig.params.includes(","))) {
|
|
var err = new TypeError("Function '".concat(name302, "' doesn't apply to matrices. To call it ") + "elementwise on a matrix 'M', try 'map(M, ".concat(name302, ")'."));
|
|
err.data = usualError.data;
|
|
throw err;
|
|
}
|
|
throw usualError;
|
|
};
|
|
typed2.onMismatch = (name302, args, signatures) => {
|
|
var usualError = typed2.createError(name302, args, signatures);
|
|
if (["wrongType", "mismatch"].includes(usualError.data.category) && args.length === 1 && isCollection(args[0]) && signatures.some((sig) => !sig.params.includes(","))) {
|
|
var err = new TypeError("Function '".concat(name302, "' doesn't apply to matrices. To call it ") + "elementwise on a matrix 'M', try 'map(M, ".concat(name302, ")'."));
|
|
err.data = usualError.data;
|
|
throw err;
|
|
}
|
|
throw usualError;
|
|
};
|
|
return typed2;
|
|
});
|
|
function throwNoBignumber(x) {
|
|
throw new Error("Cannot convert value ".concat(x, " into a BigNumber: no class 'BigNumber' provided"));
|
|
}
|
|
function throwNoComplex(x) {
|
|
throw new Error("Cannot convert value ".concat(x, " into a Complex number: no class 'Complex' provided"));
|
|
}
|
|
function throwNoMatrix() {
|
|
throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided");
|
|
}
|
|
function throwNoFraction(x) {
|
|
throw new Error("Cannot convert value ".concat(x, " into a Fraction, no class 'Fraction' provided."));
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/type/resultset/ResultSet.js
|
|
var name = "ResultSet";
|
|
var dependencies2 = [];
|
|
var createResultSet = /* @__PURE__ */ factory(name, dependencies2, () => {
|
|
function ResultSet2(entries) {
|
|
if (!(this instanceof ResultSet2)) {
|
|
throw new SyntaxError("Constructor must be called with the new operator");
|
|
}
|
|
this.entries = entries || [];
|
|
}
|
|
ResultSet2.prototype.type = "ResultSet";
|
|
ResultSet2.prototype.isResultSet = true;
|
|
ResultSet2.prototype.valueOf = function() {
|
|
return this.entries;
|
|
};
|
|
ResultSet2.prototype.toString = function() {
|
|
return "[" + this.entries.join(", ") + "]";
|
|
};
|
|
ResultSet2.prototype.toJSON = function() {
|
|
return {
|
|
mathjs: "ResultSet",
|
|
entries: this.entries
|
|
};
|
|
};
|
|
ResultSet2.fromJSON = function(json) {
|
|
return new ResultSet2(json.entries);
|
|
};
|
|
return ResultSet2;
|
|
}, {
|
|
isClass: true
|
|
});
|
|
|
|
// node_modules/decimal.js/decimal.mjs
|
|
var EXP_LIMIT = 9e15;
|
|
var MAX_DIGITS = 1e9;
|
|
var NUMERALS = "0123456789abcdef";
|
|
var LN10 = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058";
|
|
var PI = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789";
|
|
var DEFAULTS = {
|
|
precision: 20,
|
|
rounding: 4,
|
|
modulo: 1,
|
|
toExpNeg: -7,
|
|
toExpPos: 21,
|
|
minE: -EXP_LIMIT,
|
|
maxE: EXP_LIMIT,
|
|
crypto: false
|
|
};
|
|
var inexact;
|
|
var quadrant;
|
|
var external = true;
|
|
var decimalError = "[DecimalError] ";
|
|
var invalidArgument = decimalError + "Invalid argument: ";
|
|
var precisionLimitExceeded = decimalError + "Precision limit exceeded";
|
|
var cryptoUnavailable = decimalError + "crypto unavailable";
|
|
var tag = "[object Decimal]";
|
|
var mathfloor = Math.floor;
|
|
var mathpow = Math.pow;
|
|
var isBinary = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i;
|
|
var isHex = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i;
|
|
var isOctal = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i;
|
|
var isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
|
|
var BASE = 1e7;
|
|
var LOG_BASE = 7;
|
|
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
var LN10_PRECISION = LN10.length - 1;
|
|
var PI_PRECISION = PI.length - 1;
|
|
var P = { toStringTag: tag };
|
|
P.absoluteValue = P.abs = function() {
|
|
var x = new this.constructor(this);
|
|
if (x.s < 0)
|
|
x.s = 1;
|
|
return finalise(x);
|
|
};
|
|
P.ceil = function() {
|
|
return finalise(new this.constructor(this), this.e + 1, 2);
|
|
};
|
|
P.clampedTo = P.clamp = function(min3, max3) {
|
|
var k, x = this, Ctor = x.constructor;
|
|
min3 = new Ctor(min3);
|
|
max3 = new Ctor(max3);
|
|
if (!min3.s || !max3.s)
|
|
return new Ctor(NaN);
|
|
if (min3.gt(max3))
|
|
throw Error(invalidArgument + max3);
|
|
k = x.cmp(min3);
|
|
return k < 0 ? min3 : x.cmp(max3) > 0 ? max3 : new Ctor(x);
|
|
};
|
|
P.comparedTo = P.cmp = function(y) {
|
|
var i2, j, xdL, ydL, x = this, xd = x.d, yd = (y = new x.constructor(y)).d, xs = x.s, ys = y.s;
|
|
if (!xd || !yd) {
|
|
return !xs || !ys ? NaN : xs !== ys ? xs : xd === yd ? 0 : !xd ^ xs < 0 ? 1 : -1;
|
|
}
|
|
if (!xd[0] || !yd[0])
|
|
return xd[0] ? xs : yd[0] ? -ys : 0;
|
|
if (xs !== ys)
|
|
return xs;
|
|
if (x.e !== y.e)
|
|
return x.e > y.e ^ xs < 0 ? 1 : -1;
|
|
xdL = xd.length;
|
|
ydL = yd.length;
|
|
for (i2 = 0, j = xdL < ydL ? xdL : ydL; i2 < j; ++i2) {
|
|
if (xd[i2] !== yd[i2])
|
|
return xd[i2] > yd[i2] ^ xs < 0 ? 1 : -1;
|
|
}
|
|
return xdL === ydL ? 0 : xdL > ydL ^ xs < 0 ? 1 : -1;
|
|
};
|
|
P.cosine = P.cos = function() {
|
|
var pr, rm, x = this, Ctor = x.constructor;
|
|
if (!x.d)
|
|
return new Ctor(NaN);
|
|
if (!x.d[0])
|
|
return new Ctor(1);
|
|
pr = Ctor.precision;
|
|
rm = Ctor.rounding;
|
|
Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
|
|
Ctor.rounding = 1;
|
|
x = cosine(Ctor, toLessThanHalfPi(Ctor, x));
|
|
Ctor.precision = pr;
|
|
Ctor.rounding = rm;
|
|
return finalise(quadrant == 2 || quadrant == 3 ? x.neg() : x, pr, rm, true);
|
|
};
|
|
P.cubeRoot = P.cbrt = function() {
|
|
var e3, m, n, r, rep, s, sd, t, t3, t3plusx, x = this, Ctor = x.constructor;
|
|
if (!x.isFinite() || x.isZero())
|
|
return new Ctor(x);
|
|
external = false;
|
|
s = x.s * mathpow(x.s * x, 1 / 3);
|
|
if (!s || Math.abs(s) == 1 / 0) {
|
|
n = digitsToString(x.d);
|
|
e3 = x.e;
|
|
if (s = (e3 - n.length + 1) % 3)
|
|
n += s == 1 || s == -2 ? "0" : "00";
|
|
s = mathpow(n, 1 / 3);
|
|
e3 = mathfloor((e3 + 1) / 3) - (e3 % 3 == (e3 < 0 ? -1 : 2));
|
|
if (s == 1 / 0) {
|
|
n = "5e" + e3;
|
|
} else {
|
|
n = s.toExponential();
|
|
n = n.slice(0, n.indexOf("e") + 1) + e3;
|
|
}
|
|
r = new Ctor(n);
|
|
r.s = x.s;
|
|
} else {
|
|
r = new Ctor(s.toString());
|
|
}
|
|
sd = (e3 = Ctor.precision) + 3;
|
|
for (; ; ) {
|
|
t = r;
|
|
t3 = t.times(t).times(t);
|
|
t3plusx = t3.plus(x);
|
|
r = divide(t3plusx.plus(x).times(t), t3plusx.plus(t3), sd + 2, 1);
|
|
if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
|
|
n = n.slice(sd - 3, sd + 1);
|
|
if (n == "9999" || !rep && n == "4999") {
|
|
if (!rep) {
|
|
finalise(t, e3 + 1, 0);
|
|
if (t.times(t).times(t).eq(x)) {
|
|
r = t;
|
|
break;
|
|
}
|
|
}
|
|
sd += 4;
|
|
rep = 1;
|
|
} else {
|
|
if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
|
|
finalise(r, e3 + 1, 1);
|
|
m = !r.times(r).times(r).eq(x);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
external = true;
|
|
return finalise(r, e3, Ctor.rounding, m);
|
|
};
|
|
P.decimalPlaces = P.dp = function() {
|
|
var w, d = this.d, n = NaN;
|
|
if (d) {
|
|
w = d.length - 1;
|
|
n = (w - mathfloor(this.e / LOG_BASE)) * LOG_BASE;
|
|
w = d[w];
|
|
if (w)
|
|
for (; w % 10 == 0; w /= 10)
|
|
n--;
|
|
if (n < 0)
|
|
n = 0;
|
|
}
|
|
return n;
|
|
};
|
|
P.dividedBy = P.div = function(y) {
|
|
return divide(this, new this.constructor(y));
|
|
};
|
|
P.dividedToIntegerBy = P.divToInt = function(y) {
|
|
var x = this, Ctor = x.constructor;
|
|
return finalise(divide(x, new Ctor(y), 0, 1, 1), Ctor.precision, Ctor.rounding);
|
|
};
|
|
P.equals = P.eq = function(y) {
|
|
return this.cmp(y) === 0;
|
|
};
|
|
P.floor = function() {
|
|
return finalise(new this.constructor(this), this.e + 1, 3);
|
|
};
|
|
P.greaterThan = P.gt = function(y) {
|
|
return this.cmp(y) > 0;
|
|
};
|
|
P.greaterThanOrEqualTo = P.gte = function(y) {
|
|
var k = this.cmp(y);
|
|
return k == 1 || k === 0;
|
|
};
|
|
P.hyperbolicCosine = P.cosh = function() {
|
|
var k, n, pr, rm, len, x = this, Ctor = x.constructor, one = new Ctor(1);
|
|
if (!x.isFinite())
|
|
return new Ctor(x.s ? 1 / 0 : NaN);
|
|
if (x.isZero())
|
|
return one;
|
|
pr = Ctor.precision;
|
|
rm = Ctor.rounding;
|
|
Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
|
|
Ctor.rounding = 1;
|
|
len = x.d.length;
|
|
if (len < 32) {
|
|
k = Math.ceil(len / 3);
|
|
n = (1 / tinyPow(4, k)).toString();
|
|
} else {
|
|
k = 16;
|
|
n = "2.3283064365386962890625e-10";
|
|
}
|
|
x = taylorSeries(Ctor, 1, x.times(n), new Ctor(1), true);
|
|
var cosh2_x, i2 = k, d8 = new Ctor(8);
|
|
for (; i2--; ) {
|
|
cosh2_x = x.times(x);
|
|
x = one.minus(cosh2_x.times(d8.minus(cosh2_x.times(d8))));
|
|
}
|
|
return finalise(x, Ctor.precision = pr, Ctor.rounding = rm, true);
|
|
};
|
|
P.hyperbolicSine = P.sinh = function() {
|
|
var k, pr, rm, len, x = this, Ctor = x.constructor;
|
|
if (!x.isFinite() || x.isZero())
|
|
return new Ctor(x);
|
|
pr = Ctor.precision;
|
|
rm = Ctor.rounding;
|
|
Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
|
|
Ctor.rounding = 1;
|
|
len = x.d.length;
|
|
if (len < 3) {
|
|
x = taylorSeries(Ctor, 2, x, x, true);
|
|
} else {
|
|
k = 1.4 * Math.sqrt(len);
|
|
k = k > 16 ? 16 : k | 0;
|
|
x = x.times(1 / tinyPow(5, k));
|
|
x = taylorSeries(Ctor, 2, x, x, true);
|
|
var sinh2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
|
|
for (; k--; ) {
|
|
sinh2_x = x.times(x);
|
|
x = x.times(d5.plus(sinh2_x.times(d16.times(sinh2_x).plus(d20))));
|
|
}
|
|
}
|
|
Ctor.precision = pr;
|
|
Ctor.rounding = rm;
|
|
return finalise(x, pr, rm, true);
|
|
};
|
|
P.hyperbolicTangent = P.tanh = function() {
|
|
var pr, rm, x = this, Ctor = x.constructor;
|
|
if (!x.isFinite())
|
|
return new Ctor(x.s);
|
|
if (x.isZero())
|
|
return new Ctor(x);
|
|
pr = Ctor.precision;
|
|
rm = Ctor.rounding;
|
|
Ctor.precision = pr + 7;
|
|
Ctor.rounding = 1;
|
|
return divide(x.sinh(), x.cosh(), Ctor.precision = pr, Ctor.rounding = rm);
|
|
};
|
|
P.inverseCosine = P.acos = function() {
|
|
var halfPi, x = this, Ctor = x.constructor, k = x.abs().cmp(1), pr = Ctor.precision, rm = Ctor.rounding;
|
|
if (k !== -1) {
|
|
return k === 0 ? x.isNeg() ? getPi(Ctor, pr, rm) : new Ctor(0) : new Ctor(NaN);
|
|
}
|
|
if (x.isZero())
|
|
return getPi(Ctor, pr + 4, rm).times(0.5);
|
|
Ctor.precision = pr + 6;
|
|
Ctor.rounding = 1;
|
|
x = x.asin();
|
|
halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
|
|
Ctor.precision = pr;
|
|
Ctor.rounding = rm;
|
|
return halfPi.minus(x);
|
|
};
|
|
P.inverseHyperbolicCosine = P.acosh = function() {
|
|
var pr, rm, x = this, Ctor = x.constructor;
|
|
if (x.lte(1))
|
|
return new Ctor(x.eq(1) ? 0 : NaN);
|
|
if (!x.isFinite())
|
|
return new Ctor(x);
|
|
pr = Ctor.precision;
|
|
rm = Ctor.rounding;
|
|
Ctor.precision = pr + Math.max(Math.abs(x.e), x.sd()) + 4;
|
|
Ctor.rounding = 1;
|
|
external = false;
|
|
x = x.times(x).minus(1).sqrt().plus(x);
|
|
external = true;
|
|
Ctor.precision = pr;
|
|
Ctor.rounding = rm;
|
|
return x.ln();
|
|
};
|
|
P.inverseHyperbolicSine = P.asinh = function() {
|
|
var pr, rm, x = this, Ctor = x.constructor;
|
|
if (!x.isFinite() || x.isZero())
|
|
return new Ctor(x);
|
|
pr = Ctor.precision;
|
|
rm = Ctor.rounding;
|
|
Ctor.precision = pr + 2 * Math.max(Math.abs(x.e), x.sd()) + 6;
|
|
Ctor.rounding = 1;
|
|
external = false;
|
|
x = x.times(x).plus(1).sqrt().plus(x);
|
|
external = true;
|
|
Ctor.precision = pr;
|
|
Ctor.rounding = rm;
|
|
return x.ln();
|
|
};
|
|
P.inverseHyperbolicTangent = P.atanh = function() {
|
|
var pr, rm, wpr, xsd, x = this, Ctor = x.constructor;
|
|
if (!x.isFinite())
|
|
return new Ctor(NaN);
|
|
if (x.e >= 0)
|
|
return new Ctor(x.abs().eq(1) ? x.s / 0 : x.isZero() ? x : NaN);
|
|
pr = Ctor.precision;
|
|
rm = Ctor.rounding;
|
|
xsd = x.sd();
|
|
if (Math.max(xsd, pr) < 2 * -x.e - 1)
|
|
return finalise(new Ctor(x), pr, rm, true);
|
|
Ctor.precision = wpr = xsd - x.e;
|
|
x = divide(x.plus(1), new Ctor(1).minus(x), wpr + pr, 1);
|
|
Ctor.precision = pr + 4;
|
|
Ctor.rounding = 1;
|
|
x = x.ln();
|
|
Ctor.precision = pr;
|
|
Ctor.rounding = rm;
|
|
return x.times(0.5);
|
|
};
|
|
P.inverseSine = P.asin = function() {
|
|
var halfPi, k, pr, rm, x = this, Ctor = x.constructor;
|
|
if (x.isZero())
|
|
return new Ctor(x);
|
|
k = x.abs().cmp(1);
|
|
pr = Ctor.precision;
|
|
rm = Ctor.rounding;
|
|
if (k !== -1) {
|
|
if (k === 0) {
|
|
halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
|
|
halfPi.s = x.s;
|
|
return halfPi;
|
|
}
|
|
return new Ctor(NaN);
|
|
}
|
|
Ctor.precision = pr + 6;
|
|
Ctor.rounding = 1;
|
|
x = x.div(new Ctor(1).minus(x.times(x)).sqrt().plus(1)).atan();
|
|
Ctor.precision = pr;
|
|
Ctor.rounding = rm;
|
|
return x.times(2);
|
|
};
|
|
P.inverseTangent = P.atan = function() {
|
|
var i2, j, k, n, px, t, r, wpr, x2, x = this, Ctor = x.constructor, pr = Ctor.precision, rm = Ctor.rounding;
|
|
if (!x.isFinite()) {
|
|
if (!x.s)
|
|
return new Ctor(NaN);
|
|
if (pr + 4 <= PI_PRECISION) {
|
|
r = getPi(Ctor, pr + 4, rm).times(0.5);
|
|
r.s = x.s;
|
|
return r;
|
|
}
|
|
} else if (x.isZero()) {
|
|
return new Ctor(x);
|
|
} else if (x.abs().eq(1) && pr + 4 <= PI_PRECISION) {
|
|
r = getPi(Ctor, pr + 4, rm).times(0.25);
|
|
r.s = x.s;
|
|
return r;
|
|
}
|
|
Ctor.precision = wpr = pr + 10;
|
|
Ctor.rounding = 1;
|
|
k = Math.min(28, wpr / LOG_BASE + 2 | 0);
|
|
for (i2 = k; i2; --i2)
|
|
x = x.div(x.times(x).plus(1).sqrt().plus(1));
|
|
external = false;
|
|
j = Math.ceil(wpr / LOG_BASE);
|
|
n = 1;
|
|
x2 = x.times(x);
|
|
r = new Ctor(x);
|
|
px = x;
|
|
for (; i2 !== -1; ) {
|
|
px = px.times(x2);
|
|
t = r.minus(px.div(n += 2));
|
|
px = px.times(x2);
|
|
r = t.plus(px.div(n += 2));
|
|
if (r.d[j] !== void 0)
|
|
for (i2 = j; r.d[i2] === t.d[i2] && i2--; )
|
|
;
|
|
}
|
|
if (k)
|
|
r = r.times(2 << k - 1);
|
|
external = true;
|
|
return finalise(r, Ctor.precision = pr, Ctor.rounding = rm, true);
|
|
};
|
|
P.isFinite = function() {
|
|
return !!this.d;
|
|
};
|
|
P.isInteger = P.isInt = function() {
|
|
return !!this.d && mathfloor(this.e / LOG_BASE) > this.d.length - 2;
|
|
};
|
|
P.isNaN = function() {
|
|
return !this.s;
|
|
};
|
|
P.isNegative = P.isNeg = function() {
|
|
return this.s < 0;
|
|
};
|
|
P.isPositive = P.isPos = function() {
|
|
return this.s > 0;
|
|
};
|
|
P.isZero = function() {
|
|
return !!this.d && this.d[0] === 0;
|
|
};
|
|
P.lessThan = P.lt = function(y) {
|
|
return this.cmp(y) < 0;
|
|
};
|
|
P.lessThanOrEqualTo = P.lte = function(y) {
|
|
return this.cmp(y) < 1;
|
|
};
|
|
P.logarithm = P.log = function(base) {
|
|
var isBase10, d, denominator, k, inf, num, sd, r, arg2 = this, Ctor = arg2.constructor, pr = Ctor.precision, rm = Ctor.rounding, guard = 5;
|
|
if (base == null) {
|
|
base = new Ctor(10);
|
|
isBase10 = true;
|
|
} else {
|
|
base = new Ctor(base);
|
|
d = base.d;
|
|
if (base.s < 0 || !d || !d[0] || base.eq(1))
|
|
return new Ctor(NaN);
|
|
isBase10 = base.eq(10);
|
|
}
|
|
d = arg2.d;
|
|
if (arg2.s < 0 || !d || !d[0] || arg2.eq(1)) {
|
|
return new Ctor(d && !d[0] ? -1 / 0 : arg2.s != 1 ? NaN : d ? 0 : 1 / 0);
|
|
}
|
|
if (isBase10) {
|
|
if (d.length > 1) {
|
|
inf = true;
|
|
} else {
|
|
for (k = d[0]; k % 10 === 0; )
|
|
k /= 10;
|
|
inf = k !== 1;
|
|
}
|
|
}
|
|
external = false;
|
|
sd = pr + guard;
|
|
num = naturalLogarithm(arg2, sd);
|
|
denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
|
|
r = divide(num, denominator, sd, 1);
|
|
if (checkRoundingDigits(r.d, k = pr, rm)) {
|
|
do {
|
|
sd += 10;
|
|
num = naturalLogarithm(arg2, sd);
|
|
denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
|
|
r = divide(num, denominator, sd, 1);
|
|
if (!inf) {
|
|
if (+digitsToString(r.d).slice(k + 1, k + 15) + 1 == 1e14) {
|
|
r = finalise(r, pr + 1, 0);
|
|
}
|
|
break;
|
|
}
|
|
} while (checkRoundingDigits(r.d, k += 10, rm));
|
|
}
|
|
external = true;
|
|
return finalise(r, pr, rm);
|
|
};
|
|
P.minus = P.sub = function(y) {
|
|
var d, e3, i2, j, k, len, pr, rm, xd, xe, xLTy, yd, x = this, Ctor = x.constructor;
|
|
y = new Ctor(y);
|
|
if (!x.d || !y.d) {
|
|
if (!x.s || !y.s)
|
|
y = new Ctor(NaN);
|
|
else if (x.d)
|
|
y.s = -y.s;
|
|
else
|
|
y = new Ctor(y.d || x.s !== y.s ? x : NaN);
|
|
return y;
|
|
}
|
|
if (x.s != y.s) {
|
|
y.s = -y.s;
|
|
return x.plus(y);
|
|
}
|
|
xd = x.d;
|
|
yd = y.d;
|
|
pr = Ctor.precision;
|
|
rm = Ctor.rounding;
|
|
if (!xd[0] || !yd[0]) {
|
|
if (yd[0])
|
|
y.s = -y.s;
|
|
else if (xd[0])
|
|
y = new Ctor(x);
|
|
else
|
|
return new Ctor(rm === 3 ? -0 : 0);
|
|
return external ? finalise(y, pr, rm) : y;
|
|
}
|
|
e3 = mathfloor(y.e / LOG_BASE);
|
|
xe = mathfloor(x.e / LOG_BASE);
|
|
xd = xd.slice();
|
|
k = xe - e3;
|
|
if (k) {
|
|
xLTy = k < 0;
|
|
if (xLTy) {
|
|
d = xd;
|
|
k = -k;
|
|
len = yd.length;
|
|
} else {
|
|
d = yd;
|
|
e3 = xe;
|
|
len = xd.length;
|
|
}
|
|
i2 = Math.max(Math.ceil(pr / LOG_BASE), len) + 2;
|
|
if (k > i2) {
|
|
k = i2;
|
|
d.length = 1;
|
|
}
|
|
d.reverse();
|
|
for (i2 = k; i2--; )
|
|
d.push(0);
|
|
d.reverse();
|
|
} else {
|
|
i2 = xd.length;
|
|
len = yd.length;
|
|
xLTy = i2 < len;
|
|
if (xLTy)
|
|
len = i2;
|
|
for (i2 = 0; i2 < len; i2++) {
|
|
if (xd[i2] != yd[i2]) {
|
|
xLTy = xd[i2] < yd[i2];
|
|
break;
|
|
}
|
|
}
|
|
k = 0;
|
|
}
|
|
if (xLTy) {
|
|
d = xd;
|
|
xd = yd;
|
|
yd = d;
|
|
y.s = -y.s;
|
|
}
|
|
len = xd.length;
|
|
for (i2 = yd.length - len; i2 > 0; --i2)
|
|
xd[len++] = 0;
|
|
for (i2 = yd.length; i2 > k; ) {
|
|
if (xd[--i2] < yd[i2]) {
|
|
for (j = i2; j && xd[--j] === 0; )
|
|
xd[j] = BASE - 1;
|
|
--xd[j];
|
|
xd[i2] += BASE;
|
|
}
|
|
xd[i2] -= yd[i2];
|
|
}
|
|
for (; xd[--len] === 0; )
|
|
xd.pop();
|
|
for (; xd[0] === 0; xd.shift())
|
|
--e3;
|
|
if (!xd[0])
|
|
return new Ctor(rm === 3 ? -0 : 0);
|
|
y.d = xd;
|
|
y.e = getBase10Exponent(xd, e3);
|
|
return external ? finalise(y, pr, rm) : y;
|
|
};
|
|
P.modulo = P.mod = function(y) {
|
|
var q, x = this, Ctor = x.constructor;
|
|
y = new Ctor(y);
|
|
if (!x.d || !y.s || y.d && !y.d[0])
|
|
return new Ctor(NaN);
|
|
if (!y.d || x.d && !x.d[0]) {
|
|
return finalise(new Ctor(x), Ctor.precision, Ctor.rounding);
|
|
}
|
|
external = false;
|
|
if (Ctor.modulo == 9) {
|
|
q = divide(x, y.abs(), 0, 3, 1);
|
|
q.s *= y.s;
|
|
} else {
|
|
q = divide(x, y, 0, Ctor.modulo, 1);
|
|
}
|
|
q = q.times(y);
|
|
external = true;
|
|
return x.minus(q);
|
|
};
|
|
P.naturalExponential = P.exp = function() {
|
|
return naturalExponential(this);
|
|
};
|
|
P.naturalLogarithm = P.ln = function() {
|
|
return naturalLogarithm(this);
|
|
};
|
|
P.negated = P.neg = function() {
|
|
var x = new this.constructor(this);
|
|
x.s = -x.s;
|
|
return finalise(x);
|
|
};
|
|
P.plus = P.add = function(y) {
|
|
var carry, d, e3, i2, k, len, pr, rm, xd, yd, x = this, Ctor = x.constructor;
|
|
y = new Ctor(y);
|
|
if (!x.d || !y.d) {
|
|
if (!x.s || !y.s)
|
|
y = new Ctor(NaN);
|
|
else if (!x.d)
|
|
y = new Ctor(y.d || x.s === y.s ? x : NaN);
|
|
return y;
|
|
}
|
|
if (x.s != y.s) {
|
|
y.s = -y.s;
|
|
return x.minus(y);
|
|
}
|
|
xd = x.d;
|
|
yd = y.d;
|
|
pr = Ctor.precision;
|
|
rm = Ctor.rounding;
|
|
if (!xd[0] || !yd[0]) {
|
|
if (!yd[0])
|
|
y = new Ctor(x);
|
|
return external ? finalise(y, pr, rm) : y;
|
|
}
|
|
k = mathfloor(x.e / LOG_BASE);
|
|
e3 = mathfloor(y.e / LOG_BASE);
|
|
xd = xd.slice();
|
|
i2 = k - e3;
|
|
if (i2) {
|
|
if (i2 < 0) {
|
|
d = xd;
|
|
i2 = -i2;
|
|
len = yd.length;
|
|
} else {
|
|
d = yd;
|
|
e3 = k;
|
|
len = xd.length;
|
|
}
|
|
k = Math.ceil(pr / LOG_BASE);
|
|
len = k > len ? k + 1 : len + 1;
|
|
if (i2 > len) {
|
|
i2 = len;
|
|
d.length = 1;
|
|
}
|
|
d.reverse();
|
|
for (; i2--; )
|
|
d.push(0);
|
|
d.reverse();
|
|
}
|
|
len = xd.length;
|
|
i2 = yd.length;
|
|
if (len - i2 < 0) {
|
|
i2 = len;
|
|
d = yd;
|
|
yd = xd;
|
|
xd = d;
|
|
}
|
|
for (carry = 0; i2; ) {
|
|
carry = (xd[--i2] = xd[i2] + yd[i2] + carry) / BASE | 0;
|
|
xd[i2] %= BASE;
|
|
}
|
|
if (carry) {
|
|
xd.unshift(carry);
|
|
++e3;
|
|
}
|
|
for (len = xd.length; xd[--len] == 0; )
|
|
xd.pop();
|
|
y.d = xd;
|
|
y.e = getBase10Exponent(xd, e3);
|
|
return external ? finalise(y, pr, rm) : y;
|
|
};
|
|
P.precision = P.sd = function(z) {
|
|
var k, x = this;
|
|
if (z !== void 0 && z !== !!z && z !== 1 && z !== 0)
|
|
throw Error(invalidArgument + z);
|
|
if (x.d) {
|
|
k = getPrecision(x.d);
|
|
if (z && x.e + 1 > k)
|
|
k = x.e + 1;
|
|
} else {
|
|
k = NaN;
|
|
}
|
|
return k;
|
|
};
|
|
P.round = function() {
|
|
var x = this, Ctor = x.constructor;
|
|
return finalise(new Ctor(x), x.e + 1, Ctor.rounding);
|
|
};
|
|
P.sine = P.sin = function() {
|
|
var pr, rm, x = this, Ctor = x.constructor;
|
|
if (!x.isFinite())
|
|
return new Ctor(NaN);
|
|
if (x.isZero())
|
|
return new Ctor(x);
|
|
pr = Ctor.precision;
|
|
rm = Ctor.rounding;
|
|
Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
|
|
Ctor.rounding = 1;
|
|
x = sine(Ctor, toLessThanHalfPi(Ctor, x));
|
|
Ctor.precision = pr;
|
|
Ctor.rounding = rm;
|
|
return finalise(quadrant > 2 ? x.neg() : x, pr, rm, true);
|
|
};
|
|
P.squareRoot = P.sqrt = function() {
|
|
var m, n, sd, r, rep, t, x = this, d = x.d, e3 = x.e, s = x.s, Ctor = x.constructor;
|
|
if (s !== 1 || !d || !d[0]) {
|
|
return new Ctor(!s || s < 0 && (!d || d[0]) ? NaN : d ? x : 1 / 0);
|
|
}
|
|
external = false;
|
|
s = Math.sqrt(+x);
|
|
if (s == 0 || s == 1 / 0) {
|
|
n = digitsToString(d);
|
|
if ((n.length + e3) % 2 == 0)
|
|
n += "0";
|
|
s = Math.sqrt(n);
|
|
e3 = mathfloor((e3 + 1) / 2) - (e3 < 0 || e3 % 2);
|
|
if (s == 1 / 0) {
|
|
n = "5e" + e3;
|
|
} else {
|
|
n = s.toExponential();
|
|
n = n.slice(0, n.indexOf("e") + 1) + e3;
|
|
}
|
|
r = new Ctor(n);
|
|
} else {
|
|
r = new Ctor(s.toString());
|
|
}
|
|
sd = (e3 = Ctor.precision) + 3;
|
|
for (; ; ) {
|
|
t = r;
|
|
r = t.plus(divide(x, t, sd + 2, 1)).times(0.5);
|
|
if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
|
|
n = n.slice(sd - 3, sd + 1);
|
|
if (n == "9999" || !rep && n == "4999") {
|
|
if (!rep) {
|
|
finalise(t, e3 + 1, 0);
|
|
if (t.times(t).eq(x)) {
|
|
r = t;
|
|
break;
|
|
}
|
|
}
|
|
sd += 4;
|
|
rep = 1;
|
|
} else {
|
|
if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
|
|
finalise(r, e3 + 1, 1);
|
|
m = !r.times(r).eq(x);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
external = true;
|
|
return finalise(r, e3, Ctor.rounding, m);
|
|
};
|
|
P.tangent = P.tan = function() {
|
|
var pr, rm, x = this, Ctor = x.constructor;
|
|
if (!x.isFinite())
|
|
return new Ctor(NaN);
|
|
if (x.isZero())
|
|
return new Ctor(x);
|
|
pr = Ctor.precision;
|
|
rm = Ctor.rounding;
|
|
Ctor.precision = pr + 10;
|
|
Ctor.rounding = 1;
|
|
x = x.sin();
|
|
x.s = 1;
|
|
x = divide(x, new Ctor(1).minus(x.times(x)).sqrt(), pr + 10, 0);
|
|
Ctor.precision = pr;
|
|
Ctor.rounding = rm;
|
|
return finalise(quadrant == 2 || quadrant == 4 ? x.neg() : x, pr, rm, true);
|
|
};
|
|
P.times = P.mul = function(y) {
|
|
var carry, e3, i2, k, r, rL, t, xdL, ydL, x = this, Ctor = x.constructor, xd = x.d, yd = (y = new Ctor(y)).d;
|
|
y.s *= x.s;
|
|
if (!xd || !xd[0] || !yd || !yd[0]) {
|
|
return new Ctor(!y.s || xd && !xd[0] && !yd || yd && !yd[0] && !xd ? NaN : !xd || !yd ? y.s / 0 : y.s * 0);
|
|
}
|
|
e3 = mathfloor(x.e / LOG_BASE) + mathfloor(y.e / LOG_BASE);
|
|
xdL = xd.length;
|
|
ydL = yd.length;
|
|
if (xdL < ydL) {
|
|
r = xd;
|
|
xd = yd;
|
|
yd = r;
|
|
rL = xdL;
|
|
xdL = ydL;
|
|
ydL = rL;
|
|
}
|
|
r = [];
|
|
rL = xdL + ydL;
|
|
for (i2 = rL; i2--; )
|
|
r.push(0);
|
|
for (i2 = ydL; --i2 >= 0; ) {
|
|
carry = 0;
|
|
for (k = xdL + i2; k > i2; ) {
|
|
t = r[k] + yd[i2] * xd[k - i2 - 1] + carry;
|
|
r[k--] = t % BASE | 0;
|
|
carry = t / BASE | 0;
|
|
}
|
|
r[k] = (r[k] + carry) % BASE | 0;
|
|
}
|
|
for (; !r[--rL]; )
|
|
r.pop();
|
|
if (carry)
|
|
++e3;
|
|
else
|
|
r.shift();
|
|
y.d = r;
|
|
y.e = getBase10Exponent(r, e3);
|
|
return external ? finalise(y, Ctor.precision, Ctor.rounding) : y;
|
|
};
|
|
P.toBinary = function(sd, rm) {
|
|
return toStringBinary(this, 2, sd, rm);
|
|
};
|
|
P.toDecimalPlaces = P.toDP = function(dp, rm) {
|
|
var x = this, Ctor = x.constructor;
|
|
x = new Ctor(x);
|
|
if (dp === void 0)
|
|
return x;
|
|
checkInt32(dp, 0, MAX_DIGITS);
|
|
if (rm === void 0)
|
|
rm = Ctor.rounding;
|
|
else
|
|
checkInt32(rm, 0, 8);
|
|
return finalise(x, dp + x.e + 1, rm);
|
|
};
|
|
P.toExponential = function(dp, rm) {
|
|
var str, x = this, Ctor = x.constructor;
|
|
if (dp === void 0) {
|
|
str = finiteToString(x, true);
|
|
} else {
|
|
checkInt32(dp, 0, MAX_DIGITS);
|
|
if (rm === void 0)
|
|
rm = Ctor.rounding;
|
|
else
|
|
checkInt32(rm, 0, 8);
|
|
x = finalise(new Ctor(x), dp + 1, rm);
|
|
str = finiteToString(x, true, dp + 1);
|
|
}
|
|
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
};
|
|
P.toFixed = function(dp, rm) {
|
|
var str, y, x = this, Ctor = x.constructor;
|
|
if (dp === void 0) {
|
|
str = finiteToString(x);
|
|
} else {
|
|
checkInt32(dp, 0, MAX_DIGITS);
|
|
if (rm === void 0)
|
|
rm = Ctor.rounding;
|
|
else
|
|
checkInt32(rm, 0, 8);
|
|
y = finalise(new Ctor(x), dp + x.e + 1, rm);
|
|
str = finiteToString(y, false, dp + y.e + 1);
|
|
}
|
|
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
};
|
|
P.toFraction = function(maxD) {
|
|
var d, d0, d1, d2, e3, k, n, n0, n16, pr, q, r, x = this, xd = x.d, Ctor = x.constructor;
|
|
if (!xd)
|
|
return new Ctor(x);
|
|
n16 = d0 = new Ctor(1);
|
|
d1 = n0 = new Ctor(0);
|
|
d = new Ctor(d1);
|
|
e3 = d.e = getPrecision(xd) - x.e - 1;
|
|
k = e3 % LOG_BASE;
|
|
d.d[0] = mathpow(10, k < 0 ? LOG_BASE + k : k);
|
|
if (maxD == null) {
|
|
maxD = e3 > 0 ? d : n16;
|
|
} else {
|
|
n = new Ctor(maxD);
|
|
if (!n.isInt() || n.lt(n16))
|
|
throw Error(invalidArgument + n);
|
|
maxD = n.gt(d) ? e3 > 0 ? d : n16 : n;
|
|
}
|
|
external = false;
|
|
n = new Ctor(digitsToString(xd));
|
|
pr = Ctor.precision;
|
|
Ctor.precision = e3 = xd.length * LOG_BASE * 2;
|
|
for (; ; ) {
|
|
q = divide(n, d, 0, 1, 1);
|
|
d2 = d0.plus(q.times(d1));
|
|
if (d2.cmp(maxD) == 1)
|
|
break;
|
|
d0 = d1;
|
|
d1 = d2;
|
|
d2 = n16;
|
|
n16 = n0.plus(q.times(d2));
|
|
n0 = d2;
|
|
d2 = d;
|
|
d = n.minus(q.times(d2));
|
|
n = d2;
|
|
}
|
|
d2 = divide(maxD.minus(d0), d1, 0, 1, 1);
|
|
n0 = n0.plus(d2.times(n16));
|
|
d0 = d0.plus(d2.times(d1));
|
|
n0.s = n16.s = x.s;
|
|
r = divide(n16, d1, e3, 1).minus(x).abs().cmp(divide(n0, d0, e3, 1).minus(x).abs()) < 1 ? [n16, d1] : [n0, d0];
|
|
Ctor.precision = pr;
|
|
external = true;
|
|
return r;
|
|
};
|
|
P.toHexadecimal = P.toHex = function(sd, rm) {
|
|
return toStringBinary(this, 16, sd, rm);
|
|
};
|
|
P.toNearest = function(y, rm) {
|
|
var x = this, Ctor = x.constructor;
|
|
x = new Ctor(x);
|
|
if (y == null) {
|
|
if (!x.d)
|
|
return x;
|
|
y = new Ctor(1);
|
|
rm = Ctor.rounding;
|
|
} else {
|
|
y = new Ctor(y);
|
|
if (rm === void 0) {
|
|
rm = Ctor.rounding;
|
|
} else {
|
|
checkInt32(rm, 0, 8);
|
|
}
|
|
if (!x.d)
|
|
return y.s ? x : y;
|
|
if (!y.d) {
|
|
if (y.s)
|
|
y.s = x.s;
|
|
return y;
|
|
}
|
|
}
|
|
if (y.d[0]) {
|
|
external = false;
|
|
x = divide(x, y, 0, rm, 1).times(y);
|
|
external = true;
|
|
finalise(x);
|
|
} else {
|
|
y.s = x.s;
|
|
x = y;
|
|
}
|
|
return x;
|
|
};
|
|
P.toNumber = function() {
|
|
return +this;
|
|
};
|
|
P.toOctal = function(sd, rm) {
|
|
return toStringBinary(this, 8, sd, rm);
|
|
};
|
|
P.toPower = P.pow = function(y) {
|
|
var e3, k, pr, r, rm, s, x = this, Ctor = x.constructor, yn = +(y = new Ctor(y));
|
|
if (!x.d || !y.d || !x.d[0] || !y.d[0])
|
|
return new Ctor(mathpow(+x, yn));
|
|
x = new Ctor(x);
|
|
if (x.eq(1))
|
|
return x;
|
|
pr = Ctor.precision;
|
|
rm = Ctor.rounding;
|
|
if (y.eq(1))
|
|
return finalise(x, pr, rm);
|
|
e3 = mathfloor(y.e / LOG_BASE);
|
|
if (e3 >= y.d.length - 1 && (k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) {
|
|
r = intPow(Ctor, x, k, pr);
|
|
return y.s < 0 ? new Ctor(1).div(r) : finalise(r, pr, rm);
|
|
}
|
|
s = x.s;
|
|
if (s < 0) {
|
|
if (e3 < y.d.length - 1)
|
|
return new Ctor(NaN);
|
|
if ((y.d[e3] & 1) == 0)
|
|
s = 1;
|
|
if (x.e == 0 && x.d[0] == 1 && x.d.length == 1) {
|
|
x.s = s;
|
|
return x;
|
|
}
|
|
}
|
|
k = mathpow(+x, yn);
|
|
e3 = k == 0 || !isFinite(k) ? mathfloor(yn * (Math.log("0." + digitsToString(x.d)) / Math.LN10 + x.e + 1)) : new Ctor(k + "").e;
|
|
if (e3 > Ctor.maxE + 1 || e3 < Ctor.minE - 1)
|
|
return new Ctor(e3 > 0 ? s / 0 : 0);
|
|
external = false;
|
|
Ctor.rounding = x.s = 1;
|
|
k = Math.min(12, (e3 + "").length);
|
|
r = naturalExponential(y.times(naturalLogarithm(x, pr + k)), pr);
|
|
if (r.d) {
|
|
r = finalise(r, pr + 5, 1);
|
|
if (checkRoundingDigits(r.d, pr, rm)) {
|
|
e3 = pr + 10;
|
|
r = finalise(naturalExponential(y.times(naturalLogarithm(x, e3 + k)), e3), e3 + 5, 1);
|
|
if (+digitsToString(r.d).slice(pr + 1, pr + 15) + 1 == 1e14) {
|
|
r = finalise(r, pr + 1, 0);
|
|
}
|
|
}
|
|
}
|
|
r.s = s;
|
|
external = true;
|
|
Ctor.rounding = rm;
|
|
return finalise(r, pr, rm);
|
|
};
|
|
P.toPrecision = function(sd, rm) {
|
|
var str, x = this, Ctor = x.constructor;
|
|
if (sd === void 0) {
|
|
str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
|
|
} else {
|
|
checkInt32(sd, 1, MAX_DIGITS);
|
|
if (rm === void 0)
|
|
rm = Ctor.rounding;
|
|
else
|
|
checkInt32(rm, 0, 8);
|
|
x = finalise(new Ctor(x), sd, rm);
|
|
str = finiteToString(x, sd <= x.e || x.e <= Ctor.toExpNeg, sd);
|
|
}
|
|
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
};
|
|
P.toSignificantDigits = P.toSD = function(sd, rm) {
|
|
var x = this, Ctor = x.constructor;
|
|
if (sd === void 0) {
|
|
sd = Ctor.precision;
|
|
rm = Ctor.rounding;
|
|
} else {
|
|
checkInt32(sd, 1, MAX_DIGITS);
|
|
if (rm === void 0)
|
|
rm = Ctor.rounding;
|
|
else
|
|
checkInt32(rm, 0, 8);
|
|
}
|
|
return finalise(new Ctor(x), sd, rm);
|
|
};
|
|
P.toString = function() {
|
|
var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
|
|
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
};
|
|
P.truncated = P.trunc = function() {
|
|
return finalise(new this.constructor(this), this.e + 1, 1);
|
|
};
|
|
P.valueOf = P.toJSON = function() {
|
|
var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
|
|
return x.isNeg() ? "-" + str : str;
|
|
};
|
|
function digitsToString(d) {
|
|
var i2, k, ws, indexOfLastWord = d.length - 1, str = "", w = d[0];
|
|
if (indexOfLastWord > 0) {
|
|
str += w;
|
|
for (i2 = 1; i2 < indexOfLastWord; i2++) {
|
|
ws = d[i2] + "";
|
|
k = LOG_BASE - ws.length;
|
|
if (k)
|
|
str += getZeroString(k);
|
|
str += ws;
|
|
}
|
|
w = d[i2];
|
|
ws = w + "";
|
|
k = LOG_BASE - ws.length;
|
|
if (k)
|
|
str += getZeroString(k);
|
|
} else if (w === 0) {
|
|
return "0";
|
|
}
|
|
for (; w % 10 === 0; )
|
|
w /= 10;
|
|
return str + w;
|
|
}
|
|
function checkInt32(i2, min3, max3) {
|
|
if (i2 !== ~~i2 || i2 < min3 || i2 > max3) {
|
|
throw Error(invalidArgument + i2);
|
|
}
|
|
}
|
|
function checkRoundingDigits(d, i2, rm, repeating) {
|
|
var di, k, r, rd;
|
|
for (k = d[0]; k >= 10; k /= 10)
|
|
--i2;
|
|
if (--i2 < 0) {
|
|
i2 += LOG_BASE;
|
|
di = 0;
|
|
} else {
|
|
di = Math.ceil((i2 + 1) / LOG_BASE);
|
|
i2 %= LOG_BASE;
|
|
}
|
|
k = mathpow(10, LOG_BASE - i2);
|
|
rd = d[di] % k | 0;
|
|
if (repeating == null) {
|
|
if (i2 < 3) {
|
|
if (i2 == 0)
|
|
rd = rd / 100 | 0;
|
|
else if (i2 == 1)
|
|
rd = rd / 10 | 0;
|
|
r = rm < 4 && rd == 99999 || rm > 3 && rd == 49999 || rd == 5e4 || rd == 0;
|
|
} else {
|
|
r = (rm < 4 && rd + 1 == k || rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 100 | 0) == mathpow(10, i2 - 2) - 1 || (rd == k / 2 || rd == 0) && (d[di + 1] / k / 100 | 0) == 0;
|
|
}
|
|
} else {
|
|
if (i2 < 4) {
|
|
if (i2 == 0)
|
|
rd = rd / 1e3 | 0;
|
|
else if (i2 == 1)
|
|
rd = rd / 100 | 0;
|
|
else if (i2 == 2)
|
|
rd = rd / 10 | 0;
|
|
r = (repeating || rm < 4) && rd == 9999 || !repeating && rm > 3 && rd == 4999;
|
|
} else {
|
|
r = ((repeating || rm < 4) && rd + 1 == k || !repeating && rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 1e3 | 0) == mathpow(10, i2 - 3) - 1;
|
|
}
|
|
}
|
|
return r;
|
|
}
|
|
function convertBase(str, baseIn, baseOut) {
|
|
var j, arr = [0], arrL, i2 = 0, strL = str.length;
|
|
for (; i2 < strL; ) {
|
|
for (arrL = arr.length; arrL--; )
|
|
arr[arrL] *= baseIn;
|
|
arr[0] += NUMERALS.indexOf(str.charAt(i2++));
|
|
for (j = 0; j < arr.length; j++) {
|
|
if (arr[j] > baseOut - 1) {
|
|
if (arr[j + 1] === void 0)
|
|
arr[j + 1] = 0;
|
|
arr[j + 1] += arr[j] / baseOut | 0;
|
|
arr[j] %= baseOut;
|
|
}
|
|
}
|
|
}
|
|
return arr.reverse();
|
|
}
|
|
function cosine(Ctor, x) {
|
|
var k, len, y;
|
|
if (x.isZero())
|
|
return x;
|
|
len = x.d.length;
|
|
if (len < 32) {
|
|
k = Math.ceil(len / 3);
|
|
y = (1 / tinyPow(4, k)).toString();
|
|
} else {
|
|
k = 16;
|
|
y = "2.3283064365386962890625e-10";
|
|
}
|
|
Ctor.precision += k;
|
|
x = taylorSeries(Ctor, 1, x.times(y), new Ctor(1));
|
|
for (var i2 = k; i2--; ) {
|
|
var cos2x = x.times(x);
|
|
x = cos2x.times(cos2x).minus(cos2x).times(8).plus(1);
|
|
}
|
|
Ctor.precision -= k;
|
|
return x;
|
|
}
|
|
var divide = function() {
|
|
function multiplyInteger(x, k, base) {
|
|
var temp, carry = 0, i2 = x.length;
|
|
for (x = x.slice(); i2--; ) {
|
|
temp = x[i2] * k + carry;
|
|
x[i2] = temp % base | 0;
|
|
carry = temp / base | 0;
|
|
}
|
|
if (carry)
|
|
x.unshift(carry);
|
|
return x;
|
|
}
|
|
function compare2(a, b, aL, bL) {
|
|
var i2, r;
|
|
if (aL != bL) {
|
|
r = aL > bL ? 1 : -1;
|
|
} else {
|
|
for (i2 = r = 0; i2 < aL; i2++) {
|
|
if (a[i2] != b[i2]) {
|
|
r = a[i2] > b[i2] ? 1 : -1;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return r;
|
|
}
|
|
function subtract2(a, b, aL, base) {
|
|
var i2 = 0;
|
|
for (; aL--; ) {
|
|
a[aL] -= i2;
|
|
i2 = a[aL] < b[aL] ? 1 : 0;
|
|
a[aL] = i2 * base + a[aL] - b[aL];
|
|
}
|
|
for (; !a[0] && a.length > 1; )
|
|
a.shift();
|
|
}
|
|
return function(x, y, pr, rm, dp, base) {
|
|
var cmp, e3, i2, k, logBase, more, prod2, prodL, q, qd, rem, remL, rem0, sd, t, xi, xL, yd0, yL, yz, Ctor = x.constructor, sign4 = x.s == y.s ? 1 : -1, xd = x.d, yd = y.d;
|
|
if (!xd || !xd[0] || !yd || !yd[0]) {
|
|
return new Ctor(!x.s || !y.s || (xd ? yd && xd[0] == yd[0] : !yd) ? NaN : xd && xd[0] == 0 || !yd ? sign4 * 0 : sign4 / 0);
|
|
}
|
|
if (base) {
|
|
logBase = 1;
|
|
e3 = x.e - y.e;
|
|
} else {
|
|
base = BASE;
|
|
logBase = LOG_BASE;
|
|
e3 = mathfloor(x.e / logBase) - mathfloor(y.e / logBase);
|
|
}
|
|
yL = yd.length;
|
|
xL = xd.length;
|
|
q = new Ctor(sign4);
|
|
qd = q.d = [];
|
|
for (i2 = 0; yd[i2] == (xd[i2] || 0); i2++)
|
|
;
|
|
if (yd[i2] > (xd[i2] || 0))
|
|
e3--;
|
|
if (pr == null) {
|
|
sd = pr = Ctor.precision;
|
|
rm = Ctor.rounding;
|
|
} else if (dp) {
|
|
sd = pr + (x.e - y.e) + 1;
|
|
} else {
|
|
sd = pr;
|
|
}
|
|
if (sd < 0) {
|
|
qd.push(1);
|
|
more = true;
|
|
} else {
|
|
sd = sd / logBase + 2 | 0;
|
|
i2 = 0;
|
|
if (yL == 1) {
|
|
k = 0;
|
|
yd = yd[0];
|
|
sd++;
|
|
for (; (i2 < xL || k) && sd--; i2++) {
|
|
t = k * base + (xd[i2] || 0);
|
|
qd[i2] = t / yd | 0;
|
|
k = t % yd | 0;
|
|
}
|
|
more = k || i2 < xL;
|
|
} else {
|
|
k = base / (yd[0] + 1) | 0;
|
|
if (k > 1) {
|
|
yd = multiplyInteger(yd, k, base);
|
|
xd = multiplyInteger(xd, k, base);
|
|
yL = yd.length;
|
|
xL = xd.length;
|
|
}
|
|
xi = yL;
|
|
rem = xd.slice(0, yL);
|
|
remL = rem.length;
|
|
for (; remL < yL; )
|
|
rem[remL++] = 0;
|
|
yz = yd.slice();
|
|
yz.unshift(0);
|
|
yd0 = yd[0];
|
|
if (yd[1] >= base / 2)
|
|
++yd0;
|
|
do {
|
|
k = 0;
|
|
cmp = compare2(yd, rem, yL, remL);
|
|
if (cmp < 0) {
|
|
rem0 = rem[0];
|
|
if (yL != remL)
|
|
rem0 = rem0 * base + (rem[1] || 0);
|
|
k = rem0 / yd0 | 0;
|
|
if (k > 1) {
|
|
if (k >= base)
|
|
k = base - 1;
|
|
prod2 = multiplyInteger(yd, k, base);
|
|
prodL = prod2.length;
|
|
remL = rem.length;
|
|
cmp = compare2(prod2, rem, prodL, remL);
|
|
if (cmp == 1) {
|
|
k--;
|
|
subtract2(prod2, yL < prodL ? yz : yd, prodL, base);
|
|
}
|
|
} else {
|
|
if (k == 0)
|
|
cmp = k = 1;
|
|
prod2 = yd.slice();
|
|
}
|
|
prodL = prod2.length;
|
|
if (prodL < remL)
|
|
prod2.unshift(0);
|
|
subtract2(rem, prod2, remL, base);
|
|
if (cmp == -1) {
|
|
remL = rem.length;
|
|
cmp = compare2(yd, rem, yL, remL);
|
|
if (cmp < 1) {
|
|
k++;
|
|
subtract2(rem, yL < remL ? yz : yd, remL, base);
|
|
}
|
|
}
|
|
remL = rem.length;
|
|
} else if (cmp === 0) {
|
|
k++;
|
|
rem = [0];
|
|
}
|
|
qd[i2++] = k;
|
|
if (cmp && rem[0]) {
|
|
rem[remL++] = xd[xi] || 0;
|
|
} else {
|
|
rem = [xd[xi]];
|
|
remL = 1;
|
|
}
|
|
} while ((xi++ < xL || rem[0] !== void 0) && sd--);
|
|
more = rem[0] !== void 0;
|
|
}
|
|
if (!qd[0])
|
|
qd.shift();
|
|
}
|
|
if (logBase == 1) {
|
|
q.e = e3;
|
|
inexact = more;
|
|
} else {
|
|
for (i2 = 1, k = qd[0]; k >= 10; k /= 10)
|
|
i2++;
|
|
q.e = i2 + e3 * logBase - 1;
|
|
finalise(q, dp ? pr + q.e + 1 : pr, rm, more);
|
|
}
|
|
return q;
|
|
};
|
|
}();
|
|
function finalise(x, sd, rm, isTruncated) {
|
|
var digits2, i2, j, k, rd, roundUp, w, xd, xdi, Ctor = x.constructor;
|
|
out:
|
|
if (sd != null) {
|
|
xd = x.d;
|
|
if (!xd)
|
|
return x;
|
|
for (digits2 = 1, k = xd[0]; k >= 10; k /= 10)
|
|
digits2++;
|
|
i2 = sd - digits2;
|
|
if (i2 < 0) {
|
|
i2 += LOG_BASE;
|
|
j = sd;
|
|
w = xd[xdi = 0];
|
|
rd = w / mathpow(10, digits2 - j - 1) % 10 | 0;
|
|
} else {
|
|
xdi = Math.ceil((i2 + 1) / LOG_BASE);
|
|
k = xd.length;
|
|
if (xdi >= k) {
|
|
if (isTruncated) {
|
|
for (; k++ <= xdi; )
|
|
xd.push(0);
|
|
w = rd = 0;
|
|
digits2 = 1;
|
|
i2 %= LOG_BASE;
|
|
j = i2 - LOG_BASE + 1;
|
|
} else {
|
|
break out;
|
|
}
|
|
} else {
|
|
w = k = xd[xdi];
|
|
for (digits2 = 1; k >= 10; k /= 10)
|
|
digits2++;
|
|
i2 %= LOG_BASE;
|
|
j = i2 - LOG_BASE + digits2;
|
|
rd = j < 0 ? 0 : w / mathpow(10, digits2 - j - 1) % 10 | 0;
|
|
}
|
|
}
|
|
isTruncated = isTruncated || sd < 0 || xd[xdi + 1] !== void 0 || (j < 0 ? w : w % mathpow(10, digits2 - j - 1));
|
|
roundUp = rm < 4 ? (rd || isTruncated) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || isTruncated || rm == 6 && (i2 > 0 ? j > 0 ? w / mathpow(10, digits2 - j) : 0 : xd[xdi - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
|
|
if (sd < 1 || !xd[0]) {
|
|
xd.length = 0;
|
|
if (roundUp) {
|
|
sd -= x.e + 1;
|
|
xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE);
|
|
x.e = -sd || 0;
|
|
} else {
|
|
xd[0] = x.e = 0;
|
|
}
|
|
return x;
|
|
}
|
|
if (i2 == 0) {
|
|
xd.length = xdi;
|
|
k = 1;
|
|
xdi--;
|
|
} else {
|
|
xd.length = xdi + 1;
|
|
k = mathpow(10, LOG_BASE - i2);
|
|
xd[xdi] = j > 0 ? (w / mathpow(10, digits2 - j) % mathpow(10, j) | 0) * k : 0;
|
|
}
|
|
if (roundUp) {
|
|
for (; ; ) {
|
|
if (xdi == 0) {
|
|
for (i2 = 1, j = xd[0]; j >= 10; j /= 10)
|
|
i2++;
|
|
j = xd[0] += k;
|
|
for (k = 1; j >= 10; j /= 10)
|
|
k++;
|
|
if (i2 != k) {
|
|
x.e++;
|
|
if (xd[0] == BASE)
|
|
xd[0] = 1;
|
|
}
|
|
break;
|
|
} else {
|
|
xd[xdi] += k;
|
|
if (xd[xdi] != BASE)
|
|
break;
|
|
xd[xdi--] = 0;
|
|
k = 1;
|
|
}
|
|
}
|
|
}
|
|
for (i2 = xd.length; xd[--i2] === 0; )
|
|
xd.pop();
|
|
}
|
|
if (external) {
|
|
if (x.e > Ctor.maxE) {
|
|
x.d = null;
|
|
x.e = NaN;
|
|
} else if (x.e < Ctor.minE) {
|
|
x.e = 0;
|
|
x.d = [0];
|
|
}
|
|
}
|
|
return x;
|
|
}
|
|
function finiteToString(x, isExp, sd) {
|
|
if (!x.isFinite())
|
|
return nonFiniteToString(x);
|
|
var k, e3 = x.e, str = digitsToString(x.d), len = str.length;
|
|
if (isExp) {
|
|
if (sd && (k = sd - len) > 0) {
|
|
str = str.charAt(0) + "." + str.slice(1) + getZeroString(k);
|
|
} else if (len > 1) {
|
|
str = str.charAt(0) + "." + str.slice(1);
|
|
}
|
|
str = str + (x.e < 0 ? "e" : "e+") + x.e;
|
|
} else if (e3 < 0) {
|
|
str = "0." + getZeroString(-e3 - 1) + str;
|
|
if (sd && (k = sd - len) > 0)
|
|
str += getZeroString(k);
|
|
} else if (e3 >= len) {
|
|
str += getZeroString(e3 + 1 - len);
|
|
if (sd && (k = sd - e3 - 1) > 0)
|
|
str = str + "." + getZeroString(k);
|
|
} else {
|
|
if ((k = e3 + 1) < len)
|
|
str = str.slice(0, k) + "." + str.slice(k);
|
|
if (sd && (k = sd - len) > 0) {
|
|
if (e3 + 1 === len)
|
|
str += ".";
|
|
str += getZeroString(k);
|
|
}
|
|
}
|
|
return str;
|
|
}
|
|
function getBase10Exponent(digits2, e3) {
|
|
var w = digits2[0];
|
|
for (e3 *= LOG_BASE; w >= 10; w /= 10)
|
|
e3++;
|
|
return e3;
|
|
}
|
|
function getLn10(Ctor, sd, pr) {
|
|
if (sd > LN10_PRECISION) {
|
|
external = true;
|
|
if (pr)
|
|
Ctor.precision = pr;
|
|
throw Error(precisionLimitExceeded);
|
|
}
|
|
return finalise(new Ctor(LN10), sd, 1, true);
|
|
}
|
|
function getPi(Ctor, sd, rm) {
|
|
if (sd > PI_PRECISION)
|
|
throw Error(precisionLimitExceeded);
|
|
return finalise(new Ctor(PI), sd, rm, true);
|
|
}
|
|
function getPrecision(digits2) {
|
|
var w = digits2.length - 1, len = w * LOG_BASE + 1;
|
|
w = digits2[w];
|
|
if (w) {
|
|
for (; w % 10 == 0; w /= 10)
|
|
len--;
|
|
for (w = digits2[0]; w >= 10; w /= 10)
|
|
len++;
|
|
}
|
|
return len;
|
|
}
|
|
function getZeroString(k) {
|
|
var zs = "";
|
|
for (; k--; )
|
|
zs += "0";
|
|
return zs;
|
|
}
|
|
function intPow(Ctor, x, n, pr) {
|
|
var isTruncated, r = new Ctor(1), k = Math.ceil(pr / LOG_BASE + 4);
|
|
external = false;
|
|
for (; ; ) {
|
|
if (n % 2) {
|
|
r = r.times(x);
|
|
if (truncate(r.d, k))
|
|
isTruncated = true;
|
|
}
|
|
n = mathfloor(n / 2);
|
|
if (n === 0) {
|
|
n = r.d.length - 1;
|
|
if (isTruncated && r.d[n] === 0)
|
|
++r.d[n];
|
|
break;
|
|
}
|
|
x = x.times(x);
|
|
truncate(x.d, k);
|
|
}
|
|
external = true;
|
|
return r;
|
|
}
|
|
function isOdd(n) {
|
|
return n.d[n.d.length - 1] & 1;
|
|
}
|
|
function maxOrMin(Ctor, args, ltgt) {
|
|
var y, x = new Ctor(args[0]), i2 = 0;
|
|
for (; ++i2 < args.length; ) {
|
|
y = new Ctor(args[i2]);
|
|
if (!y.s) {
|
|
x = y;
|
|
break;
|
|
} else if (x[ltgt](y)) {
|
|
x = y;
|
|
}
|
|
}
|
|
return x;
|
|
}
|
|
function naturalExponential(x, sd) {
|
|
var denominator, guard, j, pow3, sum3, t, wpr, rep = 0, i2 = 0, k = 0, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
|
|
if (!x.d || !x.d[0] || x.e > 17) {
|
|
return new Ctor(x.d ? !x.d[0] ? 1 : x.s < 0 ? 0 : 1 / 0 : x.s ? x.s < 0 ? 0 : x : 0 / 0);
|
|
}
|
|
if (sd == null) {
|
|
external = false;
|
|
wpr = pr;
|
|
} else {
|
|
wpr = sd;
|
|
}
|
|
t = new Ctor(0.03125);
|
|
while (x.e > -2) {
|
|
x = x.times(t);
|
|
k += 5;
|
|
}
|
|
guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0;
|
|
wpr += guard;
|
|
denominator = pow3 = sum3 = new Ctor(1);
|
|
Ctor.precision = wpr;
|
|
for (; ; ) {
|
|
pow3 = finalise(pow3.times(x), wpr, 1);
|
|
denominator = denominator.times(++i2);
|
|
t = sum3.plus(divide(pow3, denominator, wpr, 1));
|
|
if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum3.d).slice(0, wpr)) {
|
|
j = k;
|
|
while (j--)
|
|
sum3 = finalise(sum3.times(sum3), wpr, 1);
|
|
if (sd == null) {
|
|
if (rep < 3 && checkRoundingDigits(sum3.d, wpr - guard, rm, rep)) {
|
|
Ctor.precision = wpr += 10;
|
|
denominator = pow3 = t = new Ctor(1);
|
|
i2 = 0;
|
|
rep++;
|
|
} else {
|
|
return finalise(sum3, Ctor.precision = pr, rm, external = true);
|
|
}
|
|
} else {
|
|
Ctor.precision = pr;
|
|
return sum3;
|
|
}
|
|
}
|
|
sum3 = t;
|
|
}
|
|
}
|
|
function naturalLogarithm(y, sd) {
|
|
var c, c0, denominator, e3, numerator, rep, sum3, t, wpr, x1, x2, n = 1, guard = 10, x = y, xd = x.d, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
|
|
if (x.s < 0 || !xd || !xd[0] || !x.e && xd[0] == 1 && xd.length == 1) {
|
|
return new Ctor(xd && !xd[0] ? -1 / 0 : x.s != 1 ? NaN : xd ? 0 : x);
|
|
}
|
|
if (sd == null) {
|
|
external = false;
|
|
wpr = pr;
|
|
} else {
|
|
wpr = sd;
|
|
}
|
|
Ctor.precision = wpr += guard;
|
|
c = digitsToString(xd);
|
|
c0 = c.charAt(0);
|
|
if (Math.abs(e3 = x.e) < 15e14) {
|
|
while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) {
|
|
x = x.times(y);
|
|
c = digitsToString(x.d);
|
|
c0 = c.charAt(0);
|
|
n++;
|
|
}
|
|
e3 = x.e;
|
|
if (c0 > 1) {
|
|
x = new Ctor("0." + c);
|
|
e3++;
|
|
} else {
|
|
x = new Ctor(c0 + "." + c.slice(1));
|
|
}
|
|
} else {
|
|
t = getLn10(Ctor, wpr + 2, pr).times(e3 + "");
|
|
x = naturalLogarithm(new Ctor(c0 + "." + c.slice(1)), wpr - guard).plus(t);
|
|
Ctor.precision = pr;
|
|
return sd == null ? finalise(x, pr, rm, external = true) : x;
|
|
}
|
|
x1 = x;
|
|
sum3 = numerator = x = divide(x.minus(1), x.plus(1), wpr, 1);
|
|
x2 = finalise(x.times(x), wpr, 1);
|
|
denominator = 3;
|
|
for (; ; ) {
|
|
numerator = finalise(numerator.times(x2), wpr, 1);
|
|
t = sum3.plus(divide(numerator, new Ctor(denominator), wpr, 1));
|
|
if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum3.d).slice(0, wpr)) {
|
|
sum3 = sum3.times(2);
|
|
if (e3 !== 0)
|
|
sum3 = sum3.plus(getLn10(Ctor, wpr + 2, pr).times(e3 + ""));
|
|
sum3 = divide(sum3, new Ctor(n), wpr, 1);
|
|
if (sd == null) {
|
|
if (checkRoundingDigits(sum3.d, wpr - guard, rm, rep)) {
|
|
Ctor.precision = wpr += guard;
|
|
t = numerator = x = divide(x1.minus(1), x1.plus(1), wpr, 1);
|
|
x2 = finalise(x.times(x), wpr, 1);
|
|
denominator = rep = 1;
|
|
} else {
|
|
return finalise(sum3, Ctor.precision = pr, rm, external = true);
|
|
}
|
|
} else {
|
|
Ctor.precision = pr;
|
|
return sum3;
|
|
}
|
|
}
|
|
sum3 = t;
|
|
denominator += 2;
|
|
}
|
|
}
|
|
function nonFiniteToString(x) {
|
|
return String(x.s * x.s / 0);
|
|
}
|
|
function parseDecimal(x, str) {
|
|
var e3, i2, len;
|
|
if ((e3 = str.indexOf(".")) > -1)
|
|
str = str.replace(".", "");
|
|
if ((i2 = str.search(/e/i)) > 0) {
|
|
if (e3 < 0)
|
|
e3 = i2;
|
|
e3 += +str.slice(i2 + 1);
|
|
str = str.substring(0, i2);
|
|
} else if (e3 < 0) {
|
|
e3 = str.length;
|
|
}
|
|
for (i2 = 0; str.charCodeAt(i2) === 48; i2++)
|
|
;
|
|
for (len = str.length; str.charCodeAt(len - 1) === 48; --len)
|
|
;
|
|
str = str.slice(i2, len);
|
|
if (str) {
|
|
len -= i2;
|
|
x.e = e3 = e3 - i2 - 1;
|
|
x.d = [];
|
|
i2 = (e3 + 1) % LOG_BASE;
|
|
if (e3 < 0)
|
|
i2 += LOG_BASE;
|
|
if (i2 < len) {
|
|
if (i2)
|
|
x.d.push(+str.slice(0, i2));
|
|
for (len -= LOG_BASE; i2 < len; )
|
|
x.d.push(+str.slice(i2, i2 += LOG_BASE));
|
|
str = str.slice(i2);
|
|
i2 = LOG_BASE - str.length;
|
|
} else {
|
|
i2 -= len;
|
|
}
|
|
for (; i2--; )
|
|
str += "0";
|
|
x.d.push(+str);
|
|
if (external) {
|
|
if (x.e > x.constructor.maxE) {
|
|
x.d = null;
|
|
x.e = NaN;
|
|
} else if (x.e < x.constructor.minE) {
|
|
x.e = 0;
|
|
x.d = [0];
|
|
}
|
|
}
|
|
} else {
|
|
x.e = 0;
|
|
x.d = [0];
|
|
}
|
|
return x;
|
|
}
|
|
function parseOther(x, str) {
|
|
var base, Ctor, divisor, i2, isFloat, len, p, xd, xe;
|
|
if (str.indexOf("_") > -1) {
|
|
str = str.replace(/(\d)_(?=\d)/g, "$1");
|
|
if (isDecimal.test(str))
|
|
return parseDecimal(x, str);
|
|
} else if (str === "Infinity" || str === "NaN") {
|
|
if (!+str)
|
|
x.s = NaN;
|
|
x.e = NaN;
|
|
x.d = null;
|
|
return x;
|
|
}
|
|
if (isHex.test(str)) {
|
|
base = 16;
|
|
str = str.toLowerCase();
|
|
} else if (isBinary.test(str)) {
|
|
base = 2;
|
|
} else if (isOctal.test(str)) {
|
|
base = 8;
|
|
} else {
|
|
throw Error(invalidArgument + str);
|
|
}
|
|
i2 = str.search(/p/i);
|
|
if (i2 > 0) {
|
|
p = +str.slice(i2 + 1);
|
|
str = str.substring(2, i2);
|
|
} else {
|
|
str = str.slice(2);
|
|
}
|
|
i2 = str.indexOf(".");
|
|
isFloat = i2 >= 0;
|
|
Ctor = x.constructor;
|
|
if (isFloat) {
|
|
str = str.replace(".", "");
|
|
len = str.length;
|
|
i2 = len - i2;
|
|
divisor = intPow(Ctor, new Ctor(base), i2, i2 * 2);
|
|
}
|
|
xd = convertBase(str, base, BASE);
|
|
xe = xd.length - 1;
|
|
for (i2 = xe; xd[i2] === 0; --i2)
|
|
xd.pop();
|
|
if (i2 < 0)
|
|
return new Ctor(x.s * 0);
|
|
x.e = getBase10Exponent(xd, xe);
|
|
x.d = xd;
|
|
external = false;
|
|
if (isFloat)
|
|
x = divide(x, divisor, len * 4);
|
|
if (p)
|
|
x = x.times(Math.abs(p) < 54 ? mathpow(2, p) : Decimal.pow(2, p));
|
|
external = true;
|
|
return x;
|
|
}
|
|
function sine(Ctor, x) {
|
|
var k, len = x.d.length;
|
|
if (len < 3) {
|
|
return x.isZero() ? x : taylorSeries(Ctor, 2, x, x);
|
|
}
|
|
k = 1.4 * Math.sqrt(len);
|
|
k = k > 16 ? 16 : k | 0;
|
|
x = x.times(1 / tinyPow(5, k));
|
|
x = taylorSeries(Ctor, 2, x, x);
|
|
var sin2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
|
|
for (; k--; ) {
|
|
sin2_x = x.times(x);
|
|
x = x.times(d5.plus(sin2_x.times(d16.times(sin2_x).minus(d20))));
|
|
}
|
|
return x;
|
|
}
|
|
function taylorSeries(Ctor, n, x, y, isHyperbolic) {
|
|
var j, t, u, x2, i2 = 1, pr = Ctor.precision, k = Math.ceil(pr / LOG_BASE);
|
|
external = false;
|
|
x2 = x.times(x);
|
|
u = new Ctor(y);
|
|
for (; ; ) {
|
|
t = divide(u.times(x2), new Ctor(n++ * n++), pr, 1);
|
|
u = isHyperbolic ? y.plus(t) : y.minus(t);
|
|
y = divide(t.times(x2), new Ctor(n++ * n++), pr, 1);
|
|
t = u.plus(y);
|
|
if (t.d[k] !== void 0) {
|
|
for (j = k; t.d[j] === u.d[j] && j--; )
|
|
;
|
|
if (j == -1)
|
|
break;
|
|
}
|
|
j = u;
|
|
u = y;
|
|
y = t;
|
|
t = j;
|
|
i2++;
|
|
}
|
|
external = true;
|
|
t.d.length = k + 1;
|
|
return t;
|
|
}
|
|
function tinyPow(b, e3) {
|
|
var n = b;
|
|
while (--e3)
|
|
n *= b;
|
|
return n;
|
|
}
|
|
function toLessThanHalfPi(Ctor, x) {
|
|
var t, isNeg = x.s < 0, pi3 = getPi(Ctor, Ctor.precision, 1), halfPi = pi3.times(0.5);
|
|
x = x.abs();
|
|
if (x.lte(halfPi)) {
|
|
quadrant = isNeg ? 4 : 1;
|
|
return x;
|
|
}
|
|
t = x.divToInt(pi3);
|
|
if (t.isZero()) {
|
|
quadrant = isNeg ? 3 : 2;
|
|
} else {
|
|
x = x.minus(t.times(pi3));
|
|
if (x.lte(halfPi)) {
|
|
quadrant = isOdd(t) ? isNeg ? 2 : 3 : isNeg ? 4 : 1;
|
|
return x;
|
|
}
|
|
quadrant = isOdd(t) ? isNeg ? 1 : 4 : isNeg ? 3 : 2;
|
|
}
|
|
return x.minus(pi3).abs();
|
|
}
|
|
function toStringBinary(x, baseOut, sd, rm) {
|
|
var base, e3, i2, k, len, roundUp, str, xd, y, Ctor = x.constructor, isExp = sd !== void 0;
|
|
if (isExp) {
|
|
checkInt32(sd, 1, MAX_DIGITS);
|
|
if (rm === void 0)
|
|
rm = Ctor.rounding;
|
|
else
|
|
checkInt32(rm, 0, 8);
|
|
} else {
|
|
sd = Ctor.precision;
|
|
rm = Ctor.rounding;
|
|
}
|
|
if (!x.isFinite()) {
|
|
str = nonFiniteToString(x);
|
|
} else {
|
|
str = finiteToString(x);
|
|
i2 = str.indexOf(".");
|
|
if (isExp) {
|
|
base = 2;
|
|
if (baseOut == 16) {
|
|
sd = sd * 4 - 3;
|
|
} else if (baseOut == 8) {
|
|
sd = sd * 3 - 2;
|
|
}
|
|
} else {
|
|
base = baseOut;
|
|
}
|
|
if (i2 >= 0) {
|
|
str = str.replace(".", "");
|
|
y = new Ctor(1);
|
|
y.e = str.length - i2;
|
|
y.d = convertBase(finiteToString(y), 10, base);
|
|
y.e = y.d.length;
|
|
}
|
|
xd = convertBase(str, 10, base);
|
|
e3 = len = xd.length;
|
|
for (; xd[--len] == 0; )
|
|
xd.pop();
|
|
if (!xd[0]) {
|
|
str = isExp ? "0p+0" : "0";
|
|
} else {
|
|
if (i2 < 0) {
|
|
e3--;
|
|
} else {
|
|
x = new Ctor(x);
|
|
x.d = xd;
|
|
x.e = e3;
|
|
x = divide(x, y, sd, rm, 0, base);
|
|
xd = x.d;
|
|
e3 = x.e;
|
|
roundUp = inexact;
|
|
}
|
|
i2 = xd[sd];
|
|
k = base / 2;
|
|
roundUp = roundUp || xd[sd + 1] !== void 0;
|
|
roundUp = rm < 4 ? (i2 !== void 0 || roundUp) && (rm === 0 || rm === (x.s < 0 ? 3 : 2)) : i2 > k || i2 === k && (rm === 4 || roundUp || rm === 6 && xd[sd - 1] & 1 || rm === (x.s < 0 ? 8 : 7));
|
|
xd.length = sd;
|
|
if (roundUp) {
|
|
for (; ++xd[--sd] > base - 1; ) {
|
|
xd[sd] = 0;
|
|
if (!sd) {
|
|
++e3;
|
|
xd.unshift(1);
|
|
}
|
|
}
|
|
}
|
|
for (len = xd.length; !xd[len - 1]; --len)
|
|
;
|
|
for (i2 = 0, str = ""; i2 < len; i2++)
|
|
str += NUMERALS.charAt(xd[i2]);
|
|
if (isExp) {
|
|
if (len > 1) {
|
|
if (baseOut == 16 || baseOut == 8) {
|
|
i2 = baseOut == 16 ? 4 : 3;
|
|
for (--len; len % i2; len++)
|
|
str += "0";
|
|
xd = convertBase(str, base, baseOut);
|
|
for (len = xd.length; !xd[len - 1]; --len)
|
|
;
|
|
for (i2 = 1, str = "1."; i2 < len; i2++)
|
|
str += NUMERALS.charAt(xd[i2]);
|
|
} else {
|
|
str = str.charAt(0) + "." + str.slice(1);
|
|
}
|
|
}
|
|
str = str + (e3 < 0 ? "p" : "p+") + e3;
|
|
} else if (e3 < 0) {
|
|
for (; ++e3; )
|
|
str = "0" + str;
|
|
str = "0." + str;
|
|
} else {
|
|
if (++e3 > len)
|
|
for (e3 -= len; e3--; )
|
|
str += "0";
|
|
else if (e3 < len)
|
|
str = str.slice(0, e3) + "." + str.slice(e3);
|
|
}
|
|
}
|
|
str = (baseOut == 16 ? "0x" : baseOut == 2 ? "0b" : baseOut == 8 ? "0o" : "") + str;
|
|
}
|
|
return x.s < 0 ? "-" + str : str;
|
|
}
|
|
function truncate(arr, len) {
|
|
if (arr.length > len) {
|
|
arr.length = len;
|
|
return true;
|
|
}
|
|
}
|
|
function abs(x) {
|
|
return new this(x).abs();
|
|
}
|
|
function acos(x) {
|
|
return new this(x).acos();
|
|
}
|
|
function acosh2(x) {
|
|
return new this(x).acosh();
|
|
}
|
|
function add(x, y) {
|
|
return new this(x).plus(y);
|
|
}
|
|
function asin(x) {
|
|
return new this(x).asin();
|
|
}
|
|
function asinh2(x) {
|
|
return new this(x).asinh();
|
|
}
|
|
function atan(x) {
|
|
return new this(x).atan();
|
|
}
|
|
function atanh2(x) {
|
|
return new this(x).atanh();
|
|
}
|
|
function atan2(y, x) {
|
|
y = new this(y);
|
|
x = new this(x);
|
|
var r, pr = this.precision, rm = this.rounding, wpr = pr + 4;
|
|
if (!y.s || !x.s) {
|
|
r = new this(NaN);
|
|
} else if (!y.d && !x.d) {
|
|
r = getPi(this, wpr, 1).times(x.s > 0 ? 0.25 : 0.75);
|
|
r.s = y.s;
|
|
} else if (!x.d || y.isZero()) {
|
|
r = x.s < 0 ? getPi(this, pr, rm) : new this(0);
|
|
r.s = y.s;
|
|
} else if (!y.d || x.isZero()) {
|
|
r = getPi(this, wpr, 1).times(0.5);
|
|
r.s = y.s;
|
|
} else if (x.s < 0) {
|
|
this.precision = wpr;
|
|
this.rounding = 1;
|
|
r = this.atan(divide(y, x, wpr, 1));
|
|
x = getPi(this, wpr, 1);
|
|
this.precision = pr;
|
|
this.rounding = rm;
|
|
r = y.s < 0 ? r.minus(x) : r.plus(x);
|
|
} else {
|
|
r = this.atan(divide(y, x, wpr, 1));
|
|
}
|
|
return r;
|
|
}
|
|
function cbrt3(x) {
|
|
return new this(x).cbrt();
|
|
}
|
|
function ceil(x) {
|
|
return finalise(x = new this(x), x.e + 1, 2);
|
|
}
|
|
function clamp(x, min3, max3) {
|
|
return new this(x).clamp(min3, max3);
|
|
}
|
|
function config3(obj) {
|
|
if (!obj || typeof obj !== "object")
|
|
throw Error(decimalError + "Object expected");
|
|
var i2, p, v, useDefaults = obj.defaults === true, ps = [
|
|
"precision",
|
|
1,
|
|
MAX_DIGITS,
|
|
"rounding",
|
|
0,
|
|
8,
|
|
"toExpNeg",
|
|
-EXP_LIMIT,
|
|
0,
|
|
"toExpPos",
|
|
0,
|
|
EXP_LIMIT,
|
|
"maxE",
|
|
0,
|
|
EXP_LIMIT,
|
|
"minE",
|
|
-EXP_LIMIT,
|
|
0,
|
|
"modulo",
|
|
0,
|
|
9
|
|
];
|
|
for (i2 = 0; i2 < ps.length; i2 += 3) {
|
|
if (p = ps[i2], useDefaults)
|
|
this[p] = DEFAULTS[p];
|
|
if ((v = obj[p]) !== void 0) {
|
|
if (mathfloor(v) === v && v >= ps[i2 + 1] && v <= ps[i2 + 2])
|
|
this[p] = v;
|
|
else
|
|
throw Error(invalidArgument + p + ": " + v);
|
|
}
|
|
}
|
|
if (p = "crypto", useDefaults)
|
|
this[p] = DEFAULTS[p];
|
|
if ((v = obj[p]) !== void 0) {
|
|
if (v === true || v === false || v === 0 || v === 1) {
|
|
if (v) {
|
|
if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
|
|
this[p] = true;
|
|
} else {
|
|
throw Error(cryptoUnavailable);
|
|
}
|
|
} else {
|
|
this[p] = false;
|
|
}
|
|
} else {
|
|
throw Error(invalidArgument + p + ": " + v);
|
|
}
|
|
}
|
|
return this;
|
|
}
|
|
function cos(x) {
|
|
return new this(x).cos();
|
|
}
|
|
function cosh2(x) {
|
|
return new this(x).cosh();
|
|
}
|
|
function clone2(obj) {
|
|
var i2, p, ps;
|
|
function Decimal2(v) {
|
|
var e3, i3, t, x = this;
|
|
if (!(x instanceof Decimal2))
|
|
return new Decimal2(v);
|
|
x.constructor = Decimal2;
|
|
if (isDecimalInstance(v)) {
|
|
x.s = v.s;
|
|
if (external) {
|
|
if (!v.d || v.e > Decimal2.maxE) {
|
|
x.e = NaN;
|
|
x.d = null;
|
|
} else if (v.e < Decimal2.minE) {
|
|
x.e = 0;
|
|
x.d = [0];
|
|
} else {
|
|
x.e = v.e;
|
|
x.d = v.d.slice();
|
|
}
|
|
} else {
|
|
x.e = v.e;
|
|
x.d = v.d ? v.d.slice() : v.d;
|
|
}
|
|
return;
|
|
}
|
|
t = typeof v;
|
|
if (t === "number") {
|
|
if (v === 0) {
|
|
x.s = 1 / v < 0 ? -1 : 1;
|
|
x.e = 0;
|
|
x.d = [0];
|
|
return;
|
|
}
|
|
if (v < 0) {
|
|
v = -v;
|
|
x.s = -1;
|
|
} else {
|
|
x.s = 1;
|
|
}
|
|
if (v === ~~v && v < 1e7) {
|
|
for (e3 = 0, i3 = v; i3 >= 10; i3 /= 10)
|
|
e3++;
|
|
if (external) {
|
|
if (e3 > Decimal2.maxE) {
|
|
x.e = NaN;
|
|
x.d = null;
|
|
} else if (e3 < Decimal2.minE) {
|
|
x.e = 0;
|
|
x.d = [0];
|
|
} else {
|
|
x.e = e3;
|
|
x.d = [v];
|
|
}
|
|
} else {
|
|
x.e = e3;
|
|
x.d = [v];
|
|
}
|
|
return;
|
|
} else if (v * 0 !== 0) {
|
|
if (!v)
|
|
x.s = NaN;
|
|
x.e = NaN;
|
|
x.d = null;
|
|
return;
|
|
}
|
|
return parseDecimal(x, v.toString());
|
|
} else if (t !== "string") {
|
|
throw Error(invalidArgument + v);
|
|
}
|
|
if ((i3 = v.charCodeAt(0)) === 45) {
|
|
v = v.slice(1);
|
|
x.s = -1;
|
|
} else {
|
|
if (i3 === 43)
|
|
v = v.slice(1);
|
|
x.s = 1;
|
|
}
|
|
return isDecimal.test(v) ? parseDecimal(x, v) : parseOther(x, v);
|
|
}
|
|
Decimal2.prototype = P;
|
|
Decimal2.ROUND_UP = 0;
|
|
Decimal2.ROUND_DOWN = 1;
|
|
Decimal2.ROUND_CEIL = 2;
|
|
Decimal2.ROUND_FLOOR = 3;
|
|
Decimal2.ROUND_HALF_UP = 4;
|
|
Decimal2.ROUND_HALF_DOWN = 5;
|
|
Decimal2.ROUND_HALF_EVEN = 6;
|
|
Decimal2.ROUND_HALF_CEIL = 7;
|
|
Decimal2.ROUND_HALF_FLOOR = 8;
|
|
Decimal2.EUCLID = 9;
|
|
Decimal2.config = Decimal2.set = config3;
|
|
Decimal2.clone = clone2;
|
|
Decimal2.isDecimal = isDecimalInstance;
|
|
Decimal2.abs = abs;
|
|
Decimal2.acos = acos;
|
|
Decimal2.acosh = acosh2;
|
|
Decimal2.add = add;
|
|
Decimal2.asin = asin;
|
|
Decimal2.asinh = asinh2;
|
|
Decimal2.atan = atan;
|
|
Decimal2.atanh = atanh2;
|
|
Decimal2.atan2 = atan2;
|
|
Decimal2.cbrt = cbrt3;
|
|
Decimal2.ceil = ceil;
|
|
Decimal2.clamp = clamp;
|
|
Decimal2.cos = cos;
|
|
Decimal2.cosh = cosh2;
|
|
Decimal2.div = div;
|
|
Decimal2.exp = exp;
|
|
Decimal2.floor = floor;
|
|
Decimal2.hypot = hypot;
|
|
Decimal2.ln = ln;
|
|
Decimal2.log = log;
|
|
Decimal2.log10 = log103;
|
|
Decimal2.log2 = log23;
|
|
Decimal2.max = max;
|
|
Decimal2.min = min;
|
|
Decimal2.mod = mod;
|
|
Decimal2.mul = mul;
|
|
Decimal2.pow = pow;
|
|
Decimal2.random = random;
|
|
Decimal2.round = round;
|
|
Decimal2.sign = sign2;
|
|
Decimal2.sin = sin;
|
|
Decimal2.sinh = sinh2;
|
|
Decimal2.sqrt = sqrt;
|
|
Decimal2.sub = sub;
|
|
Decimal2.sum = sum;
|
|
Decimal2.tan = tan;
|
|
Decimal2.tanh = tanh2;
|
|
Decimal2.trunc = trunc;
|
|
if (obj === void 0)
|
|
obj = {};
|
|
if (obj) {
|
|
if (obj.defaults !== true) {
|
|
ps = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"];
|
|
for (i2 = 0; i2 < ps.length; )
|
|
if (!obj.hasOwnProperty(p = ps[i2++]))
|
|
obj[p] = this[p];
|
|
}
|
|
}
|
|
Decimal2.config(obj);
|
|
return Decimal2;
|
|
}
|
|
function div(x, y) {
|
|
return new this(x).div(y);
|
|
}
|
|
function exp(x) {
|
|
return new this(x).exp();
|
|
}
|
|
function floor(x) {
|
|
return finalise(x = new this(x), x.e + 1, 3);
|
|
}
|
|
function hypot() {
|
|
var i2, n, t = new this(0);
|
|
external = false;
|
|
for (i2 = 0; i2 < arguments.length; ) {
|
|
n = new this(arguments[i2++]);
|
|
if (!n.d) {
|
|
if (n.s) {
|
|
external = true;
|
|
return new this(1 / 0);
|
|
}
|
|
t = n;
|
|
} else if (t.d) {
|
|
t = t.plus(n.times(n));
|
|
}
|
|
}
|
|
external = true;
|
|
return t.sqrt();
|
|
}
|
|
function isDecimalInstance(obj) {
|
|
return obj instanceof Decimal || obj && obj.toStringTag === tag || false;
|
|
}
|
|
function ln(x) {
|
|
return new this(x).ln();
|
|
}
|
|
function log(x, y) {
|
|
return new this(x).log(y);
|
|
}
|
|
function log23(x) {
|
|
return new this(x).log(2);
|
|
}
|
|
function log103(x) {
|
|
return new this(x).log(10);
|
|
}
|
|
function max() {
|
|
return maxOrMin(this, arguments, "lt");
|
|
}
|
|
function min() {
|
|
return maxOrMin(this, arguments, "gt");
|
|
}
|
|
function mod(x, y) {
|
|
return new this(x).mod(y);
|
|
}
|
|
function mul(x, y) {
|
|
return new this(x).mul(y);
|
|
}
|
|
function pow(x, y) {
|
|
return new this(x).pow(y);
|
|
}
|
|
function random(sd) {
|
|
var d, e3, k, n, i2 = 0, r = new this(1), rd = [];
|
|
if (sd === void 0)
|
|
sd = this.precision;
|
|
else
|
|
checkInt32(sd, 1, MAX_DIGITS);
|
|
k = Math.ceil(sd / LOG_BASE);
|
|
if (!this.crypto) {
|
|
for (; i2 < k; )
|
|
rd[i2++] = Math.random() * 1e7 | 0;
|
|
} else if (crypto.getRandomValues) {
|
|
d = crypto.getRandomValues(new Uint32Array(k));
|
|
for (; i2 < k; ) {
|
|
n = d[i2];
|
|
if (n >= 429e7) {
|
|
d[i2] = crypto.getRandomValues(new Uint32Array(1))[0];
|
|
} else {
|
|
rd[i2++] = n % 1e7;
|
|
}
|
|
}
|
|
} else if (crypto.randomBytes) {
|
|
d = crypto.randomBytes(k *= 4);
|
|
for (; i2 < k; ) {
|
|
n = d[i2] + (d[i2 + 1] << 8) + (d[i2 + 2] << 16) + ((d[i2 + 3] & 127) << 24);
|
|
if (n >= 214e7) {
|
|
crypto.randomBytes(4).copy(d, i2);
|
|
} else {
|
|
rd.push(n % 1e7);
|
|
i2 += 4;
|
|
}
|
|
}
|
|
i2 = k / 4;
|
|
} else {
|
|
throw Error(cryptoUnavailable);
|
|
}
|
|
k = rd[--i2];
|
|
sd %= LOG_BASE;
|
|
if (k && sd) {
|
|
n = mathpow(10, LOG_BASE - sd);
|
|
rd[i2] = (k / n | 0) * n;
|
|
}
|
|
for (; rd[i2] === 0; i2--)
|
|
rd.pop();
|
|
if (i2 < 0) {
|
|
e3 = 0;
|
|
rd = [0];
|
|
} else {
|
|
e3 = -1;
|
|
for (; rd[0] === 0; e3 -= LOG_BASE)
|
|
rd.shift();
|
|
for (k = 1, n = rd[0]; n >= 10; n /= 10)
|
|
k++;
|
|
if (k < LOG_BASE)
|
|
e3 -= LOG_BASE - k;
|
|
}
|
|
r.e = e3;
|
|
r.d = rd;
|
|
return r;
|
|
}
|
|
function round(x) {
|
|
return finalise(x = new this(x), x.e + 1, this.rounding);
|
|
}
|
|
function sign2(x) {
|
|
x = new this(x);
|
|
return x.d ? x.d[0] ? x.s : 0 * x.s : x.s || NaN;
|
|
}
|
|
function sin(x) {
|
|
return new this(x).sin();
|
|
}
|
|
function sinh2(x) {
|
|
return new this(x).sinh();
|
|
}
|
|
function sqrt(x) {
|
|
return new this(x).sqrt();
|
|
}
|
|
function sub(x, y) {
|
|
return new this(x).sub(y);
|
|
}
|
|
function sum() {
|
|
var i2 = 0, args = arguments, x = new this(args[i2]);
|
|
external = false;
|
|
for (; x.s && ++i2 < args.length; )
|
|
x = x.plus(args[i2]);
|
|
external = true;
|
|
return finalise(x, this.precision, this.rounding);
|
|
}
|
|
function tan(x) {
|
|
return new this(x).tan();
|
|
}
|
|
function tanh2(x) {
|
|
return new this(x).tanh();
|
|
}
|
|
function trunc(x) {
|
|
return finalise(x = new this(x), x.e + 1, 1);
|
|
}
|
|
P[Symbol.for("nodejs.util.inspect.custom")] = P.toString;
|
|
P[Symbol.toStringTag] = "Decimal";
|
|
var Decimal = P.constructor = clone2(DEFAULTS);
|
|
LN10 = new Decimal(LN10);
|
|
PI = new Decimal(PI);
|
|
var decimal_default = Decimal;
|
|
|
|
// node_modules/mathjs/lib/esm/type/bignumber/BigNumber.js
|
|
var name2 = "BigNumber";
|
|
var dependencies3 = ["?on", "config"];
|
|
var createBigNumberClass = /* @__PURE__ */ factory(name2, dependencies3, (_ref) => {
|
|
var {
|
|
on,
|
|
config: config4
|
|
} = _ref;
|
|
var BigNumber2 = decimal_default.clone({
|
|
precision: config4.precision,
|
|
modulo: decimal_default.EUCLID
|
|
});
|
|
BigNumber2.prototype = Object.create(BigNumber2.prototype);
|
|
BigNumber2.prototype.type = "BigNumber";
|
|
BigNumber2.prototype.isBigNumber = true;
|
|
BigNumber2.prototype.toJSON = function() {
|
|
return {
|
|
mathjs: "BigNumber",
|
|
value: this.toString()
|
|
};
|
|
};
|
|
BigNumber2.fromJSON = function(json) {
|
|
return new BigNumber2(json.value);
|
|
};
|
|
if (on) {
|
|
on("config", function(curr, prev) {
|
|
if (curr.precision !== prev.precision) {
|
|
BigNumber2.config({
|
|
precision: curr.precision
|
|
});
|
|
}
|
|
});
|
|
}
|
|
return BigNumber2;
|
|
}, {
|
|
isClass: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/complex/Complex.js
|
|
var import_complex = __toESM(require_complex(), 1);
|
|
var name3 = "Complex";
|
|
var dependencies4 = [];
|
|
var createComplexClass = /* @__PURE__ */ factory(name3, dependencies4, () => {
|
|
Object.defineProperty(import_complex.default, "name", {
|
|
value: "Complex"
|
|
});
|
|
import_complex.default.prototype.constructor = import_complex.default;
|
|
import_complex.default.prototype.type = "Complex";
|
|
import_complex.default.prototype.isComplex = true;
|
|
import_complex.default.prototype.toJSON = function() {
|
|
return {
|
|
mathjs: "Complex",
|
|
re: this.re,
|
|
im: this.im
|
|
};
|
|
};
|
|
import_complex.default.prototype.toPolar = function() {
|
|
return {
|
|
r: this.abs(),
|
|
phi: this.arg()
|
|
};
|
|
};
|
|
import_complex.default.prototype.format = function(options) {
|
|
var str = "";
|
|
var im2 = this.im;
|
|
var re2 = this.re;
|
|
var strRe = format(this.re, options);
|
|
var strIm = format(this.im, options);
|
|
var precision = isNumber(options) ? options : options ? options.precision : null;
|
|
if (precision !== null) {
|
|
var epsilon = Math.pow(10, -precision);
|
|
if (Math.abs(re2 / im2) < epsilon) {
|
|
re2 = 0;
|
|
}
|
|
if (Math.abs(im2 / re2) < epsilon) {
|
|
im2 = 0;
|
|
}
|
|
}
|
|
if (im2 === 0) {
|
|
str = strRe;
|
|
} else if (re2 === 0) {
|
|
if (im2 === 1) {
|
|
str = "i";
|
|
} else if (im2 === -1) {
|
|
str = "-i";
|
|
} else {
|
|
str = strIm + "i";
|
|
}
|
|
} else {
|
|
if (im2 < 0) {
|
|
if (im2 === -1) {
|
|
str = strRe + " - i";
|
|
} else {
|
|
str = strRe + " - " + strIm.substring(1) + "i";
|
|
}
|
|
} else {
|
|
if (im2 === 1) {
|
|
str = strRe + " + i";
|
|
} else {
|
|
str = strRe + " + " + strIm + "i";
|
|
}
|
|
}
|
|
}
|
|
return str;
|
|
};
|
|
import_complex.default.fromPolar = function(args) {
|
|
switch (arguments.length) {
|
|
case 1: {
|
|
var arg2 = arguments[0];
|
|
if (typeof arg2 === "object") {
|
|
return (0, import_complex.default)(arg2);
|
|
} else {
|
|
throw new TypeError("Input has to be an object with r and phi keys.");
|
|
}
|
|
}
|
|
case 2: {
|
|
var r = arguments[0];
|
|
var phi3 = arguments[1];
|
|
if (isNumber(r)) {
|
|
if (isUnit(phi3) && phi3.hasBase("ANGLE")) {
|
|
phi3 = phi3.toNumber("rad");
|
|
}
|
|
if (isNumber(phi3)) {
|
|
return new import_complex.default({
|
|
r,
|
|
phi: phi3
|
|
});
|
|
}
|
|
throw new TypeError("Phi is not a number nor an angle unit.");
|
|
} else {
|
|
throw new TypeError("Radius r is not a number.");
|
|
}
|
|
}
|
|
default:
|
|
throw new SyntaxError("Wrong number of arguments in function fromPolar");
|
|
}
|
|
};
|
|
import_complex.default.prototype.valueOf = import_complex.default.prototype.toString;
|
|
import_complex.default.fromJSON = function(json) {
|
|
return new import_complex.default(json);
|
|
};
|
|
import_complex.default.compare = function(a, b) {
|
|
if (a.re > b.re) {
|
|
return 1;
|
|
}
|
|
if (a.re < b.re) {
|
|
return -1;
|
|
}
|
|
if (a.im > b.im) {
|
|
return 1;
|
|
}
|
|
if (a.im < b.im) {
|
|
return -1;
|
|
}
|
|
return 0;
|
|
};
|
|
return import_complex.default;
|
|
}, {
|
|
isClass: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/fraction/Fraction.js
|
|
var import_fraction = __toESM(require_fraction(), 1);
|
|
var name4 = "Fraction";
|
|
var dependencies5 = [];
|
|
var createFractionClass = /* @__PURE__ */ factory(name4, dependencies5, () => {
|
|
Object.defineProperty(import_fraction.default, "name", {
|
|
value: "Fraction"
|
|
});
|
|
import_fraction.default.prototype.constructor = import_fraction.default;
|
|
import_fraction.default.prototype.type = "Fraction";
|
|
import_fraction.default.prototype.isFraction = true;
|
|
import_fraction.default.prototype.toJSON = function() {
|
|
return {
|
|
mathjs: "Fraction",
|
|
n: this.s * this.n,
|
|
d: this.d
|
|
};
|
|
};
|
|
import_fraction.default.fromJSON = function(json) {
|
|
return new import_fraction.default(json);
|
|
};
|
|
return import_fraction.default;
|
|
}, {
|
|
isClass: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/Range.js
|
|
var name5 = "Range";
|
|
var dependencies6 = [];
|
|
var createRangeClass = /* @__PURE__ */ factory(name5, dependencies6, () => {
|
|
function Range2(start, end, step) {
|
|
if (!(this instanceof Range2)) {
|
|
throw new SyntaxError("Constructor must be called with the new operator");
|
|
}
|
|
var hasStart = start !== null && start !== void 0;
|
|
var hasEnd = end !== null && end !== void 0;
|
|
var hasStep = step !== null && step !== void 0;
|
|
if (hasStart) {
|
|
if (isBigNumber(start)) {
|
|
start = start.toNumber();
|
|
} else if (typeof start !== "number") {
|
|
throw new TypeError("Parameter start must be a number");
|
|
}
|
|
}
|
|
if (hasEnd) {
|
|
if (isBigNumber(end)) {
|
|
end = end.toNumber();
|
|
} else if (typeof end !== "number") {
|
|
throw new TypeError("Parameter end must be a number");
|
|
}
|
|
}
|
|
if (hasStep) {
|
|
if (isBigNumber(step)) {
|
|
step = step.toNumber();
|
|
} else if (typeof step !== "number") {
|
|
throw new TypeError("Parameter step must be a number");
|
|
}
|
|
}
|
|
this.start = hasStart ? parseFloat(start) : 0;
|
|
this.end = hasEnd ? parseFloat(end) : 0;
|
|
this.step = hasStep ? parseFloat(step) : 1;
|
|
}
|
|
Range2.prototype.type = "Range";
|
|
Range2.prototype.isRange = true;
|
|
Range2.parse = function(str) {
|
|
if (typeof str !== "string") {
|
|
return null;
|
|
}
|
|
var args = str.split(":");
|
|
var nums = args.map(function(arg2) {
|
|
return parseFloat(arg2);
|
|
});
|
|
var invalid = nums.some(function(num) {
|
|
return isNaN(num);
|
|
});
|
|
if (invalid) {
|
|
return null;
|
|
}
|
|
switch (nums.length) {
|
|
case 2:
|
|
return new Range2(nums[0], nums[1]);
|
|
case 3:
|
|
return new Range2(nums[0], nums[2], nums[1]);
|
|
default:
|
|
return null;
|
|
}
|
|
};
|
|
Range2.prototype.clone = function() {
|
|
return new Range2(this.start, this.end, this.step);
|
|
};
|
|
Range2.prototype.size = function() {
|
|
var len = 0;
|
|
var start = this.start;
|
|
var step = this.step;
|
|
var end = this.end;
|
|
var diff2 = end - start;
|
|
if (sign(step) === sign(diff2)) {
|
|
len = Math.ceil(diff2 / step);
|
|
} else if (diff2 === 0) {
|
|
len = 0;
|
|
}
|
|
if (isNaN(len)) {
|
|
len = 0;
|
|
}
|
|
return [len];
|
|
};
|
|
Range2.prototype.min = function() {
|
|
var size2 = this.size()[0];
|
|
if (size2 > 0) {
|
|
if (this.step > 0) {
|
|
return this.start;
|
|
} else {
|
|
return this.start + (size2 - 1) * this.step;
|
|
}
|
|
} else {
|
|
return void 0;
|
|
}
|
|
};
|
|
Range2.prototype.max = function() {
|
|
var size2 = this.size()[0];
|
|
if (size2 > 0) {
|
|
if (this.step > 0) {
|
|
return this.start + (size2 - 1) * this.step;
|
|
} else {
|
|
return this.start;
|
|
}
|
|
} else {
|
|
return void 0;
|
|
}
|
|
};
|
|
Range2.prototype.forEach = function(callback) {
|
|
var x = this.start;
|
|
var step = this.step;
|
|
var end = this.end;
|
|
var i2 = 0;
|
|
if (step > 0) {
|
|
while (x < end) {
|
|
callback(x, [i2], this);
|
|
x += step;
|
|
i2++;
|
|
}
|
|
} else if (step < 0) {
|
|
while (x > end) {
|
|
callback(x, [i2], this);
|
|
x += step;
|
|
i2++;
|
|
}
|
|
}
|
|
};
|
|
Range2.prototype.map = function(callback) {
|
|
var array = [];
|
|
this.forEach(function(value, index2, obj) {
|
|
array[index2[0]] = callback(value, index2, obj);
|
|
});
|
|
return array;
|
|
};
|
|
Range2.prototype.toArray = function() {
|
|
var array = [];
|
|
this.forEach(function(value, index2) {
|
|
array[index2[0]] = value;
|
|
});
|
|
return array;
|
|
};
|
|
Range2.prototype.valueOf = function() {
|
|
return this.toArray();
|
|
};
|
|
Range2.prototype.format = function(options) {
|
|
var str = format(this.start, options);
|
|
if (this.step !== 1) {
|
|
str += ":" + format(this.step, options);
|
|
}
|
|
str += ":" + format(this.end, options);
|
|
return str;
|
|
};
|
|
Range2.prototype.toString = function() {
|
|
return this.format();
|
|
};
|
|
Range2.prototype.toJSON = function() {
|
|
return {
|
|
mathjs: "Range",
|
|
start: this.start,
|
|
end: this.end,
|
|
step: this.step
|
|
};
|
|
};
|
|
Range2.fromJSON = function(json) {
|
|
return new Range2(json.start, json.end, json.step);
|
|
};
|
|
return Range2;
|
|
}, {
|
|
isClass: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/Matrix.js
|
|
var name6 = "Matrix";
|
|
var dependencies7 = [];
|
|
var createMatrixClass = /* @__PURE__ */ factory(name6, dependencies7, () => {
|
|
function Matrix2() {
|
|
if (!(this instanceof Matrix2)) {
|
|
throw new SyntaxError("Constructor must be called with the new operator");
|
|
}
|
|
}
|
|
Matrix2.prototype.type = "Matrix";
|
|
Matrix2.prototype.isMatrix = true;
|
|
Matrix2.prototype.storage = function() {
|
|
throw new Error("Cannot invoke storage on a Matrix interface");
|
|
};
|
|
Matrix2.prototype.datatype = function() {
|
|
throw new Error("Cannot invoke datatype on a Matrix interface");
|
|
};
|
|
Matrix2.prototype.create = function(data, datatype) {
|
|
throw new Error("Cannot invoke create on a Matrix interface");
|
|
};
|
|
Matrix2.prototype.subset = function(index2, replacement, defaultValue) {
|
|
throw new Error("Cannot invoke subset on a Matrix interface");
|
|
};
|
|
Matrix2.prototype.get = function(index2) {
|
|
throw new Error("Cannot invoke get on a Matrix interface");
|
|
};
|
|
Matrix2.prototype.set = function(index2, value, defaultValue) {
|
|
throw new Error("Cannot invoke set on a Matrix interface");
|
|
};
|
|
Matrix2.prototype.resize = function(size2, defaultValue) {
|
|
throw new Error("Cannot invoke resize on a Matrix interface");
|
|
};
|
|
Matrix2.prototype.reshape = function(size2, defaultValue) {
|
|
throw new Error("Cannot invoke reshape on a Matrix interface");
|
|
};
|
|
Matrix2.prototype.clone = function() {
|
|
throw new Error("Cannot invoke clone on a Matrix interface");
|
|
};
|
|
Matrix2.prototype.size = function() {
|
|
throw new Error("Cannot invoke size on a Matrix interface");
|
|
};
|
|
Matrix2.prototype.map = function(callback, skipZeros) {
|
|
throw new Error("Cannot invoke map on a Matrix interface");
|
|
};
|
|
Matrix2.prototype.forEach = function(callback) {
|
|
throw new Error("Cannot invoke forEach on a Matrix interface");
|
|
};
|
|
Matrix2.prototype[Symbol.iterator] = function() {
|
|
throw new Error("Cannot iterate a Matrix interface");
|
|
};
|
|
Matrix2.prototype.toArray = function() {
|
|
throw new Error("Cannot invoke toArray on a Matrix interface");
|
|
};
|
|
Matrix2.prototype.valueOf = function() {
|
|
throw new Error("Cannot invoke valueOf on a Matrix interface");
|
|
};
|
|
Matrix2.prototype.format = function(options) {
|
|
throw new Error("Cannot invoke format on a Matrix interface");
|
|
};
|
|
Matrix2.prototype.toString = function() {
|
|
throw new Error("Cannot invoke toString on a Matrix interface");
|
|
};
|
|
return Matrix2;
|
|
}, {
|
|
isClass: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/utils/lruQueue.js
|
|
function lruQueue(limit) {
|
|
var size2 = 0;
|
|
var base = 1;
|
|
var queue = /* @__PURE__ */ Object.create(null);
|
|
var map3 = /* @__PURE__ */ Object.create(null);
|
|
var index2 = 0;
|
|
var del = function del2(id) {
|
|
var oldIndex = map3[id];
|
|
if (!oldIndex)
|
|
return;
|
|
delete queue[oldIndex];
|
|
delete map3[id];
|
|
--size2;
|
|
if (base !== oldIndex)
|
|
return;
|
|
if (!size2) {
|
|
index2 = 0;
|
|
base = 1;
|
|
return;
|
|
}
|
|
while (!hasOwnProperty.call(queue, ++base)) {
|
|
continue;
|
|
}
|
|
};
|
|
limit = Math.abs(limit);
|
|
return {
|
|
hit: function hit(id) {
|
|
var oldIndex = map3[id];
|
|
var nuIndex = ++index2;
|
|
queue[nuIndex] = id;
|
|
map3[id] = nuIndex;
|
|
if (!oldIndex) {
|
|
++size2;
|
|
if (size2 <= limit)
|
|
return void 0;
|
|
id = queue[base];
|
|
del(id);
|
|
return id;
|
|
}
|
|
delete queue[oldIndex];
|
|
if (base !== oldIndex)
|
|
return void 0;
|
|
while (!hasOwnProperty.call(queue, ++base)) {
|
|
continue;
|
|
}
|
|
return void 0;
|
|
},
|
|
delete: del,
|
|
clear: function clear() {
|
|
size2 = index2 = 0;
|
|
base = 1;
|
|
queue = /* @__PURE__ */ Object.create(null);
|
|
map3 = /* @__PURE__ */ Object.create(null);
|
|
}
|
|
};
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/utils/function.js
|
|
function memoize(fn) {
|
|
var {
|
|
hasher: hasher2,
|
|
limit
|
|
} = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
limit = limit == null ? Number.POSITIVE_INFINITY : limit;
|
|
hasher2 = hasher2 == null ? JSON.stringify : hasher2;
|
|
return function memoize2() {
|
|
if (typeof memoize2.cache !== "object") {
|
|
memoize2.cache = {
|
|
values: /* @__PURE__ */ new Map(),
|
|
lru: lruQueue(limit || Number.POSITIVE_INFINITY)
|
|
};
|
|
}
|
|
var args = [];
|
|
for (var i2 = 0; i2 < arguments.length; i2++) {
|
|
args[i2] = arguments[i2];
|
|
}
|
|
var hash = hasher2(args);
|
|
if (memoize2.cache.values.has(hash)) {
|
|
memoize2.cache.lru.hit(hash);
|
|
return memoize2.cache.values.get(hash);
|
|
}
|
|
var newVal = fn.apply(fn, args);
|
|
memoize2.cache.values.set(hash, newVal);
|
|
memoize2.cache.values.delete(memoize2.cache.lru.hit(hash));
|
|
return newVal;
|
|
};
|
|
}
|
|
function maxArgumentCount(fn) {
|
|
return Object.keys(fn.signatures || {}).reduce(function(args, signature) {
|
|
var count2 = (signature.match(/,/g) || []).length + 1;
|
|
return Math.max(args, count2);
|
|
}, -1);
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/DenseMatrix.js
|
|
var name7 = "DenseMatrix";
|
|
var dependencies8 = ["Matrix"];
|
|
var createDenseMatrixClass = /* @__PURE__ */ factory(name7, dependencies8, (_ref) => {
|
|
var {
|
|
Matrix: Matrix2
|
|
} = _ref;
|
|
function DenseMatrix2(data, datatype) {
|
|
if (!(this instanceof DenseMatrix2)) {
|
|
throw new SyntaxError("Constructor must be called with the new operator");
|
|
}
|
|
if (datatype && !isString(datatype)) {
|
|
throw new Error("Invalid datatype: " + datatype);
|
|
}
|
|
if (isMatrix(data)) {
|
|
if (data.type === "DenseMatrix") {
|
|
this._data = clone(data._data);
|
|
this._size = clone(data._size);
|
|
this._datatype = datatype || data._datatype;
|
|
} else {
|
|
this._data = data.toArray();
|
|
this._size = data.size();
|
|
this._datatype = datatype || data._datatype;
|
|
}
|
|
} else if (data && isArray(data.data) && isArray(data.size)) {
|
|
this._data = data.data;
|
|
this._size = data.size;
|
|
validate(this._data, this._size);
|
|
this._datatype = datatype || data.datatype;
|
|
} else if (isArray(data)) {
|
|
this._data = preprocess(data);
|
|
this._size = arraySize(this._data);
|
|
validate(this._data, this._size);
|
|
this._datatype = datatype;
|
|
} else if (data) {
|
|
throw new TypeError("Unsupported type of data (" + typeOf(data) + ")");
|
|
} else {
|
|
this._data = [];
|
|
this._size = [0];
|
|
this._datatype = datatype;
|
|
}
|
|
}
|
|
DenseMatrix2.prototype = new Matrix2();
|
|
DenseMatrix2.prototype.createDenseMatrix = function(data, datatype) {
|
|
return new DenseMatrix2(data, datatype);
|
|
};
|
|
Object.defineProperty(DenseMatrix2, "name", {
|
|
value: "DenseMatrix"
|
|
});
|
|
DenseMatrix2.prototype.constructor = DenseMatrix2;
|
|
DenseMatrix2.prototype.type = "DenseMatrix";
|
|
DenseMatrix2.prototype.isDenseMatrix = true;
|
|
DenseMatrix2.prototype.getDataType = function() {
|
|
return getArrayDataType(this._data, typeOf);
|
|
};
|
|
DenseMatrix2.prototype.storage = function() {
|
|
return "dense";
|
|
};
|
|
DenseMatrix2.prototype.datatype = function() {
|
|
return this._datatype;
|
|
};
|
|
DenseMatrix2.prototype.create = function(data, datatype) {
|
|
return new DenseMatrix2(data, datatype);
|
|
};
|
|
DenseMatrix2.prototype.subset = function(index2, replacement, defaultValue) {
|
|
switch (arguments.length) {
|
|
case 1:
|
|
return _get(this, index2);
|
|
case 2:
|
|
case 3:
|
|
return _set(this, index2, replacement, defaultValue);
|
|
default:
|
|
throw new SyntaxError("Wrong number of arguments");
|
|
}
|
|
};
|
|
DenseMatrix2.prototype.get = function(index2) {
|
|
if (!isArray(index2)) {
|
|
throw new TypeError("Array expected");
|
|
}
|
|
if (index2.length !== this._size.length) {
|
|
throw new DimensionError(index2.length, this._size.length);
|
|
}
|
|
for (var x = 0; x < index2.length; x++) {
|
|
validateIndex(index2[x], this._size[x]);
|
|
}
|
|
var data = this._data;
|
|
for (var i2 = 0, ii = index2.length; i2 < ii; i2++) {
|
|
var indexI = index2[i2];
|
|
validateIndex(indexI, data.length);
|
|
data = data[indexI];
|
|
}
|
|
return data;
|
|
};
|
|
DenseMatrix2.prototype.set = function(index2, value, defaultValue) {
|
|
if (!isArray(index2)) {
|
|
throw new TypeError("Array expected");
|
|
}
|
|
if (index2.length < this._size.length) {
|
|
throw new DimensionError(index2.length, this._size.length, "<");
|
|
}
|
|
var i2, ii, indexI;
|
|
var size2 = index2.map(function(i3) {
|
|
return i3 + 1;
|
|
});
|
|
_fit(this, size2, defaultValue);
|
|
var data = this._data;
|
|
for (i2 = 0, ii = index2.length - 1; i2 < ii; i2++) {
|
|
indexI = index2[i2];
|
|
validateIndex(indexI, data.length);
|
|
data = data[indexI];
|
|
}
|
|
indexI = index2[index2.length - 1];
|
|
validateIndex(indexI, data.length);
|
|
data[indexI] = value;
|
|
return this;
|
|
};
|
|
function _get(matrix2, index2) {
|
|
if (!isIndex(index2)) {
|
|
throw new TypeError("Invalid index");
|
|
}
|
|
var isScalar = index2.isScalar();
|
|
if (isScalar) {
|
|
return matrix2.get(index2.min());
|
|
} else {
|
|
var size2 = index2.size();
|
|
if (size2.length !== matrix2._size.length) {
|
|
throw new DimensionError(size2.length, matrix2._size.length);
|
|
}
|
|
var min3 = index2.min();
|
|
var max3 = index2.max();
|
|
for (var i2 = 0, ii = matrix2._size.length; i2 < ii; i2++) {
|
|
validateIndex(min3[i2], matrix2._size[i2]);
|
|
validateIndex(max3[i2], matrix2._size[i2]);
|
|
}
|
|
return new DenseMatrix2(_getSubmatrix(matrix2._data, index2, size2.length, 0), matrix2._datatype);
|
|
}
|
|
}
|
|
function _getSubmatrix(data, index2, dims, dim) {
|
|
var last = dim === dims - 1;
|
|
var range2 = index2.dimension(dim);
|
|
if (last) {
|
|
return range2.map(function(i2) {
|
|
validateIndex(i2, data.length);
|
|
return data[i2];
|
|
}).valueOf();
|
|
} else {
|
|
return range2.map(function(i2) {
|
|
validateIndex(i2, data.length);
|
|
var child = data[i2];
|
|
return _getSubmatrix(child, index2, dims, dim + 1);
|
|
}).valueOf();
|
|
}
|
|
}
|
|
function _set(matrix2, index2, submatrix, defaultValue) {
|
|
if (!index2 || index2.isIndex !== true) {
|
|
throw new TypeError("Invalid index");
|
|
}
|
|
var iSize = index2.size();
|
|
var isScalar = index2.isScalar();
|
|
var sSize;
|
|
if (isMatrix(submatrix)) {
|
|
sSize = submatrix.size();
|
|
submatrix = submatrix.valueOf();
|
|
} else {
|
|
sSize = arraySize(submatrix);
|
|
}
|
|
if (isScalar) {
|
|
if (sSize.length !== 0) {
|
|
throw new TypeError("Scalar expected");
|
|
}
|
|
matrix2.set(index2.min(), submatrix, defaultValue);
|
|
} else {
|
|
if (iSize.length < matrix2._size.length) {
|
|
throw new DimensionError(iSize.length, matrix2._size.length, "<");
|
|
}
|
|
if (sSize.length < iSize.length) {
|
|
var i2 = 0;
|
|
var outer = 0;
|
|
while (iSize[i2] === 1 && sSize[i2] === 1) {
|
|
i2++;
|
|
}
|
|
while (iSize[i2] === 1) {
|
|
outer++;
|
|
i2++;
|
|
}
|
|
submatrix = unsqueeze(submatrix, iSize.length, outer, sSize);
|
|
}
|
|
if (!deepStrictEqual(iSize, sSize)) {
|
|
throw new DimensionError(iSize, sSize, ">");
|
|
}
|
|
var size2 = index2.max().map(function(i3) {
|
|
return i3 + 1;
|
|
});
|
|
_fit(matrix2, size2, defaultValue);
|
|
var dims = iSize.length;
|
|
var dim = 0;
|
|
_setSubmatrix(matrix2._data, index2, submatrix, dims, dim);
|
|
}
|
|
return matrix2;
|
|
}
|
|
function _setSubmatrix(data, index2, submatrix, dims, dim) {
|
|
var last = dim === dims - 1;
|
|
var range2 = index2.dimension(dim);
|
|
if (last) {
|
|
range2.forEach(function(dataIndex, subIndex) {
|
|
validateIndex(dataIndex);
|
|
data[dataIndex] = submatrix[subIndex[0]];
|
|
});
|
|
} else {
|
|
range2.forEach(function(dataIndex, subIndex) {
|
|
validateIndex(dataIndex);
|
|
_setSubmatrix(data[dataIndex], index2, submatrix[subIndex[0]], dims, dim + 1);
|
|
});
|
|
}
|
|
}
|
|
DenseMatrix2.prototype.resize = function(size2, defaultValue, copy) {
|
|
if (!isCollection(size2)) {
|
|
throw new TypeError("Array or Matrix expected");
|
|
}
|
|
var sizeArray = size2.valueOf().map((value) => {
|
|
return Array.isArray(value) && value.length === 1 ? value[0] : value;
|
|
});
|
|
var m = copy ? this.clone() : this;
|
|
return _resize2(m, sizeArray, defaultValue);
|
|
};
|
|
function _resize2(matrix2, size2, defaultValue) {
|
|
if (size2.length === 0) {
|
|
var v = matrix2._data;
|
|
while (isArray(v)) {
|
|
v = v[0];
|
|
}
|
|
return v;
|
|
}
|
|
matrix2._size = size2.slice(0);
|
|
matrix2._data = resize(matrix2._data, matrix2._size, defaultValue);
|
|
return matrix2;
|
|
}
|
|
DenseMatrix2.prototype.reshape = function(size2, copy) {
|
|
var m = copy ? this.clone() : this;
|
|
m._data = reshape(m._data, size2);
|
|
var currentLength = m._size.reduce((length, size3) => length * size3);
|
|
m._size = processSizesWildcard(size2, currentLength);
|
|
return m;
|
|
};
|
|
function _fit(matrix2, size2, defaultValue) {
|
|
var newSize = matrix2._size.slice(0);
|
|
var changed = false;
|
|
while (newSize.length < size2.length) {
|
|
newSize.push(0);
|
|
changed = true;
|
|
}
|
|
for (var i2 = 0, ii = size2.length; i2 < ii; i2++) {
|
|
if (size2[i2] > newSize[i2]) {
|
|
newSize[i2] = size2[i2];
|
|
changed = true;
|
|
}
|
|
}
|
|
if (changed) {
|
|
_resize2(matrix2, newSize, defaultValue);
|
|
}
|
|
}
|
|
DenseMatrix2.prototype.clone = function() {
|
|
var m = new DenseMatrix2({
|
|
data: clone(this._data),
|
|
size: clone(this._size),
|
|
datatype: this._datatype
|
|
});
|
|
return m;
|
|
};
|
|
DenseMatrix2.prototype.size = function() {
|
|
return this._size.slice(0);
|
|
};
|
|
DenseMatrix2.prototype.map = function(callback) {
|
|
var me = this;
|
|
var args = maxArgumentCount(callback);
|
|
var recurse = function recurse2(value, index2) {
|
|
if (isArray(value)) {
|
|
return value.map(function(child, i2) {
|
|
return recurse2(child, index2.concat(i2));
|
|
});
|
|
} else {
|
|
if (args === 1) {
|
|
return callback(value);
|
|
} else if (args === 2) {
|
|
return callback(value, index2);
|
|
} else {
|
|
return callback(value, index2, me);
|
|
}
|
|
}
|
|
};
|
|
var data = recurse(this._data, []);
|
|
var datatype = this._datatype !== void 0 ? getArrayDataType(data, typeOf) : void 0;
|
|
return new DenseMatrix2(data, datatype);
|
|
};
|
|
DenseMatrix2.prototype.forEach = function(callback) {
|
|
var me = this;
|
|
var recurse = function recurse2(value, index2) {
|
|
if (isArray(value)) {
|
|
value.forEach(function(child, i2) {
|
|
recurse2(child, index2.concat(i2));
|
|
});
|
|
} else {
|
|
callback(value, index2, me);
|
|
}
|
|
};
|
|
recurse(this._data, []);
|
|
};
|
|
DenseMatrix2.prototype[Symbol.iterator] = function* () {
|
|
var recurse = function* recurse2(value, index2) {
|
|
if (isArray(value)) {
|
|
for (var i2 = 0; i2 < value.length; i2++) {
|
|
yield* recurse2(value[i2], index2.concat(i2));
|
|
}
|
|
} else {
|
|
yield {
|
|
value,
|
|
index: index2
|
|
};
|
|
}
|
|
};
|
|
yield* recurse(this._data, []);
|
|
};
|
|
DenseMatrix2.prototype.rows = function() {
|
|
var result = [];
|
|
var s = this.size();
|
|
if (s.length !== 2) {
|
|
throw new TypeError("Rows can only be returned for a 2D matrix.");
|
|
}
|
|
var data = this._data;
|
|
for (var row2 of data) {
|
|
result.push(new DenseMatrix2([row2], this._datatype));
|
|
}
|
|
return result;
|
|
};
|
|
DenseMatrix2.prototype.columns = function() {
|
|
var _this = this;
|
|
var result = [];
|
|
var s = this.size();
|
|
if (s.length !== 2) {
|
|
throw new TypeError("Rows can only be returned for a 2D matrix.");
|
|
}
|
|
var data = this._data;
|
|
var _loop = function _loop2(i3) {
|
|
var col = data.map((row2) => [row2[i3]]);
|
|
result.push(new DenseMatrix2(col, _this._datatype));
|
|
};
|
|
for (var i2 = 0; i2 < s[1]; i2++) {
|
|
_loop(i2);
|
|
}
|
|
return result;
|
|
};
|
|
DenseMatrix2.prototype.toArray = function() {
|
|
return clone(this._data);
|
|
};
|
|
DenseMatrix2.prototype.valueOf = function() {
|
|
return this._data;
|
|
};
|
|
DenseMatrix2.prototype.format = function(options) {
|
|
return format3(this._data, options);
|
|
};
|
|
DenseMatrix2.prototype.toString = function() {
|
|
return format3(this._data);
|
|
};
|
|
DenseMatrix2.prototype.toJSON = function() {
|
|
return {
|
|
mathjs: "DenseMatrix",
|
|
data: this._data,
|
|
size: this._size,
|
|
datatype: this._datatype
|
|
};
|
|
};
|
|
DenseMatrix2.prototype.diagonal = function(k) {
|
|
if (k) {
|
|
if (isBigNumber(k)) {
|
|
k = k.toNumber();
|
|
}
|
|
if (!isNumber(k) || !isInteger(k)) {
|
|
throw new TypeError("The parameter k must be an integer number");
|
|
}
|
|
} else {
|
|
k = 0;
|
|
}
|
|
var kSuper = k > 0 ? k : 0;
|
|
var kSub = k < 0 ? -k : 0;
|
|
var rows = this._size[0];
|
|
var columns = this._size[1];
|
|
var n = Math.min(rows - kSub, columns - kSuper);
|
|
var data = [];
|
|
for (var i2 = 0; i2 < n; i2++) {
|
|
data[i2] = this._data[i2 + kSub][i2 + kSuper];
|
|
}
|
|
return new DenseMatrix2({
|
|
data,
|
|
size: [n],
|
|
datatype: this._datatype
|
|
});
|
|
};
|
|
DenseMatrix2.diagonal = function(size2, value, k, defaultValue) {
|
|
if (!isArray(size2)) {
|
|
throw new TypeError("Array expected, size parameter");
|
|
}
|
|
if (size2.length !== 2) {
|
|
throw new Error("Only two dimensions matrix are supported");
|
|
}
|
|
size2 = size2.map(function(s) {
|
|
if (isBigNumber(s)) {
|
|
s = s.toNumber();
|
|
}
|
|
if (!isNumber(s) || !isInteger(s) || s < 1) {
|
|
throw new Error("Size values must be positive integers");
|
|
}
|
|
return s;
|
|
});
|
|
if (k) {
|
|
if (isBigNumber(k)) {
|
|
k = k.toNumber();
|
|
}
|
|
if (!isNumber(k) || !isInteger(k)) {
|
|
throw new TypeError("The parameter k must be an integer number");
|
|
}
|
|
} else {
|
|
k = 0;
|
|
}
|
|
var kSuper = k > 0 ? k : 0;
|
|
var kSub = k < 0 ? -k : 0;
|
|
var rows = size2[0];
|
|
var columns = size2[1];
|
|
var n = Math.min(rows - kSub, columns - kSuper);
|
|
var _value;
|
|
if (isArray(value)) {
|
|
if (value.length !== n) {
|
|
throw new Error("Invalid value array length");
|
|
}
|
|
_value = function _value2(i2) {
|
|
return value[i2];
|
|
};
|
|
} else if (isMatrix(value)) {
|
|
var ms = value.size();
|
|
if (ms.length !== 1 || ms[0] !== n) {
|
|
throw new Error("Invalid matrix length");
|
|
}
|
|
_value = function _value2(i2) {
|
|
return value.get([i2]);
|
|
};
|
|
} else {
|
|
_value = function _value2() {
|
|
return value;
|
|
};
|
|
}
|
|
if (!defaultValue) {
|
|
defaultValue = isBigNumber(_value(0)) ? _value(0).mul(0) : 0;
|
|
}
|
|
var data = [];
|
|
if (size2.length > 0) {
|
|
data = resize(data, size2, defaultValue);
|
|
for (var d = 0; d < n; d++) {
|
|
data[d + kSub][d + kSuper] = _value(d);
|
|
}
|
|
}
|
|
return new DenseMatrix2({
|
|
data,
|
|
size: [rows, columns]
|
|
});
|
|
};
|
|
DenseMatrix2.fromJSON = function(json) {
|
|
return new DenseMatrix2(json);
|
|
};
|
|
DenseMatrix2.prototype.swapRows = function(i2, j) {
|
|
if (!isNumber(i2) || !isInteger(i2) || !isNumber(j) || !isInteger(j)) {
|
|
throw new Error("Row index must be positive integers");
|
|
}
|
|
if (this._size.length !== 2) {
|
|
throw new Error("Only two dimensional matrix is supported");
|
|
}
|
|
validateIndex(i2, this._size[0]);
|
|
validateIndex(j, this._size[0]);
|
|
DenseMatrix2._swapRows(i2, j, this._data);
|
|
return this;
|
|
};
|
|
DenseMatrix2._swapRows = function(i2, j, data) {
|
|
var vi = data[i2];
|
|
data[i2] = data[j];
|
|
data[j] = vi;
|
|
};
|
|
function preprocess(data) {
|
|
for (var i2 = 0, ii = data.length; i2 < ii; i2++) {
|
|
var elem = data[i2];
|
|
if (isArray(elem)) {
|
|
data[i2] = preprocess(elem);
|
|
} else if (elem && elem.isMatrix === true) {
|
|
data[i2] = preprocess(elem.valueOf());
|
|
}
|
|
}
|
|
return data;
|
|
}
|
|
return DenseMatrix2;
|
|
}, {
|
|
isClass: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/utils/clone.js
|
|
var name8 = "clone";
|
|
var dependencies9 = ["typed"];
|
|
var createClone = /* @__PURE__ */ factory(name8, dependencies9, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name8, {
|
|
any: clone
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/utils/switch.js
|
|
function _switch(mat) {
|
|
var I = mat.length;
|
|
var J = mat[0].length;
|
|
var i2, j;
|
|
var ret = [];
|
|
for (j = 0; j < J; j++) {
|
|
var tmp = [];
|
|
for (i2 = 0; i2 < I; i2++) {
|
|
tmp.push(mat[i2][j]);
|
|
}
|
|
ret.push(tmp);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/utils/collection.js
|
|
function containsCollections(array) {
|
|
for (var i2 = 0; i2 < array.length; i2++) {
|
|
if (isCollection(array[i2])) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function deepForEach(array, callback) {
|
|
if (isMatrix(array)) {
|
|
array = array.valueOf();
|
|
}
|
|
for (var i2 = 0, ii = array.length; i2 < ii; i2++) {
|
|
var value = array[i2];
|
|
if (Array.isArray(value)) {
|
|
deepForEach(value, callback);
|
|
} else {
|
|
callback(value);
|
|
}
|
|
}
|
|
}
|
|
function deepMap(array, callback, skipZeros) {
|
|
if (array && typeof array.map === "function") {
|
|
return array.map(function(x) {
|
|
return deepMap(x, callback, skipZeros);
|
|
});
|
|
} else {
|
|
return callback(array);
|
|
}
|
|
}
|
|
function reduce(mat, dim, callback) {
|
|
var size2 = Array.isArray(mat) ? arraySize(mat) : mat.size();
|
|
if (dim < 0 || dim >= size2.length) {
|
|
throw new IndexError(dim, size2.length);
|
|
}
|
|
if (isMatrix(mat)) {
|
|
return mat.create(_reduce(mat.valueOf(), dim, callback));
|
|
} else {
|
|
return _reduce(mat, dim, callback);
|
|
}
|
|
}
|
|
function _reduce(mat, dim, callback) {
|
|
var i2, ret, val, tran;
|
|
if (dim <= 0) {
|
|
if (!Array.isArray(mat[0])) {
|
|
val = mat[0];
|
|
for (i2 = 1; i2 < mat.length; i2++) {
|
|
val = callback(val, mat[i2]);
|
|
}
|
|
return val;
|
|
} else {
|
|
tran = _switch(mat);
|
|
ret = [];
|
|
for (i2 = 0; i2 < tran.length; i2++) {
|
|
ret[i2] = _reduce(tran[i2], dim - 1, callback);
|
|
}
|
|
return ret;
|
|
}
|
|
} else {
|
|
ret = [];
|
|
for (i2 = 0; i2 < mat.length; i2++) {
|
|
ret[i2] = _reduce(mat[i2], dim - 1, callback);
|
|
}
|
|
return ret;
|
|
}
|
|
}
|
|
function scatter(a, j, w, x, u, mark, cindex, f, inverse, update, value) {
|
|
var avalues = a._values;
|
|
var aindex = a._index;
|
|
var aptr = a._ptr;
|
|
var k, k0, k1, i2;
|
|
if (x) {
|
|
for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) {
|
|
i2 = aindex[k];
|
|
if (w[i2] !== mark) {
|
|
w[i2] = mark;
|
|
cindex.push(i2);
|
|
if (update) {
|
|
x[i2] = inverse ? f(avalues[k], value) : f(value, avalues[k]);
|
|
u[i2] = mark;
|
|
} else {
|
|
x[i2] = avalues[k];
|
|
}
|
|
} else {
|
|
x[i2] = inverse ? f(avalues[k], x[i2]) : f(x[i2], avalues[k]);
|
|
u[i2] = mark;
|
|
}
|
|
}
|
|
} else {
|
|
for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) {
|
|
i2 = aindex[k];
|
|
if (w[i2] !== mark) {
|
|
w[i2] = mark;
|
|
cindex.push(i2);
|
|
} else {
|
|
u[i2] = mark;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/utils/isInteger.js
|
|
var name9 = "isInteger";
|
|
var dependencies10 = ["typed"];
|
|
var createIsInteger = /* @__PURE__ */ factory(name9, dependencies10, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name9, {
|
|
number: isInteger,
|
|
BigNumber: function BigNumber2(x) {
|
|
return x.isInt();
|
|
},
|
|
Fraction: function Fraction3(x) {
|
|
return x.d === 1 && isFinite(x.n);
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/plain/number/arithmetic.js
|
|
var n1 = "number";
|
|
var n2 = "number, number";
|
|
function absNumber(a) {
|
|
return Math.abs(a);
|
|
}
|
|
absNumber.signature = n1;
|
|
function addNumber(a, b) {
|
|
return a + b;
|
|
}
|
|
addNumber.signature = n2;
|
|
function subtractNumber(a, b) {
|
|
return a - b;
|
|
}
|
|
subtractNumber.signature = n2;
|
|
function multiplyNumber(a, b) {
|
|
return a * b;
|
|
}
|
|
multiplyNumber.signature = n2;
|
|
function divideNumber(a, b) {
|
|
return a / b;
|
|
}
|
|
divideNumber.signature = n2;
|
|
function unaryMinusNumber(x) {
|
|
return -x;
|
|
}
|
|
unaryMinusNumber.signature = n1;
|
|
function unaryPlusNumber(x) {
|
|
return x;
|
|
}
|
|
unaryPlusNumber.signature = n1;
|
|
function cbrtNumber(x) {
|
|
return cbrt(x);
|
|
}
|
|
cbrtNumber.signature = n1;
|
|
function cubeNumber(x) {
|
|
return x * x * x;
|
|
}
|
|
cubeNumber.signature = n1;
|
|
function expNumber(x) {
|
|
return Math.exp(x);
|
|
}
|
|
expNumber.signature = n1;
|
|
function expm1Number(x) {
|
|
return expm1(x);
|
|
}
|
|
expm1Number.signature = n1;
|
|
function gcdNumber(a, b) {
|
|
if (!isInteger(a) || !isInteger(b)) {
|
|
throw new Error("Parameters in function gcd must be integer numbers");
|
|
}
|
|
var r;
|
|
while (b !== 0) {
|
|
r = a % b;
|
|
a = b;
|
|
b = r;
|
|
}
|
|
return a < 0 ? -a : a;
|
|
}
|
|
gcdNumber.signature = n2;
|
|
function lcmNumber(a, b) {
|
|
if (!isInteger(a) || !isInteger(b)) {
|
|
throw new Error("Parameters in function lcm must be integer numbers");
|
|
}
|
|
if (a === 0 || b === 0) {
|
|
return 0;
|
|
}
|
|
var t;
|
|
var prod2 = a * b;
|
|
while (b !== 0) {
|
|
t = b;
|
|
b = a % t;
|
|
a = t;
|
|
}
|
|
return Math.abs(prod2 / a);
|
|
}
|
|
lcmNumber.signature = n2;
|
|
function logNumber(x, y) {
|
|
if (y) {
|
|
return Math.log(x) / Math.log(y);
|
|
}
|
|
return Math.log(x);
|
|
}
|
|
function log10Number(x) {
|
|
return log10(x);
|
|
}
|
|
log10Number.signature = n1;
|
|
function log2Number(x) {
|
|
return log2(x);
|
|
}
|
|
log2Number.signature = n1;
|
|
function log1pNumber(x) {
|
|
return log1p(x);
|
|
}
|
|
log1pNumber.signature = n1;
|
|
function modNumber(x, y) {
|
|
if (y > 0) {
|
|
return x - y * Math.floor(x / y);
|
|
} else if (y === 0) {
|
|
return x;
|
|
} else {
|
|
throw new Error("Cannot calculate mod for a negative divisor");
|
|
}
|
|
}
|
|
modNumber.signature = n2;
|
|
function nthRootNumber(a) {
|
|
var root = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 2;
|
|
var inv2 = root < 0;
|
|
if (inv2) {
|
|
root = -root;
|
|
}
|
|
if (root === 0) {
|
|
throw new Error("Root must be non-zero");
|
|
}
|
|
if (a < 0 && Math.abs(root) % 2 !== 1) {
|
|
throw new Error("Root must be odd when a is negative.");
|
|
}
|
|
if (a === 0) {
|
|
return inv2 ? Infinity : 0;
|
|
}
|
|
if (!isFinite(a)) {
|
|
return inv2 ? 0 : a;
|
|
}
|
|
var x = Math.pow(Math.abs(a), 1 / root);
|
|
x = a < 0 ? -x : x;
|
|
return inv2 ? 1 / x : x;
|
|
}
|
|
function signNumber(x) {
|
|
return sign(x);
|
|
}
|
|
signNumber.signature = n1;
|
|
function sqrtNumber(x) {
|
|
return Math.sqrt(x);
|
|
}
|
|
sqrtNumber.signature = n1;
|
|
function squareNumber(x) {
|
|
return x * x;
|
|
}
|
|
squareNumber.signature = n1;
|
|
function xgcdNumber(a, b) {
|
|
var t;
|
|
var q;
|
|
var r;
|
|
var x = 0;
|
|
var lastx = 1;
|
|
var y = 1;
|
|
var lasty = 0;
|
|
if (!isInteger(a) || !isInteger(b)) {
|
|
throw new Error("Parameters in function xgcd must be integer numbers");
|
|
}
|
|
while (b) {
|
|
q = Math.floor(a / b);
|
|
r = a - q * b;
|
|
t = x;
|
|
x = lastx - q * x;
|
|
lastx = t;
|
|
t = y;
|
|
y = lasty - q * y;
|
|
lasty = t;
|
|
a = b;
|
|
b = r;
|
|
}
|
|
var res;
|
|
if (a < 0) {
|
|
res = [-a, -lastx, -lasty];
|
|
} else {
|
|
res = [a, a ? lastx : 0, lasty];
|
|
}
|
|
return res;
|
|
}
|
|
xgcdNumber.signature = n2;
|
|
function powNumber(x, y) {
|
|
if (x * x < 1 && y === Infinity || x * x > 1 && y === -Infinity) {
|
|
return 0;
|
|
}
|
|
return Math.pow(x, y);
|
|
}
|
|
powNumber.signature = n2;
|
|
function roundNumber(value) {
|
|
var decimals = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
|
|
if (!isInteger(decimals) || decimals < 0 || decimals > 15) {
|
|
throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");
|
|
}
|
|
return parseFloat(toFixed(value, decimals));
|
|
}
|
|
function normNumber(x) {
|
|
return Math.abs(x);
|
|
}
|
|
normNumber.signature = n1;
|
|
|
|
// node_modules/mathjs/lib/esm/plain/number/bitwise.js
|
|
var n12 = "number";
|
|
var n22 = "number, number";
|
|
function bitAndNumber(x, y) {
|
|
if (!isInteger(x) || !isInteger(y)) {
|
|
throw new Error("Integers expected in function bitAnd");
|
|
}
|
|
return x & y;
|
|
}
|
|
bitAndNumber.signature = n22;
|
|
function bitNotNumber(x) {
|
|
if (!isInteger(x)) {
|
|
throw new Error("Integer expected in function bitNot");
|
|
}
|
|
return ~x;
|
|
}
|
|
bitNotNumber.signature = n12;
|
|
function bitOrNumber(x, y) {
|
|
if (!isInteger(x) || !isInteger(y)) {
|
|
throw new Error("Integers expected in function bitOr");
|
|
}
|
|
return x | y;
|
|
}
|
|
bitOrNumber.signature = n22;
|
|
function bitXorNumber(x, y) {
|
|
if (!isInteger(x) || !isInteger(y)) {
|
|
throw new Error("Integers expected in function bitXor");
|
|
}
|
|
return x ^ y;
|
|
}
|
|
bitXorNumber.signature = n22;
|
|
function leftShiftNumber(x, y) {
|
|
if (!isInteger(x) || !isInteger(y)) {
|
|
throw new Error("Integers expected in function leftShift");
|
|
}
|
|
return x << y;
|
|
}
|
|
leftShiftNumber.signature = n22;
|
|
function rightArithShiftNumber(x, y) {
|
|
if (!isInteger(x) || !isInteger(y)) {
|
|
throw new Error("Integers expected in function rightArithShift");
|
|
}
|
|
return x >> y;
|
|
}
|
|
rightArithShiftNumber.signature = n22;
|
|
function rightLogShiftNumber(x, y) {
|
|
if (!isInteger(x) || !isInteger(y)) {
|
|
throw new Error("Integers expected in function rightLogShift");
|
|
}
|
|
return x >>> y;
|
|
}
|
|
rightLogShiftNumber.signature = n22;
|
|
|
|
// node_modules/mathjs/lib/esm/utils/product.js
|
|
function product2(i2, n) {
|
|
if (n < i2) {
|
|
return 1;
|
|
}
|
|
if (n === i2) {
|
|
return n;
|
|
}
|
|
var half = n + i2 >> 1;
|
|
return product2(i2, half) * product2(half + 1, n);
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/plain/number/combinations.js
|
|
function combinationsNumber(n, k) {
|
|
if (!isInteger(n) || n < 0) {
|
|
throw new TypeError("Positive integer value expected in function combinations");
|
|
}
|
|
if (!isInteger(k) || k < 0) {
|
|
throw new TypeError("Positive integer value expected in function combinations");
|
|
}
|
|
if (k > n) {
|
|
throw new TypeError("k must be less than or equal to n");
|
|
}
|
|
var nMinusk = n - k;
|
|
var answer = 1;
|
|
var firstnumerator = k < nMinusk ? nMinusk + 1 : k + 1;
|
|
var nextdivisor = 2;
|
|
var lastdivisor = k < nMinusk ? k : nMinusk;
|
|
for (var nextnumerator = firstnumerator; nextnumerator <= n; ++nextnumerator) {
|
|
answer *= nextnumerator;
|
|
while (nextdivisor <= lastdivisor && answer % nextdivisor === 0) {
|
|
answer /= nextdivisor;
|
|
++nextdivisor;
|
|
}
|
|
}
|
|
if (nextdivisor <= lastdivisor) {
|
|
answer /= product2(nextdivisor, lastdivisor);
|
|
}
|
|
return answer;
|
|
}
|
|
combinationsNumber.signature = "number, number";
|
|
|
|
// node_modules/mathjs/lib/esm/plain/number/constants.js
|
|
var pi = Math.PI;
|
|
var tau = 2 * Math.PI;
|
|
var e = Math.E;
|
|
var phi = 1.618033988749895;
|
|
|
|
// node_modules/mathjs/lib/esm/plain/number/logical.js
|
|
var n13 = "number";
|
|
var n23 = "number, number";
|
|
function notNumber(x) {
|
|
return !x;
|
|
}
|
|
notNumber.signature = n13;
|
|
function orNumber(x, y) {
|
|
return !!(x || y);
|
|
}
|
|
orNumber.signature = n23;
|
|
function xorNumber(x, y) {
|
|
return !!x !== !!y;
|
|
}
|
|
xorNumber.signature = n23;
|
|
function andNumber(x, y) {
|
|
return !!(x && y);
|
|
}
|
|
andNumber.signature = n23;
|
|
|
|
// node_modules/mathjs/lib/esm/plain/number/probability.js
|
|
function gammaNumber(n) {
|
|
var x;
|
|
if (isInteger(n)) {
|
|
if (n <= 0) {
|
|
return isFinite(n) ? Infinity : NaN;
|
|
}
|
|
if (n > 171) {
|
|
return Infinity;
|
|
}
|
|
return product2(1, n - 1);
|
|
}
|
|
if (n < 0.5) {
|
|
return Math.PI / (Math.sin(Math.PI * n) * gammaNumber(1 - n));
|
|
}
|
|
if (n >= 171.35) {
|
|
return Infinity;
|
|
}
|
|
if (n > 85) {
|
|
var twoN = n * n;
|
|
var threeN = twoN * n;
|
|
var fourN = threeN * n;
|
|
var fiveN = fourN * n;
|
|
return Math.sqrt(2 * Math.PI / n) * Math.pow(n / Math.E, n) * (1 + 1 / (12 * n) + 1 / (288 * twoN) - 139 / (51840 * threeN) - 571 / (2488320 * fourN) + 163879 / (209018880 * fiveN) + 5246819 / (75246796800 * fiveN * n));
|
|
}
|
|
--n;
|
|
x = gammaP[0];
|
|
for (var i2 = 1; i2 < gammaP.length; ++i2) {
|
|
x += gammaP[i2] / (n + i2);
|
|
}
|
|
var t = n + gammaG + 0.5;
|
|
return Math.sqrt(2 * Math.PI) * Math.pow(t, n + 0.5) * Math.exp(-t) * x;
|
|
}
|
|
gammaNumber.signature = "number";
|
|
var gammaG = 4.7421875;
|
|
var gammaP = [0.9999999999999971, 57.15623566586292, -59.59796035547549, 14.136097974741746, -0.4919138160976202, 3399464998481189e-20, 4652362892704858e-20, -9837447530487956e-20, 1580887032249125e-19, -21026444172410488e-20, 21743961811521265e-20, -1643181065367639e-19, 8441822398385275e-20, -26190838401581408e-21, 36899182659531625e-22];
|
|
var lnSqrt2PI = 0.9189385332046728;
|
|
var lgammaG = 5;
|
|
var lgammaN = 7;
|
|
var lgammaSeries = [1.000000000190015, 76.18009172947146, -86.50532032941678, 24.01409824083091, -1.231739572450155, 0.001208650973866179, -5395239384953e-18];
|
|
function lgammaNumber(n) {
|
|
if (n < 0)
|
|
return NaN;
|
|
if (n === 0)
|
|
return Infinity;
|
|
if (!isFinite(n))
|
|
return n;
|
|
if (n < 0.5) {
|
|
return Math.log(Math.PI / Math.sin(Math.PI * n)) - lgammaNumber(1 - n);
|
|
}
|
|
n = n - 1;
|
|
var base = n + lgammaG + 0.5;
|
|
var sum3 = lgammaSeries[0];
|
|
for (var i2 = lgammaN - 1; i2 >= 1; i2--) {
|
|
sum3 += lgammaSeries[i2] / (n + i2);
|
|
}
|
|
return lnSqrt2PI + (n + 0.5) * Math.log(base) - base + Math.log(sum3);
|
|
}
|
|
lgammaNumber.signature = "number";
|
|
|
|
// node_modules/mathjs/lib/esm/plain/number/trigonometry.js
|
|
var n14 = "number";
|
|
var n24 = "number, number";
|
|
function acosNumber(x) {
|
|
return Math.acos(x);
|
|
}
|
|
acosNumber.signature = n14;
|
|
function acoshNumber(x) {
|
|
return acosh(x);
|
|
}
|
|
acoshNumber.signature = n14;
|
|
function acotNumber(x) {
|
|
return Math.atan(1 / x);
|
|
}
|
|
acotNumber.signature = n14;
|
|
function acothNumber(x) {
|
|
return isFinite(x) ? (Math.log((x + 1) / x) + Math.log(x / (x - 1))) / 2 : 0;
|
|
}
|
|
acothNumber.signature = n14;
|
|
function acscNumber(x) {
|
|
return Math.asin(1 / x);
|
|
}
|
|
acscNumber.signature = n14;
|
|
function acschNumber(x) {
|
|
var xInv = 1 / x;
|
|
return Math.log(xInv + Math.sqrt(xInv * xInv + 1));
|
|
}
|
|
acschNumber.signature = n14;
|
|
function asecNumber(x) {
|
|
return Math.acos(1 / x);
|
|
}
|
|
asecNumber.signature = n14;
|
|
function asechNumber(x) {
|
|
var xInv = 1 / x;
|
|
var ret = Math.sqrt(xInv * xInv - 1);
|
|
return Math.log(ret + xInv);
|
|
}
|
|
asechNumber.signature = n14;
|
|
function asinNumber(x) {
|
|
return Math.asin(x);
|
|
}
|
|
asinNumber.signature = n14;
|
|
function asinhNumber(x) {
|
|
return asinh(x);
|
|
}
|
|
asinhNumber.signature = n14;
|
|
function atanNumber(x) {
|
|
return Math.atan(x);
|
|
}
|
|
atanNumber.signature = n14;
|
|
function atan2Number(y, x) {
|
|
return Math.atan2(y, x);
|
|
}
|
|
atan2Number.signature = n24;
|
|
function atanhNumber(x) {
|
|
return atanh(x);
|
|
}
|
|
atanhNumber.signature = n14;
|
|
function cosNumber(x) {
|
|
return Math.cos(x);
|
|
}
|
|
cosNumber.signature = n14;
|
|
function coshNumber(x) {
|
|
return cosh(x);
|
|
}
|
|
coshNumber.signature = n14;
|
|
function cotNumber(x) {
|
|
return 1 / Math.tan(x);
|
|
}
|
|
cotNumber.signature = n14;
|
|
function cothNumber(x) {
|
|
var e3 = Math.exp(2 * x);
|
|
return (e3 + 1) / (e3 - 1);
|
|
}
|
|
cothNumber.signature = n14;
|
|
function cscNumber(x) {
|
|
return 1 / Math.sin(x);
|
|
}
|
|
cscNumber.signature = n14;
|
|
function cschNumber(x) {
|
|
if (x === 0) {
|
|
return Number.POSITIVE_INFINITY;
|
|
} else {
|
|
return Math.abs(2 / (Math.exp(x) - Math.exp(-x))) * sign(x);
|
|
}
|
|
}
|
|
cschNumber.signature = n14;
|
|
function secNumber(x) {
|
|
return 1 / Math.cos(x);
|
|
}
|
|
secNumber.signature = n14;
|
|
function sechNumber(x) {
|
|
return 2 / (Math.exp(x) + Math.exp(-x));
|
|
}
|
|
sechNumber.signature = n14;
|
|
function sinNumber(x) {
|
|
return Math.sin(x);
|
|
}
|
|
sinNumber.signature = n14;
|
|
function sinhNumber(x) {
|
|
return sinh(x);
|
|
}
|
|
sinhNumber.signature = n14;
|
|
function tanNumber(x) {
|
|
return Math.tan(x);
|
|
}
|
|
tanNumber.signature = n14;
|
|
function tanhNumber(x) {
|
|
return tanh(x);
|
|
}
|
|
tanhNumber.signature = n14;
|
|
|
|
// node_modules/mathjs/lib/esm/plain/number/utils.js
|
|
var n15 = "number";
|
|
function isIntegerNumber(x) {
|
|
return isInteger(x);
|
|
}
|
|
isIntegerNumber.signature = n15;
|
|
function isNegativeNumber(x) {
|
|
return x < 0;
|
|
}
|
|
isNegativeNumber.signature = n15;
|
|
function isPositiveNumber(x) {
|
|
return x > 0;
|
|
}
|
|
isPositiveNumber.signature = n15;
|
|
function isZeroNumber(x) {
|
|
return x === 0;
|
|
}
|
|
isZeroNumber.signature = n15;
|
|
function isNaNNumber(x) {
|
|
return Number.isNaN(x);
|
|
}
|
|
isNaNNumber.signature = n15;
|
|
|
|
// node_modules/mathjs/lib/esm/function/utils/isNegative.js
|
|
var name10 = "isNegative";
|
|
var dependencies11 = ["typed"];
|
|
var createIsNegative = /* @__PURE__ */ factory(name10, dependencies11, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name10, {
|
|
number: isNegativeNumber,
|
|
BigNumber: function BigNumber2(x) {
|
|
return x.isNeg() && !x.isZero() && !x.isNaN();
|
|
},
|
|
Fraction: function Fraction3(x) {
|
|
return x.s < 0;
|
|
},
|
|
Unit: typed2.referToSelf((self2) => (x) => typed2.find(self2, x.valueType())(x.value)),
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/utils/isNumeric.js
|
|
var name11 = "isNumeric";
|
|
var dependencies12 = ["typed"];
|
|
var createIsNumeric = /* @__PURE__ */ factory(name11, dependencies12, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name11, {
|
|
"number | BigNumber | Fraction | boolean": () => true,
|
|
"Complex | Unit | string | null | undefined | Node": () => false,
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/utils/hasNumericValue.js
|
|
var name12 = "hasNumericValue";
|
|
var dependencies13 = ["typed", "isNumeric"];
|
|
var createHasNumericValue = /* @__PURE__ */ factory(name12, dependencies13, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
isNumeric: isNumeric2
|
|
} = _ref;
|
|
return typed2(name12, {
|
|
boolean: () => true,
|
|
string: function string2(x) {
|
|
return x.trim().length > 0 && !isNaN(Number(x));
|
|
},
|
|
any: function any(x) {
|
|
return isNumeric2(x);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/utils/isPositive.js
|
|
var name13 = "isPositive";
|
|
var dependencies14 = ["typed"];
|
|
var createIsPositive = /* @__PURE__ */ factory(name13, dependencies14, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name13, {
|
|
number: isPositiveNumber,
|
|
BigNumber: function BigNumber2(x) {
|
|
return !x.isNeg() && !x.isZero() && !x.isNaN();
|
|
},
|
|
Fraction: function Fraction3(x) {
|
|
return x.s > 0 && x.n > 0;
|
|
},
|
|
Unit: typed2.referToSelf((self2) => (x) => typed2.find(self2, x.valueType())(x.value)),
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/utils/isZero.js
|
|
var name14 = "isZero";
|
|
var dependencies15 = ["typed"];
|
|
var createIsZero = /* @__PURE__ */ factory(name14, dependencies15, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name14, {
|
|
number: isZeroNumber,
|
|
BigNumber: function BigNumber2(x) {
|
|
return x.isZero();
|
|
},
|
|
Complex: function Complex3(x) {
|
|
return x.re === 0 && x.im === 0;
|
|
},
|
|
Fraction: function Fraction3(x) {
|
|
return x.d === 1 && x.n === 0;
|
|
},
|
|
Unit: typed2.referToSelf((self2) => (x) => typed2.find(self2, x.valueType())(x.value)),
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/utils/isNaN.js
|
|
var name15 = "isNaN";
|
|
var dependencies16 = ["typed"];
|
|
var createIsNaN = /* @__PURE__ */ factory(name15, dependencies16, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name15, {
|
|
number: isNaNNumber,
|
|
BigNumber: function BigNumber2(x) {
|
|
return x.isNaN();
|
|
},
|
|
Fraction: function Fraction3(x) {
|
|
return false;
|
|
},
|
|
Complex: function Complex3(x) {
|
|
return x.isNaN();
|
|
},
|
|
Unit: function Unit2(x) {
|
|
return Number.isNaN(x.value);
|
|
},
|
|
"Array | Matrix": function ArrayMatrix(x) {
|
|
return deepMap(x, Number.isNaN);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/utils/typeOf.js
|
|
var name16 = "typeOf";
|
|
var dependencies17 = ["typed"];
|
|
var createTypeOf = /* @__PURE__ */ factory(name16, dependencies17, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name16, {
|
|
any: typeOf
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/utils/bignumber/nearlyEqual.js
|
|
function nearlyEqual2(x, y, epsilon) {
|
|
if (epsilon === null || epsilon === void 0) {
|
|
return x.eq(y);
|
|
}
|
|
if (x.eq(y)) {
|
|
return true;
|
|
}
|
|
if (x.isNaN() || y.isNaN()) {
|
|
return false;
|
|
}
|
|
if (x.isFinite() && y.isFinite()) {
|
|
var diff2 = x.minus(y).abs();
|
|
if (diff2.isZero()) {
|
|
return true;
|
|
} else {
|
|
var max3 = x.constructor.max(x.abs(), y.abs());
|
|
return diff2.lte(max3.times(epsilon));
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/utils/complex.js
|
|
function complexEquals(x, y, epsilon) {
|
|
return nearlyEqual(x.re, y.re, epsilon) && nearlyEqual(x.im, y.im, epsilon);
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/relational/compareUnits.js
|
|
var createCompareUnits = /* @__PURE__ */ factory("compareUnits", ["typed"], (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return {
|
|
"Unit, Unit": typed2.referToSelf((self2) => (x, y) => {
|
|
if (!x.equalBase(y)) {
|
|
throw new Error("Cannot compare units with different base");
|
|
}
|
|
return typed2.find(self2, [x.valueType(), y.valueType()])(x.value, y.value);
|
|
})
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/relational/equalScalar.js
|
|
var name17 = "equalScalar";
|
|
var dependencies18 = ["typed", "config"];
|
|
var createEqualScalar = /* @__PURE__ */ factory(name17, dependencies18, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4
|
|
} = _ref;
|
|
var compareUnits = createCompareUnits({
|
|
typed: typed2
|
|
});
|
|
return typed2(name17, {
|
|
"boolean, boolean": function booleanBoolean(x, y) {
|
|
return x === y;
|
|
},
|
|
"number, number": function numberNumber(x, y) {
|
|
return nearlyEqual(x, y, config4.epsilon);
|
|
},
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(x, y) {
|
|
return x.eq(y) || nearlyEqual2(x, y, config4.epsilon);
|
|
},
|
|
"Fraction, Fraction": function FractionFraction(x, y) {
|
|
return x.equals(y);
|
|
},
|
|
"Complex, Complex": function ComplexComplex(x, y) {
|
|
return complexEquals(x, y, config4.epsilon);
|
|
}
|
|
}, compareUnits);
|
|
});
|
|
var createEqualScalarNumber = factory(name17, ["typed", "config"], (_ref2) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4
|
|
} = _ref2;
|
|
return typed2(name17, {
|
|
"number, number": function numberNumber(x, y) {
|
|
return nearlyEqual(x, y, config4.epsilon);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/SparseMatrix.js
|
|
var name18 = "SparseMatrix";
|
|
var dependencies19 = ["typed", "equalScalar", "Matrix"];
|
|
var createSparseMatrixClass = /* @__PURE__ */ factory(name18, dependencies19, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
equalScalar: equalScalar2,
|
|
Matrix: Matrix2
|
|
} = _ref;
|
|
function SparseMatrix2(data, datatype) {
|
|
if (!(this instanceof SparseMatrix2)) {
|
|
throw new SyntaxError("Constructor must be called with the new operator");
|
|
}
|
|
if (datatype && !isString(datatype)) {
|
|
throw new Error("Invalid datatype: " + datatype);
|
|
}
|
|
if (isMatrix(data)) {
|
|
_createFromMatrix(this, data, datatype);
|
|
} else if (data && isArray(data.index) && isArray(data.ptr) && isArray(data.size)) {
|
|
this._values = data.values;
|
|
this._index = data.index;
|
|
this._ptr = data.ptr;
|
|
this._size = data.size;
|
|
this._datatype = datatype || data.datatype;
|
|
} else if (isArray(data)) {
|
|
_createFromArray(this, data, datatype);
|
|
} else if (data) {
|
|
throw new TypeError("Unsupported type of data (" + typeOf(data) + ")");
|
|
} else {
|
|
this._values = [];
|
|
this._index = [];
|
|
this._ptr = [0];
|
|
this._size = [0, 0];
|
|
this._datatype = datatype;
|
|
}
|
|
}
|
|
function _createFromMatrix(matrix2, source, datatype) {
|
|
if (source.type === "SparseMatrix") {
|
|
matrix2._values = source._values ? clone(source._values) : void 0;
|
|
matrix2._index = clone(source._index);
|
|
matrix2._ptr = clone(source._ptr);
|
|
matrix2._size = clone(source._size);
|
|
matrix2._datatype = datatype || source._datatype;
|
|
} else {
|
|
_createFromArray(matrix2, source.valueOf(), datatype || source._datatype);
|
|
}
|
|
}
|
|
function _createFromArray(matrix2, data, datatype) {
|
|
matrix2._values = [];
|
|
matrix2._index = [];
|
|
matrix2._ptr = [];
|
|
matrix2._datatype = datatype;
|
|
var rows = data.length;
|
|
var columns = 0;
|
|
var eq = equalScalar2;
|
|
var zero = 0;
|
|
if (isString(datatype)) {
|
|
eq = typed2.find(equalScalar2, [datatype, datatype]) || equalScalar2;
|
|
zero = typed2.convert(0, datatype);
|
|
}
|
|
if (rows > 0) {
|
|
var j = 0;
|
|
do {
|
|
matrix2._ptr.push(matrix2._index.length);
|
|
for (var i2 = 0; i2 < rows; i2++) {
|
|
var row2 = data[i2];
|
|
if (isArray(row2)) {
|
|
if (j === 0 && columns < row2.length) {
|
|
columns = row2.length;
|
|
}
|
|
if (j < row2.length) {
|
|
var v = row2[j];
|
|
if (!eq(v, zero)) {
|
|
matrix2._values.push(v);
|
|
matrix2._index.push(i2);
|
|
}
|
|
}
|
|
} else {
|
|
if (j === 0 && columns < 1) {
|
|
columns = 1;
|
|
}
|
|
if (!eq(row2, zero)) {
|
|
matrix2._values.push(row2);
|
|
matrix2._index.push(i2);
|
|
}
|
|
}
|
|
}
|
|
j++;
|
|
} while (j < columns);
|
|
}
|
|
matrix2._ptr.push(matrix2._index.length);
|
|
matrix2._size = [rows, columns];
|
|
}
|
|
SparseMatrix2.prototype = new Matrix2();
|
|
SparseMatrix2.prototype.createSparseMatrix = function(data, datatype) {
|
|
return new SparseMatrix2(data, datatype);
|
|
};
|
|
Object.defineProperty(SparseMatrix2, "name", {
|
|
value: "SparseMatrix"
|
|
});
|
|
SparseMatrix2.prototype.constructor = SparseMatrix2;
|
|
SparseMatrix2.prototype.type = "SparseMatrix";
|
|
SparseMatrix2.prototype.isSparseMatrix = true;
|
|
SparseMatrix2.prototype.getDataType = function() {
|
|
return getArrayDataType(this._values, typeOf);
|
|
};
|
|
SparseMatrix2.prototype.storage = function() {
|
|
return "sparse";
|
|
};
|
|
SparseMatrix2.prototype.datatype = function() {
|
|
return this._datatype;
|
|
};
|
|
SparseMatrix2.prototype.create = function(data, datatype) {
|
|
return new SparseMatrix2(data, datatype);
|
|
};
|
|
SparseMatrix2.prototype.density = function() {
|
|
var rows = this._size[0];
|
|
var columns = this._size[1];
|
|
return rows !== 0 && columns !== 0 ? this._index.length / (rows * columns) : 0;
|
|
};
|
|
SparseMatrix2.prototype.subset = function(index2, replacement, defaultValue) {
|
|
if (!this._values) {
|
|
throw new Error("Cannot invoke subset on a Pattern only matrix");
|
|
}
|
|
switch (arguments.length) {
|
|
case 1:
|
|
return _getsubset(this, index2);
|
|
case 2:
|
|
case 3:
|
|
return _setsubset(this, index2, replacement, defaultValue);
|
|
default:
|
|
throw new SyntaxError("Wrong number of arguments");
|
|
}
|
|
};
|
|
function _getsubset(matrix2, idx) {
|
|
if (!isIndex(idx)) {
|
|
throw new TypeError("Invalid index");
|
|
}
|
|
var isScalar = idx.isScalar();
|
|
if (isScalar) {
|
|
return matrix2.get(idx.min());
|
|
}
|
|
var size2 = idx.size();
|
|
if (size2.length !== matrix2._size.length) {
|
|
throw new DimensionError(size2.length, matrix2._size.length);
|
|
}
|
|
var i2, ii, k, kk;
|
|
var min3 = idx.min();
|
|
var max3 = idx.max();
|
|
for (i2 = 0, ii = matrix2._size.length; i2 < ii; i2++) {
|
|
validateIndex(min3[i2], matrix2._size[i2]);
|
|
validateIndex(max3[i2], matrix2._size[i2]);
|
|
}
|
|
var mvalues = matrix2._values;
|
|
var mindex = matrix2._index;
|
|
var mptr = matrix2._ptr;
|
|
var rows = idx.dimension(0);
|
|
var columns = idx.dimension(1);
|
|
var w = [];
|
|
var pv = [];
|
|
rows.forEach(function(i3, r) {
|
|
pv[i3] = r[0];
|
|
w[i3] = true;
|
|
});
|
|
var values = mvalues ? [] : void 0;
|
|
var index2 = [];
|
|
var ptr = [];
|
|
columns.forEach(function(j) {
|
|
ptr.push(index2.length);
|
|
for (k = mptr[j], kk = mptr[j + 1]; k < kk; k++) {
|
|
i2 = mindex[k];
|
|
if (w[i2] === true) {
|
|
index2.push(pv[i2]);
|
|
if (values) {
|
|
values.push(mvalues[k]);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
ptr.push(index2.length);
|
|
return new SparseMatrix2({
|
|
values,
|
|
index: index2,
|
|
ptr,
|
|
size: size2,
|
|
datatype: matrix2._datatype
|
|
});
|
|
}
|
|
function _setsubset(matrix2, index2, submatrix, defaultValue) {
|
|
if (!index2 || index2.isIndex !== true) {
|
|
throw new TypeError("Invalid index");
|
|
}
|
|
var iSize = index2.size();
|
|
var isScalar = index2.isScalar();
|
|
var sSize;
|
|
if (isMatrix(submatrix)) {
|
|
sSize = submatrix.size();
|
|
submatrix = submatrix.toArray();
|
|
} else {
|
|
sSize = arraySize(submatrix);
|
|
}
|
|
if (isScalar) {
|
|
if (sSize.length !== 0) {
|
|
throw new TypeError("Scalar expected");
|
|
}
|
|
matrix2.set(index2.min(), submatrix, defaultValue);
|
|
} else {
|
|
if (iSize.length !== 1 && iSize.length !== 2) {
|
|
throw new DimensionError(iSize.length, matrix2._size.length, "<");
|
|
}
|
|
if (sSize.length < iSize.length) {
|
|
var i2 = 0;
|
|
var outer = 0;
|
|
while (iSize[i2] === 1 && sSize[i2] === 1) {
|
|
i2++;
|
|
}
|
|
while (iSize[i2] === 1) {
|
|
outer++;
|
|
i2++;
|
|
}
|
|
submatrix = unsqueeze(submatrix, iSize.length, outer, sSize);
|
|
}
|
|
if (!deepStrictEqual(iSize, sSize)) {
|
|
throw new DimensionError(iSize, sSize, ">");
|
|
}
|
|
if (iSize.length === 1) {
|
|
var range2 = index2.dimension(0);
|
|
range2.forEach(function(dataIndex, subIndex) {
|
|
validateIndex(dataIndex);
|
|
matrix2.set([dataIndex, 0], submatrix[subIndex[0]], defaultValue);
|
|
});
|
|
} else {
|
|
var firstDimensionRange = index2.dimension(0);
|
|
var secondDimensionRange = index2.dimension(1);
|
|
firstDimensionRange.forEach(function(firstDataIndex, firstSubIndex) {
|
|
validateIndex(firstDataIndex);
|
|
secondDimensionRange.forEach(function(secondDataIndex, secondSubIndex) {
|
|
validateIndex(secondDataIndex);
|
|
matrix2.set([firstDataIndex, secondDataIndex], submatrix[firstSubIndex[0]][secondSubIndex[0]], defaultValue);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
return matrix2;
|
|
}
|
|
SparseMatrix2.prototype.get = function(index2) {
|
|
if (!isArray(index2)) {
|
|
throw new TypeError("Array expected");
|
|
}
|
|
if (index2.length !== this._size.length) {
|
|
throw new DimensionError(index2.length, this._size.length);
|
|
}
|
|
if (!this._values) {
|
|
throw new Error("Cannot invoke get on a Pattern only matrix");
|
|
}
|
|
var i2 = index2[0];
|
|
var j = index2[1];
|
|
validateIndex(i2, this._size[0]);
|
|
validateIndex(j, this._size[1]);
|
|
var k = _getValueIndex(i2, this._ptr[j], this._ptr[j + 1], this._index);
|
|
if (k < this._ptr[j + 1] && this._index[k] === i2) {
|
|
return this._values[k];
|
|
}
|
|
return 0;
|
|
};
|
|
SparseMatrix2.prototype.set = function(index2, v, defaultValue) {
|
|
if (!isArray(index2)) {
|
|
throw new TypeError("Array expected");
|
|
}
|
|
if (index2.length !== this._size.length) {
|
|
throw new DimensionError(index2.length, this._size.length);
|
|
}
|
|
if (!this._values) {
|
|
throw new Error("Cannot invoke set on a Pattern only matrix");
|
|
}
|
|
var i2 = index2[0];
|
|
var j = index2[1];
|
|
var rows = this._size[0];
|
|
var columns = this._size[1];
|
|
var eq = equalScalar2;
|
|
var zero = 0;
|
|
if (isString(this._datatype)) {
|
|
eq = typed2.find(equalScalar2, [this._datatype, this._datatype]) || equalScalar2;
|
|
zero = typed2.convert(0, this._datatype);
|
|
}
|
|
if (i2 > rows - 1 || j > columns - 1) {
|
|
_resize2(this, Math.max(i2 + 1, rows), Math.max(j + 1, columns), defaultValue);
|
|
rows = this._size[0];
|
|
columns = this._size[1];
|
|
}
|
|
validateIndex(i2, rows);
|
|
validateIndex(j, columns);
|
|
var k = _getValueIndex(i2, this._ptr[j], this._ptr[j + 1], this._index);
|
|
if (k < this._ptr[j + 1] && this._index[k] === i2) {
|
|
if (!eq(v, zero)) {
|
|
this._values[k] = v;
|
|
} else {
|
|
_remove(k, j, this._values, this._index, this._ptr);
|
|
}
|
|
} else {
|
|
if (!eq(v, zero)) {
|
|
_insert(k, i2, j, v, this._values, this._index, this._ptr);
|
|
}
|
|
}
|
|
return this;
|
|
};
|
|
function _getValueIndex(i2, top, bottom, index2) {
|
|
if (bottom - top === 0) {
|
|
return bottom;
|
|
}
|
|
for (var r = top; r < bottom; r++) {
|
|
if (index2[r] === i2) {
|
|
return r;
|
|
}
|
|
}
|
|
return top;
|
|
}
|
|
function _remove(k, j, values, index2, ptr) {
|
|
values.splice(k, 1);
|
|
index2.splice(k, 1);
|
|
for (var x = j + 1; x < ptr.length; x++) {
|
|
ptr[x]--;
|
|
}
|
|
}
|
|
function _insert(k, i2, j, v, values, index2, ptr) {
|
|
values.splice(k, 0, v);
|
|
index2.splice(k, 0, i2);
|
|
for (var x = j + 1; x < ptr.length; x++) {
|
|
ptr[x]++;
|
|
}
|
|
}
|
|
SparseMatrix2.prototype.resize = function(size2, defaultValue, copy) {
|
|
if (!isCollection(size2)) {
|
|
throw new TypeError("Array or Matrix expected");
|
|
}
|
|
var sizeArray = size2.valueOf().map((value) => {
|
|
return Array.isArray(value) && value.length === 1 ? value[0] : value;
|
|
});
|
|
if (sizeArray.length !== 2) {
|
|
throw new Error("Only two dimensions matrix are supported");
|
|
}
|
|
sizeArray.forEach(function(value) {
|
|
if (!isNumber(value) || !isInteger(value) || value < 0) {
|
|
throw new TypeError("Invalid size, must contain positive integers (size: " + format3(sizeArray) + ")");
|
|
}
|
|
});
|
|
var m = copy ? this.clone() : this;
|
|
return _resize2(m, sizeArray[0], sizeArray[1], defaultValue);
|
|
};
|
|
function _resize2(matrix2, rows, columns, defaultValue) {
|
|
var value = defaultValue || 0;
|
|
var eq = equalScalar2;
|
|
var zero = 0;
|
|
if (isString(matrix2._datatype)) {
|
|
eq = typed2.find(equalScalar2, [matrix2._datatype, matrix2._datatype]) || equalScalar2;
|
|
zero = typed2.convert(0, matrix2._datatype);
|
|
value = typed2.convert(value, matrix2._datatype);
|
|
}
|
|
var ins = !eq(value, zero);
|
|
var r = matrix2._size[0];
|
|
var c = matrix2._size[1];
|
|
var i2, j, k;
|
|
if (columns > c) {
|
|
for (j = c; j < columns; j++) {
|
|
matrix2._ptr[j] = matrix2._values.length;
|
|
if (ins) {
|
|
for (i2 = 0; i2 < r; i2++) {
|
|
matrix2._values.push(value);
|
|
matrix2._index.push(i2);
|
|
}
|
|
}
|
|
}
|
|
matrix2._ptr[columns] = matrix2._values.length;
|
|
} else if (columns < c) {
|
|
matrix2._ptr.splice(columns + 1, c - columns);
|
|
matrix2._values.splice(matrix2._ptr[columns], matrix2._values.length);
|
|
matrix2._index.splice(matrix2._ptr[columns], matrix2._index.length);
|
|
}
|
|
c = columns;
|
|
if (rows > r) {
|
|
if (ins) {
|
|
var n = 0;
|
|
for (j = 0; j < c; j++) {
|
|
matrix2._ptr[j] = matrix2._ptr[j] + n;
|
|
k = matrix2._ptr[j + 1] + n;
|
|
var p = 0;
|
|
for (i2 = r; i2 < rows; i2++, p++) {
|
|
matrix2._values.splice(k + p, 0, value);
|
|
matrix2._index.splice(k + p, 0, i2);
|
|
n++;
|
|
}
|
|
}
|
|
matrix2._ptr[c] = matrix2._values.length;
|
|
}
|
|
} else if (rows < r) {
|
|
var d = 0;
|
|
for (j = 0; j < c; j++) {
|
|
matrix2._ptr[j] = matrix2._ptr[j] - d;
|
|
var k0 = matrix2._ptr[j];
|
|
var k1 = matrix2._ptr[j + 1] - d;
|
|
for (k = k0; k < k1; k++) {
|
|
i2 = matrix2._index[k];
|
|
if (i2 > rows - 1) {
|
|
matrix2._values.splice(k, 1);
|
|
matrix2._index.splice(k, 1);
|
|
d++;
|
|
}
|
|
}
|
|
}
|
|
matrix2._ptr[j] = matrix2._values.length;
|
|
}
|
|
matrix2._size[0] = rows;
|
|
matrix2._size[1] = columns;
|
|
return matrix2;
|
|
}
|
|
SparseMatrix2.prototype.reshape = function(sizes, copy) {
|
|
if (!isArray(sizes)) {
|
|
throw new TypeError("Array expected");
|
|
}
|
|
if (sizes.length !== 2) {
|
|
throw new Error("Sparse matrices can only be reshaped in two dimensions");
|
|
}
|
|
sizes.forEach(function(value) {
|
|
if (!isNumber(value) || !isInteger(value) || value <= -2 || value === 0) {
|
|
throw new TypeError("Invalid size, must contain positive integers or -1 (size: " + format3(sizes) + ")");
|
|
}
|
|
});
|
|
var currentLength = this._size[0] * this._size[1];
|
|
sizes = processSizesWildcard(sizes, currentLength);
|
|
var newLength = sizes[0] * sizes[1];
|
|
if (currentLength !== newLength) {
|
|
throw new Error("Reshaping sparse matrix will result in the wrong number of elements");
|
|
}
|
|
var m = copy ? this.clone() : this;
|
|
if (this._size[0] === sizes[0] && this._size[1] === sizes[1]) {
|
|
return m;
|
|
}
|
|
var colIndex = [];
|
|
for (var i2 = 0; i2 < m._ptr.length; i2++) {
|
|
for (var j = 0; j < m._ptr[i2 + 1] - m._ptr[i2]; j++) {
|
|
colIndex.push(i2);
|
|
}
|
|
}
|
|
var values = m._values.slice();
|
|
var rowIndex = m._index.slice();
|
|
for (var _i = 0; _i < m._index.length; _i++) {
|
|
var r1 = rowIndex[_i];
|
|
var c1 = colIndex[_i];
|
|
var flat = r1 * m._size[1] + c1;
|
|
colIndex[_i] = flat % sizes[1];
|
|
rowIndex[_i] = Math.floor(flat / sizes[1]);
|
|
}
|
|
m._values.length = 0;
|
|
m._index.length = 0;
|
|
m._ptr.length = sizes[1] + 1;
|
|
m._size = sizes.slice();
|
|
for (var _i2 = 0; _i2 < m._ptr.length; _i2++) {
|
|
m._ptr[_i2] = 0;
|
|
}
|
|
for (var h = 0; h < values.length; h++) {
|
|
var _i3 = rowIndex[h];
|
|
var _j = colIndex[h];
|
|
var v = values[h];
|
|
var k = _getValueIndex(_i3, m._ptr[_j], m._ptr[_j + 1], m._index);
|
|
_insert(k, _i3, _j, v, m._values, m._index, m._ptr);
|
|
}
|
|
return m;
|
|
};
|
|
SparseMatrix2.prototype.clone = function() {
|
|
var m = new SparseMatrix2({
|
|
values: this._values ? clone(this._values) : void 0,
|
|
index: clone(this._index),
|
|
ptr: clone(this._ptr),
|
|
size: clone(this._size),
|
|
datatype: this._datatype
|
|
});
|
|
return m;
|
|
};
|
|
SparseMatrix2.prototype.size = function() {
|
|
return this._size.slice(0);
|
|
};
|
|
SparseMatrix2.prototype.map = function(callback, skipZeros) {
|
|
if (!this._values) {
|
|
throw new Error("Cannot invoke map on a Pattern only matrix");
|
|
}
|
|
var me = this;
|
|
var rows = this._size[0];
|
|
var columns = this._size[1];
|
|
var args = maxArgumentCount(callback);
|
|
var invoke = function invoke2(v, i2, j) {
|
|
if (args === 1)
|
|
return callback(v);
|
|
if (args === 2)
|
|
return callback(v, [i2, j]);
|
|
return callback(v, [i2, j], me);
|
|
};
|
|
return _map3(this, 0, rows - 1, 0, columns - 1, invoke, skipZeros);
|
|
};
|
|
function _map3(matrix2, minRow, maxRow, minColumn, maxColumn, callback, skipZeros) {
|
|
var values = [];
|
|
var index2 = [];
|
|
var ptr = [];
|
|
var eq = equalScalar2;
|
|
var zero = 0;
|
|
if (isString(matrix2._datatype)) {
|
|
eq = typed2.find(equalScalar2, [matrix2._datatype, matrix2._datatype]) || equalScalar2;
|
|
zero = typed2.convert(0, matrix2._datatype);
|
|
}
|
|
var invoke = function invoke2(v, x, y) {
|
|
v = callback(v, x, y);
|
|
if (!eq(v, zero)) {
|
|
values.push(v);
|
|
index2.push(x);
|
|
}
|
|
};
|
|
for (var j = minColumn; j <= maxColumn; j++) {
|
|
ptr.push(values.length);
|
|
var k0 = matrix2._ptr[j];
|
|
var k1 = matrix2._ptr[j + 1];
|
|
if (skipZeros) {
|
|
for (var k = k0; k < k1; k++) {
|
|
var i2 = matrix2._index[k];
|
|
if (i2 >= minRow && i2 <= maxRow) {
|
|
invoke(matrix2._values[k], i2 - minRow, j - minColumn);
|
|
}
|
|
}
|
|
} else {
|
|
var _values = {};
|
|
for (var _k = k0; _k < k1; _k++) {
|
|
var _i4 = matrix2._index[_k];
|
|
_values[_i4] = matrix2._values[_k];
|
|
}
|
|
for (var _i5 = minRow; _i5 <= maxRow; _i5++) {
|
|
var value = _i5 in _values ? _values[_i5] : 0;
|
|
invoke(value, _i5 - minRow, j - minColumn);
|
|
}
|
|
}
|
|
}
|
|
ptr.push(values.length);
|
|
return new SparseMatrix2({
|
|
values,
|
|
index: index2,
|
|
ptr,
|
|
size: [maxRow - minRow + 1, maxColumn - minColumn + 1]
|
|
});
|
|
}
|
|
SparseMatrix2.prototype.forEach = function(callback, skipZeros) {
|
|
if (!this._values) {
|
|
throw new Error("Cannot invoke forEach on a Pattern only matrix");
|
|
}
|
|
var me = this;
|
|
var rows = this._size[0];
|
|
var columns = this._size[1];
|
|
for (var j = 0; j < columns; j++) {
|
|
var k0 = this._ptr[j];
|
|
var k1 = this._ptr[j + 1];
|
|
if (skipZeros) {
|
|
for (var k = k0; k < k1; k++) {
|
|
var i2 = this._index[k];
|
|
callback(this._values[k], [i2, j], me);
|
|
}
|
|
} else {
|
|
var values = {};
|
|
for (var _k2 = k0; _k2 < k1; _k2++) {
|
|
var _i6 = this._index[_k2];
|
|
values[_i6] = this._values[_k2];
|
|
}
|
|
for (var _i7 = 0; _i7 < rows; _i7++) {
|
|
var value = _i7 in values ? values[_i7] : 0;
|
|
callback(value, [_i7, j], me);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
SparseMatrix2.prototype[Symbol.iterator] = function* () {
|
|
if (!this._values) {
|
|
throw new Error("Cannot iterate a Pattern only matrix");
|
|
}
|
|
var columns = this._size[1];
|
|
for (var j = 0; j < columns; j++) {
|
|
var k0 = this._ptr[j];
|
|
var k1 = this._ptr[j + 1];
|
|
for (var k = k0; k < k1; k++) {
|
|
var i2 = this._index[k];
|
|
yield {
|
|
value: this._values[k],
|
|
index: [i2, j]
|
|
};
|
|
}
|
|
}
|
|
};
|
|
SparseMatrix2.prototype.toArray = function() {
|
|
return _toArray(this._values, this._index, this._ptr, this._size, true);
|
|
};
|
|
SparseMatrix2.prototype.valueOf = function() {
|
|
return _toArray(this._values, this._index, this._ptr, this._size, false);
|
|
};
|
|
function _toArray(values, index2, ptr, size2, copy) {
|
|
var rows = size2[0];
|
|
var columns = size2[1];
|
|
var a = [];
|
|
var i2, j;
|
|
for (i2 = 0; i2 < rows; i2++) {
|
|
a[i2] = [];
|
|
for (j = 0; j < columns; j++) {
|
|
a[i2][j] = 0;
|
|
}
|
|
}
|
|
for (j = 0; j < columns; j++) {
|
|
var k0 = ptr[j];
|
|
var k1 = ptr[j + 1];
|
|
for (var k = k0; k < k1; k++) {
|
|
i2 = index2[k];
|
|
a[i2][j] = values ? copy ? clone(values[k]) : values[k] : 1;
|
|
}
|
|
}
|
|
return a;
|
|
}
|
|
SparseMatrix2.prototype.format = function(options) {
|
|
var rows = this._size[0];
|
|
var columns = this._size[1];
|
|
var density = this.density();
|
|
var str = "Sparse Matrix [" + format3(rows, options) + " x " + format3(columns, options) + "] density: " + format3(density, options) + "\n";
|
|
for (var j = 0; j < columns; j++) {
|
|
var k0 = this._ptr[j];
|
|
var k1 = this._ptr[j + 1];
|
|
for (var k = k0; k < k1; k++) {
|
|
var i2 = this._index[k];
|
|
str += "\n (" + format3(i2, options) + ", " + format3(j, options) + ") ==> " + (this._values ? format3(this._values[k], options) : "X");
|
|
}
|
|
}
|
|
return str;
|
|
};
|
|
SparseMatrix2.prototype.toString = function() {
|
|
return format3(this.toArray());
|
|
};
|
|
SparseMatrix2.prototype.toJSON = function() {
|
|
return {
|
|
mathjs: "SparseMatrix",
|
|
values: this._values,
|
|
index: this._index,
|
|
ptr: this._ptr,
|
|
size: this._size,
|
|
datatype: this._datatype
|
|
};
|
|
};
|
|
SparseMatrix2.prototype.diagonal = function(k) {
|
|
if (k) {
|
|
if (isBigNumber(k)) {
|
|
k = k.toNumber();
|
|
}
|
|
if (!isNumber(k) || !isInteger(k)) {
|
|
throw new TypeError("The parameter k must be an integer number");
|
|
}
|
|
} else {
|
|
k = 0;
|
|
}
|
|
var kSuper = k > 0 ? k : 0;
|
|
var kSub = k < 0 ? -k : 0;
|
|
var rows = this._size[0];
|
|
var columns = this._size[1];
|
|
var n = Math.min(rows - kSub, columns - kSuper);
|
|
var values = [];
|
|
var index2 = [];
|
|
var ptr = [];
|
|
ptr[0] = 0;
|
|
for (var j = kSuper; j < columns && values.length < n; j++) {
|
|
var k0 = this._ptr[j];
|
|
var k1 = this._ptr[j + 1];
|
|
for (var x = k0; x < k1; x++) {
|
|
var i2 = this._index[x];
|
|
if (i2 === j - kSuper + kSub) {
|
|
values.push(this._values[x]);
|
|
index2[values.length - 1] = i2 - kSub;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
ptr.push(values.length);
|
|
return new SparseMatrix2({
|
|
values,
|
|
index: index2,
|
|
ptr,
|
|
size: [n, 1]
|
|
});
|
|
};
|
|
SparseMatrix2.fromJSON = function(json) {
|
|
return new SparseMatrix2(json);
|
|
};
|
|
SparseMatrix2.diagonal = function(size2, value, k, defaultValue, datatype) {
|
|
if (!isArray(size2)) {
|
|
throw new TypeError("Array expected, size parameter");
|
|
}
|
|
if (size2.length !== 2) {
|
|
throw new Error("Only two dimensions matrix are supported");
|
|
}
|
|
size2 = size2.map(function(s) {
|
|
if (isBigNumber(s)) {
|
|
s = s.toNumber();
|
|
}
|
|
if (!isNumber(s) || !isInteger(s) || s < 1) {
|
|
throw new Error("Size values must be positive integers");
|
|
}
|
|
return s;
|
|
});
|
|
if (k) {
|
|
if (isBigNumber(k)) {
|
|
k = k.toNumber();
|
|
}
|
|
if (!isNumber(k) || !isInteger(k)) {
|
|
throw new TypeError("The parameter k must be an integer number");
|
|
}
|
|
} else {
|
|
k = 0;
|
|
}
|
|
var eq = equalScalar2;
|
|
var zero = 0;
|
|
if (isString(datatype)) {
|
|
eq = typed2.find(equalScalar2, [datatype, datatype]) || equalScalar2;
|
|
zero = typed2.convert(0, datatype);
|
|
}
|
|
var kSuper = k > 0 ? k : 0;
|
|
var kSub = k < 0 ? -k : 0;
|
|
var rows = size2[0];
|
|
var columns = size2[1];
|
|
var n = Math.min(rows - kSub, columns - kSuper);
|
|
var _value;
|
|
if (isArray(value)) {
|
|
if (value.length !== n) {
|
|
throw new Error("Invalid value array length");
|
|
}
|
|
_value = function _value2(i3) {
|
|
return value[i3];
|
|
};
|
|
} else if (isMatrix(value)) {
|
|
var ms = value.size();
|
|
if (ms.length !== 1 || ms[0] !== n) {
|
|
throw new Error("Invalid matrix length");
|
|
}
|
|
_value = function _value2(i3) {
|
|
return value.get([i3]);
|
|
};
|
|
} else {
|
|
_value = function _value2() {
|
|
return value;
|
|
};
|
|
}
|
|
var values = [];
|
|
var index2 = [];
|
|
var ptr = [];
|
|
for (var j = 0; j < columns; j++) {
|
|
ptr.push(values.length);
|
|
var i2 = j - kSuper;
|
|
if (i2 >= 0 && i2 < n) {
|
|
var v = _value(i2);
|
|
if (!eq(v, zero)) {
|
|
index2.push(i2 + kSub);
|
|
values.push(v);
|
|
}
|
|
}
|
|
}
|
|
ptr.push(values.length);
|
|
return new SparseMatrix2({
|
|
values,
|
|
index: index2,
|
|
ptr,
|
|
size: [rows, columns]
|
|
});
|
|
};
|
|
SparseMatrix2.prototype.swapRows = function(i2, j) {
|
|
if (!isNumber(i2) || !isInteger(i2) || !isNumber(j) || !isInteger(j)) {
|
|
throw new Error("Row index must be positive integers");
|
|
}
|
|
if (this._size.length !== 2) {
|
|
throw new Error("Only two dimensional matrix is supported");
|
|
}
|
|
validateIndex(i2, this._size[0]);
|
|
validateIndex(j, this._size[0]);
|
|
SparseMatrix2._swapRows(i2, j, this._size[1], this._values, this._index, this._ptr);
|
|
return this;
|
|
};
|
|
SparseMatrix2._forEachRow = function(j, values, index2, ptr, callback) {
|
|
var k0 = ptr[j];
|
|
var k1 = ptr[j + 1];
|
|
for (var k = k0; k < k1; k++) {
|
|
callback(index2[k], values[k]);
|
|
}
|
|
};
|
|
SparseMatrix2._swapRows = function(x, y, columns, values, index2, ptr) {
|
|
for (var j = 0; j < columns; j++) {
|
|
var k0 = ptr[j];
|
|
var k1 = ptr[j + 1];
|
|
var kx = _getValueIndex(x, k0, k1, index2);
|
|
var ky = _getValueIndex(y, k0, k1, index2);
|
|
if (kx < k1 && ky < k1 && index2[kx] === x && index2[ky] === y) {
|
|
if (values) {
|
|
var v = values[kx];
|
|
values[kx] = values[ky];
|
|
values[ky] = v;
|
|
}
|
|
continue;
|
|
}
|
|
if (kx < k1 && index2[kx] === x && (ky >= k1 || index2[ky] !== y)) {
|
|
var vx = values ? values[kx] : void 0;
|
|
index2.splice(ky, 0, y);
|
|
if (values) {
|
|
values.splice(ky, 0, vx);
|
|
}
|
|
index2.splice(ky <= kx ? kx + 1 : kx, 1);
|
|
if (values) {
|
|
values.splice(ky <= kx ? kx + 1 : kx, 1);
|
|
}
|
|
continue;
|
|
}
|
|
if (ky < k1 && index2[ky] === y && (kx >= k1 || index2[kx] !== x)) {
|
|
var vy = values ? values[ky] : void 0;
|
|
index2.splice(kx, 0, x);
|
|
if (values) {
|
|
values.splice(kx, 0, vy);
|
|
}
|
|
index2.splice(kx <= ky ? ky + 1 : ky, 1);
|
|
if (values) {
|
|
values.splice(kx <= ky ? ky + 1 : ky, 1);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
return SparseMatrix2;
|
|
}, {
|
|
isClass: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/number.js
|
|
var name19 = "number";
|
|
var dependencies20 = ["typed"];
|
|
function getNonDecimalNumberParts(input) {
|
|
var nonDecimalWithRadixMatch = input.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);
|
|
if (nonDecimalWithRadixMatch) {
|
|
var radix = {
|
|
"0b": 2,
|
|
"0o": 8,
|
|
"0x": 16
|
|
}[nonDecimalWithRadixMatch[1]];
|
|
var integerPart = nonDecimalWithRadixMatch[2];
|
|
var fractionalPart = nonDecimalWithRadixMatch[3];
|
|
return {
|
|
input,
|
|
radix,
|
|
integerPart,
|
|
fractionalPart
|
|
};
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
function makeNumberFromNonDecimalParts(parts) {
|
|
var n = parseInt(parts.integerPart, parts.radix);
|
|
var f = 0;
|
|
for (var i2 = 0; i2 < parts.fractionalPart.length; i2++) {
|
|
var digitValue = parseInt(parts.fractionalPart[i2], parts.radix);
|
|
f += digitValue / Math.pow(parts.radix, i2 + 1);
|
|
}
|
|
var result = n + f;
|
|
if (isNaN(result)) {
|
|
throw new SyntaxError('String "' + parts.input + '" is no valid number');
|
|
}
|
|
return result;
|
|
}
|
|
var createNumber = /* @__PURE__ */ factory(name19, dependencies20, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
var number2 = typed2("number", {
|
|
"": function _() {
|
|
return 0;
|
|
},
|
|
number: function number3(x) {
|
|
return x;
|
|
},
|
|
string: function string2(x) {
|
|
if (x === "NaN")
|
|
return NaN;
|
|
var nonDecimalNumberParts = getNonDecimalNumberParts(x);
|
|
if (nonDecimalNumberParts) {
|
|
return makeNumberFromNonDecimalParts(nonDecimalNumberParts);
|
|
}
|
|
var size2 = 0;
|
|
var wordSizeSuffixMatch = x.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);
|
|
if (wordSizeSuffixMatch) {
|
|
size2 = Number(wordSizeSuffixMatch[2]);
|
|
x = wordSizeSuffixMatch[1];
|
|
}
|
|
var num = Number(x);
|
|
if (isNaN(num)) {
|
|
throw new SyntaxError('String "' + x + '" is no valid number');
|
|
}
|
|
if (wordSizeSuffixMatch) {
|
|
if (num > 2 ** size2 - 1) {
|
|
throw new SyntaxError('String "'.concat(x, '" is out of range'));
|
|
}
|
|
if (num >= 2 ** (size2 - 1)) {
|
|
num = num - 2 ** size2;
|
|
}
|
|
}
|
|
return num;
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return x.toNumber();
|
|
},
|
|
Fraction: function Fraction3(x) {
|
|
return x.valueOf();
|
|
},
|
|
Unit: function Unit2(x) {
|
|
throw new Error("Second argument with valueless unit expected");
|
|
},
|
|
null: function _null2(x) {
|
|
return 0;
|
|
},
|
|
"Unit, string | Unit": function UnitStringUnit(unit2, valuelessUnit) {
|
|
return unit2.toNumber(valuelessUnit);
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
number2.fromJSON = function(json) {
|
|
return parseFloat(json.value);
|
|
};
|
|
return number2;
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/string.js
|
|
var name20 = "string";
|
|
var dependencies21 = ["typed"];
|
|
var createString = /* @__PURE__ */ factory(name20, dependencies21, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name20, {
|
|
"": function _() {
|
|
return "";
|
|
},
|
|
number: format,
|
|
null: function _null2(x) {
|
|
return "null";
|
|
},
|
|
boolean: function boolean2(x) {
|
|
return x + "";
|
|
},
|
|
string: function string2(x) {
|
|
return x;
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2)),
|
|
any: function any(x) {
|
|
return String(x);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/boolean.js
|
|
var name21 = "boolean";
|
|
var dependencies22 = ["typed"];
|
|
var createBoolean = /* @__PURE__ */ factory(name21, dependencies22, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name21, {
|
|
"": function _() {
|
|
return false;
|
|
},
|
|
boolean: function boolean2(x) {
|
|
return x;
|
|
},
|
|
number: function number2(x) {
|
|
return !!x;
|
|
},
|
|
null: function _null2(x) {
|
|
return false;
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return !x.isZero();
|
|
},
|
|
string: function string2(x) {
|
|
var lcase = x.toLowerCase();
|
|
if (lcase === "true") {
|
|
return true;
|
|
} else if (lcase === "false") {
|
|
return false;
|
|
}
|
|
var num = Number(x);
|
|
if (x !== "" && !isNaN(num)) {
|
|
return !!num;
|
|
}
|
|
throw new Error('Cannot convert "' + x + '" to a boolean');
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/bignumber/function/bignumber.js
|
|
var name22 = "bignumber";
|
|
var dependencies23 = ["typed", "BigNumber"];
|
|
var createBignumber = /* @__PURE__ */ factory(name22, dependencies23, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
BigNumber: BigNumber2
|
|
} = _ref;
|
|
return typed2("bignumber", {
|
|
"": function _() {
|
|
return new BigNumber2(0);
|
|
},
|
|
number: function number2(x) {
|
|
return new BigNumber2(x + "");
|
|
},
|
|
string: function string2(x) {
|
|
var wordSizeSuffixMatch = x.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);
|
|
if (wordSizeSuffixMatch) {
|
|
var size2 = wordSizeSuffixMatch[2];
|
|
var n = BigNumber2(wordSizeSuffixMatch[1]);
|
|
var twoPowSize = new BigNumber2(2).pow(Number(size2));
|
|
if (n.gt(twoPowSize.sub(1))) {
|
|
throw new SyntaxError('String "'.concat(x, '" is out of range'));
|
|
}
|
|
var twoPowSizeSubOne = new BigNumber2(2).pow(Number(size2) - 1);
|
|
if (n.gte(twoPowSizeSubOne)) {
|
|
return n.sub(twoPowSize);
|
|
} else {
|
|
return n;
|
|
}
|
|
}
|
|
return new BigNumber2(x);
|
|
},
|
|
BigNumber: function BigNumber3(x) {
|
|
return x;
|
|
},
|
|
Fraction: function Fraction3(x) {
|
|
return new BigNumber2(x.n).div(x.d).times(x.s);
|
|
},
|
|
null: function _null2(x) {
|
|
return new BigNumber2(0);
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/complex/function/complex.js
|
|
var name23 = "complex";
|
|
var dependencies24 = ["typed", "Complex"];
|
|
var createComplex = /* @__PURE__ */ factory(name23, dependencies24, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
Complex: Complex3
|
|
} = _ref;
|
|
return typed2("complex", {
|
|
"": function _() {
|
|
return Complex3.ZERO;
|
|
},
|
|
number: function number2(x) {
|
|
return new Complex3(x, 0);
|
|
},
|
|
"number, number": function numberNumber(re2, im2) {
|
|
return new Complex3(re2, im2);
|
|
},
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(re2, im2) {
|
|
return new Complex3(re2.toNumber(), im2.toNumber());
|
|
},
|
|
Fraction: function Fraction3(x) {
|
|
return new Complex3(x.valueOf(), 0);
|
|
},
|
|
Complex: function Complex4(x) {
|
|
return x.clone();
|
|
},
|
|
string: function string2(x) {
|
|
return Complex3(x);
|
|
},
|
|
null: function _null2(x) {
|
|
return Complex3(0);
|
|
},
|
|
Object: function Object2(x) {
|
|
if ("re" in x && "im" in x) {
|
|
return new Complex3(x.re, x.im);
|
|
}
|
|
if ("r" in x && "phi" in x || "abs" in x && "arg" in x) {
|
|
return new Complex3(x);
|
|
}
|
|
throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)");
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/fraction/function/fraction.js
|
|
var name24 = "fraction";
|
|
var dependencies25 = ["typed", "Fraction"];
|
|
var createFraction = /* @__PURE__ */ factory(name24, dependencies25, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
Fraction: Fraction3
|
|
} = _ref;
|
|
return typed2("fraction", {
|
|
number: function number2(x) {
|
|
if (!isFinite(x) || isNaN(x)) {
|
|
throw new Error(x + " cannot be represented as a fraction");
|
|
}
|
|
return new Fraction3(x);
|
|
},
|
|
string: function string2(x) {
|
|
return new Fraction3(x);
|
|
},
|
|
"number, number": function numberNumber(numerator, denominator) {
|
|
return new Fraction3(numerator, denominator);
|
|
},
|
|
null: function _null2(x) {
|
|
return new Fraction3(0);
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return new Fraction3(x.toString());
|
|
},
|
|
Fraction: function Fraction4(x) {
|
|
return x;
|
|
},
|
|
Object: function Object2(x) {
|
|
return new Fraction3(x);
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/function/matrix.js
|
|
var name25 = "matrix";
|
|
var dependencies26 = ["typed", "Matrix", "DenseMatrix", "SparseMatrix"];
|
|
var createMatrix = /* @__PURE__ */ factory(name25, dependencies26, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
Matrix: Matrix2,
|
|
DenseMatrix: DenseMatrix2,
|
|
SparseMatrix: SparseMatrix2
|
|
} = _ref;
|
|
return typed2(name25, {
|
|
"": function _() {
|
|
return _create([]);
|
|
},
|
|
string: function string2(format5) {
|
|
return _create([], format5);
|
|
},
|
|
"string, string": function stringString(format5, datatype) {
|
|
return _create([], format5, datatype);
|
|
},
|
|
Array: function Array2(data) {
|
|
return _create(data);
|
|
},
|
|
Matrix: function Matrix3(data) {
|
|
return _create(data, data.storage());
|
|
},
|
|
"Array | Matrix, string": _create,
|
|
"Array | Matrix, string, string": _create
|
|
});
|
|
function _create(data, format5, datatype) {
|
|
if (format5 === "dense" || format5 === "default" || format5 === void 0) {
|
|
return new DenseMatrix2(data, datatype);
|
|
}
|
|
if (format5 === "sparse") {
|
|
return new SparseMatrix2(data, datatype);
|
|
}
|
|
throw new TypeError("Unknown matrix type " + JSON.stringify(format5) + ".");
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/matrixFromFunction.js
|
|
var name26 = "matrixFromFunction";
|
|
var dependencies27 = ["typed", "matrix", "isZero"];
|
|
var createMatrixFromFunction = /* @__PURE__ */ factory(name26, dependencies27, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
isZero: isZero2
|
|
} = _ref;
|
|
return typed2(name26, {
|
|
"Array | Matrix, function, string, string": function ArrayMatrixFunctionStringString(size2, fn, format5, datatype) {
|
|
return _create(size2, fn, format5, datatype);
|
|
},
|
|
"Array | Matrix, function, string": function ArrayMatrixFunctionString(size2, fn, format5) {
|
|
return _create(size2, fn, format5);
|
|
},
|
|
"Matrix, function": function MatrixFunction(size2, fn) {
|
|
return _create(size2, fn, "dense");
|
|
},
|
|
"Array, function": function ArrayFunction(size2, fn) {
|
|
return _create(size2, fn, "dense").toArray();
|
|
},
|
|
"Array | Matrix, string, function": function ArrayMatrixStringFunction(size2, format5, fn) {
|
|
return _create(size2, fn, format5);
|
|
},
|
|
"Array | Matrix, string, string, function": function ArrayMatrixStringStringFunction(size2, format5, datatype, fn) {
|
|
return _create(size2, fn, format5, datatype);
|
|
}
|
|
});
|
|
function _create(size2, fn, format5, datatype) {
|
|
var m;
|
|
if (datatype !== void 0) {
|
|
m = matrix2(format5, datatype);
|
|
} else {
|
|
m = matrix2(format5);
|
|
}
|
|
m.resize(size2);
|
|
m.forEach(function(_, index2) {
|
|
var val = fn(index2);
|
|
if (isZero2(val))
|
|
return;
|
|
m.set(index2, val);
|
|
});
|
|
return m;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/matrixFromRows.js
|
|
var name27 = "matrixFromRows";
|
|
var dependencies28 = ["typed", "matrix", "flatten", "size"];
|
|
var createMatrixFromRows = /* @__PURE__ */ factory(name27, dependencies28, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
flatten: flatten3,
|
|
size: size2
|
|
} = _ref;
|
|
return typed2(name27, {
|
|
"...Array": function Array2(arr) {
|
|
return _createArray(arr);
|
|
},
|
|
"...Matrix": function Matrix2(arr) {
|
|
return matrix2(_createArray(arr.map((m) => m.toArray())));
|
|
}
|
|
});
|
|
function _createArray(arr) {
|
|
if (arr.length === 0)
|
|
throw new TypeError("At least one row is needed to construct a matrix.");
|
|
var N = checkVectorTypeAndReturnLength(arr[0]);
|
|
var result = [];
|
|
for (var row2 of arr) {
|
|
var rowLength = checkVectorTypeAndReturnLength(row2);
|
|
if (rowLength !== N) {
|
|
throw new TypeError("The vectors had different length: " + (N | 0) + " \u2260 " + (rowLength | 0));
|
|
}
|
|
result.push(flatten3(row2));
|
|
}
|
|
return result;
|
|
}
|
|
function checkVectorTypeAndReturnLength(vec) {
|
|
var s = size2(vec);
|
|
if (s.length === 1) {
|
|
return s[0];
|
|
} else if (s.length === 2) {
|
|
if (s[0] === 1) {
|
|
return s[1];
|
|
} else if (s[1] === 1) {
|
|
return s[0];
|
|
} else {
|
|
throw new TypeError("At least one of the arguments is not a vector.");
|
|
}
|
|
} else {
|
|
throw new TypeError("Only one- or two-dimensional vectors are supported.");
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/matrixFromColumns.js
|
|
var name28 = "matrixFromColumns";
|
|
var dependencies29 = ["typed", "matrix", "flatten", "size"];
|
|
var createMatrixFromColumns = /* @__PURE__ */ factory(name28, dependencies29, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
flatten: flatten3,
|
|
size: size2
|
|
} = _ref;
|
|
return typed2(name28, {
|
|
"...Array": function Array2(arr) {
|
|
return _createArray(arr);
|
|
},
|
|
"...Matrix": function Matrix2(arr) {
|
|
return matrix2(_createArray(arr.map((m) => m.toArray())));
|
|
}
|
|
});
|
|
function _createArray(arr) {
|
|
if (arr.length === 0)
|
|
throw new TypeError("At least one column is needed to construct a matrix.");
|
|
var N = checkVectorTypeAndReturnLength(arr[0]);
|
|
var result = [];
|
|
for (var i2 = 0; i2 < N; i2++) {
|
|
result[i2] = [];
|
|
}
|
|
for (var col of arr) {
|
|
var colLength = checkVectorTypeAndReturnLength(col);
|
|
if (colLength !== N) {
|
|
throw new TypeError("The vectors had different length: " + (N | 0) + " \u2260 " + (colLength | 0));
|
|
}
|
|
var f = flatten3(col);
|
|
for (var _i = 0; _i < N; _i++) {
|
|
result[_i].push(f[_i]);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
function checkVectorTypeAndReturnLength(vec) {
|
|
var s = size2(vec);
|
|
if (s.length === 1) {
|
|
return s[0];
|
|
} else if (s.length === 2) {
|
|
if (s[0] === 1) {
|
|
return s[1];
|
|
} else if (s[1] === 1) {
|
|
return s[0];
|
|
} else {
|
|
throw new TypeError("At least one of the arguments is not a vector.");
|
|
}
|
|
} else {
|
|
throw new TypeError("Only one- or two-dimensional vectors are supported.");
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/unit/function/splitUnit.js
|
|
var name29 = "splitUnit";
|
|
var dependencies30 = ["typed"];
|
|
var createSplitUnit = /* @__PURE__ */ factory(name29, dependencies30, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name29, {
|
|
"Unit, Array": function UnitArray(unit2, parts) {
|
|
return unit2.splitUnit(parts);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/unaryMinus.js
|
|
var name30 = "unaryMinus";
|
|
var dependencies31 = ["typed"];
|
|
var createUnaryMinus = /* @__PURE__ */ factory(name30, dependencies31, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name30, {
|
|
number: unaryMinusNumber,
|
|
"Complex | BigNumber | Fraction": (x) => x.neg(),
|
|
Unit: typed2.referToSelf((self2) => (x) => {
|
|
var res = x.clone();
|
|
res.value = typed2.find(self2, res.valueType())(x.value);
|
|
return res;
|
|
}),
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2, true))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/unaryPlus.js
|
|
var name31 = "unaryPlus";
|
|
var dependencies32 = ["typed", "config", "BigNumber"];
|
|
var createUnaryPlus = /* @__PURE__ */ factory(name31, dependencies32, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
BigNumber: BigNumber2
|
|
} = _ref;
|
|
return typed2(name31, {
|
|
number: unaryPlusNumber,
|
|
Complex: function Complex3(x) {
|
|
return x;
|
|
},
|
|
BigNumber: function BigNumber3(x) {
|
|
return x;
|
|
},
|
|
Fraction: function Fraction3(x) {
|
|
return x;
|
|
},
|
|
Unit: function Unit2(x) {
|
|
return x.clone();
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2, true)),
|
|
"boolean | string": function booleanString(x) {
|
|
return config4.number === "BigNumber" ? new BigNumber2(+x) : +x;
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/abs.js
|
|
var name32 = "abs";
|
|
var dependencies33 = ["typed"];
|
|
var createAbs = /* @__PURE__ */ factory(name32, dependencies33, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name32, {
|
|
number: absNumber,
|
|
"Complex | BigNumber | Fraction | Unit": (x) => x.abs(),
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2, true))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/apply.js
|
|
var name33 = "apply";
|
|
var dependencies34 = ["typed", "isInteger"];
|
|
var createApply = /* @__PURE__ */ factory(name33, dependencies34, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
isInteger: isInteger3
|
|
} = _ref;
|
|
return typed2(name33, {
|
|
"Array | Matrix, number | BigNumber, function": function ArrayMatrixNumberBigNumberFunction(mat, dim, callback) {
|
|
if (!isInteger3(dim)) {
|
|
throw new TypeError("Integer number expected for dimension");
|
|
}
|
|
var size2 = Array.isArray(mat) ? arraySize(mat) : mat.size();
|
|
if (dim < 0 || dim >= size2.length) {
|
|
throw new IndexError(dim, size2.length);
|
|
}
|
|
if (isMatrix(mat)) {
|
|
return mat.create(_apply(mat.valueOf(), dim, callback));
|
|
} else {
|
|
return _apply(mat, dim, callback);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
function _apply(mat, dim, callback) {
|
|
var i2, ret, tran;
|
|
if (dim <= 0) {
|
|
if (!Array.isArray(mat[0])) {
|
|
return callback(mat);
|
|
} else {
|
|
tran = _switch2(mat);
|
|
ret = [];
|
|
for (i2 = 0; i2 < tran.length; i2++) {
|
|
ret[i2] = _apply(tran[i2], dim - 1, callback);
|
|
}
|
|
return ret;
|
|
}
|
|
} else {
|
|
ret = [];
|
|
for (i2 = 0; i2 < mat.length; i2++) {
|
|
ret[i2] = _apply(mat[i2], dim - 1, callback);
|
|
}
|
|
return ret;
|
|
}
|
|
}
|
|
function _switch2(mat) {
|
|
var I = mat.length;
|
|
var J = mat[0].length;
|
|
var i2, j;
|
|
var ret = [];
|
|
for (j = 0; j < J; j++) {
|
|
var tmp = [];
|
|
for (i2 = 0; i2 < I; i2++) {
|
|
tmp.push(mat[i2][j]);
|
|
}
|
|
ret.push(tmp);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/addScalar.js
|
|
var name34 = "addScalar";
|
|
var dependencies35 = ["typed"];
|
|
var createAddScalar = /* @__PURE__ */ factory(name34, dependencies35, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name34, {
|
|
"number, number": addNumber,
|
|
"Complex, Complex": function ComplexComplex(x, y) {
|
|
return x.add(y);
|
|
},
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(x, y) {
|
|
return x.plus(y);
|
|
},
|
|
"Fraction, Fraction": function FractionFraction(x, y) {
|
|
return x.add(y);
|
|
},
|
|
"Unit, Unit": typed2.referToSelf((self2) => (x, y) => {
|
|
if (x.value === null || x.value === void 0) {
|
|
throw new Error("Parameter x contains a unit with undefined value");
|
|
}
|
|
if (y.value === null || y.value === void 0) {
|
|
throw new Error("Parameter y contains a unit with undefined value");
|
|
}
|
|
if (!x.equalBase(y))
|
|
throw new Error("Units do not match");
|
|
var res = x.clone();
|
|
res.value = typed2.find(self2, [res.valueType(), y.valueType()])(res.value, y.value);
|
|
res.fixPrefix = false;
|
|
return res;
|
|
})
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/cbrt.js
|
|
var name35 = "cbrt";
|
|
var dependencies36 = ["config", "typed", "isNegative", "unaryMinus", "matrix", "Complex", "BigNumber", "Fraction"];
|
|
var createCbrt = /* @__PURE__ */ factory(name35, dependencies36, (_ref) => {
|
|
var {
|
|
config: config4,
|
|
typed: typed2,
|
|
isNegative: isNegative2,
|
|
unaryMinus: unaryMinus2,
|
|
matrix: matrix2,
|
|
Complex: Complex3,
|
|
BigNumber: BigNumber2,
|
|
Fraction: Fraction3
|
|
} = _ref;
|
|
return typed2(name35, {
|
|
number: cbrtNumber,
|
|
Complex: _cbrtComplex,
|
|
"Complex, boolean": _cbrtComplex,
|
|
BigNumber: function BigNumber3(x) {
|
|
return x.cbrt();
|
|
},
|
|
Unit: _cbrtUnit
|
|
});
|
|
function _cbrtComplex(x, allRoots) {
|
|
var arg3 = x.arg() / 3;
|
|
var abs3 = x.abs();
|
|
var principal = new Complex3(cbrtNumber(abs3), 0).mul(new Complex3(0, arg3).exp());
|
|
if (allRoots) {
|
|
var all = [principal, new Complex3(cbrtNumber(abs3), 0).mul(new Complex3(0, arg3 + Math.PI * 2 / 3).exp()), new Complex3(cbrtNumber(abs3), 0).mul(new Complex3(0, arg3 - Math.PI * 2 / 3).exp())];
|
|
return config4.matrix === "Array" ? all : matrix2(all);
|
|
} else {
|
|
return principal;
|
|
}
|
|
}
|
|
function _cbrtUnit(x) {
|
|
if (x.value && isComplex(x.value)) {
|
|
var result = x.clone();
|
|
result.value = 1;
|
|
result = result.pow(1 / 3);
|
|
result.value = _cbrtComplex(x.value);
|
|
return result;
|
|
} else {
|
|
var negate = isNegative2(x.value);
|
|
if (negate) {
|
|
x.value = unaryMinus2(x.value);
|
|
}
|
|
var third;
|
|
if (isBigNumber(x.value)) {
|
|
third = new BigNumber2(1).div(3);
|
|
} else if (isFraction(x.value)) {
|
|
third = new Fraction3(1, 3);
|
|
} else {
|
|
third = 1 / 3;
|
|
}
|
|
var _result = x.pow(third);
|
|
if (negate) {
|
|
_result.value = unaryMinus2(_result.value);
|
|
}
|
|
return _result;
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/utils/matAlgo11xS0s.js
|
|
var name36 = "matAlgo11xS0s";
|
|
var dependencies37 = ["typed", "equalScalar"];
|
|
var createMatAlgo11xS0s = /* @__PURE__ */ factory(name36, dependencies37, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
} = _ref;
|
|
return function matAlgo11xS0s(s, b, callback, inverse) {
|
|
var avalues = s._values;
|
|
var aindex = s._index;
|
|
var aptr = s._ptr;
|
|
var asize = s._size;
|
|
var adt = s._datatype;
|
|
if (!avalues) {
|
|
throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");
|
|
}
|
|
var rows = asize[0];
|
|
var columns = asize[1];
|
|
var dt;
|
|
var eq = equalScalar2;
|
|
var zero = 0;
|
|
var cf = callback;
|
|
if (typeof adt === "string") {
|
|
dt = adt;
|
|
eq = typed2.find(equalScalar2, [dt, dt]);
|
|
zero = typed2.convert(0, dt);
|
|
b = typed2.convert(b, dt);
|
|
cf = typed2.find(callback, [dt, dt]);
|
|
}
|
|
var cvalues = [];
|
|
var cindex = [];
|
|
var cptr = [];
|
|
for (var j = 0; j < columns; j++) {
|
|
cptr[j] = cindex.length;
|
|
for (var k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) {
|
|
var i2 = aindex[k];
|
|
var v = inverse ? cf(b, avalues[k]) : cf(avalues[k], b);
|
|
if (!eq(v, zero)) {
|
|
cindex.push(i2);
|
|
cvalues.push(v);
|
|
}
|
|
}
|
|
}
|
|
cptr[columns] = cindex.length;
|
|
return s.createSparseMatrix({
|
|
values: cvalues,
|
|
index: cindex,
|
|
ptr: cptr,
|
|
size: [rows, columns],
|
|
datatype: dt
|
|
});
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/utils/matAlgo12xSfs.js
|
|
var name37 = "matAlgo12xSfs";
|
|
var dependencies38 = ["typed", "DenseMatrix"];
|
|
var createMatAlgo12xSfs = /* @__PURE__ */ factory(name37, dependencies38, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
} = _ref;
|
|
return function matAlgo12xSfs(s, b, callback, inverse) {
|
|
var avalues = s._values;
|
|
var aindex = s._index;
|
|
var aptr = s._ptr;
|
|
var asize = s._size;
|
|
var adt = s._datatype;
|
|
if (!avalues) {
|
|
throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");
|
|
}
|
|
var rows = asize[0];
|
|
var columns = asize[1];
|
|
var dt;
|
|
var cf = callback;
|
|
if (typeof adt === "string") {
|
|
dt = adt;
|
|
b = typed2.convert(b, dt);
|
|
cf = typed2.find(callback, [dt, dt]);
|
|
}
|
|
var cdata = [];
|
|
var x = [];
|
|
var w = [];
|
|
for (var j = 0; j < columns; j++) {
|
|
var mark = j + 1;
|
|
for (var k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) {
|
|
var r = aindex[k];
|
|
x[r] = avalues[k];
|
|
w[r] = mark;
|
|
}
|
|
for (var i2 = 0; i2 < rows; i2++) {
|
|
if (j === 0) {
|
|
cdata[i2] = [];
|
|
}
|
|
if (w[i2] === mark) {
|
|
cdata[i2][j] = inverse ? cf(b, x[i2]) : cf(x[i2], b);
|
|
} else {
|
|
cdata[i2][j] = inverse ? cf(b, 0) : cf(0, b);
|
|
}
|
|
}
|
|
}
|
|
return new DenseMatrix2({
|
|
data: cdata,
|
|
size: [rows, columns],
|
|
datatype: dt
|
|
});
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/utils/matAlgo14xDs.js
|
|
var name38 = "matAlgo14xDs";
|
|
var dependencies39 = ["typed"];
|
|
var createMatAlgo14xDs = /* @__PURE__ */ factory(name38, dependencies39, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return function matAlgo14xDs(a, b, callback, inverse) {
|
|
var adata = a._data;
|
|
var asize = a._size;
|
|
var adt = a._datatype;
|
|
var dt;
|
|
var cf = callback;
|
|
if (typeof adt === "string") {
|
|
dt = adt;
|
|
b = typed2.convert(b, dt);
|
|
cf = typed2.find(callback, [dt, dt]);
|
|
}
|
|
var cdata = asize.length > 0 ? _iterate(cf, 0, asize, asize[0], adata, b, inverse) : [];
|
|
return a.createDenseMatrix({
|
|
data: cdata,
|
|
size: clone(asize),
|
|
datatype: dt
|
|
});
|
|
};
|
|
function _iterate(f, level, s, n, av, bv, inverse) {
|
|
var cv = [];
|
|
if (level === s.length - 1) {
|
|
for (var i2 = 0; i2 < n; i2++) {
|
|
cv[i2] = inverse ? f(bv, av[i2]) : f(av[i2], bv);
|
|
}
|
|
} else {
|
|
for (var j = 0; j < n; j++) {
|
|
cv[j] = _iterate(f, level + 1, s, s[level + 1], av[j], bv, inverse);
|
|
}
|
|
}
|
|
return cv;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/ceil.js
|
|
var name39 = "ceil";
|
|
var dependencies40 = ["typed", "config", "round", "matrix", "equalScalar", "zeros", "DenseMatrix"];
|
|
var createCeilNumber = /* @__PURE__ */ factory(name39, ["typed", "config", "round"], (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
round: round3
|
|
} = _ref;
|
|
return typed2(name39, {
|
|
number: function number2(x) {
|
|
if (nearlyEqual(x, round3(x), config4.epsilon)) {
|
|
return round3(x);
|
|
} else {
|
|
return Math.ceil(x);
|
|
}
|
|
},
|
|
"number, number": function numberNumber(x, n) {
|
|
if (nearlyEqual(x, round3(x, n), config4.epsilon)) {
|
|
return round3(x, n);
|
|
} else {
|
|
var [number2, exponent] = "".concat(x, "e").split("e");
|
|
var result = Math.ceil(Number("".concat(number2, "e").concat(Number(exponent) + n)));
|
|
[number2, exponent] = "".concat(result, "e").split("e");
|
|
return Number("".concat(number2, "e").concat(Number(exponent) - n));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
var createCeil = /* @__PURE__ */ factory(name39, dependencies40, (_ref2) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
round: round3,
|
|
matrix: matrix2,
|
|
equalScalar: equalScalar2,
|
|
zeros: zeros3,
|
|
DenseMatrix: DenseMatrix2
|
|
} = _ref2;
|
|
var matAlgo11xS0s = createMatAlgo11xS0s({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matAlgo14xDs = createMatAlgo14xDs({
|
|
typed: typed2
|
|
});
|
|
var ceilNumber = createCeilNumber({
|
|
typed: typed2,
|
|
config: config4,
|
|
round: round3
|
|
});
|
|
return typed2("ceil", {
|
|
number: ceilNumber.signatures.number,
|
|
"number,number": ceilNumber.signatures["number,number"],
|
|
Complex: function Complex3(x) {
|
|
return x.ceil();
|
|
},
|
|
"Complex, number": function ComplexNumber(x, n) {
|
|
return x.ceil(n);
|
|
},
|
|
"Complex, BigNumber": function ComplexBigNumber(x, n) {
|
|
return x.ceil(n.toNumber());
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
if (nearlyEqual2(x, round3(x), config4.epsilon)) {
|
|
return round3(x);
|
|
} else {
|
|
return x.ceil();
|
|
}
|
|
},
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(x, n) {
|
|
if (nearlyEqual2(x, round3(x, n), config4.epsilon)) {
|
|
return round3(x, n);
|
|
} else {
|
|
return x.toDecimalPlaces(n.toNumber(), decimal_default.ROUND_CEIL);
|
|
}
|
|
},
|
|
Fraction: function Fraction3(x) {
|
|
return x.ceil();
|
|
},
|
|
"Fraction, number": function FractionNumber(x, n) {
|
|
return x.ceil(n);
|
|
},
|
|
"Fraction, BigNumber": function FractionBigNumber(x, n) {
|
|
return x.ceil(n.toNumber());
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => {
|
|
return deepMap(x, self2, true);
|
|
}),
|
|
"Array, number | BigNumber": typed2.referToSelf((self2) => (x, n) => {
|
|
return deepMap(x, (i2) => self2(i2, n), true);
|
|
}),
|
|
"SparseMatrix, number | BigNumber": typed2.referToSelf((self2) => (x, y) => {
|
|
return matAlgo11xS0s(x, y, self2, false);
|
|
}),
|
|
"DenseMatrix, number | BigNumber": typed2.referToSelf((self2) => (x, y) => {
|
|
return matAlgo14xDs(x, y, self2, false);
|
|
}),
|
|
"number | Complex | Fraction | BigNumber, Array": typed2.referToSelf((self2) => (x, y) => {
|
|
return matAlgo14xDs(matrix2(y), x, self2, true).valueOf();
|
|
}),
|
|
"number | Complex | Fraction | BigNumber, Matrix": typed2.referToSelf((self2) => (x, y) => {
|
|
if (equalScalar2(x, 0))
|
|
return zeros3(y.size(), y.storage());
|
|
if (y.storage() === "dense") {
|
|
return matAlgo14xDs(y, x, self2, true);
|
|
}
|
|
return matAlgo12xSfs(y, x, self2, true);
|
|
})
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/cube.js
|
|
var name40 = "cube";
|
|
var dependencies41 = ["typed"];
|
|
var createCube = /* @__PURE__ */ factory(name40, dependencies41, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name40, {
|
|
number: cubeNumber,
|
|
Complex: function Complex3(x) {
|
|
return x.mul(x).mul(x);
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return x.times(x).times(x);
|
|
},
|
|
Fraction: function Fraction3(x) {
|
|
return x.pow(3);
|
|
},
|
|
Unit: function Unit2(x) {
|
|
return x.pow(3);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/exp.js
|
|
var name41 = "exp";
|
|
var dependencies42 = ["typed"];
|
|
var createExp = /* @__PURE__ */ factory(name41, dependencies42, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name41, {
|
|
number: expNumber,
|
|
Complex: function Complex3(x) {
|
|
return x.exp();
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return x.exp();
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/expm1.js
|
|
var name42 = "expm1";
|
|
var dependencies43 = ["typed", "Complex"];
|
|
var createExpm1 = /* @__PURE__ */ factory(name42, dependencies43, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
Complex: _Complex
|
|
} = _ref;
|
|
return typed2(name42, {
|
|
number: expm1Number,
|
|
Complex: function Complex3(x) {
|
|
var r = Math.exp(x.re);
|
|
return new _Complex(r * Math.cos(x.im) - 1, r * Math.sin(x.im));
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return x.exp().minus(1);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/fix.js
|
|
var name43 = "fix";
|
|
var dependencies44 = ["typed", "Complex", "matrix", "ceil", "floor", "equalScalar", "zeros", "DenseMatrix"];
|
|
var createFixNumber = /* @__PURE__ */ factory(name43, ["typed", "ceil", "floor"], (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
ceil: ceil3,
|
|
floor: floor3
|
|
} = _ref;
|
|
return typed2(name43, {
|
|
number: function number2(x) {
|
|
return x > 0 ? floor3(x) : ceil3(x);
|
|
},
|
|
"number, number": function numberNumber(x, n) {
|
|
return x > 0 ? floor3(x, n) : ceil3(x, n);
|
|
}
|
|
});
|
|
});
|
|
var createFix = /* @__PURE__ */ factory(name43, dependencies44, (_ref2) => {
|
|
var {
|
|
typed: typed2,
|
|
Complex: _Complex,
|
|
matrix: matrix2,
|
|
ceil: ceil3,
|
|
floor: floor3,
|
|
equalScalar: equalScalar2,
|
|
zeros: zeros3,
|
|
DenseMatrix: DenseMatrix2
|
|
} = _ref2;
|
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matAlgo14xDs = createMatAlgo14xDs({
|
|
typed: typed2
|
|
});
|
|
var fixNumber = createFixNumber({
|
|
typed: typed2,
|
|
ceil: ceil3,
|
|
floor: floor3
|
|
});
|
|
return typed2("fix", {
|
|
number: fixNumber.signatures.number,
|
|
"number, number | BigNumber": fixNumber.signatures["number,number"],
|
|
Complex: function Complex3(x) {
|
|
return new _Complex(x.re > 0 ? Math.floor(x.re) : Math.ceil(x.re), x.im > 0 ? Math.floor(x.im) : Math.ceil(x.im));
|
|
},
|
|
"Complex, number": function ComplexNumber(x, n) {
|
|
return new _Complex(x.re > 0 ? floor3(x.re, n) : ceil3(x.re, n), x.im > 0 ? floor3(x.im, n) : ceil3(x.im, n));
|
|
},
|
|
"Complex, BigNumber": function ComplexBigNumber(x, bn) {
|
|
var n = bn.toNumber();
|
|
return new _Complex(x.re > 0 ? floor3(x.re, n) : ceil3(x.re, n), x.im > 0 ? floor3(x.im, n) : ceil3(x.im, n));
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return x.isNegative() ? ceil3(x) : floor3(x);
|
|
},
|
|
"BigNumber, number | BigNumber": function BigNumberNumberBigNumber(x, n) {
|
|
return x.isNegative() ? ceil3(x, n) : floor3(x, n);
|
|
},
|
|
Fraction: function Fraction3(x) {
|
|
return x.s < 0 ? x.ceil() : x.floor();
|
|
},
|
|
"Fraction, number | BigNumber": function FractionNumberBigNumber(x, n) {
|
|
return x.s < 0 ? ceil3(x, n) : floor3(x, n);
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => {
|
|
return deepMap(x, self2, true);
|
|
}),
|
|
"Array | Matrix, number | BigNumber": typed2.referToSelf((self2) => (x, n) => {
|
|
return deepMap(x, (i2) => self2(i2, n), true);
|
|
}),
|
|
"number | Complex | Fraction | BigNumber, Array": typed2.referToSelf((self2) => (x, y) => {
|
|
return matAlgo14xDs(matrix2(y), x, self2, true).valueOf();
|
|
}),
|
|
"number | Complex | Fraction | BigNumber, Matrix": typed2.referToSelf((self2) => (x, y) => {
|
|
if (equalScalar2(x, 0))
|
|
return zeros3(y.size(), y.storage());
|
|
if (y.storage() === "dense") {
|
|
return matAlgo14xDs(y, x, self2, true);
|
|
}
|
|
return matAlgo12xSfs(y, x, self2, true);
|
|
})
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/floor.js
|
|
var name44 = "floor";
|
|
var dependencies45 = ["typed", "config", "round", "matrix", "equalScalar", "zeros", "DenseMatrix"];
|
|
var createFloorNumber = /* @__PURE__ */ factory(name44, ["typed", "config", "round"], (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
round: round3
|
|
} = _ref;
|
|
return typed2(name44, {
|
|
number: function number2(x) {
|
|
if (nearlyEqual(x, round3(x), config4.epsilon)) {
|
|
return round3(x);
|
|
} else {
|
|
return Math.floor(x);
|
|
}
|
|
},
|
|
"number, number": function numberNumber(x, n) {
|
|
if (nearlyEqual(x, round3(x, n), config4.epsilon)) {
|
|
return round3(x, n);
|
|
} else {
|
|
var [number2, exponent] = "".concat(x, "e").split("e");
|
|
var result = Math.floor(Number("".concat(number2, "e").concat(Number(exponent) + n)));
|
|
[number2, exponent] = "".concat(result, "e").split("e");
|
|
return Number("".concat(number2, "e").concat(Number(exponent) - n));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
var createFloor = /* @__PURE__ */ factory(name44, dependencies45, (_ref2) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
round: round3,
|
|
matrix: matrix2,
|
|
equalScalar: equalScalar2,
|
|
zeros: zeros3,
|
|
DenseMatrix: DenseMatrix2
|
|
} = _ref2;
|
|
var matAlgo11xS0s = createMatAlgo11xS0s({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matAlgo14xDs = createMatAlgo14xDs({
|
|
typed: typed2
|
|
});
|
|
var floorNumber = createFloorNumber({
|
|
typed: typed2,
|
|
config: config4,
|
|
round: round3
|
|
});
|
|
return typed2("floor", {
|
|
number: floorNumber.signatures.number,
|
|
"number,number": floorNumber.signatures["number,number"],
|
|
Complex: function Complex3(x) {
|
|
return x.floor();
|
|
},
|
|
"Complex, number": function ComplexNumber(x, n) {
|
|
return x.floor(n);
|
|
},
|
|
"Complex, BigNumber": function ComplexBigNumber(x, n) {
|
|
return x.floor(n.toNumber());
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
if (nearlyEqual2(x, round3(x), config4.epsilon)) {
|
|
return round3(x);
|
|
} else {
|
|
return x.floor();
|
|
}
|
|
},
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(x, n) {
|
|
if (nearlyEqual2(x, round3(x, n), config4.epsilon)) {
|
|
return round3(x, n);
|
|
} else {
|
|
return x.toDecimalPlaces(n.toNumber(), decimal_default.ROUND_FLOOR);
|
|
}
|
|
},
|
|
Fraction: function Fraction3(x) {
|
|
return x.floor();
|
|
},
|
|
"Fraction, number": function FractionNumber(x, n) {
|
|
return x.floor(n);
|
|
},
|
|
"Fraction, BigNumber": function FractionBigNumber(x, n) {
|
|
return x.floor(n.toNumber());
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => {
|
|
return deepMap(x, self2, true);
|
|
}),
|
|
"Array, number | BigNumber": typed2.referToSelf((self2) => (x, n) => {
|
|
return deepMap(x, (i2) => self2(i2, n), true);
|
|
}),
|
|
"SparseMatrix, number | BigNumber": typed2.referToSelf((self2) => (x, y) => {
|
|
return matAlgo11xS0s(x, y, self2, false);
|
|
}),
|
|
"DenseMatrix, number | BigNumber": typed2.referToSelf((self2) => (x, y) => {
|
|
return matAlgo14xDs(x, y, self2, false);
|
|
}),
|
|
"number | Complex | Fraction | BigNumber, Array": typed2.referToSelf((self2) => (x, y) => {
|
|
return matAlgo14xDs(matrix2(y), x, self2, true).valueOf();
|
|
}),
|
|
"number | Complex | Fraction | BigNumber, Matrix": typed2.referToSelf((self2) => (x, y) => {
|
|
if (equalScalar2(x, 0))
|
|
return zeros3(y.size(), y.storage());
|
|
if (y.storage() === "dense") {
|
|
return matAlgo14xDs(y, x, self2, true);
|
|
}
|
|
return matAlgo12xSfs(y, x, self2, true);
|
|
})
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/utils/matAlgo01xDSid.js
|
|
var name45 = "matAlgo01xDSid";
|
|
var dependencies46 = ["typed"];
|
|
var createMatAlgo01xDSid = /* @__PURE__ */ factory(name45, dependencies46, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return function algorithm1(denseMatrix, sparseMatrix, callback, inverse) {
|
|
var adata = denseMatrix._data;
|
|
var asize = denseMatrix._size;
|
|
var adt = denseMatrix._datatype;
|
|
var bvalues = sparseMatrix._values;
|
|
var bindex = sparseMatrix._index;
|
|
var bptr = sparseMatrix._ptr;
|
|
var bsize = sparseMatrix._size;
|
|
var bdt = sparseMatrix._datatype;
|
|
if (asize.length !== bsize.length) {
|
|
throw new DimensionError(asize.length, bsize.length);
|
|
}
|
|
if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) {
|
|
throw new RangeError("Dimension mismatch. Matrix A (" + asize + ") must match Matrix B (" + bsize + ")");
|
|
}
|
|
if (!bvalues) {
|
|
throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");
|
|
}
|
|
var rows = asize[0];
|
|
var columns = asize[1];
|
|
var dt = typeof adt === "string" && adt === bdt ? adt : void 0;
|
|
var cf = dt ? typed2.find(callback, [dt, dt]) : callback;
|
|
var i2, j;
|
|
var cdata = [];
|
|
for (i2 = 0; i2 < rows; i2++) {
|
|
cdata[i2] = [];
|
|
}
|
|
var x = [];
|
|
var w = [];
|
|
for (j = 0; j < columns; j++) {
|
|
var mark = j + 1;
|
|
for (var k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) {
|
|
i2 = bindex[k];
|
|
x[i2] = inverse ? cf(bvalues[k], adata[i2][j]) : cf(adata[i2][j], bvalues[k]);
|
|
w[i2] = mark;
|
|
}
|
|
for (i2 = 0; i2 < rows; i2++) {
|
|
if (w[i2] === mark) {
|
|
cdata[i2][j] = x[i2];
|
|
} else {
|
|
cdata[i2][j] = adata[i2][j];
|
|
}
|
|
}
|
|
}
|
|
return denseMatrix.createDenseMatrix({
|
|
data: cdata,
|
|
size: [rows, columns],
|
|
datatype: dt
|
|
});
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/utils/matAlgo04xSidSid.js
|
|
var name46 = "matAlgo04xSidSid";
|
|
var dependencies47 = ["typed", "equalScalar"];
|
|
var createMatAlgo04xSidSid = /* @__PURE__ */ factory(name46, dependencies47, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
} = _ref;
|
|
return function matAlgo04xSidSid(a, b, callback) {
|
|
var avalues = a._values;
|
|
var aindex = a._index;
|
|
var aptr = a._ptr;
|
|
var asize = a._size;
|
|
var adt = a._datatype;
|
|
var bvalues = b._values;
|
|
var bindex = b._index;
|
|
var bptr = b._ptr;
|
|
var bsize = b._size;
|
|
var bdt = b._datatype;
|
|
if (asize.length !== bsize.length) {
|
|
throw new DimensionError(asize.length, bsize.length);
|
|
}
|
|
if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) {
|
|
throw new RangeError("Dimension mismatch. Matrix A (" + asize + ") must match Matrix B (" + bsize + ")");
|
|
}
|
|
var rows = asize[0];
|
|
var columns = asize[1];
|
|
var dt;
|
|
var eq = equalScalar2;
|
|
var zero = 0;
|
|
var cf = callback;
|
|
if (typeof adt === "string" && adt === bdt) {
|
|
dt = adt;
|
|
eq = typed2.find(equalScalar2, [dt, dt]);
|
|
zero = typed2.convert(0, dt);
|
|
cf = typed2.find(callback, [dt, dt]);
|
|
}
|
|
var cvalues = avalues && bvalues ? [] : void 0;
|
|
var cindex = [];
|
|
var cptr = [];
|
|
var xa = avalues && bvalues ? [] : void 0;
|
|
var xb = avalues && bvalues ? [] : void 0;
|
|
var wa = [];
|
|
var wb = [];
|
|
var i2, j, k, k0, k1;
|
|
for (j = 0; j < columns; j++) {
|
|
cptr[j] = cindex.length;
|
|
var mark = j + 1;
|
|
for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) {
|
|
i2 = aindex[k];
|
|
cindex.push(i2);
|
|
wa[i2] = mark;
|
|
if (xa) {
|
|
xa[i2] = avalues[k];
|
|
}
|
|
}
|
|
for (k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) {
|
|
i2 = bindex[k];
|
|
if (wa[i2] === mark) {
|
|
if (xa) {
|
|
var v = cf(xa[i2], bvalues[k]);
|
|
if (!eq(v, zero)) {
|
|
xa[i2] = v;
|
|
} else {
|
|
wa[i2] = null;
|
|
}
|
|
}
|
|
} else {
|
|
cindex.push(i2);
|
|
wb[i2] = mark;
|
|
if (xb) {
|
|
xb[i2] = bvalues[k];
|
|
}
|
|
}
|
|
}
|
|
if (xa && xb) {
|
|
k = cptr[j];
|
|
while (k < cindex.length) {
|
|
i2 = cindex[k];
|
|
if (wa[i2] === mark) {
|
|
cvalues[k] = xa[i2];
|
|
k++;
|
|
} else if (wb[i2] === mark) {
|
|
cvalues[k] = xb[i2];
|
|
k++;
|
|
} else {
|
|
cindex.splice(k, 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
cptr[columns] = cindex.length;
|
|
return a.createSparseMatrix({
|
|
values: cvalues,
|
|
index: cindex,
|
|
ptr: cptr,
|
|
size: [rows, columns],
|
|
datatype: dt
|
|
});
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/utils/matAlgo10xSids.js
|
|
var name47 = "matAlgo10xSids";
|
|
var dependencies48 = ["typed", "DenseMatrix"];
|
|
var createMatAlgo10xSids = /* @__PURE__ */ factory(name47, dependencies48, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
} = _ref;
|
|
return function matAlgo10xSids(s, b, callback, inverse) {
|
|
var avalues = s._values;
|
|
var aindex = s._index;
|
|
var aptr = s._ptr;
|
|
var asize = s._size;
|
|
var adt = s._datatype;
|
|
if (!avalues) {
|
|
throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");
|
|
}
|
|
var rows = asize[0];
|
|
var columns = asize[1];
|
|
var dt;
|
|
var cf = callback;
|
|
if (typeof adt === "string") {
|
|
dt = adt;
|
|
b = typed2.convert(b, dt);
|
|
cf = typed2.find(callback, [dt, dt]);
|
|
}
|
|
var cdata = [];
|
|
var x = [];
|
|
var w = [];
|
|
for (var j = 0; j < columns; j++) {
|
|
var mark = j + 1;
|
|
for (var k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) {
|
|
var r = aindex[k];
|
|
x[r] = avalues[k];
|
|
w[r] = mark;
|
|
}
|
|
for (var i2 = 0; i2 < rows; i2++) {
|
|
if (j === 0) {
|
|
cdata[i2] = [];
|
|
}
|
|
if (w[i2] === mark) {
|
|
cdata[i2][j] = inverse ? cf(b, x[i2]) : cf(x[i2], b);
|
|
} else {
|
|
cdata[i2][j] = b;
|
|
}
|
|
}
|
|
}
|
|
return new DenseMatrix2({
|
|
data: cdata,
|
|
size: [rows, columns],
|
|
datatype: dt
|
|
});
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/utils/matAlgo13xDD.js
|
|
var name48 = "matAlgo13xDD";
|
|
var dependencies49 = ["typed"];
|
|
var createMatAlgo13xDD = /* @__PURE__ */ factory(name48, dependencies49, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return function matAlgo13xDD(a, b, callback) {
|
|
var adata = a._data;
|
|
var asize = a._size;
|
|
var adt = a._datatype;
|
|
var bdata = b._data;
|
|
var bsize = b._size;
|
|
var bdt = b._datatype;
|
|
var csize = [];
|
|
if (asize.length !== bsize.length) {
|
|
throw new DimensionError(asize.length, bsize.length);
|
|
}
|
|
for (var s = 0; s < asize.length; s++) {
|
|
if (asize[s] !== bsize[s]) {
|
|
throw new RangeError("Dimension mismatch. Matrix A (" + asize + ") must match Matrix B (" + bsize + ")");
|
|
}
|
|
csize[s] = asize[s];
|
|
}
|
|
var dt;
|
|
var cf = callback;
|
|
if (typeof adt === "string" && adt === bdt) {
|
|
dt = adt;
|
|
cf = typed2.find(callback, [dt, dt]);
|
|
}
|
|
var cdata = csize.length > 0 ? _iterate(cf, 0, csize, csize[0], adata, bdata) : [];
|
|
return a.createDenseMatrix({
|
|
data: cdata,
|
|
size: csize,
|
|
datatype: dt
|
|
});
|
|
};
|
|
function _iterate(f, level, s, n, av, bv) {
|
|
var cv = [];
|
|
if (level === s.length - 1) {
|
|
for (var i2 = 0; i2 < n; i2++) {
|
|
cv[i2] = f(av[i2], bv[i2]);
|
|
}
|
|
} else {
|
|
for (var j = 0; j < n; j++) {
|
|
cv[j] = _iterate(f, level + 1, s, s[level + 1], av[j], bv[j]);
|
|
}
|
|
}
|
|
return cv;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/utils/broadcast.js
|
|
var name49 = "broadcast";
|
|
var dependancies = ["concat"];
|
|
var createBroadcast = /* @__PURE__ */ factory(name49, dependancies, (_ref) => {
|
|
var {
|
|
concat: concat2
|
|
} = _ref;
|
|
return function(A, B) {
|
|
var N = Math.max(A._size.length, B._size.length);
|
|
if (A._size.length === B._size.length) {
|
|
if (A._size.every((dim2, i2) => dim2 === B._size[i2])) {
|
|
return [A, B];
|
|
}
|
|
}
|
|
var sizeA = _padLeft(A._size, N, 0);
|
|
var sizeB = _padLeft(B._size, N, 0);
|
|
var sizeMax = [];
|
|
for (var dim = 0; dim < N; dim++) {
|
|
sizeMax[dim] = Math.max(sizeA[dim], sizeB[dim]);
|
|
}
|
|
for (var _dim = 0; _dim < N; _dim++) {
|
|
_checkRules(sizeA, sizeMax, _dim);
|
|
_checkRules(sizeB, sizeMax, _dim);
|
|
}
|
|
var AA = A.clone();
|
|
var BB = B.clone();
|
|
if (AA._size.length < N) {
|
|
AA.reshape(_padLeft(AA._size, N, 1));
|
|
} else if (BB._size.length < N) {
|
|
BB.reshape(_padLeft(BB._size, N, 1));
|
|
}
|
|
for (var _dim2 = 0; _dim2 < N; _dim2++) {
|
|
if (AA._size[_dim2] < sizeMax[_dim2]) {
|
|
AA = _stretch(AA, sizeMax[_dim2], _dim2);
|
|
}
|
|
if (BB._size[_dim2] < sizeMax[_dim2]) {
|
|
BB = _stretch(BB, sizeMax[_dim2], _dim2);
|
|
}
|
|
}
|
|
return [AA, BB];
|
|
};
|
|
function _padLeft(shape, N, filler) {
|
|
return [...Array(N - shape.length).fill(filler), ...shape];
|
|
}
|
|
function _stretch(arrayToStretch, sizeToStretch, dimToStretch) {
|
|
return concat2(...Array(sizeToStretch).fill(arrayToStretch), dimToStretch);
|
|
}
|
|
function _checkRules(shape, sizeMax, dim) {
|
|
if (shape[dim] < sizeMax[dim] & shape[dim] > 1) {
|
|
throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(shape, ") not possible to broadcast dimension ").concat(dim, " with size ").concat(shape[dim], " to size ").concat(sizeMax[dim]));
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/utils/matrixAlgorithmSuite.js
|
|
var name50 = "matrixAlgorithmSuite";
|
|
var dependencies50 = ["typed", "matrix", "concat"];
|
|
var createMatrixAlgorithmSuite = /* @__PURE__ */ factory(name50, dependencies50, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo13xDD = createMatAlgo13xDD({
|
|
typed: typed2
|
|
});
|
|
var matAlgo14xDs = createMatAlgo14xDs({
|
|
typed: typed2
|
|
});
|
|
var broadcast = createBroadcast({
|
|
concat: concat2
|
|
});
|
|
return function matrixAlgorithmSuite(options) {
|
|
var elop = options.elop;
|
|
var SD = options.SD || options.DS;
|
|
var matrixSignatures;
|
|
if (elop) {
|
|
matrixSignatures = {
|
|
"DenseMatrix, DenseMatrix": (x, y) => matAlgo13xDD(...broadcast(x, y), elop),
|
|
"Array, Array": (x, y) => matAlgo13xDD(...broadcast(matrix2(x), matrix2(y)), elop).valueOf(),
|
|
"Array, DenseMatrix": (x, y) => matAlgo13xDD(...broadcast(matrix2(x), y), elop),
|
|
"DenseMatrix, Array": (x, y) => matAlgo13xDD(...broadcast(x, matrix2(y)), elop)
|
|
};
|
|
if (options.SS) {
|
|
matrixSignatures["SparseMatrix, SparseMatrix"] = (x, y) => options.SS(...broadcast(x, y), elop, false);
|
|
}
|
|
if (options.DS) {
|
|
matrixSignatures["DenseMatrix, SparseMatrix"] = (x, y) => options.DS(...broadcast(x, y), elop, false);
|
|
matrixSignatures["Array, SparseMatrix"] = (x, y) => options.DS(...broadcast(matrix2(x), y), elop, false);
|
|
}
|
|
if (SD) {
|
|
matrixSignatures["SparseMatrix, DenseMatrix"] = (x, y) => SD(...broadcast(y, x), elop, true);
|
|
matrixSignatures["SparseMatrix, Array"] = (x, y) => SD(...broadcast(matrix2(y), x), elop, true);
|
|
}
|
|
} else {
|
|
matrixSignatures = {
|
|
"DenseMatrix, DenseMatrix": typed2.referToSelf((self2) => (x, y) => {
|
|
return matAlgo13xDD(...broadcast(x, y), self2);
|
|
}),
|
|
"Array, Array": typed2.referToSelf((self2) => (x, y) => {
|
|
return matAlgo13xDD(...broadcast(matrix2(x), matrix2(y)), self2).valueOf();
|
|
}),
|
|
"Array, DenseMatrix": typed2.referToSelf((self2) => (x, y) => {
|
|
return matAlgo13xDD(...broadcast(matrix2(x), y), self2);
|
|
}),
|
|
"DenseMatrix, Array": typed2.referToSelf((self2) => (x, y) => {
|
|
return matAlgo13xDD(...broadcast(x, matrix2(y)), self2);
|
|
})
|
|
};
|
|
if (options.SS) {
|
|
matrixSignatures["SparseMatrix, SparseMatrix"] = typed2.referToSelf((self2) => (x, y) => {
|
|
return options.SS(...broadcast(x, y), self2, false);
|
|
});
|
|
}
|
|
if (options.DS) {
|
|
matrixSignatures["DenseMatrix, SparseMatrix"] = typed2.referToSelf((self2) => (x, y) => {
|
|
return options.DS(...broadcast(x, y), self2, false);
|
|
});
|
|
matrixSignatures["Array, SparseMatrix"] = typed2.referToSelf((self2) => (x, y) => {
|
|
return options.DS(...broadcast(matrix2(x), y), self2, false);
|
|
});
|
|
}
|
|
if (SD) {
|
|
matrixSignatures["SparseMatrix, DenseMatrix"] = typed2.referToSelf((self2) => (x, y) => {
|
|
return SD(...broadcast(y, x), self2, true);
|
|
});
|
|
matrixSignatures["SparseMatrix, Array"] = typed2.referToSelf((self2) => (x, y) => {
|
|
return SD(...broadcast(matrix2(y), x), self2, true);
|
|
});
|
|
}
|
|
}
|
|
var scalar = options.scalar || "any";
|
|
var Ds = options.Ds || options.Ss;
|
|
if (Ds) {
|
|
if (elop) {
|
|
matrixSignatures["DenseMatrix," + scalar] = (x, y) => matAlgo14xDs(x, y, elop, false);
|
|
matrixSignatures[scalar + ", DenseMatrix"] = (x, y) => matAlgo14xDs(y, x, elop, true);
|
|
matrixSignatures["Array," + scalar] = (x, y) => matAlgo14xDs(matrix2(x), y, elop, false).valueOf();
|
|
matrixSignatures[scalar + ", Array"] = (x, y) => matAlgo14xDs(matrix2(y), x, elop, true).valueOf();
|
|
} else {
|
|
matrixSignatures["DenseMatrix," + scalar] = typed2.referToSelf((self2) => (x, y) => {
|
|
return matAlgo14xDs(x, y, self2, false);
|
|
});
|
|
matrixSignatures[scalar + ", DenseMatrix"] = typed2.referToSelf((self2) => (x, y) => {
|
|
return matAlgo14xDs(y, x, self2, true);
|
|
});
|
|
matrixSignatures["Array," + scalar] = typed2.referToSelf((self2) => (x, y) => {
|
|
return matAlgo14xDs(matrix2(x), y, self2, false).valueOf();
|
|
});
|
|
matrixSignatures[scalar + ", Array"] = typed2.referToSelf((self2) => (x, y) => {
|
|
return matAlgo14xDs(matrix2(y), x, self2, true).valueOf();
|
|
});
|
|
}
|
|
}
|
|
var sS = options.sS !== void 0 ? options.sS : options.Ss;
|
|
if (elop) {
|
|
if (options.Ss) {
|
|
matrixSignatures["SparseMatrix," + scalar] = (x, y) => options.Ss(x, y, elop, false);
|
|
}
|
|
if (sS) {
|
|
matrixSignatures[scalar + ", SparseMatrix"] = (x, y) => sS(y, x, elop, true);
|
|
}
|
|
} else {
|
|
if (options.Ss) {
|
|
matrixSignatures["SparseMatrix," + scalar] = typed2.referToSelf((self2) => (x, y) => {
|
|
return options.Ss(x, y, self2, false);
|
|
});
|
|
}
|
|
if (sS) {
|
|
matrixSignatures[scalar + ", SparseMatrix"] = typed2.referToSelf((self2) => (x, y) => {
|
|
return sS(y, x, self2, true);
|
|
});
|
|
}
|
|
}
|
|
if (elop && elop.signatures) {
|
|
extend(matrixSignatures, elop.signatures);
|
|
}
|
|
return matrixSignatures;
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/gcd.js
|
|
var name51 = "gcd";
|
|
var dependencies51 = ["typed", "matrix", "equalScalar", "BigNumber", "DenseMatrix", "concat"];
|
|
var createGcd = /* @__PURE__ */ factory(name51, dependencies51, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
equalScalar: equalScalar2,
|
|
BigNumber: BigNumber2,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo01xDSid = createMatAlgo01xDSid({
|
|
typed: typed2
|
|
});
|
|
var matAlgo04xSidSid = createMatAlgo04xSidSid({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo10xSids = createMatAlgo10xSids({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
var gcdTypes = "number | BigNumber | Fraction | Matrix | Array";
|
|
var gcdManySignature = {};
|
|
gcdManySignature["".concat(gcdTypes, ", ").concat(gcdTypes, ", ...").concat(gcdTypes)] = typed2.referToSelf((self2) => (a, b, args) => {
|
|
var res = self2(a, b);
|
|
for (var i2 = 0; i2 < args.length; i2++) {
|
|
res = self2(res, args[i2]);
|
|
}
|
|
return res;
|
|
});
|
|
return typed2(name51, {
|
|
"number, number": gcdNumber,
|
|
"BigNumber, BigNumber": _gcdBigNumber,
|
|
"Fraction, Fraction": (x, y) => x.gcd(y)
|
|
}, matrixAlgorithmSuite({
|
|
SS: matAlgo04xSidSid,
|
|
DS: matAlgo01xDSid,
|
|
Ss: matAlgo10xSids
|
|
}), gcdManySignature);
|
|
function _gcdBigNumber(a, b) {
|
|
if (!a.isInt() || !b.isInt()) {
|
|
throw new Error("Parameters in function gcd must be integer numbers");
|
|
}
|
|
var zero = new BigNumber2(0);
|
|
while (!b.isZero()) {
|
|
var r = a.mod(b);
|
|
a = b;
|
|
b = r;
|
|
}
|
|
return a.lt(zero) ? a.neg() : a;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/utils/matAlgo02xDS0.js
|
|
var name52 = "matAlgo02xDS0";
|
|
var dependencies52 = ["typed", "equalScalar"];
|
|
var createMatAlgo02xDS0 = /* @__PURE__ */ factory(name52, dependencies52, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
} = _ref;
|
|
return function matAlgo02xDS0(denseMatrix, sparseMatrix, callback, inverse) {
|
|
var adata = denseMatrix._data;
|
|
var asize = denseMatrix._size;
|
|
var adt = denseMatrix._datatype;
|
|
var bvalues = sparseMatrix._values;
|
|
var bindex = sparseMatrix._index;
|
|
var bptr = sparseMatrix._ptr;
|
|
var bsize = sparseMatrix._size;
|
|
var bdt = sparseMatrix._datatype;
|
|
if (asize.length !== bsize.length) {
|
|
throw new DimensionError(asize.length, bsize.length);
|
|
}
|
|
if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) {
|
|
throw new RangeError("Dimension mismatch. Matrix A (" + asize + ") must match Matrix B (" + bsize + ")");
|
|
}
|
|
if (!bvalues) {
|
|
throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");
|
|
}
|
|
var rows = asize[0];
|
|
var columns = asize[1];
|
|
var dt;
|
|
var eq = equalScalar2;
|
|
var zero = 0;
|
|
var cf = callback;
|
|
if (typeof adt === "string" && adt === bdt) {
|
|
dt = adt;
|
|
eq = typed2.find(equalScalar2, [dt, dt]);
|
|
zero = typed2.convert(0, dt);
|
|
cf = typed2.find(callback, [dt, dt]);
|
|
}
|
|
var cvalues = [];
|
|
var cindex = [];
|
|
var cptr = [];
|
|
for (var j = 0; j < columns; j++) {
|
|
cptr[j] = cindex.length;
|
|
for (var k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) {
|
|
var i2 = bindex[k];
|
|
var cij = inverse ? cf(bvalues[k], adata[i2][j]) : cf(adata[i2][j], bvalues[k]);
|
|
if (!eq(cij, zero)) {
|
|
cindex.push(i2);
|
|
cvalues.push(cij);
|
|
}
|
|
}
|
|
}
|
|
cptr[columns] = cindex.length;
|
|
return sparseMatrix.createSparseMatrix({
|
|
values: cvalues,
|
|
index: cindex,
|
|
ptr: cptr,
|
|
size: [rows, columns],
|
|
datatype: dt
|
|
});
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/utils/matAlgo06xS0S0.js
|
|
var name53 = "matAlgo06xS0S0";
|
|
var dependencies53 = ["typed", "equalScalar"];
|
|
var createMatAlgo06xS0S0 = /* @__PURE__ */ factory(name53, dependencies53, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
} = _ref;
|
|
return function matAlgo06xS0S0(a, b, callback) {
|
|
var avalues = a._values;
|
|
var asize = a._size;
|
|
var adt = a._datatype;
|
|
var bvalues = b._values;
|
|
var bsize = b._size;
|
|
var bdt = b._datatype;
|
|
if (asize.length !== bsize.length) {
|
|
throw new DimensionError(asize.length, bsize.length);
|
|
}
|
|
if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) {
|
|
throw new RangeError("Dimension mismatch. Matrix A (" + asize + ") must match Matrix B (" + bsize + ")");
|
|
}
|
|
var rows = asize[0];
|
|
var columns = asize[1];
|
|
var dt;
|
|
var eq = equalScalar2;
|
|
var zero = 0;
|
|
var cf = callback;
|
|
if (typeof adt === "string" && adt === bdt) {
|
|
dt = adt;
|
|
eq = typed2.find(equalScalar2, [dt, dt]);
|
|
zero = typed2.convert(0, dt);
|
|
cf = typed2.find(callback, [dt, dt]);
|
|
}
|
|
var cvalues = avalues && bvalues ? [] : void 0;
|
|
var cindex = [];
|
|
var cptr = [];
|
|
var x = cvalues ? [] : void 0;
|
|
var w = [];
|
|
var u = [];
|
|
for (var j = 0; j < columns; j++) {
|
|
cptr[j] = cindex.length;
|
|
var mark = j + 1;
|
|
scatter(a, j, w, x, u, mark, cindex, cf);
|
|
scatter(b, j, w, x, u, mark, cindex, cf);
|
|
if (x) {
|
|
var k = cptr[j];
|
|
while (k < cindex.length) {
|
|
var i2 = cindex[k];
|
|
if (u[i2] === mark) {
|
|
var v = x[i2];
|
|
if (!eq(v, zero)) {
|
|
cvalues.push(v);
|
|
k++;
|
|
} else {
|
|
cindex.splice(k, 1);
|
|
}
|
|
} else {
|
|
cindex.splice(k, 1);
|
|
}
|
|
}
|
|
} else {
|
|
var p = cptr[j];
|
|
while (p < cindex.length) {
|
|
var r = cindex[p];
|
|
if (u[r] !== mark) {
|
|
cindex.splice(p, 1);
|
|
} else {
|
|
p++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
cptr[columns] = cindex.length;
|
|
return a.createSparseMatrix({
|
|
values: cvalues,
|
|
index: cindex,
|
|
ptr: cptr,
|
|
size: [rows, columns],
|
|
datatype: dt
|
|
});
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/lcm.js
|
|
var name54 = "lcm";
|
|
var dependencies54 = ["typed", "matrix", "equalScalar", "concat"];
|
|
var createLcm = /* @__PURE__ */ factory(name54, dependencies54, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
equalScalar: equalScalar2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo02xDS0 = createMatAlgo02xDS0({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo06xS0S0 = createMatAlgo06xS0S0({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo11xS0s = createMatAlgo11xS0s({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
var lcmTypes = "number | BigNumber | Fraction | Matrix | Array";
|
|
var lcmManySignature = {};
|
|
lcmManySignature["".concat(lcmTypes, ", ").concat(lcmTypes, ", ...").concat(lcmTypes)] = typed2.referToSelf((self2) => (a, b, args) => {
|
|
var res = self2(a, b);
|
|
for (var i2 = 0; i2 < args.length; i2++) {
|
|
res = self2(res, args[i2]);
|
|
}
|
|
return res;
|
|
});
|
|
return typed2(name54, {
|
|
"number, number": lcmNumber,
|
|
"BigNumber, BigNumber": _lcmBigNumber,
|
|
"Fraction, Fraction": (x, y) => x.lcm(y)
|
|
}, matrixAlgorithmSuite({
|
|
SS: matAlgo06xS0S0,
|
|
DS: matAlgo02xDS0,
|
|
Ss: matAlgo11xS0s
|
|
}), lcmManySignature);
|
|
function _lcmBigNumber(a, b) {
|
|
if (!a.isInt() || !b.isInt()) {
|
|
throw new Error("Parameters in function lcm must be integer numbers");
|
|
}
|
|
if (a.isZero()) {
|
|
return a;
|
|
}
|
|
if (b.isZero()) {
|
|
return b;
|
|
}
|
|
var prod2 = a.times(b);
|
|
while (!b.isZero()) {
|
|
var t = b;
|
|
b = a.mod(t);
|
|
a = t;
|
|
}
|
|
return prod2.div(a).abs();
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/log10.js
|
|
var name55 = "log10";
|
|
var dependencies55 = ["typed", "config", "Complex"];
|
|
var createLog10 = /* @__PURE__ */ factory(name55, dependencies55, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
Complex: _Complex
|
|
} = _ref;
|
|
return typed2(name55, {
|
|
number: function number2(x) {
|
|
if (x >= 0 || config4.predictable) {
|
|
return log10Number(x);
|
|
} else {
|
|
return new _Complex(x, 0).log().div(Math.LN10);
|
|
}
|
|
},
|
|
Complex: function Complex3(x) {
|
|
return new _Complex(x).log().div(Math.LN10);
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
if (!x.isNegative() || config4.predictable) {
|
|
return x.log();
|
|
} else {
|
|
return new _Complex(x.toNumber(), 0).log().div(Math.LN10);
|
|
}
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/log2.js
|
|
var name56 = "log2";
|
|
var dependencies56 = ["typed", "config", "Complex"];
|
|
var createLog2 = /* @__PURE__ */ factory(name56, dependencies56, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
Complex: Complex3
|
|
} = _ref;
|
|
return typed2(name56, {
|
|
number: function number2(x) {
|
|
if (x >= 0 || config4.predictable) {
|
|
return log2Number(x);
|
|
} else {
|
|
return _log2Complex(new Complex3(x, 0));
|
|
}
|
|
},
|
|
Complex: _log2Complex,
|
|
BigNumber: function BigNumber2(x) {
|
|
if (!x.isNegative() || config4.predictable) {
|
|
return x.log(2);
|
|
} else {
|
|
return _log2Complex(new Complex3(x.toNumber(), 0));
|
|
}
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
function _log2Complex(x) {
|
|
var newX = Math.sqrt(x.re * x.re + x.im * x.im);
|
|
return new Complex3(Math.log2 ? Math.log2(newX) : Math.log(newX) / Math.LN2, Math.atan2(x.im, x.re) / Math.LN2);
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/utils/matAlgo03xDSf.js
|
|
var name57 = "matAlgo03xDSf";
|
|
var dependencies57 = ["typed"];
|
|
var createMatAlgo03xDSf = /* @__PURE__ */ factory(name57, dependencies57, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return function matAlgo03xDSf(denseMatrix, sparseMatrix, callback, inverse) {
|
|
var adata = denseMatrix._data;
|
|
var asize = denseMatrix._size;
|
|
var adt = denseMatrix._datatype;
|
|
var bvalues = sparseMatrix._values;
|
|
var bindex = sparseMatrix._index;
|
|
var bptr = sparseMatrix._ptr;
|
|
var bsize = sparseMatrix._size;
|
|
var bdt = sparseMatrix._datatype;
|
|
if (asize.length !== bsize.length) {
|
|
throw new DimensionError(asize.length, bsize.length);
|
|
}
|
|
if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) {
|
|
throw new RangeError("Dimension mismatch. Matrix A (" + asize + ") must match Matrix B (" + bsize + ")");
|
|
}
|
|
if (!bvalues) {
|
|
throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");
|
|
}
|
|
var rows = asize[0];
|
|
var columns = asize[1];
|
|
var dt;
|
|
var zero = 0;
|
|
var cf = callback;
|
|
if (typeof adt === "string" && adt === bdt) {
|
|
dt = adt;
|
|
zero = typed2.convert(0, dt);
|
|
cf = typed2.find(callback, [dt, dt]);
|
|
}
|
|
var cdata = [];
|
|
for (var z = 0; z < rows; z++) {
|
|
cdata[z] = [];
|
|
}
|
|
var x = [];
|
|
var w = [];
|
|
for (var j = 0; j < columns; j++) {
|
|
var mark = j + 1;
|
|
for (var k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) {
|
|
var i2 = bindex[k];
|
|
x[i2] = inverse ? cf(bvalues[k], adata[i2][j]) : cf(adata[i2][j], bvalues[k]);
|
|
w[i2] = mark;
|
|
}
|
|
for (var y = 0; y < rows; y++) {
|
|
if (w[y] === mark) {
|
|
cdata[y][j] = x[y];
|
|
} else {
|
|
cdata[y][j] = inverse ? cf(zero, adata[y][j]) : cf(adata[y][j], zero);
|
|
}
|
|
}
|
|
}
|
|
return denseMatrix.createDenseMatrix({
|
|
data: cdata,
|
|
size: [rows, columns],
|
|
datatype: dt
|
|
});
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/utils/matAlgo05xSfSf.js
|
|
var name58 = "matAlgo05xSfSf";
|
|
var dependencies58 = ["typed", "equalScalar"];
|
|
var createMatAlgo05xSfSf = /* @__PURE__ */ factory(name58, dependencies58, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
} = _ref;
|
|
return function matAlgo05xSfSf(a, b, callback) {
|
|
var avalues = a._values;
|
|
var aindex = a._index;
|
|
var aptr = a._ptr;
|
|
var asize = a._size;
|
|
var adt = a._datatype;
|
|
var bvalues = b._values;
|
|
var bindex = b._index;
|
|
var bptr = b._ptr;
|
|
var bsize = b._size;
|
|
var bdt = b._datatype;
|
|
if (asize.length !== bsize.length) {
|
|
throw new DimensionError(asize.length, bsize.length);
|
|
}
|
|
if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) {
|
|
throw new RangeError("Dimension mismatch. Matrix A (" + asize + ") must match Matrix B (" + bsize + ")");
|
|
}
|
|
var rows = asize[0];
|
|
var columns = asize[1];
|
|
var dt;
|
|
var eq = equalScalar2;
|
|
var zero = 0;
|
|
var cf = callback;
|
|
if (typeof adt === "string" && adt === bdt) {
|
|
dt = adt;
|
|
eq = typed2.find(equalScalar2, [dt, dt]);
|
|
zero = typed2.convert(0, dt);
|
|
cf = typed2.find(callback, [dt, dt]);
|
|
}
|
|
var cvalues = avalues && bvalues ? [] : void 0;
|
|
var cindex = [];
|
|
var cptr = [];
|
|
var xa = cvalues ? [] : void 0;
|
|
var xb = cvalues ? [] : void 0;
|
|
var wa = [];
|
|
var wb = [];
|
|
var i2, j, k, k1;
|
|
for (j = 0; j < columns; j++) {
|
|
cptr[j] = cindex.length;
|
|
var mark = j + 1;
|
|
for (k = aptr[j], k1 = aptr[j + 1]; k < k1; k++) {
|
|
i2 = aindex[k];
|
|
cindex.push(i2);
|
|
wa[i2] = mark;
|
|
if (xa) {
|
|
xa[i2] = avalues[k];
|
|
}
|
|
}
|
|
for (k = bptr[j], k1 = bptr[j + 1]; k < k1; k++) {
|
|
i2 = bindex[k];
|
|
if (wa[i2] !== mark) {
|
|
cindex.push(i2);
|
|
}
|
|
wb[i2] = mark;
|
|
if (xb) {
|
|
xb[i2] = bvalues[k];
|
|
}
|
|
}
|
|
if (cvalues) {
|
|
k = cptr[j];
|
|
while (k < cindex.length) {
|
|
i2 = cindex[k];
|
|
var wai = wa[i2];
|
|
var wbi = wb[i2];
|
|
if (wai === mark || wbi === mark) {
|
|
var va = wai === mark ? xa[i2] : zero;
|
|
var vb = wbi === mark ? xb[i2] : zero;
|
|
var vc = cf(va, vb);
|
|
if (!eq(vc, zero)) {
|
|
cvalues.push(vc);
|
|
k++;
|
|
} else {
|
|
cindex.splice(k, 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
cptr[columns] = cindex.length;
|
|
return a.createSparseMatrix({
|
|
values: cvalues,
|
|
index: cindex,
|
|
ptr: cptr,
|
|
size: [rows, columns],
|
|
datatype: dt
|
|
});
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/mod.js
|
|
var name59 = "mod";
|
|
var dependencies59 = ["typed", "matrix", "equalScalar", "DenseMatrix", "concat"];
|
|
var createMod = /* @__PURE__ */ factory(name59, dependencies59, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
equalScalar: equalScalar2,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo02xDS0 = createMatAlgo02xDS0({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo03xDSf = createMatAlgo03xDSf({
|
|
typed: typed2
|
|
});
|
|
var matAlgo05xSfSf = createMatAlgo05xSfSf({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo11xS0s = createMatAlgo11xS0s({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
return typed2(name59, {
|
|
"number, number": modNumber,
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(x, y) {
|
|
if (y.isNeg()) {
|
|
throw new Error("Cannot calculate mod for a negative divisor");
|
|
}
|
|
return y.isZero() ? x : x.mod(y);
|
|
},
|
|
"Fraction, Fraction": function FractionFraction(x, y) {
|
|
if (y.compare(0) < 0) {
|
|
throw new Error("Cannot calculate mod for a negative divisor");
|
|
}
|
|
return x.compare(0) >= 0 ? x.mod(y) : x.mod(y).add(y).mod(y);
|
|
}
|
|
}, matrixAlgorithmSuite({
|
|
SS: matAlgo05xSfSf,
|
|
DS: matAlgo03xDSf,
|
|
SD: matAlgo02xDS0,
|
|
Ss: matAlgo11xS0s,
|
|
sS: matAlgo12xSfs
|
|
}));
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/multiplyScalar.js
|
|
var name60 = "multiplyScalar";
|
|
var dependencies60 = ["typed"];
|
|
var createMultiplyScalar = /* @__PURE__ */ factory(name60, dependencies60, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2("multiplyScalar", {
|
|
"number, number": multiplyNumber,
|
|
"Complex, Complex": function ComplexComplex(x, y) {
|
|
return x.mul(y);
|
|
},
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(x, y) {
|
|
return x.times(y);
|
|
},
|
|
"Fraction, Fraction": function FractionFraction(x, y) {
|
|
return x.mul(y);
|
|
},
|
|
"number | Fraction | BigNumber | Complex, Unit": (x, y) => y.multiply(x),
|
|
"Unit, number | Fraction | BigNumber | Complex | Unit": (x, y) => x.multiply(y)
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/multiply.js
|
|
var name61 = "multiply";
|
|
var dependencies61 = ["typed", "matrix", "addScalar", "multiplyScalar", "equalScalar", "dot"];
|
|
var createMultiply = /* @__PURE__ */ factory(name61, dependencies61, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
addScalar: addScalar2,
|
|
multiplyScalar: multiplyScalar2,
|
|
equalScalar: equalScalar2,
|
|
dot: dot2
|
|
} = _ref;
|
|
var matAlgo11xS0s = createMatAlgo11xS0s({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo14xDs = createMatAlgo14xDs({
|
|
typed: typed2
|
|
});
|
|
function _validateMatrixDimensions(size1, size2) {
|
|
switch (size1.length) {
|
|
case 1:
|
|
switch (size2.length) {
|
|
case 1:
|
|
if (size1[0] !== size2[0]) {
|
|
throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");
|
|
}
|
|
break;
|
|
case 2:
|
|
if (size1[0] !== size2[0]) {
|
|
throw new RangeError("Dimension mismatch in multiplication. Vector length (" + size1[0] + ") must match Matrix rows (" + size2[0] + ")");
|
|
}
|
|
break;
|
|
default:
|
|
throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has " + size2.length + " dimensions)");
|
|
}
|
|
break;
|
|
case 2:
|
|
switch (size2.length) {
|
|
case 1:
|
|
if (size1[1] !== size2[0]) {
|
|
throw new RangeError("Dimension mismatch in multiplication. Matrix columns (" + size1[1] + ") must match Vector length (" + size2[0] + ")");
|
|
}
|
|
break;
|
|
case 2:
|
|
if (size1[1] !== size2[0]) {
|
|
throw new RangeError("Dimension mismatch in multiplication. Matrix A columns (" + size1[1] + ") must match Matrix B rows (" + size2[0] + ")");
|
|
}
|
|
break;
|
|
default:
|
|
throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has " + size2.length + " dimensions)");
|
|
}
|
|
break;
|
|
default:
|
|
throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has " + size1.length + " dimensions)");
|
|
}
|
|
}
|
|
function _multiplyVectorVector(a, b, n) {
|
|
if (n === 0) {
|
|
throw new Error("Cannot multiply two empty vectors");
|
|
}
|
|
return dot2(a, b);
|
|
}
|
|
function _multiplyVectorMatrix(a, b) {
|
|
if (b.storage() !== "dense") {
|
|
throw new Error("Support for SparseMatrix not implemented");
|
|
}
|
|
return _multiplyVectorDenseMatrix(a, b);
|
|
}
|
|
function _multiplyVectorDenseMatrix(a, b) {
|
|
var adata = a._data;
|
|
var asize = a._size;
|
|
var adt = a._datatype;
|
|
var bdata = b._data;
|
|
var bsize = b._size;
|
|
var bdt = b._datatype;
|
|
var alength = asize[0];
|
|
var bcolumns = bsize[1];
|
|
var dt;
|
|
var af = addScalar2;
|
|
var mf = multiplyScalar2;
|
|
if (adt && bdt && adt === bdt && typeof adt === "string") {
|
|
dt = adt;
|
|
af = typed2.find(addScalar2, [dt, dt]);
|
|
mf = typed2.find(multiplyScalar2, [dt, dt]);
|
|
}
|
|
var c = [];
|
|
for (var j = 0; j < bcolumns; j++) {
|
|
var sum3 = mf(adata[0], bdata[0][j]);
|
|
for (var i2 = 1; i2 < alength; i2++) {
|
|
sum3 = af(sum3, mf(adata[i2], bdata[i2][j]));
|
|
}
|
|
c[j] = sum3;
|
|
}
|
|
return a.createDenseMatrix({
|
|
data: c,
|
|
size: [bcolumns],
|
|
datatype: dt
|
|
});
|
|
}
|
|
var _multiplyMatrixVector = typed2("_multiplyMatrixVector", {
|
|
"DenseMatrix, any": _multiplyDenseMatrixVector,
|
|
"SparseMatrix, any": _multiplySparseMatrixVector
|
|
});
|
|
var _multiplyMatrixMatrix = typed2("_multiplyMatrixMatrix", {
|
|
"DenseMatrix, DenseMatrix": _multiplyDenseMatrixDenseMatrix,
|
|
"DenseMatrix, SparseMatrix": _multiplyDenseMatrixSparseMatrix,
|
|
"SparseMatrix, DenseMatrix": _multiplySparseMatrixDenseMatrix,
|
|
"SparseMatrix, SparseMatrix": _multiplySparseMatrixSparseMatrix
|
|
});
|
|
function _multiplyDenseMatrixVector(a, b) {
|
|
var adata = a._data;
|
|
var asize = a._size;
|
|
var adt = a._datatype;
|
|
var bdata = b._data;
|
|
var bdt = b._datatype;
|
|
var arows = asize[0];
|
|
var acolumns = asize[1];
|
|
var dt;
|
|
var af = addScalar2;
|
|
var mf = multiplyScalar2;
|
|
if (adt && bdt && adt === bdt && typeof adt === "string") {
|
|
dt = adt;
|
|
af = typed2.find(addScalar2, [dt, dt]);
|
|
mf = typed2.find(multiplyScalar2, [dt, dt]);
|
|
}
|
|
var c = [];
|
|
for (var i2 = 0; i2 < arows; i2++) {
|
|
var row2 = adata[i2];
|
|
var sum3 = mf(row2[0], bdata[0]);
|
|
for (var j = 1; j < acolumns; j++) {
|
|
sum3 = af(sum3, mf(row2[j], bdata[j]));
|
|
}
|
|
c[i2] = sum3;
|
|
}
|
|
return a.createDenseMatrix({
|
|
data: c,
|
|
size: [arows],
|
|
datatype: dt
|
|
});
|
|
}
|
|
function _multiplyDenseMatrixDenseMatrix(a, b) {
|
|
var adata = a._data;
|
|
var asize = a._size;
|
|
var adt = a._datatype;
|
|
var bdata = b._data;
|
|
var bsize = b._size;
|
|
var bdt = b._datatype;
|
|
var arows = asize[0];
|
|
var acolumns = asize[1];
|
|
var bcolumns = bsize[1];
|
|
var dt;
|
|
var af = addScalar2;
|
|
var mf = multiplyScalar2;
|
|
if (adt && bdt && adt === bdt && typeof adt === "string") {
|
|
dt = adt;
|
|
af = typed2.find(addScalar2, [dt, dt]);
|
|
mf = typed2.find(multiplyScalar2, [dt, dt]);
|
|
}
|
|
var c = [];
|
|
for (var i2 = 0; i2 < arows; i2++) {
|
|
var row2 = adata[i2];
|
|
c[i2] = [];
|
|
for (var j = 0; j < bcolumns; j++) {
|
|
var sum3 = mf(row2[0], bdata[0][j]);
|
|
for (var x = 1; x < acolumns; x++) {
|
|
sum3 = af(sum3, mf(row2[x], bdata[x][j]));
|
|
}
|
|
c[i2][j] = sum3;
|
|
}
|
|
}
|
|
return a.createDenseMatrix({
|
|
data: c,
|
|
size: [arows, bcolumns],
|
|
datatype: dt
|
|
});
|
|
}
|
|
function _multiplyDenseMatrixSparseMatrix(a, b) {
|
|
var adata = a._data;
|
|
var asize = a._size;
|
|
var adt = a._datatype;
|
|
var bvalues = b._values;
|
|
var bindex = b._index;
|
|
var bptr = b._ptr;
|
|
var bsize = b._size;
|
|
var bdt = b._datatype;
|
|
if (!bvalues) {
|
|
throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");
|
|
}
|
|
var arows = asize[0];
|
|
var bcolumns = bsize[1];
|
|
var dt;
|
|
var af = addScalar2;
|
|
var mf = multiplyScalar2;
|
|
var eq = equalScalar2;
|
|
var zero = 0;
|
|
if (adt && bdt && adt === bdt && typeof adt === "string") {
|
|
dt = adt;
|
|
af = typed2.find(addScalar2, [dt, dt]);
|
|
mf = typed2.find(multiplyScalar2, [dt, dt]);
|
|
eq = typed2.find(equalScalar2, [dt, dt]);
|
|
zero = typed2.convert(0, dt);
|
|
}
|
|
var cvalues = [];
|
|
var cindex = [];
|
|
var cptr = [];
|
|
var c = b.createSparseMatrix({
|
|
values: cvalues,
|
|
index: cindex,
|
|
ptr: cptr,
|
|
size: [arows, bcolumns],
|
|
datatype: dt
|
|
});
|
|
for (var jb = 0; jb < bcolumns; jb++) {
|
|
cptr[jb] = cindex.length;
|
|
var kb0 = bptr[jb];
|
|
var kb1 = bptr[jb + 1];
|
|
if (kb1 > kb0) {
|
|
var last = 0;
|
|
for (var i2 = 0; i2 < arows; i2++) {
|
|
var mark = i2 + 1;
|
|
var cij = void 0;
|
|
for (var kb = kb0; kb < kb1; kb++) {
|
|
var ib = bindex[kb];
|
|
if (last !== mark) {
|
|
cij = mf(adata[i2][ib], bvalues[kb]);
|
|
last = mark;
|
|
} else {
|
|
cij = af(cij, mf(adata[i2][ib], bvalues[kb]));
|
|
}
|
|
}
|
|
if (last === mark && !eq(cij, zero)) {
|
|
cindex.push(i2);
|
|
cvalues.push(cij);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
cptr[bcolumns] = cindex.length;
|
|
return c;
|
|
}
|
|
function _multiplySparseMatrixVector(a, b) {
|
|
var avalues = a._values;
|
|
var aindex = a._index;
|
|
var aptr = a._ptr;
|
|
var adt = a._datatype;
|
|
if (!avalues) {
|
|
throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");
|
|
}
|
|
var bdata = b._data;
|
|
var bdt = b._datatype;
|
|
var arows = a._size[0];
|
|
var brows = b._size[0];
|
|
var cvalues = [];
|
|
var cindex = [];
|
|
var cptr = [];
|
|
var dt;
|
|
var af = addScalar2;
|
|
var mf = multiplyScalar2;
|
|
var eq = equalScalar2;
|
|
var zero = 0;
|
|
if (adt && bdt && adt === bdt && typeof adt === "string") {
|
|
dt = adt;
|
|
af = typed2.find(addScalar2, [dt, dt]);
|
|
mf = typed2.find(multiplyScalar2, [dt, dt]);
|
|
eq = typed2.find(equalScalar2, [dt, dt]);
|
|
zero = typed2.convert(0, dt);
|
|
}
|
|
var x = [];
|
|
var w = [];
|
|
cptr[0] = 0;
|
|
for (var ib = 0; ib < brows; ib++) {
|
|
var vbi = bdata[ib];
|
|
if (!eq(vbi, zero)) {
|
|
for (var ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) {
|
|
var ia = aindex[ka];
|
|
if (!w[ia]) {
|
|
w[ia] = true;
|
|
cindex.push(ia);
|
|
x[ia] = mf(vbi, avalues[ka]);
|
|
} else {
|
|
x[ia] = af(x[ia], mf(vbi, avalues[ka]));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for (var p1 = cindex.length, p = 0; p < p1; p++) {
|
|
var ic = cindex[p];
|
|
cvalues[p] = x[ic];
|
|
}
|
|
cptr[1] = cindex.length;
|
|
return a.createSparseMatrix({
|
|
values: cvalues,
|
|
index: cindex,
|
|
ptr: cptr,
|
|
size: [arows, 1],
|
|
datatype: dt
|
|
});
|
|
}
|
|
function _multiplySparseMatrixDenseMatrix(a, b) {
|
|
var avalues = a._values;
|
|
var aindex = a._index;
|
|
var aptr = a._ptr;
|
|
var adt = a._datatype;
|
|
if (!avalues) {
|
|
throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");
|
|
}
|
|
var bdata = b._data;
|
|
var bdt = b._datatype;
|
|
var arows = a._size[0];
|
|
var brows = b._size[0];
|
|
var bcolumns = b._size[1];
|
|
var dt;
|
|
var af = addScalar2;
|
|
var mf = multiplyScalar2;
|
|
var eq = equalScalar2;
|
|
var zero = 0;
|
|
if (adt && bdt && adt === bdt && typeof adt === "string") {
|
|
dt = adt;
|
|
af = typed2.find(addScalar2, [dt, dt]);
|
|
mf = typed2.find(multiplyScalar2, [dt, dt]);
|
|
eq = typed2.find(equalScalar2, [dt, dt]);
|
|
zero = typed2.convert(0, dt);
|
|
}
|
|
var cvalues = [];
|
|
var cindex = [];
|
|
var cptr = [];
|
|
var c = a.createSparseMatrix({
|
|
values: cvalues,
|
|
index: cindex,
|
|
ptr: cptr,
|
|
size: [arows, bcolumns],
|
|
datatype: dt
|
|
});
|
|
var x = [];
|
|
var w = [];
|
|
for (var jb = 0; jb < bcolumns; jb++) {
|
|
cptr[jb] = cindex.length;
|
|
var mark = jb + 1;
|
|
for (var ib = 0; ib < brows; ib++) {
|
|
var vbij = bdata[ib][jb];
|
|
if (!eq(vbij, zero)) {
|
|
for (var ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) {
|
|
var ia = aindex[ka];
|
|
if (w[ia] !== mark) {
|
|
w[ia] = mark;
|
|
cindex.push(ia);
|
|
x[ia] = mf(vbij, avalues[ka]);
|
|
} else {
|
|
x[ia] = af(x[ia], mf(vbij, avalues[ka]));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for (var p0 = cptr[jb], p1 = cindex.length, p = p0; p < p1; p++) {
|
|
var ic = cindex[p];
|
|
cvalues[p] = x[ic];
|
|
}
|
|
}
|
|
cptr[bcolumns] = cindex.length;
|
|
return c;
|
|
}
|
|
function _multiplySparseMatrixSparseMatrix(a, b) {
|
|
var avalues = a._values;
|
|
var aindex = a._index;
|
|
var aptr = a._ptr;
|
|
var adt = a._datatype;
|
|
var bvalues = b._values;
|
|
var bindex = b._index;
|
|
var bptr = b._ptr;
|
|
var bdt = b._datatype;
|
|
var arows = a._size[0];
|
|
var bcolumns = b._size[1];
|
|
var values = avalues && bvalues;
|
|
var dt;
|
|
var af = addScalar2;
|
|
var mf = multiplyScalar2;
|
|
if (adt && bdt && adt === bdt && typeof adt === "string") {
|
|
dt = adt;
|
|
af = typed2.find(addScalar2, [dt, dt]);
|
|
mf = typed2.find(multiplyScalar2, [dt, dt]);
|
|
}
|
|
var cvalues = values ? [] : void 0;
|
|
var cindex = [];
|
|
var cptr = [];
|
|
var c = a.createSparseMatrix({
|
|
values: cvalues,
|
|
index: cindex,
|
|
ptr: cptr,
|
|
size: [arows, bcolumns],
|
|
datatype: dt
|
|
});
|
|
var x = values ? [] : void 0;
|
|
var w = [];
|
|
var ka, ka0, ka1, kb, kb0, kb1, ia, ib;
|
|
for (var jb = 0; jb < bcolumns; jb++) {
|
|
cptr[jb] = cindex.length;
|
|
var mark = jb + 1;
|
|
for (kb0 = bptr[jb], kb1 = bptr[jb + 1], kb = kb0; kb < kb1; kb++) {
|
|
ib = bindex[kb];
|
|
if (values) {
|
|
for (ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) {
|
|
ia = aindex[ka];
|
|
if (w[ia] !== mark) {
|
|
w[ia] = mark;
|
|
cindex.push(ia);
|
|
x[ia] = mf(bvalues[kb], avalues[ka]);
|
|
} else {
|
|
x[ia] = af(x[ia], mf(bvalues[kb], avalues[ka]));
|
|
}
|
|
}
|
|
} else {
|
|
for (ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) {
|
|
ia = aindex[ka];
|
|
if (w[ia] !== mark) {
|
|
w[ia] = mark;
|
|
cindex.push(ia);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (values) {
|
|
for (var p0 = cptr[jb], p1 = cindex.length, p = p0; p < p1; p++) {
|
|
var ic = cindex[p];
|
|
cvalues[p] = x[ic];
|
|
}
|
|
}
|
|
}
|
|
cptr[bcolumns] = cindex.length;
|
|
return c;
|
|
}
|
|
return typed2(name61, multiplyScalar2, {
|
|
"Array, Array": typed2.referTo("Matrix, Matrix", (selfMM) => (x, y) => {
|
|
_validateMatrixDimensions(arraySize(x), arraySize(y));
|
|
var m = selfMM(matrix2(x), matrix2(y));
|
|
return isMatrix(m) ? m.valueOf() : m;
|
|
}),
|
|
"Matrix, Matrix": function MatrixMatrix(x, y) {
|
|
var xsize = x.size();
|
|
var ysize = y.size();
|
|
_validateMatrixDimensions(xsize, ysize);
|
|
if (xsize.length === 1) {
|
|
if (ysize.length === 1) {
|
|
return _multiplyVectorVector(x, y, xsize[0]);
|
|
}
|
|
return _multiplyVectorMatrix(x, y);
|
|
}
|
|
if (ysize.length === 1) {
|
|
return _multiplyMatrixVector(x, y);
|
|
}
|
|
return _multiplyMatrixMatrix(x, y);
|
|
},
|
|
"Matrix, Array": typed2.referTo("Matrix,Matrix", (selfMM) => (x, y) => selfMM(x, matrix2(y))),
|
|
"Array, Matrix": typed2.referToSelf((self2) => (x, y) => {
|
|
return self2(matrix2(x, y.storage()), y);
|
|
}),
|
|
"SparseMatrix, any": function SparseMatrixAny(x, y) {
|
|
return matAlgo11xS0s(x, y, multiplyScalar2, false);
|
|
},
|
|
"DenseMatrix, any": function DenseMatrixAny(x, y) {
|
|
return matAlgo14xDs(x, y, multiplyScalar2, false);
|
|
},
|
|
"any, SparseMatrix": function anySparseMatrix(x, y) {
|
|
return matAlgo11xS0s(y, x, multiplyScalar2, true);
|
|
},
|
|
"any, DenseMatrix": function anyDenseMatrix(x, y) {
|
|
return matAlgo14xDs(y, x, multiplyScalar2, true);
|
|
},
|
|
"Array, any": function ArrayAny(x, y) {
|
|
return matAlgo14xDs(matrix2(x), y, multiplyScalar2, false).valueOf();
|
|
},
|
|
"any, Array": function anyArray(x, y) {
|
|
return matAlgo14xDs(matrix2(y), x, multiplyScalar2, true).valueOf();
|
|
},
|
|
"any, any": multiplyScalar2,
|
|
"any, any, ...any": typed2.referToSelf((self2) => (x, y, rest) => {
|
|
var result = self2(x, y);
|
|
for (var i2 = 0; i2 < rest.length; i2++) {
|
|
result = self2(result, rest[i2]);
|
|
}
|
|
return result;
|
|
})
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/nthRoot.js
|
|
var name62 = "nthRoot";
|
|
var dependencies62 = ["typed", "matrix", "equalScalar", "BigNumber", "concat"];
|
|
var createNthRoot = /* @__PURE__ */ factory(name62, dependencies62, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
equalScalar: equalScalar2,
|
|
BigNumber: _BigNumber,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo01xDSid = createMatAlgo01xDSid({
|
|
typed: typed2
|
|
});
|
|
var matAlgo02xDS0 = createMatAlgo02xDS0({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo06xS0S0 = createMatAlgo06xS0S0({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo11xS0s = createMatAlgo11xS0s({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
function complexErr() {
|
|
throw new Error("Complex number not supported in function nthRoot. Use nthRoots instead.");
|
|
}
|
|
return typed2(name62, {
|
|
number: nthRootNumber,
|
|
"number, number": nthRootNumber,
|
|
BigNumber: (x) => _bigNthRoot(x, new _BigNumber(2)),
|
|
"BigNumber, BigNumber": _bigNthRoot,
|
|
Complex: complexErr,
|
|
"Complex, number": complexErr,
|
|
Array: typed2.referTo("DenseMatrix,number", (selfDn) => (x) => selfDn(matrix2(x), 2).valueOf()),
|
|
DenseMatrix: typed2.referTo("DenseMatrix,number", (selfDn) => (x) => selfDn(x, 2)),
|
|
SparseMatrix: typed2.referTo("SparseMatrix,number", (selfSn) => (x) => selfSn(x, 2)),
|
|
"SparseMatrix, SparseMatrix": typed2.referToSelf((self2) => (x, y) => {
|
|
if (y.density() === 1) {
|
|
return matAlgo06xS0S0(x, y, self2);
|
|
} else {
|
|
throw new Error("Root must be non-zero");
|
|
}
|
|
}),
|
|
"DenseMatrix, SparseMatrix": typed2.referToSelf((self2) => (x, y) => {
|
|
if (y.density() === 1) {
|
|
return matAlgo01xDSid(x, y, self2, false);
|
|
} else {
|
|
throw new Error("Root must be non-zero");
|
|
}
|
|
}),
|
|
"Array, SparseMatrix": typed2.referTo("DenseMatrix,SparseMatrix", (selfDS) => (x, y) => selfDS(matrix2(x), y)),
|
|
"number | BigNumber, SparseMatrix": typed2.referToSelf((self2) => (x, y) => {
|
|
if (y.density() === 1) {
|
|
return matAlgo11xS0s(y, x, self2, true);
|
|
} else {
|
|
throw new Error("Root must be non-zero");
|
|
}
|
|
})
|
|
}, matrixAlgorithmSuite({
|
|
scalar: "number | BigNumber",
|
|
SD: matAlgo02xDS0,
|
|
Ss: matAlgo11xS0s,
|
|
sS: false
|
|
}));
|
|
function _bigNthRoot(a, root) {
|
|
var precision = _BigNumber.precision;
|
|
var Big = _BigNumber.clone({
|
|
precision: precision + 2
|
|
});
|
|
var zero = new _BigNumber(0);
|
|
var one = new Big(1);
|
|
var inv2 = root.isNegative();
|
|
if (inv2) {
|
|
root = root.neg();
|
|
}
|
|
if (root.isZero()) {
|
|
throw new Error("Root must be non-zero");
|
|
}
|
|
if (a.isNegative() && !root.abs().mod(2).equals(1)) {
|
|
throw new Error("Root must be odd when a is negative.");
|
|
}
|
|
if (a.isZero()) {
|
|
return inv2 ? new Big(Infinity) : 0;
|
|
}
|
|
if (!a.isFinite()) {
|
|
return inv2 ? zero : a;
|
|
}
|
|
var x = a.abs().pow(one.div(root));
|
|
x = a.isNeg() ? x.neg() : x;
|
|
return new _BigNumber((inv2 ? one.div(x) : x).toPrecision(precision));
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/sign.js
|
|
var name63 = "sign";
|
|
var dependencies63 = ["typed", "BigNumber", "Fraction", "complex"];
|
|
var createSign = /* @__PURE__ */ factory(name63, dependencies63, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
BigNumber: _BigNumber,
|
|
complex: complex2,
|
|
Fraction: _Fraction
|
|
} = _ref;
|
|
return typed2(name63, {
|
|
number: signNumber,
|
|
Complex: function Complex3(x) {
|
|
return x.im === 0 ? complex2(signNumber(x.re)) : x.sign();
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return new _BigNumber(x.cmp(0));
|
|
},
|
|
Fraction: function Fraction3(x) {
|
|
return new _Fraction(x.s, 1);
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2, true)),
|
|
Unit: typed2.referToSelf((self2) => (x) => {
|
|
if (!x._isDerived() && x.units[0].unit.offset !== 0) {
|
|
throw new TypeError("sign is ambiguous for units with offset");
|
|
}
|
|
return typed2.find(self2, x.valueType())(x.value);
|
|
})
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/sqrt.js
|
|
var name64 = "sqrt";
|
|
var dependencies64 = ["config", "typed", "Complex"];
|
|
var createSqrt = /* @__PURE__ */ factory(name64, dependencies64, (_ref) => {
|
|
var {
|
|
config: config4,
|
|
typed: typed2,
|
|
Complex: Complex3
|
|
} = _ref;
|
|
return typed2("sqrt", {
|
|
number: _sqrtNumber,
|
|
Complex: function Complex4(x) {
|
|
return x.sqrt();
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
if (!x.isNegative() || config4.predictable) {
|
|
return x.sqrt();
|
|
} else {
|
|
return _sqrtNumber(x.toNumber());
|
|
}
|
|
},
|
|
Unit: function Unit2(x) {
|
|
return x.pow(0.5);
|
|
}
|
|
});
|
|
function _sqrtNumber(x) {
|
|
if (isNaN(x)) {
|
|
return NaN;
|
|
} else if (x >= 0 || config4.predictable) {
|
|
return Math.sqrt(x);
|
|
} else {
|
|
return new Complex3(x, 0).sqrt();
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/square.js
|
|
var name65 = "square";
|
|
var dependencies65 = ["typed"];
|
|
var createSquare = /* @__PURE__ */ factory(name65, dependencies65, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name65, {
|
|
number: squareNumber,
|
|
Complex: function Complex3(x) {
|
|
return x.mul(x);
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return x.times(x);
|
|
},
|
|
Fraction: function Fraction3(x) {
|
|
return x.mul(x);
|
|
},
|
|
Unit: function Unit2(x) {
|
|
return x.pow(2);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/subtract.js
|
|
var name66 = "subtract";
|
|
var dependencies66 = ["typed", "matrix", "equalScalar", "addScalar", "unaryMinus", "DenseMatrix", "concat"];
|
|
var createSubtract = /* @__PURE__ */ factory(name66, dependencies66, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
equalScalar: equalScalar2,
|
|
addScalar: addScalar2,
|
|
unaryMinus: unaryMinus2,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo01xDSid = createMatAlgo01xDSid({
|
|
typed: typed2
|
|
});
|
|
var matAlgo03xDSf = createMatAlgo03xDSf({
|
|
typed: typed2
|
|
});
|
|
var matAlgo05xSfSf = createMatAlgo05xSfSf({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo10xSids = createMatAlgo10xSids({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
return typed2(name66, {
|
|
"number, number": (x, y) => x - y,
|
|
"Complex, Complex": (x, y) => x.sub(y),
|
|
"BigNumber, BigNumber": (x, y) => x.minus(y),
|
|
"Fraction, Fraction": (x, y) => x.sub(y),
|
|
"Unit, Unit": typed2.referToSelf((self2) => (x, y) => {
|
|
if (x.value === null) {
|
|
throw new Error("Parameter x contains a unit with undefined value");
|
|
}
|
|
if (y.value === null) {
|
|
throw new Error("Parameter y contains a unit with undefined value");
|
|
}
|
|
if (!x.equalBase(y)) {
|
|
throw new Error("Units do not match");
|
|
}
|
|
var res = x.clone();
|
|
res.value = typed2.find(self2, [res.valueType(), y.valueType()])(res.value, y.value);
|
|
res.fixPrefix = false;
|
|
return res;
|
|
})
|
|
}, matrixAlgorithmSuite({
|
|
SS: matAlgo05xSfSf,
|
|
DS: matAlgo01xDSid,
|
|
SD: matAlgo03xDSf,
|
|
Ss: matAlgo12xSfs,
|
|
sS: matAlgo10xSids
|
|
}));
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/xgcd.js
|
|
var name67 = "xgcd";
|
|
var dependencies67 = ["typed", "config", "matrix", "BigNumber"];
|
|
var createXgcd = /* @__PURE__ */ factory(name67, dependencies67, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
matrix: matrix2,
|
|
BigNumber: BigNumber2
|
|
} = _ref;
|
|
return typed2(name67, {
|
|
"number, number": function numberNumber(a, b) {
|
|
var res = xgcdNumber(a, b);
|
|
return config4.matrix === "Array" ? res : matrix2(res);
|
|
},
|
|
"BigNumber, BigNumber": _xgcdBigNumber
|
|
});
|
|
function _xgcdBigNumber(a, b) {
|
|
var t;
|
|
var q;
|
|
var r;
|
|
var zero = new BigNumber2(0);
|
|
var one = new BigNumber2(1);
|
|
var x = zero;
|
|
var lastx = one;
|
|
var y = one;
|
|
var lasty = zero;
|
|
if (!a.isInt() || !b.isInt()) {
|
|
throw new Error("Parameters in function xgcd must be integer numbers");
|
|
}
|
|
while (!b.isZero()) {
|
|
q = a.div(b).floor();
|
|
r = a.mod(b);
|
|
t = x;
|
|
x = lastx.minus(q.times(x));
|
|
lastx = t;
|
|
t = y;
|
|
y = lasty.minus(q.times(y));
|
|
lasty = t;
|
|
a = b;
|
|
b = r;
|
|
}
|
|
var res;
|
|
if (a.lt(zero)) {
|
|
res = [a.neg(), lastx.neg(), lasty.neg()];
|
|
} else {
|
|
res = [a, !a.isZero() ? lastx : 0, lasty];
|
|
}
|
|
return config4.matrix === "Array" ? res : matrix2(res);
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/invmod.js
|
|
var name68 = "invmod";
|
|
var dependencies68 = ["typed", "config", "BigNumber", "xgcd", "equal", "smaller", "mod", "add", "isInteger"];
|
|
var createInvmod = /* @__PURE__ */ factory(name68, dependencies68, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
BigNumber: BigNumber2,
|
|
xgcd: xgcd2,
|
|
equal: equal2,
|
|
smaller: smaller2,
|
|
mod: mod3,
|
|
add: add3,
|
|
isInteger: isInteger3
|
|
} = _ref;
|
|
return typed2(name68, {
|
|
"number, number": invmod2,
|
|
"BigNumber, BigNumber": invmod2
|
|
});
|
|
function invmod2(a, b) {
|
|
if (!isInteger3(a) || !isInteger3(b))
|
|
throw new Error("Parameters in function invmod must be integer numbers");
|
|
a = mod3(a, b);
|
|
if (equal2(b, 0))
|
|
throw new Error("Divisor must be non zero");
|
|
var res = xgcd2(a, b);
|
|
res = res.valueOf();
|
|
var [gcd2, inv2] = res;
|
|
if (!equal2(gcd2, BigNumber2(1)))
|
|
return NaN;
|
|
inv2 = mod3(inv2, b);
|
|
if (smaller2(inv2, BigNumber2(0)))
|
|
inv2 = add3(inv2, b);
|
|
return inv2;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/utils/matAlgo09xS0Sf.js
|
|
var name69 = "matAlgo09xS0Sf";
|
|
var dependencies69 = ["typed", "equalScalar"];
|
|
var createMatAlgo09xS0Sf = /* @__PURE__ */ factory(name69, dependencies69, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
} = _ref;
|
|
return function matAlgo09xS0Sf(a, b, callback) {
|
|
var avalues = a._values;
|
|
var aindex = a._index;
|
|
var aptr = a._ptr;
|
|
var asize = a._size;
|
|
var adt = a._datatype;
|
|
var bvalues = b._values;
|
|
var bindex = b._index;
|
|
var bptr = b._ptr;
|
|
var bsize = b._size;
|
|
var bdt = b._datatype;
|
|
if (asize.length !== bsize.length) {
|
|
throw new DimensionError(asize.length, bsize.length);
|
|
}
|
|
if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) {
|
|
throw new RangeError("Dimension mismatch. Matrix A (" + asize + ") must match Matrix B (" + bsize + ")");
|
|
}
|
|
var rows = asize[0];
|
|
var columns = asize[1];
|
|
var dt;
|
|
var eq = equalScalar2;
|
|
var zero = 0;
|
|
var cf = callback;
|
|
if (typeof adt === "string" && adt === bdt) {
|
|
dt = adt;
|
|
eq = typed2.find(equalScalar2, [dt, dt]);
|
|
zero = typed2.convert(0, dt);
|
|
cf = typed2.find(callback, [dt, dt]);
|
|
}
|
|
var cvalues = avalues && bvalues ? [] : void 0;
|
|
var cindex = [];
|
|
var cptr = [];
|
|
var x = cvalues ? [] : void 0;
|
|
var w = [];
|
|
var i2, j, k, k0, k1;
|
|
for (j = 0; j < columns; j++) {
|
|
cptr[j] = cindex.length;
|
|
var mark = j + 1;
|
|
if (x) {
|
|
for (k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) {
|
|
i2 = bindex[k];
|
|
w[i2] = mark;
|
|
x[i2] = bvalues[k];
|
|
}
|
|
}
|
|
for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) {
|
|
i2 = aindex[k];
|
|
if (x) {
|
|
var vb = w[i2] === mark ? x[i2] : zero;
|
|
var vc = cf(avalues[k], vb);
|
|
if (!eq(vc, zero)) {
|
|
cindex.push(i2);
|
|
cvalues.push(vc);
|
|
}
|
|
} else {
|
|
cindex.push(i2);
|
|
}
|
|
}
|
|
}
|
|
cptr[columns] = cindex.length;
|
|
return a.createSparseMatrix({
|
|
values: cvalues,
|
|
index: cindex,
|
|
ptr: cptr,
|
|
size: [rows, columns],
|
|
datatype: dt
|
|
});
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/dotMultiply.js
|
|
var name70 = "dotMultiply";
|
|
var dependencies70 = ["typed", "matrix", "equalScalar", "multiplyScalar", "concat"];
|
|
var createDotMultiply = /* @__PURE__ */ factory(name70, dependencies70, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
equalScalar: equalScalar2,
|
|
multiplyScalar: multiplyScalar2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo02xDS0 = createMatAlgo02xDS0({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo09xS0Sf = createMatAlgo09xS0Sf({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo11xS0s = createMatAlgo11xS0s({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
return typed2(name70, matrixAlgorithmSuite({
|
|
elop: multiplyScalar2,
|
|
SS: matAlgo09xS0Sf,
|
|
DS: matAlgo02xDS0,
|
|
Ss: matAlgo11xS0s
|
|
}));
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/utils/bignumber/bitwise.js
|
|
function bitAndBigNumber(x, y) {
|
|
if (x.isFinite() && !x.isInteger() || y.isFinite() && !y.isInteger()) {
|
|
throw new Error("Integers expected in function bitAnd");
|
|
}
|
|
var BigNumber2 = x.constructor;
|
|
if (x.isNaN() || y.isNaN()) {
|
|
return new BigNumber2(NaN);
|
|
}
|
|
if (x.isZero() || y.eq(-1) || x.eq(y)) {
|
|
return x;
|
|
}
|
|
if (y.isZero() || x.eq(-1)) {
|
|
return y;
|
|
}
|
|
if (!x.isFinite() || !y.isFinite()) {
|
|
if (!x.isFinite() && !y.isFinite()) {
|
|
if (x.isNegative() === y.isNegative()) {
|
|
return x;
|
|
}
|
|
return new BigNumber2(0);
|
|
}
|
|
if (!x.isFinite()) {
|
|
if (y.isNegative()) {
|
|
return x;
|
|
}
|
|
if (x.isNegative()) {
|
|
return new BigNumber2(0);
|
|
}
|
|
return y;
|
|
}
|
|
if (!y.isFinite()) {
|
|
if (x.isNegative()) {
|
|
return y;
|
|
}
|
|
if (y.isNegative()) {
|
|
return new BigNumber2(0);
|
|
}
|
|
return x;
|
|
}
|
|
}
|
|
return bitwise(x, y, function(a, b) {
|
|
return a & b;
|
|
});
|
|
}
|
|
function bitNotBigNumber(x) {
|
|
if (x.isFinite() && !x.isInteger()) {
|
|
throw new Error("Integer expected in function bitNot");
|
|
}
|
|
var BigNumber2 = x.constructor;
|
|
var prevPrec = BigNumber2.precision;
|
|
BigNumber2.config({
|
|
precision: 1e9
|
|
});
|
|
var result = x.plus(new BigNumber2(1));
|
|
result.s = -result.s || null;
|
|
BigNumber2.config({
|
|
precision: prevPrec
|
|
});
|
|
return result;
|
|
}
|
|
function bitOrBigNumber(x, y) {
|
|
if (x.isFinite() && !x.isInteger() || y.isFinite() && !y.isInteger()) {
|
|
throw new Error("Integers expected in function bitOr");
|
|
}
|
|
var BigNumber2 = x.constructor;
|
|
if (x.isNaN() || y.isNaN()) {
|
|
return new BigNumber2(NaN);
|
|
}
|
|
var negOne = new BigNumber2(-1);
|
|
if (x.isZero() || y.eq(negOne) || x.eq(y)) {
|
|
return y;
|
|
}
|
|
if (y.isZero() || x.eq(negOne)) {
|
|
return x;
|
|
}
|
|
if (!x.isFinite() || !y.isFinite()) {
|
|
if (!x.isFinite() && !x.isNegative() && y.isNegative() || x.isNegative() && !y.isNegative() && !y.isFinite()) {
|
|
return negOne;
|
|
}
|
|
if (x.isNegative() && y.isNegative()) {
|
|
return x.isFinite() ? x : y;
|
|
}
|
|
return x.isFinite() ? y : x;
|
|
}
|
|
return bitwise(x, y, function(a, b) {
|
|
return a | b;
|
|
});
|
|
}
|
|
function bitwise(x, y, func) {
|
|
var BigNumber2 = x.constructor;
|
|
var xBits, yBits;
|
|
var xSign = +(x.s < 0);
|
|
var ySign = +(y.s < 0);
|
|
if (xSign) {
|
|
xBits = decCoefficientToBinaryString(bitNotBigNumber(x));
|
|
for (var i2 = 0; i2 < xBits.length; ++i2) {
|
|
xBits[i2] ^= 1;
|
|
}
|
|
} else {
|
|
xBits = decCoefficientToBinaryString(x);
|
|
}
|
|
if (ySign) {
|
|
yBits = decCoefficientToBinaryString(bitNotBigNumber(y));
|
|
for (var _i = 0; _i < yBits.length; ++_i) {
|
|
yBits[_i] ^= 1;
|
|
}
|
|
} else {
|
|
yBits = decCoefficientToBinaryString(y);
|
|
}
|
|
var minBits, maxBits, minSign;
|
|
if (xBits.length <= yBits.length) {
|
|
minBits = xBits;
|
|
maxBits = yBits;
|
|
minSign = xSign;
|
|
} else {
|
|
minBits = yBits;
|
|
maxBits = xBits;
|
|
minSign = ySign;
|
|
}
|
|
var shortLen = minBits.length;
|
|
var longLen = maxBits.length;
|
|
var expFuncVal = func(xSign, ySign) ^ 1;
|
|
var outVal = new BigNumber2(expFuncVal ^ 1);
|
|
var twoPower = new BigNumber2(1);
|
|
var two = new BigNumber2(2);
|
|
var prevPrec = BigNumber2.precision;
|
|
BigNumber2.config({
|
|
precision: 1e9
|
|
});
|
|
while (shortLen > 0) {
|
|
if (func(minBits[--shortLen], maxBits[--longLen]) === expFuncVal) {
|
|
outVal = outVal.plus(twoPower);
|
|
}
|
|
twoPower = twoPower.times(two);
|
|
}
|
|
while (longLen > 0) {
|
|
if (func(minSign, maxBits[--longLen]) === expFuncVal) {
|
|
outVal = outVal.plus(twoPower);
|
|
}
|
|
twoPower = twoPower.times(two);
|
|
}
|
|
BigNumber2.config({
|
|
precision: prevPrec
|
|
});
|
|
if (expFuncVal === 0) {
|
|
outVal.s = -outVal.s;
|
|
}
|
|
return outVal;
|
|
}
|
|
function decCoefficientToBinaryString(x) {
|
|
var a = x.d;
|
|
var r = a[0] + "";
|
|
for (var i2 = 1; i2 < a.length; ++i2) {
|
|
var s = a[i2] + "";
|
|
for (var z = 7 - s.length; z--; ) {
|
|
s = "0" + s;
|
|
}
|
|
r += s;
|
|
}
|
|
var j = r.length;
|
|
while (r.charAt(j) === "0") {
|
|
j--;
|
|
}
|
|
var xe = x.e;
|
|
var str = r.slice(0, j + 1 || 1);
|
|
var strL = str.length;
|
|
if (xe > 0) {
|
|
if (++xe > strL) {
|
|
xe -= strL;
|
|
while (xe--) {
|
|
str += "0";
|
|
}
|
|
} else if (xe < strL) {
|
|
str = str.slice(0, xe) + "." + str.slice(xe);
|
|
}
|
|
}
|
|
var arr = [0];
|
|
for (var _i2 = 0; _i2 < str.length; ) {
|
|
var arrL = arr.length;
|
|
while (arrL--) {
|
|
arr[arrL] *= 10;
|
|
}
|
|
arr[0] += parseInt(str.charAt(_i2++));
|
|
for (var _j = 0; _j < arr.length; ++_j) {
|
|
if (arr[_j] > 1) {
|
|
if (arr[_j + 1] === null || arr[_j + 1] === void 0) {
|
|
arr[_j + 1] = 0;
|
|
}
|
|
arr[_j + 1] += arr[_j] >> 1;
|
|
arr[_j] &= 1;
|
|
}
|
|
}
|
|
}
|
|
return arr.reverse();
|
|
}
|
|
function bitXor(x, y) {
|
|
if (x.isFinite() && !x.isInteger() || y.isFinite() && !y.isInteger()) {
|
|
throw new Error("Integers expected in function bitXor");
|
|
}
|
|
var BigNumber2 = x.constructor;
|
|
if (x.isNaN() || y.isNaN()) {
|
|
return new BigNumber2(NaN);
|
|
}
|
|
if (x.isZero()) {
|
|
return y;
|
|
}
|
|
if (y.isZero()) {
|
|
return x;
|
|
}
|
|
if (x.eq(y)) {
|
|
return new BigNumber2(0);
|
|
}
|
|
var negOne = new BigNumber2(-1);
|
|
if (x.eq(negOne)) {
|
|
return bitNotBigNumber(y);
|
|
}
|
|
if (y.eq(negOne)) {
|
|
return bitNotBigNumber(x);
|
|
}
|
|
if (!x.isFinite() || !y.isFinite()) {
|
|
if (!x.isFinite() && !y.isFinite()) {
|
|
return negOne;
|
|
}
|
|
return new BigNumber2(x.isNegative() === y.isNegative() ? Infinity : -Infinity);
|
|
}
|
|
return bitwise(x, y, function(a, b) {
|
|
return a ^ b;
|
|
});
|
|
}
|
|
function leftShiftBigNumber(x, y) {
|
|
if (x.isFinite() && !x.isInteger() || y.isFinite() && !y.isInteger()) {
|
|
throw new Error("Integers expected in function leftShift");
|
|
}
|
|
var BigNumber2 = x.constructor;
|
|
if (x.isNaN() || y.isNaN() || y.isNegative() && !y.isZero()) {
|
|
return new BigNumber2(NaN);
|
|
}
|
|
if (x.isZero() || y.isZero()) {
|
|
return x;
|
|
}
|
|
if (!x.isFinite() && !y.isFinite()) {
|
|
return new BigNumber2(NaN);
|
|
}
|
|
if (y.lt(55)) {
|
|
return x.times(Math.pow(2, y.toNumber()) + "");
|
|
}
|
|
return x.times(new BigNumber2(2).pow(y));
|
|
}
|
|
function rightArithShiftBigNumber(x, y) {
|
|
if (x.isFinite() && !x.isInteger() || y.isFinite() && !y.isInteger()) {
|
|
throw new Error("Integers expected in function rightArithShift");
|
|
}
|
|
var BigNumber2 = x.constructor;
|
|
if (x.isNaN() || y.isNaN() || y.isNegative() && !y.isZero()) {
|
|
return new BigNumber2(NaN);
|
|
}
|
|
if (x.isZero() || y.isZero()) {
|
|
return x;
|
|
}
|
|
if (!y.isFinite()) {
|
|
if (x.isNegative()) {
|
|
return new BigNumber2(-1);
|
|
}
|
|
if (!x.isFinite()) {
|
|
return new BigNumber2(NaN);
|
|
}
|
|
return new BigNumber2(0);
|
|
}
|
|
if (y.lt(55)) {
|
|
return x.div(Math.pow(2, y.toNumber()) + "").floor();
|
|
}
|
|
return x.div(new BigNumber2(2).pow(y)).floor();
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/bitwise/bitAnd.js
|
|
var name71 = "bitAnd";
|
|
var dependencies71 = ["typed", "matrix", "equalScalar", "concat"];
|
|
var createBitAnd = /* @__PURE__ */ factory(name71, dependencies71, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
equalScalar: equalScalar2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo02xDS0 = createMatAlgo02xDS0({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo06xS0S0 = createMatAlgo06xS0S0({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo11xS0s = createMatAlgo11xS0s({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
return typed2(name71, {
|
|
"number, number": bitAndNumber,
|
|
"BigNumber, BigNumber": bitAndBigNumber
|
|
}, matrixAlgorithmSuite({
|
|
SS: matAlgo06xS0S0,
|
|
DS: matAlgo02xDS0,
|
|
Ss: matAlgo11xS0s
|
|
}));
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/bitwise/bitNot.js
|
|
var name72 = "bitNot";
|
|
var dependencies72 = ["typed"];
|
|
var createBitNot = /* @__PURE__ */ factory(name72, dependencies72, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name72, {
|
|
number: bitNotNumber,
|
|
BigNumber: bitNotBigNumber,
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/bitwise/bitOr.js
|
|
var name73 = "bitOr";
|
|
var dependencies73 = ["typed", "matrix", "equalScalar", "DenseMatrix", "concat"];
|
|
var createBitOr = /* @__PURE__ */ factory(name73, dependencies73, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
equalScalar: equalScalar2,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo01xDSid = createMatAlgo01xDSid({
|
|
typed: typed2
|
|
});
|
|
var matAlgo04xSidSid = createMatAlgo04xSidSid({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo10xSids = createMatAlgo10xSids({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
return typed2(name73, {
|
|
"number, number": bitOrNumber,
|
|
"BigNumber, BigNumber": bitOrBigNumber
|
|
}, matrixAlgorithmSuite({
|
|
SS: matAlgo04xSidSid,
|
|
DS: matAlgo01xDSid,
|
|
Ss: matAlgo10xSids
|
|
}));
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/utils/matAlgo07xSSf.js
|
|
var name74 = "matAlgo07xSSf";
|
|
var dependencies74 = ["typed", "DenseMatrix"];
|
|
var createMatAlgo07xSSf = /* @__PURE__ */ factory(name74, dependencies74, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
} = _ref;
|
|
return function matAlgo07xSSf(a, b, callback) {
|
|
var asize = a._size;
|
|
var adt = a._datatype;
|
|
var bsize = b._size;
|
|
var bdt = b._datatype;
|
|
if (asize.length !== bsize.length) {
|
|
throw new DimensionError(asize.length, bsize.length);
|
|
}
|
|
if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) {
|
|
throw new RangeError("Dimension mismatch. Matrix A (" + asize + ") must match Matrix B (" + bsize + ")");
|
|
}
|
|
var rows = asize[0];
|
|
var columns = asize[1];
|
|
var dt;
|
|
var zero = 0;
|
|
var cf = callback;
|
|
if (typeof adt === "string" && adt === bdt) {
|
|
dt = adt;
|
|
zero = typed2.convert(0, dt);
|
|
cf = typed2.find(callback, [dt, dt]);
|
|
}
|
|
var i2, j;
|
|
var cdata = [];
|
|
for (i2 = 0; i2 < rows; i2++) {
|
|
cdata[i2] = [];
|
|
}
|
|
var xa = [];
|
|
var xb = [];
|
|
var wa = [];
|
|
var wb = [];
|
|
for (j = 0; j < columns; j++) {
|
|
var mark = j + 1;
|
|
_scatter(a, j, wa, xa, mark);
|
|
_scatter(b, j, wb, xb, mark);
|
|
for (i2 = 0; i2 < rows; i2++) {
|
|
var va = wa[i2] === mark ? xa[i2] : zero;
|
|
var vb = wb[i2] === mark ? xb[i2] : zero;
|
|
cdata[i2][j] = cf(va, vb);
|
|
}
|
|
}
|
|
return new DenseMatrix2({
|
|
data: cdata,
|
|
size: [rows, columns],
|
|
datatype: dt
|
|
});
|
|
};
|
|
function _scatter(m, j, w, x, mark) {
|
|
var values = m._values;
|
|
var index2 = m._index;
|
|
var ptr = m._ptr;
|
|
for (var k = ptr[j], k1 = ptr[j + 1]; k < k1; k++) {
|
|
var i2 = index2[k];
|
|
w[i2] = mark;
|
|
x[i2] = values[k];
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/bitwise/bitXor.js
|
|
var name75 = "bitXor";
|
|
var dependencies75 = ["typed", "matrix", "DenseMatrix", "concat"];
|
|
var createBitXor = /* @__PURE__ */ factory(name75, dependencies75, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo03xDSf = createMatAlgo03xDSf({
|
|
typed: typed2
|
|
});
|
|
var matAlgo07xSSf = createMatAlgo07xSSf({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
return typed2(name75, {
|
|
"number, number": bitXorNumber,
|
|
"BigNumber, BigNumber": bitXor
|
|
}, matrixAlgorithmSuite({
|
|
SS: matAlgo07xSSf,
|
|
DS: matAlgo03xDSf,
|
|
Ss: matAlgo12xSfs
|
|
}));
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/complex/arg.js
|
|
var name76 = "arg";
|
|
var dependencies76 = ["typed"];
|
|
var createArg = /* @__PURE__ */ factory(name76, dependencies76, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name76, {
|
|
number: function number2(x) {
|
|
return Math.atan2(0, x);
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return x.constructor.atan2(0, x);
|
|
},
|
|
Complex: function Complex3(x) {
|
|
return x.arg();
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/complex/conj.js
|
|
var name77 = "conj";
|
|
var dependencies77 = ["typed"];
|
|
var createConj = /* @__PURE__ */ factory(name77, dependencies77, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name77, {
|
|
"number | BigNumber | Fraction": (x) => x,
|
|
Complex: (x) => x.conjugate(),
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/complex/im.js
|
|
var name78 = "im";
|
|
var dependencies78 = ["typed"];
|
|
var createIm = /* @__PURE__ */ factory(name78, dependencies78, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name78, {
|
|
number: () => 0,
|
|
"BigNumber | Fraction": (x) => x.mul(0),
|
|
Complex: (x) => x.im,
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/complex/re.js
|
|
var name79 = "re";
|
|
var dependencies79 = ["typed"];
|
|
var createRe = /* @__PURE__ */ factory(name79, dependencies79, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name79, {
|
|
"number | BigNumber | Fraction": (x) => x,
|
|
Complex: (x) => x.re,
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/logical/not.js
|
|
var name80 = "not";
|
|
var dependencies80 = ["typed"];
|
|
var createNot = /* @__PURE__ */ factory(name80, dependencies80, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name80, {
|
|
"null | undefined": () => true,
|
|
number: notNumber,
|
|
Complex: function Complex3(x) {
|
|
return x.re === 0 && x.im === 0;
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return x.isZero() || x.isNaN();
|
|
},
|
|
Unit: typed2.referToSelf((self2) => (x) => typed2.find(self2, x.valueType())(x.value)),
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/logical/or.js
|
|
var name81 = "or";
|
|
var dependencies81 = ["typed", "matrix", "equalScalar", "DenseMatrix", "concat"];
|
|
var createOr = /* @__PURE__ */ factory(name81, dependencies81, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
equalScalar: equalScalar2,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo03xDSf = createMatAlgo03xDSf({
|
|
typed: typed2
|
|
});
|
|
var matAlgo05xSfSf = createMatAlgo05xSfSf({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
return typed2(name81, {
|
|
"number, number": orNumber,
|
|
"Complex, Complex": function ComplexComplex(x, y) {
|
|
return x.re !== 0 || x.im !== 0 || y.re !== 0 || y.im !== 0;
|
|
},
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(x, y) {
|
|
return !x.isZero() && !x.isNaN() || !y.isZero() && !y.isNaN();
|
|
},
|
|
"Unit, Unit": typed2.referToSelf((self2) => (x, y) => self2(x.value || 0, y.value || 0))
|
|
}, matrixAlgorithmSuite({
|
|
SS: matAlgo05xSfSf,
|
|
DS: matAlgo03xDSf,
|
|
Ss: matAlgo12xSfs
|
|
}));
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/logical/xor.js
|
|
var name82 = "xor";
|
|
var dependencies82 = ["typed", "matrix", "DenseMatrix", "concat"];
|
|
var createXor = /* @__PURE__ */ factory(name82, dependencies82, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo03xDSf = createMatAlgo03xDSf({
|
|
typed: typed2
|
|
});
|
|
var matAlgo07xSSf = createMatAlgo07xSSf({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
return typed2(name82, {
|
|
"number, number": xorNumber,
|
|
"Complex, Complex": function ComplexComplex(x, y) {
|
|
return (x.re !== 0 || x.im !== 0) !== (y.re !== 0 || y.im !== 0);
|
|
},
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(x, y) {
|
|
return (!x.isZero() && !x.isNaN()) !== (!y.isZero() && !y.isNaN());
|
|
},
|
|
"Unit, Unit": typed2.referToSelf((self2) => (x, y) => self2(x.value || 0, y.value || 0))
|
|
}, matrixAlgorithmSuite({
|
|
SS: matAlgo07xSSf,
|
|
DS: matAlgo03xDSf,
|
|
Ss: matAlgo12xSfs
|
|
}));
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/concat.js
|
|
var name83 = "concat";
|
|
var dependencies83 = ["typed", "matrix", "isInteger"];
|
|
var createConcat = /* @__PURE__ */ factory(name83, dependencies83, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
isInteger: isInteger3
|
|
} = _ref;
|
|
return typed2(name83, {
|
|
"...Array | Matrix | number | BigNumber": function ArrayMatrixNumberBigNumber(args) {
|
|
var i2;
|
|
var len = args.length;
|
|
var dim = -1;
|
|
var prevDim;
|
|
var asMatrix = false;
|
|
var matrices = [];
|
|
for (i2 = 0; i2 < len; i2++) {
|
|
var arg2 = args[i2];
|
|
if (isMatrix(arg2)) {
|
|
asMatrix = true;
|
|
}
|
|
if (isNumber(arg2) || isBigNumber(arg2)) {
|
|
if (i2 !== len - 1) {
|
|
throw new Error("Dimension must be specified as last argument");
|
|
}
|
|
prevDim = dim;
|
|
dim = arg2.valueOf();
|
|
if (!isInteger3(dim)) {
|
|
throw new TypeError("Integer number expected for dimension");
|
|
}
|
|
if (dim < 0 || i2 > 0 && dim > prevDim) {
|
|
throw new IndexError(dim, prevDim + 1);
|
|
}
|
|
} else {
|
|
var m = clone(arg2).valueOf();
|
|
var size2 = arraySize(m);
|
|
matrices[i2] = m;
|
|
prevDim = dim;
|
|
dim = size2.length - 1;
|
|
if (i2 > 0 && dim !== prevDim) {
|
|
throw new DimensionError(prevDim + 1, dim + 1);
|
|
}
|
|
}
|
|
}
|
|
if (matrices.length === 0) {
|
|
throw new SyntaxError("At least one matrix expected");
|
|
}
|
|
var res = matrices.shift();
|
|
while (matrices.length) {
|
|
res = _concat(res, matrices.shift(), dim, 0);
|
|
}
|
|
return asMatrix ? matrix2(res) : res;
|
|
},
|
|
"...string": function string2(args) {
|
|
return args.join("");
|
|
}
|
|
});
|
|
});
|
|
function _concat(a, b, concatDim, dim) {
|
|
if (dim < concatDim) {
|
|
if (a.length !== b.length) {
|
|
throw new DimensionError(a.length, b.length);
|
|
}
|
|
var c = [];
|
|
for (var i2 = 0; i2 < a.length; i2++) {
|
|
c[i2] = _concat(a[i2], b[i2], concatDim, dim + 1);
|
|
}
|
|
return c;
|
|
} else {
|
|
return a.concat(b);
|
|
}
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/column.js
|
|
var name84 = "column";
|
|
var dependencies84 = ["typed", "Index", "matrix", "range"];
|
|
var createColumn = /* @__PURE__ */ factory(name84, dependencies84, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
Index: Index2,
|
|
matrix: matrix2,
|
|
range: range2
|
|
} = _ref;
|
|
return typed2(name84, {
|
|
"Matrix, number": _column,
|
|
"Array, number": function ArrayNumber(value, column2) {
|
|
return _column(matrix2(clone(value)), column2).valueOf();
|
|
}
|
|
});
|
|
function _column(value, column2) {
|
|
if (value.size().length !== 2) {
|
|
throw new Error("Only two dimensional matrix is supported");
|
|
}
|
|
validateIndex(column2, value.size()[1]);
|
|
var rowRange = range2(0, value.size()[0]);
|
|
var index2 = new Index2(rowRange, column2);
|
|
var result = value.subset(index2);
|
|
return isMatrix(result) ? result : matrix2([[result]]);
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/count.js
|
|
var name85 = "count";
|
|
var dependencies85 = ["typed", "size", "prod"];
|
|
var createCount = /* @__PURE__ */ factory(name85, dependencies85, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
size: size2,
|
|
prod: prod2
|
|
} = _ref;
|
|
return typed2(name85, {
|
|
string: function string2(x) {
|
|
return x.length;
|
|
},
|
|
"Matrix | Array": function MatrixArray(x) {
|
|
return prod2(size2(x));
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/cross.js
|
|
var name86 = "cross";
|
|
var dependencies86 = ["typed", "matrix", "subtract", "multiply"];
|
|
var createCross = /* @__PURE__ */ factory(name86, dependencies86, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
subtract: subtract2,
|
|
multiply: multiply2
|
|
} = _ref;
|
|
return typed2(name86, {
|
|
"Matrix, Matrix": function MatrixMatrix(x, y) {
|
|
return matrix2(_cross(x.toArray(), y.toArray()));
|
|
},
|
|
"Matrix, Array": function MatrixArray(x, y) {
|
|
return matrix2(_cross(x.toArray(), y));
|
|
},
|
|
"Array, Matrix": function ArrayMatrix(x, y) {
|
|
return matrix2(_cross(x, y.toArray()));
|
|
},
|
|
"Array, Array": _cross
|
|
});
|
|
function _cross(x, y) {
|
|
var highestDimension = Math.max(arraySize(x).length, arraySize(y).length);
|
|
x = squeeze(x);
|
|
y = squeeze(y);
|
|
var xSize = arraySize(x);
|
|
var ySize = arraySize(y);
|
|
if (xSize.length !== 1 || ySize.length !== 1 || xSize[0] !== 3 || ySize[0] !== 3) {
|
|
throw new RangeError("Vectors with length 3 expected (Size A = [" + xSize.join(", ") + "], B = [" + ySize.join(", ") + "])");
|
|
}
|
|
var product3 = [subtract2(multiply2(x[1], y[2]), multiply2(x[2], y[1])), subtract2(multiply2(x[2], y[0]), multiply2(x[0], y[2])), subtract2(multiply2(x[0], y[1]), multiply2(x[1], y[0]))];
|
|
if (highestDimension > 1) {
|
|
return [product3];
|
|
} else {
|
|
return product3;
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/diag.js
|
|
var name87 = "diag";
|
|
var dependencies87 = ["typed", "matrix", "DenseMatrix", "SparseMatrix"];
|
|
var createDiag = /* @__PURE__ */ factory(name87, dependencies87, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
DenseMatrix: DenseMatrix2,
|
|
SparseMatrix: SparseMatrix2
|
|
} = _ref;
|
|
return typed2(name87, {
|
|
Array: function Array2(x) {
|
|
return _diag(x, 0, arraySize(x), null);
|
|
},
|
|
"Array, number": function ArrayNumber(x, k) {
|
|
return _diag(x, k, arraySize(x), null);
|
|
},
|
|
"Array, BigNumber": function ArrayBigNumber(x, k) {
|
|
return _diag(x, k.toNumber(), arraySize(x), null);
|
|
},
|
|
"Array, string": function ArrayString(x, format5) {
|
|
return _diag(x, 0, arraySize(x), format5);
|
|
},
|
|
"Array, number, string": function ArrayNumberString(x, k, format5) {
|
|
return _diag(x, k, arraySize(x), format5);
|
|
},
|
|
"Array, BigNumber, string": function ArrayBigNumberString(x, k, format5) {
|
|
return _diag(x, k.toNumber(), arraySize(x), format5);
|
|
},
|
|
Matrix: function Matrix2(x) {
|
|
return _diag(x, 0, x.size(), x.storage());
|
|
},
|
|
"Matrix, number": function MatrixNumber(x, k) {
|
|
return _diag(x, k, x.size(), x.storage());
|
|
},
|
|
"Matrix, BigNumber": function MatrixBigNumber(x, k) {
|
|
return _diag(x, k.toNumber(), x.size(), x.storage());
|
|
},
|
|
"Matrix, string": function MatrixString(x, format5) {
|
|
return _diag(x, 0, x.size(), format5);
|
|
},
|
|
"Matrix, number, string": function MatrixNumberString(x, k, format5) {
|
|
return _diag(x, k, x.size(), format5);
|
|
},
|
|
"Matrix, BigNumber, string": function MatrixBigNumberString(x, k, format5) {
|
|
return _diag(x, k.toNumber(), x.size(), format5);
|
|
}
|
|
});
|
|
function _diag(x, k, size2, format5) {
|
|
if (!isInteger(k)) {
|
|
throw new TypeError("Second parameter in function diag must be an integer");
|
|
}
|
|
var kSuper = k > 0 ? k : 0;
|
|
var kSub = k < 0 ? -k : 0;
|
|
switch (size2.length) {
|
|
case 1:
|
|
return _createDiagonalMatrix(x, k, format5, size2[0], kSub, kSuper);
|
|
case 2:
|
|
return _getDiagonal(x, k, format5, size2, kSub, kSuper);
|
|
}
|
|
throw new RangeError("Matrix for function diag must be 2 dimensional");
|
|
}
|
|
function _createDiagonalMatrix(x, k, format5, l, kSub, kSuper) {
|
|
var ms = [l + kSub, l + kSuper];
|
|
if (format5 && format5 !== "sparse" && format5 !== "dense") {
|
|
throw new TypeError("Unknown matrix type ".concat(format5, '"'));
|
|
}
|
|
var m = format5 === "sparse" ? SparseMatrix2.diagonal(ms, x, k) : DenseMatrix2.diagonal(ms, x, k);
|
|
return format5 !== null ? m : m.valueOf();
|
|
}
|
|
function _getDiagonal(x, k, format5, s, kSub, kSuper) {
|
|
if (isMatrix(x)) {
|
|
var dm = x.diagonal(k);
|
|
if (format5 !== null) {
|
|
if (format5 !== dm.storage()) {
|
|
return matrix2(dm, format5);
|
|
}
|
|
return dm;
|
|
}
|
|
return dm.valueOf();
|
|
}
|
|
var n = Math.min(s[0] - kSub, s[1] - kSuper);
|
|
var vector = [];
|
|
for (var i2 = 0; i2 < n; i2++) {
|
|
vector[i2] = x[i2 + kSub][i2 + kSuper];
|
|
}
|
|
return format5 !== null ? matrix2(vector) : vector;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/filter.js
|
|
var name88 = "filter";
|
|
var dependencies88 = ["typed"];
|
|
var createFilter = /* @__PURE__ */ factory(name88, dependencies88, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2("filter", {
|
|
"Array, function": _filterCallback,
|
|
"Matrix, function": function MatrixFunction(x, test) {
|
|
return x.create(_filterCallback(x.toArray(), test));
|
|
},
|
|
"Array, RegExp": filterRegExp,
|
|
"Matrix, RegExp": function MatrixRegExp(x, test) {
|
|
return x.create(filterRegExp(x.toArray(), test));
|
|
}
|
|
});
|
|
});
|
|
function _filterCallback(x, callback) {
|
|
var args = maxArgumentCount(callback);
|
|
return filter(x, function(value, index2, array) {
|
|
if (args === 1) {
|
|
return callback(value);
|
|
} else if (args === 2) {
|
|
return callback(value, [index2]);
|
|
} else {
|
|
return callback(value, [index2], array);
|
|
}
|
|
});
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/flatten.js
|
|
var name89 = "flatten";
|
|
var dependencies89 = ["typed", "matrix"];
|
|
var createFlatten = /* @__PURE__ */ factory(name89, dependencies89, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2
|
|
} = _ref;
|
|
return typed2(name89, {
|
|
Array: function Array2(x) {
|
|
return flatten(x);
|
|
},
|
|
Matrix: function Matrix2(x) {
|
|
var flat = flatten(x.toArray());
|
|
return matrix2(flat);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/forEach.js
|
|
var name90 = "forEach";
|
|
var dependencies90 = ["typed"];
|
|
var createForEach = /* @__PURE__ */ factory(name90, dependencies90, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name90, {
|
|
"Array, function": _forEach,
|
|
"Matrix, function": function MatrixFunction(x, callback) {
|
|
x.forEach(callback);
|
|
}
|
|
});
|
|
});
|
|
function _forEach(array, callback) {
|
|
var args = maxArgumentCount(callback);
|
|
var recurse = function recurse2(value, index2) {
|
|
if (Array.isArray(value)) {
|
|
forEach(value, function(child, i2) {
|
|
recurse2(child, index2.concat(i2));
|
|
});
|
|
} else {
|
|
if (args === 1) {
|
|
callback(value);
|
|
} else if (args === 2) {
|
|
callback(value, index2);
|
|
} else {
|
|
callback(value, index2, array);
|
|
}
|
|
}
|
|
};
|
|
recurse(array, []);
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/getMatrixDataType.js
|
|
var name91 = "getMatrixDataType";
|
|
var dependencies91 = ["typed"];
|
|
var createGetMatrixDataType = /* @__PURE__ */ factory(name91, dependencies91, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name91, {
|
|
Array: function Array2(x) {
|
|
return getArrayDataType(x, typeOf);
|
|
},
|
|
Matrix: function Matrix2(x) {
|
|
return x.getDataType();
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/identity.js
|
|
var name92 = "identity";
|
|
var dependencies92 = ["typed", "config", "matrix", "BigNumber", "DenseMatrix", "SparseMatrix"];
|
|
var createIdentity = /* @__PURE__ */ factory(name92, dependencies92, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
matrix: matrix2,
|
|
BigNumber: BigNumber2,
|
|
DenseMatrix: DenseMatrix2,
|
|
SparseMatrix: SparseMatrix2
|
|
} = _ref;
|
|
return typed2(name92, {
|
|
"": function _() {
|
|
return config4.matrix === "Matrix" ? matrix2([]) : [];
|
|
},
|
|
string: function string2(format5) {
|
|
return matrix2(format5);
|
|
},
|
|
"number | BigNumber": function numberBigNumber(rows) {
|
|
return _identity(rows, rows, config4.matrix === "Matrix" ? "dense" : void 0);
|
|
},
|
|
"number | BigNumber, string": function numberBigNumberString(rows, format5) {
|
|
return _identity(rows, rows, format5);
|
|
},
|
|
"number | BigNumber, number | BigNumber": function numberBigNumberNumberBigNumber(rows, cols) {
|
|
return _identity(rows, cols, config4.matrix === "Matrix" ? "dense" : void 0);
|
|
},
|
|
"number | BigNumber, number | BigNumber, string": function numberBigNumberNumberBigNumberString(rows, cols, format5) {
|
|
return _identity(rows, cols, format5);
|
|
},
|
|
Array: function Array2(size2) {
|
|
return _identityVector(size2);
|
|
},
|
|
"Array, string": function ArrayString(size2, format5) {
|
|
return _identityVector(size2, format5);
|
|
},
|
|
Matrix: function Matrix2(size2) {
|
|
return _identityVector(size2.valueOf(), size2.storage());
|
|
},
|
|
"Matrix, string": function MatrixString(size2, format5) {
|
|
return _identityVector(size2.valueOf(), format5);
|
|
}
|
|
});
|
|
function _identityVector(size2, format5) {
|
|
switch (size2.length) {
|
|
case 0:
|
|
return format5 ? matrix2(format5) : [];
|
|
case 1:
|
|
return _identity(size2[0], size2[0], format5);
|
|
case 2:
|
|
return _identity(size2[0], size2[1], format5);
|
|
default:
|
|
throw new Error("Vector containing two values expected");
|
|
}
|
|
}
|
|
function _identity(rows, cols, format5) {
|
|
var Big = isBigNumber(rows) || isBigNumber(cols) ? BigNumber2 : null;
|
|
if (isBigNumber(rows))
|
|
rows = rows.toNumber();
|
|
if (isBigNumber(cols))
|
|
cols = cols.toNumber();
|
|
if (!isInteger(rows) || rows < 1) {
|
|
throw new Error("Parameters in function identity must be positive integers");
|
|
}
|
|
if (!isInteger(cols) || cols < 1) {
|
|
throw new Error("Parameters in function identity must be positive integers");
|
|
}
|
|
var one = Big ? new BigNumber2(1) : 1;
|
|
var defaultValue = Big ? new Big(0) : 0;
|
|
var size2 = [rows, cols];
|
|
if (format5) {
|
|
if (format5 === "sparse") {
|
|
return SparseMatrix2.diagonal(size2, one, 0, defaultValue);
|
|
}
|
|
if (format5 === "dense") {
|
|
return DenseMatrix2.diagonal(size2, one, 0, defaultValue);
|
|
}
|
|
throw new TypeError('Unknown matrix type "'.concat(format5, '"'));
|
|
}
|
|
var res = resize([], size2, defaultValue);
|
|
var minimum = rows < cols ? rows : cols;
|
|
for (var d = 0; d < minimum; d++) {
|
|
res[d][d] = one;
|
|
}
|
|
return res;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/kron.js
|
|
var name93 = "kron";
|
|
var dependencies93 = ["typed", "matrix", "multiplyScalar"];
|
|
var createKron = /* @__PURE__ */ factory(name93, dependencies93, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
multiplyScalar: multiplyScalar2
|
|
} = _ref;
|
|
return typed2(name93, {
|
|
"Matrix, Matrix": function MatrixMatrix(x, y) {
|
|
return matrix2(_kron(x.toArray(), y.toArray()));
|
|
},
|
|
"Matrix, Array": function MatrixArray(x, y) {
|
|
return matrix2(_kron(x.toArray(), y));
|
|
},
|
|
"Array, Matrix": function ArrayMatrix(x, y) {
|
|
return matrix2(_kron(x, y.toArray()));
|
|
},
|
|
"Array, Array": _kron
|
|
});
|
|
function _kron(a, b) {
|
|
if (arraySize(a).length === 1) {
|
|
a = [a];
|
|
}
|
|
if (arraySize(b).length === 1) {
|
|
b = [b];
|
|
}
|
|
if (arraySize(a).length > 2 || arraySize(b).length > 2) {
|
|
throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = " + JSON.stringify(a.length) + ", y = " + JSON.stringify(b.length) + ")");
|
|
}
|
|
var t = [];
|
|
var r = [];
|
|
return a.map(function(a2) {
|
|
return b.map(function(b2) {
|
|
r = [];
|
|
t.push(r);
|
|
return a2.map(function(y) {
|
|
return b2.map(function(x) {
|
|
return r.push(multiplyScalar2(y, x));
|
|
});
|
|
});
|
|
});
|
|
}) && t;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/map.js
|
|
var name94 = "map";
|
|
var dependencies94 = ["typed"];
|
|
var createMap2 = /* @__PURE__ */ factory(name94, dependencies94, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name94, {
|
|
"Array, function": _map,
|
|
"Matrix, function": function MatrixFunction(x, callback) {
|
|
return x.map(callback);
|
|
}
|
|
});
|
|
});
|
|
function _map(array, callback) {
|
|
var args = maxArgumentCount(callback);
|
|
var recurse = function recurse2(value, index2) {
|
|
if (Array.isArray(value)) {
|
|
return value.map(function(child, i2) {
|
|
return recurse2(child, index2.concat(i2));
|
|
});
|
|
} else {
|
|
try {
|
|
if (args === 1) {
|
|
return callback(value);
|
|
} else if (args === 2) {
|
|
return callback(value, index2);
|
|
} else {
|
|
return callback(value, index2, array);
|
|
}
|
|
} catch (err) {
|
|
if (err instanceof TypeError && "data" in err && err.data.category === "wrongType") {
|
|
var newmsg = "map attempted to call '".concat(err.data.fn, "(").concat(value);
|
|
var indexString = JSON.stringify(index2);
|
|
if (args === 2) {
|
|
newmsg += "," + indexString;
|
|
} else if (args !== 1) {
|
|
newmsg += ",".concat(indexString, ",").concat(array);
|
|
}
|
|
newmsg += ")' but argument ".concat(err.data.index + 1, " of type ");
|
|
newmsg += "".concat(err.data.actual, " does not match expected type ");
|
|
newmsg += err.data.expected.join(" or ");
|
|
throw new TypeError(newmsg);
|
|
}
|
|
throw err;
|
|
}
|
|
}
|
|
};
|
|
return recurse(array, []);
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/diff.js
|
|
var name95 = "diff";
|
|
var dependencies95 = ["typed", "matrix", "subtract", "number"];
|
|
var createDiff = /* @__PURE__ */ factory(name95, dependencies95, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
subtract: subtract2,
|
|
number: number2
|
|
} = _ref;
|
|
return typed2(name95, {
|
|
"Array | Matrix": function ArrayMatrix(arr) {
|
|
if (isMatrix(arr)) {
|
|
return matrix2(_diff(arr.toArray()));
|
|
} else {
|
|
return _diff(arr);
|
|
}
|
|
},
|
|
"Array | Matrix, number": function ArrayMatrixNumber(arr, dim) {
|
|
if (!isInteger(dim))
|
|
throw new RangeError("Dimension must be a whole number");
|
|
if (isMatrix(arr)) {
|
|
return matrix2(_recursive(arr.toArray(), dim));
|
|
} else {
|
|
return _recursive(arr, dim);
|
|
}
|
|
},
|
|
"Array, BigNumber": typed2.referTo("Array,number", (selfAn) => (arr, dim) => selfAn(arr, number2(dim))),
|
|
"Matrix, BigNumber": typed2.referTo("Matrix,number", (selfMn) => (arr, dim) => selfMn(arr, number2(dim)))
|
|
});
|
|
function _recursive(arr, dim) {
|
|
if (isMatrix(arr)) {
|
|
arr = arr.toArray();
|
|
}
|
|
if (!Array.isArray(arr)) {
|
|
throw RangeError("Array/Matrix does not have that many dimensions");
|
|
}
|
|
if (dim > 0) {
|
|
var result = [];
|
|
arr.forEach((element) => {
|
|
result.push(_recursive(element, dim - 1));
|
|
});
|
|
return result;
|
|
} else if (dim === 0) {
|
|
return _diff(arr);
|
|
} else {
|
|
throw RangeError("Cannot have negative dimension");
|
|
}
|
|
}
|
|
function _diff(arr) {
|
|
var result = [];
|
|
var size2 = arr.length;
|
|
for (var i2 = 1; i2 < size2; i2++) {
|
|
result.push(_ElementDiff(arr[i2 - 1], arr[i2]));
|
|
}
|
|
return result;
|
|
}
|
|
function _ElementDiff(obj1, obj2) {
|
|
if (isMatrix(obj1))
|
|
obj1 = obj1.toArray();
|
|
if (isMatrix(obj2))
|
|
obj2 = obj2.toArray();
|
|
var obj1IsArray = Array.isArray(obj1);
|
|
var obj2IsArray = Array.isArray(obj2);
|
|
if (obj1IsArray && obj2IsArray) {
|
|
return _ArrayDiff(obj1, obj2);
|
|
}
|
|
if (!obj1IsArray && !obj2IsArray) {
|
|
return subtract2(obj2, obj1);
|
|
}
|
|
throw TypeError("Cannot calculate difference between 1 array and 1 non-array");
|
|
}
|
|
function _ArrayDiff(arr1, arr2) {
|
|
if (arr1.length !== arr2.length) {
|
|
throw RangeError("Not all sub-arrays have the same length");
|
|
}
|
|
var result = [];
|
|
var size2 = arr1.length;
|
|
for (var i2 = 0; i2 < size2; i2++) {
|
|
result.push(_ElementDiff(arr1[i2], arr2[i2]));
|
|
}
|
|
return result;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/ones.js
|
|
var name96 = "ones";
|
|
var dependencies96 = ["typed", "config", "matrix", "BigNumber"];
|
|
var createOnes = /* @__PURE__ */ factory(name96, dependencies96, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
matrix: matrix2,
|
|
BigNumber: BigNumber2
|
|
} = _ref;
|
|
return typed2("ones", {
|
|
"": function _() {
|
|
return config4.matrix === "Array" ? _ones([]) : _ones([], "default");
|
|
},
|
|
"...number | BigNumber | string": function numberBigNumberString(size2) {
|
|
var last = size2[size2.length - 1];
|
|
if (typeof last === "string") {
|
|
var format5 = size2.pop();
|
|
return _ones(size2, format5);
|
|
} else if (config4.matrix === "Array") {
|
|
return _ones(size2);
|
|
} else {
|
|
return _ones(size2, "default");
|
|
}
|
|
},
|
|
Array: _ones,
|
|
Matrix: function Matrix2(size2) {
|
|
var format5 = size2.storage();
|
|
return _ones(size2.valueOf(), format5);
|
|
},
|
|
"Array | Matrix, string": function ArrayMatrixString(size2, format5) {
|
|
return _ones(size2.valueOf(), format5);
|
|
}
|
|
});
|
|
function _ones(size2, format5) {
|
|
var hasBigNumbers = _normalize(size2);
|
|
var defaultValue = hasBigNumbers ? new BigNumber2(1) : 1;
|
|
_validate2(size2);
|
|
if (format5) {
|
|
var m = matrix2(format5);
|
|
if (size2.length > 0) {
|
|
return m.resize(size2, defaultValue);
|
|
}
|
|
return m;
|
|
} else {
|
|
var arr = [];
|
|
if (size2.length > 0) {
|
|
return resize(arr, size2, defaultValue);
|
|
}
|
|
return arr;
|
|
}
|
|
}
|
|
function _normalize(size2) {
|
|
var hasBigNumbers = false;
|
|
size2.forEach(function(value, index2, arr) {
|
|
if (isBigNumber(value)) {
|
|
hasBigNumbers = true;
|
|
arr[index2] = value.toNumber();
|
|
}
|
|
});
|
|
return hasBigNumbers;
|
|
}
|
|
function _validate2(size2) {
|
|
size2.forEach(function(value) {
|
|
if (typeof value !== "number" || !isInteger(value) || value < 0) {
|
|
throw new Error("Parameters in function ones must be positive integers");
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/utils/noop.js
|
|
function noBignumber() {
|
|
throw new Error('No "bignumber" implementation available');
|
|
}
|
|
function noFraction() {
|
|
throw new Error('No "fraction" implementation available');
|
|
}
|
|
function noMatrix() {
|
|
throw new Error('No "matrix" implementation available');
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/range.js
|
|
var name97 = "range";
|
|
var dependencies97 = ["typed", "config", "?matrix", "?bignumber", "smaller", "smallerEq", "larger", "largerEq"];
|
|
var createRange = /* @__PURE__ */ factory(name97, dependencies97, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
matrix: matrix2,
|
|
bignumber: bignumber2,
|
|
smaller: smaller2,
|
|
smallerEq: smallerEq2,
|
|
larger: larger2,
|
|
largerEq: largerEq2
|
|
} = _ref;
|
|
return typed2(name97, {
|
|
string: _strRange,
|
|
"string, boolean": _strRange,
|
|
"number, number": function numberNumber(start, end) {
|
|
return _out(_rangeEx(start, end, 1));
|
|
},
|
|
"number, number, number": function numberNumberNumber(start, end, step) {
|
|
return _out(_rangeEx(start, end, step));
|
|
},
|
|
"number, number, boolean": function numberNumberBoolean(start, end, includeEnd) {
|
|
return includeEnd ? _out(_rangeInc(start, end, 1)) : _out(_rangeEx(start, end, 1));
|
|
},
|
|
"number, number, number, boolean": function numberNumberNumberBoolean(start, end, step, includeEnd) {
|
|
return includeEnd ? _out(_rangeInc(start, end, step)) : _out(_rangeEx(start, end, step));
|
|
},
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(start, end) {
|
|
var BigNumber2 = start.constructor;
|
|
return _out(_bigRangeEx(start, end, new BigNumber2(1)));
|
|
},
|
|
"BigNumber, BigNumber, BigNumber": function BigNumberBigNumberBigNumber(start, end, step) {
|
|
return _out(_bigRangeEx(start, end, step));
|
|
},
|
|
"BigNumber, BigNumber, boolean": function BigNumberBigNumberBoolean(start, end, includeEnd) {
|
|
var BigNumber2 = start.constructor;
|
|
return includeEnd ? _out(_bigRangeInc(start, end, new BigNumber2(1))) : _out(_bigRangeEx(start, end, new BigNumber2(1)));
|
|
},
|
|
"BigNumber, BigNumber, BigNumber, boolean": function BigNumberBigNumberBigNumberBoolean(start, end, step, includeEnd) {
|
|
return includeEnd ? _out(_bigRangeInc(start, end, step)) : _out(_bigRangeEx(start, end, step));
|
|
}
|
|
});
|
|
function _out(arr) {
|
|
if (config4.matrix === "Matrix") {
|
|
return matrix2 ? matrix2(arr) : noMatrix();
|
|
}
|
|
return arr;
|
|
}
|
|
function _strRange(str, includeEnd) {
|
|
var r = _parse(str);
|
|
if (!r) {
|
|
throw new SyntaxError('String "' + str + '" is no valid range');
|
|
}
|
|
var fn;
|
|
if (config4.number === "BigNumber") {
|
|
if (bignumber2 === void 0) {
|
|
noBignumber();
|
|
}
|
|
fn = includeEnd ? _bigRangeInc : _bigRangeEx;
|
|
return _out(fn(bignumber2(r.start), bignumber2(r.end), bignumber2(r.step)));
|
|
} else {
|
|
fn = includeEnd ? _rangeInc : _rangeEx;
|
|
return _out(fn(r.start, r.end, r.step));
|
|
}
|
|
}
|
|
function _rangeEx(start, end, step) {
|
|
var array = [];
|
|
var x = start;
|
|
if (step > 0) {
|
|
while (smaller2(x, end)) {
|
|
array.push(x);
|
|
x += step;
|
|
}
|
|
} else if (step < 0) {
|
|
while (larger2(x, end)) {
|
|
array.push(x);
|
|
x += step;
|
|
}
|
|
}
|
|
return array;
|
|
}
|
|
function _rangeInc(start, end, step) {
|
|
var array = [];
|
|
var x = start;
|
|
if (step > 0) {
|
|
while (smallerEq2(x, end)) {
|
|
array.push(x);
|
|
x += step;
|
|
}
|
|
} else if (step < 0) {
|
|
while (largerEq2(x, end)) {
|
|
array.push(x);
|
|
x += step;
|
|
}
|
|
}
|
|
return array;
|
|
}
|
|
function _bigRangeEx(start, end, step) {
|
|
var zero = bignumber2(0);
|
|
var array = [];
|
|
var x = start;
|
|
if (step.gt(zero)) {
|
|
while (smaller2(x, end)) {
|
|
array.push(x);
|
|
x = x.plus(step);
|
|
}
|
|
} else if (step.lt(zero)) {
|
|
while (larger2(x, end)) {
|
|
array.push(x);
|
|
x = x.plus(step);
|
|
}
|
|
}
|
|
return array;
|
|
}
|
|
function _bigRangeInc(start, end, step) {
|
|
var zero = bignumber2(0);
|
|
var array = [];
|
|
var x = start;
|
|
if (step.gt(zero)) {
|
|
while (smallerEq2(x, end)) {
|
|
array.push(x);
|
|
x = x.plus(step);
|
|
}
|
|
} else if (step.lt(zero)) {
|
|
while (largerEq2(x, end)) {
|
|
array.push(x);
|
|
x = x.plus(step);
|
|
}
|
|
}
|
|
return array;
|
|
}
|
|
function _parse(str) {
|
|
var args = str.split(":");
|
|
var nums = args.map(function(arg2) {
|
|
return Number(arg2);
|
|
});
|
|
var invalid = nums.some(function(num) {
|
|
return isNaN(num);
|
|
});
|
|
if (invalid) {
|
|
return null;
|
|
}
|
|
switch (nums.length) {
|
|
case 2:
|
|
return {
|
|
start: nums[0],
|
|
end: nums[1],
|
|
step: 1
|
|
};
|
|
case 3:
|
|
return {
|
|
start: nums[0],
|
|
end: nums[2],
|
|
step: nums[1]
|
|
};
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/reshape.js
|
|
var name98 = "reshape";
|
|
var dependencies98 = ["typed", "isInteger", "matrix"];
|
|
var createReshape = /* @__PURE__ */ factory(name98, dependencies98, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
isInteger: isInteger3
|
|
} = _ref;
|
|
return typed2(name98, {
|
|
"Matrix, Array": function MatrixArray(x, sizes) {
|
|
return x.reshape(sizes, true);
|
|
},
|
|
"Array, Array": function ArrayArray(x, sizes) {
|
|
sizes.forEach(function(size2) {
|
|
if (!isInteger3(size2)) {
|
|
throw new TypeError("Invalid size for dimension: " + size2);
|
|
}
|
|
});
|
|
return reshape(x, sizes);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/error/ArgumentsError.js
|
|
function ArgumentsError(fn, count2, min3, max3) {
|
|
if (!(this instanceof ArgumentsError)) {
|
|
throw new SyntaxError("Constructor must be called with the new operator");
|
|
}
|
|
this.fn = fn;
|
|
this.count = count2;
|
|
this.min = min3;
|
|
this.max = max3;
|
|
this.message = "Wrong number of arguments in function " + fn + " (" + count2 + " provided, " + min3 + (max3 !== void 0 && max3 !== null ? "-" + max3 : "") + " expected)";
|
|
this.stack = new Error().stack;
|
|
}
|
|
ArgumentsError.prototype = new Error();
|
|
ArgumentsError.prototype.constructor = Error;
|
|
ArgumentsError.prototype.name = "ArgumentsError";
|
|
ArgumentsError.prototype.isArgumentsError = true;
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/resize.js
|
|
var name99 = "resize";
|
|
var dependencies99 = ["config", "matrix"];
|
|
var createResize = /* @__PURE__ */ factory(name99, dependencies99, (_ref) => {
|
|
var {
|
|
config: config4,
|
|
matrix: matrix2
|
|
} = _ref;
|
|
return function resize3(x, size2, defaultValue) {
|
|
if (arguments.length !== 2 && arguments.length !== 3) {
|
|
throw new ArgumentsError("resize", arguments.length, 2, 3);
|
|
}
|
|
if (isMatrix(size2)) {
|
|
size2 = size2.valueOf();
|
|
}
|
|
if (isBigNumber(size2[0])) {
|
|
size2 = size2.map(function(value) {
|
|
return !isBigNumber(value) ? value : value.toNumber();
|
|
});
|
|
}
|
|
if (isMatrix(x)) {
|
|
return x.resize(size2, defaultValue, true);
|
|
}
|
|
if (typeof x === "string") {
|
|
return _resizeString(x, size2, defaultValue);
|
|
}
|
|
var asMatrix = Array.isArray(x) ? false : config4.matrix !== "Array";
|
|
if (size2.length === 0) {
|
|
while (Array.isArray(x)) {
|
|
x = x[0];
|
|
}
|
|
return clone(x);
|
|
} else {
|
|
if (!Array.isArray(x)) {
|
|
x = [x];
|
|
}
|
|
x = clone(x);
|
|
var res = resize(x, size2, defaultValue);
|
|
return asMatrix ? matrix2(res) : res;
|
|
}
|
|
};
|
|
function _resizeString(str, size2, defaultChar) {
|
|
if (defaultChar !== void 0) {
|
|
if (typeof defaultChar !== "string" || defaultChar.length !== 1) {
|
|
throw new TypeError("Single character expected as defaultValue");
|
|
}
|
|
} else {
|
|
defaultChar = " ";
|
|
}
|
|
if (size2.length !== 1) {
|
|
throw new DimensionError(size2.length, 1);
|
|
}
|
|
var len = size2[0];
|
|
if (typeof len !== "number" || !isInteger(len)) {
|
|
throw new TypeError("Invalid size, must contain positive integers (size: " + format3(size2) + ")");
|
|
}
|
|
if (str.length > len) {
|
|
return str.substring(0, len);
|
|
} else if (str.length < len) {
|
|
var res = str;
|
|
for (var i2 = 0, ii = len - str.length; i2 < ii; i2++) {
|
|
res += defaultChar;
|
|
}
|
|
return res;
|
|
} else {
|
|
return str;
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/rotate.js
|
|
var name100 = "rotate";
|
|
var dependencies100 = ["typed", "multiply", "rotationMatrix"];
|
|
var createRotate = /* @__PURE__ */ factory(name100, dependencies100, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
multiply: multiply2,
|
|
rotationMatrix: rotationMatrix2
|
|
} = _ref;
|
|
return typed2(name100, {
|
|
"Array , number | BigNumber | Complex | Unit": function ArrayNumberBigNumberComplexUnit(w, theta) {
|
|
_validateSize(w, 2);
|
|
var matrixRes = multiply2(rotationMatrix2(theta), w);
|
|
return matrixRes.toArray();
|
|
},
|
|
"Matrix , number | BigNumber | Complex | Unit": function MatrixNumberBigNumberComplexUnit(w, theta) {
|
|
_validateSize(w, 2);
|
|
return multiply2(rotationMatrix2(theta), w);
|
|
},
|
|
"Array, number | BigNumber | Complex | Unit, Array | Matrix": function ArrayNumberBigNumberComplexUnitArrayMatrix(w, theta, v) {
|
|
_validateSize(w, 3);
|
|
var matrixRes = multiply2(rotationMatrix2(theta, v), w);
|
|
return matrixRes;
|
|
},
|
|
"Matrix, number | BigNumber | Complex | Unit, Array | Matrix": function MatrixNumberBigNumberComplexUnitArrayMatrix(w, theta, v) {
|
|
_validateSize(w, 3);
|
|
return multiply2(rotationMatrix2(theta, v), w);
|
|
}
|
|
});
|
|
function _validateSize(v, expectedSize) {
|
|
var actualSize = Array.isArray(v) ? arraySize(v) : v.size();
|
|
if (actualSize.length > 2) {
|
|
throw new RangeError("Vector must be of dimensions 1x".concat(expectedSize));
|
|
}
|
|
if (actualSize.length === 2 && actualSize[1] !== 1) {
|
|
throw new RangeError("Vector must be of dimensions 1x".concat(expectedSize));
|
|
}
|
|
if (actualSize[0] !== expectedSize) {
|
|
throw new RangeError("Vector must be of dimensions 1x".concat(expectedSize));
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/rotationMatrix.js
|
|
var name101 = "rotationMatrix";
|
|
var dependencies101 = ["typed", "config", "multiplyScalar", "addScalar", "unaryMinus", "norm", "matrix", "BigNumber", "DenseMatrix", "SparseMatrix", "cos", "sin"];
|
|
var createRotationMatrix = /* @__PURE__ */ factory(name101, dependencies101, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
multiplyScalar: multiplyScalar2,
|
|
addScalar: addScalar2,
|
|
unaryMinus: unaryMinus2,
|
|
norm: norm2,
|
|
BigNumber: BigNumber2,
|
|
matrix: matrix2,
|
|
DenseMatrix: DenseMatrix2,
|
|
SparseMatrix: SparseMatrix2,
|
|
cos: cos3,
|
|
sin: sin3
|
|
} = _ref;
|
|
return typed2(name101, {
|
|
"": function _() {
|
|
return config4.matrix === "Matrix" ? matrix2([]) : [];
|
|
},
|
|
string: function string2(format5) {
|
|
return matrix2(format5);
|
|
},
|
|
"number | BigNumber | Complex | Unit": function numberBigNumberComplexUnit(theta) {
|
|
return _rotationMatrix2x2(theta, config4.matrix === "Matrix" ? "dense" : void 0);
|
|
},
|
|
"number | BigNumber | Complex | Unit, string": function numberBigNumberComplexUnitString(theta, format5) {
|
|
return _rotationMatrix2x2(theta, format5);
|
|
},
|
|
"number | BigNumber | Complex | Unit, Array": function numberBigNumberComplexUnitArray(theta, v) {
|
|
var matrixV = matrix2(v);
|
|
_validateVector(matrixV);
|
|
return _rotationMatrix3x3(theta, matrixV, void 0);
|
|
},
|
|
"number | BigNumber | Complex | Unit, Matrix": function numberBigNumberComplexUnitMatrix(theta, v) {
|
|
_validateVector(v);
|
|
var storageType = v.storage() || (config4.matrix === "Matrix" ? "dense" : void 0);
|
|
return _rotationMatrix3x3(theta, v, storageType);
|
|
},
|
|
"number | BigNumber | Complex | Unit, Array, string": function numberBigNumberComplexUnitArrayString(theta, v, format5) {
|
|
var matrixV = matrix2(v);
|
|
_validateVector(matrixV);
|
|
return _rotationMatrix3x3(theta, matrixV, format5);
|
|
},
|
|
"number | BigNumber | Complex | Unit, Matrix, string": function numberBigNumberComplexUnitMatrixString(theta, v, format5) {
|
|
_validateVector(v);
|
|
return _rotationMatrix3x3(theta, v, format5);
|
|
}
|
|
});
|
|
function _rotationMatrix2x2(theta, format5) {
|
|
var Big = isBigNumber(theta);
|
|
var minusOne = Big ? new BigNumber2(-1) : -1;
|
|
var cosTheta = cos3(theta);
|
|
var sinTheta = sin3(theta);
|
|
var data = [[cosTheta, multiplyScalar2(minusOne, sinTheta)], [sinTheta, cosTheta]];
|
|
return _convertToFormat(data, format5);
|
|
}
|
|
function _validateVector(v) {
|
|
var size2 = v.size();
|
|
if (size2.length < 1 || size2[0] !== 3) {
|
|
throw new RangeError("Vector must be of dimensions 1x3");
|
|
}
|
|
}
|
|
function _mul(array) {
|
|
return array.reduce((p, curr) => multiplyScalar2(p, curr));
|
|
}
|
|
function _convertToFormat(data, format5) {
|
|
if (format5) {
|
|
if (format5 === "sparse") {
|
|
return new SparseMatrix2(data);
|
|
}
|
|
if (format5 === "dense") {
|
|
return new DenseMatrix2(data);
|
|
}
|
|
throw new TypeError('Unknown matrix type "'.concat(format5, '"'));
|
|
}
|
|
return data;
|
|
}
|
|
function _rotationMatrix3x3(theta, v, format5) {
|
|
var normV = norm2(v);
|
|
if (normV === 0) {
|
|
throw new RangeError("Rotation around zero vector");
|
|
}
|
|
var Big = isBigNumber(theta) ? BigNumber2 : null;
|
|
var one = Big ? new Big(1) : 1;
|
|
var minusOne = Big ? new Big(-1) : -1;
|
|
var vx = Big ? new Big(v.get([0]) / normV) : v.get([0]) / normV;
|
|
var vy = Big ? new Big(v.get([1]) / normV) : v.get([1]) / normV;
|
|
var vz = Big ? new Big(v.get([2]) / normV) : v.get([2]) / normV;
|
|
var c = cos3(theta);
|
|
var oneMinusC = addScalar2(one, unaryMinus2(c));
|
|
var s = sin3(theta);
|
|
var r11 = addScalar2(c, _mul([vx, vx, oneMinusC]));
|
|
var r12 = addScalar2(_mul([vx, vy, oneMinusC]), _mul([minusOne, vz, s]));
|
|
var r13 = addScalar2(_mul([vx, vz, oneMinusC]), _mul([vy, s]));
|
|
var r21 = addScalar2(_mul([vx, vy, oneMinusC]), _mul([vz, s]));
|
|
var r22 = addScalar2(c, _mul([vy, vy, oneMinusC]));
|
|
var r23 = addScalar2(_mul([vy, vz, oneMinusC]), _mul([minusOne, vx, s]));
|
|
var r31 = addScalar2(_mul([vx, vz, oneMinusC]), _mul([minusOne, vy, s]));
|
|
var r32 = addScalar2(_mul([vy, vz, oneMinusC]), _mul([vx, s]));
|
|
var r33 = addScalar2(c, _mul([vz, vz, oneMinusC]));
|
|
var data = [[r11, r12, r13], [r21, r22, r23], [r31, r32, r33]];
|
|
return _convertToFormat(data, format5);
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/row.js
|
|
var name102 = "row";
|
|
var dependencies102 = ["typed", "Index", "matrix", "range"];
|
|
var createRow = /* @__PURE__ */ factory(name102, dependencies102, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
Index: Index2,
|
|
matrix: matrix2,
|
|
range: range2
|
|
} = _ref;
|
|
return typed2(name102, {
|
|
"Matrix, number": _row,
|
|
"Array, number": function ArrayNumber(value, row2) {
|
|
return _row(matrix2(clone(value)), row2).valueOf();
|
|
}
|
|
});
|
|
function _row(value, row2) {
|
|
if (value.size().length !== 2) {
|
|
throw new Error("Only two dimensional matrix is supported");
|
|
}
|
|
validateIndex(row2, value.size()[0]);
|
|
var columnRange = range2(0, value.size()[1]);
|
|
var index2 = new Index2(row2, columnRange);
|
|
var result = value.subset(index2);
|
|
return isMatrix(result) ? result : matrix2([[result]]);
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/size.js
|
|
var name103 = "size";
|
|
var dependencies103 = ["typed", "config", "?matrix"];
|
|
var createSize = /* @__PURE__ */ factory(name103, dependencies103, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
matrix: matrix2
|
|
} = _ref;
|
|
return typed2(name103, {
|
|
Matrix: function Matrix2(x) {
|
|
return x.create(x.size());
|
|
},
|
|
Array: arraySize,
|
|
string: function string2(x) {
|
|
return config4.matrix === "Array" ? [x.length] : matrix2([x.length]);
|
|
},
|
|
"number | Complex | BigNumber | Unit | boolean | null": function numberComplexBigNumberUnitBooleanNull(x) {
|
|
return config4.matrix === "Array" ? [] : matrix2 ? matrix2([]) : noMatrix();
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/squeeze.js
|
|
var name104 = "squeeze";
|
|
var dependencies104 = ["typed", "matrix"];
|
|
var createSqueeze = /* @__PURE__ */ factory(name104, dependencies104, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2
|
|
} = _ref;
|
|
return typed2(name104, {
|
|
Array: function Array2(x) {
|
|
return squeeze(clone(x));
|
|
},
|
|
Matrix: function Matrix2(x) {
|
|
var res = squeeze(x.toArray());
|
|
return Array.isArray(res) ? matrix2(res) : res;
|
|
},
|
|
any: function any(x) {
|
|
return clone(x);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/subset.js
|
|
var name105 = "subset";
|
|
var dependencies105 = ["typed", "matrix"];
|
|
var createSubset = /* @__PURE__ */ factory(name105, dependencies105, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2
|
|
} = _ref;
|
|
return typed2(name105, {
|
|
"Array, Index": function ArrayIndex(value, index2) {
|
|
var m = matrix2(value);
|
|
var subset2 = m.subset(index2);
|
|
return index2.isScalar() ? subset2 : subset2.valueOf();
|
|
},
|
|
"Matrix, Index": function MatrixIndex(value, index2) {
|
|
return value.subset(index2);
|
|
},
|
|
"Object, Index": _getObjectProperty,
|
|
"string, Index": _getSubstring,
|
|
"Array, Index, any": function ArrayIndexAny(value, index2, replacement) {
|
|
return matrix2(clone(value)).subset(index2, replacement, void 0).valueOf();
|
|
},
|
|
"Array, Index, any, any": function ArrayIndexAnyAny(value, index2, replacement, defaultValue) {
|
|
return matrix2(clone(value)).subset(index2, replacement, defaultValue).valueOf();
|
|
},
|
|
"Matrix, Index, any": function MatrixIndexAny(value, index2, replacement) {
|
|
return value.clone().subset(index2, replacement);
|
|
},
|
|
"Matrix, Index, any, any": function MatrixIndexAnyAny(value, index2, replacement, defaultValue) {
|
|
return value.clone().subset(index2, replacement, defaultValue);
|
|
},
|
|
"string, Index, string": _setSubstring,
|
|
"string, Index, string, string": _setSubstring,
|
|
"Object, Index, any": _setObjectProperty
|
|
});
|
|
});
|
|
function _getSubstring(str, index2) {
|
|
if (!isIndex(index2)) {
|
|
throw new TypeError("Index expected");
|
|
}
|
|
if (index2.size().length !== 1) {
|
|
throw new DimensionError(index2.size().length, 1);
|
|
}
|
|
var strLen = str.length;
|
|
validateIndex(index2.min()[0], strLen);
|
|
validateIndex(index2.max()[0], strLen);
|
|
var range2 = index2.dimension(0);
|
|
var substr = "";
|
|
range2.forEach(function(v) {
|
|
substr += str.charAt(v);
|
|
});
|
|
return substr;
|
|
}
|
|
function _setSubstring(str, index2, replacement, defaultValue) {
|
|
if (!index2 || index2.isIndex !== true) {
|
|
throw new TypeError("Index expected");
|
|
}
|
|
if (index2.size().length !== 1) {
|
|
throw new DimensionError(index2.size().length, 1);
|
|
}
|
|
if (defaultValue !== void 0) {
|
|
if (typeof defaultValue !== "string" || defaultValue.length !== 1) {
|
|
throw new TypeError("Single character expected as defaultValue");
|
|
}
|
|
} else {
|
|
defaultValue = " ";
|
|
}
|
|
var range2 = index2.dimension(0);
|
|
var len = range2.size()[0];
|
|
if (len !== replacement.length) {
|
|
throw new DimensionError(range2.size()[0], replacement.length);
|
|
}
|
|
var strLen = str.length;
|
|
validateIndex(index2.min()[0]);
|
|
validateIndex(index2.max()[0]);
|
|
var chars = [];
|
|
for (var i2 = 0; i2 < strLen; i2++) {
|
|
chars[i2] = str.charAt(i2);
|
|
}
|
|
range2.forEach(function(v, i3) {
|
|
chars[v] = replacement.charAt(i3[0]);
|
|
});
|
|
if (chars.length > strLen) {
|
|
for (var _i = strLen - 1, _len = chars.length; _i < _len; _i++) {
|
|
if (!chars[_i]) {
|
|
chars[_i] = defaultValue;
|
|
}
|
|
}
|
|
}
|
|
return chars.join("");
|
|
}
|
|
function _getObjectProperty(object, index2) {
|
|
if (index2.size().length !== 1) {
|
|
throw new DimensionError(index2.size(), 1);
|
|
}
|
|
var key = index2.dimension(0);
|
|
if (typeof key !== "string") {
|
|
throw new TypeError("String expected as index to retrieve an object property");
|
|
}
|
|
return getSafeProperty(object, key);
|
|
}
|
|
function _setObjectProperty(object, index2, replacement) {
|
|
if (index2.size().length !== 1) {
|
|
throw new DimensionError(index2.size(), 1);
|
|
}
|
|
var key = index2.dimension(0);
|
|
if (typeof key !== "string") {
|
|
throw new TypeError("String expected as index to retrieve an object property");
|
|
}
|
|
var updated = clone(object);
|
|
setSafeProperty(updated, key, replacement);
|
|
return updated;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/transpose.js
|
|
var name106 = "transpose";
|
|
var dependencies106 = ["typed", "matrix"];
|
|
var createTranspose = /* @__PURE__ */ factory(name106, dependencies106, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2
|
|
} = _ref;
|
|
return typed2(name106, {
|
|
Array: (x) => transposeMatrix(matrix2(x)).valueOf(),
|
|
Matrix: transposeMatrix,
|
|
any: clone
|
|
});
|
|
function transposeMatrix(x) {
|
|
var size2 = x.size();
|
|
var c;
|
|
switch (size2.length) {
|
|
case 1:
|
|
c = x.clone();
|
|
break;
|
|
case 2:
|
|
{
|
|
var rows = size2[0];
|
|
var columns = size2[1];
|
|
if (columns === 0) {
|
|
throw new RangeError("Cannot transpose a 2D matrix with no columns (size: " + format3(size2) + ")");
|
|
}
|
|
switch (x.storage()) {
|
|
case "dense":
|
|
c = _denseTranspose(x, rows, columns);
|
|
break;
|
|
case "sparse":
|
|
c = _sparseTranspose(x, rows, columns);
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
throw new RangeError("Matrix must be a vector or two dimensional (size: " + format3(size2) + ")");
|
|
}
|
|
return c;
|
|
}
|
|
function _denseTranspose(m, rows, columns) {
|
|
var data = m._data;
|
|
var transposed = [];
|
|
var transposedRow;
|
|
for (var j = 0; j < columns; j++) {
|
|
transposedRow = transposed[j] = [];
|
|
for (var i2 = 0; i2 < rows; i2++) {
|
|
transposedRow[i2] = clone(data[i2][j]);
|
|
}
|
|
}
|
|
return m.createDenseMatrix({
|
|
data: transposed,
|
|
size: [columns, rows],
|
|
datatype: m._datatype
|
|
});
|
|
}
|
|
function _sparseTranspose(m, rows, columns) {
|
|
var values = m._values;
|
|
var index2 = m._index;
|
|
var ptr = m._ptr;
|
|
var cvalues = values ? [] : void 0;
|
|
var cindex = [];
|
|
var cptr = [];
|
|
var w = [];
|
|
for (var x = 0; x < rows; x++) {
|
|
w[x] = 0;
|
|
}
|
|
var p, l, j;
|
|
for (p = 0, l = index2.length; p < l; p++) {
|
|
w[index2[p]]++;
|
|
}
|
|
var sum3 = 0;
|
|
for (var i2 = 0; i2 < rows; i2++) {
|
|
cptr.push(sum3);
|
|
sum3 += w[i2];
|
|
w[i2] = cptr[i2];
|
|
}
|
|
cptr.push(sum3);
|
|
for (j = 0; j < columns; j++) {
|
|
for (var k0 = ptr[j], k1 = ptr[j + 1], k = k0; k < k1; k++) {
|
|
var q = w[index2[k]]++;
|
|
cindex[q] = j;
|
|
if (values) {
|
|
cvalues[q] = clone(values[k]);
|
|
}
|
|
}
|
|
}
|
|
return m.createSparseMatrix({
|
|
values: cvalues,
|
|
index: cindex,
|
|
ptr: cptr,
|
|
size: [columns, rows],
|
|
datatype: m._datatype
|
|
});
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/ctranspose.js
|
|
var name107 = "ctranspose";
|
|
var dependencies107 = ["typed", "transpose", "conj"];
|
|
var createCtranspose = /* @__PURE__ */ factory(name107, dependencies107, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
transpose: transpose2,
|
|
conj: conj2
|
|
} = _ref;
|
|
return typed2(name107, {
|
|
any: function any(x) {
|
|
return conj2(transpose2(x));
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/zeros.js
|
|
var name108 = "zeros";
|
|
var dependencies108 = ["typed", "config", "matrix", "BigNumber"];
|
|
var createZeros = /* @__PURE__ */ factory(name108, dependencies108, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
matrix: matrix2,
|
|
BigNumber: BigNumber2
|
|
} = _ref;
|
|
return typed2(name108, {
|
|
"": function _() {
|
|
return config4.matrix === "Array" ? _zeros([]) : _zeros([], "default");
|
|
},
|
|
"...number | BigNumber | string": function numberBigNumberString(size2) {
|
|
var last = size2[size2.length - 1];
|
|
if (typeof last === "string") {
|
|
var format5 = size2.pop();
|
|
return _zeros(size2, format5);
|
|
} else if (config4.matrix === "Array") {
|
|
return _zeros(size2);
|
|
} else {
|
|
return _zeros(size2, "default");
|
|
}
|
|
},
|
|
Array: _zeros,
|
|
Matrix: function Matrix2(size2) {
|
|
var format5 = size2.storage();
|
|
return _zeros(size2.valueOf(), format5);
|
|
},
|
|
"Array | Matrix, string": function ArrayMatrixString(size2, format5) {
|
|
return _zeros(size2.valueOf(), format5);
|
|
}
|
|
});
|
|
function _zeros(size2, format5) {
|
|
var hasBigNumbers = _normalize(size2);
|
|
var defaultValue = hasBigNumbers ? new BigNumber2(0) : 0;
|
|
_validate2(size2);
|
|
if (format5) {
|
|
var m = matrix2(format5);
|
|
if (size2.length > 0) {
|
|
return m.resize(size2, defaultValue);
|
|
}
|
|
return m;
|
|
} else {
|
|
var arr = [];
|
|
if (size2.length > 0) {
|
|
return resize(arr, size2, defaultValue);
|
|
}
|
|
return arr;
|
|
}
|
|
}
|
|
function _normalize(size2) {
|
|
var hasBigNumbers = false;
|
|
size2.forEach(function(value, index2, arr) {
|
|
if (isBigNumber(value)) {
|
|
hasBigNumbers = true;
|
|
arr[index2] = value.toNumber();
|
|
}
|
|
});
|
|
return hasBigNumbers;
|
|
}
|
|
function _validate2(size2) {
|
|
size2.forEach(function(value) {
|
|
if (typeof value !== "number" || !isInteger(value) || value < 0) {
|
|
throw new Error("Parameters in function zeros must be positive integers");
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/fft.js
|
|
var name109 = "fft";
|
|
var dependencies109 = ["typed", "matrix", "addScalar", "multiplyScalar", "divideScalar", "exp", "tau", "i", "dotDivide", "conj", "pow", "ceil", "log2"];
|
|
var createFft = /* @__PURE__ */ factory(name109, dependencies109, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
addScalar: addScalar2,
|
|
multiplyScalar: multiplyScalar2,
|
|
divideScalar: divideScalar2,
|
|
exp: exp3,
|
|
tau: tau3,
|
|
i: I,
|
|
dotDivide: dotDivide2,
|
|
conj: conj2,
|
|
pow: pow3,
|
|
ceil: ceil3,
|
|
log2: log25
|
|
} = _ref;
|
|
return typed2(name109, {
|
|
Array: _ndFft,
|
|
Matrix: function Matrix2(matrix3) {
|
|
return matrix3.create(_ndFft(matrix3.toArray()));
|
|
}
|
|
});
|
|
function _ndFft(arr) {
|
|
var size2 = arraySize(arr);
|
|
if (size2.length === 1)
|
|
return _fft(arr, size2[0]);
|
|
return _1dFft(arr.map((slice) => _ndFft(slice, size2.slice(1))), 0);
|
|
}
|
|
function _1dFft(arr, dim) {
|
|
var size2 = arraySize(arr);
|
|
if (dim !== 0)
|
|
return new Array(size2[0]).fill(0).map((_, i2) => _1dFft(arr[i2], dim - 1));
|
|
if (size2.length === 1)
|
|
return _fft(arr);
|
|
function _transpose(arr2) {
|
|
var size3 = arraySize(arr2);
|
|
return new Array(size3[1]).fill(0).map((_, j) => new Array(size3[0]).fill(0).map((_2, i2) => arr2[i2][j]));
|
|
}
|
|
return _transpose(_1dFft(_transpose(arr), 1));
|
|
}
|
|
function _czt(arr) {
|
|
var n = arr.length;
|
|
var w = exp3(divideScalar2(multiplyScalar2(-1, multiplyScalar2(I, tau3)), n));
|
|
var chirp = [];
|
|
for (var i2 = 1 - n; i2 < n; i2++) {
|
|
chirp.push(pow3(w, divideScalar2(pow3(i2, 2), 2)));
|
|
}
|
|
var N2 = pow3(2, ceil3(log25(n + n - 1)));
|
|
var xp = [...new Array(n).fill(0).map((_, i3) => multiplyScalar2(arr[i3], chirp[n - 1 + i3])), ...new Array(N2 - n).fill(0)];
|
|
var ichirp = [...new Array(n + n - 1).fill(0).map((_, i3) => divideScalar2(1, chirp[i3])), ...new Array(N2 - (n + n - 1)).fill(0)];
|
|
var fftXp = _fft(xp);
|
|
var fftIchirp = _fft(ichirp);
|
|
var fftProduct = new Array(N2).fill(0).map((_, i3) => multiplyScalar2(fftXp[i3], fftIchirp[i3]));
|
|
var ifftProduct = dotDivide2(conj2(_ndFft(conj2(fftProduct))), N2);
|
|
var ret = [];
|
|
for (var _i = n - 1; _i < n + n - 1; _i++) {
|
|
ret.push(multiplyScalar2(ifftProduct[_i], chirp[_i]));
|
|
}
|
|
return ret;
|
|
}
|
|
function _fft(arr) {
|
|
var len = arr.length;
|
|
if (len === 1)
|
|
return [arr[0]];
|
|
if (len % 2 === 0) {
|
|
var ret = [..._fft(arr.filter((_, i2) => i2 % 2 === 0), len / 2), ..._fft(arr.filter((_, i2) => i2 % 2 === 1), len / 2)];
|
|
for (var k = 0; k < len / 2; k++) {
|
|
var p = ret[k];
|
|
var q = multiplyScalar2(ret[k + len / 2], exp3(multiplyScalar2(multiplyScalar2(tau3, I), divideScalar2(-k, len))));
|
|
ret[k] = addScalar2(p, q);
|
|
ret[k + len / 2] = addScalar2(p, multiplyScalar2(-1, q));
|
|
}
|
|
return ret;
|
|
} else {
|
|
return _czt(arr);
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/ifft.js
|
|
var name110 = "ifft";
|
|
var dependencies110 = ["typed", "fft", "dotDivide", "conj"];
|
|
var createIfft = /* @__PURE__ */ factory(name110, dependencies110, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
fft: fft2,
|
|
dotDivide: dotDivide2,
|
|
conj: conj2
|
|
} = _ref;
|
|
return typed2(name110, {
|
|
"Array | Matrix": function ArrayMatrix(arr) {
|
|
var size2 = isMatrix(arr) ? arr.size() : arraySize(arr);
|
|
return dotDivide2(conj2(fft2(conj2(arr))), size2.reduce((acc, curr) => acc * curr, 1));
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/special/erf.js
|
|
var name111 = "erf";
|
|
var dependencies111 = ["typed"];
|
|
var createErf = /* @__PURE__ */ factory(name111, dependencies111, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2("name", {
|
|
number: function number2(x) {
|
|
var y = Math.abs(x);
|
|
if (y >= MAX_NUM) {
|
|
return sign(x);
|
|
}
|
|
if (y <= THRESH) {
|
|
return sign(x) * erf1(y);
|
|
}
|
|
if (y <= 4) {
|
|
return sign(x) * (1 - erfc2(y));
|
|
}
|
|
return sign(x) * (1 - erfc3(y));
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (n) => deepMap(n, self2))
|
|
});
|
|
function erf1(y) {
|
|
var ysq = y * y;
|
|
var xnum = P2[0][4] * ysq;
|
|
var xden = ysq;
|
|
var i2;
|
|
for (i2 = 0; i2 < 3; i2 += 1) {
|
|
xnum = (xnum + P2[0][i2]) * ysq;
|
|
xden = (xden + Q[0][i2]) * ysq;
|
|
}
|
|
return y * (xnum + P2[0][3]) / (xden + Q[0][3]);
|
|
}
|
|
function erfc2(y) {
|
|
var xnum = P2[1][8] * y;
|
|
var xden = y;
|
|
var i2;
|
|
for (i2 = 0; i2 < 7; i2 += 1) {
|
|
xnum = (xnum + P2[1][i2]) * y;
|
|
xden = (xden + Q[1][i2]) * y;
|
|
}
|
|
var result = (xnum + P2[1][7]) / (xden + Q[1][7]);
|
|
var ysq = parseInt(y * 16) / 16;
|
|
var del = (y - ysq) * (y + ysq);
|
|
return Math.exp(-ysq * ysq) * Math.exp(-del) * result;
|
|
}
|
|
function erfc3(y) {
|
|
var ysq = 1 / (y * y);
|
|
var xnum = P2[2][5] * ysq;
|
|
var xden = ysq;
|
|
var i2;
|
|
for (i2 = 0; i2 < 4; i2 += 1) {
|
|
xnum = (xnum + P2[2][i2]) * ysq;
|
|
xden = (xden + Q[2][i2]) * ysq;
|
|
}
|
|
var result = ysq * (xnum + P2[2][4]) / (xden + Q[2][4]);
|
|
result = (SQRPI - result) / y;
|
|
ysq = parseInt(y * 16) / 16;
|
|
var del = (y - ysq) * (y + ysq);
|
|
return Math.exp(-ysq * ysq) * Math.exp(-del) * result;
|
|
}
|
|
});
|
|
var THRESH = 0.46875;
|
|
var SQRPI = 0.5641895835477563;
|
|
var P2 = [[3.1611237438705655, 113.86415415105016, 377.485237685302, 3209.3775891384694, 0.18577770618460315], [0.5641884969886701, 8.883149794388377, 66.11919063714163, 298.6351381974001, 881.952221241769, 1712.0476126340707, 2051.0783778260716, 1230.3393547979972, 21531153547440383e-24], [0.30532663496123236, 0.36034489994980445, 0.12578172611122926, 0.016083785148742275, 6587491615298378e-19, 0.016315387137302097]];
|
|
var Q = [[23.601290952344122, 244.02463793444417, 1282.6165260773723, 2844.236833439171], [15.744926110709835, 117.6939508913125, 537.1811018620099, 1621.3895745666903, 3290.7992357334597, 4362.619090143247, 3439.3676741437216, 1230.3393548037495], [2.568520192289822, 1.8729528499234604, 0.5279051029514285, 0.06051834131244132, 0.0023352049762686918]];
|
|
var MAX_NUM = Math.pow(2, 53);
|
|
|
|
// node_modules/mathjs/lib/esm/function/statistics/mode.js
|
|
var name112 = "mode";
|
|
var dependencies112 = ["typed", "isNaN", "isNumeric"];
|
|
var createMode = /* @__PURE__ */ factory(name112, dependencies112, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
isNaN: isNaN3,
|
|
isNumeric: isNumeric2
|
|
} = _ref;
|
|
return typed2(name112, {
|
|
"Array | Matrix": _mode,
|
|
"...": function _(args) {
|
|
return _mode(args);
|
|
}
|
|
});
|
|
function _mode(values) {
|
|
values = flatten(values.valueOf());
|
|
var num = values.length;
|
|
if (num === 0) {
|
|
throw new Error("Cannot calculate mode of an empty array");
|
|
}
|
|
var count2 = {};
|
|
var mode2 = [];
|
|
var max3 = 0;
|
|
for (var i2 = 0; i2 < values.length; i2++) {
|
|
var value = values[i2];
|
|
if (isNumeric2(value) && isNaN3(value)) {
|
|
throw new Error("Cannot calculate mode of an array containing NaN values");
|
|
}
|
|
if (!(value in count2)) {
|
|
count2[value] = 0;
|
|
}
|
|
count2[value]++;
|
|
if (count2[value] === max3) {
|
|
mode2.push(value);
|
|
} else if (count2[value] > max3) {
|
|
max3 = count2[value];
|
|
mode2 = [value];
|
|
}
|
|
}
|
|
return mode2;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/statistics/utils/improveErrorMessage.js
|
|
function improveErrorMessage(err, fnName, value) {
|
|
var details;
|
|
if (String(err).indexOf("Unexpected type") !== -1) {
|
|
details = arguments.length > 2 ? " (type: " + typeOf(value) + ", value: " + JSON.stringify(value) + ")" : " (type: " + err.data.actual + ")";
|
|
return new TypeError("Cannot calculate " + fnName + ", unexpected type of argument" + details);
|
|
}
|
|
if (String(err).indexOf("complex numbers") !== -1) {
|
|
details = arguments.length > 2 ? " (type: " + typeOf(value) + ", value: " + JSON.stringify(value) + ")" : "";
|
|
return new TypeError("Cannot calculate " + fnName + ", no ordering relation is defined for complex numbers" + details);
|
|
}
|
|
return err;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/statistics/prod.js
|
|
var name113 = "prod";
|
|
var dependencies113 = ["typed", "config", "multiplyScalar", "numeric"];
|
|
var createProd = /* @__PURE__ */ factory(name113, dependencies113, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
multiplyScalar: multiplyScalar2,
|
|
numeric: numeric3
|
|
} = _ref;
|
|
return typed2(name113, {
|
|
"Array | Matrix": _prod,
|
|
"Array | Matrix, number | BigNumber": function ArrayMatrixNumberBigNumber(array, dim) {
|
|
throw new Error("prod(A, dim) is not yet supported");
|
|
},
|
|
"...": function _(args) {
|
|
return _prod(args);
|
|
}
|
|
});
|
|
function _prod(array) {
|
|
var prod2;
|
|
deepForEach(array, function(value) {
|
|
try {
|
|
prod2 = prod2 === void 0 ? value : multiplyScalar2(prod2, value);
|
|
} catch (err) {
|
|
throw improveErrorMessage(err, "prod", value);
|
|
}
|
|
});
|
|
if (typeof prod2 === "string") {
|
|
prod2 = numeric3(prod2, config4.number);
|
|
}
|
|
if (prod2 === void 0) {
|
|
throw new Error("Cannot calculate prod of an empty array");
|
|
}
|
|
return prod2;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/string/format.js
|
|
var name114 = "format";
|
|
var dependencies114 = ["typed"];
|
|
var createFormat = /* @__PURE__ */ factory(name114, dependencies114, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name114, {
|
|
any: format3,
|
|
"any, Object | function | number": format3
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/string/bin.js
|
|
var name115 = "bin";
|
|
var dependencies115 = ["typed", "format"];
|
|
var createBin = factory(name115, dependencies115, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
format: format5
|
|
} = _ref;
|
|
return typed2(name115, {
|
|
"number | BigNumber": function numberBigNumber(n) {
|
|
return format5(n, {
|
|
notation: "bin"
|
|
});
|
|
},
|
|
"number | BigNumber, number": function numberBigNumberNumber(n, wordSize) {
|
|
return format5(n, {
|
|
notation: "bin",
|
|
wordSize
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/string/oct.js
|
|
var name116 = "oct";
|
|
var dependencies116 = ["typed", "format"];
|
|
var createOct = factory(name116, dependencies116, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
format: format5
|
|
} = _ref;
|
|
return typed2(name116, {
|
|
"number | BigNumber": function numberBigNumber(n) {
|
|
return format5(n, {
|
|
notation: "oct"
|
|
});
|
|
},
|
|
"number | BigNumber, number": function numberBigNumberNumber(n, wordSize) {
|
|
return format5(n, {
|
|
notation: "oct",
|
|
wordSize
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/string/hex.js
|
|
var name117 = "hex";
|
|
var dependencies117 = ["typed", "format"];
|
|
var createHex = factory(name117, dependencies117, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
format: format5
|
|
} = _ref;
|
|
return typed2(name117, {
|
|
"number | BigNumber": function numberBigNumber(n) {
|
|
return format5(n, {
|
|
notation: "hex"
|
|
});
|
|
},
|
|
"number | BigNumber, number": function numberBigNumberNumber(n, wordSize) {
|
|
return format5(n, {
|
|
notation: "hex",
|
|
wordSize
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/string/print.js
|
|
var name118 = "print";
|
|
var dependencies118 = ["typed"];
|
|
var createPrint = /* @__PURE__ */ factory(name118, dependencies118, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name118, {
|
|
"string, Object | Array": _print,
|
|
"string, Object | Array, number | Object": _print
|
|
});
|
|
});
|
|
function _print(template, values, options) {
|
|
return template.replace(/\$([\w.]+)/g, function(original, key) {
|
|
var keys = key.split(".");
|
|
var value = values[keys.shift()];
|
|
while (keys.length && value !== void 0) {
|
|
var k = keys.shift();
|
|
value = k ? value[k] : value + ".";
|
|
}
|
|
if (value !== void 0) {
|
|
if (!isString(value)) {
|
|
return format3(value, options);
|
|
} else {
|
|
return value;
|
|
}
|
|
}
|
|
return original;
|
|
});
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/unit/to.js
|
|
var name119 = "to";
|
|
var dependencies119 = ["typed", "matrix", "concat"];
|
|
var createTo = /* @__PURE__ */ factory(name119, dependencies119, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
return typed2(name119, {
|
|
"Unit, Unit | string": (x, unit2) => x.to(unit2)
|
|
}, matrixAlgorithmSuite({
|
|
Ds: true
|
|
}));
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/utils/isPrime.js
|
|
var name120 = "isPrime";
|
|
var dependencies120 = ["typed"];
|
|
var createIsPrime = /* @__PURE__ */ factory(name120, dependencies120, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name120, {
|
|
number: function number2(x) {
|
|
if (x * 0 !== 0) {
|
|
return false;
|
|
}
|
|
if (x <= 3) {
|
|
return x > 1;
|
|
}
|
|
if (x % 2 === 0 || x % 3 === 0) {
|
|
return false;
|
|
}
|
|
for (var i2 = 5; i2 * i2 <= x; i2 += 6) {
|
|
if (x % i2 === 0 || x % (i2 + 2) === 0) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
},
|
|
BigNumber: function BigNumber2(n) {
|
|
if (n.toNumber() * 0 !== 0) {
|
|
return false;
|
|
}
|
|
if (n.lte(3))
|
|
return n.gt(1);
|
|
if (n.mod(2).eq(0) || n.mod(3).eq(0))
|
|
return false;
|
|
if (n.lt(Math.pow(2, 32))) {
|
|
var x = n.toNumber();
|
|
for (var i2 = 5; i2 * i2 <= x; i2 += 6) {
|
|
if (x % i2 === 0 || x % (i2 + 2) === 0) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function modPow(base, exponent, modulus) {
|
|
var accumulator = 1;
|
|
while (!exponent.eq(0)) {
|
|
if (exponent.mod(2).eq(0)) {
|
|
exponent = exponent.div(2);
|
|
base = base.mul(base).mod(modulus);
|
|
} else {
|
|
exponent = exponent.sub(1);
|
|
accumulator = base.mul(accumulator).mod(modulus);
|
|
}
|
|
}
|
|
return accumulator;
|
|
}
|
|
var Decimal2 = n.constructor.clone({
|
|
precision: n.toFixed(0).length * 2
|
|
});
|
|
n = new Decimal2(n);
|
|
var r = 0;
|
|
var d = n.sub(1);
|
|
while (d.mod(2).eq(0)) {
|
|
d = d.div(2);
|
|
r += 1;
|
|
}
|
|
var bases = null;
|
|
if (n.lt("3317044064679887385961981")) {
|
|
bases = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41].filter((x2) => x2 < n);
|
|
} else {
|
|
var max3 = Math.min(n.toNumber() - 2, Math.floor(2 * Math.pow(n.toFixed(0).length * Math.log(10), 2)));
|
|
bases = [];
|
|
for (var _i = 2; _i <= max3; _i += 1) {
|
|
bases.push(max3);
|
|
}
|
|
}
|
|
for (var _i2 = 0; _i2 < bases.length; _i2 += 1) {
|
|
var a = bases[_i2];
|
|
var adn = modPow(n.sub(n).add(a), d, n);
|
|
if (!adn.eq(1)) {
|
|
for (var _i3 = 0, _x = adn; !_x.eq(n.sub(1)); _i3 += 1, _x = _x.mul(_x).mod(n)) {
|
|
if (_i3 === r - 1) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/utils/numeric.js
|
|
var name121 = "numeric";
|
|
var dependencies121 = ["number", "?bignumber", "?fraction"];
|
|
var createNumeric = /* @__PURE__ */ factory(name121, dependencies121, (_ref) => {
|
|
var {
|
|
number: _number,
|
|
bignumber: bignumber2,
|
|
fraction: fraction2
|
|
} = _ref;
|
|
var validInputTypes = {
|
|
string: true,
|
|
number: true,
|
|
BigNumber: true,
|
|
Fraction: true
|
|
};
|
|
var validOutputTypes = {
|
|
number: (x) => _number(x),
|
|
BigNumber: bignumber2 ? (x) => bignumber2(x) : noBignumber,
|
|
Fraction: fraction2 ? (x) => fraction2(x) : noFraction
|
|
};
|
|
return function numeric3(value) {
|
|
var outputType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "number";
|
|
var check = arguments.length > 2 ? arguments[2] : void 0;
|
|
if (check !== void 0) {
|
|
throw new SyntaxError("numeric() takes one or two arguments");
|
|
}
|
|
var inputType = typeOf(value);
|
|
if (!(inputType in validInputTypes)) {
|
|
throw new TypeError("Cannot convert " + value + ' of type "' + inputType + '"; valid input types are ' + Object.keys(validInputTypes).join(", "));
|
|
}
|
|
if (!(outputType in validOutputTypes)) {
|
|
throw new TypeError("Cannot convert " + value + ' to type "' + outputType + '"; valid output types are ' + Object.keys(validOutputTypes).join(", "));
|
|
}
|
|
if (outputType === inputType) {
|
|
return value;
|
|
} else {
|
|
return validOutputTypes[outputType](value);
|
|
}
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/divideScalar.js
|
|
var name122 = "divideScalar";
|
|
var dependencies122 = ["typed", "numeric"];
|
|
var createDivideScalar = /* @__PURE__ */ factory(name122, dependencies122, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
numeric: numeric3
|
|
} = _ref;
|
|
return typed2(name122, {
|
|
"number, number": function numberNumber(x, y) {
|
|
return x / y;
|
|
},
|
|
"Complex, Complex": function ComplexComplex(x, y) {
|
|
return x.div(y);
|
|
},
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(x, y) {
|
|
return x.div(y);
|
|
},
|
|
"Fraction, Fraction": function FractionFraction(x, y) {
|
|
return x.div(y);
|
|
},
|
|
"Unit, number | Complex | Fraction | BigNumber | Unit": (x, y) => x.divide(y),
|
|
"number | Fraction | Complex | BigNumber, Unit": (x, y) => y.divideInto(x)
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/pow.js
|
|
var name123 = "pow";
|
|
var dependencies123 = ["typed", "config", "identity", "multiply", "matrix", "inv", "fraction", "number", "Complex"];
|
|
var createPow = /* @__PURE__ */ factory(name123, dependencies123, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
identity: identity2,
|
|
multiply: multiply2,
|
|
matrix: matrix2,
|
|
inv: inv2,
|
|
number: number2,
|
|
fraction: fraction2,
|
|
Complex: Complex3
|
|
} = _ref;
|
|
return typed2(name123, {
|
|
"number, number": _pow,
|
|
"Complex, Complex": function ComplexComplex(x, y) {
|
|
return x.pow(y);
|
|
},
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(x, y) {
|
|
if (y.isInteger() || x >= 0 || config4.predictable) {
|
|
return x.pow(y);
|
|
} else {
|
|
return new Complex3(x.toNumber(), 0).pow(y.toNumber(), 0);
|
|
}
|
|
},
|
|
"Fraction, Fraction": function FractionFraction(x, y) {
|
|
var result = x.pow(y);
|
|
if (result != null) {
|
|
return result;
|
|
}
|
|
if (config4.predictable) {
|
|
throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");
|
|
} else {
|
|
return _pow(x.valueOf(), y.valueOf());
|
|
}
|
|
},
|
|
"Array, number": _powArray,
|
|
"Array, BigNumber": function ArrayBigNumber(x, y) {
|
|
return _powArray(x, y.toNumber());
|
|
},
|
|
"Matrix, number": _powMatrix,
|
|
"Matrix, BigNumber": function MatrixBigNumber(x, y) {
|
|
return _powMatrix(x, y.toNumber());
|
|
},
|
|
"Unit, number | BigNumber": function UnitNumberBigNumber(x, y) {
|
|
return x.pow(y);
|
|
}
|
|
});
|
|
function _pow(x, y) {
|
|
if (config4.predictable && !isInteger(y) && x < 0) {
|
|
try {
|
|
var yFrac = fraction2(y);
|
|
var yNum = number2(yFrac);
|
|
if (y === yNum || Math.abs((y - yNum) / y) < 1e-14) {
|
|
if (yFrac.d % 2 === 1) {
|
|
return (yFrac.n % 2 === 0 ? 1 : -1) * Math.pow(-x, y);
|
|
}
|
|
}
|
|
} catch (ex) {
|
|
}
|
|
}
|
|
if (config4.predictable && (x < -1 && y === Infinity || x > -1 && x < 0 && y === -Infinity)) {
|
|
return NaN;
|
|
}
|
|
if (isInteger(y) || x >= 0 || config4.predictable) {
|
|
return powNumber(x, y);
|
|
} else {
|
|
if (x * x < 1 && y === Infinity || x * x > 1 && y === -Infinity) {
|
|
return 0;
|
|
}
|
|
return new Complex3(x, 0).pow(y, 0);
|
|
}
|
|
}
|
|
function _powArray(x, y) {
|
|
if (!isInteger(y)) {
|
|
throw new TypeError("For A^b, b must be an integer (value is " + y + ")");
|
|
}
|
|
var s = arraySize(x);
|
|
if (s.length !== 2) {
|
|
throw new Error("For A^b, A must be 2 dimensional (A has " + s.length + " dimensions)");
|
|
}
|
|
if (s[0] !== s[1]) {
|
|
throw new Error("For A^b, A must be square (size is " + s[0] + "x" + s[1] + ")");
|
|
}
|
|
if (y < 0) {
|
|
try {
|
|
return _powArray(inv2(x), -y);
|
|
} catch (error) {
|
|
if (error.message === "Cannot calculate inverse, determinant is zero") {
|
|
throw new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is " + y + ")");
|
|
}
|
|
throw error;
|
|
}
|
|
}
|
|
var res = identity2(s[0]).valueOf();
|
|
var px = x;
|
|
while (y >= 1) {
|
|
if ((y & 1) === 1) {
|
|
res = multiply2(px, res);
|
|
}
|
|
y >>= 1;
|
|
px = multiply2(px, px);
|
|
}
|
|
return res;
|
|
}
|
|
function _powMatrix(x, y) {
|
|
return matrix2(_powArray(x.valueOf(), y));
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/round.js
|
|
var NO_INT = "Number of decimals in function round must be an integer";
|
|
var name124 = "round";
|
|
var dependencies124 = ["typed", "matrix", "equalScalar", "zeros", "BigNumber", "DenseMatrix"];
|
|
var createRound = /* @__PURE__ */ factory(name124, dependencies124, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
equalScalar: equalScalar2,
|
|
zeros: zeros3,
|
|
BigNumber: BigNumber2,
|
|
DenseMatrix: DenseMatrix2
|
|
} = _ref;
|
|
var matAlgo11xS0s = createMatAlgo11xS0s({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matAlgo14xDs = createMatAlgo14xDs({
|
|
typed: typed2
|
|
});
|
|
return typed2(name124, {
|
|
number: roundNumber,
|
|
"number, number": roundNumber,
|
|
"number, BigNumber": function numberBigNumber(x, n) {
|
|
if (!n.isInteger()) {
|
|
throw new TypeError(NO_INT);
|
|
}
|
|
return new BigNumber2(x).toDecimalPlaces(n.toNumber());
|
|
},
|
|
Complex: function Complex3(x) {
|
|
return x.round();
|
|
},
|
|
"Complex, number": function ComplexNumber(x, n) {
|
|
if (n % 1) {
|
|
throw new TypeError(NO_INT);
|
|
}
|
|
return x.round(n);
|
|
},
|
|
"Complex, BigNumber": function ComplexBigNumber(x, n) {
|
|
if (!n.isInteger()) {
|
|
throw new TypeError(NO_INT);
|
|
}
|
|
var _n = n.toNumber();
|
|
return x.round(_n);
|
|
},
|
|
BigNumber: function BigNumber3(x) {
|
|
return x.toDecimalPlaces(0);
|
|
},
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(x, n) {
|
|
if (!n.isInteger()) {
|
|
throw new TypeError(NO_INT);
|
|
}
|
|
return x.toDecimalPlaces(n.toNumber());
|
|
},
|
|
Fraction: function Fraction3(x) {
|
|
return x.round();
|
|
},
|
|
"Fraction, number": function FractionNumber(x, n) {
|
|
if (n % 1) {
|
|
throw new TypeError(NO_INT);
|
|
}
|
|
return x.round(n);
|
|
},
|
|
"Fraction, BigNumber": function FractionBigNumber(x, n) {
|
|
if (!n.isInteger()) {
|
|
throw new TypeError(NO_INT);
|
|
}
|
|
return x.round(n.toNumber());
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2, true)),
|
|
"SparseMatrix, number | BigNumber": typed2.referToSelf((self2) => (x, y) => {
|
|
return matAlgo11xS0s(x, y, self2, false);
|
|
}),
|
|
"DenseMatrix, number | BigNumber": typed2.referToSelf((self2) => (x, y) => {
|
|
return matAlgo14xDs(x, y, self2, false);
|
|
}),
|
|
"Array, number | BigNumber": typed2.referToSelf((self2) => (x, y) => {
|
|
return matAlgo14xDs(matrix2(x), y, self2, false).valueOf();
|
|
}),
|
|
"number | Complex | BigNumber | Fraction, SparseMatrix": typed2.referToSelf((self2) => (x, y) => {
|
|
if (equalScalar2(x, 0)) {
|
|
return zeros3(y.size(), y.storage());
|
|
}
|
|
return matAlgo12xSfs(y, x, self2, true);
|
|
}),
|
|
"number | Complex | BigNumber | Fraction, DenseMatrix": typed2.referToSelf((self2) => (x, y) => {
|
|
if (equalScalar2(x, 0)) {
|
|
return zeros3(y.size(), y.storage());
|
|
}
|
|
return matAlgo14xDs(y, x, self2, true);
|
|
}),
|
|
"number | Complex | BigNumber | Fraction, Array": typed2.referToSelf((self2) => (x, y) => {
|
|
return matAlgo14xDs(matrix2(y), x, self2, true).valueOf();
|
|
})
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/log.js
|
|
var name125 = "log";
|
|
var dependencies125 = ["config", "typed", "divideScalar", "Complex"];
|
|
var createLog = /* @__PURE__ */ factory(name125, dependencies125, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
divideScalar: divideScalar2,
|
|
Complex: Complex3
|
|
} = _ref;
|
|
return typed2(name125, {
|
|
number: function number2(x) {
|
|
if (x >= 0 || config4.predictable) {
|
|
return logNumber(x);
|
|
} else {
|
|
return new Complex3(x, 0).log();
|
|
}
|
|
},
|
|
Complex: function Complex4(x) {
|
|
return x.log();
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
if (!x.isNegative() || config4.predictable) {
|
|
return x.ln();
|
|
} else {
|
|
return new Complex3(x.toNumber(), 0).log();
|
|
}
|
|
},
|
|
"any, any": typed2.referToSelf((self2) => (x, base) => {
|
|
return divideScalar2(self2(x), self2(base));
|
|
})
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/log1p.js
|
|
var name126 = "log1p";
|
|
var dependencies126 = ["typed", "config", "divideScalar", "log", "Complex"];
|
|
var createLog1p = /* @__PURE__ */ factory(name126, dependencies126, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
divideScalar: divideScalar2,
|
|
log: log4,
|
|
Complex: Complex3
|
|
} = _ref;
|
|
return typed2(name126, {
|
|
number: function number2(x) {
|
|
if (x >= -1 || config4.predictable) {
|
|
return log1p(x);
|
|
} else {
|
|
return _log1pComplex(new Complex3(x, 0));
|
|
}
|
|
},
|
|
Complex: _log1pComplex,
|
|
BigNumber: function BigNumber2(x) {
|
|
var y = x.plus(1);
|
|
if (!y.isNegative() || config4.predictable) {
|
|
return y.ln();
|
|
} else {
|
|
return _log1pComplex(new Complex3(x.toNumber(), 0));
|
|
}
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2)),
|
|
"any, any": typed2.referToSelf((self2) => (x, base) => {
|
|
return divideScalar2(self2(x), log4(base));
|
|
})
|
|
});
|
|
function _log1pComplex(x) {
|
|
var xRe1p = x.re + 1;
|
|
return new Complex3(Math.log(Math.sqrt(xRe1p * xRe1p + x.im * x.im)), Math.atan2(x.im, xRe1p));
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/nthRoots.js
|
|
var name127 = "nthRoots";
|
|
var dependencies127 = ["config", "typed", "divideScalar", "Complex"];
|
|
var createNthRoots = /* @__PURE__ */ factory(name127, dependencies127, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
divideScalar: divideScalar2,
|
|
Complex: Complex3
|
|
} = _ref;
|
|
var _calculateExactResult = [function realPos(val) {
|
|
return new Complex3(val, 0);
|
|
}, function imagPos(val) {
|
|
return new Complex3(0, val);
|
|
}, function realNeg(val) {
|
|
return new Complex3(-val, 0);
|
|
}, function imagNeg(val) {
|
|
return new Complex3(0, -val);
|
|
}];
|
|
function _nthComplexRoots(a, root) {
|
|
if (root < 0)
|
|
throw new Error("Root must be greater than zero");
|
|
if (root === 0)
|
|
throw new Error("Root must be non-zero");
|
|
if (root % 1 !== 0)
|
|
throw new Error("Root must be an integer");
|
|
if (a === 0 || a.abs() === 0)
|
|
return [new Complex3(0, 0)];
|
|
var aIsNumeric = typeof a === "number";
|
|
var offset;
|
|
if (aIsNumeric || a.re === 0 || a.im === 0) {
|
|
if (aIsNumeric) {
|
|
offset = 2 * +(a < 0);
|
|
} else if (a.im === 0) {
|
|
offset = 2 * +(a.re < 0);
|
|
} else {
|
|
offset = 2 * +(a.im < 0) + 1;
|
|
}
|
|
}
|
|
var arg2 = a.arg();
|
|
var abs3 = a.abs();
|
|
var roots = [];
|
|
var r = Math.pow(abs3, 1 / root);
|
|
for (var k = 0; k < root; k++) {
|
|
var halfPiFactor = (offset + 4 * k) / root;
|
|
if (halfPiFactor === Math.round(halfPiFactor)) {
|
|
roots.push(_calculateExactResult[halfPiFactor % 4](r));
|
|
continue;
|
|
}
|
|
roots.push(new Complex3({
|
|
r,
|
|
phi: (arg2 + 2 * Math.PI * k) / root
|
|
}));
|
|
}
|
|
return roots;
|
|
}
|
|
return typed2(name127, {
|
|
Complex: function Complex4(x) {
|
|
return _nthComplexRoots(x, 2);
|
|
},
|
|
"Complex, number": _nthComplexRoots
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/dotPow.js
|
|
var name128 = "dotPow";
|
|
var dependencies128 = ["typed", "equalScalar", "matrix", "pow", "DenseMatrix", "concat"];
|
|
var createDotPow = /* @__PURE__ */ factory(name128, dependencies128, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
equalScalar: equalScalar2,
|
|
matrix: matrix2,
|
|
pow: pow3,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo03xDSf = createMatAlgo03xDSf({
|
|
typed: typed2
|
|
});
|
|
var matAlgo07xSSf = createMatAlgo07xSSf({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matAlgo11xS0s = createMatAlgo11xS0s({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
var powScalarSignatures = {};
|
|
for (var signature in pow3.signatures) {
|
|
if (Object.prototype.hasOwnProperty.call(pow3.signatures, signature)) {
|
|
if (!signature.includes("Matrix") && !signature.includes("Array")) {
|
|
powScalarSignatures[signature] = pow3.signatures[signature];
|
|
}
|
|
}
|
|
}
|
|
var powScalar = typed2(powScalarSignatures);
|
|
return typed2(name128, matrixAlgorithmSuite({
|
|
elop: powScalar,
|
|
SS: matAlgo07xSSf,
|
|
DS: matAlgo03xDSf,
|
|
Ss: matAlgo11xS0s,
|
|
sS: matAlgo12xSfs
|
|
}));
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/dotDivide.js
|
|
var name129 = "dotDivide";
|
|
var dependencies129 = ["typed", "matrix", "equalScalar", "divideScalar", "DenseMatrix", "concat"];
|
|
var createDotDivide = /* @__PURE__ */ factory(name129, dependencies129, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
equalScalar: equalScalar2,
|
|
divideScalar: divideScalar2,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo02xDS0 = createMatAlgo02xDS0({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo03xDSf = createMatAlgo03xDSf({
|
|
typed: typed2
|
|
});
|
|
var matAlgo07xSSf = createMatAlgo07xSSf({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matAlgo11xS0s = createMatAlgo11xS0s({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
return typed2(name129, matrixAlgorithmSuite({
|
|
elop: divideScalar2,
|
|
SS: matAlgo07xSSf,
|
|
DS: matAlgo03xDSf,
|
|
SD: matAlgo02xDS0,
|
|
Ss: matAlgo11xS0s,
|
|
sS: matAlgo12xSfs
|
|
}));
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/solver/utils/solveValidation.js
|
|
function createSolveValidation(_ref) {
|
|
var {
|
|
DenseMatrix: DenseMatrix2
|
|
} = _ref;
|
|
return function solveValidation(m, b, copy) {
|
|
var mSize = m.size();
|
|
if (mSize.length !== 2) {
|
|
throw new RangeError("Matrix must be two dimensional (size: " + format3(mSize) + ")");
|
|
}
|
|
var rows = mSize[0];
|
|
var columns = mSize[1];
|
|
if (rows !== columns) {
|
|
throw new RangeError("Matrix must be square (size: " + format3(mSize) + ")");
|
|
}
|
|
var data = [];
|
|
if (isMatrix(b)) {
|
|
var bSize = b.size();
|
|
var bdata = b._data;
|
|
if (bSize.length === 1) {
|
|
if (bSize[0] !== rows) {
|
|
throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
|
|
}
|
|
for (var i2 = 0; i2 < rows; i2++) {
|
|
data[i2] = [bdata[i2]];
|
|
}
|
|
return new DenseMatrix2({
|
|
data,
|
|
size: [rows, 1],
|
|
datatype: b._datatype
|
|
});
|
|
}
|
|
if (bSize.length === 2) {
|
|
if (bSize[0] !== rows || bSize[1] !== 1) {
|
|
throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
|
|
}
|
|
if (isDenseMatrix(b)) {
|
|
if (copy) {
|
|
data = [];
|
|
for (var _i = 0; _i < rows; _i++) {
|
|
data[_i] = [bdata[_i][0]];
|
|
}
|
|
return new DenseMatrix2({
|
|
data,
|
|
size: [rows, 1],
|
|
datatype: b._datatype
|
|
});
|
|
}
|
|
return b;
|
|
}
|
|
if (isSparseMatrix(b)) {
|
|
for (var _i2 = 0; _i2 < rows; _i2++) {
|
|
data[_i2] = [0];
|
|
}
|
|
var values = b._values;
|
|
var index2 = b._index;
|
|
var ptr = b._ptr;
|
|
for (var k1 = ptr[1], k = ptr[0]; k < k1; k++) {
|
|
var _i3 = index2[k];
|
|
data[_i3][0] = values[k];
|
|
}
|
|
return new DenseMatrix2({
|
|
data,
|
|
size: [rows, 1],
|
|
datatype: b._datatype
|
|
});
|
|
}
|
|
}
|
|
throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.");
|
|
}
|
|
if (isArray(b)) {
|
|
var bsize = arraySize(b);
|
|
if (bsize.length === 1) {
|
|
if (bsize[0] !== rows) {
|
|
throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
|
|
}
|
|
for (var _i4 = 0; _i4 < rows; _i4++) {
|
|
data[_i4] = [b[_i4]];
|
|
}
|
|
return new DenseMatrix2({
|
|
data,
|
|
size: [rows, 1]
|
|
});
|
|
}
|
|
if (bsize.length === 2) {
|
|
if (bsize[0] !== rows || bsize[1] !== 1) {
|
|
throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
|
|
}
|
|
for (var _i5 = 0; _i5 < rows; _i5++) {
|
|
data[_i5] = [b[_i5][0]];
|
|
}
|
|
return new DenseMatrix2({
|
|
data,
|
|
size: [rows, 1]
|
|
});
|
|
}
|
|
throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.");
|
|
}
|
|
};
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/solver/lsolve.js
|
|
var name130 = "lsolve";
|
|
var dependencies130 = ["typed", "matrix", "divideScalar", "multiplyScalar", "subtract", "equalScalar", "DenseMatrix"];
|
|
var createLsolve = /* @__PURE__ */ factory(name130, dependencies130, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
divideScalar: divideScalar2,
|
|
multiplyScalar: multiplyScalar2,
|
|
subtract: subtract2,
|
|
equalScalar: equalScalar2,
|
|
DenseMatrix: DenseMatrix2
|
|
} = _ref;
|
|
var solveValidation = createSolveValidation({
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
return typed2(name130, {
|
|
"SparseMatrix, Array | Matrix": function SparseMatrixArrayMatrix(m, b) {
|
|
return _sparseForwardSubstitution(m, b);
|
|
},
|
|
"DenseMatrix, Array | Matrix": function DenseMatrixArrayMatrix(m, b) {
|
|
return _denseForwardSubstitution(m, b);
|
|
},
|
|
"Array, Array | Matrix": function ArrayArrayMatrix(a, b) {
|
|
var m = matrix2(a);
|
|
var r = _denseForwardSubstitution(m, b);
|
|
return r.valueOf();
|
|
}
|
|
});
|
|
function _denseForwardSubstitution(m, b) {
|
|
b = solveValidation(m, b, true);
|
|
var bdata = b._data;
|
|
var rows = m._size[0];
|
|
var columns = m._size[1];
|
|
var x = [];
|
|
var mdata = m._data;
|
|
for (var j = 0; j < columns; j++) {
|
|
var bj = bdata[j][0] || 0;
|
|
var xj = void 0;
|
|
if (!equalScalar2(bj, 0)) {
|
|
var vjj = mdata[j][j];
|
|
if (equalScalar2(vjj, 0)) {
|
|
throw new Error("Linear system cannot be solved since matrix is singular");
|
|
}
|
|
xj = divideScalar2(bj, vjj);
|
|
for (var i2 = j + 1; i2 < rows; i2++) {
|
|
bdata[i2] = [subtract2(bdata[i2][0] || 0, multiplyScalar2(xj, mdata[i2][j]))];
|
|
}
|
|
} else {
|
|
xj = 0;
|
|
}
|
|
x[j] = [xj];
|
|
}
|
|
return new DenseMatrix2({
|
|
data: x,
|
|
size: [rows, 1]
|
|
});
|
|
}
|
|
function _sparseForwardSubstitution(m, b) {
|
|
b = solveValidation(m, b, true);
|
|
var bdata = b._data;
|
|
var rows = m._size[0];
|
|
var columns = m._size[1];
|
|
var values = m._values;
|
|
var index2 = m._index;
|
|
var ptr = m._ptr;
|
|
var x = [];
|
|
for (var j = 0; j < columns; j++) {
|
|
var bj = bdata[j][0] || 0;
|
|
if (!equalScalar2(bj, 0)) {
|
|
var vjj = 0;
|
|
var jValues = [];
|
|
var jIndices = [];
|
|
var firstIndex = ptr[j];
|
|
var lastIndex = ptr[j + 1];
|
|
for (var k = firstIndex; k < lastIndex; k++) {
|
|
var i2 = index2[k];
|
|
if (i2 === j) {
|
|
vjj = values[k];
|
|
} else if (i2 > j) {
|
|
jValues.push(values[k]);
|
|
jIndices.push(i2);
|
|
}
|
|
}
|
|
if (equalScalar2(vjj, 0)) {
|
|
throw new Error("Linear system cannot be solved since matrix is singular");
|
|
}
|
|
var xj = divideScalar2(bj, vjj);
|
|
for (var _k = 0, l = jIndices.length; _k < l; _k++) {
|
|
var _i = jIndices[_k];
|
|
bdata[_i] = [subtract2(bdata[_i][0] || 0, multiplyScalar2(xj, jValues[_k]))];
|
|
}
|
|
x[j] = [xj];
|
|
} else {
|
|
x[j] = [0];
|
|
}
|
|
}
|
|
return new DenseMatrix2({
|
|
data: x,
|
|
size: [rows, 1]
|
|
});
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/solver/usolve.js
|
|
var name131 = "usolve";
|
|
var dependencies131 = ["typed", "matrix", "divideScalar", "multiplyScalar", "subtract", "equalScalar", "DenseMatrix"];
|
|
var createUsolve = /* @__PURE__ */ factory(name131, dependencies131, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
divideScalar: divideScalar2,
|
|
multiplyScalar: multiplyScalar2,
|
|
subtract: subtract2,
|
|
equalScalar: equalScalar2,
|
|
DenseMatrix: DenseMatrix2
|
|
} = _ref;
|
|
var solveValidation = createSolveValidation({
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
return typed2(name131, {
|
|
"SparseMatrix, Array | Matrix": function SparseMatrixArrayMatrix(m, b) {
|
|
return _sparseBackwardSubstitution(m, b);
|
|
},
|
|
"DenseMatrix, Array | Matrix": function DenseMatrixArrayMatrix(m, b) {
|
|
return _denseBackwardSubstitution(m, b);
|
|
},
|
|
"Array, Array | Matrix": function ArrayArrayMatrix(a, b) {
|
|
var m = matrix2(a);
|
|
var r = _denseBackwardSubstitution(m, b);
|
|
return r.valueOf();
|
|
}
|
|
});
|
|
function _denseBackwardSubstitution(m, b) {
|
|
b = solveValidation(m, b, true);
|
|
var bdata = b._data;
|
|
var rows = m._size[0];
|
|
var columns = m._size[1];
|
|
var x = [];
|
|
var mdata = m._data;
|
|
for (var j = columns - 1; j >= 0; j--) {
|
|
var bj = bdata[j][0] || 0;
|
|
var xj = void 0;
|
|
if (!equalScalar2(bj, 0)) {
|
|
var vjj = mdata[j][j];
|
|
if (equalScalar2(vjj, 0)) {
|
|
throw new Error("Linear system cannot be solved since matrix is singular");
|
|
}
|
|
xj = divideScalar2(bj, vjj);
|
|
for (var i2 = j - 1; i2 >= 0; i2--) {
|
|
bdata[i2] = [subtract2(bdata[i2][0] || 0, multiplyScalar2(xj, mdata[i2][j]))];
|
|
}
|
|
} else {
|
|
xj = 0;
|
|
}
|
|
x[j] = [xj];
|
|
}
|
|
return new DenseMatrix2({
|
|
data: x,
|
|
size: [rows, 1]
|
|
});
|
|
}
|
|
function _sparseBackwardSubstitution(m, b) {
|
|
b = solveValidation(m, b, true);
|
|
var bdata = b._data;
|
|
var rows = m._size[0];
|
|
var columns = m._size[1];
|
|
var values = m._values;
|
|
var index2 = m._index;
|
|
var ptr = m._ptr;
|
|
var x = [];
|
|
for (var j = columns - 1; j >= 0; j--) {
|
|
var bj = bdata[j][0] || 0;
|
|
if (!equalScalar2(bj, 0)) {
|
|
var vjj = 0;
|
|
var jValues = [];
|
|
var jIndices = [];
|
|
var firstIndex = ptr[j];
|
|
var lastIndex = ptr[j + 1];
|
|
for (var k = lastIndex - 1; k >= firstIndex; k--) {
|
|
var i2 = index2[k];
|
|
if (i2 === j) {
|
|
vjj = values[k];
|
|
} else if (i2 < j) {
|
|
jValues.push(values[k]);
|
|
jIndices.push(i2);
|
|
}
|
|
}
|
|
if (equalScalar2(vjj, 0)) {
|
|
throw new Error("Linear system cannot be solved since matrix is singular");
|
|
}
|
|
var xj = divideScalar2(bj, vjj);
|
|
for (var _k = 0, _lastIndex = jIndices.length; _k < _lastIndex; _k++) {
|
|
var _i = jIndices[_k];
|
|
bdata[_i] = [subtract2(bdata[_i][0], multiplyScalar2(xj, jValues[_k]))];
|
|
}
|
|
x[j] = [xj];
|
|
} else {
|
|
x[j] = [0];
|
|
}
|
|
}
|
|
return new DenseMatrix2({
|
|
data: x,
|
|
size: [rows, 1]
|
|
});
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/solver/lsolveAll.js
|
|
var name132 = "lsolveAll";
|
|
var dependencies132 = ["typed", "matrix", "divideScalar", "multiplyScalar", "subtract", "equalScalar", "DenseMatrix"];
|
|
var createLsolveAll = /* @__PURE__ */ factory(name132, dependencies132, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
divideScalar: divideScalar2,
|
|
multiplyScalar: multiplyScalar2,
|
|
subtract: subtract2,
|
|
equalScalar: equalScalar2,
|
|
DenseMatrix: DenseMatrix2
|
|
} = _ref;
|
|
var solveValidation = createSolveValidation({
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
return typed2(name132, {
|
|
"SparseMatrix, Array | Matrix": function SparseMatrixArrayMatrix(m, b) {
|
|
return _sparseForwardSubstitution(m, b);
|
|
},
|
|
"DenseMatrix, Array | Matrix": function DenseMatrixArrayMatrix(m, b) {
|
|
return _denseForwardSubstitution(m, b);
|
|
},
|
|
"Array, Array | Matrix": function ArrayArrayMatrix(a, b) {
|
|
var m = matrix2(a);
|
|
var R = _denseForwardSubstitution(m, b);
|
|
return R.map((r) => r.valueOf());
|
|
}
|
|
});
|
|
function _denseForwardSubstitution(m, b_) {
|
|
var B = [solveValidation(m, b_, true)._data.map((e3) => e3[0])];
|
|
var M = m._data;
|
|
var rows = m._size[0];
|
|
var columns = m._size[1];
|
|
for (var i2 = 0; i2 < columns; i2++) {
|
|
var L = B.length;
|
|
for (var k = 0; k < L; k++) {
|
|
var b = B[k];
|
|
if (!equalScalar2(M[i2][i2], 0)) {
|
|
b[i2] = divideScalar2(b[i2], M[i2][i2]);
|
|
for (var j = i2 + 1; j < columns; j++) {
|
|
b[j] = subtract2(b[j], multiplyScalar2(b[i2], M[j][i2]));
|
|
}
|
|
} else if (!equalScalar2(b[i2], 0)) {
|
|
if (k === 0) {
|
|
return [];
|
|
} else {
|
|
B.splice(k, 1);
|
|
k -= 1;
|
|
L -= 1;
|
|
}
|
|
} else if (k === 0) {
|
|
var bNew = [...b];
|
|
bNew[i2] = 1;
|
|
for (var _j = i2 + 1; _j < columns; _j++) {
|
|
bNew[_j] = subtract2(bNew[_j], M[_j][i2]);
|
|
}
|
|
B.push(bNew);
|
|
}
|
|
}
|
|
}
|
|
return B.map((x) => new DenseMatrix2({
|
|
data: x.map((e3) => [e3]),
|
|
size: [rows, 1]
|
|
}));
|
|
}
|
|
function _sparseForwardSubstitution(m, b_) {
|
|
var B = [solveValidation(m, b_, true)._data.map((e3) => e3[0])];
|
|
var rows = m._size[0];
|
|
var columns = m._size[1];
|
|
var values = m._values;
|
|
var index2 = m._index;
|
|
var ptr = m._ptr;
|
|
for (var i2 = 0; i2 < columns; i2++) {
|
|
var L = B.length;
|
|
for (var k = 0; k < L; k++) {
|
|
var b = B[k];
|
|
var iValues = [];
|
|
var iIndices = [];
|
|
var firstIndex = ptr[i2];
|
|
var lastIndex = ptr[i2 + 1];
|
|
var Mii = 0;
|
|
for (var j = firstIndex; j < lastIndex; j++) {
|
|
var J = index2[j];
|
|
if (J === i2) {
|
|
Mii = values[j];
|
|
} else if (J > i2) {
|
|
iValues.push(values[j]);
|
|
iIndices.push(J);
|
|
}
|
|
}
|
|
if (!equalScalar2(Mii, 0)) {
|
|
b[i2] = divideScalar2(b[i2], Mii);
|
|
for (var _j2 = 0, _lastIndex = iIndices.length; _j2 < _lastIndex; _j2++) {
|
|
var _J = iIndices[_j2];
|
|
b[_J] = subtract2(b[_J], multiplyScalar2(b[i2], iValues[_j2]));
|
|
}
|
|
} else if (!equalScalar2(b[i2], 0)) {
|
|
if (k === 0) {
|
|
return [];
|
|
} else {
|
|
B.splice(k, 1);
|
|
k -= 1;
|
|
L -= 1;
|
|
}
|
|
} else if (k === 0) {
|
|
var bNew = [...b];
|
|
bNew[i2] = 1;
|
|
for (var _j3 = 0, _lastIndex2 = iIndices.length; _j3 < _lastIndex2; _j3++) {
|
|
var _J2 = iIndices[_j3];
|
|
bNew[_J2] = subtract2(bNew[_J2], iValues[_j3]);
|
|
}
|
|
B.push(bNew);
|
|
}
|
|
}
|
|
}
|
|
return B.map((x) => new DenseMatrix2({
|
|
data: x.map((e3) => [e3]),
|
|
size: [rows, 1]
|
|
}));
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/solver/usolveAll.js
|
|
var name133 = "usolveAll";
|
|
var dependencies133 = ["typed", "matrix", "divideScalar", "multiplyScalar", "subtract", "equalScalar", "DenseMatrix"];
|
|
var createUsolveAll = /* @__PURE__ */ factory(name133, dependencies133, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
divideScalar: divideScalar2,
|
|
multiplyScalar: multiplyScalar2,
|
|
subtract: subtract2,
|
|
equalScalar: equalScalar2,
|
|
DenseMatrix: DenseMatrix2
|
|
} = _ref;
|
|
var solveValidation = createSolveValidation({
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
return typed2(name133, {
|
|
"SparseMatrix, Array | Matrix": function SparseMatrixArrayMatrix(m, b) {
|
|
return _sparseBackwardSubstitution(m, b);
|
|
},
|
|
"DenseMatrix, Array | Matrix": function DenseMatrixArrayMatrix(m, b) {
|
|
return _denseBackwardSubstitution(m, b);
|
|
},
|
|
"Array, Array | Matrix": function ArrayArrayMatrix(a, b) {
|
|
var m = matrix2(a);
|
|
var R = _denseBackwardSubstitution(m, b);
|
|
return R.map((r) => r.valueOf());
|
|
}
|
|
});
|
|
function _denseBackwardSubstitution(m, b_) {
|
|
var B = [solveValidation(m, b_, true)._data.map((e3) => e3[0])];
|
|
var M = m._data;
|
|
var rows = m._size[0];
|
|
var columns = m._size[1];
|
|
for (var i2 = columns - 1; i2 >= 0; i2--) {
|
|
var L = B.length;
|
|
for (var k = 0; k < L; k++) {
|
|
var b = B[k];
|
|
if (!equalScalar2(M[i2][i2], 0)) {
|
|
b[i2] = divideScalar2(b[i2], M[i2][i2]);
|
|
for (var j = i2 - 1; j >= 0; j--) {
|
|
b[j] = subtract2(b[j], multiplyScalar2(b[i2], M[j][i2]));
|
|
}
|
|
} else if (!equalScalar2(b[i2], 0)) {
|
|
if (k === 0) {
|
|
return [];
|
|
} else {
|
|
B.splice(k, 1);
|
|
k -= 1;
|
|
L -= 1;
|
|
}
|
|
} else if (k === 0) {
|
|
var bNew = [...b];
|
|
bNew[i2] = 1;
|
|
for (var _j = i2 - 1; _j >= 0; _j--) {
|
|
bNew[_j] = subtract2(bNew[_j], M[_j][i2]);
|
|
}
|
|
B.push(bNew);
|
|
}
|
|
}
|
|
}
|
|
return B.map((x) => new DenseMatrix2({
|
|
data: x.map((e3) => [e3]),
|
|
size: [rows, 1]
|
|
}));
|
|
}
|
|
function _sparseBackwardSubstitution(m, b_) {
|
|
var B = [solveValidation(m, b_, true)._data.map((e3) => e3[0])];
|
|
var rows = m._size[0];
|
|
var columns = m._size[1];
|
|
var values = m._values;
|
|
var index2 = m._index;
|
|
var ptr = m._ptr;
|
|
for (var i2 = columns - 1; i2 >= 0; i2--) {
|
|
var L = B.length;
|
|
for (var k = 0; k < L; k++) {
|
|
var b = B[k];
|
|
var iValues = [];
|
|
var iIndices = [];
|
|
var firstIndex = ptr[i2];
|
|
var lastIndex = ptr[i2 + 1];
|
|
var Mii = 0;
|
|
for (var j = lastIndex - 1; j >= firstIndex; j--) {
|
|
var J = index2[j];
|
|
if (J === i2) {
|
|
Mii = values[j];
|
|
} else if (J < i2) {
|
|
iValues.push(values[j]);
|
|
iIndices.push(J);
|
|
}
|
|
}
|
|
if (!equalScalar2(Mii, 0)) {
|
|
b[i2] = divideScalar2(b[i2], Mii);
|
|
for (var _j2 = 0, _lastIndex = iIndices.length; _j2 < _lastIndex; _j2++) {
|
|
var _J = iIndices[_j2];
|
|
b[_J] = subtract2(b[_J], multiplyScalar2(b[i2], iValues[_j2]));
|
|
}
|
|
} else if (!equalScalar2(b[i2], 0)) {
|
|
if (k === 0) {
|
|
return [];
|
|
} else {
|
|
B.splice(k, 1);
|
|
k -= 1;
|
|
L -= 1;
|
|
}
|
|
} else if (k === 0) {
|
|
var bNew = [...b];
|
|
bNew[i2] = 1;
|
|
for (var _j3 = 0, _lastIndex2 = iIndices.length; _j3 < _lastIndex2; _j3++) {
|
|
var _J2 = iIndices[_j3];
|
|
bNew[_J2] = subtract2(bNew[_J2], iValues[_j3]);
|
|
}
|
|
B.push(bNew);
|
|
}
|
|
}
|
|
}
|
|
return B.map((x) => new DenseMatrix2({
|
|
data: x.map((e3) => [e3]),
|
|
size: [rows, 1]
|
|
}));
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/utils/matAlgo08xS0Sid.js
|
|
var name134 = "matAlgo08xS0Sid";
|
|
var dependencies134 = ["typed", "equalScalar"];
|
|
var createMatAlgo08xS0Sid = /* @__PURE__ */ factory(name134, dependencies134, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
} = _ref;
|
|
return function matAlgo08xS0Sid(a, b, callback) {
|
|
var avalues = a._values;
|
|
var aindex = a._index;
|
|
var aptr = a._ptr;
|
|
var asize = a._size;
|
|
var adt = a._datatype;
|
|
var bvalues = b._values;
|
|
var bindex = b._index;
|
|
var bptr = b._ptr;
|
|
var bsize = b._size;
|
|
var bdt = b._datatype;
|
|
if (asize.length !== bsize.length) {
|
|
throw new DimensionError(asize.length, bsize.length);
|
|
}
|
|
if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) {
|
|
throw new RangeError("Dimension mismatch. Matrix A (" + asize + ") must match Matrix B (" + bsize + ")");
|
|
}
|
|
if (!avalues || !bvalues) {
|
|
throw new Error("Cannot perform operation on Pattern Sparse Matrices");
|
|
}
|
|
var rows = asize[0];
|
|
var columns = asize[1];
|
|
var dt;
|
|
var eq = equalScalar2;
|
|
var zero = 0;
|
|
var cf = callback;
|
|
if (typeof adt === "string" && adt === bdt) {
|
|
dt = adt;
|
|
eq = typed2.find(equalScalar2, [dt, dt]);
|
|
zero = typed2.convert(0, dt);
|
|
cf = typed2.find(callback, [dt, dt]);
|
|
}
|
|
var cvalues = [];
|
|
var cindex = [];
|
|
var cptr = [];
|
|
var x = [];
|
|
var w = [];
|
|
var k, k0, k1, i2;
|
|
for (var j = 0; j < columns; j++) {
|
|
cptr[j] = cindex.length;
|
|
var mark = j + 1;
|
|
for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) {
|
|
i2 = aindex[k];
|
|
w[i2] = mark;
|
|
x[i2] = avalues[k];
|
|
cindex.push(i2);
|
|
}
|
|
for (k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) {
|
|
i2 = bindex[k];
|
|
if (w[i2] === mark) {
|
|
x[i2] = cf(x[i2], bvalues[k]);
|
|
}
|
|
}
|
|
k = cptr[j];
|
|
while (k < cindex.length) {
|
|
i2 = cindex[k];
|
|
var v = x[i2];
|
|
if (!eq(v, zero)) {
|
|
cvalues.push(v);
|
|
k++;
|
|
} else {
|
|
cindex.splice(k, 1);
|
|
}
|
|
}
|
|
}
|
|
cptr[columns] = cindex.length;
|
|
return a.createSparseMatrix({
|
|
values: cvalues,
|
|
index: cindex,
|
|
ptr: cptr,
|
|
size: [rows, columns],
|
|
datatype: dt
|
|
});
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/bitwise/useMatrixForArrayScalar.js
|
|
var createUseMatrixForArrayScalar = /* @__PURE__ */ factory("useMatrixForArrayScalar", ["typed", "matrix"], (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2
|
|
} = _ref;
|
|
return {
|
|
"Array, number": typed2.referTo("DenseMatrix, number", (selfDn) => (x, y) => selfDn(matrix2(x), y).valueOf()),
|
|
"Array, BigNumber": typed2.referTo("DenseMatrix, BigNumber", (selfDB) => (x, y) => selfDB(matrix2(x), y).valueOf()),
|
|
"number, Array": typed2.referTo("number, DenseMatrix", (selfnD) => (x, y) => selfnD(x, matrix2(y)).valueOf()),
|
|
"BigNumber, Array": typed2.referTo("BigNumber, DenseMatrix", (selfBD) => (x, y) => selfBD(x, matrix2(y)).valueOf())
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/bitwise/leftShift.js
|
|
var name135 = "leftShift";
|
|
var dependencies135 = ["typed", "matrix", "equalScalar", "zeros", "DenseMatrix", "concat"];
|
|
var createLeftShift = /* @__PURE__ */ factory(name135, dependencies135, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
equalScalar: equalScalar2,
|
|
zeros: zeros3,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo01xDSid = createMatAlgo01xDSid({
|
|
typed: typed2
|
|
});
|
|
var matAlgo02xDS0 = createMatAlgo02xDS0({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo08xS0Sid = createMatAlgo08xS0Sid({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo10xSids = createMatAlgo10xSids({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matAlgo11xS0s = createMatAlgo11xS0s({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo14xDs = createMatAlgo14xDs({
|
|
typed: typed2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
var useMatrixForArrayScalar = createUseMatrixForArrayScalar({
|
|
typed: typed2,
|
|
matrix: matrix2
|
|
});
|
|
return typed2(name135, {
|
|
"number, number": leftShiftNumber,
|
|
"BigNumber, BigNumber": leftShiftBigNumber,
|
|
"SparseMatrix, number | BigNumber": typed2.referToSelf((self2) => (x, y) => {
|
|
if (equalScalar2(y, 0)) {
|
|
return x.clone();
|
|
}
|
|
return matAlgo11xS0s(x, y, self2, false);
|
|
}),
|
|
"DenseMatrix, number | BigNumber": typed2.referToSelf((self2) => (x, y) => {
|
|
if (equalScalar2(y, 0)) {
|
|
return x.clone();
|
|
}
|
|
return matAlgo14xDs(x, y, self2, false);
|
|
}),
|
|
"number | BigNumber, SparseMatrix": typed2.referToSelf((self2) => (x, y) => {
|
|
if (equalScalar2(x, 0)) {
|
|
return zeros3(y.size(), y.storage());
|
|
}
|
|
return matAlgo10xSids(y, x, self2, true);
|
|
}),
|
|
"number | BigNumber, DenseMatrix": typed2.referToSelf((self2) => (x, y) => {
|
|
if (equalScalar2(x, 0)) {
|
|
return zeros3(y.size(), y.storage());
|
|
}
|
|
return matAlgo14xDs(y, x, self2, true);
|
|
})
|
|
}, useMatrixForArrayScalar, matrixAlgorithmSuite({
|
|
SS: matAlgo08xS0Sid,
|
|
DS: matAlgo01xDSid,
|
|
SD: matAlgo02xDS0
|
|
}));
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/bitwise/rightArithShift.js
|
|
var name136 = "rightArithShift";
|
|
var dependencies136 = ["typed", "matrix", "equalScalar", "zeros", "DenseMatrix", "concat"];
|
|
var createRightArithShift = /* @__PURE__ */ factory(name136, dependencies136, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
equalScalar: equalScalar2,
|
|
zeros: zeros3,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo01xDSid = createMatAlgo01xDSid({
|
|
typed: typed2
|
|
});
|
|
var matAlgo02xDS0 = createMatAlgo02xDS0({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo08xS0Sid = createMatAlgo08xS0Sid({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo10xSids = createMatAlgo10xSids({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matAlgo11xS0s = createMatAlgo11xS0s({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo14xDs = createMatAlgo14xDs({
|
|
typed: typed2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
var useMatrixForArrayScalar = createUseMatrixForArrayScalar({
|
|
typed: typed2,
|
|
matrix: matrix2
|
|
});
|
|
return typed2(name136, {
|
|
"number, number": rightArithShiftNumber,
|
|
"BigNumber, BigNumber": rightArithShiftBigNumber,
|
|
"SparseMatrix, number | BigNumber": typed2.referToSelf((self2) => (x, y) => {
|
|
if (equalScalar2(y, 0)) {
|
|
return x.clone();
|
|
}
|
|
return matAlgo11xS0s(x, y, self2, false);
|
|
}),
|
|
"DenseMatrix, number | BigNumber": typed2.referToSelf((self2) => (x, y) => {
|
|
if (equalScalar2(y, 0)) {
|
|
return x.clone();
|
|
}
|
|
return matAlgo14xDs(x, y, self2, false);
|
|
}),
|
|
"number | BigNumber, SparseMatrix": typed2.referToSelf((self2) => (x, y) => {
|
|
if (equalScalar2(x, 0)) {
|
|
return zeros3(y.size(), y.storage());
|
|
}
|
|
return matAlgo10xSids(y, x, self2, true);
|
|
}),
|
|
"number | BigNumber, DenseMatrix": typed2.referToSelf((self2) => (x, y) => {
|
|
if (equalScalar2(x, 0)) {
|
|
return zeros3(y.size(), y.storage());
|
|
}
|
|
return matAlgo14xDs(y, x, self2, true);
|
|
})
|
|
}, useMatrixForArrayScalar, matrixAlgorithmSuite({
|
|
SS: matAlgo08xS0Sid,
|
|
DS: matAlgo01xDSid,
|
|
SD: matAlgo02xDS0
|
|
}));
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/bitwise/rightLogShift.js
|
|
var name137 = "rightLogShift";
|
|
var dependencies137 = ["typed", "matrix", "equalScalar", "zeros", "DenseMatrix", "concat"];
|
|
var createRightLogShift = /* @__PURE__ */ factory(name137, dependencies137, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
equalScalar: equalScalar2,
|
|
zeros: zeros3,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo01xDSid = createMatAlgo01xDSid({
|
|
typed: typed2
|
|
});
|
|
var matAlgo02xDS0 = createMatAlgo02xDS0({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo08xS0Sid = createMatAlgo08xS0Sid({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo10xSids = createMatAlgo10xSids({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matAlgo11xS0s = createMatAlgo11xS0s({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo14xDs = createMatAlgo14xDs({
|
|
typed: typed2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
var useMatrixForArrayScalar = createUseMatrixForArrayScalar({
|
|
typed: typed2,
|
|
matrix: matrix2
|
|
});
|
|
return typed2(name137, {
|
|
"number, number": rightLogShiftNumber,
|
|
"SparseMatrix, number | BigNumber": typed2.referToSelf((self2) => (x, y) => {
|
|
if (equalScalar2(y, 0)) {
|
|
return x.clone();
|
|
}
|
|
return matAlgo11xS0s(x, y, self2, false);
|
|
}),
|
|
"DenseMatrix, number | BigNumber": typed2.referToSelf((self2) => (x, y) => {
|
|
if (equalScalar2(y, 0)) {
|
|
return x.clone();
|
|
}
|
|
return matAlgo14xDs(x, y, self2, false);
|
|
}),
|
|
"number | BigNumber, SparseMatrix": typed2.referToSelf((self2) => (x, y) => {
|
|
if (equalScalar2(x, 0)) {
|
|
return zeros3(y.size(), y.storage());
|
|
}
|
|
return matAlgo10xSids(y, x, self2, true);
|
|
}),
|
|
"number | BigNumber, DenseMatrix": typed2.referToSelf((self2) => (x, y) => {
|
|
if (equalScalar2(x, 0)) {
|
|
return zeros3(y.size(), y.storage());
|
|
}
|
|
return matAlgo14xDs(y, x, self2, true);
|
|
})
|
|
}, useMatrixForArrayScalar, matrixAlgorithmSuite({
|
|
SS: matAlgo08xS0Sid,
|
|
DS: matAlgo01xDSid,
|
|
SD: matAlgo02xDS0
|
|
}));
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/logical/and.js
|
|
var name138 = "and";
|
|
var dependencies138 = ["typed", "matrix", "equalScalar", "zeros", "not", "concat"];
|
|
var createAnd = /* @__PURE__ */ factory(name138, dependencies138, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
equalScalar: equalScalar2,
|
|
zeros: zeros3,
|
|
not: not2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo02xDS0 = createMatAlgo02xDS0({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo06xS0S0 = createMatAlgo06xS0S0({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo11xS0s = createMatAlgo11xS0s({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo14xDs = createMatAlgo14xDs({
|
|
typed: typed2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
return typed2(name138, {
|
|
"number, number": andNumber,
|
|
"Complex, Complex": function ComplexComplex(x, y) {
|
|
return (x.re !== 0 || x.im !== 0) && (y.re !== 0 || y.im !== 0);
|
|
},
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(x, y) {
|
|
return !x.isZero() && !y.isZero() && !x.isNaN() && !y.isNaN();
|
|
},
|
|
"Unit, Unit": typed2.referToSelf((self2) => (x, y) => self2(x.value || 0, y.value || 0)),
|
|
"SparseMatrix, any": typed2.referToSelf((self2) => (x, y) => {
|
|
if (not2(y)) {
|
|
return zeros3(x.size(), x.storage());
|
|
}
|
|
return matAlgo11xS0s(x, y, self2, false);
|
|
}),
|
|
"DenseMatrix, any": typed2.referToSelf((self2) => (x, y) => {
|
|
if (not2(y)) {
|
|
return zeros3(x.size(), x.storage());
|
|
}
|
|
return matAlgo14xDs(x, y, self2, false);
|
|
}),
|
|
"any, SparseMatrix": typed2.referToSelf((self2) => (x, y) => {
|
|
if (not2(x)) {
|
|
return zeros3(x.size(), x.storage());
|
|
}
|
|
return matAlgo11xS0s(y, x, self2, true);
|
|
}),
|
|
"any, DenseMatrix": typed2.referToSelf((self2) => (x, y) => {
|
|
if (not2(x)) {
|
|
return zeros3(x.size(), x.storage());
|
|
}
|
|
return matAlgo14xDs(y, x, self2, true);
|
|
}),
|
|
"Array, any": typed2.referToSelf((self2) => (x, y) => {
|
|
return self2(matrix2(x), y).valueOf();
|
|
}),
|
|
"any, Array": typed2.referToSelf((self2) => (x, y) => {
|
|
return self2(x, matrix2(y)).valueOf();
|
|
})
|
|
}, matrixAlgorithmSuite({
|
|
SS: matAlgo06xS0S0,
|
|
DS: matAlgo02xDS0
|
|
}));
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/relational/compare.js
|
|
var name139 = "compare";
|
|
var dependencies139 = ["typed", "config", "matrix", "equalScalar", "BigNumber", "Fraction", "DenseMatrix", "concat"];
|
|
var createCompare = /* @__PURE__ */ factory(name139, dependencies139, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
equalScalar: equalScalar2,
|
|
matrix: matrix2,
|
|
BigNumber: BigNumber2,
|
|
Fraction: Fraction3,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo03xDSf = createMatAlgo03xDSf({
|
|
typed: typed2
|
|
});
|
|
var matAlgo05xSfSf = createMatAlgo05xSfSf({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
var compareUnits = createCompareUnits({
|
|
typed: typed2
|
|
});
|
|
return typed2(name139, createCompareNumber({
|
|
typed: typed2,
|
|
config: config4
|
|
}), {
|
|
"boolean, boolean": function booleanBoolean(x, y) {
|
|
return x === y ? 0 : x > y ? 1 : -1;
|
|
},
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(x, y) {
|
|
return nearlyEqual2(x, y, config4.epsilon) ? new BigNumber2(0) : new BigNumber2(x.cmp(y));
|
|
},
|
|
"Fraction, Fraction": function FractionFraction(x, y) {
|
|
return new Fraction3(x.compare(y));
|
|
},
|
|
"Complex, Complex": function ComplexComplex() {
|
|
throw new TypeError("No ordering relation is defined for complex numbers");
|
|
}
|
|
}, compareUnits, matrixAlgorithmSuite({
|
|
SS: matAlgo05xSfSf,
|
|
DS: matAlgo03xDSf,
|
|
Ss: matAlgo12xSfs
|
|
}));
|
|
});
|
|
var createCompareNumber = /* @__PURE__ */ factory(name139, ["typed", "config"], (_ref2) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4
|
|
} = _ref2;
|
|
return typed2(name139, {
|
|
"number, number": function numberNumber(x, y) {
|
|
return nearlyEqual(x, y, config4.epsilon) ? 0 : x > y ? 1 : -1;
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/relational/compareNatural.js
|
|
var import_javascript_natural_sort = __toESM(require_naturalSort(), 1);
|
|
var name140 = "compareNatural";
|
|
var dependencies140 = ["typed", "compare"];
|
|
var createCompareNatural = /* @__PURE__ */ factory(name140, dependencies140, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
compare: compare2
|
|
} = _ref;
|
|
var compareBooleans = compare2.signatures["boolean,boolean"];
|
|
return typed2(name140, {
|
|
"any, any": _compareNatural
|
|
});
|
|
function _compareNatural(x, y) {
|
|
var typeX = typeOf(x);
|
|
var typeY = typeOf(y);
|
|
var c;
|
|
if ((typeX === "number" || typeX === "BigNumber" || typeX === "Fraction") && (typeY === "number" || typeY === "BigNumber" || typeY === "Fraction")) {
|
|
c = compare2(x, y);
|
|
if (c.toString() !== "0") {
|
|
return c > 0 ? 1 : -1;
|
|
} else {
|
|
return (0, import_javascript_natural_sort.default)(typeX, typeY);
|
|
}
|
|
}
|
|
var matTypes = ["Array", "DenseMatrix", "SparseMatrix"];
|
|
if (matTypes.includes(typeX) || matTypes.includes(typeY)) {
|
|
c = compareMatricesAndArrays(_compareNatural, x, y);
|
|
if (c !== 0) {
|
|
return c;
|
|
} else {
|
|
return (0, import_javascript_natural_sort.default)(typeX, typeY);
|
|
}
|
|
}
|
|
if (typeX !== typeY) {
|
|
return (0, import_javascript_natural_sort.default)(typeX, typeY);
|
|
}
|
|
if (typeX === "Complex") {
|
|
return compareComplexNumbers(x, y);
|
|
}
|
|
if (typeX === "Unit") {
|
|
if (x.equalBase(y)) {
|
|
return _compareNatural(x.value, y.value);
|
|
}
|
|
return compareArrays(_compareNatural, x.formatUnits(), y.formatUnits());
|
|
}
|
|
if (typeX === "boolean") {
|
|
return compareBooleans(x, y);
|
|
}
|
|
if (typeX === "string") {
|
|
return (0, import_javascript_natural_sort.default)(x, y);
|
|
}
|
|
if (typeX === "Object") {
|
|
return compareObjects(_compareNatural, x, y);
|
|
}
|
|
if (typeX === "null") {
|
|
return 0;
|
|
}
|
|
if (typeX === "undefined") {
|
|
return 0;
|
|
}
|
|
throw new TypeError('Unsupported type of value "' + typeX + '"');
|
|
}
|
|
function compareMatricesAndArrays(compareNatural2, x, y) {
|
|
if (isSparseMatrix(x) && isSparseMatrix(y)) {
|
|
return compareArrays(compareNatural2, x.toJSON().values, y.toJSON().values);
|
|
}
|
|
if (isSparseMatrix(x)) {
|
|
return compareMatricesAndArrays(compareNatural2, x.toArray(), y);
|
|
}
|
|
if (isSparseMatrix(y)) {
|
|
return compareMatricesAndArrays(compareNatural2, x, y.toArray());
|
|
}
|
|
if (isDenseMatrix(x)) {
|
|
return compareMatricesAndArrays(compareNatural2, x.toJSON().data, y);
|
|
}
|
|
if (isDenseMatrix(y)) {
|
|
return compareMatricesAndArrays(compareNatural2, x, y.toJSON().data);
|
|
}
|
|
if (!Array.isArray(x)) {
|
|
return compareMatricesAndArrays(compareNatural2, [x], y);
|
|
}
|
|
if (!Array.isArray(y)) {
|
|
return compareMatricesAndArrays(compareNatural2, x, [y]);
|
|
}
|
|
return compareArrays(compareNatural2, x, y);
|
|
}
|
|
function compareArrays(compareNatural2, x, y) {
|
|
for (var i2 = 0, ii = Math.min(x.length, y.length); i2 < ii; i2++) {
|
|
var v = compareNatural2(x[i2], y[i2]);
|
|
if (v !== 0) {
|
|
return v;
|
|
}
|
|
}
|
|
if (x.length > y.length) {
|
|
return 1;
|
|
}
|
|
if (x.length < y.length) {
|
|
return -1;
|
|
}
|
|
return 0;
|
|
}
|
|
function compareObjects(compareNatural2, x, y) {
|
|
var keysX = Object.keys(x);
|
|
var keysY = Object.keys(y);
|
|
keysX.sort(import_javascript_natural_sort.default);
|
|
keysY.sort(import_javascript_natural_sort.default);
|
|
var c = compareArrays(compareNatural2, keysX, keysY);
|
|
if (c !== 0) {
|
|
return c;
|
|
}
|
|
for (var i2 = 0; i2 < keysX.length; i2++) {
|
|
var v = compareNatural2(x[keysX[i2]], y[keysY[i2]]);
|
|
if (v !== 0) {
|
|
return v;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
});
|
|
function compareComplexNumbers(x, y) {
|
|
if (x.re > y.re) {
|
|
return 1;
|
|
}
|
|
if (x.re < y.re) {
|
|
return -1;
|
|
}
|
|
if (x.im > y.im) {
|
|
return 1;
|
|
}
|
|
if (x.im < y.im) {
|
|
return -1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/relational/compareText.js
|
|
var name141 = "compareText";
|
|
var dependencies141 = ["typed", "matrix", "concat"];
|
|
compareText.signature = "any, any";
|
|
var createCompareText = /* @__PURE__ */ factory(name141, dependencies141, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
return typed2(name141, compareText, matrixAlgorithmSuite({
|
|
elop: compareText,
|
|
Ds: true
|
|
}));
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/relational/equal.js
|
|
var name142 = "equal";
|
|
var dependencies142 = ["typed", "matrix", "equalScalar", "DenseMatrix", "concat"];
|
|
var createEqual = /* @__PURE__ */ factory(name142, dependencies142, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
equalScalar: equalScalar2,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo03xDSf = createMatAlgo03xDSf({
|
|
typed: typed2
|
|
});
|
|
var matAlgo07xSSf = createMatAlgo07xSSf({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
return typed2(name142, createEqualNumber({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
}), matrixAlgorithmSuite({
|
|
elop: equalScalar2,
|
|
SS: matAlgo07xSSf,
|
|
DS: matAlgo03xDSf,
|
|
Ss: matAlgo12xSfs
|
|
}));
|
|
});
|
|
var createEqualNumber = factory(name142, ["typed", "equalScalar"], (_ref2) => {
|
|
var {
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
} = _ref2;
|
|
return typed2(name142, {
|
|
"any, any": function anyAny(x, y) {
|
|
if (x === null) {
|
|
return y === null;
|
|
}
|
|
if (y === null) {
|
|
return x === null;
|
|
}
|
|
if (x === void 0) {
|
|
return y === void 0;
|
|
}
|
|
if (y === void 0) {
|
|
return x === void 0;
|
|
}
|
|
return equalScalar2(x, y);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/relational/equalText.js
|
|
var name143 = "equalText";
|
|
var dependencies143 = ["typed", "compareText", "isZero"];
|
|
var createEqualText = /* @__PURE__ */ factory(name143, dependencies143, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
compareText: compareText3,
|
|
isZero: isZero2
|
|
} = _ref;
|
|
return typed2(name143, {
|
|
"any, any": function anyAny(x, y) {
|
|
return isZero2(compareText3(x, y));
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/relational/smaller.js
|
|
var name144 = "smaller";
|
|
var dependencies144 = ["typed", "config", "matrix", "DenseMatrix", "concat"];
|
|
var createSmaller = /* @__PURE__ */ factory(name144, dependencies144, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
matrix: matrix2,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo03xDSf = createMatAlgo03xDSf({
|
|
typed: typed2
|
|
});
|
|
var matAlgo07xSSf = createMatAlgo07xSSf({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
var compareUnits = createCompareUnits({
|
|
typed: typed2
|
|
});
|
|
return typed2(name144, createSmallerNumber({
|
|
typed: typed2,
|
|
config: config4
|
|
}), {
|
|
"boolean, boolean": (x, y) => x < y,
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(x, y) {
|
|
return x.lt(y) && !nearlyEqual2(x, y, config4.epsilon);
|
|
},
|
|
"Fraction, Fraction": (x, y) => x.compare(y) === -1,
|
|
"Complex, Complex": function ComplexComplex(x, y) {
|
|
throw new TypeError("No ordering relation is defined for complex numbers");
|
|
}
|
|
}, compareUnits, matrixAlgorithmSuite({
|
|
SS: matAlgo07xSSf,
|
|
DS: matAlgo03xDSf,
|
|
Ss: matAlgo12xSfs
|
|
}));
|
|
});
|
|
var createSmallerNumber = /* @__PURE__ */ factory(name144, ["typed", "config"], (_ref2) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4
|
|
} = _ref2;
|
|
return typed2(name144, {
|
|
"number, number": function numberNumber(x, y) {
|
|
return x < y && !nearlyEqual(x, y, config4.epsilon);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/relational/smallerEq.js
|
|
var name145 = "smallerEq";
|
|
var dependencies145 = ["typed", "config", "matrix", "DenseMatrix", "concat"];
|
|
var createSmallerEq = /* @__PURE__ */ factory(name145, dependencies145, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
matrix: matrix2,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo03xDSf = createMatAlgo03xDSf({
|
|
typed: typed2
|
|
});
|
|
var matAlgo07xSSf = createMatAlgo07xSSf({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
var compareUnits = createCompareUnits({
|
|
typed: typed2
|
|
});
|
|
return typed2(name145, createSmallerEqNumber({
|
|
typed: typed2,
|
|
config: config4
|
|
}), {
|
|
"boolean, boolean": (x, y) => x <= y,
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(x, y) {
|
|
return x.lte(y) || nearlyEqual2(x, y, config4.epsilon);
|
|
},
|
|
"Fraction, Fraction": (x, y) => x.compare(y) !== 1,
|
|
"Complex, Complex": function ComplexComplex() {
|
|
throw new TypeError("No ordering relation is defined for complex numbers");
|
|
}
|
|
}, compareUnits, matrixAlgorithmSuite({
|
|
SS: matAlgo07xSSf,
|
|
DS: matAlgo03xDSf,
|
|
Ss: matAlgo12xSfs
|
|
}));
|
|
});
|
|
var createSmallerEqNumber = /* @__PURE__ */ factory(name145, ["typed", "config"], (_ref2) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4
|
|
} = _ref2;
|
|
return typed2(name145, {
|
|
"number, number": function numberNumber(x, y) {
|
|
return x <= y || nearlyEqual(x, y, config4.epsilon);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/relational/larger.js
|
|
var name146 = "larger";
|
|
var dependencies146 = ["typed", "config", "matrix", "DenseMatrix", "concat"];
|
|
var createLarger = /* @__PURE__ */ factory(name146, dependencies146, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
matrix: matrix2,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo03xDSf = createMatAlgo03xDSf({
|
|
typed: typed2
|
|
});
|
|
var matAlgo07xSSf = createMatAlgo07xSSf({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
var compareUnits = createCompareUnits({
|
|
typed: typed2
|
|
});
|
|
return typed2(name146, createLargerNumber({
|
|
typed: typed2,
|
|
config: config4
|
|
}), {
|
|
"boolean, boolean": (x, y) => x > y,
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(x, y) {
|
|
return x.gt(y) && !nearlyEqual2(x, y, config4.epsilon);
|
|
},
|
|
"Fraction, Fraction": (x, y) => x.compare(y) === 1,
|
|
"Complex, Complex": function ComplexComplex() {
|
|
throw new TypeError("No ordering relation is defined for complex numbers");
|
|
}
|
|
}, compareUnits, matrixAlgorithmSuite({
|
|
SS: matAlgo07xSSf,
|
|
DS: matAlgo03xDSf,
|
|
Ss: matAlgo12xSfs
|
|
}));
|
|
});
|
|
var createLargerNumber = /* @__PURE__ */ factory(name146, ["typed", "config"], (_ref2) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4
|
|
} = _ref2;
|
|
return typed2(name146, {
|
|
"number, number": function numberNumber(x, y) {
|
|
return x > y && !nearlyEqual(x, y, config4.epsilon);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/relational/largerEq.js
|
|
var name147 = "largerEq";
|
|
var dependencies147 = ["typed", "config", "matrix", "DenseMatrix", "concat"];
|
|
var createLargerEq = /* @__PURE__ */ factory(name147, dependencies147, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
matrix: matrix2,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo03xDSf = createMatAlgo03xDSf({
|
|
typed: typed2
|
|
});
|
|
var matAlgo07xSSf = createMatAlgo07xSSf({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
var compareUnits = createCompareUnits({
|
|
typed: typed2
|
|
});
|
|
return typed2(name147, createLargerEqNumber({
|
|
typed: typed2,
|
|
config: config4
|
|
}), {
|
|
"boolean, boolean": (x, y) => x >= y,
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(x, y) {
|
|
return x.gte(y) || nearlyEqual2(x, y, config4.epsilon);
|
|
},
|
|
"Fraction, Fraction": (x, y) => x.compare(y) !== -1,
|
|
"Complex, Complex": function ComplexComplex() {
|
|
throw new TypeError("No ordering relation is defined for complex numbers");
|
|
}
|
|
}, compareUnits, matrixAlgorithmSuite({
|
|
SS: matAlgo07xSSf,
|
|
DS: matAlgo03xDSf,
|
|
Ss: matAlgo12xSfs
|
|
}));
|
|
});
|
|
var createLargerEqNumber = /* @__PURE__ */ factory(name147, ["typed", "config"], (_ref2) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4
|
|
} = _ref2;
|
|
return typed2(name147, {
|
|
"number, number": function numberNumber(x, y) {
|
|
return x >= y || nearlyEqual(x, y, config4.epsilon);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/relational/deepEqual.js
|
|
var name148 = "deepEqual";
|
|
var dependencies148 = ["typed", "equal"];
|
|
var createDeepEqual = /* @__PURE__ */ factory(name148, dependencies148, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
equal: equal2
|
|
} = _ref;
|
|
return typed2(name148, {
|
|
"any, any": function anyAny(x, y) {
|
|
return _deepEqual(x.valueOf(), y.valueOf());
|
|
}
|
|
});
|
|
function _deepEqual(x, y) {
|
|
if (Array.isArray(x)) {
|
|
if (Array.isArray(y)) {
|
|
var len = x.length;
|
|
if (len !== y.length) {
|
|
return false;
|
|
}
|
|
for (var i2 = 0; i2 < len; i2++) {
|
|
if (!_deepEqual(x[i2], y[i2])) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
} else {
|
|
if (Array.isArray(y)) {
|
|
return false;
|
|
} else {
|
|
return equal2(x, y);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/relational/unequal.js
|
|
var name149 = "unequal";
|
|
var dependencies149 = ["typed", "config", "equalScalar", "matrix", "DenseMatrix", "concat"];
|
|
var createUnequal = /* @__PURE__ */ factory(name149, dependencies149, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
equalScalar: equalScalar2,
|
|
matrix: matrix2,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo03xDSf = createMatAlgo03xDSf({
|
|
typed: typed2
|
|
});
|
|
var matAlgo07xSSf = createMatAlgo07xSSf({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
return typed2(name149, createUnequalNumber({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
}), matrixAlgorithmSuite({
|
|
elop: _unequal,
|
|
SS: matAlgo07xSSf,
|
|
DS: matAlgo03xDSf,
|
|
Ss: matAlgo12xSfs
|
|
}));
|
|
function _unequal(x, y) {
|
|
return !equalScalar2(x, y);
|
|
}
|
|
});
|
|
var createUnequalNumber = factory(name149, ["typed", "equalScalar"], (_ref2) => {
|
|
var {
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
} = _ref2;
|
|
return typed2(name149, {
|
|
"any, any": function anyAny(x, y) {
|
|
if (x === null) {
|
|
return y !== null;
|
|
}
|
|
if (y === null) {
|
|
return x !== null;
|
|
}
|
|
if (x === void 0) {
|
|
return y !== void 0;
|
|
}
|
|
if (y === void 0) {
|
|
return x !== void 0;
|
|
}
|
|
return !equalScalar2(x, y);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/partitionSelect.js
|
|
var name150 = "partitionSelect";
|
|
var dependencies150 = ["typed", "isNumeric", "isNaN", "compare"];
|
|
var createPartitionSelect = /* @__PURE__ */ factory(name150, dependencies150, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
isNumeric: isNumeric2,
|
|
isNaN: isNaN3,
|
|
compare: compare2
|
|
} = _ref;
|
|
var asc = compare2;
|
|
var desc = (a, b) => -compare2(a, b);
|
|
return typed2(name150, {
|
|
"Array | Matrix, number": function ArrayMatrixNumber(x, k) {
|
|
return _partitionSelect(x, k, asc);
|
|
},
|
|
"Array | Matrix, number, string": function ArrayMatrixNumberString(x, k, compare3) {
|
|
if (compare3 === "asc") {
|
|
return _partitionSelect(x, k, asc);
|
|
} else if (compare3 === "desc") {
|
|
return _partitionSelect(x, k, desc);
|
|
} else {
|
|
throw new Error('Compare string must be "asc" or "desc"');
|
|
}
|
|
},
|
|
"Array | Matrix, number, function": _partitionSelect
|
|
});
|
|
function _partitionSelect(x, k, compare3) {
|
|
if (!isInteger(k) || k < 0) {
|
|
throw new Error("k must be a non-negative integer");
|
|
}
|
|
if (isMatrix(x)) {
|
|
var size2 = x.size();
|
|
if (size2.length > 1) {
|
|
throw new Error("Only one dimensional matrices supported");
|
|
}
|
|
return quickSelect(x.valueOf(), k, compare3);
|
|
}
|
|
if (Array.isArray(x)) {
|
|
return quickSelect(x, k, compare3);
|
|
}
|
|
}
|
|
function quickSelect(arr, k, compare3) {
|
|
if (k >= arr.length) {
|
|
throw new Error("k out of bounds");
|
|
}
|
|
for (var i2 = 0; i2 < arr.length; i2++) {
|
|
if (isNumeric2(arr[i2]) && isNaN3(arr[i2])) {
|
|
return arr[i2];
|
|
}
|
|
}
|
|
var from = 0;
|
|
var to2 = arr.length - 1;
|
|
while (from < to2) {
|
|
var r = from;
|
|
var w = to2;
|
|
var pivot = arr[Math.floor(Math.random() * (to2 - from + 1)) + from];
|
|
while (r < w) {
|
|
if (compare3(arr[r], pivot) >= 0) {
|
|
var tmp = arr[w];
|
|
arr[w] = arr[r];
|
|
arr[r] = tmp;
|
|
--w;
|
|
} else {
|
|
++r;
|
|
}
|
|
}
|
|
if (compare3(arr[r], pivot) > 0) {
|
|
--r;
|
|
}
|
|
if (k <= r) {
|
|
to2 = r;
|
|
} else {
|
|
from = r + 1;
|
|
}
|
|
}
|
|
return arr[k];
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/sort.js
|
|
var name151 = "sort";
|
|
var dependencies151 = ["typed", "matrix", "compare", "compareNatural"];
|
|
var createSort = /* @__PURE__ */ factory(name151, dependencies151, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
compare: compare2,
|
|
compareNatural: compareNatural2
|
|
} = _ref;
|
|
var compareAsc = compare2;
|
|
var compareDesc = (a, b) => -compare2(a, b);
|
|
return typed2(name151, {
|
|
Array: function Array2(x) {
|
|
_arrayIsVector(x);
|
|
return x.sort(compareAsc);
|
|
},
|
|
Matrix: function Matrix2(x) {
|
|
_matrixIsVector(x);
|
|
return matrix2(x.toArray().sort(compareAsc), x.storage());
|
|
},
|
|
"Array, function": function ArrayFunction(x, _comparator2) {
|
|
_arrayIsVector(x);
|
|
return x.sort(_comparator2);
|
|
},
|
|
"Matrix, function": function MatrixFunction(x, _comparator2) {
|
|
_matrixIsVector(x);
|
|
return matrix2(x.toArray().sort(_comparator2), x.storage());
|
|
},
|
|
"Array, string": function ArrayString(x, order) {
|
|
_arrayIsVector(x);
|
|
return x.sort(_comparator(order));
|
|
},
|
|
"Matrix, string": function MatrixString(x, order) {
|
|
_matrixIsVector(x);
|
|
return matrix2(x.toArray().sort(_comparator(order)), x.storage());
|
|
}
|
|
});
|
|
function _comparator(order) {
|
|
if (order === "asc") {
|
|
return compareAsc;
|
|
} else if (order === "desc") {
|
|
return compareDesc;
|
|
} else if (order === "natural") {
|
|
return compareNatural2;
|
|
} else {
|
|
throw new Error('String "asc", "desc", or "natural" expected');
|
|
}
|
|
}
|
|
function _arrayIsVector(array) {
|
|
if (arraySize(array).length !== 1) {
|
|
throw new Error("One dimensional array expected");
|
|
}
|
|
}
|
|
function _matrixIsVector(matrix3) {
|
|
if (matrix3.size().length !== 1) {
|
|
throw new Error("One dimensional matrix expected");
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/statistics/max.js
|
|
var name152 = "max";
|
|
var dependencies152 = ["typed", "config", "numeric", "larger"];
|
|
var createMax = /* @__PURE__ */ factory(name152, dependencies152, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
numeric: numeric3,
|
|
larger: larger2
|
|
} = _ref;
|
|
return typed2(name152, {
|
|
"Array | Matrix": _max,
|
|
"Array | Matrix, number | BigNumber": function ArrayMatrixNumberBigNumber(array, dim) {
|
|
return reduce(array, dim.valueOf(), _largest);
|
|
},
|
|
"...": function _(args) {
|
|
if (containsCollections(args)) {
|
|
throw new TypeError("Scalar values expected in function max");
|
|
}
|
|
return _max(args);
|
|
}
|
|
});
|
|
function _largest(x, y) {
|
|
try {
|
|
return larger2(x, y) ? x : y;
|
|
} catch (err) {
|
|
throw improveErrorMessage(err, "max", y);
|
|
}
|
|
}
|
|
function _max(array) {
|
|
var res;
|
|
deepForEach(array, function(value) {
|
|
try {
|
|
if (isNaN(value) && typeof value === "number") {
|
|
res = NaN;
|
|
} else if (res === void 0 || larger2(value, res)) {
|
|
res = value;
|
|
}
|
|
} catch (err) {
|
|
throw improveErrorMessage(err, "max", value);
|
|
}
|
|
});
|
|
if (res === void 0) {
|
|
throw new Error("Cannot calculate max of an empty array");
|
|
}
|
|
if (typeof res === "string") {
|
|
res = numeric3(res, config4.number);
|
|
}
|
|
return res;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/statistics/min.js
|
|
var name153 = "min";
|
|
var dependencies153 = ["typed", "config", "numeric", "smaller"];
|
|
var createMin = /* @__PURE__ */ factory(name153, dependencies153, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
numeric: numeric3,
|
|
smaller: smaller2
|
|
} = _ref;
|
|
return typed2(name153, {
|
|
"Array | Matrix": _min,
|
|
"Array | Matrix, number | BigNumber": function ArrayMatrixNumberBigNumber(array, dim) {
|
|
return reduce(array, dim.valueOf(), _smallest);
|
|
},
|
|
"...": function _(args) {
|
|
if (containsCollections(args)) {
|
|
throw new TypeError("Scalar values expected in function min");
|
|
}
|
|
return _min(args);
|
|
}
|
|
});
|
|
function _smallest(x, y) {
|
|
try {
|
|
return smaller2(x, y) ? x : y;
|
|
} catch (err) {
|
|
throw improveErrorMessage(err, "min", y);
|
|
}
|
|
}
|
|
function _min(array) {
|
|
var min3;
|
|
deepForEach(array, function(value) {
|
|
try {
|
|
if (isNaN(value) && typeof value === "number") {
|
|
min3 = NaN;
|
|
} else if (min3 === void 0 || smaller2(value, min3)) {
|
|
min3 = value;
|
|
}
|
|
} catch (err) {
|
|
throw improveErrorMessage(err, "min", value);
|
|
}
|
|
});
|
|
if (min3 === void 0) {
|
|
throw new Error("Cannot calculate min of an empty array");
|
|
}
|
|
if (typeof min3 === "string") {
|
|
min3 = numeric3(min3, config4.number);
|
|
}
|
|
return min3;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/ImmutableDenseMatrix.js
|
|
var name154 = "ImmutableDenseMatrix";
|
|
var dependencies154 = ["smaller", "DenseMatrix"];
|
|
var createImmutableDenseMatrixClass = /* @__PURE__ */ factory(name154, dependencies154, (_ref) => {
|
|
var {
|
|
smaller: smaller2,
|
|
DenseMatrix: DenseMatrix2
|
|
} = _ref;
|
|
function ImmutableDenseMatrix2(data, datatype) {
|
|
if (!(this instanceof ImmutableDenseMatrix2)) {
|
|
throw new SyntaxError("Constructor must be called with the new operator");
|
|
}
|
|
if (datatype && !isString(datatype)) {
|
|
throw new Error("Invalid datatype: " + datatype);
|
|
}
|
|
if (isMatrix(data) || isArray(data)) {
|
|
var matrix2 = new DenseMatrix2(data, datatype);
|
|
this._data = matrix2._data;
|
|
this._size = matrix2._size;
|
|
this._datatype = matrix2._datatype;
|
|
this._min = null;
|
|
this._max = null;
|
|
} else if (data && isArray(data.data) && isArray(data.size)) {
|
|
this._data = data.data;
|
|
this._size = data.size;
|
|
this._datatype = data.datatype;
|
|
this._min = typeof data.min !== "undefined" ? data.min : null;
|
|
this._max = typeof data.max !== "undefined" ? data.max : null;
|
|
} else if (data) {
|
|
throw new TypeError("Unsupported type of data (" + typeOf(data) + ")");
|
|
} else {
|
|
this._data = [];
|
|
this._size = [0];
|
|
this._datatype = datatype;
|
|
this._min = null;
|
|
this._max = null;
|
|
}
|
|
}
|
|
ImmutableDenseMatrix2.prototype = new DenseMatrix2();
|
|
ImmutableDenseMatrix2.prototype.type = "ImmutableDenseMatrix";
|
|
ImmutableDenseMatrix2.prototype.isImmutableDenseMatrix = true;
|
|
ImmutableDenseMatrix2.prototype.subset = function(index2) {
|
|
switch (arguments.length) {
|
|
case 1: {
|
|
var m = DenseMatrix2.prototype.subset.call(this, index2);
|
|
if (isMatrix(m)) {
|
|
return new ImmutableDenseMatrix2({
|
|
data: m._data,
|
|
size: m._size,
|
|
datatype: m._datatype
|
|
});
|
|
}
|
|
return m;
|
|
}
|
|
case 2:
|
|
case 3:
|
|
throw new Error("Cannot invoke set subset on an Immutable Matrix instance");
|
|
default:
|
|
throw new SyntaxError("Wrong number of arguments");
|
|
}
|
|
};
|
|
ImmutableDenseMatrix2.prototype.set = function() {
|
|
throw new Error("Cannot invoke set on an Immutable Matrix instance");
|
|
};
|
|
ImmutableDenseMatrix2.prototype.resize = function() {
|
|
throw new Error("Cannot invoke resize on an Immutable Matrix instance");
|
|
};
|
|
ImmutableDenseMatrix2.prototype.reshape = function() {
|
|
throw new Error("Cannot invoke reshape on an Immutable Matrix instance");
|
|
};
|
|
ImmutableDenseMatrix2.prototype.clone = function() {
|
|
return new ImmutableDenseMatrix2({
|
|
data: clone(this._data),
|
|
size: clone(this._size),
|
|
datatype: this._datatype
|
|
});
|
|
};
|
|
ImmutableDenseMatrix2.prototype.toJSON = function() {
|
|
return {
|
|
mathjs: "ImmutableDenseMatrix",
|
|
data: this._data,
|
|
size: this._size,
|
|
datatype: this._datatype
|
|
};
|
|
};
|
|
ImmutableDenseMatrix2.fromJSON = function(json) {
|
|
return new ImmutableDenseMatrix2(json);
|
|
};
|
|
ImmutableDenseMatrix2.prototype.swapRows = function() {
|
|
throw new Error("Cannot invoke swapRows on an Immutable Matrix instance");
|
|
};
|
|
ImmutableDenseMatrix2.prototype.min = function() {
|
|
if (this._min === null) {
|
|
var m = null;
|
|
this.forEach(function(v) {
|
|
if (m === null || smaller2(v, m)) {
|
|
m = v;
|
|
}
|
|
});
|
|
this._min = m !== null ? m : void 0;
|
|
}
|
|
return this._min;
|
|
};
|
|
ImmutableDenseMatrix2.prototype.max = function() {
|
|
if (this._max === null) {
|
|
var m = null;
|
|
this.forEach(function(v) {
|
|
if (m === null || smaller2(m, v)) {
|
|
m = v;
|
|
}
|
|
});
|
|
this._max = m !== null ? m : void 0;
|
|
}
|
|
return this._max;
|
|
};
|
|
return ImmutableDenseMatrix2;
|
|
}, {
|
|
isClass: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/MatrixIndex.js
|
|
var name155 = "Index";
|
|
var dependencies155 = ["ImmutableDenseMatrix"];
|
|
var createIndexClass = /* @__PURE__ */ factory(name155, dependencies155, (_ref) => {
|
|
var {
|
|
ImmutableDenseMatrix: ImmutableDenseMatrix2
|
|
} = _ref;
|
|
function Index2(ranges) {
|
|
if (!(this instanceof Index2)) {
|
|
throw new SyntaxError("Constructor must be called with the new operator");
|
|
}
|
|
this._dimensions = [];
|
|
this._isScalar = true;
|
|
for (var i2 = 0, ii = arguments.length; i2 < ii; i2++) {
|
|
var arg2 = arguments[i2];
|
|
if (isRange(arg2)) {
|
|
this._dimensions.push(arg2);
|
|
this._isScalar = false;
|
|
} else if (Array.isArray(arg2) || isMatrix(arg2)) {
|
|
var m = _createImmutableMatrix(arg2.valueOf());
|
|
this._dimensions.push(m);
|
|
var size2 = m.size();
|
|
if (size2.length !== 1 || size2[0] !== 1) {
|
|
this._isScalar = false;
|
|
}
|
|
} else if (typeof arg2 === "number") {
|
|
this._dimensions.push(_createImmutableMatrix([arg2]));
|
|
} else if (typeof arg2 === "string") {
|
|
this._dimensions.push(arg2);
|
|
} else {
|
|
throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");
|
|
}
|
|
}
|
|
}
|
|
Index2.prototype.type = "Index";
|
|
Index2.prototype.isIndex = true;
|
|
function _createImmutableMatrix(arg2) {
|
|
for (var i2 = 0, l = arg2.length; i2 < l; i2++) {
|
|
if (typeof arg2[i2] !== "number" || !isInteger(arg2[i2])) {
|
|
throw new TypeError("Index parameters must be positive integer numbers");
|
|
}
|
|
}
|
|
return new ImmutableDenseMatrix2(arg2);
|
|
}
|
|
Index2.prototype.clone = function() {
|
|
var index2 = new Index2();
|
|
index2._dimensions = clone(this._dimensions);
|
|
index2._isScalar = this._isScalar;
|
|
return index2;
|
|
};
|
|
Index2.create = function(ranges) {
|
|
var index2 = new Index2();
|
|
Index2.apply(index2, ranges);
|
|
return index2;
|
|
};
|
|
Index2.prototype.size = function() {
|
|
var size2 = [];
|
|
for (var i2 = 0, ii = this._dimensions.length; i2 < ii; i2++) {
|
|
var d = this._dimensions[i2];
|
|
size2[i2] = typeof d === "string" ? 1 : d.size()[0];
|
|
}
|
|
return size2;
|
|
};
|
|
Index2.prototype.max = function() {
|
|
var values = [];
|
|
for (var i2 = 0, ii = this._dimensions.length; i2 < ii; i2++) {
|
|
var range2 = this._dimensions[i2];
|
|
values[i2] = typeof range2 === "string" ? range2 : range2.max();
|
|
}
|
|
return values;
|
|
};
|
|
Index2.prototype.min = function() {
|
|
var values = [];
|
|
for (var i2 = 0, ii = this._dimensions.length; i2 < ii; i2++) {
|
|
var range2 = this._dimensions[i2];
|
|
values[i2] = typeof range2 === "string" ? range2 : range2.min();
|
|
}
|
|
return values;
|
|
};
|
|
Index2.prototype.forEach = function(callback) {
|
|
for (var i2 = 0, ii = this._dimensions.length; i2 < ii; i2++) {
|
|
callback(this._dimensions[i2], i2, this);
|
|
}
|
|
};
|
|
Index2.prototype.dimension = function(dim) {
|
|
return this._dimensions[dim] || null;
|
|
};
|
|
Index2.prototype.isObjectProperty = function() {
|
|
return this._dimensions.length === 1 && typeof this._dimensions[0] === "string";
|
|
};
|
|
Index2.prototype.getObjectProperty = function() {
|
|
return this.isObjectProperty() ? this._dimensions[0] : null;
|
|
};
|
|
Index2.prototype.isScalar = function() {
|
|
return this._isScalar;
|
|
};
|
|
Index2.prototype.toArray = function() {
|
|
var array = [];
|
|
for (var i2 = 0, ii = this._dimensions.length; i2 < ii; i2++) {
|
|
var dimension = this._dimensions[i2];
|
|
array.push(typeof dimension === "string" ? dimension : dimension.toArray());
|
|
}
|
|
return array;
|
|
};
|
|
Index2.prototype.valueOf = Index2.prototype.toArray;
|
|
Index2.prototype.toString = function() {
|
|
var strings = [];
|
|
for (var i2 = 0, ii = this._dimensions.length; i2 < ii; i2++) {
|
|
var dimension = this._dimensions[i2];
|
|
if (typeof dimension === "string") {
|
|
strings.push(JSON.stringify(dimension));
|
|
} else {
|
|
strings.push(dimension.toString());
|
|
}
|
|
}
|
|
return "[" + strings.join(", ") + "]";
|
|
};
|
|
Index2.prototype.toJSON = function() {
|
|
return {
|
|
mathjs: "Index",
|
|
dimensions: this._dimensions
|
|
};
|
|
};
|
|
Index2.fromJSON = function(json) {
|
|
return Index2.create(json.dimensions);
|
|
};
|
|
return Index2;
|
|
}, {
|
|
isClass: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/FibonacciHeap.js
|
|
var name156 = "FibonacciHeap";
|
|
var dependencies156 = ["smaller", "larger"];
|
|
var createFibonacciHeapClass = /* @__PURE__ */ factory(name156, dependencies156, (_ref) => {
|
|
var {
|
|
smaller: smaller2,
|
|
larger: larger2
|
|
} = _ref;
|
|
var oneOverLogPhi = 1 / Math.log((1 + Math.sqrt(5)) / 2);
|
|
function FibonacciHeap2() {
|
|
if (!(this instanceof FibonacciHeap2)) {
|
|
throw new SyntaxError("Constructor must be called with the new operator");
|
|
}
|
|
this._minimum = null;
|
|
this._size = 0;
|
|
}
|
|
FibonacciHeap2.prototype.type = "FibonacciHeap";
|
|
FibonacciHeap2.prototype.isFibonacciHeap = true;
|
|
FibonacciHeap2.prototype.insert = function(key, value) {
|
|
var node = {
|
|
key,
|
|
value,
|
|
degree: 0
|
|
};
|
|
if (this._minimum) {
|
|
var minimum = this._minimum;
|
|
node.left = minimum;
|
|
node.right = minimum.right;
|
|
minimum.right = node;
|
|
node.right.left = node;
|
|
if (smaller2(key, minimum.key)) {
|
|
this._minimum = node;
|
|
}
|
|
} else {
|
|
node.left = node;
|
|
node.right = node;
|
|
this._minimum = node;
|
|
}
|
|
this._size++;
|
|
return node;
|
|
};
|
|
FibonacciHeap2.prototype.size = function() {
|
|
return this._size;
|
|
};
|
|
FibonacciHeap2.prototype.clear = function() {
|
|
this._minimum = null;
|
|
this._size = 0;
|
|
};
|
|
FibonacciHeap2.prototype.isEmpty = function() {
|
|
return this._size === 0;
|
|
};
|
|
FibonacciHeap2.prototype.extractMinimum = function() {
|
|
var node = this._minimum;
|
|
if (node === null) {
|
|
return node;
|
|
}
|
|
var minimum = this._minimum;
|
|
var numberOfChildren = node.degree;
|
|
var x = node.child;
|
|
while (numberOfChildren > 0) {
|
|
var tempRight = x.right;
|
|
x.left.right = x.right;
|
|
x.right.left = x.left;
|
|
x.left = minimum;
|
|
x.right = minimum.right;
|
|
minimum.right = x;
|
|
x.right.left = x;
|
|
x.parent = null;
|
|
x = tempRight;
|
|
numberOfChildren--;
|
|
}
|
|
node.left.right = node.right;
|
|
node.right.left = node.left;
|
|
if (node === node.right) {
|
|
minimum = null;
|
|
} else {
|
|
minimum = node.right;
|
|
minimum = _findMinimumNode(minimum, this._size);
|
|
}
|
|
this._size--;
|
|
this._minimum = minimum;
|
|
return node;
|
|
};
|
|
FibonacciHeap2.prototype.remove = function(node) {
|
|
this._minimum = _decreaseKey(this._minimum, node, -1);
|
|
this.extractMinimum();
|
|
};
|
|
function _decreaseKey(minimum, node, key) {
|
|
node.key = key;
|
|
var parent = node.parent;
|
|
if (parent && smaller2(node.key, parent.key)) {
|
|
_cut(minimum, node, parent);
|
|
_cascadingCut(minimum, parent);
|
|
}
|
|
if (smaller2(node.key, minimum.key)) {
|
|
minimum = node;
|
|
}
|
|
return minimum;
|
|
}
|
|
function _cut(minimum, node, parent) {
|
|
node.left.right = node.right;
|
|
node.right.left = node.left;
|
|
parent.degree--;
|
|
if (parent.child === node) {
|
|
parent.child = node.right;
|
|
}
|
|
if (parent.degree === 0) {
|
|
parent.child = null;
|
|
}
|
|
node.left = minimum;
|
|
node.right = minimum.right;
|
|
minimum.right = node;
|
|
node.right.left = node;
|
|
node.parent = null;
|
|
node.mark = false;
|
|
}
|
|
function _cascadingCut(minimum, node) {
|
|
var parent = node.parent;
|
|
if (!parent) {
|
|
return;
|
|
}
|
|
if (!node.mark) {
|
|
node.mark = true;
|
|
} else {
|
|
_cut(minimum, node, parent);
|
|
_cascadingCut(parent);
|
|
}
|
|
}
|
|
var _linkNodes = function _linkNodes2(node, parent) {
|
|
node.left.right = node.right;
|
|
node.right.left = node.left;
|
|
node.parent = parent;
|
|
if (!parent.child) {
|
|
parent.child = node;
|
|
node.right = node;
|
|
node.left = node;
|
|
} else {
|
|
node.left = parent.child;
|
|
node.right = parent.child.right;
|
|
parent.child.right = node;
|
|
node.right.left = node;
|
|
}
|
|
parent.degree++;
|
|
node.mark = false;
|
|
};
|
|
function _findMinimumNode(minimum, size2) {
|
|
var arraySize2 = Math.floor(Math.log(size2) * oneOverLogPhi) + 1;
|
|
var array = new Array(arraySize2);
|
|
var numRoots = 0;
|
|
var x = minimum;
|
|
if (x) {
|
|
numRoots++;
|
|
x = x.right;
|
|
while (x !== minimum) {
|
|
numRoots++;
|
|
x = x.right;
|
|
}
|
|
}
|
|
var y;
|
|
while (numRoots > 0) {
|
|
var d = x.degree;
|
|
var next = x.right;
|
|
while (true) {
|
|
y = array[d];
|
|
if (!y) {
|
|
break;
|
|
}
|
|
if (larger2(x.key, y.key)) {
|
|
var temp = y;
|
|
y = x;
|
|
x = temp;
|
|
}
|
|
_linkNodes(y, x);
|
|
array[d] = null;
|
|
d++;
|
|
}
|
|
array[d] = x;
|
|
x = next;
|
|
numRoots--;
|
|
}
|
|
minimum = null;
|
|
for (var i2 = 0; i2 < arraySize2; i2++) {
|
|
y = array[i2];
|
|
if (!y) {
|
|
continue;
|
|
}
|
|
if (minimum) {
|
|
y.left.right = y.right;
|
|
y.right.left = y.left;
|
|
y.left = minimum;
|
|
y.right = minimum.right;
|
|
minimum.right = y;
|
|
y.right.left = y;
|
|
if (smaller2(y.key, minimum.key)) {
|
|
minimum = y;
|
|
}
|
|
} else {
|
|
minimum = y;
|
|
}
|
|
}
|
|
return minimum;
|
|
}
|
|
return FibonacciHeap2;
|
|
}, {
|
|
isClass: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/Spa.js
|
|
var name157 = "Spa";
|
|
var dependencies157 = ["addScalar", "equalScalar", "FibonacciHeap"];
|
|
var createSpaClass = /* @__PURE__ */ factory(name157, dependencies157, (_ref) => {
|
|
var {
|
|
addScalar: addScalar2,
|
|
equalScalar: equalScalar2,
|
|
FibonacciHeap: FibonacciHeap2
|
|
} = _ref;
|
|
function Spa2() {
|
|
if (!(this instanceof Spa2)) {
|
|
throw new SyntaxError("Constructor must be called with the new operator");
|
|
}
|
|
this._values = [];
|
|
this._heap = new FibonacciHeap2();
|
|
}
|
|
Spa2.prototype.type = "Spa";
|
|
Spa2.prototype.isSpa = true;
|
|
Spa2.prototype.set = function(i2, v) {
|
|
if (!this._values[i2]) {
|
|
var node = this._heap.insert(i2, v);
|
|
this._values[i2] = node;
|
|
} else {
|
|
this._values[i2].value = v;
|
|
}
|
|
};
|
|
Spa2.prototype.get = function(i2) {
|
|
var node = this._values[i2];
|
|
if (node) {
|
|
return node.value;
|
|
}
|
|
return 0;
|
|
};
|
|
Spa2.prototype.accumulate = function(i2, v) {
|
|
var node = this._values[i2];
|
|
if (!node) {
|
|
node = this._heap.insert(i2, v);
|
|
this._values[i2] = node;
|
|
} else {
|
|
node.value = addScalar2(node.value, v);
|
|
}
|
|
};
|
|
Spa2.prototype.forEach = function(from, to2, callback) {
|
|
var heap = this._heap;
|
|
var values = this._values;
|
|
var nodes = [];
|
|
var node = heap.extractMinimum();
|
|
if (node) {
|
|
nodes.push(node);
|
|
}
|
|
while (node && node.key <= to2) {
|
|
if (node.key >= from) {
|
|
if (!equalScalar2(node.value, 0)) {
|
|
callback(node.key, node.value, this);
|
|
}
|
|
}
|
|
node = heap.extractMinimum();
|
|
if (node) {
|
|
nodes.push(node);
|
|
}
|
|
}
|
|
for (var i2 = 0; i2 < nodes.length; i2++) {
|
|
var n = nodes[i2];
|
|
node = heap.insert(n.key, n.value);
|
|
values[node.key] = node;
|
|
}
|
|
};
|
|
Spa2.prototype.swap = function(i2, j) {
|
|
var nodei = this._values[i2];
|
|
var nodej = this._values[j];
|
|
if (!nodei && nodej) {
|
|
nodei = this._heap.insert(i2, nodej.value);
|
|
this._heap.remove(nodej);
|
|
this._values[i2] = nodei;
|
|
this._values[j] = void 0;
|
|
} else if (nodei && !nodej) {
|
|
nodej = this._heap.insert(j, nodei.value);
|
|
this._heap.remove(nodei);
|
|
this._values[j] = nodej;
|
|
this._values[i2] = void 0;
|
|
} else if (nodei && nodej) {
|
|
var v = nodei.value;
|
|
nodei.value = nodej.value;
|
|
nodej.value = v;
|
|
}
|
|
};
|
|
return Spa2;
|
|
}, {
|
|
isClass: true
|
|
});
|
|
|
|
// node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
function _typeof(obj) {
|
|
"@babel/helpers - typeof";
|
|
return _typeof = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(obj2) {
|
|
return typeof obj2;
|
|
} : function(obj2) {
|
|
return obj2 && typeof Symbol == "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
}, _typeof(obj);
|
|
}
|
|
|
|
// node_modules/@babel/runtime/helpers/esm/toPrimitive.js
|
|
function _toPrimitive(input, hint) {
|
|
if (_typeof(input) !== "object" || input === null)
|
|
return input;
|
|
var prim = input[Symbol.toPrimitive];
|
|
if (prim !== void 0) {
|
|
var res = prim.call(input, hint || "default");
|
|
if (_typeof(res) !== "object")
|
|
return res;
|
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
}
|
|
return (hint === "string" ? String : Number)(input);
|
|
}
|
|
|
|
// node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
|
|
function _toPropertyKey(arg2) {
|
|
var key = _toPrimitive(arg2, "string");
|
|
return _typeof(key) === "symbol" ? key : String(key);
|
|
}
|
|
|
|
// node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
function _defineProperty(obj, key, value) {
|
|
key = _toPropertyKey(key);
|
|
if (key in obj) {
|
|
Object.defineProperty(obj, key, {
|
|
value,
|
|
enumerable: true,
|
|
configurable: true,
|
|
writable: true
|
|
});
|
|
} else {
|
|
obj[key] = value;
|
|
}
|
|
return obj;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/utils/bignumber/constants.js
|
|
var createBigNumberE = memoize(function(BigNumber2) {
|
|
return new BigNumber2(1).exp();
|
|
}, {
|
|
hasher
|
|
});
|
|
var createBigNumberPhi = memoize(function(BigNumber2) {
|
|
return new BigNumber2(1).plus(new BigNumber2(5).sqrt()).div(2);
|
|
}, {
|
|
hasher
|
|
});
|
|
var createBigNumberPi = memoize(function(BigNumber2) {
|
|
return BigNumber2.acos(-1);
|
|
}, {
|
|
hasher
|
|
});
|
|
var createBigNumberTau = memoize(function(BigNumber2) {
|
|
return createBigNumberPi(BigNumber2).times(2);
|
|
}, {
|
|
hasher
|
|
});
|
|
function hasher(args) {
|
|
return args[0].precision;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/type/unit/Unit.js
|
|
function ownKeys(object, enumerableOnly) {
|
|
var keys = Object.keys(object);
|
|
if (Object.getOwnPropertySymbols) {
|
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
})), keys.push.apply(keys, symbols);
|
|
}
|
|
return keys;
|
|
}
|
|
function _objectSpread(target) {
|
|
for (var i2 = 1; i2 < arguments.length; i2++) {
|
|
var source = arguments[i2] != null ? arguments[i2] : {};
|
|
i2 % 2 ? ownKeys(Object(source), true).forEach(function(key) {
|
|
_defineProperty(target, key, source[key]);
|
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
});
|
|
}
|
|
return target;
|
|
}
|
|
var name158 = "Unit";
|
|
var dependencies158 = ["?on", "config", "addScalar", "subtract", "multiplyScalar", "divideScalar", "pow", "abs", "fix", "round", "equal", "isNumeric", "format", "number", "Complex", "BigNumber", "Fraction"];
|
|
var createUnitClass = /* @__PURE__ */ factory(name158, dependencies158, (_ref) => {
|
|
var {
|
|
on,
|
|
config: config4,
|
|
addScalar: addScalar2,
|
|
subtract: subtract2,
|
|
multiplyScalar: multiplyScalar2,
|
|
divideScalar: divideScalar2,
|
|
pow: pow3,
|
|
abs: abs3,
|
|
fix: fix2,
|
|
round: round3,
|
|
equal: equal2,
|
|
isNumeric: isNumeric2,
|
|
format: format5,
|
|
number: number2,
|
|
Complex: Complex3,
|
|
BigNumber: _BigNumber,
|
|
Fraction: _Fraction
|
|
} = _ref;
|
|
var toNumber = number2;
|
|
function Unit2(value, valuelessUnit) {
|
|
if (!(this instanceof Unit2)) {
|
|
throw new Error("Constructor must be called with the new operator");
|
|
}
|
|
if (!(value === null || value === void 0 || isNumeric2(value) || isComplex(value))) {
|
|
throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");
|
|
}
|
|
this.fixPrefix = false;
|
|
this.skipAutomaticSimplification = true;
|
|
if (valuelessUnit === void 0) {
|
|
this.units = [];
|
|
this.dimensions = BASE_DIMENSIONS.map((x) => 0);
|
|
} else if (typeof valuelessUnit === "string") {
|
|
var u = Unit2.parse(valuelessUnit);
|
|
this.units = u.units;
|
|
this.dimensions = u.dimensions;
|
|
} else if (isUnit(valuelessUnit) && valuelessUnit.value === null) {
|
|
this.fixPrefix = valuelessUnit.fixPrefix;
|
|
this.skipAutomaticSimplification = valuelessUnit.skipAutomaticSimplification;
|
|
this.dimensions = valuelessUnit.dimensions.slice(0);
|
|
this.units = valuelessUnit.units.map((u2) => _extends({}, u2));
|
|
} else {
|
|
throw new TypeError("Second parameter in Unit constructor must be a string or valueless Unit");
|
|
}
|
|
this.value = this._normalize(value);
|
|
}
|
|
Object.defineProperty(Unit2, "name", {
|
|
value: "Unit"
|
|
});
|
|
Unit2.prototype.constructor = Unit2;
|
|
Unit2.prototype.type = "Unit";
|
|
Unit2.prototype.isUnit = true;
|
|
var text, index2, c;
|
|
function skipWhitespace() {
|
|
while (c === " " || c === " ") {
|
|
next();
|
|
}
|
|
}
|
|
function isDigitDot(c2) {
|
|
return c2 >= "0" && c2 <= "9" || c2 === ".";
|
|
}
|
|
function isDigit(c2) {
|
|
return c2 >= "0" && c2 <= "9";
|
|
}
|
|
function next() {
|
|
index2++;
|
|
c = text.charAt(index2);
|
|
}
|
|
function revert(oldIndex) {
|
|
index2 = oldIndex;
|
|
c = text.charAt(index2);
|
|
}
|
|
function parseNumber() {
|
|
var number3 = "";
|
|
var oldIndex = index2;
|
|
if (c === "+") {
|
|
next();
|
|
} else if (c === "-") {
|
|
number3 += c;
|
|
next();
|
|
}
|
|
if (!isDigitDot(c)) {
|
|
revert(oldIndex);
|
|
return null;
|
|
}
|
|
if (c === ".") {
|
|
number3 += c;
|
|
next();
|
|
if (!isDigit(c)) {
|
|
revert(oldIndex);
|
|
return null;
|
|
}
|
|
} else {
|
|
while (isDigit(c)) {
|
|
number3 += c;
|
|
next();
|
|
}
|
|
if (c === ".") {
|
|
number3 += c;
|
|
next();
|
|
}
|
|
}
|
|
while (isDigit(c)) {
|
|
number3 += c;
|
|
next();
|
|
}
|
|
if (c === "E" || c === "e") {
|
|
var tentativeNumber = "";
|
|
var tentativeIndex = index2;
|
|
tentativeNumber += c;
|
|
next();
|
|
if (c === "+" || c === "-") {
|
|
tentativeNumber += c;
|
|
next();
|
|
}
|
|
if (!isDigit(c)) {
|
|
revert(tentativeIndex);
|
|
return number3;
|
|
}
|
|
number3 = number3 + tentativeNumber;
|
|
while (isDigit(c)) {
|
|
number3 += c;
|
|
next();
|
|
}
|
|
}
|
|
return number3;
|
|
}
|
|
function parseUnit() {
|
|
var unitName = "";
|
|
while (isDigit(c) || Unit2.isValidAlpha(c)) {
|
|
unitName += c;
|
|
next();
|
|
}
|
|
var firstC = unitName.charAt(0);
|
|
if (Unit2.isValidAlpha(firstC)) {
|
|
return unitName;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
function parseCharacter(toFind) {
|
|
if (c === toFind) {
|
|
next();
|
|
return toFind;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
Unit2.parse = function(str, options) {
|
|
options = options || {};
|
|
text = str;
|
|
index2 = -1;
|
|
c = "";
|
|
if (typeof text !== "string") {
|
|
throw new TypeError("Invalid argument in Unit.parse, string expected");
|
|
}
|
|
var unit3 = new Unit2();
|
|
unit3.units = [];
|
|
var powerMultiplierCurrent = 1;
|
|
var expectingUnit = false;
|
|
next();
|
|
skipWhitespace();
|
|
var valueStr = parseNumber();
|
|
var value = null;
|
|
if (valueStr) {
|
|
if (config4.number === "BigNumber") {
|
|
value = new _BigNumber(valueStr);
|
|
} else if (config4.number === "Fraction") {
|
|
try {
|
|
value = new _Fraction(valueStr);
|
|
} catch (err) {
|
|
value = parseFloat(valueStr);
|
|
}
|
|
} else {
|
|
value = parseFloat(valueStr);
|
|
}
|
|
skipWhitespace();
|
|
if (parseCharacter("*")) {
|
|
powerMultiplierCurrent = 1;
|
|
expectingUnit = true;
|
|
} else if (parseCharacter("/")) {
|
|
powerMultiplierCurrent = -1;
|
|
expectingUnit = true;
|
|
}
|
|
}
|
|
var powerMultiplierStack = [];
|
|
var powerMultiplierStackProduct = 1;
|
|
while (true) {
|
|
skipWhitespace();
|
|
while (c === "(") {
|
|
powerMultiplierStack.push(powerMultiplierCurrent);
|
|
powerMultiplierStackProduct *= powerMultiplierCurrent;
|
|
powerMultiplierCurrent = 1;
|
|
next();
|
|
skipWhitespace();
|
|
}
|
|
var uStr = void 0;
|
|
if (c) {
|
|
var oldC = c;
|
|
uStr = parseUnit();
|
|
if (uStr === null) {
|
|
throw new SyntaxError('Unexpected "' + oldC + '" in "' + text + '" at index ' + index2.toString());
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
var res = _findUnit(uStr);
|
|
if (res === null) {
|
|
throw new SyntaxError('Unit "' + uStr + '" not found.');
|
|
}
|
|
var power = powerMultiplierCurrent * powerMultiplierStackProduct;
|
|
skipWhitespace();
|
|
if (parseCharacter("^")) {
|
|
skipWhitespace();
|
|
var p = parseNumber();
|
|
if (p === null) {
|
|
throw new SyntaxError('In "' + str + '", "^" must be followed by a floating-point number');
|
|
}
|
|
power *= p;
|
|
}
|
|
unit3.units.push({
|
|
unit: res.unit,
|
|
prefix: res.prefix,
|
|
power
|
|
});
|
|
for (var i2 = 0; i2 < BASE_DIMENSIONS.length; i2++) {
|
|
unit3.dimensions[i2] += (res.unit.dimensions[i2] || 0) * power;
|
|
}
|
|
skipWhitespace();
|
|
while (c === ")") {
|
|
if (powerMultiplierStack.length === 0) {
|
|
throw new SyntaxError('Unmatched ")" in "' + text + '" at index ' + index2.toString());
|
|
}
|
|
powerMultiplierStackProduct /= powerMultiplierStack.pop();
|
|
next();
|
|
skipWhitespace();
|
|
}
|
|
expectingUnit = false;
|
|
if (parseCharacter("*")) {
|
|
powerMultiplierCurrent = 1;
|
|
expectingUnit = true;
|
|
} else if (parseCharacter("/")) {
|
|
powerMultiplierCurrent = -1;
|
|
expectingUnit = true;
|
|
} else {
|
|
powerMultiplierCurrent = 1;
|
|
}
|
|
if (res.unit.base) {
|
|
var baseDim = res.unit.base.key;
|
|
UNIT_SYSTEMS.auto[baseDim] = {
|
|
unit: res.unit,
|
|
prefix: res.prefix
|
|
};
|
|
}
|
|
}
|
|
skipWhitespace();
|
|
if (c) {
|
|
throw new SyntaxError('Could not parse: "' + str + '"');
|
|
}
|
|
if (expectingUnit) {
|
|
throw new SyntaxError('Trailing characters: "' + str + '"');
|
|
}
|
|
if (powerMultiplierStack.length !== 0) {
|
|
throw new SyntaxError('Unmatched "(" in "' + text + '"');
|
|
}
|
|
if (unit3.units.length === 0 && !options.allowNoUnits) {
|
|
throw new SyntaxError('"' + str + '" contains no units');
|
|
}
|
|
unit3.value = value !== void 0 ? unit3._normalize(value) : null;
|
|
return unit3;
|
|
};
|
|
Unit2.prototype.clone = function() {
|
|
var unit3 = new Unit2();
|
|
unit3.fixPrefix = this.fixPrefix;
|
|
unit3.skipAutomaticSimplification = this.skipAutomaticSimplification;
|
|
unit3.value = clone(this.value);
|
|
unit3.dimensions = this.dimensions.slice(0);
|
|
unit3.units = [];
|
|
for (var i2 = 0; i2 < this.units.length; i2++) {
|
|
unit3.units[i2] = {};
|
|
for (var p in this.units[i2]) {
|
|
if (hasOwnProperty2(this.units[i2], p)) {
|
|
unit3.units[i2][p] = this.units[i2][p];
|
|
}
|
|
}
|
|
}
|
|
return unit3;
|
|
};
|
|
Unit2.prototype.valueType = function() {
|
|
return typeOf(this.value);
|
|
};
|
|
Unit2.prototype._isDerived = function() {
|
|
if (this.units.length === 0) {
|
|
return false;
|
|
}
|
|
return this.units.length > 1 || Math.abs(this.units[0].power - 1) > 1e-15;
|
|
};
|
|
Unit2.prototype._normalize = function(value) {
|
|
if (value === null || value === void 0 || this.units.length === 0) {
|
|
return value;
|
|
}
|
|
var res = value;
|
|
var convert = Unit2._getNumberConverter(typeOf(value));
|
|
for (var i2 = 0; i2 < this.units.length; i2++) {
|
|
var unitValue = convert(this.units[i2].unit.value);
|
|
var unitPrefixValue = convert(this.units[i2].prefix.value);
|
|
var unitPower = convert(this.units[i2].power);
|
|
res = multiplyScalar2(res, pow3(multiplyScalar2(unitValue, unitPrefixValue), unitPower));
|
|
}
|
|
return res;
|
|
};
|
|
Unit2.prototype._denormalize = function(value, prefixValue) {
|
|
if (value === null || value === void 0 || this.units.length === 0) {
|
|
return value;
|
|
}
|
|
var res = value;
|
|
var convert = Unit2._getNumberConverter(typeOf(value));
|
|
for (var i2 = 0; i2 < this.units.length; i2++) {
|
|
var unitValue = convert(this.units[i2].unit.value);
|
|
var unitPrefixValue = convert(this.units[i2].prefix.value);
|
|
var unitPower = convert(this.units[i2].power);
|
|
res = divideScalar2(res, pow3(multiplyScalar2(unitValue, unitPrefixValue), unitPower));
|
|
}
|
|
return res;
|
|
};
|
|
var _findUnit = memoize((str) => {
|
|
if (hasOwnProperty2(UNITS, str)) {
|
|
var unit3 = UNITS[str];
|
|
var prefix = unit3.prefixes[""];
|
|
return {
|
|
unit: unit3,
|
|
prefix
|
|
};
|
|
}
|
|
for (var _name in UNITS) {
|
|
if (hasOwnProperty2(UNITS, _name)) {
|
|
if (endsWith(str, _name)) {
|
|
var _unit = UNITS[_name];
|
|
var prefixLen = str.length - _name.length;
|
|
var prefixName = str.substring(0, prefixLen);
|
|
var _prefix = hasOwnProperty2(_unit.prefixes, prefixName) ? _unit.prefixes[prefixName] : void 0;
|
|
if (_prefix !== void 0) {
|
|
return {
|
|
unit: _unit,
|
|
prefix: _prefix
|
|
};
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}, {
|
|
hasher: (args) => args[0],
|
|
limit: 100
|
|
});
|
|
Unit2.isValuelessUnit = function(name302) {
|
|
return _findUnit(name302) !== null;
|
|
};
|
|
Unit2.prototype.hasBase = function(base) {
|
|
if (typeof base === "string") {
|
|
base = BASE_UNITS[base];
|
|
}
|
|
if (!base) {
|
|
return false;
|
|
}
|
|
for (var i2 = 0; i2 < BASE_DIMENSIONS.length; i2++) {
|
|
if (Math.abs((this.dimensions[i2] || 0) - (base.dimensions[i2] || 0)) > 1e-12) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
Unit2.prototype.equalBase = function(other) {
|
|
for (var i2 = 0; i2 < BASE_DIMENSIONS.length; i2++) {
|
|
if (Math.abs((this.dimensions[i2] || 0) - (other.dimensions[i2] || 0)) > 1e-12) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
Unit2.prototype.equals = function(other) {
|
|
return this.equalBase(other) && equal2(this.value, other.value);
|
|
};
|
|
Unit2.prototype.multiply = function(_other) {
|
|
var res = this.clone();
|
|
var other = isUnit(_other) ? _other : new Unit2(_other);
|
|
for (var i2 = 0; i2 < BASE_DIMENSIONS.length; i2++) {
|
|
res.dimensions[i2] = (this.dimensions[i2] || 0) + (other.dimensions[i2] || 0);
|
|
}
|
|
for (var _i = 0; _i < other.units.length; _i++) {
|
|
var inverted = _objectSpread({}, other.units[_i]);
|
|
res.units.push(inverted);
|
|
}
|
|
if (this.value !== null || other.value !== null) {
|
|
var valThis = this.value === null ? this._normalize(1) : this.value;
|
|
var valOther = other.value === null ? other._normalize(1) : other.value;
|
|
res.value = multiplyScalar2(valThis, valOther);
|
|
} else {
|
|
res.value = null;
|
|
}
|
|
if (isUnit(_other)) {
|
|
res.skipAutomaticSimplification = false;
|
|
}
|
|
return getNumericIfUnitless(res);
|
|
};
|
|
Unit2.prototype.divideInto = function(numerator) {
|
|
return new Unit2(numerator).divide(this);
|
|
};
|
|
Unit2.prototype.divide = function(_other) {
|
|
var res = this.clone();
|
|
var other = isUnit(_other) ? _other : new Unit2(_other);
|
|
for (var i2 = 0; i2 < BASE_DIMENSIONS.length; i2++) {
|
|
res.dimensions[i2] = (this.dimensions[i2] || 0) - (other.dimensions[i2] || 0);
|
|
}
|
|
for (var _i2 = 0; _i2 < other.units.length; _i2++) {
|
|
var inverted = _objectSpread(_objectSpread({}, other.units[_i2]), {}, {
|
|
power: -other.units[_i2].power
|
|
});
|
|
res.units.push(inverted);
|
|
}
|
|
if (this.value !== null || other.value !== null) {
|
|
var valThis = this.value === null ? this._normalize(1) : this.value;
|
|
var valOther = other.value === null ? other._normalize(1) : other.value;
|
|
res.value = divideScalar2(valThis, valOther);
|
|
} else {
|
|
res.value = null;
|
|
}
|
|
if (isUnit(_other)) {
|
|
res.skipAutomaticSimplification = false;
|
|
}
|
|
return getNumericIfUnitless(res);
|
|
};
|
|
Unit2.prototype.pow = function(p) {
|
|
var res = this.clone();
|
|
for (var i2 = 0; i2 < BASE_DIMENSIONS.length; i2++) {
|
|
res.dimensions[i2] = (this.dimensions[i2] || 0) * p;
|
|
}
|
|
for (var _i3 = 0; _i3 < res.units.length; _i3++) {
|
|
res.units[_i3].power *= p;
|
|
}
|
|
if (res.value !== null) {
|
|
res.value = pow3(res.value, p);
|
|
} else {
|
|
res.value = null;
|
|
}
|
|
res.skipAutomaticSimplification = false;
|
|
return getNumericIfUnitless(res);
|
|
};
|
|
function getNumericIfUnitless(unit3) {
|
|
if (unit3.equalBase(BASE_UNITS.NONE) && unit3.value !== null && !config4.predictable) {
|
|
return unit3.value;
|
|
} else {
|
|
return unit3;
|
|
}
|
|
}
|
|
Unit2.prototype.abs = function() {
|
|
var ret = this.clone();
|
|
if (ret.value !== null) {
|
|
if (ret._isDerived() || ret.units[0].unit.offset === 0) {
|
|
ret.value = abs3(ret.value);
|
|
} else {
|
|
var convert = ret._numberConverter();
|
|
var unitValue = convert(ret.units[0].unit.value);
|
|
var nominalOffset = convert(ret.units[0].unit.offset);
|
|
var unitOffset = multiplyScalar2(unitValue, nominalOffset);
|
|
ret.value = subtract2(abs3(addScalar2(ret.value, unitOffset)), unitOffset);
|
|
}
|
|
}
|
|
for (var i2 in ret.units) {
|
|
if (ret.units[i2].unit.name === "VA" || ret.units[i2].unit.name === "VAR") {
|
|
ret.units[i2].unit = UNITS.W;
|
|
}
|
|
}
|
|
return ret;
|
|
};
|
|
Unit2.prototype.to = function(valuelessUnit) {
|
|
var value = this.value === null ? this._normalize(1) : this.value;
|
|
var other;
|
|
if (typeof valuelessUnit === "string") {
|
|
other = Unit2.parse(valuelessUnit);
|
|
} else if (isUnit(valuelessUnit)) {
|
|
other = valuelessUnit.clone();
|
|
} else {
|
|
throw new Error("String or Unit expected as parameter");
|
|
}
|
|
if (!this.equalBase(other)) {
|
|
throw new Error("Units do not match ('".concat(other.toString(), "' != '").concat(this.toString(), "')"));
|
|
}
|
|
if (other.value !== null) {
|
|
throw new Error("Cannot convert to a unit with a value");
|
|
}
|
|
if (this.value === null || this._isDerived() || this.units[0].unit.offset === other.units[0].unit.offset) {
|
|
other.value = clone(value);
|
|
} else {
|
|
var convert = Unit2._getNumberConverter(typeOf(value));
|
|
var thisUnitValue = convert(this.units[0].unit.value);
|
|
var thisNominalOffset = convert(this.units[0].unit.offset);
|
|
var thisUnitOffset = multiplyScalar2(thisUnitValue, thisNominalOffset);
|
|
var otherUnitValue = convert(other.units[0].unit.value);
|
|
var otherNominalOffset = convert(other.units[0].unit.offset);
|
|
var otherUnitOffset = multiplyScalar2(otherUnitValue, otherNominalOffset);
|
|
other.value = subtract2(addScalar2(value, thisUnitOffset), otherUnitOffset);
|
|
}
|
|
other.fixPrefix = true;
|
|
other.skipAutomaticSimplification = true;
|
|
return other;
|
|
};
|
|
Unit2.prototype.toNumber = function(valuelessUnit) {
|
|
return toNumber(this.toNumeric(valuelessUnit));
|
|
};
|
|
Unit2.prototype.toNumeric = function(valuelessUnit) {
|
|
var other;
|
|
if (valuelessUnit) {
|
|
other = this.to(valuelessUnit);
|
|
} else {
|
|
other = this.clone();
|
|
}
|
|
if (other._isDerived() || other.units.length === 0) {
|
|
return other._denormalize(other.value);
|
|
} else {
|
|
return other._denormalize(other.value, other.units[0].prefix.value);
|
|
}
|
|
};
|
|
Unit2.prototype.toString = function() {
|
|
return this.format();
|
|
};
|
|
Unit2.prototype.toJSON = function() {
|
|
return {
|
|
mathjs: "Unit",
|
|
value: this._denormalize(this.value),
|
|
unit: this.formatUnits(),
|
|
fixPrefix: this.fixPrefix
|
|
};
|
|
};
|
|
Unit2.fromJSON = function(json) {
|
|
var unit3 = new Unit2(json.value, json.unit);
|
|
unit3.fixPrefix = json.fixPrefix || false;
|
|
return unit3;
|
|
};
|
|
Unit2.prototype.valueOf = Unit2.prototype.toString;
|
|
Unit2.prototype.simplify = function() {
|
|
var ret = this.clone();
|
|
var proposedUnitList = [];
|
|
var matchingBase;
|
|
for (var key2 in currentUnitSystem) {
|
|
if (hasOwnProperty2(currentUnitSystem, key2)) {
|
|
if (ret.hasBase(BASE_UNITS[key2])) {
|
|
matchingBase = key2;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (matchingBase === "NONE") {
|
|
ret.units = [];
|
|
} else {
|
|
var matchingUnit;
|
|
if (matchingBase) {
|
|
if (hasOwnProperty2(currentUnitSystem, matchingBase)) {
|
|
matchingUnit = currentUnitSystem[matchingBase];
|
|
}
|
|
}
|
|
if (matchingUnit) {
|
|
ret.units = [{
|
|
unit: matchingUnit.unit,
|
|
prefix: matchingUnit.prefix,
|
|
power: 1
|
|
}];
|
|
} else {
|
|
var missingBaseDim = false;
|
|
for (var i2 = 0; i2 < BASE_DIMENSIONS.length; i2++) {
|
|
var baseDim = BASE_DIMENSIONS[i2];
|
|
if (Math.abs(ret.dimensions[i2] || 0) > 1e-12) {
|
|
if (hasOwnProperty2(currentUnitSystem, baseDim)) {
|
|
proposedUnitList.push({
|
|
unit: currentUnitSystem[baseDim].unit,
|
|
prefix: currentUnitSystem[baseDim].prefix,
|
|
power: ret.dimensions[i2] || 0
|
|
});
|
|
} else {
|
|
missingBaseDim = true;
|
|
}
|
|
}
|
|
}
|
|
if (proposedUnitList.length < ret.units.length && !missingBaseDim) {
|
|
ret.units = proposedUnitList;
|
|
}
|
|
}
|
|
}
|
|
return ret;
|
|
};
|
|
Unit2.prototype.toSI = function() {
|
|
var ret = this.clone();
|
|
var proposedUnitList = [];
|
|
for (var i2 = 0; i2 < BASE_DIMENSIONS.length; i2++) {
|
|
var baseDim = BASE_DIMENSIONS[i2];
|
|
if (Math.abs(ret.dimensions[i2] || 0) > 1e-12) {
|
|
if (hasOwnProperty2(UNIT_SYSTEMS.si, baseDim)) {
|
|
proposedUnitList.push({
|
|
unit: UNIT_SYSTEMS.si[baseDim].unit,
|
|
prefix: UNIT_SYSTEMS.si[baseDim].prefix,
|
|
power: ret.dimensions[i2] || 0
|
|
});
|
|
} else {
|
|
throw new Error("Cannot express custom unit " + baseDim + " in SI units");
|
|
}
|
|
}
|
|
}
|
|
ret.units = proposedUnitList;
|
|
ret.fixPrefix = true;
|
|
ret.skipAutomaticSimplification = true;
|
|
return ret;
|
|
};
|
|
Unit2.prototype.formatUnits = function() {
|
|
var strNum = "";
|
|
var strDen = "";
|
|
var nNum = 0;
|
|
var nDen = 0;
|
|
for (var i2 = 0; i2 < this.units.length; i2++) {
|
|
if (this.units[i2].power > 0) {
|
|
nNum++;
|
|
strNum += " " + this.units[i2].prefix.name + this.units[i2].unit.name;
|
|
if (Math.abs(this.units[i2].power - 1) > 1e-15) {
|
|
strNum += "^" + this.units[i2].power;
|
|
}
|
|
} else if (this.units[i2].power < 0) {
|
|
nDen++;
|
|
}
|
|
}
|
|
if (nDen > 0) {
|
|
for (var _i4 = 0; _i4 < this.units.length; _i4++) {
|
|
if (this.units[_i4].power < 0) {
|
|
if (nNum > 0) {
|
|
strDen += " " + this.units[_i4].prefix.name + this.units[_i4].unit.name;
|
|
if (Math.abs(this.units[_i4].power + 1) > 1e-15) {
|
|
strDen += "^" + -this.units[_i4].power;
|
|
}
|
|
} else {
|
|
strDen += " " + this.units[_i4].prefix.name + this.units[_i4].unit.name;
|
|
strDen += "^" + this.units[_i4].power;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
strNum = strNum.substr(1);
|
|
strDen = strDen.substr(1);
|
|
if (nNum > 1 && nDen > 0) {
|
|
strNum = "(" + strNum + ")";
|
|
}
|
|
if (nDen > 1 && nNum > 0) {
|
|
strDen = "(" + strDen + ")";
|
|
}
|
|
var str = strNum;
|
|
if (nNum > 0 && nDen > 0) {
|
|
str += " / ";
|
|
}
|
|
str += strDen;
|
|
return str;
|
|
};
|
|
Unit2.prototype.format = function(options) {
|
|
var simp = this.skipAutomaticSimplification || this.value === null ? this.clone() : this.simplify();
|
|
var isImaginary = false;
|
|
if (typeof simp.value !== "undefined" && simp.value !== null && isComplex(simp.value)) {
|
|
isImaginary = Math.abs(simp.value.re) < 1e-14;
|
|
}
|
|
for (var i2 in simp.units) {
|
|
if (hasOwnProperty2(simp.units, i2)) {
|
|
if (simp.units[i2].unit) {
|
|
if (simp.units[i2].unit.name === "VA" && isImaginary) {
|
|
simp.units[i2].unit = UNITS.VAR;
|
|
} else if (simp.units[i2].unit.name === "VAR" && !isImaginary) {
|
|
simp.units[i2].unit = UNITS.VA;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (simp.units.length === 1 && !simp.fixPrefix) {
|
|
if (Math.abs(simp.units[0].power - Math.round(simp.units[0].power)) < 1e-14) {
|
|
simp.units[0].prefix = simp._bestPrefix();
|
|
}
|
|
}
|
|
var value = simp._denormalize(simp.value);
|
|
var str = simp.value !== null ? format5(value, options || {}) : "";
|
|
var unitStr = simp.formatUnits();
|
|
if (simp.value && isComplex(simp.value)) {
|
|
str = "(" + str + ")";
|
|
}
|
|
if (unitStr.length > 0 && str.length > 0) {
|
|
str += " ";
|
|
}
|
|
str += unitStr;
|
|
return str;
|
|
};
|
|
Unit2.prototype._bestPrefix = function() {
|
|
if (this.units.length !== 1) {
|
|
throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");
|
|
}
|
|
if (Math.abs(this.units[0].power - Math.round(this.units[0].power)) >= 1e-14) {
|
|
throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");
|
|
}
|
|
var absValue = this.value !== null ? abs3(this.value) : 0;
|
|
var absUnitValue = abs3(this.units[0].unit.value);
|
|
var bestPrefix = this.units[0].prefix;
|
|
if (absValue === 0) {
|
|
return bestPrefix;
|
|
}
|
|
var power = this.units[0].power;
|
|
var bestDiff = Math.log(absValue / Math.pow(bestPrefix.value * absUnitValue, power)) / Math.LN10 - 1.2;
|
|
if (bestDiff > -2.200001 && bestDiff < 1.800001)
|
|
return bestPrefix;
|
|
bestDiff = Math.abs(bestDiff);
|
|
var prefixes = this.units[0].unit.prefixes;
|
|
for (var p in prefixes) {
|
|
if (hasOwnProperty2(prefixes, p)) {
|
|
var prefix = prefixes[p];
|
|
if (prefix.scientific) {
|
|
var diff2 = Math.abs(Math.log(absValue / Math.pow(prefix.value * absUnitValue, power)) / Math.LN10 - 1.2);
|
|
if (diff2 < bestDiff || diff2 === bestDiff && prefix.name.length < bestPrefix.name.length) {
|
|
bestPrefix = prefix;
|
|
bestDiff = diff2;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return bestPrefix;
|
|
};
|
|
Unit2.prototype.splitUnit = function(parts) {
|
|
var x = this.clone();
|
|
var ret = [];
|
|
for (var i2 = 0; i2 < parts.length; i2++) {
|
|
x = x.to(parts[i2]);
|
|
if (i2 === parts.length - 1)
|
|
break;
|
|
var xNumeric = x.toNumeric();
|
|
var xRounded = round3(xNumeric);
|
|
var xFixed = void 0;
|
|
var isNearlyEqual = equal2(xRounded, xNumeric);
|
|
if (isNearlyEqual) {
|
|
xFixed = xRounded;
|
|
} else {
|
|
xFixed = fix2(x.toNumeric());
|
|
}
|
|
var y = new Unit2(xFixed, parts[i2].toString());
|
|
ret.push(y);
|
|
x = subtract2(x, y);
|
|
}
|
|
var testSum = 0;
|
|
for (var _i5 = 0; _i5 < ret.length; _i5++) {
|
|
testSum = addScalar2(testSum, ret[_i5].value);
|
|
}
|
|
if (equal2(testSum, this.value)) {
|
|
x.value = 0;
|
|
}
|
|
ret.push(x);
|
|
return ret;
|
|
};
|
|
var PREFIXES = {
|
|
NONE: {
|
|
"": {
|
|
name: "",
|
|
value: 1,
|
|
scientific: true
|
|
}
|
|
},
|
|
SHORT: {
|
|
"": {
|
|
name: "",
|
|
value: 1,
|
|
scientific: true
|
|
},
|
|
da: {
|
|
name: "da",
|
|
value: 10,
|
|
scientific: false
|
|
},
|
|
h: {
|
|
name: "h",
|
|
value: 100,
|
|
scientific: false
|
|
},
|
|
k: {
|
|
name: "k",
|
|
value: 1e3,
|
|
scientific: true
|
|
},
|
|
M: {
|
|
name: "M",
|
|
value: 1e6,
|
|
scientific: true
|
|
},
|
|
G: {
|
|
name: "G",
|
|
value: 1e9,
|
|
scientific: true
|
|
},
|
|
T: {
|
|
name: "T",
|
|
value: 1e12,
|
|
scientific: true
|
|
},
|
|
P: {
|
|
name: "P",
|
|
value: 1e15,
|
|
scientific: true
|
|
},
|
|
E: {
|
|
name: "E",
|
|
value: 1e18,
|
|
scientific: true
|
|
},
|
|
Z: {
|
|
name: "Z",
|
|
value: 1e21,
|
|
scientific: true
|
|
},
|
|
Y: {
|
|
name: "Y",
|
|
value: 1e24,
|
|
scientific: true
|
|
},
|
|
d: {
|
|
name: "d",
|
|
value: 0.1,
|
|
scientific: false
|
|
},
|
|
c: {
|
|
name: "c",
|
|
value: 0.01,
|
|
scientific: false
|
|
},
|
|
m: {
|
|
name: "m",
|
|
value: 1e-3,
|
|
scientific: true
|
|
},
|
|
u: {
|
|
name: "u",
|
|
value: 1e-6,
|
|
scientific: true
|
|
},
|
|
n: {
|
|
name: "n",
|
|
value: 1e-9,
|
|
scientific: true
|
|
},
|
|
p: {
|
|
name: "p",
|
|
value: 1e-12,
|
|
scientific: true
|
|
},
|
|
f: {
|
|
name: "f",
|
|
value: 1e-15,
|
|
scientific: true
|
|
},
|
|
a: {
|
|
name: "a",
|
|
value: 1e-18,
|
|
scientific: true
|
|
},
|
|
z: {
|
|
name: "z",
|
|
value: 1e-21,
|
|
scientific: true
|
|
},
|
|
y: {
|
|
name: "y",
|
|
value: 1e-24,
|
|
scientific: true
|
|
}
|
|
},
|
|
LONG: {
|
|
"": {
|
|
name: "",
|
|
value: 1,
|
|
scientific: true
|
|
},
|
|
deca: {
|
|
name: "deca",
|
|
value: 10,
|
|
scientific: false
|
|
},
|
|
hecto: {
|
|
name: "hecto",
|
|
value: 100,
|
|
scientific: false
|
|
},
|
|
kilo: {
|
|
name: "kilo",
|
|
value: 1e3,
|
|
scientific: true
|
|
},
|
|
mega: {
|
|
name: "mega",
|
|
value: 1e6,
|
|
scientific: true
|
|
},
|
|
giga: {
|
|
name: "giga",
|
|
value: 1e9,
|
|
scientific: true
|
|
},
|
|
tera: {
|
|
name: "tera",
|
|
value: 1e12,
|
|
scientific: true
|
|
},
|
|
peta: {
|
|
name: "peta",
|
|
value: 1e15,
|
|
scientific: true
|
|
},
|
|
exa: {
|
|
name: "exa",
|
|
value: 1e18,
|
|
scientific: true
|
|
},
|
|
zetta: {
|
|
name: "zetta",
|
|
value: 1e21,
|
|
scientific: true
|
|
},
|
|
yotta: {
|
|
name: "yotta",
|
|
value: 1e24,
|
|
scientific: true
|
|
},
|
|
deci: {
|
|
name: "deci",
|
|
value: 0.1,
|
|
scientific: false
|
|
},
|
|
centi: {
|
|
name: "centi",
|
|
value: 0.01,
|
|
scientific: false
|
|
},
|
|
milli: {
|
|
name: "milli",
|
|
value: 1e-3,
|
|
scientific: true
|
|
},
|
|
micro: {
|
|
name: "micro",
|
|
value: 1e-6,
|
|
scientific: true
|
|
},
|
|
nano: {
|
|
name: "nano",
|
|
value: 1e-9,
|
|
scientific: true
|
|
},
|
|
pico: {
|
|
name: "pico",
|
|
value: 1e-12,
|
|
scientific: true
|
|
},
|
|
femto: {
|
|
name: "femto",
|
|
value: 1e-15,
|
|
scientific: true
|
|
},
|
|
atto: {
|
|
name: "atto",
|
|
value: 1e-18,
|
|
scientific: true
|
|
},
|
|
zepto: {
|
|
name: "zepto",
|
|
value: 1e-21,
|
|
scientific: true
|
|
},
|
|
yocto: {
|
|
name: "yocto",
|
|
value: 1e-24,
|
|
scientific: true
|
|
}
|
|
},
|
|
SQUARED: {
|
|
"": {
|
|
name: "",
|
|
value: 1,
|
|
scientific: true
|
|
},
|
|
da: {
|
|
name: "da",
|
|
value: 100,
|
|
scientific: false
|
|
},
|
|
h: {
|
|
name: "h",
|
|
value: 1e4,
|
|
scientific: false
|
|
},
|
|
k: {
|
|
name: "k",
|
|
value: 1e6,
|
|
scientific: true
|
|
},
|
|
M: {
|
|
name: "M",
|
|
value: 1e12,
|
|
scientific: true
|
|
},
|
|
G: {
|
|
name: "G",
|
|
value: 1e18,
|
|
scientific: true
|
|
},
|
|
T: {
|
|
name: "T",
|
|
value: 1e24,
|
|
scientific: true
|
|
},
|
|
P: {
|
|
name: "P",
|
|
value: 1e30,
|
|
scientific: true
|
|
},
|
|
E: {
|
|
name: "E",
|
|
value: 1e36,
|
|
scientific: true
|
|
},
|
|
Z: {
|
|
name: "Z",
|
|
value: 1e42,
|
|
scientific: true
|
|
},
|
|
Y: {
|
|
name: "Y",
|
|
value: 1e48,
|
|
scientific: true
|
|
},
|
|
d: {
|
|
name: "d",
|
|
value: 0.01,
|
|
scientific: false
|
|
},
|
|
c: {
|
|
name: "c",
|
|
value: 1e-4,
|
|
scientific: false
|
|
},
|
|
m: {
|
|
name: "m",
|
|
value: 1e-6,
|
|
scientific: true
|
|
},
|
|
u: {
|
|
name: "u",
|
|
value: 1e-12,
|
|
scientific: true
|
|
},
|
|
n: {
|
|
name: "n",
|
|
value: 1e-18,
|
|
scientific: true
|
|
},
|
|
p: {
|
|
name: "p",
|
|
value: 1e-24,
|
|
scientific: true
|
|
},
|
|
f: {
|
|
name: "f",
|
|
value: 1e-30,
|
|
scientific: true
|
|
},
|
|
a: {
|
|
name: "a",
|
|
value: 1e-36,
|
|
scientific: true
|
|
},
|
|
z: {
|
|
name: "z",
|
|
value: 1e-42,
|
|
scientific: true
|
|
},
|
|
y: {
|
|
name: "y",
|
|
value: 1e-48,
|
|
scientific: true
|
|
}
|
|
},
|
|
CUBIC: {
|
|
"": {
|
|
name: "",
|
|
value: 1,
|
|
scientific: true
|
|
},
|
|
da: {
|
|
name: "da",
|
|
value: 1e3,
|
|
scientific: false
|
|
},
|
|
h: {
|
|
name: "h",
|
|
value: 1e6,
|
|
scientific: false
|
|
},
|
|
k: {
|
|
name: "k",
|
|
value: 1e9,
|
|
scientific: true
|
|
},
|
|
M: {
|
|
name: "M",
|
|
value: 1e18,
|
|
scientific: true
|
|
},
|
|
G: {
|
|
name: "G",
|
|
value: 1e27,
|
|
scientific: true
|
|
},
|
|
T: {
|
|
name: "T",
|
|
value: 1e36,
|
|
scientific: true
|
|
},
|
|
P: {
|
|
name: "P",
|
|
value: 1e45,
|
|
scientific: true
|
|
},
|
|
E: {
|
|
name: "E",
|
|
value: 1e54,
|
|
scientific: true
|
|
},
|
|
Z: {
|
|
name: "Z",
|
|
value: 1e63,
|
|
scientific: true
|
|
},
|
|
Y: {
|
|
name: "Y",
|
|
value: 1e72,
|
|
scientific: true
|
|
},
|
|
d: {
|
|
name: "d",
|
|
value: 1e-3,
|
|
scientific: false
|
|
},
|
|
c: {
|
|
name: "c",
|
|
value: 1e-6,
|
|
scientific: false
|
|
},
|
|
m: {
|
|
name: "m",
|
|
value: 1e-9,
|
|
scientific: true
|
|
},
|
|
u: {
|
|
name: "u",
|
|
value: 1e-18,
|
|
scientific: true
|
|
},
|
|
n: {
|
|
name: "n",
|
|
value: 1e-27,
|
|
scientific: true
|
|
},
|
|
p: {
|
|
name: "p",
|
|
value: 1e-36,
|
|
scientific: true
|
|
},
|
|
f: {
|
|
name: "f",
|
|
value: 1e-45,
|
|
scientific: true
|
|
},
|
|
a: {
|
|
name: "a",
|
|
value: 1e-54,
|
|
scientific: true
|
|
},
|
|
z: {
|
|
name: "z",
|
|
value: 1e-63,
|
|
scientific: true
|
|
},
|
|
y: {
|
|
name: "y",
|
|
value: 1e-72,
|
|
scientific: true
|
|
}
|
|
},
|
|
BINARY_SHORT_SI: {
|
|
"": {
|
|
name: "",
|
|
value: 1,
|
|
scientific: true
|
|
},
|
|
k: {
|
|
name: "k",
|
|
value: 1e3,
|
|
scientific: true
|
|
},
|
|
M: {
|
|
name: "M",
|
|
value: 1e6,
|
|
scientific: true
|
|
},
|
|
G: {
|
|
name: "G",
|
|
value: 1e9,
|
|
scientific: true
|
|
},
|
|
T: {
|
|
name: "T",
|
|
value: 1e12,
|
|
scientific: true
|
|
},
|
|
P: {
|
|
name: "P",
|
|
value: 1e15,
|
|
scientific: true
|
|
},
|
|
E: {
|
|
name: "E",
|
|
value: 1e18,
|
|
scientific: true
|
|
},
|
|
Z: {
|
|
name: "Z",
|
|
value: 1e21,
|
|
scientific: true
|
|
},
|
|
Y: {
|
|
name: "Y",
|
|
value: 1e24,
|
|
scientific: true
|
|
}
|
|
},
|
|
BINARY_SHORT_IEC: {
|
|
"": {
|
|
name: "",
|
|
value: 1,
|
|
scientific: true
|
|
},
|
|
Ki: {
|
|
name: "Ki",
|
|
value: 1024,
|
|
scientific: true
|
|
},
|
|
Mi: {
|
|
name: "Mi",
|
|
value: Math.pow(1024, 2),
|
|
scientific: true
|
|
},
|
|
Gi: {
|
|
name: "Gi",
|
|
value: Math.pow(1024, 3),
|
|
scientific: true
|
|
},
|
|
Ti: {
|
|
name: "Ti",
|
|
value: Math.pow(1024, 4),
|
|
scientific: true
|
|
},
|
|
Pi: {
|
|
name: "Pi",
|
|
value: Math.pow(1024, 5),
|
|
scientific: true
|
|
},
|
|
Ei: {
|
|
name: "Ei",
|
|
value: Math.pow(1024, 6),
|
|
scientific: true
|
|
},
|
|
Zi: {
|
|
name: "Zi",
|
|
value: Math.pow(1024, 7),
|
|
scientific: true
|
|
},
|
|
Yi: {
|
|
name: "Yi",
|
|
value: Math.pow(1024, 8),
|
|
scientific: true
|
|
}
|
|
},
|
|
BINARY_LONG_SI: {
|
|
"": {
|
|
name: "",
|
|
value: 1,
|
|
scientific: true
|
|
},
|
|
kilo: {
|
|
name: "kilo",
|
|
value: 1e3,
|
|
scientific: true
|
|
},
|
|
mega: {
|
|
name: "mega",
|
|
value: 1e6,
|
|
scientific: true
|
|
},
|
|
giga: {
|
|
name: "giga",
|
|
value: 1e9,
|
|
scientific: true
|
|
},
|
|
tera: {
|
|
name: "tera",
|
|
value: 1e12,
|
|
scientific: true
|
|
},
|
|
peta: {
|
|
name: "peta",
|
|
value: 1e15,
|
|
scientific: true
|
|
},
|
|
exa: {
|
|
name: "exa",
|
|
value: 1e18,
|
|
scientific: true
|
|
},
|
|
zetta: {
|
|
name: "zetta",
|
|
value: 1e21,
|
|
scientific: true
|
|
},
|
|
yotta: {
|
|
name: "yotta",
|
|
value: 1e24,
|
|
scientific: true
|
|
}
|
|
},
|
|
BINARY_LONG_IEC: {
|
|
"": {
|
|
name: "",
|
|
value: 1,
|
|
scientific: true
|
|
},
|
|
kibi: {
|
|
name: "kibi",
|
|
value: 1024,
|
|
scientific: true
|
|
},
|
|
mebi: {
|
|
name: "mebi",
|
|
value: Math.pow(1024, 2),
|
|
scientific: true
|
|
},
|
|
gibi: {
|
|
name: "gibi",
|
|
value: Math.pow(1024, 3),
|
|
scientific: true
|
|
},
|
|
tebi: {
|
|
name: "tebi",
|
|
value: Math.pow(1024, 4),
|
|
scientific: true
|
|
},
|
|
pebi: {
|
|
name: "pebi",
|
|
value: Math.pow(1024, 5),
|
|
scientific: true
|
|
},
|
|
exi: {
|
|
name: "exi",
|
|
value: Math.pow(1024, 6),
|
|
scientific: true
|
|
},
|
|
zebi: {
|
|
name: "zebi",
|
|
value: Math.pow(1024, 7),
|
|
scientific: true
|
|
},
|
|
yobi: {
|
|
name: "yobi",
|
|
value: Math.pow(1024, 8),
|
|
scientific: true
|
|
}
|
|
},
|
|
BTU: {
|
|
"": {
|
|
name: "",
|
|
value: 1,
|
|
scientific: true
|
|
},
|
|
MM: {
|
|
name: "MM",
|
|
value: 1e6,
|
|
scientific: true
|
|
}
|
|
}
|
|
};
|
|
PREFIXES.SHORTLONG = _extends({}, PREFIXES.SHORT, PREFIXES.LONG);
|
|
PREFIXES.BINARY_SHORT = _extends({}, PREFIXES.BINARY_SHORT_SI, PREFIXES.BINARY_SHORT_IEC);
|
|
PREFIXES.BINARY_LONG = _extends({}, PREFIXES.BINARY_LONG_SI, PREFIXES.BINARY_LONG_IEC);
|
|
var BASE_DIMENSIONS = ["MASS", "LENGTH", "TIME", "CURRENT", "TEMPERATURE", "LUMINOUS_INTENSITY", "AMOUNT_OF_SUBSTANCE", "ANGLE", "BIT"];
|
|
var BASE_UNITS = {
|
|
NONE: {
|
|
dimensions: [0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
},
|
|
MASS: {
|
|
dimensions: [1, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
},
|
|
LENGTH: {
|
|
dimensions: [0, 1, 0, 0, 0, 0, 0, 0, 0]
|
|
},
|
|
TIME: {
|
|
dimensions: [0, 0, 1, 0, 0, 0, 0, 0, 0]
|
|
},
|
|
CURRENT: {
|
|
dimensions: [0, 0, 0, 1, 0, 0, 0, 0, 0]
|
|
},
|
|
TEMPERATURE: {
|
|
dimensions: [0, 0, 0, 0, 1, 0, 0, 0, 0]
|
|
},
|
|
LUMINOUS_INTENSITY: {
|
|
dimensions: [0, 0, 0, 0, 0, 1, 0, 0, 0]
|
|
},
|
|
AMOUNT_OF_SUBSTANCE: {
|
|
dimensions: [0, 0, 0, 0, 0, 0, 1, 0, 0]
|
|
},
|
|
FORCE: {
|
|
dimensions: [1, 1, -2, 0, 0, 0, 0, 0, 0]
|
|
},
|
|
SURFACE: {
|
|
dimensions: [0, 2, 0, 0, 0, 0, 0, 0, 0]
|
|
},
|
|
VOLUME: {
|
|
dimensions: [0, 3, 0, 0, 0, 0, 0, 0, 0]
|
|
},
|
|
ENERGY: {
|
|
dimensions: [1, 2, -2, 0, 0, 0, 0, 0, 0]
|
|
},
|
|
POWER: {
|
|
dimensions: [1, 2, -3, 0, 0, 0, 0, 0, 0]
|
|
},
|
|
PRESSURE: {
|
|
dimensions: [1, -1, -2, 0, 0, 0, 0, 0, 0]
|
|
},
|
|
ELECTRIC_CHARGE: {
|
|
dimensions: [0, 0, 1, 1, 0, 0, 0, 0, 0]
|
|
},
|
|
ELECTRIC_CAPACITANCE: {
|
|
dimensions: [-1, -2, 4, 2, 0, 0, 0, 0, 0]
|
|
},
|
|
ELECTRIC_POTENTIAL: {
|
|
dimensions: [1, 2, -3, -1, 0, 0, 0, 0, 0]
|
|
},
|
|
ELECTRIC_RESISTANCE: {
|
|
dimensions: [1, 2, -3, -2, 0, 0, 0, 0, 0]
|
|
},
|
|
ELECTRIC_INDUCTANCE: {
|
|
dimensions: [1, 2, -2, -2, 0, 0, 0, 0, 0]
|
|
},
|
|
ELECTRIC_CONDUCTANCE: {
|
|
dimensions: [-1, -2, 3, 2, 0, 0, 0, 0, 0]
|
|
},
|
|
MAGNETIC_FLUX: {
|
|
dimensions: [1, 2, -2, -1, 0, 0, 0, 0, 0]
|
|
},
|
|
MAGNETIC_FLUX_DENSITY: {
|
|
dimensions: [1, 0, -2, -1, 0, 0, 0, 0, 0]
|
|
},
|
|
FREQUENCY: {
|
|
dimensions: [0, 0, -1, 0, 0, 0, 0, 0, 0]
|
|
},
|
|
ANGLE: {
|
|
dimensions: [0, 0, 0, 0, 0, 0, 0, 1, 0]
|
|
},
|
|
BIT: {
|
|
dimensions: [0, 0, 0, 0, 0, 0, 0, 0, 1]
|
|
}
|
|
};
|
|
for (var key in BASE_UNITS) {
|
|
if (hasOwnProperty2(BASE_UNITS, key)) {
|
|
BASE_UNITS[key].key = key;
|
|
}
|
|
}
|
|
var BASE_UNIT_NONE = {};
|
|
var UNIT_NONE = {
|
|
name: "",
|
|
base: BASE_UNIT_NONE,
|
|
value: 1,
|
|
offset: 0,
|
|
dimensions: BASE_DIMENSIONS.map((x) => 0)
|
|
};
|
|
var UNITS = {
|
|
meter: {
|
|
name: "meter",
|
|
base: BASE_UNITS.LENGTH,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
inch: {
|
|
name: "inch",
|
|
base: BASE_UNITS.LENGTH,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.0254,
|
|
offset: 0
|
|
},
|
|
foot: {
|
|
name: "foot",
|
|
base: BASE_UNITS.LENGTH,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.3048,
|
|
offset: 0
|
|
},
|
|
yard: {
|
|
name: "yard",
|
|
base: BASE_UNITS.LENGTH,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.9144,
|
|
offset: 0
|
|
},
|
|
mile: {
|
|
name: "mile",
|
|
base: BASE_UNITS.LENGTH,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 1609.344,
|
|
offset: 0
|
|
},
|
|
link: {
|
|
name: "link",
|
|
base: BASE_UNITS.LENGTH,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.201168,
|
|
offset: 0
|
|
},
|
|
rod: {
|
|
name: "rod",
|
|
base: BASE_UNITS.LENGTH,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 5.0292,
|
|
offset: 0
|
|
},
|
|
chain: {
|
|
name: "chain",
|
|
base: BASE_UNITS.LENGTH,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 20.1168,
|
|
offset: 0
|
|
},
|
|
angstrom: {
|
|
name: "angstrom",
|
|
base: BASE_UNITS.LENGTH,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 1e-10,
|
|
offset: 0
|
|
},
|
|
m: {
|
|
name: "m",
|
|
base: BASE_UNITS.LENGTH,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
in: {
|
|
name: "in",
|
|
base: BASE_UNITS.LENGTH,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.0254,
|
|
offset: 0
|
|
},
|
|
ft: {
|
|
name: "ft",
|
|
base: BASE_UNITS.LENGTH,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.3048,
|
|
offset: 0
|
|
},
|
|
yd: {
|
|
name: "yd",
|
|
base: BASE_UNITS.LENGTH,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.9144,
|
|
offset: 0
|
|
},
|
|
mi: {
|
|
name: "mi",
|
|
base: BASE_UNITS.LENGTH,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 1609.344,
|
|
offset: 0
|
|
},
|
|
li: {
|
|
name: "li",
|
|
base: BASE_UNITS.LENGTH,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.201168,
|
|
offset: 0
|
|
},
|
|
rd: {
|
|
name: "rd",
|
|
base: BASE_UNITS.LENGTH,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 5.02921,
|
|
offset: 0
|
|
},
|
|
ch: {
|
|
name: "ch",
|
|
base: BASE_UNITS.LENGTH,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 20.1168,
|
|
offset: 0
|
|
},
|
|
mil: {
|
|
name: "mil",
|
|
base: BASE_UNITS.LENGTH,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 254e-7,
|
|
offset: 0
|
|
},
|
|
m2: {
|
|
name: "m2",
|
|
base: BASE_UNITS.SURFACE,
|
|
prefixes: PREFIXES.SQUARED,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
sqin: {
|
|
name: "sqin",
|
|
base: BASE_UNITS.SURFACE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 64516e-8,
|
|
offset: 0
|
|
},
|
|
sqft: {
|
|
name: "sqft",
|
|
base: BASE_UNITS.SURFACE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.09290304,
|
|
offset: 0
|
|
},
|
|
sqyd: {
|
|
name: "sqyd",
|
|
base: BASE_UNITS.SURFACE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.83612736,
|
|
offset: 0
|
|
},
|
|
sqmi: {
|
|
name: "sqmi",
|
|
base: BASE_UNITS.SURFACE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 2589988110336e-6,
|
|
offset: 0
|
|
},
|
|
sqrd: {
|
|
name: "sqrd",
|
|
base: BASE_UNITS.SURFACE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 25.29295,
|
|
offset: 0
|
|
},
|
|
sqch: {
|
|
name: "sqch",
|
|
base: BASE_UNITS.SURFACE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 404.6873,
|
|
offset: 0
|
|
},
|
|
sqmil: {
|
|
name: "sqmil",
|
|
base: BASE_UNITS.SURFACE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 64516e-14,
|
|
offset: 0
|
|
},
|
|
acre: {
|
|
name: "acre",
|
|
base: BASE_UNITS.SURFACE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 4046.86,
|
|
offset: 0
|
|
},
|
|
hectare: {
|
|
name: "hectare",
|
|
base: BASE_UNITS.SURFACE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 1e4,
|
|
offset: 0
|
|
},
|
|
m3: {
|
|
name: "m3",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.CUBIC,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
L: {
|
|
name: "L",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1e-3,
|
|
offset: 0
|
|
},
|
|
l: {
|
|
name: "l",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1e-3,
|
|
offset: 0
|
|
},
|
|
litre: {
|
|
name: "litre",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1e-3,
|
|
offset: 0
|
|
},
|
|
cuin: {
|
|
name: "cuin",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 16387064e-12,
|
|
offset: 0
|
|
},
|
|
cuft: {
|
|
name: "cuft",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.028316846592,
|
|
offset: 0
|
|
},
|
|
cuyd: {
|
|
name: "cuyd",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.764554857984,
|
|
offset: 0
|
|
},
|
|
teaspoon: {
|
|
name: "teaspoon",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 5e-6,
|
|
offset: 0
|
|
},
|
|
tablespoon: {
|
|
name: "tablespoon",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 15e-6,
|
|
offset: 0
|
|
},
|
|
drop: {
|
|
name: "drop",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 5e-8,
|
|
offset: 0
|
|
},
|
|
gtt: {
|
|
name: "gtt",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 5e-8,
|
|
offset: 0
|
|
},
|
|
minim: {
|
|
name: "minim",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 6161152e-14,
|
|
offset: 0
|
|
},
|
|
fluiddram: {
|
|
name: "fluiddram",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 36966911e-13,
|
|
offset: 0
|
|
},
|
|
fluidounce: {
|
|
name: "fluidounce",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 2957353e-11,
|
|
offset: 0
|
|
},
|
|
gill: {
|
|
name: "gill",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 1182941e-10,
|
|
offset: 0
|
|
},
|
|
cc: {
|
|
name: "cc",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 1e-6,
|
|
offset: 0
|
|
},
|
|
cup: {
|
|
name: "cup",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 2365882e-10,
|
|
offset: 0
|
|
},
|
|
pint: {
|
|
name: "pint",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 4731765e-10,
|
|
offset: 0
|
|
},
|
|
quart: {
|
|
name: "quart",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 9463529e-10,
|
|
offset: 0
|
|
},
|
|
gallon: {
|
|
name: "gallon",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 3785412e-9,
|
|
offset: 0
|
|
},
|
|
beerbarrel: {
|
|
name: "beerbarrel",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.1173478,
|
|
offset: 0
|
|
},
|
|
oilbarrel: {
|
|
name: "oilbarrel",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.1589873,
|
|
offset: 0
|
|
},
|
|
hogshead: {
|
|
name: "hogshead",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.238481,
|
|
offset: 0
|
|
},
|
|
fldr: {
|
|
name: "fldr",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 36966911e-13,
|
|
offset: 0
|
|
},
|
|
floz: {
|
|
name: "floz",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 2957353e-11,
|
|
offset: 0
|
|
},
|
|
gi: {
|
|
name: "gi",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 1182941e-10,
|
|
offset: 0
|
|
},
|
|
cp: {
|
|
name: "cp",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 2365882e-10,
|
|
offset: 0
|
|
},
|
|
pt: {
|
|
name: "pt",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 4731765e-10,
|
|
offset: 0
|
|
},
|
|
qt: {
|
|
name: "qt",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 9463529e-10,
|
|
offset: 0
|
|
},
|
|
gal: {
|
|
name: "gal",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 3785412e-9,
|
|
offset: 0
|
|
},
|
|
bbl: {
|
|
name: "bbl",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.1173478,
|
|
offset: 0
|
|
},
|
|
obl: {
|
|
name: "obl",
|
|
base: BASE_UNITS.VOLUME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.1589873,
|
|
offset: 0
|
|
},
|
|
g: {
|
|
name: "g",
|
|
base: BASE_UNITS.MASS,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1e-3,
|
|
offset: 0
|
|
},
|
|
gram: {
|
|
name: "gram",
|
|
base: BASE_UNITS.MASS,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1e-3,
|
|
offset: 0
|
|
},
|
|
ton: {
|
|
name: "ton",
|
|
base: BASE_UNITS.MASS,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 907.18474,
|
|
offset: 0
|
|
},
|
|
t: {
|
|
name: "t",
|
|
base: BASE_UNITS.MASS,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1e3,
|
|
offset: 0
|
|
},
|
|
tonne: {
|
|
name: "tonne",
|
|
base: BASE_UNITS.MASS,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1e3,
|
|
offset: 0
|
|
},
|
|
grain: {
|
|
name: "grain",
|
|
base: BASE_UNITS.MASS,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 6479891e-11,
|
|
offset: 0
|
|
},
|
|
dram: {
|
|
name: "dram",
|
|
base: BASE_UNITS.MASS,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.0017718451953125,
|
|
offset: 0
|
|
},
|
|
ounce: {
|
|
name: "ounce",
|
|
base: BASE_UNITS.MASS,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.028349523125,
|
|
offset: 0
|
|
},
|
|
poundmass: {
|
|
name: "poundmass",
|
|
base: BASE_UNITS.MASS,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.45359237,
|
|
offset: 0
|
|
},
|
|
hundredweight: {
|
|
name: "hundredweight",
|
|
base: BASE_UNITS.MASS,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 45.359237,
|
|
offset: 0
|
|
},
|
|
stick: {
|
|
name: "stick",
|
|
base: BASE_UNITS.MASS,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.115,
|
|
offset: 0
|
|
},
|
|
stone: {
|
|
name: "stone",
|
|
base: BASE_UNITS.MASS,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 6.35029318,
|
|
offset: 0
|
|
},
|
|
gr: {
|
|
name: "gr",
|
|
base: BASE_UNITS.MASS,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 6479891e-11,
|
|
offset: 0
|
|
},
|
|
dr: {
|
|
name: "dr",
|
|
base: BASE_UNITS.MASS,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.0017718451953125,
|
|
offset: 0
|
|
},
|
|
oz: {
|
|
name: "oz",
|
|
base: BASE_UNITS.MASS,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.028349523125,
|
|
offset: 0
|
|
},
|
|
lbm: {
|
|
name: "lbm",
|
|
base: BASE_UNITS.MASS,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 0.45359237,
|
|
offset: 0
|
|
},
|
|
cwt: {
|
|
name: "cwt",
|
|
base: BASE_UNITS.MASS,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 45.359237,
|
|
offset: 0
|
|
},
|
|
s: {
|
|
name: "s",
|
|
base: BASE_UNITS.TIME,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
min: {
|
|
name: "min",
|
|
base: BASE_UNITS.TIME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 60,
|
|
offset: 0
|
|
},
|
|
h: {
|
|
name: "h",
|
|
base: BASE_UNITS.TIME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 3600,
|
|
offset: 0
|
|
},
|
|
second: {
|
|
name: "second",
|
|
base: BASE_UNITS.TIME,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
sec: {
|
|
name: "sec",
|
|
base: BASE_UNITS.TIME,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
minute: {
|
|
name: "minute",
|
|
base: BASE_UNITS.TIME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 60,
|
|
offset: 0
|
|
},
|
|
hour: {
|
|
name: "hour",
|
|
base: BASE_UNITS.TIME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 3600,
|
|
offset: 0
|
|
},
|
|
day: {
|
|
name: "day",
|
|
base: BASE_UNITS.TIME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 86400,
|
|
offset: 0
|
|
},
|
|
week: {
|
|
name: "week",
|
|
base: BASE_UNITS.TIME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 7 * 86400,
|
|
offset: 0
|
|
},
|
|
month: {
|
|
name: "month",
|
|
base: BASE_UNITS.TIME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 2629800,
|
|
offset: 0
|
|
},
|
|
year: {
|
|
name: "year",
|
|
base: BASE_UNITS.TIME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 31557600,
|
|
offset: 0
|
|
},
|
|
decade: {
|
|
name: "decade",
|
|
base: BASE_UNITS.TIME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 315576e3,
|
|
offset: 0
|
|
},
|
|
century: {
|
|
name: "century",
|
|
base: BASE_UNITS.TIME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 315576e4,
|
|
offset: 0
|
|
},
|
|
millennium: {
|
|
name: "millennium",
|
|
base: BASE_UNITS.TIME,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 315576e5,
|
|
offset: 0
|
|
},
|
|
hertz: {
|
|
name: "Hertz",
|
|
base: BASE_UNITS.FREQUENCY,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1,
|
|
offset: 0,
|
|
reciprocal: true
|
|
},
|
|
Hz: {
|
|
name: "Hz",
|
|
base: BASE_UNITS.FREQUENCY,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0,
|
|
reciprocal: true
|
|
},
|
|
rad: {
|
|
name: "rad",
|
|
base: BASE_UNITS.ANGLE,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
radian: {
|
|
name: "radian",
|
|
base: BASE_UNITS.ANGLE,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
deg: {
|
|
name: "deg",
|
|
base: BASE_UNITS.ANGLE,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: null,
|
|
offset: 0
|
|
},
|
|
degree: {
|
|
name: "degree",
|
|
base: BASE_UNITS.ANGLE,
|
|
prefixes: PREFIXES.LONG,
|
|
value: null,
|
|
offset: 0
|
|
},
|
|
grad: {
|
|
name: "grad",
|
|
base: BASE_UNITS.ANGLE,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: null,
|
|
offset: 0
|
|
},
|
|
gradian: {
|
|
name: "gradian",
|
|
base: BASE_UNITS.ANGLE,
|
|
prefixes: PREFIXES.LONG,
|
|
value: null,
|
|
offset: 0
|
|
},
|
|
cycle: {
|
|
name: "cycle",
|
|
base: BASE_UNITS.ANGLE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: null,
|
|
offset: 0
|
|
},
|
|
arcsec: {
|
|
name: "arcsec",
|
|
base: BASE_UNITS.ANGLE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: null,
|
|
offset: 0
|
|
},
|
|
arcmin: {
|
|
name: "arcmin",
|
|
base: BASE_UNITS.ANGLE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: null,
|
|
offset: 0
|
|
},
|
|
A: {
|
|
name: "A",
|
|
base: BASE_UNITS.CURRENT,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
ampere: {
|
|
name: "ampere",
|
|
base: BASE_UNITS.CURRENT,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
K: {
|
|
name: "K",
|
|
base: BASE_UNITS.TEMPERATURE,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
degC: {
|
|
name: "degC",
|
|
base: BASE_UNITS.TEMPERATURE,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 273.15
|
|
},
|
|
degF: {
|
|
name: "degF",
|
|
base: BASE_UNITS.TEMPERATURE,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1 / 1.8,
|
|
offset: 459.67
|
|
},
|
|
degR: {
|
|
name: "degR",
|
|
base: BASE_UNITS.TEMPERATURE,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1 / 1.8,
|
|
offset: 0
|
|
},
|
|
kelvin: {
|
|
name: "kelvin",
|
|
base: BASE_UNITS.TEMPERATURE,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
celsius: {
|
|
name: "celsius",
|
|
base: BASE_UNITS.TEMPERATURE,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1,
|
|
offset: 273.15
|
|
},
|
|
fahrenheit: {
|
|
name: "fahrenheit",
|
|
base: BASE_UNITS.TEMPERATURE,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1 / 1.8,
|
|
offset: 459.67
|
|
},
|
|
rankine: {
|
|
name: "rankine",
|
|
base: BASE_UNITS.TEMPERATURE,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1 / 1.8,
|
|
offset: 0
|
|
},
|
|
mol: {
|
|
name: "mol",
|
|
base: BASE_UNITS.AMOUNT_OF_SUBSTANCE,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
mole: {
|
|
name: "mole",
|
|
base: BASE_UNITS.AMOUNT_OF_SUBSTANCE,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
cd: {
|
|
name: "cd",
|
|
base: BASE_UNITS.LUMINOUS_INTENSITY,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
candela: {
|
|
name: "candela",
|
|
base: BASE_UNITS.LUMINOUS_INTENSITY,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
N: {
|
|
name: "N",
|
|
base: BASE_UNITS.FORCE,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
newton: {
|
|
name: "newton",
|
|
base: BASE_UNITS.FORCE,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
dyn: {
|
|
name: "dyn",
|
|
base: BASE_UNITS.FORCE,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1e-5,
|
|
offset: 0
|
|
},
|
|
dyne: {
|
|
name: "dyne",
|
|
base: BASE_UNITS.FORCE,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1e-5,
|
|
offset: 0
|
|
},
|
|
lbf: {
|
|
name: "lbf",
|
|
base: BASE_UNITS.FORCE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 4.4482216152605,
|
|
offset: 0
|
|
},
|
|
poundforce: {
|
|
name: "poundforce",
|
|
base: BASE_UNITS.FORCE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 4.4482216152605,
|
|
offset: 0
|
|
},
|
|
kip: {
|
|
name: "kip",
|
|
base: BASE_UNITS.FORCE,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 4448.2216,
|
|
offset: 0
|
|
},
|
|
kilogramforce: {
|
|
name: "kilogramforce",
|
|
base: BASE_UNITS.FORCE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 9.80665,
|
|
offset: 0
|
|
},
|
|
J: {
|
|
name: "J",
|
|
base: BASE_UNITS.ENERGY,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
joule: {
|
|
name: "joule",
|
|
base: BASE_UNITS.ENERGY,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
erg: {
|
|
name: "erg",
|
|
base: BASE_UNITS.ENERGY,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 1e-7,
|
|
offset: 0
|
|
},
|
|
Wh: {
|
|
name: "Wh",
|
|
base: BASE_UNITS.ENERGY,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 3600,
|
|
offset: 0
|
|
},
|
|
BTU: {
|
|
name: "BTU",
|
|
base: BASE_UNITS.ENERGY,
|
|
prefixes: PREFIXES.BTU,
|
|
value: 1055.05585262,
|
|
offset: 0
|
|
},
|
|
eV: {
|
|
name: "eV",
|
|
base: BASE_UNITS.ENERGY,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1602176565e-28,
|
|
offset: 0
|
|
},
|
|
electronvolt: {
|
|
name: "electronvolt",
|
|
base: BASE_UNITS.ENERGY,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1602176565e-28,
|
|
offset: 0
|
|
},
|
|
W: {
|
|
name: "W",
|
|
base: BASE_UNITS.POWER,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
watt: {
|
|
name: "watt",
|
|
base: BASE_UNITS.POWER,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
hp: {
|
|
name: "hp",
|
|
base: BASE_UNITS.POWER,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 745.6998715386,
|
|
offset: 0
|
|
},
|
|
VAR: {
|
|
name: "VAR",
|
|
base: BASE_UNITS.POWER,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: Complex3.I,
|
|
offset: 0
|
|
},
|
|
VA: {
|
|
name: "VA",
|
|
base: BASE_UNITS.POWER,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
Pa: {
|
|
name: "Pa",
|
|
base: BASE_UNITS.PRESSURE,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
psi: {
|
|
name: "psi",
|
|
base: BASE_UNITS.PRESSURE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 6894.75729276459,
|
|
offset: 0
|
|
},
|
|
atm: {
|
|
name: "atm",
|
|
base: BASE_UNITS.PRESSURE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 101325,
|
|
offset: 0
|
|
},
|
|
bar: {
|
|
name: "bar",
|
|
base: BASE_UNITS.PRESSURE,
|
|
prefixes: PREFIXES.SHORTLONG,
|
|
value: 1e5,
|
|
offset: 0
|
|
},
|
|
torr: {
|
|
name: "torr",
|
|
base: BASE_UNITS.PRESSURE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 133.322,
|
|
offset: 0
|
|
},
|
|
mmHg: {
|
|
name: "mmHg",
|
|
base: BASE_UNITS.PRESSURE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 133.322,
|
|
offset: 0
|
|
},
|
|
mmH2O: {
|
|
name: "mmH2O",
|
|
base: BASE_UNITS.PRESSURE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 9.80665,
|
|
offset: 0
|
|
},
|
|
cmH2O: {
|
|
name: "cmH2O",
|
|
base: BASE_UNITS.PRESSURE,
|
|
prefixes: PREFIXES.NONE,
|
|
value: 98.0665,
|
|
offset: 0
|
|
},
|
|
coulomb: {
|
|
name: "coulomb",
|
|
base: BASE_UNITS.ELECTRIC_CHARGE,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
C: {
|
|
name: "C",
|
|
base: BASE_UNITS.ELECTRIC_CHARGE,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
farad: {
|
|
name: "farad",
|
|
base: BASE_UNITS.ELECTRIC_CAPACITANCE,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
F: {
|
|
name: "F",
|
|
base: BASE_UNITS.ELECTRIC_CAPACITANCE,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
volt: {
|
|
name: "volt",
|
|
base: BASE_UNITS.ELECTRIC_POTENTIAL,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
V: {
|
|
name: "V",
|
|
base: BASE_UNITS.ELECTRIC_POTENTIAL,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
ohm: {
|
|
name: "ohm",
|
|
base: BASE_UNITS.ELECTRIC_RESISTANCE,
|
|
prefixes: PREFIXES.SHORTLONG,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
henry: {
|
|
name: "henry",
|
|
base: BASE_UNITS.ELECTRIC_INDUCTANCE,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
H: {
|
|
name: "H",
|
|
base: BASE_UNITS.ELECTRIC_INDUCTANCE,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
siemens: {
|
|
name: "siemens",
|
|
base: BASE_UNITS.ELECTRIC_CONDUCTANCE,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
S: {
|
|
name: "S",
|
|
base: BASE_UNITS.ELECTRIC_CONDUCTANCE,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
weber: {
|
|
name: "weber",
|
|
base: BASE_UNITS.MAGNETIC_FLUX,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
Wb: {
|
|
name: "Wb",
|
|
base: BASE_UNITS.MAGNETIC_FLUX,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
tesla: {
|
|
name: "tesla",
|
|
base: BASE_UNITS.MAGNETIC_FLUX_DENSITY,
|
|
prefixes: PREFIXES.LONG,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
T: {
|
|
name: "T",
|
|
base: BASE_UNITS.MAGNETIC_FLUX_DENSITY,
|
|
prefixes: PREFIXES.SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
b: {
|
|
name: "b",
|
|
base: BASE_UNITS.BIT,
|
|
prefixes: PREFIXES.BINARY_SHORT,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
bits: {
|
|
name: "bits",
|
|
base: BASE_UNITS.BIT,
|
|
prefixes: PREFIXES.BINARY_LONG,
|
|
value: 1,
|
|
offset: 0
|
|
},
|
|
B: {
|
|
name: "B",
|
|
base: BASE_UNITS.BIT,
|
|
prefixes: PREFIXES.BINARY_SHORT,
|
|
value: 8,
|
|
offset: 0
|
|
},
|
|
bytes: {
|
|
name: "bytes",
|
|
base: BASE_UNITS.BIT,
|
|
prefixes: PREFIXES.BINARY_LONG,
|
|
value: 8,
|
|
offset: 0
|
|
}
|
|
};
|
|
var ALIASES = {
|
|
meters: "meter",
|
|
inches: "inch",
|
|
feet: "foot",
|
|
yards: "yard",
|
|
miles: "mile",
|
|
links: "link",
|
|
rods: "rod",
|
|
chains: "chain",
|
|
angstroms: "angstrom",
|
|
lt: "l",
|
|
litres: "litre",
|
|
liter: "litre",
|
|
liters: "litre",
|
|
teaspoons: "teaspoon",
|
|
tablespoons: "tablespoon",
|
|
minims: "minim",
|
|
fluiddrams: "fluiddram",
|
|
fluidounces: "fluidounce",
|
|
gills: "gill",
|
|
cups: "cup",
|
|
pints: "pint",
|
|
quarts: "quart",
|
|
gallons: "gallon",
|
|
beerbarrels: "beerbarrel",
|
|
oilbarrels: "oilbarrel",
|
|
hogsheads: "hogshead",
|
|
gtts: "gtt",
|
|
grams: "gram",
|
|
tons: "ton",
|
|
tonnes: "tonne",
|
|
grains: "grain",
|
|
drams: "dram",
|
|
ounces: "ounce",
|
|
poundmasses: "poundmass",
|
|
hundredweights: "hundredweight",
|
|
sticks: "stick",
|
|
lb: "lbm",
|
|
lbs: "lbm",
|
|
kips: "kip",
|
|
kgf: "kilogramforce",
|
|
acres: "acre",
|
|
hectares: "hectare",
|
|
sqfeet: "sqft",
|
|
sqyard: "sqyd",
|
|
sqmile: "sqmi",
|
|
sqmiles: "sqmi",
|
|
mmhg: "mmHg",
|
|
mmh2o: "mmH2O",
|
|
cmh2o: "cmH2O",
|
|
seconds: "second",
|
|
secs: "second",
|
|
minutes: "minute",
|
|
mins: "minute",
|
|
hours: "hour",
|
|
hr: "hour",
|
|
hrs: "hour",
|
|
days: "day",
|
|
weeks: "week",
|
|
months: "month",
|
|
years: "year",
|
|
decades: "decade",
|
|
centuries: "century",
|
|
millennia: "millennium",
|
|
hertz: "hertz",
|
|
radians: "radian",
|
|
degrees: "degree",
|
|
gradians: "gradian",
|
|
cycles: "cycle",
|
|
arcsecond: "arcsec",
|
|
arcseconds: "arcsec",
|
|
arcminute: "arcmin",
|
|
arcminutes: "arcmin",
|
|
BTUs: "BTU",
|
|
watts: "watt",
|
|
joules: "joule",
|
|
amperes: "ampere",
|
|
coulombs: "coulomb",
|
|
volts: "volt",
|
|
ohms: "ohm",
|
|
farads: "farad",
|
|
webers: "weber",
|
|
teslas: "tesla",
|
|
electronvolts: "electronvolt",
|
|
moles: "mole",
|
|
bit: "bits",
|
|
byte: "bytes"
|
|
};
|
|
function calculateAngleValues(config5) {
|
|
if (config5.number === "BigNumber") {
|
|
var pi3 = createBigNumberPi(_BigNumber);
|
|
UNITS.rad.value = new _BigNumber(1);
|
|
UNITS.deg.value = pi3.div(180);
|
|
UNITS.grad.value = pi3.div(200);
|
|
UNITS.cycle.value = pi3.times(2);
|
|
UNITS.arcsec.value = pi3.div(648e3);
|
|
UNITS.arcmin.value = pi3.div(10800);
|
|
} else {
|
|
UNITS.rad.value = 1;
|
|
UNITS.deg.value = Math.PI / 180;
|
|
UNITS.grad.value = Math.PI / 200;
|
|
UNITS.cycle.value = Math.PI * 2;
|
|
UNITS.arcsec.value = Math.PI / 648e3;
|
|
UNITS.arcmin.value = Math.PI / 10800;
|
|
}
|
|
UNITS.radian.value = UNITS.rad.value;
|
|
UNITS.degree.value = UNITS.deg.value;
|
|
UNITS.gradian.value = UNITS.grad.value;
|
|
}
|
|
calculateAngleValues(config4);
|
|
if (on) {
|
|
on("config", function(curr, prev) {
|
|
if (curr.number !== prev.number) {
|
|
calculateAngleValues(curr);
|
|
}
|
|
});
|
|
}
|
|
var UNIT_SYSTEMS = {
|
|
si: {
|
|
NONE: {
|
|
unit: UNIT_NONE,
|
|
prefix: PREFIXES.NONE[""]
|
|
},
|
|
LENGTH: {
|
|
unit: UNITS.m,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
MASS: {
|
|
unit: UNITS.g,
|
|
prefix: PREFIXES.SHORT.k
|
|
},
|
|
TIME: {
|
|
unit: UNITS.s,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
CURRENT: {
|
|
unit: UNITS.A,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
TEMPERATURE: {
|
|
unit: UNITS.K,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
LUMINOUS_INTENSITY: {
|
|
unit: UNITS.cd,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
AMOUNT_OF_SUBSTANCE: {
|
|
unit: UNITS.mol,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
ANGLE: {
|
|
unit: UNITS.rad,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
BIT: {
|
|
unit: UNITS.bits,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
FORCE: {
|
|
unit: UNITS.N,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
ENERGY: {
|
|
unit: UNITS.J,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
POWER: {
|
|
unit: UNITS.W,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
PRESSURE: {
|
|
unit: UNITS.Pa,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
ELECTRIC_CHARGE: {
|
|
unit: UNITS.C,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
ELECTRIC_CAPACITANCE: {
|
|
unit: UNITS.F,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
ELECTRIC_POTENTIAL: {
|
|
unit: UNITS.V,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
ELECTRIC_RESISTANCE: {
|
|
unit: UNITS.ohm,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
ELECTRIC_INDUCTANCE: {
|
|
unit: UNITS.H,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
ELECTRIC_CONDUCTANCE: {
|
|
unit: UNITS.S,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
MAGNETIC_FLUX: {
|
|
unit: UNITS.Wb,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
MAGNETIC_FLUX_DENSITY: {
|
|
unit: UNITS.T,
|
|
prefix: PREFIXES.SHORT[""]
|
|
},
|
|
FREQUENCY: {
|
|
unit: UNITS.Hz,
|
|
prefix: PREFIXES.SHORT[""]
|
|
}
|
|
}
|
|
};
|
|
UNIT_SYSTEMS.cgs = JSON.parse(JSON.stringify(UNIT_SYSTEMS.si));
|
|
UNIT_SYSTEMS.cgs.LENGTH = {
|
|
unit: UNITS.m,
|
|
prefix: PREFIXES.SHORT.c
|
|
};
|
|
UNIT_SYSTEMS.cgs.MASS = {
|
|
unit: UNITS.g,
|
|
prefix: PREFIXES.SHORT[""]
|
|
};
|
|
UNIT_SYSTEMS.cgs.FORCE = {
|
|
unit: UNITS.dyn,
|
|
prefix: PREFIXES.SHORT[""]
|
|
};
|
|
UNIT_SYSTEMS.cgs.ENERGY = {
|
|
unit: UNITS.erg,
|
|
prefix: PREFIXES.NONE[""]
|
|
};
|
|
UNIT_SYSTEMS.us = JSON.parse(JSON.stringify(UNIT_SYSTEMS.si));
|
|
UNIT_SYSTEMS.us.LENGTH = {
|
|
unit: UNITS.ft,
|
|
prefix: PREFIXES.NONE[""]
|
|
};
|
|
UNIT_SYSTEMS.us.MASS = {
|
|
unit: UNITS.lbm,
|
|
prefix: PREFIXES.NONE[""]
|
|
};
|
|
UNIT_SYSTEMS.us.TEMPERATURE = {
|
|
unit: UNITS.degF,
|
|
prefix: PREFIXES.NONE[""]
|
|
};
|
|
UNIT_SYSTEMS.us.FORCE = {
|
|
unit: UNITS.lbf,
|
|
prefix: PREFIXES.NONE[""]
|
|
};
|
|
UNIT_SYSTEMS.us.ENERGY = {
|
|
unit: UNITS.BTU,
|
|
prefix: PREFIXES.BTU[""]
|
|
};
|
|
UNIT_SYSTEMS.us.POWER = {
|
|
unit: UNITS.hp,
|
|
prefix: PREFIXES.NONE[""]
|
|
};
|
|
UNIT_SYSTEMS.us.PRESSURE = {
|
|
unit: UNITS.psi,
|
|
prefix: PREFIXES.NONE[""]
|
|
};
|
|
UNIT_SYSTEMS.auto = JSON.parse(JSON.stringify(UNIT_SYSTEMS.si));
|
|
var currentUnitSystem = UNIT_SYSTEMS.auto;
|
|
Unit2.setUnitSystem = function(name302) {
|
|
if (hasOwnProperty2(UNIT_SYSTEMS, name302)) {
|
|
currentUnitSystem = UNIT_SYSTEMS[name302];
|
|
} else {
|
|
throw new Error("Unit system " + name302 + " does not exist. Choices are: " + Object.keys(UNIT_SYSTEMS).join(", "));
|
|
}
|
|
};
|
|
Unit2.getUnitSystem = function() {
|
|
for (var _key in UNIT_SYSTEMS) {
|
|
if (hasOwnProperty2(UNIT_SYSTEMS, _key)) {
|
|
if (UNIT_SYSTEMS[_key] === currentUnitSystem) {
|
|
return _key;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
Unit2.typeConverters = {
|
|
BigNumber: function BigNumber2(x) {
|
|
return new _BigNumber(x + "");
|
|
},
|
|
Fraction: function Fraction3(x) {
|
|
return new _Fraction(x);
|
|
},
|
|
Complex: function Complex4(x) {
|
|
return x;
|
|
},
|
|
number: function number3(x) {
|
|
return x;
|
|
}
|
|
};
|
|
Unit2.prototype._numberConverter = function() {
|
|
var convert = Unit2.typeConverters[this.valueType()];
|
|
if (convert) {
|
|
return convert;
|
|
}
|
|
throw new TypeError('Unsupported Unit value type "' + this.valueType() + '"');
|
|
};
|
|
Unit2._getNumberConverter = function(type) {
|
|
if (!Unit2.typeConverters[type]) {
|
|
throw new TypeError('Unsupported type "' + type + '"');
|
|
}
|
|
return Unit2.typeConverters[type];
|
|
};
|
|
for (var _key2 in UNITS) {
|
|
if (hasOwnProperty2(UNITS, _key2)) {
|
|
var unit2 = UNITS[_key2];
|
|
unit2.dimensions = unit2.base.dimensions;
|
|
}
|
|
}
|
|
for (var _name2 in ALIASES) {
|
|
if (hasOwnProperty2(ALIASES, _name2)) {
|
|
var _unit2 = UNITS[ALIASES[_name2]];
|
|
var alias = {};
|
|
for (var _key3 in _unit2) {
|
|
if (hasOwnProperty2(_unit2, _key3)) {
|
|
alias[_key3] = _unit2[_key3];
|
|
}
|
|
}
|
|
alias.name = _name2;
|
|
UNITS[_name2] = alias;
|
|
}
|
|
}
|
|
Unit2.isValidAlpha = function isValidAlpha(c2) {
|
|
return /^[a-zA-Z]$/.test(c2);
|
|
};
|
|
function assertUnitNameIsValid(name302) {
|
|
for (var i2 = 0; i2 < name302.length; i2++) {
|
|
c = name302.charAt(i2);
|
|
if (i2 === 0 && !Unit2.isValidAlpha(c)) {
|
|
throw new Error('Invalid unit name (must begin with alpha character): "' + name302 + '"');
|
|
}
|
|
if (i2 > 0 && !(Unit2.isValidAlpha(c) || isDigit(c))) {
|
|
throw new Error('Invalid unit name (only alphanumeric characters are allowed): "' + name302 + '"');
|
|
}
|
|
}
|
|
}
|
|
Unit2.createUnit = function(obj, options) {
|
|
if (typeof obj !== "object") {
|
|
throw new TypeError("createUnit expects first parameter to be of type 'Object'");
|
|
}
|
|
if (options && options.override) {
|
|
for (var _key4 in obj) {
|
|
if (hasOwnProperty2(obj, _key4)) {
|
|
Unit2.deleteUnit(_key4);
|
|
}
|
|
if (obj[_key4].aliases) {
|
|
for (var i2 = 0; i2 < obj[_key4].aliases.length; i2++) {
|
|
Unit2.deleteUnit(obj[_key4].aliases[i2]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var lastUnit;
|
|
for (var _key5 in obj) {
|
|
if (hasOwnProperty2(obj, _key5)) {
|
|
lastUnit = Unit2.createUnitSingle(_key5, obj[_key5]);
|
|
}
|
|
}
|
|
return lastUnit;
|
|
};
|
|
Unit2.createUnitSingle = function(name302, obj) {
|
|
if (typeof obj === "undefined" || obj === null) {
|
|
obj = {};
|
|
}
|
|
if (typeof name302 !== "string") {
|
|
throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");
|
|
}
|
|
if (hasOwnProperty2(UNITS, name302)) {
|
|
throw new Error('Cannot create unit "' + name302 + '": a unit with that name already exists');
|
|
}
|
|
assertUnitNameIsValid(name302);
|
|
var defUnit = null;
|
|
var aliases = [];
|
|
var offset = 0;
|
|
var definition;
|
|
var prefixes;
|
|
var baseName;
|
|
if (obj && obj.type === "Unit") {
|
|
defUnit = obj.clone();
|
|
} else if (typeof obj === "string") {
|
|
if (obj !== "") {
|
|
definition = obj;
|
|
}
|
|
} else if (typeof obj === "object") {
|
|
definition = obj.definition;
|
|
prefixes = obj.prefixes;
|
|
offset = obj.offset;
|
|
baseName = obj.baseName;
|
|
if (obj.aliases) {
|
|
aliases = obj.aliases.valueOf();
|
|
}
|
|
} else {
|
|
throw new TypeError('Cannot create unit "' + name302 + '" from "' + obj.toString() + '": expecting "string" or "Unit" or "Object"');
|
|
}
|
|
if (aliases) {
|
|
for (var i2 = 0; i2 < aliases.length; i2++) {
|
|
if (hasOwnProperty2(UNITS, aliases[i2])) {
|
|
throw new Error('Cannot create alias "' + aliases[i2] + '": a unit with that name already exists');
|
|
}
|
|
}
|
|
}
|
|
if (definition && typeof definition === "string" && !defUnit) {
|
|
try {
|
|
defUnit = Unit2.parse(definition, {
|
|
allowNoUnits: true
|
|
});
|
|
} catch (ex) {
|
|
ex.message = 'Could not create unit "' + name302 + '" from "' + definition + '": ' + ex.message;
|
|
throw ex;
|
|
}
|
|
} else if (definition && definition.type === "Unit") {
|
|
defUnit = definition.clone();
|
|
}
|
|
aliases = aliases || [];
|
|
offset = offset || 0;
|
|
if (prefixes && prefixes.toUpperCase) {
|
|
prefixes = PREFIXES[prefixes.toUpperCase()] || PREFIXES.NONE;
|
|
} else {
|
|
prefixes = PREFIXES.NONE;
|
|
}
|
|
var newUnit = {};
|
|
if (!defUnit) {
|
|
baseName = baseName || name302 + "_STUFF";
|
|
if (BASE_DIMENSIONS.indexOf(baseName) >= 0) {
|
|
throw new Error('Cannot create new base unit "' + name302 + '": a base unit with that name already exists (and cannot be overridden)');
|
|
}
|
|
BASE_DIMENSIONS.push(baseName);
|
|
for (var b in BASE_UNITS) {
|
|
if (hasOwnProperty2(BASE_UNITS, b)) {
|
|
BASE_UNITS[b].dimensions[BASE_DIMENSIONS.length - 1] = 0;
|
|
}
|
|
}
|
|
var newBaseUnit = {
|
|
dimensions: []
|
|
};
|
|
for (var _i6 = 0; _i6 < BASE_DIMENSIONS.length; _i6++) {
|
|
newBaseUnit.dimensions[_i6] = 0;
|
|
}
|
|
newBaseUnit.dimensions[BASE_DIMENSIONS.length - 1] = 1;
|
|
newBaseUnit.key = baseName;
|
|
BASE_UNITS[baseName] = newBaseUnit;
|
|
newUnit = {
|
|
name: name302,
|
|
value: 1,
|
|
dimensions: BASE_UNITS[baseName].dimensions.slice(0),
|
|
prefixes,
|
|
offset,
|
|
base: BASE_UNITS[baseName]
|
|
};
|
|
currentUnitSystem[baseName] = {
|
|
unit: newUnit,
|
|
prefix: PREFIXES.NONE[""]
|
|
};
|
|
} else {
|
|
newUnit = {
|
|
name: name302,
|
|
value: defUnit.value,
|
|
dimensions: defUnit.dimensions.slice(0),
|
|
prefixes,
|
|
offset
|
|
};
|
|
var anyMatch = false;
|
|
for (var _i7 in BASE_UNITS) {
|
|
if (hasOwnProperty2(BASE_UNITS, _i7)) {
|
|
var match = true;
|
|
for (var j = 0; j < BASE_DIMENSIONS.length; j++) {
|
|
if (Math.abs((newUnit.dimensions[j] || 0) - (BASE_UNITS[_i7].dimensions[j] || 0)) > 1e-12) {
|
|
match = false;
|
|
break;
|
|
}
|
|
}
|
|
if (match) {
|
|
anyMatch = true;
|
|
newUnit.base = BASE_UNITS[_i7];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (!anyMatch) {
|
|
baseName = baseName || name302 + "_STUFF";
|
|
var _newBaseUnit = {
|
|
dimensions: defUnit.dimensions.slice(0)
|
|
};
|
|
_newBaseUnit.key = baseName;
|
|
BASE_UNITS[baseName] = _newBaseUnit;
|
|
currentUnitSystem[baseName] = {
|
|
unit: newUnit,
|
|
prefix: PREFIXES.NONE[""]
|
|
};
|
|
newUnit.base = BASE_UNITS[baseName];
|
|
}
|
|
}
|
|
Unit2.UNITS[name302] = newUnit;
|
|
for (var _i8 = 0; _i8 < aliases.length; _i8++) {
|
|
var aliasName = aliases[_i8];
|
|
var _alias = {};
|
|
for (var _key6 in newUnit) {
|
|
if (hasOwnProperty2(newUnit, _key6)) {
|
|
_alias[_key6] = newUnit[_key6];
|
|
}
|
|
}
|
|
_alias.name = aliasName;
|
|
Unit2.UNITS[aliasName] = _alias;
|
|
}
|
|
delete _findUnit.cache;
|
|
return new Unit2(null, name302);
|
|
};
|
|
Unit2.deleteUnit = function(name302) {
|
|
delete Unit2.UNITS[name302];
|
|
};
|
|
Unit2.PREFIXES = PREFIXES;
|
|
Unit2.BASE_DIMENSIONS = BASE_DIMENSIONS;
|
|
Unit2.BASE_UNITS = BASE_UNITS;
|
|
Unit2.UNIT_SYSTEMS = UNIT_SYSTEMS;
|
|
Unit2.UNITS = UNITS;
|
|
return Unit2;
|
|
}, {
|
|
isClass: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/unit/function/unit.js
|
|
var name159 = "unit";
|
|
var dependencies159 = ["typed", "Unit"];
|
|
var createUnitFunction = /* @__PURE__ */ factory(name159, dependencies159, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
Unit: Unit2
|
|
} = _ref;
|
|
return typed2(name159, {
|
|
Unit: function Unit3(x) {
|
|
return x.clone();
|
|
},
|
|
string: function string2(x) {
|
|
if (Unit2.isValuelessUnit(x)) {
|
|
return new Unit2(null, x);
|
|
}
|
|
return Unit2.parse(x, {
|
|
allowNoUnits: true
|
|
});
|
|
},
|
|
"number | BigNumber | Fraction | Complex, string | Unit": function numberBigNumberFractionComplexStringUnit(value, unit2) {
|
|
return new Unit2(value, unit2);
|
|
},
|
|
"number | BigNumber | Fraction": function numberBigNumberFraction(value) {
|
|
return new Unit2(value);
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (x) => deepMap(x, self2))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/function/sparse.js
|
|
var name160 = "sparse";
|
|
var dependencies160 = ["typed", "SparseMatrix"];
|
|
var createSparse = /* @__PURE__ */ factory(name160, dependencies160, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
SparseMatrix: SparseMatrix2
|
|
} = _ref;
|
|
return typed2(name160, {
|
|
"": function _() {
|
|
return new SparseMatrix2([]);
|
|
},
|
|
string: function string2(datatype) {
|
|
return new SparseMatrix2([], datatype);
|
|
},
|
|
"Array | Matrix": function ArrayMatrix(data) {
|
|
return new SparseMatrix2(data);
|
|
},
|
|
"Array | Matrix, string": function ArrayMatrixString(data, datatype) {
|
|
return new SparseMatrix2(data, datatype);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/unit/function/createUnit.js
|
|
var name161 = "createUnit";
|
|
var dependencies161 = ["typed", "Unit"];
|
|
var createCreateUnit = /* @__PURE__ */ factory(name161, dependencies161, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
Unit: Unit2
|
|
} = _ref;
|
|
return typed2(name161, {
|
|
"Object, Object": function ObjectObject(obj, options) {
|
|
return Unit2.createUnit(obj, options);
|
|
},
|
|
Object: function Object2(obj) {
|
|
return Unit2.createUnit(obj, {});
|
|
},
|
|
"string, Unit | string | Object, Object": function stringUnitStringObjectObject(name302, def, options) {
|
|
var obj = {};
|
|
obj[name302] = def;
|
|
return Unit2.createUnit(obj, options);
|
|
},
|
|
"string, Unit | string | Object": function stringUnitStringObject(name302, def) {
|
|
var obj = {};
|
|
obj[name302] = def;
|
|
return Unit2.createUnit(obj, {});
|
|
},
|
|
string: function string2(name302) {
|
|
var obj = {};
|
|
obj[name302] = {};
|
|
return Unit2.createUnit(obj, {});
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/acos.js
|
|
var name162 = "acos";
|
|
var dependencies162 = ["typed", "config", "Complex"];
|
|
var createAcos = /* @__PURE__ */ factory(name162, dependencies162, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
Complex: Complex3
|
|
} = _ref;
|
|
return typed2(name162, {
|
|
number: function number2(x) {
|
|
if (x >= -1 && x <= 1 || config4.predictable) {
|
|
return Math.acos(x);
|
|
} else {
|
|
return new Complex3(x, 0).acos();
|
|
}
|
|
},
|
|
Complex: function Complex4(x) {
|
|
return x.acos();
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return x.acos();
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/acosh.js
|
|
var name163 = "acosh";
|
|
var dependencies163 = ["typed", "config", "Complex"];
|
|
var createAcosh = /* @__PURE__ */ factory(name163, dependencies163, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
Complex: Complex3
|
|
} = _ref;
|
|
return typed2(name163, {
|
|
number: function number2(x) {
|
|
if (x >= 1 || config4.predictable) {
|
|
return acoshNumber(x);
|
|
}
|
|
if (x <= -1) {
|
|
return new Complex3(Math.log(Math.sqrt(x * x - 1) - x), Math.PI);
|
|
}
|
|
return new Complex3(x, 0).acosh();
|
|
},
|
|
Complex: function Complex4(x) {
|
|
return x.acosh();
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return x.acosh();
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/acot.js
|
|
var name164 = "acot";
|
|
var dependencies164 = ["typed", "BigNumber"];
|
|
var createAcot = /* @__PURE__ */ factory(name164, dependencies164, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
BigNumber: _BigNumber
|
|
} = _ref;
|
|
return typed2(name164, {
|
|
number: acotNumber,
|
|
Complex: function Complex3(x) {
|
|
return x.acot();
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return new _BigNumber(1).div(x).atan();
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/acoth.js
|
|
var name165 = "acoth";
|
|
var dependencies165 = ["typed", "config", "Complex", "BigNumber"];
|
|
var createAcoth = /* @__PURE__ */ factory(name165, dependencies165, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
Complex: Complex3,
|
|
BigNumber: _BigNumber
|
|
} = _ref;
|
|
return typed2(name165, {
|
|
number: function number2(x) {
|
|
if (x >= 1 || x <= -1 || config4.predictable) {
|
|
return acothNumber(x);
|
|
}
|
|
return new Complex3(x, 0).acoth();
|
|
},
|
|
Complex: function Complex4(x) {
|
|
return x.acoth();
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return new _BigNumber(1).div(x).atanh();
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/acsc.js
|
|
var name166 = "acsc";
|
|
var dependencies166 = ["typed", "config", "Complex", "BigNumber"];
|
|
var createAcsc = /* @__PURE__ */ factory(name166, dependencies166, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
Complex: Complex3,
|
|
BigNumber: _BigNumber
|
|
} = _ref;
|
|
return typed2(name166, {
|
|
number: function number2(x) {
|
|
if (x <= -1 || x >= 1 || config4.predictable) {
|
|
return acscNumber(x);
|
|
}
|
|
return new Complex3(x, 0).acsc();
|
|
},
|
|
Complex: function Complex4(x) {
|
|
return x.acsc();
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return new _BigNumber(1).div(x).asin();
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/acsch.js
|
|
var name167 = "acsch";
|
|
var dependencies167 = ["typed", "BigNumber"];
|
|
var createAcsch = /* @__PURE__ */ factory(name167, dependencies167, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
BigNumber: _BigNumber
|
|
} = _ref;
|
|
return typed2(name167, {
|
|
number: acschNumber,
|
|
Complex: function Complex3(x) {
|
|
return x.acsch();
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return new _BigNumber(1).div(x).asinh();
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/asec.js
|
|
var name168 = "asec";
|
|
var dependencies168 = ["typed", "config", "Complex", "BigNumber"];
|
|
var createAsec = /* @__PURE__ */ factory(name168, dependencies168, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
Complex: Complex3,
|
|
BigNumber: _BigNumber
|
|
} = _ref;
|
|
return typed2(name168, {
|
|
number: function number2(x) {
|
|
if (x <= -1 || x >= 1 || config4.predictable) {
|
|
return asecNumber(x);
|
|
}
|
|
return new Complex3(x, 0).asec();
|
|
},
|
|
Complex: function Complex4(x) {
|
|
return x.asec();
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return new _BigNumber(1).div(x).acos();
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/asech.js
|
|
var name169 = "asech";
|
|
var dependencies169 = ["typed", "config", "Complex", "BigNumber"];
|
|
var createAsech = /* @__PURE__ */ factory(name169, dependencies169, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
Complex: Complex3,
|
|
BigNumber: _BigNumber
|
|
} = _ref;
|
|
return typed2(name169, {
|
|
number: function number2(x) {
|
|
if (x <= 1 && x >= -1 || config4.predictable) {
|
|
var xInv = 1 / x;
|
|
if (xInv > 0 || config4.predictable) {
|
|
return asechNumber(x);
|
|
}
|
|
var ret = Math.sqrt(xInv * xInv - 1);
|
|
return new Complex3(Math.log(ret - xInv), Math.PI);
|
|
}
|
|
return new Complex3(x, 0).asech();
|
|
},
|
|
Complex: function Complex4(x) {
|
|
return x.asech();
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return new _BigNumber(1).div(x).acosh();
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/asin.js
|
|
var name170 = "asin";
|
|
var dependencies170 = ["typed", "config", "Complex"];
|
|
var createAsin = /* @__PURE__ */ factory(name170, dependencies170, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
Complex: Complex3
|
|
} = _ref;
|
|
return typed2(name170, {
|
|
number: function number2(x) {
|
|
if (x >= -1 && x <= 1 || config4.predictable) {
|
|
return Math.asin(x);
|
|
} else {
|
|
return new Complex3(x, 0).asin();
|
|
}
|
|
},
|
|
Complex: function Complex4(x) {
|
|
return x.asin();
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return x.asin();
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/asinh.js
|
|
var name171 = "asinh";
|
|
var dependencies171 = ["typed"];
|
|
var createAsinh = /* @__PURE__ */ factory(name171, dependencies171, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2("asinh", {
|
|
number: asinhNumber,
|
|
Complex: function Complex3(x) {
|
|
return x.asinh();
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return x.asinh();
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/atan.js
|
|
var name172 = "atan";
|
|
var dependencies172 = ["typed"];
|
|
var createAtan = /* @__PURE__ */ factory(name172, dependencies172, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2("atan", {
|
|
number: function number2(x) {
|
|
return Math.atan(x);
|
|
},
|
|
Complex: function Complex3(x) {
|
|
return x.atan();
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return x.atan();
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/atan2.js
|
|
var name173 = "atan2";
|
|
var dependencies173 = ["typed", "matrix", "equalScalar", "BigNumber", "DenseMatrix", "concat"];
|
|
var createAtan2 = /* @__PURE__ */ factory(name173, dependencies173, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
equalScalar: equalScalar2,
|
|
BigNumber: BigNumber2,
|
|
DenseMatrix: DenseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo02xDS0 = createMatAlgo02xDS0({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo03xDSf = createMatAlgo03xDSf({
|
|
typed: typed2
|
|
});
|
|
var matAlgo09xS0Sf = createMatAlgo09xS0Sf({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo11xS0s = createMatAlgo11xS0s({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
return typed2(name173, {
|
|
"number, number": Math.atan2,
|
|
"BigNumber, BigNumber": (y, x) => BigNumber2.atan2(y, x)
|
|
}, matrixAlgorithmSuite({
|
|
scalar: "number | BigNumber",
|
|
SS: matAlgo09xS0Sf,
|
|
DS: matAlgo03xDSf,
|
|
SD: matAlgo02xDS0,
|
|
Ss: matAlgo11xS0s,
|
|
sS: matAlgo12xSfs
|
|
}));
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/atanh.js
|
|
var name174 = "atanh";
|
|
var dependencies174 = ["typed", "config", "Complex"];
|
|
var createAtanh = /* @__PURE__ */ factory(name174, dependencies174, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
Complex: Complex3
|
|
} = _ref;
|
|
return typed2(name174, {
|
|
number: function number2(x) {
|
|
if (x <= 1 && x >= -1 || config4.predictable) {
|
|
return atanhNumber(x);
|
|
}
|
|
return new Complex3(x, 0).atanh();
|
|
},
|
|
Complex: function Complex4(x) {
|
|
return x.atanh();
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return x.atanh();
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/trigUnit.js
|
|
var createTrigUnit = /* @__PURE__ */ factory("trigUnit", ["typed"], (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return {
|
|
Unit: typed2.referToSelf((self2) => (x) => {
|
|
if (!x.hasBase(x.constructor.BASE_UNITS.ANGLE)) {
|
|
throw new TypeError("Unit in function cot is no angle");
|
|
}
|
|
return typed2.find(self2, x.valueType())(x.value);
|
|
})
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/cos.js
|
|
var name175 = "cos";
|
|
var dependencies175 = ["typed"];
|
|
var createCos = /* @__PURE__ */ factory(name175, dependencies175, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
var trigUnit = createTrigUnit({
|
|
typed: typed2
|
|
});
|
|
return typed2(name175, {
|
|
number: Math.cos,
|
|
"Complex | BigNumber": (x) => x.cos()
|
|
}, trigUnit);
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/cosh.js
|
|
var name176 = "cosh";
|
|
var dependencies176 = ["typed"];
|
|
var createCosh = /* @__PURE__ */ factory(name176, dependencies176, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name176, {
|
|
number: cosh,
|
|
"Complex | BigNumber": (x) => x.cosh()
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/cot.js
|
|
var name177 = "cot";
|
|
var dependencies177 = ["typed", "BigNumber"];
|
|
var createCot = /* @__PURE__ */ factory(name177, dependencies177, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
BigNumber: _BigNumber
|
|
} = _ref;
|
|
var trigUnit = createTrigUnit({
|
|
typed: typed2
|
|
});
|
|
return typed2(name177, {
|
|
number: cotNumber,
|
|
Complex: (x) => x.cot(),
|
|
BigNumber: (x) => new _BigNumber(1).div(x.tan())
|
|
}, trigUnit);
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/coth.js
|
|
var name178 = "coth";
|
|
var dependencies178 = ["typed", "BigNumber"];
|
|
var createCoth = /* @__PURE__ */ factory(name178, dependencies178, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
BigNumber: _BigNumber
|
|
} = _ref;
|
|
return typed2(name178, {
|
|
number: cothNumber,
|
|
Complex: (x) => x.coth(),
|
|
BigNumber: (x) => new _BigNumber(1).div(x.tanh())
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/csc.js
|
|
var name179 = "csc";
|
|
var dependencies179 = ["typed", "BigNumber"];
|
|
var createCsc = /* @__PURE__ */ factory(name179, dependencies179, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
BigNumber: _BigNumber
|
|
} = _ref;
|
|
var trigUnit = createTrigUnit({
|
|
typed: typed2
|
|
});
|
|
return typed2(name179, {
|
|
number: cscNumber,
|
|
Complex: (x) => x.csc(),
|
|
BigNumber: (x) => new _BigNumber(1).div(x.sin())
|
|
}, trigUnit);
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/csch.js
|
|
var name180 = "csch";
|
|
var dependencies180 = ["typed", "BigNumber"];
|
|
var createCsch = /* @__PURE__ */ factory(name180, dependencies180, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
BigNumber: _BigNumber
|
|
} = _ref;
|
|
return typed2(name180, {
|
|
number: cschNumber,
|
|
Complex: (x) => x.csch(),
|
|
BigNumber: (x) => new _BigNumber(1).div(x.sinh())
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/sec.js
|
|
var name181 = "sec";
|
|
var dependencies181 = ["typed", "BigNumber"];
|
|
var createSec = /* @__PURE__ */ factory(name181, dependencies181, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
BigNumber: _BigNumber
|
|
} = _ref;
|
|
var trigUnit = createTrigUnit({
|
|
typed: typed2
|
|
});
|
|
return typed2(name181, {
|
|
number: secNumber,
|
|
Complex: (x) => x.sec(),
|
|
BigNumber: (x) => new _BigNumber(1).div(x.cos())
|
|
}, trigUnit);
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/sech.js
|
|
var name182 = "sech";
|
|
var dependencies182 = ["typed", "BigNumber"];
|
|
var createSech = /* @__PURE__ */ factory(name182, dependencies182, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
BigNumber: _BigNumber
|
|
} = _ref;
|
|
return typed2(name182, {
|
|
number: sechNumber,
|
|
Complex: (x) => x.sech(),
|
|
BigNumber: (x) => new _BigNumber(1).div(x.cosh())
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/sin.js
|
|
var name183 = "sin";
|
|
var dependencies183 = ["typed"];
|
|
var createSin = /* @__PURE__ */ factory(name183, dependencies183, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
var trigUnit = createTrigUnit({
|
|
typed: typed2
|
|
});
|
|
return typed2(name183, {
|
|
number: Math.sin,
|
|
"Complex | BigNumber": (x) => x.sin()
|
|
}, trigUnit);
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/sinh.js
|
|
var name184 = "sinh";
|
|
var dependencies184 = ["typed"];
|
|
var createSinh = /* @__PURE__ */ factory(name184, dependencies184, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name184, {
|
|
number: sinhNumber,
|
|
"Complex | BigNumber": (x) => x.sinh()
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/tan.js
|
|
var name185 = "tan";
|
|
var dependencies185 = ["typed"];
|
|
var createTan = /* @__PURE__ */ factory(name185, dependencies185, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
var trigUnit = createTrigUnit({
|
|
typed: typed2
|
|
});
|
|
return typed2(name185, {
|
|
number: Math.tan,
|
|
"Complex | BigNumber": (x) => x.tan()
|
|
}, trigUnit);
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/trigonometry/tanh.js
|
|
var name186 = "tanh";
|
|
var dependencies186 = ["typed"];
|
|
var createTanh = /* @__PURE__ */ factory(name186, dependencies186, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2("tanh", {
|
|
number: tanh,
|
|
"Complex | BigNumber": (x) => x.tanh()
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/set/setCartesian.js
|
|
var name187 = "setCartesian";
|
|
var dependencies187 = ["typed", "size", "subset", "compareNatural", "Index", "DenseMatrix"];
|
|
var createSetCartesian = /* @__PURE__ */ factory(name187, dependencies187, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
size: size2,
|
|
subset: subset2,
|
|
compareNatural: compareNatural2,
|
|
Index: Index2,
|
|
DenseMatrix: DenseMatrix2
|
|
} = _ref;
|
|
return typed2(name187, {
|
|
"Array | Matrix, Array | Matrix": function ArrayMatrixArrayMatrix(a1, a2) {
|
|
var result = [];
|
|
if (subset2(size2(a1), new Index2(0)) !== 0 && subset2(size2(a2), new Index2(0)) !== 0) {
|
|
var b1 = flatten(Array.isArray(a1) ? a1 : a1.toArray()).sort(compareNatural2);
|
|
var b2 = flatten(Array.isArray(a2) ? a2 : a2.toArray()).sort(compareNatural2);
|
|
result = [];
|
|
for (var i2 = 0; i2 < b1.length; i2++) {
|
|
for (var j = 0; j < b2.length; j++) {
|
|
result.push([b1[i2], b2[j]]);
|
|
}
|
|
}
|
|
}
|
|
if (Array.isArray(a1) && Array.isArray(a2)) {
|
|
return result;
|
|
}
|
|
return new DenseMatrix2(result);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/set/setDifference.js
|
|
var name188 = "setDifference";
|
|
var dependencies188 = ["typed", "size", "subset", "compareNatural", "Index", "DenseMatrix"];
|
|
var createSetDifference = /* @__PURE__ */ factory(name188, dependencies188, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
size: size2,
|
|
subset: subset2,
|
|
compareNatural: compareNatural2,
|
|
Index: Index2,
|
|
DenseMatrix: DenseMatrix2
|
|
} = _ref;
|
|
return typed2(name188, {
|
|
"Array | Matrix, Array | Matrix": function ArrayMatrixArrayMatrix(a1, a2) {
|
|
var result;
|
|
if (subset2(size2(a1), new Index2(0)) === 0) {
|
|
result = [];
|
|
} else if (subset2(size2(a2), new Index2(0)) === 0) {
|
|
return flatten(a1.toArray());
|
|
} else {
|
|
var b1 = identify(flatten(Array.isArray(a1) ? a1 : a1.toArray()).sort(compareNatural2));
|
|
var b2 = identify(flatten(Array.isArray(a2) ? a2 : a2.toArray()).sort(compareNatural2));
|
|
result = [];
|
|
var inb2;
|
|
for (var i2 = 0; i2 < b1.length; i2++) {
|
|
inb2 = false;
|
|
for (var j = 0; j < b2.length; j++) {
|
|
if (compareNatural2(b1[i2].value, b2[j].value) === 0 && b1[i2].identifier === b2[j].identifier) {
|
|
inb2 = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!inb2) {
|
|
result.push(b1[i2]);
|
|
}
|
|
}
|
|
}
|
|
if (Array.isArray(a1) && Array.isArray(a2)) {
|
|
return generalize(result);
|
|
}
|
|
return new DenseMatrix2(generalize(result));
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/set/setDistinct.js
|
|
var name189 = "setDistinct";
|
|
var dependencies189 = ["typed", "size", "subset", "compareNatural", "Index", "DenseMatrix"];
|
|
var createSetDistinct = /* @__PURE__ */ factory(name189, dependencies189, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
size: size2,
|
|
subset: subset2,
|
|
compareNatural: compareNatural2,
|
|
Index: Index2,
|
|
DenseMatrix: DenseMatrix2
|
|
} = _ref;
|
|
return typed2(name189, {
|
|
"Array | Matrix": function ArrayMatrix(a) {
|
|
var result;
|
|
if (subset2(size2(a), new Index2(0)) === 0) {
|
|
result = [];
|
|
} else {
|
|
var b = flatten(Array.isArray(a) ? a : a.toArray()).sort(compareNatural2);
|
|
result = [];
|
|
result.push(b[0]);
|
|
for (var i2 = 1; i2 < b.length; i2++) {
|
|
if (compareNatural2(b[i2], b[i2 - 1]) !== 0) {
|
|
result.push(b[i2]);
|
|
}
|
|
}
|
|
}
|
|
if (Array.isArray(a)) {
|
|
return result;
|
|
}
|
|
return new DenseMatrix2(result);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/set/setIntersect.js
|
|
var name190 = "setIntersect";
|
|
var dependencies190 = ["typed", "size", "subset", "compareNatural", "Index", "DenseMatrix"];
|
|
var createSetIntersect = /* @__PURE__ */ factory(name190, dependencies190, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
size: size2,
|
|
subset: subset2,
|
|
compareNatural: compareNatural2,
|
|
Index: Index2,
|
|
DenseMatrix: DenseMatrix2
|
|
} = _ref;
|
|
return typed2(name190, {
|
|
"Array | Matrix, Array | Matrix": function ArrayMatrixArrayMatrix(a1, a2) {
|
|
var result;
|
|
if (subset2(size2(a1), new Index2(0)) === 0 || subset2(size2(a2), new Index2(0)) === 0) {
|
|
result = [];
|
|
} else {
|
|
var b1 = identify(flatten(Array.isArray(a1) ? a1 : a1.toArray()).sort(compareNatural2));
|
|
var b2 = identify(flatten(Array.isArray(a2) ? a2 : a2.toArray()).sort(compareNatural2));
|
|
result = [];
|
|
for (var i2 = 0; i2 < b1.length; i2++) {
|
|
for (var j = 0; j < b2.length; j++) {
|
|
if (compareNatural2(b1[i2].value, b2[j].value) === 0 && b1[i2].identifier === b2[j].identifier) {
|
|
result.push(b1[i2]);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (Array.isArray(a1) && Array.isArray(a2)) {
|
|
return generalize(result);
|
|
}
|
|
return new DenseMatrix2(generalize(result));
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/set/setIsSubset.js
|
|
var name191 = "setIsSubset";
|
|
var dependencies191 = ["typed", "size", "subset", "compareNatural", "Index"];
|
|
var createSetIsSubset = /* @__PURE__ */ factory(name191, dependencies191, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
size: size2,
|
|
subset: subset2,
|
|
compareNatural: compareNatural2,
|
|
Index: Index2
|
|
} = _ref;
|
|
return typed2(name191, {
|
|
"Array | Matrix, Array | Matrix": function ArrayMatrixArrayMatrix(a1, a2) {
|
|
if (subset2(size2(a1), new Index2(0)) === 0) {
|
|
return true;
|
|
} else if (subset2(size2(a2), new Index2(0)) === 0) {
|
|
return false;
|
|
}
|
|
var b1 = identify(flatten(Array.isArray(a1) ? a1 : a1.toArray()).sort(compareNatural2));
|
|
var b2 = identify(flatten(Array.isArray(a2) ? a2 : a2.toArray()).sort(compareNatural2));
|
|
var inb2;
|
|
for (var i2 = 0; i2 < b1.length; i2++) {
|
|
inb2 = false;
|
|
for (var j = 0; j < b2.length; j++) {
|
|
if (compareNatural2(b1[i2].value, b2[j].value) === 0 && b1[i2].identifier === b2[j].identifier) {
|
|
inb2 = true;
|
|
break;
|
|
}
|
|
}
|
|
if (inb2 === false) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/set/setMultiplicity.js
|
|
var name192 = "setMultiplicity";
|
|
var dependencies192 = ["typed", "size", "subset", "compareNatural", "Index"];
|
|
var createSetMultiplicity = /* @__PURE__ */ factory(name192, dependencies192, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
size: size2,
|
|
subset: subset2,
|
|
compareNatural: compareNatural2,
|
|
Index: Index2
|
|
} = _ref;
|
|
return typed2(name192, {
|
|
"number | BigNumber | Fraction | Complex, Array | Matrix": function numberBigNumberFractionComplexArrayMatrix(e3, a) {
|
|
if (subset2(size2(a), new Index2(0)) === 0) {
|
|
return 0;
|
|
}
|
|
var b = flatten(Array.isArray(a) ? a : a.toArray());
|
|
var count2 = 0;
|
|
for (var i2 = 0; i2 < b.length; i2++) {
|
|
if (compareNatural2(b[i2], e3) === 0) {
|
|
count2++;
|
|
}
|
|
}
|
|
return count2;
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/set/setPowerset.js
|
|
var name193 = "setPowerset";
|
|
var dependencies193 = ["typed", "size", "subset", "compareNatural", "Index"];
|
|
var createSetPowerset = /* @__PURE__ */ factory(name193, dependencies193, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
size: size2,
|
|
subset: subset2,
|
|
compareNatural: compareNatural2,
|
|
Index: Index2
|
|
} = _ref;
|
|
return typed2(name193, {
|
|
"Array | Matrix": function ArrayMatrix(a) {
|
|
if (subset2(size2(a), new Index2(0)) === 0) {
|
|
return [];
|
|
}
|
|
var b = flatten(Array.isArray(a) ? a : a.toArray()).sort(compareNatural2);
|
|
var result = [];
|
|
var number2 = 0;
|
|
while (number2.toString(2).length <= b.length) {
|
|
result.push(_subset(b, number2.toString(2).split("").reverse()));
|
|
number2++;
|
|
}
|
|
return _sort(result);
|
|
}
|
|
});
|
|
function _subset(array, bitarray) {
|
|
var result = [];
|
|
for (var i2 = 0; i2 < bitarray.length; i2++) {
|
|
if (bitarray[i2] === "1") {
|
|
result.push(array[i2]);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
function _sort(array) {
|
|
var temp = [];
|
|
for (var i2 = array.length - 1; i2 > 0; i2--) {
|
|
for (var j = 0; j < i2; j++) {
|
|
if (array[j].length > array[j + 1].length) {
|
|
temp = array[j];
|
|
array[j] = array[j + 1];
|
|
array[j + 1] = temp;
|
|
}
|
|
}
|
|
}
|
|
return array;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/set/setSize.js
|
|
var name194 = "setSize";
|
|
var dependencies194 = ["typed", "compareNatural"];
|
|
var createSetSize = /* @__PURE__ */ factory(name194, dependencies194, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
compareNatural: compareNatural2
|
|
} = _ref;
|
|
return typed2(name194, {
|
|
"Array | Matrix": function ArrayMatrix(a) {
|
|
return Array.isArray(a) ? flatten(a).length : flatten(a.toArray()).length;
|
|
},
|
|
"Array | Matrix, boolean": function ArrayMatrixBoolean(a, unique) {
|
|
if (unique === false || a.length === 0) {
|
|
return Array.isArray(a) ? flatten(a).length : flatten(a.toArray()).length;
|
|
} else {
|
|
var b = flatten(Array.isArray(a) ? a : a.toArray()).sort(compareNatural2);
|
|
var count2 = 1;
|
|
for (var i2 = 1; i2 < b.length; i2++) {
|
|
if (compareNatural2(b[i2], b[i2 - 1]) !== 0) {
|
|
count2++;
|
|
}
|
|
}
|
|
return count2;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/set/setSymDifference.js
|
|
var name195 = "setSymDifference";
|
|
var dependencies195 = ["typed", "size", "concat", "subset", "setDifference", "Index"];
|
|
var createSetSymDifference = /* @__PURE__ */ factory(name195, dependencies195, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
size: size2,
|
|
concat: concat2,
|
|
subset: subset2,
|
|
setDifference: setDifference2,
|
|
Index: Index2
|
|
} = _ref;
|
|
return typed2(name195, {
|
|
"Array | Matrix, Array | Matrix": function ArrayMatrixArrayMatrix(a1, a2) {
|
|
if (subset2(size2(a1), new Index2(0)) === 0) {
|
|
return flatten(a2);
|
|
} else if (subset2(size2(a2), new Index2(0)) === 0) {
|
|
return flatten(a1);
|
|
}
|
|
var b1 = flatten(a1);
|
|
var b2 = flatten(a2);
|
|
return concat2(setDifference2(b1, b2), setDifference2(b2, b1));
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/set/setUnion.js
|
|
var name196 = "setUnion";
|
|
var dependencies196 = ["typed", "size", "concat", "subset", "setIntersect", "setSymDifference", "Index"];
|
|
var createSetUnion = /* @__PURE__ */ factory(name196, dependencies196, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
size: size2,
|
|
concat: concat2,
|
|
subset: subset2,
|
|
setIntersect: setIntersect2,
|
|
setSymDifference: setSymDifference2,
|
|
Index: Index2
|
|
} = _ref;
|
|
return typed2(name196, {
|
|
"Array | Matrix, Array | Matrix": function ArrayMatrixArrayMatrix(a1, a2) {
|
|
if (subset2(size2(a1), new Index2(0)) === 0) {
|
|
return flatten(a2);
|
|
} else if (subset2(size2(a2), new Index2(0)) === 0) {
|
|
return flatten(a1);
|
|
}
|
|
var b1 = flatten(a1);
|
|
var b2 = flatten(a2);
|
|
return concat2(setSymDifference2(b1, b2), setIntersect2(b1, b2));
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/add.js
|
|
var name197 = "add";
|
|
var dependencies197 = ["typed", "matrix", "addScalar", "equalScalar", "DenseMatrix", "SparseMatrix", "concat"];
|
|
var createAdd = /* @__PURE__ */ factory(name197, dependencies197, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
addScalar: addScalar2,
|
|
equalScalar: equalScalar2,
|
|
DenseMatrix: DenseMatrix2,
|
|
SparseMatrix: SparseMatrix2,
|
|
concat: concat2
|
|
} = _ref;
|
|
var matAlgo01xDSid = createMatAlgo01xDSid({
|
|
typed: typed2
|
|
});
|
|
var matAlgo04xSidSid = createMatAlgo04xSidSid({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo10xSids = createMatAlgo10xSids({
|
|
typed: typed2,
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
concat: concat2
|
|
});
|
|
return typed2(name197, {
|
|
"any, any": addScalar2,
|
|
"any, any, ...any": typed2.referToSelf((self2) => (x, y, rest) => {
|
|
var result = self2(x, y);
|
|
for (var i2 = 0; i2 < rest.length; i2++) {
|
|
result = self2(result, rest[i2]);
|
|
}
|
|
return result;
|
|
})
|
|
}, matrixAlgorithmSuite({
|
|
elop: addScalar2,
|
|
DS: matAlgo01xDSid,
|
|
SS: matAlgo04xSidSid,
|
|
Ss: matAlgo10xSids
|
|
}));
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/hypot.js
|
|
var name198 = "hypot";
|
|
var dependencies198 = ["typed", "abs", "addScalar", "divideScalar", "multiplyScalar", "sqrt", "smaller", "isPositive"];
|
|
var createHypot = /* @__PURE__ */ factory(name198, dependencies198, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
abs: abs3,
|
|
addScalar: addScalar2,
|
|
divideScalar: divideScalar2,
|
|
multiplyScalar: multiplyScalar2,
|
|
sqrt: sqrt3,
|
|
smaller: smaller2,
|
|
isPositive: isPositive2
|
|
} = _ref;
|
|
return typed2(name198, {
|
|
"... number | BigNumber": _hypot,
|
|
Array: _hypot,
|
|
Matrix: (M) => _hypot(flatten(M.toArray()))
|
|
});
|
|
function _hypot(args) {
|
|
var result = 0;
|
|
var largest = 0;
|
|
for (var i2 = 0; i2 < args.length; i2++) {
|
|
if (isComplex(args[i2])) {
|
|
throw new TypeError("Unexpected type of argument to hypot");
|
|
}
|
|
var value = abs3(args[i2]);
|
|
if (smaller2(largest, value)) {
|
|
result = multiplyScalar2(result, multiplyScalar2(divideScalar2(largest, value), divideScalar2(largest, value)));
|
|
result = addScalar2(result, 1);
|
|
largest = value;
|
|
} else {
|
|
result = addScalar2(result, isPositive2(value) ? multiplyScalar2(divideScalar2(value, largest), divideScalar2(value, largest)) : value);
|
|
}
|
|
}
|
|
return multiplyScalar2(largest, sqrt3(result));
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/norm.js
|
|
var name199 = "norm";
|
|
var dependencies199 = ["typed", "abs", "add", "pow", "conj", "sqrt", "multiply", "equalScalar", "larger", "smaller", "matrix", "ctranspose", "eigs"];
|
|
var createNorm = /* @__PURE__ */ factory(name199, dependencies199, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
abs: abs3,
|
|
add: add3,
|
|
pow: pow3,
|
|
conj: conj2,
|
|
sqrt: sqrt3,
|
|
multiply: multiply2,
|
|
equalScalar: equalScalar2,
|
|
larger: larger2,
|
|
smaller: smaller2,
|
|
matrix: matrix2,
|
|
ctranspose: ctranspose2,
|
|
eigs: eigs2
|
|
} = _ref;
|
|
return typed2(name199, {
|
|
number: Math.abs,
|
|
Complex: function Complex3(x) {
|
|
return x.abs();
|
|
},
|
|
BigNumber: function BigNumber2(x) {
|
|
return x.abs();
|
|
},
|
|
boolean: function boolean2(x) {
|
|
return Math.abs(x);
|
|
},
|
|
Array: function Array2(x) {
|
|
return _norm(matrix2(x), 2);
|
|
},
|
|
Matrix: function Matrix2(x) {
|
|
return _norm(x, 2);
|
|
},
|
|
"Array, number | BigNumber | string": function ArrayNumberBigNumberString(x, p) {
|
|
return _norm(matrix2(x), p);
|
|
},
|
|
"Matrix, number | BigNumber | string": function MatrixNumberBigNumberString(x, p) {
|
|
return _norm(x, p);
|
|
}
|
|
});
|
|
function _vectorNormPlusInfinity(x) {
|
|
var pinf = 0;
|
|
x.forEach(function(value) {
|
|
var v = abs3(value);
|
|
if (larger2(v, pinf)) {
|
|
pinf = v;
|
|
}
|
|
}, true);
|
|
return pinf;
|
|
}
|
|
function _vectorNormMinusInfinity(x) {
|
|
var ninf;
|
|
x.forEach(function(value) {
|
|
var v = abs3(value);
|
|
if (!ninf || smaller2(v, ninf)) {
|
|
ninf = v;
|
|
}
|
|
}, true);
|
|
return ninf || 0;
|
|
}
|
|
function _vectorNorm(x, p) {
|
|
if (p === Number.POSITIVE_INFINITY || p === "inf") {
|
|
return _vectorNormPlusInfinity(x);
|
|
}
|
|
if (p === Number.NEGATIVE_INFINITY || p === "-inf") {
|
|
return _vectorNormMinusInfinity(x);
|
|
}
|
|
if (p === "fro") {
|
|
return _norm(x, 2);
|
|
}
|
|
if (typeof p === "number" && !isNaN(p)) {
|
|
if (!equalScalar2(p, 0)) {
|
|
var n = 0;
|
|
x.forEach(function(value) {
|
|
n = add3(pow3(abs3(value), p), n);
|
|
}, true);
|
|
return pow3(n, 1 / p);
|
|
}
|
|
return Number.POSITIVE_INFINITY;
|
|
}
|
|
throw new Error("Unsupported parameter value");
|
|
}
|
|
function _matrixNormFrobenius(x) {
|
|
var fro = 0;
|
|
x.forEach(function(value, index2) {
|
|
fro = add3(fro, multiply2(value, conj2(value)));
|
|
});
|
|
return abs3(sqrt3(fro));
|
|
}
|
|
function _matrixNormOne(x) {
|
|
var c = [];
|
|
var maxc = 0;
|
|
x.forEach(function(value, index2) {
|
|
var j = index2[1];
|
|
var cj = add3(c[j] || 0, abs3(value));
|
|
if (larger2(cj, maxc)) {
|
|
maxc = cj;
|
|
}
|
|
c[j] = cj;
|
|
}, true);
|
|
return maxc;
|
|
}
|
|
function _matrixNormTwo(x) {
|
|
var sizeX = x.size();
|
|
if (sizeX[0] !== sizeX[1]) {
|
|
throw new RangeError("Invalid matrix dimensions");
|
|
}
|
|
var tx = ctranspose2(x);
|
|
var squaredX = multiply2(tx, x);
|
|
var eigenVals = eigs2(squaredX).values.toArray();
|
|
var rho = eigenVals[eigenVals.length - 1];
|
|
return abs3(sqrt3(rho));
|
|
}
|
|
function _matrixNormInfinity(x) {
|
|
var r = [];
|
|
var maxr = 0;
|
|
x.forEach(function(value, index2) {
|
|
var i2 = index2[0];
|
|
var ri = add3(r[i2] || 0, abs3(value));
|
|
if (larger2(ri, maxr)) {
|
|
maxr = ri;
|
|
}
|
|
r[i2] = ri;
|
|
}, true);
|
|
return maxr;
|
|
}
|
|
function _matrixNorm(x, p) {
|
|
if (p === 1) {
|
|
return _matrixNormOne(x);
|
|
}
|
|
if (p === Number.POSITIVE_INFINITY || p === "inf") {
|
|
return _matrixNormInfinity(x);
|
|
}
|
|
if (p === "fro") {
|
|
return _matrixNormFrobenius(x);
|
|
}
|
|
if (p === 2) {
|
|
return _matrixNormTwo(x);
|
|
}
|
|
throw new Error("Unsupported parameter value " + p);
|
|
}
|
|
function _norm(x, p) {
|
|
var sizeX = x.size();
|
|
if (sizeX.length === 1) {
|
|
return _vectorNorm(x, p);
|
|
}
|
|
if (sizeX.length === 2) {
|
|
if (sizeX[0] && sizeX[1]) {
|
|
return _matrixNorm(x, p);
|
|
} else {
|
|
throw new RangeError("Invalid matrix dimensions");
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/dot.js
|
|
var name200 = "dot";
|
|
var dependencies200 = ["typed", "addScalar", "multiplyScalar", "conj", "size"];
|
|
var createDot = /* @__PURE__ */ factory(name200, dependencies200, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
addScalar: addScalar2,
|
|
multiplyScalar: multiplyScalar2,
|
|
conj: conj2,
|
|
size: size2
|
|
} = _ref;
|
|
return typed2(name200, {
|
|
"Array | DenseMatrix, Array | DenseMatrix": _denseDot,
|
|
"SparseMatrix, SparseMatrix": _sparseDot
|
|
});
|
|
function _validateDim(x, y) {
|
|
var xSize = _size(x);
|
|
var ySize = _size(y);
|
|
var xLen, yLen;
|
|
if (xSize.length === 1) {
|
|
xLen = xSize[0];
|
|
} else if (xSize.length === 2 && xSize[1] === 1) {
|
|
xLen = xSize[0];
|
|
} else {
|
|
throw new RangeError("Expected a column vector, instead got a matrix of size (" + xSize.join(", ") + ")");
|
|
}
|
|
if (ySize.length === 1) {
|
|
yLen = ySize[0];
|
|
} else if (ySize.length === 2 && ySize[1] === 1) {
|
|
yLen = ySize[0];
|
|
} else {
|
|
throw new RangeError("Expected a column vector, instead got a matrix of size (" + ySize.join(", ") + ")");
|
|
}
|
|
if (xLen !== yLen)
|
|
throw new RangeError("Vectors must have equal length (" + xLen + " != " + yLen + ")");
|
|
if (xLen === 0)
|
|
throw new RangeError("Cannot calculate the dot product of empty vectors");
|
|
return xLen;
|
|
}
|
|
function _denseDot(a, b) {
|
|
var N = _validateDim(a, b);
|
|
var adata = isMatrix(a) ? a._data : a;
|
|
var adt = isMatrix(a) ? a._datatype : void 0;
|
|
var bdata = isMatrix(b) ? b._data : b;
|
|
var bdt = isMatrix(b) ? b._datatype : void 0;
|
|
var aIsColumn = _size(a).length === 2;
|
|
var bIsColumn = _size(b).length === 2;
|
|
var add3 = addScalar2;
|
|
var mul2 = multiplyScalar2;
|
|
if (adt && bdt && adt === bdt && typeof adt === "string") {
|
|
var dt = adt;
|
|
add3 = typed2.find(addScalar2, [dt, dt]);
|
|
mul2 = typed2.find(multiplyScalar2, [dt, dt]);
|
|
}
|
|
if (!aIsColumn && !bIsColumn) {
|
|
var c = mul2(conj2(adata[0]), bdata[0]);
|
|
for (var i2 = 1; i2 < N; i2++) {
|
|
c = add3(c, mul2(conj2(adata[i2]), bdata[i2]));
|
|
}
|
|
return c;
|
|
}
|
|
if (!aIsColumn && bIsColumn) {
|
|
var _c = mul2(conj2(adata[0]), bdata[0][0]);
|
|
for (var _i = 1; _i < N; _i++) {
|
|
_c = add3(_c, mul2(conj2(adata[_i]), bdata[_i][0]));
|
|
}
|
|
return _c;
|
|
}
|
|
if (aIsColumn && !bIsColumn) {
|
|
var _c2 = mul2(conj2(adata[0][0]), bdata[0]);
|
|
for (var _i2 = 1; _i2 < N; _i2++) {
|
|
_c2 = add3(_c2, mul2(conj2(adata[_i2][0]), bdata[_i2]));
|
|
}
|
|
return _c2;
|
|
}
|
|
if (aIsColumn && bIsColumn) {
|
|
var _c3 = mul2(conj2(adata[0][0]), bdata[0][0]);
|
|
for (var _i3 = 1; _i3 < N; _i3++) {
|
|
_c3 = add3(_c3, mul2(conj2(adata[_i3][0]), bdata[_i3][0]));
|
|
}
|
|
return _c3;
|
|
}
|
|
}
|
|
function _sparseDot(x, y) {
|
|
_validateDim(x, y);
|
|
var xindex = x._index;
|
|
var xvalues = x._values;
|
|
var yindex = y._index;
|
|
var yvalues = y._values;
|
|
var c = 0;
|
|
var add3 = addScalar2;
|
|
var mul2 = multiplyScalar2;
|
|
var i2 = 0;
|
|
var j = 0;
|
|
while (i2 < xindex.length && j < yindex.length) {
|
|
var I = xindex[i2];
|
|
var J = yindex[j];
|
|
if (I < J) {
|
|
i2++;
|
|
continue;
|
|
}
|
|
if (I > J) {
|
|
j++;
|
|
continue;
|
|
}
|
|
if (I === J) {
|
|
c = add3(c, mul2(xvalues[i2], yvalues[j]));
|
|
i2++;
|
|
j++;
|
|
}
|
|
}
|
|
return c;
|
|
}
|
|
function _size(x) {
|
|
return isMatrix(x) ? x.size() : size2(x);
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/trace.js
|
|
var name201 = "trace";
|
|
var dependencies201 = ["typed", "matrix", "add"];
|
|
var createTrace = /* @__PURE__ */ factory(name201, dependencies201, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
add: add3
|
|
} = _ref;
|
|
return typed2("trace", {
|
|
Array: function _arrayTrace(x) {
|
|
return _denseTrace(matrix2(x));
|
|
},
|
|
SparseMatrix: _sparseTrace,
|
|
DenseMatrix: _denseTrace,
|
|
any: clone
|
|
});
|
|
function _denseTrace(m) {
|
|
var size2 = m._size;
|
|
var data = m._data;
|
|
switch (size2.length) {
|
|
case 1:
|
|
if (size2[0] === 1) {
|
|
return clone(data[0]);
|
|
}
|
|
throw new RangeError("Matrix must be square (size: " + format3(size2) + ")");
|
|
case 2: {
|
|
var rows = size2[0];
|
|
var cols = size2[1];
|
|
if (rows === cols) {
|
|
var sum3 = 0;
|
|
for (var i2 = 0; i2 < rows; i2++) {
|
|
sum3 = add3(sum3, data[i2][i2]);
|
|
}
|
|
return sum3;
|
|
} else {
|
|
throw new RangeError("Matrix must be square (size: " + format3(size2) + ")");
|
|
}
|
|
}
|
|
default:
|
|
throw new RangeError("Matrix must be two dimensional (size: " + format3(size2) + ")");
|
|
}
|
|
}
|
|
function _sparseTrace(m) {
|
|
var values = m._values;
|
|
var index2 = m._index;
|
|
var ptr = m._ptr;
|
|
var size2 = m._size;
|
|
var rows = size2[0];
|
|
var columns = size2[1];
|
|
if (rows === columns) {
|
|
var sum3 = 0;
|
|
if (values.length > 0) {
|
|
for (var j = 0; j < columns; j++) {
|
|
var k0 = ptr[j];
|
|
var k1 = ptr[j + 1];
|
|
for (var k = k0; k < k1; k++) {
|
|
var i2 = index2[k];
|
|
if (i2 === j) {
|
|
sum3 = add3(sum3, values[k]);
|
|
break;
|
|
}
|
|
if (i2 > j) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return sum3;
|
|
}
|
|
throw new RangeError("Matrix must be square (size: " + format3(size2) + ")");
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/matrix/function/index.js
|
|
var name202 = "index";
|
|
var dependencies202 = ["typed", "Index"];
|
|
var createIndex = /* @__PURE__ */ factory(name202, dependencies202, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
Index: Index2
|
|
} = _ref;
|
|
return typed2(name202, {
|
|
"...number | string | BigNumber | Range | Array | Matrix": function numberStringBigNumberRangeArrayMatrix(args) {
|
|
var ranges = args.map(function(arg2) {
|
|
if (isBigNumber(arg2)) {
|
|
return arg2.toNumber();
|
|
} else if (Array.isArray(arg2) || isMatrix(arg2)) {
|
|
return arg2.map(function(elem) {
|
|
return isBigNumber(elem) ? elem.toNumber() : elem;
|
|
});
|
|
} else {
|
|
return arg2;
|
|
}
|
|
});
|
|
var res = new Index2();
|
|
Index2.apply(res, ranges);
|
|
return res;
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/keywords.js
|
|
var keywords = /* @__PURE__ */ new Set(["end"]);
|
|
|
|
// node_modules/mathjs/lib/esm/expression/node/Node.js
|
|
var name203 = "Node";
|
|
var dependencies203 = ["mathWithTransform"];
|
|
var createNode = /* @__PURE__ */ factory(name203, dependencies203, (_ref) => {
|
|
var {
|
|
mathWithTransform: mathWithTransform2
|
|
} = _ref;
|
|
function _validateScope(scope) {
|
|
for (var symbol of [...keywords]) {
|
|
if (scope.has(symbol)) {
|
|
throw new Error('Scope contains an illegal symbol, "' + symbol + '" is a reserved keyword');
|
|
}
|
|
}
|
|
}
|
|
class Node2 {
|
|
get type() {
|
|
return "Node";
|
|
}
|
|
get isNode() {
|
|
return true;
|
|
}
|
|
evaluate(scope) {
|
|
return this.compile().evaluate(scope);
|
|
}
|
|
compile() {
|
|
var expr = this._compile(mathWithTransform2, {});
|
|
var args = {};
|
|
var context = null;
|
|
function evaluate2(scope) {
|
|
var s = createMap(scope);
|
|
_validateScope(s);
|
|
return expr(s, args, context);
|
|
}
|
|
return {
|
|
evaluate: evaluate2
|
|
};
|
|
}
|
|
_compile(math2, argNames) {
|
|
throw new Error("Method _compile must be implemented by type " + this.type);
|
|
}
|
|
forEach(callback) {
|
|
throw new Error("Cannot run forEach on a Node interface");
|
|
}
|
|
map(callback) {
|
|
throw new Error("Cannot run map on a Node interface");
|
|
}
|
|
_ifNode(node) {
|
|
if (!isNode(node)) {
|
|
throw new TypeError("Callback function must return a Node");
|
|
}
|
|
return node;
|
|
}
|
|
traverse(callback) {
|
|
callback(this, null, null);
|
|
function _traverse(node, callback2) {
|
|
node.forEach(function(child, path, parent) {
|
|
callback2(child, path, parent);
|
|
_traverse(child, callback2);
|
|
});
|
|
}
|
|
_traverse(this, callback);
|
|
}
|
|
transform(callback) {
|
|
function _transform(child, path, parent) {
|
|
var replacement = callback(child, path, parent);
|
|
if (replacement !== child) {
|
|
return replacement;
|
|
}
|
|
return child.map(_transform);
|
|
}
|
|
return _transform(this, null, null);
|
|
}
|
|
filter(callback) {
|
|
var nodes = [];
|
|
this.traverse(function(node, path, parent) {
|
|
if (callback(node, path, parent)) {
|
|
nodes.push(node);
|
|
}
|
|
});
|
|
return nodes;
|
|
}
|
|
clone() {
|
|
throw new Error("Cannot clone a Node interface");
|
|
}
|
|
cloneDeep() {
|
|
return this.map(function(node) {
|
|
return node.cloneDeep();
|
|
});
|
|
}
|
|
equals(other) {
|
|
return other ? this.type === other.type && deepStrictEqual(this, other) : false;
|
|
}
|
|
toString(options) {
|
|
var customString = this._getCustomString(options);
|
|
if (typeof customString !== "undefined") {
|
|
return customString;
|
|
}
|
|
return this._toString(options);
|
|
}
|
|
toJSON() {
|
|
throw new Error("Cannot serialize object: toJSON not implemented by " + this.type);
|
|
}
|
|
toHTML(options) {
|
|
var customString = this._getCustomString(options);
|
|
if (typeof customString !== "undefined") {
|
|
return customString;
|
|
}
|
|
return this.toHTML(options);
|
|
}
|
|
_toString() {
|
|
throw new Error("_toString not implemented for " + this.type);
|
|
}
|
|
toTex(options) {
|
|
var customString = this._getCustomString(options);
|
|
if (typeof customString !== "undefined") {
|
|
return customString;
|
|
}
|
|
return this._toTex(options);
|
|
}
|
|
_toTex(options) {
|
|
throw new Error("_toTex not implemented for " + this.type);
|
|
}
|
|
_getCustomString(options) {
|
|
if (options && typeof options === "object") {
|
|
switch (typeof options.handler) {
|
|
case "object":
|
|
case "undefined":
|
|
return;
|
|
case "function":
|
|
return options.handler(this, options);
|
|
default:
|
|
throw new TypeError("Object or function expected as callback");
|
|
}
|
|
}
|
|
}
|
|
getIdentifier() {
|
|
return this.type;
|
|
}
|
|
getContent() {
|
|
return this;
|
|
}
|
|
}
|
|
return Node2;
|
|
}, {
|
|
isClass: true,
|
|
isNode: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/utils/errorTransform.js
|
|
function errorTransform(err) {
|
|
if (err && err.isIndexError) {
|
|
return new IndexError(err.index + 1, err.min + 1, err.max !== void 0 ? err.max + 1 : void 0);
|
|
}
|
|
return err;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/expression/node/utils/access.js
|
|
function accessFactory(_ref) {
|
|
var {
|
|
subset: subset2
|
|
} = _ref;
|
|
return function access(object, index2) {
|
|
try {
|
|
if (Array.isArray(object)) {
|
|
return subset2(object, index2);
|
|
} else if (object && typeof object.subset === "function") {
|
|
return object.subset(index2);
|
|
} else if (typeof object === "string") {
|
|
return subset2(object, index2);
|
|
} else if (typeof object === "object") {
|
|
if (!index2.isObjectProperty()) {
|
|
throw new TypeError("Cannot apply a numeric index as object property");
|
|
}
|
|
return getSafeProperty(object, index2.getObjectProperty());
|
|
} else {
|
|
throw new TypeError("Cannot apply index: unsupported type of object");
|
|
}
|
|
} catch (err) {
|
|
throw errorTransform(err);
|
|
}
|
|
};
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/expression/node/AccessorNode.js
|
|
var name204 = "AccessorNode";
|
|
var dependencies204 = ["subset", "Node"];
|
|
var createAccessorNode = /* @__PURE__ */ factory(name204, dependencies204, (_ref) => {
|
|
var {
|
|
subset: subset2,
|
|
Node: Node2
|
|
} = _ref;
|
|
var access = accessFactory({
|
|
subset: subset2
|
|
});
|
|
function needParenthesis(node) {
|
|
return !(isAccessorNode(node) || isArrayNode(node) || isConstantNode(node) || isFunctionNode(node) || isObjectNode(node) || isParenthesisNode(node) || isSymbolNode(node));
|
|
}
|
|
class AccessorNode2 extends Node2 {
|
|
constructor(object, index2) {
|
|
super();
|
|
if (!isNode(object)) {
|
|
throw new TypeError('Node expected for parameter "object"');
|
|
}
|
|
if (!isIndexNode(index2)) {
|
|
throw new TypeError('IndexNode expected for parameter "index"');
|
|
}
|
|
this.object = object;
|
|
this.index = index2;
|
|
}
|
|
get name() {
|
|
if (this.index) {
|
|
return this.index.isObjectProperty() ? this.index.getObjectProperty() : "";
|
|
} else {
|
|
return this.object.name || "";
|
|
}
|
|
}
|
|
get type() {
|
|
return name204;
|
|
}
|
|
get isAccessorNode() {
|
|
return true;
|
|
}
|
|
_compile(math2, argNames) {
|
|
var evalObject = this.object._compile(math2, argNames);
|
|
var evalIndex = this.index._compile(math2, argNames);
|
|
if (this.index.isObjectProperty()) {
|
|
var prop = this.index.getObjectProperty();
|
|
return function evalAccessorNode(scope, args, context) {
|
|
return getSafeProperty(evalObject(scope, args, context), prop);
|
|
};
|
|
} else {
|
|
return function evalAccessorNode(scope, args, context) {
|
|
var object = evalObject(scope, args, context);
|
|
var index2 = evalIndex(scope, args, object);
|
|
return access(object, index2);
|
|
};
|
|
}
|
|
}
|
|
forEach(callback) {
|
|
callback(this.object, "object", this);
|
|
callback(this.index, "index", this);
|
|
}
|
|
map(callback) {
|
|
return new AccessorNode2(this._ifNode(callback(this.object, "object", this)), this._ifNode(callback(this.index, "index", this)));
|
|
}
|
|
clone() {
|
|
return new AccessorNode2(this.object, this.index);
|
|
}
|
|
_toString(options) {
|
|
var object = this.object.toString(options);
|
|
if (needParenthesis(this.object)) {
|
|
object = "(" + object + ")";
|
|
}
|
|
return object + this.index.toString(options);
|
|
}
|
|
toHTML(options) {
|
|
var object = this.object.toHTML(options);
|
|
if (needParenthesis(this.object)) {
|
|
object = '<span class="math-parenthesis math-round-parenthesis">(</span>' + object + '<span class="math-parenthesis math-round-parenthesis">)</span>';
|
|
}
|
|
return object + this.index.toHTML(options);
|
|
}
|
|
_toTex(options) {
|
|
var object = this.object.toTex(options);
|
|
if (needParenthesis(this.object)) {
|
|
object = "\\left(' + object + '\\right)";
|
|
}
|
|
return object + this.index.toTex(options);
|
|
}
|
|
toJSON() {
|
|
return {
|
|
mathjs: name204,
|
|
object: this.object,
|
|
index: this.index
|
|
};
|
|
}
|
|
static fromJSON(json) {
|
|
return new AccessorNode2(json.object, json.index);
|
|
}
|
|
}
|
|
_defineProperty(AccessorNode2, "name", name204);
|
|
return AccessorNode2;
|
|
}, {
|
|
isClass: true,
|
|
isNode: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/node/ArrayNode.js
|
|
var name205 = "ArrayNode";
|
|
var dependencies205 = ["Node"];
|
|
var createArrayNode = /* @__PURE__ */ factory(name205, dependencies205, (_ref) => {
|
|
var {
|
|
Node: Node2
|
|
} = _ref;
|
|
class ArrayNode2 extends Node2 {
|
|
constructor(items) {
|
|
super();
|
|
this.items = items || [];
|
|
if (!Array.isArray(this.items) || !this.items.every(isNode)) {
|
|
throw new TypeError("Array containing Nodes expected");
|
|
}
|
|
}
|
|
get type() {
|
|
return name205;
|
|
}
|
|
get isArrayNode() {
|
|
return true;
|
|
}
|
|
_compile(math2, argNames) {
|
|
var evalItems = map(this.items, function(item) {
|
|
return item._compile(math2, argNames);
|
|
});
|
|
var asMatrix = math2.config.matrix !== "Array";
|
|
if (asMatrix) {
|
|
var matrix2 = math2.matrix;
|
|
return function evalArrayNode(scope, args, context) {
|
|
return matrix2(map(evalItems, function(evalItem) {
|
|
return evalItem(scope, args, context);
|
|
}));
|
|
};
|
|
} else {
|
|
return function evalArrayNode(scope, args, context) {
|
|
return map(evalItems, function(evalItem) {
|
|
return evalItem(scope, args, context);
|
|
});
|
|
};
|
|
}
|
|
}
|
|
forEach(callback) {
|
|
for (var i2 = 0; i2 < this.items.length; i2++) {
|
|
var node = this.items[i2];
|
|
callback(node, "items[" + i2 + "]", this);
|
|
}
|
|
}
|
|
map(callback) {
|
|
var items = [];
|
|
for (var i2 = 0; i2 < this.items.length; i2++) {
|
|
items[i2] = this._ifNode(callback(this.items[i2], "items[" + i2 + "]", this));
|
|
}
|
|
return new ArrayNode2(items);
|
|
}
|
|
clone() {
|
|
return new ArrayNode2(this.items.slice(0));
|
|
}
|
|
_toString(options) {
|
|
var items = this.items.map(function(node) {
|
|
return node.toString(options);
|
|
});
|
|
return "[" + items.join(", ") + "]";
|
|
}
|
|
toJSON() {
|
|
return {
|
|
mathjs: name205,
|
|
items: this.items
|
|
};
|
|
}
|
|
static fromJSON(json) {
|
|
return new ArrayNode2(json.items);
|
|
}
|
|
toHTML(options) {
|
|
var items = this.items.map(function(node) {
|
|
return node.toHTML(options);
|
|
});
|
|
return '<span class="math-parenthesis math-square-parenthesis">[</span>' + items.join('<span class="math-separator">,</span>') + '<span class="math-parenthesis math-square-parenthesis">]</span>';
|
|
}
|
|
_toTex(options) {
|
|
function itemsToTex(items, nested) {
|
|
var mixedItems = items.some(isArrayNode) && !items.every(isArrayNode);
|
|
var itemsFormRow = nested || mixedItems;
|
|
var itemSep = itemsFormRow ? "&" : "\\\\";
|
|
var itemsTex = items.map(function(node) {
|
|
if (node.items) {
|
|
return itemsToTex(node.items, !nested);
|
|
} else {
|
|
return node.toTex(options);
|
|
}
|
|
}).join(itemSep);
|
|
return mixedItems || !itemsFormRow || itemsFormRow && !nested ? "\\begin{bmatrix}" + itemsTex + "\\end{bmatrix}" : itemsTex;
|
|
}
|
|
return itemsToTex(this.items, false);
|
|
}
|
|
}
|
|
_defineProperty(ArrayNode2, "name", name205);
|
|
return ArrayNode2;
|
|
}, {
|
|
isClass: true,
|
|
isNode: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/node/utils/assign.js
|
|
function assignFactory(_ref) {
|
|
var {
|
|
subset: subset2,
|
|
matrix: matrix2
|
|
} = _ref;
|
|
return function assign2(object, index2, value) {
|
|
try {
|
|
if (Array.isArray(object)) {
|
|
return matrix2(object).subset(index2, value).valueOf();
|
|
} else if (object && typeof object.subset === "function") {
|
|
return object.subset(index2, value);
|
|
} else if (typeof object === "string") {
|
|
return subset2(object, index2, value);
|
|
} else if (typeof object === "object") {
|
|
if (!index2.isObjectProperty()) {
|
|
throw TypeError("Cannot apply a numeric index as object property");
|
|
}
|
|
setSafeProperty(object, index2.getObjectProperty(), value);
|
|
return object;
|
|
} else {
|
|
throw new TypeError("Cannot apply index: unsupported type of object");
|
|
}
|
|
} catch (err) {
|
|
throw errorTransform(err);
|
|
}
|
|
};
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/expression/operators.js
|
|
var properties = [{
|
|
AssignmentNode: {},
|
|
FunctionAssignmentNode: {}
|
|
}, {
|
|
ConditionalNode: {
|
|
latexLeftParens: false,
|
|
latexRightParens: false,
|
|
latexParens: false
|
|
}
|
|
}, {
|
|
"OperatorNode:or": {
|
|
op: "or",
|
|
associativity: "left",
|
|
associativeWith: []
|
|
}
|
|
}, {
|
|
"OperatorNode:xor": {
|
|
op: "xor",
|
|
associativity: "left",
|
|
associativeWith: []
|
|
}
|
|
}, {
|
|
"OperatorNode:and": {
|
|
op: "and",
|
|
associativity: "left",
|
|
associativeWith: []
|
|
}
|
|
}, {
|
|
"OperatorNode:bitOr": {
|
|
op: "|",
|
|
associativity: "left",
|
|
associativeWith: []
|
|
}
|
|
}, {
|
|
"OperatorNode:bitXor": {
|
|
op: "^|",
|
|
associativity: "left",
|
|
associativeWith: []
|
|
}
|
|
}, {
|
|
"OperatorNode:bitAnd": {
|
|
op: "&",
|
|
associativity: "left",
|
|
associativeWith: []
|
|
}
|
|
}, {
|
|
"OperatorNode:equal": {
|
|
op: "==",
|
|
associativity: "left",
|
|
associativeWith: []
|
|
},
|
|
"OperatorNode:unequal": {
|
|
op: "!=",
|
|
associativity: "left",
|
|
associativeWith: []
|
|
},
|
|
"OperatorNode:smaller": {
|
|
op: "<",
|
|
associativity: "left",
|
|
associativeWith: []
|
|
},
|
|
"OperatorNode:larger": {
|
|
op: ">",
|
|
associativity: "left",
|
|
associativeWith: []
|
|
},
|
|
"OperatorNode:smallerEq": {
|
|
op: "<=",
|
|
associativity: "left",
|
|
associativeWith: []
|
|
},
|
|
"OperatorNode:largerEq": {
|
|
op: ">=",
|
|
associativity: "left",
|
|
associativeWith: []
|
|
},
|
|
RelationalNode: {
|
|
associativity: "left",
|
|
associativeWith: []
|
|
}
|
|
}, {
|
|
"OperatorNode:leftShift": {
|
|
op: "<<",
|
|
associativity: "left",
|
|
associativeWith: []
|
|
},
|
|
"OperatorNode:rightArithShift": {
|
|
op: ">>",
|
|
associativity: "left",
|
|
associativeWith: []
|
|
},
|
|
"OperatorNode:rightLogShift": {
|
|
op: ">>>",
|
|
associativity: "left",
|
|
associativeWith: []
|
|
}
|
|
}, {
|
|
"OperatorNode:to": {
|
|
op: "to",
|
|
associativity: "left",
|
|
associativeWith: []
|
|
}
|
|
}, {
|
|
RangeNode: {}
|
|
}, {
|
|
"OperatorNode:add": {
|
|
op: "+",
|
|
associativity: "left",
|
|
associativeWith: ["OperatorNode:add", "OperatorNode:subtract"]
|
|
},
|
|
"OperatorNode:subtract": {
|
|
op: "-",
|
|
associativity: "left",
|
|
associativeWith: []
|
|
}
|
|
}, {
|
|
"OperatorNode:multiply": {
|
|
op: "*",
|
|
associativity: "left",
|
|
associativeWith: ["OperatorNode:multiply", "OperatorNode:divide", "Operator:dotMultiply", "Operator:dotDivide"]
|
|
},
|
|
"OperatorNode:divide": {
|
|
op: "/",
|
|
associativity: "left",
|
|
associativeWith: [],
|
|
latexLeftParens: false,
|
|
latexRightParens: false,
|
|
latexParens: false
|
|
},
|
|
"OperatorNode:dotMultiply": {
|
|
op: ".*",
|
|
associativity: "left",
|
|
associativeWith: ["OperatorNode:multiply", "OperatorNode:divide", "OperatorNode:dotMultiply", "OperatorNode:doDivide"]
|
|
},
|
|
"OperatorNode:dotDivide": {
|
|
op: "./",
|
|
associativity: "left",
|
|
associativeWith: []
|
|
},
|
|
"OperatorNode:mod": {
|
|
op: "mod",
|
|
associativity: "left",
|
|
associativeWith: []
|
|
}
|
|
}, {
|
|
"OperatorNode:multiply": {
|
|
associativity: "left",
|
|
associativeWith: ["OperatorNode:multiply", "OperatorNode:divide", "Operator:dotMultiply", "Operator:dotDivide"]
|
|
}
|
|
}, {
|
|
"OperatorNode:unaryPlus": {
|
|
op: "+",
|
|
associativity: "right"
|
|
},
|
|
"OperatorNode:unaryMinus": {
|
|
op: "-",
|
|
associativity: "right"
|
|
},
|
|
"OperatorNode:bitNot": {
|
|
op: "~",
|
|
associativity: "right"
|
|
},
|
|
"OperatorNode:not": {
|
|
op: "not",
|
|
associativity: "right"
|
|
}
|
|
}, {
|
|
"OperatorNode:pow": {
|
|
op: "^",
|
|
associativity: "right",
|
|
associativeWith: [],
|
|
latexRightParens: false
|
|
},
|
|
"OperatorNode:dotPow": {
|
|
op: ".^",
|
|
associativity: "right",
|
|
associativeWith: []
|
|
}
|
|
}, {
|
|
"OperatorNode:factorial": {
|
|
op: "!",
|
|
associativity: "left"
|
|
}
|
|
}, {
|
|
"OperatorNode:ctranspose": {
|
|
op: "'",
|
|
associativity: "left"
|
|
}
|
|
}];
|
|
function unwrapParen(_node, parenthesis) {
|
|
if (!parenthesis || parenthesis !== "auto")
|
|
return _node;
|
|
var node = _node;
|
|
while (isParenthesisNode(node)) {
|
|
node = node.content;
|
|
}
|
|
return node;
|
|
}
|
|
function getPrecedence(_node, parenthesis, implicit, parent) {
|
|
var node = _node;
|
|
if (parenthesis !== "keep") {
|
|
node = _node.getContent();
|
|
}
|
|
var identifier = node.getIdentifier();
|
|
var precedence = null;
|
|
for (var i2 = 0; i2 < properties.length; i2++) {
|
|
if (identifier in properties[i2]) {
|
|
precedence = i2;
|
|
break;
|
|
}
|
|
}
|
|
if (identifier === "OperatorNode:multiply" && node.implicit && implicit !== "show") {
|
|
var leftArg = unwrapParen(node.args[0], parenthesis);
|
|
if (!(isConstantNode(leftArg) && parent && parent.getIdentifier() === "OperatorNode:divide" && rule2Node(unwrapParen(parent.args[0], parenthesis))) && !(leftArg.getIdentifier() === "OperatorNode:divide" && rule2Node(unwrapParen(leftArg.args[0], parenthesis)) && isConstantNode(unwrapParen(leftArg.args[1])))) {
|
|
precedence += 1;
|
|
}
|
|
}
|
|
return precedence;
|
|
}
|
|
function getAssociativity(_node, parenthesis) {
|
|
var node = _node;
|
|
if (parenthesis !== "keep") {
|
|
node = _node.getContent();
|
|
}
|
|
var identifier = node.getIdentifier();
|
|
var index2 = getPrecedence(node, parenthesis);
|
|
if (index2 === null) {
|
|
return null;
|
|
}
|
|
var property = properties[index2][identifier];
|
|
if (hasOwnProperty2(property, "associativity")) {
|
|
if (property.associativity === "left") {
|
|
return "left";
|
|
}
|
|
if (property.associativity === "right") {
|
|
return "right";
|
|
}
|
|
throw Error("'" + identifier + "' has the invalid associativity '" + property.associativity + "'.");
|
|
}
|
|
return null;
|
|
}
|
|
function isAssociativeWith(nodeA, nodeB, parenthesis) {
|
|
var a = parenthesis !== "keep" ? nodeA.getContent() : nodeA;
|
|
var b = parenthesis !== "keep" ? nodeA.getContent() : nodeB;
|
|
var identifierA = a.getIdentifier();
|
|
var identifierB = b.getIdentifier();
|
|
var index2 = getPrecedence(a, parenthesis);
|
|
if (index2 === null) {
|
|
return null;
|
|
}
|
|
var property = properties[index2][identifierA];
|
|
if (hasOwnProperty2(property, "associativeWith") && property.associativeWith instanceof Array) {
|
|
for (var i2 = 0; i2 < property.associativeWith.length; i2++) {
|
|
if (property.associativeWith[i2] === identifierB) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
return null;
|
|
}
|
|
function getOperator(fn) {
|
|
var identifier = "OperatorNode:" + fn;
|
|
for (var group of properties) {
|
|
if (identifier in group) {
|
|
return group[identifier].op;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/expression/node/AssignmentNode.js
|
|
var name206 = "AssignmentNode";
|
|
var dependencies206 = [
|
|
"subset",
|
|
"?matrix",
|
|
"Node"
|
|
];
|
|
var createAssignmentNode = /* @__PURE__ */ factory(name206, dependencies206, (_ref) => {
|
|
var {
|
|
subset: subset2,
|
|
matrix: matrix2,
|
|
Node: Node2
|
|
} = _ref;
|
|
var access = accessFactory({
|
|
subset: subset2
|
|
});
|
|
var assign2 = assignFactory({
|
|
subset: subset2,
|
|
matrix: matrix2
|
|
});
|
|
function needParenthesis(node, parenthesis, implicit) {
|
|
if (!parenthesis) {
|
|
parenthesis = "keep";
|
|
}
|
|
var precedence = getPrecedence(node, parenthesis, implicit);
|
|
var exprPrecedence = getPrecedence(node.value, parenthesis, implicit);
|
|
return parenthesis === "all" || exprPrecedence !== null && exprPrecedence <= precedence;
|
|
}
|
|
class AssignmentNode2 extends Node2 {
|
|
constructor(object, index2, value) {
|
|
super();
|
|
this.object = object;
|
|
this.index = value ? index2 : null;
|
|
this.value = value || index2;
|
|
if (!isSymbolNode(object) && !isAccessorNode(object)) {
|
|
throw new TypeError('SymbolNode or AccessorNode expected as "object"');
|
|
}
|
|
if (isSymbolNode(object) && object.name === "end") {
|
|
throw new Error('Cannot assign to symbol "end"');
|
|
}
|
|
if (this.index && !isIndexNode(this.index)) {
|
|
throw new TypeError('IndexNode expected as "index"');
|
|
}
|
|
if (!isNode(this.value)) {
|
|
throw new TypeError('Node expected as "value"');
|
|
}
|
|
}
|
|
get name() {
|
|
if (this.index) {
|
|
return this.index.isObjectProperty() ? this.index.getObjectProperty() : "";
|
|
} else {
|
|
return this.object.name || "";
|
|
}
|
|
}
|
|
get type() {
|
|
return name206;
|
|
}
|
|
get isAssignmentNode() {
|
|
return true;
|
|
}
|
|
_compile(math2, argNames) {
|
|
var evalObject = this.object._compile(math2, argNames);
|
|
var evalIndex = this.index ? this.index._compile(math2, argNames) : null;
|
|
var evalValue = this.value._compile(math2, argNames);
|
|
var name302 = this.object.name;
|
|
if (!this.index) {
|
|
if (!isSymbolNode(this.object)) {
|
|
throw new TypeError("SymbolNode expected as object");
|
|
}
|
|
return function evalAssignmentNode(scope, args, context) {
|
|
var value = evalValue(scope, args, context);
|
|
scope.set(name302, value);
|
|
return value;
|
|
};
|
|
} else if (this.index.isObjectProperty()) {
|
|
var prop = this.index.getObjectProperty();
|
|
return function evalAssignmentNode(scope, args, context) {
|
|
var object = evalObject(scope, args, context);
|
|
var value = evalValue(scope, args, context);
|
|
setSafeProperty(object, prop, value);
|
|
return value;
|
|
};
|
|
} else if (isSymbolNode(this.object)) {
|
|
return function evalAssignmentNode(scope, args, context) {
|
|
var childObject = evalObject(scope, args, context);
|
|
var value = evalValue(scope, args, context);
|
|
var index2 = evalIndex(scope, args, childObject);
|
|
scope.set(name302, assign2(childObject, index2, value));
|
|
return value;
|
|
};
|
|
} else {
|
|
var evalParentObject = this.object.object._compile(math2, argNames);
|
|
if (this.object.index.isObjectProperty()) {
|
|
var parentProp = this.object.index.getObjectProperty();
|
|
return function evalAssignmentNode(scope, args, context) {
|
|
var parent = evalParentObject(scope, args, context);
|
|
var childObject = getSafeProperty(parent, parentProp);
|
|
var index2 = evalIndex(scope, args, childObject);
|
|
var value = evalValue(scope, args, context);
|
|
setSafeProperty(parent, parentProp, assign2(childObject, index2, value));
|
|
return value;
|
|
};
|
|
} else {
|
|
var evalParentIndex = this.object.index._compile(math2, argNames);
|
|
return function evalAssignmentNode(scope, args, context) {
|
|
var parent = evalParentObject(scope, args, context);
|
|
var parentIndex = evalParentIndex(scope, args, parent);
|
|
var childObject = access(parent, parentIndex);
|
|
var index2 = evalIndex(scope, args, childObject);
|
|
var value = evalValue(scope, args, context);
|
|
assign2(parent, parentIndex, assign2(childObject, index2, value));
|
|
return value;
|
|
};
|
|
}
|
|
}
|
|
}
|
|
forEach(callback) {
|
|
callback(this.object, "object", this);
|
|
if (this.index) {
|
|
callback(this.index, "index", this);
|
|
}
|
|
callback(this.value, "value", this);
|
|
}
|
|
map(callback) {
|
|
var object = this._ifNode(callback(this.object, "object", this));
|
|
var index2 = this.index ? this._ifNode(callback(this.index, "index", this)) : null;
|
|
var value = this._ifNode(callback(this.value, "value", this));
|
|
return new AssignmentNode2(object, index2, value);
|
|
}
|
|
clone() {
|
|
return new AssignmentNode2(this.object, this.index, this.value);
|
|
}
|
|
_toString(options) {
|
|
var object = this.object.toString(options);
|
|
var index2 = this.index ? this.index.toString(options) : "";
|
|
var value = this.value.toString(options);
|
|
if (needParenthesis(this, options && options.parenthesis, options && options.implicit)) {
|
|
value = "(" + value + ")";
|
|
}
|
|
return object + index2 + " = " + value;
|
|
}
|
|
toJSON() {
|
|
return {
|
|
mathjs: name206,
|
|
object: this.object,
|
|
index: this.index,
|
|
value: this.value
|
|
};
|
|
}
|
|
static fromJSON(json) {
|
|
return new AssignmentNode2(json.object, json.index, json.value);
|
|
}
|
|
toHTML(options) {
|
|
var object = this.object.toHTML(options);
|
|
var index2 = this.index ? this.index.toHTML(options) : "";
|
|
var value = this.value.toHTML(options);
|
|
if (needParenthesis(this, options && options.parenthesis, options && options.implicit)) {
|
|
value = '<span class="math-paranthesis math-round-parenthesis">(</span>' + value + '<span class="math-paranthesis math-round-parenthesis">)</span>';
|
|
}
|
|
return object + index2 + '<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>' + value;
|
|
}
|
|
_toTex(options) {
|
|
var object = this.object.toTex(options);
|
|
var index2 = this.index ? this.index.toTex(options) : "";
|
|
var value = this.value.toTex(options);
|
|
if (needParenthesis(this, options && options.parenthesis, options && options.implicit)) {
|
|
value = "\\left(".concat(value, "\\right)");
|
|
}
|
|
return object + index2 + ":=" + value;
|
|
}
|
|
}
|
|
_defineProperty(AssignmentNode2, "name", name206);
|
|
return AssignmentNode2;
|
|
}, {
|
|
isClass: true,
|
|
isNode: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/node/BlockNode.js
|
|
var name207 = "BlockNode";
|
|
var dependencies207 = ["ResultSet", "Node"];
|
|
var createBlockNode = /* @__PURE__ */ factory(name207, dependencies207, (_ref) => {
|
|
var {
|
|
ResultSet: ResultSet2,
|
|
Node: Node2
|
|
} = _ref;
|
|
class BlockNode2 extends Node2 {
|
|
constructor(blocks) {
|
|
super();
|
|
if (!Array.isArray(blocks))
|
|
throw new Error("Array expected");
|
|
this.blocks = blocks.map(function(block) {
|
|
var node = block && block.node;
|
|
var visible = block && block.visible !== void 0 ? block.visible : true;
|
|
if (!isNode(node))
|
|
throw new TypeError('Property "node" must be a Node');
|
|
if (typeof visible !== "boolean") {
|
|
throw new TypeError('Property "visible" must be a boolean');
|
|
}
|
|
return {
|
|
node,
|
|
visible
|
|
};
|
|
});
|
|
}
|
|
get type() {
|
|
return name207;
|
|
}
|
|
get isBlockNode() {
|
|
return true;
|
|
}
|
|
_compile(math2, argNames) {
|
|
var evalBlocks = map(this.blocks, function(block) {
|
|
return {
|
|
evaluate: block.node._compile(math2, argNames),
|
|
visible: block.visible
|
|
};
|
|
});
|
|
return function evalBlockNodes(scope, args, context) {
|
|
var results = [];
|
|
forEach(evalBlocks, function evalBlockNode(block) {
|
|
var result = block.evaluate(scope, args, context);
|
|
if (block.visible) {
|
|
results.push(result);
|
|
}
|
|
});
|
|
return new ResultSet2(results);
|
|
};
|
|
}
|
|
forEach(callback) {
|
|
for (var i2 = 0; i2 < this.blocks.length; i2++) {
|
|
callback(this.blocks[i2].node, "blocks[" + i2 + "].node", this);
|
|
}
|
|
}
|
|
map(callback) {
|
|
var blocks = [];
|
|
for (var i2 = 0; i2 < this.blocks.length; i2++) {
|
|
var block = this.blocks[i2];
|
|
var node = this._ifNode(callback(block.node, "blocks[" + i2 + "].node", this));
|
|
blocks[i2] = {
|
|
node,
|
|
visible: block.visible
|
|
};
|
|
}
|
|
return new BlockNode2(blocks);
|
|
}
|
|
clone() {
|
|
var blocks = this.blocks.map(function(block) {
|
|
return {
|
|
node: block.node,
|
|
visible: block.visible
|
|
};
|
|
});
|
|
return new BlockNode2(blocks);
|
|
}
|
|
_toString(options) {
|
|
return this.blocks.map(function(param) {
|
|
return param.node.toString(options) + (param.visible ? "" : ";");
|
|
}).join("\n");
|
|
}
|
|
toJSON() {
|
|
return {
|
|
mathjs: name207,
|
|
blocks: this.blocks
|
|
};
|
|
}
|
|
static fromJSON(json) {
|
|
return new BlockNode2(json.blocks);
|
|
}
|
|
toHTML(options) {
|
|
return this.blocks.map(function(param) {
|
|
return param.node.toHTML(options) + (param.visible ? "" : '<span class="math-separator">;</span>');
|
|
}).join('<span class="math-separator"><br /></span>');
|
|
}
|
|
_toTex(options) {
|
|
return this.blocks.map(function(param) {
|
|
return param.node.toTex(options) + (param.visible ? "" : ";");
|
|
}).join("\\;\\;\n");
|
|
}
|
|
}
|
|
_defineProperty(BlockNode2, "name", name207);
|
|
return BlockNode2;
|
|
}, {
|
|
isClass: true,
|
|
isNode: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/node/ConditionalNode.js
|
|
var name208 = "ConditionalNode";
|
|
var dependencies208 = ["Node"];
|
|
var createConditionalNode = /* @__PURE__ */ factory(name208, dependencies208, (_ref) => {
|
|
var {
|
|
Node: Node2
|
|
} = _ref;
|
|
function testCondition(condition) {
|
|
if (typeof condition === "number" || typeof condition === "boolean" || typeof condition === "string") {
|
|
return !!condition;
|
|
}
|
|
if (condition) {
|
|
if (isBigNumber(condition)) {
|
|
return !condition.isZero();
|
|
}
|
|
if (isComplex(condition)) {
|
|
return !!(condition.re || condition.im);
|
|
}
|
|
if (isUnit(condition)) {
|
|
return !!condition.value;
|
|
}
|
|
}
|
|
if (condition === null || condition === void 0) {
|
|
return false;
|
|
}
|
|
throw new TypeError('Unsupported type of condition "' + typeOf(condition) + '"');
|
|
}
|
|
class ConditionalNode2 extends Node2 {
|
|
constructor(condition, trueExpr, falseExpr) {
|
|
super();
|
|
if (!isNode(condition)) {
|
|
throw new TypeError("Parameter condition must be a Node");
|
|
}
|
|
if (!isNode(trueExpr)) {
|
|
throw new TypeError("Parameter trueExpr must be a Node");
|
|
}
|
|
if (!isNode(falseExpr)) {
|
|
throw new TypeError("Parameter falseExpr must be a Node");
|
|
}
|
|
this.condition = condition;
|
|
this.trueExpr = trueExpr;
|
|
this.falseExpr = falseExpr;
|
|
}
|
|
get type() {
|
|
return name208;
|
|
}
|
|
get isConditionalNode() {
|
|
return true;
|
|
}
|
|
_compile(math2, argNames) {
|
|
var evalCondition = this.condition._compile(math2, argNames);
|
|
var evalTrueExpr = this.trueExpr._compile(math2, argNames);
|
|
var evalFalseExpr = this.falseExpr._compile(math2, argNames);
|
|
return function evalConditionalNode(scope, args, context) {
|
|
return testCondition(evalCondition(scope, args, context)) ? evalTrueExpr(scope, args, context) : evalFalseExpr(scope, args, context);
|
|
};
|
|
}
|
|
forEach(callback) {
|
|
callback(this.condition, "condition", this);
|
|
callback(this.trueExpr, "trueExpr", this);
|
|
callback(this.falseExpr, "falseExpr", this);
|
|
}
|
|
map(callback) {
|
|
return new ConditionalNode2(this._ifNode(callback(this.condition, "condition", this)), this._ifNode(callback(this.trueExpr, "trueExpr", this)), this._ifNode(callback(this.falseExpr, "falseExpr", this)));
|
|
}
|
|
clone() {
|
|
return new ConditionalNode2(this.condition, this.trueExpr, this.falseExpr);
|
|
}
|
|
_toString(options) {
|
|
var parenthesis = options && options.parenthesis ? options.parenthesis : "keep";
|
|
var precedence = getPrecedence(this, parenthesis, options && options.implicit);
|
|
var condition = this.condition.toString(options);
|
|
var conditionPrecedence = getPrecedence(this.condition, parenthesis, options && options.implicit);
|
|
if (parenthesis === "all" || this.condition.type === "OperatorNode" || conditionPrecedence !== null && conditionPrecedence <= precedence) {
|
|
condition = "(" + condition + ")";
|
|
}
|
|
var trueExpr = this.trueExpr.toString(options);
|
|
var truePrecedence = getPrecedence(this.trueExpr, parenthesis, options && options.implicit);
|
|
if (parenthesis === "all" || this.trueExpr.type === "OperatorNode" || truePrecedence !== null && truePrecedence <= precedence) {
|
|
trueExpr = "(" + trueExpr + ")";
|
|
}
|
|
var falseExpr = this.falseExpr.toString(options);
|
|
var falsePrecedence = getPrecedence(this.falseExpr, parenthesis, options && options.implicit);
|
|
if (parenthesis === "all" || this.falseExpr.type === "OperatorNode" || falsePrecedence !== null && falsePrecedence <= precedence) {
|
|
falseExpr = "(" + falseExpr + ")";
|
|
}
|
|
return condition + " ? " + trueExpr + " : " + falseExpr;
|
|
}
|
|
toJSON() {
|
|
return {
|
|
mathjs: name208,
|
|
condition: this.condition,
|
|
trueExpr: this.trueExpr,
|
|
falseExpr: this.falseExpr
|
|
};
|
|
}
|
|
static fromJSON(json) {
|
|
return new ConditionalNode2(json.condition, json.trueExpr, json.falseExpr);
|
|
}
|
|
toHTML(options) {
|
|
var parenthesis = options && options.parenthesis ? options.parenthesis : "keep";
|
|
var precedence = getPrecedence(this, parenthesis, options && options.implicit);
|
|
var condition = this.condition.toHTML(options);
|
|
var conditionPrecedence = getPrecedence(this.condition, parenthesis, options && options.implicit);
|
|
if (parenthesis === "all" || this.condition.type === "OperatorNode" || conditionPrecedence !== null && conditionPrecedence <= precedence) {
|
|
condition = '<span class="math-parenthesis math-round-parenthesis">(</span>' + condition + '<span class="math-parenthesis math-round-parenthesis">)</span>';
|
|
}
|
|
var trueExpr = this.trueExpr.toHTML(options);
|
|
var truePrecedence = getPrecedence(this.trueExpr, parenthesis, options && options.implicit);
|
|
if (parenthesis === "all" || this.trueExpr.type === "OperatorNode" || truePrecedence !== null && truePrecedence <= precedence) {
|
|
trueExpr = '<span class="math-parenthesis math-round-parenthesis">(</span>' + trueExpr + '<span class="math-parenthesis math-round-parenthesis">)</span>';
|
|
}
|
|
var falseExpr = this.falseExpr.toHTML(options);
|
|
var falsePrecedence = getPrecedence(this.falseExpr, parenthesis, options && options.implicit);
|
|
if (parenthesis === "all" || this.falseExpr.type === "OperatorNode" || falsePrecedence !== null && falsePrecedence <= precedence) {
|
|
falseExpr = '<span class="math-parenthesis math-round-parenthesis">(</span>' + falseExpr + '<span class="math-parenthesis math-round-parenthesis">)</span>';
|
|
}
|
|
return condition + '<span class="math-operator math-conditional-operator">?</span>' + trueExpr + '<span class="math-operator math-conditional-operator">:</span>' + falseExpr;
|
|
}
|
|
_toTex(options) {
|
|
return "\\begin{cases} {" + this.trueExpr.toTex(options) + "}, &\\quad{\\text{if }\\;" + this.condition.toTex(options) + "}\\\\{" + this.falseExpr.toTex(options) + "}, &\\quad{\\text{otherwise}}\\end{cases}";
|
|
}
|
|
}
|
|
_defineProperty(ConditionalNode2, "name", name208);
|
|
return ConditionalNode2;
|
|
}, {
|
|
isClass: true,
|
|
isNode: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/utils/latex.js
|
|
var import_escape_latex = __toESM(require_dist(), 1);
|
|
var latexSymbols = {
|
|
Alpha: "A",
|
|
alpha: "\\alpha",
|
|
Beta: "B",
|
|
beta: "\\beta",
|
|
Gamma: "\\Gamma",
|
|
gamma: "\\gamma",
|
|
Delta: "\\Delta",
|
|
delta: "\\delta",
|
|
Epsilon: "E",
|
|
epsilon: "\\epsilon",
|
|
varepsilon: "\\varepsilon",
|
|
Zeta: "Z",
|
|
zeta: "\\zeta",
|
|
Eta: "H",
|
|
eta: "\\eta",
|
|
Theta: "\\Theta",
|
|
theta: "\\theta",
|
|
vartheta: "\\vartheta",
|
|
Iota: "I",
|
|
iota: "\\iota",
|
|
Kappa: "K",
|
|
kappa: "\\kappa",
|
|
varkappa: "\\varkappa",
|
|
Lambda: "\\Lambda",
|
|
lambda: "\\lambda",
|
|
Mu: "M",
|
|
mu: "\\mu",
|
|
Nu: "N",
|
|
nu: "\\nu",
|
|
Xi: "\\Xi",
|
|
xi: "\\xi",
|
|
Omicron: "O",
|
|
omicron: "o",
|
|
Pi: "\\Pi",
|
|
pi: "\\pi",
|
|
varpi: "\\varpi",
|
|
Rho: "P",
|
|
rho: "\\rho",
|
|
varrho: "\\varrho",
|
|
Sigma: "\\Sigma",
|
|
sigma: "\\sigma",
|
|
varsigma: "\\varsigma",
|
|
Tau: "T",
|
|
tau: "\\tau",
|
|
Upsilon: "\\Upsilon",
|
|
upsilon: "\\upsilon",
|
|
Phi: "\\Phi",
|
|
phi: "\\phi",
|
|
varphi: "\\varphi",
|
|
Chi: "X",
|
|
chi: "\\chi",
|
|
Psi: "\\Psi",
|
|
psi: "\\psi",
|
|
Omega: "\\Omega",
|
|
omega: "\\omega",
|
|
true: "\\mathrm{True}",
|
|
false: "\\mathrm{False}",
|
|
i: "i",
|
|
inf: "\\infty",
|
|
Inf: "\\infty",
|
|
infinity: "\\infty",
|
|
Infinity: "\\infty",
|
|
oo: "\\infty",
|
|
lim: "\\lim",
|
|
undefined: "\\mathbf{?}"
|
|
};
|
|
var latexOperators = {
|
|
transpose: "^\\top",
|
|
ctranspose: "^H",
|
|
factorial: "!",
|
|
pow: "^",
|
|
dotPow: ".^\\wedge",
|
|
unaryPlus: "+",
|
|
unaryMinus: "-",
|
|
bitNot: "\\~",
|
|
not: "\\neg",
|
|
multiply: "\\cdot",
|
|
divide: "\\frac",
|
|
dotMultiply: ".\\cdot",
|
|
dotDivide: ".:",
|
|
mod: "\\mod",
|
|
add: "+",
|
|
subtract: "-",
|
|
to: "\\rightarrow",
|
|
leftShift: "<<",
|
|
rightArithShift: ">>",
|
|
rightLogShift: ">>>",
|
|
equal: "=",
|
|
unequal: "\\neq",
|
|
smaller: "<",
|
|
larger: ">",
|
|
smallerEq: "\\leq",
|
|
largerEq: "\\geq",
|
|
bitAnd: "\\&",
|
|
bitXor: "\\underline{|}",
|
|
bitOr: "|",
|
|
and: "\\wedge",
|
|
xor: "\\veebar",
|
|
or: "\\vee"
|
|
};
|
|
var latexFunctions = {
|
|
abs: {
|
|
1: "\\left|${args[0]}\\right|"
|
|
},
|
|
add: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.add, "${args[1]}\\right)")
|
|
},
|
|
cbrt: {
|
|
1: "\\sqrt[3]{${args[0]}}"
|
|
},
|
|
ceil: {
|
|
1: "\\left\\lceil${args[0]}\\right\\rceil"
|
|
},
|
|
cube: {
|
|
1: "\\left(${args[0]}\\right)^3"
|
|
},
|
|
divide: {
|
|
2: "\\frac{${args[0]}}{${args[1]}}"
|
|
},
|
|
dotDivide: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.dotDivide, "${args[1]}\\right)")
|
|
},
|
|
dotMultiply: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.dotMultiply, "${args[1]}\\right)")
|
|
},
|
|
dotPow: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.dotPow, "${args[1]}\\right)")
|
|
},
|
|
exp: {
|
|
1: "\\exp\\left(${args[0]}\\right)"
|
|
},
|
|
expm1: "\\left(e".concat(latexOperators.pow, "{${args[0]}}-1\\right)"),
|
|
fix: {
|
|
1: "\\mathrm{${name}}\\left(${args[0]}\\right)"
|
|
},
|
|
floor: {
|
|
1: "\\left\\lfloor${args[0]}\\right\\rfloor"
|
|
},
|
|
gcd: "\\gcd\\left(${args}\\right)",
|
|
hypot: "\\hypot\\left(${args}\\right)",
|
|
log: {
|
|
1: "\\ln\\left(${args[0]}\\right)",
|
|
2: "\\log_{${args[1]}}\\left(${args[0]}\\right)"
|
|
},
|
|
log10: {
|
|
1: "\\log_{10}\\left(${args[0]}\\right)"
|
|
},
|
|
log1p: {
|
|
1: "\\ln\\left(${args[0]}+1\\right)",
|
|
2: "\\log_{${args[1]}}\\left(${args[0]}+1\\right)"
|
|
},
|
|
log2: "\\log_{2}\\left(${args[0]}\\right)",
|
|
mod: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.mod, "${args[1]}\\right)")
|
|
},
|
|
multiply: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.multiply, "${args[1]}\\right)")
|
|
},
|
|
norm: {
|
|
1: "\\left\\|${args[0]}\\right\\|",
|
|
2: void 0
|
|
},
|
|
nthRoot: {
|
|
2: "\\sqrt[${args[1]}]{${args[0]}}"
|
|
},
|
|
nthRoots: {
|
|
2: "\\{y : $y^{args[1]} = {${args[0]}}\\}"
|
|
},
|
|
pow: {
|
|
2: "\\left(${args[0]}\\right)".concat(latexOperators.pow, "{${args[1]}}")
|
|
},
|
|
round: {
|
|
1: "\\left\\lfloor${args[0]}\\right\\rceil",
|
|
2: void 0
|
|
},
|
|
sign: {
|
|
1: "\\mathrm{${name}}\\left(${args[0]}\\right)"
|
|
},
|
|
sqrt: {
|
|
1: "\\sqrt{${args[0]}}"
|
|
},
|
|
square: {
|
|
1: "\\left(${args[0]}\\right)^2"
|
|
},
|
|
subtract: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.subtract, "${args[1]}\\right)")
|
|
},
|
|
unaryMinus: {
|
|
1: "".concat(latexOperators.unaryMinus, "\\left(${args[0]}\\right)")
|
|
},
|
|
unaryPlus: {
|
|
1: "".concat(latexOperators.unaryPlus, "\\left(${args[0]}\\right)")
|
|
},
|
|
bitAnd: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.bitAnd, "${args[1]}\\right)")
|
|
},
|
|
bitNot: {
|
|
1: latexOperators.bitNot + "\\left(${args[0]}\\right)"
|
|
},
|
|
bitOr: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.bitOr, "${args[1]}\\right)")
|
|
},
|
|
bitXor: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.bitXor, "${args[1]}\\right)")
|
|
},
|
|
leftShift: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.leftShift, "${args[1]}\\right)")
|
|
},
|
|
rightArithShift: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.rightArithShift, "${args[1]}\\right)")
|
|
},
|
|
rightLogShift: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.rightLogShift, "${args[1]}\\right)")
|
|
},
|
|
bellNumbers: {
|
|
1: "\\mathrm{B}_{${args[0]}}"
|
|
},
|
|
catalan: {
|
|
1: "\\mathrm{C}_{${args[0]}}"
|
|
},
|
|
stirlingS2: {
|
|
2: "\\mathrm{S}\\left(${args}\\right)"
|
|
},
|
|
arg: {
|
|
1: "\\arg\\left(${args[0]}\\right)"
|
|
},
|
|
conj: {
|
|
1: "\\left(${args[0]}\\right)^*"
|
|
},
|
|
im: {
|
|
1: "\\Im\\left\\lbrace${args[0]}\\right\\rbrace"
|
|
},
|
|
re: {
|
|
1: "\\Re\\left\\lbrace${args[0]}\\right\\rbrace"
|
|
},
|
|
and: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.and, "${args[1]}\\right)")
|
|
},
|
|
not: {
|
|
1: latexOperators.not + "\\left(${args[0]}\\right)"
|
|
},
|
|
or: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.or, "${args[1]}\\right)")
|
|
},
|
|
xor: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.xor, "${args[1]}\\right)")
|
|
},
|
|
cross: {
|
|
2: "\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"
|
|
},
|
|
ctranspose: {
|
|
1: "\\left(${args[0]}\\right)".concat(latexOperators.ctranspose)
|
|
},
|
|
det: {
|
|
1: "\\det\\left(${args[0]}\\right)"
|
|
},
|
|
dot: {
|
|
2: "\\left(${args[0]}\\cdot${args[1]}\\right)"
|
|
},
|
|
expm: {
|
|
1: "\\exp\\left(${args[0]}\\right)"
|
|
},
|
|
inv: {
|
|
1: "\\left(${args[0]}\\right)^{-1}"
|
|
},
|
|
pinv: {
|
|
1: "\\left(${args[0]}\\right)^{+}"
|
|
},
|
|
sqrtm: {
|
|
1: "{${args[0]}}".concat(latexOperators.pow, "{\\frac{1}{2}}")
|
|
},
|
|
trace: {
|
|
1: "\\mathrm{tr}\\left(${args[0]}\\right)"
|
|
},
|
|
transpose: {
|
|
1: "\\left(${args[0]}\\right)".concat(latexOperators.transpose)
|
|
},
|
|
combinations: {
|
|
2: "\\binom{${args[0]}}{${args[1]}}"
|
|
},
|
|
combinationsWithRep: {
|
|
2: "\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"
|
|
},
|
|
factorial: {
|
|
1: "\\left(${args[0]}\\right)".concat(latexOperators.factorial)
|
|
},
|
|
gamma: {
|
|
1: "\\Gamma\\left(${args[0]}\\right)"
|
|
},
|
|
lgamma: {
|
|
1: "\\ln\\Gamma\\left(${args[0]}\\right)"
|
|
},
|
|
equal: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.equal, "${args[1]}\\right)")
|
|
},
|
|
larger: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.larger, "${args[1]}\\right)")
|
|
},
|
|
largerEq: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.largerEq, "${args[1]}\\right)")
|
|
},
|
|
smaller: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.smaller, "${args[1]}\\right)")
|
|
},
|
|
smallerEq: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.smallerEq, "${args[1]}\\right)")
|
|
},
|
|
unequal: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.unequal, "${args[1]}\\right)")
|
|
},
|
|
erf: {
|
|
1: "erf\\left(${args[0]}\\right)"
|
|
},
|
|
max: "\\max\\left(${args}\\right)",
|
|
min: "\\min\\left(${args}\\right)",
|
|
variance: "\\mathrm{Var}\\left(${args}\\right)",
|
|
acos: {
|
|
1: "\\cos^{-1}\\left(${args[0]}\\right)"
|
|
},
|
|
acosh: {
|
|
1: "\\cosh^{-1}\\left(${args[0]}\\right)"
|
|
},
|
|
acot: {
|
|
1: "\\cot^{-1}\\left(${args[0]}\\right)"
|
|
},
|
|
acoth: {
|
|
1: "\\coth^{-1}\\left(${args[0]}\\right)"
|
|
},
|
|
acsc: {
|
|
1: "\\csc^{-1}\\left(${args[0]}\\right)"
|
|
},
|
|
acsch: {
|
|
1: "\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"
|
|
},
|
|
asec: {
|
|
1: "\\sec^{-1}\\left(${args[0]}\\right)"
|
|
},
|
|
asech: {
|
|
1: "\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"
|
|
},
|
|
asin: {
|
|
1: "\\sin^{-1}\\left(${args[0]}\\right)"
|
|
},
|
|
asinh: {
|
|
1: "\\sinh^{-1}\\left(${args[0]}\\right)"
|
|
},
|
|
atan: {
|
|
1: "\\tan^{-1}\\left(${args[0]}\\right)"
|
|
},
|
|
atan2: {
|
|
2: "\\mathrm{atan2}\\left(${args}\\right)"
|
|
},
|
|
atanh: {
|
|
1: "\\tanh^{-1}\\left(${args[0]}\\right)"
|
|
},
|
|
cos: {
|
|
1: "\\cos\\left(${args[0]}\\right)"
|
|
},
|
|
cosh: {
|
|
1: "\\cosh\\left(${args[0]}\\right)"
|
|
},
|
|
cot: {
|
|
1: "\\cot\\left(${args[0]}\\right)"
|
|
},
|
|
coth: {
|
|
1: "\\coth\\left(${args[0]}\\right)"
|
|
},
|
|
csc: {
|
|
1: "\\csc\\left(${args[0]}\\right)"
|
|
},
|
|
csch: {
|
|
1: "\\mathrm{csch}\\left(${args[0]}\\right)"
|
|
},
|
|
sec: {
|
|
1: "\\sec\\left(${args[0]}\\right)"
|
|
},
|
|
sech: {
|
|
1: "\\mathrm{sech}\\left(${args[0]}\\right)"
|
|
},
|
|
sin: {
|
|
1: "\\sin\\left(${args[0]}\\right)"
|
|
},
|
|
sinh: {
|
|
1: "\\sinh\\left(${args[0]}\\right)"
|
|
},
|
|
tan: {
|
|
1: "\\tan\\left(${args[0]}\\right)"
|
|
},
|
|
tanh: {
|
|
1: "\\tanh\\left(${args[0]}\\right)"
|
|
},
|
|
to: {
|
|
2: "\\left(${args[0]}".concat(latexOperators.to, "${args[1]}\\right)")
|
|
},
|
|
numeric: function numeric(node, options) {
|
|
return node.args[0].toTex();
|
|
},
|
|
number: {
|
|
0: "0",
|
|
1: "\\left(${args[0]}\\right)",
|
|
2: "\\left(\\left(${args[0]}\\right)${args[1]}\\right)"
|
|
},
|
|
string: {
|
|
0: '\\mathtt{""}',
|
|
1: "\\mathrm{string}\\left(${args[0]}\\right)"
|
|
},
|
|
bignumber: {
|
|
0: "0",
|
|
1: "\\left(${args[0]}\\right)"
|
|
},
|
|
complex: {
|
|
0: "0",
|
|
1: "\\left(${args[0]}\\right)",
|
|
2: "\\left(\\left(${args[0]}\\right)+".concat(latexSymbols.i, "\\cdot\\left(${args[1]}\\right)\\right)")
|
|
},
|
|
matrix: {
|
|
0: "\\begin{bmatrix}\\end{bmatrix}",
|
|
1: "\\left(${args[0]}\\right)",
|
|
2: "\\left(${args[0]}\\right)"
|
|
},
|
|
sparse: {
|
|
0: "\\begin{bsparse}\\end{bsparse}",
|
|
1: "\\left(${args[0]}\\right)"
|
|
},
|
|
unit: {
|
|
1: "\\left(${args[0]}\\right)",
|
|
2: "\\left(\\left(${args[0]}\\right)${args[1]}\\right)"
|
|
}
|
|
};
|
|
var defaultTemplate = "\\mathrm{${name}}\\left(${args}\\right)";
|
|
var latexUnits = {
|
|
deg: "^\\circ"
|
|
};
|
|
function escapeLatex(string2) {
|
|
return (0, import_escape_latex.default)(string2, {
|
|
preserveFormatting: true
|
|
});
|
|
}
|
|
function toSymbol(name302, isUnit2) {
|
|
isUnit2 = typeof isUnit2 === "undefined" ? false : isUnit2;
|
|
if (isUnit2) {
|
|
if (hasOwnProperty2(latexUnits, name302)) {
|
|
return latexUnits[name302];
|
|
}
|
|
return "\\mathrm{" + escapeLatex(name302) + "}";
|
|
}
|
|
if (hasOwnProperty2(latexSymbols, name302)) {
|
|
return latexSymbols[name302];
|
|
}
|
|
return escapeLatex(name302);
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/expression/node/ConstantNode.js
|
|
var name209 = "ConstantNode";
|
|
var dependencies209 = ["Node"];
|
|
var createConstantNode = /* @__PURE__ */ factory(name209, dependencies209, (_ref) => {
|
|
var {
|
|
Node: Node2
|
|
} = _ref;
|
|
class ConstantNode2 extends Node2 {
|
|
constructor(value) {
|
|
super();
|
|
this.value = value;
|
|
}
|
|
get type() {
|
|
return name209;
|
|
}
|
|
get isConstantNode() {
|
|
return true;
|
|
}
|
|
_compile(math2, argNames) {
|
|
var value = this.value;
|
|
return function evalConstantNode() {
|
|
return value;
|
|
};
|
|
}
|
|
forEach(callback) {
|
|
}
|
|
map(callback) {
|
|
return this.clone();
|
|
}
|
|
clone() {
|
|
return new ConstantNode2(this.value);
|
|
}
|
|
_toString(options) {
|
|
return format3(this.value, options);
|
|
}
|
|
toHTML(options) {
|
|
var value = this._toString(options);
|
|
switch (typeOf(this.value)) {
|
|
case "number":
|
|
case "BigNumber":
|
|
case "Fraction":
|
|
return '<span class="math-number">' + value + "</span>";
|
|
case "string":
|
|
return '<span class="math-string">' + value + "</span>";
|
|
case "boolean":
|
|
return '<span class="math-boolean">' + value + "</span>";
|
|
case "null":
|
|
return '<span class="math-null-symbol">' + value + "</span>";
|
|
case "undefined":
|
|
return '<span class="math-undefined">' + value + "</span>";
|
|
default:
|
|
return '<span class="math-symbol">' + value + "</span>";
|
|
}
|
|
}
|
|
toJSON() {
|
|
return {
|
|
mathjs: name209,
|
|
value: this.value
|
|
};
|
|
}
|
|
static fromJSON(json) {
|
|
return new ConstantNode2(json.value);
|
|
}
|
|
_toTex(options) {
|
|
var value = this._toString(options);
|
|
switch (typeOf(this.value)) {
|
|
case "string":
|
|
return "\\mathtt{" + escapeLatex(value) + "}";
|
|
case "number":
|
|
case "BigNumber":
|
|
{
|
|
if (!isFinite(this.value)) {
|
|
return this.value.valueOf() < 0 ? "-\\infty" : "\\infty";
|
|
}
|
|
var index2 = value.toLowerCase().indexOf("e");
|
|
if (index2 !== -1) {
|
|
return value.substring(0, index2) + "\\cdot10^{" + value.substring(index2 + 1) + "}";
|
|
}
|
|
}
|
|
return value;
|
|
case "Fraction":
|
|
return this.value.toLatex();
|
|
default:
|
|
return value;
|
|
}
|
|
}
|
|
}
|
|
_defineProperty(ConstantNode2, "name", name209);
|
|
return ConstantNode2;
|
|
}, {
|
|
isClass: true,
|
|
isNode: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/node/FunctionAssignmentNode.js
|
|
var name210 = "FunctionAssignmentNode";
|
|
var dependencies210 = ["typed", "Node"];
|
|
var createFunctionAssignmentNode = /* @__PURE__ */ factory(name210, dependencies210, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
Node: Node2
|
|
} = _ref;
|
|
function needParenthesis(node, parenthesis, implicit) {
|
|
var precedence = getPrecedence(node, parenthesis, implicit);
|
|
var exprPrecedence = getPrecedence(node.expr, parenthesis, implicit);
|
|
return parenthesis === "all" || exprPrecedence !== null && exprPrecedence <= precedence;
|
|
}
|
|
class FunctionAssignmentNode2 extends Node2 {
|
|
constructor(name302, params, expr) {
|
|
super();
|
|
if (typeof name302 !== "string") {
|
|
throw new TypeError('String expected for parameter "name"');
|
|
}
|
|
if (!Array.isArray(params)) {
|
|
throw new TypeError('Array containing strings or objects expected for parameter "params"');
|
|
}
|
|
if (!isNode(expr)) {
|
|
throw new TypeError('Node expected for parameter "expr"');
|
|
}
|
|
if (keywords.has(name302)) {
|
|
throw new Error('Illegal function name, "' + name302 + '" is a reserved keyword');
|
|
}
|
|
var paramNames = /* @__PURE__ */ new Set();
|
|
for (var param of params) {
|
|
var _name = typeof param === "string" ? param : param.name;
|
|
if (paramNames.has(_name)) {
|
|
throw new Error('Duplicate parameter name "'.concat(_name, '"'));
|
|
} else {
|
|
paramNames.add(_name);
|
|
}
|
|
}
|
|
this.name = name302;
|
|
this.params = params.map(function(param2) {
|
|
return param2 && param2.name || param2;
|
|
});
|
|
this.types = params.map(function(param2) {
|
|
return param2 && param2.type || "any";
|
|
});
|
|
this.expr = expr;
|
|
}
|
|
get type() {
|
|
return name210;
|
|
}
|
|
get isFunctionAssignmentNode() {
|
|
return true;
|
|
}
|
|
_compile(math2, argNames) {
|
|
var childArgNames = Object.create(argNames);
|
|
forEach(this.params, function(param) {
|
|
childArgNames[param] = true;
|
|
});
|
|
var evalExpr = this.expr._compile(math2, childArgNames);
|
|
var name302 = this.name;
|
|
var params = this.params;
|
|
var signature = join(this.types, ",");
|
|
var syntax = name302 + "(" + join(this.params, ", ") + ")";
|
|
return function evalFunctionAssignmentNode(scope, args, context) {
|
|
var signatures = {};
|
|
signatures[signature] = function() {
|
|
var childArgs = Object.create(args);
|
|
for (var i2 = 0; i2 < params.length; i2++) {
|
|
childArgs[params[i2]] = arguments[i2];
|
|
}
|
|
return evalExpr(scope, childArgs, context);
|
|
};
|
|
var fn = typed2(name302, signatures);
|
|
fn.syntax = syntax;
|
|
scope.set(name302, fn);
|
|
return fn;
|
|
};
|
|
}
|
|
forEach(callback) {
|
|
callback(this.expr, "expr", this);
|
|
}
|
|
map(callback) {
|
|
var expr = this._ifNode(callback(this.expr, "expr", this));
|
|
return new FunctionAssignmentNode2(this.name, this.params.slice(0), expr);
|
|
}
|
|
clone() {
|
|
return new FunctionAssignmentNode2(this.name, this.params.slice(0), this.expr);
|
|
}
|
|
_toString(options) {
|
|
var parenthesis = options && options.parenthesis ? options.parenthesis : "keep";
|
|
var expr = this.expr.toString(options);
|
|
if (needParenthesis(this, parenthesis, options && options.implicit)) {
|
|
expr = "(" + expr + ")";
|
|
}
|
|
return this.name + "(" + this.params.join(", ") + ") = " + expr;
|
|
}
|
|
toJSON() {
|
|
var types = this.types;
|
|
return {
|
|
mathjs: name210,
|
|
name: this.name,
|
|
params: this.params.map(function(param, index2) {
|
|
return {
|
|
name: param,
|
|
type: types[index2]
|
|
};
|
|
}),
|
|
expr: this.expr
|
|
};
|
|
}
|
|
static fromJSON(json) {
|
|
return new FunctionAssignmentNode2(json.name, json.params, json.expr);
|
|
}
|
|
toHTML(options) {
|
|
var parenthesis = options && options.parenthesis ? options.parenthesis : "keep";
|
|
var params = [];
|
|
for (var i2 = 0; i2 < this.params.length; i2++) {
|
|
params.push('<span class="math-symbol math-parameter">' + escape(this.params[i2]) + "</span>");
|
|
}
|
|
var expr = this.expr.toHTML(options);
|
|
if (needParenthesis(this, parenthesis, options && options.implicit)) {
|
|
expr = '<span class="math-parenthesis math-round-parenthesis">(</span>' + expr + '<span class="math-parenthesis math-round-parenthesis">)</span>';
|
|
}
|
|
return '<span class="math-function">' + escape(this.name) + '</span><span class="math-parenthesis math-round-parenthesis">(</span>' + params.join('<span class="math-separator">,</span>') + '<span class="math-parenthesis math-round-parenthesis">)</span><span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>' + expr;
|
|
}
|
|
_toTex(options) {
|
|
var parenthesis = options && options.parenthesis ? options.parenthesis : "keep";
|
|
var expr = this.expr.toTex(options);
|
|
if (needParenthesis(this, parenthesis, options && options.implicit)) {
|
|
expr = "\\left(".concat(expr, "\\right)");
|
|
}
|
|
return "\\mathrm{" + this.name + "}\\left(" + this.params.map(toSymbol).join(",") + "\\right):=" + expr;
|
|
}
|
|
}
|
|
_defineProperty(FunctionAssignmentNode2, "name", name210);
|
|
return FunctionAssignmentNode2;
|
|
}, {
|
|
isClass: true,
|
|
isNode: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/node/IndexNode.js
|
|
var name211 = "IndexNode";
|
|
var dependencies211 = ["Node", "size"];
|
|
var createIndexNode = /* @__PURE__ */ factory(name211, dependencies211, (_ref) => {
|
|
var {
|
|
Node: Node2,
|
|
size: size2
|
|
} = _ref;
|
|
class IndexNode2 extends Node2 {
|
|
constructor(dimensions, dotNotation) {
|
|
super();
|
|
this.dimensions = dimensions;
|
|
this.dotNotation = dotNotation || false;
|
|
if (!Array.isArray(dimensions) || !dimensions.every(isNode)) {
|
|
throw new TypeError('Array containing Nodes expected for parameter "dimensions"');
|
|
}
|
|
if (this.dotNotation && !this.isObjectProperty()) {
|
|
throw new Error("dotNotation only applicable for object properties");
|
|
}
|
|
}
|
|
get type() {
|
|
return name211;
|
|
}
|
|
get isIndexNode() {
|
|
return true;
|
|
}
|
|
_compile(math2, argNames) {
|
|
var evalDimensions = map(this.dimensions, function(dimension, i2) {
|
|
var needsEnd = dimension.filter((node) => node.isSymbolNode && node.name === "end").length > 0;
|
|
if (needsEnd) {
|
|
var childArgNames = Object.create(argNames);
|
|
childArgNames.end = true;
|
|
var _evalDimension = dimension._compile(math2, childArgNames);
|
|
return function evalDimension(scope, args, context) {
|
|
if (!isMatrix(context) && !isArray(context) && !isString(context)) {
|
|
throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is ' + typeOf(context));
|
|
}
|
|
var s = size2(context).valueOf();
|
|
var childArgs = Object.create(args);
|
|
childArgs.end = s[i2];
|
|
return _evalDimension(scope, childArgs, context);
|
|
};
|
|
} else {
|
|
return dimension._compile(math2, argNames);
|
|
}
|
|
});
|
|
var index2 = getSafeProperty(math2, "index");
|
|
return function evalIndexNode(scope, args, context) {
|
|
var dimensions = map(evalDimensions, function(evalDimension) {
|
|
return evalDimension(scope, args, context);
|
|
});
|
|
return index2(...dimensions);
|
|
};
|
|
}
|
|
forEach(callback) {
|
|
for (var i2 = 0; i2 < this.dimensions.length; i2++) {
|
|
callback(this.dimensions[i2], "dimensions[" + i2 + "]", this);
|
|
}
|
|
}
|
|
map(callback) {
|
|
var dimensions = [];
|
|
for (var i2 = 0; i2 < this.dimensions.length; i2++) {
|
|
dimensions[i2] = this._ifNode(callback(this.dimensions[i2], "dimensions[" + i2 + "]", this));
|
|
}
|
|
return new IndexNode2(dimensions, this.dotNotation);
|
|
}
|
|
clone() {
|
|
return new IndexNode2(this.dimensions.slice(0), this.dotNotation);
|
|
}
|
|
isObjectProperty() {
|
|
return this.dimensions.length === 1 && isConstantNode(this.dimensions[0]) && typeof this.dimensions[0].value === "string";
|
|
}
|
|
getObjectProperty() {
|
|
return this.isObjectProperty() ? this.dimensions[0].value : null;
|
|
}
|
|
_toString(options) {
|
|
return this.dotNotation ? "." + this.getObjectProperty() : "[" + this.dimensions.join(", ") + "]";
|
|
}
|
|
toJSON() {
|
|
return {
|
|
mathjs: name211,
|
|
dimensions: this.dimensions,
|
|
dotNotation: this.dotNotation
|
|
};
|
|
}
|
|
static fromJSON(json) {
|
|
return new IndexNode2(json.dimensions, json.dotNotation);
|
|
}
|
|
toHTML(options) {
|
|
var dimensions = [];
|
|
for (var i2 = 0; i2 < this.dimensions.length; i2++) {
|
|
dimensions[i2] = this.dimensions[i2].toHTML();
|
|
}
|
|
if (this.dotNotation) {
|
|
return '<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">' + escape(this.getObjectProperty()) + "</span>";
|
|
} else {
|
|
return '<span class="math-parenthesis math-square-parenthesis">[</span>' + dimensions.join('<span class="math-separator">,</span>') + '<span class="math-parenthesis math-square-parenthesis">]</span>';
|
|
}
|
|
}
|
|
_toTex(options) {
|
|
var dimensions = this.dimensions.map(function(range2) {
|
|
return range2.toTex(options);
|
|
});
|
|
return this.dotNotation ? "." + this.getObjectProperty() : "_{" + dimensions.join(",") + "}";
|
|
}
|
|
}
|
|
_defineProperty(IndexNode2, "name", name211);
|
|
return IndexNode2;
|
|
}, {
|
|
isClass: true,
|
|
isNode: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/node/ObjectNode.js
|
|
var name212 = "ObjectNode";
|
|
var dependencies212 = ["Node"];
|
|
var createObjectNode = /* @__PURE__ */ factory(name212, dependencies212, (_ref) => {
|
|
var {
|
|
Node: Node2
|
|
} = _ref;
|
|
class ObjectNode2 extends Node2 {
|
|
constructor(properties2) {
|
|
super();
|
|
this.properties = properties2 || {};
|
|
if (properties2) {
|
|
if (!(typeof properties2 === "object") || !Object.keys(properties2).every(function(key) {
|
|
return isNode(properties2[key]);
|
|
})) {
|
|
throw new TypeError("Object containing Nodes expected");
|
|
}
|
|
}
|
|
}
|
|
get type() {
|
|
return name212;
|
|
}
|
|
get isObjectNode() {
|
|
return true;
|
|
}
|
|
_compile(math2, argNames) {
|
|
var evalEntries = {};
|
|
for (var key in this.properties) {
|
|
if (hasOwnProperty2(this.properties, key)) {
|
|
var stringifiedKey = stringify(key);
|
|
var parsedKey = JSON.parse(stringifiedKey);
|
|
if (!isSafeProperty(this.properties, parsedKey)) {
|
|
throw new Error('No access to property "' + parsedKey + '"');
|
|
}
|
|
evalEntries[parsedKey] = this.properties[key]._compile(math2, argNames);
|
|
}
|
|
}
|
|
return function evalObjectNode(scope, args, context) {
|
|
var obj = {};
|
|
for (var _key in evalEntries) {
|
|
if (hasOwnProperty2(evalEntries, _key)) {
|
|
obj[_key] = evalEntries[_key](scope, args, context);
|
|
}
|
|
}
|
|
return obj;
|
|
};
|
|
}
|
|
forEach(callback) {
|
|
for (var key in this.properties) {
|
|
if (hasOwnProperty2(this.properties, key)) {
|
|
callback(this.properties[key], "properties[" + stringify(key) + "]", this);
|
|
}
|
|
}
|
|
}
|
|
map(callback) {
|
|
var properties2 = {};
|
|
for (var key in this.properties) {
|
|
if (hasOwnProperty2(this.properties, key)) {
|
|
properties2[key] = this._ifNode(callback(this.properties[key], "properties[" + stringify(key) + "]", this));
|
|
}
|
|
}
|
|
return new ObjectNode2(properties2);
|
|
}
|
|
clone() {
|
|
var properties2 = {};
|
|
for (var key in this.properties) {
|
|
if (hasOwnProperty2(this.properties, key)) {
|
|
properties2[key] = this.properties[key];
|
|
}
|
|
}
|
|
return new ObjectNode2(properties2);
|
|
}
|
|
_toString(options) {
|
|
var entries = [];
|
|
for (var key in this.properties) {
|
|
if (hasOwnProperty2(this.properties, key)) {
|
|
entries.push(stringify(key) + ": " + this.properties[key].toString(options));
|
|
}
|
|
}
|
|
return "{" + entries.join(", ") + "}";
|
|
}
|
|
toJSON() {
|
|
return {
|
|
mathjs: name212,
|
|
properties: this.properties
|
|
};
|
|
}
|
|
static fromJSON(json) {
|
|
return new ObjectNode2(json.properties);
|
|
}
|
|
toHTML(options) {
|
|
var entries = [];
|
|
for (var key in this.properties) {
|
|
if (hasOwnProperty2(this.properties, key)) {
|
|
entries.push('<span class="math-symbol math-property">' + escape(key) + '</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>' + this.properties[key].toHTML(options));
|
|
}
|
|
}
|
|
return '<span class="math-parenthesis math-curly-parenthesis">{</span>' + entries.join('<span class="math-separator">,</span>') + '<span class="math-parenthesis math-curly-parenthesis">}</span>';
|
|
}
|
|
_toTex(options) {
|
|
var entries = [];
|
|
for (var key in this.properties) {
|
|
if (hasOwnProperty2(this.properties, key)) {
|
|
entries.push("\\mathbf{" + key + ":} & " + this.properties[key].toTex(options) + "\\\\");
|
|
}
|
|
}
|
|
var tex = "\\left\\{\\begin{array}{ll}" + entries.join("\n") + "\\end{array}\\right\\}";
|
|
return tex;
|
|
}
|
|
}
|
|
_defineProperty(ObjectNode2, "name", name212);
|
|
return ObjectNode2;
|
|
}, {
|
|
isClass: true,
|
|
isNode: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/node/OperatorNode.js
|
|
var name213 = "OperatorNode";
|
|
var dependencies213 = ["Node"];
|
|
var createOperatorNode = /* @__PURE__ */ factory(name213, dependencies213, (_ref) => {
|
|
var {
|
|
Node: Node2
|
|
} = _ref;
|
|
function startsWithConstant(expr, parenthesis) {
|
|
var curNode = expr;
|
|
if (parenthesis === "auto") {
|
|
while (isParenthesisNode(curNode)) {
|
|
curNode = curNode.content;
|
|
}
|
|
}
|
|
if (isConstantNode(curNode))
|
|
return true;
|
|
if (isOperatorNode(curNode)) {
|
|
return startsWithConstant(curNode.args[0], parenthesis);
|
|
}
|
|
return false;
|
|
}
|
|
function calculateNecessaryParentheses(root, parenthesis, implicit, args, latex) {
|
|
var precedence = getPrecedence(root, parenthesis, implicit);
|
|
var associativity = getAssociativity(root, parenthesis);
|
|
if (parenthesis === "all" || args.length > 2 && root.getIdentifier() !== "OperatorNode:add" && root.getIdentifier() !== "OperatorNode:multiply") {
|
|
return args.map(function(arg2) {
|
|
switch (arg2.getContent().type) {
|
|
case "ArrayNode":
|
|
case "ConstantNode":
|
|
case "SymbolNode":
|
|
case "ParenthesisNode":
|
|
return false;
|
|
default:
|
|
return true;
|
|
}
|
|
});
|
|
}
|
|
var result;
|
|
switch (args.length) {
|
|
case 0:
|
|
result = [];
|
|
break;
|
|
case 1:
|
|
{
|
|
var operandPrecedence = getPrecedence(args[0], parenthesis, implicit, root);
|
|
if (latex && operandPrecedence !== null) {
|
|
var operandIdentifier;
|
|
var rootIdentifier;
|
|
if (parenthesis === "keep") {
|
|
operandIdentifier = args[0].getIdentifier();
|
|
rootIdentifier = root.getIdentifier();
|
|
} else {
|
|
operandIdentifier = args[0].getContent().getIdentifier();
|
|
rootIdentifier = root.getContent().getIdentifier();
|
|
}
|
|
if (properties[precedence][rootIdentifier].latexLeftParens === false) {
|
|
result = [false];
|
|
break;
|
|
}
|
|
if (properties[operandPrecedence][operandIdentifier].latexParens === false) {
|
|
result = [false];
|
|
break;
|
|
}
|
|
}
|
|
if (operandPrecedence === null) {
|
|
result = [false];
|
|
break;
|
|
}
|
|
if (operandPrecedence <= precedence) {
|
|
result = [true];
|
|
break;
|
|
}
|
|
result = [false];
|
|
}
|
|
break;
|
|
case 2:
|
|
{
|
|
var lhsParens;
|
|
var lhsPrecedence = getPrecedence(args[0], parenthesis, implicit, root);
|
|
var assocWithLhs = isAssociativeWith(root, args[0], parenthesis);
|
|
if (lhsPrecedence === null) {
|
|
lhsParens = false;
|
|
} else if (lhsPrecedence === precedence && associativity === "right" && !assocWithLhs) {
|
|
lhsParens = true;
|
|
} else if (lhsPrecedence < precedence) {
|
|
lhsParens = true;
|
|
} else {
|
|
lhsParens = false;
|
|
}
|
|
var rhsParens;
|
|
var rhsPrecedence = getPrecedence(args[1], parenthesis, implicit, root);
|
|
var assocWithRhs = isAssociativeWith(root, args[1], parenthesis);
|
|
if (rhsPrecedence === null) {
|
|
rhsParens = false;
|
|
} else if (rhsPrecedence === precedence && associativity === "left" && !assocWithRhs) {
|
|
rhsParens = true;
|
|
} else if (rhsPrecedence < precedence) {
|
|
rhsParens = true;
|
|
} else {
|
|
rhsParens = false;
|
|
}
|
|
if (latex) {
|
|
var _rootIdentifier;
|
|
var lhsIdentifier;
|
|
var rhsIdentifier;
|
|
if (parenthesis === "keep") {
|
|
_rootIdentifier = root.getIdentifier();
|
|
lhsIdentifier = root.args[0].getIdentifier();
|
|
rhsIdentifier = root.args[1].getIdentifier();
|
|
} else {
|
|
_rootIdentifier = root.getContent().getIdentifier();
|
|
lhsIdentifier = root.args[0].getContent().getIdentifier();
|
|
rhsIdentifier = root.args[1].getContent().getIdentifier();
|
|
}
|
|
if (lhsPrecedence !== null) {
|
|
if (properties[precedence][_rootIdentifier].latexLeftParens === false) {
|
|
lhsParens = false;
|
|
}
|
|
if (properties[lhsPrecedence][lhsIdentifier].latexParens === false) {
|
|
lhsParens = false;
|
|
}
|
|
}
|
|
if (rhsPrecedence !== null) {
|
|
if (properties[precedence][_rootIdentifier].latexRightParens === false) {
|
|
rhsParens = false;
|
|
}
|
|
if (properties[rhsPrecedence][rhsIdentifier].latexParens === false) {
|
|
rhsParens = false;
|
|
}
|
|
}
|
|
}
|
|
result = [lhsParens, rhsParens];
|
|
}
|
|
break;
|
|
default:
|
|
if (root.getIdentifier() === "OperatorNode:add" || root.getIdentifier() === "OperatorNode:multiply") {
|
|
result = args.map(function(arg2) {
|
|
var argPrecedence = getPrecedence(arg2, parenthesis, implicit, root);
|
|
var assocWithArg = isAssociativeWith(root, arg2, parenthesis);
|
|
var argAssociativity = getAssociativity(arg2, parenthesis);
|
|
if (argPrecedence === null) {
|
|
return false;
|
|
} else if (precedence === argPrecedence && associativity === argAssociativity && !assocWithArg) {
|
|
return true;
|
|
} else if (argPrecedence < precedence) {
|
|
return true;
|
|
}
|
|
return false;
|
|
});
|
|
}
|
|
break;
|
|
}
|
|
if (args.length >= 2 && root.getIdentifier() === "OperatorNode:multiply" && root.implicit && parenthesis !== "all" && implicit === "hide") {
|
|
for (var i2 = 1; i2 < result.length; ++i2) {
|
|
if (startsWithConstant(args[i2], parenthesis) && !result[i2 - 1] && (parenthesis !== "keep" || !isParenthesisNode(args[i2 - 1]))) {
|
|
result[i2] = true;
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
class OperatorNode2 extends Node2 {
|
|
constructor(op, fn, args, implicit, isPercentage) {
|
|
super();
|
|
if (typeof op !== "string") {
|
|
throw new TypeError('string expected for parameter "op"');
|
|
}
|
|
if (typeof fn !== "string") {
|
|
throw new TypeError('string expected for parameter "fn"');
|
|
}
|
|
if (!Array.isArray(args) || !args.every(isNode)) {
|
|
throw new TypeError('Array containing Nodes expected for parameter "args"');
|
|
}
|
|
this.implicit = implicit === true;
|
|
this.isPercentage = isPercentage === true;
|
|
this.op = op;
|
|
this.fn = fn;
|
|
this.args = args || [];
|
|
}
|
|
get type() {
|
|
return name213;
|
|
}
|
|
get isOperatorNode() {
|
|
return true;
|
|
}
|
|
_compile(math2, argNames) {
|
|
if (typeof this.fn !== "string" || !isSafeMethod(math2, this.fn)) {
|
|
if (!math2[this.fn]) {
|
|
throw new Error("Function " + this.fn + ' missing in provided namespace "math"');
|
|
} else {
|
|
throw new Error('No access to function "' + this.fn + '"');
|
|
}
|
|
}
|
|
var fn = getSafeProperty(math2, this.fn);
|
|
var evalArgs = map(this.args, function(arg2) {
|
|
return arg2._compile(math2, argNames);
|
|
});
|
|
if (evalArgs.length === 1) {
|
|
var evalArg0 = evalArgs[0];
|
|
return function evalOperatorNode(scope, args, context) {
|
|
return fn(evalArg0(scope, args, context));
|
|
};
|
|
} else if (evalArgs.length === 2) {
|
|
var _evalArg = evalArgs[0];
|
|
var evalArg1 = evalArgs[1];
|
|
return function evalOperatorNode(scope, args, context) {
|
|
return fn(_evalArg(scope, args, context), evalArg1(scope, args, context));
|
|
};
|
|
} else {
|
|
return function evalOperatorNode(scope, args, context) {
|
|
return fn.apply(null, map(evalArgs, function(evalArg) {
|
|
return evalArg(scope, args, context);
|
|
}));
|
|
};
|
|
}
|
|
}
|
|
forEach(callback) {
|
|
for (var i2 = 0; i2 < this.args.length; i2++) {
|
|
callback(this.args[i2], "args[" + i2 + "]", this);
|
|
}
|
|
}
|
|
map(callback) {
|
|
var args = [];
|
|
for (var i2 = 0; i2 < this.args.length; i2++) {
|
|
args[i2] = this._ifNode(callback(this.args[i2], "args[" + i2 + "]", this));
|
|
}
|
|
return new OperatorNode2(this.op, this.fn, args, this.implicit, this.isPercentage);
|
|
}
|
|
clone() {
|
|
return new OperatorNode2(this.op, this.fn, this.args.slice(0), this.implicit, this.isPercentage);
|
|
}
|
|
isUnary() {
|
|
return this.args.length === 1;
|
|
}
|
|
isBinary() {
|
|
return this.args.length === 2;
|
|
}
|
|
_toString(options) {
|
|
var parenthesis = options && options.parenthesis ? options.parenthesis : "keep";
|
|
var implicit = options && options.implicit ? options.implicit : "hide";
|
|
var args = this.args;
|
|
var parens = calculateNecessaryParentheses(this, parenthesis, implicit, args, false);
|
|
if (args.length === 1) {
|
|
var assoc = getAssociativity(this, parenthesis);
|
|
var operand = args[0].toString(options);
|
|
if (parens[0]) {
|
|
operand = "(" + operand + ")";
|
|
}
|
|
var opIsNamed = /[a-zA-Z]+/.test(this.op);
|
|
if (assoc === "right") {
|
|
return this.op + (opIsNamed ? " " : "") + operand;
|
|
} else if (assoc === "left") {
|
|
return operand + (opIsNamed ? " " : "") + this.op;
|
|
}
|
|
return operand + this.op;
|
|
} else if (args.length === 2) {
|
|
var lhs = args[0].toString(options);
|
|
var rhs = args[1].toString(options);
|
|
if (parens[0]) {
|
|
lhs = "(" + lhs + ")";
|
|
}
|
|
if (parens[1]) {
|
|
rhs = "(" + rhs + ")";
|
|
}
|
|
if (this.implicit && this.getIdentifier() === "OperatorNode:multiply" && implicit === "hide") {
|
|
return lhs + " " + rhs;
|
|
}
|
|
return lhs + " " + this.op + " " + rhs;
|
|
} else if (args.length > 2 && (this.getIdentifier() === "OperatorNode:add" || this.getIdentifier() === "OperatorNode:multiply")) {
|
|
var stringifiedArgs = args.map(function(arg2, index2) {
|
|
arg2 = arg2.toString(options);
|
|
if (parens[index2]) {
|
|
arg2 = "(" + arg2 + ")";
|
|
}
|
|
return arg2;
|
|
});
|
|
if (this.implicit && this.getIdentifier() === "OperatorNode:multiply" && implicit === "hide") {
|
|
return stringifiedArgs.join(" ");
|
|
}
|
|
return stringifiedArgs.join(" " + this.op + " ");
|
|
} else {
|
|
return this.fn + "(" + this.args.join(", ") + ")";
|
|
}
|
|
}
|
|
toJSON() {
|
|
return {
|
|
mathjs: name213,
|
|
op: this.op,
|
|
fn: this.fn,
|
|
args: this.args,
|
|
implicit: this.implicit,
|
|
isPercentage: this.isPercentage
|
|
};
|
|
}
|
|
static fromJSON(json) {
|
|
return new OperatorNode2(json.op, json.fn, json.args, json.implicit, json.isPercentage);
|
|
}
|
|
toHTML(options) {
|
|
var parenthesis = options && options.parenthesis ? options.parenthesis : "keep";
|
|
var implicit = options && options.implicit ? options.implicit : "hide";
|
|
var args = this.args;
|
|
var parens = calculateNecessaryParentheses(this, parenthesis, implicit, args, false);
|
|
if (args.length === 1) {
|
|
var assoc = getAssociativity(this, parenthesis);
|
|
var operand = args[0].toHTML(options);
|
|
if (parens[0]) {
|
|
operand = '<span class="math-parenthesis math-round-parenthesis">(</span>' + operand + '<span class="math-parenthesis math-round-parenthesis">)</span>';
|
|
}
|
|
if (assoc === "right") {
|
|
return '<span class="math-operator math-unary-operator math-lefthand-unary-operator">' + escape(this.op) + "</span>" + operand;
|
|
} else {
|
|
return operand + '<span class="math-operator math-unary-operator math-righthand-unary-operator">' + escape(this.op) + "</span>";
|
|
}
|
|
} else if (args.length === 2) {
|
|
var lhs = args[0].toHTML(options);
|
|
var rhs = args[1].toHTML(options);
|
|
if (parens[0]) {
|
|
lhs = '<span class="math-parenthesis math-round-parenthesis">(</span>' + lhs + '<span class="math-parenthesis math-round-parenthesis">)</span>';
|
|
}
|
|
if (parens[1]) {
|
|
rhs = '<span class="math-parenthesis math-round-parenthesis">(</span>' + rhs + '<span class="math-parenthesis math-round-parenthesis">)</span>';
|
|
}
|
|
if (this.implicit && this.getIdentifier() === "OperatorNode:multiply" && implicit === "hide") {
|
|
return lhs + '<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>' + rhs;
|
|
}
|
|
return lhs + '<span class="math-operator math-binary-operator math-explicit-binary-operator">' + escape(this.op) + "</span>" + rhs;
|
|
} else {
|
|
var stringifiedArgs = args.map(function(arg2, index2) {
|
|
arg2 = arg2.toHTML(options);
|
|
if (parens[index2]) {
|
|
arg2 = '<span class="math-parenthesis math-round-parenthesis">(</span>' + arg2 + '<span class="math-parenthesis math-round-parenthesis">)</span>';
|
|
}
|
|
return arg2;
|
|
});
|
|
if (args.length > 2 && (this.getIdentifier() === "OperatorNode:add" || this.getIdentifier() === "OperatorNode:multiply")) {
|
|
if (this.implicit && this.getIdentifier() === "OperatorNode:multiply" && implicit === "hide") {
|
|
return stringifiedArgs.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>');
|
|
}
|
|
return stringifiedArgs.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">' + escape(this.op) + "</span>");
|
|
} else {
|
|
return '<span class="math-function">' + escape(this.fn) + '</span><span class="math-paranthesis math-round-parenthesis">(</span>' + stringifiedArgs.join('<span class="math-separator">,</span>') + '<span class="math-paranthesis math-round-parenthesis">)</span>';
|
|
}
|
|
}
|
|
}
|
|
_toTex(options) {
|
|
var parenthesis = options && options.parenthesis ? options.parenthesis : "keep";
|
|
var implicit = options && options.implicit ? options.implicit : "hide";
|
|
var args = this.args;
|
|
var parens = calculateNecessaryParentheses(this, parenthesis, implicit, args, true);
|
|
var op = latexOperators[this.fn];
|
|
op = typeof op === "undefined" ? this.op : op;
|
|
if (args.length === 1) {
|
|
var assoc = getAssociativity(this, parenthesis);
|
|
var operand = args[0].toTex(options);
|
|
if (parens[0]) {
|
|
operand = "\\left(".concat(operand, "\\right)");
|
|
}
|
|
if (assoc === "right") {
|
|
return op + operand;
|
|
} else if (assoc === "left") {
|
|
return operand + op;
|
|
}
|
|
return operand + op;
|
|
} else if (args.length === 2) {
|
|
var lhs = args[0];
|
|
var lhsTex = lhs.toTex(options);
|
|
if (parens[0]) {
|
|
lhsTex = "\\left(".concat(lhsTex, "\\right)");
|
|
}
|
|
var rhs = args[1];
|
|
var rhsTex = rhs.toTex(options);
|
|
if (parens[1]) {
|
|
rhsTex = "\\left(".concat(rhsTex, "\\right)");
|
|
}
|
|
var lhsIdentifier;
|
|
if (parenthesis === "keep") {
|
|
lhsIdentifier = lhs.getIdentifier();
|
|
} else {
|
|
lhsIdentifier = lhs.getContent().getIdentifier();
|
|
}
|
|
switch (this.getIdentifier()) {
|
|
case "OperatorNode:divide":
|
|
return op + "{" + lhsTex + "}{" + rhsTex + "}";
|
|
case "OperatorNode:pow":
|
|
lhsTex = "{" + lhsTex + "}";
|
|
rhsTex = "{" + rhsTex + "}";
|
|
switch (lhsIdentifier) {
|
|
case "ConditionalNode":
|
|
case "OperatorNode:divide":
|
|
lhsTex = "\\left(".concat(lhsTex, "\\right)");
|
|
}
|
|
break;
|
|
case "OperatorNode:multiply":
|
|
if (this.implicit && implicit === "hide") {
|
|
return lhsTex + "~" + rhsTex;
|
|
}
|
|
}
|
|
return lhsTex + op + rhsTex;
|
|
} else if (args.length > 2 && (this.getIdentifier() === "OperatorNode:add" || this.getIdentifier() === "OperatorNode:multiply")) {
|
|
var texifiedArgs = args.map(function(arg2, index2) {
|
|
arg2 = arg2.toTex(options);
|
|
if (parens[index2]) {
|
|
arg2 = "\\left(".concat(arg2, "\\right)");
|
|
}
|
|
return arg2;
|
|
});
|
|
if (this.getIdentifier() === "OperatorNode:multiply" && this.implicit && implicit === "hide") {
|
|
return texifiedArgs.join("~");
|
|
}
|
|
return texifiedArgs.join(op);
|
|
} else {
|
|
return "\\mathrm{" + this.fn + "}\\left(" + args.map(function(arg2) {
|
|
return arg2.toTex(options);
|
|
}).join(",") + "\\right)";
|
|
}
|
|
}
|
|
getIdentifier() {
|
|
return this.type + ":" + this.fn;
|
|
}
|
|
}
|
|
_defineProperty(OperatorNode2, "name", name213);
|
|
return OperatorNode2;
|
|
}, {
|
|
isClass: true,
|
|
isNode: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/node/ParenthesisNode.js
|
|
var name214 = "ParenthesisNode";
|
|
var dependencies214 = ["Node"];
|
|
var createParenthesisNode = /* @__PURE__ */ factory(name214, dependencies214, (_ref) => {
|
|
var {
|
|
Node: Node2
|
|
} = _ref;
|
|
class ParenthesisNode2 extends Node2 {
|
|
constructor(content) {
|
|
super();
|
|
if (!isNode(content)) {
|
|
throw new TypeError('Node expected for parameter "content"');
|
|
}
|
|
this.content = content;
|
|
}
|
|
get type() {
|
|
return name214;
|
|
}
|
|
get isParenthesisNode() {
|
|
return true;
|
|
}
|
|
_compile(math2, argNames) {
|
|
return this.content._compile(math2, argNames);
|
|
}
|
|
getContent() {
|
|
return this.content.getContent();
|
|
}
|
|
forEach(callback) {
|
|
callback(this.content, "content", this);
|
|
}
|
|
map(callback) {
|
|
var content = callback(this.content, "content", this);
|
|
return new ParenthesisNode2(content);
|
|
}
|
|
clone() {
|
|
return new ParenthesisNode2(this.content);
|
|
}
|
|
_toString(options) {
|
|
if (!options || options && !options.parenthesis || options && options.parenthesis === "keep") {
|
|
return "(" + this.content.toString(options) + ")";
|
|
}
|
|
return this.content.toString(options);
|
|
}
|
|
toJSON() {
|
|
return {
|
|
mathjs: name214,
|
|
content: this.content
|
|
};
|
|
}
|
|
static fromJSON(json) {
|
|
return new ParenthesisNode2(json.content);
|
|
}
|
|
toHTML(options) {
|
|
if (!options || options && !options.parenthesis || options && options.parenthesis === "keep") {
|
|
return '<span class="math-parenthesis math-round-parenthesis">(</span>' + this.content.toHTML(options) + '<span class="math-parenthesis math-round-parenthesis">)</span>';
|
|
}
|
|
return this.content.toHTML(options);
|
|
}
|
|
_toTex(options) {
|
|
if (!options || options && !options.parenthesis || options && options.parenthesis === "keep") {
|
|
return "\\left(".concat(this.content.toTex(options), "\\right)");
|
|
}
|
|
return this.content.toTex(options);
|
|
}
|
|
}
|
|
_defineProperty(ParenthesisNode2, "name", name214);
|
|
return ParenthesisNode2;
|
|
}, {
|
|
isClass: true,
|
|
isNode: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/node/RangeNode.js
|
|
var name215 = "RangeNode";
|
|
var dependencies215 = ["Node"];
|
|
var createRangeNode = /* @__PURE__ */ factory(name215, dependencies215, (_ref) => {
|
|
var {
|
|
Node: Node2
|
|
} = _ref;
|
|
function calculateNecessaryParentheses(node, parenthesis, implicit) {
|
|
var precedence = getPrecedence(node, parenthesis, implicit);
|
|
var parens = {};
|
|
var startPrecedence = getPrecedence(node.start, parenthesis, implicit);
|
|
parens.start = startPrecedence !== null && startPrecedence <= precedence || parenthesis === "all";
|
|
if (node.step) {
|
|
var stepPrecedence = getPrecedence(node.step, parenthesis, implicit);
|
|
parens.step = stepPrecedence !== null && stepPrecedence <= precedence || parenthesis === "all";
|
|
}
|
|
var endPrecedence = getPrecedence(node.end, parenthesis, implicit);
|
|
parens.end = endPrecedence !== null && endPrecedence <= precedence || parenthesis === "all";
|
|
return parens;
|
|
}
|
|
class RangeNode2 extends Node2 {
|
|
constructor(start, end, step) {
|
|
super();
|
|
if (!isNode(start))
|
|
throw new TypeError("Node expected");
|
|
if (!isNode(end))
|
|
throw new TypeError("Node expected");
|
|
if (step && !isNode(step))
|
|
throw new TypeError("Node expected");
|
|
if (arguments.length > 3)
|
|
throw new Error("Too many arguments");
|
|
this.start = start;
|
|
this.end = end;
|
|
this.step = step || null;
|
|
}
|
|
get type() {
|
|
return name215;
|
|
}
|
|
get isRangeNode() {
|
|
return true;
|
|
}
|
|
needsEnd() {
|
|
var endSymbols = this.filter(function(node) {
|
|
return isSymbolNode(node) && node.name === "end";
|
|
});
|
|
return endSymbols.length > 0;
|
|
}
|
|
_compile(math2, argNames) {
|
|
var range2 = math2.range;
|
|
var evalStart = this.start._compile(math2, argNames);
|
|
var evalEnd = this.end._compile(math2, argNames);
|
|
if (this.step) {
|
|
var evalStep = this.step._compile(math2, argNames);
|
|
return function evalRangeNode(scope, args, context) {
|
|
return range2(evalStart(scope, args, context), evalEnd(scope, args, context), evalStep(scope, args, context));
|
|
};
|
|
} else {
|
|
return function evalRangeNode(scope, args, context) {
|
|
return range2(evalStart(scope, args, context), evalEnd(scope, args, context));
|
|
};
|
|
}
|
|
}
|
|
forEach(callback) {
|
|
callback(this.start, "start", this);
|
|
callback(this.end, "end", this);
|
|
if (this.step) {
|
|
callback(this.step, "step", this);
|
|
}
|
|
}
|
|
map(callback) {
|
|
return new RangeNode2(this._ifNode(callback(this.start, "start", this)), this._ifNode(callback(this.end, "end", this)), this.step && this._ifNode(callback(this.step, "step", this)));
|
|
}
|
|
clone() {
|
|
return new RangeNode2(this.start, this.end, this.step && this.step);
|
|
}
|
|
_toString(options) {
|
|
var parenthesis = options && options.parenthesis ? options.parenthesis : "keep";
|
|
var parens = calculateNecessaryParentheses(this, parenthesis, options && options.implicit);
|
|
var str;
|
|
var start = this.start.toString(options);
|
|
if (parens.start) {
|
|
start = "(" + start + ")";
|
|
}
|
|
str = start;
|
|
if (this.step) {
|
|
var step = this.step.toString(options);
|
|
if (parens.step) {
|
|
step = "(" + step + ")";
|
|
}
|
|
str += ":" + step;
|
|
}
|
|
var end = this.end.toString(options);
|
|
if (parens.end) {
|
|
end = "(" + end + ")";
|
|
}
|
|
str += ":" + end;
|
|
return str;
|
|
}
|
|
toJSON() {
|
|
return {
|
|
mathjs: name215,
|
|
start: this.start,
|
|
end: this.end,
|
|
step: this.step
|
|
};
|
|
}
|
|
static fromJSON(json) {
|
|
return new RangeNode2(json.start, json.end, json.step);
|
|
}
|
|
toHTML(options) {
|
|
var parenthesis = options && options.parenthesis ? options.parenthesis : "keep";
|
|
var parens = calculateNecessaryParentheses(this, parenthesis, options && options.implicit);
|
|
var str;
|
|
var start = this.start.toHTML(options);
|
|
if (parens.start) {
|
|
start = '<span class="math-parenthesis math-round-parenthesis">(</span>' + start + '<span class="math-parenthesis math-round-parenthesis">)</span>';
|
|
}
|
|
str = start;
|
|
if (this.step) {
|
|
var step = this.step.toHTML(options);
|
|
if (parens.step) {
|
|
step = '<span class="math-parenthesis math-round-parenthesis">(</span>' + step + '<span class="math-parenthesis math-round-parenthesis">)</span>';
|
|
}
|
|
str += '<span class="math-operator math-range-operator">:</span>' + step;
|
|
}
|
|
var end = this.end.toHTML(options);
|
|
if (parens.end) {
|
|
end = '<span class="math-parenthesis math-round-parenthesis">(</span>' + end + '<span class="math-parenthesis math-round-parenthesis">)</span>';
|
|
}
|
|
str += '<span class="math-operator math-range-operator">:</span>' + end;
|
|
return str;
|
|
}
|
|
_toTex(options) {
|
|
var parenthesis = options && options.parenthesis ? options.parenthesis : "keep";
|
|
var parens = calculateNecessaryParentheses(this, parenthesis, options && options.implicit);
|
|
var str = this.start.toTex(options);
|
|
if (parens.start) {
|
|
str = "\\left(".concat(str, "\\right)");
|
|
}
|
|
if (this.step) {
|
|
var step = this.step.toTex(options);
|
|
if (parens.step) {
|
|
step = "\\left(".concat(step, "\\right)");
|
|
}
|
|
str += ":" + step;
|
|
}
|
|
var end = this.end.toTex(options);
|
|
if (parens.end) {
|
|
end = "\\left(".concat(end, "\\right)");
|
|
}
|
|
str += ":" + end;
|
|
return str;
|
|
}
|
|
}
|
|
_defineProperty(RangeNode2, "name", name215);
|
|
return RangeNode2;
|
|
}, {
|
|
isClass: true,
|
|
isNode: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/node/RelationalNode.js
|
|
var name216 = "RelationalNode";
|
|
var dependencies216 = ["Node"];
|
|
var createRelationalNode = /* @__PURE__ */ factory(name216, dependencies216, (_ref) => {
|
|
var {
|
|
Node: Node2
|
|
} = _ref;
|
|
var operatorMap = {
|
|
equal: "==",
|
|
unequal: "!=",
|
|
smaller: "<",
|
|
larger: ">",
|
|
smallerEq: "<=",
|
|
largerEq: ">="
|
|
};
|
|
class RelationalNode2 extends Node2 {
|
|
constructor(conditionals, params) {
|
|
super();
|
|
if (!Array.isArray(conditionals)) {
|
|
throw new TypeError("Parameter conditionals must be an array");
|
|
}
|
|
if (!Array.isArray(params)) {
|
|
throw new TypeError("Parameter params must be an array");
|
|
}
|
|
if (conditionals.length !== params.length - 1) {
|
|
throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");
|
|
}
|
|
this.conditionals = conditionals;
|
|
this.params = params;
|
|
}
|
|
get type() {
|
|
return name216;
|
|
}
|
|
get isRelationalNode() {
|
|
return true;
|
|
}
|
|
_compile(math2, argNames) {
|
|
var self2 = this;
|
|
var compiled = this.params.map((p) => p._compile(math2, argNames));
|
|
return function evalRelationalNode(scope, args, context) {
|
|
var evalLhs;
|
|
var evalRhs = compiled[0](scope, args, context);
|
|
for (var i2 = 0; i2 < self2.conditionals.length; i2++) {
|
|
evalLhs = evalRhs;
|
|
evalRhs = compiled[i2 + 1](scope, args, context);
|
|
var condFn = getSafeProperty(math2, self2.conditionals[i2]);
|
|
if (!condFn(evalLhs, evalRhs)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
}
|
|
forEach(callback) {
|
|
this.params.forEach((n, i2) => callback(n, "params[" + i2 + "]", this), this);
|
|
}
|
|
map(callback) {
|
|
return new RelationalNode2(this.conditionals.slice(), this.params.map((n, i2) => this._ifNode(callback(n, "params[" + i2 + "]", this)), this));
|
|
}
|
|
clone() {
|
|
return new RelationalNode2(this.conditionals, this.params);
|
|
}
|
|
_toString(options) {
|
|
var parenthesis = options && options.parenthesis ? options.parenthesis : "keep";
|
|
var precedence = getPrecedence(this, parenthesis, options && options.implicit);
|
|
var paramStrings = this.params.map(function(p, index2) {
|
|
var paramPrecedence = getPrecedence(p, parenthesis, options && options.implicit);
|
|
return parenthesis === "all" || paramPrecedence !== null && paramPrecedence <= precedence ? "(" + p.toString(options) + ")" : p.toString(options);
|
|
});
|
|
var ret = paramStrings[0];
|
|
for (var i2 = 0; i2 < this.conditionals.length; i2++) {
|
|
ret += " " + operatorMap[this.conditionals[i2]];
|
|
ret += " " + paramStrings[i2 + 1];
|
|
}
|
|
return ret;
|
|
}
|
|
toJSON() {
|
|
return {
|
|
mathjs: name216,
|
|
conditionals: this.conditionals,
|
|
params: this.params
|
|
};
|
|
}
|
|
static fromJSON(json) {
|
|
return new RelationalNode2(json.conditionals, json.params);
|
|
}
|
|
toHTML(options) {
|
|
var parenthesis = options && options.parenthesis ? options.parenthesis : "keep";
|
|
var precedence = getPrecedence(this, parenthesis, options && options.implicit);
|
|
var paramStrings = this.params.map(function(p, index2) {
|
|
var paramPrecedence = getPrecedence(p, parenthesis, options && options.implicit);
|
|
return parenthesis === "all" || paramPrecedence !== null && paramPrecedence <= precedence ? '<span class="math-parenthesis math-round-parenthesis">(</span>' + p.toHTML(options) + '<span class="math-parenthesis math-round-parenthesis">)</span>' : p.toHTML(options);
|
|
});
|
|
var ret = paramStrings[0];
|
|
for (var i2 = 0; i2 < this.conditionals.length; i2++) {
|
|
ret += '<span class="math-operator math-binary-operator math-explicit-binary-operator">' + escape(operatorMap[this.conditionals[i2]]) + "</span>" + paramStrings[i2 + 1];
|
|
}
|
|
return ret;
|
|
}
|
|
_toTex(options) {
|
|
var parenthesis = options && options.parenthesis ? options.parenthesis : "keep";
|
|
var precedence = getPrecedence(this, parenthesis, options && options.implicit);
|
|
var paramStrings = this.params.map(function(p, index2) {
|
|
var paramPrecedence = getPrecedence(p, parenthesis, options && options.implicit);
|
|
return parenthesis === "all" || paramPrecedence !== null && paramPrecedence <= precedence ? "\\left(" + p.toTex(options) + "\right)" : p.toTex(options);
|
|
});
|
|
var ret = paramStrings[0];
|
|
for (var i2 = 0; i2 < this.conditionals.length; i2++) {
|
|
ret += latexOperators[this.conditionals[i2]] + paramStrings[i2 + 1];
|
|
}
|
|
return ret;
|
|
}
|
|
}
|
|
_defineProperty(RelationalNode2, "name", name216);
|
|
return RelationalNode2;
|
|
}, {
|
|
isClass: true,
|
|
isNode: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/node/SymbolNode.js
|
|
var name217 = "SymbolNode";
|
|
var dependencies217 = ["math", "?Unit", "Node"];
|
|
var createSymbolNode = /* @__PURE__ */ factory(name217, dependencies217, (_ref) => {
|
|
var {
|
|
math: math2,
|
|
Unit: Unit2,
|
|
Node: Node2
|
|
} = _ref;
|
|
function isValuelessUnit(name302) {
|
|
return Unit2 ? Unit2.isValuelessUnit(name302) : false;
|
|
}
|
|
class SymbolNode2 extends Node2 {
|
|
constructor(name302) {
|
|
super();
|
|
if (typeof name302 !== "string") {
|
|
throw new TypeError('String expected for parameter "name"');
|
|
}
|
|
this.name = name302;
|
|
}
|
|
get type() {
|
|
return "SymbolNode";
|
|
}
|
|
get isSymbolNode() {
|
|
return true;
|
|
}
|
|
_compile(math3, argNames) {
|
|
var name302 = this.name;
|
|
if (argNames[name302] === true) {
|
|
return function(scope, args, context) {
|
|
return args[name302];
|
|
};
|
|
} else if (name302 in math3) {
|
|
return function(scope, args, context) {
|
|
return scope.has(name302) ? scope.get(name302) : getSafeProperty(math3, name302);
|
|
};
|
|
} else {
|
|
var isUnit2 = isValuelessUnit(name302);
|
|
return function(scope, args, context) {
|
|
return scope.has(name302) ? scope.get(name302) : isUnit2 ? new Unit2(null, name302) : SymbolNode2.onUndefinedSymbol(name302);
|
|
};
|
|
}
|
|
}
|
|
forEach(callback) {
|
|
}
|
|
map(callback) {
|
|
return this.clone();
|
|
}
|
|
static onUndefinedSymbol(name302) {
|
|
throw new Error("Undefined symbol " + name302);
|
|
}
|
|
clone() {
|
|
return new SymbolNode2(this.name);
|
|
}
|
|
_toString(options) {
|
|
return this.name;
|
|
}
|
|
toHTML(options) {
|
|
var name302 = escape(this.name);
|
|
if (name302 === "true" || name302 === "false") {
|
|
return '<span class="math-symbol math-boolean">' + name302 + "</span>";
|
|
} else if (name302 === "i") {
|
|
return '<span class="math-symbol math-imaginary-symbol">' + name302 + "</span>";
|
|
} else if (name302 === "Infinity") {
|
|
return '<span class="math-symbol math-infinity-symbol">' + name302 + "</span>";
|
|
} else if (name302 === "NaN") {
|
|
return '<span class="math-symbol math-nan-symbol">' + name302 + "</span>";
|
|
} else if (name302 === "null") {
|
|
return '<span class="math-symbol math-null-symbol">' + name302 + "</span>";
|
|
} else if (name302 === "undefined") {
|
|
return '<span class="math-symbol math-undefined-symbol">' + name302 + "</span>";
|
|
}
|
|
return '<span class="math-symbol">' + name302 + "</span>";
|
|
}
|
|
toJSON() {
|
|
return {
|
|
mathjs: "SymbolNode",
|
|
name: this.name
|
|
};
|
|
}
|
|
static fromJSON(json) {
|
|
return new SymbolNode2(json.name);
|
|
}
|
|
_toTex(options) {
|
|
var isUnit2 = false;
|
|
if (typeof math2[this.name] === "undefined" && isValuelessUnit(this.name)) {
|
|
isUnit2 = true;
|
|
}
|
|
var symbol = toSymbol(this.name, isUnit2);
|
|
if (symbol[0] === "\\") {
|
|
return symbol;
|
|
}
|
|
return " " + symbol;
|
|
}
|
|
}
|
|
return SymbolNode2;
|
|
}, {
|
|
isClass: true,
|
|
isNode: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/utils/scope.js
|
|
function createSubScope(parentScope) {
|
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
args[_key - 1] = arguments[_key];
|
|
}
|
|
if (typeof parentScope.createSubScope === "function") {
|
|
return assign(parentScope.createSubScope(), ...args);
|
|
}
|
|
return assign(createEmptyMap(), parentScope, ...args);
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/expression/node/FunctionNode.js
|
|
var name218 = "FunctionNode";
|
|
var dependencies218 = ["math", "Node", "SymbolNode"];
|
|
var createFunctionNode = /* @__PURE__ */ factory(name218, dependencies218, (_ref) => {
|
|
var {
|
|
math: math2,
|
|
Node: Node2,
|
|
SymbolNode: SymbolNode2
|
|
} = _ref;
|
|
var strin = (entity) => format3(entity, {
|
|
truncate: 78
|
|
});
|
|
function expandTemplate(template, node, options) {
|
|
var latex = "";
|
|
var regex = /\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi;
|
|
var inputPos = 0;
|
|
var match;
|
|
while ((match = regex.exec(template)) !== null) {
|
|
latex += template.substring(inputPos, match.index);
|
|
inputPos = match.index;
|
|
if (match[0] === "$$") {
|
|
latex += "$";
|
|
inputPos++;
|
|
} else {
|
|
inputPos += match[0].length;
|
|
var property = node[match[1]];
|
|
if (!property) {
|
|
throw new ReferenceError("Template: Property " + match[1] + " does not exist.");
|
|
}
|
|
if (match[2] === void 0) {
|
|
switch (typeof property) {
|
|
case "string":
|
|
latex += property;
|
|
break;
|
|
case "object":
|
|
if (isNode(property)) {
|
|
latex += property.toTex(options);
|
|
} else if (Array.isArray(property)) {
|
|
latex += property.map(function(arg2, index2) {
|
|
if (isNode(arg2)) {
|
|
return arg2.toTex(options);
|
|
}
|
|
throw new TypeError("Template: " + match[1] + "[" + index2 + "] is not a Node.");
|
|
}).join(",");
|
|
} else {
|
|
throw new TypeError("Template: " + match[1] + " has to be a Node, String or array of Nodes");
|
|
}
|
|
break;
|
|
default:
|
|
throw new TypeError("Template: " + match[1] + " has to be a Node, String or array of Nodes");
|
|
}
|
|
} else {
|
|
if (isNode(property[match[2]] && property[match[2]])) {
|
|
latex += property[match[2]].toTex(options);
|
|
} else {
|
|
throw new TypeError("Template: " + match[1] + "[" + match[2] + "] is not a Node.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
latex += template.slice(inputPos);
|
|
return latex;
|
|
}
|
|
class FunctionNode2 extends Node2 {
|
|
constructor(fn, args) {
|
|
super();
|
|
if (typeof fn === "string") {
|
|
fn = new SymbolNode2(fn);
|
|
}
|
|
if (!isNode(fn))
|
|
throw new TypeError('Node expected as parameter "fn"');
|
|
if (!Array.isArray(args) || !args.every(isNode)) {
|
|
throw new TypeError('Array containing Nodes expected for parameter "args"');
|
|
}
|
|
this.fn = fn;
|
|
this.args = args || [];
|
|
}
|
|
get name() {
|
|
return this.fn.name || "";
|
|
}
|
|
get type() {
|
|
return name218;
|
|
}
|
|
get isFunctionNode() {
|
|
return true;
|
|
}
|
|
_compile(math3, argNames) {
|
|
var evalArgs = this.args.map((arg2) => arg2._compile(math3, argNames));
|
|
if (isSymbolNode(this.fn)) {
|
|
var _name = this.fn.name;
|
|
if (!argNames[_name]) {
|
|
var fn = _name in math3 ? getSafeProperty(math3, _name) : void 0;
|
|
var isRaw = typeof fn === "function" && fn.rawArgs === true;
|
|
var resolveFn = (scope) => {
|
|
var value;
|
|
if (scope.has(_name)) {
|
|
value = scope.get(_name);
|
|
} else if (_name in math3) {
|
|
value = getSafeProperty(math3, _name);
|
|
} else {
|
|
return FunctionNode2.onUndefinedFunction(_name);
|
|
}
|
|
if (typeof value === "function") {
|
|
return value;
|
|
}
|
|
throw new TypeError("'".concat(_name, "' is not a function; its value is:\n ").concat(strin(value)));
|
|
};
|
|
if (isRaw) {
|
|
var rawArgs = this.args;
|
|
return function evalFunctionNode(scope, args, context) {
|
|
var fn2 = resolveFn(scope);
|
|
return fn2(rawArgs, math3, createSubScope(scope, args), scope);
|
|
};
|
|
} else {
|
|
switch (evalArgs.length) {
|
|
case 0:
|
|
return function evalFunctionNode(scope, args, context) {
|
|
var fn2 = resolveFn(scope);
|
|
return fn2();
|
|
};
|
|
case 1:
|
|
return function evalFunctionNode(scope, args, context) {
|
|
var fn2 = resolveFn(scope);
|
|
var evalArg0 = evalArgs[0];
|
|
return fn2(evalArg0(scope, args, context));
|
|
};
|
|
case 2:
|
|
return function evalFunctionNode(scope, args, context) {
|
|
var fn2 = resolveFn(scope);
|
|
var evalArg0 = evalArgs[0];
|
|
var evalArg1 = evalArgs[1];
|
|
return fn2(evalArg0(scope, args, context), evalArg1(scope, args, context));
|
|
};
|
|
default:
|
|
return function evalFunctionNode(scope, args, context) {
|
|
var fn2 = resolveFn(scope);
|
|
var values = evalArgs.map((evalArg) => evalArg(scope, args, context));
|
|
return fn2(...values);
|
|
};
|
|
}
|
|
}
|
|
} else {
|
|
var _rawArgs = this.args;
|
|
return function evalFunctionNode(scope, args, context) {
|
|
var fn2 = args[_name];
|
|
if (typeof fn2 !== "function") {
|
|
throw new TypeError("Argument '".concat(_name, "' was not a function; received: ").concat(strin(fn2)));
|
|
}
|
|
if (fn2.rawArgs) {
|
|
return fn2(_rawArgs, math3, createSubScope(scope, args), scope);
|
|
} else {
|
|
var values = evalArgs.map((evalArg) => evalArg(scope, args, context));
|
|
return fn2.apply(fn2, values);
|
|
}
|
|
};
|
|
}
|
|
} else if (isAccessorNode(this.fn) && isIndexNode(this.fn.index) && this.fn.index.isObjectProperty()) {
|
|
var evalObject = this.fn.object._compile(math3, argNames);
|
|
var prop = this.fn.index.getObjectProperty();
|
|
var _rawArgs2 = this.args;
|
|
return function evalFunctionNode(scope, args, context) {
|
|
var object = evalObject(scope, args, context);
|
|
validateSafeMethod(object, prop);
|
|
var isRaw2 = object[prop] && object[prop].rawArgs;
|
|
if (isRaw2) {
|
|
return object[prop](_rawArgs2, math3, createSubScope(scope, args), scope);
|
|
} else {
|
|
var values = evalArgs.map((evalArg) => evalArg(scope, args, context));
|
|
return object[prop].apply(object, values);
|
|
}
|
|
};
|
|
} else {
|
|
var fnExpr = this.fn.toString();
|
|
var evalFn = this.fn._compile(math3, argNames);
|
|
var _rawArgs3 = this.args;
|
|
return function evalFunctionNode(scope, args, context) {
|
|
var fn2 = evalFn(scope, args, context);
|
|
if (typeof fn2 !== "function") {
|
|
throw new TypeError("Expression '".concat(fnExpr, "' did not evaluate to a function; value is:") + "\n ".concat(strin(fn2)));
|
|
}
|
|
if (fn2.rawArgs) {
|
|
return fn2(_rawArgs3, math3, createSubScope(scope, args), scope);
|
|
} else {
|
|
var values = evalArgs.map((evalArg) => evalArg(scope, args, context));
|
|
return fn2.apply(fn2, values);
|
|
}
|
|
};
|
|
}
|
|
}
|
|
forEach(callback) {
|
|
callback(this.fn, "fn", this);
|
|
for (var i2 = 0; i2 < this.args.length; i2++) {
|
|
callback(this.args[i2], "args[" + i2 + "]", this);
|
|
}
|
|
}
|
|
map(callback) {
|
|
var fn = this._ifNode(callback(this.fn, "fn", this));
|
|
var args = [];
|
|
for (var i2 = 0; i2 < this.args.length; i2++) {
|
|
args[i2] = this._ifNode(callback(this.args[i2], "args[" + i2 + "]", this));
|
|
}
|
|
return new FunctionNode2(fn, args);
|
|
}
|
|
clone() {
|
|
return new FunctionNode2(this.fn, this.args.slice(0));
|
|
}
|
|
toString(options) {
|
|
var customString;
|
|
var name302 = this.fn.toString(options);
|
|
if (options && typeof options.handler === "object" && hasOwnProperty2(options.handler, name302)) {
|
|
customString = options.handler[name302](this, options);
|
|
}
|
|
if (typeof customString !== "undefined") {
|
|
return customString;
|
|
}
|
|
return super.toString(options);
|
|
}
|
|
_toString(options) {
|
|
var args = this.args.map(function(arg2) {
|
|
return arg2.toString(options);
|
|
});
|
|
var fn = isFunctionAssignmentNode(this.fn) ? "(" + this.fn.toString(options) + ")" : this.fn.toString(options);
|
|
return fn + "(" + args.join(", ") + ")";
|
|
}
|
|
toJSON() {
|
|
return {
|
|
mathjs: name218,
|
|
fn: this.fn,
|
|
args: this.args
|
|
};
|
|
}
|
|
toHTML(options) {
|
|
var args = this.args.map(function(arg2) {
|
|
return arg2.toHTML(options);
|
|
});
|
|
return '<span class="math-function">' + escape(this.fn) + '</span><span class="math-paranthesis math-round-parenthesis">(</span>' + args.join('<span class="math-separator">,</span>') + '<span class="math-paranthesis math-round-parenthesis">)</span>';
|
|
}
|
|
toTex(options) {
|
|
var customTex;
|
|
if (options && typeof options.handler === "object" && hasOwnProperty2(options.handler, this.name)) {
|
|
customTex = options.handler[this.name](this, options);
|
|
}
|
|
if (typeof customTex !== "undefined") {
|
|
return customTex;
|
|
}
|
|
return super.toTex(options);
|
|
}
|
|
_toTex(options) {
|
|
var args = this.args.map(function(arg2) {
|
|
return arg2.toTex(options);
|
|
});
|
|
var latexConverter;
|
|
if (latexFunctions[this.name]) {
|
|
latexConverter = latexFunctions[this.name];
|
|
}
|
|
if (math2[this.name] && (typeof math2[this.name].toTex === "function" || typeof math2[this.name].toTex === "object" || typeof math2[this.name].toTex === "string")) {
|
|
latexConverter = math2[this.name].toTex;
|
|
}
|
|
var customToTex;
|
|
switch (typeof latexConverter) {
|
|
case "function":
|
|
customToTex = latexConverter(this, options);
|
|
break;
|
|
case "string":
|
|
customToTex = expandTemplate(latexConverter, this, options);
|
|
break;
|
|
case "object":
|
|
switch (typeof latexConverter[args.length]) {
|
|
case "function":
|
|
customToTex = latexConverter[args.length](this, options);
|
|
break;
|
|
case "string":
|
|
customToTex = expandTemplate(latexConverter[args.length], this, options);
|
|
break;
|
|
}
|
|
}
|
|
if (typeof customToTex !== "undefined") {
|
|
return customToTex;
|
|
}
|
|
return expandTemplate(defaultTemplate, this, options);
|
|
}
|
|
getIdentifier() {
|
|
return this.type + ":" + this.name;
|
|
}
|
|
}
|
|
_defineProperty(FunctionNode2, "name", name218);
|
|
_defineProperty(FunctionNode2, "onUndefinedFunction", function(name302) {
|
|
throw new Error("Undefined function " + name302);
|
|
});
|
|
_defineProperty(FunctionNode2, "fromJSON", function(json) {
|
|
return new FunctionNode2(json.fn, json.args);
|
|
});
|
|
return FunctionNode2;
|
|
}, {
|
|
isClass: true,
|
|
isNode: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/parse.js
|
|
var name219 = "parse";
|
|
var dependencies219 = ["typed", "numeric", "config", "AccessorNode", "ArrayNode", "AssignmentNode", "BlockNode", "ConditionalNode", "ConstantNode", "FunctionAssignmentNode", "FunctionNode", "IndexNode", "ObjectNode", "OperatorNode", "ParenthesisNode", "RangeNode", "RelationalNode", "SymbolNode"];
|
|
var createParse = /* @__PURE__ */ factory(name219, dependencies219, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
numeric: numeric3,
|
|
config: config4,
|
|
AccessorNode: AccessorNode2,
|
|
ArrayNode: ArrayNode2,
|
|
AssignmentNode: AssignmentNode2,
|
|
BlockNode: BlockNode2,
|
|
ConditionalNode: ConditionalNode2,
|
|
ConstantNode: ConstantNode2,
|
|
FunctionAssignmentNode: FunctionAssignmentNode2,
|
|
FunctionNode: FunctionNode2,
|
|
IndexNode: IndexNode2,
|
|
ObjectNode: ObjectNode2,
|
|
OperatorNode: OperatorNode2,
|
|
ParenthesisNode: ParenthesisNode2,
|
|
RangeNode: RangeNode2,
|
|
RelationalNode: RelationalNode2,
|
|
SymbolNode: SymbolNode2
|
|
} = _ref;
|
|
var parse2 = typed2(name219, {
|
|
string: function string2(expression) {
|
|
return parseStart(expression, {});
|
|
},
|
|
"Array | Matrix": function ArrayMatrix(expressions) {
|
|
return parseMultiple(expressions, {});
|
|
},
|
|
"string, Object": function stringObject(expression, options) {
|
|
var extraNodes = options.nodes !== void 0 ? options.nodes : {};
|
|
return parseStart(expression, extraNodes);
|
|
},
|
|
"Array | Matrix, Object": parseMultiple
|
|
});
|
|
function parseMultiple(expressions) {
|
|
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
var extraNodes = options.nodes !== void 0 ? options.nodes : {};
|
|
return deepMap(expressions, function(elem) {
|
|
if (typeof elem !== "string")
|
|
throw new TypeError("String expected");
|
|
return parseStart(elem, extraNodes);
|
|
});
|
|
}
|
|
var TOKENTYPE = {
|
|
NULL: 0,
|
|
DELIMITER: 1,
|
|
NUMBER: 2,
|
|
SYMBOL: 3,
|
|
UNKNOWN: 4
|
|
};
|
|
var DELIMITERS = {
|
|
",": true,
|
|
"(": true,
|
|
")": true,
|
|
"[": true,
|
|
"]": true,
|
|
"{": true,
|
|
"}": true,
|
|
'"': true,
|
|
"'": true,
|
|
";": true,
|
|
"+": true,
|
|
"-": true,
|
|
"*": true,
|
|
".*": true,
|
|
"/": true,
|
|
"./": true,
|
|
"%": true,
|
|
"^": true,
|
|
".^": true,
|
|
"~": true,
|
|
"!": true,
|
|
"&": true,
|
|
"|": true,
|
|
"^|": true,
|
|
"=": true,
|
|
":": true,
|
|
"?": true,
|
|
"==": true,
|
|
"!=": true,
|
|
"<": true,
|
|
">": true,
|
|
"<=": true,
|
|
">=": true,
|
|
"<<": true,
|
|
">>": true,
|
|
">>>": true
|
|
};
|
|
var NAMED_DELIMITERS = {
|
|
mod: true,
|
|
to: true,
|
|
in: true,
|
|
and: true,
|
|
xor: true,
|
|
or: true,
|
|
not: true
|
|
};
|
|
var CONSTANTS = {
|
|
true: true,
|
|
false: false,
|
|
null: null,
|
|
undefined: void 0
|
|
};
|
|
var NUMERIC_CONSTANTS = ["NaN", "Infinity"];
|
|
function initialState() {
|
|
return {
|
|
extraNodes: {},
|
|
expression: "",
|
|
comment: "",
|
|
index: 0,
|
|
token: "",
|
|
tokenType: TOKENTYPE.NULL,
|
|
nestingLevel: 0,
|
|
conditionalLevel: null
|
|
};
|
|
}
|
|
function currentString(state, length) {
|
|
return state.expression.substr(state.index, length);
|
|
}
|
|
function currentCharacter(state) {
|
|
return currentString(state, 1);
|
|
}
|
|
function next(state) {
|
|
state.index++;
|
|
}
|
|
function prevCharacter(state) {
|
|
return state.expression.charAt(state.index - 1);
|
|
}
|
|
function nextCharacter(state) {
|
|
return state.expression.charAt(state.index + 1);
|
|
}
|
|
function getToken(state) {
|
|
state.tokenType = TOKENTYPE.NULL;
|
|
state.token = "";
|
|
state.comment = "";
|
|
while (true) {
|
|
if (currentCharacter(state) === "#") {
|
|
while (currentCharacter(state) !== "\n" && currentCharacter(state) !== "") {
|
|
state.comment += currentCharacter(state);
|
|
next(state);
|
|
}
|
|
}
|
|
if (parse2.isWhitespace(currentCharacter(state), state.nestingLevel)) {
|
|
next(state);
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
if (currentCharacter(state) === "") {
|
|
state.tokenType = TOKENTYPE.DELIMITER;
|
|
return;
|
|
}
|
|
if (currentCharacter(state) === "\n" && !state.nestingLevel) {
|
|
state.tokenType = TOKENTYPE.DELIMITER;
|
|
state.token = currentCharacter(state);
|
|
next(state);
|
|
return;
|
|
}
|
|
var c1 = currentCharacter(state);
|
|
var c2 = currentString(state, 2);
|
|
var c3 = currentString(state, 3);
|
|
if (c3.length === 3 && DELIMITERS[c3]) {
|
|
state.tokenType = TOKENTYPE.DELIMITER;
|
|
state.token = c3;
|
|
next(state);
|
|
next(state);
|
|
next(state);
|
|
return;
|
|
}
|
|
if (c2.length === 2 && DELIMITERS[c2]) {
|
|
state.tokenType = TOKENTYPE.DELIMITER;
|
|
state.token = c2;
|
|
next(state);
|
|
next(state);
|
|
return;
|
|
}
|
|
if (DELIMITERS[c1]) {
|
|
state.tokenType = TOKENTYPE.DELIMITER;
|
|
state.token = c1;
|
|
next(state);
|
|
return;
|
|
}
|
|
if (parse2.isDigitDot(c1)) {
|
|
state.tokenType = TOKENTYPE.NUMBER;
|
|
var _c = currentString(state, 2);
|
|
if (_c === "0b" || _c === "0o" || _c === "0x") {
|
|
state.token += currentCharacter(state);
|
|
next(state);
|
|
state.token += currentCharacter(state);
|
|
next(state);
|
|
while (parse2.isHexDigit(currentCharacter(state))) {
|
|
state.token += currentCharacter(state);
|
|
next(state);
|
|
}
|
|
if (currentCharacter(state) === ".") {
|
|
state.token += ".";
|
|
next(state);
|
|
while (parse2.isHexDigit(currentCharacter(state))) {
|
|
state.token += currentCharacter(state);
|
|
next(state);
|
|
}
|
|
} else if (currentCharacter(state) === "i") {
|
|
state.token += "i";
|
|
next(state);
|
|
while (parse2.isDigit(currentCharacter(state))) {
|
|
state.token += currentCharacter(state);
|
|
next(state);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
if (currentCharacter(state) === ".") {
|
|
state.token += currentCharacter(state);
|
|
next(state);
|
|
if (!parse2.isDigit(currentCharacter(state))) {
|
|
state.tokenType = TOKENTYPE.DELIMITER;
|
|
return;
|
|
}
|
|
} else {
|
|
while (parse2.isDigit(currentCharacter(state))) {
|
|
state.token += currentCharacter(state);
|
|
next(state);
|
|
}
|
|
if (parse2.isDecimalMark(currentCharacter(state), nextCharacter(state))) {
|
|
state.token += currentCharacter(state);
|
|
next(state);
|
|
}
|
|
}
|
|
while (parse2.isDigit(currentCharacter(state))) {
|
|
state.token += currentCharacter(state);
|
|
next(state);
|
|
}
|
|
if (currentCharacter(state) === "E" || currentCharacter(state) === "e") {
|
|
if (parse2.isDigit(nextCharacter(state)) || nextCharacter(state) === "-" || nextCharacter(state) === "+") {
|
|
state.token += currentCharacter(state);
|
|
next(state);
|
|
if (currentCharacter(state) === "+" || currentCharacter(state) === "-") {
|
|
state.token += currentCharacter(state);
|
|
next(state);
|
|
}
|
|
if (!parse2.isDigit(currentCharacter(state))) {
|
|
throw createSyntaxError(state, 'Digit expected, got "' + currentCharacter(state) + '"');
|
|
}
|
|
while (parse2.isDigit(currentCharacter(state))) {
|
|
state.token += currentCharacter(state);
|
|
next(state);
|
|
}
|
|
if (parse2.isDecimalMark(currentCharacter(state), nextCharacter(state))) {
|
|
throw createSyntaxError(state, 'Digit expected, got "' + currentCharacter(state) + '"');
|
|
}
|
|
} else if (nextCharacter(state) === ".") {
|
|
next(state);
|
|
throw createSyntaxError(state, 'Digit expected, got "' + currentCharacter(state) + '"');
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
if (parse2.isAlpha(currentCharacter(state), prevCharacter(state), nextCharacter(state))) {
|
|
while (parse2.isAlpha(currentCharacter(state), prevCharacter(state), nextCharacter(state)) || parse2.isDigit(currentCharacter(state))) {
|
|
state.token += currentCharacter(state);
|
|
next(state);
|
|
}
|
|
if (hasOwnProperty2(NAMED_DELIMITERS, state.token)) {
|
|
state.tokenType = TOKENTYPE.DELIMITER;
|
|
} else {
|
|
state.tokenType = TOKENTYPE.SYMBOL;
|
|
}
|
|
return;
|
|
}
|
|
state.tokenType = TOKENTYPE.UNKNOWN;
|
|
while (currentCharacter(state) !== "") {
|
|
state.token += currentCharacter(state);
|
|
next(state);
|
|
}
|
|
throw createSyntaxError(state, 'Syntax error in part "' + state.token + '"');
|
|
}
|
|
function getTokenSkipNewline(state) {
|
|
do {
|
|
getToken(state);
|
|
} while (state.token === "\n");
|
|
}
|
|
function openParams(state) {
|
|
state.nestingLevel++;
|
|
}
|
|
function closeParams(state) {
|
|
state.nestingLevel--;
|
|
}
|
|
parse2.isAlpha = function isAlpha(c, cPrev, cNext) {
|
|
return parse2.isValidLatinOrGreek(c) || parse2.isValidMathSymbol(c, cNext) || parse2.isValidMathSymbol(cPrev, c);
|
|
};
|
|
parse2.isValidLatinOrGreek = function isValidLatinOrGreek(c) {
|
|
return /^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(c);
|
|
};
|
|
parse2.isValidMathSymbol = function isValidMathSymbol(high, low) {
|
|
return /^[\uD835]$/.test(high) && /^[\uDC00-\uDFFF]$/.test(low) && /^[^\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDFCC\uDFCD]$/.test(low);
|
|
};
|
|
parse2.isWhitespace = function isWhitespace(c, nestingLevel) {
|
|
return c === " " || c === " " || c === "\n" && nestingLevel > 0;
|
|
};
|
|
parse2.isDecimalMark = function isDecimalMark(c, cNext) {
|
|
return c === "." && cNext !== "/" && cNext !== "*" && cNext !== "^";
|
|
};
|
|
parse2.isDigitDot = function isDigitDot(c) {
|
|
return c >= "0" && c <= "9" || c === ".";
|
|
};
|
|
parse2.isDigit = function isDigit(c) {
|
|
return c >= "0" && c <= "9";
|
|
};
|
|
parse2.isHexDigit = function isHexDigit(c) {
|
|
return c >= "0" && c <= "9" || c >= "a" && c <= "f" || c >= "A" && c <= "F";
|
|
};
|
|
function parseStart(expression, extraNodes) {
|
|
var state = initialState();
|
|
_extends(state, {
|
|
expression,
|
|
extraNodes
|
|
});
|
|
getToken(state);
|
|
var node = parseBlock(state);
|
|
if (state.token !== "") {
|
|
if (state.tokenType === TOKENTYPE.DELIMITER) {
|
|
throw createError(state, "Unexpected operator " + state.token);
|
|
} else {
|
|
throw createSyntaxError(state, 'Unexpected part "' + state.token + '"');
|
|
}
|
|
}
|
|
return node;
|
|
}
|
|
function parseBlock(state) {
|
|
var node;
|
|
var blocks = [];
|
|
var visible;
|
|
if (state.token !== "" && state.token !== "\n" && state.token !== ";") {
|
|
node = parseAssignment(state);
|
|
if (state.comment) {
|
|
node.comment = state.comment;
|
|
}
|
|
}
|
|
while (state.token === "\n" || state.token === ";") {
|
|
if (blocks.length === 0 && node) {
|
|
visible = state.token !== ";";
|
|
blocks.push({
|
|
node,
|
|
visible
|
|
});
|
|
}
|
|
getToken(state);
|
|
if (state.token !== "\n" && state.token !== ";" && state.token !== "") {
|
|
node = parseAssignment(state);
|
|
if (state.comment) {
|
|
node.comment = state.comment;
|
|
}
|
|
visible = state.token !== ";";
|
|
blocks.push({
|
|
node,
|
|
visible
|
|
});
|
|
}
|
|
}
|
|
if (blocks.length > 0) {
|
|
return new BlockNode2(blocks);
|
|
} else {
|
|
if (!node) {
|
|
node = new ConstantNode2(void 0);
|
|
if (state.comment) {
|
|
node.comment = state.comment;
|
|
}
|
|
}
|
|
return node;
|
|
}
|
|
}
|
|
function parseAssignment(state) {
|
|
var name302, args, value, valid;
|
|
var node = parseConditional(state);
|
|
if (state.token === "=") {
|
|
if (isSymbolNode(node)) {
|
|
name302 = node.name;
|
|
getTokenSkipNewline(state);
|
|
value = parseAssignment(state);
|
|
return new AssignmentNode2(new SymbolNode2(name302), value);
|
|
} else if (isAccessorNode(node)) {
|
|
getTokenSkipNewline(state);
|
|
value = parseAssignment(state);
|
|
return new AssignmentNode2(node.object, node.index, value);
|
|
} else if (isFunctionNode(node) && isSymbolNode(node.fn)) {
|
|
valid = true;
|
|
args = [];
|
|
name302 = node.name;
|
|
node.args.forEach(function(arg2, index2) {
|
|
if (isSymbolNode(arg2)) {
|
|
args[index2] = arg2.name;
|
|
} else {
|
|
valid = false;
|
|
}
|
|
});
|
|
if (valid) {
|
|
getTokenSkipNewline(state);
|
|
value = parseAssignment(state);
|
|
return new FunctionAssignmentNode2(name302, args, value);
|
|
}
|
|
}
|
|
throw createSyntaxError(state, "Invalid left hand side of assignment operator =");
|
|
}
|
|
return node;
|
|
}
|
|
function parseConditional(state) {
|
|
var node = parseLogicalOr(state);
|
|
while (state.token === "?") {
|
|
var prev = state.conditionalLevel;
|
|
state.conditionalLevel = state.nestingLevel;
|
|
getTokenSkipNewline(state);
|
|
var condition = node;
|
|
var trueExpr = parseAssignment(state);
|
|
if (state.token !== ":")
|
|
throw createSyntaxError(state, "False part of conditional expression expected");
|
|
state.conditionalLevel = null;
|
|
getTokenSkipNewline(state);
|
|
var falseExpr = parseAssignment(state);
|
|
node = new ConditionalNode2(condition, trueExpr, falseExpr);
|
|
state.conditionalLevel = prev;
|
|
}
|
|
return node;
|
|
}
|
|
function parseLogicalOr(state) {
|
|
var node = parseLogicalXor(state);
|
|
while (state.token === "or") {
|
|
getTokenSkipNewline(state);
|
|
node = new OperatorNode2("or", "or", [node, parseLogicalXor(state)]);
|
|
}
|
|
return node;
|
|
}
|
|
function parseLogicalXor(state) {
|
|
var node = parseLogicalAnd(state);
|
|
while (state.token === "xor") {
|
|
getTokenSkipNewline(state);
|
|
node = new OperatorNode2("xor", "xor", [node, parseLogicalAnd(state)]);
|
|
}
|
|
return node;
|
|
}
|
|
function parseLogicalAnd(state) {
|
|
var node = parseBitwiseOr(state);
|
|
while (state.token === "and") {
|
|
getTokenSkipNewline(state);
|
|
node = new OperatorNode2("and", "and", [node, parseBitwiseOr(state)]);
|
|
}
|
|
return node;
|
|
}
|
|
function parseBitwiseOr(state) {
|
|
var node = parseBitwiseXor(state);
|
|
while (state.token === "|") {
|
|
getTokenSkipNewline(state);
|
|
node = new OperatorNode2("|", "bitOr", [node, parseBitwiseXor(state)]);
|
|
}
|
|
return node;
|
|
}
|
|
function parseBitwiseXor(state) {
|
|
var node = parseBitwiseAnd(state);
|
|
while (state.token === "^|") {
|
|
getTokenSkipNewline(state);
|
|
node = new OperatorNode2("^|", "bitXor", [node, parseBitwiseAnd(state)]);
|
|
}
|
|
return node;
|
|
}
|
|
function parseBitwiseAnd(state) {
|
|
var node = parseRelational(state);
|
|
while (state.token === "&") {
|
|
getTokenSkipNewline(state);
|
|
node = new OperatorNode2("&", "bitAnd", [node, parseRelational(state)]);
|
|
}
|
|
return node;
|
|
}
|
|
function parseRelational(state) {
|
|
var params = [parseShift(state)];
|
|
var conditionals = [];
|
|
var operators = {
|
|
"==": "equal",
|
|
"!=": "unequal",
|
|
"<": "smaller",
|
|
">": "larger",
|
|
"<=": "smallerEq",
|
|
">=": "largerEq"
|
|
};
|
|
while (hasOwnProperty2(operators, state.token)) {
|
|
var cond = {
|
|
name: state.token,
|
|
fn: operators[state.token]
|
|
};
|
|
conditionals.push(cond);
|
|
getTokenSkipNewline(state);
|
|
params.push(parseShift(state));
|
|
}
|
|
if (params.length === 1) {
|
|
return params[0];
|
|
} else if (params.length === 2) {
|
|
return new OperatorNode2(conditionals[0].name, conditionals[0].fn, params);
|
|
} else {
|
|
return new RelationalNode2(conditionals.map((c) => c.fn), params);
|
|
}
|
|
}
|
|
function parseShift(state) {
|
|
var node, name302, fn, params;
|
|
node = parseConversion(state);
|
|
var operators = {
|
|
"<<": "leftShift",
|
|
">>": "rightArithShift",
|
|
">>>": "rightLogShift"
|
|
};
|
|
while (hasOwnProperty2(operators, state.token)) {
|
|
name302 = state.token;
|
|
fn = operators[name302];
|
|
getTokenSkipNewline(state);
|
|
params = [node, parseConversion(state)];
|
|
node = new OperatorNode2(name302, fn, params);
|
|
}
|
|
return node;
|
|
}
|
|
function parseConversion(state) {
|
|
var node, name302, fn, params;
|
|
node = parseRange(state);
|
|
var operators = {
|
|
to: "to",
|
|
in: "to"
|
|
};
|
|
while (hasOwnProperty2(operators, state.token)) {
|
|
name302 = state.token;
|
|
fn = operators[name302];
|
|
getTokenSkipNewline(state);
|
|
if (name302 === "in" && state.token === "") {
|
|
node = new OperatorNode2("*", "multiply", [node, new SymbolNode2("in")], true);
|
|
} else {
|
|
params = [node, parseRange(state)];
|
|
node = new OperatorNode2(name302, fn, params);
|
|
}
|
|
}
|
|
return node;
|
|
}
|
|
function parseRange(state) {
|
|
var node;
|
|
var params = [];
|
|
if (state.token === ":") {
|
|
node = new ConstantNode2(1);
|
|
} else {
|
|
node = parseAddSubtract(state);
|
|
}
|
|
if (state.token === ":" && state.conditionalLevel !== state.nestingLevel) {
|
|
params.push(node);
|
|
while (state.token === ":" && params.length < 3) {
|
|
getTokenSkipNewline(state);
|
|
if (state.token === ")" || state.token === "]" || state.token === "," || state.token === "") {
|
|
params.push(new SymbolNode2("end"));
|
|
} else {
|
|
params.push(parseAddSubtract(state));
|
|
}
|
|
}
|
|
if (params.length === 3) {
|
|
node = new RangeNode2(params[0], params[2], params[1]);
|
|
} else {
|
|
node = new RangeNode2(params[0], params[1]);
|
|
}
|
|
}
|
|
return node;
|
|
}
|
|
function parseAddSubtract(state) {
|
|
var node, name302, fn, params;
|
|
node = parseMultiplyDivide(state);
|
|
var operators = {
|
|
"+": "add",
|
|
"-": "subtract"
|
|
};
|
|
while (hasOwnProperty2(operators, state.token)) {
|
|
name302 = state.token;
|
|
fn = operators[name302];
|
|
getTokenSkipNewline(state);
|
|
var rightNode = parseMultiplyDivide(state);
|
|
if (rightNode.isPercentage) {
|
|
params = [node, new OperatorNode2("*", "multiply", [node, rightNode])];
|
|
} else {
|
|
params = [node, rightNode];
|
|
}
|
|
node = new OperatorNode2(name302, fn, params);
|
|
}
|
|
return node;
|
|
}
|
|
function parseMultiplyDivide(state) {
|
|
var node, last, name302, fn;
|
|
node = parseImplicitMultiplication(state);
|
|
last = node;
|
|
var operators = {
|
|
"*": "multiply",
|
|
".*": "dotMultiply",
|
|
"/": "divide",
|
|
"./": "dotDivide"
|
|
};
|
|
while (true) {
|
|
if (hasOwnProperty2(operators, state.token)) {
|
|
name302 = state.token;
|
|
fn = operators[name302];
|
|
getTokenSkipNewline(state);
|
|
last = parseImplicitMultiplication(state);
|
|
node = new OperatorNode2(name302, fn, [node, last]);
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
return node;
|
|
}
|
|
function parseImplicitMultiplication(state) {
|
|
var node, last;
|
|
node = parseRule2(state);
|
|
last = node;
|
|
while (true) {
|
|
if (state.tokenType === TOKENTYPE.SYMBOL || state.token === "in" && isConstantNode(node) || state.tokenType === TOKENTYPE.NUMBER && !isConstantNode(last) && (!isOperatorNode(last) || last.op === "!") || state.token === "(") {
|
|
last = parseRule2(state);
|
|
node = new OperatorNode2("*", "multiply", [node, last], true);
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
return node;
|
|
}
|
|
function parseRule2(state) {
|
|
var node = parsePercentage(state);
|
|
var last = node;
|
|
var tokenStates = [];
|
|
while (true) {
|
|
if (state.token === "/" && rule2Node(last)) {
|
|
tokenStates.push(_extends({}, state));
|
|
getTokenSkipNewline(state);
|
|
if (state.tokenType === TOKENTYPE.NUMBER) {
|
|
tokenStates.push(_extends({}, state));
|
|
getTokenSkipNewline(state);
|
|
if (state.tokenType === TOKENTYPE.SYMBOL || state.token === "(") {
|
|
_extends(state, tokenStates.pop());
|
|
tokenStates.pop();
|
|
last = parsePercentage(state);
|
|
node = new OperatorNode2("/", "divide", [node, last]);
|
|
} else {
|
|
tokenStates.pop();
|
|
_extends(state, tokenStates.pop());
|
|
break;
|
|
}
|
|
} else {
|
|
_extends(state, tokenStates.pop());
|
|
break;
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
return node;
|
|
}
|
|
function parsePercentage(state) {
|
|
var node, name302, fn, params;
|
|
node = parseUnary(state);
|
|
var operators = {
|
|
"%": "mod",
|
|
mod: "mod"
|
|
};
|
|
while (hasOwnProperty2(operators, state.token)) {
|
|
name302 = state.token;
|
|
fn = operators[name302];
|
|
getTokenSkipNewline(state);
|
|
if (name302 === "%" && state.tokenType === TOKENTYPE.DELIMITER && state.token !== "(") {
|
|
node = new OperatorNode2("/", "divide", [node, new ConstantNode2(100)], false, true);
|
|
} else {
|
|
params = [node, parseUnary(state)];
|
|
node = new OperatorNode2(name302, fn, params);
|
|
}
|
|
}
|
|
return node;
|
|
}
|
|
function parseUnary(state) {
|
|
var name302, params, fn;
|
|
var operators = {
|
|
"-": "unaryMinus",
|
|
"+": "unaryPlus",
|
|
"~": "bitNot",
|
|
not: "not"
|
|
};
|
|
if (hasOwnProperty2(operators, state.token)) {
|
|
fn = operators[state.token];
|
|
name302 = state.token;
|
|
getTokenSkipNewline(state);
|
|
params = [parseUnary(state)];
|
|
return new OperatorNode2(name302, fn, params);
|
|
}
|
|
return parsePow(state);
|
|
}
|
|
function parsePow(state) {
|
|
var node, name302, fn, params;
|
|
node = parseLeftHandOperators(state);
|
|
if (state.token === "^" || state.token === ".^") {
|
|
name302 = state.token;
|
|
fn = name302 === "^" ? "pow" : "dotPow";
|
|
getTokenSkipNewline(state);
|
|
params = [node, parseUnary(state)];
|
|
node = new OperatorNode2(name302, fn, params);
|
|
}
|
|
return node;
|
|
}
|
|
function parseLeftHandOperators(state) {
|
|
var node, name302, fn, params;
|
|
node = parseCustomNodes(state);
|
|
var operators = {
|
|
"!": "factorial",
|
|
"'": "ctranspose"
|
|
};
|
|
while (hasOwnProperty2(operators, state.token)) {
|
|
name302 = state.token;
|
|
fn = operators[name302];
|
|
getToken(state);
|
|
params = [node];
|
|
node = new OperatorNode2(name302, fn, params);
|
|
node = parseAccessors(state, node);
|
|
}
|
|
return node;
|
|
}
|
|
function parseCustomNodes(state) {
|
|
var params = [];
|
|
if (state.tokenType === TOKENTYPE.SYMBOL && hasOwnProperty2(state.extraNodes, state.token)) {
|
|
var CustomNode = state.extraNodes[state.token];
|
|
getToken(state);
|
|
if (state.token === "(") {
|
|
params = [];
|
|
openParams(state);
|
|
getToken(state);
|
|
if (state.token !== ")") {
|
|
params.push(parseAssignment(state));
|
|
while (state.token === ",") {
|
|
getToken(state);
|
|
params.push(parseAssignment(state));
|
|
}
|
|
}
|
|
if (state.token !== ")") {
|
|
throw createSyntaxError(state, "Parenthesis ) expected");
|
|
}
|
|
closeParams(state);
|
|
getToken(state);
|
|
}
|
|
return new CustomNode(params);
|
|
}
|
|
return parseSymbol(state);
|
|
}
|
|
function parseSymbol(state) {
|
|
var node, name302;
|
|
if (state.tokenType === TOKENTYPE.SYMBOL || state.tokenType === TOKENTYPE.DELIMITER && state.token in NAMED_DELIMITERS) {
|
|
name302 = state.token;
|
|
getToken(state);
|
|
if (hasOwnProperty2(CONSTANTS, name302)) {
|
|
node = new ConstantNode2(CONSTANTS[name302]);
|
|
} else if (NUMERIC_CONSTANTS.indexOf(name302) !== -1) {
|
|
node = new ConstantNode2(numeric3(name302, "number"));
|
|
} else {
|
|
node = new SymbolNode2(name302);
|
|
}
|
|
node = parseAccessors(state, node);
|
|
return node;
|
|
}
|
|
return parseDoubleQuotesString(state);
|
|
}
|
|
function parseAccessors(state, node, types) {
|
|
var params;
|
|
while ((state.token === "(" || state.token === "[" || state.token === ".") && (!types || types.indexOf(state.token) !== -1)) {
|
|
params = [];
|
|
if (state.token === "(") {
|
|
if (isSymbolNode(node) || isAccessorNode(node)) {
|
|
openParams(state);
|
|
getToken(state);
|
|
if (state.token !== ")") {
|
|
params.push(parseAssignment(state));
|
|
while (state.token === ",") {
|
|
getToken(state);
|
|
params.push(parseAssignment(state));
|
|
}
|
|
}
|
|
if (state.token !== ")") {
|
|
throw createSyntaxError(state, "Parenthesis ) expected");
|
|
}
|
|
closeParams(state);
|
|
getToken(state);
|
|
node = new FunctionNode2(node, params);
|
|
} else {
|
|
return node;
|
|
}
|
|
} else if (state.token === "[") {
|
|
openParams(state);
|
|
getToken(state);
|
|
if (state.token !== "]") {
|
|
params.push(parseAssignment(state));
|
|
while (state.token === ",") {
|
|
getToken(state);
|
|
params.push(parseAssignment(state));
|
|
}
|
|
}
|
|
if (state.token !== "]") {
|
|
throw createSyntaxError(state, "Parenthesis ] expected");
|
|
}
|
|
closeParams(state);
|
|
getToken(state);
|
|
node = new AccessorNode2(node, new IndexNode2(params));
|
|
} else {
|
|
getToken(state);
|
|
if (state.tokenType !== TOKENTYPE.SYMBOL) {
|
|
throw createSyntaxError(state, "Property name expected after dot");
|
|
}
|
|
params.push(new ConstantNode2(state.token));
|
|
getToken(state);
|
|
var dotNotation = true;
|
|
node = new AccessorNode2(node, new IndexNode2(params, dotNotation));
|
|
}
|
|
}
|
|
return node;
|
|
}
|
|
function parseDoubleQuotesString(state) {
|
|
var node, str;
|
|
if (state.token === '"') {
|
|
str = parseDoubleQuotesStringToken(state);
|
|
node = new ConstantNode2(str);
|
|
node = parseAccessors(state, node);
|
|
return node;
|
|
}
|
|
return parseSingleQuotesString(state);
|
|
}
|
|
function parseDoubleQuotesStringToken(state) {
|
|
var str = "";
|
|
while (currentCharacter(state) !== "" && currentCharacter(state) !== '"') {
|
|
if (currentCharacter(state) === "\\") {
|
|
str += currentCharacter(state);
|
|
next(state);
|
|
}
|
|
str += currentCharacter(state);
|
|
next(state);
|
|
}
|
|
getToken(state);
|
|
if (state.token !== '"') {
|
|
throw createSyntaxError(state, 'End of string " expected');
|
|
}
|
|
getToken(state);
|
|
return JSON.parse('"' + str + '"');
|
|
}
|
|
function parseSingleQuotesString(state) {
|
|
var node, str;
|
|
if (state.token === "'") {
|
|
str = parseSingleQuotesStringToken(state);
|
|
node = new ConstantNode2(str);
|
|
node = parseAccessors(state, node);
|
|
return node;
|
|
}
|
|
return parseMatrix(state);
|
|
}
|
|
function parseSingleQuotesStringToken(state) {
|
|
var str = "";
|
|
while (currentCharacter(state) !== "" && currentCharacter(state) !== "'") {
|
|
if (currentCharacter(state) === "\\") {
|
|
str += currentCharacter(state);
|
|
next(state);
|
|
}
|
|
str += currentCharacter(state);
|
|
next(state);
|
|
}
|
|
getToken(state);
|
|
if (state.token !== "'") {
|
|
throw createSyntaxError(state, "End of string ' expected");
|
|
}
|
|
getToken(state);
|
|
return JSON.parse('"' + str + '"');
|
|
}
|
|
function parseMatrix(state) {
|
|
var array, params, rows, cols;
|
|
if (state.token === "[") {
|
|
openParams(state);
|
|
getToken(state);
|
|
if (state.token !== "]") {
|
|
var row2 = parseRow(state);
|
|
if (state.token === ";") {
|
|
rows = 1;
|
|
params = [row2];
|
|
while (state.token === ";") {
|
|
getToken(state);
|
|
params[rows] = parseRow(state);
|
|
rows++;
|
|
}
|
|
if (state.token !== "]") {
|
|
throw createSyntaxError(state, "End of matrix ] expected");
|
|
}
|
|
closeParams(state);
|
|
getToken(state);
|
|
cols = params[0].items.length;
|
|
for (var r = 1; r < rows; r++) {
|
|
if (params[r].items.length !== cols) {
|
|
throw createError(state, "Column dimensions mismatch (" + params[r].items.length + " !== " + cols + ")");
|
|
}
|
|
}
|
|
array = new ArrayNode2(params);
|
|
} else {
|
|
if (state.token !== "]") {
|
|
throw createSyntaxError(state, "End of matrix ] expected");
|
|
}
|
|
closeParams(state);
|
|
getToken(state);
|
|
array = row2;
|
|
}
|
|
} else {
|
|
closeParams(state);
|
|
getToken(state);
|
|
array = new ArrayNode2([]);
|
|
}
|
|
return parseAccessors(state, array);
|
|
}
|
|
return parseObject(state);
|
|
}
|
|
function parseRow(state) {
|
|
var params = [parseAssignment(state)];
|
|
var len = 1;
|
|
while (state.token === ",") {
|
|
getToken(state);
|
|
params[len] = parseAssignment(state);
|
|
len++;
|
|
}
|
|
return new ArrayNode2(params);
|
|
}
|
|
function parseObject(state) {
|
|
if (state.token === "{") {
|
|
openParams(state);
|
|
var key;
|
|
var properties2 = {};
|
|
do {
|
|
getToken(state);
|
|
if (state.token !== "}") {
|
|
if (state.token === '"') {
|
|
key = parseDoubleQuotesStringToken(state);
|
|
} else if (state.token === "'") {
|
|
key = parseSingleQuotesStringToken(state);
|
|
} else if (state.tokenType === TOKENTYPE.SYMBOL || state.tokenType === TOKENTYPE.DELIMITER && state.token in NAMED_DELIMITERS) {
|
|
key = state.token;
|
|
getToken(state);
|
|
} else {
|
|
throw createSyntaxError(state, "Symbol or string expected as object key");
|
|
}
|
|
if (state.token !== ":") {
|
|
throw createSyntaxError(state, "Colon : expected after object key");
|
|
}
|
|
getToken(state);
|
|
properties2[key] = parseAssignment(state);
|
|
}
|
|
} while (state.token === ",");
|
|
if (state.token !== "}") {
|
|
throw createSyntaxError(state, "Comma , or bracket } expected after object value");
|
|
}
|
|
closeParams(state);
|
|
getToken(state);
|
|
var node = new ObjectNode2(properties2);
|
|
node = parseAccessors(state, node);
|
|
return node;
|
|
}
|
|
return parseNumber(state);
|
|
}
|
|
function parseNumber(state) {
|
|
var numberStr;
|
|
if (state.tokenType === TOKENTYPE.NUMBER) {
|
|
numberStr = state.token;
|
|
getToken(state);
|
|
return new ConstantNode2(numeric3(numberStr, config4.number));
|
|
}
|
|
return parseParentheses(state);
|
|
}
|
|
function parseParentheses(state) {
|
|
var node;
|
|
if (state.token === "(") {
|
|
openParams(state);
|
|
getToken(state);
|
|
node = parseAssignment(state);
|
|
if (state.token !== ")") {
|
|
throw createSyntaxError(state, "Parenthesis ) expected");
|
|
}
|
|
closeParams(state);
|
|
getToken(state);
|
|
node = new ParenthesisNode2(node);
|
|
node = parseAccessors(state, node);
|
|
return node;
|
|
}
|
|
return parseEnd(state);
|
|
}
|
|
function parseEnd(state) {
|
|
if (state.token === "") {
|
|
throw createSyntaxError(state, "Unexpected end of expression");
|
|
} else {
|
|
throw createSyntaxError(state, "Value expected");
|
|
}
|
|
}
|
|
function col(state) {
|
|
return state.index - state.token.length + 1;
|
|
}
|
|
function createSyntaxError(state, message) {
|
|
var c = col(state);
|
|
var error = new SyntaxError(message + " (char " + c + ")");
|
|
error.char = c;
|
|
return error;
|
|
}
|
|
function createError(state, message) {
|
|
var c = col(state);
|
|
var error = new SyntaxError(message + " (char " + c + ")");
|
|
error.char = c;
|
|
return error;
|
|
}
|
|
typed2.addConversion({
|
|
from: "string",
|
|
to: "Node",
|
|
convert: parse2
|
|
});
|
|
return parse2;
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/function/compile.js
|
|
var name220 = "compile";
|
|
var dependencies220 = ["typed", "parse"];
|
|
var createCompile = /* @__PURE__ */ factory(name220, dependencies220, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
parse: parse2
|
|
} = _ref;
|
|
return typed2(name220, {
|
|
string: function string2(expr) {
|
|
return parse2(expr).compile();
|
|
},
|
|
"Array | Matrix": function ArrayMatrix(expr) {
|
|
return deepMap(expr, function(entry) {
|
|
return parse2(entry).compile();
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/function/evaluate.js
|
|
var name221 = "evaluate";
|
|
var dependencies221 = ["typed", "parse"];
|
|
var createEvaluate = /* @__PURE__ */ factory(name221, dependencies221, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
parse: parse2
|
|
} = _ref;
|
|
return typed2(name221, {
|
|
string: function string2(expr) {
|
|
var scope = createEmptyMap();
|
|
return parse2(expr).compile().evaluate(scope);
|
|
},
|
|
"string, Map | Object": function stringMapObject(expr, scope) {
|
|
return parse2(expr).compile().evaluate(scope);
|
|
},
|
|
"Array | Matrix": function ArrayMatrix(expr) {
|
|
var scope = createEmptyMap();
|
|
return deepMap(expr, function(entry) {
|
|
return parse2(entry).compile().evaluate(scope);
|
|
});
|
|
},
|
|
"Array | Matrix, Map | Object": function ArrayMatrixMapObject(expr, scope) {
|
|
return deepMap(expr, function(entry) {
|
|
return parse2(entry).compile().evaluate(scope);
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/Parser.js
|
|
var name222 = "Parser";
|
|
var dependencies222 = ["evaluate"];
|
|
var createParserClass = /* @__PURE__ */ factory(name222, dependencies222, (_ref) => {
|
|
var {
|
|
evaluate: evaluate2
|
|
} = _ref;
|
|
function Parser2() {
|
|
if (!(this instanceof Parser2)) {
|
|
throw new SyntaxError("Constructor must be called with the new operator");
|
|
}
|
|
Object.defineProperty(this, "scope", {
|
|
value: createEmptyMap(),
|
|
writable: false
|
|
});
|
|
}
|
|
Parser2.prototype.type = "Parser";
|
|
Parser2.prototype.isParser = true;
|
|
Parser2.prototype.evaluate = function(expr) {
|
|
return evaluate2(expr, this.scope);
|
|
};
|
|
Parser2.prototype.get = function(name302) {
|
|
if (this.scope.has(name302)) {
|
|
return this.scope.get(name302);
|
|
}
|
|
};
|
|
Parser2.prototype.getAll = function() {
|
|
return toObject(this.scope);
|
|
};
|
|
Parser2.prototype.getAllAsMap = function() {
|
|
return this.scope;
|
|
};
|
|
Parser2.prototype.set = function(name302, value) {
|
|
this.scope.set(name302, value);
|
|
return value;
|
|
};
|
|
Parser2.prototype.remove = function(name302) {
|
|
this.scope.delete(name302);
|
|
};
|
|
Parser2.prototype.clear = function() {
|
|
this.scope.clear();
|
|
};
|
|
return Parser2;
|
|
}, {
|
|
isClass: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/function/parser.js
|
|
var name223 = "parser";
|
|
var dependencies223 = ["typed", "Parser"];
|
|
var createParser = /* @__PURE__ */ factory(name223, dependencies223, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
Parser: Parser2
|
|
} = _ref;
|
|
return typed2(name223, {
|
|
"": function _() {
|
|
return new Parser2();
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/decomposition/lup.js
|
|
var name224 = "lup";
|
|
var dependencies224 = ["typed", "matrix", "abs", "addScalar", "divideScalar", "multiplyScalar", "subtract", "larger", "equalScalar", "unaryMinus", "DenseMatrix", "SparseMatrix", "Spa"];
|
|
var createLup = /* @__PURE__ */ factory(name224, dependencies224, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
abs: abs3,
|
|
addScalar: addScalar2,
|
|
divideScalar: divideScalar2,
|
|
multiplyScalar: multiplyScalar2,
|
|
subtract: subtract2,
|
|
larger: larger2,
|
|
equalScalar: equalScalar2,
|
|
unaryMinus: unaryMinus2,
|
|
DenseMatrix: DenseMatrix2,
|
|
SparseMatrix: SparseMatrix2,
|
|
Spa: Spa2
|
|
} = _ref;
|
|
return typed2(name224, {
|
|
DenseMatrix: function DenseMatrix3(m) {
|
|
return _denseLUP(m);
|
|
},
|
|
SparseMatrix: function SparseMatrix3(m) {
|
|
return _sparseLUP(m);
|
|
},
|
|
Array: function Array2(a) {
|
|
var m = matrix2(a);
|
|
var r = _denseLUP(m);
|
|
return {
|
|
L: r.L.valueOf(),
|
|
U: r.U.valueOf(),
|
|
p: r.p
|
|
};
|
|
}
|
|
});
|
|
function _denseLUP(m) {
|
|
var rows = m._size[0];
|
|
var columns = m._size[1];
|
|
var n = Math.min(rows, columns);
|
|
var data = clone(m._data);
|
|
var ldata = [];
|
|
var lsize = [rows, n];
|
|
var udata = [];
|
|
var usize = [n, columns];
|
|
var i2, j, k;
|
|
var p = [];
|
|
for (i2 = 0; i2 < rows; i2++) {
|
|
p[i2] = i2;
|
|
}
|
|
for (j = 0; j < columns; j++) {
|
|
if (j > 0) {
|
|
for (i2 = 0; i2 < rows; i2++) {
|
|
var min3 = Math.min(i2, j);
|
|
var s = 0;
|
|
for (k = 0; k < min3; k++) {
|
|
s = addScalar2(s, multiplyScalar2(data[i2][k], data[k][j]));
|
|
}
|
|
data[i2][j] = subtract2(data[i2][j], s);
|
|
}
|
|
}
|
|
var pi3 = j;
|
|
var pabsv = 0;
|
|
var vjj = 0;
|
|
for (i2 = j; i2 < rows; i2++) {
|
|
var v = data[i2][j];
|
|
var absv = abs3(v);
|
|
if (larger2(absv, pabsv)) {
|
|
pi3 = i2;
|
|
pabsv = absv;
|
|
vjj = v;
|
|
}
|
|
}
|
|
if (j !== pi3) {
|
|
p[j] = [p[pi3], p[pi3] = p[j]][0];
|
|
DenseMatrix2._swapRows(j, pi3, data);
|
|
}
|
|
if (j < rows) {
|
|
for (i2 = j + 1; i2 < rows; i2++) {
|
|
var vij = data[i2][j];
|
|
if (!equalScalar2(vij, 0)) {
|
|
data[i2][j] = divideScalar2(data[i2][j], vjj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for (j = 0; j < columns; j++) {
|
|
for (i2 = 0; i2 < rows; i2++) {
|
|
if (j === 0) {
|
|
if (i2 < columns) {
|
|
udata[i2] = [];
|
|
}
|
|
ldata[i2] = [];
|
|
}
|
|
if (i2 < j) {
|
|
if (i2 < columns) {
|
|
udata[i2][j] = data[i2][j];
|
|
}
|
|
if (j < rows) {
|
|
ldata[i2][j] = 0;
|
|
}
|
|
continue;
|
|
}
|
|
if (i2 === j) {
|
|
if (i2 < columns) {
|
|
udata[i2][j] = data[i2][j];
|
|
}
|
|
if (j < rows) {
|
|
ldata[i2][j] = 1;
|
|
}
|
|
continue;
|
|
}
|
|
if (i2 < columns) {
|
|
udata[i2][j] = 0;
|
|
}
|
|
if (j < rows) {
|
|
ldata[i2][j] = data[i2][j];
|
|
}
|
|
}
|
|
}
|
|
var l = new DenseMatrix2({
|
|
data: ldata,
|
|
size: lsize
|
|
});
|
|
var u = new DenseMatrix2({
|
|
data: udata,
|
|
size: usize
|
|
});
|
|
var pv = [];
|
|
for (i2 = 0, n = p.length; i2 < n; i2++) {
|
|
pv[p[i2]] = i2;
|
|
}
|
|
return {
|
|
L: l,
|
|
U: u,
|
|
p: pv,
|
|
toString: function toString() {
|
|
return "L: " + this.L.toString() + "\nU: " + this.U.toString() + "\nP: " + this.p;
|
|
}
|
|
};
|
|
}
|
|
function _sparseLUP(m) {
|
|
var rows = m._size[0];
|
|
var columns = m._size[1];
|
|
var n = Math.min(rows, columns);
|
|
var values = m._values;
|
|
var index2 = m._index;
|
|
var ptr = m._ptr;
|
|
var lvalues = [];
|
|
var lindex = [];
|
|
var lptr = [];
|
|
var lsize = [rows, n];
|
|
var uvalues = [];
|
|
var uindex = [];
|
|
var uptr = [];
|
|
var usize = [n, columns];
|
|
var i2, j, k;
|
|
var pvCo = [];
|
|
var pvOc = [];
|
|
for (i2 = 0; i2 < rows; i2++) {
|
|
pvCo[i2] = i2;
|
|
pvOc[i2] = i2;
|
|
}
|
|
var swapIndeces = function swapIndeces2(x, y) {
|
|
var kx = pvOc[x];
|
|
var ky = pvOc[y];
|
|
pvCo[kx] = y;
|
|
pvCo[ky] = x;
|
|
pvOc[x] = ky;
|
|
pvOc[y] = kx;
|
|
};
|
|
var _loop = function _loop2() {
|
|
var spa = new Spa2();
|
|
if (j < rows) {
|
|
lptr.push(lvalues.length);
|
|
lvalues.push(1);
|
|
lindex.push(j);
|
|
}
|
|
uptr.push(uvalues.length);
|
|
var k0 = ptr[j];
|
|
var k1 = ptr[j + 1];
|
|
for (k = k0; k < k1; k++) {
|
|
i2 = index2[k];
|
|
spa.set(pvCo[i2], values[k]);
|
|
}
|
|
if (j > 0) {
|
|
spa.forEach(0, j - 1, function(k2, vkj) {
|
|
SparseMatrix2._forEachRow(k2, lvalues, lindex, lptr, function(i3, vik) {
|
|
if (i3 > k2) {
|
|
spa.accumulate(i3, unaryMinus2(multiplyScalar2(vik, vkj)));
|
|
}
|
|
});
|
|
});
|
|
}
|
|
var pi3 = j;
|
|
var vjj = spa.get(j);
|
|
var pabsv = abs3(vjj);
|
|
spa.forEach(j + 1, rows - 1, function(x, v) {
|
|
var absv = abs3(v);
|
|
if (larger2(absv, pabsv)) {
|
|
pi3 = x;
|
|
pabsv = absv;
|
|
vjj = v;
|
|
}
|
|
});
|
|
if (j !== pi3) {
|
|
SparseMatrix2._swapRows(j, pi3, lsize[1], lvalues, lindex, lptr);
|
|
SparseMatrix2._swapRows(j, pi3, usize[1], uvalues, uindex, uptr);
|
|
spa.swap(j, pi3);
|
|
swapIndeces(j, pi3);
|
|
}
|
|
spa.forEach(0, rows - 1, function(x, v) {
|
|
if (x <= j) {
|
|
uvalues.push(v);
|
|
uindex.push(x);
|
|
} else {
|
|
v = divideScalar2(v, vjj);
|
|
if (!equalScalar2(v, 0)) {
|
|
lvalues.push(v);
|
|
lindex.push(x);
|
|
}
|
|
}
|
|
});
|
|
};
|
|
for (j = 0; j < columns; j++) {
|
|
_loop();
|
|
}
|
|
uptr.push(uvalues.length);
|
|
lptr.push(lvalues.length);
|
|
return {
|
|
L: new SparseMatrix2({
|
|
values: lvalues,
|
|
index: lindex,
|
|
ptr: lptr,
|
|
size: lsize
|
|
}),
|
|
U: new SparseMatrix2({
|
|
values: uvalues,
|
|
index: uindex,
|
|
ptr: uptr,
|
|
size: usize
|
|
}),
|
|
p: pvCo,
|
|
toString: function toString() {
|
|
return "L: " + this.L.toString() + "\nU: " + this.U.toString() + "\nP: " + this.p;
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/decomposition/qr.js
|
|
var name225 = "qr";
|
|
var dependencies225 = ["typed", "matrix", "zeros", "identity", "isZero", "equal", "sign", "sqrt", "conj", "unaryMinus", "addScalar", "divideScalar", "multiplyScalar", "subtract", "complex"];
|
|
var createQr = /* @__PURE__ */ factory(name225, dependencies225, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
zeros: zeros3,
|
|
identity: identity2,
|
|
isZero: isZero2,
|
|
equal: equal2,
|
|
sign: sign4,
|
|
sqrt: sqrt3,
|
|
conj: conj2,
|
|
unaryMinus: unaryMinus2,
|
|
addScalar: addScalar2,
|
|
divideScalar: divideScalar2,
|
|
multiplyScalar: multiplyScalar2,
|
|
subtract: subtract2,
|
|
complex: complex2
|
|
} = _ref;
|
|
return _extends(typed2(name225, {
|
|
DenseMatrix: function DenseMatrix2(m) {
|
|
return _denseQR(m);
|
|
},
|
|
SparseMatrix: function SparseMatrix2(m) {
|
|
return _sparseQR(m);
|
|
},
|
|
Array: function Array2(a) {
|
|
var m = matrix2(a);
|
|
var r = _denseQR(m);
|
|
return {
|
|
Q: r.Q.valueOf(),
|
|
R: r.R.valueOf()
|
|
};
|
|
}
|
|
}), {
|
|
_denseQRimpl
|
|
});
|
|
function _denseQRimpl(m) {
|
|
var rows = m._size[0];
|
|
var cols = m._size[1];
|
|
var Q2 = identity2([rows], "dense");
|
|
var Qdata = Q2._data;
|
|
var R = m.clone();
|
|
var Rdata = R._data;
|
|
var i2, j, k;
|
|
var w = zeros3([rows], "");
|
|
for (k = 0; k < Math.min(cols, rows); ++k) {
|
|
var pivot = Rdata[k][k];
|
|
var sgn = unaryMinus2(equal2(pivot, 0) ? 1 : sign4(pivot));
|
|
var conjSgn = conj2(sgn);
|
|
var alphaSquared = 0;
|
|
for (i2 = k; i2 < rows; i2++) {
|
|
alphaSquared = addScalar2(alphaSquared, multiplyScalar2(Rdata[i2][k], conj2(Rdata[i2][k])));
|
|
}
|
|
var alpha = multiplyScalar2(sgn, sqrt3(alphaSquared));
|
|
if (!isZero2(alpha)) {
|
|
var u1 = subtract2(pivot, alpha);
|
|
w[k] = 1;
|
|
for (i2 = k + 1; i2 < rows; i2++) {
|
|
w[i2] = divideScalar2(Rdata[i2][k], u1);
|
|
}
|
|
var tau3 = unaryMinus2(conj2(divideScalar2(u1, alpha)));
|
|
var s = void 0;
|
|
for (j = k; j < cols; j++) {
|
|
s = 0;
|
|
for (i2 = k; i2 < rows; i2++) {
|
|
s = addScalar2(s, multiplyScalar2(conj2(w[i2]), Rdata[i2][j]));
|
|
}
|
|
s = multiplyScalar2(s, tau3);
|
|
for (i2 = k; i2 < rows; i2++) {
|
|
Rdata[i2][j] = multiplyScalar2(subtract2(Rdata[i2][j], multiplyScalar2(w[i2], s)), conjSgn);
|
|
}
|
|
}
|
|
for (i2 = 0; i2 < rows; i2++) {
|
|
s = 0;
|
|
for (j = k; j < rows; j++) {
|
|
s = addScalar2(s, multiplyScalar2(Qdata[i2][j], w[j]));
|
|
}
|
|
s = multiplyScalar2(s, tau3);
|
|
for (j = k; j < rows; ++j) {
|
|
Qdata[i2][j] = divideScalar2(subtract2(Qdata[i2][j], multiplyScalar2(s, conj2(w[j]))), conjSgn);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return {
|
|
Q: Q2,
|
|
R,
|
|
toString: function toString() {
|
|
return "Q: " + this.Q.toString() + "\nR: " + this.R.toString();
|
|
}
|
|
};
|
|
}
|
|
function _denseQR(m) {
|
|
var ret = _denseQRimpl(m);
|
|
var Rdata = ret.R._data;
|
|
if (m._data.length > 0) {
|
|
var zero = Rdata[0][0].type === "Complex" ? complex2(0) : 0;
|
|
for (var i2 = 0; i2 < Rdata.length; ++i2) {
|
|
for (var j = 0; j < i2 && j < (Rdata[0] || []).length; ++j) {
|
|
Rdata[i2][j] = zero;
|
|
}
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
function _sparseQR(m) {
|
|
throw new Error("qr not implemented for sparse matrices yet");
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/sparse/csPermute.js
|
|
function csPermute(a, pinv2, q, values) {
|
|
var avalues = a._values;
|
|
var aindex = a._index;
|
|
var aptr = a._ptr;
|
|
var asize = a._size;
|
|
var adt = a._datatype;
|
|
var m = asize[0];
|
|
var n = asize[1];
|
|
var cvalues = values && a._values ? [] : null;
|
|
var cindex = [];
|
|
var cptr = [];
|
|
var nz = 0;
|
|
for (var k = 0; k < n; k++) {
|
|
cptr[k] = nz;
|
|
var j = q ? q[k] : k;
|
|
for (var t0 = aptr[j], t1 = aptr[j + 1], t = t0; t < t1; t++) {
|
|
var r = pinv2 ? pinv2[aindex[t]] : aindex[t];
|
|
cindex[nz] = r;
|
|
if (cvalues) {
|
|
cvalues[nz] = avalues[t];
|
|
}
|
|
nz++;
|
|
}
|
|
}
|
|
cptr[n] = nz;
|
|
return a.createSparseMatrix({
|
|
values: cvalues,
|
|
index: cindex,
|
|
ptr: cptr,
|
|
size: [m, n],
|
|
datatype: adt
|
|
});
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/sparse/csTdfs.js
|
|
function csTdfs(j, k, w, head, next, post, stack) {
|
|
var top = 0;
|
|
w[stack] = j;
|
|
while (top >= 0) {
|
|
var p = w[stack + top];
|
|
var i2 = w[head + p];
|
|
if (i2 === -1) {
|
|
top--;
|
|
post[k++] = p;
|
|
} else {
|
|
w[head + p] = w[next + i2];
|
|
++top;
|
|
w[stack + top] = i2;
|
|
}
|
|
}
|
|
return k;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/sparse/csPost.js
|
|
function csPost(parent, n) {
|
|
if (!parent) {
|
|
return null;
|
|
}
|
|
var k = 0;
|
|
var j;
|
|
var post = [];
|
|
var w = [];
|
|
var head = 0;
|
|
var next = n;
|
|
var stack = 2 * n;
|
|
for (j = 0; j < n; j++) {
|
|
w[head + j] = -1;
|
|
}
|
|
for (j = n - 1; j >= 0; j--) {
|
|
if (parent[j] === -1) {
|
|
continue;
|
|
}
|
|
w[next + j] = w[head + parent[j]];
|
|
w[head + parent[j]] = j;
|
|
}
|
|
for (j = 0; j < n; j++) {
|
|
if (parent[j] !== -1) {
|
|
continue;
|
|
}
|
|
k = csTdfs(j, k, w, head, next, post, stack);
|
|
}
|
|
return post;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/sparse/csEtree.js
|
|
function csEtree(a, ata) {
|
|
if (!a) {
|
|
return null;
|
|
}
|
|
var aindex = a._index;
|
|
var aptr = a._ptr;
|
|
var asize = a._size;
|
|
var m = asize[0];
|
|
var n = asize[1];
|
|
var parent = [];
|
|
var w = [];
|
|
var ancestor = 0;
|
|
var prev = n;
|
|
var i2, inext;
|
|
if (ata) {
|
|
for (i2 = 0; i2 < m; i2++) {
|
|
w[prev + i2] = -1;
|
|
}
|
|
}
|
|
for (var k = 0; k < n; k++) {
|
|
parent[k] = -1;
|
|
w[ancestor + k] = -1;
|
|
for (var p0 = aptr[k], p1 = aptr[k + 1], p = p0; p < p1; p++) {
|
|
var r = aindex[p];
|
|
i2 = ata ? w[prev + r] : r;
|
|
for (; i2 !== -1 && i2 < k; i2 = inext) {
|
|
inext = w[ancestor + i2];
|
|
w[ancestor + i2] = k;
|
|
if (inext === -1) {
|
|
parent[i2] = k;
|
|
}
|
|
}
|
|
if (ata) {
|
|
w[prev + r] = k;
|
|
}
|
|
}
|
|
}
|
|
return parent;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/sparse/csFkeep.js
|
|
function csFkeep(a, callback, other) {
|
|
var avalues = a._values;
|
|
var aindex = a._index;
|
|
var aptr = a._ptr;
|
|
var asize = a._size;
|
|
var n = asize[1];
|
|
var nz = 0;
|
|
for (var j = 0; j < n; j++) {
|
|
var p = aptr[j];
|
|
aptr[j] = nz;
|
|
for (; p < aptr[j + 1]; p++) {
|
|
if (callback(aindex[p], j, avalues ? avalues[p] : 1, other)) {
|
|
aindex[nz] = aindex[p];
|
|
if (avalues) {
|
|
avalues[nz] = avalues[p];
|
|
}
|
|
nz++;
|
|
}
|
|
}
|
|
}
|
|
aptr[n] = nz;
|
|
aindex.splice(nz, aindex.length - nz);
|
|
if (avalues) {
|
|
avalues.splice(nz, avalues.length - nz);
|
|
}
|
|
return nz;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/sparse/csFlip.js
|
|
function csFlip(i2) {
|
|
return -i2 - 2;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/sparse/csAmd.js
|
|
var name226 = "csAmd";
|
|
var dependencies226 = ["add", "multiply", "transpose"];
|
|
var createCsAmd = /* @__PURE__ */ factory(name226, dependencies226, (_ref) => {
|
|
var {
|
|
add: add3,
|
|
multiply: multiply2,
|
|
transpose: transpose2
|
|
} = _ref;
|
|
return function csAmd(order, a) {
|
|
if (!a || order <= 0 || order > 3) {
|
|
return null;
|
|
}
|
|
var asize = a._size;
|
|
var m = asize[0];
|
|
var n = asize[1];
|
|
var lemax = 0;
|
|
var dense = Math.max(16, 10 * Math.sqrt(n));
|
|
dense = Math.min(n - 2, dense);
|
|
var cm = _createTargetMatrix(order, a, m, n, dense);
|
|
csFkeep(cm, _diag, null);
|
|
var cindex = cm._index;
|
|
var cptr = cm._ptr;
|
|
var cnz = cptr[n];
|
|
var P3 = [];
|
|
var W = [];
|
|
var len = 0;
|
|
var nv = n + 1;
|
|
var next = 2 * (n + 1);
|
|
var head = 3 * (n + 1);
|
|
var elen = 4 * (n + 1);
|
|
var degree = 5 * (n + 1);
|
|
var w = 6 * (n + 1);
|
|
var hhead = 7 * (n + 1);
|
|
var last = P3;
|
|
var mark = _initializeQuotientGraph(n, cptr, W, len, head, last, next, hhead, nv, w, elen, degree);
|
|
var nel = _initializeDegreeLists(n, cptr, W, degree, elen, w, dense, nv, head, last, next);
|
|
var mindeg = 0;
|
|
var i2, j, k, k1, k2, e3, pj, ln2, nvi, pk, eln, p1, p2, pn, h, d;
|
|
while (nel < n) {
|
|
for (k = -1; mindeg < n && (k = W[head + mindeg]) === -1; mindeg++) {
|
|
;
|
|
}
|
|
if (W[next + k] !== -1) {
|
|
last[W[next + k]] = -1;
|
|
}
|
|
W[head + mindeg] = W[next + k];
|
|
var elenk = W[elen + k];
|
|
var nvk = W[nv + k];
|
|
nel += nvk;
|
|
var dk = 0;
|
|
W[nv + k] = -nvk;
|
|
var p = cptr[k];
|
|
var pk1 = elenk === 0 ? p : cnz;
|
|
var pk2 = pk1;
|
|
for (k1 = 1; k1 <= elenk + 1; k1++) {
|
|
if (k1 > elenk) {
|
|
e3 = k;
|
|
pj = p;
|
|
ln2 = W[len + k] - elenk;
|
|
} else {
|
|
e3 = cindex[p++];
|
|
pj = cptr[e3];
|
|
ln2 = W[len + e3];
|
|
}
|
|
for (k2 = 1; k2 <= ln2; k2++) {
|
|
i2 = cindex[pj++];
|
|
if ((nvi = W[nv + i2]) <= 0) {
|
|
continue;
|
|
}
|
|
dk += nvi;
|
|
W[nv + i2] = -nvi;
|
|
cindex[pk2++] = i2;
|
|
if (W[next + i2] !== -1) {
|
|
last[W[next + i2]] = last[i2];
|
|
}
|
|
if (last[i2] !== -1) {
|
|
W[next + last[i2]] = W[next + i2];
|
|
} else {
|
|
W[head + W[degree + i2]] = W[next + i2];
|
|
}
|
|
}
|
|
if (e3 !== k) {
|
|
cptr[e3] = csFlip(k);
|
|
W[w + e3] = 0;
|
|
}
|
|
}
|
|
if (elenk !== 0) {
|
|
cnz = pk2;
|
|
}
|
|
W[degree + k] = dk;
|
|
cptr[k] = pk1;
|
|
W[len + k] = pk2 - pk1;
|
|
W[elen + k] = -2;
|
|
mark = _wclear(mark, lemax, W, w, n);
|
|
for (pk = pk1; pk < pk2; pk++) {
|
|
i2 = cindex[pk];
|
|
if ((eln = W[elen + i2]) <= 0) {
|
|
continue;
|
|
}
|
|
nvi = -W[nv + i2];
|
|
var wnvi = mark - nvi;
|
|
for (p = cptr[i2], p1 = cptr[i2] + eln - 1; p <= p1; p++) {
|
|
e3 = cindex[p];
|
|
if (W[w + e3] >= mark) {
|
|
W[w + e3] -= nvi;
|
|
} else if (W[w + e3] !== 0) {
|
|
W[w + e3] = W[degree + e3] + wnvi;
|
|
}
|
|
}
|
|
}
|
|
for (pk = pk1; pk < pk2; pk++) {
|
|
i2 = cindex[pk];
|
|
p1 = cptr[i2];
|
|
p2 = p1 + W[elen + i2] - 1;
|
|
pn = p1;
|
|
for (h = 0, d = 0, p = p1; p <= p2; p++) {
|
|
e3 = cindex[p];
|
|
if (W[w + e3] !== 0) {
|
|
var dext = W[w + e3] - mark;
|
|
if (dext > 0) {
|
|
d += dext;
|
|
cindex[pn++] = e3;
|
|
h += e3;
|
|
} else {
|
|
cptr[e3] = csFlip(k);
|
|
W[w + e3] = 0;
|
|
}
|
|
}
|
|
}
|
|
W[elen + i2] = pn - p1 + 1;
|
|
var p3 = pn;
|
|
var p4 = p1 + W[len + i2];
|
|
for (p = p2 + 1; p < p4; p++) {
|
|
j = cindex[p];
|
|
var nvj = W[nv + j];
|
|
if (nvj <= 0) {
|
|
continue;
|
|
}
|
|
d += nvj;
|
|
cindex[pn++] = j;
|
|
h += j;
|
|
}
|
|
if (d === 0) {
|
|
cptr[i2] = csFlip(k);
|
|
nvi = -W[nv + i2];
|
|
dk -= nvi;
|
|
nvk += nvi;
|
|
nel += nvi;
|
|
W[nv + i2] = 0;
|
|
W[elen + i2] = -1;
|
|
} else {
|
|
W[degree + i2] = Math.min(W[degree + i2], d);
|
|
cindex[pn] = cindex[p3];
|
|
cindex[p3] = cindex[p1];
|
|
cindex[p1] = k;
|
|
W[len + i2] = pn - p1 + 1;
|
|
h = (h < 0 ? -h : h) % n;
|
|
W[next + i2] = W[hhead + h];
|
|
W[hhead + h] = i2;
|
|
last[i2] = h;
|
|
}
|
|
}
|
|
W[degree + k] = dk;
|
|
lemax = Math.max(lemax, dk);
|
|
mark = _wclear(mark + lemax, lemax, W, w, n);
|
|
for (pk = pk1; pk < pk2; pk++) {
|
|
i2 = cindex[pk];
|
|
if (W[nv + i2] >= 0) {
|
|
continue;
|
|
}
|
|
h = last[i2];
|
|
i2 = W[hhead + h];
|
|
W[hhead + h] = -1;
|
|
for (; i2 !== -1 && W[next + i2] !== -1; i2 = W[next + i2], mark++) {
|
|
ln2 = W[len + i2];
|
|
eln = W[elen + i2];
|
|
for (p = cptr[i2] + 1; p <= cptr[i2] + ln2 - 1; p++) {
|
|
W[w + cindex[p]] = mark;
|
|
}
|
|
var jlast = i2;
|
|
for (j = W[next + i2]; j !== -1; ) {
|
|
var ok = W[len + j] === ln2 && W[elen + j] === eln;
|
|
for (p = cptr[j] + 1; ok && p <= cptr[j] + ln2 - 1; p++) {
|
|
if (W[w + cindex[p]] !== mark) {
|
|
ok = 0;
|
|
}
|
|
}
|
|
if (ok) {
|
|
cptr[j] = csFlip(i2);
|
|
W[nv + i2] += W[nv + j];
|
|
W[nv + j] = 0;
|
|
W[elen + j] = -1;
|
|
j = W[next + j];
|
|
W[next + jlast] = j;
|
|
} else {
|
|
jlast = j;
|
|
j = W[next + j];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for (p = pk1, pk = pk1; pk < pk2; pk++) {
|
|
i2 = cindex[pk];
|
|
if ((nvi = -W[nv + i2]) <= 0) {
|
|
continue;
|
|
}
|
|
W[nv + i2] = nvi;
|
|
d = W[degree + i2] + dk - nvi;
|
|
d = Math.min(d, n - nel - nvi);
|
|
if (W[head + d] !== -1) {
|
|
last[W[head + d]] = i2;
|
|
}
|
|
W[next + i2] = W[head + d];
|
|
last[i2] = -1;
|
|
W[head + d] = i2;
|
|
mindeg = Math.min(mindeg, d);
|
|
W[degree + i2] = d;
|
|
cindex[p++] = i2;
|
|
}
|
|
W[nv + k] = nvk;
|
|
if ((W[len + k] = p - pk1) === 0) {
|
|
cptr[k] = -1;
|
|
W[w + k] = 0;
|
|
}
|
|
if (elenk !== 0) {
|
|
cnz = p;
|
|
}
|
|
}
|
|
for (i2 = 0; i2 < n; i2++) {
|
|
cptr[i2] = csFlip(cptr[i2]);
|
|
}
|
|
for (j = 0; j <= n; j++) {
|
|
W[head + j] = -1;
|
|
}
|
|
for (j = n; j >= 0; j--) {
|
|
if (W[nv + j] > 0) {
|
|
continue;
|
|
}
|
|
W[next + j] = W[head + cptr[j]];
|
|
W[head + cptr[j]] = j;
|
|
}
|
|
for (e3 = n; e3 >= 0; e3--) {
|
|
if (W[nv + e3] <= 0) {
|
|
continue;
|
|
}
|
|
if (cptr[e3] !== -1) {
|
|
W[next + e3] = W[head + cptr[e3]];
|
|
W[head + cptr[e3]] = e3;
|
|
}
|
|
}
|
|
for (k = 0, i2 = 0; i2 <= n; i2++) {
|
|
if (cptr[i2] === -1) {
|
|
k = csTdfs(i2, k, W, head, next, P3, w);
|
|
}
|
|
}
|
|
P3.splice(P3.length - 1, 1);
|
|
return P3;
|
|
};
|
|
function _createTargetMatrix(order, a, m, n, dense) {
|
|
var at = transpose2(a);
|
|
if (order === 1 && n === m) {
|
|
return add3(a, at);
|
|
}
|
|
if (order === 2) {
|
|
var tindex = at._index;
|
|
var tptr = at._ptr;
|
|
var p2 = 0;
|
|
for (var j = 0; j < m; j++) {
|
|
var p = tptr[j];
|
|
tptr[j] = p2;
|
|
if (tptr[j + 1] - p > dense) {
|
|
continue;
|
|
}
|
|
for (var p1 = tptr[j + 1]; p < p1; p++) {
|
|
tindex[p2++] = tindex[p];
|
|
}
|
|
}
|
|
tptr[m] = p2;
|
|
a = transpose2(at);
|
|
return multiply2(at, a);
|
|
}
|
|
return multiply2(at, a);
|
|
}
|
|
function _initializeQuotientGraph(n, cptr, W, len, head, last, next, hhead, nv, w, elen, degree) {
|
|
for (var k = 0; k < n; k++) {
|
|
W[len + k] = cptr[k + 1] - cptr[k];
|
|
}
|
|
W[len + n] = 0;
|
|
for (var i2 = 0; i2 <= n; i2++) {
|
|
W[head + i2] = -1;
|
|
last[i2] = -1;
|
|
W[next + i2] = -1;
|
|
W[hhead + i2] = -1;
|
|
W[nv + i2] = 1;
|
|
W[w + i2] = 1;
|
|
W[elen + i2] = 0;
|
|
W[degree + i2] = W[len + i2];
|
|
}
|
|
var mark = _wclear(0, 0, W, w, n);
|
|
W[elen + n] = -2;
|
|
cptr[n] = -1;
|
|
W[w + n] = 0;
|
|
return mark;
|
|
}
|
|
function _initializeDegreeLists(n, cptr, W, degree, elen, w, dense, nv, head, last, next) {
|
|
var nel = 0;
|
|
for (var i2 = 0; i2 < n; i2++) {
|
|
var d = W[degree + i2];
|
|
if (d === 0) {
|
|
W[elen + i2] = -2;
|
|
nel++;
|
|
cptr[i2] = -1;
|
|
W[w + i2] = 0;
|
|
} else if (d > dense) {
|
|
W[nv + i2] = 0;
|
|
W[elen + i2] = -1;
|
|
nel++;
|
|
cptr[i2] = csFlip(n);
|
|
W[nv + n]++;
|
|
} else {
|
|
var h = W[head + d];
|
|
if (h !== -1) {
|
|
last[h] = i2;
|
|
}
|
|
W[next + i2] = W[head + d];
|
|
W[head + d] = i2;
|
|
}
|
|
}
|
|
return nel;
|
|
}
|
|
function _wclear(mark, lemax, W, w, n) {
|
|
if (mark < 2 || mark + lemax < 0) {
|
|
for (var k = 0; k < n; k++) {
|
|
if (W[w + k] !== 0) {
|
|
W[w + k] = 1;
|
|
}
|
|
}
|
|
mark = 2;
|
|
}
|
|
return mark;
|
|
}
|
|
function _diag(i2, j) {
|
|
return i2 !== j;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/sparse/csLeaf.js
|
|
function csLeaf(i2, j, w, first, maxfirst, prevleaf, ancestor) {
|
|
var s, sparent;
|
|
var jleaf = 0;
|
|
var q;
|
|
if (i2 <= j || w[first + j] <= w[maxfirst + i2]) {
|
|
return -1;
|
|
}
|
|
w[maxfirst + i2] = w[first + j];
|
|
var jprev = w[prevleaf + i2];
|
|
w[prevleaf + i2] = j;
|
|
if (jprev === -1) {
|
|
jleaf = 1;
|
|
q = i2;
|
|
} else {
|
|
jleaf = 2;
|
|
for (q = jprev; q !== w[ancestor + q]; q = w[ancestor + q]) {
|
|
;
|
|
}
|
|
for (s = jprev; s !== q; s = sparent) {
|
|
sparent = w[ancestor + s];
|
|
w[ancestor + s] = q;
|
|
}
|
|
}
|
|
return {
|
|
jleaf,
|
|
q
|
|
};
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/sparse/csCounts.js
|
|
var name227 = "csCounts";
|
|
var dependencies227 = ["transpose"];
|
|
var createCsCounts = /* @__PURE__ */ factory(name227, dependencies227, (_ref) => {
|
|
var {
|
|
transpose: transpose2
|
|
} = _ref;
|
|
return function(a, parent, post, ata) {
|
|
if (!a || !parent || !post) {
|
|
return null;
|
|
}
|
|
var asize = a._size;
|
|
var m = asize[0];
|
|
var n = asize[1];
|
|
var i2, j, k, J, p, p0, p1;
|
|
var s = 4 * n + (ata ? n + m + 1 : 0);
|
|
var w = [];
|
|
var ancestor = 0;
|
|
var maxfirst = n;
|
|
var prevleaf = 2 * n;
|
|
var first = 3 * n;
|
|
var head = 4 * n;
|
|
var next = 5 * n + 1;
|
|
for (k = 0; k < s; k++) {
|
|
w[k] = -1;
|
|
}
|
|
var colcount = [];
|
|
var at = transpose2(a);
|
|
var tindex = at._index;
|
|
var tptr = at._ptr;
|
|
for (k = 0; k < n; k++) {
|
|
j = post[k];
|
|
colcount[j] = w[first + j] === -1 ? 1 : 0;
|
|
for (; j !== -1 && w[first + j] === -1; j = parent[j]) {
|
|
w[first + j] = k;
|
|
}
|
|
}
|
|
if (ata) {
|
|
for (k = 0; k < n; k++) {
|
|
w[post[k]] = k;
|
|
}
|
|
for (i2 = 0; i2 < m; i2++) {
|
|
for (k = n, p0 = tptr[i2], p1 = tptr[i2 + 1], p = p0; p < p1; p++) {
|
|
k = Math.min(k, w[tindex[p]]);
|
|
}
|
|
w[next + i2] = w[head + k];
|
|
w[head + k] = i2;
|
|
}
|
|
}
|
|
for (i2 = 0; i2 < n; i2++) {
|
|
w[ancestor + i2] = i2;
|
|
}
|
|
for (k = 0; k < n; k++) {
|
|
j = post[k];
|
|
if (parent[j] !== -1) {
|
|
colcount[parent[j]]--;
|
|
}
|
|
for (J = ata ? w[head + k] : j; J !== -1; J = ata ? w[next + J] : -1) {
|
|
for (p = tptr[J]; p < tptr[J + 1]; p++) {
|
|
i2 = tindex[p];
|
|
var r = csLeaf(i2, j, w, first, maxfirst, prevleaf, ancestor);
|
|
if (r.jleaf >= 1) {
|
|
colcount[j]++;
|
|
}
|
|
if (r.jleaf === 2) {
|
|
colcount[r.q]--;
|
|
}
|
|
}
|
|
}
|
|
if (parent[j] !== -1) {
|
|
w[ancestor + j] = parent[j];
|
|
}
|
|
}
|
|
for (j = 0; j < n; j++) {
|
|
if (parent[j] !== -1) {
|
|
colcount[parent[j]] += colcount[j];
|
|
}
|
|
}
|
|
return colcount;
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/sparse/csSqr.js
|
|
var name228 = "csSqr";
|
|
var dependencies228 = ["add", "multiply", "transpose"];
|
|
var createCsSqr = /* @__PURE__ */ factory(name228, dependencies228, (_ref) => {
|
|
var {
|
|
add: add3,
|
|
multiply: multiply2,
|
|
transpose: transpose2
|
|
} = _ref;
|
|
var csAmd = createCsAmd({
|
|
add: add3,
|
|
multiply: multiply2,
|
|
transpose: transpose2
|
|
});
|
|
var csCounts = createCsCounts({
|
|
transpose: transpose2
|
|
});
|
|
return function csSqr(order, a, qr2) {
|
|
var aptr = a._ptr;
|
|
var asize = a._size;
|
|
var n = asize[1];
|
|
var k;
|
|
var s = {};
|
|
s.q = csAmd(order, a);
|
|
if (order && !s.q) {
|
|
return null;
|
|
}
|
|
if (qr2) {
|
|
var c = order ? csPermute(a, null, s.q, 0) : a;
|
|
s.parent = csEtree(c, 1);
|
|
var post = csPost(s.parent, n);
|
|
s.cp = csCounts(c, s.parent, post, 1);
|
|
if (c && s.parent && s.cp && _vcount(c, s)) {
|
|
for (s.unz = 0, k = 0; k < n; k++) {
|
|
s.unz += s.cp[k];
|
|
}
|
|
}
|
|
} else {
|
|
s.unz = 4 * aptr[n] + n;
|
|
s.lnz = s.unz;
|
|
}
|
|
return s;
|
|
};
|
|
function _vcount(a, s) {
|
|
var aptr = a._ptr;
|
|
var aindex = a._index;
|
|
var asize = a._size;
|
|
var m = asize[0];
|
|
var n = asize[1];
|
|
s.pinv = [];
|
|
s.leftmost = [];
|
|
var parent = s.parent;
|
|
var pinv2 = s.pinv;
|
|
var leftmost = s.leftmost;
|
|
var w = [];
|
|
var next = 0;
|
|
var head = m;
|
|
var tail = m + n;
|
|
var nque = m + 2 * n;
|
|
var i2, k, p, p0, p1;
|
|
for (k = 0; k < n; k++) {
|
|
w[head + k] = -1;
|
|
w[tail + k] = -1;
|
|
w[nque + k] = 0;
|
|
}
|
|
for (i2 = 0; i2 < m; i2++) {
|
|
leftmost[i2] = -1;
|
|
}
|
|
for (k = n - 1; k >= 0; k--) {
|
|
for (p0 = aptr[k], p1 = aptr[k + 1], p = p0; p < p1; p++) {
|
|
leftmost[aindex[p]] = k;
|
|
}
|
|
}
|
|
for (i2 = m - 1; i2 >= 0; i2--) {
|
|
pinv2[i2] = -1;
|
|
k = leftmost[i2];
|
|
if (k === -1) {
|
|
continue;
|
|
}
|
|
if (w[nque + k]++ === 0) {
|
|
w[tail + k] = i2;
|
|
}
|
|
w[next + i2] = w[head + k];
|
|
w[head + k] = i2;
|
|
}
|
|
s.lnz = 0;
|
|
s.m2 = m;
|
|
for (k = 0; k < n; k++) {
|
|
i2 = w[head + k];
|
|
s.lnz++;
|
|
if (i2 < 0) {
|
|
i2 = s.m2++;
|
|
}
|
|
pinv2[i2] = k;
|
|
if (--nque[k] <= 0) {
|
|
continue;
|
|
}
|
|
s.lnz += w[nque + k];
|
|
var pa = parent[k];
|
|
if (pa !== -1) {
|
|
if (w[nque + pa] === 0) {
|
|
w[tail + pa] = w[tail + k];
|
|
}
|
|
w[next + w[tail + k]] = w[head + pa];
|
|
w[head + pa] = w[next + i2];
|
|
w[nque + pa] += w[nque + k];
|
|
}
|
|
}
|
|
for (i2 = 0; i2 < m; i2++) {
|
|
if (pinv2[i2] < 0) {
|
|
pinv2[i2] = k++;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/sparse/csMarked.js
|
|
function csMarked(w, j) {
|
|
return w[j] < 0;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/sparse/csMark.js
|
|
function csMark(w, j) {
|
|
w[j] = csFlip(w[j]);
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/sparse/csUnflip.js
|
|
function csUnflip(i2) {
|
|
return i2 < 0 ? csFlip(i2) : i2;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/sparse/csDfs.js
|
|
function csDfs(j, g, top, xi, pinv2) {
|
|
var index2 = g._index;
|
|
var ptr = g._ptr;
|
|
var size2 = g._size;
|
|
var n = size2[1];
|
|
var i2, p, p2;
|
|
var head = 0;
|
|
xi[0] = j;
|
|
while (head >= 0) {
|
|
j = xi[head];
|
|
var jnew = pinv2 ? pinv2[j] : j;
|
|
if (!csMarked(ptr, j)) {
|
|
csMark(ptr, j);
|
|
xi[n + head] = jnew < 0 ? 0 : csUnflip(ptr[jnew]);
|
|
}
|
|
var done = 1;
|
|
for (p = xi[n + head], p2 = jnew < 0 ? 0 : csUnflip(ptr[jnew + 1]); p < p2; p++) {
|
|
i2 = index2[p];
|
|
if (csMarked(ptr, i2)) {
|
|
continue;
|
|
}
|
|
xi[n + head] = p;
|
|
xi[++head] = i2;
|
|
done = 0;
|
|
break;
|
|
}
|
|
if (done) {
|
|
head--;
|
|
xi[--top] = j;
|
|
}
|
|
}
|
|
return top;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/sparse/csReach.js
|
|
function csReach(g, b, k, xi, pinv2) {
|
|
var gptr = g._ptr;
|
|
var gsize = g._size;
|
|
var bindex = b._index;
|
|
var bptr = b._ptr;
|
|
var n = gsize[1];
|
|
var p, p0, p1;
|
|
var top = n;
|
|
for (p0 = bptr[k], p1 = bptr[k + 1], p = p0; p < p1; p++) {
|
|
var i2 = bindex[p];
|
|
if (!csMarked(gptr, i2)) {
|
|
top = csDfs(i2, g, top, xi, pinv2);
|
|
}
|
|
}
|
|
for (p = top; p < n; p++) {
|
|
csMark(gptr, xi[p]);
|
|
}
|
|
return top;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/sparse/csSpsolve.js
|
|
var name229 = "csSpsolve";
|
|
var dependencies229 = ["divideScalar", "multiply", "subtract"];
|
|
var createCsSpsolve = /* @__PURE__ */ factory(name229, dependencies229, (_ref) => {
|
|
var {
|
|
divideScalar: divideScalar2,
|
|
multiply: multiply2,
|
|
subtract: subtract2
|
|
} = _ref;
|
|
return function csSpsolve(g, b, k, xi, x, pinv2, lo) {
|
|
var gvalues = g._values;
|
|
var gindex = g._index;
|
|
var gptr = g._ptr;
|
|
var gsize = g._size;
|
|
var n = gsize[1];
|
|
var bvalues = b._values;
|
|
var bindex = b._index;
|
|
var bptr = b._ptr;
|
|
var p, p0, p1, q;
|
|
var top = csReach(g, b, k, xi, pinv2);
|
|
for (p = top; p < n; p++) {
|
|
x[xi[p]] = 0;
|
|
}
|
|
for (p0 = bptr[k], p1 = bptr[k + 1], p = p0; p < p1; p++) {
|
|
x[bindex[p]] = bvalues[p];
|
|
}
|
|
for (var px = top; px < n; px++) {
|
|
var j = xi[px];
|
|
var J = pinv2 ? pinv2[j] : j;
|
|
if (J < 0) {
|
|
continue;
|
|
}
|
|
p0 = gptr[J];
|
|
p1 = gptr[J + 1];
|
|
x[j] = divideScalar2(x[j], gvalues[lo ? p0 : p1 - 1]);
|
|
p = lo ? p0 + 1 : p0;
|
|
q = lo ? p1 : p1 - 1;
|
|
for (; p < q; p++) {
|
|
var i2 = gindex[p];
|
|
x[i2] = subtract2(x[i2], multiply2(gvalues[p], x[j]));
|
|
}
|
|
}
|
|
return top;
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/sparse/csLu.js
|
|
var name230 = "csLu";
|
|
var dependencies230 = ["abs", "divideScalar", "multiply", "subtract", "larger", "largerEq", "SparseMatrix"];
|
|
var createCsLu = /* @__PURE__ */ factory(name230, dependencies230, (_ref) => {
|
|
var {
|
|
abs: abs3,
|
|
divideScalar: divideScalar2,
|
|
multiply: multiply2,
|
|
subtract: subtract2,
|
|
larger: larger2,
|
|
largerEq: largerEq2,
|
|
SparseMatrix: SparseMatrix2
|
|
} = _ref;
|
|
var csSpsolve = createCsSpsolve({
|
|
divideScalar: divideScalar2,
|
|
multiply: multiply2,
|
|
subtract: subtract2
|
|
});
|
|
return function csLu(m, s, tol) {
|
|
if (!m) {
|
|
return null;
|
|
}
|
|
var size2 = m._size;
|
|
var n = size2[1];
|
|
var q;
|
|
var lnz = 100;
|
|
var unz = 100;
|
|
if (s) {
|
|
q = s.q;
|
|
lnz = s.lnz || lnz;
|
|
unz = s.unz || unz;
|
|
}
|
|
var lvalues = [];
|
|
var lindex = [];
|
|
var lptr = [];
|
|
var L = new SparseMatrix2({
|
|
values: lvalues,
|
|
index: lindex,
|
|
ptr: lptr,
|
|
size: [n, n]
|
|
});
|
|
var uvalues = [];
|
|
var uindex = [];
|
|
var uptr = [];
|
|
var U = new SparseMatrix2({
|
|
values: uvalues,
|
|
index: uindex,
|
|
ptr: uptr,
|
|
size: [n, n]
|
|
});
|
|
var pinv2 = [];
|
|
var i2, p;
|
|
var x = [];
|
|
var xi = [];
|
|
for (i2 = 0; i2 < n; i2++) {
|
|
x[i2] = 0;
|
|
pinv2[i2] = -1;
|
|
lptr[i2 + 1] = 0;
|
|
}
|
|
lnz = 0;
|
|
unz = 0;
|
|
for (var k = 0; k < n; k++) {
|
|
lptr[k] = lnz;
|
|
uptr[k] = unz;
|
|
var col = q ? q[k] : k;
|
|
var top = csSpsolve(L, m, col, xi, x, pinv2, 1);
|
|
var ipiv = -1;
|
|
var a = -1;
|
|
for (p = top; p < n; p++) {
|
|
i2 = xi[p];
|
|
if (pinv2[i2] < 0) {
|
|
var xabs = abs3(x[i2]);
|
|
if (larger2(xabs, a)) {
|
|
a = xabs;
|
|
ipiv = i2;
|
|
}
|
|
} else {
|
|
uindex[unz] = pinv2[i2];
|
|
uvalues[unz++] = x[i2];
|
|
}
|
|
}
|
|
if (ipiv === -1 || a <= 0) {
|
|
return null;
|
|
}
|
|
if (pinv2[col] < 0 && largerEq2(abs3(x[col]), multiply2(a, tol))) {
|
|
ipiv = col;
|
|
}
|
|
var pivot = x[ipiv];
|
|
uindex[unz] = k;
|
|
uvalues[unz++] = pivot;
|
|
pinv2[ipiv] = k;
|
|
lindex[lnz] = ipiv;
|
|
lvalues[lnz++] = 1;
|
|
for (p = top; p < n; p++) {
|
|
i2 = xi[p];
|
|
if (pinv2[i2] < 0) {
|
|
lindex[lnz] = i2;
|
|
lvalues[lnz++] = divideScalar2(x[i2], pivot);
|
|
}
|
|
x[i2] = 0;
|
|
}
|
|
}
|
|
lptr[n] = lnz;
|
|
uptr[n] = unz;
|
|
for (p = 0; p < lnz; p++) {
|
|
lindex[p] = pinv2[lindex[p]];
|
|
}
|
|
lvalues.splice(lnz, lvalues.length - lnz);
|
|
lindex.splice(lnz, lindex.length - lnz);
|
|
uvalues.splice(unz, uvalues.length - unz);
|
|
uindex.splice(unz, uindex.length - unz);
|
|
return {
|
|
L,
|
|
U,
|
|
pinv: pinv2
|
|
};
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/decomposition/slu.js
|
|
var name231 = "slu";
|
|
var dependencies231 = ["typed", "abs", "add", "multiply", "transpose", "divideScalar", "subtract", "larger", "largerEq", "SparseMatrix"];
|
|
var createSlu = /* @__PURE__ */ factory(name231, dependencies231, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
abs: abs3,
|
|
add: add3,
|
|
multiply: multiply2,
|
|
transpose: transpose2,
|
|
divideScalar: divideScalar2,
|
|
subtract: subtract2,
|
|
larger: larger2,
|
|
largerEq: largerEq2,
|
|
SparseMatrix: SparseMatrix2
|
|
} = _ref;
|
|
var csSqr = createCsSqr({
|
|
add: add3,
|
|
multiply: multiply2,
|
|
transpose: transpose2
|
|
});
|
|
var csLu = createCsLu({
|
|
abs: abs3,
|
|
divideScalar: divideScalar2,
|
|
multiply: multiply2,
|
|
subtract: subtract2,
|
|
larger: larger2,
|
|
largerEq: largerEq2,
|
|
SparseMatrix: SparseMatrix2
|
|
});
|
|
return typed2(name231, {
|
|
"SparseMatrix, number, number": function SparseMatrixNumberNumber(a, order, threshold) {
|
|
if (!isInteger(order) || order < 0 || order > 3) {
|
|
throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");
|
|
}
|
|
if (threshold < 0 || threshold > 1) {
|
|
throw new Error("Partial pivoting threshold must be a number from 0 to 1");
|
|
}
|
|
var s = csSqr(order, a, false);
|
|
var f = csLu(a, s, threshold);
|
|
return {
|
|
L: f.L,
|
|
U: f.U,
|
|
p: f.pinv,
|
|
q: s.q,
|
|
toString: function toString() {
|
|
return "L: " + this.L.toString() + "\nU: " + this.U.toString() + "\np: " + this.p.toString() + (this.q ? "\nq: " + this.q.toString() : "") + "\n";
|
|
}
|
|
};
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/sparse/csIpvec.js
|
|
function csIpvec(p, b) {
|
|
var k;
|
|
var n = b.length;
|
|
var x = [];
|
|
if (p) {
|
|
for (k = 0; k < n; k++) {
|
|
x[p[k]] = b[k];
|
|
}
|
|
} else {
|
|
for (k = 0; k < n; k++) {
|
|
x[k] = b[k];
|
|
}
|
|
}
|
|
return x;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/solver/lusolve.js
|
|
var name232 = "lusolve";
|
|
var dependencies232 = ["typed", "matrix", "lup", "slu", "usolve", "lsolve", "DenseMatrix"];
|
|
var createLusolve = /* @__PURE__ */ factory(name232, dependencies232, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
lup: lup2,
|
|
slu: slu2,
|
|
usolve: usolve2,
|
|
lsolve: lsolve2,
|
|
DenseMatrix: DenseMatrix2
|
|
} = _ref;
|
|
var solveValidation = createSolveValidation({
|
|
DenseMatrix: DenseMatrix2
|
|
});
|
|
return typed2(name232, {
|
|
"Array, Array | Matrix": function ArrayArrayMatrix(a, b) {
|
|
a = matrix2(a);
|
|
var d = lup2(a);
|
|
var x = _lusolve(d.L, d.U, d.p, null, b);
|
|
return x.valueOf();
|
|
},
|
|
"DenseMatrix, Array | Matrix": function DenseMatrixArrayMatrix(a, b) {
|
|
var d = lup2(a);
|
|
return _lusolve(d.L, d.U, d.p, null, b);
|
|
},
|
|
"SparseMatrix, Array | Matrix": function SparseMatrixArrayMatrix(a, b) {
|
|
var d = lup2(a);
|
|
return _lusolve(d.L, d.U, d.p, null, b);
|
|
},
|
|
"SparseMatrix, Array | Matrix, number, number": function SparseMatrixArrayMatrixNumberNumber(a, b, order, threshold) {
|
|
var d = slu2(a, order, threshold);
|
|
return _lusolve(d.L, d.U, d.p, d.q, b);
|
|
},
|
|
"Object, Array | Matrix": function ObjectArrayMatrix(d, b) {
|
|
return _lusolve(d.L, d.U, d.p, d.q, b);
|
|
}
|
|
});
|
|
function _toMatrix(a) {
|
|
if (isMatrix(a)) {
|
|
return a;
|
|
}
|
|
if (isArray(a)) {
|
|
return matrix2(a);
|
|
}
|
|
throw new TypeError("Invalid Matrix LU decomposition");
|
|
}
|
|
function _lusolve(l, u, p, q, b) {
|
|
l = _toMatrix(l);
|
|
u = _toMatrix(u);
|
|
if (p) {
|
|
b = solveValidation(l, b, true);
|
|
b._data = csIpvec(p, b._data);
|
|
}
|
|
var y = lsolve2(l, b);
|
|
var x = usolve2(u, y);
|
|
if (q) {
|
|
x._data = csIpvec(q, x._data);
|
|
}
|
|
return x;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/polynomialRoot.js
|
|
var name233 = "polynomialRoot";
|
|
var dependencies233 = ["typed", "isZero", "equalScalar", "add", "subtract", "multiply", "divide", "sqrt", "unaryMinus", "cbrt", "typeOf", "im", "re"];
|
|
var createPolynomialRoot = /* @__PURE__ */ factory(name233, dependencies233, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
isZero: isZero2,
|
|
equalScalar: equalScalar2,
|
|
add: add3,
|
|
subtract: subtract2,
|
|
multiply: multiply2,
|
|
divide: divide3,
|
|
sqrt: sqrt3,
|
|
unaryMinus: unaryMinus2,
|
|
cbrt: cbrt5,
|
|
typeOf: typeOf3,
|
|
im: im2,
|
|
re: re2
|
|
} = _ref;
|
|
return typed2(name233, {
|
|
"number|Complex, ...number|Complex": (constant, restCoeffs) => {
|
|
var coeffs = [constant, ...restCoeffs];
|
|
while (coeffs.length > 0 && isZero2(coeffs[coeffs.length - 1])) {
|
|
coeffs.pop();
|
|
}
|
|
if (coeffs.length < 2) {
|
|
throw new RangeError("Polynomial [".concat(constant, ", ").concat(restCoeffs, "] must have a non-zero non-constant coefficient"));
|
|
}
|
|
switch (coeffs.length) {
|
|
case 2:
|
|
return [unaryMinus2(divide3(coeffs[0], coeffs[1]))];
|
|
case 3: {
|
|
var [c, b, a] = coeffs;
|
|
var denom = multiply2(2, a);
|
|
var d1 = multiply2(b, b);
|
|
var d2 = multiply2(4, a, c);
|
|
if (equalScalar2(d1, d2))
|
|
return [divide3(unaryMinus2(b), denom)];
|
|
var discriminant = sqrt3(subtract2(d1, d2));
|
|
return [divide3(subtract2(discriminant, b), denom), divide3(subtract2(unaryMinus2(discriminant), b), denom)];
|
|
}
|
|
case 4: {
|
|
var [d, _c, _b, _a] = coeffs;
|
|
var _denom = unaryMinus2(multiply2(3, _a));
|
|
var D0_1 = multiply2(_b, _b);
|
|
var D0_2 = multiply2(3, _a, _c);
|
|
var D1_1 = add3(multiply2(2, _b, _b, _b), multiply2(27, _a, _a, d));
|
|
var D1_2 = multiply2(9, _a, _b, _c);
|
|
if (equalScalar2(D0_1, D0_2) && equalScalar2(D1_1, D1_2)) {
|
|
return [divide3(_b, _denom)];
|
|
}
|
|
var Delta0 = subtract2(D0_1, D0_2);
|
|
var Delta1 = subtract2(D1_1, D1_2);
|
|
var discriminant1 = add3(multiply2(18, _a, _b, _c, d), multiply2(_b, _b, _c, _c));
|
|
var discriminant2 = add3(multiply2(4, _b, _b, _b, d), multiply2(4, _a, _c, _c, _c), multiply2(27, _a, _a, d, d));
|
|
if (equalScalar2(discriminant1, discriminant2)) {
|
|
return [
|
|
divide3(subtract2(multiply2(4, _a, _b, _c), add3(multiply2(9, _a, _a, d), multiply2(_b, _b, _b))), multiply2(_a, Delta0)),
|
|
divide3(subtract2(multiply2(9, _a, d), multiply2(_b, _c)), multiply2(2, Delta0))
|
|
];
|
|
}
|
|
var Ccubed;
|
|
if (equalScalar2(D0_1, D0_2)) {
|
|
Ccubed = Delta1;
|
|
} else {
|
|
Ccubed = divide3(add3(Delta1, sqrt3(subtract2(multiply2(Delta1, Delta1), multiply2(4, Delta0, Delta0, Delta0)))), 2);
|
|
}
|
|
var allRoots = true;
|
|
var rawRoots = cbrt5(Ccubed, allRoots).toArray().map((C) => divide3(add3(_b, C, divide3(Delta0, C)), _denom));
|
|
return rawRoots.map((r) => {
|
|
if (typeOf3(r) === "Complex" && equalScalar2(re2(r), re2(r) + im2(r))) {
|
|
return re2(r);
|
|
}
|
|
return r;
|
|
});
|
|
}
|
|
default:
|
|
throw new RangeError("only implemented for cubic or lower-order polynomials, not ".concat(coeffs));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/Help.js
|
|
var name234 = "Help";
|
|
var dependencies234 = ["parse"];
|
|
var createHelpClass = /* @__PURE__ */ factory(name234, dependencies234, (_ref) => {
|
|
var {
|
|
parse: parse2
|
|
} = _ref;
|
|
function Help2(doc) {
|
|
if (!(this instanceof Help2)) {
|
|
throw new SyntaxError("Constructor must be called with the new operator");
|
|
}
|
|
if (!doc)
|
|
throw new Error('Argument "doc" missing');
|
|
this.doc = doc;
|
|
}
|
|
Help2.prototype.type = "Help";
|
|
Help2.prototype.isHelp = true;
|
|
Help2.prototype.toString = function() {
|
|
var doc = this.doc || {};
|
|
var desc = "\n";
|
|
if (doc.name) {
|
|
desc += "Name: " + doc.name + "\n\n";
|
|
}
|
|
if (doc.category) {
|
|
desc += "Category: " + doc.category + "\n\n";
|
|
}
|
|
if (doc.description) {
|
|
desc += "Description:\n " + doc.description + "\n\n";
|
|
}
|
|
if (doc.syntax) {
|
|
desc += "Syntax:\n " + doc.syntax.join("\n ") + "\n\n";
|
|
}
|
|
if (doc.examples) {
|
|
desc += "Examples:\n";
|
|
var scope = {};
|
|
for (var i2 = 0; i2 < doc.examples.length; i2++) {
|
|
var expr = doc.examples[i2];
|
|
desc += " " + expr + "\n";
|
|
var res = void 0;
|
|
try {
|
|
res = parse2(expr).compile().evaluate(scope);
|
|
} catch (e3) {
|
|
res = e3;
|
|
}
|
|
if (res !== void 0 && !isHelp(res)) {
|
|
desc += " " + format3(res, {
|
|
precision: 14
|
|
}) + "\n";
|
|
}
|
|
}
|
|
desc += "\n";
|
|
}
|
|
if (doc.mayThrow && doc.mayThrow.length) {
|
|
desc += "Throws: " + doc.mayThrow.join(", ") + "\n\n";
|
|
}
|
|
if (doc.seealso && doc.seealso.length) {
|
|
desc += "See also: " + doc.seealso.join(", ") + "\n";
|
|
}
|
|
return desc;
|
|
};
|
|
Help2.prototype.toJSON = function() {
|
|
var obj = clone(this.doc);
|
|
obj.mathjs = "Help";
|
|
return obj;
|
|
};
|
|
Help2.fromJSON = function(json) {
|
|
var doc = {};
|
|
Object.keys(json).filter((prop) => prop !== "mathjs").forEach((prop) => {
|
|
doc[prop] = json[prop];
|
|
});
|
|
return new Help2(doc);
|
|
};
|
|
Help2.prototype.valueOf = Help2.prototype.toString;
|
|
return Help2;
|
|
}, {
|
|
isClass: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/chain/Chain.js
|
|
var name235 = "Chain";
|
|
var dependencies235 = ["?on", "math", "typed"];
|
|
var createChainClass = /* @__PURE__ */ factory(name235, dependencies235, (_ref) => {
|
|
var {
|
|
on,
|
|
math: math2,
|
|
typed: typed2
|
|
} = _ref;
|
|
function Chain2(value) {
|
|
if (!(this instanceof Chain2)) {
|
|
throw new SyntaxError("Constructor must be called with the new operator");
|
|
}
|
|
if (isChain(value)) {
|
|
this.value = value.value;
|
|
} else {
|
|
this.value = value;
|
|
}
|
|
}
|
|
Chain2.prototype.type = "Chain";
|
|
Chain2.prototype.isChain = true;
|
|
Chain2.prototype.done = function() {
|
|
return this.value;
|
|
};
|
|
Chain2.prototype.valueOf = function() {
|
|
return this.value;
|
|
};
|
|
Chain2.prototype.toString = function() {
|
|
return format3(this.value);
|
|
};
|
|
Chain2.prototype.toJSON = function() {
|
|
return {
|
|
mathjs: "Chain",
|
|
value: this.value
|
|
};
|
|
};
|
|
Chain2.fromJSON = function(json) {
|
|
return new Chain2(json.value);
|
|
};
|
|
function createProxy(name302, fn) {
|
|
if (typeof fn === "function") {
|
|
Chain2.prototype[name302] = chainify(fn);
|
|
}
|
|
}
|
|
function createLazyProxy(name302, resolver) {
|
|
lazy(Chain2.prototype, name302, function outerResolver() {
|
|
var fn = resolver();
|
|
if (typeof fn === "function") {
|
|
return chainify(fn);
|
|
}
|
|
return void 0;
|
|
});
|
|
}
|
|
function chainify(fn) {
|
|
return function() {
|
|
if (arguments.length === 0) {
|
|
return new Chain2(fn(this.value));
|
|
}
|
|
var args = [this.value];
|
|
for (var i2 = 0; i2 < arguments.length; i2++) {
|
|
args[i2 + 1] = arguments[i2];
|
|
}
|
|
if (typed2.isTypedFunction(fn)) {
|
|
var sigObject = typed2.resolve(fn, args);
|
|
if (sigObject.params.length === 1) {
|
|
throw new Error("chain function " + fn.name + " cannot match rest parameter between chain value and additional arguments.");
|
|
}
|
|
return new Chain2(sigObject.implementation.apply(fn, args));
|
|
}
|
|
return new Chain2(fn.apply(fn, args));
|
|
};
|
|
}
|
|
Chain2.createProxy = function(arg0, arg1) {
|
|
if (typeof arg0 === "string") {
|
|
createProxy(arg0, arg1);
|
|
} else {
|
|
var _loop = function _loop2(_name2) {
|
|
if (hasOwnProperty2(arg0, _name2) && excludedNames[_name2] === void 0) {
|
|
createLazyProxy(_name2, () => arg0[_name2]);
|
|
}
|
|
};
|
|
for (var _name in arg0) {
|
|
_loop(_name);
|
|
}
|
|
}
|
|
};
|
|
var excludedNames = {
|
|
expression: true,
|
|
docs: true,
|
|
type: true,
|
|
classes: true,
|
|
json: true,
|
|
error: true,
|
|
isChain: true
|
|
};
|
|
Chain2.createProxy(math2);
|
|
if (on) {
|
|
on("import", function(name302, resolver, path) {
|
|
if (!path) {
|
|
createLazyProxy(name302, resolver);
|
|
}
|
|
});
|
|
}
|
|
return Chain2;
|
|
}, {
|
|
isClass: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/constants/e.js
|
|
var eDocs = {
|
|
name: "e",
|
|
category: "Constants",
|
|
syntax: ["e"],
|
|
description: "Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",
|
|
examples: ["e", "e ^ 2", "exp(2)", "log(e)"],
|
|
seealso: ["exp"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/constants/false.js
|
|
var falseDocs = {
|
|
name: "false",
|
|
category: "Constants",
|
|
syntax: ["false"],
|
|
description: "Boolean value false",
|
|
examples: ["false"],
|
|
seealso: ["true"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/constants/i.js
|
|
var iDocs = {
|
|
name: "i",
|
|
category: "Constants",
|
|
syntax: ["i"],
|
|
description: "Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",
|
|
examples: ["i", "i * i", "sqrt(-1)"],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/constants/Infinity.js
|
|
var InfinityDocs = {
|
|
name: "Infinity",
|
|
category: "Constants",
|
|
syntax: ["Infinity"],
|
|
description: "Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",
|
|
examples: ["Infinity", "1 / 0"],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/constants/LN10.js
|
|
var LN10Docs = {
|
|
name: "LN10",
|
|
category: "Constants",
|
|
syntax: ["LN10"],
|
|
description: "Returns the natural logarithm of 10, approximately equal to 2.302",
|
|
examples: ["LN10", "log(10)"],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/constants/LN2.js
|
|
var LN2Docs = {
|
|
name: "LN2",
|
|
category: "Constants",
|
|
syntax: ["LN2"],
|
|
description: "Returns the natural logarithm of 2, approximately equal to 0.693",
|
|
examples: ["LN2", "log(2)"],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/constants/LOG10E.js
|
|
var LOG10EDocs = {
|
|
name: "LOG10E",
|
|
category: "Constants",
|
|
syntax: ["LOG10E"],
|
|
description: "Returns the base-10 logarithm of E, approximately equal to 0.434",
|
|
examples: ["LOG10E", "log(e, 10)"],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/constants/LOG2E.js
|
|
var LOG2EDocs = {
|
|
name: "LOG2E",
|
|
category: "Constants",
|
|
syntax: ["LOG2E"],
|
|
description: "Returns the base-2 logarithm of E, approximately equal to 1.442",
|
|
examples: ["LOG2E", "log(e, 2)"],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/constants/NaN.js
|
|
var NaNDocs = {
|
|
name: "NaN",
|
|
category: "Constants",
|
|
syntax: ["NaN"],
|
|
description: "Not a number",
|
|
examples: ["NaN", "0 / 0"],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/constants/null.js
|
|
var nullDocs = {
|
|
name: "null",
|
|
category: "Constants",
|
|
syntax: ["null"],
|
|
description: "Value null",
|
|
examples: ["null"],
|
|
seealso: ["true", "false"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/constants/phi.js
|
|
var phiDocs = {
|
|
name: "phi",
|
|
category: "Constants",
|
|
syntax: ["phi"],
|
|
description: "Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",
|
|
examples: ["phi"],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/constants/pi.js
|
|
var piDocs = {
|
|
name: "pi",
|
|
category: "Constants",
|
|
syntax: ["pi"],
|
|
description: "The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",
|
|
examples: ["pi", "sin(pi/2)"],
|
|
seealso: ["tau"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/constants/SQRT1_2.js
|
|
var SQRT12Docs = {
|
|
name: "SQRT1_2",
|
|
category: "Constants",
|
|
syntax: ["SQRT1_2"],
|
|
description: "Returns the square root of 1/2, approximately equal to 0.707",
|
|
examples: ["SQRT1_2", "sqrt(1/2)"],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/constants/SQRT2.js
|
|
var SQRT2Docs = {
|
|
name: "SQRT2",
|
|
category: "Constants",
|
|
syntax: ["SQRT2"],
|
|
description: "Returns the square root of 2, approximately equal to 1.414",
|
|
examples: ["SQRT2", "sqrt(2)"],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/constants/tau.js
|
|
var tauDocs = {
|
|
name: "tau",
|
|
category: "Constants",
|
|
syntax: ["tau"],
|
|
description: "Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",
|
|
examples: ["tau", "2 * pi"],
|
|
seealso: ["pi"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/constants/true.js
|
|
var trueDocs = {
|
|
name: "true",
|
|
category: "Constants",
|
|
syntax: ["true"],
|
|
description: "Boolean value true",
|
|
examples: ["true"],
|
|
seealso: ["false"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/constants/version.js
|
|
var versionDocs = {
|
|
name: "version",
|
|
category: "Constants",
|
|
syntax: ["version"],
|
|
description: "A string with the version number of math.js",
|
|
examples: ["version"],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/construction/bignumber.js
|
|
var bignumberDocs = {
|
|
name: "bignumber",
|
|
category: "Construction",
|
|
syntax: ["bignumber(x)"],
|
|
description: "Create a big number from a number or string.",
|
|
examples: ["0.1 + 0.2", "bignumber(0.1) + bignumber(0.2)", 'bignumber("7.2")', 'bignumber("7.2e500")', "bignumber([0.1, 0.2, 0.3])"],
|
|
seealso: ["boolean", "complex", "fraction", "index", "matrix", "string", "unit"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/construction/boolean.js
|
|
var booleanDocs = {
|
|
name: "boolean",
|
|
category: "Construction",
|
|
syntax: ["x", "boolean(x)"],
|
|
description: "Convert a string or number into a boolean.",
|
|
examples: ["boolean(0)", "boolean(1)", "boolean(3)", 'boolean("true")', 'boolean("false")', "boolean([1, 0, 1, 1])"],
|
|
seealso: ["bignumber", "complex", "index", "matrix", "number", "string", "unit"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/construction/complex.js
|
|
var complexDocs = {
|
|
name: "complex",
|
|
category: "Construction",
|
|
syntax: ["complex()", "complex(re, im)", "complex(string)"],
|
|
description: "Create a complex number.",
|
|
examples: ["complex()", "complex(2, 3)", 'complex("7 - 2i")'],
|
|
seealso: ["bignumber", "boolean", "index", "matrix", "number", "string", "unit"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/construction/createUnit.js
|
|
var createUnitDocs = {
|
|
name: "createUnit",
|
|
category: "Construction",
|
|
syntax: ["createUnit(definitions)", "createUnit(name, definition)"],
|
|
description: "Create a user-defined unit and register it with the Unit type.",
|
|
examples: ['createUnit("foo")', 'createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})', 'createUnit("mph", "1 mile/hour")'],
|
|
seealso: ["unit", "splitUnit"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/construction/fraction.js
|
|
var fractionDocs = {
|
|
name: "fraction",
|
|
category: "Construction",
|
|
syntax: ["fraction(num)", "fraction(matrix)", "fraction(num,den)", "fraction({n: num, d: den})"],
|
|
description: "Create a fraction from a number or from integer numerator and denominator.",
|
|
examples: ["fraction(0.125)", "fraction(1, 3) + fraction(2, 5)", "fraction({n: 333, d: 53})", "fraction([sqrt(9), sqrt(10), sqrt(11)])"],
|
|
seealso: ["bignumber", "boolean", "complex", "index", "matrix", "string", "unit"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/construction/index.js
|
|
var indexDocs = {
|
|
name: "index",
|
|
category: "Construction",
|
|
syntax: ["[start]", "[start:end]", "[start:step:end]", "[start1, start 2, ...]", "[start1:end1, start2:end2, ...]", "[start1:step1:end1, start2:step2:end2, ...]"],
|
|
description: "Create an index to get or replace a subset of a matrix",
|
|
examples: ["[1, 2, 3]", "A = [1, 2, 3; 4, 5, 6]", "A[1, :]", "A[1, 2] = 50", "A[1:2, 1:2] = ones(2, 2)"],
|
|
seealso: ["bignumber", "boolean", "complex", "matrix,", "number", "range", "string", "unit"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/construction/matrix.js
|
|
var matrixDocs = {
|
|
name: "matrix",
|
|
category: "Construction",
|
|
syntax: ["[]", "[a1, b1, ...; a2, b2, ...]", "matrix()", 'matrix("dense")', "matrix([...])"],
|
|
description: "Create a matrix.",
|
|
examples: ["[]", "[1, 2, 3]", "[1, 2, 3; 4, 5, 6]", "matrix()", "matrix([3, 4])", 'matrix([3, 4; 5, 6], "sparse")', 'matrix([3, 4; 5, 6], "sparse", "number")'],
|
|
seealso: ["bignumber", "boolean", "complex", "index", "number", "string", "unit", "sparse"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/construction/number.js
|
|
var numberDocs = {
|
|
name: "number",
|
|
category: "Construction",
|
|
syntax: ["x", "number(x)", "number(unit, valuelessUnit)"],
|
|
description: "Create a number or convert a string or boolean into a number.",
|
|
examples: ["2", "2e3", "4.05", "number(2)", 'number("7.2")', "number(true)", "number([true, false, true, true])", 'number(unit("52cm"), "m")'],
|
|
seealso: ["bignumber", "boolean", "complex", "fraction", "index", "matrix", "string", "unit"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/construction/sparse.js
|
|
var sparseDocs = {
|
|
name: "sparse",
|
|
category: "Construction",
|
|
syntax: ["sparse()", "sparse([a1, b1, ...; a1, b2, ...])", 'sparse([a1, b1, ...; a1, b2, ...], "number")'],
|
|
description: "Create a sparse matrix.",
|
|
examples: ["sparse()", "sparse([3, 4; 5, 6])", 'sparse([3, 0; 5, 0], "number")'],
|
|
seealso: ["bignumber", "boolean", "complex", "index", "number", "string", "unit", "matrix"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/construction/splitUnit.js
|
|
var splitUnitDocs = {
|
|
name: "splitUnit",
|
|
category: "Construction",
|
|
syntax: ["splitUnit(unit: Unit, parts: Unit[])"],
|
|
description: "Split a unit in an array of units whose sum is equal to the original unit.",
|
|
examples: ['splitUnit(1 m, ["feet", "inch"])'],
|
|
seealso: ["unit", "createUnit"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/construction/string.js
|
|
var stringDocs = {
|
|
name: "string",
|
|
category: "Construction",
|
|
syntax: ['"text"', "string(x)"],
|
|
description: "Create a string or convert a value to a string",
|
|
examples: ['"Hello World!"', "string(4.2)", "string(3 + 2i)"],
|
|
seealso: ["bignumber", "boolean", "complex", "index", "matrix", "number", "unit"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/construction/unit.js
|
|
var unitDocs = {
|
|
name: "unit",
|
|
category: "Construction",
|
|
syntax: ["value unit", "unit(value, unit)", "unit(string)"],
|
|
description: "Create a unit.",
|
|
examples: ["5.5 mm", "3 inch", 'unit(7.1, "kilogram")', 'unit("23 deg")'],
|
|
seealso: ["bignumber", "boolean", "complex", "index", "matrix", "number", "string"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/core/config.js
|
|
var configDocs = {
|
|
name: "config",
|
|
category: "Core",
|
|
syntax: ["config()", "config(options)"],
|
|
description: "Get configuration or change configuration.",
|
|
examples: ["config()", "1/3 + 1/4", 'config({number: "Fraction"})', "1/3 + 1/4"],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/core/import.js
|
|
var importDocs = {
|
|
name: "import",
|
|
category: "Core",
|
|
syntax: ["import(functions)", "import(functions, options)"],
|
|
description: "Import functions or constants from an object.",
|
|
examples: ["import({myFn: f(x)=x^2, myConstant: 32 })", "myFn(2)", "myConstant"],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/core/typed.js
|
|
var typedDocs = {
|
|
name: "typed",
|
|
category: "Core",
|
|
syntax: ["typed(signatures)", "typed(name, signatures)"],
|
|
description: "Create a typed function.",
|
|
examples: ['double = typed({ "number": f(x)=x+x })', "double(2)", 'double("hello")'],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/algebra/derivative.js
|
|
var derivativeDocs = {
|
|
name: "derivative",
|
|
category: "Algebra",
|
|
syntax: ["derivative(expr, variable)", "derivative(expr, variable, {simplify: boolean})"],
|
|
description: "Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",
|
|
examples: ['derivative("2x^3", "x")', 'derivative("2x^3", "x", {simplify: false})', 'derivative("2x^2 + 3x + 4", "x")', 'derivative("sin(2x)", "x")', 'f = parse("x^2 + x")', 'x = parse("x")', "df = derivative(f, x)", "df.evaluate({x: 3})"],
|
|
seealso: ["simplify", "parse", "evaluate"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/algebra/leafCount.js
|
|
var leafCountDocs = {
|
|
name: "leafCount",
|
|
category: "Algebra",
|
|
syntax: ["leafCount(expr)"],
|
|
description: "Computes the number of leaves in the parse tree of the given expression",
|
|
examples: ['leafCount("e^(i*pi)-1")', 'leafCount(parse("{a: 22/7, b: 10^(1/2)}"))'],
|
|
seealso: ["simplify"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/algebra/lsolve.js
|
|
var lsolveDocs = {
|
|
name: "lsolve",
|
|
category: "Algebra",
|
|
syntax: ["x=lsolve(L, b)"],
|
|
description: "Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",
|
|
examples: ["a = [-2, 3; 2, 1]", "b = [11, 9]", "x = lsolve(a, b)"],
|
|
seealso: ["lsolveAll", "lup", "lusolve", "usolve", "matrix", "sparse"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/algebra/lsolveAll.js
|
|
var lsolveAllDocs = {
|
|
name: "lsolveAll",
|
|
category: "Algebra",
|
|
syntax: ["x=lsolveAll(L, b)"],
|
|
description: "Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",
|
|
examples: ["a = [-2, 3; 2, 1]", "b = [11, 9]", "x = lsolve(a, b)"],
|
|
seealso: ["lsolve", "lup", "lusolve", "usolve", "matrix", "sparse"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/algebra/lup.js
|
|
var lupDocs = {
|
|
name: "lup",
|
|
category: "Algebra",
|
|
syntax: ["lup(m)"],
|
|
description: "Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",
|
|
examples: ["lup([[2, 1], [1, 4]])", "lup(matrix([[2, 1], [1, 4]]))", "lup(sparse([[2, 1], [1, 4]]))"],
|
|
seealso: ["lusolve", "lsolve", "usolve", "matrix", "sparse", "slu", "qr"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/algebra/lusolve.js
|
|
var lusolveDocs = {
|
|
name: "lusolve",
|
|
category: "Algebra",
|
|
syntax: ["x=lusolve(A, b)", "x=lusolve(lu, b)"],
|
|
description: "Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",
|
|
examples: ["a = [-2, 3; 2, 1]", "b = [11, 9]", "x = lusolve(a, b)"],
|
|
seealso: ["lup", "slu", "lsolve", "usolve", "matrix", "sparse"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/algebra/polynomialRoot.js
|
|
var polynomialRootDocs = {
|
|
name: "polynomialRoot",
|
|
category: "Algebra",
|
|
syntax: ["x=polynomialRoot(-6, 3)", "x=polynomialRoot(4, -4, 1)", "x=polynomialRoot(-8, 12, -6, 1)"],
|
|
description: "Finds the roots of a univariate polynomial given by its coefficients starting from constant, linear, and so on, increasing in degree.",
|
|
examples: ["a = polynomialRoot(-6, 11, -6 1)"],
|
|
seealso: ["cbrt", "sqrt"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/algebra/qr.js
|
|
var qrDocs = {
|
|
name: "qr",
|
|
category: "Algebra",
|
|
syntax: ["qr(A)"],
|
|
description: "Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",
|
|
examples: ["qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])"],
|
|
seealso: ["lup", "slu", "matrix"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/algebra/rationalize.js
|
|
var rationalizeDocs = {
|
|
name: "rationalize",
|
|
category: "Algebra",
|
|
syntax: ["rationalize(expr)", "rationalize(expr, scope)", "rationalize(expr, scope, detailed)"],
|
|
description: "Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",
|
|
examples: ['rationalize("2x/y - y/(x+1)")', 'rationalize("2x/y - y/(x+1)", true)'],
|
|
seealso: ["simplify"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/algebra/resolve.js
|
|
var resolveDocs = {
|
|
name: "resolve",
|
|
category: "Algebra",
|
|
syntax: ["resolve(node, scope)"],
|
|
description: "Recursively substitute variables in an expression tree.",
|
|
examples: ['resolve(parse("1 + x"), { x: 7 })', 'resolve(parse("size(text)"), { text: "Hello World" })', 'resolve(parse("x + y"), { x: parse("3z") })', 'resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })'],
|
|
seealso: ["simplify", "evaluate"],
|
|
mayThrow: ["ReferenceError"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/algebra/simplify.js
|
|
var simplifyDocs = {
|
|
name: "simplify",
|
|
category: "Algebra",
|
|
syntax: ["simplify(expr)", "simplify(expr, rules)"],
|
|
description: "Simplify an expression tree.",
|
|
examples: ['simplify("3 + 2 / 4")', 'simplify("2x + x")', 'f = parse("x * (x + 2 + x)")', "simplified = simplify(f)", "simplified.evaluate({x: 2})"],
|
|
seealso: ["simplifyCore", "derivative", "evaluate", "parse", "rationalize", "resolve"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/algebra/simplifyConstant.js
|
|
var simplifyConstantDocs = {
|
|
name: "simplifyConstant",
|
|
category: "Algebra",
|
|
syntax: ["simplifyConstant(expr)", "simplifyConstant(expr, options)"],
|
|
description: "Replace constant subexpressions of node with their values.",
|
|
examples: ['simplifyConatant("(3-3)*x")', 'simplifyConstant(parse("z-cos(tau/8)"))'],
|
|
seealso: ["simplify", "simplifyCore", "evaluate"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/algebra/simplifyCore.js
|
|
var simplifyCoreDocs = {
|
|
name: "simplifyCore",
|
|
category: "Algebra",
|
|
syntax: ["simplifyCore(node)"],
|
|
description: "Perform simple one-pass simplifications on an expression tree.",
|
|
examples: ['simplifyCore(parse("0*x"))', 'simplifyCore(parse("(x+0)*2"))'],
|
|
seealso: ["simplify", "simplifyConstant", "evaluate"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/algebra/slu.js
|
|
var sluDocs = {
|
|
name: "slu",
|
|
category: "Algebra",
|
|
syntax: ["slu(A, order, threshold)"],
|
|
description: "Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",
|
|
examples: ["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],
|
|
seealso: ["lusolve", "lsolve", "usolve", "matrix", "sparse", "lup", "qr"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/algebra/symbolicEqual.js
|
|
var symbolicEqualDocs = {
|
|
name: "symbolicEqual",
|
|
category: "Algebra",
|
|
syntax: ["symbolicEqual(expr1, expr2)", "symbolicEqual(expr1, expr2, options)"],
|
|
description: "Returns true if the difference of the expressions simplifies to 0",
|
|
examples: ['symbolicEqual("x*y","y*x")', 'symbolicEqual("abs(x^2)", "x^2")', 'symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})'],
|
|
seealso: ["simplify", "evaluate"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/algebra/usolve.js
|
|
var usolveDocs = {
|
|
name: "usolve",
|
|
category: "Algebra",
|
|
syntax: ["x=usolve(U, b)"],
|
|
description: "Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",
|
|
examples: ["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],
|
|
seealso: ["usolveAll", "lup", "lusolve", "lsolve", "matrix", "sparse"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/algebra/usolveAll.js
|
|
var usolveAllDocs = {
|
|
name: "usolveAll",
|
|
category: "Algebra",
|
|
syntax: ["x=usolve(U, b)"],
|
|
description: "Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",
|
|
examples: ["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],
|
|
seealso: ["usolve", "lup", "lusolve", "lsolve", "matrix", "sparse"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/abs.js
|
|
var absDocs = {
|
|
name: "abs",
|
|
category: "Arithmetic",
|
|
syntax: ["abs(x)"],
|
|
description: "Compute the absolute value.",
|
|
examples: ["abs(3.5)", "abs(-4.2)"],
|
|
seealso: ["sign"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/add.js
|
|
var addDocs = {
|
|
name: "add",
|
|
category: "Operators",
|
|
syntax: ["x + y", "add(x, y)"],
|
|
description: "Add two values.",
|
|
examples: ["a = 2.1 + 3.6", "a - 3.6", "3 + 2i", "3 cm + 2 inch", '"2.3" + "4"'],
|
|
seealso: ["subtract"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/cbrt.js
|
|
var cbrtDocs = {
|
|
name: "cbrt",
|
|
category: "Arithmetic",
|
|
syntax: ["cbrt(x)", "cbrt(x, allRoots)"],
|
|
description: "Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",
|
|
examples: ["cbrt(64)", "cube(4)", "cbrt(-8)", "cbrt(2 + 3i)", "cbrt(8i)", "cbrt(8i, true)", "cbrt(27 m^3)"],
|
|
seealso: ["square", "sqrt", "cube", "multiply"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/ceil.js
|
|
var ceilDocs = {
|
|
name: "ceil",
|
|
category: "Arithmetic",
|
|
syntax: ["ceil(x)"],
|
|
description: "Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",
|
|
examples: ["ceil(3.2)", "ceil(3.8)", "ceil(-4.2)"],
|
|
seealso: ["floor", "fix", "round"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/cube.js
|
|
var cubeDocs = {
|
|
name: "cube",
|
|
category: "Arithmetic",
|
|
syntax: ["cube(x)"],
|
|
description: "Compute the cube of a value. The cube of x is x * x * x.",
|
|
examples: ["cube(2)", "2^3", "2 * 2 * 2"],
|
|
seealso: ["multiply", "square", "pow"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/divide.js
|
|
var divideDocs = {
|
|
name: "divide",
|
|
category: "Operators",
|
|
syntax: ["x / y", "divide(x, y)"],
|
|
description: "Divide two values.",
|
|
examples: ["a = 2 / 3", "a * 3", "4.5 / 2", "3 + 4 / 2", "(3 + 4) / 2", "18 km / 4.5"],
|
|
seealso: ["multiply"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/dotDivide.js
|
|
var dotDivideDocs = {
|
|
name: "dotDivide",
|
|
category: "Operators",
|
|
syntax: ["x ./ y", "dotDivide(x, y)"],
|
|
description: "Divide two values element wise.",
|
|
examples: ["a = [1, 2, 3; 4, 5, 6]", "b = [2, 1, 1; 3, 2, 5]", "a ./ b"],
|
|
seealso: ["multiply", "dotMultiply", "divide"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/dotMultiply.js
|
|
var dotMultiplyDocs = {
|
|
name: "dotMultiply",
|
|
category: "Operators",
|
|
syntax: ["x .* y", "dotMultiply(x, y)"],
|
|
description: "Multiply two values element wise.",
|
|
examples: ["a = [1, 2, 3; 4, 5, 6]", "b = [2, 1, 1; 3, 2, 5]", "a .* b"],
|
|
seealso: ["multiply", "divide", "dotDivide"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/dotPow.js
|
|
var dotPowDocs = {
|
|
name: "dotPow",
|
|
category: "Operators",
|
|
syntax: ["x .^ y", "dotPow(x, y)"],
|
|
description: "Calculates the power of x to y element wise.",
|
|
examples: ["a = [1, 2, 3; 4, 5, 6]", "a .^ 2"],
|
|
seealso: ["pow"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/exp.js
|
|
var expDocs = {
|
|
name: "exp",
|
|
category: "Arithmetic",
|
|
syntax: ["exp(x)"],
|
|
description: "Calculate the exponent of a value.",
|
|
examples: ["exp(1.3)", "e ^ 1.3", "log(exp(1.3))", "x = 2.4", "(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],
|
|
seealso: ["expm", "expm1", "pow", "log"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/expm.js
|
|
var expmDocs = {
|
|
name: "expm",
|
|
category: "Arithmetic",
|
|
syntax: ["exp(x)"],
|
|
description: "Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",
|
|
examples: ["expm([[0,2],[0,0]])"],
|
|
seealso: ["exp"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/expm1.js
|
|
var expm1Docs = {
|
|
name: "expm1",
|
|
category: "Arithmetic",
|
|
syntax: ["expm1(x)"],
|
|
description: "Calculate the value of subtracting 1 from the exponential value.",
|
|
examples: ["expm1(2)", "pow(e, 2) - 1", "log(expm1(2) + 1)"],
|
|
seealso: ["exp", "pow", "log"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/fix.js
|
|
var fixDocs = {
|
|
name: "fix",
|
|
category: "Arithmetic",
|
|
syntax: ["fix(x)"],
|
|
description: "Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",
|
|
examples: ["fix(3.2)", "fix(3.8)", "fix(-4.2)", "fix(-4.8)"],
|
|
seealso: ["ceil", "floor", "round"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/floor.js
|
|
var floorDocs = {
|
|
name: "floor",
|
|
category: "Arithmetic",
|
|
syntax: ["floor(x)"],
|
|
description: "Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",
|
|
examples: ["floor(3.2)", "floor(3.8)", "floor(-4.2)"],
|
|
seealso: ["ceil", "fix", "round"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/gcd.js
|
|
var gcdDocs = {
|
|
name: "gcd",
|
|
category: "Arithmetic",
|
|
syntax: ["gcd(a, b)", "gcd(a, b, c, ...)"],
|
|
description: "Compute the greatest common divisor.",
|
|
examples: ["gcd(8, 12)", "gcd(-4, 6)", "gcd(25, 15, -10)"],
|
|
seealso: ["lcm", "xgcd"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/hypot.js
|
|
var hypotDocs = {
|
|
name: "hypot",
|
|
category: "Arithmetic",
|
|
syntax: ["hypot(a, b, c, ...)", "hypot([a, b, c, ...])"],
|
|
description: "Calculate the hypotenusa of a list with values. ",
|
|
examples: ["hypot(3, 4)", "sqrt(3^2 + 4^2)", "hypot(-2)", "hypot([3, 4, 5])"],
|
|
seealso: ["abs", "norm"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/invmod.js
|
|
var invmodDocs = {
|
|
name: "invmod",
|
|
category: "Arithmetic",
|
|
syntax: ["invmod(a, b)"],
|
|
description: "Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax \u2263 1 (mod b)",
|
|
examples: ["invmod(8, 12)=NaN", "invmod(7, 13)=2", "invmod(15151, 15122)=10429"],
|
|
seealso: ["gcd", "xgcd"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/lcm.js
|
|
var lcmDocs = {
|
|
name: "lcm",
|
|
category: "Arithmetic",
|
|
syntax: ["lcm(x, y)"],
|
|
description: "Compute the least common multiple.",
|
|
examples: ["lcm(4, 6)", "lcm(6, 21)", "lcm(6, 21, 5)"],
|
|
seealso: ["gcd"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/log.js
|
|
var logDocs = {
|
|
name: "log",
|
|
category: "Arithmetic",
|
|
syntax: ["log(x)", "log(x, base)"],
|
|
description: "Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",
|
|
examples: ["log(3.5)", "a = log(2.4)", "exp(a)", "10 ^ 4", "log(10000, 10)", "log(10000) / log(10)", "b = log(1024, 2)", "2 ^ b"],
|
|
seealso: ["exp", "log1p", "log2", "log10"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/log10.js
|
|
var log10Docs = {
|
|
name: "log10",
|
|
category: "Arithmetic",
|
|
syntax: ["log10(x)"],
|
|
description: "Compute the 10-base logarithm of a value.",
|
|
examples: ["log10(0.00001)", "log10(10000)", "10 ^ 4", "log(10000) / log(10)", "log(10000, 10)"],
|
|
seealso: ["exp", "log"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/log1p.js
|
|
var log1pDocs = {
|
|
name: "log1p",
|
|
category: "Arithmetic",
|
|
syntax: ["log1p(x)", "log1p(x, base)"],
|
|
description: "Calculate the logarithm of a `value+1`",
|
|
examples: ["log1p(2.5)", "exp(log1p(1.4))", "pow(10, 4)", "log1p(9999, 10)", "log1p(9999) / log(10)"],
|
|
seealso: ["exp", "log", "log2", "log10"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/log2.js
|
|
var log2Docs = {
|
|
name: "log2",
|
|
category: "Arithmetic",
|
|
syntax: ["log2(x)"],
|
|
description: "Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",
|
|
examples: ["log2(0.03125)", "log2(16)", "log2(16) / log2(2)", "pow(2, 4)"],
|
|
seealso: ["exp", "log1p", "log", "log10"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/mod.js
|
|
var modDocs = {
|
|
name: "mod",
|
|
category: "Operators",
|
|
syntax: ["x % y", "x mod y", "mod(x, y)"],
|
|
description: "Calculates the modulus, the remainder of an integer division.",
|
|
examples: ["7 % 3", "11 % 2", "10 mod 4", "isOdd(x) = x % 2", "isOdd(2)", "isOdd(3)"],
|
|
seealso: ["divide"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/multiply.js
|
|
var multiplyDocs = {
|
|
name: "multiply",
|
|
category: "Operators",
|
|
syntax: ["x * y", "multiply(x, y)"],
|
|
description: "multiply two values.",
|
|
examples: ["a = 2.1 * 3.4", "a / 3.4", "2 * 3 + 4", "2 * (3 + 4)", "3 * 2.1 km"],
|
|
seealso: ["divide"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/norm.js
|
|
var normDocs = {
|
|
name: "norm",
|
|
category: "Arithmetic",
|
|
syntax: ["norm(x)", "norm(x, p)"],
|
|
description: "Calculate the norm of a number, vector or matrix.",
|
|
examples: ["abs(-3.5)", "norm(-3.5)", "norm(3 - 4i)", "norm([1, 2, -3], Infinity)", "norm([1, 2, -3], -Infinity)", "norm([3, 4], 2)", "norm([[1, 2], [3, 4]], 1)", 'norm([[1, 2], [3, 4]], "inf")', 'norm([[1, 2], [3, 4]], "fro")']
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/nthRoot.js
|
|
var nthRootDocs = {
|
|
name: "nthRoot",
|
|
category: "Arithmetic",
|
|
syntax: ["nthRoot(a)", "nthRoot(a, root)"],
|
|
description: 'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',
|
|
examples: ["4 ^ 3", "nthRoot(64, 3)", "nthRoot(9, 2)", "sqrt(9)"],
|
|
seealso: ["nthRoots", "pow", "sqrt"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/nthRoots.js
|
|
var nthRootsDocs = {
|
|
name: "nthRoots",
|
|
category: "Arithmetic",
|
|
syntax: ["nthRoots(A)", "nthRoots(A, root)"],
|
|
description: 'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',
|
|
examples: ["nthRoots(1)", "nthRoots(1, 3)"],
|
|
seealso: ["sqrt", "pow", "nthRoot"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/pow.js
|
|
var powDocs = {
|
|
name: "pow",
|
|
category: "Operators",
|
|
syntax: ["x ^ y", "pow(x, y)"],
|
|
description: "Calculates the power of x to y, x^y.",
|
|
examples: ["2^3", "2*2*2", "1 + e ^ (pi * i)", "pow([[1, 2], [4, 3]], 2)", "pow([[1, 2], [4, 3]], -1)"],
|
|
seealso: ["multiply", "nthRoot", "nthRoots", "sqrt"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/round.js
|
|
var roundDocs = {
|
|
name: "round",
|
|
category: "Arithmetic",
|
|
syntax: ["round(x)", "round(x, n)"],
|
|
description: "round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",
|
|
examples: ["round(3.2)", "round(3.8)", "round(-4.2)", "round(-4.8)", "round(pi, 3)", "round(123.45678, 2)"],
|
|
seealso: ["ceil", "floor", "fix"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/sign.js
|
|
var signDocs = {
|
|
name: "sign",
|
|
category: "Arithmetic",
|
|
syntax: ["sign(x)"],
|
|
description: "Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",
|
|
examples: ["sign(3.5)", "sign(-4.2)", "sign(0)"],
|
|
seealso: ["abs"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/sqrt.js
|
|
var sqrtDocs = {
|
|
name: "sqrt",
|
|
category: "Arithmetic",
|
|
syntax: ["sqrt(x)"],
|
|
description: "Compute the square root value. If x = y * y, then y is the square root of x.",
|
|
examples: ["sqrt(25)", "5 * 5", "sqrt(-1)"],
|
|
seealso: ["square", "sqrtm", "multiply", "nthRoot", "nthRoots", "pow"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/sqrtm.js
|
|
var sqrtmDocs = {
|
|
name: "sqrtm",
|
|
category: "Arithmetic",
|
|
syntax: ["sqrtm(x)"],
|
|
description: "Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",
|
|
examples: ["sqrtm([[33, 24], [48, 57]])"],
|
|
seealso: ["sqrt", "abs", "square", "multiply"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/sylvester.js
|
|
var sylvesterDocs = {
|
|
name: "sylvester",
|
|
category: "Matrix",
|
|
syntax: ["sylvester(A,B,C)"],
|
|
description: "Solves the real-valued Sylvester equation AX+XB=C for X",
|
|
examples: ["sylvester([[-1, -2], [1, 1]], [[-2, 1], [-1, 2]], [[-3, 2], [3, 0]])", "sylvester(A,B,C)"],
|
|
seealso: ["schur", "lyap"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/schur.js
|
|
var schurDocs = {
|
|
name: "schur",
|
|
category: "Matrix",
|
|
syntax: ["schur(A)"],
|
|
description: "Performs a real Schur decomposition of the real matrix A = UTU'",
|
|
examples: ["schur([[1, 0], [-4, 3]])", "schur(A)"],
|
|
seealso: ["lyap", "sylvester"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/lyap.js
|
|
var lyapDocs = {
|
|
name: "lyap",
|
|
category: "Matrix",
|
|
syntax: ["lyap(A,Q)"],
|
|
description: "Solves the Continuous-time Lyapunov equation AP+PA'+Q=0 for P",
|
|
examples: ["lyap([[-2, 0], [1, -4]], [[3, 1], [1, 3]])", "lyap(A,Q)"],
|
|
seealso: ["schur", "sylvester"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/square.js
|
|
var squareDocs = {
|
|
name: "square",
|
|
category: "Arithmetic",
|
|
syntax: ["square(x)"],
|
|
description: "Compute the square of a value. The square of x is x * x.",
|
|
examples: ["square(3)", "sqrt(9)", "3^2", "3 * 3"],
|
|
seealso: ["multiply", "pow", "sqrt", "cube"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/subtract.js
|
|
var subtractDocs = {
|
|
name: "subtract",
|
|
category: "Operators",
|
|
syntax: ["x - y", "subtract(x, y)"],
|
|
description: "subtract two values.",
|
|
examples: ["a = 5.3 - 2", "a + 2", "2/3 - 1/6", "2 * 3 - 3", "2.1 km - 500m"],
|
|
seealso: ["add"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/unaryMinus.js
|
|
var unaryMinusDocs = {
|
|
name: "unaryMinus",
|
|
category: "Operators",
|
|
syntax: ["-x", "unaryMinus(x)"],
|
|
description: "Inverse the sign of a value. Converts booleans and strings to numbers.",
|
|
examples: ["-4.5", "-(-5.6)", '-"22"'],
|
|
seealso: ["add", "subtract", "unaryPlus"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/unaryPlus.js
|
|
var unaryPlusDocs = {
|
|
name: "unaryPlus",
|
|
category: "Operators",
|
|
syntax: ["+x", "unaryPlus(x)"],
|
|
description: "Converts booleans and strings to numbers.",
|
|
examples: ["+true", '+"2"'],
|
|
seealso: ["add", "subtract", "unaryMinus"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/arithmetic/xgcd.js
|
|
var xgcdDocs = {
|
|
name: "xgcd",
|
|
category: "Arithmetic",
|
|
syntax: ["xgcd(a, b)"],
|
|
description: "Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",
|
|
examples: ["xgcd(8, 12)", "gcd(8, 12)", "xgcd(36163, 21199)"],
|
|
seealso: ["gcd", "lcm"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/bitwise/bitAnd.js
|
|
var bitAndDocs = {
|
|
name: "bitAnd",
|
|
category: "Bitwise",
|
|
syntax: ["x & y", "bitAnd(x, y)"],
|
|
description: "Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",
|
|
examples: ["5 & 3", "bitAnd(53, 131)", "[1, 12, 31] & 42"],
|
|
seealso: ["bitNot", "bitOr", "bitXor", "leftShift", "rightArithShift", "rightLogShift"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/bitwise/bitNot.js
|
|
var bitNotDocs = {
|
|
name: "bitNot",
|
|
category: "Bitwise",
|
|
syntax: ["~x", "bitNot(x)"],
|
|
description: "Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",
|
|
examples: ["~1", "~2", "bitNot([2, -3, 4])"],
|
|
seealso: ["bitAnd", "bitOr", "bitXor", "leftShift", "rightArithShift", "rightLogShift"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/bitwise/bitOr.js
|
|
var bitOrDocs = {
|
|
name: "bitOr",
|
|
category: "Bitwise",
|
|
syntax: ["x | y", "bitOr(x, y)"],
|
|
description: "Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",
|
|
examples: ["5 | 3", "bitOr([1, 2, 3], 4)"],
|
|
seealso: ["bitAnd", "bitNot", "bitXor", "leftShift", "rightArithShift", "rightLogShift"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/bitwise/bitXor.js
|
|
var bitXorDocs = {
|
|
name: "bitXor",
|
|
category: "Bitwise",
|
|
syntax: ["bitXor(x, y)"],
|
|
description: "Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",
|
|
examples: ["bitOr(1, 2)", "bitXor([2, 3, 4], 4)"],
|
|
seealso: ["bitAnd", "bitNot", "bitOr", "leftShift", "rightArithShift", "rightLogShift"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/bitwise/leftShift.js
|
|
var leftShiftDocs = {
|
|
name: "leftShift",
|
|
category: "Bitwise",
|
|
syntax: ["x << y", "leftShift(x, y)"],
|
|
description: "Bitwise left logical shift of a value x by y number of bits.",
|
|
examples: ["4 << 1", "8 >> 1"],
|
|
seealso: ["bitAnd", "bitNot", "bitOr", "bitXor", "rightArithShift", "rightLogShift"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/bitwise/rightArithShift.js
|
|
var rightArithShiftDocs = {
|
|
name: "rightArithShift",
|
|
category: "Bitwise",
|
|
syntax: ["x >> y", "rightArithShift(x, y)"],
|
|
description: "Bitwise right arithmetic shift of a value x by y number of bits.",
|
|
examples: ["8 >> 1", "4 << 1", "-12 >> 2"],
|
|
seealso: ["bitAnd", "bitNot", "bitOr", "bitXor", "leftShift", "rightLogShift"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/bitwise/rightLogShift.js
|
|
var rightLogShiftDocs = {
|
|
name: "rightLogShift",
|
|
category: "Bitwise",
|
|
syntax: ["x >>> y", "rightLogShift(x, y)"],
|
|
description: "Bitwise right logical shift of a value x by y number of bits.",
|
|
examples: ["8 >>> 1", "4 << 1", "-12 >>> 2"],
|
|
seealso: ["bitAnd", "bitNot", "bitOr", "bitXor", "leftShift", "rightArithShift"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/combinatorics/bellNumbers.js
|
|
var bellNumbersDocs = {
|
|
name: "bellNumbers",
|
|
category: "Combinatorics",
|
|
syntax: ["bellNumbers(n)"],
|
|
description: "The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",
|
|
examples: ["bellNumbers(3)", "bellNumbers(8)"],
|
|
seealso: ["stirlingS2"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/combinatorics/catalan.js
|
|
var catalanDocs = {
|
|
name: "catalan",
|
|
category: "Combinatorics",
|
|
syntax: ["catalan(n)"],
|
|
description: "The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",
|
|
examples: ["catalan(3)", "catalan(8)"],
|
|
seealso: ["bellNumbers"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/combinatorics/composition.js
|
|
var compositionDocs = {
|
|
name: "composition",
|
|
category: "Combinatorics",
|
|
syntax: ["composition(n, k)"],
|
|
description: "The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",
|
|
examples: ["composition(5, 3)"],
|
|
seealso: ["combinations"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/combinatorics/stirlingS2.js
|
|
var stirlingS2Docs = {
|
|
name: "stirlingS2",
|
|
category: "Combinatorics",
|
|
syntax: ["stirlingS2(n, k)"],
|
|
description: "he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",
|
|
examples: ["stirlingS2(5, 3)"],
|
|
seealso: ["bellNumbers"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/complex/arg.js
|
|
var argDocs = {
|
|
name: "arg",
|
|
category: "Complex",
|
|
syntax: ["arg(x)"],
|
|
description: "Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",
|
|
examples: ["arg(2 + 2i)", "atan2(3, 2)", "arg(2 + 3i)"],
|
|
seealso: ["re", "im", "conj", "abs"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/complex/conj.js
|
|
var conjDocs = {
|
|
name: "conj",
|
|
category: "Complex",
|
|
syntax: ["conj(x)"],
|
|
description: "Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",
|
|
examples: ["conj(2 + 3i)", "conj(2 - 3i)", "conj(-5.2i)"],
|
|
seealso: ["re", "im", "abs", "arg"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/complex/im.js
|
|
var imDocs = {
|
|
name: "im",
|
|
category: "Complex",
|
|
syntax: ["im(x)"],
|
|
description: "Get the imaginary part of a complex number.",
|
|
examples: ["im(2 + 3i)", "re(2 + 3i)", "im(-5.2i)", "im(2.4)"],
|
|
seealso: ["re", "conj", "abs", "arg"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/complex/re.js
|
|
var reDocs = {
|
|
name: "re",
|
|
category: "Complex",
|
|
syntax: ["re(x)"],
|
|
description: "Get the real part of a complex number.",
|
|
examples: ["re(2 + 3i)", "im(2 + 3i)", "re(-5.2i)", "re(2.4)"],
|
|
seealso: ["im", "conj", "abs", "arg"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/expression/evaluate.js
|
|
var evaluateDocs = {
|
|
name: "evaluate",
|
|
category: "Expression",
|
|
syntax: ["evaluate(expression)", "evaluate([expr1, expr2, expr3, ...])"],
|
|
description: "Evaluate an expression or an array with expressions.",
|
|
examples: ['evaluate("2 + 3")', 'evaluate("sqrt(" + 4 + ")")'],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/expression/help.js
|
|
var helpDocs = {
|
|
name: "help",
|
|
category: "Expression",
|
|
syntax: ["help(object)", "help(string)"],
|
|
description: "Display documentation on a function or data type.",
|
|
examples: ["help(sqrt)", 'help("complex")'],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/geometry/distance.js
|
|
var distanceDocs = {
|
|
name: "distance",
|
|
category: "Geometry",
|
|
syntax: ["distance([x1, y1], [x2, y2])", "distance([[x1, y1], [x2, y2]])"],
|
|
description: "Calculates the Euclidean distance between two points.",
|
|
examples: ["distance([0,0], [4,4])", "distance([[0,0], [4,4]])"],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/geometry/intersect.js
|
|
var intersectDocs = {
|
|
name: "intersect",
|
|
category: "Geometry",
|
|
syntax: ["intersect(expr1, expr2, expr3, expr4)", "intersect(expr1, expr2, expr3)"],
|
|
description: "Computes the intersection point of lines and/or planes.",
|
|
examples: ["intersect([0, 0], [10, 10], [10, 0], [0, 10])", "intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/logical/and.js
|
|
var andDocs = {
|
|
name: "and",
|
|
category: "Logical",
|
|
syntax: ["x and y", "and(x, y)"],
|
|
description: "Logical and. Test whether two values are both defined with a nonzero/nonempty value.",
|
|
examples: ["true and false", "true and true", "2 and 4"],
|
|
seealso: ["not", "or", "xor"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/logical/not.js
|
|
var notDocs = {
|
|
name: "not",
|
|
category: "Logical",
|
|
syntax: ["not x", "not(x)"],
|
|
description: "Logical not. Flips the boolean value of given argument.",
|
|
examples: ["not true", "not false", "not 2", "not 0"],
|
|
seealso: ["and", "or", "xor"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/logical/or.js
|
|
var orDocs = {
|
|
name: "or",
|
|
category: "Logical",
|
|
syntax: ["x or y", "or(x, y)"],
|
|
description: "Logical or. Test if at least one value is defined with a nonzero/nonempty value.",
|
|
examples: ["true or false", "false or false", "0 or 4"],
|
|
seealso: ["not", "and", "xor"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/logical/xor.js
|
|
var xorDocs = {
|
|
name: "xor",
|
|
category: "Logical",
|
|
syntax: ["x xor y", "xor(x, y)"],
|
|
description: "Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",
|
|
examples: ["true xor false", "false xor false", "true xor true", "0 xor 4"],
|
|
seealso: ["not", "and", "or"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/column.js
|
|
var columnDocs = {
|
|
name: "column",
|
|
category: "Matrix",
|
|
syntax: ["column(x, index)"],
|
|
description: "Return a column from a matrix or array.",
|
|
examples: ["A = [[1, 2], [3, 4]]", "column(A, 1)", "column(A, 2)"],
|
|
seealso: ["row", "matrixFromColumns"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/concat.js
|
|
var concatDocs = {
|
|
name: "concat",
|
|
category: "Matrix",
|
|
syntax: ["concat(A, B, C, ...)", "concat(A, B, C, ..., dim)"],
|
|
description: "Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",
|
|
examples: ["A = [1, 2; 5, 6]", "B = [3, 4; 7, 8]", "concat(A, B)", "concat(A, B, 1)", "concat(A, B, 2)"],
|
|
seealso: ["det", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/count.js
|
|
var countDocs = {
|
|
name: "count",
|
|
category: "Matrix",
|
|
syntax: ["count(x)"],
|
|
description: "Count the number of elements of a matrix, array or string.",
|
|
examples: ["a = [1, 2; 3, 4; 5, 6]", "count(a)", "size(a)", 'count("hello world")'],
|
|
seealso: ["size"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/cross.js
|
|
var crossDocs = {
|
|
name: "cross",
|
|
category: "Matrix",
|
|
syntax: ["cross(A, B)"],
|
|
description: "Calculate the cross product for two vectors in three dimensional space.",
|
|
examples: ["cross([1, 1, 0], [0, 1, 1])", "cross([3, -3, 1], [4, 9, 2])", "cross([2, 3, 4], [5, 6, 7])"],
|
|
seealso: ["multiply", "dot"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/ctranspose.js
|
|
var ctransposeDocs = {
|
|
name: "ctranspose",
|
|
category: "Matrix",
|
|
syntax: ["x'", "ctranspose(x)"],
|
|
description: "Complex Conjugate and Transpose a matrix",
|
|
examples: ["a = [1, 2, 3; 4, 5, 6]", "a'", "ctranspose(a)"],
|
|
seealso: ["concat", "det", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "zeros"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/det.js
|
|
var detDocs = {
|
|
name: "det",
|
|
category: "Matrix",
|
|
syntax: ["det(x)"],
|
|
description: "Calculate the determinant of a matrix",
|
|
examples: ["det([1, 2; 3, 4])", "det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],
|
|
seealso: ["concat", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/diag.js
|
|
var diagDocs = {
|
|
name: "diag",
|
|
category: "Matrix",
|
|
syntax: ["diag(x)", "diag(x, k)"],
|
|
description: "Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",
|
|
examples: ["diag(1:3)", "diag(1:3, 1)", "a = [1, 2, 3; 4, 5, 6; 7, 8, 9]", "diag(a)"],
|
|
seealso: ["concat", "det", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/diff.js
|
|
var diffDocs = {
|
|
name: "diff",
|
|
category: "Matrix",
|
|
syntax: ["diff(arr)", "diff(arr, dim)"],
|
|
description: ["Create a new matrix or array with the difference of the passed matrix or array.", "Dim parameter is optional and used to indicant the dimension of the array/matrix to apply the difference", "If no dimension parameter is passed it is assumed as dimension 0", "Dimension is zero-based in javascript and one-based in the parser", "Arrays must be 'rectangular' meaning arrays like [1, 2]", "If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],
|
|
examples: ["diff([1, 2, 4, 7, 0])", "diff([1, 2, 4, 7, 0], 0)", "diff(matrix([1, 2, 4, 7, 0]))", "diff([[1, 2], [3, 4]])", "diff([[1, 2], [3, 4]], 0)", "diff([[1, 2], [3, 4]], 1)", "diff([[1, 2], [3, 4]], bignumber(1))", "diff(matrix([[1, 2], [3, 4]]), 1)", "diff([[1, 2], matrix([3, 4])], 1)"],
|
|
seealso: ["subtract", "partitionSelect"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/dot.js
|
|
var dotDocs = {
|
|
name: "dot",
|
|
category: "Matrix",
|
|
syntax: ["dot(A, B)", "A * B"],
|
|
description: "Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",
|
|
examples: ["dot([2, 4, 1], [2, 2, 3])", "[2, 4, 1] * [2, 2, 3]"],
|
|
seealso: ["multiply", "cross"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/eigs.js
|
|
var eigsDocs = {
|
|
name: "eigs",
|
|
category: "Matrix",
|
|
syntax: ["eigs(x)"],
|
|
description: "Calculate the eigenvalues and eigenvectors of a real symmetric matrix",
|
|
examples: ["eigs([[5, 2.3], [2.3, 1]])"],
|
|
seealso: ["inv"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/filter.js
|
|
var filterDocs = {
|
|
name: "filter",
|
|
category: "Matrix",
|
|
syntax: ["filter(x, test)"],
|
|
description: "Filter items in a matrix.",
|
|
examples: ["isPositive(x) = x > 0", "filter([6, -2, -1, 4, 3], isPositive)", "filter([6, -2, 0, 1, 0], x != 0)"],
|
|
seealso: ["sort", "map", "forEach"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/flatten.js
|
|
var flattenDocs = {
|
|
name: "flatten",
|
|
category: "Matrix",
|
|
syntax: ["flatten(x)"],
|
|
description: "Flatten a multi dimensional matrix into a single dimensional matrix.",
|
|
examples: ["a = [1, 2, 3; 4, 5, 6]", "size(a)", "b = flatten(a)", "size(b)"],
|
|
seealso: ["concat", "resize", "size", "squeeze"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/forEach.js
|
|
var forEachDocs = {
|
|
name: "forEach",
|
|
category: "Matrix",
|
|
syntax: ["forEach(x, callback)"],
|
|
description: "Iterates over all elements of a matrix/array, and executes the given callback function.",
|
|
examples: ["numberOfPets = {}", "addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;", 'forEach(["Dog","Cat","Cat"], addPet)', "numberOfPets"],
|
|
seealso: ["map", "sort", "filter"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/getMatrixDataType.js
|
|
var getMatrixDataTypeDocs = {
|
|
name: "getMatrixDataType",
|
|
category: "Matrix",
|
|
syntax: ["getMatrixDataType(x)"],
|
|
description: 'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',
|
|
examples: ["getMatrixDataType([1, 2, 3])", "getMatrixDataType([[5 cm], [2 inch]])", 'getMatrixDataType([1, "text"])', "getMatrixDataType([1, bignumber(4)])"],
|
|
seealso: ["matrix", "sparse", "typeOf"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/identity.js
|
|
var identityDocs = {
|
|
name: "identity",
|
|
category: "Matrix",
|
|
syntax: ["identity(n)", "identity(m, n)", "identity([m, n])"],
|
|
description: "Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",
|
|
examples: ["identity(3)", "identity(3, 5)", "a = [1, 2, 3; 4, 5, 6]", "identity(size(a))"],
|
|
seealso: ["concat", "det", "diag", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/inv.js
|
|
var invDocs = {
|
|
name: "inv",
|
|
category: "Matrix",
|
|
syntax: ["inv(x)"],
|
|
description: "Calculate the inverse of a matrix",
|
|
examples: ["inv([1, 2; 3, 4])", "inv(4)", "1 / 4"],
|
|
seealso: ["concat", "det", "diag", "identity", "ones", "range", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/pinv.js
|
|
var pinvDocs = {
|
|
name: "pinv",
|
|
category: "Matrix",
|
|
syntax: ["pinv(x)"],
|
|
description: "Calculate the Moore\u2013Penrose inverse of a matrix",
|
|
examples: ["pinv([1, 2; 3, 4])", "pinv([[1, 0], [0, 1], [0, 1]])", "pinv(4)"],
|
|
seealso: ["inv"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/kron.js
|
|
var kronDocs = {
|
|
name: "kron",
|
|
category: "Matrix",
|
|
syntax: ["kron(x, y)"],
|
|
description: "Calculates the kronecker product of 2 matrices or vectors.",
|
|
examples: ["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])", "kron([1,1], [2,3,4])"],
|
|
seealso: ["multiply", "dot", "cross"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/map.js
|
|
var mapDocs = {
|
|
name: "map",
|
|
category: "Matrix",
|
|
syntax: ["map(x, callback)"],
|
|
description: "Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",
|
|
examples: ["map([1, 2, 3], square)"],
|
|
seealso: ["filter", "forEach"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/matrixFromColumns.js
|
|
var matrixFromColumnsDocs = {
|
|
name: "matrixFromColumns",
|
|
category: "Matrix",
|
|
syntax: ["matrixFromColumns(...arr)", "matrixFromColumns(row1, row2)", "matrixFromColumns(row1, row2, row3)"],
|
|
description: "Create a dense matrix from vectors as individual columns.",
|
|
examples: ["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],
|
|
seealso: ["matrix", "matrixFromRows", "matrixFromFunction", "zeros"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/matrixFromFunction.js
|
|
var matrixFromFunctionDocs = {
|
|
name: "matrixFromFunction",
|
|
category: "Matrix",
|
|
syntax: ["matrixFromFunction(size, fn)", "matrixFromFunction(size, fn, format)", "matrixFromFunction(size, fn, format, datatype)", "matrixFromFunction(size, format, fn)", "matrixFromFunction(size, format, datatype, fn)"],
|
|
description: "Create a matrix by evaluating a generating function at each index.",
|
|
examples: ["f(I) = I[1] - I[2]", "matrixFromFunction([3,3], f)", "g(I) = I[1] - I[2] == 1 ? 4 : 0", 'matrixFromFunction([100, 100], "sparse", g)', "matrixFromFunction([5], random)"],
|
|
seealso: ["matrix", "matrixFromRows", "matrixFromColumns", "zeros"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/matrixFromRows.js
|
|
var matrixFromRowsDocs = {
|
|
name: "matrixFromRows",
|
|
category: "Matrix",
|
|
syntax: ["matrixFromRows(...arr)", "matrixFromRows(row1, row2)", "matrixFromRows(row1, row2, row3)"],
|
|
description: "Create a dense matrix from vectors as individual rows.",
|
|
examples: ["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],
|
|
seealso: ["matrix", "matrixFromColumns", "matrixFromFunction", "zeros"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/ones.js
|
|
var onesDocs = {
|
|
name: "ones",
|
|
category: "Matrix",
|
|
syntax: ["ones(m)", "ones(m, n)", "ones(m, n, p, ...)", "ones([m])", "ones([m, n])", "ones([m, n, p, ...])"],
|
|
description: "Create a matrix containing ones.",
|
|
examples: ["ones(3)", "ones(3, 5)", "ones([2,3]) * 4.5", "a = [1, 2, 3; 4, 5, 6]", "ones(size(a))"],
|
|
seealso: ["concat", "det", "diag", "identity", "inv", "range", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/partitionSelect.js
|
|
var partitionSelectDocs = {
|
|
name: "partitionSelect",
|
|
category: "Matrix",
|
|
syntax: ["partitionSelect(x, k)", "partitionSelect(x, k, compare)"],
|
|
description: "Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",
|
|
examples: ["partitionSelect([5, 10, 1], 2)", 'partitionSelect(["C", "B", "A", "D"], 1)'],
|
|
seealso: ["sort"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/range.js
|
|
var rangeDocs = {
|
|
name: "range",
|
|
category: "Type",
|
|
syntax: ["start:end", "start:step:end", "range(start, end)", "range(start, end, step)", "range(string)"],
|
|
description: "Create a range. Lower bound of the range is included, upper bound is excluded.",
|
|
examples: ["1:5", "3:-1:-3", "range(3, 7)", "range(0, 12, 2)", 'range("4:10")', "a = [1, 2, 3, 4; 5, 6, 7, 8]", "a[1:2, 1:2]"],
|
|
seealso: ["concat", "det", "diag", "identity", "inv", "ones", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/reshape.js
|
|
var reshapeDocs = {
|
|
name: "reshape",
|
|
category: "Matrix",
|
|
syntax: ["reshape(x, sizes)"],
|
|
description: "Reshape a multi dimensional array to fit the specified dimensions.",
|
|
examples: ["reshape([1, 2, 3, 4, 5, 6], [2, 3])", "reshape([[1, 2], [3, 4]], [1, 4])", "reshape([[1, 2], [3, 4]], [4])", "reshape([1, 2, 3, 4], [-1, 2])"],
|
|
seealso: ["size", "squeeze", "resize"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/resize.js
|
|
var resizeDocs = {
|
|
name: "resize",
|
|
category: "Matrix",
|
|
syntax: ["resize(x, size)", "resize(x, size, defaultValue)"],
|
|
description: "Resize a matrix.",
|
|
examples: ["resize([1,2,3,4,5], [3])", "resize([1,2,3], [5])", "resize([1,2,3], [5], -1)", "resize(2, [2, 3])", 'resize("hello", [8], "!")'],
|
|
seealso: ["size", "subset", "squeeze", "reshape"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/rotate.js
|
|
var rotateDocs = {
|
|
name: "rotate",
|
|
category: "Matrix",
|
|
syntax: ["rotate(w, theta)", "rotate(w, theta, v)"],
|
|
description: "Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",
|
|
examples: ["rotate([1, 0], pi / 2)", 'rotate(matrix([1, 0]), unit("35deg"))', 'rotate([1, 0, 0], unit("90deg"), [0, 0, 1])', 'rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],
|
|
seealso: ["matrix", "rotationMatrix"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/rotationMatrix.js
|
|
var rotationMatrixDocs = {
|
|
name: "rotationMatrix",
|
|
category: "Matrix",
|
|
syntax: ["rotationMatrix(theta)", "rotationMatrix(theta, v)", "rotationMatrix(theta, v, format)"],
|
|
description: "Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",
|
|
examples: ["rotationMatrix(pi / 2)", 'rotationMatrix(unit("45deg"), [0, 0, 1])', 'rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],
|
|
seealso: ["cos", "sin"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/row.js
|
|
var rowDocs = {
|
|
name: "row",
|
|
category: "Matrix",
|
|
syntax: ["row(x, index)"],
|
|
description: "Return a row from a matrix or array.",
|
|
examples: ["A = [[1, 2], [3, 4]]", "row(A, 1)", "row(A, 2)"],
|
|
seealso: ["column", "matrixFromRows"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/size.js
|
|
var sizeDocs = {
|
|
name: "size",
|
|
category: "Matrix",
|
|
syntax: ["size(x)"],
|
|
description: "Calculate the size of a matrix.",
|
|
examples: ["size(2.3)", 'size("hello world")', "a = [1, 2; 3, 4; 5, 6]", "size(a)", "size(1:6)"],
|
|
seealso: ["concat", "count", "det", "diag", "identity", "inv", "ones", "range", "squeeze", "subset", "trace", "transpose", "zeros"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/sort.js
|
|
var sortDocs = {
|
|
name: "sort",
|
|
category: "Matrix",
|
|
syntax: ["sort(x)", "sort(x, compare)"],
|
|
description: 'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',
|
|
examples: ["sort([5, 10, 1])", 'sort(["C", "B", "A", "D"], "natural")', "sortByLength(a, b) = size(a)[1] - size(b)[1]", 'sort(["Langdon", "Tom", "Sara"], sortByLength)', 'sort(["10", "1", "2"], "natural")'],
|
|
seealso: ["map", "filter", "forEach"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/squeeze.js
|
|
var squeezeDocs = {
|
|
name: "squeeze",
|
|
category: "Matrix",
|
|
syntax: ["squeeze(x)"],
|
|
description: "Remove inner and outer singleton dimensions from a matrix.",
|
|
examples: ["a = zeros(3,2,1)", "size(squeeze(a))", "b = zeros(1,1,3)", "size(squeeze(b))"],
|
|
seealso: ["concat", "det", "diag", "identity", "inv", "ones", "range", "size", "subset", "trace", "transpose", "zeros"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/subset.js
|
|
var subsetDocs = {
|
|
name: "subset",
|
|
category: "Matrix",
|
|
syntax: ["value(index)", "value(index) = replacement", "subset(value, [index])", "subset(value, [index], replacement)"],
|
|
description: "Get or set a subset of the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation `l:u`. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.",
|
|
examples: ["d = [1, 2; 3, 4]", "e = []", "e[1, 1:2] = [5, 6]", "e[2, :] = [7, 8]", "f = d * e", "f[2, 1]", "f[:, 1]", "f[[1,2], [1,3]] = [9, 10; 11, 12]", "f"],
|
|
seealso: ["concat", "det", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "trace", "transpose", "zeros"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/trace.js
|
|
var traceDocs = {
|
|
name: "trace",
|
|
category: "Matrix",
|
|
syntax: ["trace(A)"],
|
|
description: "Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",
|
|
examples: ["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]", "trace(A)"],
|
|
seealso: ["concat", "det", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "transpose", "zeros"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/transpose.js
|
|
var transposeDocs = {
|
|
name: "transpose",
|
|
category: "Matrix",
|
|
syntax: ["x'", "transpose(x)"],
|
|
description: "Transpose a matrix",
|
|
examples: ["a = [1, 2, 3; 4, 5, 6]", "a'", "transpose(a)"],
|
|
seealso: ["concat", "det", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "zeros"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/zeros.js
|
|
var zerosDocs = {
|
|
name: "zeros",
|
|
category: "Matrix",
|
|
syntax: ["zeros(m)", "zeros(m, n)", "zeros(m, n, p, ...)", "zeros([m])", "zeros([m, n])", "zeros([m, n, p, ...])"],
|
|
description: "Create a matrix containing zeros.",
|
|
examples: ["zeros(3)", "zeros(3, 5)", "a = [1, 2, 3; 4, 5, 6]", "zeros(size(a))"],
|
|
seealso: ["concat", "det", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "transpose"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/fft.js
|
|
var fftDocs = {
|
|
name: "fft",
|
|
category: "Matrix",
|
|
syntax: ["fft(x)"],
|
|
description: "Calculate N-dimensional fourier transform",
|
|
examples: ["fft([[1, 0], [1, 0]])"],
|
|
seealso: ["ifft"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/matrix/ifft.js
|
|
var ifftDocs = {
|
|
name: "ifft",
|
|
category: "Matrix",
|
|
syntax: ["ifft(x)"],
|
|
description: "Calculate N-dimensional inverse fourier transform",
|
|
examples: ["ifft([[2, 2], [0, 0]])"],
|
|
seealso: ["fft"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/probability/combinations.js
|
|
var combinationsDocs = {
|
|
name: "combinations",
|
|
category: "Probability",
|
|
syntax: ["combinations(n, k)"],
|
|
description: "Compute the number of combinations of n items taken k at a time",
|
|
examples: ["combinations(7, 5)"],
|
|
seealso: ["combinationsWithRep", "permutations", "factorial"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/probability/combinationsWithRep.js
|
|
var combinationsWithRepDocs = {
|
|
name: "combinationsWithRep",
|
|
category: "Probability",
|
|
syntax: ["combinationsWithRep(n, k)"],
|
|
description: "Compute the number of combinations of n items taken k at a time with replacements.",
|
|
examples: ["combinationsWithRep(7, 5)"],
|
|
seealso: ["combinations", "permutations", "factorial"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/probability/factorial.js
|
|
var factorialDocs = {
|
|
name: "factorial",
|
|
category: "Probability",
|
|
syntax: ["n!", "factorial(n)"],
|
|
description: "Compute the factorial of a value",
|
|
examples: ["5!", "5 * 4 * 3 * 2 * 1", "3!"],
|
|
seealso: ["combinations", "combinationsWithRep", "permutations", "gamma"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/probability/gamma.js
|
|
var gammaDocs = {
|
|
name: "gamma",
|
|
category: "Probability",
|
|
syntax: ["gamma(n)"],
|
|
description: "Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",
|
|
examples: ["gamma(4)", "3!", "gamma(1/2)", "sqrt(pi)"],
|
|
seealso: ["factorial"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/probability/lgamma.js
|
|
var lgammaDocs = {
|
|
name: "lgamma",
|
|
category: "Probability",
|
|
syntax: ["lgamma(n)"],
|
|
description: "Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.",
|
|
examples: ["lgamma(4)", "lgamma(1/2)", "lgamma(i)", "lgamma(complex(1.1, 2))"],
|
|
seealso: ["gamma"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/probability/kldivergence.js
|
|
var kldivergenceDocs = {
|
|
name: "kldivergence",
|
|
category: "Probability",
|
|
syntax: ["kldivergence(x, y)"],
|
|
description: "Calculate the Kullback-Leibler (KL) divergence between two distributions.",
|
|
examples: ["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/probability/multinomial.js
|
|
var multinomialDocs = {
|
|
name: "multinomial",
|
|
category: "Probability",
|
|
syntax: ["multinomial(A)"],
|
|
description: "Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",
|
|
examples: ["multinomial([1, 2, 1])"],
|
|
seealso: ["combinations", "factorial"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/probability/permutations.js
|
|
var permutationsDocs = {
|
|
name: "permutations",
|
|
category: "Probability",
|
|
syntax: ["permutations(n)", "permutations(n, k)"],
|
|
description: "Compute the number of permutations of n items taken k at a time",
|
|
examples: ["permutations(5)", "permutations(5, 3)"],
|
|
seealso: ["combinations", "combinationsWithRep", "factorial"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/probability/pickRandom.js
|
|
var pickRandomDocs = {
|
|
name: "pickRandom",
|
|
category: "Probability",
|
|
syntax: ["pickRandom(array)", "pickRandom(array, number)", "pickRandom(array, weights)", "pickRandom(array, number, weights)", "pickRandom(array, weights, number)"],
|
|
description: "Pick a random entry from a given array.",
|
|
examples: ["pickRandom(0:10)", "pickRandom([1, 3, 1, 6])", "pickRandom([1, 3, 1, 6], 2)", "pickRandom([1, 3, 1, 6], [2, 3, 2, 1])", "pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])", "pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],
|
|
seealso: ["random", "randomInt"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/probability/random.js
|
|
var randomDocs = {
|
|
name: "random",
|
|
category: "Probability",
|
|
syntax: ["random()", "random(max)", "random(min, max)", "random(size)", "random(size, max)", "random(size, min, max)"],
|
|
description: "Return a random number.",
|
|
examples: ["random()", "random(10, 20)", "random([2, 3])"],
|
|
seealso: ["pickRandom", "randomInt"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/probability/randomInt.js
|
|
var randomIntDocs = {
|
|
name: "randomInt",
|
|
category: "Probability",
|
|
syntax: ["randomInt(max)", "randomInt(min, max)", "randomInt(size)", "randomInt(size, max)", "randomInt(size, min, max)"],
|
|
description: "Return a random integer number",
|
|
examples: ["randomInt(10, 20)", "randomInt([2, 3], 10)"],
|
|
seealso: ["pickRandom", "random"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/relational/compare.js
|
|
var compareDocs = {
|
|
name: "compare",
|
|
category: "Relational",
|
|
syntax: ["compare(x, y)"],
|
|
description: "Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",
|
|
examples: ["compare(2, 3)", "compare(3, 2)", "compare(2, 2)", "compare(5cm, 40mm)", "compare(2, [1, 2, 3])"],
|
|
seealso: ["equal", "unequal", "smaller", "smallerEq", "largerEq", "compareNatural", "compareText"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/relational/compareNatural.js
|
|
var compareNaturalDocs = {
|
|
name: "compareNatural",
|
|
category: "Relational",
|
|
syntax: ["compareNatural(x, y)"],
|
|
description: "Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",
|
|
examples: ["compareNatural(2, 3)", "compareNatural(3, 2)", "compareNatural(2, 2)", "compareNatural(5cm, 40mm)", 'compareNatural("2", "10")', "compareNatural(2 + 3i, 2 + 4i)", "compareNatural([1, 2, 4], [1, 2, 3])", "compareNatural([1, 5], [1, 2, 3])", "compareNatural([1, 2], [1, 2])", "compareNatural({a: 2}, {a: 4})"],
|
|
seealso: ["equal", "unequal", "smaller", "smallerEq", "largerEq", "compare", "compareText"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/relational/compareText.js
|
|
var compareTextDocs = {
|
|
name: "compareText",
|
|
category: "Relational",
|
|
syntax: ["compareText(x, y)"],
|
|
description: "Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",
|
|
examples: ['compareText("B", "A")', 'compareText("A", "B")', 'compareText("A", "A")', 'compareText("2", "10")', 'compare("2", "10")', "compare(2, 10)", 'compareNatural("2", "10")', 'compareText("B", ["A", "B", "C"])'],
|
|
seealso: ["compare", "compareNatural"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/relational/deepEqual.js
|
|
var deepEqualDocs = {
|
|
name: "deepEqual",
|
|
category: "Relational",
|
|
syntax: ["deepEqual(x, y)"],
|
|
description: "Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",
|
|
examples: ["deepEqual([1,3,4], [1,3,4])", "deepEqual([1,3,4], [1,3])"],
|
|
seealso: ["equal", "unequal", "smaller", "larger", "smallerEq", "largerEq", "compare"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/relational/equal.js
|
|
var equalDocs = {
|
|
name: "equal",
|
|
category: "Relational",
|
|
syntax: ["x == y", "equal(x, y)"],
|
|
description: "Check equality of two values. Returns true if the values are equal, and false if not.",
|
|
examples: ["2+2 == 3", "2+2 == 4", "a = 3.2", "b = 6-2.8", "a == b", "50cm == 0.5m"],
|
|
seealso: ["unequal", "smaller", "larger", "smallerEq", "largerEq", "compare", "deepEqual", "equalText"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/relational/equalText.js
|
|
var equalTextDocs = {
|
|
name: "equalText",
|
|
category: "Relational",
|
|
syntax: ["equalText(x, y)"],
|
|
description: "Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",
|
|
examples: ['equalText("Hello", "Hello")', 'equalText("a", "A")', 'equal("2e3", "2000")', 'equalText("2e3", "2000")', 'equalText("B", ["A", "B", "C"])'],
|
|
seealso: ["compare", "compareNatural", "compareText", "equal"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/relational/larger.js
|
|
var largerDocs = {
|
|
name: "larger",
|
|
category: "Relational",
|
|
syntax: ["x > y", "larger(x, y)"],
|
|
description: "Check if value x is larger than y. Returns true if x is larger than y, and false if not.",
|
|
examples: ["2 > 3", "5 > 2*2", "a = 3.3", "b = 6-2.8", "(a > b)", "(b < a)", "5 cm > 2 inch"],
|
|
seealso: ["equal", "unequal", "smaller", "smallerEq", "largerEq", "compare"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/relational/largerEq.js
|
|
var largerEqDocs = {
|
|
name: "largerEq",
|
|
category: "Relational",
|
|
syntax: ["x >= y", "largerEq(x, y)"],
|
|
description: "Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",
|
|
examples: ["2 >= 1+1", "2 > 1+1", "a = 3.2", "b = 6-2.8", "(a >= b)"],
|
|
seealso: ["equal", "unequal", "smallerEq", "smaller", "compare"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/relational/smaller.js
|
|
var smallerDocs = {
|
|
name: "smaller",
|
|
category: "Relational",
|
|
syntax: ["x < y", "smaller(x, y)"],
|
|
description: "Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",
|
|
examples: ["2 < 3", "5 < 2*2", "a = 3.3", "b = 6-2.8", "(a < b)", "5 cm < 2 inch"],
|
|
seealso: ["equal", "unequal", "larger", "smallerEq", "largerEq", "compare"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/relational/smallerEq.js
|
|
var smallerEqDocs = {
|
|
name: "smallerEq",
|
|
category: "Relational",
|
|
syntax: ["x <= y", "smallerEq(x, y)"],
|
|
description: "Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",
|
|
examples: ["2 <= 1+1", "2 < 1+1", "a = 3.2", "b = 6-2.8", "(a <= b)"],
|
|
seealso: ["equal", "unequal", "larger", "smaller", "largerEq", "compare"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/relational/unequal.js
|
|
var unequalDocs = {
|
|
name: "unequal",
|
|
category: "Relational",
|
|
syntax: ["x != y", "unequal(x, y)"],
|
|
description: "Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",
|
|
examples: ["2+2 != 3", "2+2 != 4", "a = 3.2", "b = 6-2.8", "a != b", "50cm != 0.5m", "5 cm != 2 inch"],
|
|
seealso: ["equal", "smaller", "larger", "smallerEq", "largerEq", "compare", "deepEqual"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/set/setCartesian.js
|
|
var setCartesianDocs = {
|
|
name: "setCartesian",
|
|
category: "Set",
|
|
syntax: ["setCartesian(set1, set2)"],
|
|
description: "Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays and the values will be sorted in ascending order before the operation.",
|
|
examples: ["setCartesian([1, 2], [3, 4])"],
|
|
seealso: ["setUnion", "setIntersect", "setDifference", "setPowerset"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/set/setDifference.js
|
|
var setDifferenceDocs = {
|
|
name: "setDifference",
|
|
category: "Set",
|
|
syntax: ["setDifference(set1, set2)"],
|
|
description: "Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",
|
|
examples: ["setDifference([1, 2, 3, 4], [3, 4, 5, 6])", "setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],
|
|
seealso: ["setUnion", "setIntersect", "setSymDifference"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/set/setDistinct.js
|
|
var setDistinctDocs = {
|
|
name: "setDistinct",
|
|
category: "Set",
|
|
syntax: ["setDistinct(set)"],
|
|
description: "Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",
|
|
examples: ["setDistinct([1, 1, 1, 2, 2, 3])"],
|
|
seealso: ["setMultiplicity"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/set/setIntersect.js
|
|
var setIntersectDocs = {
|
|
name: "setIntersect",
|
|
category: "Set",
|
|
syntax: ["setIntersect(set1, set2)"],
|
|
description: "Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",
|
|
examples: ["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])", "setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],
|
|
seealso: ["setUnion", "setDifference"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/set/setIsSubset.js
|
|
var setIsSubsetDocs = {
|
|
name: "setIsSubset",
|
|
category: "Set",
|
|
syntax: ["setIsSubset(set1, set2)"],
|
|
description: "Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",
|
|
examples: ["setIsSubset([1, 2], [3, 4, 5, 6])", "setIsSubset([3, 4], [3, 4, 5, 6])"],
|
|
seealso: ["setUnion", "setIntersect", "setDifference"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/set/setMultiplicity.js
|
|
var setMultiplicityDocs = {
|
|
name: "setMultiplicity",
|
|
category: "Set",
|
|
syntax: ["setMultiplicity(element, set)"],
|
|
description: "Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",
|
|
examples: ["setMultiplicity(1, [1, 2, 2, 4])", "setMultiplicity(2, [1, 2, 2, 4])"],
|
|
seealso: ["setDistinct", "setSize"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/set/setPowerset.js
|
|
var setPowersetDocs = {
|
|
name: "setPowerset",
|
|
category: "Set",
|
|
syntax: ["setPowerset(set)"],
|
|
description: "Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",
|
|
examples: ["setPowerset([1, 2, 3])"],
|
|
seealso: ["setCartesian"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/set/setSize.js
|
|
var setSizeDocs = {
|
|
name: "setSize",
|
|
category: "Set",
|
|
syntax: ["setSize(set)", "setSize(set, unique)"],
|
|
description: 'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',
|
|
examples: ["setSize([1, 2, 2, 4])", "setSize([1, 2, 2, 4], true)"],
|
|
seealso: ["setUnion", "setIntersect", "setDifference"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/set/setSymDifference.js
|
|
var setSymDifferenceDocs = {
|
|
name: "setSymDifference",
|
|
category: "Set",
|
|
syntax: ["setSymDifference(set1, set2)"],
|
|
description: "Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",
|
|
examples: ["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])", "setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],
|
|
seealso: ["setUnion", "setIntersect", "setDifference"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/set/setUnion.js
|
|
var setUnionDocs = {
|
|
name: "setUnion",
|
|
category: "Set",
|
|
syntax: ["setUnion(set1, set2)"],
|
|
description: "Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",
|
|
examples: ["setUnion([1, 2, 3, 4], [3, 4, 5, 6])", "setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],
|
|
seealso: ["setIntersect", "setDifference"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/special/erf.js
|
|
var erfDocs = {
|
|
name: "erf",
|
|
category: "Special",
|
|
syntax: ["erf(x)"],
|
|
description: "Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",
|
|
examples: ["erf(0.2)", "erf(-0.5)", "erf(4)"],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/statistics/mad.js
|
|
var madDocs = {
|
|
name: "mad",
|
|
category: "Statistics",
|
|
syntax: ["mad(a, b, c, ...)", "mad(A)"],
|
|
description: "Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",
|
|
examples: ["mad(10, 20, 30)", "mad([1, 2, 3])"],
|
|
seealso: ["mean", "median", "std", "abs"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/statistics/max.js
|
|
var maxDocs = {
|
|
name: "max",
|
|
category: "Statistics",
|
|
syntax: ["max(a, b, c, ...)", "max(A)", "max(A, dimension)"],
|
|
description: "Compute the maximum value of a list of values.",
|
|
examples: ["max(2, 3, 4, 1)", "max([2, 3, 4, 1])", "max([2, 5; 4, 3])", "max([2, 5; 4, 3], 1)", "max([2, 5; 4, 3], 2)", "max(2.7, 7.1, -4.5, 2.0, 4.1)", "min(2.7, 7.1, -4.5, 2.0, 4.1)"],
|
|
seealso: ["mean", "median", "min", "prod", "std", "sum", "variance"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/statistics/mean.js
|
|
var meanDocs = {
|
|
name: "mean",
|
|
category: "Statistics",
|
|
syntax: ["mean(a, b, c, ...)", "mean(A)", "mean(A, dimension)"],
|
|
description: "Compute the arithmetic mean of a list of values.",
|
|
examples: ["mean(2, 3, 4, 1)", "mean([2, 3, 4, 1])", "mean([2, 5; 4, 3])", "mean([2, 5; 4, 3], 1)", "mean([2, 5; 4, 3], 2)", "mean([1.0, 2.7, 3.2, 4.0])"],
|
|
seealso: ["max", "median", "min", "prod", "std", "sum", "variance"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/statistics/median.js
|
|
var medianDocs = {
|
|
name: "median",
|
|
category: "Statistics",
|
|
syntax: ["median(a, b, c, ...)", "median(A)"],
|
|
description: "Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",
|
|
examples: ["median(5, 2, 7)", "median([3, -1, 5, 7])"],
|
|
seealso: ["max", "mean", "min", "prod", "std", "sum", "variance", "quantileSeq"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/statistics/min.js
|
|
var minDocs = {
|
|
name: "min",
|
|
category: "Statistics",
|
|
syntax: ["min(a, b, c, ...)", "min(A)", "min(A, dimension)"],
|
|
description: "Compute the minimum value of a list of values.",
|
|
examples: ["min(2, 3, 4, 1)", "min([2, 3, 4, 1])", "min([2, 5; 4, 3])", "min([2, 5; 4, 3], 1)", "min([2, 5; 4, 3], 2)", "min(2.7, 7.1, -4.5, 2.0, 4.1)", "max(2.7, 7.1, -4.5, 2.0, 4.1)"],
|
|
seealso: ["max", "mean", "median", "prod", "std", "sum", "variance"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/statistics/mode.js
|
|
var modeDocs = {
|
|
name: "mode",
|
|
category: "Statistics",
|
|
syntax: ["mode(a, b, c, ...)", "mode(A)", "mode(A, a, b, B, c, ...)"],
|
|
description: "Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",
|
|
examples: ["mode(2, 1, 4, 3, 1)", "mode([1, 2.7, 3.2, 4, 2.7])", "mode(1, 4, 6, 1, 6)"],
|
|
seealso: ["max", "mean", "min", "median", "prod", "std", "sum", "variance"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/statistics/prod.js
|
|
var prodDocs = {
|
|
name: "prod",
|
|
category: "Statistics",
|
|
syntax: ["prod(a, b, c, ...)", "prod(A)"],
|
|
description: "Compute the product of all values.",
|
|
examples: ["prod(2, 3, 4)", "prod([2, 3, 4])", "prod([2, 5; 4, 3])"],
|
|
seealso: ["max", "mean", "min", "median", "min", "std", "sum", "variance"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/statistics/quantileSeq.js
|
|
var quantileSeqDocs = {
|
|
name: "quantileSeq",
|
|
category: "Statistics",
|
|
syntax: ["quantileSeq(A, prob[, sorted])", "quantileSeq(A, [prob1, prob2, ...][, sorted])", "quantileSeq(A, N[, sorted])"],
|
|
description: "Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.",
|
|
examples: ["quantileSeq([3, -1, 5, 7], 0.5)", "quantileSeq([3, -1, 5, 7], [1/3, 2/3])", "quantileSeq([3, -1, 5, 7], 2)", "quantileSeq([-1, 3, 5, 7], 0.5, true)"],
|
|
seealso: ["mean", "median", "min", "max", "prod", "std", "sum", "variance"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/statistics/std.js
|
|
var stdDocs = {
|
|
name: "std",
|
|
category: "Statistics",
|
|
syntax: ["std(a, b, c, ...)", "std(A)", "std(A, dimension)", "std(A, normalization)", "std(A, dimension, normalization)"],
|
|
description: 'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',
|
|
examples: ["std(2, 4, 6)", "std([2, 4, 6, 8])", 'std([2, 4, 6, 8], "uncorrected")', 'std([2, 4, 6, 8], "biased")', "std([1, 2, 3; 4, 5, 6])"],
|
|
seealso: ["max", "mean", "min", "median", "prod", "sum", "variance"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/statistics/cumsum.js
|
|
var cumSumDocs = {
|
|
name: "cumsum",
|
|
category: "Statistics",
|
|
syntax: ["cumsum(a, b, c, ...)", "cumsum(A)"],
|
|
description: "Compute the cumulative sum of all values.",
|
|
examples: ["cumsum(2, 3, 4, 1)", "cumsum([2, 3, 4, 1])", "cumsum([1, 2; 3, 4])", "cumsum([1, 2; 3, 4], 1)", "cumsum([1, 2; 3, 4], 2)"],
|
|
seealso: ["max", "mean", "median", "min", "prod", "std", "sum", "variance"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/statistics/sum.js
|
|
var sumDocs = {
|
|
name: "sum",
|
|
category: "Statistics",
|
|
syntax: ["sum(a, b, c, ...)", "sum(A)", "sum(A, dimension)"],
|
|
description: "Compute the sum of all values.",
|
|
examples: ["sum(2, 3, 4, 1)", "sum([2, 3, 4, 1])", "sum([2, 5; 4, 3])"],
|
|
seealso: ["max", "mean", "median", "min", "prod", "std", "sum", "variance"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/statistics/variance.js
|
|
var varianceDocs = {
|
|
name: "variance",
|
|
category: "Statistics",
|
|
syntax: ["variance(a, b, c, ...)", "variance(A)", "variance(A, dimension)", "variance(A, normalization)", "variance(A, dimension, normalization)"],
|
|
description: 'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',
|
|
examples: ["variance(2, 4, 6)", "variance([2, 4, 6, 8])", 'variance([2, 4, 6, 8], "uncorrected")', 'variance([2, 4, 6, 8], "biased")', "variance([1, 2, 3; 4, 5, 6])"],
|
|
seealso: ["max", "mean", "min", "median", "min", "prod", "std", "sum"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/acos.js
|
|
var acosDocs = {
|
|
name: "acos",
|
|
category: "Trigonometry",
|
|
syntax: ["acos(x)"],
|
|
description: "Compute the inverse cosine of a value in radians.",
|
|
examples: ["acos(0.5)", "acos(cos(2.3))"],
|
|
seealso: ["cos", "atan", "asin"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/acosh.js
|
|
var acoshDocs = {
|
|
name: "acosh",
|
|
category: "Trigonometry",
|
|
syntax: ["acosh(x)"],
|
|
description: "Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",
|
|
examples: ["acosh(1.5)"],
|
|
seealso: ["cosh", "asinh", "atanh"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/acot.js
|
|
var acotDocs = {
|
|
name: "acot",
|
|
category: "Trigonometry",
|
|
syntax: ["acot(x)"],
|
|
description: "Calculate the inverse cotangent of a value.",
|
|
examples: ["acot(0.5)", "acot(cot(0.5))", "acot(2)"],
|
|
seealso: ["cot", "atan"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/acoth.js
|
|
var acothDocs = {
|
|
name: "acoth",
|
|
category: "Trigonometry",
|
|
syntax: ["acoth(x)"],
|
|
description: "Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",
|
|
examples: ["acoth(2)", "acoth(0.5)"],
|
|
seealso: ["acsch", "asech"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/acsc.js
|
|
var acscDocs = {
|
|
name: "acsc",
|
|
category: "Trigonometry",
|
|
syntax: ["acsc(x)"],
|
|
description: "Calculate the inverse cotangent of a value.",
|
|
examples: ["acsc(2)", "acsc(csc(0.5))", "acsc(0.5)"],
|
|
seealso: ["csc", "asin", "asec"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/acsch.js
|
|
var acschDocs = {
|
|
name: "acsch",
|
|
category: "Trigonometry",
|
|
syntax: ["acsch(x)"],
|
|
description: "Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",
|
|
examples: ["acsch(0.5)"],
|
|
seealso: ["asech", "acoth"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/asec.js
|
|
var asecDocs = {
|
|
name: "asec",
|
|
category: "Trigonometry",
|
|
syntax: ["asec(x)"],
|
|
description: "Calculate the inverse secant of a value.",
|
|
examples: ["asec(0.5)", "asec(sec(0.5))", "asec(2)"],
|
|
seealso: ["acos", "acot", "acsc"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/asech.js
|
|
var asechDocs = {
|
|
name: "asech",
|
|
category: "Trigonometry",
|
|
syntax: ["asech(x)"],
|
|
description: "Calculate the inverse secant of a value.",
|
|
examples: ["asech(0.5)"],
|
|
seealso: ["acsch", "acoth"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/asin.js
|
|
var asinDocs = {
|
|
name: "asin",
|
|
category: "Trigonometry",
|
|
syntax: ["asin(x)"],
|
|
description: "Compute the inverse sine of a value in radians.",
|
|
examples: ["asin(0.5)", "asin(sin(0.5))"],
|
|
seealso: ["sin", "acos", "atan"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/asinh.js
|
|
var asinhDocs = {
|
|
name: "asinh",
|
|
category: "Trigonometry",
|
|
syntax: ["asinh(x)"],
|
|
description: "Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",
|
|
examples: ["asinh(0.5)"],
|
|
seealso: ["acosh", "atanh"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/atan.js
|
|
var atanDocs = {
|
|
name: "atan",
|
|
category: "Trigonometry",
|
|
syntax: ["atan(x)"],
|
|
description: "Compute the inverse tangent of a value in radians.",
|
|
examples: ["atan(0.5)", "atan(tan(0.5))"],
|
|
seealso: ["tan", "acos", "asin"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/atan2.js
|
|
var atan2Docs = {
|
|
name: "atan2",
|
|
category: "Trigonometry",
|
|
syntax: ["atan2(y, x)"],
|
|
description: "Computes the principal value of the arc tangent of y/x in radians.",
|
|
examples: ["atan2(2, 2) / pi", "angle = 60 deg in rad", "x = cos(angle)", "y = sin(angle)", "atan2(y, x)"],
|
|
seealso: ["sin", "cos", "tan"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/atanh.js
|
|
var atanhDocs = {
|
|
name: "atanh",
|
|
category: "Trigonometry",
|
|
syntax: ["atanh(x)"],
|
|
description: "Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",
|
|
examples: ["atanh(0.5)"],
|
|
seealso: ["acosh", "asinh"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/cos.js
|
|
var cosDocs = {
|
|
name: "cos",
|
|
category: "Trigonometry",
|
|
syntax: ["cos(x)"],
|
|
description: "Compute the cosine of x in radians.",
|
|
examples: ["cos(2)", "cos(pi / 4) ^ 2", "cos(180 deg)", "cos(60 deg)", "sin(0.2)^2 + cos(0.2)^2"],
|
|
seealso: ["acos", "sin", "tan"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/cosh.js
|
|
var coshDocs = {
|
|
name: "cosh",
|
|
category: "Trigonometry",
|
|
syntax: ["cosh(x)"],
|
|
description: "Compute the hyperbolic cosine of x in radians.",
|
|
examples: ["cosh(0.5)"],
|
|
seealso: ["sinh", "tanh", "coth"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/cot.js
|
|
var cotDocs = {
|
|
name: "cot",
|
|
category: "Trigonometry",
|
|
syntax: ["cot(x)"],
|
|
description: "Compute the cotangent of x in radians. Defined as 1/tan(x)",
|
|
examples: ["cot(2)", "1 / tan(2)"],
|
|
seealso: ["sec", "csc", "tan"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/coth.js
|
|
var cothDocs = {
|
|
name: "coth",
|
|
category: "Trigonometry",
|
|
syntax: ["coth(x)"],
|
|
description: "Compute the hyperbolic cotangent of x in radians.",
|
|
examples: ["coth(2)", "1 / tanh(2)"],
|
|
seealso: ["sech", "csch", "tanh"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/csc.js
|
|
var cscDocs = {
|
|
name: "csc",
|
|
category: "Trigonometry",
|
|
syntax: ["csc(x)"],
|
|
description: "Compute the cosecant of x in radians. Defined as 1/sin(x)",
|
|
examples: ["csc(2)", "1 / sin(2)"],
|
|
seealso: ["sec", "cot", "sin"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/csch.js
|
|
var cschDocs = {
|
|
name: "csch",
|
|
category: "Trigonometry",
|
|
syntax: ["csch(x)"],
|
|
description: "Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",
|
|
examples: ["csch(2)", "1 / sinh(2)"],
|
|
seealso: ["sech", "coth", "sinh"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/sec.js
|
|
var secDocs = {
|
|
name: "sec",
|
|
category: "Trigonometry",
|
|
syntax: ["sec(x)"],
|
|
description: "Compute the secant of x in radians. Defined as 1/cos(x)",
|
|
examples: ["sec(2)", "1 / cos(2)"],
|
|
seealso: ["cot", "csc", "cos"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/sech.js
|
|
var sechDocs = {
|
|
name: "sech",
|
|
category: "Trigonometry",
|
|
syntax: ["sech(x)"],
|
|
description: "Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",
|
|
examples: ["sech(2)", "1 / cosh(2)"],
|
|
seealso: ["coth", "csch", "cosh"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/sin.js
|
|
var sinDocs = {
|
|
name: "sin",
|
|
category: "Trigonometry",
|
|
syntax: ["sin(x)"],
|
|
description: "Compute the sine of x in radians.",
|
|
examples: ["sin(2)", "sin(pi / 4) ^ 2", "sin(90 deg)", "sin(30 deg)", "sin(0.2)^2 + cos(0.2)^2"],
|
|
seealso: ["asin", "cos", "tan"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/sinh.js
|
|
var sinhDocs = {
|
|
name: "sinh",
|
|
category: "Trigonometry",
|
|
syntax: ["sinh(x)"],
|
|
description: "Compute the hyperbolic sine of x in radians.",
|
|
examples: ["sinh(0.5)"],
|
|
seealso: ["cosh", "tanh"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/tan.js
|
|
var tanDocs = {
|
|
name: "tan",
|
|
category: "Trigonometry",
|
|
syntax: ["tan(x)"],
|
|
description: "Compute the tangent of x in radians.",
|
|
examples: ["tan(0.5)", "sin(0.5) / cos(0.5)", "tan(pi / 4)", "tan(45 deg)"],
|
|
seealso: ["atan", "sin", "cos"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/trigonometry/tanh.js
|
|
var tanhDocs = {
|
|
name: "tanh",
|
|
category: "Trigonometry",
|
|
syntax: ["tanh(x)"],
|
|
description: "Compute the hyperbolic tangent of x in radians.",
|
|
examples: ["tanh(0.5)", "sinh(0.5) / cosh(0.5)"],
|
|
seealso: ["sinh", "cosh"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/units/to.js
|
|
var toDocs = {
|
|
name: "to",
|
|
category: "Units",
|
|
syntax: ["x to unit", "to(x, unit)"],
|
|
description: "Change the unit of a value.",
|
|
examples: ["5 inch to cm", "3.2kg to g", "16 bytes in bits"],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/utils/bin.js
|
|
var binDocs = {
|
|
name: "bin",
|
|
category: "Utils",
|
|
syntax: ["bin(value)"],
|
|
description: "Format a number as binary",
|
|
examples: ["bin(2)"],
|
|
seealso: ["oct", "hex"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/utils/clone.js
|
|
var cloneDocs = {
|
|
name: "clone",
|
|
category: "Utils",
|
|
syntax: ["clone(x)"],
|
|
description: "Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",
|
|
examples: ["clone(3.5)", "clone(2 - 4i)", "clone(45 deg)", "clone([1, 2; 3, 4])", 'clone("hello world")'],
|
|
seealso: []
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/utils/format.js
|
|
var formatDocs = {
|
|
name: "format",
|
|
category: "Utils",
|
|
syntax: ["format(value)", "format(value, precision)"],
|
|
description: "Format a value of any type as string.",
|
|
examples: ["format(2.3)", "format(3 - 4i)", "format([])", "format(pi, 3)"],
|
|
seealso: ["print"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/utils/hasNumericValue.js
|
|
var hasNumericValueDocs = {
|
|
name: "hasNumericValue",
|
|
category: "Utils",
|
|
syntax: ["hasNumericValue(x)"],
|
|
description: "Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",
|
|
examples: ["hasNumericValue(2)", 'hasNumericValue("2")', 'isNumeric("2")', "hasNumericValue(0)", "hasNumericValue(bignumber(500))", "hasNumericValue(fraction(0.125))", "hasNumericValue(2 + 3i)", 'hasNumericValue([2.3, "foo", false])'],
|
|
seealso: ["isInteger", "isZero", "isNegative", "isPositive", "isNaN", "isNumeric"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/utils/hex.js
|
|
var hexDocs = {
|
|
name: "hex",
|
|
category: "Utils",
|
|
syntax: ["hex(value)"],
|
|
description: "Format a number as hexadecimal",
|
|
examples: ["hex(240)"],
|
|
seealso: ["bin", "oct"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/utils/isInteger.js
|
|
var isIntegerDocs = {
|
|
name: "isInteger",
|
|
category: "Utils",
|
|
syntax: ["isInteger(x)"],
|
|
description: "Test whether a value is an integer number.",
|
|
examples: ["isInteger(2)", "isInteger(3.5)", "isInteger([3, 0.5, -2])"],
|
|
seealso: ["isNegative", "isNumeric", "isPositive", "isZero"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/utils/isNaN.js
|
|
var isNaNDocs = {
|
|
name: "isNaN",
|
|
category: "Utils",
|
|
syntax: ["isNaN(x)"],
|
|
description: "Test whether a value is NaN (not a number)",
|
|
examples: ["isNaN(2)", "isNaN(0 / 0)", "isNaN(NaN)", "isNaN(Infinity)"],
|
|
seealso: ["isNegative", "isNumeric", "isPositive", "isZero"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/utils/isNegative.js
|
|
var isNegativeDocs = {
|
|
name: "isNegative",
|
|
category: "Utils",
|
|
syntax: ["isNegative(x)"],
|
|
description: "Test whether a value is negative: smaller than zero.",
|
|
examples: ["isNegative(2)", "isNegative(0)", "isNegative(-4)", "isNegative([3, 0.5, -2])"],
|
|
seealso: ["isInteger", "isNumeric", "isPositive", "isZero"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/utils/isNumeric.js
|
|
var isNumericDocs = {
|
|
name: "isNumeric",
|
|
category: "Utils",
|
|
syntax: ["isNumeric(x)"],
|
|
description: "Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",
|
|
examples: ["isNumeric(2)", 'isNumeric("2")', 'hasNumericValue("2")', "isNumeric(0)", "isNumeric(bignumber(500))", "isNumeric(fraction(0.125))", "isNumeric(2 + 3i)", 'isNumeric([2.3, "foo", false])'],
|
|
seealso: ["isInteger", "isZero", "isNegative", "isPositive", "isNaN", "hasNumericValue"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/utils/isPositive.js
|
|
var isPositiveDocs = {
|
|
name: "isPositive",
|
|
category: "Utils",
|
|
syntax: ["isPositive(x)"],
|
|
description: "Test whether a value is positive: larger than zero.",
|
|
examples: ["isPositive(2)", "isPositive(0)", "isPositive(-4)", "isPositive([3, 0.5, -2])"],
|
|
seealso: ["isInteger", "isNumeric", "isNegative", "isZero"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/utils/isPrime.js
|
|
var isPrimeDocs = {
|
|
name: "isPrime",
|
|
category: "Utils",
|
|
syntax: ["isPrime(x)"],
|
|
description: "Test whether a value is prime: has no divisors other than itself and one.",
|
|
examples: ["isPrime(3)", "isPrime(-2)", "isPrime([2, 17, 100])"],
|
|
seealso: ["isInteger", "isNumeric", "isNegative", "isZero"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/utils/isZero.js
|
|
var isZeroDocs = {
|
|
name: "isZero",
|
|
category: "Utils",
|
|
syntax: ["isZero(x)"],
|
|
description: "Test whether a value is zero.",
|
|
examples: ["isZero(2)", "isZero(0)", "isZero(-4)", "isZero([3, 0, -2, 0])"],
|
|
seealso: ["isInteger", "isNumeric", "isNegative", "isPositive"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/utils/numeric.js
|
|
var numericDocs = {
|
|
name: "numeric",
|
|
category: "Utils",
|
|
syntax: ["numeric(x)"],
|
|
description: "Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.",
|
|
examples: ['numeric("4")', 'numeric("4", "number")', 'numeric("4", "BigNumber")', 'numeric("4", "Fraction)', 'numeric(4, "Fraction")', 'numeric(fraction(2, 5), "number)'],
|
|
seealso: ["number", "fraction", "bignumber", "string", "format"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/utils/oct.js
|
|
var octDocs = {
|
|
name: "oct",
|
|
category: "Utils",
|
|
syntax: ["oct(value)"],
|
|
description: "Format a number as octal",
|
|
examples: ["oct(56)"],
|
|
seealso: ["bin", "hex"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/utils/print.js
|
|
var printDocs = {
|
|
name: "print",
|
|
category: "Utils",
|
|
syntax: ["print(template, values)", "print(template, values, precision)"],
|
|
description: "Interpolate values into a string template.",
|
|
examples: ['print("Lucy is $age years old", {age: 5})', 'print("The value of pi is $pi", {pi: pi}, 3)', 'print("Hello, $user.name!", {user: {name: "John"}})', 'print("Values: $0, $1, $2", [6, 9, 4])'],
|
|
seealso: ["format"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/function/utils/typeOf.js
|
|
var typeOfDocs = {
|
|
name: "typeOf",
|
|
category: "Utils",
|
|
syntax: ["typeOf(x)"],
|
|
description: "Get the type of a variable.",
|
|
examples: ["typeOf(3.5)", "typeOf(2 - 4i)", "typeOf(45 deg)", 'typeOf("hello world")'],
|
|
seealso: ["getMatrixDataType"]
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/embeddedDocs/embeddedDocs.js
|
|
var embeddedDocs = {
|
|
bignumber: bignumberDocs,
|
|
boolean: booleanDocs,
|
|
complex: complexDocs,
|
|
createUnit: createUnitDocs,
|
|
fraction: fractionDocs,
|
|
index: indexDocs,
|
|
matrix: matrixDocs,
|
|
number: numberDocs,
|
|
sparse: sparseDocs,
|
|
splitUnit: splitUnitDocs,
|
|
string: stringDocs,
|
|
unit: unitDocs,
|
|
e: eDocs,
|
|
E: eDocs,
|
|
false: falseDocs,
|
|
i: iDocs,
|
|
Infinity: InfinityDocs,
|
|
LN2: LN2Docs,
|
|
LN10: LN10Docs,
|
|
LOG2E: LOG2EDocs,
|
|
LOG10E: LOG10EDocs,
|
|
NaN: NaNDocs,
|
|
null: nullDocs,
|
|
pi: piDocs,
|
|
PI: piDocs,
|
|
phi: phiDocs,
|
|
SQRT1_2: SQRT12Docs,
|
|
SQRT2: SQRT2Docs,
|
|
tau: tauDocs,
|
|
true: trueDocs,
|
|
version: versionDocs,
|
|
speedOfLight: {
|
|
description: "Speed of light in vacuum",
|
|
examples: ["speedOfLight"]
|
|
},
|
|
gravitationConstant: {
|
|
description: "Newtonian constant of gravitation",
|
|
examples: ["gravitationConstant"]
|
|
},
|
|
planckConstant: {
|
|
description: "Planck constant",
|
|
examples: ["planckConstant"]
|
|
},
|
|
reducedPlanckConstant: {
|
|
description: "Reduced Planck constant",
|
|
examples: ["reducedPlanckConstant"]
|
|
},
|
|
magneticConstant: {
|
|
description: "Magnetic constant (vacuum permeability)",
|
|
examples: ["magneticConstant"]
|
|
},
|
|
electricConstant: {
|
|
description: "Electric constant (vacuum permeability)",
|
|
examples: ["electricConstant"]
|
|
},
|
|
vacuumImpedance: {
|
|
description: "Characteristic impedance of vacuum",
|
|
examples: ["vacuumImpedance"]
|
|
},
|
|
coulomb: {
|
|
description: "Coulomb's constant",
|
|
examples: ["coulomb"]
|
|
},
|
|
elementaryCharge: {
|
|
description: "Elementary charge",
|
|
examples: ["elementaryCharge"]
|
|
},
|
|
bohrMagneton: {
|
|
description: "Borh magneton",
|
|
examples: ["bohrMagneton"]
|
|
},
|
|
conductanceQuantum: {
|
|
description: "Conductance quantum",
|
|
examples: ["conductanceQuantum"]
|
|
},
|
|
inverseConductanceQuantum: {
|
|
description: "Inverse conductance quantum",
|
|
examples: ["inverseConductanceQuantum"]
|
|
},
|
|
magneticFluxQuantum: {
|
|
description: "Magnetic flux quantum",
|
|
examples: ["magneticFluxQuantum"]
|
|
},
|
|
nuclearMagneton: {
|
|
description: "Nuclear magneton",
|
|
examples: ["nuclearMagneton"]
|
|
},
|
|
klitzing: {
|
|
description: "Von Klitzing constant",
|
|
examples: ["klitzing"]
|
|
},
|
|
bohrRadius: {
|
|
description: "Borh radius",
|
|
examples: ["bohrRadius"]
|
|
},
|
|
classicalElectronRadius: {
|
|
description: "Classical electron radius",
|
|
examples: ["classicalElectronRadius"]
|
|
},
|
|
electronMass: {
|
|
description: "Electron mass",
|
|
examples: ["electronMass"]
|
|
},
|
|
fermiCoupling: {
|
|
description: "Fermi coupling constant",
|
|
examples: ["fermiCoupling"]
|
|
},
|
|
fineStructure: {
|
|
description: "Fine-structure constant",
|
|
examples: ["fineStructure"]
|
|
},
|
|
hartreeEnergy: {
|
|
description: "Hartree energy",
|
|
examples: ["hartreeEnergy"]
|
|
},
|
|
protonMass: {
|
|
description: "Proton mass",
|
|
examples: ["protonMass"]
|
|
},
|
|
deuteronMass: {
|
|
description: "Deuteron Mass",
|
|
examples: ["deuteronMass"]
|
|
},
|
|
neutronMass: {
|
|
description: "Neutron mass",
|
|
examples: ["neutronMass"]
|
|
},
|
|
quantumOfCirculation: {
|
|
description: "Quantum of circulation",
|
|
examples: ["quantumOfCirculation"]
|
|
},
|
|
rydberg: {
|
|
description: "Rydberg constant",
|
|
examples: ["rydberg"]
|
|
},
|
|
thomsonCrossSection: {
|
|
description: "Thomson cross section",
|
|
examples: ["thomsonCrossSection"]
|
|
},
|
|
weakMixingAngle: {
|
|
description: "Weak mixing angle",
|
|
examples: ["weakMixingAngle"]
|
|
},
|
|
efimovFactor: {
|
|
description: "Efimov factor",
|
|
examples: ["efimovFactor"]
|
|
},
|
|
atomicMass: {
|
|
description: "Atomic mass constant",
|
|
examples: ["atomicMass"]
|
|
},
|
|
avogadro: {
|
|
description: "Avogadro's number",
|
|
examples: ["avogadro"]
|
|
},
|
|
boltzmann: {
|
|
description: "Boltzmann constant",
|
|
examples: ["boltzmann"]
|
|
},
|
|
faraday: {
|
|
description: "Faraday constant",
|
|
examples: ["faraday"]
|
|
},
|
|
firstRadiation: {
|
|
description: "First radiation constant",
|
|
examples: ["firstRadiation"]
|
|
},
|
|
loschmidt: {
|
|
description: "Loschmidt constant at T=273.15 K and p=101.325 kPa",
|
|
examples: ["loschmidt"]
|
|
},
|
|
gasConstant: {
|
|
description: "Gas constant",
|
|
examples: ["gasConstant"]
|
|
},
|
|
molarPlanckConstant: {
|
|
description: "Molar Planck constant",
|
|
examples: ["molarPlanckConstant"]
|
|
},
|
|
molarVolume: {
|
|
description: "Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",
|
|
examples: ["molarVolume"]
|
|
},
|
|
sackurTetrode: {
|
|
description: "Sackur-Tetrode constant at T=1 K and p=101.325 kPa",
|
|
examples: ["sackurTetrode"]
|
|
},
|
|
secondRadiation: {
|
|
description: "Second radiation constant",
|
|
examples: ["secondRadiation"]
|
|
},
|
|
stefanBoltzmann: {
|
|
description: "Stefan-Boltzmann constant",
|
|
examples: ["stefanBoltzmann"]
|
|
},
|
|
wienDisplacement: {
|
|
description: "Wien displacement law constant",
|
|
examples: ["wienDisplacement"]
|
|
},
|
|
molarMass: {
|
|
description: "Molar mass constant",
|
|
examples: ["molarMass"]
|
|
},
|
|
molarMassC12: {
|
|
description: "Molar mass constant of carbon-12",
|
|
examples: ["molarMassC12"]
|
|
},
|
|
gravity: {
|
|
description: "Standard acceleration of gravity (standard acceleration of free-fall on Earth)",
|
|
examples: ["gravity"]
|
|
},
|
|
planckLength: {
|
|
description: "Planck length",
|
|
examples: ["planckLength"]
|
|
},
|
|
planckMass: {
|
|
description: "Planck mass",
|
|
examples: ["planckMass"]
|
|
},
|
|
planckTime: {
|
|
description: "Planck time",
|
|
examples: ["planckTime"]
|
|
},
|
|
planckCharge: {
|
|
description: "Planck charge",
|
|
examples: ["planckCharge"]
|
|
},
|
|
planckTemperature: {
|
|
description: "Planck temperature",
|
|
examples: ["planckTemperature"]
|
|
},
|
|
derivative: derivativeDocs,
|
|
lsolve: lsolveDocs,
|
|
lsolveAll: lsolveAllDocs,
|
|
lup: lupDocs,
|
|
lusolve: lusolveDocs,
|
|
leafCount: leafCountDocs,
|
|
polynomialRoot: polynomialRootDocs,
|
|
resolve: resolveDocs,
|
|
simplify: simplifyDocs,
|
|
simplifyConstant: simplifyConstantDocs,
|
|
simplifyCore: simplifyCoreDocs,
|
|
symbolicEqual: symbolicEqualDocs,
|
|
rationalize: rationalizeDocs,
|
|
slu: sluDocs,
|
|
usolve: usolveDocs,
|
|
usolveAll: usolveAllDocs,
|
|
qr: qrDocs,
|
|
abs: absDocs,
|
|
add: addDocs,
|
|
cbrt: cbrtDocs,
|
|
ceil: ceilDocs,
|
|
cube: cubeDocs,
|
|
divide: divideDocs,
|
|
dotDivide: dotDivideDocs,
|
|
dotMultiply: dotMultiplyDocs,
|
|
dotPow: dotPowDocs,
|
|
exp: expDocs,
|
|
expm: expmDocs,
|
|
expm1: expm1Docs,
|
|
fix: fixDocs,
|
|
floor: floorDocs,
|
|
gcd: gcdDocs,
|
|
hypot: hypotDocs,
|
|
lcm: lcmDocs,
|
|
log: logDocs,
|
|
log2: log2Docs,
|
|
log1p: log1pDocs,
|
|
log10: log10Docs,
|
|
mod: modDocs,
|
|
multiply: multiplyDocs,
|
|
norm: normDocs,
|
|
nthRoot: nthRootDocs,
|
|
nthRoots: nthRootsDocs,
|
|
pow: powDocs,
|
|
round: roundDocs,
|
|
sign: signDocs,
|
|
sqrt: sqrtDocs,
|
|
sqrtm: sqrtmDocs,
|
|
square: squareDocs,
|
|
subtract: subtractDocs,
|
|
unaryMinus: unaryMinusDocs,
|
|
unaryPlus: unaryPlusDocs,
|
|
xgcd: xgcdDocs,
|
|
invmod: invmodDocs,
|
|
bitAnd: bitAndDocs,
|
|
bitNot: bitNotDocs,
|
|
bitOr: bitOrDocs,
|
|
bitXor: bitXorDocs,
|
|
leftShift: leftShiftDocs,
|
|
rightArithShift: rightArithShiftDocs,
|
|
rightLogShift: rightLogShiftDocs,
|
|
bellNumbers: bellNumbersDocs,
|
|
catalan: catalanDocs,
|
|
composition: compositionDocs,
|
|
stirlingS2: stirlingS2Docs,
|
|
config: configDocs,
|
|
import: importDocs,
|
|
typed: typedDocs,
|
|
arg: argDocs,
|
|
conj: conjDocs,
|
|
re: reDocs,
|
|
im: imDocs,
|
|
evaluate: evaluateDocs,
|
|
help: helpDocs,
|
|
distance: distanceDocs,
|
|
intersect: intersectDocs,
|
|
and: andDocs,
|
|
not: notDocs,
|
|
or: orDocs,
|
|
xor: xorDocs,
|
|
concat: concatDocs,
|
|
count: countDocs,
|
|
cross: crossDocs,
|
|
column: columnDocs,
|
|
ctranspose: ctransposeDocs,
|
|
det: detDocs,
|
|
diag: diagDocs,
|
|
diff: diffDocs,
|
|
dot: dotDocs,
|
|
getMatrixDataType: getMatrixDataTypeDocs,
|
|
identity: identityDocs,
|
|
filter: filterDocs,
|
|
flatten: flattenDocs,
|
|
forEach: forEachDocs,
|
|
inv: invDocs,
|
|
pinv: pinvDocs,
|
|
eigs: eigsDocs,
|
|
kron: kronDocs,
|
|
matrixFromFunction: matrixFromFunctionDocs,
|
|
matrixFromRows: matrixFromRowsDocs,
|
|
matrixFromColumns: matrixFromColumnsDocs,
|
|
map: mapDocs,
|
|
ones: onesDocs,
|
|
partitionSelect: partitionSelectDocs,
|
|
range: rangeDocs,
|
|
resize: resizeDocs,
|
|
reshape: reshapeDocs,
|
|
rotate: rotateDocs,
|
|
rotationMatrix: rotationMatrixDocs,
|
|
row: rowDocs,
|
|
size: sizeDocs,
|
|
sort: sortDocs,
|
|
squeeze: squeezeDocs,
|
|
subset: subsetDocs,
|
|
trace: traceDocs,
|
|
transpose: transposeDocs,
|
|
zeros: zerosDocs,
|
|
fft: fftDocs,
|
|
ifft: ifftDocs,
|
|
sylvester: sylvesterDocs,
|
|
schur: schurDocs,
|
|
lyap: lyapDocs,
|
|
combinations: combinationsDocs,
|
|
combinationsWithRep: combinationsWithRepDocs,
|
|
factorial: factorialDocs,
|
|
gamma: gammaDocs,
|
|
kldivergence: kldivergenceDocs,
|
|
lgamma: lgammaDocs,
|
|
multinomial: multinomialDocs,
|
|
permutations: permutationsDocs,
|
|
pickRandom: pickRandomDocs,
|
|
random: randomDocs,
|
|
randomInt: randomIntDocs,
|
|
compare: compareDocs,
|
|
compareNatural: compareNaturalDocs,
|
|
compareText: compareTextDocs,
|
|
deepEqual: deepEqualDocs,
|
|
equal: equalDocs,
|
|
equalText: equalTextDocs,
|
|
larger: largerDocs,
|
|
largerEq: largerEqDocs,
|
|
smaller: smallerDocs,
|
|
smallerEq: smallerEqDocs,
|
|
unequal: unequalDocs,
|
|
setCartesian: setCartesianDocs,
|
|
setDifference: setDifferenceDocs,
|
|
setDistinct: setDistinctDocs,
|
|
setIntersect: setIntersectDocs,
|
|
setIsSubset: setIsSubsetDocs,
|
|
setMultiplicity: setMultiplicityDocs,
|
|
setPowerset: setPowersetDocs,
|
|
setSize: setSizeDocs,
|
|
setSymDifference: setSymDifferenceDocs,
|
|
setUnion: setUnionDocs,
|
|
erf: erfDocs,
|
|
cumsum: cumSumDocs,
|
|
mad: madDocs,
|
|
max: maxDocs,
|
|
mean: meanDocs,
|
|
median: medianDocs,
|
|
min: minDocs,
|
|
mode: modeDocs,
|
|
prod: prodDocs,
|
|
quantileSeq: quantileSeqDocs,
|
|
std: stdDocs,
|
|
sum: sumDocs,
|
|
variance: varianceDocs,
|
|
acos: acosDocs,
|
|
acosh: acoshDocs,
|
|
acot: acotDocs,
|
|
acoth: acothDocs,
|
|
acsc: acscDocs,
|
|
acsch: acschDocs,
|
|
asec: asecDocs,
|
|
asech: asechDocs,
|
|
asin: asinDocs,
|
|
asinh: asinhDocs,
|
|
atan: atanDocs,
|
|
atanh: atanhDocs,
|
|
atan2: atan2Docs,
|
|
cos: cosDocs,
|
|
cosh: coshDocs,
|
|
cot: cotDocs,
|
|
coth: cothDocs,
|
|
csc: cscDocs,
|
|
csch: cschDocs,
|
|
sec: secDocs,
|
|
sech: sechDocs,
|
|
sin: sinDocs,
|
|
sinh: sinhDocs,
|
|
tan: tanDocs,
|
|
tanh: tanhDocs,
|
|
to: toDocs,
|
|
clone: cloneDocs,
|
|
format: formatDocs,
|
|
bin: binDocs,
|
|
oct: octDocs,
|
|
hex: hexDocs,
|
|
isNaN: isNaNDocs,
|
|
isInteger: isIntegerDocs,
|
|
isNegative: isNegativeDocs,
|
|
isNumeric: isNumericDocs,
|
|
hasNumericValue: hasNumericValueDocs,
|
|
isPositive: isPositiveDocs,
|
|
isPrime: isPrimeDocs,
|
|
isZero: isZeroDocs,
|
|
print: printDocs,
|
|
typeOf: typeOfDocs,
|
|
numeric: numericDocs
|
|
};
|
|
|
|
// node_modules/mathjs/lib/esm/expression/function/help.js
|
|
var name236 = "help";
|
|
var dependencies236 = ["typed", "mathWithTransform", "Help"];
|
|
var createHelp = /* @__PURE__ */ factory(name236, dependencies236, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
mathWithTransform: mathWithTransform2,
|
|
Help: Help2
|
|
} = _ref;
|
|
return typed2(name236, {
|
|
any: function any(search) {
|
|
var prop;
|
|
var searchName = search;
|
|
if (typeof search !== "string") {
|
|
for (prop in mathWithTransform2) {
|
|
if (hasOwnProperty2(mathWithTransform2, prop) && search === mathWithTransform2[prop]) {
|
|
searchName = prop;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
var doc = getSafeProperty(embeddedDocs, searchName);
|
|
if (!doc) {
|
|
var searchText = typeof searchName === "function" ? searchName.name : searchName;
|
|
throw new Error('No documentation found on "' + searchText + '"');
|
|
}
|
|
return new Help2(doc);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/type/chain/function/chain.js
|
|
var name237 = "chain";
|
|
var dependencies237 = ["typed", "Chain"];
|
|
var createChain = /* @__PURE__ */ factory(name237, dependencies237, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
Chain: Chain2
|
|
} = _ref;
|
|
return typed2(name237, {
|
|
"": function _() {
|
|
return new Chain2();
|
|
},
|
|
any: function any(value) {
|
|
return new Chain2(value);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/det.js
|
|
var name238 = "det";
|
|
var dependencies238 = ["typed", "matrix", "subtract", "multiply", "divideScalar", "isZero", "unaryMinus"];
|
|
var createDet = /* @__PURE__ */ factory(name238, dependencies238, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
subtract: subtract2,
|
|
multiply: multiply2,
|
|
divideScalar: divideScalar2,
|
|
isZero: isZero2,
|
|
unaryMinus: unaryMinus2
|
|
} = _ref;
|
|
return typed2(name238, {
|
|
any: function any(x) {
|
|
return clone(x);
|
|
},
|
|
"Array | Matrix": function det2(x) {
|
|
var size2;
|
|
if (isMatrix(x)) {
|
|
size2 = x.size();
|
|
} else if (Array.isArray(x)) {
|
|
x = matrix2(x);
|
|
size2 = x.size();
|
|
} else {
|
|
size2 = [];
|
|
}
|
|
switch (size2.length) {
|
|
case 0:
|
|
return clone(x);
|
|
case 1:
|
|
if (size2[0] === 1) {
|
|
return clone(x.valueOf()[0]);
|
|
} else {
|
|
throw new RangeError("Matrix must be square (size: " + format3(size2) + ")");
|
|
}
|
|
case 2: {
|
|
var rows = size2[0];
|
|
var cols = size2[1];
|
|
if (rows === cols) {
|
|
return _det(x.clone().valueOf(), rows, cols);
|
|
} else {
|
|
throw new RangeError("Matrix must be square (size: " + format3(size2) + ")");
|
|
}
|
|
}
|
|
default:
|
|
throw new RangeError("Matrix must be two dimensional (size: " + format3(size2) + ")");
|
|
}
|
|
}
|
|
});
|
|
function _det(matrix3, rows, cols) {
|
|
if (rows === 1) {
|
|
return clone(matrix3[0][0]);
|
|
} else if (rows === 2) {
|
|
return subtract2(multiply2(matrix3[0][0], matrix3[1][1]), multiply2(matrix3[1][0], matrix3[0][1]));
|
|
} else {
|
|
var negated = false;
|
|
var rowIndices = new Array(rows).fill(0).map((_, i3) => i3);
|
|
for (var k = 0; k < rows; k++) {
|
|
var k_ = rowIndices[k];
|
|
if (isZero2(matrix3[k_][k])) {
|
|
var _k = void 0;
|
|
for (_k = k + 1; _k < rows; _k++) {
|
|
if (!isZero2(matrix3[rowIndices[_k]][k])) {
|
|
k_ = rowIndices[_k];
|
|
rowIndices[_k] = rowIndices[k];
|
|
rowIndices[k] = k_;
|
|
negated = !negated;
|
|
break;
|
|
}
|
|
}
|
|
if (_k === rows)
|
|
return matrix3[k_][k];
|
|
}
|
|
var piv = matrix3[k_][k];
|
|
var piv_ = k === 0 ? 1 : matrix3[rowIndices[k - 1]][k - 1];
|
|
for (var i2 = k + 1; i2 < rows; i2++) {
|
|
var i_ = rowIndices[i2];
|
|
for (var j = k + 1; j < rows; j++) {
|
|
matrix3[i_][j] = divideScalar2(subtract2(multiply2(matrix3[i_][j], piv), multiply2(matrix3[i_][k], matrix3[k_][j])), piv_);
|
|
}
|
|
}
|
|
}
|
|
var det2 = matrix3[rowIndices[rows - 1]][rows - 1];
|
|
return negated ? unaryMinus2(det2) : det2;
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/inv.js
|
|
var name239 = "inv";
|
|
var dependencies239 = ["typed", "matrix", "divideScalar", "addScalar", "multiply", "unaryMinus", "det", "identity", "abs"];
|
|
var createInv = /* @__PURE__ */ factory(name239, dependencies239, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
divideScalar: divideScalar2,
|
|
addScalar: addScalar2,
|
|
multiply: multiply2,
|
|
unaryMinus: unaryMinus2,
|
|
det: det2,
|
|
identity: identity2,
|
|
abs: abs3
|
|
} = _ref;
|
|
return typed2(name239, {
|
|
"Array | Matrix": function ArrayMatrix(x) {
|
|
var size2 = isMatrix(x) ? x.size() : arraySize(x);
|
|
switch (size2.length) {
|
|
case 1:
|
|
if (size2[0] === 1) {
|
|
if (isMatrix(x)) {
|
|
return matrix2([divideScalar2(1, x.valueOf()[0])]);
|
|
} else {
|
|
return [divideScalar2(1, x[0])];
|
|
}
|
|
} else {
|
|
throw new RangeError("Matrix must be square (size: " + format3(size2) + ")");
|
|
}
|
|
case 2: {
|
|
var rows = size2[0];
|
|
var cols = size2[1];
|
|
if (rows === cols) {
|
|
if (isMatrix(x)) {
|
|
return matrix2(_inv(x.valueOf(), rows, cols), x.storage());
|
|
} else {
|
|
return _inv(x, rows, cols);
|
|
}
|
|
} else {
|
|
throw new RangeError("Matrix must be square (size: " + format3(size2) + ")");
|
|
}
|
|
}
|
|
default:
|
|
throw new RangeError("Matrix must be two dimensional (size: " + format3(size2) + ")");
|
|
}
|
|
},
|
|
any: function any(x) {
|
|
return divideScalar2(1, x);
|
|
}
|
|
});
|
|
function _inv(mat, rows, cols) {
|
|
var r, s, f, value, temp;
|
|
if (rows === 1) {
|
|
value = mat[0][0];
|
|
if (value === 0) {
|
|
throw Error("Cannot calculate inverse, determinant is zero");
|
|
}
|
|
return [[divideScalar2(1, value)]];
|
|
} else if (rows === 2) {
|
|
var d = det2(mat);
|
|
if (d === 0) {
|
|
throw Error("Cannot calculate inverse, determinant is zero");
|
|
}
|
|
return [[divideScalar2(mat[1][1], d), divideScalar2(unaryMinus2(mat[0][1]), d)], [divideScalar2(unaryMinus2(mat[1][0]), d), divideScalar2(mat[0][0], d)]];
|
|
} else {
|
|
var A = mat.concat();
|
|
for (r = 0; r < rows; r++) {
|
|
A[r] = A[r].concat();
|
|
}
|
|
var B = identity2(rows).valueOf();
|
|
for (var c = 0; c < cols; c++) {
|
|
var ABig = abs3(A[c][c]);
|
|
var rBig = c;
|
|
r = c + 1;
|
|
while (r < rows) {
|
|
if (abs3(A[r][c]) > ABig) {
|
|
ABig = abs3(A[r][c]);
|
|
rBig = r;
|
|
}
|
|
r++;
|
|
}
|
|
if (ABig === 0) {
|
|
throw Error("Cannot calculate inverse, determinant is zero");
|
|
}
|
|
r = rBig;
|
|
if (r !== c) {
|
|
temp = A[c];
|
|
A[c] = A[r];
|
|
A[r] = temp;
|
|
temp = B[c];
|
|
B[c] = B[r];
|
|
B[r] = temp;
|
|
}
|
|
var Ac = A[c];
|
|
var Bc = B[c];
|
|
for (r = 0; r < rows; r++) {
|
|
var Ar = A[r];
|
|
var Br = B[r];
|
|
if (r !== c) {
|
|
if (Ar[c] !== 0) {
|
|
f = divideScalar2(unaryMinus2(Ar[c]), Ac[c]);
|
|
for (s = c; s < cols; s++) {
|
|
Ar[s] = addScalar2(Ar[s], multiply2(f, Ac[s]));
|
|
}
|
|
for (s = 0; s < cols; s++) {
|
|
Br[s] = addScalar2(Br[s], multiply2(f, Bc[s]));
|
|
}
|
|
}
|
|
} else {
|
|
f = Ac[c];
|
|
for (s = c; s < cols; s++) {
|
|
Ar[s] = divideScalar2(Ar[s], f);
|
|
}
|
|
for (s = 0; s < cols; s++) {
|
|
Br[s] = divideScalar2(Br[s], f);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return B;
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/pinv.js
|
|
var name240 = "pinv";
|
|
var dependencies240 = ["typed", "matrix", "inv", "deepEqual", "equal", "dotDivide", "dot", "ctranspose", "divideScalar", "multiply", "add", "Complex"];
|
|
var createPinv = /* @__PURE__ */ factory(name240, dependencies240, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
inv: inv2,
|
|
deepEqual: deepEqual2,
|
|
equal: equal2,
|
|
dotDivide: dotDivide2,
|
|
dot: dot2,
|
|
ctranspose: ctranspose2,
|
|
divideScalar: divideScalar2,
|
|
multiply: multiply2,
|
|
add: add3,
|
|
Complex: Complex3
|
|
} = _ref;
|
|
return typed2(name240, {
|
|
"Array | Matrix": function ArrayMatrix(x) {
|
|
var size2 = isMatrix(x) ? x.size() : arraySize(x);
|
|
switch (size2.length) {
|
|
case 1:
|
|
if (_isZeros(x))
|
|
return ctranspose2(x);
|
|
if (size2[0] === 1) {
|
|
return inv2(x);
|
|
} else {
|
|
return dotDivide2(ctranspose2(x), dot2(x, x));
|
|
}
|
|
case 2: {
|
|
if (_isZeros(x))
|
|
return ctranspose2(x);
|
|
var rows = size2[0];
|
|
var cols = size2[1];
|
|
if (rows === cols) {
|
|
try {
|
|
return inv2(x);
|
|
} catch (err) {
|
|
if (err instanceof Error && err.message.match(/Cannot calculate inverse, determinant is zero/)) {
|
|
} else {
|
|
throw err;
|
|
}
|
|
}
|
|
}
|
|
if (isMatrix(x)) {
|
|
return matrix2(_pinv(x.valueOf(), rows, cols), x.storage());
|
|
} else {
|
|
return _pinv(x, rows, cols);
|
|
}
|
|
}
|
|
default:
|
|
throw new RangeError("Matrix must be two dimensional (size: " + format3(size2) + ")");
|
|
}
|
|
},
|
|
any: function any(x) {
|
|
if (equal2(x, 0))
|
|
return clone(x);
|
|
return divideScalar2(1, x);
|
|
}
|
|
});
|
|
function _pinv(mat, rows, cols) {
|
|
var {
|
|
C,
|
|
F
|
|
} = _rankFact(mat, rows, cols);
|
|
var Cpinv = multiply2(inv2(multiply2(ctranspose2(C), C)), ctranspose2(C));
|
|
var Fpinv = multiply2(ctranspose2(F), inv2(multiply2(F, ctranspose2(F))));
|
|
return multiply2(Fpinv, Cpinv);
|
|
}
|
|
function _rref(mat, rows, cols) {
|
|
var M = clone(mat);
|
|
var lead = 0;
|
|
for (var r = 0; r < rows; r++) {
|
|
if (cols <= lead) {
|
|
return M;
|
|
}
|
|
var i2 = r;
|
|
while (_isZero(M[i2][lead])) {
|
|
i2++;
|
|
if (rows === i2) {
|
|
i2 = r;
|
|
lead++;
|
|
if (cols === lead) {
|
|
return M;
|
|
}
|
|
}
|
|
}
|
|
[M[i2], M[r]] = [M[r], M[i2]];
|
|
var val = M[r][lead];
|
|
for (var j = 0; j < cols; j++) {
|
|
M[r][j] = dotDivide2(M[r][j], val);
|
|
}
|
|
for (var _i = 0; _i < rows; _i++) {
|
|
if (_i === r)
|
|
continue;
|
|
val = M[_i][lead];
|
|
for (var _j = 0; _j < cols; _j++) {
|
|
M[_i][_j] = add3(M[_i][_j], multiply2(-1, multiply2(val, M[r][_j])));
|
|
}
|
|
}
|
|
lead++;
|
|
}
|
|
return M;
|
|
}
|
|
function _rankFact(mat, rows, cols) {
|
|
var rref = _rref(mat, rows, cols);
|
|
var C = mat.map((_, i2) => _.filter((_2, j) => j < rows && !_isZero(dot2(rref[j], rref[j]))));
|
|
var F = rref.filter((_, i2) => !_isZero(dot2(rref[i2], rref[i2])));
|
|
return {
|
|
C,
|
|
F
|
|
};
|
|
}
|
|
function _isZero(x) {
|
|
return equal2(add3(x, Complex3(1, 1)), add3(0, Complex3(1, 1)));
|
|
}
|
|
function _isZeros(arr) {
|
|
return deepEqual2(add3(arr, Complex3(1, 1)), add3(multiply2(arr, 0), Complex3(1, 1)));
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/eigs/complexEigs.js
|
|
function createComplexEigs(_ref) {
|
|
var {
|
|
addScalar: addScalar2,
|
|
subtract: subtract2,
|
|
flatten: flatten3,
|
|
multiply: multiply2,
|
|
multiplyScalar: multiplyScalar2,
|
|
divideScalar: divideScalar2,
|
|
sqrt: sqrt3,
|
|
abs: abs3,
|
|
bignumber: bignumber2,
|
|
diag: diag2,
|
|
inv: inv2,
|
|
qr: qr2,
|
|
usolve: usolve2,
|
|
usolveAll: usolveAll2,
|
|
equal: equal2,
|
|
complex: complex2,
|
|
larger: larger2,
|
|
smaller: smaller2,
|
|
matrixFromColumns: matrixFromColumns2,
|
|
dot: dot2
|
|
} = _ref;
|
|
function complexEigs(arr, N, prec, type, findVectors) {
|
|
if (findVectors === void 0) {
|
|
findVectors = true;
|
|
}
|
|
var R = balance(arr, N, prec, type, findVectors);
|
|
reduceToHessenberg(arr, N, prec, type, findVectors, R);
|
|
var {
|
|
values,
|
|
C
|
|
} = iterateUntilTriangular(arr, N, prec, type, findVectors);
|
|
var vectors;
|
|
if (findVectors) {
|
|
vectors = findEigenvectors(arr, N, C, R, values, prec, type);
|
|
vectors = matrixFromColumns2(...vectors);
|
|
}
|
|
return {
|
|
values,
|
|
vectors
|
|
};
|
|
}
|
|
function balance(arr, N, prec, type, findVectors) {
|
|
var big = type === "BigNumber";
|
|
var cplx = type === "Complex";
|
|
var realzero = big ? bignumber2(0) : 0;
|
|
var one = big ? bignumber2(1) : cplx ? complex2(1) : 1;
|
|
var realone = big ? bignumber2(1) : 1;
|
|
var radix = big ? bignumber2(10) : 2;
|
|
var radixSq = multiplyScalar2(radix, radix);
|
|
var Rdiag;
|
|
if (findVectors) {
|
|
Rdiag = Array(N).fill(one);
|
|
}
|
|
var last = false;
|
|
while (!last) {
|
|
last = true;
|
|
for (var i2 = 0; i2 < N; i2++) {
|
|
var colNorm = realzero;
|
|
var rowNorm = realzero;
|
|
for (var j = 0; j < N; j++) {
|
|
if (i2 === j)
|
|
continue;
|
|
var c = abs3(arr[i2][j]);
|
|
colNorm = addScalar2(colNorm, c);
|
|
rowNorm = addScalar2(rowNorm, c);
|
|
}
|
|
if (!equal2(colNorm, 0) && !equal2(rowNorm, 0)) {
|
|
var f = realone;
|
|
var _c = colNorm;
|
|
var rowDivRadix = divideScalar2(rowNorm, radix);
|
|
var rowMulRadix = multiplyScalar2(rowNorm, radix);
|
|
while (smaller2(_c, rowDivRadix)) {
|
|
_c = multiplyScalar2(_c, radixSq);
|
|
f = multiplyScalar2(f, radix);
|
|
}
|
|
while (larger2(_c, rowMulRadix)) {
|
|
_c = divideScalar2(_c, radixSq);
|
|
f = divideScalar2(f, radix);
|
|
}
|
|
var condition = smaller2(divideScalar2(addScalar2(_c, rowNorm), f), multiplyScalar2(addScalar2(colNorm, rowNorm), 0.95));
|
|
if (condition) {
|
|
last = false;
|
|
var g = divideScalar2(1, f);
|
|
for (var _j = 0; _j < N; _j++) {
|
|
if (i2 === _j) {
|
|
continue;
|
|
}
|
|
arr[i2][_j] = multiplyScalar2(arr[i2][_j], f);
|
|
arr[_j][i2] = multiplyScalar2(arr[_j][i2], g);
|
|
}
|
|
if (findVectors) {
|
|
Rdiag[i2] = multiplyScalar2(Rdiag[i2], f);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return diag2(Rdiag);
|
|
}
|
|
function reduceToHessenberg(arr, N, prec, type, findVectors, R) {
|
|
var big = type === "BigNumber";
|
|
var cplx = type === "Complex";
|
|
var zero = big ? bignumber2(0) : cplx ? complex2(0) : 0;
|
|
if (big) {
|
|
prec = bignumber2(prec);
|
|
}
|
|
for (var i2 = 0; i2 < N - 2; i2++) {
|
|
var maxIndex = 0;
|
|
var max3 = zero;
|
|
for (var j = i2 + 1; j < N; j++) {
|
|
var el = arr[j][i2];
|
|
if (smaller2(abs3(max3), abs3(el))) {
|
|
max3 = el;
|
|
maxIndex = j;
|
|
}
|
|
}
|
|
if (smaller2(abs3(max3), prec)) {
|
|
continue;
|
|
}
|
|
if (maxIndex !== i2 + 1) {
|
|
var tmp1 = arr[maxIndex];
|
|
arr[maxIndex] = arr[i2 + 1];
|
|
arr[i2 + 1] = tmp1;
|
|
for (var _j2 = 0; _j2 < N; _j2++) {
|
|
var tmp2 = arr[_j2][maxIndex];
|
|
arr[_j2][maxIndex] = arr[_j2][i2 + 1];
|
|
arr[_j2][i2 + 1] = tmp2;
|
|
}
|
|
if (findVectors) {
|
|
var tmp3 = R[maxIndex];
|
|
R[maxIndex] = R[i2 + 1];
|
|
R[i2 + 1] = tmp3;
|
|
}
|
|
}
|
|
for (var _j3 = i2 + 2; _j3 < N; _j3++) {
|
|
var n = divideScalar2(arr[_j3][i2], max3);
|
|
if (n === 0) {
|
|
continue;
|
|
}
|
|
for (var k = 0; k < N; k++) {
|
|
arr[_j3][k] = subtract2(arr[_j3][k], multiplyScalar2(n, arr[i2 + 1][k]));
|
|
}
|
|
for (var _k = 0; _k < N; _k++) {
|
|
arr[_k][i2 + 1] = addScalar2(arr[_k][i2 + 1], multiplyScalar2(n, arr[_k][_j3]));
|
|
}
|
|
if (findVectors) {
|
|
for (var _k2 = 0; _k2 < N; _k2++) {
|
|
R[_j3][_k2] = subtract2(R[_j3][_k2], multiplyScalar2(n, R[i2 + 1][_k2]));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return R;
|
|
}
|
|
function iterateUntilTriangular(A, N, prec, type, findVectors) {
|
|
var big = type === "BigNumber";
|
|
var cplx = type === "Complex";
|
|
var one = big ? bignumber2(1) : cplx ? complex2(1) : 1;
|
|
if (big) {
|
|
prec = bignumber2(prec);
|
|
}
|
|
var arr = clone(A);
|
|
var lambdas = [];
|
|
var n = N;
|
|
var Sdiag = [];
|
|
var Qtotal = findVectors ? diag2(Array(N).fill(one)) : void 0;
|
|
var Qpartial = findVectors ? diag2(Array(n).fill(one)) : void 0;
|
|
var lastConvergenceBefore = 0;
|
|
while (lastConvergenceBefore <= 100) {
|
|
lastConvergenceBefore += 1;
|
|
var k = 0;
|
|
for (var i2 = 0; i2 < n; i2++) {
|
|
arr[i2][i2] = subtract2(arr[i2][i2], k);
|
|
}
|
|
var {
|
|
Q: Q2,
|
|
R
|
|
} = qr2(arr);
|
|
arr = multiply2(R, Q2);
|
|
for (var _i = 0; _i < n; _i++) {
|
|
arr[_i][_i] = addScalar2(arr[_i][_i], k);
|
|
}
|
|
if (findVectors) {
|
|
Qpartial = multiply2(Qpartial, Q2);
|
|
}
|
|
if (n === 1 || smaller2(abs3(arr[n - 1][n - 2]), prec)) {
|
|
lastConvergenceBefore = 0;
|
|
lambdas.push(arr[n - 1][n - 1]);
|
|
if (findVectors) {
|
|
Sdiag.unshift([[1]]);
|
|
inflateMatrix(Qpartial, N);
|
|
Qtotal = multiply2(Qtotal, Qpartial);
|
|
if (n > 1) {
|
|
Qpartial = diag2(Array(n - 1).fill(one));
|
|
}
|
|
}
|
|
n -= 1;
|
|
arr.pop();
|
|
for (var _i2 = 0; _i2 < n; _i2++) {
|
|
arr[_i2].pop();
|
|
}
|
|
} else if (n === 2 || smaller2(abs3(arr[n - 2][n - 3]), prec)) {
|
|
lastConvergenceBefore = 0;
|
|
var ll = eigenvalues2x2(arr[n - 2][n - 2], arr[n - 2][n - 1], arr[n - 1][n - 2], arr[n - 1][n - 1]);
|
|
lambdas.push(...ll);
|
|
if (findVectors) {
|
|
Sdiag.unshift(jordanBase2x2(arr[n - 2][n - 2], arr[n - 2][n - 1], arr[n - 1][n - 2], arr[n - 1][n - 1], ll[0], ll[1], prec, type));
|
|
inflateMatrix(Qpartial, N);
|
|
Qtotal = multiply2(Qtotal, Qpartial);
|
|
if (n > 2) {
|
|
Qpartial = diag2(Array(n - 2).fill(one));
|
|
}
|
|
}
|
|
n -= 2;
|
|
arr.pop();
|
|
arr.pop();
|
|
for (var _i3 = 0; _i3 < n; _i3++) {
|
|
arr[_i3].pop();
|
|
arr[_i3].pop();
|
|
}
|
|
}
|
|
if (n === 0) {
|
|
break;
|
|
}
|
|
}
|
|
lambdas.sort((a, b) => +subtract2(abs3(a), abs3(b)));
|
|
if (lastConvergenceBefore > 100) {
|
|
var err = Error("The eigenvalues failed to converge. Only found these eigenvalues: " + lambdas.join(", "));
|
|
err.values = lambdas;
|
|
err.vectors = [];
|
|
throw err;
|
|
}
|
|
var C = findVectors ? multiply2(Qtotal, blockDiag(Sdiag, N)) : void 0;
|
|
return {
|
|
values: lambdas,
|
|
C
|
|
};
|
|
}
|
|
function findEigenvectors(A, N, C, R, values, prec, type) {
|
|
var Cinv = inv2(C);
|
|
var U = multiply2(Cinv, A, C);
|
|
var big = type === "BigNumber";
|
|
var cplx = type === "Complex";
|
|
var zero = big ? bignumber2(0) : cplx ? complex2(0) : 0;
|
|
var one = big ? bignumber2(1) : cplx ? complex2(1) : 1;
|
|
var uniqueValues = [];
|
|
var multiplicities = [];
|
|
for (var \u03BB of values) {
|
|
var i2 = indexOf(uniqueValues, \u03BB, equal2);
|
|
if (i2 === -1) {
|
|
uniqueValues.push(\u03BB);
|
|
multiplicities.push(1);
|
|
} else {
|
|
multiplicities[i2] += 1;
|
|
}
|
|
}
|
|
var vectors = [];
|
|
var len = uniqueValues.length;
|
|
var b = Array(N).fill(zero);
|
|
var E = diag2(Array(N).fill(one));
|
|
var failedLambdas = [];
|
|
var _loop = function _loop2(_i42) {
|
|
var \u03BB2 = uniqueValues[_i42];
|
|
var S = subtract2(U, multiply2(\u03BB2, E));
|
|
var solutions = usolveAll2(S, b);
|
|
solutions.shift();
|
|
while (solutions.length < multiplicities[_i42]) {
|
|
var approxVec = inverseIterate(S, N, solutions, prec, type);
|
|
if (approxVec == null) {
|
|
failedLambdas.push(\u03BB2);
|
|
break;
|
|
}
|
|
solutions.push(approxVec);
|
|
}
|
|
var correction = multiply2(inv2(R), C);
|
|
solutions = solutions.map((v) => multiply2(correction, v));
|
|
vectors.push(...solutions.map((v) => flatten3(v)));
|
|
};
|
|
for (var _i4 = 0; _i4 < len; _i4++) {
|
|
_loop(_i4);
|
|
}
|
|
if (failedLambdas.length !== 0) {
|
|
var err = new Error("Failed to find eigenvectors for the following eigenvalues: " + failedLambdas.join(", "));
|
|
err.values = values;
|
|
err.vectors = vectors;
|
|
throw err;
|
|
}
|
|
return vectors;
|
|
}
|
|
function eigenvalues2x2(a, b, c, d) {
|
|
var trA = addScalar2(a, d);
|
|
var detA = subtract2(multiplyScalar2(a, d), multiplyScalar2(b, c));
|
|
var x = multiplyScalar2(trA, 0.5);
|
|
var y = multiplyScalar2(sqrt3(subtract2(multiplyScalar2(trA, trA), multiplyScalar2(4, detA))), 0.5);
|
|
return [addScalar2(x, y), subtract2(x, y)];
|
|
}
|
|
function jordanBase2x2(a, b, c, d, l1, l2, prec, type) {
|
|
var big = type === "BigNumber";
|
|
var cplx = type === "Complex";
|
|
var zero = big ? bignumber2(0) : cplx ? complex2(0) : 0;
|
|
var one = big ? bignumber2(1) : cplx ? complex2(1) : 1;
|
|
if (smaller2(abs3(c), prec)) {
|
|
return [[one, zero], [zero, one]];
|
|
}
|
|
if (larger2(abs3(subtract2(l1, l2)), prec)) {
|
|
return [[subtract2(l1, d), subtract2(l2, d)], [c, c]];
|
|
}
|
|
var na = subtract2(a, l1);
|
|
var nb = subtract2(b, l1);
|
|
var nc = subtract2(c, l1);
|
|
var nd = subtract2(d, l1);
|
|
if (smaller2(abs3(nb), prec)) {
|
|
return [[na, one], [nc, zero]];
|
|
} else {
|
|
return [[nb, zero], [nd, one]];
|
|
}
|
|
}
|
|
function inflateMatrix(arr, N) {
|
|
for (var i2 = 0; i2 < arr.length; i2++) {
|
|
arr[i2].push(...Array(N - arr[i2].length).fill(0));
|
|
}
|
|
for (var _i5 = arr.length; _i5 < N; _i5++) {
|
|
arr.push(Array(N).fill(0));
|
|
arr[_i5][_i5] = 1;
|
|
}
|
|
return arr;
|
|
}
|
|
function blockDiag(arr, N) {
|
|
var M = [];
|
|
for (var i2 = 0; i2 < N; i2++) {
|
|
M[i2] = Array(N).fill(0);
|
|
}
|
|
var I = 0;
|
|
for (var sub2 of arr) {
|
|
var n = sub2.length;
|
|
for (var _i6 = 0; _i6 < n; _i6++) {
|
|
for (var j = 0; j < n; j++) {
|
|
M[I + _i6][I + j] = sub2[_i6][j];
|
|
}
|
|
}
|
|
I += n;
|
|
}
|
|
return M;
|
|
}
|
|
function indexOf(arr, el, fn) {
|
|
for (var i2 = 0; i2 < arr.length; i2++) {
|
|
if (fn(arr[i2], el)) {
|
|
return i2;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
function inverseIterate(A, N, orthog, prec, type) {
|
|
var largeNum = type === "BigNumber" ? bignumber2(1e3) : 1e3;
|
|
var b;
|
|
var i2 = 0;
|
|
while (true) {
|
|
b = randomOrthogonalVector(N, orthog, type);
|
|
b = usolve2(A, b);
|
|
if (larger2(norm2(b), largeNum)) {
|
|
break;
|
|
}
|
|
if (++i2 >= 5) {
|
|
return null;
|
|
}
|
|
}
|
|
i2 = 0;
|
|
while (true) {
|
|
var c = usolve2(A, b);
|
|
if (smaller2(norm2(orthogonalComplement(b, [c])), prec)) {
|
|
break;
|
|
}
|
|
if (++i2 >= 10) {
|
|
return null;
|
|
}
|
|
b = normalize(c);
|
|
}
|
|
return b;
|
|
}
|
|
function randomOrthogonalVector(N, orthog, type) {
|
|
var big = type === "BigNumber";
|
|
var cplx = type === "Complex";
|
|
var v = Array(N).fill(0).map((_) => 2 * Math.random() - 1);
|
|
if (big) {
|
|
v = v.map((n) => bignumber2(n));
|
|
}
|
|
if (cplx) {
|
|
v = v.map((n) => complex2(n));
|
|
}
|
|
v = orthogonalComplement(v, orthog);
|
|
return normalize(v, type);
|
|
}
|
|
function orthogonalComplement(v, orthog) {
|
|
for (var w of orthog) {
|
|
v = subtract2(v, multiply2(divideScalar2(dot2(w, v), dot2(w, w)), w));
|
|
}
|
|
return v;
|
|
}
|
|
function norm2(v) {
|
|
return abs3(sqrt3(dot2(v, v)));
|
|
}
|
|
function normalize(v, type) {
|
|
var big = type === "BigNumber";
|
|
var cplx = type === "Complex";
|
|
var one = big ? bignumber2(1) : cplx ? complex2(1) : 1;
|
|
return multiply2(divideScalar2(one, norm2(v)), v);
|
|
}
|
|
return complexEigs;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/eigs/realSymetric.js
|
|
function createRealSymmetric(_ref) {
|
|
var {
|
|
config: config4,
|
|
addScalar: addScalar2,
|
|
subtract: subtract2,
|
|
abs: abs3,
|
|
atan: atan4,
|
|
cos: cos3,
|
|
sin: sin3,
|
|
multiplyScalar: multiplyScalar2,
|
|
inv: inv2,
|
|
bignumber: bignumber2,
|
|
multiply: multiply2,
|
|
add: add3
|
|
} = _ref;
|
|
function main(arr, N) {
|
|
var prec = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : config4.epsilon;
|
|
var type = arguments.length > 3 ? arguments[3] : void 0;
|
|
if (type === "number") {
|
|
return diag2(arr, prec);
|
|
}
|
|
if (type === "BigNumber") {
|
|
return diagBig(arr, prec);
|
|
}
|
|
throw TypeError("Unsupported data type: " + type);
|
|
}
|
|
function diag2(x, precision) {
|
|
var N = x.length;
|
|
var e0 = Math.abs(precision / N);
|
|
var psi;
|
|
var Sij = new Array(N);
|
|
for (var i2 = 0; i2 < N; i2++) {
|
|
Sij[i2] = createArray(N, 0);
|
|
Sij[i2][i2] = 1;
|
|
}
|
|
var Vab = getAij(x);
|
|
while (Math.abs(Vab[1]) >= Math.abs(e0)) {
|
|
var _i = Vab[0][0];
|
|
var j = Vab[0][1];
|
|
psi = getTheta(x[_i][_i], x[j][j], x[_i][j]);
|
|
x = x1(x, psi, _i, j);
|
|
Sij = Sij1(Sij, psi, _i, j);
|
|
Vab = getAij(x);
|
|
}
|
|
var Ei = createArray(N, 0);
|
|
for (var _i2 = 0; _i2 < N; _i2++) {
|
|
Ei[_i2] = x[_i2][_i2];
|
|
}
|
|
return sorting(clone(Ei), clone(Sij));
|
|
}
|
|
function diagBig(x, precision) {
|
|
var N = x.length;
|
|
var e0 = abs3(precision / N);
|
|
var psi;
|
|
var Sij = new Array(N);
|
|
for (var i2 = 0; i2 < N; i2++) {
|
|
Sij[i2] = createArray(N, 0);
|
|
Sij[i2][i2] = 1;
|
|
}
|
|
var Vab = getAijBig(x);
|
|
while (abs3(Vab[1]) >= abs3(e0)) {
|
|
var _i3 = Vab[0][0];
|
|
var j = Vab[0][1];
|
|
psi = getThetaBig(x[_i3][_i3], x[j][j], x[_i3][j]);
|
|
x = x1Big(x, psi, _i3, j);
|
|
Sij = Sij1Big(Sij, psi, _i3, j);
|
|
Vab = getAijBig(x);
|
|
}
|
|
var Ei = createArray(N, 0);
|
|
for (var _i4 = 0; _i4 < N; _i4++) {
|
|
Ei[_i4] = x[_i4][_i4];
|
|
}
|
|
return sorting(clone(Ei), clone(Sij));
|
|
}
|
|
function getTheta(aii, ajj, aij) {
|
|
var denom = ajj - aii;
|
|
if (Math.abs(denom) <= config4.epsilon) {
|
|
return Math.PI / 4;
|
|
} else {
|
|
return 0.5 * Math.atan(2 * aij / (ajj - aii));
|
|
}
|
|
}
|
|
function getThetaBig(aii, ajj, aij) {
|
|
var denom = subtract2(ajj, aii);
|
|
if (abs3(denom) <= config4.epsilon) {
|
|
return bignumber2(-1).acos().div(4);
|
|
} else {
|
|
return multiplyScalar2(0.5, atan4(multiply2(2, aij, inv2(denom))));
|
|
}
|
|
}
|
|
function Sij1(Sij, theta, i2, j) {
|
|
var N = Sij.length;
|
|
var c = Math.cos(theta);
|
|
var s = Math.sin(theta);
|
|
var Ski = createArray(N, 0);
|
|
var Skj = createArray(N, 0);
|
|
for (var k = 0; k < N; k++) {
|
|
Ski[k] = c * Sij[k][i2] - s * Sij[k][j];
|
|
Skj[k] = s * Sij[k][i2] + c * Sij[k][j];
|
|
}
|
|
for (var _k = 0; _k < N; _k++) {
|
|
Sij[_k][i2] = Ski[_k];
|
|
Sij[_k][j] = Skj[_k];
|
|
}
|
|
return Sij;
|
|
}
|
|
function Sij1Big(Sij, theta, i2, j) {
|
|
var N = Sij.length;
|
|
var c = cos3(theta);
|
|
var s = sin3(theta);
|
|
var Ski = createArray(N, bignumber2(0));
|
|
var Skj = createArray(N, bignumber2(0));
|
|
for (var k = 0; k < N; k++) {
|
|
Ski[k] = subtract2(multiplyScalar2(c, Sij[k][i2]), multiplyScalar2(s, Sij[k][j]));
|
|
Skj[k] = addScalar2(multiplyScalar2(s, Sij[k][i2]), multiplyScalar2(c, Sij[k][j]));
|
|
}
|
|
for (var _k2 = 0; _k2 < N; _k2++) {
|
|
Sij[_k2][i2] = Ski[_k2];
|
|
Sij[_k2][j] = Skj[_k2];
|
|
}
|
|
return Sij;
|
|
}
|
|
function x1Big(Hij, theta, i2, j) {
|
|
var N = Hij.length;
|
|
var c = bignumber2(cos3(theta));
|
|
var s = bignumber2(sin3(theta));
|
|
var c2 = multiplyScalar2(c, c);
|
|
var s2 = multiplyScalar2(s, s);
|
|
var Aki = createArray(N, bignumber2(0));
|
|
var Akj = createArray(N, bignumber2(0));
|
|
var csHij = multiply2(bignumber2(2), c, s, Hij[i2][j]);
|
|
var Aii = addScalar2(subtract2(multiplyScalar2(c2, Hij[i2][i2]), csHij), multiplyScalar2(s2, Hij[j][j]));
|
|
var Ajj = add3(multiplyScalar2(s2, Hij[i2][i2]), csHij, multiplyScalar2(c2, Hij[j][j]));
|
|
for (var k = 0; k < N; k++) {
|
|
Aki[k] = subtract2(multiplyScalar2(c, Hij[i2][k]), multiplyScalar2(s, Hij[j][k]));
|
|
Akj[k] = addScalar2(multiplyScalar2(s, Hij[i2][k]), multiplyScalar2(c, Hij[j][k]));
|
|
}
|
|
Hij[i2][i2] = Aii;
|
|
Hij[j][j] = Ajj;
|
|
Hij[i2][j] = bignumber2(0);
|
|
Hij[j][i2] = bignumber2(0);
|
|
for (var _k3 = 0; _k3 < N; _k3++) {
|
|
if (_k3 !== i2 && _k3 !== j) {
|
|
Hij[i2][_k3] = Aki[_k3];
|
|
Hij[_k3][i2] = Aki[_k3];
|
|
Hij[j][_k3] = Akj[_k3];
|
|
Hij[_k3][j] = Akj[_k3];
|
|
}
|
|
}
|
|
return Hij;
|
|
}
|
|
function x1(Hij, theta, i2, j) {
|
|
var N = Hij.length;
|
|
var c = Math.cos(theta);
|
|
var s = Math.sin(theta);
|
|
var c2 = c * c;
|
|
var s2 = s * s;
|
|
var Aki = createArray(N, 0);
|
|
var Akj = createArray(N, 0);
|
|
var Aii = c2 * Hij[i2][i2] - 2 * c * s * Hij[i2][j] + s2 * Hij[j][j];
|
|
var Ajj = s2 * Hij[i2][i2] + 2 * c * s * Hij[i2][j] + c2 * Hij[j][j];
|
|
for (var k = 0; k < N; k++) {
|
|
Aki[k] = c * Hij[i2][k] - s * Hij[j][k];
|
|
Akj[k] = s * Hij[i2][k] + c * Hij[j][k];
|
|
}
|
|
Hij[i2][i2] = Aii;
|
|
Hij[j][j] = Ajj;
|
|
Hij[i2][j] = 0;
|
|
Hij[j][i2] = 0;
|
|
for (var _k4 = 0; _k4 < N; _k4++) {
|
|
if (_k4 !== i2 && _k4 !== j) {
|
|
Hij[i2][_k4] = Aki[_k4];
|
|
Hij[_k4][i2] = Aki[_k4];
|
|
Hij[j][_k4] = Akj[_k4];
|
|
Hij[_k4][j] = Akj[_k4];
|
|
}
|
|
}
|
|
return Hij;
|
|
}
|
|
function getAij(Mij) {
|
|
var N = Mij.length;
|
|
var maxMij = 0;
|
|
var maxIJ = [0, 1];
|
|
for (var i2 = 0; i2 < N; i2++) {
|
|
for (var j = i2 + 1; j < N; j++) {
|
|
if (Math.abs(maxMij) < Math.abs(Mij[i2][j])) {
|
|
maxMij = Math.abs(Mij[i2][j]);
|
|
maxIJ = [i2, j];
|
|
}
|
|
}
|
|
}
|
|
return [maxIJ, maxMij];
|
|
}
|
|
function getAijBig(Mij) {
|
|
var N = Mij.length;
|
|
var maxMij = 0;
|
|
var maxIJ = [0, 1];
|
|
for (var i2 = 0; i2 < N; i2++) {
|
|
for (var j = i2 + 1; j < N; j++) {
|
|
if (abs3(maxMij) < abs3(Mij[i2][j])) {
|
|
maxMij = abs3(Mij[i2][j]);
|
|
maxIJ = [i2, j];
|
|
}
|
|
}
|
|
}
|
|
return [maxIJ, maxMij];
|
|
}
|
|
function sorting(E, S) {
|
|
var N = E.length;
|
|
var values = Array(N);
|
|
var vectors = Array(N);
|
|
for (var k = 0; k < N; k++) {
|
|
vectors[k] = Array(N);
|
|
}
|
|
for (var i2 = 0; i2 < N; i2++) {
|
|
var minID = 0;
|
|
var minE = E[0];
|
|
for (var j = 0; j < E.length; j++) {
|
|
if (abs3(E[j]) < abs3(minE)) {
|
|
minID = j;
|
|
minE = E[minID];
|
|
}
|
|
}
|
|
values[i2] = E.splice(minID, 1)[0];
|
|
for (var _k5 = 0; _k5 < N; _k5++) {
|
|
vectors[_k5][i2] = S[_k5][minID];
|
|
S[_k5].splice(minID, 1);
|
|
}
|
|
}
|
|
return {
|
|
values,
|
|
vectors
|
|
};
|
|
}
|
|
function createArray(size2, value) {
|
|
var array = new Array(size2);
|
|
for (var i2 = 0; i2 < size2; i2++) {
|
|
array[i2] = value;
|
|
}
|
|
return array;
|
|
}
|
|
return main;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/eigs.js
|
|
var name241 = "eigs";
|
|
var dependencies241 = ["config", "typed", "matrix", "addScalar", "equal", "subtract", "abs", "atan", "cos", "sin", "multiplyScalar", "divideScalar", "inv", "bignumber", "multiply", "add", "larger", "column", "flatten", "number", "complex", "sqrt", "diag", "qr", "usolve", "usolveAll", "im", "re", "smaller", "matrixFromColumns", "dot"];
|
|
var createEigs = /* @__PURE__ */ factory(name241, dependencies241, (_ref) => {
|
|
var {
|
|
config: config4,
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
addScalar: addScalar2,
|
|
subtract: subtract2,
|
|
equal: equal2,
|
|
abs: abs3,
|
|
atan: atan4,
|
|
cos: cos3,
|
|
sin: sin3,
|
|
multiplyScalar: multiplyScalar2,
|
|
divideScalar: divideScalar2,
|
|
inv: inv2,
|
|
bignumber: bignumber2,
|
|
multiply: multiply2,
|
|
add: add3,
|
|
larger: larger2,
|
|
column: column2,
|
|
flatten: flatten3,
|
|
number: number2,
|
|
complex: complex2,
|
|
sqrt: sqrt3,
|
|
diag: diag2,
|
|
qr: qr2,
|
|
usolve: usolve2,
|
|
usolveAll: usolveAll2,
|
|
im: im2,
|
|
re: re2,
|
|
smaller: smaller2,
|
|
matrixFromColumns: matrixFromColumns2,
|
|
dot: dot2
|
|
} = _ref;
|
|
var doRealSymetric = createRealSymmetric({
|
|
config: config4,
|
|
addScalar: addScalar2,
|
|
subtract: subtract2,
|
|
column: column2,
|
|
flatten: flatten3,
|
|
equal: equal2,
|
|
abs: abs3,
|
|
atan: atan4,
|
|
cos: cos3,
|
|
sin: sin3,
|
|
multiplyScalar: multiplyScalar2,
|
|
inv: inv2,
|
|
bignumber: bignumber2,
|
|
complex: complex2,
|
|
multiply: multiply2,
|
|
add: add3
|
|
});
|
|
var doComplexEigs = createComplexEigs({
|
|
config: config4,
|
|
addScalar: addScalar2,
|
|
subtract: subtract2,
|
|
multiply: multiply2,
|
|
multiplyScalar: multiplyScalar2,
|
|
flatten: flatten3,
|
|
divideScalar: divideScalar2,
|
|
sqrt: sqrt3,
|
|
abs: abs3,
|
|
bignumber: bignumber2,
|
|
diag: diag2,
|
|
qr: qr2,
|
|
inv: inv2,
|
|
usolve: usolve2,
|
|
usolveAll: usolveAll2,
|
|
equal: equal2,
|
|
complex: complex2,
|
|
larger: larger2,
|
|
smaller: smaller2,
|
|
matrixFromColumns: matrixFromColumns2,
|
|
dot: dot2
|
|
});
|
|
return typed2("eigs", {
|
|
Array: function Array2(x) {
|
|
var mat = matrix2(x);
|
|
return computeValuesAndVectors(mat);
|
|
},
|
|
"Array, number|BigNumber": function ArrayNumberBigNumber(x, prec) {
|
|
var mat = matrix2(x);
|
|
return computeValuesAndVectors(mat, prec);
|
|
},
|
|
Matrix: function Matrix2(mat) {
|
|
var {
|
|
values,
|
|
vectors
|
|
} = computeValuesAndVectors(mat);
|
|
return {
|
|
values: matrix2(values),
|
|
vectors: matrix2(vectors)
|
|
};
|
|
},
|
|
"Matrix, number|BigNumber": function MatrixNumberBigNumber(mat, prec) {
|
|
var {
|
|
values,
|
|
vectors
|
|
} = computeValuesAndVectors(mat, prec);
|
|
return {
|
|
values: matrix2(values),
|
|
vectors: matrix2(vectors)
|
|
};
|
|
}
|
|
});
|
|
function computeValuesAndVectors(mat, prec) {
|
|
if (prec === void 0) {
|
|
prec = config4.epsilon;
|
|
}
|
|
var size2 = mat.size();
|
|
if (size2.length !== 2 || size2[0] !== size2[1]) {
|
|
throw new RangeError("Matrix must be square (size: " + format3(size2) + ")");
|
|
}
|
|
var arr = mat.toArray();
|
|
var N = size2[0];
|
|
if (isReal(arr, N, prec)) {
|
|
coerceReal(arr, N);
|
|
if (isSymmetric(arr, N, prec)) {
|
|
var _type = coerceTypes(mat, arr, N);
|
|
return doRealSymetric(arr, N, prec, _type);
|
|
}
|
|
}
|
|
var type = coerceTypes(mat, arr, N);
|
|
return doComplexEigs(arr, N, prec, type);
|
|
}
|
|
function isSymmetric(arr, N, prec) {
|
|
for (var i2 = 0; i2 < N; i2++) {
|
|
for (var j = i2; j < N; j++) {
|
|
if (larger2(bignumber2(abs3(subtract2(arr[i2][j], arr[j][i2]))), prec)) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function isReal(arr, N, prec) {
|
|
for (var i2 = 0; i2 < N; i2++) {
|
|
for (var j = 0; j < N; j++) {
|
|
if (larger2(bignumber2(abs3(im2(arr[i2][j]))), prec)) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function coerceReal(arr, N) {
|
|
for (var i2 = 0; i2 < N; i2++) {
|
|
for (var j = 0; j < N; j++) {
|
|
arr[i2][j] = re2(arr[i2][j]);
|
|
}
|
|
}
|
|
}
|
|
function coerceTypes(mat, arr, N) {
|
|
var type = mat.datatype();
|
|
if (type === "number" || type === "BigNumber" || type === "Complex") {
|
|
return type;
|
|
}
|
|
var hasNumber = false;
|
|
var hasBig = false;
|
|
var hasComplex = false;
|
|
for (var i2 = 0; i2 < N; i2++) {
|
|
for (var j = 0; j < N; j++) {
|
|
var el = arr[i2][j];
|
|
if (isNumber(el) || isFraction(el)) {
|
|
hasNumber = true;
|
|
} else if (isBigNumber(el)) {
|
|
hasBig = true;
|
|
} else if (isComplex(el)) {
|
|
hasComplex = true;
|
|
} else {
|
|
throw TypeError("Unsupported type in Matrix: " + typeOf(el));
|
|
}
|
|
}
|
|
}
|
|
if (hasBig && hasComplex) {
|
|
console.warn("Complex BigNumbers not supported, this operation will lose precission.");
|
|
}
|
|
if (hasComplex) {
|
|
for (var _i = 0; _i < N; _i++) {
|
|
for (var _j = 0; _j < N; _j++) {
|
|
arr[_i][_j] = complex2(arr[_i][_j]);
|
|
}
|
|
}
|
|
return "Complex";
|
|
}
|
|
if (hasBig) {
|
|
for (var _i2 = 0; _i2 < N; _i2++) {
|
|
for (var _j2 = 0; _j2 < N; _j2++) {
|
|
arr[_i2][_j2] = bignumber2(arr[_i2][_j2]);
|
|
}
|
|
}
|
|
return "BigNumber";
|
|
}
|
|
if (hasNumber) {
|
|
for (var _i3 = 0; _i3 < N; _i3++) {
|
|
for (var _j3 = 0; _j3 < N; _j3++) {
|
|
arr[_i3][_j3] = number2(arr[_i3][_j3]);
|
|
}
|
|
}
|
|
return "number";
|
|
} else {
|
|
throw TypeError("Matrix contains unsupported types only.");
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/expm.js
|
|
var name242 = "expm";
|
|
var dependencies242 = ["typed", "abs", "add", "identity", "inv", "multiply"];
|
|
var createExpm = /* @__PURE__ */ factory(name242, dependencies242, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
abs: abs3,
|
|
add: add3,
|
|
identity: identity2,
|
|
inv: inv2,
|
|
multiply: multiply2
|
|
} = _ref;
|
|
return typed2(name242, {
|
|
Matrix: function Matrix2(A) {
|
|
var size2 = A.size();
|
|
if (size2.length !== 2 || size2[0] !== size2[1]) {
|
|
throw new RangeError("Matrix must be square (size: " + format3(size2) + ")");
|
|
}
|
|
var n = size2[0];
|
|
var eps = 1e-15;
|
|
var infNorm = infinityNorm(A);
|
|
var params = findParams(infNorm, eps);
|
|
var q = params.q;
|
|
var j = params.j;
|
|
var Apos = multiply2(A, Math.pow(2, -j));
|
|
var N = identity2(n);
|
|
var D = identity2(n);
|
|
var factor = 1;
|
|
var AposToI = Apos;
|
|
var alternate = -1;
|
|
for (var i2 = 1; i2 <= q; i2++) {
|
|
if (i2 > 1) {
|
|
AposToI = multiply2(AposToI, Apos);
|
|
alternate = -alternate;
|
|
}
|
|
factor = factor * (q - i2 + 1) / ((2 * q - i2 + 1) * i2);
|
|
N = add3(N, multiply2(factor, AposToI));
|
|
D = add3(D, multiply2(factor * alternate, AposToI));
|
|
}
|
|
var R = multiply2(inv2(D), N);
|
|
for (var _i = 0; _i < j; _i++) {
|
|
R = multiply2(R, R);
|
|
}
|
|
return isSparseMatrix(A) ? A.createSparseMatrix(R) : R;
|
|
}
|
|
});
|
|
function infinityNorm(A) {
|
|
var n = A.size()[0];
|
|
var infNorm = 0;
|
|
for (var i2 = 0; i2 < n; i2++) {
|
|
var rowSum = 0;
|
|
for (var j = 0; j < n; j++) {
|
|
rowSum += abs3(A.get([i2, j]));
|
|
}
|
|
infNorm = Math.max(rowSum, infNorm);
|
|
}
|
|
return infNorm;
|
|
}
|
|
function findParams(infNorm, eps) {
|
|
var maxSearchSize = 30;
|
|
for (var k = 0; k < maxSearchSize; k++) {
|
|
for (var q = 0; q <= k; q++) {
|
|
var j = k - q;
|
|
if (errorEstimate(infNorm, q, j) < eps) {
|
|
return {
|
|
q,
|
|
j
|
|
};
|
|
}
|
|
}
|
|
}
|
|
throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)");
|
|
}
|
|
function errorEstimate(infNorm, q, j) {
|
|
var qfac = 1;
|
|
for (var i2 = 2; i2 <= q; i2++) {
|
|
qfac *= i2;
|
|
}
|
|
var twoqfac = qfac;
|
|
for (var _i2 = q + 1; _i2 <= 2 * q; _i2++) {
|
|
twoqfac *= _i2;
|
|
}
|
|
var twoqp1fac = twoqfac * (2 * q + 1);
|
|
return 8 * Math.pow(infNorm / Math.pow(2, j), 2 * q) * qfac * qfac / (twoqfac * twoqp1fac);
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/matrix/sqrtm.js
|
|
var name243 = "sqrtm";
|
|
var dependencies243 = ["typed", "abs", "add", "multiply", "map", "sqrt", "subtract", "inv", "size", "max", "identity"];
|
|
var createSqrtm = /* @__PURE__ */ factory(name243, dependencies243, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
abs: abs3,
|
|
add: add3,
|
|
multiply: multiply2,
|
|
map: map3,
|
|
sqrt: sqrt3,
|
|
subtract: subtract2,
|
|
inv: inv2,
|
|
size: size2,
|
|
max: max3,
|
|
identity: identity2
|
|
} = _ref;
|
|
var _maxIterations = 1e3;
|
|
var _tolerance = 1e-6;
|
|
function _denmanBeavers(A) {
|
|
var error;
|
|
var iterations = 0;
|
|
var Y = A;
|
|
var Z = identity2(size2(A));
|
|
do {
|
|
var Yk = Y;
|
|
Y = multiply2(0.5, add3(Yk, inv2(Z)));
|
|
Z = multiply2(0.5, add3(Z, inv2(Yk)));
|
|
error = max3(abs3(subtract2(Y, Yk)));
|
|
if (error > _tolerance && ++iterations > _maxIterations) {
|
|
throw new Error("computing square root of matrix: iterative method could not converge");
|
|
}
|
|
} while (error > _tolerance);
|
|
return Y;
|
|
}
|
|
return typed2(name243, {
|
|
"Array | Matrix": function ArrayMatrix(A) {
|
|
var size3 = isMatrix(A) ? A.size() : arraySize(A);
|
|
switch (size3.length) {
|
|
case 1:
|
|
if (size3[0] === 1) {
|
|
return map3(A, sqrt3);
|
|
} else {
|
|
throw new RangeError("Matrix must be square (size: " + format3(size3) + ")");
|
|
}
|
|
case 2: {
|
|
var rows = size3[0];
|
|
var cols = size3[1];
|
|
if (rows === cols) {
|
|
return _denmanBeavers(A);
|
|
} else {
|
|
throw new RangeError("Matrix must be square (size: " + format3(size3) + ")");
|
|
}
|
|
}
|
|
default:
|
|
throw new RangeError("Matrix must be at most two dimensional (size: " + format3(size3) + ")");
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/sylvester.js
|
|
var name244 = "sylvester";
|
|
var dependencies244 = ["typed", "schur", "matrixFromColumns", "matrix", "multiply", "range", "concat", "transpose", "index", "subset", "add", "subtract", "identity", "lusolve", "abs"];
|
|
var createSylvester = /* @__PURE__ */ factory(name244, dependencies244, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
schur: schur2,
|
|
matrixFromColumns: matrixFromColumns2,
|
|
matrix: matrix2,
|
|
multiply: multiply2,
|
|
range: range2,
|
|
concat: concat2,
|
|
transpose: transpose2,
|
|
index: index2,
|
|
subset: subset2,
|
|
add: add3,
|
|
subtract: subtract2,
|
|
identity: identity2,
|
|
lusolve: lusolve2,
|
|
abs: abs3
|
|
} = _ref;
|
|
return typed2(name244, {
|
|
"Matrix, Matrix, Matrix": _sylvester,
|
|
"Array, Matrix, Matrix": function ArrayMatrixMatrix(A, B, C) {
|
|
return _sylvester(matrix2(A), B, C);
|
|
},
|
|
"Array, Array, Matrix": function ArrayArrayMatrix(A, B, C) {
|
|
return _sylvester(matrix2(A), matrix2(B), C);
|
|
},
|
|
"Array, Matrix, Array": function ArrayMatrixArray(A, B, C) {
|
|
return _sylvester(matrix2(A), B, matrix2(C));
|
|
},
|
|
"Matrix, Array, Matrix": function MatrixArrayMatrix(A, B, C) {
|
|
return _sylvester(A, matrix2(B), C);
|
|
},
|
|
"Matrix, Array, Array": function MatrixArrayArray(A, B, C) {
|
|
return _sylvester(A, matrix2(B), matrix2(C));
|
|
},
|
|
"Matrix, Matrix, Array": function MatrixMatrixArray(A, B, C) {
|
|
return _sylvester(A, B, matrix2(C));
|
|
},
|
|
"Array, Array, Array": function ArrayArrayArray(A, B, C) {
|
|
return _sylvester(matrix2(A), matrix2(B), matrix2(C)).toArray();
|
|
}
|
|
});
|
|
function _sylvester(A, B, C) {
|
|
var n = B.size()[0];
|
|
var m = A.size()[0];
|
|
var sA = schur2(A);
|
|
var F = sA.T;
|
|
var U = sA.U;
|
|
var sB = schur2(multiply2(-1, B));
|
|
var G = sB.T;
|
|
var V = sB.U;
|
|
var D = multiply2(multiply2(transpose2(U), C), V);
|
|
var all = range2(0, m);
|
|
var y = [];
|
|
var hc = (a, b) => concat2(a, b, 1);
|
|
var vc = (a, b) => concat2(a, b, 0);
|
|
for (var k = 0; k < n; k++) {
|
|
if (k < n - 1 && abs3(subset2(G, index2(k + 1, k))) > 1e-5) {
|
|
var RHS = vc(subset2(D, index2(all, k)), subset2(D, index2(all, k + 1)));
|
|
for (var j = 0; j < k; j++) {
|
|
RHS = add3(RHS, vc(multiply2(y[j], subset2(G, index2(j, k))), multiply2(y[j], subset2(G, index2(j, k + 1)))));
|
|
}
|
|
var gkk = multiply2(identity2(m), multiply2(-1, subset2(G, index2(k, k))));
|
|
var gmk = multiply2(identity2(m), multiply2(-1, subset2(G, index2(k + 1, k))));
|
|
var gkm = multiply2(identity2(m), multiply2(-1, subset2(G, index2(k, k + 1))));
|
|
var gmm = multiply2(identity2(m), multiply2(-1, subset2(G, index2(k + 1, k + 1))));
|
|
var LHS = vc(hc(add3(F, gkk), gmk), hc(gkm, add3(F, gmm)));
|
|
var yAux = lusolve2(LHS, RHS);
|
|
y[k] = yAux.subset(index2(range2(0, m), 0));
|
|
y[k + 1] = yAux.subset(index2(range2(m, 2 * m), 0));
|
|
k++;
|
|
} else {
|
|
var _RHS = subset2(D, index2(all, k));
|
|
for (var _j = 0; _j < k; _j++) {
|
|
_RHS = add3(_RHS, multiply2(y[_j], subset2(G, index2(_j, k))));
|
|
}
|
|
var _gkk = subset2(G, index2(k, k));
|
|
var _LHS = subtract2(F, multiply2(_gkk, identity2(m)));
|
|
y[k] = lusolve2(_LHS, _RHS);
|
|
}
|
|
}
|
|
var Y = matrix2(matrixFromColumns2(...y));
|
|
var X = multiply2(U, multiply2(Y, transpose2(V)));
|
|
return X;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/decomposition/schur.js
|
|
var name245 = "schur";
|
|
var dependencies245 = ["typed", "matrix", "identity", "multiply", "qr", "norm", "subtract"];
|
|
var createSchur = /* @__PURE__ */ factory(name245, dependencies245, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
identity: identity2,
|
|
multiply: multiply2,
|
|
qr: qr2,
|
|
norm: norm2,
|
|
subtract: subtract2
|
|
} = _ref;
|
|
return typed2(name245, {
|
|
Array: function Array2(X) {
|
|
var r = _schur(matrix2(X));
|
|
return {
|
|
U: r.U.valueOf(),
|
|
T: r.T.valueOf()
|
|
};
|
|
},
|
|
Matrix: function Matrix2(X) {
|
|
return _schur(X);
|
|
}
|
|
});
|
|
function _schur(X) {
|
|
var n = X.size()[0];
|
|
var A = X;
|
|
var U = identity2(n);
|
|
var k = 0;
|
|
var A0;
|
|
do {
|
|
A0 = A;
|
|
var QR = qr2(A);
|
|
var Q2 = QR.Q;
|
|
var R = QR.R;
|
|
A = multiply2(R, Q2);
|
|
U = multiply2(U, Q2);
|
|
if (k++ > 100) {
|
|
break;
|
|
}
|
|
} while (norm2(subtract2(A, A0)) > 1e-4);
|
|
return {
|
|
U,
|
|
T: A
|
|
};
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/lyap.js
|
|
var name246 = "lyap";
|
|
var dependencies246 = ["typed", "matrix", "sylvester", "multiply", "transpose"];
|
|
var createLyap = /* @__PURE__ */ factory(name246, dependencies246, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
sylvester: sylvester2,
|
|
multiply: multiply2,
|
|
transpose: transpose2
|
|
} = _ref;
|
|
return typed2(name246, {
|
|
"Matrix, Matrix": function MatrixMatrix(A, Q2) {
|
|
return sylvester2(A, transpose2(A), multiply2(-1, Q2));
|
|
},
|
|
"Array, Matrix": function ArrayMatrix(A, Q2) {
|
|
return sylvester2(matrix2(A), transpose2(matrix2(A)), multiply2(-1, Q2));
|
|
},
|
|
"Matrix, Array": function MatrixArray(A, Q2) {
|
|
return sylvester2(A, transpose2(matrix2(A)), matrix2(multiply2(-1, Q2)));
|
|
},
|
|
"Array, Array": function ArrayArray(A, Q2) {
|
|
return sylvester2(matrix2(A), transpose2(matrix2(A)), matrix2(multiply2(-1, Q2))).toArray();
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/arithmetic/divide.js
|
|
var name247 = "divide";
|
|
var dependencies247 = ["typed", "matrix", "multiply", "equalScalar", "divideScalar", "inv"];
|
|
var createDivide = /* @__PURE__ */ factory(name247, dependencies247, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
multiply: multiply2,
|
|
equalScalar: equalScalar2,
|
|
divideScalar: divideScalar2,
|
|
inv: inv2
|
|
} = _ref;
|
|
var matAlgo11xS0s = createMatAlgo11xS0s({
|
|
typed: typed2,
|
|
equalScalar: equalScalar2
|
|
});
|
|
var matAlgo14xDs = createMatAlgo14xDs({
|
|
typed: typed2
|
|
});
|
|
return typed2("divide", extend({
|
|
"Array | Matrix, Array | Matrix": function ArrayMatrixArrayMatrix(x, y) {
|
|
return multiply2(x, inv2(y));
|
|
},
|
|
"DenseMatrix, any": function DenseMatrixAny(x, y) {
|
|
return matAlgo14xDs(x, y, divideScalar2, false);
|
|
},
|
|
"SparseMatrix, any": function SparseMatrixAny(x, y) {
|
|
return matAlgo11xS0s(x, y, divideScalar2, false);
|
|
},
|
|
"Array, any": function ArrayAny(x, y) {
|
|
return matAlgo14xDs(matrix2(x), y, divideScalar2, false).valueOf();
|
|
},
|
|
"any, Array | Matrix": function anyArrayMatrix(x, y) {
|
|
return multiply2(x, inv2(y));
|
|
}
|
|
}, divideScalar2.signatures));
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/geometry/distance.js
|
|
var name248 = "distance";
|
|
var dependencies248 = ["typed", "addScalar", "subtract", "divideScalar", "multiplyScalar", "unaryMinus", "sqrt", "abs"];
|
|
var createDistance = /* @__PURE__ */ factory(name248, dependencies248, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
addScalar: addScalar2,
|
|
subtract: subtract2,
|
|
multiplyScalar: multiplyScalar2,
|
|
divideScalar: divideScalar2,
|
|
unaryMinus: unaryMinus2,
|
|
sqrt: sqrt3,
|
|
abs: abs3
|
|
} = _ref;
|
|
return typed2(name248, {
|
|
"Array, Array, Array": function ArrayArrayArray(x, y, z) {
|
|
if (x.length === 2 && y.length === 2 && z.length === 2) {
|
|
if (!_2d(x)) {
|
|
throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");
|
|
}
|
|
if (!_2d(y)) {
|
|
throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");
|
|
}
|
|
if (!_2d(z)) {
|
|
throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");
|
|
}
|
|
var m = divideScalar2(subtract2(z[1], z[0]), subtract2(y[1], y[0]));
|
|
var xCoeff = multiplyScalar2(multiplyScalar2(m, m), y[0]);
|
|
var yCoeff = unaryMinus2(multiplyScalar2(m, y[0]));
|
|
var constant = x[1];
|
|
return _distancePointLine2D(x[0], x[1], xCoeff, yCoeff, constant);
|
|
} else {
|
|
throw new TypeError("Invalid Arguments: Try again");
|
|
}
|
|
},
|
|
"Object, Object, Object": function ObjectObjectObject(x, y, z) {
|
|
if (Object.keys(x).length === 2 && Object.keys(y).length === 2 && Object.keys(z).length === 2) {
|
|
if (!_2d(x)) {
|
|
throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");
|
|
}
|
|
if (!_2d(y)) {
|
|
throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");
|
|
}
|
|
if (!_2d(z)) {
|
|
throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");
|
|
}
|
|
if ("pointX" in x && "pointY" in x && "lineOnePtX" in y && "lineOnePtY" in y && "lineTwoPtX" in z && "lineTwoPtY" in z) {
|
|
var m = divideScalar2(subtract2(z.lineTwoPtY, z.lineTwoPtX), subtract2(y.lineOnePtY, y.lineOnePtX));
|
|
var xCoeff = multiplyScalar2(multiplyScalar2(m, m), y.lineOnePtX);
|
|
var yCoeff = unaryMinus2(multiplyScalar2(m, y.lineOnePtX));
|
|
var constant = x.pointX;
|
|
return _distancePointLine2D(x.pointX, x.pointY, xCoeff, yCoeff, constant);
|
|
} else {
|
|
throw new TypeError("Key names do not match");
|
|
}
|
|
} else {
|
|
throw new TypeError("Invalid Arguments: Try again");
|
|
}
|
|
},
|
|
"Array, Array": function ArrayArray(x, y) {
|
|
if (x.length === 2 && y.length === 3) {
|
|
if (!_2d(x)) {
|
|
throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");
|
|
}
|
|
if (!_3d(y)) {
|
|
throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");
|
|
}
|
|
return _distancePointLine2D(x[0], x[1], y[0], y[1], y[2]);
|
|
} else if (x.length === 3 && y.length === 6) {
|
|
if (!_3d(x)) {
|
|
throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");
|
|
}
|
|
if (!_parametricLine(y)) {
|
|
throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");
|
|
}
|
|
return _distancePointLine3D(x[0], x[1], x[2], y[0], y[1], y[2], y[3], y[4], y[5]);
|
|
} else if (x.length === y.length && x.length > 0) {
|
|
if (!_containsOnlyNumbers(x)) {
|
|
throw new TypeError("All values of an array should be numbers or BigNumbers");
|
|
}
|
|
if (!_containsOnlyNumbers(y)) {
|
|
throw new TypeError("All values of an array should be numbers or BigNumbers");
|
|
}
|
|
return _euclideanDistance(x, y);
|
|
} else {
|
|
throw new TypeError("Invalid Arguments: Try again");
|
|
}
|
|
},
|
|
"Object, Object": function ObjectObject(x, y) {
|
|
if (Object.keys(x).length === 2 && Object.keys(y).length === 3) {
|
|
if (!_2d(x)) {
|
|
throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");
|
|
}
|
|
if (!_3d(y)) {
|
|
throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");
|
|
}
|
|
if ("pointX" in x && "pointY" in x && "xCoeffLine" in y && "yCoeffLine" in y && "constant" in y) {
|
|
return _distancePointLine2D(x.pointX, x.pointY, y.xCoeffLine, y.yCoeffLine, y.constant);
|
|
} else {
|
|
throw new TypeError("Key names do not match");
|
|
}
|
|
} else if (Object.keys(x).length === 3 && Object.keys(y).length === 6) {
|
|
if (!_3d(x)) {
|
|
throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");
|
|
}
|
|
if (!_parametricLine(y)) {
|
|
throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");
|
|
}
|
|
if ("pointX" in x && "pointY" in x && "x0" in y && "y0" in y && "z0" in y && "a" in y && "b" in y && "c" in y) {
|
|
return _distancePointLine3D(x.pointX, x.pointY, x.pointZ, y.x0, y.y0, y.z0, y.a, y.b, y.c);
|
|
} else {
|
|
throw new TypeError("Key names do not match");
|
|
}
|
|
} else if (Object.keys(x).length === 2 && Object.keys(y).length === 2) {
|
|
if (!_2d(x)) {
|
|
throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");
|
|
}
|
|
if (!_2d(y)) {
|
|
throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");
|
|
}
|
|
if ("pointOneX" in x && "pointOneY" in x && "pointTwoX" in y && "pointTwoY" in y) {
|
|
return _euclideanDistance([x.pointOneX, x.pointOneY], [y.pointTwoX, y.pointTwoY]);
|
|
} else {
|
|
throw new TypeError("Key names do not match");
|
|
}
|
|
} else if (Object.keys(x).length === 3 && Object.keys(y).length === 3) {
|
|
if (!_3d(x)) {
|
|
throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");
|
|
}
|
|
if (!_3d(y)) {
|
|
throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");
|
|
}
|
|
if ("pointOneX" in x && "pointOneY" in x && "pointOneZ" in x && "pointTwoX" in y && "pointTwoY" in y && "pointTwoZ" in y) {
|
|
return _euclideanDistance([x.pointOneX, x.pointOneY, x.pointOneZ], [y.pointTwoX, y.pointTwoY, y.pointTwoZ]);
|
|
} else {
|
|
throw new TypeError("Key names do not match");
|
|
}
|
|
} else {
|
|
throw new TypeError("Invalid Arguments: Try again");
|
|
}
|
|
},
|
|
Array: function Array2(arr) {
|
|
if (!_pairwise(arr)) {
|
|
throw new TypeError("Incorrect array format entered for pairwise distance calculation");
|
|
}
|
|
return _distancePairwise(arr);
|
|
}
|
|
});
|
|
function _isNumber(a) {
|
|
return typeof a === "number" || isBigNumber(a);
|
|
}
|
|
function _2d(a) {
|
|
if (a.constructor !== Array) {
|
|
a = _objectToArray(a);
|
|
}
|
|
return _isNumber(a[0]) && _isNumber(a[1]);
|
|
}
|
|
function _3d(a) {
|
|
if (a.constructor !== Array) {
|
|
a = _objectToArray(a);
|
|
}
|
|
return _isNumber(a[0]) && _isNumber(a[1]) && _isNumber(a[2]);
|
|
}
|
|
function _containsOnlyNumbers(a) {
|
|
if (!Array.isArray(a)) {
|
|
a = _objectToArray(a);
|
|
}
|
|
return a.every(_isNumber);
|
|
}
|
|
function _parametricLine(a) {
|
|
if (a.constructor !== Array) {
|
|
a = _objectToArray(a);
|
|
}
|
|
return _isNumber(a[0]) && _isNumber(a[1]) && _isNumber(a[2]) && _isNumber(a[3]) && _isNumber(a[4]) && _isNumber(a[5]);
|
|
}
|
|
function _objectToArray(o) {
|
|
var keys = Object.keys(o);
|
|
var a = [];
|
|
for (var i2 = 0; i2 < keys.length; i2++) {
|
|
a.push(o[keys[i2]]);
|
|
}
|
|
return a;
|
|
}
|
|
function _pairwise(a) {
|
|
if (a[0].length === 2 && _isNumber(a[0][0]) && _isNumber(a[0][1])) {
|
|
if (a.some((aI) => aI.length !== 2 || !_isNumber(aI[0]) || !_isNumber(aI[1]))) {
|
|
return false;
|
|
}
|
|
} else if (a[0].length === 3 && _isNumber(a[0][0]) && _isNumber(a[0][1]) && _isNumber(a[0][2])) {
|
|
if (a.some((aI) => aI.length !== 3 || !_isNumber(aI[0]) || !_isNumber(aI[1]) || !_isNumber(aI[2]))) {
|
|
return false;
|
|
}
|
|
} else {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
function _distancePointLine2D(x, y, a, b, c) {
|
|
var num = abs3(addScalar2(addScalar2(multiplyScalar2(a, x), multiplyScalar2(b, y)), c));
|
|
var den = sqrt3(addScalar2(multiplyScalar2(a, a), multiplyScalar2(b, b)));
|
|
return divideScalar2(num, den);
|
|
}
|
|
function _distancePointLine3D(x, y, z, x0, y0, z0, a, b, c) {
|
|
var num = [subtract2(multiplyScalar2(subtract2(y0, y), c), multiplyScalar2(subtract2(z0, z), b)), subtract2(multiplyScalar2(subtract2(z0, z), a), multiplyScalar2(subtract2(x0, x), c)), subtract2(multiplyScalar2(subtract2(x0, x), b), multiplyScalar2(subtract2(y0, y), a))];
|
|
num = sqrt3(addScalar2(addScalar2(multiplyScalar2(num[0], num[0]), multiplyScalar2(num[1], num[1])), multiplyScalar2(num[2], num[2])));
|
|
var den = sqrt3(addScalar2(addScalar2(multiplyScalar2(a, a), multiplyScalar2(b, b)), multiplyScalar2(c, c)));
|
|
return divideScalar2(num, den);
|
|
}
|
|
function _euclideanDistance(x, y) {
|
|
var vectorSize = x.length;
|
|
var result = 0;
|
|
var diff2 = 0;
|
|
for (var i2 = 0; i2 < vectorSize; i2++) {
|
|
diff2 = subtract2(x[i2], y[i2]);
|
|
result = addScalar2(multiplyScalar2(diff2, diff2), result);
|
|
}
|
|
return sqrt3(result);
|
|
}
|
|
function _distancePairwise(a) {
|
|
var result = [];
|
|
var pointA = [];
|
|
var pointB = [];
|
|
for (var i2 = 0; i2 < a.length - 1; i2++) {
|
|
for (var j = i2 + 1; j < a.length; j++) {
|
|
if (a[0].length === 2) {
|
|
pointA = [a[i2][0], a[i2][1]];
|
|
pointB = [a[j][0], a[j][1]];
|
|
} else if (a[0].length === 3) {
|
|
pointA = [a[i2][0], a[i2][1], a[i2][2]];
|
|
pointB = [a[j][0], a[j][1], a[j][2]];
|
|
}
|
|
result.push(_euclideanDistance(pointA, pointB));
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/geometry/intersect.js
|
|
var name249 = "intersect";
|
|
var dependencies249 = ["typed", "config", "abs", "add", "addScalar", "matrix", "multiply", "multiplyScalar", "divideScalar", "subtract", "smaller", "equalScalar", "flatten", "isZero", "isNumeric"];
|
|
var createIntersect = /* @__PURE__ */ factory(name249, dependencies249, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
abs: abs3,
|
|
add: add3,
|
|
addScalar: addScalar2,
|
|
matrix: matrix2,
|
|
multiply: multiply2,
|
|
multiplyScalar: multiplyScalar2,
|
|
divideScalar: divideScalar2,
|
|
subtract: subtract2,
|
|
smaller: smaller2,
|
|
equalScalar: equalScalar2,
|
|
flatten: flatten3,
|
|
isZero: isZero2,
|
|
isNumeric: isNumeric2
|
|
} = _ref;
|
|
return typed2("intersect", {
|
|
"Array, Array, Array": _AAA,
|
|
"Array, Array, Array, Array": _AAAA,
|
|
"Matrix, Matrix, Matrix": function MatrixMatrixMatrix(x, y, plane) {
|
|
var arr = _AAA(x.valueOf(), y.valueOf(), plane.valueOf());
|
|
return arr === null ? null : matrix2(arr);
|
|
},
|
|
"Matrix, Matrix, Matrix, Matrix": function MatrixMatrixMatrixMatrix(w, x, y, z) {
|
|
var arr = _AAAA(w.valueOf(), x.valueOf(), y.valueOf(), z.valueOf());
|
|
return arr === null ? null : matrix2(arr);
|
|
}
|
|
});
|
|
function _AAA(x, y, plane) {
|
|
x = _coerceArr(x);
|
|
y = _coerceArr(y);
|
|
plane = _coerceArr(plane);
|
|
if (!_3d(x)) {
|
|
throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");
|
|
}
|
|
if (!_3d(y)) {
|
|
throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");
|
|
}
|
|
if (!_4d(plane)) {
|
|
throw new TypeError("Array with 4 numbers expected as third argument");
|
|
}
|
|
return _intersectLinePlane(x[0], x[1], x[2], y[0], y[1], y[2], plane[0], plane[1], plane[2], plane[3]);
|
|
}
|
|
function _AAAA(w, x, y, z) {
|
|
w = _coerceArr(w);
|
|
x = _coerceArr(x);
|
|
y = _coerceArr(y);
|
|
z = _coerceArr(z);
|
|
if (w.length === 2) {
|
|
if (!_2d(w)) {
|
|
throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");
|
|
}
|
|
if (!_2d(x)) {
|
|
throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");
|
|
}
|
|
if (!_2d(y)) {
|
|
throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");
|
|
}
|
|
if (!_2d(z)) {
|
|
throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");
|
|
}
|
|
return _intersect2d(w, x, y, z);
|
|
} else if (w.length === 3) {
|
|
if (!_3d(w)) {
|
|
throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");
|
|
}
|
|
if (!_3d(x)) {
|
|
throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");
|
|
}
|
|
if (!_3d(y)) {
|
|
throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");
|
|
}
|
|
if (!_3d(z)) {
|
|
throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");
|
|
}
|
|
return _intersect3d(w[0], w[1], w[2], x[0], x[1], x[2], y[0], y[1], y[2], z[0], z[1], z[2]);
|
|
} else {
|
|
throw new TypeError("Arrays with two or thee dimensional points expected");
|
|
}
|
|
}
|
|
function _coerceArr(arr) {
|
|
if (arr.length === 1)
|
|
return arr[0];
|
|
if (arr.length > 1 && Array.isArray(arr[0])) {
|
|
if (arr.every((el) => Array.isArray(el) && el.length === 1))
|
|
return flatten3(arr);
|
|
}
|
|
return arr;
|
|
}
|
|
function _2d(x) {
|
|
return x.length === 2 && isNumeric2(x[0]) && isNumeric2(x[1]);
|
|
}
|
|
function _3d(x) {
|
|
return x.length === 3 && isNumeric2(x[0]) && isNumeric2(x[1]) && isNumeric2(x[2]);
|
|
}
|
|
function _4d(x) {
|
|
return x.length === 4 && isNumeric2(x[0]) && isNumeric2(x[1]) && isNumeric2(x[2]) && isNumeric2(x[3]);
|
|
}
|
|
function _intersect2d(p1a, p1b, p2a, p2b) {
|
|
var o1 = p1a;
|
|
var o2 = p2a;
|
|
var d1 = subtract2(o1, p1b);
|
|
var d2 = subtract2(o2, p2b);
|
|
var det2 = subtract2(multiplyScalar2(d1[0], d2[1]), multiplyScalar2(d2[0], d1[1]));
|
|
if (isZero2(det2))
|
|
return null;
|
|
if (smaller2(abs3(det2), config4.epsilon)) {
|
|
return null;
|
|
}
|
|
var d20o11 = multiplyScalar2(d2[0], o1[1]);
|
|
var d21o10 = multiplyScalar2(d2[1], o1[0]);
|
|
var d20o21 = multiplyScalar2(d2[0], o2[1]);
|
|
var d21o20 = multiplyScalar2(d2[1], o2[0]);
|
|
var t = divideScalar2(addScalar2(subtract2(subtract2(d20o11, d21o10), d20o21), d21o20), det2);
|
|
return add3(multiply2(d1, t), o1);
|
|
}
|
|
function _intersect3dHelper(a, b, c, d, e3, f, g, h, i2, j, k, l) {
|
|
var add1 = multiplyScalar2(subtract2(a, b), subtract2(c, d));
|
|
var add22 = multiplyScalar2(subtract2(e3, f), subtract2(g, h));
|
|
var add32 = multiplyScalar2(subtract2(i2, j), subtract2(k, l));
|
|
return addScalar2(addScalar2(add1, add22), add32);
|
|
}
|
|
function _intersect3d(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4) {
|
|
var d1343 = _intersect3dHelper(x1, x3, x4, x3, y1, y3, y4, y3, z1, z3, z4, z3);
|
|
var d4321 = _intersect3dHelper(x4, x3, x2, x1, y4, y3, y2, y1, z4, z3, z2, z1);
|
|
var d1321 = _intersect3dHelper(x1, x3, x2, x1, y1, y3, y2, y1, z1, z3, z2, z1);
|
|
var d4343 = _intersect3dHelper(x4, x3, x4, x3, y4, y3, y4, y3, z4, z3, z4, z3);
|
|
var d2121 = _intersect3dHelper(x2, x1, x2, x1, y2, y1, y2, y1, z2, z1, z2, z1);
|
|
var numerator = subtract2(multiplyScalar2(d1343, d4321), multiplyScalar2(d1321, d4343));
|
|
var denominator = subtract2(multiplyScalar2(d2121, d4343), multiplyScalar2(d4321, d4321));
|
|
if (isZero2(denominator))
|
|
return null;
|
|
var ta = divideScalar2(numerator, denominator);
|
|
var tb = divideScalar2(addScalar2(d1343, multiplyScalar2(ta, d4321)), d4343);
|
|
var pax = addScalar2(x1, multiplyScalar2(ta, subtract2(x2, x1)));
|
|
var pay = addScalar2(y1, multiplyScalar2(ta, subtract2(y2, y1)));
|
|
var paz = addScalar2(z1, multiplyScalar2(ta, subtract2(z2, z1)));
|
|
var pbx = addScalar2(x3, multiplyScalar2(tb, subtract2(x4, x3)));
|
|
var pby = addScalar2(y3, multiplyScalar2(tb, subtract2(y4, y3)));
|
|
var pbz = addScalar2(z3, multiplyScalar2(tb, subtract2(z4, z3)));
|
|
if (equalScalar2(pax, pbx) && equalScalar2(pay, pby) && equalScalar2(paz, pbz)) {
|
|
return [pax, pay, paz];
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
function _intersectLinePlane(x1, y1, z1, x2, y2, z2, x, y, z, c) {
|
|
var x1x = multiplyScalar2(x1, x);
|
|
var x2x = multiplyScalar2(x2, x);
|
|
var y1y = multiplyScalar2(y1, y);
|
|
var y2y = multiplyScalar2(y2, y);
|
|
var z1z = multiplyScalar2(z1, z);
|
|
var z2z = multiplyScalar2(z2, z);
|
|
var numerator = subtract2(subtract2(subtract2(c, x1x), y1y), z1z);
|
|
var denominator = subtract2(subtract2(subtract2(addScalar2(addScalar2(x2x, y2y), z2z), x1x), y1y), z1z);
|
|
var t = divideScalar2(numerator, denominator);
|
|
var px = addScalar2(x1, multiplyScalar2(t, subtract2(x2, x1)));
|
|
var py = addScalar2(y1, multiplyScalar2(t, subtract2(y2, y1)));
|
|
var pz = addScalar2(z1, multiplyScalar2(t, subtract2(z2, z1)));
|
|
return [px, py, pz];
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/statistics/sum.js
|
|
var name250 = "sum";
|
|
var dependencies250 = ["typed", "config", "add", "numeric"];
|
|
var createSum = /* @__PURE__ */ factory(name250, dependencies250, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
add: add3,
|
|
numeric: numeric3
|
|
} = _ref;
|
|
return typed2(name250, {
|
|
"Array | Matrix": _sum,
|
|
"Array | Matrix, number | BigNumber": _nsumDim,
|
|
"...": function _(args) {
|
|
if (containsCollections(args)) {
|
|
throw new TypeError("Scalar values expected in function sum");
|
|
}
|
|
return _sum(args);
|
|
}
|
|
});
|
|
function _sum(array) {
|
|
var sum3;
|
|
deepForEach(array, function(value) {
|
|
try {
|
|
sum3 = sum3 === void 0 ? value : add3(sum3, value);
|
|
} catch (err) {
|
|
throw improveErrorMessage(err, "sum", value);
|
|
}
|
|
});
|
|
if (sum3 === void 0) {
|
|
sum3 = numeric3(0, config4.number);
|
|
}
|
|
if (typeof sum3 === "string") {
|
|
sum3 = numeric3(sum3, config4.number);
|
|
}
|
|
return sum3;
|
|
}
|
|
function _nsumDim(array, dim) {
|
|
try {
|
|
var sum3 = reduce(array, dim, add3);
|
|
return sum3;
|
|
} catch (err) {
|
|
throw improveErrorMessage(err, "sum");
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/statistics/cumsum.js
|
|
var name251 = "cumsum";
|
|
var dependencies251 = ["typed", "add", "unaryPlus"];
|
|
var createCumSum = /* @__PURE__ */ factory(name251, dependencies251, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
add: add3,
|
|
unaryPlus: unaryPlus2
|
|
} = _ref;
|
|
return typed2(name251, {
|
|
Array: _cumsum,
|
|
Matrix: function Matrix2(matrix2) {
|
|
return matrix2.create(_cumsum(matrix2.valueOf()));
|
|
},
|
|
"Array, number | BigNumber": _ncumSumDim,
|
|
"Matrix, number | BigNumber": function MatrixNumberBigNumber(matrix2, dim) {
|
|
return matrix2.create(_ncumSumDim(matrix2.valueOf(), dim));
|
|
},
|
|
"...": function _(args) {
|
|
if (containsCollections(args)) {
|
|
throw new TypeError("All values expected to be scalar in function cumsum");
|
|
}
|
|
return _cumsum(args);
|
|
}
|
|
});
|
|
function _cumsum(array) {
|
|
try {
|
|
return _cumsummap(array);
|
|
} catch (err) {
|
|
throw improveErrorMessage(err, name251);
|
|
}
|
|
}
|
|
function _cumsummap(array) {
|
|
if (array.length === 0) {
|
|
return [];
|
|
}
|
|
var sums = [unaryPlus2(array[0])];
|
|
for (var i2 = 1; i2 < array.length; ++i2) {
|
|
sums.push(add3(sums[i2 - 1], array[i2]));
|
|
}
|
|
return sums;
|
|
}
|
|
function _ncumSumDim(array, dim) {
|
|
var size2 = arraySize(array);
|
|
if (dim < 0 || dim >= size2.length) {
|
|
throw new IndexError(dim, size2.length);
|
|
}
|
|
try {
|
|
return _cumsumDimensional(array, dim);
|
|
} catch (err) {
|
|
throw improveErrorMessage(err, name251);
|
|
}
|
|
}
|
|
function _cumsumDimensional(mat, dim) {
|
|
var i2, ret, tran;
|
|
if (dim <= 0) {
|
|
var initialValue = mat[0][0];
|
|
if (!Array.isArray(initialValue)) {
|
|
return _cumsummap(mat);
|
|
} else {
|
|
tran = _switch(mat);
|
|
ret = [];
|
|
for (i2 = 0; i2 < tran.length; i2++) {
|
|
ret[i2] = _cumsumDimensional(tran[i2], dim - 1);
|
|
}
|
|
return ret;
|
|
}
|
|
} else {
|
|
ret = [];
|
|
for (i2 = 0; i2 < mat.length; i2++) {
|
|
ret[i2] = _cumsumDimensional(mat[i2], dim - 1);
|
|
}
|
|
return ret;
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/statistics/mean.js
|
|
var name252 = "mean";
|
|
var dependencies252 = ["typed", "add", "divide"];
|
|
var createMean = /* @__PURE__ */ factory(name252, dependencies252, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
add: add3,
|
|
divide: divide3
|
|
} = _ref;
|
|
return typed2(name252, {
|
|
"Array | Matrix": _mean,
|
|
"Array | Matrix, number | BigNumber": _nmeanDim,
|
|
"...": function _(args) {
|
|
if (containsCollections(args)) {
|
|
throw new TypeError("Scalar values expected in function mean");
|
|
}
|
|
return _mean(args);
|
|
}
|
|
});
|
|
function _nmeanDim(array, dim) {
|
|
try {
|
|
var sum3 = reduce(array, dim, add3);
|
|
var s = Array.isArray(array) ? arraySize(array) : array.size();
|
|
return divide3(sum3, s[dim]);
|
|
} catch (err) {
|
|
throw improveErrorMessage(err, "mean");
|
|
}
|
|
}
|
|
function _mean(array) {
|
|
var sum3;
|
|
var num = 0;
|
|
deepForEach(array, function(value) {
|
|
try {
|
|
sum3 = sum3 === void 0 ? value : add3(sum3, value);
|
|
num++;
|
|
} catch (err) {
|
|
throw improveErrorMessage(err, "mean", value);
|
|
}
|
|
});
|
|
if (num === 0) {
|
|
throw new Error("Cannot calculate the mean of an empty array");
|
|
}
|
|
return divide3(sum3, num);
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/statistics/median.js
|
|
var name253 = "median";
|
|
var dependencies253 = ["typed", "add", "divide", "compare", "partitionSelect"];
|
|
var createMedian = /* @__PURE__ */ factory(name253, dependencies253, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
add: add3,
|
|
divide: divide3,
|
|
compare: compare2,
|
|
partitionSelect: partitionSelect2
|
|
} = _ref;
|
|
function _median(array) {
|
|
try {
|
|
array = flatten(array.valueOf());
|
|
var num = array.length;
|
|
if (num === 0) {
|
|
throw new Error("Cannot calculate median of an empty array");
|
|
}
|
|
if (num % 2 === 0) {
|
|
var mid = num / 2 - 1;
|
|
var right = partitionSelect2(array, mid + 1);
|
|
var left = array[mid];
|
|
for (var i2 = 0; i2 < mid; ++i2) {
|
|
if (compare2(array[i2], left) > 0) {
|
|
left = array[i2];
|
|
}
|
|
}
|
|
return middle2(left, right);
|
|
} else {
|
|
var m = partitionSelect2(array, (num - 1) / 2);
|
|
return middle(m);
|
|
}
|
|
} catch (err) {
|
|
throw improveErrorMessage(err, "median");
|
|
}
|
|
}
|
|
var middle = typed2({
|
|
"number | BigNumber | Complex | Unit": function numberBigNumberComplexUnit(value) {
|
|
return value;
|
|
}
|
|
});
|
|
var middle2 = typed2({
|
|
"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit": function numberBigNumberComplexUnitNumberBigNumberComplexUnit(left, right) {
|
|
return divide3(add3(left, right), 2);
|
|
}
|
|
});
|
|
return typed2(name253, {
|
|
"Array | Matrix": _median,
|
|
"Array | Matrix, number | BigNumber": function ArrayMatrixNumberBigNumber(array, dim) {
|
|
throw new Error("median(A, dim) is not yet supported");
|
|
},
|
|
"...": function _(args) {
|
|
if (containsCollections(args)) {
|
|
throw new TypeError("Scalar values expected in function median");
|
|
}
|
|
return _median(args);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/statistics/mad.js
|
|
var name254 = "mad";
|
|
var dependencies254 = ["typed", "abs", "map", "median", "subtract"];
|
|
var createMad = /* @__PURE__ */ factory(name254, dependencies254, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
abs: abs3,
|
|
map: map3,
|
|
median: median2,
|
|
subtract: subtract2
|
|
} = _ref;
|
|
return typed2(name254, {
|
|
"Array | Matrix": _mad,
|
|
"...": function _(args) {
|
|
return _mad(args);
|
|
}
|
|
});
|
|
function _mad(array) {
|
|
array = flatten(array.valueOf());
|
|
if (array.length === 0) {
|
|
throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");
|
|
}
|
|
try {
|
|
var med = median2(array);
|
|
return median2(map3(array, function(value) {
|
|
return abs3(subtract2(value, med));
|
|
}));
|
|
} catch (err) {
|
|
if (err instanceof TypeError && err.message.indexOf("median") !== -1) {
|
|
throw new TypeError(err.message.replace("median", "mad"));
|
|
} else {
|
|
throw improveErrorMessage(err, "mad");
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/statistics/variance.js
|
|
var DEFAULT_NORMALIZATION = "unbiased";
|
|
var name255 = "variance";
|
|
var dependencies255 = ["typed", "add", "subtract", "multiply", "divide", "apply", "isNaN"];
|
|
var createVariance = /* @__PURE__ */ factory(name255, dependencies255, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
add: add3,
|
|
subtract: subtract2,
|
|
multiply: multiply2,
|
|
divide: divide3,
|
|
apply: apply2,
|
|
isNaN: isNaN3
|
|
} = _ref;
|
|
return typed2(name255, {
|
|
"Array | Matrix": function ArrayMatrix(array) {
|
|
return _var(array, DEFAULT_NORMALIZATION);
|
|
},
|
|
"Array | Matrix, string": _var,
|
|
"Array | Matrix, number | BigNumber": function ArrayMatrixNumberBigNumber(array, dim) {
|
|
return _varDim(array, dim, DEFAULT_NORMALIZATION);
|
|
},
|
|
"Array | Matrix, number | BigNumber, string": _varDim,
|
|
"...": function _(args) {
|
|
return _var(args, DEFAULT_NORMALIZATION);
|
|
}
|
|
});
|
|
function _var(array, normalization) {
|
|
var sum3;
|
|
var num = 0;
|
|
if (array.length === 0) {
|
|
throw new SyntaxError("Function variance requires one or more parameters (0 provided)");
|
|
}
|
|
deepForEach(array, function(value) {
|
|
try {
|
|
sum3 = sum3 === void 0 ? value : add3(sum3, value);
|
|
num++;
|
|
} catch (err) {
|
|
throw improveErrorMessage(err, "variance", value);
|
|
}
|
|
});
|
|
if (num === 0)
|
|
throw new Error("Cannot calculate variance of an empty array");
|
|
var mean2 = divide3(sum3, num);
|
|
sum3 = void 0;
|
|
deepForEach(array, function(value) {
|
|
var diff2 = subtract2(value, mean2);
|
|
sum3 = sum3 === void 0 ? multiply2(diff2, diff2) : add3(sum3, multiply2(diff2, diff2));
|
|
});
|
|
if (isNaN3(sum3)) {
|
|
return sum3;
|
|
}
|
|
switch (normalization) {
|
|
case "uncorrected":
|
|
return divide3(sum3, num);
|
|
case "biased":
|
|
return divide3(sum3, num + 1);
|
|
case "unbiased": {
|
|
var zero = isBigNumber(sum3) ? sum3.mul(0) : 0;
|
|
return num === 1 ? zero : divide3(sum3, num - 1);
|
|
}
|
|
default:
|
|
throw new Error('Unknown normalization "' + normalization + '". Choose "unbiased" (default), "uncorrected", or "biased".');
|
|
}
|
|
}
|
|
function _varDim(array, dim, normalization) {
|
|
try {
|
|
if (array.length === 0) {
|
|
throw new SyntaxError("Function variance requires one or more parameters (0 provided)");
|
|
}
|
|
return apply2(array, dim, (x) => _var(x, normalization));
|
|
} catch (err) {
|
|
throw improveErrorMessage(err, "variance");
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/statistics/quantileSeq.js
|
|
var name256 = "quantileSeq";
|
|
var dependencies256 = ["typed", "add", "multiply", "partitionSelect", "compare"];
|
|
var createQuantileSeq = /* @__PURE__ */ factory(name256, dependencies256, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
add: add3,
|
|
multiply: multiply2,
|
|
partitionSelect: partitionSelect2,
|
|
compare: compare2
|
|
} = _ref;
|
|
function quantileSeq2(data, probOrN, sorted) {
|
|
var probArr, dataArr, one;
|
|
if (arguments.length < 2 || arguments.length > 3) {
|
|
throw new SyntaxError("Function quantileSeq requires two or three parameters");
|
|
}
|
|
if (isCollection(data)) {
|
|
sorted = sorted || false;
|
|
if (typeof sorted === "boolean") {
|
|
dataArr = data.valueOf();
|
|
if (isNumber(probOrN)) {
|
|
if (probOrN < 0) {
|
|
throw new Error("N/prob must be non-negative");
|
|
}
|
|
if (probOrN <= 1) {
|
|
return _quantileSeq(dataArr, probOrN, sorted);
|
|
}
|
|
if (probOrN > 1) {
|
|
if (!isInteger(probOrN)) {
|
|
throw new Error("N must be a positive integer");
|
|
}
|
|
var nPlusOne = probOrN + 1;
|
|
probArr = new Array(probOrN);
|
|
for (var i2 = 0; i2 < probOrN; ) {
|
|
probArr[i2] = _quantileSeq(dataArr, ++i2 / nPlusOne, sorted);
|
|
}
|
|
return probArr;
|
|
}
|
|
}
|
|
if (isBigNumber(probOrN)) {
|
|
var BigNumber2 = probOrN.constructor;
|
|
if (probOrN.isNegative()) {
|
|
throw new Error("N/prob must be non-negative");
|
|
}
|
|
one = new BigNumber2(1);
|
|
if (probOrN.lte(one)) {
|
|
return new BigNumber2(_quantileSeq(dataArr, probOrN, sorted));
|
|
}
|
|
if (probOrN.gt(one)) {
|
|
if (!probOrN.isInteger()) {
|
|
throw new Error("N must be a positive integer");
|
|
}
|
|
var intN = probOrN.toNumber();
|
|
if (intN > 4294967295) {
|
|
throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");
|
|
}
|
|
var _nPlusOne = new BigNumber2(intN + 1);
|
|
probArr = new Array(intN);
|
|
for (var _i = 0; _i < intN; ) {
|
|
probArr[_i] = new BigNumber2(_quantileSeq(dataArr, new BigNumber2(++_i).div(_nPlusOne), sorted));
|
|
}
|
|
return probArr;
|
|
}
|
|
}
|
|
if (isCollection(probOrN)) {
|
|
var probOrNArr = probOrN.valueOf();
|
|
probArr = new Array(probOrNArr.length);
|
|
for (var _i2 = 0; _i2 < probArr.length; ++_i2) {
|
|
var currProb = probOrNArr[_i2];
|
|
if (isNumber(currProb)) {
|
|
if (currProb < 0 || currProb > 1) {
|
|
throw new Error("Probability must be between 0 and 1, inclusive");
|
|
}
|
|
} else if (isBigNumber(currProb)) {
|
|
one = new currProb.constructor(1);
|
|
if (currProb.isNegative() || currProb.gt(one)) {
|
|
throw new Error("Probability must be between 0 and 1, inclusive");
|
|
}
|
|
} else {
|
|
throw new TypeError("Unexpected type of argument in function quantileSeq");
|
|
}
|
|
probArr[_i2] = _quantileSeq(dataArr, currProb, sorted);
|
|
}
|
|
return probArr;
|
|
}
|
|
throw new TypeError("Unexpected type of argument in function quantileSeq");
|
|
}
|
|
throw new TypeError("Unexpected type of argument in function quantileSeq");
|
|
}
|
|
throw new TypeError("Unexpected type of argument in function quantileSeq");
|
|
}
|
|
function _quantileSeq(array, prob, sorted) {
|
|
var flat = flatten(array);
|
|
var len = flat.length;
|
|
if (len === 0) {
|
|
throw new Error("Cannot calculate quantile of an empty sequence");
|
|
}
|
|
if (isNumber(prob)) {
|
|
var _index = prob * (len - 1);
|
|
var _fracPart = _index % 1;
|
|
if (_fracPart === 0) {
|
|
var value = sorted ? flat[_index] : partitionSelect2(flat, _index);
|
|
validate2(value);
|
|
return value;
|
|
}
|
|
var _integerPart = Math.floor(_index);
|
|
var _left;
|
|
var _right;
|
|
if (sorted) {
|
|
_left = flat[_integerPart];
|
|
_right = flat[_integerPart + 1];
|
|
} else {
|
|
_right = partitionSelect2(flat, _integerPart + 1);
|
|
_left = flat[_integerPart];
|
|
for (var i2 = 0; i2 < _integerPart; ++i2) {
|
|
if (compare2(flat[i2], _left) > 0) {
|
|
_left = flat[i2];
|
|
}
|
|
}
|
|
}
|
|
validate2(_left);
|
|
validate2(_right);
|
|
return add3(multiply2(_left, 1 - _fracPart), multiply2(_right, _fracPart));
|
|
}
|
|
var index2 = prob.times(len - 1);
|
|
if (index2.isInteger()) {
|
|
index2 = index2.toNumber();
|
|
var _value = sorted ? flat[index2] : partitionSelect2(flat, index2);
|
|
validate2(_value);
|
|
return _value;
|
|
}
|
|
var integerPart = index2.floor();
|
|
var fracPart = index2.minus(integerPart);
|
|
var integerPartNumber = integerPart.toNumber();
|
|
var left;
|
|
var right;
|
|
if (sorted) {
|
|
left = flat[integerPartNumber];
|
|
right = flat[integerPartNumber + 1];
|
|
} else {
|
|
right = partitionSelect2(flat, integerPartNumber + 1);
|
|
left = flat[integerPartNumber];
|
|
for (var _i3 = 0; _i3 < integerPartNumber; ++_i3) {
|
|
if (compare2(flat[_i3], left) > 0) {
|
|
left = flat[_i3];
|
|
}
|
|
}
|
|
}
|
|
validate2(left);
|
|
validate2(right);
|
|
var one = new fracPart.constructor(1);
|
|
return add3(multiply2(left, one.minus(fracPart)), multiply2(right, fracPart));
|
|
}
|
|
var validate2 = typed2({
|
|
"number | BigNumber | Unit": function numberBigNumberUnit(x) {
|
|
return x;
|
|
}
|
|
});
|
|
return quantileSeq2;
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/statistics/std.js
|
|
var name257 = "std";
|
|
var dependencies257 = ["typed", "map", "sqrt", "variance"];
|
|
var createStd = /* @__PURE__ */ factory(name257, dependencies257, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
map: map3,
|
|
sqrt: sqrt3,
|
|
variance: variance2
|
|
} = _ref;
|
|
return typed2(name257, {
|
|
"Array | Matrix": _std,
|
|
"Array | Matrix, string": _std,
|
|
"Array | Matrix, number | BigNumber": _std,
|
|
"Array | Matrix, number | BigNumber, string": _std,
|
|
"...": function _(args) {
|
|
return _std(args);
|
|
}
|
|
});
|
|
function _std(array, normalization) {
|
|
if (array.length === 0) {
|
|
throw new SyntaxError("Function std requires one or more parameters (0 provided)");
|
|
}
|
|
try {
|
|
var v = variance2.apply(null, arguments);
|
|
if (isCollection(v)) {
|
|
return map3(v, sqrt3);
|
|
} else {
|
|
return sqrt3(v);
|
|
}
|
|
} catch (err) {
|
|
if (err instanceof TypeError && err.message.indexOf(" variance") !== -1) {
|
|
throw new TypeError(err.message.replace(" variance", " std"));
|
|
} else {
|
|
throw err;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/probability/combinations.js
|
|
var name258 = "combinations";
|
|
var dependencies258 = ["typed"];
|
|
var createCombinations = /* @__PURE__ */ factory(name258, dependencies258, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name258, {
|
|
"number, number": combinationsNumber,
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(n, k) {
|
|
var BigNumber2 = n.constructor;
|
|
var result, i2;
|
|
var nMinusk = n.minus(k);
|
|
var one = new BigNumber2(1);
|
|
if (!isPositiveInteger(n) || !isPositiveInteger(k)) {
|
|
throw new TypeError("Positive integer value expected in function combinations");
|
|
}
|
|
if (k.gt(n)) {
|
|
throw new TypeError("k must be less than n in function combinations");
|
|
}
|
|
result = one;
|
|
if (k.lt(nMinusk)) {
|
|
for (i2 = one; i2.lte(nMinusk); i2 = i2.plus(one)) {
|
|
result = result.times(k.plus(i2)).dividedBy(i2);
|
|
}
|
|
} else {
|
|
for (i2 = one; i2.lte(k); i2 = i2.plus(one)) {
|
|
result = result.times(nMinusk.plus(i2)).dividedBy(i2);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
});
|
|
});
|
|
function isPositiveInteger(n) {
|
|
return n.isInteger() && n.gte(0);
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/probability/combinationsWithRep.js
|
|
var name259 = "combinationsWithRep";
|
|
var dependencies259 = ["typed"];
|
|
var createCombinationsWithRep = /* @__PURE__ */ factory(name259, dependencies259, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
return typed2(name259, {
|
|
"number, number": function numberNumber(n, k) {
|
|
if (!isInteger(n) || n < 0) {
|
|
throw new TypeError("Positive integer value expected in function combinationsWithRep");
|
|
}
|
|
if (!isInteger(k) || k < 0) {
|
|
throw new TypeError("Positive integer value expected in function combinationsWithRep");
|
|
}
|
|
if (n < 1) {
|
|
throw new TypeError("k must be less than or equal to n + k - 1");
|
|
}
|
|
if (k < n - 1) {
|
|
var _prodrange = product2(n, n + k - 1);
|
|
return _prodrange / product2(1, k);
|
|
}
|
|
var prodrange = product2(k + 1, n + k - 1);
|
|
return prodrange / product2(1, n - 1);
|
|
},
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(n, k) {
|
|
var BigNumber2 = n.constructor;
|
|
var result, i2;
|
|
var one = new BigNumber2(1);
|
|
var nMinusOne = n.minus(one);
|
|
if (!isPositiveInteger2(n) || !isPositiveInteger2(k)) {
|
|
throw new TypeError("Positive integer value expected in function combinationsWithRep");
|
|
}
|
|
if (n.lt(one)) {
|
|
throw new TypeError("k must be less than or equal to n + k - 1 in function combinationsWithRep");
|
|
}
|
|
result = one;
|
|
if (k.lt(nMinusOne)) {
|
|
for (i2 = one; i2.lte(nMinusOne); i2 = i2.plus(one)) {
|
|
result = result.times(k.plus(i2)).dividedBy(i2);
|
|
}
|
|
} else {
|
|
for (i2 = one; i2.lte(k); i2 = i2.plus(one)) {
|
|
result = result.times(nMinusOne.plus(i2)).dividedBy(i2);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
});
|
|
});
|
|
function isPositiveInteger2(n) {
|
|
return n.isInteger() && n.gte(0);
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/probability/gamma.js
|
|
var name260 = "gamma";
|
|
var dependencies260 = ["typed", "config", "multiplyScalar", "pow", "BigNumber", "Complex"];
|
|
var createGamma = /* @__PURE__ */ factory(name260, dependencies260, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
multiplyScalar: multiplyScalar2,
|
|
pow: pow3,
|
|
BigNumber: _BigNumber,
|
|
Complex: Complex3
|
|
} = _ref;
|
|
function gammaComplex(n) {
|
|
if (n.im === 0) {
|
|
return gammaNumber(n.re);
|
|
}
|
|
if (n.re < 0.5) {
|
|
var _t = new Complex3(1 - n.re, -n.im);
|
|
var r = new Complex3(Math.PI * n.re, Math.PI * n.im);
|
|
return new Complex3(Math.PI).div(r.sin()).div(gammaComplex(_t));
|
|
}
|
|
n = new Complex3(n.re - 1, n.im);
|
|
var x = new Complex3(gammaP[0], 0);
|
|
for (var i2 = 1; i2 < gammaP.length; ++i2) {
|
|
var gammaPval = new Complex3(gammaP[i2], 0);
|
|
x = x.add(gammaPval.div(n.add(i2)));
|
|
}
|
|
var t = new Complex3(n.re + gammaG + 0.5, n.im);
|
|
var twoPiSqrt = Math.sqrt(2 * Math.PI);
|
|
var tpow = t.pow(n.add(0.5));
|
|
var expt = t.neg().exp();
|
|
return x.mul(twoPiSqrt).mul(tpow).mul(expt);
|
|
}
|
|
return typed2(name260, {
|
|
number: gammaNumber,
|
|
Complex: gammaComplex,
|
|
BigNumber: function BigNumber2(n) {
|
|
if (n.isInteger()) {
|
|
return n.isNegative() || n.isZero() ? new _BigNumber(Infinity) : bigFactorial(n.minus(1));
|
|
}
|
|
if (!n.isFinite()) {
|
|
return new _BigNumber(n.isNegative() ? NaN : Infinity);
|
|
}
|
|
throw new Error("Integer BigNumber expected");
|
|
}
|
|
});
|
|
function bigFactorial(n) {
|
|
if (n < 8) {
|
|
return new _BigNumber([1, 1, 2, 6, 24, 120, 720, 5040][n]);
|
|
}
|
|
var precision = config4.precision + (Math.log(n.toNumber()) | 0);
|
|
var Big = _BigNumber.clone({
|
|
precision
|
|
});
|
|
if (n % 2 === 1) {
|
|
return n.times(bigFactorial(new _BigNumber(n - 1)));
|
|
}
|
|
var p = n;
|
|
var prod2 = new Big(n);
|
|
var sum3 = n.toNumber();
|
|
while (p > 2) {
|
|
p -= 2;
|
|
sum3 += p;
|
|
prod2 = prod2.times(sum3);
|
|
}
|
|
return new _BigNumber(prod2.toPrecision(_BigNumber.precision));
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/probability/lgamma.js
|
|
var name261 = "lgamma";
|
|
var dependencies261 = ["Complex", "typed"];
|
|
var createLgamma = /* @__PURE__ */ factory(name261, dependencies261, (_ref) => {
|
|
var {
|
|
Complex: Complex3,
|
|
typed: typed2
|
|
} = _ref;
|
|
var SMALL_RE = 7;
|
|
var SMALL_IM = 7;
|
|
var coeffs = [-0.029550653594771242, 0.00641025641025641, -0.0019175269175269176, 8417508417508417e-19, -5952380952380953e-19, 7936507936507937e-19, -0.002777777777777778, 0.08333333333333333];
|
|
return typed2(name261, {
|
|
number: lgammaNumber,
|
|
Complex: lgammaComplex,
|
|
BigNumber: function BigNumber2() {
|
|
throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber");
|
|
}
|
|
});
|
|
function lgammaComplex(n) {
|
|
var TWOPI = 6.283185307179586;
|
|
var LOGPI = 1.1447298858494002;
|
|
var REFLECTION = 0.1;
|
|
if (n.isNaN()) {
|
|
return new Complex3(NaN, NaN);
|
|
} else if (n.im === 0) {
|
|
return new Complex3(lgammaNumber(n.re), 0);
|
|
} else if (n.re >= SMALL_RE || Math.abs(n.im) >= SMALL_IM) {
|
|
return lgammaStirling(n);
|
|
} else if (n.re <= REFLECTION) {
|
|
var tmp = copysign(TWOPI, n.im) * Math.floor(0.5 * n.re + 0.25);
|
|
var a = n.mul(Math.PI).sin().log();
|
|
var b = lgammaComplex(new Complex3(1 - n.re, -n.im));
|
|
return new Complex3(LOGPI, tmp).sub(a).sub(b);
|
|
} else if (n.im >= 0) {
|
|
return lgammaRecurrence(n);
|
|
} else {
|
|
return lgammaRecurrence(n.conjugate()).conjugate();
|
|
}
|
|
}
|
|
function lgammaStirling(z) {
|
|
var leftPart = z.sub(0.5).mul(z.log()).sub(z).add(lnSqrt2PI);
|
|
var rz = new Complex3(1, 0).div(z);
|
|
var rzz = rz.div(z);
|
|
var a = coeffs[0];
|
|
var b = coeffs[1];
|
|
var r = 2 * rzz.re;
|
|
var s = rzz.re * rzz.re + rzz.im * rzz.im;
|
|
for (var i2 = 2; i2 < 8; i2++) {
|
|
var tmp = b;
|
|
b = -s * a + coeffs[i2];
|
|
a = r * a + tmp;
|
|
}
|
|
var rightPart = rz.mul(rzz.mul(a).add(b));
|
|
return leftPart.add(rightPart);
|
|
}
|
|
function lgammaRecurrence(z) {
|
|
var signflips = 0;
|
|
var sb = 0;
|
|
var shiftprod = z;
|
|
z = z.add(1);
|
|
while (z.re <= SMALL_RE) {
|
|
shiftprod = shiftprod.mul(z);
|
|
var nsb = shiftprod.im < 0 ? 1 : 0;
|
|
if (nsb !== 0 && sb === 0)
|
|
signflips++;
|
|
sb = nsb;
|
|
z = z.add(1);
|
|
}
|
|
return lgammaStirling(z).sub(shiftprod.log()).sub(new Complex3(0, signflips * 2 * Math.PI * 1));
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/probability/factorial.js
|
|
var name262 = "factorial";
|
|
var dependencies262 = ["typed", "gamma"];
|
|
var createFactorial = /* @__PURE__ */ factory(name262, dependencies262, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
gamma: gamma2
|
|
} = _ref;
|
|
return typed2(name262, {
|
|
number: function number2(n) {
|
|
if (n < 0) {
|
|
throw new Error("Value must be non-negative");
|
|
}
|
|
return gamma2(n + 1);
|
|
},
|
|
BigNumber: function BigNumber2(n) {
|
|
if (n.isNegative()) {
|
|
throw new Error("Value must be non-negative");
|
|
}
|
|
return gamma2(n.plus(1));
|
|
},
|
|
"Array | Matrix": typed2.referToSelf((self2) => (n) => deepMap(n, self2))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/probability/kldivergence.js
|
|
var name263 = "kldivergence";
|
|
var dependencies263 = ["typed", "matrix", "divide", "sum", "multiply", "map", "dotDivide", "log", "isNumeric"];
|
|
var createKldivergence = /* @__PURE__ */ factory(name263, dependencies263, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
divide: divide3,
|
|
sum: sum3,
|
|
multiply: multiply2,
|
|
map: map3,
|
|
dotDivide: dotDivide2,
|
|
log: log4,
|
|
isNumeric: isNumeric2
|
|
} = _ref;
|
|
return typed2(name263, {
|
|
"Array, Array": function ArrayArray(q, p) {
|
|
return _kldiv(matrix2(q), matrix2(p));
|
|
},
|
|
"Matrix, Array": function MatrixArray(q, p) {
|
|
return _kldiv(q, matrix2(p));
|
|
},
|
|
"Array, Matrix": function ArrayMatrix(q, p) {
|
|
return _kldiv(matrix2(q), p);
|
|
},
|
|
"Matrix, Matrix": function MatrixMatrix(q, p) {
|
|
return _kldiv(q, p);
|
|
}
|
|
});
|
|
function _kldiv(q, p) {
|
|
var plength = p.size().length;
|
|
var qlength = q.size().length;
|
|
if (plength > 1) {
|
|
throw new Error("first object must be one dimensional");
|
|
}
|
|
if (qlength > 1) {
|
|
throw new Error("second object must be one dimensional");
|
|
}
|
|
if (plength !== qlength) {
|
|
throw new Error("Length of two vectors must be equal");
|
|
}
|
|
var sumq = sum3(q);
|
|
if (sumq === 0) {
|
|
throw new Error("Sum of elements in first object must be non zero");
|
|
}
|
|
var sump = sum3(p);
|
|
if (sump === 0) {
|
|
throw new Error("Sum of elements in second object must be non zero");
|
|
}
|
|
var qnorm = divide3(q, sum3(q));
|
|
var pnorm = divide3(p, sum3(p));
|
|
var result = sum3(multiply2(qnorm, map3(dotDivide2(qnorm, pnorm), (x) => log4(x))));
|
|
if (isNumeric2(result)) {
|
|
return result;
|
|
} else {
|
|
return Number.NaN;
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/probability/multinomial.js
|
|
var name264 = "multinomial";
|
|
var dependencies264 = ["typed", "add", "divide", "multiply", "factorial", "isInteger", "isPositive"];
|
|
var createMultinomial = /* @__PURE__ */ factory(name264, dependencies264, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
add: add3,
|
|
divide: divide3,
|
|
multiply: multiply2,
|
|
factorial: factorial2,
|
|
isInteger: isInteger3,
|
|
isPositive: isPositive2
|
|
} = _ref;
|
|
return typed2(name264, {
|
|
"Array | Matrix": function ArrayMatrix(a) {
|
|
var sum3 = 0;
|
|
var denom = 1;
|
|
deepForEach(a, function(ai) {
|
|
if (!isInteger3(ai) || !isPositive2(ai)) {
|
|
throw new TypeError("Positive integer value expected in function multinomial");
|
|
}
|
|
sum3 = add3(sum3, ai);
|
|
denom = multiply2(denom, factorial2(ai));
|
|
});
|
|
return divide3(factorial2(sum3), denom);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/probability/permutations.js
|
|
var name265 = "permutations";
|
|
var dependencies265 = ["typed", "factorial"];
|
|
var createPermutations = /* @__PURE__ */ factory(name265, dependencies265, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
factorial: factorial2
|
|
} = _ref;
|
|
return typed2(name265, {
|
|
"number | BigNumber": factorial2,
|
|
"number, number": function numberNumber(n, k) {
|
|
if (!isInteger(n) || n < 0) {
|
|
throw new TypeError("Positive integer value expected in function permutations");
|
|
}
|
|
if (!isInteger(k) || k < 0) {
|
|
throw new TypeError("Positive integer value expected in function permutations");
|
|
}
|
|
if (k > n) {
|
|
throw new TypeError("second argument k must be less than or equal to first argument n");
|
|
}
|
|
return product2(n - k + 1, n);
|
|
},
|
|
"BigNumber, BigNumber": function BigNumberBigNumber(n, k) {
|
|
var result, i2;
|
|
if (!isPositiveInteger3(n) || !isPositiveInteger3(k)) {
|
|
throw new TypeError("Positive integer value expected in function permutations");
|
|
}
|
|
if (k.gt(n)) {
|
|
throw new TypeError("second argument k must be less than or equal to first argument n");
|
|
}
|
|
var one = n.mul(0).add(1);
|
|
result = one;
|
|
for (i2 = n.minus(k).plus(1); i2.lte(n); i2 = i2.plus(1)) {
|
|
result = result.times(i2);
|
|
}
|
|
return result;
|
|
}
|
|
});
|
|
});
|
|
function isPositiveInteger3(n) {
|
|
return n.isInteger() && n.gte(0);
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/probability/util/seededRNG.js
|
|
var import_seedrandom = __toESM(require_seedrandom2(), 1);
|
|
var singletonRandom = /* @__PURE__ */ (0, import_seedrandom.default)(Date.now());
|
|
function createRng(randomSeed) {
|
|
var random3;
|
|
function setSeed(seed) {
|
|
random3 = seed === null ? singletonRandom : (0, import_seedrandom.default)(String(seed));
|
|
}
|
|
setSeed(randomSeed);
|
|
function rng() {
|
|
return random3();
|
|
}
|
|
return rng;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/probability/pickRandom.js
|
|
var name266 = "pickRandom";
|
|
var dependencies266 = ["typed", "config", "?on"];
|
|
var createPickRandom = /* @__PURE__ */ factory(name266, dependencies266, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
on
|
|
} = _ref;
|
|
var rng = createRng(config4.randomSeed);
|
|
if (on) {
|
|
on("config", function(curr, prev) {
|
|
if (curr.randomSeed !== prev.randomSeed) {
|
|
rng = createRng(curr.randomSeed);
|
|
}
|
|
});
|
|
}
|
|
return typed2(name266, {
|
|
"Array | Matrix": function ArrayMatrix(possibles) {
|
|
return _pickRandom(possibles, {});
|
|
},
|
|
"Array | Matrix, Object": function ArrayMatrixObject(possibles, options) {
|
|
return _pickRandom(possibles, options);
|
|
},
|
|
"Array | Matrix, number": function ArrayMatrixNumber(possibles, number2) {
|
|
return _pickRandom(possibles, {
|
|
number: number2
|
|
});
|
|
},
|
|
"Array | Matrix, Array | Matrix": function ArrayMatrixArrayMatrix(possibles, weights) {
|
|
return _pickRandom(possibles, {
|
|
weights
|
|
});
|
|
},
|
|
"Array | Matrix, Array | Matrix, number": function ArrayMatrixArrayMatrixNumber(possibles, weights, number2) {
|
|
return _pickRandom(possibles, {
|
|
number: number2,
|
|
weights
|
|
});
|
|
},
|
|
"Array | Matrix, number, Array | Matrix": function ArrayMatrixNumberArrayMatrix(possibles, number2, weights) {
|
|
return _pickRandom(possibles, {
|
|
number: number2,
|
|
weights
|
|
});
|
|
}
|
|
});
|
|
function _pickRandom(possibles, _ref2) {
|
|
var {
|
|
number: number2,
|
|
weights,
|
|
elementWise = true
|
|
} = _ref2;
|
|
var single = typeof number2 === "undefined";
|
|
if (single) {
|
|
number2 = 1;
|
|
}
|
|
var createMatrix2 = isMatrix(possibles) ? possibles.create : isMatrix(weights) ? weights.create : null;
|
|
possibles = possibles.valueOf();
|
|
if (weights) {
|
|
weights = weights.valueOf();
|
|
}
|
|
if (elementWise === true) {
|
|
possibles = flatten(possibles);
|
|
weights = flatten(weights);
|
|
}
|
|
var totalWeights = 0;
|
|
if (typeof weights !== "undefined") {
|
|
if (weights.length !== possibles.length) {
|
|
throw new Error("Weights must have the same length as possibles");
|
|
}
|
|
for (var i2 = 0, len = weights.length; i2 < len; i2++) {
|
|
if (!isNumber(weights[i2]) || weights[i2] < 0) {
|
|
throw new Error("Weights must be an array of positive numbers");
|
|
}
|
|
totalWeights += weights[i2];
|
|
}
|
|
}
|
|
var length = possibles.length;
|
|
var result = [];
|
|
var pick;
|
|
while (result.length < number2) {
|
|
if (typeof weights === "undefined") {
|
|
pick = possibles[Math.floor(rng() * length)];
|
|
} else {
|
|
var randKey = rng() * totalWeights;
|
|
for (var _i = 0, _len = possibles.length; _i < _len; _i++) {
|
|
randKey -= weights[_i];
|
|
if (randKey < 0) {
|
|
pick = possibles[_i];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
result.push(pick);
|
|
}
|
|
return single ? result[0] : createMatrix2 ? createMatrix2(result) : result;
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/probability/util/randomMatrix.js
|
|
function randomMatrix(size2, random3) {
|
|
var data = [];
|
|
size2 = size2.slice(0);
|
|
if (size2.length > 1) {
|
|
for (var i2 = 0, length = size2.shift(); i2 < length; i2++) {
|
|
data.push(randomMatrix(size2, random3));
|
|
}
|
|
} else {
|
|
for (var _i = 0, _length = size2.shift(); _i < _length; _i++) {
|
|
data.push(random3());
|
|
}
|
|
}
|
|
return data;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/probability/random.js
|
|
var name267 = "random";
|
|
var dependencies267 = ["typed", "config", "?on"];
|
|
var createRandom = /* @__PURE__ */ factory(name267, dependencies267, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
on
|
|
} = _ref;
|
|
var rng = createRng(config4.randomSeed);
|
|
if (on) {
|
|
on("config", function(curr, prev) {
|
|
if (curr.randomSeed !== prev.randomSeed) {
|
|
rng = createRng(curr.randomSeed);
|
|
}
|
|
});
|
|
}
|
|
return typed2(name267, {
|
|
"": () => _random(0, 1),
|
|
number: (max3) => _random(0, max3),
|
|
"number, number": (min3, max3) => _random(min3, max3),
|
|
"Array | Matrix": (size2) => _randomMatrix(size2, 0, 1),
|
|
"Array | Matrix, number": (size2, max3) => _randomMatrix(size2, 0, max3),
|
|
"Array | Matrix, number, number": (size2, min3, max3) => _randomMatrix(size2, min3, max3)
|
|
});
|
|
function _randomMatrix(size2, min3, max3) {
|
|
var res = randomMatrix(size2.valueOf(), () => _random(min3, max3));
|
|
return isMatrix(size2) ? size2.create(res) : res;
|
|
}
|
|
function _random(min3, max3) {
|
|
return min3 + rng() * (max3 - min3);
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/probability/randomInt.js
|
|
var name268 = "randomInt";
|
|
var dependencies268 = ["typed", "config", "?on"];
|
|
var createRandomInt = /* @__PURE__ */ factory(name268, dependencies268, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
on
|
|
} = _ref;
|
|
var rng = createRng(config4.randomSeed);
|
|
if (on) {
|
|
on("config", function(curr, prev) {
|
|
if (curr.randomSeed !== prev.randomSeed) {
|
|
rng = createRng(curr.randomSeed);
|
|
}
|
|
});
|
|
}
|
|
return typed2(name268, {
|
|
"": () => _randomInt(0, 1),
|
|
number: (max3) => _randomInt(0, max3),
|
|
"number, number": (min3, max3) => _randomInt(min3, max3),
|
|
"Array | Matrix": (size2) => _randomIntMatrix(size2, 0, 1),
|
|
"Array | Matrix, number": (size2, max3) => _randomIntMatrix(size2, 0, max3),
|
|
"Array | Matrix, number, number": (size2, min3, max3) => _randomIntMatrix(size2, min3, max3)
|
|
});
|
|
function _randomIntMatrix(size2, min3, max3) {
|
|
var res = randomMatrix(size2.valueOf(), () => _randomInt(min3, max3));
|
|
return isMatrix(size2) ? size2.create(res) : res;
|
|
}
|
|
function _randomInt(min3, max3) {
|
|
return Math.floor(min3 + rng() * (max3 - min3));
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/combinatorics/stirlingS2.js
|
|
var name269 = "stirlingS2";
|
|
var dependencies269 = ["typed", "addScalar", "subtract", "multiplyScalar", "divideScalar", "pow", "factorial", "combinations", "isNegative", "isInteger", "number", "?bignumber", "larger"];
|
|
var createStirlingS2 = /* @__PURE__ */ factory(name269, dependencies269, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
addScalar: addScalar2,
|
|
subtract: subtract2,
|
|
multiplyScalar: multiplyScalar2,
|
|
divideScalar: divideScalar2,
|
|
pow: pow3,
|
|
factorial: factorial2,
|
|
combinations: combinations2,
|
|
isNegative: isNegative2,
|
|
isInteger: isInteger3,
|
|
number: number2,
|
|
bignumber: bignumber2,
|
|
larger: larger2
|
|
} = _ref;
|
|
var smallCache = [];
|
|
var bigCache = [];
|
|
return typed2(name269, {
|
|
"number | BigNumber, number | BigNumber": function numberBigNumberNumberBigNumber(n, k) {
|
|
if (!isInteger3(n) || isNegative2(n) || !isInteger3(k) || isNegative2(k)) {
|
|
throw new TypeError("Non-negative integer value expected in function stirlingS2");
|
|
} else if (larger2(k, n)) {
|
|
throw new TypeError("k must be less than or equal to n in function stirlingS2");
|
|
}
|
|
var big = !(isNumber(n) && isNumber(k));
|
|
var cache = big ? bigCache : smallCache;
|
|
var make = big ? bignumber2 : number2;
|
|
var nn = number2(n);
|
|
var nk = number2(k);
|
|
if (cache[nn] && cache[nn].length > nk) {
|
|
return cache[nn][nk];
|
|
}
|
|
for (var m = 0; m <= nn; ++m) {
|
|
if (!cache[m]) {
|
|
cache[m] = [m === 0 ? make(1) : make(0)];
|
|
}
|
|
if (m === 0)
|
|
continue;
|
|
var row2 = cache[m];
|
|
var prev = cache[m - 1];
|
|
for (var i2 = row2.length; i2 <= m && i2 <= nk; ++i2) {
|
|
if (i2 === m) {
|
|
row2[i2] = 1;
|
|
} else {
|
|
row2[i2] = addScalar2(multiplyScalar2(make(i2), prev[i2]), prev[i2 - 1]);
|
|
}
|
|
}
|
|
}
|
|
return cache[nn][nk];
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/combinatorics/bellNumbers.js
|
|
var name270 = "bellNumbers";
|
|
var dependencies270 = ["typed", "addScalar", "isNegative", "isInteger", "stirlingS2"];
|
|
var createBellNumbers = /* @__PURE__ */ factory(name270, dependencies270, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
addScalar: addScalar2,
|
|
isNegative: isNegative2,
|
|
isInteger: isInteger3,
|
|
stirlingS2: stirlingS22
|
|
} = _ref;
|
|
return typed2(name270, {
|
|
"number | BigNumber": function numberBigNumber(n) {
|
|
if (!isInteger3(n) || isNegative2(n)) {
|
|
throw new TypeError("Non-negative integer value expected in function bellNumbers");
|
|
}
|
|
var result = 0;
|
|
for (var i2 = 0; i2 <= n; i2++) {
|
|
result = addScalar2(result, stirlingS22(n, i2));
|
|
}
|
|
return result;
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/combinatorics/catalan.js
|
|
var name271 = "catalan";
|
|
var dependencies271 = ["typed", "addScalar", "divideScalar", "multiplyScalar", "combinations", "isNegative", "isInteger"];
|
|
var createCatalan = /* @__PURE__ */ factory(name271, dependencies271, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
addScalar: addScalar2,
|
|
divideScalar: divideScalar2,
|
|
multiplyScalar: multiplyScalar2,
|
|
combinations: combinations2,
|
|
isNegative: isNegative2,
|
|
isInteger: isInteger3
|
|
} = _ref;
|
|
return typed2(name271, {
|
|
"number | BigNumber": function numberBigNumber(n) {
|
|
if (!isInteger3(n) || isNegative2(n)) {
|
|
throw new TypeError("Non-negative integer value expected in function catalan");
|
|
}
|
|
return divideScalar2(combinations2(multiplyScalar2(n, 2), n), addScalar2(n, 1));
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/combinatorics/composition.js
|
|
var name272 = "composition";
|
|
var dependencies272 = ["typed", "addScalar", "combinations", "isNegative", "isPositive", "isInteger", "larger"];
|
|
var createComposition = /* @__PURE__ */ factory(name272, dependencies272, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
addScalar: addScalar2,
|
|
combinations: combinations2,
|
|
isPositive: isPositive2,
|
|
isNegative: isNegative2,
|
|
isInteger: isInteger3,
|
|
larger: larger2
|
|
} = _ref;
|
|
return typed2(name272, {
|
|
"number | BigNumber, number | BigNumber": function numberBigNumberNumberBigNumber(n, k) {
|
|
if (!isInteger3(n) || !isPositive2(n) || !isInteger3(k) || !isPositive2(k)) {
|
|
throw new TypeError("Positive integer value expected in function composition");
|
|
} else if (larger2(k, n)) {
|
|
throw new TypeError("k must be less than or equal to n in function composition");
|
|
}
|
|
return combinations2(addScalar2(n, -1), addScalar2(k, -1));
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/leafCount.js
|
|
var name273 = "leafCount";
|
|
var dependencies273 = ["parse", "typed"];
|
|
var createLeafCount = /* @__PURE__ */ factory(name273, dependencies273, (_ref) => {
|
|
var {
|
|
parse: parse2,
|
|
typed: typed2
|
|
} = _ref;
|
|
function countLeaves(node) {
|
|
var count2 = 0;
|
|
node.forEach((n) => {
|
|
count2 += countLeaves(n);
|
|
});
|
|
return count2 || 1;
|
|
}
|
|
return typed2(name273, {
|
|
Node: function Node2(expr) {
|
|
return countLeaves(expr);
|
|
}
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/simplify/wildcards.js
|
|
function isNumericNode(x) {
|
|
return isConstantNode(x) || isOperatorNode(x) && x.isUnary() && isConstantNode(x.args[0]);
|
|
}
|
|
function isConstantExpression(x) {
|
|
if (isConstantNode(x)) {
|
|
return true;
|
|
}
|
|
if ((isFunctionNode(x) || isOperatorNode(x)) && x.args.every(isConstantExpression)) {
|
|
return true;
|
|
}
|
|
if (isParenthesisNode(x) && isConstantExpression(x.content)) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/simplify/util.js
|
|
function ownKeys2(object, enumerableOnly) {
|
|
var keys = Object.keys(object);
|
|
if (Object.getOwnPropertySymbols) {
|
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
})), keys.push.apply(keys, symbols);
|
|
}
|
|
return keys;
|
|
}
|
|
function _objectSpread2(target) {
|
|
for (var i2 = 1; i2 < arguments.length; i2++) {
|
|
var source = arguments[i2] != null ? arguments[i2] : {};
|
|
i2 % 2 ? ownKeys2(Object(source), true).forEach(function(key) {
|
|
_defineProperty(target, key, source[key]);
|
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys2(Object(source)).forEach(function(key) {
|
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
});
|
|
}
|
|
return target;
|
|
}
|
|
var name274 = "simplifyUtil";
|
|
var dependencies274 = ["FunctionNode", "OperatorNode", "SymbolNode"];
|
|
var createUtil = /* @__PURE__ */ factory(name274, dependencies274, (_ref) => {
|
|
var {
|
|
FunctionNode: FunctionNode2,
|
|
OperatorNode: OperatorNode2,
|
|
SymbolNode: SymbolNode2
|
|
} = _ref;
|
|
var T = true;
|
|
var F = false;
|
|
var defaultName = "defaultF";
|
|
var defaultContext = {
|
|
add: {
|
|
trivial: T,
|
|
total: T,
|
|
commutative: T,
|
|
associative: T
|
|
},
|
|
unaryPlus: {
|
|
trivial: T,
|
|
total: T,
|
|
commutative: T,
|
|
associative: T
|
|
},
|
|
subtract: {
|
|
trivial: F,
|
|
total: T,
|
|
commutative: F,
|
|
associative: F
|
|
},
|
|
multiply: {
|
|
trivial: T,
|
|
total: T,
|
|
commutative: T,
|
|
associative: T
|
|
},
|
|
divide: {
|
|
trivial: F,
|
|
total: T,
|
|
commutative: F,
|
|
associative: F
|
|
},
|
|
paren: {
|
|
trivial: T,
|
|
total: T,
|
|
commutative: T,
|
|
associative: F
|
|
},
|
|
defaultF: {
|
|
trivial: F,
|
|
total: T,
|
|
commutative: F,
|
|
associative: F
|
|
}
|
|
};
|
|
var realContext = {
|
|
divide: {
|
|
total: F
|
|
},
|
|
log: {
|
|
total: F
|
|
}
|
|
};
|
|
var positiveContext = {
|
|
subtract: {
|
|
total: F
|
|
},
|
|
abs: {
|
|
trivial: T
|
|
},
|
|
log: {
|
|
total: T
|
|
}
|
|
};
|
|
function hasProperty(nodeOrName, property) {
|
|
var context = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : defaultContext;
|
|
var name302 = defaultName;
|
|
if (typeof nodeOrName === "string") {
|
|
name302 = nodeOrName;
|
|
} else if (isOperatorNode(nodeOrName)) {
|
|
name302 = nodeOrName.fn.toString();
|
|
} else if (isFunctionNode(nodeOrName)) {
|
|
name302 = nodeOrName.name;
|
|
} else if (isParenthesisNode(nodeOrName)) {
|
|
name302 = "paren";
|
|
}
|
|
if (hasOwnProperty2(context, name302)) {
|
|
var properties2 = context[name302];
|
|
if (hasOwnProperty2(properties2, property)) {
|
|
return properties2[property];
|
|
}
|
|
if (hasOwnProperty2(defaultContext, name302)) {
|
|
return defaultContext[name302][property];
|
|
}
|
|
}
|
|
if (hasOwnProperty2(context, defaultName)) {
|
|
var _properties = context[defaultName];
|
|
if (hasOwnProperty2(_properties, property)) {
|
|
return _properties[property];
|
|
}
|
|
return defaultContext[defaultName][property];
|
|
}
|
|
if (hasOwnProperty2(defaultContext, name302)) {
|
|
var _properties2 = defaultContext[name302];
|
|
if (hasOwnProperty2(_properties2, property)) {
|
|
return _properties2[property];
|
|
}
|
|
}
|
|
return defaultContext[defaultName][property];
|
|
}
|
|
function isCommutative(node) {
|
|
var context = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultContext;
|
|
return hasProperty(node, "commutative", context);
|
|
}
|
|
function isAssociative(node) {
|
|
var context = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultContext;
|
|
return hasProperty(node, "associative", context);
|
|
}
|
|
function mergeContext(primary, secondary) {
|
|
var merged = _objectSpread2({}, primary);
|
|
for (var prop in secondary) {
|
|
if (hasOwnProperty2(primary, prop)) {
|
|
merged[prop] = _objectSpread2(_objectSpread2({}, secondary[prop]), primary[prop]);
|
|
} else {
|
|
merged[prop] = secondary[prop];
|
|
}
|
|
}
|
|
return merged;
|
|
}
|
|
function flatten3(node, context) {
|
|
if (!node.args || node.args.length === 0) {
|
|
return node;
|
|
}
|
|
node.args = allChildren(node, context);
|
|
for (var i2 = 0; i2 < node.args.length; i2++) {
|
|
flatten3(node.args[i2], context);
|
|
}
|
|
}
|
|
function allChildren(node, context) {
|
|
var op;
|
|
var children = [];
|
|
var findChildren = function findChildren2(node2) {
|
|
for (var i2 = 0; i2 < node2.args.length; i2++) {
|
|
var child = node2.args[i2];
|
|
if (isOperatorNode(child) && op === child.op) {
|
|
findChildren2(child);
|
|
} else {
|
|
children.push(child);
|
|
}
|
|
}
|
|
};
|
|
if (isAssociative(node, context)) {
|
|
op = node.op;
|
|
findChildren(node);
|
|
return children;
|
|
} else {
|
|
return node.args;
|
|
}
|
|
}
|
|
function unflattenr(node, context) {
|
|
if (!node.args || node.args.length === 0) {
|
|
return;
|
|
}
|
|
var makeNode = createMakeNodeFunction(node);
|
|
var l = node.args.length;
|
|
for (var i2 = 0; i2 < l; i2++) {
|
|
unflattenr(node.args[i2], context);
|
|
}
|
|
if (l > 2 && isAssociative(node, context)) {
|
|
var curnode = node.args.pop();
|
|
while (node.args.length > 0) {
|
|
curnode = makeNode([node.args.pop(), curnode]);
|
|
}
|
|
node.args = curnode.args;
|
|
}
|
|
}
|
|
function unflattenl(node, context) {
|
|
if (!node.args || node.args.length === 0) {
|
|
return;
|
|
}
|
|
var makeNode = createMakeNodeFunction(node);
|
|
var l = node.args.length;
|
|
for (var i2 = 0; i2 < l; i2++) {
|
|
unflattenl(node.args[i2], context);
|
|
}
|
|
if (l > 2 && isAssociative(node, context)) {
|
|
var curnode = node.args.shift();
|
|
while (node.args.length > 0) {
|
|
curnode = makeNode([curnode, node.args.shift()]);
|
|
}
|
|
node.args = curnode.args;
|
|
}
|
|
}
|
|
function createMakeNodeFunction(node) {
|
|
if (isOperatorNode(node)) {
|
|
return function(args) {
|
|
try {
|
|
return new OperatorNode2(node.op, node.fn, args, node.implicit);
|
|
} catch (err) {
|
|
console.error(err);
|
|
return [];
|
|
}
|
|
};
|
|
} else {
|
|
return function(args) {
|
|
return new FunctionNode2(new SymbolNode2(node.name), args);
|
|
};
|
|
}
|
|
}
|
|
return {
|
|
createMakeNodeFunction,
|
|
hasProperty,
|
|
isCommutative,
|
|
isAssociative,
|
|
mergeContext,
|
|
flatten: flatten3,
|
|
allChildren,
|
|
unflattenr,
|
|
unflattenl,
|
|
defaultContext,
|
|
realContext,
|
|
positiveContext
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/simplify.js
|
|
var name275 = "simplify";
|
|
var dependencies275 = ["config", "typed", "parse", "add", "subtract", "multiply", "divide", "pow", "isZero", "equal", "resolve", "simplifyConstant", "simplifyCore", "?fraction", "?bignumber", "mathWithTransform", "matrix", "AccessorNode", "ArrayNode", "ConstantNode", "FunctionNode", "IndexNode", "ObjectNode", "OperatorNode", "ParenthesisNode", "SymbolNode"];
|
|
var createSimplify = /* @__PURE__ */ factory(name275, dependencies275, (_ref) => {
|
|
var {
|
|
config: config4,
|
|
typed: typed2,
|
|
parse: parse2,
|
|
add: add3,
|
|
subtract: subtract2,
|
|
multiply: multiply2,
|
|
divide: divide3,
|
|
pow: pow3,
|
|
isZero: isZero2,
|
|
equal: equal2,
|
|
resolve: resolve2,
|
|
simplifyConstant: simplifyConstant2,
|
|
simplifyCore: simplifyCore2,
|
|
fraction: fraction2,
|
|
bignumber: bignumber2,
|
|
mathWithTransform: mathWithTransform2,
|
|
matrix: matrix2,
|
|
AccessorNode: AccessorNode2,
|
|
ArrayNode: ArrayNode2,
|
|
ConstantNode: ConstantNode2,
|
|
FunctionNode: FunctionNode2,
|
|
IndexNode: IndexNode2,
|
|
ObjectNode: ObjectNode2,
|
|
OperatorNode: OperatorNode2,
|
|
ParenthesisNode: ParenthesisNode2,
|
|
SymbolNode: SymbolNode2
|
|
} = _ref;
|
|
var {
|
|
hasProperty,
|
|
isCommutative,
|
|
isAssociative,
|
|
mergeContext,
|
|
flatten: flatten3,
|
|
unflattenr,
|
|
unflattenl,
|
|
createMakeNodeFunction,
|
|
defaultContext,
|
|
realContext,
|
|
positiveContext
|
|
} = createUtil({
|
|
FunctionNode: FunctionNode2,
|
|
OperatorNode: OperatorNode2,
|
|
SymbolNode: SymbolNode2
|
|
});
|
|
typed2.addConversion({
|
|
from: "Object",
|
|
to: "Map",
|
|
convert: createMap
|
|
});
|
|
var simplify2 = typed2("simplify", {
|
|
Node: _simplify,
|
|
"Node, Map": (expr, scope) => _simplify(expr, false, scope),
|
|
"Node, Map, Object": (expr, scope, options) => _simplify(expr, false, scope, options),
|
|
"Node, Array": _simplify,
|
|
"Node, Array, Map": _simplify,
|
|
"Node, Array, Map, Object": _simplify
|
|
});
|
|
typed2.removeConversion({
|
|
from: "Object",
|
|
to: "Map",
|
|
convert: createMap
|
|
});
|
|
simplify2.defaultContext = defaultContext;
|
|
simplify2.realContext = realContext;
|
|
simplify2.positiveContext = positiveContext;
|
|
function removeParens(node) {
|
|
return node.transform(function(node2, path, parent) {
|
|
return isParenthesisNode(node2) ? removeParens(node2.content) : node2;
|
|
});
|
|
}
|
|
var SUPPORTED_CONSTANTS = {
|
|
true: true,
|
|
false: true,
|
|
e: true,
|
|
i: true,
|
|
Infinity: true,
|
|
LN2: true,
|
|
LN10: true,
|
|
LOG2E: true,
|
|
LOG10E: true,
|
|
NaN: true,
|
|
phi: true,
|
|
pi: true,
|
|
SQRT1_2: true,
|
|
SQRT2: true,
|
|
tau: true
|
|
};
|
|
simplify2.rules = [
|
|
simplifyCore2,
|
|
{
|
|
l: "log(e)",
|
|
r: "1"
|
|
},
|
|
{
|
|
s: "n-n1 -> n+-n1",
|
|
assuming: {
|
|
subtract: {
|
|
total: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "n-n -> 0",
|
|
assuming: {
|
|
subtract: {
|
|
total: false
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "-(cl*v) -> v * (-cl)",
|
|
assuming: {
|
|
multiply: {
|
|
commutative: true
|
|
},
|
|
subtract: {
|
|
total: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "-(cl*v) -> (-cl) * v",
|
|
assuming: {
|
|
multiply: {
|
|
commutative: false
|
|
},
|
|
subtract: {
|
|
total: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "-(v*cl) -> v * (-cl)",
|
|
assuming: {
|
|
multiply: {
|
|
commutative: false
|
|
},
|
|
subtract: {
|
|
total: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
l: "-(n1/n2)",
|
|
r: "-n1/n2"
|
|
},
|
|
{
|
|
l: "-v",
|
|
r: "v * (-1)"
|
|
},
|
|
{
|
|
l: "(n1 + n2)*(-1)",
|
|
r: "n1*(-1) + n2*(-1)",
|
|
repeat: true
|
|
},
|
|
{
|
|
l: "n/n1^n2",
|
|
r: "n*n1^-n2"
|
|
},
|
|
{
|
|
l: "n/n1",
|
|
r: "n*n1^-1"
|
|
},
|
|
{
|
|
s: "(n1*n2)^n3 -> n1^n3 * n2^n3",
|
|
assuming: {
|
|
multiply: {
|
|
commutative: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "(n1*n2)^(-1) -> n2^(-1) * n1^(-1)",
|
|
assuming: {
|
|
multiply: {
|
|
commutative: false
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "(n ^ n1) ^ n2 -> n ^ (n1 * n2)",
|
|
assuming: {
|
|
divide: {
|
|
total: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
l: " vd * ( vd * n1 + n2)",
|
|
r: "vd^2 * n1 + vd * n2"
|
|
},
|
|
{
|
|
s: " vd * (vd^n4 * n1 + n2) -> vd^(1+n4) * n1 + vd * n2",
|
|
assuming: {
|
|
divide: {
|
|
total: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "vd^n3 * ( vd * n1 + n2) -> vd^(n3+1) * n1 + vd^n3 * n2",
|
|
assuming: {
|
|
divide: {
|
|
total: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "vd^n3 * (vd^n4 * n1 + n2) -> vd^(n3+n4) * n1 + vd^n3 * n2",
|
|
assuming: {
|
|
divide: {
|
|
total: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
l: "n*n",
|
|
r: "n^2"
|
|
},
|
|
{
|
|
s: "n * n^n1 -> n^(n1+1)",
|
|
assuming: {
|
|
divide: {
|
|
total: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "n^n1 * n^n2 -> n^(n1+n2)",
|
|
assuming: {
|
|
divide: {
|
|
total: true
|
|
}
|
|
}
|
|
},
|
|
simplifyConstant2,
|
|
{
|
|
s: "n+n -> 2*n",
|
|
assuming: {
|
|
add: {
|
|
total: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
l: "n+-n",
|
|
r: "0"
|
|
},
|
|
{
|
|
l: "vd*n + vd",
|
|
r: "vd*(n+1)"
|
|
},
|
|
{
|
|
l: "n3*n1 + n3*n2",
|
|
r: "n3*(n1+n2)"
|
|
},
|
|
{
|
|
l: "n3^(-n4)*n1 + n3 * n2",
|
|
r: "n3^(-n4)*(n1 + n3^(n4+1) *n2)"
|
|
},
|
|
{
|
|
l: "n3^(-n4)*n1 + n3^n5 * n2",
|
|
r: "n3^(-n4)*(n1 + n3^(n4+n5)*n2)"
|
|
},
|
|
{
|
|
s: "n*vd + vd -> (n+1)*vd",
|
|
assuming: {
|
|
multiply: {
|
|
commutative: false
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "vd + n*vd -> (1+n)*vd",
|
|
assuming: {
|
|
multiply: {
|
|
commutative: false
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "n1*n3 + n2*n3 -> (n1+n2)*n3",
|
|
assuming: {
|
|
multiply: {
|
|
commutative: false
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "n^n1 * n -> n^(n1+1)",
|
|
assuming: {
|
|
divide: {
|
|
total: true
|
|
},
|
|
multiply: {
|
|
commutative: false
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "n1*n3^(-n4) + n2 * n3 -> (n1 + n2*n3^(n4 + 1))*n3^(-n4)",
|
|
assuming: {
|
|
multiply: {
|
|
commutative: false
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "n1*n3^(-n4) + n2 * n3^n5 -> (n1 + n2*n3^(n4 + n5))*n3^(-n4)",
|
|
assuming: {
|
|
multiply: {
|
|
commutative: false
|
|
}
|
|
}
|
|
},
|
|
{
|
|
l: "n*cd + cd",
|
|
r: "(n+1)*cd"
|
|
},
|
|
{
|
|
s: "cd*n + cd -> cd*(n+1)",
|
|
assuming: {
|
|
multiply: {
|
|
commutative: false
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "cd + cd*n -> cd*(1+n)",
|
|
assuming: {
|
|
multiply: {
|
|
commutative: false
|
|
}
|
|
}
|
|
},
|
|
simplifyConstant2,
|
|
{
|
|
s: "(-n)*n1 -> -(n*n1)",
|
|
assuming: {
|
|
subtract: {
|
|
total: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "n1*(-n) -> -(n1*n)",
|
|
assuming: {
|
|
subtract: {
|
|
total: true
|
|
},
|
|
multiply: {
|
|
commutative: false
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "ce+ve -> ve+ce",
|
|
assuming: {
|
|
add: {
|
|
commutative: true
|
|
}
|
|
},
|
|
imposeContext: {
|
|
add: {
|
|
commutative: false
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "vd*cd -> cd*vd",
|
|
assuming: {
|
|
multiply: {
|
|
commutative: true
|
|
}
|
|
},
|
|
imposeContext: {
|
|
multiply: {
|
|
commutative: false
|
|
}
|
|
}
|
|
},
|
|
{
|
|
l: "n+-n1",
|
|
r: "n-n1"
|
|
},
|
|
{
|
|
s: "n*(n1^-1) -> n/n1",
|
|
assuming: {
|
|
multiply: {
|
|
commutative: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "n*n1^-n2 -> n/n1^n2",
|
|
assuming: {
|
|
multiply: {
|
|
commutative: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "n^-1 -> 1/n",
|
|
assuming: {
|
|
multiply: {
|
|
commutative: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
l: "n^1",
|
|
r: "n"
|
|
},
|
|
{
|
|
s: "n*(n1/n2) -> (n*n1)/n2",
|
|
assuming: {
|
|
multiply: {
|
|
associative: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "n-(n1+n2) -> n-n1-n2",
|
|
assuming: {
|
|
addition: {
|
|
associative: true,
|
|
commutative: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
l: "1*n",
|
|
r: "n",
|
|
imposeContext: {
|
|
multiply: {
|
|
commutative: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
s: "n1/(n2/n3) -> (n1*n3)/n2",
|
|
assuming: {
|
|
multiply: {
|
|
associative: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
l: "n1/(-n2)",
|
|
r: "-n1/n2"
|
|
}
|
|
];
|
|
function _canonicalizeRule(ruleObject, context) {
|
|
var newRule = {};
|
|
if (ruleObject.s) {
|
|
var lr = ruleObject.s.split("->");
|
|
if (lr.length === 2) {
|
|
newRule.l = lr[0];
|
|
newRule.r = lr[1];
|
|
} else {
|
|
throw SyntaxError("Could not parse rule: " + ruleObject.s);
|
|
}
|
|
} else {
|
|
newRule.l = ruleObject.l;
|
|
newRule.r = ruleObject.r;
|
|
}
|
|
newRule.l = removeParens(parse2(newRule.l));
|
|
newRule.r = removeParens(parse2(newRule.r));
|
|
for (var prop of ["imposeContext", "repeat", "assuming"]) {
|
|
if (prop in ruleObject) {
|
|
newRule[prop] = ruleObject[prop];
|
|
}
|
|
}
|
|
if (ruleObject.evaluate) {
|
|
newRule.evaluate = parse2(ruleObject.evaluate);
|
|
}
|
|
if (isAssociative(newRule.l, context)) {
|
|
var nonCommutative = !isCommutative(newRule.l, context);
|
|
var leftExpandsym;
|
|
if (nonCommutative)
|
|
leftExpandsym = _getExpandPlaceholderSymbol();
|
|
var makeNode = createMakeNodeFunction(newRule.l);
|
|
var expandsym = _getExpandPlaceholderSymbol();
|
|
newRule.expanded = {};
|
|
newRule.expanded.l = makeNode([newRule.l, expandsym]);
|
|
flatten3(newRule.expanded.l, context);
|
|
unflattenr(newRule.expanded.l, context);
|
|
newRule.expanded.r = makeNode([newRule.r, expandsym]);
|
|
if (nonCommutative) {
|
|
newRule.expandedNC1 = {};
|
|
newRule.expandedNC1.l = makeNode([leftExpandsym, newRule.l]);
|
|
newRule.expandedNC1.r = makeNode([leftExpandsym, newRule.r]);
|
|
newRule.expandedNC2 = {};
|
|
newRule.expandedNC2.l = makeNode([leftExpandsym, newRule.expanded.l]);
|
|
newRule.expandedNC2.r = makeNode([leftExpandsym, newRule.expanded.r]);
|
|
}
|
|
}
|
|
return newRule;
|
|
}
|
|
function _buildRules(rules, context) {
|
|
var ruleSet = [];
|
|
for (var i2 = 0; i2 < rules.length; i2++) {
|
|
var rule = rules[i2];
|
|
var newRule = void 0;
|
|
var ruleType = typeof rule;
|
|
switch (ruleType) {
|
|
case "string":
|
|
rule = {
|
|
s: rule
|
|
};
|
|
case "object":
|
|
newRule = _canonicalizeRule(rule, context);
|
|
break;
|
|
case "function":
|
|
newRule = rule;
|
|
break;
|
|
default:
|
|
throw TypeError("Unsupported type of rule: " + ruleType);
|
|
}
|
|
ruleSet.push(newRule);
|
|
}
|
|
return ruleSet;
|
|
}
|
|
var _lastsym = 0;
|
|
function _getExpandPlaceholderSymbol() {
|
|
return new SymbolNode2("_p" + _lastsym++);
|
|
}
|
|
function _simplify(expr, rules) {
|
|
var scope = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : createEmptyMap();
|
|
var options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
var debug = options.consoleDebug;
|
|
rules = _buildRules(rules || simplify2.rules, options.context);
|
|
var res = resolve2(expr, scope);
|
|
res = removeParens(res);
|
|
var visited = {};
|
|
var str = res.toString({
|
|
parenthesis: "all"
|
|
});
|
|
while (!visited[str]) {
|
|
visited[str] = true;
|
|
_lastsym = 0;
|
|
var laststr = str;
|
|
if (debug)
|
|
console.log("Working on: ", str);
|
|
for (var i2 = 0; i2 < rules.length; i2++) {
|
|
var rulestr = "";
|
|
if (typeof rules[i2] === "function") {
|
|
res = rules[i2](res, options);
|
|
if (debug)
|
|
rulestr = rules[i2].name;
|
|
} else {
|
|
flatten3(res, options.context);
|
|
res = applyRule(res, rules[i2], options.context);
|
|
if (debug) {
|
|
rulestr = "".concat(rules[i2].l.toString(), " -> ").concat(rules[i2].r.toString());
|
|
}
|
|
}
|
|
if (debug) {
|
|
var newstr = res.toString({
|
|
parenthesis: "all"
|
|
});
|
|
if (newstr !== laststr) {
|
|
console.log("Applying", rulestr, "produced", newstr);
|
|
laststr = newstr;
|
|
}
|
|
}
|
|
unflattenl(res, options.context);
|
|
}
|
|
str = res.toString({
|
|
parenthesis: "all"
|
|
});
|
|
}
|
|
return res;
|
|
}
|
|
function mapRule(nodes, rule, context) {
|
|
var resNodes = nodes;
|
|
if (nodes) {
|
|
for (var i2 = 0; i2 < nodes.length; ++i2) {
|
|
var newNode = applyRule(nodes[i2], rule, context);
|
|
if (newNode !== nodes[i2]) {
|
|
if (resNodes === nodes) {
|
|
resNodes = nodes.slice();
|
|
}
|
|
resNodes[i2] = newNode;
|
|
}
|
|
}
|
|
}
|
|
return resNodes;
|
|
}
|
|
function applyRule(node, rule, context) {
|
|
if (rule.assuming) {
|
|
for (var symbol in rule.assuming) {
|
|
for (var property in rule.assuming[symbol]) {
|
|
if (hasProperty(symbol, property, context) !== rule.assuming[symbol][property]) {
|
|
return node;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var mergedContext = mergeContext(rule.imposeContext, context);
|
|
var res = node;
|
|
if (res instanceof OperatorNode2 || res instanceof FunctionNode2) {
|
|
var newArgs = mapRule(res.args, rule, context);
|
|
if (newArgs !== res.args) {
|
|
res = res.clone();
|
|
res.args = newArgs;
|
|
}
|
|
} else if (res instanceof ParenthesisNode2) {
|
|
if (res.content) {
|
|
var newContent = applyRule(res.content, rule, context);
|
|
if (newContent !== res.content) {
|
|
res = new ParenthesisNode2(newContent);
|
|
}
|
|
}
|
|
} else if (res instanceof ArrayNode2) {
|
|
var newItems = mapRule(res.items, rule, context);
|
|
if (newItems !== res.items) {
|
|
res = new ArrayNode2(newItems);
|
|
}
|
|
} else if (res instanceof AccessorNode2) {
|
|
var newObj = res.object;
|
|
if (res.object) {
|
|
newObj = applyRule(res.object, rule, context);
|
|
}
|
|
var newIndex = res.index;
|
|
if (res.index) {
|
|
newIndex = applyRule(res.index, rule, context);
|
|
}
|
|
if (newObj !== res.object || newIndex !== res.index) {
|
|
res = new AccessorNode2(newObj, newIndex);
|
|
}
|
|
} else if (res instanceof IndexNode2) {
|
|
var newDims = mapRule(res.dimensions, rule, context);
|
|
if (newDims !== res.dimensions) {
|
|
res = new IndexNode2(newDims);
|
|
}
|
|
} else if (res instanceof ObjectNode2) {
|
|
var changed = false;
|
|
var newProps = {};
|
|
for (var prop in res.properties) {
|
|
newProps[prop] = applyRule(res.properties[prop], rule, context);
|
|
if (newProps[prop] !== res.properties[prop]) {
|
|
changed = true;
|
|
}
|
|
}
|
|
if (changed) {
|
|
res = new ObjectNode2(newProps);
|
|
}
|
|
}
|
|
var repl = rule.r;
|
|
var matches = _ruleMatch(rule.l, res, mergedContext)[0];
|
|
if (!matches && rule.expanded) {
|
|
repl = rule.expanded.r;
|
|
matches = _ruleMatch(rule.expanded.l, res, mergedContext)[0];
|
|
}
|
|
if (!matches && rule.expandedNC1) {
|
|
repl = rule.expandedNC1.r;
|
|
matches = _ruleMatch(rule.expandedNC1.l, res, mergedContext)[0];
|
|
if (!matches) {
|
|
repl = rule.expandedNC2.r;
|
|
matches = _ruleMatch(rule.expandedNC2.l, res, mergedContext)[0];
|
|
}
|
|
}
|
|
if (matches) {
|
|
var implicit = res.implicit;
|
|
res = repl.clone();
|
|
if (implicit && "implicit" in repl) {
|
|
res.implicit = true;
|
|
}
|
|
res = res.transform(function(node2) {
|
|
if (node2.isSymbolNode && hasOwnProperty2(matches.placeholders, node2.name)) {
|
|
return matches.placeholders[node2.name].clone();
|
|
} else {
|
|
return node2;
|
|
}
|
|
});
|
|
}
|
|
if (rule.repeat && res !== node) {
|
|
res = applyRule(res, rule, context);
|
|
}
|
|
return res;
|
|
}
|
|
function getSplits(node, context) {
|
|
var res = [];
|
|
var right, rightArgs;
|
|
var makeNode = createMakeNodeFunction(node);
|
|
if (isCommutative(node, context)) {
|
|
for (var i2 = 0; i2 < node.args.length; i2++) {
|
|
rightArgs = node.args.slice(0);
|
|
rightArgs.splice(i2, 1);
|
|
right = rightArgs.length === 1 ? rightArgs[0] : makeNode(rightArgs);
|
|
res.push(makeNode([node.args[i2], right]));
|
|
}
|
|
} else {
|
|
for (var _i = 1; _i < node.args.length; _i++) {
|
|
var left = node.args[0];
|
|
if (_i > 1) {
|
|
left = makeNode(node.args.slice(0, _i));
|
|
}
|
|
rightArgs = node.args.slice(_i);
|
|
right = rightArgs.length === 1 ? rightArgs[0] : makeNode(rightArgs);
|
|
res.push(makeNode([left, right]));
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
function mergeMatch(match1, match2) {
|
|
var res = {
|
|
placeholders: {}
|
|
};
|
|
if (!match1.placeholders && !match2.placeholders) {
|
|
return res;
|
|
} else if (!match1.placeholders) {
|
|
return match2;
|
|
} else if (!match2.placeholders) {
|
|
return match1;
|
|
}
|
|
for (var key in match1.placeholders) {
|
|
if (hasOwnProperty2(match1.placeholders, key)) {
|
|
res.placeholders[key] = match1.placeholders[key];
|
|
if (hasOwnProperty2(match2.placeholders, key)) {
|
|
if (!_exactMatch(match1.placeholders[key], match2.placeholders[key])) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for (var _key in match2.placeholders) {
|
|
if (hasOwnProperty2(match2.placeholders, _key)) {
|
|
res.placeholders[_key] = match2.placeholders[_key];
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
function combineChildMatches(list1, list2) {
|
|
var res = [];
|
|
if (list1.length === 0 || list2.length === 0) {
|
|
return res;
|
|
}
|
|
var merged;
|
|
for (var i1 = 0; i1 < list1.length; i1++) {
|
|
for (var i2 = 0; i2 < list2.length; i2++) {
|
|
merged = mergeMatch(list1[i1], list2[i2]);
|
|
if (merged) {
|
|
res.push(merged);
|
|
}
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
function mergeChildMatches(childMatches) {
|
|
if (childMatches.length === 0) {
|
|
return childMatches;
|
|
}
|
|
var sets = childMatches.reduce(combineChildMatches);
|
|
var uniqueSets = [];
|
|
var unique = {};
|
|
for (var i2 = 0; i2 < sets.length; i2++) {
|
|
var s = JSON.stringify(sets[i2]);
|
|
if (!unique[s]) {
|
|
unique[s] = true;
|
|
uniqueSets.push(sets[i2]);
|
|
}
|
|
}
|
|
return uniqueSets;
|
|
}
|
|
function _ruleMatch(rule, node, context, isSplit) {
|
|
var res = [{
|
|
placeholders: {}
|
|
}];
|
|
if (rule instanceof OperatorNode2 && node instanceof OperatorNode2 || rule instanceof FunctionNode2 && node instanceof FunctionNode2) {
|
|
if (rule instanceof OperatorNode2) {
|
|
if (rule.op !== node.op || rule.fn !== node.fn) {
|
|
return [];
|
|
}
|
|
} else if (rule instanceof FunctionNode2) {
|
|
if (rule.name !== node.name) {
|
|
return [];
|
|
}
|
|
}
|
|
if (node.args.length === 1 && rule.args.length === 1 || !isAssociative(node, context) && node.args.length === rule.args.length || isSplit) {
|
|
var childMatches = [];
|
|
for (var i2 = 0; i2 < rule.args.length; i2++) {
|
|
var childMatch = _ruleMatch(rule.args[i2], node.args[i2], context);
|
|
if (childMatch.length === 0) {
|
|
break;
|
|
}
|
|
childMatches.push(childMatch);
|
|
}
|
|
if (childMatches.length !== rule.args.length) {
|
|
if (!isCommutative(node, context) || rule.args.length === 1) {
|
|
return [];
|
|
}
|
|
if (rule.args.length > 2) {
|
|
throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");
|
|
}
|
|
var leftMatch = _ruleMatch(rule.args[0], node.args[1], context);
|
|
if (leftMatch.length === 0) {
|
|
return [];
|
|
}
|
|
var rightMatch = _ruleMatch(rule.args[1], node.args[0], context);
|
|
if (rightMatch.length === 0) {
|
|
return [];
|
|
}
|
|
childMatches = [leftMatch, rightMatch];
|
|
}
|
|
res = mergeChildMatches(childMatches);
|
|
} else if (node.args.length >= 2 && rule.args.length === 2) {
|
|
var splits = getSplits(node, context);
|
|
var splitMatches = [];
|
|
for (var _i2 = 0; _i2 < splits.length; _i2++) {
|
|
var matchSet = _ruleMatch(rule, splits[_i2], context, true);
|
|
splitMatches = splitMatches.concat(matchSet);
|
|
}
|
|
return splitMatches;
|
|
} else if (rule.args.length > 2) {
|
|
throw Error("Unexpected non-binary associative function: " + rule.toString());
|
|
} else {
|
|
return [];
|
|
}
|
|
} else if (rule instanceof SymbolNode2) {
|
|
if (rule.name.length === 0) {
|
|
throw new Error("Symbol in rule has 0 length...!?");
|
|
}
|
|
if (SUPPORTED_CONSTANTS[rule.name]) {
|
|
if (rule.name !== node.name) {
|
|
return [];
|
|
}
|
|
} else {
|
|
switch (rule.name[1] >= "a" && rule.name[1] <= "z" ? rule.name.substring(0, 2) : rule.name[0]) {
|
|
case "n":
|
|
case "_p":
|
|
res[0].placeholders[rule.name] = node;
|
|
break;
|
|
case "c":
|
|
case "cl":
|
|
if (isConstantNode(node)) {
|
|
res[0].placeholders[rule.name] = node;
|
|
} else {
|
|
return [];
|
|
}
|
|
break;
|
|
case "v":
|
|
if (!isConstantNode(node)) {
|
|
res[0].placeholders[rule.name] = node;
|
|
} else {
|
|
return [];
|
|
}
|
|
break;
|
|
case "vl":
|
|
if (isSymbolNode(node)) {
|
|
res[0].placeholders[rule.name] = node;
|
|
} else {
|
|
return [];
|
|
}
|
|
break;
|
|
case "cd":
|
|
if (isNumericNode(node)) {
|
|
res[0].placeholders[rule.name] = node;
|
|
} else {
|
|
return [];
|
|
}
|
|
break;
|
|
case "vd":
|
|
if (!isNumericNode(node)) {
|
|
res[0].placeholders[rule.name] = node;
|
|
} else {
|
|
return [];
|
|
}
|
|
break;
|
|
case "ce":
|
|
if (isConstantExpression(node)) {
|
|
res[0].placeholders[rule.name] = node;
|
|
} else {
|
|
return [];
|
|
}
|
|
break;
|
|
case "ve":
|
|
if (!isConstantExpression(node)) {
|
|
res[0].placeholders[rule.name] = node;
|
|
} else {
|
|
return [];
|
|
}
|
|
break;
|
|
default:
|
|
throw new Error("Invalid symbol in rule: " + rule.name);
|
|
}
|
|
}
|
|
} else if (rule instanceof ConstantNode2) {
|
|
if (!equal2(rule.value, node.value)) {
|
|
return [];
|
|
}
|
|
} else {
|
|
return [];
|
|
}
|
|
return res;
|
|
}
|
|
function _exactMatch(p, q) {
|
|
if (p instanceof ConstantNode2 && q instanceof ConstantNode2) {
|
|
if (!equal2(p.value, q.value)) {
|
|
return false;
|
|
}
|
|
} else if (p instanceof SymbolNode2 && q instanceof SymbolNode2) {
|
|
if (p.name !== q.name) {
|
|
return false;
|
|
}
|
|
} else if (p instanceof OperatorNode2 && q instanceof OperatorNode2 || p instanceof FunctionNode2 && q instanceof FunctionNode2) {
|
|
if (p instanceof OperatorNode2) {
|
|
if (p.op !== q.op || p.fn !== q.fn) {
|
|
return false;
|
|
}
|
|
} else if (p instanceof FunctionNode2) {
|
|
if (p.name !== q.name) {
|
|
return false;
|
|
}
|
|
}
|
|
if (p.args.length !== q.args.length) {
|
|
return false;
|
|
}
|
|
for (var i2 = 0; i2 < p.args.length; i2++) {
|
|
if (!_exactMatch(p.args[i2], q.args[i2])) {
|
|
return false;
|
|
}
|
|
}
|
|
} else {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
return simplify2;
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/simplifyConstant.js
|
|
var name276 = "simplifyConstant";
|
|
var dependencies276 = ["typed", "config", "mathWithTransform", "matrix", "?fraction", "?bignumber", "AccessorNode", "ArrayNode", "ConstantNode", "FunctionNode", "IndexNode", "ObjectNode", "OperatorNode", "SymbolNode"];
|
|
var createSimplifyConstant = /* @__PURE__ */ factory(name276, dependencies276, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
mathWithTransform: mathWithTransform2,
|
|
matrix: matrix2,
|
|
fraction: fraction2,
|
|
bignumber: bignumber2,
|
|
AccessorNode: AccessorNode2,
|
|
ArrayNode: ArrayNode2,
|
|
ConstantNode: ConstantNode2,
|
|
FunctionNode: FunctionNode2,
|
|
IndexNode: IndexNode2,
|
|
ObjectNode: ObjectNode2,
|
|
OperatorNode: OperatorNode2,
|
|
SymbolNode: SymbolNode2
|
|
} = _ref;
|
|
var {
|
|
isCommutative,
|
|
isAssociative,
|
|
allChildren,
|
|
createMakeNodeFunction
|
|
} = createUtil({
|
|
FunctionNode: FunctionNode2,
|
|
OperatorNode: OperatorNode2,
|
|
SymbolNode: SymbolNode2
|
|
});
|
|
var simplifyConstant2 = typed2("simplifyConstant", {
|
|
Node: (node) => _ensureNode(foldFraction(node, {})),
|
|
"Node, Object": function NodeObject(expr, options) {
|
|
return _ensureNode(foldFraction(expr, options));
|
|
}
|
|
});
|
|
function _removeFractions(thing) {
|
|
if (isFraction(thing)) {
|
|
return thing.valueOf();
|
|
}
|
|
if (thing instanceof Array) {
|
|
return thing.map(_removeFractions);
|
|
}
|
|
if (isMatrix(thing)) {
|
|
return matrix2(_removeFractions(thing.valueOf()));
|
|
}
|
|
return thing;
|
|
}
|
|
function _eval(fnname, args, options) {
|
|
try {
|
|
return mathWithTransform2[fnname].apply(null, args);
|
|
} catch (ignore) {
|
|
args = args.map(_removeFractions);
|
|
return _toNumber(mathWithTransform2[fnname].apply(null, args), options);
|
|
}
|
|
}
|
|
var _toNode = typed2({
|
|
Fraction: _fractionToNode,
|
|
number: function number2(n) {
|
|
if (n < 0) {
|
|
return unaryMinusNode(new ConstantNode2(-n));
|
|
}
|
|
return new ConstantNode2(n);
|
|
},
|
|
BigNumber: function BigNumber2(n) {
|
|
if (n < 0) {
|
|
return unaryMinusNode(new ConstantNode2(-n));
|
|
}
|
|
return new ConstantNode2(n);
|
|
},
|
|
Complex: function Complex3(s) {
|
|
throw new Error("Cannot convert Complex number to Node");
|
|
},
|
|
string: function string2(s) {
|
|
return new ConstantNode2(s);
|
|
},
|
|
Matrix: function Matrix2(m) {
|
|
return new ArrayNode2(m.valueOf().map((e3) => _toNode(e3)));
|
|
}
|
|
});
|
|
function _ensureNode(thing) {
|
|
if (isNode(thing)) {
|
|
return thing;
|
|
}
|
|
return _toNode(thing);
|
|
}
|
|
function _exactFraction(n, options) {
|
|
var exactFractions = options && options.exactFractions !== false;
|
|
if (exactFractions && isFinite(n) && fraction2) {
|
|
var f = fraction2(n);
|
|
var fractionsLimit = options && typeof options.fractionsLimit === "number" ? options.fractionsLimit : Infinity;
|
|
if (f.valueOf() === n && f.n < fractionsLimit && f.d < fractionsLimit) {
|
|
return f;
|
|
}
|
|
}
|
|
return n;
|
|
}
|
|
var _toNumber = typed2({
|
|
"string, Object": function stringObject(s, options) {
|
|
if (config4.number === "BigNumber") {
|
|
if (bignumber2 === void 0) {
|
|
noBignumber();
|
|
}
|
|
return bignumber2(s);
|
|
} else if (config4.number === "Fraction") {
|
|
if (fraction2 === void 0) {
|
|
noFraction();
|
|
}
|
|
return fraction2(s);
|
|
} else {
|
|
var n = parseFloat(s);
|
|
return _exactFraction(n, options);
|
|
}
|
|
},
|
|
"Fraction, Object": function FractionObject(s, options) {
|
|
return s;
|
|
},
|
|
"BigNumber, Object": function BigNumberObject(s, options) {
|
|
return s;
|
|
},
|
|
"number, Object": function numberObject(s, options) {
|
|
return _exactFraction(s, options);
|
|
},
|
|
"Complex, Object": function ComplexObject(s, options) {
|
|
if (s.im !== 0) {
|
|
return s;
|
|
}
|
|
return _exactFraction(s.re, options);
|
|
},
|
|
"Matrix, Object": function MatrixObject(s, options) {
|
|
return matrix2(_exactFraction(s.valueOf()));
|
|
},
|
|
"Array, Object": function ArrayObject(s, options) {
|
|
return s.map(_exactFraction);
|
|
}
|
|
});
|
|
function unaryMinusNode(n) {
|
|
return new OperatorNode2("-", "unaryMinus", [n]);
|
|
}
|
|
function _fractionToNode(f) {
|
|
var n;
|
|
var vn = f.s * f.n;
|
|
if (vn < 0) {
|
|
n = new OperatorNode2("-", "unaryMinus", [new ConstantNode2(-vn)]);
|
|
} else {
|
|
n = new ConstantNode2(vn);
|
|
}
|
|
if (f.d === 1) {
|
|
return n;
|
|
}
|
|
return new OperatorNode2("/", "divide", [n, new ConstantNode2(f.d)]);
|
|
}
|
|
function _foldAccessor(obj, index2, options) {
|
|
if (!isIndexNode(index2)) {
|
|
return new AccessorNode2(_ensureNode(obj), _ensureNode(index2));
|
|
}
|
|
if (isArrayNode(obj) || isMatrix(obj)) {
|
|
var remainingDims = Array.from(index2.dimensions);
|
|
while (remainingDims.length > 0) {
|
|
if (isConstantNode(remainingDims[0]) && typeof remainingDims[0].value !== "string") {
|
|
var first = _toNumber(remainingDims.shift().value, options);
|
|
if (isArrayNode(obj)) {
|
|
obj = obj.items[first - 1];
|
|
} else {
|
|
obj = obj.valueOf()[first - 1];
|
|
if (obj instanceof Array) {
|
|
obj = matrix2(obj);
|
|
}
|
|
}
|
|
} else if (remainingDims.length > 1 && isConstantNode(remainingDims[1]) && typeof remainingDims[1].value !== "string") {
|
|
var second = _toNumber(remainingDims[1].value, options);
|
|
var tryItems = [];
|
|
var fromItems = isArrayNode(obj) ? obj.items : obj.valueOf();
|
|
for (var item of fromItems) {
|
|
if (isArrayNode(item)) {
|
|
tryItems.push(item.items[second - 1]);
|
|
} else if (isMatrix(obj)) {
|
|
tryItems.push(item[second - 1]);
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
if (tryItems.length === fromItems.length) {
|
|
if (isArrayNode(obj)) {
|
|
obj = new ArrayNode2(tryItems);
|
|
} else {
|
|
obj = matrix2(tryItems);
|
|
}
|
|
remainingDims.splice(1, 1);
|
|
} else {
|
|
break;
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
if (remainingDims.length === index2.dimensions.length) {
|
|
return new AccessorNode2(_ensureNode(obj), index2);
|
|
}
|
|
if (remainingDims.length > 0) {
|
|
index2 = new IndexNode2(remainingDims);
|
|
return new AccessorNode2(_ensureNode(obj), index2);
|
|
}
|
|
return obj;
|
|
}
|
|
if (isObjectNode(obj) && index2.dimensions.length === 1 && isConstantNode(index2.dimensions[0])) {
|
|
var key = index2.dimensions[0].value;
|
|
if (key in obj.properties) {
|
|
return obj.properties[key];
|
|
}
|
|
return new ConstantNode2();
|
|
}
|
|
return new AccessorNode2(_ensureNode(obj), index2);
|
|
}
|
|
function foldOp(fn, args, makeNode, options) {
|
|
var first = args.shift();
|
|
var reduction = args.reduce((sofar, next) => {
|
|
if (!isNode(next)) {
|
|
var last = sofar.pop();
|
|
if (isNode(last)) {
|
|
return [last, next];
|
|
}
|
|
try {
|
|
sofar.push(_eval(fn, [last, next], options));
|
|
return sofar;
|
|
} catch (ignoreandcontinue) {
|
|
sofar.push(last);
|
|
}
|
|
}
|
|
sofar.push(_ensureNode(sofar.pop()));
|
|
var newtree = sofar.length === 1 ? sofar[0] : makeNode(sofar);
|
|
return [makeNode([newtree, _ensureNode(next)])];
|
|
}, [first]);
|
|
if (reduction.length === 1) {
|
|
return reduction[0];
|
|
}
|
|
return makeNode([reduction[0], _toNode(reduction[1])]);
|
|
}
|
|
function foldFraction(node, options) {
|
|
switch (node.type) {
|
|
case "SymbolNode":
|
|
return node;
|
|
case "ConstantNode":
|
|
switch (typeof node.value) {
|
|
case "number":
|
|
return _toNumber(node.value, options);
|
|
case "string":
|
|
return node.value;
|
|
default:
|
|
if (!isNaN(node.value))
|
|
return _toNumber(node.value, options);
|
|
}
|
|
return node;
|
|
case "FunctionNode":
|
|
if (mathWithTransform2[node.name] && mathWithTransform2[node.name].rawArgs) {
|
|
return node;
|
|
}
|
|
{
|
|
var operatorFunctions = ["add", "multiply"];
|
|
if (operatorFunctions.indexOf(node.name) === -1) {
|
|
var args = node.args.map((arg2) => foldFraction(arg2, options));
|
|
if (!args.some(isNode)) {
|
|
try {
|
|
return _eval(node.name, args, options);
|
|
} catch (ignoreandcontinue) {
|
|
}
|
|
}
|
|
if (node.name === "size" && args.length === 1 && isArrayNode(args[0])) {
|
|
var sz = [];
|
|
var section = args[0];
|
|
while (isArrayNode(section)) {
|
|
sz.push(section.items.length);
|
|
section = section.items[0];
|
|
}
|
|
return matrix2(sz);
|
|
}
|
|
return new FunctionNode2(node.name, args.map(_ensureNode));
|
|
} else {
|
|
}
|
|
}
|
|
case "OperatorNode": {
|
|
var fn = node.fn.toString();
|
|
var _args;
|
|
var res;
|
|
var makeNode = createMakeNodeFunction(node);
|
|
if (isOperatorNode(node) && node.isUnary()) {
|
|
_args = [foldFraction(node.args[0], options)];
|
|
if (!isNode(_args[0])) {
|
|
res = _eval(fn, _args, options);
|
|
} else {
|
|
res = makeNode(_args);
|
|
}
|
|
} else if (isAssociative(node, options.context)) {
|
|
_args = allChildren(node, options.context);
|
|
_args = _args.map((arg2) => foldFraction(arg2, options));
|
|
if (isCommutative(fn, options.context)) {
|
|
var consts = [];
|
|
var vars = [];
|
|
for (var i2 = 0; i2 < _args.length; i2++) {
|
|
if (!isNode(_args[i2])) {
|
|
consts.push(_args[i2]);
|
|
} else {
|
|
vars.push(_args[i2]);
|
|
}
|
|
}
|
|
if (consts.length > 1) {
|
|
res = foldOp(fn, consts, makeNode, options);
|
|
vars.unshift(res);
|
|
res = foldOp(fn, vars, makeNode, options);
|
|
} else {
|
|
res = foldOp(fn, _args, makeNode, options);
|
|
}
|
|
} else {
|
|
res = foldOp(fn, _args, makeNode, options);
|
|
}
|
|
} else {
|
|
_args = node.args.map((arg2) => foldFraction(arg2, options));
|
|
res = foldOp(fn, _args, makeNode, options);
|
|
}
|
|
return res;
|
|
}
|
|
case "ParenthesisNode":
|
|
return foldFraction(node.content, options);
|
|
case "AccessorNode":
|
|
return _foldAccessor(foldFraction(node.object, options), foldFraction(node.index, options), options);
|
|
case "ArrayNode": {
|
|
var foldItems = node.items.map((item) => foldFraction(item, options));
|
|
if (foldItems.some(isNode)) {
|
|
return new ArrayNode2(foldItems.map(_ensureNode));
|
|
}
|
|
return matrix2(foldItems);
|
|
}
|
|
case "IndexNode": {
|
|
return new IndexNode2(node.dimensions.map((n) => simplifyConstant2(n, options)));
|
|
}
|
|
case "ObjectNode": {
|
|
var foldProps = {};
|
|
for (var prop in node.properties) {
|
|
foldProps[prop] = simplifyConstant2(node.properties[prop], options);
|
|
}
|
|
return new ObjectNode2(foldProps);
|
|
}
|
|
case "AssignmentNode":
|
|
case "BlockNode":
|
|
case "FunctionAssignmentNode":
|
|
case "RangeNode":
|
|
case "ConditionalNode":
|
|
default:
|
|
throw new Error("Unimplemented node type in simplifyConstant: ".concat(node.type));
|
|
}
|
|
}
|
|
return simplifyConstant2;
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/simplifyCore.js
|
|
var name277 = "simplifyCore";
|
|
var dependencies277 = ["typed", "parse", "equal", "isZero", "add", "subtract", "multiply", "divide", "pow", "AccessorNode", "ArrayNode", "ConstantNode", "FunctionNode", "IndexNode", "ObjectNode", "OperatorNode", "ParenthesisNode", "SymbolNode"];
|
|
var createSimplifyCore = /* @__PURE__ */ factory(name277, dependencies277, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
parse: parse2,
|
|
equal: equal2,
|
|
isZero: isZero2,
|
|
add: add3,
|
|
subtract: subtract2,
|
|
multiply: multiply2,
|
|
divide: divide3,
|
|
pow: pow3,
|
|
AccessorNode: AccessorNode2,
|
|
ArrayNode: ArrayNode2,
|
|
ConstantNode: ConstantNode2,
|
|
FunctionNode: FunctionNode2,
|
|
IndexNode: IndexNode2,
|
|
ObjectNode: ObjectNode2,
|
|
OperatorNode: OperatorNode2,
|
|
ParenthesisNode: ParenthesisNode2,
|
|
SymbolNode: SymbolNode2
|
|
} = _ref;
|
|
var node0 = new ConstantNode2(0);
|
|
var node1 = new ConstantNode2(1);
|
|
var nodeT = new ConstantNode2(true);
|
|
var nodeF = new ConstantNode2(false);
|
|
function isAlwaysBoolean(node) {
|
|
return isOperatorNode(node) && ["and", "not", "or"].includes(node.op);
|
|
}
|
|
var {
|
|
hasProperty,
|
|
isCommutative
|
|
} = createUtil({
|
|
FunctionNode: FunctionNode2,
|
|
OperatorNode: OperatorNode2,
|
|
SymbolNode: SymbolNode2
|
|
});
|
|
function _simplifyCore(nodeToSimplify) {
|
|
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
var context = options ? options.context : void 0;
|
|
if (hasProperty(nodeToSimplify, "trivial", context)) {
|
|
if (isFunctionNode(nodeToSimplify) && nodeToSimplify.args.length === 1) {
|
|
return _simplifyCore(nodeToSimplify.args[0], options);
|
|
}
|
|
var simpChild = false;
|
|
var childCount = 0;
|
|
nodeToSimplify.forEach((c) => {
|
|
++childCount;
|
|
if (childCount === 1) {
|
|
simpChild = _simplifyCore(c, options);
|
|
}
|
|
});
|
|
if (childCount === 1) {
|
|
return simpChild;
|
|
}
|
|
}
|
|
var node = nodeToSimplify;
|
|
if (isFunctionNode(node)) {
|
|
var op = getOperator(node.name);
|
|
if (op) {
|
|
if (node.args.length > 2 && hasProperty(node, "associative", context)) {
|
|
while (node.args.length > 2) {
|
|
var last = node.args.pop();
|
|
var seclast = node.args.pop();
|
|
node.args.push(new OperatorNode2(op, node.name, [last, seclast]));
|
|
}
|
|
}
|
|
node = new OperatorNode2(op, node.name, node.args);
|
|
} else {
|
|
return new FunctionNode2(_simplifyCore(node.fn), node.args.map((n) => _simplifyCore(n, options)));
|
|
}
|
|
}
|
|
if (isOperatorNode(node) && node.isUnary()) {
|
|
var a0 = _simplifyCore(node.args[0], options);
|
|
if (node.op === "~") {
|
|
if (isOperatorNode(a0) && a0.isUnary() && a0.op === "~") {
|
|
return a0.args[0];
|
|
}
|
|
}
|
|
if (node.op === "not") {
|
|
if (isOperatorNode(a0) && a0.isUnary() && a0.op === "not") {
|
|
if (isAlwaysBoolean(a0.args[0])) {
|
|
return a0.args[0];
|
|
}
|
|
}
|
|
}
|
|
var finish = true;
|
|
if (node.op === "-") {
|
|
if (isOperatorNode(a0)) {
|
|
if (a0.isBinary() && a0.fn === "subtract") {
|
|
node = new OperatorNode2("-", "subtract", [a0.args[1], a0.args[0]]);
|
|
finish = false;
|
|
}
|
|
if (a0.isUnary() && a0.op === "-") {
|
|
return a0.args[0];
|
|
}
|
|
}
|
|
}
|
|
if (finish)
|
|
return new OperatorNode2(node.op, node.fn, [a0]);
|
|
}
|
|
if (isOperatorNode(node) && node.isBinary()) {
|
|
var _a = _simplifyCore(node.args[0], options);
|
|
var a1 = _simplifyCore(node.args[1], options);
|
|
if (node.op === "+") {
|
|
if (isConstantNode(_a) && isZero2(_a.value)) {
|
|
return a1;
|
|
}
|
|
if (isConstantNode(a1) && isZero2(a1.value)) {
|
|
return _a;
|
|
}
|
|
if (isOperatorNode(a1) && a1.isUnary() && a1.op === "-") {
|
|
a1 = a1.args[0];
|
|
node = new OperatorNode2("-", "subtract", [_a, a1]);
|
|
}
|
|
}
|
|
if (node.op === "-") {
|
|
if (isOperatorNode(a1) && a1.isUnary() && a1.op === "-") {
|
|
return _simplifyCore(new OperatorNode2("+", "add", [_a, a1.args[0]]), options);
|
|
}
|
|
if (isConstantNode(_a) && isZero2(_a.value)) {
|
|
return _simplifyCore(new OperatorNode2("-", "unaryMinus", [a1]));
|
|
}
|
|
if (isConstantNode(a1) && isZero2(a1.value)) {
|
|
return _a;
|
|
}
|
|
return new OperatorNode2(node.op, node.fn, [_a, a1]);
|
|
}
|
|
if (node.op === "*") {
|
|
if (isConstantNode(_a)) {
|
|
if (isZero2(_a.value)) {
|
|
return node0;
|
|
} else if (equal2(_a.value, 1)) {
|
|
return a1;
|
|
}
|
|
}
|
|
if (isConstantNode(a1)) {
|
|
if (isZero2(a1.value)) {
|
|
return node0;
|
|
} else if (equal2(a1.value, 1)) {
|
|
return _a;
|
|
}
|
|
if (isCommutative(node, context)) {
|
|
return new OperatorNode2(node.op, node.fn, [a1, _a], node.implicit);
|
|
}
|
|
}
|
|
return new OperatorNode2(node.op, node.fn, [_a, a1], node.implicit);
|
|
}
|
|
if (node.op === "/") {
|
|
if (isConstantNode(_a) && isZero2(_a.value)) {
|
|
return node0;
|
|
}
|
|
if (isConstantNode(a1) && equal2(a1.value, 1)) {
|
|
return _a;
|
|
}
|
|
return new OperatorNode2(node.op, node.fn, [_a, a1]);
|
|
}
|
|
if (node.op === "^") {
|
|
if (isConstantNode(a1)) {
|
|
if (isZero2(a1.value)) {
|
|
return node1;
|
|
} else if (equal2(a1.value, 1)) {
|
|
return _a;
|
|
}
|
|
}
|
|
}
|
|
if (node.op === "and") {
|
|
if (isConstantNode(_a)) {
|
|
if (_a.value) {
|
|
if (isAlwaysBoolean(a1))
|
|
return a1;
|
|
} else {
|
|
return nodeF;
|
|
}
|
|
}
|
|
if (isConstantNode(a1)) {
|
|
if (a1.value) {
|
|
if (isAlwaysBoolean(_a))
|
|
return _a;
|
|
} else {
|
|
return nodeF;
|
|
}
|
|
}
|
|
}
|
|
if (node.op === "or") {
|
|
if (isConstantNode(_a)) {
|
|
if (_a.value) {
|
|
return nodeT;
|
|
} else {
|
|
if (isAlwaysBoolean(a1))
|
|
return a1;
|
|
}
|
|
}
|
|
if (isConstantNode(a1)) {
|
|
if (a1.value) {
|
|
return nodeT;
|
|
} else {
|
|
if (isAlwaysBoolean(_a))
|
|
return _a;
|
|
}
|
|
}
|
|
}
|
|
return new OperatorNode2(node.op, node.fn, [_a, a1]);
|
|
}
|
|
if (isOperatorNode(node)) {
|
|
return new OperatorNode2(node.op, node.fn, node.args.map((a) => _simplifyCore(a, options)));
|
|
}
|
|
if (isArrayNode(node)) {
|
|
return new ArrayNode2(node.items.map((n) => _simplifyCore(n, options)));
|
|
}
|
|
if (isAccessorNode(node)) {
|
|
return new AccessorNode2(_simplifyCore(node.object, options), _simplifyCore(node.index, options));
|
|
}
|
|
if (isIndexNode(node)) {
|
|
return new IndexNode2(node.dimensions.map((n) => _simplifyCore(n, options)));
|
|
}
|
|
if (isObjectNode(node)) {
|
|
var newProps = {};
|
|
for (var prop in node.properties) {
|
|
newProps[prop] = _simplifyCore(node.properties[prop], options);
|
|
}
|
|
return new ObjectNode2(newProps);
|
|
}
|
|
return node;
|
|
}
|
|
return typed2(name277, {
|
|
Node: _simplifyCore,
|
|
"Node,Object": _simplifyCore
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/resolve.js
|
|
var name278 = "resolve";
|
|
var dependencies278 = ["typed", "parse", "ConstantNode", "FunctionNode", "OperatorNode", "ParenthesisNode"];
|
|
var createResolve = /* @__PURE__ */ factory(name278, dependencies278, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
parse: parse2,
|
|
ConstantNode: ConstantNode2,
|
|
FunctionNode: FunctionNode2,
|
|
OperatorNode: OperatorNode2,
|
|
ParenthesisNode: ParenthesisNode2
|
|
} = _ref;
|
|
function _resolve(node, scope) {
|
|
var within = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : /* @__PURE__ */ new Set();
|
|
if (!scope) {
|
|
return node;
|
|
}
|
|
if (isSymbolNode(node)) {
|
|
if (within.has(node.name)) {
|
|
var variables = Array.from(within).join(", ");
|
|
throw new ReferenceError("recursive loop of variable definitions among {".concat(variables, "}"));
|
|
}
|
|
var value = scope.get(node.name);
|
|
if (isNode(value)) {
|
|
var nextWithin = new Set(within);
|
|
nextWithin.add(node.name);
|
|
return _resolve(value, scope, nextWithin);
|
|
} else if (typeof value === "number") {
|
|
return parse2(String(value));
|
|
} else if (value !== void 0) {
|
|
return new ConstantNode2(value);
|
|
} else {
|
|
return node;
|
|
}
|
|
} else if (isOperatorNode(node)) {
|
|
var args = node.args.map(function(arg2) {
|
|
return _resolve(arg2, scope, within);
|
|
});
|
|
return new OperatorNode2(node.op, node.fn, args, node.implicit);
|
|
} else if (isParenthesisNode(node)) {
|
|
return new ParenthesisNode2(_resolve(node.content, scope, within));
|
|
} else if (isFunctionNode(node)) {
|
|
var _args = node.args.map(function(arg2) {
|
|
return _resolve(arg2, scope, within);
|
|
});
|
|
return new FunctionNode2(node.name, _args);
|
|
}
|
|
return node.map((child) => _resolve(child, scope, within));
|
|
}
|
|
return typed2("resolve", {
|
|
Node: _resolve,
|
|
"Node, Map | null | undefined": _resolve,
|
|
"Node, Object": (n, scope) => _resolve(n, createMap(scope)),
|
|
"Array | Matrix": typed2.referToSelf((self2) => (A) => A.map((n) => self2(n))),
|
|
"Array | Matrix, null | undefined": typed2.referToSelf((self2) => (A) => A.map((n) => self2(n))),
|
|
"Array, Object": typed2.referTo("Array,Map", (selfAM) => (A, scope) => selfAM(A, createMap(scope))),
|
|
"Matrix, Object": typed2.referTo("Matrix,Map", (selfMM) => (A, scope) => selfMM(A, createMap(scope))),
|
|
"Array | Matrix, Map": typed2.referToSelf((self2) => (A, scope) => A.map((n) => self2(n, scope)))
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/symbolicEqual.js
|
|
var name279 = "symbolicEqual";
|
|
var dependencies279 = ["parse", "simplify", "typed", "OperatorNode"];
|
|
var createSymbolicEqual = /* @__PURE__ */ factory(name279, dependencies279, (_ref) => {
|
|
var {
|
|
parse: parse2,
|
|
simplify: simplify2,
|
|
typed: typed2,
|
|
OperatorNode: OperatorNode2
|
|
} = _ref;
|
|
function _symbolicEqual(e1, e22) {
|
|
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
var diff2 = new OperatorNode2("-", "subtract", [e1, e22]);
|
|
var simplified = simplify2(diff2, {}, options);
|
|
return isConstantNode(simplified) && !simplified.value;
|
|
}
|
|
return typed2(name279, {
|
|
"Node, Node": _symbolicEqual,
|
|
"Node, Node, Object": _symbolicEqual
|
|
});
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/derivative.js
|
|
var name280 = "derivative";
|
|
var dependencies280 = ["typed", "config", "parse", "simplify", "equal", "isZero", "numeric", "ConstantNode", "FunctionNode", "OperatorNode", "ParenthesisNode", "SymbolNode"];
|
|
var createDerivative = /* @__PURE__ */ factory(name280, dependencies280, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
parse: parse2,
|
|
simplify: simplify2,
|
|
equal: equal2,
|
|
isZero: isZero2,
|
|
numeric: numeric3,
|
|
ConstantNode: ConstantNode2,
|
|
FunctionNode: FunctionNode2,
|
|
OperatorNode: OperatorNode2,
|
|
ParenthesisNode: ParenthesisNode2,
|
|
SymbolNode: SymbolNode2
|
|
} = _ref;
|
|
function plainDerivative(expr, variable) {
|
|
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
|
|
simplify: true
|
|
};
|
|
var constNodes = {};
|
|
constTag(constNodes, expr, variable.name);
|
|
var res = _derivative(expr, constNodes);
|
|
return options.simplify ? simplify2(res) : res;
|
|
}
|
|
typed2.addConversion({
|
|
from: "identifier",
|
|
to: "SymbolNode",
|
|
convert: parse2
|
|
});
|
|
var derivative2 = typed2(name280, {
|
|
"Node, SymbolNode": plainDerivative,
|
|
"Node, SymbolNode, Object": plainDerivative
|
|
});
|
|
typed2.removeConversion({
|
|
from: "identifier",
|
|
to: "SymbolNode",
|
|
convert: parse2
|
|
});
|
|
derivative2._simplify = true;
|
|
derivative2.toTex = function(deriv) {
|
|
return _derivTex.apply(null, deriv.args);
|
|
};
|
|
var _derivTex = typed2("_derivTex", {
|
|
"Node, SymbolNode": function NodeSymbolNode(expr, x) {
|
|
if (isConstantNode(expr) && typeOf(expr.value) === "string") {
|
|
return _derivTex(parse2(expr.value).toString(), x.toString(), 1);
|
|
} else {
|
|
return _derivTex(expr.toTex(), x.toString(), 1);
|
|
}
|
|
},
|
|
"Node, ConstantNode": function NodeConstantNode(expr, x) {
|
|
if (typeOf(x.value) === "string") {
|
|
return _derivTex(expr, parse2(x.value));
|
|
} else {
|
|
throw new Error("The second parameter to 'derivative' is a non-string constant");
|
|
}
|
|
},
|
|
"Node, SymbolNode, ConstantNode": function NodeSymbolNodeConstantNode(expr, x, order) {
|
|
return _derivTex(expr.toString(), x.name, order.value);
|
|
},
|
|
"string, string, number": function stringStringNumber(expr, x, order) {
|
|
var d;
|
|
if (order === 1) {
|
|
d = "{d\\over d" + x + "}";
|
|
} else {
|
|
d = "{d^{" + order + "}\\over d" + x + "^{" + order + "}}";
|
|
}
|
|
return d + "\\left[".concat(expr, "\\right]");
|
|
}
|
|
});
|
|
var constTag = typed2("constTag", {
|
|
"Object, ConstantNode, string": function ObjectConstantNodeString(constNodes, node) {
|
|
constNodes[node] = true;
|
|
return true;
|
|
},
|
|
"Object, SymbolNode, string": function ObjectSymbolNodeString(constNodes, node, varName) {
|
|
if (node.name !== varName) {
|
|
constNodes[node] = true;
|
|
return true;
|
|
}
|
|
return false;
|
|
},
|
|
"Object, ParenthesisNode, string": function ObjectParenthesisNodeString(constNodes, node, varName) {
|
|
return constTag(constNodes, node.content, varName);
|
|
},
|
|
"Object, FunctionAssignmentNode, string": function ObjectFunctionAssignmentNodeString(constNodes, node, varName) {
|
|
if (node.params.indexOf(varName) === -1) {
|
|
constNodes[node] = true;
|
|
return true;
|
|
}
|
|
return constTag(constNodes, node.expr, varName);
|
|
},
|
|
"Object, FunctionNode | OperatorNode, string": function ObjectFunctionNodeOperatorNodeString(constNodes, node, varName) {
|
|
if (node.args.length > 0) {
|
|
var isConst = constTag(constNodes, node.args[0], varName);
|
|
for (var i2 = 1; i2 < node.args.length; ++i2) {
|
|
isConst = constTag(constNodes, node.args[i2], varName) && isConst;
|
|
}
|
|
if (isConst) {
|
|
constNodes[node] = true;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
});
|
|
var _derivative = typed2("_derivative", {
|
|
"ConstantNode, Object": function ConstantNodeObject(node) {
|
|
return createConstantNode2(0);
|
|
},
|
|
"SymbolNode, Object": function SymbolNodeObject(node, constNodes) {
|
|
if (constNodes[node] !== void 0) {
|
|
return createConstantNode2(0);
|
|
}
|
|
return createConstantNode2(1);
|
|
},
|
|
"ParenthesisNode, Object": function ParenthesisNodeObject(node, constNodes) {
|
|
return new ParenthesisNode2(_derivative(node.content, constNodes));
|
|
},
|
|
"FunctionAssignmentNode, Object": function FunctionAssignmentNodeObject(node, constNodes) {
|
|
if (constNodes[node] !== void 0) {
|
|
return createConstantNode2(0);
|
|
}
|
|
return _derivative(node.expr, constNodes);
|
|
},
|
|
"FunctionNode, Object": function FunctionNodeObject(node, constNodes) {
|
|
if (node.args.length !== 1) {
|
|
funcArgsCheck(node);
|
|
}
|
|
if (constNodes[node] !== void 0) {
|
|
return createConstantNode2(0);
|
|
}
|
|
var arg0 = node.args[0];
|
|
var arg1;
|
|
var div2 = false;
|
|
var negative = false;
|
|
var funcDerivative;
|
|
switch (node.name) {
|
|
case "cbrt":
|
|
div2 = true;
|
|
funcDerivative = new OperatorNode2("*", "multiply", [createConstantNode2(3), new OperatorNode2("^", "pow", [arg0, new OperatorNode2("/", "divide", [createConstantNode2(2), createConstantNode2(3)])])]);
|
|
break;
|
|
case "sqrt":
|
|
case "nthRoot":
|
|
if (node.args.length === 1) {
|
|
div2 = true;
|
|
funcDerivative = new OperatorNode2("*", "multiply", [createConstantNode2(2), new FunctionNode2("sqrt", [arg0])]);
|
|
} else if (node.args.length === 2) {
|
|
arg1 = new OperatorNode2("/", "divide", [createConstantNode2(1), node.args[1]]);
|
|
constNodes[arg1] = constNodes[node.args[1]];
|
|
return _derivative(new OperatorNode2("^", "pow", [arg0, arg1]), constNodes);
|
|
}
|
|
break;
|
|
case "log10":
|
|
arg1 = createConstantNode2(10);
|
|
case "log":
|
|
if (!arg1 && node.args.length === 1) {
|
|
funcDerivative = arg0.clone();
|
|
div2 = true;
|
|
} else if (node.args.length === 1 && arg1 || node.args.length === 2 && constNodes[node.args[1]] !== void 0) {
|
|
funcDerivative = new OperatorNode2("*", "multiply", [arg0.clone(), new FunctionNode2("log", [arg1 || node.args[1]])]);
|
|
div2 = true;
|
|
} else if (node.args.length === 2) {
|
|
return _derivative(new OperatorNode2("/", "divide", [new FunctionNode2("log", [arg0]), new FunctionNode2("log", [node.args[1]])]), constNodes);
|
|
}
|
|
break;
|
|
case "pow":
|
|
constNodes[arg1] = constNodes[node.args[1]];
|
|
return _derivative(new OperatorNode2("^", "pow", [arg0, node.args[1]]), constNodes);
|
|
case "exp":
|
|
funcDerivative = new FunctionNode2("exp", [arg0.clone()]);
|
|
break;
|
|
case "sin":
|
|
funcDerivative = new FunctionNode2("cos", [arg0.clone()]);
|
|
break;
|
|
case "cos":
|
|
funcDerivative = new OperatorNode2("-", "unaryMinus", [new FunctionNode2("sin", [arg0.clone()])]);
|
|
break;
|
|
case "tan":
|
|
funcDerivative = new OperatorNode2("^", "pow", [new FunctionNode2("sec", [arg0.clone()]), createConstantNode2(2)]);
|
|
break;
|
|
case "sec":
|
|
funcDerivative = new OperatorNode2("*", "multiply", [node, new FunctionNode2("tan", [arg0.clone()])]);
|
|
break;
|
|
case "csc":
|
|
negative = true;
|
|
funcDerivative = new OperatorNode2("*", "multiply", [node, new FunctionNode2("cot", [arg0.clone()])]);
|
|
break;
|
|
case "cot":
|
|
negative = true;
|
|
funcDerivative = new OperatorNode2("^", "pow", [new FunctionNode2("csc", [arg0.clone()]), createConstantNode2(2)]);
|
|
break;
|
|
case "asin":
|
|
div2 = true;
|
|
funcDerivative = new FunctionNode2("sqrt", [new OperatorNode2("-", "subtract", [createConstantNode2(1), new OperatorNode2("^", "pow", [arg0.clone(), createConstantNode2(2)])])]);
|
|
break;
|
|
case "acos":
|
|
div2 = true;
|
|
negative = true;
|
|
funcDerivative = new FunctionNode2("sqrt", [new OperatorNode2("-", "subtract", [createConstantNode2(1), new OperatorNode2("^", "pow", [arg0.clone(), createConstantNode2(2)])])]);
|
|
break;
|
|
case "atan":
|
|
div2 = true;
|
|
funcDerivative = new OperatorNode2("+", "add", [new OperatorNode2("^", "pow", [arg0.clone(), createConstantNode2(2)]), createConstantNode2(1)]);
|
|
break;
|
|
case "asec":
|
|
div2 = true;
|
|
funcDerivative = new OperatorNode2("*", "multiply", [new FunctionNode2("abs", [arg0.clone()]), new FunctionNode2("sqrt", [new OperatorNode2("-", "subtract", [new OperatorNode2("^", "pow", [arg0.clone(), createConstantNode2(2)]), createConstantNode2(1)])])]);
|
|
break;
|
|
case "acsc":
|
|
div2 = true;
|
|
negative = true;
|
|
funcDerivative = new OperatorNode2("*", "multiply", [new FunctionNode2("abs", [arg0.clone()]), new FunctionNode2("sqrt", [new OperatorNode2("-", "subtract", [new OperatorNode2("^", "pow", [arg0.clone(), createConstantNode2(2)]), createConstantNode2(1)])])]);
|
|
break;
|
|
case "acot":
|
|
div2 = true;
|
|
negative = true;
|
|
funcDerivative = new OperatorNode2("+", "add", [new OperatorNode2("^", "pow", [arg0.clone(), createConstantNode2(2)]), createConstantNode2(1)]);
|
|
break;
|
|
case "sinh":
|
|
funcDerivative = new FunctionNode2("cosh", [arg0.clone()]);
|
|
break;
|
|
case "cosh":
|
|
funcDerivative = new FunctionNode2("sinh", [arg0.clone()]);
|
|
break;
|
|
case "tanh":
|
|
funcDerivative = new OperatorNode2("^", "pow", [new FunctionNode2("sech", [arg0.clone()]), createConstantNode2(2)]);
|
|
break;
|
|
case "sech":
|
|
negative = true;
|
|
funcDerivative = new OperatorNode2("*", "multiply", [node, new FunctionNode2("tanh", [arg0.clone()])]);
|
|
break;
|
|
case "csch":
|
|
negative = true;
|
|
funcDerivative = new OperatorNode2("*", "multiply", [node, new FunctionNode2("coth", [arg0.clone()])]);
|
|
break;
|
|
case "coth":
|
|
negative = true;
|
|
funcDerivative = new OperatorNode2("^", "pow", [new FunctionNode2("csch", [arg0.clone()]), createConstantNode2(2)]);
|
|
break;
|
|
case "asinh":
|
|
div2 = true;
|
|
funcDerivative = new FunctionNode2("sqrt", [new OperatorNode2("+", "add", [new OperatorNode2("^", "pow", [arg0.clone(), createConstantNode2(2)]), createConstantNode2(1)])]);
|
|
break;
|
|
case "acosh":
|
|
div2 = true;
|
|
funcDerivative = new FunctionNode2("sqrt", [new OperatorNode2("-", "subtract", [new OperatorNode2("^", "pow", [arg0.clone(), createConstantNode2(2)]), createConstantNode2(1)])]);
|
|
break;
|
|
case "atanh":
|
|
div2 = true;
|
|
funcDerivative = new OperatorNode2("-", "subtract", [createConstantNode2(1), new OperatorNode2("^", "pow", [arg0.clone(), createConstantNode2(2)])]);
|
|
break;
|
|
case "asech":
|
|
div2 = true;
|
|
negative = true;
|
|
funcDerivative = new OperatorNode2("*", "multiply", [arg0.clone(), new FunctionNode2("sqrt", [new OperatorNode2("-", "subtract", [createConstantNode2(1), new OperatorNode2("^", "pow", [arg0.clone(), createConstantNode2(2)])])])]);
|
|
break;
|
|
case "acsch":
|
|
div2 = true;
|
|
negative = true;
|
|
funcDerivative = new OperatorNode2("*", "multiply", [new FunctionNode2("abs", [arg0.clone()]), new FunctionNode2("sqrt", [new OperatorNode2("+", "add", [new OperatorNode2("^", "pow", [arg0.clone(), createConstantNode2(2)]), createConstantNode2(1)])])]);
|
|
break;
|
|
case "acoth":
|
|
div2 = true;
|
|
negative = true;
|
|
funcDerivative = new OperatorNode2("-", "subtract", [createConstantNode2(1), new OperatorNode2("^", "pow", [arg0.clone(), createConstantNode2(2)])]);
|
|
break;
|
|
case "abs":
|
|
funcDerivative = new OperatorNode2("/", "divide", [new FunctionNode2(new SymbolNode2("abs"), [arg0.clone()]), arg0.clone()]);
|
|
break;
|
|
case "gamma":
|
|
default:
|
|
throw new Error('Function "' + node.name + '" is not supported by derivative, or a wrong number of arguments is passed');
|
|
}
|
|
var op, func;
|
|
if (div2) {
|
|
op = "/";
|
|
func = "divide";
|
|
} else {
|
|
op = "*";
|
|
func = "multiply";
|
|
}
|
|
var chainDerivative = _derivative(arg0, constNodes);
|
|
if (negative) {
|
|
chainDerivative = new OperatorNode2("-", "unaryMinus", [chainDerivative]);
|
|
}
|
|
return new OperatorNode2(op, func, [chainDerivative, funcDerivative]);
|
|
},
|
|
"OperatorNode, Object": function OperatorNodeObject(node, constNodes) {
|
|
if (constNodes[node] !== void 0) {
|
|
return createConstantNode2(0);
|
|
}
|
|
if (node.op === "+") {
|
|
return new OperatorNode2(node.op, node.fn, node.args.map(function(arg2) {
|
|
return _derivative(arg2, constNodes);
|
|
}));
|
|
}
|
|
if (node.op === "-") {
|
|
if (node.isUnary()) {
|
|
return new OperatorNode2(node.op, node.fn, [_derivative(node.args[0], constNodes)]);
|
|
}
|
|
if (node.isBinary()) {
|
|
return new OperatorNode2(node.op, node.fn, [_derivative(node.args[0], constNodes), _derivative(node.args[1], constNodes)]);
|
|
}
|
|
}
|
|
if (node.op === "*") {
|
|
var constantTerms = node.args.filter(function(arg2) {
|
|
return constNodes[arg2] !== void 0;
|
|
});
|
|
if (constantTerms.length > 0) {
|
|
var nonConstantTerms = node.args.filter(function(arg2) {
|
|
return constNodes[arg2] === void 0;
|
|
});
|
|
var nonConstantNode = nonConstantTerms.length === 1 ? nonConstantTerms[0] : new OperatorNode2("*", "multiply", nonConstantTerms);
|
|
var newArgs = constantTerms.concat(_derivative(nonConstantNode, constNodes));
|
|
return new OperatorNode2("*", "multiply", newArgs);
|
|
}
|
|
return new OperatorNode2("+", "add", node.args.map(function(argOuter) {
|
|
return new OperatorNode2("*", "multiply", node.args.map(function(argInner) {
|
|
return argInner === argOuter ? _derivative(argInner, constNodes) : argInner.clone();
|
|
}));
|
|
}));
|
|
}
|
|
if (node.op === "/" && node.isBinary()) {
|
|
var arg0 = node.args[0];
|
|
var arg1 = node.args[1];
|
|
if (constNodes[arg1] !== void 0) {
|
|
return new OperatorNode2("/", "divide", [_derivative(arg0, constNodes), arg1]);
|
|
}
|
|
if (constNodes[arg0] !== void 0) {
|
|
return new OperatorNode2("*", "multiply", [new OperatorNode2("-", "unaryMinus", [arg0]), new OperatorNode2("/", "divide", [_derivative(arg1, constNodes), new OperatorNode2("^", "pow", [arg1.clone(), createConstantNode2(2)])])]);
|
|
}
|
|
return new OperatorNode2("/", "divide", [new OperatorNode2("-", "subtract", [new OperatorNode2("*", "multiply", [_derivative(arg0, constNodes), arg1.clone()]), new OperatorNode2("*", "multiply", [arg0.clone(), _derivative(arg1, constNodes)])]), new OperatorNode2("^", "pow", [arg1.clone(), createConstantNode2(2)])]);
|
|
}
|
|
if (node.op === "^" && node.isBinary()) {
|
|
var _arg = node.args[0];
|
|
var _arg2 = node.args[1];
|
|
if (constNodes[_arg] !== void 0) {
|
|
if (isConstantNode(_arg) && (isZero2(_arg.value) || equal2(_arg.value, 1))) {
|
|
return createConstantNode2(0);
|
|
}
|
|
return new OperatorNode2("*", "multiply", [node, new OperatorNode2("*", "multiply", [new FunctionNode2("log", [_arg.clone()]), _derivative(_arg2.clone(), constNodes)])]);
|
|
}
|
|
if (constNodes[_arg2] !== void 0) {
|
|
if (isConstantNode(_arg2)) {
|
|
if (isZero2(_arg2.value)) {
|
|
return createConstantNode2(0);
|
|
}
|
|
if (equal2(_arg2.value, 1)) {
|
|
return _derivative(_arg, constNodes);
|
|
}
|
|
}
|
|
var powMinusOne = new OperatorNode2("^", "pow", [_arg.clone(), new OperatorNode2("-", "subtract", [_arg2, createConstantNode2(1)])]);
|
|
return new OperatorNode2("*", "multiply", [_arg2.clone(), new OperatorNode2("*", "multiply", [_derivative(_arg, constNodes), powMinusOne])]);
|
|
}
|
|
return new OperatorNode2("*", "multiply", [new OperatorNode2("^", "pow", [_arg.clone(), _arg2.clone()]), new OperatorNode2("+", "add", [new OperatorNode2("*", "multiply", [_derivative(_arg, constNodes), new OperatorNode2("/", "divide", [_arg2.clone(), _arg.clone()])]), new OperatorNode2("*", "multiply", [_derivative(_arg2, constNodes), new FunctionNode2("log", [_arg.clone()])])])]);
|
|
}
|
|
throw new Error('Operator "' + node.op + '" is not supported by derivative, or a wrong number of arguments is passed');
|
|
}
|
|
});
|
|
function funcArgsCheck(node) {
|
|
if ((node.name === "log" || node.name === "nthRoot" || node.name === "pow") && node.args.length === 2) {
|
|
return;
|
|
}
|
|
for (var i2 = 0; i2 < node.args.length; ++i2) {
|
|
node.args[i2] = createConstantNode2(0);
|
|
}
|
|
node.compile().evaluate();
|
|
throw new Error("Expected TypeError, but none found");
|
|
}
|
|
function createConstantNode2(value, valueType) {
|
|
return new ConstantNode2(numeric3(value, valueType || config4.number));
|
|
}
|
|
return derivative2;
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/function/algebra/rationalize.js
|
|
var name281 = "rationalize";
|
|
var dependencies281 = ["config", "typed", "equal", "isZero", "add", "subtract", "multiply", "divide", "pow", "parse", "simplifyConstant", "simplifyCore", "simplify", "?bignumber", "?fraction", "mathWithTransform", "matrix", "AccessorNode", "ArrayNode", "ConstantNode", "FunctionNode", "IndexNode", "ObjectNode", "OperatorNode", "SymbolNode", "ParenthesisNode"];
|
|
var createRationalize = /* @__PURE__ */ factory(name281, dependencies281, (_ref) => {
|
|
var {
|
|
config: config4,
|
|
typed: typed2,
|
|
equal: equal2,
|
|
isZero: isZero2,
|
|
add: add3,
|
|
subtract: subtract2,
|
|
multiply: multiply2,
|
|
divide: divide3,
|
|
pow: pow3,
|
|
parse: parse2,
|
|
simplifyConstant: simplifyConstant2,
|
|
simplifyCore: simplifyCore2,
|
|
simplify: simplify2,
|
|
fraction: fraction2,
|
|
bignumber: bignumber2,
|
|
mathWithTransform: mathWithTransform2,
|
|
matrix: matrix2,
|
|
AccessorNode: AccessorNode2,
|
|
ArrayNode: ArrayNode2,
|
|
ConstantNode: ConstantNode2,
|
|
FunctionNode: FunctionNode2,
|
|
IndexNode: IndexNode2,
|
|
ObjectNode: ObjectNode2,
|
|
OperatorNode: OperatorNode2,
|
|
SymbolNode: SymbolNode2,
|
|
ParenthesisNode: ParenthesisNode2
|
|
} = _ref;
|
|
function _rationalize(expr) {
|
|
var scope = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
var detailed = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
var setRules = rulesRationalize();
|
|
var polyRet = polynomial(expr, scope, true, setRules.firstRules);
|
|
var nVars = polyRet.variables.length;
|
|
var noExactFractions = {
|
|
exactFractions: false
|
|
};
|
|
var withExactFractions = {
|
|
exactFractions: true
|
|
};
|
|
expr = polyRet.expression;
|
|
if (nVars >= 1) {
|
|
expr = expandPower(expr);
|
|
var sBefore;
|
|
var rules;
|
|
var eDistrDiv = true;
|
|
var redoInic = false;
|
|
expr = simplify2(expr, setRules.firstRules, {}, noExactFractions);
|
|
var s;
|
|
while (true) {
|
|
rules = eDistrDiv ? setRules.distrDivRules : setRules.sucDivRules;
|
|
expr = simplify2(expr, rules, {}, withExactFractions);
|
|
eDistrDiv = !eDistrDiv;
|
|
s = expr.toString();
|
|
if (s === sBefore) {
|
|
break;
|
|
}
|
|
redoInic = true;
|
|
sBefore = s;
|
|
}
|
|
if (redoInic) {
|
|
expr = simplify2(expr, setRules.firstRulesAgain, {}, noExactFractions);
|
|
}
|
|
expr = simplify2(expr, setRules.finalRules, {}, noExactFractions);
|
|
}
|
|
var coefficients = [];
|
|
var retRationalize = {};
|
|
if (expr.type === "OperatorNode" && expr.isBinary() && expr.op === "/") {
|
|
if (nVars === 1) {
|
|
expr.args[0] = polyToCanonical(expr.args[0], coefficients);
|
|
expr.args[1] = polyToCanonical(expr.args[1]);
|
|
}
|
|
if (detailed) {
|
|
retRationalize.numerator = expr.args[0];
|
|
retRationalize.denominator = expr.args[1];
|
|
}
|
|
} else {
|
|
if (nVars === 1) {
|
|
expr = polyToCanonical(expr, coefficients);
|
|
}
|
|
if (detailed) {
|
|
retRationalize.numerator = expr;
|
|
retRationalize.denominator = null;
|
|
}
|
|
}
|
|
if (!detailed)
|
|
return expr;
|
|
retRationalize.coefficients = coefficients;
|
|
retRationalize.variables = polyRet.variables;
|
|
retRationalize.expression = expr;
|
|
return retRationalize;
|
|
}
|
|
return typed2(name281, {
|
|
Node: _rationalize,
|
|
"Node, boolean": (expr, detailed) => _rationalize(expr, {}, detailed),
|
|
"Node, Object": _rationalize,
|
|
"Node, Object, boolean": _rationalize
|
|
});
|
|
function polynomial(expr, scope, extended, rules) {
|
|
var variables = [];
|
|
var node = simplify2(expr, rules, scope, {
|
|
exactFractions: false
|
|
});
|
|
extended = !!extended;
|
|
var oper = "+-*" + (extended ? "/" : "");
|
|
recPoly(node);
|
|
var retFunc = {};
|
|
retFunc.expression = node;
|
|
retFunc.variables = variables;
|
|
return retFunc;
|
|
function recPoly(node2) {
|
|
var tp = node2.type;
|
|
if (tp === "FunctionNode") {
|
|
throw new Error("There is an unsolved function call");
|
|
} else if (tp === "OperatorNode") {
|
|
if (node2.op === "^") {
|
|
if (node2.args[1].type !== "ConstantNode" || !isInteger(parseFloat(node2.args[1].value))) {
|
|
throw new Error("There is a non-integer exponent");
|
|
} else {
|
|
recPoly(node2.args[0]);
|
|
}
|
|
} else {
|
|
if (oper.indexOf(node2.op) === -1) {
|
|
throw new Error("Operator " + node2.op + " invalid in polynomial expression");
|
|
}
|
|
for (var i2 = 0; i2 < node2.args.length; i2++) {
|
|
recPoly(node2.args[i2]);
|
|
}
|
|
}
|
|
} else if (tp === "SymbolNode") {
|
|
var _name = node2.name;
|
|
var pos = variables.indexOf(_name);
|
|
if (pos === -1) {
|
|
variables.push(_name);
|
|
}
|
|
} else if (tp === "ParenthesisNode") {
|
|
recPoly(node2.content);
|
|
} else if (tp !== "ConstantNode") {
|
|
throw new Error("type " + tp + " is not allowed in polynomial expression");
|
|
}
|
|
}
|
|
}
|
|
function rulesRationalize() {
|
|
var oldRules = [
|
|
simplifyCore2,
|
|
{
|
|
l: "n+n",
|
|
r: "2*n"
|
|
},
|
|
{
|
|
l: "n+-n",
|
|
r: "0"
|
|
},
|
|
simplifyConstant2,
|
|
{
|
|
l: "n*(n1^-1)",
|
|
r: "n/n1"
|
|
},
|
|
{
|
|
l: "n*n1^-n2",
|
|
r: "n/n1^n2"
|
|
},
|
|
{
|
|
l: "n1^-1",
|
|
r: "1/n1"
|
|
},
|
|
{
|
|
l: "n*(n1/n2)",
|
|
r: "(n*n1)/n2"
|
|
},
|
|
{
|
|
l: "1*n",
|
|
r: "n"
|
|
}
|
|
];
|
|
var rulesFirst = [
|
|
{
|
|
l: "(-n1)/(-n2)",
|
|
r: "n1/n2"
|
|
},
|
|
{
|
|
l: "(-n1)*(-n2)",
|
|
r: "n1*n2"
|
|
},
|
|
{
|
|
l: "n1--n2",
|
|
r: "n1+n2"
|
|
},
|
|
{
|
|
l: "n1-n2",
|
|
r: "n1+(-n2)"
|
|
},
|
|
{
|
|
l: "(n1+n2)*n3",
|
|
r: "(n1*n3 + n2*n3)"
|
|
},
|
|
{
|
|
l: "n1*(n2+n3)",
|
|
r: "(n1*n2+n1*n3)"
|
|
},
|
|
{
|
|
l: "c1*n + c2*n",
|
|
r: "(c1+c2)*n"
|
|
},
|
|
{
|
|
l: "c1*n + n",
|
|
r: "(c1+1)*n"
|
|
},
|
|
{
|
|
l: "c1*n - c2*n",
|
|
r: "(c1-c2)*n"
|
|
},
|
|
{
|
|
l: "c1*n - n",
|
|
r: "(c1-1)*n"
|
|
},
|
|
{
|
|
l: "v/c",
|
|
r: "(1/c)*v"
|
|
},
|
|
{
|
|
l: "v/-c",
|
|
r: "-(1/c)*v"
|
|
},
|
|
{
|
|
l: "-v*-c",
|
|
r: "c*v"
|
|
},
|
|
{
|
|
l: "-v*c",
|
|
r: "-c*v"
|
|
},
|
|
{
|
|
l: "v*-c",
|
|
r: "-c*v"
|
|
},
|
|
{
|
|
l: "v*c",
|
|
r: "c*v"
|
|
},
|
|
{
|
|
l: "-(-n1*n2)",
|
|
r: "(n1*n2)"
|
|
},
|
|
{
|
|
l: "-(n1*n2)",
|
|
r: "(-n1*n2)"
|
|
},
|
|
{
|
|
l: "-(-n1+n2)",
|
|
r: "(n1-n2)"
|
|
},
|
|
{
|
|
l: "-(n1+n2)",
|
|
r: "(-n1-n2)"
|
|
},
|
|
{
|
|
l: "(n1^n2)^n3",
|
|
r: "(n1^(n2*n3))"
|
|
},
|
|
{
|
|
l: "-(-n1/n2)",
|
|
r: "(n1/n2)"
|
|
},
|
|
{
|
|
l: "-(n1/n2)",
|
|
r: "(-n1/n2)"
|
|
}
|
|
];
|
|
var rulesDistrDiv = [
|
|
{
|
|
l: "(n1/n2 + n3/n4)",
|
|
r: "((n1*n4 + n3*n2)/(n2*n4))"
|
|
},
|
|
{
|
|
l: "(n1/n2 + n3)",
|
|
r: "((n1 + n3*n2)/n2)"
|
|
},
|
|
{
|
|
l: "(n1 + n2/n3)",
|
|
r: "((n1*n3 + n2)/n3)"
|
|
}
|
|
];
|
|
var rulesSucDiv = [
|
|
{
|
|
l: "(n1/(n2/n3))",
|
|
r: "((n1*n3)/n2)"
|
|
},
|
|
{
|
|
l: "(n1/n2/n3)",
|
|
r: "(n1/(n2*n3))"
|
|
}
|
|
];
|
|
var setRules = {};
|
|
setRules.firstRules = oldRules.concat(rulesFirst, rulesSucDiv);
|
|
setRules.distrDivRules = rulesDistrDiv;
|
|
setRules.sucDivRules = rulesSucDiv;
|
|
setRules.firstRulesAgain = oldRules.concat(rulesFirst);
|
|
setRules.finalRules = [
|
|
simplifyCore2,
|
|
{
|
|
l: "n*-n",
|
|
r: "-n^2"
|
|
},
|
|
{
|
|
l: "n*n",
|
|
r: "n^2"
|
|
},
|
|
simplifyConstant2,
|
|
{
|
|
l: "n*-n^n1",
|
|
r: "-n^(n1+1)"
|
|
},
|
|
{
|
|
l: "n*n^n1",
|
|
r: "n^(n1+1)"
|
|
},
|
|
{
|
|
l: "n^n1*-n^n2",
|
|
r: "-n^(n1+n2)"
|
|
},
|
|
{
|
|
l: "n^n1*n^n2",
|
|
r: "n^(n1+n2)"
|
|
},
|
|
{
|
|
l: "n^n1*-n",
|
|
r: "-n^(n1+1)"
|
|
},
|
|
{
|
|
l: "n^n1*n",
|
|
r: "n^(n1+1)"
|
|
},
|
|
{
|
|
l: "n^n1/-n",
|
|
r: "-n^(n1-1)"
|
|
},
|
|
{
|
|
l: "n^n1/n",
|
|
r: "n^(n1-1)"
|
|
},
|
|
{
|
|
l: "n/-n^n1",
|
|
r: "-n^(1-n1)"
|
|
},
|
|
{
|
|
l: "n/n^n1",
|
|
r: "n^(1-n1)"
|
|
},
|
|
{
|
|
l: "n^n1/-n^n2",
|
|
r: "n^(n1-n2)"
|
|
},
|
|
{
|
|
l: "n^n1/n^n2",
|
|
r: "n^(n1-n2)"
|
|
},
|
|
{
|
|
l: "n1+(-n2*n3)",
|
|
r: "n1-n2*n3"
|
|
},
|
|
{
|
|
l: "v*(-c)",
|
|
r: "-c*v"
|
|
},
|
|
{
|
|
l: "n1+-n2",
|
|
r: "n1-n2"
|
|
},
|
|
{
|
|
l: "v*c",
|
|
r: "c*v"
|
|
},
|
|
{
|
|
l: "(n1^n2)^n3",
|
|
r: "(n1^(n2*n3))"
|
|
}
|
|
];
|
|
return setRules;
|
|
}
|
|
function expandPower(node, parent, indParent) {
|
|
var tp = node.type;
|
|
var internal = arguments.length > 1;
|
|
if (tp === "OperatorNode" && node.isBinary()) {
|
|
var does = false;
|
|
var val;
|
|
if (node.op === "^") {
|
|
if ((node.args[0].type === "ParenthesisNode" || node.args[0].type === "OperatorNode") && node.args[1].type === "ConstantNode") {
|
|
val = parseFloat(node.args[1].value);
|
|
does = val >= 2 && isInteger(val);
|
|
}
|
|
}
|
|
if (does) {
|
|
if (val > 2) {
|
|
var nEsqTopo = node.args[0];
|
|
var nDirTopo = new OperatorNode2("^", "pow", [node.args[0].cloneDeep(), new ConstantNode2(val - 1)]);
|
|
node = new OperatorNode2("*", "multiply", [nEsqTopo, nDirTopo]);
|
|
} else {
|
|
node = new OperatorNode2("*", "multiply", [node.args[0], node.args[0].cloneDeep()]);
|
|
}
|
|
if (internal) {
|
|
if (indParent === "content") {
|
|
parent.content = node;
|
|
} else {
|
|
parent.args[indParent] = node;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (tp === "ParenthesisNode") {
|
|
expandPower(node.content, node, "content");
|
|
} else if (tp !== "ConstantNode" && tp !== "SymbolNode") {
|
|
for (var i2 = 0; i2 < node.args.length; i2++) {
|
|
expandPower(node.args[i2], node, i2);
|
|
}
|
|
}
|
|
if (!internal) {
|
|
return node;
|
|
}
|
|
}
|
|
function polyToCanonical(node, coefficients) {
|
|
if (coefficients === void 0) {
|
|
coefficients = [];
|
|
}
|
|
coefficients[0] = 0;
|
|
var o = {};
|
|
o.cte = 1;
|
|
o.oper = "+";
|
|
o.fire = "";
|
|
var maxExpo = 0;
|
|
var varname = "";
|
|
recurPol(node, null, o);
|
|
maxExpo = coefficients.length - 1;
|
|
var first = true;
|
|
var no;
|
|
for (var i2 = maxExpo; i2 >= 0; i2--) {
|
|
if (coefficients[i2] === 0)
|
|
continue;
|
|
var n16 = new ConstantNode2(first ? coefficients[i2] : Math.abs(coefficients[i2]));
|
|
var op = coefficients[i2] < 0 ? "-" : "+";
|
|
if (i2 > 0) {
|
|
var n25 = new SymbolNode2(varname);
|
|
if (i2 > 1) {
|
|
var n3 = new ConstantNode2(i2);
|
|
n25 = new OperatorNode2("^", "pow", [n25, n3]);
|
|
}
|
|
if (coefficients[i2] === -1 && first) {
|
|
n16 = new OperatorNode2("-", "unaryMinus", [n25]);
|
|
} else if (Math.abs(coefficients[i2]) === 1) {
|
|
n16 = n25;
|
|
} else {
|
|
n16 = new OperatorNode2("*", "multiply", [n16, n25]);
|
|
}
|
|
}
|
|
if (first) {
|
|
no = n16;
|
|
} else if (op === "+") {
|
|
no = new OperatorNode2("+", "add", [no, n16]);
|
|
} else {
|
|
no = new OperatorNode2("-", "subtract", [no, n16]);
|
|
}
|
|
first = false;
|
|
}
|
|
if (first) {
|
|
return new ConstantNode2(0);
|
|
} else {
|
|
return no;
|
|
}
|
|
function recurPol(node2, noPai, o2) {
|
|
var tp = node2.type;
|
|
if (tp === "FunctionNode") {
|
|
throw new Error("There is an unsolved function call");
|
|
} else if (tp === "OperatorNode") {
|
|
if ("+-*^".indexOf(node2.op) === -1)
|
|
throw new Error("Operator " + node2.op + " invalid");
|
|
if (noPai !== null) {
|
|
if ((node2.fn === "unaryMinus" || node2.fn === "pow") && noPai.fn !== "add" && noPai.fn !== "subtract" && noPai.fn !== "multiply") {
|
|
throw new Error("Invalid " + node2.op + " placing");
|
|
}
|
|
if ((node2.fn === "subtract" || node2.fn === "add" || node2.fn === "multiply") && noPai.fn !== "add" && noPai.fn !== "subtract") {
|
|
throw new Error("Invalid " + node2.op + " placing");
|
|
}
|
|
if ((node2.fn === "subtract" || node2.fn === "add" || node2.fn === "unaryMinus") && o2.noFil !== 0) {
|
|
throw new Error("Invalid " + node2.op + " placing");
|
|
}
|
|
}
|
|
if (node2.op === "^" || node2.op === "*") {
|
|
o2.fire = node2.op;
|
|
}
|
|
for (var _i = 0; _i < node2.args.length; _i++) {
|
|
if (node2.fn === "unaryMinus")
|
|
o2.oper = "-";
|
|
if (node2.op === "+" || node2.fn === "subtract") {
|
|
o2.fire = "";
|
|
o2.cte = 1;
|
|
o2.oper = _i === 0 ? "+" : node2.op;
|
|
}
|
|
o2.noFil = _i;
|
|
recurPol(node2.args[_i], node2, o2);
|
|
}
|
|
} else if (tp === "SymbolNode") {
|
|
if (node2.name !== varname && varname !== "") {
|
|
throw new Error("There is more than one variable");
|
|
}
|
|
varname = node2.name;
|
|
if (noPai === null) {
|
|
coefficients[1] = 1;
|
|
return;
|
|
}
|
|
if (noPai.op === "^" && o2.noFil !== 0) {
|
|
throw new Error("In power the variable should be the first parameter");
|
|
}
|
|
if (noPai.op === "*" && o2.noFil !== 1) {
|
|
throw new Error("In multiply the variable should be the second parameter");
|
|
}
|
|
if (o2.fire === "" || o2.fire === "*") {
|
|
if (maxExpo < 1)
|
|
coefficients[1] = 0;
|
|
coefficients[1] += o2.cte * (o2.oper === "+" ? 1 : -1);
|
|
maxExpo = Math.max(1, maxExpo);
|
|
}
|
|
} else if (tp === "ConstantNode") {
|
|
var valor = parseFloat(node2.value);
|
|
if (noPai === null) {
|
|
coefficients[0] = valor;
|
|
return;
|
|
}
|
|
if (noPai.op === "^") {
|
|
if (o2.noFil !== 1)
|
|
throw new Error("Constant cannot be powered");
|
|
if (!isInteger(valor) || valor <= 0) {
|
|
throw new Error("Non-integer exponent is not allowed");
|
|
}
|
|
for (var _i2 = maxExpo + 1; _i2 < valor; _i2++) {
|
|
coefficients[_i2] = 0;
|
|
}
|
|
if (valor > maxExpo)
|
|
coefficients[valor] = 0;
|
|
coefficients[valor] += o2.cte * (o2.oper === "+" ? 1 : -1);
|
|
maxExpo = Math.max(valor, maxExpo);
|
|
return;
|
|
}
|
|
o2.cte = valor;
|
|
if (o2.fire === "") {
|
|
coefficients[0] += o2.cte * (o2.oper === "+" ? 1 : -1);
|
|
}
|
|
} else {
|
|
throw new Error("Type " + tp + " is not allowed");
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/json/reviver.js
|
|
var name282 = "reviver";
|
|
var dependencies282 = ["classes"];
|
|
var createReviver = /* @__PURE__ */ factory(name282, dependencies282, (_ref) => {
|
|
var {
|
|
classes: classes2
|
|
} = _ref;
|
|
return function reviver2(key, value) {
|
|
var constructor = classes2[value && value.mathjs];
|
|
if (constructor && typeof constructor.fromJSON === "function") {
|
|
return constructor.fromJSON(value);
|
|
}
|
|
return value;
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/json/replacer.js
|
|
var name283 = "replacer";
|
|
var dependencies283 = [];
|
|
var createReplacer = /* @__PURE__ */ factory(name283, dependencies283, () => {
|
|
return function replacer2(key, value) {
|
|
if (typeof value === "number" && (!isFinite(value) || isNaN(value))) {
|
|
return {
|
|
mathjs: "number",
|
|
value: String(value)
|
|
};
|
|
}
|
|
return value;
|
|
};
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/version.js
|
|
var version = "11.6.0";
|
|
|
|
// node_modules/mathjs/lib/esm/constants.js
|
|
var createTrue = /* @__PURE__ */ factory("true", [], () => true);
|
|
var createFalse = /* @__PURE__ */ factory("false", [], () => false);
|
|
var createNull = /* @__PURE__ */ factory("null", [], () => null);
|
|
var createInfinity = /* @__PURE__ */ recreateFactory("Infinity", ["config", "?BigNumber"], (_ref) => {
|
|
var {
|
|
config: config4,
|
|
BigNumber: BigNumber2
|
|
} = _ref;
|
|
return config4.number === "BigNumber" ? new BigNumber2(Infinity) : Infinity;
|
|
});
|
|
var createNaN = /* @__PURE__ */ recreateFactory("NaN", ["config", "?BigNumber"], (_ref2) => {
|
|
var {
|
|
config: config4,
|
|
BigNumber: BigNumber2
|
|
} = _ref2;
|
|
return config4.number === "BigNumber" ? new BigNumber2(NaN) : NaN;
|
|
});
|
|
var createPi = /* @__PURE__ */ recreateFactory("pi", ["config", "?BigNumber"], (_ref3) => {
|
|
var {
|
|
config: config4,
|
|
BigNumber: BigNumber2
|
|
} = _ref3;
|
|
return config4.number === "BigNumber" ? createBigNumberPi(BigNumber2) : pi;
|
|
});
|
|
var createTau = /* @__PURE__ */ recreateFactory("tau", ["config", "?BigNumber"], (_ref4) => {
|
|
var {
|
|
config: config4,
|
|
BigNumber: BigNumber2
|
|
} = _ref4;
|
|
return config4.number === "BigNumber" ? createBigNumberTau(BigNumber2) : tau;
|
|
});
|
|
var createE = /* @__PURE__ */ recreateFactory("e", ["config", "?BigNumber"], (_ref5) => {
|
|
var {
|
|
config: config4,
|
|
BigNumber: BigNumber2
|
|
} = _ref5;
|
|
return config4.number === "BigNumber" ? createBigNumberE(BigNumber2) : e;
|
|
});
|
|
var createPhi = /* @__PURE__ */ recreateFactory("phi", ["config", "?BigNumber"], (_ref6) => {
|
|
var {
|
|
config: config4,
|
|
BigNumber: BigNumber2
|
|
} = _ref6;
|
|
return config4.number === "BigNumber" ? createBigNumberPhi(BigNumber2) : phi;
|
|
});
|
|
var createLN2 = /* @__PURE__ */ recreateFactory("LN2", ["config", "?BigNumber"], (_ref7) => {
|
|
var {
|
|
config: config4,
|
|
BigNumber: BigNumber2
|
|
} = _ref7;
|
|
return config4.number === "BigNumber" ? new BigNumber2(2).ln() : Math.LN2;
|
|
});
|
|
var createLN10 = /* @__PURE__ */ recreateFactory("LN10", ["config", "?BigNumber"], (_ref8) => {
|
|
var {
|
|
config: config4,
|
|
BigNumber: BigNumber2
|
|
} = _ref8;
|
|
return config4.number === "BigNumber" ? new BigNumber2(10).ln() : Math.LN10;
|
|
});
|
|
var createLOG2E = /* @__PURE__ */ recreateFactory("LOG2E", ["config", "?BigNumber"], (_ref9) => {
|
|
var {
|
|
config: config4,
|
|
BigNumber: BigNumber2
|
|
} = _ref9;
|
|
return config4.number === "BigNumber" ? new BigNumber2(1).div(new BigNumber2(2).ln()) : Math.LOG2E;
|
|
});
|
|
var createLOG10E = /* @__PURE__ */ recreateFactory("LOG10E", ["config", "?BigNumber"], (_ref10) => {
|
|
var {
|
|
config: config4,
|
|
BigNumber: BigNumber2
|
|
} = _ref10;
|
|
return config4.number === "BigNumber" ? new BigNumber2(1).div(new BigNumber2(10).ln()) : Math.LOG10E;
|
|
});
|
|
var createSQRT1_2 = /* @__PURE__ */ recreateFactory("SQRT1_2", ["config", "?BigNumber"], (_ref11) => {
|
|
var {
|
|
config: config4,
|
|
BigNumber: BigNumber2
|
|
} = _ref11;
|
|
return config4.number === "BigNumber" ? new BigNumber2("0.5").sqrt() : Math.SQRT1_2;
|
|
});
|
|
var createSQRT2 = /* @__PURE__ */ recreateFactory("SQRT2", ["config", "?BigNumber"], (_ref12) => {
|
|
var {
|
|
config: config4,
|
|
BigNumber: BigNumber2
|
|
} = _ref12;
|
|
return config4.number === "BigNumber" ? new BigNumber2(2).sqrt() : Math.SQRT2;
|
|
});
|
|
var createI = /* @__PURE__ */ recreateFactory("i", ["Complex"], (_ref13) => {
|
|
var {
|
|
Complex: Complex3
|
|
} = _ref13;
|
|
return Complex3.I;
|
|
});
|
|
var createVersion = /* @__PURE__ */ factory("version", [], () => version);
|
|
function recreateFactory(name302, dependencies302, create) {
|
|
return factory(name302, dependencies302, create, {
|
|
recreateOnConfigChange: true
|
|
});
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/type/unit/physicalConstants.js
|
|
var createSpeedOfLight = /* @__PURE__ */ unitFactory("speedOfLight", "299792458", "m s^-1");
|
|
var createGravitationConstant = /* @__PURE__ */ unitFactory("gravitationConstant", "6.67430e-11", "m^3 kg^-1 s^-2");
|
|
var createPlanckConstant = /* @__PURE__ */ unitFactory("planckConstant", "6.62607015e-34", "J s");
|
|
var createReducedPlanckConstant = /* @__PURE__ */ unitFactory("reducedPlanckConstant", "1.0545718176461565e-34", "J s");
|
|
var createMagneticConstant = /* @__PURE__ */ unitFactory("magneticConstant", "1.25663706212e-6", "N A^-2");
|
|
var createElectricConstant = /* @__PURE__ */ unitFactory("electricConstant", "8.8541878128e-12", "F m^-1");
|
|
var createVacuumImpedance = /* @__PURE__ */ unitFactory("vacuumImpedance", "376.730313667", "ohm");
|
|
var createCoulomb = /* @__PURE__ */ unitFactory("coulomb", "8.987551792261171e9", "N m^2 C^-2");
|
|
var createElementaryCharge = /* @__PURE__ */ unitFactory("elementaryCharge", "1.602176634e-19", "C");
|
|
var createBohrMagneton = /* @__PURE__ */ unitFactory("bohrMagneton", "9.2740100783e-24", "J T^-1");
|
|
var createConductanceQuantum = /* @__PURE__ */ unitFactory("conductanceQuantum", "7.748091729863649e-5", "S");
|
|
var createInverseConductanceQuantum = /* @__PURE__ */ unitFactory("inverseConductanceQuantum", "12906.403729652257", "ohm");
|
|
var createMagneticFluxQuantum = /* @__PURE__ */ unitFactory("magneticFluxQuantum", "2.0678338484619295e-15", "Wb");
|
|
var createNuclearMagneton = /* @__PURE__ */ unitFactory("nuclearMagneton", "5.0507837461e-27", "J T^-1");
|
|
var createKlitzing = /* @__PURE__ */ unitFactory("klitzing", "25812.807459304513", "ohm");
|
|
var createBohrRadius = /* @__PURE__ */ unitFactory("bohrRadius", "5.29177210903e-11", "m");
|
|
var createClassicalElectronRadius = /* @__PURE__ */ unitFactory("classicalElectronRadius", "2.8179403262e-15", "m");
|
|
var createElectronMass = /* @__PURE__ */ unitFactory("electronMass", "9.1093837015e-31", "kg");
|
|
var createFermiCoupling = /* @__PURE__ */ unitFactory("fermiCoupling", "1.1663787e-5", "GeV^-2");
|
|
var createFineStructure = numberFactory("fineStructure", 0.0072973525693);
|
|
var createHartreeEnergy = /* @__PURE__ */ unitFactory("hartreeEnergy", "4.3597447222071e-18", "J");
|
|
var createProtonMass = /* @__PURE__ */ unitFactory("protonMass", "1.67262192369e-27", "kg");
|
|
var createDeuteronMass = /* @__PURE__ */ unitFactory("deuteronMass", "3.3435830926e-27", "kg");
|
|
var createNeutronMass = /* @__PURE__ */ unitFactory("neutronMass", "1.6749271613e-27", "kg");
|
|
var createQuantumOfCirculation = /* @__PURE__ */ unitFactory("quantumOfCirculation", "3.6369475516e-4", "m^2 s^-1");
|
|
var createRydberg = /* @__PURE__ */ unitFactory("rydberg", "10973731.568160", "m^-1");
|
|
var createThomsonCrossSection = /* @__PURE__ */ unitFactory("thomsonCrossSection", "6.6524587321e-29", "m^2");
|
|
var createWeakMixingAngle = numberFactory("weakMixingAngle", 0.2229);
|
|
var createEfimovFactor = numberFactory("efimovFactor", 22.7);
|
|
var createAtomicMass = /* @__PURE__ */ unitFactory("atomicMass", "1.66053906660e-27", "kg");
|
|
var createAvogadro = /* @__PURE__ */ unitFactory("avogadro", "6.02214076e23", "mol^-1");
|
|
var createBoltzmann = /* @__PURE__ */ unitFactory("boltzmann", "1.380649e-23", "J K^-1");
|
|
var createFaraday = /* @__PURE__ */ unitFactory("faraday", "96485.33212331001", "C mol^-1");
|
|
var createFirstRadiation = /* @__PURE__ */ unitFactory("firstRadiation", "3.7417718521927573e-16", "W m^2");
|
|
var createLoschmidt = /* @__PURE__ */ unitFactory("loschmidt", "2.686780111798444e25", "m^-3");
|
|
var createGasConstant = /* @__PURE__ */ unitFactory("gasConstant", "8.31446261815324", "J K^-1 mol^-1");
|
|
var createMolarPlanckConstant = /* @__PURE__ */ unitFactory("molarPlanckConstant", "3.990312712893431e-10", "J s mol^-1");
|
|
var createMolarVolume = /* @__PURE__ */ unitFactory("molarVolume", "0.022413969545014137", "m^3 mol^-1");
|
|
var createSackurTetrode = numberFactory("sackurTetrode", -1.16487052358);
|
|
var createSecondRadiation = /* @__PURE__ */ unitFactory("secondRadiation", "0.014387768775039337", "m K");
|
|
var createStefanBoltzmann = /* @__PURE__ */ unitFactory("stefanBoltzmann", "5.67037441918443e-8", "W m^-2 K^-4");
|
|
var createWienDisplacement = /* @__PURE__ */ unitFactory("wienDisplacement", "2.897771955e-3", "m K");
|
|
var createMolarMass = /* @__PURE__ */ unitFactory("molarMass", "0.99999999965e-3", "kg mol^-1");
|
|
var createMolarMassC12 = /* @__PURE__ */ unitFactory("molarMassC12", "11.9999999958e-3", "kg mol^-1");
|
|
var createGravity = /* @__PURE__ */ unitFactory("gravity", "9.80665", "m s^-2");
|
|
var createPlanckLength = /* @__PURE__ */ unitFactory("planckLength", "1.616255e-35", "m");
|
|
var createPlanckMass = /* @__PURE__ */ unitFactory("planckMass", "2.176435e-8", "kg");
|
|
var createPlanckTime = /* @__PURE__ */ unitFactory("planckTime", "5.391245e-44", "s");
|
|
var createPlanckCharge = /* @__PURE__ */ unitFactory("planckCharge", "1.87554603778e-18", "C");
|
|
var createPlanckTemperature = /* @__PURE__ */ unitFactory("planckTemperature", "1.416785e+32", "K");
|
|
function unitFactory(name302, valueStr, unitStr) {
|
|
var dependencies302 = ["config", "Unit", "BigNumber"];
|
|
return factory(name302, dependencies302, (_ref) => {
|
|
var {
|
|
config: config4,
|
|
Unit: Unit2,
|
|
BigNumber: BigNumber2
|
|
} = _ref;
|
|
var value = config4.number === "BigNumber" ? new BigNumber2(valueStr) : parseFloat(valueStr);
|
|
var unit2 = new Unit2(value, unitStr);
|
|
unit2.fixPrefix = true;
|
|
return unit2;
|
|
});
|
|
}
|
|
function numberFactory(name302, value) {
|
|
var dependencies302 = ["config", "BigNumber"];
|
|
return factory(name302, dependencies302, (_ref2) => {
|
|
var {
|
|
config: config4,
|
|
BigNumber: BigNumber2
|
|
} = _ref2;
|
|
return config4.number === "BigNumber" ? new BigNumber2(value) : value;
|
|
});
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/apply.transform.js
|
|
var name284 = "apply";
|
|
var dependencies284 = ["typed", "isInteger"];
|
|
var createApplyTransform = /* @__PURE__ */ factory(name284, dependencies284, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
isInteger: isInteger3
|
|
} = _ref;
|
|
var apply2 = createApply({
|
|
typed: typed2,
|
|
isInteger: isInteger3
|
|
});
|
|
return typed2("apply", {
|
|
"...any": function any(args) {
|
|
var dim = args[1];
|
|
if (isNumber(dim)) {
|
|
args[1] = dim - 1;
|
|
} else if (isBigNumber(dim)) {
|
|
args[1] = dim.minus(1);
|
|
}
|
|
try {
|
|
return apply2.apply(null, args);
|
|
} catch (err) {
|
|
throw errorTransform(err);
|
|
}
|
|
}
|
|
});
|
|
}, {
|
|
isTransformFunction: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/column.transform.js
|
|
var name285 = "column";
|
|
var dependencies285 = ["typed", "Index", "matrix", "range"];
|
|
var createColumnTransform = /* @__PURE__ */ factory(name285, dependencies285, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
Index: Index2,
|
|
matrix: matrix2,
|
|
range: range2
|
|
} = _ref;
|
|
var column2 = createColumn({
|
|
typed: typed2,
|
|
Index: Index2,
|
|
matrix: matrix2,
|
|
range: range2
|
|
});
|
|
return typed2("column", {
|
|
"...any": function any(args) {
|
|
var lastIndex = args.length - 1;
|
|
var last = args[lastIndex];
|
|
if (isNumber(last)) {
|
|
args[lastIndex] = last - 1;
|
|
}
|
|
try {
|
|
return column2.apply(null, args);
|
|
} catch (err) {
|
|
throw errorTransform(err);
|
|
}
|
|
}
|
|
});
|
|
}, {
|
|
isTransformFunction: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/utils/compileInlineExpression.js
|
|
function compileInlineExpression(expression, math2, scope) {
|
|
var symbol = expression.filter(function(node) {
|
|
return isSymbolNode(node) && !(node.name in math2) && !scope.has(node.name);
|
|
})[0];
|
|
if (!symbol) {
|
|
throw new Error('No undefined variable found in inline expression "' + expression + '"');
|
|
}
|
|
var name302 = symbol.name;
|
|
var subScope = createSubScope(scope);
|
|
var eq = expression.compile();
|
|
return function inlineExpression(x) {
|
|
subScope.set(name302, x);
|
|
return eq.evaluate(subScope);
|
|
};
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/filter.transform.js
|
|
var name286 = "filter";
|
|
var dependencies286 = ["typed"];
|
|
var createFilterTransform = /* @__PURE__ */ factory(name286, dependencies286, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
function filterTransform(args, math2, scope) {
|
|
var x, callback;
|
|
if (args[0]) {
|
|
x = args[0].compile().evaluate(scope);
|
|
}
|
|
if (args[1]) {
|
|
if (isSymbolNode(args[1]) || isFunctionAssignmentNode(args[1])) {
|
|
callback = args[1].compile().evaluate(scope);
|
|
} else {
|
|
callback = compileInlineExpression(args[1], math2, scope);
|
|
}
|
|
}
|
|
return filter3(x, callback);
|
|
}
|
|
filterTransform.rawArgs = true;
|
|
var filter3 = typed2("filter", {
|
|
"Array, function": _filter,
|
|
"Matrix, function": function MatrixFunction(x, test) {
|
|
return x.create(_filter(x.toArray(), test));
|
|
},
|
|
"Array, RegExp": filterRegExp,
|
|
"Matrix, RegExp": function MatrixRegExp(x, test) {
|
|
return x.create(filterRegExp(x.toArray(), test));
|
|
}
|
|
});
|
|
return filterTransform;
|
|
}, {
|
|
isTransformFunction: true
|
|
});
|
|
function _filter(x, callback) {
|
|
var args = maxArgumentCount(callback);
|
|
return filter(x, function(value, index2, array) {
|
|
if (args === 1) {
|
|
return callback(value);
|
|
} else if (args === 2) {
|
|
return callback(value, [index2 + 1]);
|
|
} else {
|
|
return callback(value, [index2 + 1], array);
|
|
}
|
|
});
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/forEach.transform.js
|
|
var name287 = "forEach";
|
|
var dependencies287 = ["typed"];
|
|
var createForEachTransform = /* @__PURE__ */ factory(name287, dependencies287, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
function forEachTransform(args, math2, scope) {
|
|
var x, callback;
|
|
if (args[0]) {
|
|
x = args[0].compile().evaluate(scope);
|
|
}
|
|
if (args[1]) {
|
|
if (isSymbolNode(args[1]) || isFunctionAssignmentNode(args[1])) {
|
|
callback = args[1].compile().evaluate(scope);
|
|
} else {
|
|
callback = compileInlineExpression(args[1], math2, scope);
|
|
}
|
|
}
|
|
return _forEach2(x, callback);
|
|
}
|
|
forEachTransform.rawArgs = true;
|
|
var _forEach2 = typed2("forEach", {
|
|
"Array | Matrix, function": function ArrayMatrixFunction(array, callback) {
|
|
var args = maxArgumentCount(callback);
|
|
var recurse = function recurse2(value, index2) {
|
|
if (Array.isArray(value)) {
|
|
forEach(value, function(child, i2) {
|
|
recurse2(child, index2.concat(i2 + 1));
|
|
});
|
|
} else {
|
|
if (args === 1) {
|
|
callback(value);
|
|
} else if (args === 2) {
|
|
callback(value, index2);
|
|
} else {
|
|
callback(value, index2, array);
|
|
}
|
|
}
|
|
};
|
|
recurse(array.valueOf(), []);
|
|
}
|
|
});
|
|
return forEachTransform;
|
|
}, {
|
|
isTransformFunction: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/index.transform.js
|
|
var name288 = "index";
|
|
var dependencies288 = ["Index"];
|
|
var createIndexTransform = /* @__PURE__ */ factory(name288, dependencies288, (_ref) => {
|
|
var {
|
|
Index: Index2
|
|
} = _ref;
|
|
return function indexTransform() {
|
|
var args = [];
|
|
for (var i2 = 0, ii = arguments.length; i2 < ii; i2++) {
|
|
var arg2 = arguments[i2];
|
|
if (isRange(arg2)) {
|
|
arg2.start--;
|
|
arg2.end -= arg2.step > 0 ? 0 : 2;
|
|
} else if (arg2 && arg2.isSet === true) {
|
|
arg2 = arg2.map(function(v) {
|
|
return v - 1;
|
|
});
|
|
} else if (isArray(arg2) || isMatrix(arg2)) {
|
|
arg2 = arg2.map(function(v) {
|
|
return v - 1;
|
|
});
|
|
} else if (isNumber(arg2)) {
|
|
arg2--;
|
|
} else if (isBigNumber(arg2)) {
|
|
arg2 = arg2.toNumber() - 1;
|
|
} else if (typeof arg2 === "string") {
|
|
} else {
|
|
throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");
|
|
}
|
|
args[i2] = arg2;
|
|
}
|
|
var res = new Index2();
|
|
Index2.apply(res, args);
|
|
return res;
|
|
};
|
|
}, {
|
|
isTransformFunction: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/map.transform.js
|
|
var name289 = "map";
|
|
var dependencies289 = ["typed"];
|
|
var createMapTransform = /* @__PURE__ */ factory(name289, dependencies289, (_ref) => {
|
|
var {
|
|
typed: typed2
|
|
} = _ref;
|
|
function mapTransform(args, math2, scope) {
|
|
var x, callback;
|
|
if (args[0]) {
|
|
x = args[0].compile().evaluate(scope);
|
|
}
|
|
if (args[1]) {
|
|
if (isSymbolNode(args[1]) || isFunctionAssignmentNode(args[1])) {
|
|
callback = args[1].compile().evaluate(scope);
|
|
} else {
|
|
callback = compileInlineExpression(args[1], math2, scope);
|
|
}
|
|
}
|
|
return map3(x, callback);
|
|
}
|
|
mapTransform.rawArgs = true;
|
|
var map3 = typed2("map", {
|
|
"Array, function": function ArrayFunction(x, callback) {
|
|
return _map2(x, callback, x);
|
|
},
|
|
"Matrix, function": function MatrixFunction(x, callback) {
|
|
return x.create(_map2(x.valueOf(), callback, x));
|
|
}
|
|
});
|
|
return mapTransform;
|
|
}, {
|
|
isTransformFunction: true
|
|
});
|
|
function _map2(array, callback, orig) {
|
|
var argsCount = maxArgumentCount(callback);
|
|
function recurse(value, index2) {
|
|
if (Array.isArray(value)) {
|
|
return map(value, function(child, i2) {
|
|
return recurse(child, index2.concat(i2 + 1));
|
|
});
|
|
} else {
|
|
if (argsCount === 1) {
|
|
return callback(value);
|
|
} else if (argsCount === 2) {
|
|
return callback(value, index2);
|
|
} else {
|
|
return callback(value, index2, orig);
|
|
}
|
|
}
|
|
}
|
|
return recurse(array, []);
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/utils/lastDimToZeroBase.js
|
|
function lastDimToZeroBase(args) {
|
|
if (args.length === 2 && isCollection(args[0])) {
|
|
args = args.slice();
|
|
var dim = args[1];
|
|
if (isNumber(dim)) {
|
|
args[1] = dim - 1;
|
|
} else if (isBigNumber(dim)) {
|
|
args[1] = dim.minus(1);
|
|
}
|
|
}
|
|
return args;
|
|
}
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/max.transform.js
|
|
var name290 = "max";
|
|
var dependencies290 = ["typed", "config", "numeric", "larger"];
|
|
var createMaxTransform = /* @__PURE__ */ factory(name290, dependencies290, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
numeric: numeric3,
|
|
larger: larger2
|
|
} = _ref;
|
|
var max3 = createMax({
|
|
typed: typed2,
|
|
config: config4,
|
|
numeric: numeric3,
|
|
larger: larger2
|
|
});
|
|
return typed2("max", {
|
|
"...any": function any(args) {
|
|
args = lastDimToZeroBase(args);
|
|
try {
|
|
return max3.apply(null, args);
|
|
} catch (err) {
|
|
throw errorTransform(err);
|
|
}
|
|
}
|
|
});
|
|
}, {
|
|
isTransformFunction: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/mean.transform.js
|
|
var name291 = "mean";
|
|
var dependencies291 = ["typed", "add", "divide"];
|
|
var createMeanTransform = /* @__PURE__ */ factory(name291, dependencies291, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
add: add3,
|
|
divide: divide3
|
|
} = _ref;
|
|
var mean2 = createMean({
|
|
typed: typed2,
|
|
add: add3,
|
|
divide: divide3
|
|
});
|
|
return typed2("mean", {
|
|
"...any": function any(args) {
|
|
args = lastDimToZeroBase(args);
|
|
try {
|
|
return mean2.apply(null, args);
|
|
} catch (err) {
|
|
throw errorTransform(err);
|
|
}
|
|
}
|
|
});
|
|
}, {
|
|
isTransformFunction: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/min.transform.js
|
|
var name292 = "min";
|
|
var dependencies292 = ["typed", "config", "numeric", "smaller"];
|
|
var createMinTransform = /* @__PURE__ */ factory(name292, dependencies292, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
numeric: numeric3,
|
|
smaller: smaller2
|
|
} = _ref;
|
|
var min3 = createMin({
|
|
typed: typed2,
|
|
config: config4,
|
|
numeric: numeric3,
|
|
smaller: smaller2
|
|
});
|
|
return typed2("min", {
|
|
"...any": function any(args) {
|
|
args = lastDimToZeroBase(args);
|
|
try {
|
|
return min3.apply(null, args);
|
|
} catch (err) {
|
|
throw errorTransform(err);
|
|
}
|
|
}
|
|
});
|
|
}, {
|
|
isTransformFunction: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/range.transform.js
|
|
var name293 = "range";
|
|
var dependencies293 = ["typed", "config", "?matrix", "?bignumber", "smaller", "smallerEq", "larger", "largerEq"];
|
|
var createRangeTransform = /* @__PURE__ */ factory(name293, dependencies293, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
matrix: matrix2,
|
|
bignumber: bignumber2,
|
|
smaller: smaller2,
|
|
smallerEq: smallerEq2,
|
|
larger: larger2,
|
|
largerEq: largerEq2
|
|
} = _ref;
|
|
var range2 = createRange({
|
|
typed: typed2,
|
|
config: config4,
|
|
matrix: matrix2,
|
|
bignumber: bignumber2,
|
|
smaller: smaller2,
|
|
smallerEq: smallerEq2,
|
|
larger: larger2,
|
|
largerEq: largerEq2
|
|
});
|
|
return typed2("range", {
|
|
"...any": function any(args) {
|
|
var lastIndex = args.length - 1;
|
|
var last = args[lastIndex];
|
|
if (typeof last !== "boolean") {
|
|
args.push(true);
|
|
}
|
|
return range2.apply(null, args);
|
|
}
|
|
});
|
|
}, {
|
|
isTransformFunction: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/row.transform.js
|
|
var name294 = "row";
|
|
var dependencies294 = ["typed", "Index", "matrix", "range"];
|
|
var createRowTransform = /* @__PURE__ */ factory(name294, dependencies294, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
Index: Index2,
|
|
matrix: matrix2,
|
|
range: range2
|
|
} = _ref;
|
|
var row2 = createRow({
|
|
typed: typed2,
|
|
Index: Index2,
|
|
matrix: matrix2,
|
|
range: range2
|
|
});
|
|
return typed2("row", {
|
|
"...any": function any(args) {
|
|
var lastIndex = args.length - 1;
|
|
var last = args[lastIndex];
|
|
if (isNumber(last)) {
|
|
args[lastIndex] = last - 1;
|
|
}
|
|
try {
|
|
return row2.apply(null, args);
|
|
} catch (err) {
|
|
throw errorTransform(err);
|
|
}
|
|
}
|
|
});
|
|
}, {
|
|
isTransformFunction: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/subset.transform.js
|
|
var name295 = "subset";
|
|
var dependencies295 = ["typed", "matrix"];
|
|
var createSubsetTransform = /* @__PURE__ */ factory(name295, dependencies295, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2
|
|
} = _ref;
|
|
var subset2 = createSubset({
|
|
typed: typed2,
|
|
matrix: matrix2
|
|
});
|
|
return typed2("subset", {
|
|
"...any": function any(args) {
|
|
try {
|
|
return subset2.apply(null, args);
|
|
} catch (err) {
|
|
throw errorTransform(err);
|
|
}
|
|
}
|
|
});
|
|
}, {
|
|
isTransformFunction: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/concat.transform.js
|
|
var name296 = "concat";
|
|
var dependencies296 = ["typed", "matrix", "isInteger"];
|
|
var createConcatTransform = /* @__PURE__ */ factory(name296, dependencies296, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
isInteger: isInteger3
|
|
} = _ref;
|
|
var concat2 = createConcat({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
isInteger: isInteger3
|
|
});
|
|
return typed2("concat", {
|
|
"...any": function any(args) {
|
|
var lastIndex = args.length - 1;
|
|
var last = args[lastIndex];
|
|
if (isNumber(last)) {
|
|
args[lastIndex] = last - 1;
|
|
} else if (isBigNumber(last)) {
|
|
args[lastIndex] = last.minus(1);
|
|
}
|
|
try {
|
|
return concat2.apply(null, args);
|
|
} catch (err) {
|
|
throw errorTransform(err);
|
|
}
|
|
}
|
|
});
|
|
}, {
|
|
isTransformFunction: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/diff.transform.js
|
|
var name297 = "diff";
|
|
var dependencies297 = ["typed", "matrix", "subtract", "number", "bignumber"];
|
|
var createDiffTransform = /* @__PURE__ */ factory(name297, dependencies297, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
subtract: subtract2,
|
|
number: number2,
|
|
bignumber: bignumber2
|
|
} = _ref;
|
|
var diff2 = createDiff({
|
|
typed: typed2,
|
|
matrix: matrix2,
|
|
subtract: subtract2,
|
|
number: number2,
|
|
bignumber: bignumber2
|
|
});
|
|
return typed2(name297, {
|
|
"...any": function any(args) {
|
|
args = lastDimToZeroBase(args);
|
|
try {
|
|
return diff2.apply(null, args);
|
|
} catch (err) {
|
|
throw errorTransform(err);
|
|
}
|
|
}
|
|
});
|
|
}, {
|
|
isTransformFunction: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/std.transform.js
|
|
var name298 = "std";
|
|
var dependencies298 = ["typed", "map", "sqrt", "variance"];
|
|
var createStdTransform = /* @__PURE__ */ factory(name298, dependencies298, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
map: map3,
|
|
sqrt: sqrt3,
|
|
variance: variance2
|
|
} = _ref;
|
|
var std2 = createStd({
|
|
typed: typed2,
|
|
map: map3,
|
|
sqrt: sqrt3,
|
|
variance: variance2
|
|
});
|
|
return typed2("std", {
|
|
"...any": function any(args) {
|
|
args = lastDimToZeroBase(args);
|
|
try {
|
|
return std2.apply(null, args);
|
|
} catch (err) {
|
|
throw errorTransform(err);
|
|
}
|
|
}
|
|
});
|
|
}, {
|
|
isTransformFunction: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/sum.transform.js
|
|
var name299 = "sum";
|
|
var dependencies299 = ["typed", "config", "add", "numeric"];
|
|
var createSumTransform = /* @__PURE__ */ factory(name299, dependencies299, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
config: config4,
|
|
add: add3,
|
|
numeric: numeric3
|
|
} = _ref;
|
|
var sum3 = createSum({
|
|
typed: typed2,
|
|
config: config4,
|
|
add: add3,
|
|
numeric: numeric3
|
|
});
|
|
return typed2(name299, {
|
|
"...any": function any(args) {
|
|
args = lastDimToZeroBase(args);
|
|
try {
|
|
return sum3.apply(null, args);
|
|
} catch (err) {
|
|
throw errorTransform(err);
|
|
}
|
|
}
|
|
});
|
|
}, {
|
|
isTransformFunction: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/cumsum.transform.js
|
|
var name300 = "cumsum";
|
|
var dependencies300 = ["typed", "add", "unaryPlus"];
|
|
var createCumSumTransform = /* @__PURE__ */ factory(name300, dependencies300, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
add: add3,
|
|
unaryPlus: unaryPlus2
|
|
} = _ref;
|
|
var cumsum2 = createCumSum({
|
|
typed: typed2,
|
|
add: add3,
|
|
unaryPlus: unaryPlus2
|
|
});
|
|
return typed2(name300, {
|
|
"...any": function any(args) {
|
|
if (args.length === 2 && isCollection(args[0])) {
|
|
var dim = args[1];
|
|
if (isNumber(dim)) {
|
|
args[1] = dim - 1;
|
|
} else if (isBigNumber(dim)) {
|
|
args[1] = dim.minus(1);
|
|
}
|
|
}
|
|
try {
|
|
return cumsum2.apply(null, args);
|
|
} catch (err) {
|
|
throw errorTransform(err);
|
|
}
|
|
}
|
|
});
|
|
}, {
|
|
isTransformFunction: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/expression/transform/variance.transform.js
|
|
var name301 = "variance";
|
|
var dependencies301 = ["typed", "add", "subtract", "multiply", "divide", "apply", "isNaN"];
|
|
var createVarianceTransform = /* @__PURE__ */ factory(name301, dependencies301, (_ref) => {
|
|
var {
|
|
typed: typed2,
|
|
add: add3,
|
|
subtract: subtract2,
|
|
multiply: multiply2,
|
|
divide: divide3,
|
|
apply: apply2,
|
|
isNaN: isNaN3
|
|
} = _ref;
|
|
var variance2 = createVariance({
|
|
typed: typed2,
|
|
add: add3,
|
|
subtract: subtract2,
|
|
multiply: multiply2,
|
|
divide: divide3,
|
|
apply: apply2,
|
|
isNaN: isNaN3
|
|
});
|
|
return typed2(name301, {
|
|
"...any": function any(args) {
|
|
args = lastDimToZeroBase(args);
|
|
try {
|
|
return variance2.apply(null, args);
|
|
} catch (err) {
|
|
throw errorTransform(err);
|
|
}
|
|
}
|
|
});
|
|
}, {
|
|
isTransformFunction: true
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/entry/pureFunctionsAny.generated.js
|
|
var BigNumber = /* @__PURE__ */ createBigNumberClass({
|
|
config
|
|
});
|
|
var Complex2 = /* @__PURE__ */ createComplexClass({});
|
|
var e2 = /* @__PURE__ */ createE({
|
|
BigNumber,
|
|
config
|
|
});
|
|
var _false = /* @__PURE__ */ createFalse({});
|
|
var fineStructure = /* @__PURE__ */ createFineStructure({
|
|
BigNumber,
|
|
config
|
|
});
|
|
var Fraction2 = /* @__PURE__ */ createFractionClass({});
|
|
var i = /* @__PURE__ */ createI({
|
|
Complex: Complex2
|
|
});
|
|
var _Infinity = /* @__PURE__ */ createInfinity({
|
|
BigNumber,
|
|
config
|
|
});
|
|
var LN102 = /* @__PURE__ */ createLN10({
|
|
BigNumber,
|
|
config
|
|
});
|
|
var LOG10E = /* @__PURE__ */ createLOG10E({
|
|
BigNumber,
|
|
config
|
|
});
|
|
var Matrix = /* @__PURE__ */ createMatrixClass({});
|
|
var _NaN = /* @__PURE__ */ createNaN({
|
|
BigNumber,
|
|
config
|
|
});
|
|
var _null = /* @__PURE__ */ createNull({});
|
|
var phi2 = /* @__PURE__ */ createPhi({
|
|
BigNumber,
|
|
config
|
|
});
|
|
var Range = /* @__PURE__ */ createRangeClass({});
|
|
var ResultSet = /* @__PURE__ */ createResultSet({});
|
|
var SQRT1_2 = /* @__PURE__ */ createSQRT1_2({
|
|
BigNumber,
|
|
config
|
|
});
|
|
var sackurTetrode = /* @__PURE__ */ createSackurTetrode({
|
|
BigNumber,
|
|
config
|
|
});
|
|
var tau2 = /* @__PURE__ */ createTau({
|
|
BigNumber,
|
|
config
|
|
});
|
|
var _true = /* @__PURE__ */ createTrue({});
|
|
var version2 = /* @__PURE__ */ createVersion({});
|
|
var DenseMatrix = /* @__PURE__ */ createDenseMatrixClass({
|
|
Matrix
|
|
});
|
|
var efimovFactor = /* @__PURE__ */ createEfimovFactor({
|
|
BigNumber,
|
|
config
|
|
});
|
|
var LN2 = /* @__PURE__ */ createLN2({
|
|
BigNumber,
|
|
config
|
|
});
|
|
var pi2 = /* @__PURE__ */ createPi({
|
|
BigNumber,
|
|
config
|
|
});
|
|
var replacer = /* @__PURE__ */ createReplacer({});
|
|
var SQRT2 = /* @__PURE__ */ createSQRT2({
|
|
BigNumber,
|
|
config
|
|
});
|
|
var typed = /* @__PURE__ */ createTyped({
|
|
BigNumber,
|
|
Complex: Complex2,
|
|
DenseMatrix,
|
|
Fraction: Fraction2
|
|
});
|
|
var unaryPlus = /* @__PURE__ */ createUnaryPlus({
|
|
BigNumber,
|
|
config,
|
|
typed
|
|
});
|
|
var weakMixingAngle = /* @__PURE__ */ createWeakMixingAngle({
|
|
BigNumber,
|
|
config
|
|
});
|
|
var abs2 = /* @__PURE__ */ createAbs({
|
|
typed
|
|
});
|
|
var acos2 = /* @__PURE__ */ createAcos({
|
|
Complex: Complex2,
|
|
config,
|
|
typed
|
|
});
|
|
var acot = /* @__PURE__ */ createAcot({
|
|
BigNumber,
|
|
typed
|
|
});
|
|
var acsc = /* @__PURE__ */ createAcsc({
|
|
BigNumber,
|
|
Complex: Complex2,
|
|
config,
|
|
typed
|
|
});
|
|
var addScalar = /* @__PURE__ */ createAddScalar({
|
|
typed
|
|
});
|
|
var arg = /* @__PURE__ */ createArg({
|
|
typed
|
|
});
|
|
var asech = /* @__PURE__ */ createAsech({
|
|
BigNumber,
|
|
Complex: Complex2,
|
|
config,
|
|
typed
|
|
});
|
|
var asinh3 = /* @__PURE__ */ createAsinh({
|
|
typed
|
|
});
|
|
var atan3 = /* @__PURE__ */ createAtan({
|
|
typed
|
|
});
|
|
var atanh3 = /* @__PURE__ */ createAtanh({
|
|
Complex: Complex2,
|
|
config,
|
|
typed
|
|
});
|
|
var bignumber = /* @__PURE__ */ createBignumber({
|
|
BigNumber,
|
|
typed
|
|
});
|
|
var bitNot = /* @__PURE__ */ createBitNot({
|
|
typed
|
|
});
|
|
var boolean = /* @__PURE__ */ createBoolean({
|
|
typed
|
|
});
|
|
var clone3 = /* @__PURE__ */ createClone({
|
|
typed
|
|
});
|
|
var combinations = /* @__PURE__ */ createCombinations({
|
|
typed
|
|
});
|
|
var complex = /* @__PURE__ */ createComplex({
|
|
Complex: Complex2,
|
|
typed
|
|
});
|
|
var conj = /* @__PURE__ */ createConj({
|
|
typed
|
|
});
|
|
var cosh3 = /* @__PURE__ */ createCosh({
|
|
typed
|
|
});
|
|
var coth = /* @__PURE__ */ createCoth({
|
|
BigNumber,
|
|
typed
|
|
});
|
|
var csc = /* @__PURE__ */ createCsc({
|
|
BigNumber,
|
|
typed
|
|
});
|
|
var cube = /* @__PURE__ */ createCube({
|
|
typed
|
|
});
|
|
var equalScalar = /* @__PURE__ */ createEqualScalar({
|
|
config,
|
|
typed
|
|
});
|
|
var erf = /* @__PURE__ */ createErf({
|
|
typed
|
|
});
|
|
var exp2 = /* @__PURE__ */ createExp({
|
|
typed
|
|
});
|
|
var expm13 = /* @__PURE__ */ createExpm1({
|
|
Complex: Complex2,
|
|
typed
|
|
});
|
|
var filter2 = /* @__PURE__ */ createFilter({
|
|
typed
|
|
});
|
|
var forEach2 = /* @__PURE__ */ createForEach({
|
|
typed
|
|
});
|
|
var format4 = /* @__PURE__ */ createFormat({
|
|
typed
|
|
});
|
|
var getMatrixDataType = /* @__PURE__ */ createGetMatrixDataType({
|
|
typed
|
|
});
|
|
var hex = /* @__PURE__ */ createHex({
|
|
format: format4,
|
|
typed
|
|
});
|
|
var im = /* @__PURE__ */ createIm({
|
|
typed
|
|
});
|
|
var isInteger2 = /* @__PURE__ */ createIsInteger({
|
|
typed
|
|
});
|
|
var isNegative = /* @__PURE__ */ createIsNegative({
|
|
typed
|
|
});
|
|
var isPositive = /* @__PURE__ */ createIsPositive({
|
|
typed
|
|
});
|
|
var isZero = /* @__PURE__ */ createIsZero({
|
|
typed
|
|
});
|
|
var LOG2E = /* @__PURE__ */ createLOG2E({
|
|
BigNumber,
|
|
config
|
|
});
|
|
var lgamma = /* @__PURE__ */ createLgamma({
|
|
Complex: Complex2,
|
|
typed
|
|
});
|
|
var log104 = /* @__PURE__ */ createLog10({
|
|
Complex: Complex2,
|
|
config,
|
|
typed
|
|
});
|
|
var log24 = /* @__PURE__ */ createLog2({
|
|
Complex: Complex2,
|
|
config,
|
|
typed
|
|
});
|
|
var map2 = /* @__PURE__ */ createMap2({
|
|
typed
|
|
});
|
|
var multiplyScalar = /* @__PURE__ */ createMultiplyScalar({
|
|
typed
|
|
});
|
|
var not = /* @__PURE__ */ createNot({
|
|
typed
|
|
});
|
|
var number = /* @__PURE__ */ createNumber({
|
|
typed
|
|
});
|
|
var oct = /* @__PURE__ */ createOct({
|
|
format: format4,
|
|
typed
|
|
});
|
|
var pickRandom = /* @__PURE__ */ createPickRandom({
|
|
config,
|
|
typed
|
|
});
|
|
var print = /* @__PURE__ */ createPrint({
|
|
typed
|
|
});
|
|
var random2 = /* @__PURE__ */ createRandom({
|
|
config,
|
|
typed
|
|
});
|
|
var re = /* @__PURE__ */ createRe({
|
|
typed
|
|
});
|
|
var sec = /* @__PURE__ */ createSec({
|
|
BigNumber,
|
|
typed
|
|
});
|
|
var sign3 = /* @__PURE__ */ createSign({
|
|
BigNumber,
|
|
Fraction: Fraction2,
|
|
complex,
|
|
typed
|
|
});
|
|
var sin2 = /* @__PURE__ */ createSin({
|
|
typed
|
|
});
|
|
var SparseMatrix = /* @__PURE__ */ createSparseMatrixClass({
|
|
Matrix,
|
|
equalScalar,
|
|
typed
|
|
});
|
|
var splitUnit = /* @__PURE__ */ createSplitUnit({
|
|
typed
|
|
});
|
|
var square = /* @__PURE__ */ createSquare({
|
|
typed
|
|
});
|
|
var string = /* @__PURE__ */ createString({
|
|
typed
|
|
});
|
|
var tan2 = /* @__PURE__ */ createTan({
|
|
typed
|
|
});
|
|
var typeOf2 = /* @__PURE__ */ createTypeOf({
|
|
typed
|
|
});
|
|
var acosh3 = /* @__PURE__ */ createAcosh({
|
|
Complex: Complex2,
|
|
config,
|
|
typed
|
|
});
|
|
var acsch = /* @__PURE__ */ createAcsch({
|
|
BigNumber,
|
|
typed
|
|
});
|
|
var apply = /* @__PURE__ */ createApply({
|
|
isInteger: isInteger2,
|
|
typed
|
|
});
|
|
var asec = /* @__PURE__ */ createAsec({
|
|
BigNumber,
|
|
Complex: Complex2,
|
|
config,
|
|
typed
|
|
});
|
|
var bin = /* @__PURE__ */ createBin({
|
|
format: format4,
|
|
typed
|
|
});
|
|
var combinationsWithRep = /* @__PURE__ */ createCombinationsWithRep({
|
|
typed
|
|
});
|
|
var cos2 = /* @__PURE__ */ createCos({
|
|
typed
|
|
});
|
|
var csch = /* @__PURE__ */ createCsch({
|
|
BigNumber,
|
|
typed
|
|
});
|
|
var isNaN2 = /* @__PURE__ */ createIsNaN({
|
|
typed
|
|
});
|
|
var isPrime = /* @__PURE__ */ createIsPrime({
|
|
typed
|
|
});
|
|
var randomInt = /* @__PURE__ */ createRandomInt({
|
|
config,
|
|
typed
|
|
});
|
|
var sech = /* @__PURE__ */ createSech({
|
|
BigNumber,
|
|
typed
|
|
});
|
|
var sinh3 = /* @__PURE__ */ createSinh({
|
|
typed
|
|
});
|
|
var sparse = /* @__PURE__ */ createSparse({
|
|
SparseMatrix,
|
|
typed
|
|
});
|
|
var sqrt2 = /* @__PURE__ */ createSqrt({
|
|
Complex: Complex2,
|
|
config,
|
|
typed
|
|
});
|
|
var tanh3 = /* @__PURE__ */ createTanh({
|
|
typed
|
|
});
|
|
var unaryMinus = /* @__PURE__ */ createUnaryMinus({
|
|
typed
|
|
});
|
|
var acoth = /* @__PURE__ */ createAcoth({
|
|
BigNumber,
|
|
Complex: Complex2,
|
|
config,
|
|
typed
|
|
});
|
|
var cot = /* @__PURE__ */ createCot({
|
|
BigNumber,
|
|
typed
|
|
});
|
|
var fraction = /* @__PURE__ */ createFraction({
|
|
Fraction: Fraction2,
|
|
typed
|
|
});
|
|
var isNumeric = /* @__PURE__ */ createIsNumeric({
|
|
typed
|
|
});
|
|
var matrix = /* @__PURE__ */ createMatrix({
|
|
DenseMatrix,
|
|
Matrix,
|
|
SparseMatrix,
|
|
typed
|
|
});
|
|
var matrixFromFunction = /* @__PURE__ */ createMatrixFromFunction({
|
|
isZero,
|
|
matrix,
|
|
typed
|
|
});
|
|
var mode = /* @__PURE__ */ createMode({
|
|
isNaN: isNaN2,
|
|
isNumeric,
|
|
typed
|
|
});
|
|
var numeric2 = /* @__PURE__ */ createNumeric({
|
|
bignumber,
|
|
fraction,
|
|
number
|
|
});
|
|
var prod = /* @__PURE__ */ createProd({
|
|
config,
|
|
multiplyScalar,
|
|
numeric: numeric2,
|
|
typed
|
|
});
|
|
var reshape2 = /* @__PURE__ */ createReshape({
|
|
isInteger: isInteger2,
|
|
matrix,
|
|
typed
|
|
});
|
|
var size = /* @__PURE__ */ createSize({
|
|
matrix,
|
|
config,
|
|
typed
|
|
});
|
|
var squeeze2 = /* @__PURE__ */ createSqueeze({
|
|
matrix,
|
|
typed
|
|
});
|
|
var subset = /* @__PURE__ */ createSubset({
|
|
matrix,
|
|
typed
|
|
});
|
|
var transpose = /* @__PURE__ */ createTranspose({
|
|
matrix,
|
|
typed
|
|
});
|
|
var xgcd = /* @__PURE__ */ createXgcd({
|
|
BigNumber,
|
|
config,
|
|
matrix,
|
|
typed
|
|
});
|
|
var zeros2 = /* @__PURE__ */ createZeros({
|
|
BigNumber,
|
|
config,
|
|
matrix,
|
|
typed
|
|
});
|
|
var asin2 = /* @__PURE__ */ createAsin({
|
|
Complex: Complex2,
|
|
config,
|
|
typed
|
|
});
|
|
var cbrt4 = /* @__PURE__ */ createCbrt({
|
|
BigNumber,
|
|
Complex: Complex2,
|
|
Fraction: Fraction2,
|
|
config,
|
|
isNegative,
|
|
matrix,
|
|
typed,
|
|
unaryMinus
|
|
});
|
|
var concat = /* @__PURE__ */ createConcat({
|
|
isInteger: isInteger2,
|
|
matrix,
|
|
typed
|
|
});
|
|
var count = /* @__PURE__ */ createCount({
|
|
prod,
|
|
size,
|
|
typed
|
|
});
|
|
var ctranspose = /* @__PURE__ */ createCtranspose({
|
|
conj,
|
|
transpose,
|
|
typed
|
|
});
|
|
var diag = /* @__PURE__ */ createDiag({
|
|
DenseMatrix,
|
|
SparseMatrix,
|
|
matrix,
|
|
typed
|
|
});
|
|
var divideScalar = /* @__PURE__ */ createDivideScalar({
|
|
numeric: numeric2,
|
|
typed
|
|
});
|
|
var dotDivide = /* @__PURE__ */ createDotDivide({
|
|
DenseMatrix,
|
|
concat,
|
|
divideScalar,
|
|
equalScalar,
|
|
matrix,
|
|
typed
|
|
});
|
|
var equal = /* @__PURE__ */ createEqual({
|
|
DenseMatrix,
|
|
concat,
|
|
equalScalar,
|
|
matrix,
|
|
typed
|
|
});
|
|
var flatten2 = /* @__PURE__ */ createFlatten({
|
|
matrix,
|
|
typed
|
|
});
|
|
var gcd = /* @__PURE__ */ createGcd({
|
|
BigNumber,
|
|
DenseMatrix,
|
|
concat,
|
|
equalScalar,
|
|
matrix,
|
|
typed
|
|
});
|
|
var hasNumericValue = /* @__PURE__ */ createHasNumericValue({
|
|
isNumeric,
|
|
typed
|
|
});
|
|
var identity = /* @__PURE__ */ createIdentity({
|
|
BigNumber,
|
|
DenseMatrix,
|
|
SparseMatrix,
|
|
config,
|
|
matrix,
|
|
typed
|
|
});
|
|
var kron = /* @__PURE__ */ createKron({
|
|
matrix,
|
|
multiplyScalar,
|
|
typed
|
|
});
|
|
var largerEq = /* @__PURE__ */ createLargerEq({
|
|
DenseMatrix,
|
|
concat,
|
|
config,
|
|
matrix,
|
|
typed
|
|
});
|
|
var leftShift = /* @__PURE__ */ createLeftShift({
|
|
DenseMatrix,
|
|
concat,
|
|
equalScalar,
|
|
matrix,
|
|
typed,
|
|
zeros: zeros2
|
|
});
|
|
var matrixFromColumns = /* @__PURE__ */ createMatrixFromColumns({
|
|
flatten: flatten2,
|
|
matrix,
|
|
size,
|
|
typed
|
|
});
|
|
var mod2 = /* @__PURE__ */ createMod({
|
|
DenseMatrix,
|
|
concat,
|
|
equalScalar,
|
|
matrix,
|
|
typed
|
|
});
|
|
var nthRoot = /* @__PURE__ */ createNthRoot({
|
|
BigNumber,
|
|
concat,
|
|
equalScalar,
|
|
matrix,
|
|
typed
|
|
});
|
|
var ones = /* @__PURE__ */ createOnes({
|
|
BigNumber,
|
|
config,
|
|
matrix,
|
|
typed
|
|
});
|
|
var resize2 = /* @__PURE__ */ createResize({
|
|
config,
|
|
matrix
|
|
});
|
|
var rightArithShift = /* @__PURE__ */ createRightArithShift({
|
|
DenseMatrix,
|
|
concat,
|
|
equalScalar,
|
|
matrix,
|
|
typed,
|
|
zeros: zeros2
|
|
});
|
|
var round2 = /* @__PURE__ */ createRound({
|
|
BigNumber,
|
|
DenseMatrix,
|
|
equalScalar,
|
|
matrix,
|
|
typed,
|
|
zeros: zeros2
|
|
});
|
|
var smaller = /* @__PURE__ */ createSmaller({
|
|
DenseMatrix,
|
|
concat,
|
|
config,
|
|
matrix,
|
|
typed
|
|
});
|
|
var to = /* @__PURE__ */ createTo({
|
|
concat,
|
|
matrix,
|
|
typed
|
|
});
|
|
var unequal = /* @__PURE__ */ createUnequal({
|
|
DenseMatrix,
|
|
concat,
|
|
config,
|
|
equalScalar,
|
|
matrix,
|
|
typed
|
|
});
|
|
var xor = /* @__PURE__ */ createXor({
|
|
DenseMatrix,
|
|
concat,
|
|
matrix,
|
|
typed
|
|
});
|
|
var add2 = /* @__PURE__ */ createAdd({
|
|
DenseMatrix,
|
|
SparseMatrix,
|
|
addScalar,
|
|
concat,
|
|
equalScalar,
|
|
matrix,
|
|
typed
|
|
});
|
|
var bitAnd = /* @__PURE__ */ createBitAnd({
|
|
concat,
|
|
equalScalar,
|
|
matrix,
|
|
typed
|
|
});
|
|
var bitXor2 = /* @__PURE__ */ createBitXor({
|
|
DenseMatrix,
|
|
concat,
|
|
matrix,
|
|
typed
|
|
});
|
|
var catalan = /* @__PURE__ */ createCatalan({
|
|
addScalar,
|
|
combinations,
|
|
divideScalar,
|
|
isInteger: isInteger2,
|
|
isNegative,
|
|
multiplyScalar,
|
|
typed
|
|
});
|
|
var compare = /* @__PURE__ */ createCompare({
|
|
BigNumber,
|
|
DenseMatrix,
|
|
Fraction: Fraction2,
|
|
concat,
|
|
config,
|
|
equalScalar,
|
|
matrix,
|
|
typed
|
|
});
|
|
var compareText2 = /* @__PURE__ */ createCompareText({
|
|
concat,
|
|
matrix,
|
|
typed
|
|
});
|
|
var cumsum = /* @__PURE__ */ createCumSum({
|
|
add: add2,
|
|
typed,
|
|
unaryPlus
|
|
});
|
|
var deepEqual = /* @__PURE__ */ createDeepEqual({
|
|
equal,
|
|
typed
|
|
});
|
|
var dot = /* @__PURE__ */ createDot({
|
|
addScalar,
|
|
conj,
|
|
multiplyScalar,
|
|
size,
|
|
typed
|
|
});
|
|
var equalText = /* @__PURE__ */ createEqualText({
|
|
compareText: compareText2,
|
|
isZero,
|
|
typed
|
|
});
|
|
var floor2 = /* @__PURE__ */ createFloor({
|
|
DenseMatrix,
|
|
config,
|
|
equalScalar,
|
|
matrix,
|
|
round: round2,
|
|
typed,
|
|
zeros: zeros2
|
|
});
|
|
var hypot2 = /* @__PURE__ */ createHypot({
|
|
abs: abs2,
|
|
addScalar,
|
|
divideScalar,
|
|
isPositive,
|
|
multiplyScalar,
|
|
smaller,
|
|
sqrt: sqrt2,
|
|
typed
|
|
});
|
|
var ImmutableDenseMatrix = /* @__PURE__ */ createImmutableDenseMatrixClass({
|
|
DenseMatrix,
|
|
smaller
|
|
});
|
|
var Index = /* @__PURE__ */ createIndexClass({
|
|
ImmutableDenseMatrix
|
|
});
|
|
var invmod = /* @__PURE__ */ createInvmod({
|
|
BigNumber,
|
|
add: add2,
|
|
config,
|
|
equal,
|
|
isInteger: isInteger2,
|
|
mod: mod2,
|
|
smaller,
|
|
typed,
|
|
xgcd
|
|
});
|
|
var larger = /* @__PURE__ */ createLarger({
|
|
DenseMatrix,
|
|
concat,
|
|
config,
|
|
matrix,
|
|
typed
|
|
});
|
|
var log3 = /* @__PURE__ */ createLog({
|
|
Complex: Complex2,
|
|
config,
|
|
divideScalar,
|
|
typed
|
|
});
|
|
var matrixFromRows = /* @__PURE__ */ createMatrixFromRows({
|
|
flatten: flatten2,
|
|
matrix,
|
|
size,
|
|
typed
|
|
});
|
|
var min2 = /* @__PURE__ */ createMin({
|
|
config,
|
|
numeric: numeric2,
|
|
smaller,
|
|
typed
|
|
});
|
|
var multiply = /* @__PURE__ */ createMultiply({
|
|
addScalar,
|
|
dot,
|
|
equalScalar,
|
|
matrix,
|
|
multiplyScalar,
|
|
typed
|
|
});
|
|
var nthRoots = /* @__PURE__ */ createNthRoots({
|
|
Complex: Complex2,
|
|
config,
|
|
divideScalar,
|
|
typed
|
|
});
|
|
var or = /* @__PURE__ */ createOr({
|
|
DenseMatrix,
|
|
concat,
|
|
equalScalar,
|
|
matrix,
|
|
typed
|
|
});
|
|
var partitionSelect = /* @__PURE__ */ createPartitionSelect({
|
|
compare,
|
|
isNaN: isNaN2,
|
|
isNumeric,
|
|
typed
|
|
});
|
|
var quantileSeq = /* @__PURE__ */ createQuantileSeq({
|
|
add: add2,
|
|
compare,
|
|
multiply,
|
|
partitionSelect,
|
|
typed
|
|
});
|
|
var rightLogShift = /* @__PURE__ */ createRightLogShift({
|
|
DenseMatrix,
|
|
concat,
|
|
equalScalar,
|
|
matrix,
|
|
typed,
|
|
zeros: zeros2
|
|
});
|
|
var smallerEq = /* @__PURE__ */ createSmallerEq({
|
|
DenseMatrix,
|
|
concat,
|
|
config,
|
|
matrix,
|
|
typed
|
|
});
|
|
var subtract = /* @__PURE__ */ createSubtract({
|
|
DenseMatrix,
|
|
addScalar,
|
|
concat,
|
|
equalScalar,
|
|
matrix,
|
|
typed,
|
|
unaryMinus
|
|
});
|
|
var trace = /* @__PURE__ */ createTrace({
|
|
add: add2,
|
|
matrix,
|
|
typed
|
|
});
|
|
var usolve = /* @__PURE__ */ createUsolve({
|
|
DenseMatrix,
|
|
divideScalar,
|
|
equalScalar,
|
|
matrix,
|
|
multiplyScalar,
|
|
subtract,
|
|
typed
|
|
});
|
|
var and = /* @__PURE__ */ createAnd({
|
|
concat,
|
|
equalScalar,
|
|
matrix,
|
|
not,
|
|
typed,
|
|
zeros: zeros2
|
|
});
|
|
var bitOr = /* @__PURE__ */ createBitOr({
|
|
DenseMatrix,
|
|
concat,
|
|
equalScalar,
|
|
matrix,
|
|
typed
|
|
});
|
|
var ceil2 = /* @__PURE__ */ createCeil({
|
|
DenseMatrix,
|
|
config,
|
|
equalScalar,
|
|
matrix,
|
|
round: round2,
|
|
typed,
|
|
zeros: zeros2
|
|
});
|
|
var compareNatural = /* @__PURE__ */ createCompareNatural({
|
|
compare,
|
|
typed
|
|
});
|
|
var composition = /* @__PURE__ */ createComposition({
|
|
addScalar,
|
|
combinations,
|
|
isInteger: isInteger2,
|
|
isNegative,
|
|
isPositive,
|
|
larger,
|
|
typed
|
|
});
|
|
var cross = /* @__PURE__ */ createCross({
|
|
matrix,
|
|
multiply,
|
|
subtract,
|
|
typed
|
|
});
|
|
var det = /* @__PURE__ */ createDet({
|
|
divideScalar,
|
|
isZero,
|
|
matrix,
|
|
multiply,
|
|
subtract,
|
|
typed,
|
|
unaryMinus
|
|
});
|
|
var diff = /* @__PURE__ */ createDiff({
|
|
matrix,
|
|
number,
|
|
subtract,
|
|
typed
|
|
});
|
|
var distance = /* @__PURE__ */ createDistance({
|
|
abs: abs2,
|
|
addScalar,
|
|
divideScalar,
|
|
multiplyScalar,
|
|
sqrt: sqrt2,
|
|
subtract,
|
|
typed,
|
|
unaryMinus
|
|
});
|
|
var dotMultiply = /* @__PURE__ */ createDotMultiply({
|
|
concat,
|
|
equalScalar,
|
|
matrix,
|
|
multiplyScalar,
|
|
typed
|
|
});
|
|
var FibonacciHeap = /* @__PURE__ */ createFibonacciHeapClass({
|
|
larger,
|
|
smaller
|
|
});
|
|
var fix = /* @__PURE__ */ createFix({
|
|
Complex: Complex2,
|
|
DenseMatrix,
|
|
ceil: ceil2,
|
|
equalScalar,
|
|
floor: floor2,
|
|
matrix,
|
|
typed,
|
|
zeros: zeros2
|
|
});
|
|
var index = /* @__PURE__ */ createIndex({
|
|
Index,
|
|
typed
|
|
});
|
|
var intersect = /* @__PURE__ */ createIntersect({
|
|
abs: abs2,
|
|
add: add2,
|
|
addScalar,
|
|
config,
|
|
divideScalar,
|
|
equalScalar,
|
|
flatten: flatten2,
|
|
isNumeric,
|
|
isZero,
|
|
matrix,
|
|
multiply,
|
|
multiplyScalar,
|
|
smaller,
|
|
subtract,
|
|
typed
|
|
});
|
|
var lcm = /* @__PURE__ */ createLcm({
|
|
concat,
|
|
equalScalar,
|
|
matrix,
|
|
typed
|
|
});
|
|
var log1p2 = /* @__PURE__ */ createLog1p({
|
|
Complex: Complex2,
|
|
config,
|
|
divideScalar,
|
|
log: log3,
|
|
typed
|
|
});
|
|
var lsolve = /* @__PURE__ */ createLsolve({
|
|
DenseMatrix,
|
|
divideScalar,
|
|
equalScalar,
|
|
matrix,
|
|
multiplyScalar,
|
|
subtract,
|
|
typed
|
|
});
|
|
var max2 = /* @__PURE__ */ createMax({
|
|
config,
|
|
larger,
|
|
numeric: numeric2,
|
|
typed
|
|
});
|
|
var qr = /* @__PURE__ */ createQr({
|
|
addScalar,
|
|
complex,
|
|
conj,
|
|
divideScalar,
|
|
equal,
|
|
identity,
|
|
isZero,
|
|
matrix,
|
|
multiplyScalar,
|
|
sign: sign3,
|
|
sqrt: sqrt2,
|
|
subtract,
|
|
typed,
|
|
unaryMinus,
|
|
zeros: zeros2
|
|
});
|
|
var range = /* @__PURE__ */ createRange({
|
|
bignumber,
|
|
matrix,
|
|
config,
|
|
larger,
|
|
largerEq,
|
|
smaller,
|
|
smallerEq,
|
|
typed
|
|
});
|
|
var row = /* @__PURE__ */ createRow({
|
|
Index,
|
|
matrix,
|
|
range,
|
|
typed
|
|
});
|
|
var setCartesian = /* @__PURE__ */ createSetCartesian({
|
|
DenseMatrix,
|
|
Index,
|
|
compareNatural,
|
|
size,
|
|
subset,
|
|
typed
|
|
});
|
|
var setDistinct = /* @__PURE__ */ createSetDistinct({
|
|
DenseMatrix,
|
|
Index,
|
|
compareNatural,
|
|
size,
|
|
subset,
|
|
typed
|
|
});
|
|
var setIsSubset = /* @__PURE__ */ createSetIsSubset({
|
|
Index,
|
|
compareNatural,
|
|
size,
|
|
subset,
|
|
typed
|
|
});
|
|
var setPowerset = /* @__PURE__ */ createSetPowerset({
|
|
Index,
|
|
compareNatural,
|
|
size,
|
|
subset,
|
|
typed
|
|
});
|
|
var slu = /* @__PURE__ */ createSlu({
|
|
SparseMatrix,
|
|
abs: abs2,
|
|
add: add2,
|
|
divideScalar,
|
|
larger,
|
|
largerEq,
|
|
multiply,
|
|
subtract,
|
|
transpose,
|
|
typed
|
|
});
|
|
var Spa = /* @__PURE__ */ createSpaClass({
|
|
FibonacciHeap,
|
|
addScalar,
|
|
equalScalar
|
|
});
|
|
var sum2 = /* @__PURE__ */ createSum({
|
|
add: add2,
|
|
config,
|
|
numeric: numeric2,
|
|
typed
|
|
});
|
|
var usolveAll = /* @__PURE__ */ createUsolveAll({
|
|
DenseMatrix,
|
|
divideScalar,
|
|
equalScalar,
|
|
matrix,
|
|
multiplyScalar,
|
|
subtract,
|
|
typed
|
|
});
|
|
var atan22 = /* @__PURE__ */ createAtan2({
|
|
BigNumber,
|
|
DenseMatrix,
|
|
concat,
|
|
equalScalar,
|
|
matrix,
|
|
typed
|
|
});
|
|
var column = /* @__PURE__ */ createColumn({
|
|
Index,
|
|
matrix,
|
|
range,
|
|
typed
|
|
});
|
|
var lsolveAll = /* @__PURE__ */ createLsolveAll({
|
|
DenseMatrix,
|
|
divideScalar,
|
|
equalScalar,
|
|
matrix,
|
|
multiplyScalar,
|
|
subtract,
|
|
typed
|
|
});
|
|
var setDifference = /* @__PURE__ */ createSetDifference({
|
|
DenseMatrix,
|
|
Index,
|
|
compareNatural,
|
|
size,
|
|
subset,
|
|
typed
|
|
});
|
|
var setMultiplicity = /* @__PURE__ */ createSetMultiplicity({
|
|
Index,
|
|
compareNatural,
|
|
size,
|
|
subset,
|
|
typed
|
|
});
|
|
var setSymDifference = /* @__PURE__ */ createSetSymDifference({
|
|
Index,
|
|
concat,
|
|
setDifference,
|
|
size,
|
|
subset,
|
|
typed
|
|
});
|
|
var sort = /* @__PURE__ */ createSort({
|
|
compare,
|
|
compareNatural,
|
|
matrix,
|
|
typed
|
|
});
|
|
var inv = /* @__PURE__ */ createInv({
|
|
abs: abs2,
|
|
addScalar,
|
|
det,
|
|
divideScalar,
|
|
identity,
|
|
matrix,
|
|
multiply,
|
|
typed,
|
|
unaryMinus
|
|
});
|
|
var lup = /* @__PURE__ */ createLup({
|
|
DenseMatrix,
|
|
Spa,
|
|
SparseMatrix,
|
|
abs: abs2,
|
|
addScalar,
|
|
divideScalar,
|
|
equalScalar,
|
|
larger,
|
|
matrix,
|
|
multiplyScalar,
|
|
subtract,
|
|
typed,
|
|
unaryMinus
|
|
});
|
|
var pinv = /* @__PURE__ */ createPinv({
|
|
Complex: Complex2,
|
|
add: add2,
|
|
ctranspose,
|
|
deepEqual,
|
|
divideScalar,
|
|
dot,
|
|
dotDivide,
|
|
equal,
|
|
inv,
|
|
matrix,
|
|
multiply,
|
|
typed
|
|
});
|
|
var pow2 = /* @__PURE__ */ createPow({
|
|
Complex: Complex2,
|
|
config,
|
|
fraction,
|
|
identity,
|
|
inv,
|
|
matrix,
|
|
multiply,
|
|
number,
|
|
typed
|
|
});
|
|
var setIntersect = /* @__PURE__ */ createSetIntersect({
|
|
DenseMatrix,
|
|
Index,
|
|
compareNatural,
|
|
size,
|
|
subset,
|
|
typed
|
|
});
|
|
var setUnion = /* @__PURE__ */ createSetUnion({
|
|
Index,
|
|
concat,
|
|
setIntersect,
|
|
setSymDifference,
|
|
size,
|
|
subset,
|
|
typed
|
|
});
|
|
var sqrtm = /* @__PURE__ */ createSqrtm({
|
|
abs: abs2,
|
|
add: add2,
|
|
identity,
|
|
inv,
|
|
map: map2,
|
|
max: max2,
|
|
multiply,
|
|
size,
|
|
sqrt: sqrt2,
|
|
subtract,
|
|
typed
|
|
});
|
|
var Unit = /* @__PURE__ */ createUnitClass({
|
|
BigNumber,
|
|
Complex: Complex2,
|
|
Fraction: Fraction2,
|
|
abs: abs2,
|
|
addScalar,
|
|
config,
|
|
divideScalar,
|
|
equal,
|
|
fix,
|
|
format: format4,
|
|
isNumeric,
|
|
multiplyScalar,
|
|
number,
|
|
pow: pow2,
|
|
round: round2,
|
|
subtract
|
|
});
|
|
var vacuumImpedance = /* @__PURE__ */ createVacuumImpedance({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var wienDisplacement = /* @__PURE__ */ createWienDisplacement({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var atomicMass = /* @__PURE__ */ createAtomicMass({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var bohrMagneton = /* @__PURE__ */ createBohrMagneton({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var boltzmann = /* @__PURE__ */ createBoltzmann({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var conductanceQuantum = /* @__PURE__ */ createConductanceQuantum({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var createUnit = /* @__PURE__ */ createCreateUnit({
|
|
Unit,
|
|
typed
|
|
});
|
|
var deuteronMass = /* @__PURE__ */ createDeuteronMass({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var dotPow = /* @__PURE__ */ createDotPow({
|
|
DenseMatrix,
|
|
concat,
|
|
equalScalar,
|
|
matrix,
|
|
pow: pow2,
|
|
typed
|
|
});
|
|
var electricConstant = /* @__PURE__ */ createElectricConstant({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var elementaryCharge = /* @__PURE__ */ createElementaryCharge({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var expm = /* @__PURE__ */ createExpm({
|
|
abs: abs2,
|
|
add: add2,
|
|
identity,
|
|
inv,
|
|
multiply,
|
|
typed
|
|
});
|
|
var faraday = /* @__PURE__ */ createFaraday({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var fft = /* @__PURE__ */ createFft({
|
|
addScalar,
|
|
ceil: ceil2,
|
|
conj,
|
|
divideScalar,
|
|
dotDivide,
|
|
exp: exp2,
|
|
i,
|
|
log2: log24,
|
|
matrix,
|
|
multiplyScalar,
|
|
pow: pow2,
|
|
tau: tau2,
|
|
typed
|
|
});
|
|
var gamma = /* @__PURE__ */ createGamma({
|
|
BigNumber,
|
|
Complex: Complex2,
|
|
config,
|
|
multiplyScalar,
|
|
pow: pow2,
|
|
typed
|
|
});
|
|
var gravitationConstant = /* @__PURE__ */ createGravitationConstant({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var hartreeEnergy = /* @__PURE__ */ createHartreeEnergy({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var ifft = /* @__PURE__ */ createIfft({
|
|
conj,
|
|
dotDivide,
|
|
fft,
|
|
typed
|
|
});
|
|
var klitzing = /* @__PURE__ */ createKlitzing({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var loschmidt = /* @__PURE__ */ createLoschmidt({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var magneticConstant = /* @__PURE__ */ createMagneticConstant({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var molarMass = /* @__PURE__ */ createMolarMass({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var molarPlanckConstant = /* @__PURE__ */ createMolarPlanckConstant({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var neutronMass = /* @__PURE__ */ createNeutronMass({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var nuclearMagneton = /* @__PURE__ */ createNuclearMagneton({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var planckCharge = /* @__PURE__ */ createPlanckCharge({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var planckLength = /* @__PURE__ */ createPlanckLength({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var planckTemperature = /* @__PURE__ */ createPlanckTemperature({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var protonMass = /* @__PURE__ */ createProtonMass({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var reducedPlanckConstant = /* @__PURE__ */ createReducedPlanckConstant({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var rydberg = /* @__PURE__ */ createRydberg({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var secondRadiation = /* @__PURE__ */ createSecondRadiation({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var speedOfLight = /* @__PURE__ */ createSpeedOfLight({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var stefanBoltzmann = /* @__PURE__ */ createStefanBoltzmann({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var thomsonCrossSection = /* @__PURE__ */ createThomsonCrossSection({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var avogadro = /* @__PURE__ */ createAvogadro({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var bohrRadius = /* @__PURE__ */ createBohrRadius({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var coulomb = /* @__PURE__ */ createCoulomb({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var divide2 = /* @__PURE__ */ createDivide({
|
|
divideScalar,
|
|
equalScalar,
|
|
inv,
|
|
matrix,
|
|
multiply,
|
|
typed
|
|
});
|
|
var electronMass = /* @__PURE__ */ createElectronMass({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var factorial = /* @__PURE__ */ createFactorial({
|
|
gamma,
|
|
typed
|
|
});
|
|
var firstRadiation = /* @__PURE__ */ createFirstRadiation({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var gasConstant = /* @__PURE__ */ createGasConstant({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var inverseConductanceQuantum = /* @__PURE__ */ createInverseConductanceQuantum({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var lusolve = /* @__PURE__ */ createLusolve({
|
|
DenseMatrix,
|
|
lsolve,
|
|
lup,
|
|
matrix,
|
|
slu,
|
|
typed,
|
|
usolve
|
|
});
|
|
var magneticFluxQuantum = /* @__PURE__ */ createMagneticFluxQuantum({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var molarMassC12 = /* @__PURE__ */ createMolarMassC12({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var multinomial = /* @__PURE__ */ createMultinomial({
|
|
add: add2,
|
|
divide: divide2,
|
|
factorial,
|
|
isInteger: isInteger2,
|
|
isPositive,
|
|
multiply,
|
|
typed
|
|
});
|
|
var permutations = /* @__PURE__ */ createPermutations({
|
|
factorial,
|
|
typed
|
|
});
|
|
var planckMass = /* @__PURE__ */ createPlanckMass({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var polynomialRoot = /* @__PURE__ */ createPolynomialRoot({
|
|
add: add2,
|
|
cbrt: cbrt4,
|
|
divide: divide2,
|
|
equalScalar,
|
|
im,
|
|
isZero,
|
|
multiply,
|
|
re,
|
|
sqrt: sqrt2,
|
|
subtract,
|
|
typeOf: typeOf2,
|
|
typed,
|
|
unaryMinus
|
|
});
|
|
var setSize = /* @__PURE__ */ createSetSize({
|
|
compareNatural,
|
|
typed
|
|
});
|
|
var stirlingS2 = /* @__PURE__ */ createStirlingS2({
|
|
bignumber,
|
|
addScalar,
|
|
combinations,
|
|
divideScalar,
|
|
factorial,
|
|
isInteger: isInteger2,
|
|
isNegative,
|
|
larger,
|
|
multiplyScalar,
|
|
number,
|
|
pow: pow2,
|
|
subtract,
|
|
typed
|
|
});
|
|
var unit = /* @__PURE__ */ createUnitFunction({
|
|
Unit,
|
|
typed
|
|
});
|
|
var bellNumbers = /* @__PURE__ */ createBellNumbers({
|
|
addScalar,
|
|
isInteger: isInteger2,
|
|
isNegative,
|
|
stirlingS2,
|
|
typed
|
|
});
|
|
var eigs = /* @__PURE__ */ createEigs({
|
|
abs: abs2,
|
|
add: add2,
|
|
addScalar,
|
|
atan: atan3,
|
|
bignumber,
|
|
column,
|
|
complex,
|
|
config,
|
|
cos: cos2,
|
|
diag,
|
|
divideScalar,
|
|
dot,
|
|
equal,
|
|
flatten: flatten2,
|
|
im,
|
|
inv,
|
|
larger,
|
|
matrix,
|
|
matrixFromColumns,
|
|
multiply,
|
|
multiplyScalar,
|
|
number,
|
|
qr,
|
|
re,
|
|
sin: sin2,
|
|
smaller,
|
|
sqrt: sqrt2,
|
|
subtract,
|
|
typed,
|
|
usolve,
|
|
usolveAll
|
|
});
|
|
var fermiCoupling = /* @__PURE__ */ createFermiCoupling({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var gravity = /* @__PURE__ */ createGravity({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var kldivergence = /* @__PURE__ */ createKldivergence({
|
|
divide: divide2,
|
|
dotDivide,
|
|
isNumeric,
|
|
log: log3,
|
|
map: map2,
|
|
matrix,
|
|
multiply,
|
|
sum: sum2,
|
|
typed
|
|
});
|
|
var mean = /* @__PURE__ */ createMean({
|
|
add: add2,
|
|
divide: divide2,
|
|
typed
|
|
});
|
|
var molarVolume = /* @__PURE__ */ createMolarVolume({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var planckConstant = /* @__PURE__ */ createPlanckConstant({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var quantumOfCirculation = /* @__PURE__ */ createQuantumOfCirculation({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var variance = /* @__PURE__ */ createVariance({
|
|
add: add2,
|
|
apply,
|
|
divide: divide2,
|
|
isNaN: isNaN2,
|
|
multiply,
|
|
subtract,
|
|
typed
|
|
});
|
|
var classicalElectronRadius = /* @__PURE__ */ createClassicalElectronRadius({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var median = /* @__PURE__ */ createMedian({
|
|
add: add2,
|
|
compare,
|
|
divide: divide2,
|
|
partitionSelect,
|
|
typed
|
|
});
|
|
var planckTime = /* @__PURE__ */ createPlanckTime({
|
|
BigNumber,
|
|
Unit,
|
|
config
|
|
});
|
|
var std = /* @__PURE__ */ createStd({
|
|
map: map2,
|
|
sqrt: sqrt2,
|
|
typed,
|
|
variance
|
|
});
|
|
var mad = /* @__PURE__ */ createMad({
|
|
abs: abs2,
|
|
map: map2,
|
|
median,
|
|
subtract,
|
|
typed
|
|
});
|
|
var norm = /* @__PURE__ */ createNorm({
|
|
abs: abs2,
|
|
add: add2,
|
|
conj,
|
|
ctranspose,
|
|
eigs,
|
|
equalScalar,
|
|
larger,
|
|
matrix,
|
|
multiply,
|
|
pow: pow2,
|
|
smaller,
|
|
sqrt: sqrt2,
|
|
typed
|
|
});
|
|
var rotationMatrix = /* @__PURE__ */ createRotationMatrix({
|
|
BigNumber,
|
|
DenseMatrix,
|
|
SparseMatrix,
|
|
addScalar,
|
|
config,
|
|
cos: cos2,
|
|
matrix,
|
|
multiplyScalar,
|
|
norm,
|
|
sin: sin2,
|
|
typed,
|
|
unaryMinus
|
|
});
|
|
var rotate = /* @__PURE__ */ createRotate({
|
|
multiply,
|
|
rotationMatrix,
|
|
typed
|
|
});
|
|
var schur = /* @__PURE__ */ createSchur({
|
|
identity,
|
|
matrix,
|
|
multiply,
|
|
norm,
|
|
qr,
|
|
subtract,
|
|
typed
|
|
});
|
|
var sylvester = /* @__PURE__ */ createSylvester({
|
|
abs: abs2,
|
|
add: add2,
|
|
concat,
|
|
identity,
|
|
index,
|
|
lusolve,
|
|
matrix,
|
|
matrixFromColumns,
|
|
multiply,
|
|
range,
|
|
schur,
|
|
subset,
|
|
subtract,
|
|
transpose,
|
|
typed
|
|
});
|
|
var lyap = /* @__PURE__ */ createLyap({
|
|
matrix,
|
|
multiply,
|
|
sylvester,
|
|
transpose,
|
|
typed
|
|
});
|
|
|
|
// node_modules/mathjs/lib/esm/entry/impureFunctionsAny.generated.js
|
|
var math = {};
|
|
var mathWithTransform = {};
|
|
var classes = {};
|
|
var Node = createNode({
|
|
mathWithTransform
|
|
});
|
|
var ObjectNode = createObjectNode({
|
|
Node
|
|
});
|
|
var OperatorNode = createOperatorNode({
|
|
Node
|
|
});
|
|
var ParenthesisNode = createParenthesisNode({
|
|
Node
|
|
});
|
|
var RelationalNode = createRelationalNode({
|
|
Node
|
|
});
|
|
var ArrayNode = createArrayNode({
|
|
Node
|
|
});
|
|
var BlockNode = createBlockNode({
|
|
Node,
|
|
ResultSet
|
|
});
|
|
var ConditionalNode = createConditionalNode({
|
|
Node
|
|
});
|
|
var ConstantNode = createConstantNode({
|
|
Node
|
|
});
|
|
var RangeNode = createRangeNode({
|
|
Node
|
|
});
|
|
var reviver = createReviver({
|
|
classes
|
|
});
|
|
var Chain = createChainClass({
|
|
math,
|
|
typed
|
|
});
|
|
var FunctionAssignmentNode = createFunctionAssignmentNode({
|
|
Node,
|
|
typed
|
|
});
|
|
var chain = createChain({
|
|
Chain,
|
|
typed
|
|
});
|
|
var AccessorNode = createAccessorNode({
|
|
Node,
|
|
subset
|
|
});
|
|
var IndexNode = createIndexNode({
|
|
Node,
|
|
size
|
|
});
|
|
var AssignmentNode = createAssignmentNode({
|
|
matrix,
|
|
Node,
|
|
subset
|
|
});
|
|
var SymbolNode = createSymbolNode({
|
|
Unit,
|
|
Node,
|
|
math
|
|
});
|
|
var FunctionNode = createFunctionNode({
|
|
Node,
|
|
SymbolNode,
|
|
math
|
|
});
|
|
var parse = createParse({
|
|
AccessorNode,
|
|
ArrayNode,
|
|
AssignmentNode,
|
|
BlockNode,
|
|
ConditionalNode,
|
|
ConstantNode,
|
|
FunctionAssignmentNode,
|
|
FunctionNode,
|
|
IndexNode,
|
|
ObjectNode,
|
|
OperatorNode,
|
|
ParenthesisNode,
|
|
RangeNode,
|
|
RelationalNode,
|
|
SymbolNode,
|
|
config,
|
|
numeric: numeric2,
|
|
typed
|
|
});
|
|
var resolve = createResolve({
|
|
ConstantNode,
|
|
FunctionNode,
|
|
OperatorNode,
|
|
ParenthesisNode,
|
|
parse,
|
|
typed
|
|
});
|
|
var simplifyConstant = createSimplifyConstant({
|
|
bignumber,
|
|
fraction,
|
|
AccessorNode,
|
|
ArrayNode,
|
|
ConstantNode,
|
|
FunctionNode,
|
|
IndexNode,
|
|
ObjectNode,
|
|
OperatorNode,
|
|
SymbolNode,
|
|
config,
|
|
mathWithTransform,
|
|
matrix,
|
|
typed
|
|
});
|
|
var compile = createCompile({
|
|
parse,
|
|
typed
|
|
});
|
|
var evaluate = createEvaluate({
|
|
parse,
|
|
typed
|
|
});
|
|
var Help = createHelpClass({
|
|
parse
|
|
});
|
|
var Parser = createParserClass({
|
|
evaluate
|
|
});
|
|
var simplifyCore = createSimplifyCore({
|
|
AccessorNode,
|
|
ArrayNode,
|
|
ConstantNode,
|
|
FunctionNode,
|
|
IndexNode,
|
|
ObjectNode,
|
|
OperatorNode,
|
|
ParenthesisNode,
|
|
SymbolNode,
|
|
add: add2,
|
|
divide: divide2,
|
|
equal,
|
|
isZero,
|
|
multiply,
|
|
parse,
|
|
pow: pow2,
|
|
subtract,
|
|
typed
|
|
});
|
|
var help = createHelp({
|
|
Help,
|
|
mathWithTransform,
|
|
typed
|
|
});
|
|
var simplify = createSimplify({
|
|
bignumber,
|
|
fraction,
|
|
AccessorNode,
|
|
ArrayNode,
|
|
ConstantNode,
|
|
FunctionNode,
|
|
IndexNode,
|
|
ObjectNode,
|
|
OperatorNode,
|
|
ParenthesisNode,
|
|
SymbolNode,
|
|
add: add2,
|
|
config,
|
|
divide: divide2,
|
|
equal,
|
|
isZero,
|
|
mathWithTransform,
|
|
matrix,
|
|
multiply,
|
|
parse,
|
|
pow: pow2,
|
|
resolve,
|
|
simplifyConstant,
|
|
simplifyCore,
|
|
subtract,
|
|
typed
|
|
});
|
|
var symbolicEqual = createSymbolicEqual({
|
|
OperatorNode,
|
|
parse,
|
|
simplify,
|
|
typed
|
|
});
|
|
var derivative = createDerivative({
|
|
ConstantNode,
|
|
FunctionNode,
|
|
OperatorNode,
|
|
ParenthesisNode,
|
|
SymbolNode,
|
|
config,
|
|
equal,
|
|
isZero,
|
|
numeric: numeric2,
|
|
parse,
|
|
simplify,
|
|
typed
|
|
});
|
|
var parser = createParser({
|
|
Parser,
|
|
typed
|
|
});
|
|
var leafCount = createLeafCount({
|
|
parse,
|
|
typed
|
|
});
|
|
var rationalize = createRationalize({
|
|
bignumber,
|
|
fraction,
|
|
AccessorNode,
|
|
ArrayNode,
|
|
ConstantNode,
|
|
FunctionNode,
|
|
IndexNode,
|
|
ObjectNode,
|
|
OperatorNode,
|
|
ParenthesisNode,
|
|
SymbolNode,
|
|
add: add2,
|
|
config,
|
|
divide: divide2,
|
|
equal,
|
|
isZero,
|
|
mathWithTransform,
|
|
matrix,
|
|
multiply,
|
|
parse,
|
|
pow: pow2,
|
|
simplify,
|
|
simplifyConstant,
|
|
simplifyCore,
|
|
subtract,
|
|
typed
|
|
});
|
|
_extends(math, {
|
|
e: e2,
|
|
false: _false,
|
|
fineStructure,
|
|
i,
|
|
Infinity: _Infinity,
|
|
LN10: LN102,
|
|
LOG10E,
|
|
NaN: _NaN,
|
|
null: _null,
|
|
phi: phi2,
|
|
SQRT1_2,
|
|
sackurTetrode,
|
|
tau: tau2,
|
|
true: _true,
|
|
"E": e2,
|
|
version: version2,
|
|
efimovFactor,
|
|
LN2,
|
|
pi: pi2,
|
|
replacer,
|
|
reviver,
|
|
SQRT2,
|
|
typed,
|
|
unaryPlus,
|
|
"PI": pi2,
|
|
weakMixingAngle,
|
|
abs: abs2,
|
|
acos: acos2,
|
|
acot,
|
|
acsc,
|
|
addScalar,
|
|
arg,
|
|
asech,
|
|
asinh: asinh3,
|
|
atan: atan3,
|
|
atanh: atanh3,
|
|
bignumber,
|
|
bitNot,
|
|
boolean,
|
|
clone: clone3,
|
|
combinations,
|
|
complex,
|
|
conj,
|
|
cosh: cosh3,
|
|
coth,
|
|
csc,
|
|
cube,
|
|
equalScalar,
|
|
erf,
|
|
exp: exp2,
|
|
expm1: expm13,
|
|
filter: filter2,
|
|
forEach: forEach2,
|
|
format: format4,
|
|
getMatrixDataType,
|
|
hex,
|
|
im,
|
|
isInteger: isInteger2,
|
|
isNegative,
|
|
isPositive,
|
|
isZero,
|
|
LOG2E,
|
|
lgamma,
|
|
log10: log104,
|
|
log2: log24,
|
|
map: map2,
|
|
multiplyScalar,
|
|
not,
|
|
number,
|
|
oct,
|
|
pickRandom,
|
|
print,
|
|
random: random2,
|
|
re,
|
|
sec,
|
|
sign: sign3,
|
|
sin: sin2,
|
|
splitUnit,
|
|
square,
|
|
string,
|
|
tan: tan2,
|
|
typeOf: typeOf2,
|
|
acosh: acosh3,
|
|
acsch,
|
|
apply,
|
|
asec,
|
|
bin,
|
|
chain,
|
|
combinationsWithRep,
|
|
cos: cos2,
|
|
csch,
|
|
isNaN: isNaN2,
|
|
isPrime,
|
|
randomInt,
|
|
sech,
|
|
sinh: sinh3,
|
|
sparse,
|
|
sqrt: sqrt2,
|
|
tanh: tanh3,
|
|
unaryMinus,
|
|
acoth,
|
|
cot,
|
|
fraction,
|
|
isNumeric,
|
|
matrix,
|
|
matrixFromFunction,
|
|
mode,
|
|
numeric: numeric2,
|
|
prod,
|
|
reshape: reshape2,
|
|
size,
|
|
squeeze: squeeze2,
|
|
subset,
|
|
transpose,
|
|
xgcd,
|
|
zeros: zeros2,
|
|
asin: asin2,
|
|
cbrt: cbrt4,
|
|
concat,
|
|
count,
|
|
ctranspose,
|
|
diag,
|
|
divideScalar,
|
|
dotDivide,
|
|
equal,
|
|
flatten: flatten2,
|
|
gcd,
|
|
hasNumericValue,
|
|
identity,
|
|
kron,
|
|
largerEq,
|
|
leftShift,
|
|
matrixFromColumns,
|
|
mod: mod2,
|
|
nthRoot,
|
|
ones,
|
|
resize: resize2,
|
|
rightArithShift,
|
|
round: round2,
|
|
smaller,
|
|
to,
|
|
unequal,
|
|
xor,
|
|
add: add2,
|
|
bitAnd,
|
|
bitXor: bitXor2,
|
|
catalan,
|
|
compare,
|
|
compareText: compareText2,
|
|
cumsum,
|
|
deepEqual,
|
|
dot,
|
|
equalText,
|
|
floor: floor2,
|
|
hypot: hypot2,
|
|
invmod,
|
|
larger,
|
|
log: log3,
|
|
matrixFromRows,
|
|
min: min2,
|
|
multiply,
|
|
nthRoots,
|
|
or,
|
|
partitionSelect,
|
|
quantileSeq,
|
|
rightLogShift,
|
|
smallerEq,
|
|
subtract,
|
|
trace,
|
|
usolve,
|
|
and,
|
|
bitOr,
|
|
ceil: ceil2,
|
|
compareNatural,
|
|
composition,
|
|
cross,
|
|
det,
|
|
diff,
|
|
distance,
|
|
dotMultiply,
|
|
fix,
|
|
index,
|
|
intersect,
|
|
lcm,
|
|
log1p: log1p2,
|
|
lsolve,
|
|
max: max2,
|
|
qr,
|
|
range,
|
|
row,
|
|
setCartesian,
|
|
setDistinct,
|
|
setIsSubset,
|
|
setPowerset,
|
|
slu,
|
|
sum: sum2,
|
|
usolveAll,
|
|
atan2: atan22,
|
|
column,
|
|
lsolveAll,
|
|
setDifference,
|
|
setMultiplicity,
|
|
setSymDifference,
|
|
sort,
|
|
inv,
|
|
lup,
|
|
pinv,
|
|
pow: pow2,
|
|
setIntersect,
|
|
setUnion,
|
|
sqrtm,
|
|
vacuumImpedance,
|
|
wienDisplacement,
|
|
atomicMass,
|
|
bohrMagneton,
|
|
boltzmann,
|
|
conductanceQuantum,
|
|
createUnit,
|
|
deuteronMass,
|
|
dotPow,
|
|
electricConstant,
|
|
elementaryCharge,
|
|
expm,
|
|
faraday,
|
|
fft,
|
|
gamma,
|
|
gravitationConstant,
|
|
hartreeEnergy,
|
|
ifft,
|
|
klitzing,
|
|
loschmidt,
|
|
magneticConstant,
|
|
molarMass,
|
|
molarPlanckConstant,
|
|
neutronMass,
|
|
nuclearMagneton,
|
|
planckCharge,
|
|
planckLength,
|
|
planckTemperature,
|
|
protonMass,
|
|
reducedPlanckConstant,
|
|
rydberg,
|
|
secondRadiation,
|
|
speedOfLight,
|
|
stefanBoltzmann,
|
|
thomsonCrossSection,
|
|
avogadro,
|
|
bohrRadius,
|
|
coulomb,
|
|
divide: divide2,
|
|
electronMass,
|
|
factorial,
|
|
firstRadiation,
|
|
gasConstant,
|
|
inverseConductanceQuantum,
|
|
lusolve,
|
|
magneticFluxQuantum,
|
|
molarMassC12,
|
|
multinomial,
|
|
permutations,
|
|
planckMass,
|
|
polynomialRoot,
|
|
setSize,
|
|
stirlingS2,
|
|
unit,
|
|
bellNumbers,
|
|
eigs,
|
|
fermiCoupling,
|
|
gravity,
|
|
kldivergence,
|
|
mean,
|
|
molarVolume,
|
|
planckConstant,
|
|
quantumOfCirculation,
|
|
variance,
|
|
classicalElectronRadius,
|
|
median,
|
|
parse,
|
|
planckTime,
|
|
resolve,
|
|
simplifyConstant,
|
|
std,
|
|
compile,
|
|
evaluate,
|
|
mad,
|
|
simplifyCore,
|
|
help,
|
|
norm,
|
|
rotationMatrix,
|
|
simplify,
|
|
symbolicEqual,
|
|
derivative,
|
|
parser,
|
|
rotate,
|
|
leafCount,
|
|
rationalize,
|
|
schur,
|
|
sylvester,
|
|
lyap,
|
|
config
|
|
});
|
|
_extends(mathWithTransform, math, {
|
|
filter: createFilterTransform({
|
|
typed
|
|
}),
|
|
forEach: createForEachTransform({
|
|
typed
|
|
}),
|
|
map: createMapTransform({
|
|
typed
|
|
}),
|
|
apply: createApplyTransform({
|
|
isInteger: isInteger2,
|
|
typed
|
|
}),
|
|
subset: createSubsetTransform({
|
|
matrix,
|
|
typed
|
|
}),
|
|
concat: createConcatTransform({
|
|
isInteger: isInteger2,
|
|
matrix,
|
|
typed
|
|
}),
|
|
max: createMaxTransform({
|
|
config,
|
|
larger,
|
|
numeric: numeric2,
|
|
typed
|
|
}),
|
|
sum: createSumTransform({
|
|
add: add2,
|
|
config,
|
|
numeric: numeric2,
|
|
typed
|
|
}),
|
|
min: createMinTransform({
|
|
config,
|
|
numeric: numeric2,
|
|
smaller,
|
|
typed
|
|
}),
|
|
cumsum: createCumSumTransform({
|
|
add: add2,
|
|
typed,
|
|
unaryPlus
|
|
}),
|
|
diff: createDiffTransform({
|
|
bignumber,
|
|
matrix,
|
|
number,
|
|
subtract,
|
|
typed
|
|
}),
|
|
index: createIndexTransform({
|
|
Index
|
|
}),
|
|
range: createRangeTransform({
|
|
bignumber,
|
|
matrix,
|
|
config,
|
|
larger,
|
|
largerEq,
|
|
smaller,
|
|
smallerEq,
|
|
typed
|
|
}),
|
|
row: createRowTransform({
|
|
Index,
|
|
matrix,
|
|
range,
|
|
typed
|
|
}),
|
|
column: createColumnTransform({
|
|
Index,
|
|
matrix,
|
|
range,
|
|
typed
|
|
}),
|
|
mean: createMeanTransform({
|
|
add: add2,
|
|
divide: divide2,
|
|
typed
|
|
}),
|
|
variance: createVarianceTransform({
|
|
add: add2,
|
|
apply,
|
|
divide: divide2,
|
|
isNaN: isNaN2,
|
|
multiply,
|
|
subtract,
|
|
typed
|
|
}),
|
|
std: createStdTransform({
|
|
map: map2,
|
|
sqrt: sqrt2,
|
|
typed,
|
|
variance
|
|
})
|
|
});
|
|
_extends(classes, {
|
|
BigNumber,
|
|
Complex: Complex2,
|
|
Fraction: Fraction2,
|
|
Matrix,
|
|
Node,
|
|
ObjectNode,
|
|
OperatorNode,
|
|
ParenthesisNode,
|
|
Range,
|
|
RelationalNode,
|
|
ResultSet,
|
|
ArrayNode,
|
|
BlockNode,
|
|
ConditionalNode,
|
|
ConstantNode,
|
|
DenseMatrix,
|
|
RangeNode,
|
|
Chain,
|
|
FunctionAssignmentNode,
|
|
SparseMatrix,
|
|
AccessorNode,
|
|
IndexNode,
|
|
AssignmentNode,
|
|
ImmutableDenseMatrix,
|
|
Index,
|
|
FibonacciHeap,
|
|
Spa,
|
|
Unit,
|
|
SymbolNode,
|
|
FunctionNode,
|
|
Help,
|
|
Parser
|
|
});
|
|
Chain.createProxy(math);
|
|
|
|
// main.ts
|
|
var NumeralsLayout = /* @__PURE__ */ ((NumeralsLayout2) => {
|
|
NumeralsLayout2["TwoPanes"] = "TwoPanes";
|
|
NumeralsLayout2["AnswerRight"] = "AnswerRight";
|
|
NumeralsLayout2["AnswerBelow"] = "AnswerBelow";
|
|
NumeralsLayout2["AnswerInline"] = "AnswerInline";
|
|
return NumeralsLayout2;
|
|
})(NumeralsLayout || {});
|
|
var numeralsLayoutClasses = {
|
|
["TwoPanes" /* TwoPanes */]: "numerals-panes",
|
|
["AnswerRight" /* AnswerRight */]: "numerals-answer-right",
|
|
["AnswerBelow" /* AnswerBelow */]: "numerals-answer-below",
|
|
["AnswerInline" /* AnswerInline */]: "numerals-answer-inline"
|
|
};
|
|
var NumeralsRenderStyle = /* @__PURE__ */ ((NumeralsRenderStyle2) => {
|
|
NumeralsRenderStyle2["Plain"] = "Plain";
|
|
NumeralsRenderStyle2["TeX"] = "TeX";
|
|
NumeralsRenderStyle2["SyntaxHighlight"] = "SyntaxHighlight";
|
|
return NumeralsRenderStyle2;
|
|
})(NumeralsRenderStyle || {});
|
|
var numeralsRenderStyleClasses = {
|
|
["Plain" /* Plain */]: "numerals-plain",
|
|
["TeX" /* TeX */]: "numerals-tex",
|
|
["SyntaxHighlight" /* SyntaxHighlight */]: "numerals-syntax"
|
|
};
|
|
var NumeralsNumberFormat = /* @__PURE__ */ ((NumeralsNumberFormat2) => {
|
|
NumeralsNumberFormat2["System"] = "System";
|
|
NumeralsNumberFormat2["Fixed"] = "Fixed";
|
|
NumeralsNumberFormat2["Exponential"] = "Exponential";
|
|
NumeralsNumberFormat2["Engineering"] = "Engineering";
|
|
NumeralsNumberFormat2["Format_CommaThousands_PeriodDecimal"] = "Format_CommaThousands_PeriodDecimal";
|
|
NumeralsNumberFormat2["Format_PeriodThousands_CommaDecimal"] = "Format_PeriodThousands_CommaDecimal";
|
|
NumeralsNumberFormat2["Format_SpaceThousands_CommaDecimal"] = "Format_SpaceThousands_CommaDecimal";
|
|
NumeralsNumberFormat2["Format_Indian"] = "Format_Indian";
|
|
return NumeralsNumberFormat2;
|
|
})(NumeralsNumberFormat || {});
|
|
var NumberalsNumberFormatSettingsStrings = {
|
|
["System" /* System */]: `System Formatted: ${100000.1 .toLocaleString()}`,
|
|
["Fixed" /* Fixed */]: "Fixed: 100000.1",
|
|
["Exponential" /* Exponential */]: "Exponential: 1.000001e+5",
|
|
["Engineering" /* Engineering */]: "Engineering: 100.0001e+3",
|
|
["Format_CommaThousands_PeriodDecimal" /* Format_CommaThousands_PeriodDecimal */]: "Formatted: 100,000.1",
|
|
["Format_PeriodThousands_CommaDecimal" /* Format_PeriodThousands_CommaDecimal */]: "Formatted: 100.000,1",
|
|
["Format_SpaceThousands_CommaDecimal" /* Format_SpaceThousands_CommaDecimal */]: "Formatted: 100\xA0000,1",
|
|
["Format_Indian" /* Format_Indian */]: "Formatted: 1,00,000.1"
|
|
};
|
|
var DEFAULT_SETTINGS = {
|
|
resultSeparator: " \u2192 ",
|
|
layoutStyle: "TwoPanes" /* TwoPanes */,
|
|
alternateRowColor: true,
|
|
defaultRenderStyle: "Plain" /* Plain */,
|
|
hideLinesWithoutMarkupWhenEmitting: true,
|
|
hideEmitterMarkupInInput: true,
|
|
dollarSymbolCurrency: { symbol: "$", currency: "USD" },
|
|
yenSymbolCurrency: { symbol: "\xA5", currency: "JPY" },
|
|
provideSuggestions: true,
|
|
suggestionsIncludeMathjsSymbols: false,
|
|
numberFormat: "System" /* System */
|
|
};
|
|
var defaultCurrencyMap = [
|
|
{ symbol: "$", unicode: "x024", name: "dollar", currency: "USD" },
|
|
{ symbol: "\u20AC", unicode: "x20AC", name: "euro", currency: "EUR" },
|
|
{ symbol: "\xA3", unicode: "x00A3", name: "pound", currency: "GBP" },
|
|
{ symbol: "\xA5", unicode: "x00A5", name: "yen", currency: "JPY" },
|
|
{ symbol: "\u20B9", unicode: "x20B9", name: "rupee", currency: "INR" }
|
|
];
|
|
var currencyCodesForDollarSign = {
|
|
ARS: "Argentine Peso",
|
|
AUD: "Australian Dollar",
|
|
BBD: "Barbadian Dollar",
|
|
BMD: "Bermudian Dollar",
|
|
BND: "Brunei Dollar",
|
|
BSD: "Bahamian Dollar",
|
|
BZD: "Belize Dollar",
|
|
CAD: "Canadian Dollar",
|
|
CLP: "Chilean Peso",
|
|
COP: "Colombian Peso",
|
|
FJD: "Fijian Dollar",
|
|
GYD: "Guyanese Dollar",
|
|
HKD: "Hong Kong Dollar",
|
|
JMD: "Jamaican Dollar",
|
|
KYD: "Cayman Islands Dollar",
|
|
LRD: "Liberian Dollar",
|
|
MXN: "Mexican Peso",
|
|
NAD: "Namibian Dollar",
|
|
NZD: "New Zealand Dollar",
|
|
SBD: "Solomon Islands Dollar",
|
|
SGD: "Singapore Dollar",
|
|
SRD: "Surinamese Dollar",
|
|
TTD: "Trinidad and Tobago Dollar",
|
|
TWD: "New Taiwan Dollar",
|
|
USD: "United States Dollar",
|
|
UYU: "Uruguayan Peso",
|
|
XCD: "East Caribbean Dollar"
|
|
};
|
|
var currencyCodesForYenSign = {
|
|
JPY: "Japanese Yen",
|
|
CNY: "Chinese Yuan",
|
|
KRW: "Korean Won"
|
|
};
|
|
var currencySymbols = defaultCurrencyMap.map((m) => m.symbol);
|
|
var isAlphaOriginal = parse.isAlpha;
|
|
parse.isAlpha = function(c, cPrev, cNext) {
|
|
return isAlphaOriginal(c, cPrev, cNext) || currencySymbols.includes(c);
|
|
};
|
|
var isUnitAlphaOriginal = Unit.isValidAlpha;
|
|
Unit.isValidAlpha = function(c, cPrev, cNext) {
|
|
return isUnitAlphaOriginal(c, cPrev, cNext) || currencySymbols.includes(c);
|
|
};
|
|
function texCurrencyReplacement(input_tex) {
|
|
for (let symbolType of defaultCurrencyMap) {
|
|
input_tex = input_tex.replace(RegExp("\\\\*\\" + symbolType.symbol, "g"), "\\" + symbolType.name);
|
|
}
|
|
return input_tex;
|
|
}
|
|
function htmlToElements(html) {
|
|
const sanitizedHTML = (0, import_obsidian.sanitizeHTMLToDom)(html);
|
|
return sanitizedHTML;
|
|
}
|
|
async function mathjaxLoop(container, value) {
|
|
const html = (0, import_obsidian.renderMath)(value, true);
|
|
await (0, import_obsidian.finishRenderMath)();
|
|
container.append(html);
|
|
}
|
|
function getLocaleFormatter(locale = null) {
|
|
if (locale === null) {
|
|
return (value) => value.toLocaleString();
|
|
} else {
|
|
return (value) => value.toLocaleString(locale);
|
|
}
|
|
}
|
|
function getMathjsFormat(format5) {
|
|
switch (format5) {
|
|
case "System" /* System */:
|
|
return getLocaleFormatter();
|
|
case "Fixed" /* Fixed */:
|
|
return { notation: "fixed" };
|
|
case "Exponential" /* Exponential */:
|
|
return { notation: "exponential" };
|
|
case "Engineering" /* Engineering */:
|
|
return { notation: "engineering" };
|
|
case "Format_CommaThousands_PeriodDecimal" /* Format_CommaThousands_PeriodDecimal */:
|
|
return getLocaleFormatter("en-US");
|
|
case "Format_PeriodThousands_CommaDecimal" /* Format_PeriodThousands_CommaDecimal */:
|
|
return getLocaleFormatter("de-DE");
|
|
case "Format_SpaceThousands_CommaDecimal" /* Format_SpaceThousands_CommaDecimal */:
|
|
return getLocaleFormatter("fr-FR");
|
|
case "Format_Indian" /* Format_Indian */:
|
|
return getLocaleFormatter("en-IN");
|
|
default:
|
|
return { notation: "fixed" };
|
|
}
|
|
}
|
|
var NumeralsPlugin = class extends import_obsidian.Plugin {
|
|
constructor() {
|
|
super(...arguments);
|
|
this.currencyMap = defaultCurrencyMap;
|
|
}
|
|
async numeralsMathBlockHandler(type, source, el, ctx) {
|
|
const blockRenderStyle = type ? type : this.settings.defaultRenderStyle;
|
|
el.toggleClass("numerals-block", true);
|
|
el.toggleClass(numeralsLayoutClasses[this.settings.layoutStyle], true);
|
|
el.toggleClass(numeralsRenderStyleClasses[blockRenderStyle], true);
|
|
el.toggleClass("numerals-alt-row-color", this.settings.alternateRowColor);
|
|
const rawRows = source.split("\n");
|
|
let processedSource = source;
|
|
const emitter_lines = [];
|
|
for (let i2 = 0; i2 < rawRows.length; i2++) {
|
|
if (rawRows[i2].match(/^[^#\r\n]*=>.*$/)) {
|
|
emitter_lines.push(i2);
|
|
}
|
|
}
|
|
if (emitter_lines.length > 0) {
|
|
el.toggleClass("numerals-emitters-present", true);
|
|
el.toggleClass("numerals-hide-non-emitters", this.settings.hideLinesWithoutMarkupWhenEmitting);
|
|
}
|
|
processedSource = processedSource.replace(/^([^#\r\n]*)(=>[\t ]*)(.*)$/gm, "$1$3");
|
|
for (let processor of this.preProcessors) {
|
|
processedSource = processedSource.replace(processor.regex, processor.replaceStr);
|
|
}
|
|
let errorMsg = null;
|
|
let errorInput = "";
|
|
const rows = processedSource.split("\n");
|
|
let results = [];
|
|
let inputs = [];
|
|
let scope = {};
|
|
for (let row2 of rows.slice(0, -1)) {
|
|
try {
|
|
results.push(evaluate(row2, scope));
|
|
inputs.push(row2);
|
|
} catch (error) {
|
|
errorMsg = error;
|
|
errorInput = row2;
|
|
break;
|
|
}
|
|
}
|
|
const lastRow = rows.slice(-1)[0];
|
|
if (lastRow != "") {
|
|
try {
|
|
results.push(evaluate(lastRow, scope));
|
|
inputs.push(lastRow);
|
|
} catch (error) {
|
|
errorMsg = error;
|
|
errorInput = lastRow;
|
|
}
|
|
}
|
|
for (let i2 = 0; i2 < inputs.length; i2++) {
|
|
const line = el.createEl("div", { cls: "numerals-line" });
|
|
const emptyLine = results[i2] === void 0;
|
|
if (emitter_lines.includes(i2)) {
|
|
line.toggleClass("numerals-emitter", true);
|
|
}
|
|
if (this.settings.hideEmitterMarkupInInput) {
|
|
rawRows[i2] = rawRows[i2].replace(/^([^#\r\n]*)(=>[\t ]*)(.*)$/gm, "$1$3");
|
|
}
|
|
let inputElement, resultElement;
|
|
switch (blockRenderStyle) {
|
|
case "Plain" /* Plain */: {
|
|
let rawInputSansComment = rawRows[i2].replace(/#.+$/, "");
|
|
let inputText = emptyLine ? rawRows[i2] : rawInputSansComment;
|
|
inputElement = line.createEl("span", { text: inputText, cls: "numerals-input" });
|
|
const formattedResult = !emptyLine ? this.settings.resultSeparator + format4(results[i2], this.numberFormat) : "\xA0";
|
|
resultElement = line.createEl("span", { text: formattedResult, cls: "numerals-result" });
|
|
break;
|
|
}
|
|
case "TeX" /* TeX */: {
|
|
let inputText = emptyLine ? rawRows[i2] : "";
|
|
inputElement = line.createEl("span", { text: inputText, cls: "numerals-input" });
|
|
const resultContent = !emptyLine ? "" : "\xA0";
|
|
resultElement = line.createEl("span", { text: resultContent, cls: "numerals-result" });
|
|
if (!emptyLine) {
|
|
let input_tex = parse(inputs[i2]).toTex();
|
|
let inputTexElement = inputElement.createEl("span", { cls: "numerals-tex" });
|
|
input_tex = texCurrencyReplacement(input_tex);
|
|
mathjaxLoop(inputTexElement, input_tex);
|
|
let resultTexElement = resultElement.createEl("span", { cls: "numerals-tex" });
|
|
let processedResult = format4(results[i2], getLocaleFormatter("posix"));
|
|
for (let processor of this.preProcessors) {
|
|
processedResult = processedResult.replace(processor.regex, processor.replaceStr);
|
|
}
|
|
let texResult = parse(processedResult).toTex();
|
|
texResult = texCurrencyReplacement(texResult);
|
|
mathjaxLoop(resultTexElement, texResult);
|
|
}
|
|
break;
|
|
}
|
|
case "SyntaxHighlight" /* SyntaxHighlight */: {
|
|
let inputText = emptyLine ? rawRows[i2] : "";
|
|
inputElement = line.createEl("span", { text: inputText, cls: "numerals-input" });
|
|
if (!emptyLine) {
|
|
const input_elements = htmlToElements(parse(inputs[i2]).toHTML());
|
|
inputElement.appendChild(input_elements);
|
|
}
|
|
const formattedResult = !emptyLine ? this.settings.resultSeparator + format4(results[i2], this.numberFormat) : "\xA0";
|
|
resultElement = line.createEl("span", { text: formattedResult, cls: "numerals-result" });
|
|
break;
|
|
}
|
|
}
|
|
if (!emptyLine) {
|
|
let inlineComment = rawRows[i2].match(/#.+$/);
|
|
if (inlineComment) {
|
|
inputElement.createEl("span", { cls: "numerals-inline-comment", text: inlineComment[0] });
|
|
}
|
|
} else {
|
|
resultElement.toggleClass("numerals-empty", true);
|
|
inputElement.toggleClass("numerals-empty", true);
|
|
resultElement.setText("\xA0");
|
|
}
|
|
}
|
|
if (errorMsg) {
|
|
const line = el.createEl("div", { cls: "numerals-error-line" });
|
|
const inputElement = line.createEl("span", { text: errorInput, cls: "numerals-input" });
|
|
const resultElement = line.createEl("span", { cls: "numerals-result" });
|
|
resultElement.createEl("span", { cls: "numerals-error-name", text: errorMsg.name + ":" });
|
|
resultElement.createEl("span", { cls: "numerals-error-message", text: errorMsg.message });
|
|
}
|
|
}
|
|
createCurrencyMap(dollarCurrency, yenCurrency) {
|
|
const currencyMap = defaultCurrencyMap.map((m) => {
|
|
if (m.symbol === "$") {
|
|
if (Object.keys(currencyCodesForDollarSign).includes(dollarCurrency)) {
|
|
m.currency = dollarCurrency;
|
|
}
|
|
} else if (m.symbol === "\xA5") {
|
|
if (Object.keys(currencyCodesForYenSign).includes(yenCurrency)) {
|
|
m.currency = yenCurrency;
|
|
}
|
|
}
|
|
return m;
|
|
});
|
|
return currencyMap;
|
|
}
|
|
async onload() {
|
|
await this.loadSettings();
|
|
await (0, import_obsidian.loadMathJax)();
|
|
this.currencyMap = this.createCurrencyMap(this.settings.dollarSymbolCurrency.currency, this.settings.yenSymbolCurrency.currency);
|
|
const configureCurrencyStr = this.currencyMap.map((m) => "\\def\\" + m.name + "{\\unicode{" + m.unicode + "}}").join("\n");
|
|
const currencyTex = (0, import_obsidian.renderMath)(configureCurrencyStr, true);
|
|
for (let moneyType of this.currencyMap) {
|
|
createUnit(moneyType.currency, { aliases: [moneyType.currency.toLowerCase(), moneyType.symbol] });
|
|
}
|
|
this.currencyPreProcessors = this.currencyMap.map((m) => {
|
|
return { regex: RegExp("\\" + m.symbol + "([\\d\\.]+)", "g"), replaceStr: "$1 " + m.currency };
|
|
});
|
|
this.preProcessors = [
|
|
{ regex: /,(\d{3})/g, replaceStr: "$1" },
|
|
...this.currencyPreProcessors
|
|
];
|
|
this.registerMarkdownCodeBlockProcessor("math", this.numeralsMathBlockHandler.bind(this, null));
|
|
this.registerMarkdownCodeBlockProcessor("Math", this.numeralsMathBlockHandler.bind(this, null));
|
|
this.registerMarkdownCodeBlockProcessor("math-plain", this.numeralsMathBlockHandler.bind(this, "Plain" /* Plain */));
|
|
this.registerMarkdownCodeBlockProcessor("math-tex", this.numeralsMathBlockHandler.bind(this, "TeX" /* TeX */));
|
|
this.registerMarkdownCodeBlockProcessor("math-TeX", this.numeralsMathBlockHandler.bind(this, "TeX" /* TeX */));
|
|
this.registerMarkdownCodeBlockProcessor("math-highlight", this.numeralsMathBlockHandler.bind(this, "SyntaxHighlight" /* SyntaxHighlight */));
|
|
this.addSettingTab(new NumeralsSettingTab(this.app, this));
|
|
if (this.settings.provideSuggestions) {
|
|
this.registerEditorSuggest(new NumeralsSuggestor(this));
|
|
}
|
|
this.updateLocale();
|
|
}
|
|
async loadSettings() {
|
|
let loadData = await this.loadData();
|
|
if (loadData) {
|
|
if (loadData.layoutStyle == void 0) {
|
|
const oldRenderStyleMap = {
|
|
1: "TwoPanes" /* TwoPanes */,
|
|
2: "AnswerRight" /* AnswerRight */,
|
|
3: "AnswerBelow" /* AnswerBelow */
|
|
};
|
|
loadData.layoutStyle = oldRenderStyleMap[loadData.renderStyle];
|
|
if (loadData.layoutStyle) {
|
|
delete loadData.renderStyle;
|
|
this.settings = loadData;
|
|
this.saveSettings();
|
|
} else {
|
|
console.log("Numerals: Error porting old layout style");
|
|
}
|
|
} else if (loadData.layoutStyle in [0, 1, 2, 3]) {
|
|
const oldLayoutStyleMap = {
|
|
0: "TwoPanes" /* TwoPanes */,
|
|
1: "AnswerRight" /* AnswerRight */,
|
|
2: "AnswerBelow" /* AnswerBelow */,
|
|
3: "AnswerInline" /* AnswerInline */
|
|
};
|
|
loadData.layoutStyle = oldLayoutStyleMap[loadData.layoutStyle];
|
|
if (loadData.layoutStyle) {
|
|
this.settings = loadData;
|
|
this.saveSettings();
|
|
} else {
|
|
console.log("Numerals: Error porting old layout style");
|
|
}
|
|
}
|
|
}
|
|
this.settings = Object.assign({}, DEFAULT_SETTINGS, loadData);
|
|
}
|
|
async saveSettings() {
|
|
await this.saveData(this.settings);
|
|
}
|
|
updateLocale() {
|
|
this.numberFormat = getMathjsFormat(this.settings.numberFormat);
|
|
}
|
|
};
|
|
var NumeralsSettingTab = class extends import_obsidian.PluginSettingTab {
|
|
constructor(app, plugin) {
|
|
super(app, plugin);
|
|
this.plugin = plugin;
|
|
}
|
|
display() {
|
|
const { containerEl } = this;
|
|
containerEl.empty();
|
|
containerEl.createEl("h1", { text: "Numerals Plugin Settings" });
|
|
new import_obsidian.Setting(containerEl).setHeading().setName("Layout and Render Settings");
|
|
new import_obsidian.Setting(containerEl).setName("Numerals Layout Style").setDesc("Layout of math blocks in Live Preview and Reading mode").addDropdown((dropDown) => {
|
|
dropDown.addOption("TwoPanes" /* TwoPanes */, "2 Panes");
|
|
dropDown.addOption("AnswerRight" /* AnswerRight */, "Answer to the right");
|
|
dropDown.addOption("AnswerBelow" /* AnswerBelow */, "Answer below each line");
|
|
dropDown.addOption("AnswerInline" /* AnswerInline */, "Answer inline, beside input");
|
|
dropDown.setValue(this.plugin.settings.layoutStyle);
|
|
dropDown.onChange(async (value) => {
|
|
let layoutStyleStr = value;
|
|
this.plugin.settings.layoutStyle = NumeralsLayout[layoutStyleStr];
|
|
await this.plugin.saveSettings();
|
|
});
|
|
});
|
|
new import_obsidian.Setting(containerEl).setName("Default Numerals Rendering Style").setDesc("Choose how the input and results are rendered by default. Note that you can specify the rendering style on a per block basis, by using `math-plain`, `math-tex`, or `math-highlight`").addDropdown((dropDown) => {
|
|
dropDown.addOption("Plain" /* Plain */, "Plain Text");
|
|
dropDown.addOption("TeX" /* TeX */, "TeX Style");
|
|
dropDown.addOption("SyntaxHighlight" /* SyntaxHighlight */, "Syntax Highlighting of Plain Text");
|
|
dropDown.setValue(this.plugin.settings.defaultRenderStyle);
|
|
dropDown.onChange(async (value) => {
|
|
let renderStyleStr = value;
|
|
this.plugin.settings.defaultRenderStyle = NumeralsRenderStyle[renderStyleStr];
|
|
await this.plugin.saveSettings();
|
|
});
|
|
});
|
|
new import_obsidian.Setting(containerEl).setHeading().setName("Auto-Complete Suggestion Settings");
|
|
new import_obsidian.Setting(containerEl).setName("Provide Auto-Complete Suggestions").setDesc("Enable auto-complete suggestions when inside a math codeblock. Will base suggestions on variables in current codeblock, as well as mathjs functions and constants if enabled below (Disabling requires restart to take effect)").addToggle((toggle) => toggle.setValue(this.plugin.settings.provideSuggestions).onChange(async (value) => {
|
|
this.plugin.settings.provideSuggestions = value;
|
|
if (value) {
|
|
this.plugin.registerEditorSuggest(new NumeralsSuggestor(this.plugin));
|
|
}
|
|
await this.plugin.saveSettings();
|
|
}));
|
|
new import_obsidian.Setting(containerEl).setName("Include Functions and Constants in Suggestions").setDesc("Auto-complete suggestions will include mathjs functions, constants, and physical constants.").addToggle((toggle) => toggle.setValue(this.plugin.settings.suggestionsIncludeMathjsSymbols).onChange(async (value) => {
|
|
this.plugin.settings.suggestionsIncludeMathjsSymbols = value;
|
|
await this.plugin.saveSettings();
|
|
}));
|
|
new import_obsidian.Setting(containerEl).setHeading().setName("Styling Settings");
|
|
new import_obsidian.Setting(containerEl).setName("Result Indicator").setDesc("String to show preceeding the calculation result").addText((text) => text.setPlaceholder('" \u2192 "').setValue(this.plugin.settings.resultSeparator).onChange(async (value) => {
|
|
this.plugin.settings.resultSeparator = value;
|
|
await this.plugin.saveSettings();
|
|
}));
|
|
new import_obsidian.Setting(containerEl).setName("Alternating row color").setDesc("Alternating rows are colored slightly differently to help differentiate between rows").addToggle((toggle) => toggle.setValue(this.plugin.settings.alternateRowColor).onChange(async (value) => {
|
|
this.plugin.settings.alternateRowColor = value;
|
|
await this.plugin.saveSettings();
|
|
}));
|
|
new import_obsidian.Setting(containerEl).setName("Hide Result on Lines without Result Annotation").setDesc("If a math block uses result annotation (`=>`) on any line, hide the results for lines that are not annotated as a result. If off, results of non-annotated lines will be shown in faint text color.").addToggle((toggle) => toggle.setValue(this.plugin.settings.hideLinesWithoutMarkupWhenEmitting).onChange(async (value) => {
|
|
this.plugin.settings.hideLinesWithoutMarkupWhenEmitting = value;
|
|
await this.plugin.saveSettings();
|
|
}));
|
|
let resultAnnotationMarkupDesc = document.createDocumentFragment();
|
|
resultAnnotationMarkupDesc.append("Result Annotation markup (`=>`) is used to indicate which line is the result of the calculation. It can be used on any line, and can be used multiple times in a single block. If used, the result of the last line with the markup will be shown in the result column. If not used, the result of the last line will be shown in the result column.");
|
|
new import_obsidian.Setting(containerEl).setName("Hide Result Annotation Markup in Input").setDesc("Result Annotation markup (`=>`) will be hidden in the input when rendering the math block").addToggle((toggle) => toggle.setValue(this.plugin.settings.hideEmitterMarkupInInput).onChange(async (value) => {
|
|
this.plugin.settings.hideEmitterMarkupInInput = value;
|
|
await this.plugin.saveSettings();
|
|
}));
|
|
new import_obsidian.Setting(containerEl).setHeading().setName("Number and Currency Formatting");
|
|
let customLocaleSetting;
|
|
new import_obsidian.Setting(containerEl).setName("Rendered Number Format").setDesc(htmlToElements(`Choose how to format numbers in the results.<br><b>System Formatted:</b> Use your local system settings for number formatting (Currently <code>${navigator.language}</code>)<br><b>Fixed:</b> No thousands seperator and full precision.<br><b>Exponential:</b> Always use exponential notation.<br><b>Engineering:</b> Exponential notation with exponent a multiple of 3.<br><b>Formatted:</b> Forces a specific type of formatted notation.<br><br><i>Note:</i> <code>math-tex</code> mode will always use period as decimal seperator, regardless of locale.<br>`)).addDropdown((dropDown) => {
|
|
for (const settingName in NumberalsNumberFormatSettingsStrings) {
|
|
dropDown.addOption(settingName, NumberalsNumberFormatSettingsStrings[settingName]);
|
|
}
|
|
dropDown.setValue(this.plugin.settings.numberFormat);
|
|
dropDown.onChange(async (value) => {
|
|
let formatStyleStr = value;
|
|
this.plugin.settings.numberFormat = NumeralsNumberFormat[formatStyleStr];
|
|
await this.plugin.saveSettings();
|
|
this.plugin.updateLocale();
|
|
});
|
|
});
|
|
new import_obsidian.Setting(containerEl).setName("`$` symbol currency mapping").setDesc("Choose the currency the `$` symbol maps to (requires Obsidian reload to take effect)").addDropdown((dropDown) => {
|
|
for (let currencyCode in currencyCodesForDollarSign) {
|
|
dropDown.addOption(currencyCode, `${currencyCode} (${currencyCodesForDollarSign[currencyCode]})`);
|
|
}
|
|
dropDown.setValue(this.plugin.settings.dollarSymbolCurrency.currency);
|
|
dropDown.onChange(async (value) => {
|
|
this.plugin.settings.dollarSymbolCurrency.currency = value;
|
|
await this.plugin.saveSettings();
|
|
});
|
|
});
|
|
new import_obsidian.Setting(containerEl).setName("`\xA5` symbol currency mapping").setDesc("Choose the currency the `\xA5` symbol maps to (requires Obsidian reload to take effect)").addDropdown((dropDown) => {
|
|
for (let currencyCode in currencyCodesForYenSign) {
|
|
dropDown.addOption(currencyCode, `${currencyCode} (${currencyCodesForYenSign[currencyCode]})`);
|
|
}
|
|
dropDown.setValue(this.plugin.settings.yenSymbolCurrency.currency);
|
|
dropDown.onChange(async (value) => {
|
|
this.plugin.settings.yenSymbolCurrency.currency = value;
|
|
await this.plugin.saveSettings();
|
|
});
|
|
});
|
|
}
|
|
};
|
|
var NumeralsSuggestor = class extends import_obsidian.EditorSuggest {
|
|
constructor(plugin) {
|
|
super(plugin.app);
|
|
this.lastSuggestionListUpdate = 0;
|
|
this.localSuggestionCache = [];
|
|
this.plugin = plugin;
|
|
}
|
|
onTrigger(cursor, editor, file) {
|
|
const currentFileToCursor = editor.getRange({ line: 0, ch: 0 }, cursor);
|
|
const indexOfLastCodeBlockStart = currentFileToCursor.lastIndexOf("```");
|
|
const isMathBlock = currentFileToCursor.slice(indexOfLastCodeBlockStart + 3, indexOfLastCodeBlockStart + 7).toLowerCase() === "math";
|
|
if (!isMathBlock) {
|
|
return null;
|
|
}
|
|
let currentLineToCursor = editor.getLine(cursor.line).slice(0, cursor.ch);
|
|
let currentLineLastWordStart = currentLineToCursor.search(/\w+$/);
|
|
if (currentLineLastWordStart === -1) {
|
|
return null;
|
|
}
|
|
return {
|
|
start: { line: cursor.line, ch: currentLineLastWordStart },
|
|
end: cursor,
|
|
query: currentLineToCursor.slice(currentLineLastWordStart)
|
|
};
|
|
}
|
|
getSuggestions(context) {
|
|
let localSymbols = [];
|
|
if (performance.now() - this.lastSuggestionListUpdate > 200) {
|
|
const currentFileToStart = context.editor.getRange({ line: 0, ch: 0 }, context.start);
|
|
const indexOfLastCodeBlockStart = currentFileToStart.lastIndexOf("```");
|
|
if (indexOfLastCodeBlockStart > -1) {
|
|
const lastCodeBlockStart = currentFileToStart.lastIndexOf("```");
|
|
const lastCodeBlockStartToCursor = currentFileToStart.slice(lastCodeBlockStart);
|
|
const matches = lastCodeBlockStartToCursor.matchAll(/^\s*(\S*?)\s*=.*$/gm);
|
|
localSymbols = [...new Set(Array.from(matches, (match) => "v|" + match[1]))];
|
|
}
|
|
this.localSuggestionCache = localSymbols;
|
|
this.lastSuggestionListUpdate = performance.now();
|
|
} else {
|
|
localSymbols = this.localSuggestionCache;
|
|
}
|
|
const query_lower = context.query.toLowerCase();
|
|
const local_suggestions = localSymbols.filter((value) => value.slice(0, -1).toLowerCase().startsWith(query_lower, 2));
|
|
local_suggestions.sort((a, b) => a.slice(2).localeCompare(b.slice(2)));
|
|
let suggestions = [];
|
|
if (this.plugin.settings.suggestionsIncludeMathjsSymbols) {
|
|
const mathjs_suggestions = getMathJsSymbols().filter((value) => value.slice(0, -1).toLowerCase().startsWith(query_lower, 2));
|
|
suggestions = local_suggestions.concat(mathjs_suggestions);
|
|
} else {
|
|
suggestions = local_suggestions;
|
|
}
|
|
return suggestions;
|
|
}
|
|
renderSuggestion(value, el) {
|
|
el.addClasses(["mod-complex", "numerals-suggestion"]);
|
|
let suggestionContent = el.createDiv({ cls: "suggestion-content" });
|
|
let suggestionTitle = suggestionContent.createDiv({ cls: "suggestion-title" });
|
|
let suggestionNote = suggestionContent.createDiv({ cls: "suggestion-note" });
|
|
let suggestionAux = el.createDiv({ cls: "suggestion-aux" });
|
|
let suggestionFlair = suggestionAux.createDiv({ cls: "suggestion-flair" });
|
|
let [iconType, suggestionText, noteText] = value.split("|");
|
|
if (iconType === "f") {
|
|
(0, import_obsidian.setIcon)(suggestionFlair, "function-square");
|
|
} else if (iconType === "c") {
|
|
(0, import_obsidian.setIcon)(suggestionFlair, "locate-fixed");
|
|
} else if (iconType === "v") {
|
|
(0, import_obsidian.setIcon)(suggestionFlair, "file-code");
|
|
} else if (iconType === "p") {
|
|
(0, import_obsidian.setIcon)(suggestionFlair, "box");
|
|
}
|
|
suggestionTitle.setText(suggestionText);
|
|
}
|
|
selectSuggestion(value, evt) {
|
|
if (this.context) {
|
|
let editor = this.context.editor;
|
|
let [suggestionType, suggestion] = value.split("|");
|
|
let start = this.context.start;
|
|
let end = editor.getCursor();
|
|
editor.replaceRange(suggestion, start, end);
|
|
let newCursor = end;
|
|
if (suggestionType === "f") {
|
|
newCursor.ch = start.ch + suggestion.length - 1;
|
|
} else {
|
|
newCursor.ch = start.ch + suggestion.length;
|
|
}
|
|
editor.setCursor(newCursor);
|
|
this.close();
|
|
}
|
|
}
|
|
};
|
|
function getMathJsSymbols() {
|
|
const mathjsBuiltInSymbols = [
|
|
"f|abs()",
|
|
"f|acos()",
|
|
"f|acosh()",
|
|
"f|acot()",
|
|
"f|acoth()",
|
|
"f|acsc()",
|
|
"f|acsch()",
|
|
"f|add()",
|
|
"f|and()",
|
|
"f|apply()",
|
|
"f|arg()",
|
|
"f|asec()",
|
|
"f|asech()",
|
|
"f|asin()",
|
|
"f|asinh()",
|
|
"f|atan()",
|
|
"f|atan2()",
|
|
"f|atanh()",
|
|
"p|atm",
|
|
"p|atomicMass",
|
|
"p|avogadro",
|
|
"f|bellNumbers()",
|
|
"f|bin()",
|
|
"f|bitAnd()",
|
|
"f|bitNot()",
|
|
"f|bitOr()",
|
|
"f|bitXor()",
|
|
"p|bohrMagneton",
|
|
"p|bohrRadius",
|
|
"p|boltzmann",
|
|
"f|catalan()",
|
|
"f|cbrt()",
|
|
"f|ceil()",
|
|
"p|classicalElectronRadius",
|
|
"f|clone()",
|
|
"f|column()",
|
|
"f|combinations()",
|
|
"f|combinationsWithRep()",
|
|
"f|compare()",
|
|
"f|compareNatural()",
|
|
"f|compareText()",
|
|
"f|compile()",
|
|
"f|composition()",
|
|
"f|concat()",
|
|
"p|conductanceQuantum",
|
|
"f|conj()",
|
|
"f|cos()",
|
|
"f|cosh()",
|
|
"f|cot()",
|
|
"f|coth()",
|
|
"p|coulomb",
|
|
"f|count()",
|
|
"f|cross()",
|
|
"f|csc()",
|
|
"f|csch()",
|
|
"f|ctranspose()",
|
|
"f|cube()",
|
|
"f|cumsum()",
|
|
"f|deepEqual()",
|
|
"f|derivative()",
|
|
"f|det()",
|
|
"p|deuteronMass",
|
|
"f|diag()",
|
|
"f|diff()",
|
|
"f|distance()",
|
|
"f|divide()",
|
|
"f|dot()",
|
|
"f|dotDivide()",
|
|
"f|dotMultiply()",
|
|
"f|dotPow()",
|
|
"c|e",
|
|
"p|efimovFactor",
|
|
"f|eigs()",
|
|
"p|electricConstant",
|
|
"p|electronMass",
|
|
"p|elementaryCharge",
|
|
"f|equal()",
|
|
"f|equalText()",
|
|
"f|erf()",
|
|
"f|evaluate()",
|
|
"f|exp()",
|
|
"f|expm()",
|
|
"f|expm1()",
|
|
"f|factorial()",
|
|
"p|faraday",
|
|
"p|fermiCoupling",
|
|
"f|fft()",
|
|
"f|filter()",
|
|
"p|fineStructure",
|
|
"p|firstRadiation",
|
|
"f|fix()",
|
|
"f|flatten()",
|
|
"f|floor()",
|
|
"f|forEach()",
|
|
"f|format()",
|
|
"f|gamma()",
|
|
"p|gasConstant",
|
|
"f|gcd()",
|
|
"f|getMatrixDataType()",
|
|
"p|gravitationConstant",
|
|
"p|gravity",
|
|
"p|hartreeEnergy",
|
|
"f|hasNumericValue()",
|
|
"f|help()",
|
|
"f|hex()",
|
|
"f|hypot()",
|
|
"c|i",
|
|
"f|identity()",
|
|
"f|ifft()",
|
|
"f|im()",
|
|
"c|Infinity",
|
|
"f|intersect()",
|
|
"f|inv()",
|
|
"p|inverseConductanceQuantum",
|
|
"f|invmod()",
|
|
"f|isInteger()",
|
|
"f|isNaN()",
|
|
"f|isNegative()",
|
|
"f|isNumeric()",
|
|
"f|isPositive()",
|
|
"f|isPrime()",
|
|
"f|isZero()",
|
|
"f|kldivergence()",
|
|
"p|klitzing",
|
|
"f|kron()",
|
|
"f|larger()",
|
|
"f|largerEq()",
|
|
"f|lcm()",
|
|
"f|leafCount()",
|
|
"f|leftShift()",
|
|
"f|lgamma()",
|
|
"c|LN10",
|
|
"c|LN2",
|
|
"f|log()",
|
|
"f|log10()",
|
|
"c|LOG10E",
|
|
"f|log1p()",
|
|
"f|log2()",
|
|
"c|LOG2E",
|
|
"p|loschmidt",
|
|
"f|lsolve()",
|
|
"f|lsolveAll()",
|
|
"f|lup()",
|
|
"f|lusolve()",
|
|
"f|lyap()",
|
|
"f|mad()",
|
|
"p|magneticConstant",
|
|
"p|magneticFluxQuantum",
|
|
"f|map()",
|
|
"f|matrixFromColumns()",
|
|
"f|matrixFromFunction()",
|
|
"f|matrixFromRows()",
|
|
"f|max()",
|
|
"f|mean()",
|
|
"f|median()",
|
|
"f|min()",
|
|
"f|mod()",
|
|
"f|mode()",
|
|
"p|molarMass",
|
|
"p|molarMassC12",
|
|
"p|molarPlanckConstant",
|
|
"p|molarVolume",
|
|
"f|multinomial()",
|
|
"f|multiply()",
|
|
"c|NaN",
|
|
"p|neutronMass",
|
|
"f|norm()",
|
|
"f|not()",
|
|
"f|nthRoot()",
|
|
"f|nthRoots()",
|
|
"p|nuclearMagneton",
|
|
"c|null",
|
|
"f|numeric()",
|
|
"f|oct()",
|
|
"f|ones()",
|
|
"f|or()",
|
|
"f|parser()",
|
|
"f|partitionSelect()",
|
|
"f|permutations()",
|
|
"c|phi",
|
|
"c|pi",
|
|
"f|pickRandom()",
|
|
"f|pinv()",
|
|
"p|planckCharge",
|
|
"p|planckConstant",
|
|
"p|planckLength",
|
|
"p|planckMass",
|
|
"p|planckTemperature",
|
|
"p|planckTime",
|
|
"f|polynomialRoot()",
|
|
"f|pow()",
|
|
"f|print()",
|
|
"f|prod()",
|
|
"p|protonMass",
|
|
"f|qr()",
|
|
"f|quantileSeq()",
|
|
"p|quantumOfCirculation",
|
|
"f|random()",
|
|
"f|randomInt()",
|
|
"f|range()",
|
|
"f|rationalize()",
|
|
"f|re()",
|
|
"p|reducedPlanckConstant",
|
|
"f|reshape()",
|
|
"f|resize()",
|
|
"f|resolve()",
|
|
"f|rightArithShift()",
|
|
"f|rightLogShift()",
|
|
"f|rotate()",
|
|
"f|rotationMatrix()",
|
|
"f|round()",
|
|
"f|row()",
|
|
"p|rydberg",
|
|
"p|sackurTetrode",
|
|
"f|schur()",
|
|
"f|sec()",
|
|
"f|sech()",
|
|
"p|secondRadiation",
|
|
"f|setCartesian()",
|
|
"f|setDifference()",
|
|
"f|setDistinct()",
|
|
"f|setIntersect()",
|
|
"f|setIsSubset()",
|
|
"f|setMultiplicity()",
|
|
"f|setPowerset()",
|
|
"f|setSize()",
|
|
"f|setSymDifference()",
|
|
"f|setUnion()",
|
|
"f|sign()",
|
|
"f|simplify()",
|
|
"f|simplifyConstant()",
|
|
"f|simplifyCore()",
|
|
"f|sin()",
|
|
"f|sinh()",
|
|
"f|size()",
|
|
"f|slu()",
|
|
"f|smaller()",
|
|
"f|smallerEq()",
|
|
"f|sort()",
|
|
"p|speedOfLight",
|
|
"f|sqrt()",
|
|
"c|SQRT1_2",
|
|
"c|SQRT2",
|
|
"f|sqrtm()",
|
|
"f|square()",
|
|
"f|squeeze()",
|
|
"f|std()",
|
|
"p|stefanBoltzmann",
|
|
"f|stirlingS2()",
|
|
"f|subset()",
|
|
"f|subtract()",
|
|
"f|sum()",
|
|
"f|sylvester()",
|
|
"f|symbolicEqual()",
|
|
"f|tan()",
|
|
"f|tanh()",
|
|
"c|tau",
|
|
"p|thomsonCrossSection",
|
|
"f|to()",
|
|
"f|trace()",
|
|
"f|transpose()",
|
|
"f|typeOf()",
|
|
"f|unaryMinus()",
|
|
"f|unaryPlus()",
|
|
"f|unequal()",
|
|
"f|usolve()",
|
|
"f|usolveAll()",
|
|
"p|vacuumImpedance",
|
|
"f|variance()",
|
|
"p|weakMixingAngle",
|
|
"p|wienDisplacement",
|
|
"f|xgcd()",
|
|
"f|xor()",
|
|
"f|zeros()"
|
|
];
|
|
return mathjsBuiltInSymbols;
|
|
}
|
|
/*!
|
|
* decimal.js v10.4.3
|
|
* An arbitrary-precision Decimal type for JavaScript.
|
|
* https://github.com/MikeMcl/decimal.js
|
|
* Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
* MIT Licence
|
|
*/
|
|
/**
|
|
* @license Complex.js v2.1.1 12/05/2020
|
|
*
|
|
* Copyright (c) 2020, Robert Eisele (robert@xarg.org)
|
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
**/
|
|
/**
|
|
* @license Fraction.js v4.2.0 05/03/2022
|
|
* https://www.xarg.org/2014/03/rational-numbers-in-javascript/
|
|
*
|
|
* Copyright (c) 2021, Robert Eisele (robert@xarg.org)
|
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
**/
|