From 9131029fc7194e3ee634b5e126fa224aa54d567b Mon Sep 17 00:00:00 2001 From: Manuel Henke Date: Sat, 26 Feb 2022 16:40:15 +0100 Subject: [PATCH] minor style improvement and linting --- dist/ios-calculator.js | 135 +++++++++------- dist/ios-calculator.min.js | 18 +-- dist/ios-calculator.min.js.LICENSE.txt | 14 ++ src/iOSCalculator.js | 214 +++++++++++++++---------- src/ios-calculator.scss | 7 +- 5 files changed, 225 insertions(+), 163 deletions(-) create mode 100644 dist/ios-calculator.min.js.LICENSE.txt diff --git a/dist/ios-calculator.js b/dist/ios-calculator.js index 3c3ba64..b4b8721 100644 --- a/dist/ios-calculator.js +++ b/dist/ios-calculator.js @@ -1431,7 +1431,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/** var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default())); // Module -___CSS_LOADER_EXPORT___.push([module.id, "@font-face{font-family:\"San Francisco\";font-weight:400;src:url(\"https://applesocial.s3.amazonaws.com/assets/styles/fonts/sanfrancisco/sanfranciscodisplay-regular-webfont.woff\")}:host{display:inline-block}*,*::after,*::before{box-sizing:border-box}.calc{background-color:#000;border-radius:10px;display:inline-block;font-family:\"San Francisco\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen,Ubuntu,Cantarell,\"Open Sans\",\"Helvetica Neue\",sans-serif;color:#fff;padding:1rem}.calc .calc-solution{padding:3rem .5rem .5rem .5rem;font-size:4rem;overflow:hidden;white-space:nowrap;text-align:right;text-overflow:ellipsis;width:17.875rem}.calc .calc-buttons-container{-webkit-user-select:none;user-select:none;display:grid;grid-template-columns:repeat(4, 1fr);grid-template-rows:repeat(5, 1fr);gap:.625rem;font-size:2rem}.calc .calc-buttons-container .calc-button{padding:.5rem;border-radius:100%;cursor:pointer;opacity:.9;position:relative;transition-duration:.4s;overflow:hidden}.calc .calc-buttons-container .calc-button>span{display:inline-flex;place-items:center;place-content:center;text-align:center;height:3rem;width:3rem;line-height:3rem}.calc .calc-buttons-container .calc-button:hover{opacity:1}.calc .calc-buttons-container .calc-button:active:after{opacity:1;transition:0s}.calc .calc-buttons-container .calc-button:after{content:\"\";background:rgba(255,255,255,.25);display:block;position:absolute;inset:0;opacity:0;transition:all .8s}.calc .calc-buttons-container .calc-button.calc-button-double{grid-column:span 2;border-radius:5rem;justify-content:start}.calc .calc-buttons-container .calc-button.calc-button-digit{background-color:#444}.calc .calc-buttons-container .calc-button.calc-button-operand{background-color:orange}.calc .calc-buttons-container .calc-button.calc-button-operand.active{opacity:1;background-color:#fff;color:orange}.calc .calc-buttons-container .calc-button.calc-button-func{background-color:#afafaf;color:#000}", ""]); +___CSS_LOADER_EXPORT___.push([module.id, "@font-face{font-family:\"San Francisco\";font-weight:400;src:url(\"https://applesocial.s3.amazonaws.com/assets/styles/fonts/sanfrancisco/sanfranciscodisplay-regular-webfont.woff\")}:host{display:inline-block}*,*::after,*::before{box-sizing:border-box}.calc{background-color:#000;border-radius:10px;display:inline-block;font-family:\"San Francisco\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen,Ubuntu,Cantarell,\"Open Sans\",\"Helvetica Neue\",sans-serif;color:#fff;padding:1rem}.calc .calc-solution{padding:3rem .5rem .5rem .5rem;font-size:4rem;overflow:hidden;white-space:nowrap;text-align:right;text-overflow:ellipsis;width:17.875rem}.calc .calc-buttons-container{-webkit-user-select:none;user-select:none;display:grid;grid-template-columns:repeat(4, 1fr);grid-template-rows:repeat(5, 1fr);gap:.625rem;font-size:2rem}.calc .calc-buttons-container .calc-button{padding:.5rem;border-radius:100%;cursor:pointer;opacity:.9;position:relative;transition-duration:.4s;overflow:hidden}.calc .calc-buttons-container .calc-button>span{display:inline-flex;place-items:center;place-content:center;text-align:center;height:3rem;width:3rem;line-height:3rem}.calc .calc-buttons-container .calc-button:hover{opacity:1}.calc .calc-buttons-container .calc-button:active:after{opacity:1;transition:0s}.calc .calc-buttons-container .calc-button:after{content:\"\";background:rgba(255,255,255,.25);display:block;position:absolute;inset:0;opacity:0;transition:all .8s;border-radius:inherit}.calc .calc-buttons-container .calc-button.calc-button-double{grid-column:span 2;border-radius:5rem;justify-content:start}.calc .calc-buttons-container .calc-button.calc-button-digit{background-color:#444}.calc .calc-buttons-container .calc-button.calc-button-operand{background-color:orange}.calc .calc-buttons-container .calc-button.calc-button-operand.active{opacity:1;background-color:#fff;color:orange}.calc .calc-buttons-container .calc-button.calc-button-func{background-color:#afafaf;color:#000}", ""]); // Exports /* harmony default export */ __webpack_exports__["Z"] = (___CSS_LOADER_EXPORT___); @@ -67576,9 +67576,9 @@ function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor. -const template = document.createElement("template"); +const template = document.createElement('template'); template.innerHTML = ios_calculator; -const sheet = document.createElement("style"); +const sheet = document.createElement('style'); sheet.innerHTML = src_ios_calculator/* default.toString */.Z.toString(); var _currentExpression = /*#__PURE__*/new WeakMap(); @@ -67664,22 +67664,22 @@ class iOSCalculator extends HTMLElement { _classPrivateFieldInitSpec(this, _currentExpression, { writable: true, - value: "" + value: '' }); _classPrivateFieldInitSpec(this, _currentInput, { writable: true, - value: "" + value: '' }); _classPrivateFieldInitSpec(this, _suggestedInput, { writable: true, - value: "" + value: '' }); _classPrivateFieldInitSpec(this, _lastOperand, { writable: true, - value: "" + value: '' }); _classPrivateFieldInitSpec(this, _calcSolution, { @@ -67713,32 +67713,32 @@ class iOSCalculator extends HTMLElement { }); const shadowRoot = this.attachShadow({ - mode: "open" + mode: 'open' }); shadowRoot.appendChild(sheet.cloneNode(true)); shadowRoot.appendChild(template.content.cloneNode(true)); - _classPrivateFieldSet(this, _calcSolution, shadowRoot.querySelector(".calc-solution")); + _classPrivateFieldSet(this, _calcSolution, shadowRoot.querySelector('.calc-solution')); - _classPrivateFieldSet(this, _resetButton, shadowRoot.getElementById("reset")); + _classPrivateFieldSet(this, _resetButton, shadowRoot.getElementById('reset')); - _classPrivateFieldSet(this, _plusMinusButton, shadowRoot.getElementById("plus-minus")); + _classPrivateFieldSet(this, _plusMinusButton, shadowRoot.getElementById('plus-minus')); - _classPrivateFieldSet(this, _percentageButton, shadowRoot.getElementById("percentage")); + _classPrivateFieldSet(this, _percentageButton, shadowRoot.getElementById('percentage')); - _classPrivateFieldSet(this, _operandButtons, Array.from(shadowRoot.querySelectorAll(".calc-button-operand"))); + _classPrivateFieldSet(this, _operandButtons, Array.from(shadowRoot.querySelectorAll('.calc-button-operand'))); - _classPrivateFieldSet(this, _digitButtons, Array.from(shadowRoot.querySelectorAll(".calc-button-digit"))); + _classPrivateFieldSet(this, _digitButtons, Array.from(shadowRoot.querySelectorAll('.calc-button-digit'))); - _classPrivateFieldGet(this, _resetButton).addEventListener("click", _classPrivateMethodGet(this, _onResetClick, _onResetClick2).bind(this)); + _classPrivateFieldGet(this, _resetButton).addEventListener('click', _classPrivateMethodGet(this, _onResetClick, _onResetClick2).bind(this)); - _classPrivateFieldGet(this, _plusMinusButton).addEventListener("click", _classPrivateMethodGet(this, _onPlusMinusClick, _onPlusMinusClick2).bind(this)); + _classPrivateFieldGet(this, _plusMinusButton).addEventListener('click', _classPrivateMethodGet(this, _onPlusMinusClick, _onPlusMinusClick2).bind(this)); - _classPrivateFieldGet(this, _percentageButton).addEventListener("click", _classPrivateMethodGet(this, _onPercentageClick, _onPercentageClick2).bind(this)); + _classPrivateFieldGet(this, _percentageButton).addEventListener('click', _classPrivateMethodGet(this, _onPercentageClick, _onPercentageClick2).bind(this)); - _classPrivateFieldGet(this, _operandButtons).forEach(operandButton => operandButton.addEventListener("click", () => _classPrivateMethodGet(this, _onOperandClick, _onOperandClick2).call(this, operandButton))); + _classPrivateFieldGet(this, _operandButtons).forEach(operandButton => operandButton.addEventListener('click', event => _classPrivateMethodGet(this, _onOperandClick, _onOperandClick2).call(this, event, operandButton))); - _classPrivateFieldGet(this, _digitButtons).forEach(digitButton => digitButton.addEventListener("click", () => _classPrivateMethodGet(this, _onDigitClick, _onDigitClick2).call(this, digitButton))); + _classPrivateFieldGet(this, _digitButtons).forEach(digitButton => digitButton.addEventListener('click', event => _classPrivateMethodGet(this, _onDigitClick, _onDigitClick2).call(this, event, digitButton))); } connectedCallback() { @@ -67746,11 +67746,15 @@ class iOSCalculator extends HTMLElement { _classPrivateMethodGet(this, _displaySolution, _displaySolution2).call(this); } } + /** + * @param {PointerEvent} event + */ + /** - * @param {string} name - * @param {string} oldValue - * @param {string} newValue + * @param {string} name + * @param {string} oldValue + * @param {string} newValue */ attributeChangedCallback(name, oldValue, newValue) { if (newValue != oldValue) { @@ -67760,28 +67764,31 @@ class iOSCalculator extends HTMLElement { } -function _onResetClick2() { - const textSpan = _classPrivateFieldGet(this, _resetButton).querySelector("span"); +function _onResetClick2(event) { + event.preventDefault(); + + const textSpan = _classPrivateFieldGet(this, _resetButton).querySelector('span'); - if (textSpan.textContent === "AC") { + if (textSpan.textContent === 'AC') { // AC - _classPrivateFieldSet(this, _currentInput, ""); + _classPrivateFieldSet(this, _currentInput, ''); - _classPrivateFieldSet(this, _currentExpression, ""); + _classPrivateFieldSet(this, _currentExpression, ''); _classPrivateFieldGet(this, _operandButtons).forEach(_classPrivateMethodGet(this, _removeActiveState, _removeActiveState2)); } else { // C - _classPrivateFieldSet(this, _currentInput, "0"); + _classPrivateFieldSet(this, _currentInput, '0'); - textSpan.textContent = "AC"; + textSpan.textContent = 'AC'; } _classPrivateMethodGet(this, _displaySolution, _displaySolution2).call(this); } -function _onPlusMinusClick2() { - let number = "0"; +function _onPlusMinusClick2(event) { + event.preventDefault(); + let number = '0'; if (_classPrivateFieldGet(this, _currentInput).length > 0) { number = _classPrivateFieldGet(this, _currentInput); @@ -67798,8 +67805,9 @@ function _onPlusMinusClick2() { _classPrivateMethodGet(this, _displaySolution, _displaySolution2).call(this); } -function _onPercentageClick2() { - let number = "0"; +function _onPercentageClick2(event) { + event.preventDefault(); + let number = '0'; if (_classPrivateFieldGet(this, _currentInput).length > 0) { number = _classPrivateFieldGet(this, _currentInput); @@ -67807,18 +67815,19 @@ function _onPercentageClick2() { number = _classPrivateMethodGet(this, _getCurrentSolution, _getCurrentSolution2).call(this); } - let intermediateInput = number.replace(/,/g, "."); - intermediateInput += "/100"; + let intermediateInput = number.replace(/,/g, '.'); + intermediateInput += '/100'; _classPrivateFieldSet(this, _currentInput, String(evaluate(intermediateInput))); - _classPrivateFieldSet(this, _currentInput, _classPrivateFieldGet(this, _currentInput).replace(".", _classStaticPrivateFieldSpecGet(iOSCalculator, iOSCalculator, _CHARACTERS).COMMA)); + _classPrivateFieldSet(this, _currentInput, _classPrivateFieldGet(this, _currentInput).replace('.', _classStaticPrivateFieldSpecGet(iOSCalculator, iOSCalculator, _CHARACTERS).COMMA)); _classPrivateMethodGet(this, _displaySolution, _displaySolution2).call(this); } -function _onDigitClick2(digitButton) { - const clickedDigit = digitButton.dataset.digit || ""; +function _onDigitClick2(event, digitButton) { + event.preventDefault(); + const clickedDigit = digitButton.dataset.digit || ''; if (clickedDigit === _classStaticPrivateFieldSpecGet(iOSCalculator, iOSCalculator, _CHARACTERS).NEGATIVE && _classPrivateFieldGet(this, _currentInput).includes(_classStaticPrivateFieldSpecGet(iOSCalculator, iOSCalculator, _CHARACTERS).NEGATIVE)) { // prevent clicking multiple times -> , @@ -67828,14 +67837,14 @@ function _onDigitClick2(digitButton) { if (!_classPrivateMethodGet(this, _endsWithOperand, _endsWithOperand2).call(this, _classPrivateFieldGet(this, _currentExpression))) { // reset expression if user starts a new calculations // -> clicking a number with clicking an operand beforehand - _classPrivateFieldSet(this, _currentExpression, ""); + _classPrivateFieldSet(this, _currentExpression, ''); } - _classPrivateFieldGet(this, _resetButton).querySelector("span").textContent = "C"; + _classPrivateFieldGet(this, _resetButton).querySelector('span').textContent = 'C'; - if (_classPrivateFieldGet(this, _currentInput) === "" && clickedDigit === _classStaticPrivateFieldSpecGet(iOSCalculator, iOSCalculator, _CHARACTERS).COMMA) { - _classPrivateFieldSet(this, _currentInput, "0" + _classStaticPrivateFieldSpecGet(iOSCalculator, iOSCalculator, _CHARACTERS).COMMA); - } else if (_classPrivateFieldGet(this, _currentInput) === "0" && clickedDigit !== _classStaticPrivateFieldSpecGet(iOSCalculator, iOSCalculator, _CHARACTERS).COMMA) { + if (_classPrivateFieldGet(this, _currentInput) === '' && clickedDigit === _classStaticPrivateFieldSpecGet(iOSCalculator, iOSCalculator, _CHARACTERS).COMMA) { + _classPrivateFieldSet(this, _currentInput, '0' + _classStaticPrivateFieldSpecGet(iOSCalculator, iOSCalculator, _CHARACTERS).COMMA); + } else if (_classPrivateFieldGet(this, _currentInput) === '0' && clickedDigit !== _classStaticPrivateFieldSpecGet(iOSCalculator, iOSCalculator, _CHARACTERS).COMMA) { _classPrivateFieldSet(this, _currentInput, clickedDigit); } else if (_classPrivateFieldGet(this, _currentInput) === `${_classStaticPrivateFieldSpecGet(iOSCalculator, iOSCalculator, _CHARACTERS).NEGATIVE}0` && clickedDigit !== _classStaticPrivateFieldSpecGet(iOSCalculator, iOSCalculator, _CHARACTERS).COMMA) { _classPrivateFieldSet(this, _currentInput, _classStaticPrivateFieldSpecGet(iOSCalculator, iOSCalculator, _CHARACTERS).NEGATIVE + clickedDigit); @@ -67846,7 +67855,9 @@ function _onDigitClick2(digitButton) { _classPrivateMethodGet(this, _displaySolution, _displaySolution2).call(this); } -function _onOperandClick2(operandButton) { +function _onOperandClick2(event, operandButton) { + event.preventDefault(); + _classPrivateFieldGet(this, _operandButtons).forEach(_classPrivateMethodGet(this, _removeActiveState, _removeActiveState2)); const clickedOperand = operandButton.dataset.operand; @@ -67857,7 +67868,7 @@ function _onOperandClick2(operandButton) { if (_classPrivateFieldGet(this, _currentExpression).length === 0) { // in case user starts his calculation directly with an operand - _classPrivateFieldSet(this, _currentExpression, "0"); + _classPrivateFieldSet(this, _currentExpression, '0'); } if (_classPrivateMethodGet(this, _endsWithOperand, _endsWithOperand2).call(this, _classPrivateFieldGet(this, _currentExpression))) { @@ -67870,7 +67881,7 @@ function _onOperandClick2(operandButton) { _classPrivateMethodGet(this, _addActiveState, _addActiveState2).call(this, operandButton); } else { - if (_classPrivateFieldGet(this, _currentExpression).endsWith(")")) { + if (_classPrivateFieldGet(this, _currentExpression).endsWith(')')) { // clicking = multiple times in a row let latestOperandIndex = -1; @@ -67889,17 +67900,17 @@ function _onOperandClick2(operandButton) { _classPrivateFieldSet(this, _currentExpression, `(${_classPrivateFieldGet(this, _currentExpression)})`); } - _classPrivateFieldSet(this, _currentInput, ""); + _classPrivateFieldSet(this, _currentInput, ''); _classPrivateMethodGet(this, _displaySolution, _displaySolution2).call(this); } function _addActiveState2(elem) { - elem.classList.add("active"); + elem.classList.add('active'); } function _removeActiveState2(elem) { - elem.classList.remove("active"); + elem.classList.remove('active'); } function _endsWithOperand2(str) { @@ -67908,19 +67919,19 @@ function _endsWithOperand2(str) { } function _getCurrentSolution2() { - let expressionToEvaluate = _classPrivateFieldGet(this, _currentExpression) || "0"; + let expressionToEvaluate = _classPrivateFieldGet(this, _currentExpression) || '0'; if (_classPrivateMethodGet(this, _endsWithOperand, _endsWithOperand2).call(this, expressionToEvaluate)) { expressionToEvaluate = expressionToEvaluate.slice(0, -1); } - expressionToEvaluate = expressionToEvaluate.replace(/,/g, "."); + expressionToEvaluate = expressionToEvaluate.replace(/,/g, '.'); try { return evaluate(expressionToEvaluate).toString(); } catch (err) { console.error(err); - return "Error"; + return 'Error'; } } @@ -67932,7 +67943,7 @@ function _displaySolution2() { integerToDisplay = _classPrivateFieldGet(this, _currentInput); } else if (_classPrivateFieldGet(this, _currentExpression).length > 0) { - let expressionToDisplay = _classPrivateFieldGet(this, _currentExpression) || "0"; + let expressionToDisplay = _classPrivateFieldGet(this, _currentExpression) || '0'; if (!_classPrivateMethodGet(this, _endsWithOperand, _endsWithOperand2).call(this, expressionToDisplay)) { _classPrivateFieldGet(this, _operandButtons).forEach(_classPrivateMethodGet(this, _removeActiveState, _removeActiveState2)); @@ -67940,23 +67951,23 @@ function _displaySolution2() { integerToDisplay = _classPrivateMethodGet(this, _getCurrentSolution, _getCurrentSolution2).call(this); } else { - integerToDisplay = "0"; + integerToDisplay = '0'; } - integerToDisplay = integerToDisplay.replace(".", _classStaticPrivateFieldSpecGet(iOSCalculator, iOSCalculator, _CHARACTERS).COMMA); + integerToDisplay = integerToDisplay.replace('.', _classStaticPrivateFieldSpecGet(iOSCalculator, iOSCalculator, _CHARACTERS).COMMA); _classPrivateFieldGet(this, _calcSolution).textContent = integerToDisplay; } var _CHARACTERS = { writable: true, value: { - PLUS: "+", - MINUS: "-", - MULTIPLY: "*", - DIVIDE: "/", - EQUALS: "=", - NEGATIVE: "-", - COMMA: "," + PLUS: '+', + MINUS: '-', + MULTIPLY: '*', + DIVIDE: '/', + EQUALS: '=', + NEGATIVE: '-', + COMMA: ',' } }; window.customElements.define('ios-calculator', iOSCalculator); diff --git a/dist/ios-calculator.min.js b/dist/ios-calculator.min.js index 1496445..65192c6 100644 --- a/dist/ios-calculator.min.js +++ b/dist/ios-calculator.min.js @@ -1,16 +1,2 @@ -!function(){var r={977:function(e,t){var a; -/** - * @license Complex.js v2.0.15 12/05/2020 - * - * Copyright (c) 2020, Robert Eisele (robert@xarg.org) - * Dual licensed under the MIT or GPL Version 2 licenses. - **/ -!function(){"use strict";function n(e){return.5*(Math.exp(e)+Math.exp(-e))}function i(e){return.5*(Math.exp(e)-Math.exp(-e))}var u=function(){throw SyntaxError("Invalid Param")};function o(e,t){var r=Math.abs(e),n=Math.abs(t);return 0===e?Math.log(n):0===t?Math.log(r):r<3e3&&n<3e3?.5*Math.log(e*e+t*t):Math.log(e/Math.cos(Math.atan2(t,e)))}function r(e,t){var r={re:0,im:0};if(null==e)r.re=r.im=0;else if(void 0!==t)r.re=e,r.im=t;else switch(typeof e){case"object":if("im"in e&&"re"in e)r.re=e.re,r.im=e.im;else if("abs"in e&&"arg"in e){if(!Number.isFinite(e.abs)&&Number.isFinite(e.arg))return c.INFINITY;r.re=e.abs*Math.cos(e.arg),r.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!Number.isFinite(e.r)&&Number.isFinite(e.phi))return c.INFINITY;r.re=e.r*Math.cos(e.phi),r.im=e.r*Math.sin(e.phi)}else 2===e.length?(r.re=e[0],r.im=e[1]):u();break;case"string":r.im=r.re=0;var n=e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),i=1,a=0;null===n&&u();for(var o=0;ospan{display:inline-flex;place-items:center;place-content:center;text-align:center;height:3rem;width:3rem;line-height:3rem}.calc .calc-buttons-container .calc-button:hover{opacity:1}.calc .calc-buttons-container .calc-button:active:after{opacity:1;transition:0s}.calc .calc-buttons-container .calc-button:after{content:"";background:rgba(255,255,255,.25);display:block;position:absolute;inset:0;opacity:0;transition:all .8s}.calc .calc-buttons-container .calc-button.calc-button-double{grid-column:span 2;border-radius:5rem;justify-content:start}.calc .calc-buttons-container .calc-button.calc-button-digit{background-color:#444}.calc .calc-buttons-container .calc-button.calc-button-operand{background-color:orange}.calc .calc-buttons-container .calc-button.calc-button-operand.active{opacity:1;background-color:#fff;color:orange}.calc .calc-buttons-container .calc-button.calc-button-func{background-color:#afafaf;color:#000}',""]),t.Z=r},645:function(e){"use strict";e.exports=function(n){var l=[];return l.toString=function(){return this.map(function(e){var t="",r=void 0!==e[5];return e[4]&&(t+="@supports (".concat(e[4],") {")),e[2]&&(t+="@media ".concat(e[2]," {")),r&&(t+="@layer".concat(0r-1&&(void 0===a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/r|0,a[n]%=r)}return a.reverse()}o.absoluteValue=o.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),q(e)},o.ceil=function(){return q(new this.constructor(this),this.e+1,2)},o.clampedTo=o.clamp=function(e,t){var r=this.constructor;if(e=new r(e),t=new r(t),!e.s||!t.s)return new r(NaN);if(e.gt(t))throw Error(v+t);return this.cmp(e)<0?e:0e.e^o<0?1:-1;for(t=0,r=(s=i.length)<(n=a.length)?s:n;ta[t]^o<0?1:-1;return s===n?0:nthis.d.length-2},o.isNaN=function(){return!this.s},o.isNegative=o.isNeg=function(){return this.s<0},o.isPositive=o.isPos=function(){return 0t&&(t=this.e+1)):t=NaN,t},o.round=function(){var e=this.constructor;return q(new e(this),this.e+1,e.rounding)},o.sine=o.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+B,n.rounding=1,r=function(e,t){var r,n=t.d.length;if(n<3)return t.isZero()?t:Y(e,2,t,t);r=16<(r=1.4*Math.sqrt(n))?16:0|r,t=t.times(1/J(5,r)),t=Y(e,2,t,t);for(var i,a=new e(5),o=new e(16),s=new e(20);r--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}(n,X(n,r)),n.precision=e,n.rounding=t,q(2=e.d.length-1&&(r=c<0?-c:c)<=9007199254740991)return i=H(u,s,r,n),e.s<0?new u(1).div(i):q(i,n,a);if((o=s.s)<0){if(tu.maxE+1||t=n.toExpPos):(h(e,1,y),void 0===t?t=n.rounding:h(t,0,8),R(r=q(new n(r),e,t),e<=r.e||r.e<=n.toExpNeg,e));return r.isNeg()&&!r.isZero()?"-"+t:t},o.toSignificantDigits=o.toSD=function(e,t){var r=this.constructor;return void 0===e?(e=r.precision,t=r.rounding):(h(e,1,y),void 0===t?t=r.rounding:h(t,0,8)),q(new r(this),e,t)},o.toString=function(){var e=this,t=e.constructor,t=R(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+t:t},o.truncated=o.trunc=function(){return q(new this.constructor(this),this.e+1,1)},o.valueOf=o.toJSON=function(){var e=this,t=e.constructor,t=R(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+t:t};var w=function(l,f,p,m,h,e){var d,y,t,r,g,v,x,b,w,n,i,N,a,M,E,S,A,o,O,C=l.constructor,s=l.s==f.s?1:-1,u=l.d,c=f.d;if(!(u&&u[0]&&c&&c[0]))return new C(l.s&&f.s&&(u?!c||u[0]!=c[0]:c)?u&&0==u[0]||!c?0*s:s/0:NaN);for(y=e?(g=1,l.e-f.e):(e=T,_(l.e/(g=B))-_(f.e/g)),o=c.length,S=u.length,w=(s=new C(s)).d=[],t=0;c[t]==(u[t]||0);t++);if(c[t]>(u[t]||0)&&y--,null==p?(a=p=C.precision,m=C.rounding):a=h?p+(l.e-f.e)+1:p,a<0)w.push(1),v=!0;else{if(a=a/g+2|0,t=0,1==o){for(c=c[r=0],a++;(t=e/2&&++A;r=0,(d=k(c,n,o,i))<0?(N=n[0],1<(r=(N=o!=i?N*e+(n[1]||0):N)/A|0)?1==(d=k(x=z(c,r=e<=r?e-1:r,e),n,b=x.length,i=n.length))&&(r--,D(x,ot[i]?1:-1;break}return a}function D(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]p.maxE?(e.d=null,e.e=NaN):e.ee.constructor.maxE?(e.d=null,e.e=NaN):e.ei-1;)c[r]=0,r||(++a,c.unshift(1));for(s=c.length;!c[s-1];--s);for(o=0,u="";os)for(a-=s;a--;)u+="0";else at&&(e.length=t,1)}function K(e){return new this(e).abs()}function ee(e){return new this(e).acos()}function te(e){return new this(e).acosh()}function re(e,t){return new this(e).plus(t)}function ne(e){return new this(e).asin()}function ie(e){return new this(e).asinh()}function ae(e){return new this(e).atan()}function oe(e){return new this(e).atanh()}function se(e,t){e=new this(e),t=new this(t);var r,n=this.precision,i=this.rounding,a=n+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(r=t.s<0?P(this,n,i):new this(0)).s=e.s:!e.d||t.isZero()?(r=P(this,a,1).times(.5)).s=e.s:r=t.s<0?(this.precision=a,this.rounding=1,r=this.atan(w(e,t,a,1)),t=P(this,a,1),this.precision=n,this.rounding=i,e.s<0?r.minus(t):r.plus(t)):this.atan(w(e,t,a,1)):(r=P(this,a,1).times(0a.maxE?(i.e=NaN,i.d=null):e.e=e.length&&n.slice(0,e.length)===e&&(i+=a[o[t]],n=n.slice(e.length,n.length),r=!0)}),r||(i+=n.slice(0,1),n=n.slice(1,n.length))}();return i}},628:function(n,i){var a; -/** - * @license Fraction.js v4.1.3 23/05/2021 - * 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. - **/ -!function(){"use strict";var d={s:1,n:0,d:1};function e(t){function e(){var e=Error.apply(this,arguments);e.name=this.name=t,this.stack=e.stack,this.message=e.message}function r(){}return r.prototype=Error.prototype,e.prototype=new r,e}var y=c.DivisionByZero=e("DivisionByZero"),t=c.InvalidParameter=e("InvalidParameter");function g(e,t){return isNaN(e=parseInt(e,10))&&v(),e*t}function v(){throw new t}function s(e){for(var t={},r=e,n=2,i=4;i<=r;){for(;r%n==0;)r/=n,t[n]=(t[n]||0)+1;i+=1+2*n++}return r!==e?1>=1)1&t&&(n=n*e%r);return n}(10,r,t),a=0;a<300;a++){if(n===i)return a;n=10*n%t,i=10*i%t}return 0}function r(e,t){if(!e)return t;if(!t)return e;for(;;){if(!(e%=t))return t;if(!(t%=e))return e}}function c(e,t){if(!(this instanceof c))return new c(e,t);u(e,t),e=r(d.d,d.n),this.s=d.s,this.n=d.n/e,this.d=d.d/e}c.prototype={s:1,n:0,d:1,abs:function(){return new c(this.n,this.d)},neg:function(){return new c(-this.s*this.n,this.d)},add:function(e,t){return u(e,t),new c(this.s*this.n*d.d+d.s*this.d*d.n,this.d*d.d)},sub:function(e,t){return u(e,t),new c(this.s*this.n*d.d-d.s*this.d*d.n,this.d*d.d)},mul:function(e,t){return u(e,t),new c(this.s*d.s*this.n*d.n,this.d*d.d)},div:function(e,t){return u(e,t),new c(this.s*d.s*this.n*d.d,this.d*d.n)},clone:function(){return new c(this)},mod:function(e,t){return isNaN(this.n)||isNaN(this.d)?new c(NaN):void 0===e?new c(this.s*this.n%this.d,1):(u(e,t),0===d.n&&0===this.d&&c(0,0),new c(this.s*(d.d*this.n)%(d.n*this.d),d.d*this.d))},gcd:function(e,t){return u(e,t),new c(r(d.n,this.n)*r(d.d,this.d),d.d*this.d)},lcm:function(e,t){return u(e,t),0===d.n&&0===this.n?new c:new c(d.n*this.n,r(d.n,this.n)*r(d.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):new c(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):new c(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):new c(Math.round(e*this.s*this.n/this.d),e)},inverse:function(){return new c(this.s*this.d,this.n)},pow:function(e,t){if(u(e,t),1===d.d)return d.s<0?new c(Math.pow(this.s*this.d,d.n),Math.pow(this.n,d.n)):new c(Math.pow(this.s*this.n,d.n),Math.pow(this.d,d.n));if(this.s<0)return null;var r,n=s(this.n),i=s(this.d),a=1,o=1;for(r in n)if("1"!==r){if("0"===r){a=0;break}if(n[r]*=d.n,n[r]%d.d!=0)return null;n[r]/=d.d,a*=Math.pow(r,n[r])}for(r in i)if("1"!==r){if(i[r]*=d.n,i[r]%d.d!=0)return null;i[r]/=d.d,o*=Math.pow(r,i[r])}return d.s<0?new c(o,a):new c(a,o)},equals:function(e,t){return u(e,t),this.s*this.n*d.d==d.s*d.n*this.d},compare:function(e,t){u(e,t);e=this.s*this.n*d.d-d.s*d.n*this.d;return(0>>0))*n)>>>0,n+=4294967296*(r-=n)}return 2.3283064365386963e-10*(n>>>0)});t.next=function(){var e=2091639*t.s0+2.3283064365386963e-10*t.c;return t.s0=t.s1,t.s1=t.s2,t.s2=e-(t.c=0|e)},t.c=1,t.s0=r(" "),t.s1=r(" "),t.s2=r(" "),t.s0-=r(e),t.s0<0&&(t.s0+=1),t.s1-=r(e),t.s1<0&&(t.s1+=1),t.s2-=r(e),t.s2<0&&(t.s2+=1)}function a(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function t(e,t){var r=new i(e),e=t&&t.state,n=r.next;return n.int32=function(){return 4294967296*r.next()|0},n.double=function(){return n()+11102230246251565e-32*(2097152*n()|0)},n.quick=n,e&&("object"==typeof e&&a(e,r),n.state=function(){return a(r,{})}),n}e&&e.exports?e.exports=t:n.amdD&&n.amdO?void 0===(o=function(){return t}.call(r,n,r,e))||(e.exports=o):this.alea=t})(e=n.nmd(e),n.amdD)},49:function(e,r,n){var o;(function(e){function i(e){var i=this,t="";i.next=function(){var e=(e=i.b)<<25^e>>>7^(t=i.c),t=t-(r=i.d)|0,r=r<<24^r>>>8^(n=i.a),n=n-e|0;return i.b=e=e<<20^e>>>12^t,i.c=t=t-r|0,i.d=r<<16^t>>>16^n,i.a=n-e|0},i.a=0,i.b=0,i.c=-1640531527,i.d=1367130551,e===Math.floor(e)?(i.a=e/4294967296|0,i.b=0|e):t+=e;for(var r=0;r>>0)/4294967296}var n=new i(e),e=t&&t.state;return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,e&&("object"==typeof e&&a(e,n),r.state=function(){return a(n,{})}),r}e&&e.exports?e.exports=t:n.amdD&&n.amdO?void 0===(o=function(){return t}.call(r,n,r,e))||(e.exports=o):this.tychei=t})(e=n.nmd(e),n.amdD)},652:function(e,r,n){var o;(function(e){function i(e){var t=this,r="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:r+=e;for(var n=0;n>>0)/4294967296}var n=new i(e),e=t&&t.state;return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,e&&("object"==typeof e&&a(e,n),r.state=function(){return a(n,{})}),r}e&&e.exports?e.exports=t:n.amdD&&n.amdO?void 0===(o=function(){return t}.call(r,n,r,e))||(e.exports=o):this.xor128=t})(e=n.nmd(e),n.amdD)},618:function(e,r,n){var o;(function(e){function i(l){var a=this;a.next=function(){var e,t,r=a.w,n=a.X,i=a.i;return a.w=r=r+1640531527|0,t=n[i+34&127],e=n[i=i+1&127],t=n[i]=(t^=t<<13)^t>>>15^((e^=e<<17)^e>>>12),a.i=i,t+(r^r>>>16)|0};var e,t,r,n,i,o=a,s=l,u=[],c=128;for(s===(0|s)?(t=s,s=null):(s+="\0",t=0,c=Math.max(c,s.length)),r=0,n=-32;n>>15)^t<<4)^t>>>13,0<=n&&(r=0==(e=u[127&n]^=t+(i=i+1640531527|0))?r+1:0);for(128<=r&&(u[127&(s&&s.length||0)]=-1),r=127,n=512;0>>15,e=(e^=e<<17)^e>>>12,u[r]=t^e;o.w=i,o.X=u,o.i=r}function a(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function t(e,t){function r(){return(n.next()>>>0)/4294967296}var n=new i(e=null==e?+new Date:e),e=t&&t.state;return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,e&&(e.X&&a(e,n),r.state=function(){return a(n,{})}),r}e&&e.exports?e.exports=t:n.amdD&&n.amdO?void 0===(o=function(){return t}.call(r,n,r,e))||(e.exports=o):this.xor4096=t})(e=n.nmd(e),n.amdD)},30:function(e,r,n){var o;(function(e){function i(e){var i=this;i.next=function(){var e=i.x,t=i.i,r=e[t],n=(r^=r>>>7)^r<<24;return n=(n^=(r=e[t+1&7])^r>>>10)^((r=e[t+3&7])^r>>>3)^((r=e[t+4&7])^r<<7),r=e[t+7&7],e[t]=n^=(r^=r<<13)^r<<9,i.i=t+1&7,n};var t,r=i,n=e,a=[];if(n===(0|n))a[0]=n;else for(n=""+n,t=0;t>>0)/4294967296}var n=new i(e=null==e?+new Date:e),e=t&&t.state;return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,e&&(e.x&&a(e,n),r.state=function(){return a(n,{})}),r}e&&e.exports?e.exports=t:n.amdD&&n.amdO?void 0===(o=function(){return t}.call(r,n,r,e))||(e.exports=o):this.xorshift7=t})(e=n.nmd(e),n.amdD)},801:function(e,r,n){var o;(function(e){function i(e){var t=this,r="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,e===((t.v=0)|e)?t.x=e:r+=e;for(var n=0;n>>4),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function t(e,t){function r(){return(n.next()>>>0)/4294967296}var n=new i(e),e=t&&t.state;return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,e&&("object"==typeof e&&a(e,n),r.state=function(){return a(n,{})}),r}e&&e.exports?e.exports=t:n.amdD&&n.amdO?void 0===(o=function(){return t}.call(r,n,r,e))||(e.exports=o):this.xorwow=t})(e=n.nmd(e),n.amdD)},971:function(e,r,t){var o,s="undefined"!=typeof self?self:this,u=[],c=Math,l=256,h=c.pow(l,6),d=c.pow(2,52),y=2*d,f=l-1;function n(e,t,r){function n(){for(var e=a.g(6),t=h,r=0;e>>=1;return(e+r)/t}var i=[],e=p(function e(t,r){var n,i=[],a=typeof t;if(r&&"object"==a)for(n in t)try{i.push(e(t[n],r-1))}catch(e){}return i.length?i:"string"==a?t:t+"\0"}((t=1==t?{entropy:!0}:t||{}).entropy?[e,m(u)]:null==e?function(){try{return o&&(t=o.randomBytes)?t=t(l):(t=new Uint8Array(l),(s.crypto||s.msCrypto).getRandomValues(t)),m(t)}catch(e){var t=s.navigator,t=t&&t.plugins;return[+new Date,s,t,s.screen,m(u)]}}():e,3),i),a=new g(i);return n.int32=function(){return 0|a.g(4)},n.quick=function(){return a.g(4)/4294967296},n.double=n,p(m(a.S),u),(t.pass||r||function(e,t,r,n){return n&&(n.S&&v(n,a),e.state=function(){return v(a,{})}),r?(c.random=e,t):e})(n,e,"global"in t?t.global:this==c,t.state)}function g(e){var t,r=e.length,o=this,n=0,i=o.i=o.j=0,a=o.S=[];for(r||(e=[r++]);n3?e.slice(3):"any";var i=n.split("|").map(M).filter(E).filter(N);var a=b(r,i);var o=i.map(function(e){var t=u(e);return{name:e,typeIndex:c(t),test:t.test,conversion:null,conversionIndex:-1}});var s=a.map(function(e){var t=u(e.from);return{name:e.from,typeIndex:c(t),test:t.test,conversion:e,conversionIndex:r.indexOf(e)}});return{types:o.concat(s),restParam:t}}function V(e,t,i){var r=[];if(e.trim()!=="")r=e.split(",").map(M).map(function(e,t,r){var n=f(e,i);if(n.restParam&&t!==r.length-1)throw new SyntaxError('Unexpected rest parameter "'+e+'": '+"only allowed for the last parameter");return n});if(r.some(S))return null;return{params:r,fn:t}}function H(e){var t=O(e);return t?t.restParam:false}function s(e){return e.types.some(function(e){return e.conversion!=null})}function $(e){if(!e||e.types.length===0)return z;else if(e.types.length===1)return u(e.types[0].name).test;else if(e.types.length===2){var r=u(e.types[0].name).test;var n=u(e.types[1].name).test;return function e(t){return r(t)||n(t)}}else{var i=e.types.map(function(e){return u(e.name).test});return function e(t){for(var r=0;r=a+1}}else if(e.length===0)return function e(t){return t.length===0};else if(e.length===1){r=$(e[0]);return function e(t){return r(t[0])&&t.length===1}}else if(e.length===2){r=$(e[0]);i=$(e[1]);return function e(t){return r(t[0])&&i(t[1])&&t.length===2}}else{n=e.map($);return function e(t){for(var r=0;r0){var s=p(r[a]);e=new TypeError("Unexpected type of argument in function "+n+" (expected: "+t.join(" or ")+", actual: "+s+", index: "+a+")");e.data={category:"wrongType",fn:n,index:a,actual:s,expected:t};return e}}else i=o}var u=i.map(function(e){return H(e.params)?Infinity:e.params.length});if(r.lengthc){e=new TypeError("Too many arguments in function "+n+" (expected: "+c+", actual: "+r.length+")");e.data={category:"tooManyArgs",fn:n,index:r.length,expectedLength:c};return e}e=new TypeError('Arguments of type "'+r.join(", ")+'" do not match any of the defined signatures of function '+n+".");e.data={category:"mismatch",actual:r.map(p)};return e}function g(e){var t=999;for(var r=0;r=o:c?o>=s:o===s}function i(l,t){if(Object.keys(t).length===0)throw new SyntaxError("No signatures provided");var r=[];Object.keys(t).map(function(e){return V(e,t[e],j.conversions)}).filter(ee).forEach(function(t){var e=G(r,function(e){return K(e,t)});if(e)throw new TypeError('Conflicting signatures "'+L(e.params)+'" and "'+L(t.params)+'".');r.push(t)});var n=te(r,function(t){var e=t?Q(t.params,false):[];return e.map(function(e){return{params:e,fn:t.fn}})}).filter(ee);n.sort(Y);var e=n[0]&&n[0].params.length<=2&&!H(n[0].params);var i=n[1]&&n[1].params.length<=2&&!H(n[1].params);var a=n[2]&&n[2].params.length<=2&&!H(n[2].params);var o=n[3]&&n[3].params.length<=2&&!H(n[3].params);var s=n[4]&&n[4].params.length<=2&&!H(n[4].params);var u=n[5]&&n[5].params.length<=2&&!H(n[5].params);var f=e&&i&&a&&o&&s&&u;var p=n.map(function(e){return Z(e.params)});var m=e?$(n[0].params[0]):re;var h=i?$(n[1].params[0]):re;var d=a?$(n[2].params[0]):re;var y=o?$(n[3].params[0]):re;var g=s?$(n[4].params[0]):re;var v=u?$(n[5].params[0]):re;var x=e?$(n[0].params[1]):re;var b=i?$(n[1].params[1]):re;var w=a?$(n[2].params[1]):re;var N=o?$(n[3].params[1]):re;var M=s?$(n[4].params[1]):re;var E=u?$(n[5].params[1]):re;var c=n.map(function(e){return J(e.params,e.fn)});var S=e?c[0]:ne;var A=i?c[1]:ne;var O=a?c[2]:ne;var C=o?c[3]:ne;var _=s?c[4]:ne;var T=u?c[5]:ne;var B=e?n[0].params.length:-1;var q=i?n[1].params.length:-1;var I=a?n[2].params.length:-1;var z=o?n[3].params.length:-1;var k=s?n[4].params.length:-1;var D=u?n[5].params.length:-1;var R=f?6:0;var U=n.length;var F=function e(){"use strict";for(var t=R;ts.length||o-u+1>s.length;)s.push(0);else for(var f=Math.abs(o-u)-(s.length-1),p=0;p=r?re(e,t):(n=i.coefficients,r=i.exponent,n=(n=n.lengtht&&5<=n.splice(t,n.length-t)[0]){var i=t-1;for(n[i]++;10===n[i];)n.pop(),0===i&&(n.unshift(0),r.exponent++,i++),n[--i]++}return r}function pe(e){for(var t=[],r=0;r'"'+e+'": '+Ee(t[e],r)).join(", ")+"}":String(t);var e}function Se(e){for(var t=String(e),r="",n=0;n/g,">")}function Oe(e,t){if(!B(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+W(e)+", index: 0)");if(!B(t))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+W(t)+", index: 1)");return e===t?0:t{return!(e&&"?"===e[0])}).every(e=>void 0!==i[e]))throw n=n.filter(e=>void 0===i[e]),new Error('Cannot create function "'.concat(r,'", ')+"some dependencies are missing: ".concat(n.map(e=>'"'.concat(e,'"')).join(", "),"."));return s(t)}return t.isFactory=!0,t.fn=a,t.dependencies=o.slice().sort(),e&&(t.meta=e),t}function Te(e){return e&&"?"===e[0]?e.slice(1):e}var u=a("Chain",["?on","math"],e=>{var{on:e,math:t}=e;function o(e){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");j(e)?this.value=e.value:this.value=e}function i(e,t){var r,n,i,a;r=o.prototype,n=function(){var e=t();if("function"==typeof e)return s(e)},a=!0,Object.defineProperty(r,e,{get:function(){return a&&(i=n(),a=!1),i},set:function(e){i=e,a=!1},configurable:!0,enumerable:!0})}function s(r){return function(){for(var e=[this.value],t=0;tt[e])}(r);var n})(t),e&&e("import",function(e,t,r){r||i(e,t)}),o},{isClass:!0}),Be=new Set(["end"]);function qe(e,t){if(De(e)&&ze(e,t))return e[t];if("function"==typeof e[t]&&ke(e,t))throw new Error('Cannot access method "'+t+'" as a property');throw new Error('No access to property "'+t+'"')}function Ie(e,t,r){if(De(e)&&ze(e,t))return e[t]=r;throw new Error('No access to property "'+t+'"')}function ze(e,t){return e&&"object"==typeof e&&(ie(Re,t)||!(t in Object.prototype)&&!(t in Function.prototype))}function ke(e,t){return null!=e&&"function"==typeof e[t]&&(!(ie(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e))&&(ie(Ue,t)||!(t in Object.prototype)&&!(t in Function.prototype)))}function De(e){return"object"==typeof e&&e&&e.constructor===Object}var Re={length:!0,name:!0},Ue={toString:!0,valueOf:!0,toLocaleString:!0};class Fe{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return qe(this.wrappedObject,e)}set(e,t){return Ie(this.wrappedObject,e,t),this}has(e){return t=this.wrappedObject,e in t;var t}}function Pe(){return new Map}function je(e){if(!e)return Pe();if(Le(e))return e;if(v(e))return new Fe(e);throw new Error("createMap can create maps from objects or Maps")}function Le(e){return!!e&&(e instanceof Map||e instanceof Fe||"function"==typeof e.set&&"function"==typeof e.get&&"function"==typeof e.keys&&"function"==typeof e.has)}function He(e){for(var t,r=arguments.length,n=new Array(1{var t=e["mathWithTransform"];function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator")}return r.prototype.evaluate=function(e){return this.compile().evaluate(e)},r.prototype.type="Node",r.prototype.isNode=!0,r.prototype.comment="",r.prototype.compile=function(){var n=this._compile(t,{}),i={},a=null;return{evaluate:function(e){var t,r=e=je(e);for(t of[...Be])if(r.has(t))throw new Error('Scope contains an illegal symbol, "'+t+'" is a reserved keyword');return n(e,i,a)}}},r.prototype._compile=function(e,t){throw new Error("Method _compile should be implemented by type "+this.type)},r.prototype.forEach=function(e){throw new Error("Cannot run forEach on a Node interface")},r.prototype.map=function(e){throw new Error("Cannot run map on a Node interface")},r.prototype._ifNode=function(e){if(!U(e))throw new TypeError("Callback function must return a Node");return e},r.prototype.traverse=function(e){e(this,null,null),function n(e,i){e.forEach(function(e,t,r){i(e,t,r),n(e,i)})}(this,e)},r.prototype.transform=function(i){return function e(t,r,n){r=i(t,r,n);return r!==t?r:t.map(e)}(this,null,null)},r.prototype.filter=function(n){var i=[];return this.traverse(function(e,t,r){n(e,t,r)&&i.push(e)}),i},r.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},r.prototype.cloneDeep=function(){return this.map(function(e){return e.cloneDeep()})},r.prototype.equals=function(e){return!!e&&_e(this,e)},r.prototype.toString=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toString(e)},r.prototype.toJSON=function(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)},r.prototype.toHTML=function(e){var t=this._getCustomString(e);return void 0!==t?t:this.toHTML(e)},r.prototype._toString=function(){throw new Error("_toString not implemented for "+this.type)},r.prototype.toTex=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toTex(e)},r.prototype._toTex=function(e){throw new Error("_toTex not implemented for "+this.type)},r.prototype._getCustomString=function(e){if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":return;case"function":return e.handler(this,e);default:throw new TypeError("Object or function expected as callback")}},r.prototype.getIdentifier=function(){return this.type},r.prototype.getContent=function(){return this},r},{isClass:!0,isNode:!0}),$e=a("ObjectNode",["Node"],e=>{e=e.Node;function n(t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=t||{},t&&("object"!=typeof t||!Object.keys(t).every(function(e){return U(t[e])})))throw new TypeError("Object containing Nodes expected")}return(n.prototype=new e).type="ObjectNode",n.prototype.isObjectNode=!0,n.prototype._compile=function(e,t){var r,a={};for(r in this.properties)if(ie(this.properties,r)){var n=Se(r),n=JSON.parse(n);if(!ze(this.properties,n))throw new Error('No access to property "'+n+'"');a[n]=this.properties[r]._compile(e,t)}return function(e,t,r){var n,i={};for(n in a)ie(a,n)&&(i[n]=a[n](e,t,r));return i}},n.prototype.forEach=function(e){for(var t in this.properties)ie(this.properties,t)&&e(this.properties[t],"properties["+Se(t)+"]",this)},n.prototype.map=function(e){var t,r={};for(t in this.properties)ie(this.properties,t)&&(r[t]=this._ifNode(e(this.properties[t],"properties["+Se(t)+"]",this)));return new n(r)},n.prototype.clone=function(){var e,t={};for(e in this.properties)ie(this.properties,e)&&(t[e]=this.properties[e]);return new n(t)},n.prototype._toString=function(e){var t,r=[];for(t in this.properties)ie(this.properties,t)&&r.push(Se(t)+": "+this.properties[t].toString(e));return"{"+r.join(", ")+"}"},n.prototype.toJSON=function(){return{mathjs:"ObjectNode",properties:this.properties}},n.fromJSON=function(e){return new n(e.properties)},n.prototype.toHTML=function(e){var t,r=[];for(t in this.properties)ie(this.properties,t)&&r.push(''+Ae(t)+':'+this.properties[t].toHTML(e));return'{'+r.join(',')+'}'},n.prototype._toTex=function(e){var t,r=[];for(t in this.properties)ie(this.properties,t)&&r.push("\\mathbf{"+t+":} & "+this.properties[t].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(r.join("\n"),"\\end{array}\\right\\}")},n},{isClass:!0,isNode:!0});function Ge(e,t,r){if(!(this instanceof Ge))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=t,this.relation=r,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=(new Error).stack}function Ve(e,t,r){if(!(this instanceof Ve))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=r),void 0!==this.min&&this.index=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}function Ze(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function We(e,t){if(0===t.length){if(Array.isArray(e))throw new Ge(e.length,0)}else!function e(t,r,n){var i=t.length;if(i!==r[n])throw new Ge(i,r[n]);if(n")}(e,t,0)}function Ye(e,t){if(!k(e)||!O(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&t<=e)throw new Ve(e,t)}function Je(e,t,r){if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");return t.forEach(function(e){if(!k(e)||!O(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Ee(t)+")")}),function e(t,r,n,i){var a;var o;var l=t.length;var s=r[n];var u=Math.min(l,s);t.length=s;if(ne*t,1)}function et(e,t){for(var r=t||Ze(e);Array.isArray(e)&&1===e.length;)e=e[0],r.shift();for(var n=r.length;1===r[n-1];)n--;return nt.test(e))}function st(e,t){return Array.prototype.join.call(e,t)}function ut(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;var t=[],r=0;t[0]={value:e[0],identifier:0};for(var n=1;n>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},vt={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(gt.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(gt.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(gt.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(gt.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(gt.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(gt.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(gt.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(gt.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(gt.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(gt.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(gt.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(gt.bitAnd,"${args[1]}\\right)")},bitNot:{1:gt.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(gt.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(gt.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(gt.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(gt.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(gt.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(gt.and,"${args[1]}\\right)")},not:{1:gt.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(gt.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(gt.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(gt.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}"},sqrtm:{1:"{${args[0]}}".concat(gt.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(gt.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(gt.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(gt.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(gt.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(gt.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(gt.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(gt.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(gt.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(gt.to,"${args[1]}\\right)")},numeric:function(e,t){return e.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(yt.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)"}},xt={deg:"^\\circ"};function bt(e){return dt(e,{preserveFormatting:!0})}function wt(e,t){return(t=void 0!==t&&t)?ie(xt,e)?xt[e]:"\\mathrm{"+bt(e)+"}":ie(yt,e)?yt[e]:bt(e)}var Nt=a("OperatorNode",["Node"],e=>{e=e.Node;function a(e,t,r,n,i){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('string expected for parameter "op"');if("string"!=typeof t)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(r)||!r.every(U))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=!0===n,this.isPercentage=!0===i,this.op=e,this.fn=t,this.args=r||[]}function f(n,i,l,e,f){var r,a=pt(n,i),p=mt(n,i);if("all"===i||2('+e+')'),"right"===t?''+Ae(this.op)+""+e:e+''+Ae(this.op)+""):2===i.length?(t=i[0].toHTML(r),e=i[1].toHTML(r),a[0]&&(t='('+t+')'),a[1]&&(e='('+e+')'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===n?t+''+e:t+''+Ae(this.op)+""+e):(t=i.map(function(e,t){return e=e.toHTML(r),e=a[t]?'('+e+')':e}),2'):t.join(''+Ae(this.op)+""):''+Ae(this.fn)+'('+t.join(',')+')')},a.prototype._toTex=function(r){var e=r&&r.parenthesis?r.parenthesis:"keep",t=r&&r.implicit?r.implicit:"hide",n=this.args,i=f(this,e,t,n,!0),a=void 0===(a=gt[this.fn])?this.op:a;if(1===n.length)return o=mt(this,e),s=n[0].toTex(r),i[0]&&(s="\\left(".concat(s,"\\right)")),"right"===o?a+s:s+a;if(2!==n.length)return 2{e=e.Node;function t(e){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(!U(e))throw new TypeError('Node expected for parameter "content"');this.content=e}return(t.prototype=new e).type="ParenthesisNode",t.prototype.isParenthesisNode=!0,t.prototype._compile=function(e,t){return this.content._compile(e,t)},t.prototype.getContent=function(){return this.content.getContent()},t.prototype.forEach=function(e){e(this.content,"content",this)},t.prototype.map=function(e){return new t(e(this.content,"content",this))},t.prototype.clone=function(){return new t(this.content)},t.prototype._toString=function(e){return!e||!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)},t.prototype.toJSON=function(){return{mathjs:"ParenthesisNode",content:this.content}},t.fromJSON=function(e){return new t(e.content)},t.prototype.toHTML=function(e){return!e||!e.parenthesis||e&&"keep"===e.parenthesis?'('+this.content.toHTML(e)+')':this.content.toHTML(e)},t.prototype._toTex=function(e){return!e||!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)},t},{isClass:!0,isNode:!0}),Et=a("RelationalNode",["Node"],e=>{e=e.Node;function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(t))throw new TypeError("Parameter params must be an array");if(e.length!==t.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=t}return(n.prototype=new e).type="RelationalNode",n.prototype.isRelationalNode=!0,n.prototype._compile=function(o,t){var s=this,u=this.params.map(e=>e._compile(o,t));return function(e,t,r){for(var n=u[0](e,t,r),i=0;ir(e,"params["+t+"]",this),this)},n.prototype.map=function(r){return new n(this.conditionals.slice(),this.params.map((e,t)=>this._ifNode(r(e,"params["+t+"]",this)),this))},n.prototype.clone=function(){return new n(this.conditionals,this.params)},n.prototype._toString=function(n){for(var i=n&&n.parenthesis?n.parenthesis:"keep",a=pt(this,i),e=this.params.map(function(e,t){var r=pt(e,i);return"all"===i||null!==r&&r<=a?"("+e.toString(n)+")":e.toString(n)}),t={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},r=e[0],o=0;o('+e.toHTML(n)+')':e.toHTML(n)}),t={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},r=e[0],o=0;o'+Ae(t[this.conditionals[o]])+""+e[o+1];return r},n.prototype._toTex=function(n){for(var i=n&&n.parenthesis?n.parenthesis:"keep",a=pt(this,i),e=this.params.map(function(e,t){var r=pt(e,i);return"all"===i||null!==r&&r<=a?"\\left("+e.toTex(n)+"\right)":e.toTex(n)}),t=e[0],r=0;r{e=e.Node;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=e||[],!Array.isArray(this.items)||!this.items.every(U))throw new TypeError("Array containing Nodes expected")}return(n.prototype=new e).type="ArrayNode",n.prototype.isArrayNode=!0,n.prototype._compile=function(t,r){var e,i=nt(this.items,function(e){return e._compile(t,r)});return"Array"!==t.config.matrix?(e=t.matrix,function(t,r,n){return e(nt(i,function(e){return e(t,r,n)}))}):function(t,r,n){return nt(i,function(e){return e(t,r,n)})}},n.prototype.forEach=function(e){for(var t=0;t['+this.items.map(function(e){return e.toHTML(t)}).join(',')+']'},n.prototype._toTex=function(o){return function t(e,r){var n=e.some(T)&&!e.every(T),i=r||n,a=i?"&":"\\\\",e=e.map(function(e){return e.items?t(e.items,!r):e.toTex(o)}).join(a);return n||!i||i&&!r?"\\begin{bmatrix}"+e+"\\end{bmatrix}":e}(this.items,!1)},n},{isClass:!0,isNode:!0}),At=a("BlockNode",["ResultSet","Node"],e=>{var{ResultSet:o,Node:e}=e;function a(e){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map(function(e){var t=e&&e.node,e=!e||void 0===e.visible||e.visible;if(!U(t))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof e)throw new TypeError('Property "visible" must be a boolean');return{node:t,visible:e}})}return(a.prototype=new e).type="BlockNode",a.prototype.isBlockNode=!0,a.prototype._compile=function(t,r){var e=nt(this.blocks,function(e){return{evaluate:e.node._compile(t,r),visible:e.visible}});return function(r,n,i){var a=[];return it(e,function(e){var t=e.evaluate(r,n,i);e.visible&&a.push(t)}),new o(a)}},a.prototype.forEach=function(e){for(var t=0;t;')}).join('
')},a.prototype._toTex=function(t){return this.blocks.map(function(e){return e.node.toTex(t)+(e.visible?"":";")}).join("\\;\\;\n")},a},{isClass:!0,isNode:!0}),Ot=a("ConditionalNode",["Node"],e=>{e=e.Node;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!U(e))throw new TypeError("Parameter condition must be a Node");if(!U(t))throw new TypeError("Parameter trueExpr must be a Node");if(!U(r))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=t,this.falseExpr=r}return(n.prototype=new e).type="ConditionalNode",n.prototype.isConditionalNode=!0,n.prototype._compile=function(e,t){var n=this.condition._compile(e,t),i=this.trueExpr._compile(e,t),a=this.falseExpr._compile(e,t);return function(e,t,r){return(function(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return!!e;if(e){if(D(e))return!e.isZero();if(V(e))return!(!e.re&&!e.im);if(Z(e))return!!e.value}if(null!=e)throw new TypeError('Unsupported type of condition "'+W(e)+'"');return!1}(n(e,t,r))?i:a)(e,t,r)}},n.prototype.forEach=function(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)},n.prototype.map=function(e){return new n(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))},n.prototype.clone=function(){return new n(this.condition,this.trueExpr,this.falseExpr)},n.prototype._toString=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=pt(this,t),n=this.condition.toString(e),i=pt(this.condition,t),i=(("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n="("+n+")"),this.trueExpr.toString(e)),a=pt(this.trueExpr,t),a=(("all"===t||"OperatorNode"===this.trueExpr.type||null!==a&&a<=r)&&(i="("+i+")"),this.falseExpr.toString(e)),e=pt(this.falseExpr,t);return n+" ? "+i+" : "+(a="all"===t||"OperatorNode"===this.falseExpr.type||null!==e&&e<=r?"("+a+")":a)},n.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},n.fromJSON=function(e){return new n(e.condition,e.trueExpr,e.falseExpr)},n.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=pt(this,t),n=this.condition.toHTML(e),i=pt(this.condition,t),i=(("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n='('+n+')'),this.trueExpr.toHTML(e)),a=pt(this.trueExpr,t),a=(("all"===t||"OperatorNode"===this.trueExpr.type||null!==a&&a<=r)&&(i='('+i+')'),this.falseExpr.toHTML(e)),e=pt(this.falseExpr,t);return n+'?'+i+':'+(a="all"===t||"OperatorNode"===this.falseExpr.type||null!==e&&e<=r?'('+a+')':a)},n.prototype._toTex=function(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"},n},{isClass:!0,isNode:!0}),Ct=a("ConstantNode",["Node"],e=>{e=e.Node;function t(e){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");this.value=e}return(t.prototype=new e).type="ConstantNode",t.prototype.isConstantNode=!0,t.prototype._compile=function(e,t){var r=this.value;return function(){return r}},t.prototype.forEach=function(e){},t.prototype.map=function(e){return this.clone()},t.prototype.clone=function(){return new t(this.value)},t.prototype._toString=function(e){return Ee(this.value,e)},t.prototype.toHTML=function(e){var t=this._toString(e);switch(W(this.value)){case"number":case"BigNumber":case"Fraction":return''+t+"";case"string":return''+t+"";case"boolean":return''+t+"";case"null":return''+t+"";case"undefined":return''+t+"";default:return''+t+""}},t.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},t.fromJSON=function(e){return new t(e.value)},t.prototype._toTex=function(e){var t=this._toString(e);switch(W(this.value)){case"string":return"\\mathtt{"+bt(t)+"}";case"number":case"BigNumber":if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var r=t.toLowerCase().indexOf("e");return-1!==r?t.substring(0,r)+"\\cdot10^{"+t.substring(r+1)+"}":t;case"Fraction":return this.value.toLatex();default:return t}},t},{isClass:!0,isNode:!0}),_t=a("RangeNode",["Node"],e=>{e=e.Node;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!U(e))throw new TypeError("Node expected");if(!U(t))throw new TypeError("Node expected");if(r&&!U(r))throw new TypeError("Node expected");if(3('+r+')':r,this.step&&(n=this.step.toHTML(e),r+=':'+(n=t.step?'('+n+')':n)),this.end.toHTML(e));return r+=':'+(n=t.end?'('+n+')':n)},n.prototype._toTex=function(e){var t=i(this,e&&e.parenthesis?e.parenthesis:"keep"),r=this.start.toTex(e),n=(t.start&&(r="\\left(".concat(r,"\\right)")),this.step&&(n=this.step.toTex(e),r+=":"+(n=t.step?"\\left(".concat(n,"\\right)"):n)),this.end.toTex(e));return r+=":"+(n=t.end?"\\left(".concat(n,"\\right)"):n)},n},{isClass:!0,isNode:!0}),Tt=a("reviver",["classes"],e=>{var n=e["classes"];return function(e,t){var r=n[t&&t.mathjs];return r&&"function"==typeof r.fromJSON?r.fromJSON(t):t}}),Bt=a("chain",["typed","Chain"],e=>{var{typed:e,Chain:t}=e;return e("chain",{"":function(){return new t},any:function(e){return new t(e)}})}),qt=a("FunctionAssignmentNode",["typed","Node"],e=>{var{typed:l,Node:e}=e;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(t))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!U(r))throw new TypeError('Node expected for parameter "expr"');if(Be.has(e))throw new Error('Illegal function name, "'+e+'" is a reserved keyword');this.name=e,this.params=t.map(function(e){return e&&e.name||e}),this.types=t.map(function(e){return e&&e.type||"any"}),this.expr=r}function i(e,t){var r=pt(e,t),e=pt(e.expr,t);return"all"===t||null!==e&&e<=r}return(n.prototype=new e).type="FunctionAssignmentNode",n.prototype.isFunctionAssignmentNode=!0,n.prototype._compile=function(e,t){var r=Object.create(t),a=(it(this.params,function(e){r[e]=!0}),this.expr._compile(e,r)),o=this.name,s=this.params,u=st(this.types,","),c=o+"("+st(this.params,", ")+")";return function(r,n,i){var e={},e=(e[u]=function(){for(var e=Object.create(n),t=0;t'+Ae(this.params[n])+"");e=this.expr.toHTML(e);return i(this,t)&&(e='('+e+')'),''+Ae(this.name)+'('+r.join(',')+')='+e},n.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",e=this.expr.toTex(e);return i(this,t)&&(e="\\left(".concat(e,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(wt).join(",")+"\\right):="+e},n},{isClass:!0,isNode:!0});function It(e){return e&&e.isIndexError?new Ve(e.index+1,e.min+1,void 0!==e.max?e.max+1:void 0):e}function zt(e){var r=e["subset"];return function(e,t){try{if(Array.isArray(e))return r(e,t);if(e&&"function"==typeof e.subset)return e.subset(t);if("string"==typeof e)return r(e,t);if("object"!=typeof e)throw new TypeError("Cannot apply index: unsupported type of object");if(!t.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return qe(e,t.getObjectProperty())}catch(e){throw It(e)}}}var kt=a("AccessorNode",["subset","Node"],e=>{var{subset:e,Node:t}=e,o=zt({subset:e});function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!U(e))throw new TypeError('Node expected for parameter "object"');if(!z(t))throw new TypeError('IndexNode expected for parameter "index"');this.object=e||null,this.index=t,Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function n(e){return!(se(e)||T(e)||ue(e)||ce(e)||F(e)||P(e)||fe(e))}return(r.prototype=new t).type="AccessorNode",r.prototype.isAccessorNode=!0,r.prototype._compile=function(e,t){var n,i=this.object._compile(e,t),a=this.index._compile(e,t);return this.index.isObjectProperty()?(n=this.index.getObjectProperty(),function(e,t,r){return qe(i(e,t,r),n)}):function(e,t,r){r=i(e,t,r),e=a(e,t,r);return o(r,e)}},r.prototype.forEach=function(e){e(this.object,"object",this),e(this.index,"index",this)},r.prototype.map=function(e){return new r(this._ifNode(e(this.object,"object",this)),this._ifNode(e(this.index,"index",this)))},r.prototype.clone=function(){return new r(this.object,this.index)},r.prototype._toString=function(e){var t=this.object.toString(e);return(t=n(this.object)?"("+t+")":t)+this.index.toString(e)},r.prototype.toHTML=function(e){var t=this.object.toHTML(e);return(t=n(this.object)?'('+t+')':t)+this.index.toHTML(e)},r.prototype._toTex=function(e){var t=this.object.toTex(e);return(t=n(this.object)?"\\left(' + object + '\\right)":t)+this.index.toTex(e)},r.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},r.fromJSON=function(e){return new r(e.object,e.index)},r},{isClass:!0,isNode:!0});var Dt=a("AssignmentNode",["subset","?matrix","Node"],e=>{var{subset:e,matrix:t,Node:r}=e,p=zt({subset:e}),m=function(e){var{subset:n,matrix:i}=e;return function(e,t,r){try{if(Array.isArray(e))return i(e).subset(t,r).valueOf();if(e&&"function"==typeof e.subset)return e.subset(t,r);if("string"==typeof e)return n(e,t,r);if("object"!=typeof e)throw new TypeError("Cannot apply index: unsupported type of object");if(!t.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return Ie(e,t.getObjectProperty(),r),e}catch(e){throw It(e)}}}({subset:e,matrix:t});function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=e,this.index=r?t:null,this.value=r||t,!fe(e)&&!se(e))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(fe(e)&&"end"===e.name)throw new Error('Cannot assign to symbol "end"');if(this.index&&!z(this.index))throw new TypeError('IndexNode expected as "index"');if(!U(this.value))throw new TypeError('Node expected as "value"');Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function i(e,t){var r=pt(e,t=t||"keep"),e=pt(e.value,t);return"all"===t||null!==e&&e<=r}return(n.prototype=new r).type="AssignmentNode",n.prototype.isAssignmentNode=!0,n.prototype._compile=function(e,t){var i,s,o,u,a=this.object._compile(e,t),c=this.index?this.index._compile(e,t):null,l=this.value._compile(e,t),f=this.object.name;if(this.index)return this.index.isObjectProperty()?(i=this.index.getObjectProperty(),function(e,t,r){var n=a(e,t,r),e=l(e,t,r);return Ie(n,i,e),e}):fe(this.object)?function(e,t,r){var n=a(e,t,r),r=l(e,t,r),t=c(e,t,n);return e.set(f,m(n,t,r)),r}:(s=this.object.object._compile(e,t),this.object.index.isObjectProperty()?(o=this.object.index.getObjectProperty(),function(e,t,r){var n=s(e,t,r),i=qe(n,o),a=c(e,t,i),e=l(e,t,r);return Ie(n,o,m(i,a,e)),e}):(u=this.object.index._compile(e,t),function(e,t,r){var n=s(e,t,r),i=u(e,t,n),a=p(n,i),o=c(e,t,a),e=l(e,t,r);return m(n,i,m(a,o,e)),e}));if(!fe(this.object))throw new TypeError("SymbolNode expected as object");return function(e,t,r){t=l(e,t,r);return e.set(f,t),t}},n.prototype.forEach=function(e){e(this.object,"object",this),this.index&&e(this.index,"index",this),e(this.value,"value",this)},n.prototype.map=function(e){return new n(this._ifNode(e(this.object,"object",this)),this.index?this._ifNode(e(this.index,"index",this)):null,this._ifNode(e(this.value,"value",this)))},n.prototype.clone=function(){return new n(this.object,this.index,this.value)},n.prototype._toString=function(e){var t=this.object.toString(e),r=this.index?this.index.toString(e):"",n=this.value.toString(e);return t+r+" = "+(n=i(this,e&&e.parenthesis)?"("+n+")":n)},n.prototype.toJSON=function(){return{mathjs:"AssignmentNode",object:this.object,index:this.index,value:this.value}},n.fromJSON=function(e){return new n(e.object,e.index,e.value)},n.prototype.toHTML=function(e){var t=this.object.toHTML(e),r=this.index?this.index.toHTML(e):"",n=this.value.toHTML(e);return t+r+'='+(n=i(this,e&&e.parenthesis)?'('+n+')':n)},n.prototype._toTex=function(e){var t=this.object.toTex(e),r=this.index?this.index.toTex(e):"",n=this.value.toTex(e);return t+r+":="+(n=i(this,e&&e.parenthesis)?"\\left(".concat(n,"\\right)"):n)},n},{isClass:!0,isNode:!0}),Rt=a("IndexNode",["Range","Node","size"],e=>{var{Range:n,Node:e,size:m}=e;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(this.dimensions=e,this.dotNotation=t||!1,!Array.isArray(e)||!e.every(U))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}function h(e,t,r){return new n(D(e)?e.toNumber():e,D(t)?t.toNumber():t,D(r)?r.toNumber():r)}return(i.prototype=new e).type="IndexNode",i.prototype.isIndexNode=!0,i.prototype._compile=function(r,p){var i=nt(this.dimensions,function(e,i){var a,o,s,n,u,c,t,l,f;return _(e)?e.needsEnd()?((t=Object.create(p)).end=!0,a=e.start._compile(r,t),o=e.end._compile(r,t),s=e.step?e.step._compile(r,t):function(){return 1},function(e,t,r){var n=m(r).valueOf(),t=Object.create(t);return t.end=n[i],h(a(e,t,r),o(e,t,r),s(e,t,r))}):(n=e.start._compile(r,p),u=e.end._compile(r,p),c=e.step?e.step._compile(r,p):function(){return 1},function(e,t,r){return h(n(e,t,r),u(e,t,r),c(e,t,r))}):fe(e)&&"end"===e.name?((t=Object.create(p)).end=!0,l=e._compile(r,t),function(e,t,r){var n=m(r).valueOf(),t=Object.create(t);return t.end=n[i],l(e,t,r)}):(f=e._compile(r,p),function(e,t,r){return f(e,t,r)})}),a=qe(r,"index");return function(t,r,n){var e=nt(i,function(e){return e(t,r,n)});return a(...e)}},i.prototype.forEach=function(e){for(var t=0;t.'+Ae(this.getObjectProperty())+"":'['+t.join(',')+']'},i.prototype._toTex=function(t){var e=this.dimensions.map(function(e){return e.toTex(t)});return this.dotNotation?"."+this.getObjectProperty():"_{"+e.join(",")+"}"},i},{isClass:!0,isNode:!0}),Ut=a("SymbolNode",["math","?Unit","Node"],e=>{var{math:r,Unit:o,Node:e}=e;function s(e){return!!o&&o.isValuelessUnit(e)}function u(e){if(!(this instanceof u))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');this.name=e}return(u.prototype=new e).type="SymbolNode",u.prototype.isSymbolNode=!0,u.prototype._compile=function(n,e){var i,a=this.name;return!0===e[a]?function(e,t,r){return t[a]}:a in n?function(e,t,r){return e.has(a)?e.get(a):qe(n,a)}:(i=s(a),function(e,t,r){return e.has(a)?e.get(a):i?new o(null,a):u.onUndefinedSymbol(a)})},u.prototype.forEach=function(e){},u.prototype.map=function(e){return this.clone()},u.onUndefinedSymbol=function(e){throw new Error("Undefined symbol "+e)},u.prototype.clone=function(){return new u(this.name)},u.prototype._toString=function(e){return this.name},u.prototype.toHTML=function(e){var t=Ae(this.name);return"true"===t||"false"===t?''+t+"":"i"===t?''+t+"":"Infinity"===t?''+t+"":"NaN"===t?''+t+"":"null"===t?''+t+"":"undefined"===t?''+t+"":''+t+""},u.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},u.fromJSON=function(e){return new u(e.name)},u.prototype._toTex=function(e){var t=!1,t=(void 0===r[this.name]&&s(this.name)&&(t=!0),wt(this.name,t));return"\\"===t[0]?t:" "+t},u},{isClass:!0,isNode:!0});function Ft(e){for(var t=arguments.length,r=new Array(1{var{math:i,Node:e,SymbolNode:r}=e;function m(e,t){if(!(this instanceof m))throw new SyntaxError("Constructor must be called with the new operator");if(!U(e="string"==typeof e?new r(e):e))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(t)||!t.every(U))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=e,this.args=t||[],Object.defineProperty(this,"name",{get:function(){return this.fn.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}(m.prototype=new e).type="FunctionNode",m.prototype.isFunctionNode=!0,m.prototype._compile=function(a,t){if(!(this instanceof m))throw new TypeError("No valid FunctionNode");var o,s,u,c,p,l=this.args.map(e=>e._compile(a,t));if(!fe(this.fn))return se(this.fn)&&z(this.fn.index)&&this.fn.index.isObjectProperty()?(o=this.fn.object._compile(a,t),s=this.fn.index.getObjectProperty(),u=this.args,function(t,r,n){var e=o(t,r,n),i=s;if(!ke(e,i))throw new Error('No access to method "'+i+'"');return e[s]&&e[s].rawArgs?e[s](u,a,Ft(t,r),t):(i=l.map(e=>e(t,r,n)),e[s].apply(e,i))}):(c=this.fn._compile(a,t),p=this.args,function(t,r,n){var e,i=c(t,r,n);return i&&i.rawArgs?i(p,a,Ft(t,r),t):(e=l.map(e=>e(t,r,n)),i.apply(i,e))});var n,r=this.fn.name,e=r in a?qe(a,r):void 0,e="function"==typeof e&&!0===e.rawArgs,f=e=>e.has(r)?e.get(r):r in a?qe(a,r):m.onUndefinedFunction(r);if(e)return n=this.args,function(e,t,r){return f(e)(n,a,Ft(e,t),e)};switch(l.length){case 0:return function(e,t,r){return f(e)()};case 1:return function(e,t,r){return f(e)((0,l[0])(e,t,r))};case 2:return function(e,t,r){var n=f(e),i=l[0],a=l[1];return n(i(e,t,r),a(e,t,r))};default:return function(t,r,n){return f(t)(...l.map(e=>e(t,r,n)))}}},m.prototype.forEach=function(e){e(this.fn,"fn",this);for(var t=0;t'+Ae(this.fn)+'('+e.join(',')+')'};var o=m.prototype.toTex;return m.prototype.toTex=function(e){var t;return void 0!==(t=e&&"object"==typeof e.handler&&ie(e.handler,this.name)?e.handler[this.name](this,e):t)?t:o.call(this,e)},m.prototype._toTex=function(t){var e,r,n=this.args.map(function(e){return e.toTex(t)});switch(vt[this.name]&&(e=vt[this.name]),typeof(e=!i[this.name]||"function"!=typeof i[this.name].toTex&&"object"!=typeof i[this.name].toTex&&"string"!=typeof i[this.name].toTex?e:i[this.name].toTex)){case"function":r=e(this,t);break;case"string":r=a(e,this,t);break;case"object":switch(typeof e[n.length]){case"function":r=e[n.length](this,t);break;case"string":r=a(e[n.length],this,t)}}return void 0!==r?r:a("\\mathrm{${name}}\\left(${args}\\right)",this,t)},m.prototype.getIdentifier=function(){return this.type+":"+this.name},m},{isClass:!0,isNode:!0});function jt(e){for(var t=0;t=n.length)throw new Ve(t,n.length);return q(e)?e.create($t(e.valueOf(),t,r)):$t(e,t,r)}function $t(e,t,r){var n,i,a,o;if(t<=0){if(Array.isArray(e[0])){for(o=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r{var{typed:e,numeric:b,config:w,AccessorNode:c,ArrayNode:N,AssignmentNode:l,BlockNode:f,ConditionalNode:p,ConstantNode:d,FunctionAssignmentNode:m,FunctionNode:h,IndexNode:M,ObjectNode:E,OperatorNode:o,ParenthesisNode:S,RangeNode:n,RelationalNode:A,SymbolNode:O}=e,i=e("parse",{string:function(e){return R(e,{})},"Array | Matrix":function(e){return t(e,{})},"string, Object":function(e,t){return R(e,void 0!==t.nodes?t.nodes:{})},"Array | Matrix, Object":t});function t(e){var t=1":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},_={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},T={true:!0,false:!1,null:null,undefined:void 0},B=["NaN","Infinity"];function q(e,t){return e.expression.substr(e.index,t)}function a(e){return q(e,1)}function s(e){e.index++}function I(e){return e.expression.charAt(e.index-1)}function z(e){return e.expression.charAt(e.index+1)}function g(e){for(e.tokenType=y.NULL,e.token="",e.comment="";i.isWhitespace(a(e),e.nestingLevel);)s(e);if("#"===a(e))for(;"\n"!==a(e)&&""!==a(e);)e.comment+=a(e),s(e);if(""!==a(e)){if("\n"===a(e)&&!e.nestingLevel)return e.tokenType=y.DELIMITER,e.token=a(e),void s(e);var t=a(e),r=q(e,2),n=q(e,3);if(3===n.length&&C[n])return e.tokenType=y.DELIMITER,e.token=n,s(e),s(e),void s(e);if(2===r.length&&C[r])return e.tokenType=y.DELIMITER,e.token=r,s(e),void s(e);if(C[t])return e.tokenType=y.DELIMITER,e.token=t,void s(e);if(i.isDigitDot(t)){e.tokenType=y.NUMBER;n=q(e,2);if("0b"!==n&&"0o"!==n&&"0x"!==n){if("."===a(e)){if(e.token+=a(e),s(e),!i.isDigit(a(e)))return void(e.tokenType=y.DELIMITER)}else{for(;i.isDigit(a(e));)e.token+=a(e),s(e);i.isDecimalMark(a(e),z(e))&&(e.token+=a(e),s(e))}for(;i.isDigit(a(e));)e.token+=a(e),s(e);if("E"===a(e)||"e"===a(e))if(i.isDigit(z(e))||"-"===z(e)||"+"===z(e)){if(e.token+=a(e),s(e),"+"!==a(e)&&"-"!==a(e)||(e.token+=a(e),s(e)),!i.isDigit(a(e)))throw x(e,'Digit expected, got "'+a(e)+'"');for(;i.isDigit(a(e));)e.token+=a(e),s(e);if(i.isDecimalMark(a(e),z(e)))throw x(e,'Digit expected, got "'+a(e)+'"')}else if("."===z(e))throw s(e),x(e,'Digit expected, got "'+a(e)+'"')}else{for(e.token+=a(e),s(e),e.token+=a(e),s(e);i.isHexDigit(a(e));)e.token+=a(e),s(e);if("."===a(e))for(e.token+=".",s(e);i.isHexDigit(a(e));)e.token+=a(e),s(e);else if("i"===a(e))for(e.token+="i",s(e);i.isDigit(a(e));)e.token+=a(e),s(e)}}else{if(!i.isAlpha(a(e),I(e),z(e))){for(e.tokenType=y.UNKNOWN;""!==a(e);)e.token+=a(e),s(e);throw x(e,'Syntax error in part "'+e.token+'"')}for(;i.isAlpha(a(e),I(e),z(e))||i.isDigit(a(e));)e.token+=a(e),s(e);ie(_,e.token)?e.tokenType=y.DELIMITER:e.tokenType=y.SYMBOL}}else e.tokenType=y.DELIMITER}function u(e){for(;g(e),"\n"===e.token;);}function k(e){e.nestingLevel++}function D(e){e.nestingLevel--}function R(e,t){var r={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:y.NULL,nestingLevel:0,conditionalLevel:null},e=(oe(r,{expression:e,extraNodes:t}),g(r),function(e){var t,r,n=[];""!==e.token&&"\n"!==e.token&&";"!==e.token&&((t=v(e)).comment=e.comment);for(;"\n"===e.token||";"===e.token;)0===n.length&&t&&(r=";"!==e.token,n.push({node:t,visible:r})),g(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&((t=v(e)).comment=e.comment,r=";"!==e.token,n.push({node:t,visible:r}));return 0":"larger","<=":"smallerEq",">=":"largerEq"};ie(n,e.token);){var i={name:e.token,fn:n[e.token]};r.push(i),u(e),t.push(H(e))}return 1===t.length?t[0]:2===t.length?new o(r[0].name,r[0].fn,t):new A(r.map(e=>e.fn),t)}function H(e){for(var t,r,n,i=$(e),a={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};ie(a,e.token);)r=a[t=e.token],u(e),n=[i,$(e)],i=new o(t,r,n);return i}function $(e){for(var t,r,n,i=G(e),a={to:"to",in:"to"};ie(a,e.token);)r=a[t=e.token],u(e),i="in"===t&&""===e.token?new o("*","multiply",[i,new O("in")],!0):(n=[i,G(e)],new o(t,r,n));return i}function G(e){var t=[],r=":"===e.token?new d(1):V(e);if(":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(t.push(r);":"===e.token&&t.length<3;)u(e),")"===e.token||"]"===e.token||","===e.token||""===e.token?t.push(new O("end")):t.push(V(e));r=3===t.length?new n(t[0],t[2],t[1]):new n(t[0],t[1])}return r}function V(e){a=Z(e);for(var t,r,n={"+":"add","-":"subtract"};ie(n,e.token);){r=n[t=e.token],u(e);var i=Z(e),i=i.isPercentage?[a,new o("*","multiply",[a,i])]:[a,i],a=new o(t,r,i)}return a}function Z(e){for(var t,r,n,i=W(e),a={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};ie(a,e.token);)r=a[t=e.token],u(e),n=W(e),i=new o(t,r,[i,n]);return i}function W(e){for(var t=Y(e),r=t;e.tokenType===y.SYMBOL||"in"===e.token&&ue(t)||!(e.tokenType!==y.NUMBER||ue(r)||le(r)&&"!"!==r.op)||"("===e.token;)r=Y(e),t=new o("*","multiply",[t,r],!0);return t}function Y(e){for(var t=J(e),r=t,n=[];"/"===e.token&&ue(r);){if(n.push(oe({},e)),u(e),e.tokenType!==y.NUMBER){oe(e,n.pop());break}if(n.push(oe({},e)),u(e),e.tokenType!==y.SYMBOL&&"("!==e.token){n.pop(),oe(e,n.pop());break}oe(e,n.pop()),n.pop(),r=J(e),t=new o("/","divide",[t,r])}return t}function J(e){for(var t,r,n,i=X(e),a={"%":"mod",mod:"mod"};ie(a,e.token);)r=a[t=e.token],u(e),i="%"===t&&e.tokenType===y.DELIMITER&&"("!==e.token?new o("/","divide",[i,new d(100)],!1,!0):(n=[i,X(e)],new o(t,r,n));return i}function X(e){var t,r,n={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return ie(n,e.token)?(n=n[e.token],r=e.token,u(e),t=[X(e)],new o(r,n,t)):(r=e,n=function(e){t=function(e){var t=[];if(e.tokenType===y.SYMBOL&&ie(e.extraNodes,e.token)){var r=e.extraNodes[e.token];if(g(e),"("===e.token){if(t=[],k(e),g(e),")"!==e.token)for(t.push(v(e));","===e.token;)g(e),t.push(v(e));if(")"!==e.token)throw x(e,"Parenthesis ) expected");D(e),g(e)}return new r(t)}return function(e){var t;if(e.tokenType===y.SYMBOL||e.tokenType===y.DELIMITER&&e.token in _)return t=e.token,g(e),t=ie(T,t)?new d(T[t]):-1!==B.indexOf(t)?new d(b(t,"number")):new O(t),t=Q(e,t);return function(e){var t,r,l,f;if('"'===e.token)return n=K(e),n=new d(n),n=Q(e,n);var n=e;if("'"===n.token)return a=ee(n),a=new d(a),a=Q(n,a);var i=n;if("["===i.token){if(k(i),g(i),"]"!==i.token){var a=te(i);if(";"===i.token){for(l=1,r=[a];";"===i.token;)g(i),r[l]=te(i),l++;if("]"!==i.token)throw x(i,"End of matrix ] expected");D(i),g(i),f=r[0].items.length;for(var p=1;p{var{typed:e,parse:t}=e;return e(Zt,{string:function(e){return t(e).compile()},"Array | Matrix":function(e){return ae(e,function(e){return t(e).compile()})}})}),Yt="evaluate",Jt=a(Yt,["typed","parse"],e=>{var{typed:e,parse:r}=e;return e(Yt,{string:function(e){var t=Pe();return r(e).compile().evaluate(t)},"string, Map | Object":function(e,t){return r(e).compile().evaluate(t)},"Array | Matrix":function(e){var t=Pe();return ae(e,function(e){return r(e).compile().evaluate(t)})},"Array | Matrix, Map | Object":function(e,t){return ae(e,function(e){return r(e).compile().evaluate(t)})}})}),Xt=a("Help",["parse"],e=>{var o=e["parse"];function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw new Error('Argument "doc" missing');this.doc=e}return n.prototype.type="Help",n.prototype.isHelp=!0,n.prototype.toString=function(){var e=this.doc||{},t="\n";if(e.name&&(t+="Name: "+e.name+"\n\n"),e.category&&(t+="Category: "+e.category+"\n\n"),e.description&&(t+="Description:\n "+e.description+"\n\n"),e.syntax&&(t+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){t+="Examples:\n";for(var r={},n=0;n"mathjs"!==e).forEach(e=>{r[e]=t[e]}),new n(r)},n.prototype.valueOf=n.prototype.toString,n},{isClass:!0}),Qt=a("Parser",["evaluate"],e=>{var t=e["evaluate"];function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:Pe(),writable:!1})}return r.prototype.type="Parser",r.prototype.isParser=!0,r.prototype.evaluate=function(e){return t(e,this.scope)},r.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},r.prototype.getAll=function(){var e=this.scope;if(e instanceof Fe)return e.wrappedObject;var t,r={};for(t of e.keys())Ie(r,t,e.get(t));return r},r.prototype.getAllAsMap=function(){return this.scope},r.prototype.set=function(e,t){return this.scope.set(e,t),t},r.prototype.remove=function(e){this.scope.delete(e)},r.prototype.clear=function(){this.scope.clear()},r},{isClass:!0}),Kt=a("parser",["typed","Parser"],e=>{var{typed:e,Parser:t}=e;return e("parser",{"":function(){return new t}})}),er=a("simplifyUtil",["FunctionNode","OperatorNode","SymbolNode"],e=>{var{FunctionNode:r,OperatorNode:n,SymbolNode:i}=e,a={add:!0,multiply:!0},o={add:!0,multiply:!0};function s(e,t){if(!le(e))return!1;e=e.fn.toString();return t&&ie(t,e)&&ie(t[e],"associative")?t[e].associative:o[e]||!1}function u(e){function n(e){for(var t=0;t{var{equal:o,isZero:s,add:u,subtract:d,multiply:c,divide:y,pow:g,AccessorNode:v,ArrayNode:x,ConstantNode:l,FunctionNode:b,IndexNode:w,ObjectNode:N,OperatorNode:f,ParenthesisNode:M}=e,p=new l(0),E=new l(1);function m(e){return e.map(h).map(function(e){return P(e)?e.content:e})}function h(e){if(le(e)&&e.isUnary()){var t=h(e.args[0]);if("+"===e.op)return t;if("-"===e.op){if(le(t)){if(t.isUnary()&&"-"===t.op)return t.args[0];if(t.isBinary()&&"subtract"===t.fn)return new f("-","subtract",[t.args[1],t.args[0]])}return new f(e.op,e.fn,[t])}}else if(le(e)&&e.isBinary()){var t=h(e.args[0]),r=h(e.args[1]);if("+"===e.op){if(ue(t)){if(s(t.value))return r;if(ue(r))return new l(u(t.value,r.value))}return ue(r)&&s(r.value)?t:le(r)&&r.isUnary()&&"-"===r.op?new f("-","subtract",[t,r.args[0]]):new f(e.op,e.fn,r?[t,r]:[t])}if("-"===e.op){if(ue(t)&&r){if(ue(r))return new l(d(t.value,r.value));if(s(t.value))return new f("-","unaryMinus",[r])}if("subtract"===e.fn)return ue(r)&&s(r.value)?t:le(r)&&r.isUnary()&&"-"===r.op?h(new f("+","add",[t,r.args[0]])):new f(e.op,e.fn,[t,r])}else{if("*"===e.op){if(ue(t)){if(s(t.value))return p;if(o(t.value,1))return r;if(ue(r))return new l(c(t.value,r.value))}if(ue(r)){if(s(r.value))return p;if(o(r.value,1))return t;if(le(t)&&t.isBinary()&&t.op===e.op){var n=t.args[0];if(ue(n))return n=new l(c(n.value,r.value)),new f(e.op,e.fn,[n,t.args[1]],e.implicit)}return new f(e.op,e.fn,[r,t],e.implicit)}return new f(e.op,e.fn,[t,r],e.implicit)}if("/"===e.op){if(ue(t)){if(s(t.value))return p;if(ue(r)&&(o(r.value,1)||o(r.value,2)||o(r.value,4)))return new l(y(t.value,r.value))}return new f(e.op,e.fn,[t,r])}if("^"===e.op){if(ue(r)){if(s(r.value))return E;if(o(r.value,1))return t;if(ue(t))return new l(g(t.value,r.value));if(le(t)&&t.isBinary()&&"^"===t.op){n=t.args[1];if(ue(n))return new f(e.op,e.fn,[t.args[0],new l(c(n.value,r.value))])}}return new f(e.op,e.fn,[t,r])}}}else{if(P(e))return P(n=h(e.content))||fe(n)||ue(n)?n:new M(n);if(ce(e))return new b(h(e.fn),m(e.args));if(T(e))return new x(m(e.items));if(se(e))return P(t=m(e.object))&&(t=t.content),new v(t,h(e.index));if(z(e))return new w(m(e.dimensions));if(F(e)){var i,a={};for(i in e.properties)a[i]=h(e.properties[i]);return new N(a)}}return e}return h});function rr(){throw new Error('No "bignumber" implementation available')}function nr(){throw new Error('No "fraction" implementation available')}function ir(){throw new Error('No "matrix" implementation available')}var ar=a("simplifyConstant",["typed","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],e=>{var{typed:e,config:i,mathWithTransform:h,matrix:d,fraction:n,bignumber:o,AccessorNode:c,ArrayNode:x,ConstantNode:l,FunctionNode:b,IndexNode:w,ObjectNode:N,OperatorNode:s,SymbolNode:t}=e,{isCommutative:M,isAssociative:E,allChildren:S,createMakeNodeFunction:A}=er({FunctionNode:b,OperatorNode:s,SymbolNode:t});function O(e,t){return y(function t(e,r){switch(e.type){case"SymbolNode":return e;case"ConstantNode":switch(typeof e.value){case"number":return g(e.value,r);case"string":return e.value;default:if(!isNaN(e.value))return g(e.value,r)}return e;case"FunctionNode":if(h[e.name]&&h[e.name].rawArgs)return e;var n=["add","multiply"];if(-1===n.indexOf(e.name)){n=e.args.map(e=>t(e,r));if(!n.some(U))try{return C(e.name,n,r)}catch(e){}if("size"===e.name&&1===n.length&&T(n[0])){for(var l=[],i=n[0];T(i);)l.push(i.items.length),i=i.items[0];return d(l)}return new b(e.name,n.map(y))}case"OperatorNode":var a,o,n=e.fn.toString(),s=A(e);if(le(e)&&e.isUnary())a=[t(e.args[0],r)],o=U(a[0])?s(a):C(n,a,r);else if(E(e))if(a=(a=S(e)).map(e=>t(e,r)),M(n)){for(var u=[],f=[],c=0;ct(e,r)),o=v(n,a,s,r);return o;case"ParenthesisNode":return t(e.content,r);case"AccessorNode":return _(t(e.object,r),t(e.index,r),r);case"ArrayNode":n=e.items.map(e=>t(e,r));return n.some(U)?new x(n.map(y)):d(n);case"IndexNode":return new w(e.dimensions.map(e=>O(e,r)));case"ObjectNode":var p,m={};for(p in e.properties)m[p]=O(e.properties[p],r);return new N(m);default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(e.type))}}(e,t))}function u(e){return R(e)?e.valueOf():e instanceof Array?e.map(u):q(e)?d(u(e.valueOf())):e}function C(t,r,n){try{return h[t].apply(null,r)}catch(e){return r=r.map(u),g(h[t].apply(null,r),n)}}var a=e({Fraction:function(e){var t=e.s*e.n;t=t<0?new s("-","unaryMinus",[new l(-t)]):new l(t);return 1!==e.d?new s("/","divide",[t,new l(e.d)]):t},number:function(e){return e<0?f(new l(-e)):new l(e)},BigNumber:function(e){return e<0?f(new l(-e)):new l(e)},Complex:function(e){throw new Error("Cannot convert Complex number to Node")},string:function(e){return new l(e)},Matrix:function(e){return new x(e.valueOf().map(e=>a(e)))}});function y(e){return U(e)?e:a(e)}function r(e,t){if(t&&!1!==t.exactFractions&&isFinite(e)&&n){var r=n(e),t=t&&"number"==typeof t.fractionsLimit?t.fractionsLimit:1/0;if(r.valueOf()===e&&r.n{var{parse:i,FunctionNode:a,OperatorNode:o,ParenthesisNode:s}=e;return function t(e,r){if(!r)return e;if(Le(r)||(r=je(r)),fe(e)){var n=r.get(e.name);if(U(n))return t(n,r);if("number"==typeof n)return i(String(n))}else{if(le(e))return n=e.args.map(function(e){return t(e,r)}),new o(e.op,e.fn,n,e.implicit);if(P(e))return new s(t(e.content,r));if(ce(e))return n=e.args.map(function(e){return t(e,r)}),new a(e.name,n)}return e}}),sr=a("simplify",["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","?fraction","?bignumber","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],e=>{var{config:e,typed:r,parse:p,add:n,subtract:i,multiply:a,divide:o,pow:s,isZero:u,equal:x,fraction:c,bignumber:l,mathWithTransform:b,matrix:t,AccessorNode:w,ArrayNode:N,ConstantNode:f,FunctionNode:m,IndexNode:M,ObjectNode:E,OperatorNode:h,ParenthesisNode:S,SymbolNode:d}=e,e=ar({typed:r,config:e,mathWithTransform:b,matrix:t,fraction:c,bignumber:l,AccessorNode:w,ArrayNode:N,ConstantNode:f,FunctionNode:m,IndexNode:M,ObjectNode:E,OperatorNode:h,SymbolNode:d}),b=tr({equal:x,isZero:u,add:n,subtract:i,multiply:a,divide:o,pow:s,AccessorNode:w,ArrayNode:N,ConstantNode:f,FunctionNode:m,IndexNode:M,ObjectNode:E,OperatorNode:h,ParenthesisNode:S}),A=or({parse:p,FunctionNode:m,OperatorNode:h,ParenthesisNode:S}),{isCommutative:O,isAssociative:C,flatten:_,unflattenr:T,unflattenl:B,createMakeNodeFunction:q}=er({FunctionNode:m,OperatorNode:h,SymbolNode:d}),t=r("simplify",{string:function(e){return this(p(e),this.rules,Pe(),{})},"string, Map | Object":function(e,t){return this(p(e),this.rules,t,{})},"string, Map | Object, Object":function(e,t,r){return this(p(e),this.rules,t,r)},"string, Array":function(e,t){return this(p(e),t,Pe(),{})},"string, Array, Map | Object":function(e,t,r){return this(p(e),t,r,{})},"string, Array, Map | Object, Object":function(e,t,r,n){return this(p(e),t,r,n)},"Node, Map | Object":function(e,t){return this(e,this.rules,t,{})},"Node, Map | Object, Object":function(e,t,r){return this(e,this.rules,t,r)},Node:function(e){return this(e,this.rules,Pe(),{})},"Node, Array":function(e,t){return this(e,t,Pe(),{})},"Node, Array, Map | Object":function(e,t,r){return this(e,t,r,{})},"Node, Array, Object, Object":function(e,t,r,n){return this(e,t,je(r),n)},"Node, Array, Map, Object":function(l,e,f,t){for(var r=t.consoleDebug,n=(e=function(e){for(var t=[],r=0;r");if(2!==s.length)throw SyntaxError("Could not parse rule: "+i);i={l:s[0],r:s[1]};case"object":a={l:y(p(i.l)),r:y(p(i.r))},i.context&&(a.context=i.context),i.evaluate&&(a.evaluate=p(i.evaluate)),C(a.l)&&(s=q(a.l),n=new d("_p"+z++),a.expanded={},a.expanded.l=s([a.l.clone(),n]),_(a.expanded.l),T(a.expanded.l),a.expanded.r=s([a.r,n]));break;case"function":a=i;break;default:throw TypeError("Unsupported type of rule: "+o)}t.push(a)}return t}(e),A(l,f)),i={},a=(n=y(n)).toString({parenthesis:"all"});!i[a];){i[a]=!0,z=0;var o=a;r&&console.log("Working on: ",a);for(var s=0;s ").concat(e[s].r.toString()))),!r||(u=n.toString({parenthesis:"all"}))!==o&&(console.log("Applying",c,"produced",u),o=u),B(n)}a=n.toString({parenthesis:"all"})}return n}});function y(e){return e.transform(function(e,t,r){return P(e)?y(e.content):e})}t.simplifyCore=b,t.resolve=A;var I={true:!0,false:!0,e:!0,i:!0,Infinity:!0,LN2:!0,LN10:!0,LOG2E:!0,LOG10E:!0,NaN:!0,phi:!0,pi:!0,SQRT1_2:!0,SQRT2:!0,tau:!0};t.rules=[b,{l:"log(e)",r:"1"},{l:"n-n1",r:"n+-n1"},{l:"-(c*v)",r:"v * (-c)"},{l:"-v",r:"v * (-1)"},{l:"n/n1^n2",r:"n*n1^-n2"},{l:"n/n1",r:"n*n1^-1"},e,{l:"(n ^ n1) ^ n2",r:"n ^ (n1 * n2)"},{l:"n*n",r:"n^2"},{l:"n * n^n1",r:"n^(n1+1)"},{l:"n^n1 * n^n2",r:"n^(n1+n2)"},{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},{l:"v*n + v",r:"v*(n+1)"},{l:"n3*n1 + n3*n2",r:"n3*(n1+n2)"},{l:"n*c + c",r:"(n+1)*c"},{l:"n1 + (n2 + n3)*(-1)",r:"n1 + n2*(-1) + n3*(-1)"},{l:"(-n)*n1",r:"-(n*n1)"},{l:"c+v",r:"v+c",context:{add:{commutative:!1}}},{l:"v*c",r:"c*v",context:{multiply:{commutative:!1}}},{l:"n+-n1",r:"n-n1"},{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:"n-(n1+n2)",r:"n-n1-n2"},{l:"1*n",r:"n"},{l:"n1/(n2/n3)",r:"(n1*n3)/n2"},{l:"n1/(-n2)",r:"-n1/n2"}];var z=0;function k(e,t){if(e)for(var r=0;r{var{typed:e,config:r,parse:n,simplify:s,equal:a,isZero:u,numeric:c,ConstantNode:l,FunctionNode:p,OperatorNode:m,ParenthesisNode:f,SymbolNode:y}=e,t=e("derivative",{"Node, SymbolNode, Object":function(e,t,r){var n={},t=(o(n,e,t.name),h(e,n));return r.simplify?s(t):t},"Node, SymbolNode":function(e,t){return this(e,t,{simplify:!0})},"string, SymbolNode":function(e,t){return this(n(e),t)},"string, SymbolNode, Object":function(e,t,r){return this(n(e),t,r)},"string, string":function(e,t){return this(n(e),n(t))},"string, string, Object":function(e,t,r){return this(n(e),n(t),r)},"Node, string":function(e,t){return this(e,n(t))},"Node, string, Object":function(e,t,r){return this(e,n(t),r)}}),i=(t._simplify=!0,t.toTex=function(e){return i.apply(null,e.args)},e("_derivTex",{"Node, SymbolNode":function(e,t){return ue(e)&&"string"===W(e.value)?i(n(e.value).toString(),t.toString(),1):i(e.toString(),t.toString(),1)},"Node, ConstantNode":function(e,t){if("string"===W(t.value))return i(e,n(t.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(e,t,r){return i(e.toString(),t.name,r.value)},"string, string, number":function(e,t,r){t=1===r?"{d\\over d"+t+"}":"{d^{"+r+"}\\over d"+t+"^{"+r+"}}";return t+"\\left[".concat(e,"\\right]")}})),o=e("constTag",{"Object, ConstantNode, string":function(e,t){return e[t]=!0},"Object, SymbolNode, string":function(e,t,r){return t.name!==r&&(e[t]=!0)},"Object, ParenthesisNode, string":function(e,t,r){return o(e,t.content,r)},"Object, FunctionAssignmentNode, string":function(e,t,r){return-1===t.params.indexOf(r)?e[t]=!0:o(e,t.expr,r)},"Object, FunctionNode | OperatorNode, string":function(e,t,r){if(01, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},sqrt:{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"]},sqrtm:{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([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},square:{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"]},subtract:{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"]},unaryMinus:{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"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{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"]},invmod:{name:"invmod",category:"Arithmetic",syntax:["invmod(a, b)"],description:"Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)",examples:["invmod(8, 12)=NaN","invmod(7, 13)=2","math.invmod(15151, 15122)=10429"],seealso:["gcd","xgcd"]},bitAnd:{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"]},bitNot:{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"]},bitOr:{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"]},bitXor:{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"]},leftShift:{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"]},rightArithShift:{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"]},rightLogShift:{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"]},bellNumbers:{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"]},catalan:{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"]},composition:{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"]},stirlingS2:{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"]},config:{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:[]},import:{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:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number, number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},arg:{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"]},conj:{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"]},re:{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"]},im:{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"]},evaluate:{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:[]},help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},distance:{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:[]},intersect:{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:[]},and:{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"]},not:{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"]},or:{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"]},xor:{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"]},concat:{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"]},count:{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"]},cross:{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"]},column:{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"]},ctranspose:{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"]},det:{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"]},diag:{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"]},diff:{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"]},dot:{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"]},getMatrixDataType:{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"]},identity:{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"]},filter:{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"]},flatten:{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"]},forEach:{name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:[],seealso:["map","sort","filter"]},inv:{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"]},eigs:{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"]},kron:{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"]},matrixFromFunction:{name:"matrixFromFunction",category:"Matrix",syntax:["math.matrixFromFunction(size, fn)","math.matrixFromFunction(size, fn, format)","math.matrixFromFunction(size, fn, format, datatype)","math.matrixFromFunction(size, format, fn)","math.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"]},matrixFromRows:{name:"matrixFromRows",category:"Matrix",syntax:["math.matrixFromRows(...arr)","math.matrixFromRows(row1, row2)","math.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"]},matrixFromColumns:{name:"matrixFromColumns",category:"Matrix",syntax:["math.matrixFromColumns(...arr)","math.matrixFromColumns(row1, row2)","math.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"]},map:{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"]},ones:{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"]},partitionSelect:{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"]},range:{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"]},resize:{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"]},reshape:{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])"],seealso:["size","squeeze","resize"]},rotate:{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], math.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"]},rotationMatrix:{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"]},row:{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"]},size:{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"]},sort:{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"])',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},squeeze:{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"]},subset:{name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of a matrix or string. Indexes are one-based. Both the ranges lower-bound and upper-bound are included.",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]"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},trace:{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"]},transpose:{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"]},zeros:{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"]},combinations:{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"]},combinationsWithRep:{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"]},factorial:{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"]},gamma:{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"]},kldivergence:{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:[]},multinomial:{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"]},permutations:{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"]},pickRandom:{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"]},random:{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"]},randomInt:{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"]},compare:{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"]},compareNatural:{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"]},compareText:{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"]},deepEqual:{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"]},equal:{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"]},equalText:{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"]},larger:{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"]},largerEq:{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"]},smaller:{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"]},smallerEq:{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"]},unequal:{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"]},setCartesian:{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"]},setDifference:{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"]},setDistinct:{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"]},setIntersect:{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"]},setIsSubset:{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"]},setMultiplicity:{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"]},setPowerset:{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"]},setSize:{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"]},setSymDifference:{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"]},setUnion:{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"]},erf:{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:[]},mad:{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"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],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"]},mean:{name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],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"]},median:{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"]},min:{name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],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"]},mode:{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"]},prod:{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"]},quantileSeq:{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"]},std:{name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, 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"]},sum:{name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],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"]},variance:{name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, 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"]},acos:{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"]},acosh:{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"]},acot:{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"]},acoth:{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"]},acsc:{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"]},acsch:{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"]},asec:{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"]},asech:{name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},asin:{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"]},asinh:{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"]},atan:{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"]},atanh:{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"]},atan2:{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"]},cos:{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"]},cosh:{name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},cot:{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"]},coth:{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"]},csc:{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"]},csch:{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"]},sec:{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"]},sech:{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"]},sin:{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"]},sinh:{name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},tan:{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"]},tanh:{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"]},to:{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:[]},clone:{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:[]},format:{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"]},bin:{name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},oct:{name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},hex:{name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},isNaN:{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"]},isInteger:{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"]},isNegative:{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"]},isNumeric:{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"]},hasNumericValue:{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"]},isPositive:{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"]},isPrime:{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"]},isZero:{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"]},print:{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"]},typeOf:{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"]},numeric:{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"]}},lr=a("help",["typed","mathWithTransform","Help"],e=>{var{typed:e,mathWithTransform:a,Help:o}=e;return e("help",{any:function(e){var t,r=e;if("string"!=typeof e)for(t in a)if(ie(a,t)&&e===a[t]){r=t;break}var n,i=qe(fr,r);if(!i)throw n="function"==typeof r?r.name:r,new Error('No documentation found on "'+n+'"');return new o(i)}})}),pr="rationalize",cr=a(pr,["config","typed","equal","isZero","add","subtract","multiply","divide","pow","parse","simplify","?bignumber","?fraction","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode","ParenthesisNode"],e=>{var{config:e,typed:t,equal:o,isZero:s,add:u,subtract:c,multiply:l,divide:f,pow:p,parse:n,simplify:h,fraction:m,bignumber:v,mathWithTransform:x,matrix:b,AccessorNode:r,ArrayNode:i,ConstantNode:d,FunctionNode:a,IndexNode:w,ObjectNode:N,OperatorNode:y,SymbolNode:M,ParenthesisNode:E}=e,S=ar({typed:t,config:e,mathWithTransform:x,matrix:b,fraction:m,bignumber:v,AccessorNode:r,ArrayNode:i,ConstantNode:d,FunctionNode:a,IndexNode:w,ObjectNode:N,OperatorNode:y,SymbolNode:M}),A=tr({equal:o,isZero:s,add:u,subtract:c,multiply:l,divide:f,pow:p,AccessorNode:r,ArrayNode:i,ConstantNode:d,FunctionNode:a,IndexNode:w,ObjectNode:N,OperatorNode:y,ParenthesisNode:E});return t(pr,{string:function(e){return this(n(e),{},!1)},"string, boolean":function(e,t){return this(n(e),{},t)},"string, Object":function(e,t){return this(n(e),t,!1)},"string, Object, boolean":function(e,t,r){return this(n(e),t,r)},Node:function(e){return this(e,{},!1)},"Node, boolean":function(e,t){return this(e,{},t)},"Node, Object":function(e,t){return this(e,t,!1)},"Node, Object, boolean":function(e,t,r){(a={}).firstRules=(u=[A,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},S,{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"}]).concat(n=[{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)"}],c=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}]),a.distrDivRules=[{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)"}],a.sucDivRules=c,a.firstRulesAgain=u.concat(n),a.finalRules=[A,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},S,{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))"}];var n,o,l,i=a,a=(c=e,u=!0,n=i.firstRules,c=h(c,n,t,{exactFractions:!(o=[])}),l="+-*"+((u=!!u)?"/":""),function e(t){var r=t.type;{if("FunctionNode"===r)throw new Error("There is an unsolved function call");if("OperatorNode"===r)if("^"===t.op){if("ConstantNode"!==t.args[1].type||!O(parseFloat(t.args[1].value)))throw new Error("There is a non-integer exponent");e(t.args[0])}else{if(-1===l.indexOf(t.op))throw new Error("Operator "+t.op+" invalid in polynomial expression");for(var n=0;n{e=e.typed;function t(e,t,r){var n,i;return e[0]&&(n=e[0].compile().evaluate(r)),e[1]&&(i=fe(e[1])||C(e[1])?e[1].compile().evaluate(r):yr(e[1],t,r)),a(n,i)}t.rawArgs=!0;var a=e("filter",{"Array, function":vr,"Matrix, function":function(e,t){return e.create(vr(e.toArray(),t))},"Array, RegExp":ot,"Matrix, RegExp":function(e,t){return e.create(ot(e.toArray(),t))}});return t},{isTransformFunction:!0});function vr(e,n){var i=dr(n);return at(e,function(e,t,r){return 1===i?n(e):2===i?n(e,[t+1]):n(e,[t+1],r)})}var xr=a("forEach",["typed"],e=>{e=e.typed;function t(e,t,r){var n,i;return e[0]&&(n=e[0].compile().evaluate(r)),e[1]&&(i=fe(e[1])||C(e[1])?e[1].compile().evaluate(r):yr(e[1],t,r)),a(n,i)}t.rawArgs=!0;var a=e("forEach",{"Array | Matrix, function":function(t,i){var a=dr(i);(function r(e,n){Array.isArray(e)?it(e,function(e,t){r(e,n.concat(t+1))}):1===a?i(e):2===a?i(e,n):i(e,n,t)})(t.valueOf(),[])}});return t},{isTransformFunction:!0}),br=a("map",["typed"],e=>{e=e.typed;function t(e,t,r){var n,i;return e[0]&&(n=e[0].compile().evaluate(r)),e[1]&&(i=fe(e[1])||C(e[1])?e[1].compile().evaluate(r):yr(e[1],t,r)),a(n,i)}t.rawArgs=!0;var a=e("map",{"Array, function":function(e,t){return wr(e,t,e)},"Matrix, function":function(e,t){return e.create(wr(e.valueOf(),t,e))}});return t},{isTransformFunction:!0});function wr(e,t,i){var a=dr(t);return function r(e,n){return Array.isArray(e)?nt(e,function(e,t){return r(e,n.concat(t+1))}):1===a?t(e):2===a?t(e,n):t(e,n,i)}(e,[])}var Nr=a("apply",["typed","isInteger"],e=>{var{typed:e,isInteger:i}=e;return e("apply",{"Array | Matrix, number | BigNumber, function":function(e,t,r){if(!i(t))throw new TypeError("Integer number expected for dimension");var n=Array.isArray(e)?Ze(e):e.size();if(t<0||t>=n.length)throw new Ve(t,n.length);return q(e)?e.create(Mr(e.valueOf(),t,r)):Mr(e,t,r)}})});function Mr(e,t,r){var n,i,a;if(t<=0){if(Array.isArray(e[0])){for(a=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r{var{typed:e,isInteger:t}=e,r=Nr({typed:e,isInteger:t});return e("apply",{"...any":function(e){var t=e[1];k(t)?e[1]=t-1:D(t)&&(e[1]=t.minus(1));try{return r.apply(null,e)}catch(e){throw It(e)}}})},{isTransformFunction:!0}),Sr=a("diff",["typed","matrix","subtract","number"],e=>{var{typed:e,matrix:r,subtract:c,number:n}=e;return e("diff",{"Array | Matrix":function(e){return q(e)?r(a(e.toArray())):a(e)},"Array | Matrix, number":function(e,t){if(!O(t))throw new RangeError("Dimension must be a whole number");return q(e)?r(i(e.toArray(),t)):i(e,t)},"Array | Matrix, BigNumber":function(e,t){return this(e,n(t))}});function i(e,t){if(q(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError("Array/Matrix does not have that many dimensions");var r;if(0{r.push(i(e,t-1))}),r;if(0===t)return a(e);throw RangeError("Cannot have negative dimension")}function a(e){var t=[],r=e.length;if(r<2)return e;for(var n=1;n{var{typed:e,matrix:t,subtract:r,number:n,bignumber:i}=e,a=Sr({typed:e,matrix:t,subtract:r,number:n,bignumber:i});return e("diff",{"...any":function(e){e=Ar(e);try{return a.apply(null,e)}catch(e){throw It(e)}}})},{isTransformFunction:!0}),Cr=a("index",["Index"],e=>{var a=e["Index"];return function(){for(var e=[],t=0,r=arguments.length;t{var{typed:e,matrix:i}=e;return e("subset",{"Array, Index":function(e,t){e=i(e).subset(t);return t.isScalar()?e:e.valueOf()},"Matrix, Index":function(e,t){return e.subset(t)},"Object, Index":qr,"string, Index":Tr,"Array, Index, any":function(e,t,r){return i(X(e)).subset(t,r,void 0).valueOf()},"Array, Index, any, any":function(e,t,r,n){return i(X(e)).subset(t,r,n).valueOf()},"Matrix, Index, any":function(e,t,r){return e.clone().subset(t,r)},"Matrix, Index, any, any":function(e,t,r,n){return e.clone().subset(t,r,n)},"string, Index, string":Br,"string, Index, string, string":Br,"Object, Index, any":Ir})});function Tr(t,e){if(!I(e))throw new TypeError("Index expected");if(1!==e.size().length)throw new Ge(e.size().length,1);var r=t.length,r=(Ye(e.min()[0],r),Ye(e.max()[0],r),e.dimension(0)),n="";return r.forEach(function(e){n+=t.charAt(e)}),n}function Br(e,t,r,n){if(!t||!0!==t.isIndex)throw new TypeError("Index expected");if(1!==t.size().length)throw new Ge(t.size().length,1);if(void 0!==n){if("string"!=typeof n||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";var i=t.dimension(0);if(i.size()[0]!==r.length)throw new Ge(i.size()[0],r.length);for(var a=e.length,o=(Ye(t.min()[0]),Ye(t.max()[0]),[]),s=0;sa)for(var u=a-1,c=o.length;u{var{typed:e,matrix:t}=e,r=_r({typed:e,matrix:t});return e("subset",{"...any":function(e){try{return r.apply(null,e)}catch(e){throw It(e)}}})},{isTransformFunction:!0}),kr=a("concat",["typed","matrix","isInteger"],e=>{var{typed:e,matrix:l,isInteger:f}=e;return e("concat",{"...Array | Matrix | number | BigNumber":function(e){for(var t,r=e.length,n=-1,i=!1,a=[],o=0;o{var{typed:e,matrix:t,isInteger:r}=e,n=kr({typed:e,matrix:t,isInteger:r});return e("concat",{"...any":function(e){var t=e.length-1,r=e[t];k(r)?e[t]=r-1:D(r)&&(e[t]=r.minus(1));try{return n.apply(null,e)}catch(e){throw It(e)}}})},{isTransformFunction:!0});function Rr(e,t,r){var n;return-1!==String(e).indexOf("Unexpected type")?(n=2{var{typed:e,config:t,numeric:n,larger:i}=e;return e("max",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){return Ht(e,t.valueOf(),r)},"...":function(e){if(jt(e))throw new TypeError("Scalar values expected in function max");return a(e)}});function r(e,t){try{return i(e,t)?e:t}catch(e){throw Rr(e,"max",t)}}function a(e){var r;if(Lt(e,function(t){try{isNaN(t)&&"number"==typeof t?r=NaN:void 0!==r&&!i(t,r)||(r=t)}catch(e){throw Rr(e,"max",t)}}),void 0===r)throw new Error("Cannot calculate max of an empty array");return r="string"==typeof r?n(r,t.number):r}}),Fr=a("max",["typed","config","numeric","larger"],e=>{var{typed:e,config:t,numeric:r,larger:n}=e,i=Ur({typed:e,config:t,numeric:r,larger:n});return e("max",{"...any":function(e){e=Ar(e);try{return i.apply(null,e)}catch(e){throw It(e)}}})},{isTransformFunction:!0}),Pr=a("min",["typed","config","numeric","smaller"],e=>{var{typed:e,config:t,numeric:n,smaller:i}=e;return e("min",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){return Ht(e,t.valueOf(),r)},"...":function(e){if(jt(e))throw new TypeError("Scalar values expected in function min");return a(e)}});function r(e,t){try{return i(e,t)?e:t}catch(e){throw Rr(e,"min",t)}}function a(e){var r;if(Lt(e,function(t){try{isNaN(t)&&"number"==typeof t?r=NaN:void 0!==r&&!i(t,r)||(r=t)}catch(e){throw Rr(e,"min",t)}}),void 0===r)throw new Error("Cannot calculate min of an empty array");return r="string"==typeof r?n(r,t.number):r}}),jr=a("min",["typed","config","numeric","smaller"],e=>{var{typed:e,config:t,numeric:r,smaller:n}=e,i=Pr({typed:e,config:t,numeric:r,smaller:n});return e("min",{"...any":function(e){e=Ar(e);try{return i.apply(null,e)}catch(e){throw It(e)}}})},{isTransformFunction:!0}),Lr=a("range",["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],e=>{var{typed:e,config:n,matrix:t,bignumber:o,smaller:s,smallerEq:f,larger:p,largerEq:m}=e;return e("range",{string:r,"string, boolean":r,"number, number":function(e,t){return i(a(e,t,1))},"number, number, number":function(e,t,r){return i(a(e,t,r))},"number, number, boolean":function(e,t,r){return i((r?u:a)(e,t,1))},"number, number, number, boolean":function(e,t,r,n){return i((n?u:a)(e,t,r))},"BigNumber, BigNumber":function(e,t){return i(c(e,t,new e.constructor(1)))},"BigNumber, BigNumber, BigNumber":function(e,t,r){return i(c(e,t,r))},"BigNumber, BigNumber, boolean":function(e,t,r){var n=e.constructor;return i((r?l:c)(e,t,new n(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,r,n){return i((n?l:c)(e,t,r))}});function i(e){return"Matrix"===n.matrix?t?t(e):ir():e}function r(e,t){var r=function(e){var t=e.split(":").map(function(e){return Number(e)});if(t.some(function(e){return isNaN(e)}))return null;switch(t.length){case 2:return{start:t[0],end:t[1],step:1};case 3:return{start:t[0],end:t[2],step:t[1]};default:return null}}(e);if(!r)throw new SyntaxError('String "'+e+'" is no valid range');return"BigNumber"===n.number?(void 0===o&&rr(),i((t?l:c)(o(r.start),o(r.end),o(r.step)))):i((t?u:a)(r.start,r.end,r.step))}function a(e,t,r){var n=[],i=e;if(0{var{typed:e,config:t,matrix:r,bignumber:n,smaller:i,smallerEq:a,larger:o,largerEq:s}=e,u=Lr({typed:e,config:t,matrix:r,bignumber:n,smaller:i,smallerEq:a,larger:o,largerEq:s});return e("range",{"...any":function(e){return"boolean"!=typeof e[e.length-1]&&e.push(!0),u.apply(null,e)}})},{isTransformFunction:!0}),$r=a("row",["typed","Index","matrix","range"],e=>{var{typed:e,Index:n,matrix:r,range:i}=e;return e("row",{"Matrix, number":a,"Array, number":function(e,t){return a(r(X(e)),t).valueOf()}});function a(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");Ye(t,e.size()[0]);var r=i(0,e.size()[1]),t=new n(t,r);return e.subset(t)}}),Gr=a("row",["typed","Index","matrix","range"],e=>{var{typed:e,Index:t,matrix:r,range:n}=e,i=$r({typed:e,Index:t,matrix:r,range:n});return e("row",{"...any":function(e){var t=e.length-1,r=e[t];k(r)&&(e[t]=r-1);try{return i.apply(null,e)}catch(e){throw It(e)}}})},{isTransformFunction:!0}),Vr=a("sum",["typed","config","add","numeric"],e=>{var{typed:e,config:t,add:n,numeric:i}=e;return e("sum",{"Array | Matrix":r,"Array | Matrix, number | BigNumber":function(e,t){try{return Ht(e,t,n)}catch(e){throw Rr(e,"sum")}},"...":function(e){if(jt(e))throw new TypeError("Scalar values expected in function sum");return r(e)}});function r(e){var r;return Lt(e,function(t){try{r=void 0===r?t:n(r,t)}catch(e){throw Rr(e,"sum",t)}}),r="string"==typeof(r=void 0===r?i(0,t.number):r)?i(r,t.number):r}}),Zr=a("sum",["typed","config","add","numeric"],e=>{var{typed:e,config:t,add:r,numeric:n}=e,i=Vr({typed:e,config:t,add:r,numeric:n});return e("sum",{"...any":function(e){e=Ar(e);try{return i.apply(null,e)}catch(e){throw It(e)}}})},{isTransformFunction:!0}),Wr=a("column",["typed","Index","matrix","range"],e=>{var{typed:e,Index:n,matrix:r,range:i}=e;return e("column",{"Matrix, number":a,"Array, number":function(e,t){return a(r(X(e)),t).valueOf()}});function a(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");Ye(t,e.size()[1]);var r=i(0,e.size()[0]),r=new n(r,t);return e.subset(r)}}),Yr=a("column",["typed","Index","matrix","range"],e=>{var{typed:e,Index:t,matrix:r,range:n}=e,i=Wr({typed:e,Index:t,matrix:r,range:n});return e("column",{"...any":function(e){var t=e.length-1,r=e[t];k(r)&&(e[t]=r-1);try{return i.apply(null,e)}catch(e){throw It(e)}}})},{isTransformFunction:!0}),Jr=a("mean",["typed","add","divide"],e=>{var{typed:e,add:i,divide:a}=e;return e("mean",{"Array | Matrix":t,"Array | Matrix, number | BigNumber":function(e,t){try{var r=Ht(e,t,i),n=Array.isArray(e)?Ze(e):e.size();return a(r,n[t])}catch(e){throw Rr(e,"mean")}},"...":function(e){if(jt(e))throw new TypeError("Scalar values expected in function mean");return t(e)}});function t(e){var r,n=0;if(Lt(e,function(t){try{r=void 0===r?t:i(r,t),n++}catch(e){throw Rr(e,"mean",t)}}),0===n)throw new Error("Cannot calculate the mean of an empty array");return a(r,n)}}),Xr=a("mean",["typed","add","divide"],e=>{var{typed:e,add:t,divide:r}=e,n=Jr({typed:e,add:t,divide:r});return e("mean",{"...any":function(e){e=Ar(e);try{return n.apply(null,e)}catch(e){throw It(e)}}})},{isTransformFunction:!0}),Qr="unbiased",Kr="variance",en=a(Kr,["typed","add","subtract","multiply","divide","apply","isNaN"],e=>{var{typed:e,add:o,subtract:s,multiply:u,divide:c,apply:n,isNaN:l}=e;return e(Kr,{"Array | Matrix":function(e){return i(e,Qr)},"Array | Matrix, string":i,"Array | Matrix, number | BigNumber":function(e,t){return r(e,t,Qr)},"Array | Matrix, number | BigNumber, string":r,"...":function(e){return i(e,Qr)}});function i(e,t){var r=0;if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Lt(e,function(t){try{i=void 0===i?t:o(i,t),r++}catch(e){throw Rr(e,"variance",t)}}),0===r)throw new Error("Cannot calculate variance of an empty array");var n=c(i,r),i=void 0;if(Lt(e,function(e){e=s(e,n);i=void 0===i?u(e,e):o(i,u(e,e))}),l(i))return i;switch(t){case"uncorrected":return c(i,r);case"biased":return c(i,r+1);case"unbiased":var a=D(i)?i.mul(0):0;return 1===r?a:c(i,r-1);default:throw new Error('Unknown normalization "'+t+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function r(e,t,r){try{if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return n(e,t,e=>i(e,r))}catch(e){throw Rr(e,"variance")}}}),tn="variance",rn=a(tn,["typed","add","subtract","multiply","divide","apply","isNaN"],e=>{var{typed:e,add:t,subtract:r,multiply:n,divide:i,apply:a,isNaN:o}=e,s=en({typed:e,add:t,subtract:r,multiply:n,divide:i,apply:a,isNaN:o});return e(tn,{"...any":function(e){e=Ar(e);try{return s.apply(null,e)}catch(e){throw It(e)}}})},{isTransformFunction:!0}),nn=a("std",["typed","sqrt","variance"],e=>{var{typed:e,sqrt:r,variance:n}=e;return e("std",{"Array | Matrix":t,"Array | Matrix, string":t,"Array | Matrix, number | BigNumber":t,"Array | Matrix, number | BigNumber, string":t,"...":function(e){return t(e)}});function t(e,t){if(0===e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{return r(n.apply(null,arguments))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf(" variance")?new TypeError(e.message.replace(" variance"," std")):e}}}),an=a("std",["typed","sqrt","variance"],e=>{var{typed:e,sqrt:t,variance:r}=e,n=nn({typed:e,sqrt:t,variance:r});return e("std",{"...any":function(e){e=Ar(e);try{return n.apply(null,e)}catch(e){throw It(e)}}})},{isTransformFunction:!0}),on=lm(776),t=a("BigNumber",["?on","config"],e=>{var{on:e,config:t}=e,r=on.clone({precision:t.precision,modulo:on.EUCLID});return r.prototype=Object.create(r.prototype),r.prototype.type="BigNumber",r.prototype.isBigNumber=!0,r.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},r.fromJSON=function(e){return new r(e.value)},e&&e("config",function(e,t){e.precision!==t.precision&&r.config({precision:e.precision})}),r},{isClass:!0}),sn=lm(977),un=a("Complex",[],()=>(sn.prototype.type="Complex",sn.prototype.isComplex=!0,sn.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},sn.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},sn.prototype.format=function(e){var t=this.im,r=this.re,n=K(this.re,e),i=K(this.im,e),e=k(e)?e:e?e.precision:null;return null!==e&&(e=Math.pow(10,-e),Math.abs(r/t)t.re?1:e.ret.im?1:e.im!0),vn=a("false",[],()=>!1),xn=a("null",[],()=>null),bn=zn("Infinity",["config","?BigNumber"],e=>{var{config:e,BigNumber:t}=e;return"BigNumber"===e.number?new t(1/0):1/0}),wn=zn("NaN",["config","?BigNumber"],e=>{var{config:e,BigNumber:t}=e;return"BigNumber"===e.number?new t(NaN):NaN}),Nn=zn("pi",["config","?BigNumber"],e=>{var{config:e,BigNumber:t}=e;return"BigNumber"===e.number?fn(t):hn}),Mn=zn("tau",["config","?BigNumber"],e=>{var{config:e,BigNumber:t}=e;return"BigNumber"===e.number?pn(t):dn}),En=zn("e",["config","?BigNumber"],e=>{var{config:e,BigNumber:t}=e;return"BigNumber"===e.number?cn(t):yn}),Sn=zn("phi",["config","?BigNumber"],e=>{var{config:e,BigNumber:t}=e;return"BigNumber"===e.number?ln(t):1.618033988749895}),An=zn("LN2",["config","?BigNumber"],e=>{var{config:e,BigNumber:t}=e;return"BigNumber"===e.number?new t(2).ln():Math.LN2}),On=zn("LN10",["config","?BigNumber"],e=>{var{config:e,BigNumber:t}=e;return"BigNumber"===e.number?new t(10).ln():Math.LN10}),Cn=zn("LOG2E",["config","?BigNumber"],e=>{var{config:e,BigNumber:t}=e;return"BigNumber"===e.number?new t(1).div(new t(2).ln()):Math.LOG2E}),_n=zn("LOG10E",["config","?BigNumber"],e=>{var{config:e,BigNumber:t}=e;return"BigNumber"===e.number?new t(1).div(new t(10).ln()):Math.LOG10E}),Tn=zn("SQRT1_2",["config","?BigNumber"],e=>{var{config:e,BigNumber:t}=e;return"BigNumber"===e.number?new t("0.5").sqrt():Math.SQRT1_2}),Bn=zn("SQRT2",["config","?BigNumber"],e=>{var{config:e,BigNumber:t}=e;return"BigNumber"===e.number?new t(2).sqrt():Math.SQRT2}),qn=zn("i",["Complex"],e=>{e=e.Complex;return e.I}),In=a("version",[],()=>"10.1.1");function zn(e,t,r){return a(e,t,r,{recreateOnConfigChange:!0})}var kn=Bi("speedOfLight","299792458","m s^-1"),Dn=Bi("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),Rn=Bi("planckConstant","6.62607015e-34","J s"),Un=Bi("reducedPlanckConstant","1.0545718176461565e-34","J s"),Fn=Bi("magneticConstant","1.25663706212e-6","N A^-2"),Pn=Bi("electricConstant","8.8541878128e-12","F m^-1"),jn=Bi("vacuumImpedance","376.730313667","ohm"),Ln=Bi("coulomb","8.987551792261171e9","N m^2 C^-2"),Hn=Bi("elementaryCharge","1.602176634e-19","C"),$n=Bi("bohrMagneton","9.2740100783e-24","J T^-1"),Gn=Bi("conductanceQuantum","7.748091729863649e-5","S"),Vn=Bi("inverseConductanceQuantum","12906.403729652257","ohm"),Zn=Bi("magneticFluxQuantum","2.0678338484619295e-15","Wb"),Wn=Bi("nuclearMagneton","5.0507837461e-27","J T^-1"),Yn=Bi("klitzing","25812.807459304513","ohm"),Jn=Bi("bohrRadius","5.29177210903e-11","m"),Xn=Bi("classicalElectronRadius","2.8179403262e-15","m"),Qn=Bi("electronMass","9.1093837015e-31","kg"),Kn=Bi("fermiCoupling","1.1663787e-5","GeV^-2"),ei=qi("fineStructure",.0072973525693),ti=Bi("hartreeEnergy","4.3597447222071e-18","J"),ri=Bi("protonMass","1.67262192369e-27","kg"),ni=Bi("deuteronMass","3.3435830926e-27","kg"),ii=Bi("neutronMass","1.6749271613e-27","kg"),ai=Bi("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),oi=Bi("rydberg","10973731.568160","m^-1"),si=Bi("thomsonCrossSection","6.6524587321e-29","m^2"),ui=qi("weakMixingAngle",.2229),ci=qi("efimovFactor",22.7),li=Bi("atomicMass","1.66053906660e-27","kg"),fi=Bi("avogadro","6.02214076e23","mol^-1"),pi=Bi("boltzmann","1.380649e-23","J K^-1"),mi=Bi("faraday","96485.33212331001","C mol^-1"),hi=Bi("firstRadiation","3.7417718521927573e-16","W m^2"),di=Bi("loschmidt","2.686780111798444e25","m^-3"),yi=Bi("gasConstant","8.31446261815324","J K^-1 mol^-1"),gi=Bi("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),vi=Bi("molarVolume","0.022413969545014137","m^3 mol^-1"),xi=qi("sackurTetrode",-1.16487052358),bi=Bi("secondRadiation","0.014387768775039337","m K"),wi=Bi("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),Ni=Bi("wienDisplacement","2.897771955e-3","m K"),Mi=Bi("molarMass","0.99999999965e-3","kg mol^-1"),Ei=Bi("molarMassC12","11.9999999958e-3","kg mol^-1"),Si=Bi("gravity","9.80665","m s^-2"),Ai=Bi("planckLength","1.616255e-35","m"),Oi=Bi("planckMass","2.176435e-8","kg"),Ci=Bi("planckTime","5.391245e-44","s"),_i=Bi("planckCharge","1.87554603778e-18","C"),Ti=Bi("planckTemperature","1.416785e+32","K");function Bi(e,n,i){return a(e,["config","Unit","BigNumber"],e=>{var{config:e,Unit:t,BigNumber:r}=e,t=new t("BigNumber"===e.number?new r(n):parseFloat(n),i);return t.fixPrefix=!0,t})}function qi(e,r){return a(e,["config","BigNumber"],e=>{var{config:e,BigNumber:t}=e;return"BigNumber"===e.number?new t(r):r})}var Ii=lm(628),zi=a("Fraction",[],()=>(Ii.prototype.type="Fraction",Ii.prototype.isFraction=!0,Ii.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},Ii.fromJSON=function(e){return new Ii(e)},Ii),{isClass:!0}),ki=a("Matrix",[],()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(e,t,r){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(e,t,r){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e},{isClass:!0}),Di=a("Range",[],()=>{function o(e,t,r){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");var n=null!=e,i=null!=t,a=null!=r;if(n)if(D(e))e=e.toNumber();else if("number"!=typeof e)throw new TypeError("Parameter start must be a number");if(i)if(D(t))t=t.toNumber();else if("number"!=typeof t)throw new TypeError("Parameter end must be a number");if(a)if(D(r))r=r.toNumber();else if("number"!=typeof r)throw new TypeError("Parameter step must be a number");this.start=n?parseFloat(e):0,this.end=i?parseFloat(t):0,this.step=a?parseFloat(r):1}return o.prototype.type="Range",o.prototype.isRange=!0,o.parse=function(e){if("string"!=typeof e)return null;var t=e.split(":").map(function(e){return parseFloat(e)});if(t.some(function(e){return isNaN(e)}))return null;switch(t.length){case 2:return new o(t[0],t[1]);case 3:return new o(t[0],t[2],t[1]);default:return null}},o.prototype.clone=function(){return new o(this.start,this.end,this.step)},o.prototype.size=function(){var e=0,t=this.start,r=this.step,t=this.end-t;return L(r)===L(t)?e=Math.ceil(t/r):0==t&&(e=0),[e=isNaN(e)?0:e]},o.prototype.min=function(){var e=this.size()[0];if(0{function t(e){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");this.entries=e||[]}return t.prototype.type="ResultSet",t.prototype.isResultSet=!0,t.prototype.valueOf=function(){return this.entries},t.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},t.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},t.fromJSON=function(e){return new t(e.entries)},t},{isClass:!0}),Ui=a("DenseMatrix",["Matrix"],e=>{e=e.Matrix;function g(e,t){if(!(this instanceof g))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!B(t))throw new Error("Invalid datatype: "+t);if(q(e))"DenseMatrix"===e.type?(this._data=X(e._data),this._size=X(e._size)):(this._data=e.toArray(),this._size=e.size()),this._datatype=t||e._datatype;else if(e&&x(e.data)&&x(e.size))this._data=e.data,this._size=e.size,We(this._data,this._size),this._datatype=t||e.datatype;else if(x(e))this._data=function e(t){for(var r=0,n=t.length;rn[a]&&(n[a]=t[a],i=!0);i&&s(e,n,r)}return(g.prototype=new e).createDenseMatrix=function(e,t){return new g(e,t)},g.prototype.type="DenseMatrix",g.prototype.isDenseMatrix=!0,g.prototype.getDataType=function(){return lt(this._data,W)},g.prototype.storage=function(){return"dense"},g.prototype.datatype=function(){return this._datatype},g.prototype.create=function(e,t){return new g(e,t)},g.prototype.subset=function(e,l,f){switch(arguments.length){case 1:var t=this,r=e;if(!I(r))throw new TypeError("Invalid index");if(r.isScalar())return t.get(r.min());var n=r.size();if(n.length!==t._size.length)throw new Ge(n.length,t._size.length);for(var p=r.min(),m=r.max(),i=0,h=t._size.length;i");u=n.max().map(function(e){return e+1}),u=(v(r,u,d),s.length);!function r(n,i,a,o,s){var e=s===o-1;var t=i.dimension(s);e?t.forEach(function(e,t){Ye(e),n[e]=a[t[0]]}):t.forEach(function(e,t){Ye(e),r(n[e],i,a[t[0]],o,s+1)})}(r._data,n,a,u,0)}return r;default:throw new SyntaxError("Wrong number of arguments")}},g.prototype.get=function(e){if(!x(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new Ge(e.length,this._size.length);for(var t=0;tArray.isArray(e)&&1===e.length?e[0]:e);return s(r?this.clone():this,e,t)},g.prototype.reshape=function(e,t){var t=t?this.clone():this,r=(t._data=Xe(t._data,e),t._size.reduce((e,t)=>e*t));return t._size=Qe(e,r),t},g.prototype.clone=function(){return new g({data:X(this._data),size:X(this._size),datatype:this._datatype})},g.prototype.size=function(){return this._size.slice(0)},g.prototype.map=function(t){var i=this,e=function r(e,n){return x(e)?e.map(function(e,t){return r(e,n.concat(t))}):t(e,n,i)}(this._data,[]);return new g(e,void 0!==this._datatype?lt(e,W):void 0)},g.prototype.forEach=function(t){var i=this;(function r(e,n){x(e)?e.forEach(function(e,t){r(e,n.concat(t))}):t(e,n,i)})(this._data,[])},g.prototype[Symbol.iterator]=function*(){yield*function*e(t,r){if(x(t))for(var n=0;n[e[t]]);n.push(new g(e,r._datatype))}(t);return n},g.prototype.toArray=function(){return X(this._data)},g.prototype.valueOf=function(){return this._data},g.prototype.format=function(e){return Ee(this._data,e)},g.prototype.toString=function(){return Ee(this._data)},g.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},g.prototype.diagonal=function(e){if(e){if(!k(e=D(e)?e.toNumber():e)||!O(e))throw new TypeError("The parameter k must be an integer number")}else e=0;for(var t=0function(e,t){return"number"!=typeof t||isFinite(t)&&!isNaN(t)?t:{mathjs:"number",value:String(t)}}),Pi=lm(287),ji=function(){return ji=Pi.create,Pi},r=a("typed",["?BigNumber","?Complex","?DenseMatrix","?Fraction"],function(e){var{BigNumber:r,Complex:n,DenseMatrix:t,Fraction:i}=e,e=ji();return e.types=[{name:"number",test:k},{name:"Complex",test:V},{name:"BigNumber",test:D},{name:"Fraction",test:R},{name:"Unit",test:Z},{name:"string",test:B},{name:"Chain",test:j},{name:"Array",test:x},{name:"Matrix",test:q},{name:"DenseMatrix",test:y},{name:"SparseMatrix",test:w},{name:"Range",test:l},{name:"Index",test:I},{name:"boolean",test:f},{name:"ResultSet",test:p},{name:"Help",test:m},{name:"function",test:h},{name:"Date",test:d},{name:"RegExp",test:g},{name:"null",test:N},{name:"undefined",test:M},{name:"AccessorNode",test:se},{name:"ArrayNode",test:T},{name:"AssignmentNode",test:E},{name:"BlockNode",test:S},{name:"ConditionalNode",test:A},{name:"ConstantNode",test:ue},{name:"FunctionNode",test:ce},{name:"FunctionAssignmentNode",test:C},{name:"IndexNode",test:z},{name:"Node",test:U},{name:"ObjectNode",test:F},{name:"OperatorNode",test:le},{name:"ParenthesisNode",test:P},{name:"RangeNode",test:_},{name:"SymbolNode",test:fe},{name:"Map",test:Le},{name:"Object",test:v}],e.conversions=[{from:"number",to:"BigNumber",convert:function(e){if(r||Li(e),1515 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new r(e)}},{from:"number",to:"Complex",convert:function(e){return n||Hi(e),new n(e,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(e){return n||Hi(e),new n(e.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(e){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(e){return n||Hi(e),new n(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){i||$i(e);var t=new i(e);if(t.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return t}},{from:"string",to:"number",convert:function(e){var t=Number(e);if(isNaN(t))throw new Error('Cannot convert "'+e+'" to a number');return t}},{from:"string",to:"BigNumber",convert:function(t){r||Li(t);try{return new r(t)}catch(e){throw new Error('Cannot convert "'+t+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(t){i||$i(t);try{return new i(t)}catch(e){throw new Error('Cannot convert "'+t+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(t){n||Hi(t);try{return new n(t)}catch(e){throw new Error('Cannot convert "'+t+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return r||Li(e),new r(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return i||$i(e),new i(+e)}},{from:"boolean",to:"string",convert:function(e){return String(e)}},{from:"Array",to:"Matrix",convert:function(e){if(!t)throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided");return new t(e)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}],e});function Li(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function Hi(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function $i(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var Gi="number",Vi="number, number";function Zi(e){return Math.abs(e)}function Wi(e,t){return e+t}function Yi(e,t){return e*t}function Ji(e){return-e}function Xi(e){return e}function Qi(e){return Y(e)}function Ki(e){return Math.ceil(e)}function ea(e){return e*e*e}function ta(e){return Math.exp(e)}function ra(e){return J(e)}function na(e,t){if(!O(e)||!O(t))throw new Error("Parameters in function gcd must be integer numbers");for(var r;0!==t;)r=e%t,e=t,t=r;return e<0?-e:e}function ia(e,t){if(!O(e)||!O(t))throw new Error("Parameters in function lcm must be integer numbers");if(0===e||0===t)return 0;for(var r,n=e*t;0!==t;)t=e%(r=t),e=r;return Math.abs(n/e)}function aa(e){return Math.log(e)}function oa(e){return $(e)}function sa(e){return H(e)}function ua(e,t){if(0{var{typed:e,config:t,BigNumber:r}=e;return e(da,{number:Xi,Complex:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":function(e){return ae(e,this,!0)},"boolean | string":function(e){return"BigNumber"===t.number?new r(+e):+e}})}),Vi=a("abs",["typed"],e=>{e=e.typed;return e("abs",{number:Zi,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},Fraction:function(e){return e.abs()},"Array | Matrix":function(e){return ae(e,this,!0)},Unit:function(e){return e.abs()}})}),ya=a("acos",["typed","config","Complex"],e=>{var{typed:e,config:t,Complex:r}=e;return e("acos",{number:function(e){return-1<=e&&e<=1||t.predictable?Math.acos(e):new r(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()},"Array | Matrix":function(e){return ae(e,this)}})}),ga="number";function va(e){return de(e)}function xa(e){return Math.atan(1/e)}function ba(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}function wa(e){return Math.asin(1/e)}function Na(e){e=1/e;return Math.log(e+Math.sqrt(e*e+1))}function Ma(e){return Math.acos(1/e)}function Ea(e){var e=1/e,t=Math.sqrt(e*e-1);return Math.log(t+e)}function Sa(e){return ye(e)}function Aa(e){return ge(e)}function Oa(e){return 1/Math.tan(e)}function Ca(e){e=Math.exp(2*e);return(e+1)/(e-1)}function _a(e){return 1/Math.sin(e)}function Ta(e){return 0===e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*L(e)}function Ba(e){return 1/Math.cos(e)}function qa(e){return 2/(Math.exp(e)+Math.exp(-e))}function Ia(e){return xe(e)}Ia.signature=qa.signature=Ba.signature=Ta.signature=_a.signature=Ca.signature=Oa.signature=Aa.signature=Sa.signature=Ea.signature=Ma.signature=Na.signature=wa.signature=ba.signature=xa.signature=va.signature=ga;var ga=a("acot",["typed","BigNumber"],e=>{var{typed:e,BigNumber:t}=e;return e("acot",{number:xa,Complex:function(e){return e.acot()},BigNumber:function(e){return new t(1).div(e).atan()},"Array | Matrix":function(e){return ae(e,this)}})}),za=a("acsc",["typed","config","Complex","BigNumber"],e=>{var{typed:e,config:t,Complex:r,BigNumber:n}=e;return e("acsc",{number:function(e){return e<=-1||1<=e||t.predictable?wa(e):new r(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new n(1).div(e).asin()},"Array | Matrix":function(e){return ae(e,this)}})}),ka="addScalar",Da=a(ka,["typed"],e=>{e=e.typed;return e(ka,{"number, number":Wi,"Complex, Complex":function(e,t){return e.add(t)},"BigNumber, BigNumber":function(e,t){return e.plus(t)},"Fraction, Fraction":function(e,t){return e.add(t)},"Unit, Unit":function(e,t){if(null===e.value||void 0===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value||void 0===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");e=e.clone();return e.value=this(e.value,t.value),e.fixPrefix=!1,e}})}),Ra=a("arg",["typed"],e=>{e=e.typed;return e("arg",{number:function(e){return Math.atan2(0,e)},BigNumber:function(e){return e.constructor.atan2(0,e)},Complex:function(e){return e.arg()},"Array | Matrix":function(e){return ae(e,this)}})}),Ua=a("asech",["typed","config","Complex","BigNumber"],e=>{var{typed:e,config:n,Complex:i,BigNumber:t}=e;return e("asech",{number:function(e){if(e<=1&&-1<=e||n.predictable){var t=1/e;if(0{e=e.typed;return e("asinh",{number:Sa,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()},"Array | Matrix":function(e){return ae(e,this,!0)}})}),Pa=a("atan",["typed"],e=>{e=e.typed;return e("atan",{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()},"Array | Matrix":function(e){return ae(e,this,!0)}})}),ja=a("atanh",["typed","config","Complex"],e=>{var{typed:e,config:t,Complex:r}=e;return e("atanh",{number:function(e){return e<=1&&-1<=e||t.predictable?Aa(e):new r(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()},"Array | Matrix":function(e){return ae(e,this,!0)}})}),La=a("bignumber",["typed","BigNumber"],e=>{var{typed:e,BigNumber:i}=e;return e("bignumber",{"":function(){return new i(0)},number:function(e){return new i(e+"")},string:function(e){var t=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(t){var r=t[2],t=i(t[1]),n=new i(2).pow(Number(r));if(t.gt(n.sub(1)))throw new SyntaxError('String "'.concat(e,'" is out of range'));r=new i(2).pow(Number(r)-1);return t.gte(r)?t.sub(n):t}return new i(e)},BigNumber:function(e){return e},Fraction:function(e){return new i(e.n).div(e.d).times(e.s)},null:function(e){return new i(0)},"Array | Matrix":function(e){return ae(e,this)}})});function Ha(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitAnd");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero()||t.eq(-1)||e.eq(t))return e;if(t.isZero()||e.eq(-1))return t;if(!e.isFinite()||!t.isFinite()){if(!e.isFinite()&&!t.isFinite())return e.isNegative()===t.isNegative()?e:new r(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new r(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new r(0):e}return Va(e,t,function(e,t){return e&t})}function $a(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var t=e.constructor,r=t.precision,e=(t.config({precision:1e9}),e.plus(new t(1)));return e.s=-e.s||null,t.config({precision:r}),e}function Ga(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitOr");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);r=new r(-1);return e.isZero()||t.eq(r)||e.eq(t)?t:t.isZero()||e.eq(r)?e:e.isFinite()&&t.isFinite()?Va(e,t,function(e,t){return e|t}):!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?r:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e}function Va(e,t,l){var r,n,i=e.constructor,f=+(e.s<0),p=+(t.s<0);if(f)for(var a=Za($a(e)),m=0;me)for(o-=e;o--;)s+="0";else o>1,u[c]&=1)}return u.reverse()}function Wa(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new r(0);var n=new r(-1);return e.eq(n)?$a(t):t.eq(n)?$a(e):e.isFinite()&&t.isFinite()?Va(e,t,function(e,t){return e^t}):e.isFinite()||t.isFinite()?new r(e.isNegative()===t.isNegative()?1/0:-1/0):n}function Ya(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:e.isFinite()||t.isFinite()?t.lt(55)?e.times(Math.pow(2,t.toNumber())+""):e.times(new r(2).pow(t)):new r(NaN)}function Ja(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:t.isFinite()?(t.lt(55)?e.div(Math.pow(2,t.toNumber())+""):e.div(new r(2).pow(t))).floor():e.isNegative()?new r(-1):e.isFinite()?new r(0):new r(NaN)}var Xa="number, number";function Qa(e,t){if(!O(e)||!O(t))throw new Error("Integers expected in function bitAnd");return e&t}function Ka(e){if(!O(e))throw new Error("Integer expected in function bitNot");return~e}function eo(e,t){if(!O(e)||!O(t))throw new Error("Integers expected in function bitOr");return e|t}function to(e,t){if(!O(e)||!O(t))throw new Error("Integers expected in function bitXor");return e^t}function ro(e,t){if(!O(e)||!O(t))throw new Error("Integers expected in function leftShift");return e<>t}function io(e,t){if(!O(e)||!O(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}Qa.signature=Xa,Ka.signature="number",io.signature=no.signature=ro.signature=to.signature=eo.signature=Xa;var Xa=a("bitNot",["typed"],e=>{e=e.typed;return e("bitNot",{number:Ka,BigNumber:$a,"Array | Matrix":function(e){return ae(e,this)}})}),ao="boolean",oo=a(ao,["typed"],e=>{e=e.typed;return e(ao,{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(e){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;t=Number(e);if(""!==e&&!isNaN(t))return!!t;throw new Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":function(e){return ae(e,this)}})}),so=a("clone",["typed"],e=>{e=e.typed;return e("clone",{any:X})});function uo(e,t){if(t>1;return uo(e,r)*uo(1+r,t)}function co(e,t){if(!O(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!O(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(e{e=e.typed;return e(lo,{"number, number":co,"BigNumber, BigNumber":function(e,t){var r,n,i=e.constructor,a=e.minus(t),o=new i(1);if(!po(e)||!po(t))throw new TypeError("Positive integer value expected in function combinations");if(t.gt(e))throw new TypeError("k must be less than n in function combinations");if(r=o,t.lt(a))for(n=o;n.lte(a);n=n.plus(o))r=r.times(t.plus(n)).dividedBy(n);else for(n=o;n.lte(t);n=n.plus(o))r=r.times(a.plus(n)).dividedBy(n);return r}})});function po(e){return e.isInteger()&&e.gte(0)}var mo=a("complex",["typed","Complex"],e=>{var{typed:e,Complex:r}=e;return e("complex",{"":function(){return r.ZERO},number:function(e){return new r(e,0)},"number, number":function(e,t){return new r(e,t)},"BigNumber, BigNumber":function(e,t){return new r(e.toNumber(),t.toNumber())},Fraction:function(e){return new r(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return r(e)},null:function(e){return r(0)},Object:function(e){if("re"in e&&"im"in e)return new r(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new r(e);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(e){return ae(e,this)}})}),ho=a("conj",["typed"],e=>{e=e.typed;return e("conj",{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.conjugate()},"Array | Matrix":function(e){return ae(e,this)}})}),yo=a("cosh",["typed"],e=>{e=e.typed;return e("cosh",{number:ve,Complex:function(e){return e.cosh()},BigNumber:function(e){return e.cosh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(e.value)},"Array | Matrix":function(e){return ae(e,this)}})}),go=a("coth",["typed","BigNumber"],e=>{var{typed:e,BigNumber:t}=e;return e("coth",{number:Ca,Complex:function(e){return e.coth()},BigNumber:function(e){return new t(1).div(e.tanh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(e.value)},"Array | Matrix":function(e){return ae(e,this)}})}),vo=a("csc",["typed","BigNumber"],e=>{var{typed:e,BigNumber:t}=e;return e("csc",{number:_a,Complex:function(e){return e.csc()},BigNumber:function(e){return new t(1).div(e.sin())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(e.value)},"Array | Matrix":function(e){return ae(e,this)}})}),xo=a("cube",["typed"],e=>{e=e.typed;return e("cube",{number:ea,Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},Fraction:function(e){return e.pow(3)},"Array | Matrix":function(e){return ae(e,this,!0)},Unit:function(e){return e.pow(3)}})});function bo(e,t,r){return null==r?e.eq(t):!!e.eq(t)||!e.isNaN()&&!t.isNaN()&&(!(!e.isFinite()||!t.isFinite())&&(!!(n=e.minus(t).abs()).isZero()||(e=e.constructor.max(e.abs(),t.abs()),n.lte(e.times(r)))));var n}var wo="equalScalar",No=a(wo,["typed","config"],e=>{var{typed:e,config:n}=e;return e(wo,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return he(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||bo(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return e.equals(t)},"Complex, Complex":function(e,t){return e=e,t=t,r=n.epsilon,he(e.re,t.re,r)&&he(e.im,t.im,r);var r},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)}})}),Mo=(a(wo,["typed","config"],e=>{var{typed:e,config:r}=e;return e(wo,{"number, number":function(e,t){return he(e,t,r.epsilon)}})}),a("erf",["typed"],e=>{e=e.typed;return e("name",{number:function(e){var t=Math.abs(e);return Co<=t?L(e):t<=Eo?L(e)*function(e){var t,r=e*e,n=Ao[0][4]*r,i=r;for(t=0;t<3;t+=1)n=(n+Ao[0][t])*r,i=(i+Oo[0][t])*r;return e*(n+Ao[0][3])/(i+Oo[0][3])}(t):t<=4?L(e)*(1-function(e){var t,r=Ao[1][8]*e,n=e;for(t=0;t<7;t+=1)r=(r+Ao[1][t])*e,n=(n+Oo[1][t])*e;var i=(r+Ao[1][7])/(n+Oo[1][7]),a=parseInt(16*e)/16,o=(e-a)*(e+a);return Math.exp(-a*a)*Math.exp(-o)*i}(t)):L(e)*(1-function(e){var t,r=1/(e*e),n=Ao[2][5]*r,i=r;for(t=0;t<4;t+=1)n=(n+Ao[2][t])*r,i=(i+Oo[2][t])*r;var a=r*(n+Ao[2][4])/(i+Oo[2][4]),e=(a=(So-a)/e,r=parseInt(16*e)/16,(e-r)*(e+r));return Math.exp(-r*r)*Math.exp(-e)*a}(t))},"Array | Matrix":function(e){return ae(e,this)}})})),Eo=.46875,So=.5641895835477563,Ao=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],Oo=[[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,.5279051029514285,.06051834131244132,.0023352049762686918]],Co=Math.pow(2,53),_o=a("exp",["typed"],e=>{e=e.typed;return e("exp",{number:ta,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()},"Array | Matrix":function(e){return ae(e,this)}})}),To=a("expm1",["typed","Complex"],e=>{var{typed:e,Complex:r}=e;return e("expm1",{number:ra,Complex:function(e){var t=Math.exp(e.re);return new r(t*Math.cos(e.im)-1,t*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)},"Array | Matrix":function(e){return ae(e,this)}})}),Bo=a("filter",["typed"],e=>{e=e.typed;return e("filter",{"Array, function":qo,"Matrix, function":function(e,t){return e.create(qo(e.toArray(),t))},"Array, RegExp":ot,"Matrix, RegExp":function(e,t){return e.create(ot(e.toArray(),t))}})});function qo(e,n){var i=dr(n);return at(e,function(e,t,r){return 1===i?n(e):2===i?n(e,[t]):n(e,[t],r)})}var Io="forEach",zo=a(Io,["typed"],e=>{e=e.typed;return e(Io,{"Array, function":ko,"Matrix, function":function(e,t){return e.forEach(t)}})});function ko(t,i){var a=dr(i);(function r(e,n){Array.isArray(e)?it(e,function(e,t){r(e,n.concat(t))}):1===a?i(e):2===a?i(e,n):i(e,n,t)})(t,[])}var Do=a("format",["typed"],e=>{e=e.typed;return e("format",{any:Ee,"any, Object | function | number":Ee})}),Ro="getMatrixDataType",Uo=a(Ro,["typed"],e=>{e=e.typed;return e(Ro,{Array:function(e){return lt(e,W)},Matrix:function(e){return e.getDataType()}})}),Fo=a("hex",["typed","format"],e=>{var{typed:e,format:r}=e;return e("hex",{"number | BigNumber":function(e){return r(e,{notation:"hex"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"hex",wordSize:t})}})}),Po=a("im",["typed"],e=>{e=e.typed;return e("im",{number:function(e){return 0},BigNumber:function(e){return e.mul(0)},Fraction:function(e){return e.mul(0)},Complex:function(e){return e.im},"Array | Matrix":function(e){return ae(e,this)}})}),jo="isInteger",Lo=a(jo,["typed"],e=>{e=e.typed;return e(jo,{number:O,BigNumber:function(e){return e.isInt()},Fraction:function(e){return 1===e.d&&isFinite(e.n)},"Array | Matrix":function(e){return ae(e,this)}})}),Ho="number";function $o(e){return e<0}function Go(e){return 0{e=e.typed;return e(Wo,{number:$o,BigNumber:function(e){return e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s<0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return ae(e,this)}})}),Yo="isPositive",Jo=a(Yo,["typed"],e=>{e=e.typed;return e(Yo,{number:Go,BigNumber:function(e){return!e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return 0{e=e.typed;return e("isZero",{number:Vo,BigNumber:function(e){return e.isZero()},Complex:function(e){return 0===e.re&&0===e.im},Fraction:function(e){return 1===e.d&&0===e.n},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return ae(e,this)}})}),Qo=a("log10",["typed","config","Complex"],e=>{var{typed:e,config:t,Complex:r}=e;return e("log10",{number:function(e){return 0<=e||t.predictable?oa(e):new r(e,0).log().div(Math.LN10)},Complex:function(e){return new r(e).log().div(Math.LN10)},BigNumber:function(e){return!e.isNegative()||t.predictable?e.log():new r(e.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(e){return ae(e,this)}})}),Ko=a("log2",["typed","config","Complex"],e=>{var{typed:e,config:t,Complex:r}=e;return e("log2",{number:function(e){return 0<=e||t.predictable?sa(e):n(new r(e,0))},Complex:n,BigNumber:function(e){return!e.isNegative()||t.predictable?e.log(2):n(new r(e.toNumber(),0))},"Array | Matrix":function(e){return ae(e,this)}});function n(e){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new r(Math.log2?Math.log2(t):Math.log(t)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}}),es=a("map",["typed"],e=>{e=e.typed;return e("map",{"Array, function":ts,"Matrix, function":function(e,t){return e.map(t)}})});function ts(t,i){var a=dr(i);return function r(e,n){return Array.isArray(e)?e.map(function(e,t){return r(e,n.concat(t))}):1===a?i(e):2===a?i(e,n):i(e,n,t)}(t,[])}var rs=a("multiplyScalar",["typed"],e=>{e=e.typed;return e("multiplyScalar",{"number, number":Yi,"Complex, Complex":function(e,t){return e.mul(t)},"BigNumber, BigNumber":function(e,t){return e.times(t)},"Fraction, Fraction":function(e,t){return e.mul(t)},"number | Fraction | BigNumber | Complex, Unit":function(e,t){t=t.clone();return t.value=null===t.value?t._normalize(e):this(t.value,e),t},"Unit, number | Fraction | BigNumber | Complex":function(e,t){e=e.clone();return e.value=null===e.value?e._normalize(t):this(e.value,t),e},"Unit, Unit":function(e,t){return e.multiply(t)}})}),ns="number, number";function is(e){return!e}function as(e,t){return!(!e&&!t)}function os(e,t){return!!e!=!!t}function ss(e,t){return!(!e||!t)}is.signature="number",ss.signature=os.signature=as.signature=ns;ns=a("not",["typed"],e=>{e=e.typed;return e("not",{number:is,Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},Unit:function(e){return null===e.value||this(e.value)},"Array | Matrix":function(e){return ae(e,this)}})});var us=a("number",["typed"],e=>{e=e.typed,e=e("number",{"":function(){return 0},number:function(e){return e},string:function(e){if("NaN"===e)return NaN;var t=(n=(t=e).match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/))?{input:t,radix:{"0b":2,"0o":8,"0x":16}[n[1]],integerPart:n[2],fractionalPart:n[3]}:null;if(t){for(var r=t,n=parseInt(r.integerPart,r.radix),i=0,a=0;a{var{typed:e,format:r}=e;return e("oct",{"number | BigNumber":function(e){return r(e,{notation:"oct"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"oct",wordSize:t})}})}),ls=lm(377),fs=ls(Date.now());function ps(e){var t;return t=null===(e=e)?fs:ls(String(e)),function(){return t()}}var ms="pickRandom",hs=a(ms,["typed","config","?on"],e=>{var{typed:e,config:t,on:r}=e,d=ps(t.randomSeed);return r&&r("config",function(e,t){e.randomSeed!==t.randomSeed&&(d=ps(e.randomSeed))}),e(ms,{"Array | Matrix":function(e){return n(e,{})},"Array | Matrix, Object":n,"Array | Matrix, number":function(e,t){return n(e,{number:t})},"Array | Matrix, Array | Matrix":function(e,t){return n(e,{weights:t})},"Array | Matrix, Array | Matrix, number":function(e,t,r){return n(e,{number:r,weights:t})},"Array | Matrix, number, Array | Matrix":function(e,t,r){return n(e,{number:t,weights:r})}});function n(e,t){var{number:r,weights:n,elementWise:t=!0}=t,i=void 0===r,a=(i&&(r=1),q(e)?e.create:q(n)?n.create:null),l=(e=e.valueOf(),n=n&&n.valueOf(),!0===t&&(e=rt(e),n=rt(n)),0);if(void 0!==n){if(n.length!==e.length)throw new Error("Weights must have the same length as possibles");for(var o=0,f=n.length;o{e=e.typed;return e("print",{"string, Object | Array":ys,"string, Object | Array, number | Object":ys})});function ys(e,a,o){return e.replace(/\$([\w.]+)/g,function(e,t){for(var r=t.split("."),n=a[r.shift()];r.length&&void 0!==n;)var i=r.shift(),n=i?n[i]:n+".";return void 0!==n?B(n)?n:Ee(n,o):e})}function gs(e,t){var r=[];if(1<(e=e.slice(0)).length)for(var n=0,i=e.shift();n{var{typed:e,config:t,on:r}=e,n=ps(t.randomSeed);return r&&r("config",function(e,t){e.randomSeed!==t.randomSeed&&(n=ps(e.randomSeed))}),e(vs,{"":()=>a(0,1),number:e=>a(0,e),"number, number":(e,t)=>a(e,t),"Array | Matrix":e=>i(e,0,1),"Array | Matrix, number":(e,t)=>i(e,0,t),"Array | Matrix, number, number":(e,t,r)=>i(e,t,r)});function i(e,t,r){var n=gs(e.valueOf(),()=>a(t,r));return q(e)?e.create(n):n}function a(e,t){return e+n()*(t-e)}}),bs=a("re",["typed"],e=>{e=e.typed;return e("re",{number:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Complex:function(e){return e.re},"Array | Matrix":function(e){return ae(e,this)}})}),ws=a("sec",["typed","BigNumber"],e=>{var{typed:e,BigNumber:t}=e;return e("sec",{number:Ba,Complex:function(e){return e.sec()},BigNumber:function(e){return new t(1).div(e.cos())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return this(e.value)},"Array | Matrix":function(e){return ae(e,this)}})}),Ns=a("sign",["typed","BigNumber","Fraction","complex"],e=>{var{typed:e,BigNumber:t,complex:r,Fraction:n}=e;return e("sign",{number:la,Complex:function(e){return 0===e.im?r(la(e.re)):e.sign()},BigNumber:function(e){return new t(e.cmp(0))},Fraction:function(e){return new n(e.s,1)},"Array | Matrix":function(e){return ae(e,this,!0)},Unit:function(e){return this(e.value)}})}),Ms=a("sin",["typed"],e=>{e=e.typed;return e("sin",{number:Math.sin,Complex:function(e){return e.sin()},BigNumber:function(e){return e.sin()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(e.value)},"Array | Matrix":function(e){return ae(e,this,!0)}})}),Es=a("SparseMatrix",["typed","equalScalar","Matrix"],e=>{var{typed:C,equalScalar:_,Matrix:e}=e;function T(e,t){if(!(this instanceof T))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!B(t))throw new Error("Invalid datatype: "+t);if(q(e))r=this,i=t,"SparseMatrix"===(n=e).type?(r._values=n._values?X(n._values):void 0,r._index=X(n._index),r._ptr=X(n._ptr),r._size=X(n._size),r._datatype=i||n._datatype):a(r,n.valueOf(),i||n._datatype);else if(e&&x(e.index)&&x(e.ptr)&&x(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=t||e.datatype;else if(x(e))a(this,e,t);else{if(e)throw new TypeError("Unsupported type of data ("+W(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=t}var r,n,i}function a(e,t,r){e._values=[],e._index=[],e._ptr=[],e._datatype=r;var n=t.length,i=0,a=_,o=0;if(B(r)&&(a=C.find(_,[r,r])||_,o=C.convert(0,r)),0");1===u.length?i.dimension(0).forEach(function(e,t){Ye(e),a.set([e,0],o[t[0]],A)}):(t=i.dimension(0),O=i.dimension(1),t.forEach(function(r,n){Ye(r),O.forEach(function(e,t){Ye(e),a.set([r,e],o[n[0]][t[0]],A)})}))}return a;default:throw new SyntaxError("Wrong number of arguments")}},T.prototype.get=function(e){if(!x(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new Ge(e.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var t=e[0],e=e[1],r=(Ye(t,this._size[0]),Ye(e,this._size[1]),g(t,this._ptr[e],this._ptr[e+1],this._index));return rArray.isArray(e)&&1===e.length?e[0]:e);if(2!==n.length)throw new Error("Only two dimensions matrix are supported");return n.forEach(function(e){if(!k(e)||!O(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Ee(n)+")")}),l(r?this.clone():this,n[0],n[1],t)},T.prototype.reshape=function(t,l){if(!x(t))throw new TypeError("Array expected");if(2!==t.length)throw new Error("Sparse matrices can only be reshaped in two dimensions");t.forEach(function(e){if(!k(e)||!O(e)||e<=-2||0===e)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Ee(t)+")")});var f=this._size[0]*this._size[1];if(f!=(t=Qe(t,f))[0]*t[1])throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var e=l?this.clone():this;if(this._size[0]===t[0]&&this._size[1]===t[1])return e;for(var r=[],n=0;n "+(this._values?Ee(this._values[u],e):"X");return i},T.prototype.toString=function(){return Ee(this.toArray())},T.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},T.prototype.diagonal=function(e){if(e){if(!k(e=D(e)?e.toNumber():e)||!O(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var t=0{e=e.typed;return e(Ss,{"Unit, Array":function(e,t){return e.splitUnit(t)}})}),Os=a("square",["typed"],e=>{e=e.typed;return e("square",{number:fa,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},Fraction:function(e){return e.mul(e)},"Array | Matrix":function(e){return ae(e,this,!0)},Unit:function(e){return e.pow(2)}})}),Cs=a("string",["typed"],e=>{e=e.typed;return e("string",{"":function(){return""},number:K,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":function(e){return ae(e,this)},any:function(e){return String(e)}})}),_s=a("tan",["typed"],e=>{e=e.typed;return e("tan",{number:Math.tan,Complex:function(e){return e.tan()},BigNumber:function(e){return e.tan()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(e.value)},"Array | Matrix":function(e){return ae(e,this,!0)}})}),Ts=a("typeOf",["typed"],e=>{e=e.typed;return e("typeOf",{any:W})}),Bs=a("acosh",["typed","config","Complex"],e=>{var{typed:e,config:t,Complex:r}=e;return e("acosh",{number:function(e){return 1<=e||t.predictable?va(e):e<=-1?new r(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new r(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()},"Array | Matrix":function(e){return ae(e,this)}})}),qs=a("acsch",["typed","BigNumber"],e=>{var{typed:e,BigNumber:t}=e;return e("acsch",{number:Na,Complex:function(e){return e.acsch()},BigNumber:function(e){return new t(1).div(e).asinh()},"Array | Matrix":function(e){return ae(e,this)}})}),Is=a("asec",["typed","config","Complex","BigNumber"],e=>{var{typed:e,config:t,Complex:r,BigNumber:n}=e;return e("asec",{number:function(e){return e<=-1||1<=e||t.predictable?Ma(e):new r(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new n(1).div(e).acos()},"Array | Matrix":function(e){return ae(e,this)}})}),zs=a("bin",["typed","format"],e=>{var{typed:e,format:r}=e;return e("bin",{"number | BigNumber":function(e){return r(e,{notation:"bin"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"bin",wordSize:t})}})}),ks="combinationsWithRep",Ds=a(ks,["typed"],e=>{e=e.typed;return e(ks,{"number, number":function(e,t){if(!O(e)||e<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!O(t)||t<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e<1)throw new TypeError("k must be less than or equal to n + k - 1");return t{e=e.typed;return e("cos",{number:Math.cos,Complex:function(e){return e.cos()},BigNumber:function(e){return e.cos()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return this(e.value)},"Array | Matrix":function(e){return ae(e,this)}})}),Fs=a("csch",["typed","BigNumber"],e=>{var{typed:e,BigNumber:t}=e;return e("csch",{number:Ta,Complex:function(e){return e.csch()},BigNumber:function(e){return new t(1).div(e.sinh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(e.value)},"Array | Matrix":function(e){return ae(e,this)}})}),Ps=a("isNaN",["typed"],e=>{e=e.typed;return e("isNaN",{number:Zo,BigNumber:function(e){return e.isNaN()},Fraction:function(e){return!1},Complex:function(e){return e.isNaN()},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":function(e){return ae(e,Number.isNaN)}})}),js="isPrime",Ls=a(js,["typed"],e=>{e=e.typed;return e(js,{number:function(e){if(0*e!=0)return!1;if(e<=3)return 1e{var{typed:e,config:t,on:r}=e,n=ps(t.randomSeed);return r&&r("config",function(e,t){e.randomSeed!==t.randomSeed&&(n=ps(e.randomSeed))}),e(Hs,{"":()=>a(0,1),number:e=>a(0,e),"number, number":(e,t)=>a(e,t),"Array | Matrix":e=>i(e,0,1),"Array | Matrix, number":(e,t)=>i(e,0,t),"Array | Matrix, number, number":(e,t,r)=>i(e,t,r)});function i(e,t,r){var n=gs(e.valueOf(),()=>a(t,r));return q(e)?e.create(n):n}function a(e,t){return Math.floor(e+n()*(t-e))}}),Gs=a("sech",["typed","BigNumber"],e=>{var{typed:e,BigNumber:t}=e;return e("sech",{number:qa,Complex:function(e){return e.sech()},BigNumber:function(e){return new t(1).div(e.cosh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return this(e.value)},"Array | Matrix":function(e){return ae(e,this)}})}),Vs=a("sinh",["typed"],e=>{e=e.typed;return e("sinh",{number:Ia,Complex:function(e){return e.sinh()},BigNumber:function(e){return e.sinh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(e.value)},"Array | Matrix":function(e){return ae(e,this,!0)}})}),Zs=a("sparse",["typed","SparseMatrix"],e=>{var{typed:e,SparseMatrix:r}=e;return e("sparse",{"":function(){return new r([])},string:function(e){return new r([],e)},"Array | Matrix":function(e){return new r(e)},"Array | Matrix, string":function(e,t){return new r(e,t)}})}),Ws=a("sqrt",["config","typed","Complex"],e=>{var{config:t,typed:e,Complex:r}=e;return e("sqrt",{number:n,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.sqrt():n(e.toNumber())},"Array | Matrix":function(e){return ae(e,this,!0)},Unit:function(e){return e.pow(.5)}});function n(e){return isNaN(e)?NaN:0<=e||t.predictable?Math.sqrt(e):new r(e,0).sqrt()}}),Ys=a("tanh",["typed"],e=>{e=e.typed;return e("tanh",{number:be,Complex:function(e){return e.tanh()},BigNumber:function(e){return e.tanh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(e.value)},"Array | Matrix":function(e){return ae(e,this,!0)}})}),Js="unaryMinus",Xs=a(Js,["typed"],e=>{e=e.typed;return e(Js,{number:Ji,Complex:function(e){return e.neg()},BigNumber:function(e){return e.neg()},Fraction:function(e){return e.neg()},Unit:function(e){var t=e.clone();return t.value=this(e.value),t},"Array | Matrix":function(e){return ae(e,this,!0)}})}),Qs=a("acoth",["typed","config","Complex","BigNumber"],e=>{var{typed:e,config:t,Complex:r,BigNumber:n}=e;return e("acoth",{number:function(e){return 1<=e||e<=-1||t.predictable?ba(e):new r(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new n(1).div(e).atanh()},"Array | Matrix":function(e){return ae(e,this)}})}),Ks=a("cot",["typed","BigNumber"],e=>{var{typed:e,BigNumber:t}=e;return e("cot",{number:Oa,Complex:function(e){return e.cot()},BigNumber:function(e){return new t(1).div(e.tan())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(e.value)},"Array | Matrix":function(e){return ae(e,this)}})}),eu=a("fraction",["typed","Fraction"],e=>{var{typed:e,Fraction:r}=e;return e("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw new Error(e+" cannot be represented as a fraction");return new r(e)},string:function(e){return new r(e)},"number, number":function(e,t){return new r(e,t)},null:function(e){return new r(0)},BigNumber:function(e){return new r(e.toString())},Fraction:function(e){return e},Object:function(e){return new r(e)},"Array | Matrix":function(e){return ae(e,this)}})}),tu="isNumeric",ru=a(tu,["typed"],e=>{e=e.typed;return e(tu,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(e){return ae(e,this)}})}),n=a("matrix",["typed","Matrix","DenseMatrix","SparseMatrix"],e=>{var{typed:e,DenseMatrix:n,SparseMatrix:i}=e;return e("matrix",{"":function(){return r([])},string:function(e){return r([],e)},"string, string":function(e,t){return r([],e,t)},Array:function(e){return r(e)},Matrix:function(e){return r(e,e.storage())},"Array | Matrix, string":r,"Array | Matrix, string, string":r});function r(e,t,r){if("dense"===t||"default"===t||void 0===t)return new n(e,r);if("sparse"===t)return new i(e,r);throw new TypeError("Unknown matrix type "+JSON.stringify(t)+".")}}),nu="matrixFromFunction",iu=a(nu,["typed","matrix","isZero"],e=>{var{typed:e,matrix:a,isZero:o}=e;return e(nu,{"Array | Matrix, function, string, string":i,"Array | Matrix, function, string":function(e,t,r){return i(e,t,r)},"Matrix, function":function(e,t){return i(e,t,"dense")},"Array, function":function(e,t){return i(e,t,"dense").toArray()},"Array | Matrix, string, function":function(e,t,r){return i(e,r,t)},"Array | Matrix, string, string, function":function(e,t,r,n){return i(e,n,t,r)}});function i(e,n,t,r){var i=void 0!==r?a(t,r):a(t);return i.resize(e),i.forEach(function(e,t){var r=n(t);o(r)||i.set(t,r)}),i}}),au=a("algorithm02",["typed","equalScalar"],e=>{var{typed:S,equalScalar:A}=e;return function(e,t,l,f){var p=e._data,r=e._size,e=e._datatype,n=t._values,m=t._index,h=t._ptr,i=t._size,d=t._datatype;if(r.length!==i.length)throw new Ge(r.length,i.length);if(r[0]!==i[0]||r[1]!==i[1])throw new RangeError("Dimension mismatch. Matrix A ("+r+") must match Matrix B ("+i+")");if(!n)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");for(var a,i=r[0],o=r[1],y=A,g=0,v=l,x=("string"==typeof e&&e===d&&(y=S.find(A,[a=e,a]),g=S.convert(0,a),v=S.find(l,[a,a])),[]),s=[],b=[],u=0;u{var O=e["typed"];return function(e,t,l,f){var r=e._data,n=e._size,p=e._datatype,m=t._values,h=t._index,d=t._ptr,i=t._size,t=t._datatype;if(n.length!==i.length)throw new Ge(n.length,i.length);if(n[0]!==i[0]||n[1]!==i[1])throw new RangeError("Dimension mismatch. Matrix A ("+n+") must match Matrix B ("+i+")");if(!m)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");for(var a,y=n[0],g=n[1],v=0,o=l,x=("string"==typeof p&&p===t&&(v=O.convert(0,a=p),o=O.find(l,[a,a])),[]),b=0;b{var{typed:B,equalScalar:q}=e;return function(e,t,l){var f=e._values,p=e._index,m=e._ptr,r=e._size,h=e._datatype,d=t._values,y=t._index,g=t._ptr,n=t._size,t=t._datatype;if(r.length!==n.length)throw new Ge(r.length,n.length);if(r[0]!==n[0]||r[1]!==n[1])throw new RangeError("Dimension mismatch. Matrix A ("+r+") must match Matrix B ("+n+")");for(var i,n=r[0],v=r[1],x=q,b=0,w=l,N=("string"==typeof h&&h===t&&(x=B.find(q,[i=h,i]),b=B.convert(0,i),w=B.find(l,[i,i])),f&&d?[]:void 0),a=[],M=[],E=N?[]:void 0,S=N?[]:void 0,A=[],O=[],o=0;o{var{typed:E,equalScalar:S}=e;return function(e,t,l,f){var r=e._values,p=e._index,m=e._ptr,h=e._size,d=e._datatype;if(!r)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");for(var n,y=h[0],i=h[1],g=S,v=0,a=l,x=("string"==typeof d&&(g=E.find(S,[n=d,n]),v=E.convert(0,n),t=E.convert(t,n),a=E.find(l,[n,n])),[]),o=[],s=[],u=0;u{var{typed:N,DenseMatrix:M}=e;return function(e,t,r,l){var f=e._values,p=e._index,m=e._ptr,h=e._size,e=e._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");for(var n,d=h[0],y=h[1],i=r,a=("string"==typeof e&&(t=N.convert(t,n=e),i=N.find(r,[n,n])),[]),o=[],g=[],s=0;s{var p=e["typed"];return function(e,t,r){var l=e._data,n=e._size,i=e._datatype,f=t._data,a=t._size,t=t._datatype,o=[];if(n.length!==a.length)throw new Ge(n.length,a.length);for(var s,u=0;u{var c=e["typed"];return function(e,t,r,n){var i,a=e._data,o=e._size,s=e._datatype,u=r,s=("string"==typeof s&&(t=c.convert(t,i=s),u=c.find(r,[i,i])),0{var{typed:e,matrix:r,equalScalar:t,DenseMatrix:n}=e,i=au({typed:e,equalScalar:t}),a=ou({typed:e}),o=su({typed:e,equalScalar:t}),s=uu({typed:e,equalScalar:t}),u=cu({typed:e,DenseMatrix:n}),l=lu({typed:e}),c=fu({typed:e});return e("mod",{"number, number":ua,"BigNumber, BigNumber":function(e,t){if(t.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return t.isZero()?e:e.mod(t)},"Fraction, Fraction":function(e,t){if(t.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return(0<=e.compare(0)?e:e.mod(t).add(t)).mod(t)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return u(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})}),mu=a("algorithm01",["typed"],e=>{var M=e["typed"];return function(e,t,l,f){var r=e._data,n=e._size,i=e._datatype,p=t._values,m=t._index,h=t._ptr,a=t._size,t=t._datatype;if(n.length!==a.length)throw new Ge(n.length,a.length);if(n[0]!==a[0]||n[1]!==a[1])throw new RangeError("Dimension mismatch. Matrix A ("+n+") must match Matrix B ("+a+")");if(!p)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");for(var d=n[0],y=n[1],a="string"==typeof i&&i===t?i:void 0,g=a?M.find(l,[a,a]):l,o=[],s=0;s{var{typed:A,equalScalar:O}=e;return function(e,t,l){var f=e._values,r=e._size,p=e._datatype,m=t._values,n=t._size,h=t._datatype;if(r.length!==n.length)throw new Ge(r.length,n.length);if(r[0]!==n[0]||r[1]!==n[1])throw new RangeError("Dimension mismatch. Matrix A ("+r+") must match Matrix B ("+n+")");for(var i,n=r[0],d=r[1],y=O,g=0,v=l,x=("string"==typeof p&&p===h&&(y=A.find(O,[i=p,i]),g=A.convert(0,i),v=A.find(l,[i,i])),f&&m?[]:void 0),a=[],o=[],s=x?[]:void 0,b=[],u=[],c=0;c{var{typed:e,matrix:r,equalScalar:t,BigNumber:s}=e,n=mu({typed:e}),i=au({typed:e,equalScalar:t}),l=hu({typed:e,equalScalar:t}),a=uu({typed:e,equalScalar:t}),f=lu({typed:e}),o=fu({typed:e}),u="Complex number not supported in function nthRoot. Use nthRoots instead.";return e(du,{number:function(e){return ca(e,2)},"number, number":ca,BigNumber:function(e){return c(e,new s(2))},Complex:function(e){throw new Error(u)},"Complex, number":function(e,t){throw new Error(u)},"BigNumber, BigNumber":c,"Array | Matrix":function(e){return this(e,2)},"SparseMatrix, SparseMatrix":function(e,t){if(1===t.density())return l(e,t,this);throw new Error("Root must be non-zero")},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){if(1===t.density())return n(e,t,this,!1);throw new Error("Root must be non-zero")},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return a(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){if(1===t.density())return a(t,e,this,!0);throw new Error("Root must be non-zero")},"number | BigNumber, DenseMatrix":function(e,t){return o(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}});function c(e,t){var r=s.precision,n=s.clone({precision:r+2}),i=new s(0),a=new n(1),o=t.isNegative();if((t=o?t.neg():t).isZero())throw new Error("Root must be non-zero");if(e.isNegative()&&!t.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(e.isZero())return o?new n(1/0):0;if(!e.isFinite())return o?i:e;n=e.abs().pow(a.div(t)),n=e.isNeg()?n.neg():n;return new s((o?a.div(n):n).toPrecision(r))}}),gu=a("numeric",["number","?bignumber","?fraction"],e=>{var{number:t,bignumber:r,fraction:n}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},a={number:e=>t(e),BigNumber:r?e=>r(e):rr,Fraction:n?e=>n(e):nr};return function(e,t){var r=W(e);if(!(r in i))throw new TypeError("Cannot convert "+e+' of type "'+r+'"; valid input types are '+Object.keys(i).join(", "));if(!(t in a))throw new TypeError("Cannot convert "+e+' to type "'+t+'"; valid output types are '+Object.keys(a).join(", "));return t===r?e:a[t](e)}}),vu=a("or",["typed","matrix","equalScalar","DenseMatrix"],e=>{var{typed:e,matrix:r,equalScalar:t,DenseMatrix:n}=e,i=ou({typed:e}),a=su({typed:e,equalScalar:t}),o=cu({typed:e,DenseMatrix:n}),s=lu({typed:e}),u=fu({typed:e});return e("or",{"number, number":as,"Complex, Complex":function(e,t){return 0!==e.re||0!==e.im||0!==t.re||0!==t.im},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!e.isNaN()||!t.isZero()&&!t.isNaN()},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})}),xu=a("prod",["typed","config","multiplyScalar","numeric"],e=>{var{typed:e,config:t,multiplyScalar:n,numeric:i}=e;return e("prod",{"Array | Matrix":r,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("prod(A, dim) is not yet supported")},"...":r});function r(e){var r;if(Lt(e,function(t){try{r=void 0===r?t:n(r,t)}catch(e){throw Rr(e,"prod",t)}}),void 0===(r="string"==typeof r?i(r,t.number):r))throw new Error("Cannot calculate prod of an empty array");return r}}),bu="reshape",wu=a(bu,["typed","isInteger","matrix"],e=>{var{typed:e,isInteger:r}=e;return e(bu,{"Matrix, Array":function(e,t){return e.reshape(t)},"Array, Array":function(e,t){return t.forEach(function(e){if(!r(e))throw new TypeError("Invalid size for dimension: "+e)}),Xe(e,t)}})}),Nu=a("size",["typed","config","?matrix"],e=>{var{typed:e,config:t,matrix:r}=e;return e("size",{Matrix:function(e){return e.create(e.size())},Array:Ze,string:function(e){return"Array"===t.matrix?[e.length]:r([e.length])},"number | Complex | BigNumber | Unit | boolean | null":function(e){return"Array"===t.matrix?[]:r?r([]):ir()}})}),Mu=a("algorithm07",["typed","DenseMatrix"],e=>{var{typed:b,DenseMatrix:w}=e;return function(e,t,l){var r=e._size,n=e._datatype,i=t._size,f=t._datatype;if(r.length!==i.length)throw new Ge(r.length,i.length);if(r[0]!==i[0]||r[1]!==i[1])throw new RangeError("Dimension mismatch. Matrix A ("+r+") must match Matrix B ("+i+")");for(var a,o=r[0],p=r[1],m=0,h=l,d=("string"==typeof n&&n===f&&(m=b.convert(0,a=n),h=b.find(l,[a,a])),[]),s=0;s{var{typed:e,config:r,matrix:n,DenseMatrix:t}=e,i=ou({typed:e}),a=Mu({typed:e,DenseMatrix:t}),o=cu({typed:e,DenseMatrix:t}),s=lu({typed:e}),u=fu({typed:e});return e(Eu,{"boolean, boolean":function(e,t){return e{var{typed:e,matrix:t}=e;return e(Au,{Array:function(e){return et(X(e))},Matrix:function(e){e=et(e.toArray());return Array.isArray(e)?t(e):e},any:X})}),Cu=a("algorithm10",["typed","DenseMatrix"],e=>{var{typed:N,DenseMatrix:M}=e;return function(e,t,r,l){var f=e._values,p=e._index,m=e._ptr,h=e._size,e=e._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");for(var n,d=h[0],y=h[1],i=r,a=("string"==typeof e&&(t=N.convert(t,n=e),i=N.find(r,[n,n])),[]),o=[],g=[],s=0;s{var{typed:e,matrix:r,equalScalar:t,addScalar:n,unaryMinus:i,DenseMatrix:a}=e,o=mu({typed:e}),s=ou({typed:e}),l=su({typed:e,equalScalar:t}),u=Cu({typed:e,DenseMatrix:a}),f=lu({typed:e}),c=fu({typed:e});return e(_u,{"number, number":function(e,t){return e-t},"Complex, Complex":function(e,t){return e.sub(t)},"BigNumber, BigNumber":function(e,t){return e.minus(t)},"Fraction, Fraction":function(e,t){return e.sub(t)},"Unit, Unit":function(e,t){if(null===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");e=e.clone();return e.value=this(e.value,t.value),e.fixPrefix=!1,e},"SparseMatrix, SparseMatrix":function(e,t){return Bu(e,t),l(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return Bu(e,t),s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return Bu(e,t),o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return Bu(e,t),f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return u(e,i(t),n)},"DenseMatrix, any":function(e,t){return c(e,t,this)},"any, SparseMatrix":function(e,t){return u(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})});function Bu(e,t){e=e.size(),t=t.size();if(e.length!==t.length)throw new Ge(e.length,t.length)}var qu=a("to",["typed","matrix"],e=>{var{typed:e,matrix:r}=e,n=lu({typed:e}),i=fu({typed:e});return e("to",{"Unit, Unit | string":function(e,t){return e.to(t)},"Matrix, Matrix":function(e,t){return n(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"Matrix, any":function(e,t){return i(e,t,this,!1)},"any, Matrix":function(e,t){return i(t,e,this,!0)},"Array, any":function(e,t){return i(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return i(r(t),e,this,!0).valueOf()}})}),Iu=a("transpose",["typed","matrix"],e=>{var{typed:e,matrix:t}=e;return e("transpose",{Array:function(e){return this(t(e)).valueOf()},Matrix:function(e){var t,r=e.size();switch(r.length){case 1:t=e.clone();break;case 2:var n=r[0],i=r[1];if(0===i)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+Ee(r)+")");switch(e.storage()){case"dense":t=function(e,t,r){for(var n,i=e._data,a=[],o=0;o{var{typed:e,config:f,matrix:p,BigNumber:m}=e;return e("xgcd",{"number, number":function(e,t){e=pa(e,t);return"Array"===f.matrix?e:p(e)},"BigNumber, BigNumber":function(e,t){var r,n,l,i=new m(0),a=new m(1),o=i,s=a,u=a,c=i;if(!e.isInt()||!t.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!t.isZero();)n=e.div(t).floor(),l=e.mod(t),r=o,o=s.minus(n.times(o)),s=r,r=u,u=c.minus(n.times(u)),c=r,e=t,t=l;a=e.lt(i)?[e.neg(),s.neg(),c.neg()]:[e,e.isZero()?0:s,c];return"Array"===f.matrix?a:p(a)}})}),ku=a("zeros",["typed","config","matrix","BigNumber"],e=>{var{typed:e,config:r,matrix:i,BigNumber:a}=e;return e("zeros",{"":function(){return"Array"===r.matrix?n([]):n([],"default")},"...number | BigNumber | string":function(e){var t;return"string"==typeof e[e.length-1]?(t=e.pop(),n(e,t)):"Array"===r.matrix?n(e):n(e,"default")},Array:n,Matrix:function(e){var t=e.storage();return n(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return n(e.valueOf(),t)}});function n(e,t){n=!1,e.forEach(function(e,t,r){D(e)&&(n=!0,r[t]=e.toNumber())});var n,r=n?new a(0):0;return e.forEach(function(e){if("number"!=typeof e||!O(e)||e<0)throw new Error("Parameters in function zeros must be positive integers")}),t?(t=i(t),0{var{typed:e,matrix:r,equalScalar:t,zeros:n,not:i}=e,a=au({typed:e,equalScalar:t}),o=hu({typed:e,equalScalar:t}),s=uu({typed:e,equalScalar:t}),u=lu({typed:e}),c=fu({typed:e});return e("and",{"number, number":ss,"Complex, Complex":function(e,t){return!(0===e.re&&0===e.im||0===t.re&&0===t.im)},"BigNumber, BigNumber":function(e,t){return!(e.isZero()||t.isZero()||e.isNaN()||t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return i(t)?n(e.size(),e.storage()):s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return i(t)?n(e.size(),e.storage()):c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return i(e)?n(e.size(),e.storage()):s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return i(e)?n(e.size(),e.storage()):c(t,e,this,!0)},"Array, any":function(e,t){return this(r(e),t).valueOf()},"any, Array":function(e,t){return this(e,r(t)).valueOf()}})}),Ru=a("bitAnd",["typed","matrix","equalScalar"],e=>{var{typed:e,matrix:r,equalScalar:t}=e,n=au({typed:e,equalScalar:t}),i=hu({typed:e,equalScalar:t}),a=uu({typed:e,equalScalar:t}),o=lu({typed:e}),s=fu({typed:e});return e("bitAnd",{"number, number":Qa,"BigNumber, BigNumber":Ha,"SparseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return n(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return n(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return o(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return a(e,t,this,!1)},"DenseMatrix, any":function(e,t){return s(e,t,this,!1)},"any, SparseMatrix":function(e,t){return a(t,e,this,!0)},"any, DenseMatrix":function(e,t){return s(t,e,this,!0)},"Array, any":function(e,t){return s(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return s(r(t),e,this,!0).valueOf()}})}),Uu=a("bitXor",["typed","matrix","DenseMatrix"],e=>{var{typed:e,matrix:r,DenseMatrix:t}=e,n=ou({typed:e}),i=Mu({typed:e,DenseMatrix:t}),a=cu({typed:e,DenseMatrix:t}),o=lu({typed:e}),s=fu({typed:e});return e("bitXor",{"number, number":to,"BigNumber, BigNumber":Wa,"SparseMatrix, SparseMatrix":function(e,t){return i(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return n(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return n(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return o(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return a(e,t,this,!1)},"DenseMatrix, any":function(e,t){return s(e,t,this,!1)},"any, SparseMatrix":function(e,t){return a(t,e,this,!0)},"any, DenseMatrix":function(e,t){return s(t,e,this,!0)},"Array, any":function(e,t){return s(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return s(r(t),e,this,!0).valueOf()}})}),Fu=a("cbrt",["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],e=>{var{config:i,typed:e,isNegative:n,unaryMinus:a,matrix:o,Complex:s,BigNumber:u,Fraction:c}=e;return e("cbrt",{number:Qi,Complex:l,"Complex, boolean":l,BigNumber:function(e){return e.cbrt()},Unit:function(e){{var t,r;return e.value&&V(e.value)?((t=e.clone()).value=1,(t=t.pow(1/3)).value=l(e.value),t):((t=n(e.value))&&(e.value=a(e.value)),r=D(e.value)?new u(1).div(3):R(e.value)?new c(1,3):1/3,e=e.pow(r),t&&(e.value=a(e.value)),e)}},"Array | Matrix":function(e){return ae(e,this,!0)}});function l(e,t){var r=e.arg()/3,e=e.abs(),n=new s(Qi(e),0).mul(new s(0,r).exp());return t?(t=[n,new s(Qi(e),0).mul(new s(0,r+2*Math.PI/3).exp()),new s(Qi(e),0).mul(new s(0,r-2*Math.PI/3).exp())],"Array"===i.matrix?t:o(t)):n}}),Pu="compare",ju=a(Pu,["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],e=>{var{typed:e,config:r,equalScalar:t,matrix:n,BigNumber:i,Fraction:a,DenseMatrix:o}=e,s=ou({typed:e}),l=su({typed:e,equalScalar:t}),u=cu({typed:e,DenseMatrix:o}),f=lu({typed:e}),c=fu({typed:e});return e(Pu,{"boolean, boolean":function(e,t){return e===t?0:t{var{typed:e,matrix:r}=e,n=lu({typed:e}),i=fu({typed:e});return e(Lu,{"any, any":Oe,"DenseMatrix, DenseMatrix":function(e,t){return n(e,t,Oe)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"DenseMatrix, any":function(e,t){return i(e,t,Oe,!1)},"any, DenseMatrix":function(e,t){return i(t,e,Oe,!0)},"Array, any":function(e,t){return i(r(e),t,Oe,!1).valueOf()},"any, Array":function(e,t){return i(r(t),e,Oe,!0).valueOf()}})}),$u=a("count",["typed","size","prod"],e=>{var{typed:e,size:t,prod:r}=e;return e("count",{string:function(e){return e.length},"Matrix | Array":function(e){return r(t(e))}})}),Gu="ctranspose",Vu=a(Gu,["typed","transpose","conj"],e=>{var{typed:e,transpose:t,conj:r}=e;return e(Gu,{any:function(e){return r(t(e))}})}),Zu=a("diag",["typed","matrix","DenseMatrix","SparseMatrix"],e=>{var{typed:e,matrix:g,DenseMatrix:v,SparseMatrix:x}=e;return e("diag",{Array:function(e){return n(e,0,Ze(e),null)},"Array, number":function(e,t){return n(e,t,Ze(e),null)},"Array, BigNumber":function(e,t){return n(e,t.toNumber(),Ze(e),null)},"Array, string":function(e,t){return n(e,0,Ze(e),t)},"Array, number, string":function(e,t,r){return n(e,t,Ze(e),r)},"Array, BigNumber, string":function(e,t,r){return n(e,t.toNumber(),Ze(e),r)},Matrix:function(e){return n(e,0,e.size(),e.storage())},"Matrix, number":function(e,t){return n(e,t,e.size(),e.storage())},"Matrix, BigNumber":function(e,t){return n(e,t.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,t){return n(e,0,e.size(),t)},"Matrix, number, string":function(e,t,r){return n(e,t,e.size(),r)},"Matrix, BigNumber, string":function(e,t,r){return n(e,t.toNumber(),e.size(),r)}});function n(l,e,t,f){if(!O(e))throw new TypeError("Second parameter in function diag must be an integer");var p=0{var{typed:e,numeric:i}=e;return e(Wu,{"number, number":function(e,t){return e/t},"Complex, Complex":function(e,t){return e.div(t)},"BigNumber, BigNumber":function(e,t){return e.div(t)},"Fraction, Fraction":function(e,t){return e.div(t)},"Unit, number | Fraction | BigNumber":function(e,t){var e=e.clone(),r=i(1,W(t));return e.value=this(null===e.value?e._normalize(r):e.value,t),e},"number | Fraction | BigNumber, Unit":function(e,t){var r=(r=t.clone()).pow(-1),n=i(1,W(e));return r.value=this(e,null===t.value?t._normalize(n):t.value),r},"Unit, Unit":function(e,t){return e.divide(t)}})}),Ju="dotDivide",Xu=a(Ju,["typed","matrix","equalScalar","divideScalar","DenseMatrix"],e=>{var{typed:e,matrix:r,equalScalar:t,divideScalar:n,DenseMatrix:i}=e,a=au({typed:e,equalScalar:t}),o=ou({typed:e}),s=Mu({typed:e,DenseMatrix:i}),u=uu({typed:e,equalScalar:t}),l=cu({typed:e,DenseMatrix:i}),f=lu({typed:e}),c=fu({typed:e});return e(Ju,{"any, any":n,"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,n,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,n,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,n,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,n)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return u(e,t,n,!1)},"DenseMatrix, any":function(e,t){return c(e,t,n,!1)},"any, SparseMatrix":function(e,t){return l(t,e,n,!0)},"any, DenseMatrix":function(e,t){return c(t,e,n,!0)},"Array, any":function(e,t){return c(r(e),t,n,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,n,!0).valueOf()}})}),Qu="equal",Ku=a(Qu,["typed","matrix","equalScalar","DenseMatrix"],e=>{var{typed:e,matrix:r,equalScalar:n,DenseMatrix:t}=e,i=ou({typed:e}),a=Mu({typed:e,DenseMatrix:t}),o=cu({typed:e,DenseMatrix:t}),s=lu({typed:e}),u=fu({typed:e});return e(Qu,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:n(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,n)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,n,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,n,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,n)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,n,!1)},"DenseMatrix, any":function(e,t){return u(e,t,n,!1)},"any, SparseMatrix":function(e,t){return o(t,e,n,!0)},"any, DenseMatrix":function(e,t){return u(t,e,n,!0)},"Array, any":function(e,t){return u(r(e),t,n,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,n,!0).valueOf()}})}),ec=(a(Qu,["typed","equalScalar"],e=>{var{typed:e,equalScalar:r}=e;return e(Qu,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:r(e,t)}})}),"flatten"),tc=a(ec,["typed","matrix"],e=>{var{typed:e,matrix:t}=e;return e(ec,{Array:function(e){return rt(X(e))},Matrix:function(e){e=rt(X(e.toArray()));return t(e)}})}),rc=a("algorithm04",["typed","equalScalar"],e=>{var{typed:B,equalScalar:q}=e;return function(e,t,l){var f=e._values,p=e._index,m=e._ptr,r=e._size,h=e._datatype,d=t._values,y=t._index,g=t._ptr,n=t._size,t=t._datatype;if(r.length!==n.length)throw new Ge(r.length,n.length);if(r[0]!==n[0]||r[1]!==n[1])throw new RangeError("Dimension mismatch. Matrix A ("+r+") must match Matrix B ("+n+")");for(var i,n=r[0],v=r[1],x=q,b=0,w=l,N=("string"==typeof h&&h===t&&(x=B.find(q,[i=h,i]),b=B.convert(0,i),w=B.find(l,[i,i])),f&&d?[]:void 0),a=[],M=[],o=f&&d?[]:void 0,E=f&&d?[]:void 0,S=[],A=[],s=0;s{var{typed:e,matrix:r,equalScalar:t,BigNumber:i,DenseMatrix:n}=e,a=mu({typed:e}),o=rc({typed:e,equalScalar:t}),s=Cu({typed:e,DenseMatrix:n}),u=lu({typed:e}),c=fu({typed:e});return e("gcd",{"number, number":na,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function gcd must be integer numbers");var r=new i(0);for(;!t.isZero();){var n=e.mod(t);e=t,t=n}return e.lt(r)?e.neg():e},"Fraction, Fraction":function(e,t){return e.gcd(t)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return s(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return c(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return c(r(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:e,isNumeric:t}=e;return e(ic,{string:function(e){return 0{var{typed:e,abs:a,addScalar:o,divideScalar:s,multiplyScalar:u,sqrt:c,smaller:l,isPositive:f}=e;return e("hypot",{"... number | BigNumber":function(e){for(var t=0,r=0,n=0;n{var{smaller:r,DenseMatrix:n}=e;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!B(t))throw new Error("Invalid datatype: "+t);if(q(e)||x(e)){var r=new n(e,t);this._data=r._data,this._size=r._size,this._datatype=r._datatype,this._min=null,this._max=null}else if(e&&x(e.data)&&x(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=void 0!==e.min?e.min:null,this._max=void 0!==e.max?e.max:null;else{if(e)throw new TypeError("Unsupported type of data ("+W(e)+")");this._data=[],this._size=[0],this._datatype=t,this._min=null,this._max=null}}return(i.prototype=new n).type="ImmutableDenseMatrix",i.prototype.isImmutableDenseMatrix=!0,i.prototype.subset=function(e){switch(arguments.length){case 1:var t=n.prototype.subset.call(this,e);return q(t)?new i({data:t._data,size:t._size,datatype:t._datatype}):t;case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},i.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},i.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},i.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},i.prototype.clone=function(){return new i({data:X(this._data),size:X(this._size),datatype:this._datatype})},i.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},i.fromJSON=function(e){return new i(e)},i.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},i.prototype.min=function(){var t;return null===this._min&&(t=null,this.forEach(function(e){null!==t&&!r(e,t)||(t=e)}),this._min=null!==t?t:void 0),this._min},i.prototype.max=function(){var t;return null===this._max&&(t=null,this.forEach(function(e){null!==t&&!r(t,e)||(t=e)}),this._max=null!==t?t:void 0),this._max},i},{isClass:!0}),uc=a("Index",["ImmutableDenseMatrix"],e=>{var n=e["ImmutableDenseMatrix"];function a(e){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var t=0,r=arguments.length;t{var{typed:e,matrix:r,multiplyScalar:a}=e;return e("kron",{"Matrix, Matrix":function(e,t){return r(n(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(n(e.toArray(),t))},"Array, Matrix":function(e,t){return r(n(e,t.toArray()))},"Array, Array":n});function n(e,r){if(1===Ze(e).length&&(e=[e]),1===Ze(r).length&&(r=[r]),2{var{typed:e,config:r,matrix:n,DenseMatrix:t}=e,i=ou({typed:e}),a=Mu({typed:e,DenseMatrix:t}),o=cu({typed:e,DenseMatrix:t}),s=lu({typed:e}),u=fu({typed:e});return e(lc,{"boolean, boolean":function(e,t){return t<=e},"number, number":function(e,t){return t<=e||he(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gte(t)||bo(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return-1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(n(t),e,this,!0).valueOf()}})}),pc=a("algorithm08",["typed","equalScalar"],e=>{var{typed:_,equalScalar:T}=e;return function(e,t,l){var f=e._values,p=e._index,m=e._ptr,r=e._size,h=e._datatype,d=t._values,y=t._index,g=t._ptr,n=t._size,t=t._datatype;if(r.length!==n.length)throw new Ge(r.length,n.length);if(r[0]!==n[0]||r[1]!==n[1])throw new RangeError("Dimension mismatch. Matrix A ("+r+") must match Matrix B ("+n+")");if(!f||!d)throw new Error("Cannot perform operation on Pattern Sparse Matrices");for(var i,n=r[0],v=r[1],x=T,b=0,w=l,N=("string"==typeof h&&h===t&&(x=_.find(T,[i=h,i]),b=_.convert(0,i),w=_.find(l,[i,i])),[]),a=[],o=[],M=[],E=[],s=0;s{var{typed:e,matrix:r,equalScalar:n,zeros:i,DenseMatrix:t}=e,a=mu({typed:e}),o=au({typed:e,equalScalar:n}),s=pc({typed:e,equalScalar:n}),u=Cu({typed:e,DenseMatrix:t}),l=uu({typed:e,equalScalar:n}),f=lu({typed:e}),c=fu({typed:e});return e(mc,{"number, number":ro,"BigNumber, BigNumber":Ya,"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():c(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):u(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})});function dc(e){var d=e["DenseMatrix"];return function(e,t,r){e=e.size();if(2!==e.length)throw new RangeError("Matrix must be two dimensional (size: "+Ee(e)+")");var n=e[0];if(n!==e[1])throw new RangeError("Matrix must be square (size: "+Ee(e)+")");var i=[];if(q(t)){var e=t.size(),l=t._data;if(1===e.length){if(e[0]!==n)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var a=0;a{var{typed:e,matrix:r,divideScalar:w,multiplyScalar:N,subtract:M,equalScalar:E,DenseMatrix:S}=e,A=dc({DenseMatrix:S});return e("lsolve",{"SparseMatrix, Array | Matrix":function(e,t){for(var r=(t=A(e,t=t,!0))._data,t=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,n=[],i=0;i{var{typed:e,matrix:t,flatten:u,size:r}=e;return e(gc,{"...Array":n,"...Matrix":function(e){return t(n(e.map(e=>e.toArray())))}});function n(e){if(0===e.length)throw new TypeError("At least one column is needed to construct a matrix.");for(var t,r=c(e[0]),n=[],i=0;i{var{typed:e,isNaN:o,isNumeric:s}=e;return e("mode",{"Array | Matrix":t,"...":t});function t(e){if(0===(e=rt(e.valueOf())).length)throw new Error("Cannot calculate mode of an empty array");for(var t={},r=[],n=0,i=0;in&&(n=t[a],r=[a])}return r}}),bc="nthRoots",wc=a(bc,["config","typed","divideScalar","Complex"],e=>{var{typed:e,Complex:c}=e,l=[function(e){return new c(e,0)},function(e){return new c(0,e)},function(e){return new c(-e,0)},function(e){return new c(0,-e)}];function t(e,t){if(t<0)throw new Error("Root must be greater than zero");if(0===t)throw new Error("Root must be non-zero");if(t%1!=0)throw new Error("Root must be an integer");if(0===e||0===e.abs())return[new c(0,0)];for(var r,n="number"==typeof e,i=(!n&&0!==e.re&&0!==e.im||(r=n?2*(e<0):0===e.im?2*(e.re<0):2*(e.im<0)+1),e.arg()),n=e.abs(),a=[],o=Math.pow(n,1/t),s=0;s{var{typed:e,config:r,matrix:i,BigNumber:a}=e;return e("ones",{"":function(){return"Array"===r.matrix?n([]):n([],"default")},"...number | BigNumber | string":function(e){var t;return"string"==typeof e[e.length-1]?(t=e.pop(),n(e,t)):"Array"===r.matrix?n(e):n(e,"default")},Array:n,Matrix:function(e){var t=e.storage();return n(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return n(e.valueOf(),t)}});function n(e,t){n=!1,e.forEach(function(e,t,r){D(e)&&(n=!0,r[t]=e.toNumber())});var n,r=n?new a(1):1;return e.forEach(function(e){if("number"!=typeof e||!O(e)||e<0)throw new Error("Parameters in function ones must be positive integers")}),t?(t=i(t),0{var{typed:e,isNumeric:l,isNaN:f,compare:r}=e,n=r,i=(e,t)=>-r(e,t);return e(Mc,{"Array | Matrix, number":function(e,t){return a(e,t,n)},"Array | Matrix, number, string":function(e,t,r){if("asc"===r)return a(e,t,n);if("desc"===r)return a(e,t,i);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":a});function a(e,t,r){if(!O(t)||t<0)throw new Error("k must be a non-negative integer");if(q(e)){if(1=e.length)throw new Error("k out of bounds");for(var n=0;n{var{config:l,matrix:f}=e;return function(e,t,r){if(2!==arguments.length&&3!==arguments.length)throw new Sc("resize",arguments.length,2,3);if(D((t=q(t)?t.valueOf():t)[0])&&(t=t.map(function(e){return D(e)?e.toNumber():e})),q(e))return e.resize(t,r,!0);if("string"==typeof e){var n=e,i=t,a=r;if(void 0!==a){if("string"!=typeof a||1!==a.length)throw new TypeError("Single character expected as defaultValue")}else a=" ";if(1!==i.length)throw new Ge(i.length,1);var o=i[0];if("number"!=typeof o||!O(o))throw new TypeError("Invalid size, must contain positive integers (size: "+Ee(i)+")");if(n.length>o)return n.substring(0,o);if(n.length{var{typed:e,matrix:r,equalScalar:n,zeros:i,DenseMatrix:t}=e,a=mu({typed:e}),o=au({typed:e,equalScalar:n}),s=pc({typed:e,equalScalar:n}),u=Cu({typed:e,DenseMatrix:t}),l=uu({typed:e,equalScalar:n}),f=lu({typed:e}),c=fu({typed:e});return e(Oc,{"number, number":io,"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():c(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):u(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})});function _c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Tc(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function Bc(t){for(var e=1;e{var{typed:e,matrix:r,equalScalar:n,zeros:i,BigNumber:a,DenseMatrix:t}=e,o=uu({typed:e,equalScalar:n}),s=cu({typed:e,DenseMatrix:t}),u=fu({typed:e});return e(Ic,Bc(Bc({},kc),{},{Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw new TypeError(qc);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(qc);t=t.toNumber();return e.round(t)},"number, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(qc);return new a(e).toDecimalPlaces(t.toNumber())},BigNumber:function(e){return e.toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(qc);return e.toDecimalPlaces(t.toNumber())},Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw new TypeError(qc);return e.round(t)},"Array | Matrix":function(e){return ae(e,this,!0)},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"number | Complex | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):s(t,e,this,!0)},"number | Complex | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):u(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return u(r(e),t,this,!1).valueOf()},"number | Complex | BigNumber, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}}))}),kc={number:ha,"number, number":function(e,t){if(!O(t))throw new TypeError(qc);if(t<0||15{var{typed:e,config:r,matrix:n,DenseMatrix:t}=e,i=ou({typed:e}),a=Mu({typed:e,DenseMatrix:t}),o=cu({typed:e,DenseMatrix:t}),s=lu({typed:e}),u=fu({typed:e});return e(Dc,{"boolean, boolean":function(e,t){return e<=t},"number, number":function(e,t){return e<=t||he(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.lte(t)||bo(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return 1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(n(t),e,this,!0).valueOf()}})}),Uc="unequal",Fc=a(Uc,["typed","config","equalScalar","matrix","DenseMatrix"],e=>{var{typed:e,equalScalar:r,matrix:n,DenseMatrix:t}=e,i=ou({typed:e}),a=Mu({typed:e,DenseMatrix:t}),o=cu({typed:e,DenseMatrix:t}),s=lu({typed:e}),u=fu({typed:e});return e("unequal",{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:c(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,c)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,c,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,c,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,c)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return o(e,t,c,!1)},"DenseMatrix, any":function(e,t){return u(e,t,c,!1)},"any, SparseMatrix":function(e,t){return o(t,e,c,!0)},"any, DenseMatrix":function(e,t){return u(t,e,c,!0)},"Array, any":function(e,t){return u(n(e),t,c,!1).valueOf()},"any, Array":function(e,t){return u(n(t),e,c,!0).valueOf()}});function c(e,t){return!r(e,t)}}),Pc=(a(Uc,["typed","equalScalar"],e=>{var{typed:e,equalScalar:r}=e;return e(Uc,{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:!r(e,t)}})}),a("usolve",["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],e=>{var{typed:e,matrix:r,divideScalar:b,multiplyScalar:w,subtract:N,equalScalar:M,DenseMatrix:E}=e,S=dc({DenseMatrix:E});return e("usolve",{"SparseMatrix, Array | Matrix":function(e,t){for(var r=(t=S(e,t=t,!0))._data,t=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,n=[],i=l-1;0<=i;i--){var h=r[i][0]||0;if(M(h,0))n[i]=[0];else{for(var a=0,d=[],o=[],y=m[i],s=m[i+1]-1;y<=s;s--){var u=p[s];u===i?a=f[s]:u{var{typed:e,matrix:r,DenseMatrix:t}=e,n=ou({typed:e}),i=Mu({typed:e,DenseMatrix:t}),a=cu({typed:e,DenseMatrix:t}),o=lu({typed:e}),s=fu({typed:e});return e("xor",{"number, number":os,"Complex, Complex":function(e,t){return(0!==e.re||0!==e.im)!=(0!==t.re||0!==t.im)},"BigNumber, BigNumber":function(e,t){return(!e.isZero()&&!e.isNaN())!=(!t.isZero()&&!t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return i(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return n(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return n(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return o(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return a(e,t,this,!1)},"DenseMatrix, any":function(e,t){return s(e,t,this,!1)},"any, SparseMatrix":function(e,t){return a(t,e,this,!0)},"any, DenseMatrix":function(e,t){return s(t,e,this,!0)},"Array, any":function(e,t){return s(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return s(r(t),e,this,!0).valueOf()}})}),Lc=a("add",["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],e=>{var{typed:e,matrix:r,addScalar:n,equalScalar:t,DenseMatrix:i}=e,a=mu({typed:e}),o=rc({typed:e,equalScalar:t}),s=Cu({typed:e,DenseMatrix:i}),u=lu({typed:e}),c=fu({typed:e});return e("add",Ce({"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,n)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,n,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,n,!0)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,n)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"DenseMatrix, any":function(e,t){return c(e,t,n,!1)},"SparseMatrix, any":function(e,t){return s(e,t,n,!1)},"any, DenseMatrix":function(e,t){return c(t,e,n,!0)},"any, SparseMatrix":function(e,t){return s(t,e,n,!0)},"Array, any":function(e,t){return c(r(e),t,n,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,n,!0).valueOf()},"any, any":n,"any, any, ...any":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:_,equalScalar:T}=e;return function(e,t,l){var f=e._values,p=e._index,m=e._ptr,r=e._size,h=e._datatype,d=t._values,y=t._index,g=t._ptr,n=t._size,t=t._datatype;if(r.length!==n.length)throw new Ge(r.length,n.length);if(r[0]!==n[0]||r[1]!==n[1])throw new RangeError("Dimension mismatch. Matrix A ("+r+") must match Matrix B ("+n+")");for(var i,a,o,v,n=r[0],x=r[1],b=T,w=0,N=l,M=("string"==typeof h&&h===t&&(b=_.find(T,[i=h,i]),w=_.convert(0,i),N=_.find(l,[i,i])),f&&d?[]:void 0),s=[],E=[],S=M?[]:void 0,A=[],u=0;u{var{typed:e,matrix:r,equalScalar:t,BigNumber:n,DenseMatrix:i}=e,a=au({typed:e,equalScalar:t}),o=ou({typed:e}),s=Hc({typed:e,equalScalar:t}),u=uu({typed:e,equalScalar:t}),l=cu({typed:e,DenseMatrix:i}),f=lu({typed:e}),c=fu({typed:e});return e("atan2",{"number, number":Math.atan2,"BigNumber, BigNumber":function(e,t){return n.atan2(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return l(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return c(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})}),Gc=a("bitOr",["typed","matrix","equalScalar","DenseMatrix"],e=>{var{typed:e,matrix:r,equalScalar:t,DenseMatrix:n}=e,i=mu({typed:e}),a=rc({typed:e,equalScalar:t}),o=Cu({typed:e,DenseMatrix:n}),s=lu({typed:e}),u=fu({typed:e});return e("bitOr",{"number, number":eo,"BigNumber, BigNumber":Ga,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})}),Vc="catalan",Zc=a(Vc,["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],e=>{var{typed:e,addScalar:t,divideScalar:r,multiplyScalar:n,combinations:i,isNegative:a,isInteger:o}=e;return e(Vc,{"number | BigNumber":function(e){if(!o(e)||a(e))throw new TypeError("Non-negative integer value expected in function catalan");return r(i(n(e,2),e),t(e,1))}})}),Wc=lm(228),Yc="compareNatural",Jc=a(Yc,["typed","compare"],e=>{var{typed:e,compare:p}=e,m=p.signatures["boolean,boolean"];return e(Yc,{"any, any":function(e,t){var r,n=W(e),i=W(t);if(!("number"!==n&&"BigNumber"!==n&&"Fraction"!==n||"number"!==i&&"BigNumber"!==i&&"Fraction"!==i))return"0"!==(r=p(e,t)).toString()?0r.re?1:i.rer.im?1:i.imr.length?1:t.length{var{typed:e,equal:a}=e;return e(Xc,{"any, any":function(e,t){return function e(t,r){{if(Array.isArray(t)){if(Array.isArray(r)){var n=t.length;if(n!==r.length)return!1;for(var i=0;i{var{typed:g,addScalar:v,multiplyScalar:x,conj:b,size:t}=e;return g("dot",{"Array | DenseMatrix, Array | DenseMatrix":function(e,t){var r=w(e,t),n=q(e)?e._data:e,i=q(e)?e._datatype:void 0,a=q(t)?t._data:t,o=q(t)?t._datatype:void 0,e=2===N(e).length,t=2===N(t).length,s=v,u=x;i&&o&&i===o&&"string"==typeof i&&(o=i,s=g.find(v,[o,o]),u=g.find(x,[o,o]));if(!e&&!t){for(var l=u(b(n[0]),a[0]),c=1;c{var{typed:e,compareText:r,isZero:n}=e;return e(el,{"any, any":function(e,t){return n(r(e,t))}})}),rl=a("floor",["typed","config","round","matrix","equalScalar"],e=>{var{typed:e,config:i,round:a,matrix:r,equalScalar:t}=e,n=uu({typed:e,equalScalar:t}),o=fu({typed:e});return e("floor",{number:function(e){return he(e,a(e),i.epsilon)?a(e):Math.floor(e)},"number, number":function(e,t){var r,n;return he(e,a(e,t),i.epsilon)?a(e,t):([e,r]="".concat(e,"e").split("e"),n=Math.floor(Number("".concat(e,"e").concat(Number(r)+t))),[e,r]="".concat(n,"e").split("e"),Number("".concat(e,"e").concat(Number(r)-t)))},Complex:function(e){return e.floor()},"Complex, number":function(e,t){return e.floor(t)},BigNumber:function(e){return bo(e,a(e),i.epsilon)?a(e):e.floor()},"BigNumber, BigNumber":function(e,t){return bo(e,a(e,t),i.epsilon)?a(e,t):e.toDecimalPlaces(t.toNumber(),on.ROUND_FLOOR)},Fraction:function(e){return e.floor()},"Fraction, number":function(e,t){return e.floor(t)},"Array | Matrix":function(e){return ae(e,this,!0)},"Array | Matrix, number":function(e,t){return ae(e,e=>this(e,t),!0)},"SparseMatrix, number | BigNumber":function(e,t){return n(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"number | Complex | BigNumber, Array":function(e,t){return o(r(t),e,this,!0).valueOf()}})}),nl="identity",il=a(nl,["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],e=>{var{typed:e,config:r,matrix:n,BigNumber:c,DenseMatrix:l,SparseMatrix:f}=e;return e(nl,{"":function(){return"Matrix"===r.matrix?n([]):[]},string:function(e){return n(e)},"number | BigNumber":function(e){return a(e,e,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, string":function(e,t){return a(e,e,t)},"number | BigNumber, number | BigNumber":function(e,t){return a(e,t,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, number | BigNumber, string":a,Array:function(e){return i(e)},"Array, string":i,Matrix:function(e){return i(e.valueOf(),e.storage())},"Matrix, string":function(e,t){return i(e.valueOf(),t)}});function i(e,t){switch(e.length){case 0:return t?n(t):[];case 1:return a(e[0],e[0],t);case 2:return a(e[0],e[1],t);default:throw new Error("Vector containing two values expected")}}function a(e,t,r){var n=D(e)||D(t)?c:null;if(D(e)&&(e=e.toNumber()),D(t)&&(t=t.toNumber()),!O(e)||e<1)throw new Error("Parameters in function identity must be positive integers");if(!O(t)||t<1)throw new Error("Parameters in function identity must be positive integers");var i=n?new c(1):1,n=n?new n(0):0,a=[e,t];if(r){if("sparse"===r)return f.diagonal(a,i,0,n);if("dense"===r)return l.diagonal(a,i,0,n);throw new TypeError('Unknown matrix type "'.concat(r,'"'))}for(var o=Je([],a,n),s=e{var{typed:e,BigNumber:n,xgcd:i,equal:a,smaller:o,mod:s,add:u,isInteger:c}=e;return e("invmod",{"number, number":t,"BigNumber, BigNumber":t});function t(e,t){if(!c(e)||!c(t))throw new Error("Parameters in function invmod must be integer numbers");if(e=s(e,t),a(t,0))throw new Error("Divisor must be non zero");var[e,r]=i(e,t).valueOf();return a(e,n(1))?(r=s(r,t),o(r,n(0))?u(r,t):r):NaN}}),ol="larger",sl=a(ol,["typed","config","matrix","DenseMatrix"],e=>{var{typed:e,config:r,matrix:n,DenseMatrix:t}=e,i=ou({typed:e}),a=Mu({typed:e,DenseMatrix:t}),o=cu({typed:e,DenseMatrix:t}),s=lu({typed:e}),u=fu({typed:e});return e(ol,{"boolean, boolean":function(e,t){return t{var{typed:e,config:t,divideScalar:r,Complex:n}=e;return e("log",{number:function(e){return 0<=e||t.predictable?aa(e):new n(e,0).log()},Complex:function(e){return e.log()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.ln():new n(e.toNumber(),0).log()},"Array | Matrix":function(e){return ae(e,this)},"any, any":function(e,t){return r(this(e),this(t))}})}),cl="lsolveAll",ll=a(cl,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],e=>{var{typed:e,matrix:r,divideScalar:A,multiplyScalar:O,subtract:C,equalScalar:_,DenseMatrix:T}=e,B=dc({DenseMatrix:T});return e(cl,{"SparseMatrix, Array | Matrix":function(e,l){for(var t=[B(e,l,!0)._data.map(e=>e[0])],f=e._size[0],p=e._size[1],m=e._values,h=e._index,d=e._ptr,r=0;rnew T({data:e.map(e=>[e]),size:[f,1]}))},"DenseMatrix, Array | Matrix":n,"Array, Array | Matrix":function(e,t){return n(r(e),t).map(e=>e.valueOf())}});function n(e,l){for(var t=[B(e,l,!0)._data.map(e=>e[0])],r=e._data,f=e._size[0],n=e._size[1],i=0;inew T({data:e.map(e=>[e]),size:[f,1]}))}}),fl="matrixFromRows",pl=a(fl,["typed","matrix","flatten","size"],e=>{var{typed:e,matrix:t,flatten:a,size:r}=e;return e(fl,{"...Array":n,"...Matrix":function(e){return t(n(e.map(e=>e.toArray())))}});function n(e){if(0===e.length)throw new TypeError("At least one row is needed to construct a matrix.");var t,r=o(e[0]),n=[];for(t of e){var i=o(t);if(i!==r)throw new TypeError("The vectors had different length: "+(0|r)+" ≠ "+(0|i));n.push(a(t))}return n}function o(e){e=r(e);if(1===e.length)return e[0];if(2!==e.length)throw new TypeError("Only one- or two-dimensional vectors are supported.");if(1===e[0])return e[1];if(1===e[1])return e[0];throw new TypeError("At least one of the arguments is not a vector.")}}),ml="multiply",hl=a(ml,["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],e=>{var{typed:z,matrix:r,addScalar:k,multiplyScalar:D,equalScalar:I,dot:i}=e,n=uu({typed:z,equalScalar:I}),a=fu({typed:z});function o(e,t){switch(e.length){case 1:switch(t.length){case 1:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;case 2:switch(t.length){case 1:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+t[0]+")");break;case 2:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}}function s(e,t){if("dense"!==t.storage())throw new Error("Support for SparseMatrix not implemented");var r,n=e._data,l=e._size,i=e._datatype,a=t._data,f=t._size,t=t._datatype,p=l[0],m=f[1],h=k,o=D;i&&t&&i===t&&"string"==typeof i&&(r=i,h=z.find(k,[r,r]),o=z.find(D,[r,r]));for(var d=[],s=0;s{var{typed:e,config:i,identity:a,multiply:o,matrix:r,number:s,fraction:f,Complex:u}=e;return e("pow",{"number, number":n,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(e,t){return t.isInteger()||0<=e||i.predictable?e.pow(t):new u(e.toNumber(),0).pow(t.toNumber(),0)},"Fraction, Fraction":function(e,t){var r=e.pow(t);if(null!=r)return r;if(i.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return n(e.valueOf(),t.valueOf())},"Array, number":c,"Array, BigNumber":function(e,t){return c(e,t.toNumber())},"Matrix, number":l,"Matrix, BigNumber":function(e,t){return l(e,t.toNumber())},"Unit, number | BigNumber":function(e,t){return e.pow(t)}});function n(e,t){if(i.predictable&&!O(t)&&e<0)try{var r=f(t),n=s(r);if((t===n||Math.abs((t-n)/t)<1e-14)&&r.d%2==1)return(r.n%2==0?1:-1)*Math.pow(-e,t)}catch(e){}return i.predictable&&(e<-1&&t===1/0||-1>=1,i=o(i,i);return n}function l(e,t){return r(c(e.valueOf(),t))}}),yl=a("qr",["typed","matrix","zeros","identity","isZero","equal","sign","sqrt","conj","unaryMinus","addScalar","divideScalar","multiplyScalar","subtract","complex"],e=>{var{typed:e,matrix:t,zeros:M,identity:E,isZero:S,equal:A,sign:O,sqrt:C,conj:g,unaryMinus:v,addScalar:x,divideScalar:b,multiplyScalar:w,subtract:N,complex:s}=e;return oe(e("qr",{DenseMatrix:r,SparseMatrix:function(e){throw new Error("qr not implemented for sparse matrices yet")},Array:function(e){e=r(t(e));return{Q:e.Q.valueOf(),R:e.R.valueOf()}}}),{_denseQRimpl:o});function o(e){for(var t=e._size[0],l=e._size[1],f=E([t],"dense"),r=f._data,e=e.clone(),n=e._data,i=M([t],""),a=0;a{var{typed:e,matrix:r,equalScalar:n,zeros:i,DenseMatrix:t}=e,a=mu({typed:e}),o=au({typed:e,equalScalar:n}),s=pc({typed:e,equalScalar:n}),u=Cu({typed:e,DenseMatrix:t}),l=uu({typed:e,equalScalar:n}),f=lu({typed:e}),c=fu({typed:e});return e(gl,{"number, number":no,"BigNumber, BigNumber":Ja,"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():c(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):u(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})}),xl="setCartesian",bl=a(xl,["typed","size","subset","compareNatural","Index","DenseMatrix"],e=>{var{typed:e,size:s,subset:u,compareNatural:c,Index:l,DenseMatrix:f}=e;return e(xl,{"Array | Matrix, Array | Matrix":function(e,t){var r=[];if(0!==u(s(e),new l(0))&&0!==u(s(t),new l(0)))for(var n=rt(Array.isArray(e)?e:e.toArray()).sort(c),i=rt(Array.isArray(t)?t:t.toArray()).sort(c),r=[],a=0;a{var{typed:e,size:i,subset:a,compareNatural:o,Index:s,DenseMatrix:u}=e;return e(wl,{"Array | Matrix":function(e){if(0===a(i(e),new s(0)))t=[];else{var t,r=rt(Array.isArray(e)?e:e.toArray()).sort(o);(t=[]).push(r[0]);for(var n=1;n{var{typed:e,size:s,subset:u,compareNatural:c,Index:l}=e;return e(Ml,{"Array | Matrix, Array | Matrix":function(e,t){if(0===u(s(e),new l(0)))return!0;if(0===u(s(t),new l(0)))return!1;for(var r=ut(rt(Array.isArray(e)?e:e.toArray()).sort(c)),n=ut(rt(Array.isArray(t)?t:t.toArray()).sort(c)),i=0;i{var{typed:e,size:u,subset:c,compareNatural:l,Index:f}=e;return e(Sl,{"Array | Matrix":function(e){if(0===c(u(e),new f(0)))return[];for(var t=rt(Array.isArray(e)?e:e.toArray()).sort(l),r=[],n=0;n.toString(2).length<=t.length;)r.push(function(e,t){for(var r=[],n=0;ni[s+1].length&&(a=i[s],i[s]=i[s+1],i[s+1]=a);return i}})});function Ol(e,t,r,n,i,a,o){var s=0;for(r[o]=e;0<=s;){var u=r[o+s],c=r[n+u];-1===c?(s--,a[t++]=u):(r[n+u]=r[i+c],r[o+ ++s]=c)}return t}var Cl=a("csAmd",["add","multiply","transpose"],e=>{var{add:oe,multiply:se,transpose:ue}=e;return function(l,f){if(!f||l<=0||3l))for(var f=o[u+1];c=L?a[F+s]-=Q:0!==a[F+s]&&(a[F+s]=a[U+s]+K);for(O=Y;O{var S=e["transpose"];return function(l,e,t,f){if(!l||!e||!t)return null;for(var r,n,i,p,m,h=l._size,d=h[0],a=h[1],y=4*a+(f?a+d+1:0),o=[],g=a,v=2*a,x=3*a,b=4*a,w=5*a+1,s=0;s{var{add:e,multiply:t,transpose:r}=e,s=Cl({add:e,multiply:t,transpose:r}),u=_l({transpose:r});return function(e,t,r){var n,i=t._ptr,a=t._size[1],o={};if(o.q=s(e,t),e&&!o.q)return null;if(r){r=e?function(e,t,r,l){for(var f=e._values,n=e._index,p=e._ptr,m=e._size,h=e._datatype,d=m[0],i=m[1],a=l&&e._values?[]:null,y=[],o=[],s=0,u=0;u{var{divideScalar:N,multiply:M,subtract:E}=e;return function(e,t,r,n,i,a,l){for(var o,s,f,p=e._values,m=e._index,h=e._ptr,d=e._size[1],y=t._values,g=t._index,v=t._ptr,e=Il(e,t,r,n,a),u=e;u{var{abs:A,divideScalar:O,multiply:C,subtract:e,larger:_,largerEq:T,SparseMatrix:B}=e,q=zl({divideScalar:O,multiply:C,subtract:e});return function(l,f,p){if(!l)return null;var m,e=l._size[1],t=100,r=100,h=(f&&(m=f.q,t=f.lnz||t,r=f.unz||r),[]),n=[],d=[],y=new B({values:h,index:n,ptr:d,size:[e,e]}),g=[],v=[],x=[],f=new B({values:g,index:v,ptr:x,size:[e,e]}),i=[],a=[],b=[];for(s=0;s{var{typed:e,abs:t,add:r,multiply:n,transpose:i,divideScalar:a,subtract:o,larger:s,largerEq:u,SparseMatrix:c}=e,l=Tl({add:r,multiply:n,transpose:i}),f=kl({abs:t,divideScalar:a,multiply:n,subtract:o,larger:s,largerEq:u,SparseMatrix:c});return e("slu",{"SparseMatrix, number, number":function(e,t,r){if(!O(t)||t<0||3{var{typed:e,matrix:t,add:p}=e;return e("trace",{Array:function(e){return r(t(e))},SparseMatrix:function(e){var t=e._values,r=e._index,n=e._ptr,e=e._size,i=e[0],a=e[1];if(i!==a)throw new RangeError("Matrix must be square (size: "+Ee(e)+")");var o=0;if(0{var{typed:e,matrix:r,divideScalar:S,multiplyScalar:A,subtract:O,equalScalar:C,DenseMatrix:_}=e,T=dc({DenseMatrix:_});return e(Ul,{"SparseMatrix, Array | Matrix":function(e,l){for(var t=[T(e,l=l,!0)._data.map(e=>e[0])],f=e._size[0],l=e._size[1],p=e._values,m=e._index,h=e._ptr,r=l-1;0<=r;r--)for(var d=t.length,n=0;nnew _({data:e.map(e=>[e]),size:[f,1]}))},"DenseMatrix, Array | Matrix":n,"Array, Array | Matrix":function(e,t){return n(r(e),t).map(e=>e.valueOf())}});function n(e,l){for(var t=[T(e,l,!0)._data.map(e=>e[0])],r=e._data,f=e._size[0],n=e._size[1]-1;0<=n;n--)for(var i=t.length,a=0;anew _({data:e.map(e=>[e]),size:[f,1]}))}}),Pl=a("asin",["typed","config","Complex"],e=>{var{typed:e,config:t,Complex:r}=e;return e("asin",{number:function(e){return-1<=e&&e<=1||t.predictable?Math.asin(e):new r(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()},"Array | Matrix":function(e){return ae(e,this,!0)}})}),jl=a("ceil",["typed","config","round","matrix","equalScalar"],e=>{var{typed:e,config:i,round:a,matrix:r,equalScalar:t}=e,n=uu({typed:e,equalScalar:t}),o=fu({typed:e});return e("ceil",{number:function(e){return(he(e,a(e),i.epsilon)?a:Ki)(e)},"number, number":function(e,t){var r,n;return he(e,a(e,t),i.epsilon)?a(e,t):([e,r]="".concat(e,"e").split("e"),n=Math.ceil(Number("".concat(e,"e").concat(Number(r)+t))),[e,r]="".concat(n,"e").split("e"),Number("".concat(e,"e").concat(Number(r)-t)))},Complex:function(e){return e.ceil()},"Complex, number":function(e,t){return e.ceil(t)},BigNumber:function(e){return bo(e,a(e),i.epsilon)?a(e):e.ceil()},"BigNumber, BigNumber":function(e,t){return bo(e,a(e,t),i.epsilon)?a(e,t):e.toDecimalPlaces(t.toNumber(),on.ROUND_CEIL)},Fraction:function(e){return e.ceil()},"Fraction, number":function(e,t){return e.ceil(t)},"Array | Matrix":function(e){return ae(e,this,!0)},"Array | Matrix, number":function(e,t){return ae(e,e=>this(e,t),!0)},"SparseMatrix, number | BigNumber":function(e,t){return n(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"number | Complex | BigNumber, Array":function(e,t){return o(r(t),e,this,!0).valueOf()}})}),Ll="composition",Hl=a(Ll,["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],e=>{var{typed:e,addScalar:r,combinations:n,isPositive:i,isInteger:a,larger:o}=e;return e(Ll,{"number | BigNumber, number | BigNumber":function(e,t){if(!(a(e)&&i(e)&&a(t)&&i(t)))throw new TypeError("Positive integer value expected in function composition");if(o(t,e))throw new TypeError("k must be less than or equal to n in function composition");return n(r(e,-1),r(t,-1))}})}),$l=a("cross",["typed","matrix","subtract","multiply"],e=>{var{typed:e,matrix:r,subtract:a,multiply:o}=e;return e("cross",{"Matrix, Matrix":function(e,t){return r(n(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(n(e.toArray(),t))},"Array, Matrix":function(e,t){return r(n(e,t.toArray()))},"Array, Array":n});function n(e,t){var r=Math.max(Ze(e).length,Ze(t).length),n=(e=et(e),t=et(t),Ze(e)),i=Ze(t);if(1!==n.length||1!==i.length||3!==n[0]||3!==i[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+n.join(", ")+"], B = ["+i.join(", ")+"])");n=[a(o(e[1],t[2]),o(e[2],t[1])),a(o(e[2],t[0]),o(e[0],t[2])),a(o(e[0],t[1]),o(e[1],t[0]))];return 1{var{typed:e,addScalar:c,subtract:l,multiplyScalar:f,divideScalar:p,unaryMinus:o,sqrt:m,abs:u}=e;return e(Gl,{"Array, Array, Array":function(e,t,r){if(2!==e.length||2!==t.length||2!==r.length)throw new TypeError("Invalid Arguments: Try again");if(!i(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!i(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!i(r))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var r=p(l(r[1],r[0]),l(t[1],t[0])),n=f(f(r,r),t[0]),r=o(f(r,t[0])),t=e[1];return a(e[0],e[1],n,r,t)},"Object, Object, Object":function(e,t,r){if(2!==Object.keys(e).length||2!==Object.keys(t).length||2!==Object.keys(r).length)throw new TypeError("Invalid Arguments: Try again");if(!i(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!i(t))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!i(r))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");var n;if("pointX"in e&&"pointY"in e&&"lineOnePtX"in t&&"lineOnePtY"in t&&"lineTwoPtX"in r&&"lineTwoPtY"in r)return r=p(l(r.lineTwoPtY,r.lineTwoPtX),l(t.lineOnePtY,t.lineOnePtX)),n=f(f(r,r),t.lineOnePtX),r=o(f(r,t.lineOnePtX)),t=e.pointX,a(e.pointX,e.pointY,n,r,t);throw new TypeError("Key names do not match")},"Array, Array":function(e,t){if(2===e.length&&3===t.length){if(!i(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!r(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return a(e[0],e[1],t[0],t[1],t[2])}if(3===e.length&&6===t.length){if(!r(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!h(t))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return d(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}if(e.length===t.length&&02!==e.length||!s(e[0])||!s(e[1])))return!1}else{if(!(3===e[0].length&&s(e[0][0])&&s(e[0][1])&&s(e[0][2])))return!1;if(e.some(e=>3!==e.length||!s(e[0])||!s(e[1])||!s(e[2])))return!1}return!0}(e))throw new TypeError("Incorrect array format entered for pairwise distance calculation");for(var t=e,r=[],n=[],i=[],a=0;a{var{typed:e,matrix:r,equalScalar:t,multiplyScalar:n}=e,i=au({typed:e,equalScalar:t}),a=Hc({typed:e,equalScalar:t}),o=uu({typed:e,equalScalar:t}),s=lu({typed:e}),u=fu({typed:e});return e(Zl,{"any, any":n,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,n,!1)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,n,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,n,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,n)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,n,!1)},"DenseMatrix, any":function(e,t){return u(e,t,n,!1)},"any, SparseMatrix":function(e,t){return o(t,e,n,!0)},"any, DenseMatrix":function(e,t){return u(t,e,n,!0)},"Array, any":function(e,t){return u(r(e),t,n,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,n,!0).valueOf()}})}),Yl=a("FibonacciHeap",["smaller","larger"],e=>{var{smaller:f,larger:p}=e,m=1/Math.log((1+Math.sqrt(5))/2);function t(){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}function i(e,t,r){t.left.right=t.right,t.right.left=t.left,r.degree--,r.child===t&&(r.child=t.right),0===r.degree&&(r.child=null),t.left=e,t.right=e.right,((e.right=t).right.left=t).parent=null,t.mark=!1}t.prototype.type="FibonacciHeap",t.prototype.isFibonacciHeap=!0,t.prototype.insert=function(e,t){var r,t={key:e,value:t,degree:0};return this._minimum?(r=this._minimum,t.left=r,t.right=r.right,(r.right=t).right.left=t,f(e,r.key)&&(this._minimum=t)):((t.left=t).right=t,this._minimum=t),this._size++,t},t.prototype.size=function(){return this._size},t.prototype.clear=function(){this._minimum=null,this._size=0},t.prototype.isEmpty=function(){return 0===this._size},t.prototype.extractMinimum=function(){var e=this._minimum;if(null===e)return e;for(var t=this._minimum,r=e.degree,n=e.child;0{var{typed:e,Complex:r,matrix:n,ceil:i,floor:a}=e,o=fu({typed:e});return e("fix",{number:function(e){return(0this(e,t),!0)},"number | Complex | BigNumber, Array":function(e,t){return o(n(t),e,this,!0).valueOf()}})});function Xl(e){var t,r,n;if(O(e))return e<=0?isFinite(e)?1/0:NaN:171+_(I(e),I(t))),100T(r,e))).shift();c.length2*Math.random()-1);n&&(e=e.map(e=>z(e)));i&&(e=e.map(e=>D(e)));return J(e=W(e,t),r)}(t,r,i),a=L(e,a),G(Y(a),o))break;if(5<=++s)return null}s=0;for(;;){var u=L(e,a);if(R(Y(W(a,[u])),n))break;if(10<=++s)return null;a=J(u)}return a}(w,t,c,f,n);if(null==N){x.push(b);break}c.push(N)}d.push(...c.map(e=>U(e)))}if(0===x.length)return d;e=new Error("Failed to find eigenvectors for the following eigenvalues: "+x.join(", "));throw e.values=l,e.vectors=d,e}(l,f,g,i,p,m),O=V(...O)),{values:i,vectors:O}}}function xf(e){var{config:O,addScalar:C,subtract:_,abs:T,atan:R,cos:B,sin:q,multiplyScalar:I,inv:U,bignumber:z,multiply:k,add:F}=e;function P(e){for(var t=e.length,r=0,n=[0,1],i=0;i=Math.abs(d);){var i=y[0][0],a=y[0][1];m=function(e,t,r){var n=t-e;return Math.abs(n)<=O.epsilon?Math.PI/4:.5*Math.atan(2*r/(t-e))}(e[i][i],e[a][a],e[i][a]),e=function(e,t,r,n){for(var i=e.length,a=Math.cos(t),o=Math.sin(t),t=a*a,s=o*o,l=D(i,0),f=D(i,0),p=t*e[r][r]-2*a*o*e[r][n]+s*e[n][n],s=s*e[r][r]+2*a*o*e[r][n]+t*e[n][n],u=0;u=T(x);){var M=N[0][0],E=N[0][1];v=function(e,t,r){t=_(t,e);return T(t)<=O.epsilon?z(-1).acos().div(4):I(.5,R(k(2,r,U(t))))}(s[M][M],s[E][E],s[M][E]),s=function(e,t,r,n){for(var i=e.length,a=z(B(t)),o=z(q(t)),t=I(a,a),s=I(o,o),l=D(i,z(0)),f=D(i,z(0)),p=k(z(2),a,o,e[r][n]),m=C(_(I(t,e[r][r]),p),I(s,e[n][n])),s=F(I(s,e[r][r]),p,I(t,e[n][n])),u=0;u{var{typed:e,config:o,BigNumber:s,Complex:u}=e;return e("gamma",{number:Xl,Complex:function(e){if(0===e.im)return this(e.re);if(e.re<.5)return a=new u(1-e.re,-e.im),i=new u(Math.PI*e.re,Math.PI*e.im),new u(Math.PI).div(i.sin()).div(this(a));e=new u(e.re-1,e.im);for(var t=new u(Kl[0],0),r=1;r{var{typed:e,Index:r}=e;return e("index",{"...number | string | BigNumber | Range | Array | Matrix":function(e){var e=e.map(function(e){return D(e)?e.toNumber():Array.isArray(e)||q(e)?e.map(function(e){return D(e)?e.toNumber():e}):e}),t=new r;return r.apply(t,e),t}})})({Index:uc,typed:r}),If=a("lcm",["typed","matrix","equalScalar"],e=>{var{typed:e,matrix:r,equalScalar:t}=e,n=au({typed:e,equalScalar:t}),i=hu({typed:e,equalScalar:t}),a=uu({typed:e,equalScalar:t}),o=lu({typed:e}),s=fu({typed:e});return e("lcm",{"number, number":ia,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(e.isZero())return e;if(t.isZero())return t;var r=e.times(t);for(;!t.isZero();){var n=t;t=e.mod(n),e=n}return r.div(e).abs()},"Fraction, Fraction":function(e,t){return e.lcm(t)},"SparseMatrix, SparseMatrix":function(e,t){return i(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return n(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return n(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return o(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return a(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return a(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return s(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return s(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return s(r(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:e,add:d,multiply:y,partitionSelect:g,compare:v}=e;function h(l,e,f){var t=rt(l),l=t.length;if(0===l)throw new Error("Cannot calculate quantile of an empty sequence");if(k(e)){var r=e*(l-1),n=r%1;if(0==n)return s=f?t[r]:g(t,r),x(s),s;var i=Math.floor(r);if(f)o=t[i],a=t[i+1];else for(var a=g(t,i+1),o=t[i],p=0;p{var{typed:e,size:u,subset:c,compareNatural:l,Index:f,DenseMatrix:p}=e;return e(ef,{"Array | Matrix, Array | Matrix":function(e,t){if(0===c(u(e),new f(0)))i=[];else{if(0===c(u(t),new f(0)))return rt(e.toArray());for(var r=ut(rt(Array.isArray(e)?e:e.toArray()).sort(l)),n=ut(rt(Array.isArray(t)?t:t.toArray()).sort(l)),i=[],a=0;a{var{typed:e,size:a,subset:o,compareNatural:s,Index:u}=e;return e(tf,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,t){if(0===o(a(t),new u(0)))return 0;for(var r=rt(Array.isArray(t)?t:t.toArray()),n=0,i=0;i{var{typed:e,size:r,concat:n,subset:i,setDifference:a,Index:o}=e;return e(rf,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new o(0)))return rt(t);if(0===i(r(t),new o(0)))return rt(e);e=rt(e),t=rt(t);return n(a(e,t),a(t,e))}})})({Index:uc,concat:Ef,setDifference:Df,size:Nu,subset:Mf,typed:r}),Ff=a("sort",["typed","matrix","compare","compareNatural"],e=>{var{typed:e,matrix:r,compare:n,compareNatural:t}=e,i=n,a=(e,t)=>-n(e,t);return e("sort",{Array:function(e){return s(e),e.sort(i)},Matrix:function(e){return u(e),r(e.toArray().sort(i),e.storage())},"Array, function":function(e,t){return s(e),e.sort(t)},"Matrix, function":function(e,t){return u(e),r(e.toArray().sort(t),e.storage())},"Array, string":function(e,t){return s(e),e.sort(o(t))},"Matrix, string":function(e,t){return u(e),r(e.toArray().sort(o(t)),e.storage())}});function o(e){if("asc"===e)return i;if("desc"===e)return a;if("natural"===e)return t;throw new Error('String "asc", "desc", or "natural" expected')}function s(e){if(1!==Ze(e).length)throw new Error("One dimensional array expected")}function u(e){if(1!==e.size().length)throw new Error("One dimensional matrix expected")}})({compare:ju,compareNatural:Jc,matrix:n,typed:r}),i=a("Unit",["?on","config","addScalar","subtract","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","number","Complex","BigNumber","Fraction"],e=>{var g,h,E,{on:e,config:v,addScalar:u,subtract:c,multiplyScalar:l,divideScalar:f,pow:p,abs:m,fix:x,round:b,equal:w,isNumeric:n,format:a,number:t,Complex:r,BigNumber:N,Fraction:M}=e,i=t;function S(e,t){if(!(this instanceof S))throw new Error("Constructor must be called with the new operator");if(null!=e&&!n(e)&&!V(e))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(void 0!==t&&("string"!=typeof t||""===t))throw new TypeError("Second parameter in Unit constructor must be a string");if(void 0!==t){t=S.parse(t);this.units=t.units,this.dimensions=t.dimensions}else{this.units=[{unit:R,prefix:A.NONE,power:0}],this.dimensions=[];for(var r=0;r{var t,r;if(ie(_,e))return{unit:t=_[e],prefix:t.prefixes[""]};for(r in _)if(ie(_,r)&&(a=r,i=n=void 0,n=e.length-a.length,i=e.length,e.substring(n,i)===a)){var n=_[r],i=e.length-r.length,a=e.substring(0,i),o=ie(n.prefixes,a)?n.prefixes[a]:void 0;if(void 0!==o)return{unit:n,prefix:o}}return null},{hasher:e=>e[0],limit:100});function s(e){return e.equalBase(C.NONE)&&null!==e.value&&!v.predictable?e.value:e}S.isValuelessUnit=function(e){return null!==k(e)},S.prototype.hasBase=function(e){if(!(e="string"==typeof e?C[e]:e))return!1;for(var t=0;t0)},_={meter:{name:"meter",base:C.LENGTH,prefixes:A.LONG,value:1,offset:0},inch:{name:"inch",base:C.LENGTH,prefixes:A.NONE,value:.0254,offset:0},foot:{name:"foot",base:C.LENGTH,prefixes:A.NONE,value:.3048,offset:0},yard:{name:"yard",base:C.LENGTH,prefixes:A.NONE,value:.9144,offset:0},mile:{name:"mile",base:C.LENGTH,prefixes:A.NONE,value:1609.344,offset:0},link:{name:"link",base:C.LENGTH,prefixes:A.NONE,value:.201168,offset:0},rod:{name:"rod",base:C.LENGTH,prefixes:A.NONE,value:5.0292,offset:0},chain:{name:"chain",base:C.LENGTH,prefixes:A.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:C.LENGTH,prefixes:A.NONE,value:1e-10,offset:0},m:{name:"m",base:C.LENGTH,prefixes:A.SHORT,value:1,offset:0},in:{name:"in",base:C.LENGTH,prefixes:A.NONE,value:.0254,offset:0},ft:{name:"ft",base:C.LENGTH,prefixes:A.NONE,value:.3048,offset:0},yd:{name:"yd",base:C.LENGTH,prefixes:A.NONE,value:.9144,offset:0},mi:{name:"mi",base:C.LENGTH,prefixes:A.NONE,value:1609.344,offset:0},li:{name:"li",base:C.LENGTH,prefixes:A.NONE,value:.201168,offset:0},rd:{name:"rd",base:C.LENGTH,prefixes:A.NONE,value:5.02921,offset:0},ch:{name:"ch",base:C.LENGTH,prefixes:A.NONE,value:20.1168,offset:0},mil:{name:"mil",base:C.LENGTH,prefixes:A.NONE,value:254e-7,offset:0},m2:{name:"m2",base:C.SURFACE,prefixes:A.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:C.SURFACE,prefixes:A.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:C.SURFACE,prefixes:A.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:C.SURFACE,prefixes:A.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:C.SURFACE,prefixes:A.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:C.SURFACE,prefixes:A.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:C.SURFACE,prefixes:A.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:C.SURFACE,prefixes:A.NONE,value:6.4516e-10,offset:0},acre:{name:"acre",base:C.SURFACE,prefixes:A.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:C.SURFACE,prefixes:A.NONE,value:1e4,offset:0},m3:{name:"m3",base:C.VOLUME,prefixes:A.CUBIC,value:1,offset:0},L:{name:"L",base:C.VOLUME,prefixes:A.SHORT,value:.001,offset:0},l:{name:"l",base:C.VOLUME,prefixes:A.SHORT,value:.001,offset:0},litre:{name:"litre",base:C.VOLUME,prefixes:A.LONG,value:.001,offset:0},cuin:{name:"cuin",base:C.VOLUME,prefixes:A.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:C.VOLUME,prefixes:A.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:C.VOLUME,prefixes:A.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:C.VOLUME,prefixes:A.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:C.VOLUME,prefixes:A.NONE,value:15e-6,offset:0},drop:{name:"drop",base:C.VOLUME,prefixes:A.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:C.VOLUME,prefixes:A.NONE,value:5e-8,offset:0},minim:{name:"minim",base:C.VOLUME,prefixes:A.NONE,value:6.161152e-8,offset:0},fluiddram:{name:"fluiddram",base:C.VOLUME,prefixes:A.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:C.VOLUME,prefixes:A.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:C.VOLUME,prefixes:A.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:C.VOLUME,prefixes:A.NONE,value:1e-6,offset:0},cup:{name:"cup",base:C.VOLUME,prefixes:A.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:C.VOLUME,prefixes:A.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:C.VOLUME,prefixes:A.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:C.VOLUME,prefixes:A.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:C.VOLUME,prefixes:A.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:C.VOLUME,prefixes:A.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:C.VOLUME,prefixes:A.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:C.VOLUME,prefixes:A.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:C.VOLUME,prefixes:A.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:C.VOLUME,prefixes:A.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:C.VOLUME,prefixes:A.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:C.VOLUME,prefixes:A.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:C.VOLUME,prefixes:A.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:C.VOLUME,prefixes:A.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:C.VOLUME,prefixes:A.NONE,value:.1173478,offset:0},obl:{name:"obl",base:C.VOLUME,prefixes:A.NONE,value:.1589873,offset:0},g:{name:"g",base:C.MASS,prefixes:A.SHORT,value:.001,offset:0},gram:{name:"gram",base:C.MASS,prefixes:A.LONG,value:.001,offset:0},ton:{name:"ton",base:C.MASS,prefixes:A.SHORT,value:907.18474,offset:0},t:{name:"t",base:C.MASS,prefixes:A.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:C.MASS,prefixes:A.LONG,value:1e3,offset:0},grain:{name:"grain",base:C.MASS,prefixes:A.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:C.MASS,prefixes:A.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:C.MASS,prefixes:A.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:C.MASS,prefixes:A.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:C.MASS,prefixes:A.NONE,value:45.359237,offset:0},stick:{name:"stick",base:C.MASS,prefixes:A.NONE,value:.115,offset:0},stone:{name:"stone",base:C.MASS,prefixes:A.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:C.MASS,prefixes:A.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:C.MASS,prefixes:A.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:C.MASS,prefixes:A.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:C.MASS,prefixes:A.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:C.MASS,prefixes:A.NONE,value:45.359237,offset:0},s:{name:"s",base:C.TIME,prefixes:A.SHORT,value:1,offset:0},min:{name:"min",base:C.TIME,prefixes:A.NONE,value:60,offset:0},h:{name:"h",base:C.TIME,prefixes:A.NONE,value:3600,offset:0},second:{name:"second",base:C.TIME,prefixes:A.LONG,value:1,offset:0},sec:{name:"sec",base:C.TIME,prefixes:A.LONG,value:1,offset:0},minute:{name:"minute",base:C.TIME,prefixes:A.NONE,value:60,offset:0},hour:{name:"hour",base:C.TIME,prefixes:A.NONE,value:3600,offset:0},day:{name:"day",base:C.TIME,prefixes:A.NONE,value:86400,offset:0},week:{name:"week",base:C.TIME,prefixes:A.NONE,value:604800,offset:0},month:{name:"month",base:C.TIME,prefixes:A.NONE,value:2629800,offset:0},year:{name:"year",base:C.TIME,prefixes:A.NONE,value:31557600,offset:0},decade:{name:"decade",base:C.TIME,prefixes:A.NONE,value:315576e3,offset:0},century:{name:"century",base:C.TIME,prefixes:A.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:C.TIME,prefixes:A.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:C.FREQUENCY,prefixes:A.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:C.FREQUENCY,prefixes:A.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:C.ANGLE,prefixes:A.SHORT,value:1,offset:0},radian:{name:"radian",base:C.ANGLE,prefixes:A.LONG,value:1,offset:0},deg:{name:"deg",base:C.ANGLE,prefixes:A.SHORT,value:null,offset:0},degree:{name:"degree",base:C.ANGLE,prefixes:A.LONG,value:null,offset:0},grad:{name:"grad",base:C.ANGLE,prefixes:A.SHORT,value:null,offset:0},gradian:{name:"gradian",base:C.ANGLE,prefixes:A.LONG,value:null,offset:0},cycle:{name:"cycle",base:C.ANGLE,prefixes:A.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:C.ANGLE,prefixes:A.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:C.ANGLE,prefixes:A.NONE,value:null,offset:0},A:{name:"A",base:C.CURRENT,prefixes:A.SHORT,value:1,offset:0},ampere:{name:"ampere",base:C.CURRENT,prefixes:A.LONG,value:1,offset:0},K:{name:"K",base:C.TEMPERATURE,prefixes:A.NONE,value:1,offset:0},degC:{name:"degC",base:C.TEMPERATURE,prefixes:A.NONE,value:1,offset:273.15},degF:{name:"degF",base:C.TEMPERATURE,prefixes:A.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:C.TEMPERATURE,prefixes:A.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:C.TEMPERATURE,prefixes:A.NONE,value:1,offset:0},celsius:{name:"celsius",base:C.TEMPERATURE,prefixes:A.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:C.TEMPERATURE,prefixes:A.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:C.TEMPERATURE,prefixes:A.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:C.AMOUNT_OF_SUBSTANCE,prefixes:A.SHORT,value:1,offset:0},mole:{name:"mole",base:C.AMOUNT_OF_SUBSTANCE,prefixes:A.LONG,value:1,offset:0},cd:{name:"cd",base:C.LUMINOUS_INTENSITY,prefixes:A.SHORT,value:1,offset:0},candela:{name:"candela",base:C.LUMINOUS_INTENSITY,prefixes:A.LONG,value:1,offset:0},N:{name:"N",base:C.FORCE,prefixes:A.SHORT,value:1,offset:0},newton:{name:"newton",base:C.FORCE,prefixes:A.LONG,value:1,offset:0},dyn:{name:"dyn",base:C.FORCE,prefixes:A.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:C.FORCE,prefixes:A.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:C.FORCE,prefixes:A.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:C.FORCE,prefixes:A.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:C.FORCE,prefixes:A.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:C.FORCE,prefixes:A.NONE,value:9.80665,offset:0},J:{name:"J",base:C.ENERGY,prefixes:A.SHORT,value:1,offset:0},joule:{name:"joule",base:C.ENERGY,prefixes:A.SHORT,value:1,offset:0},erg:{name:"erg",base:C.ENERGY,prefixes:A.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:C.ENERGY,prefixes:A.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:C.ENERGY,prefixes:A.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:C.ENERGY,prefixes:A.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:C.ENERGY,prefixes:A.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:C.POWER,prefixes:A.SHORT,value:1,offset:0},watt:{name:"watt",base:C.POWER,prefixes:A.LONG,value:1,offset:0},hp:{name:"hp",base:C.POWER,prefixes:A.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:C.POWER,prefixes:A.SHORT,value:r.I,offset:0},VA:{name:"VA",base:C.POWER,prefixes:A.SHORT,value:1,offset:0},Pa:{name:"Pa",base:C.PRESSURE,prefixes:A.SHORT,value:1,offset:0},psi:{name:"psi",base:C.PRESSURE,prefixes:A.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:C.PRESSURE,prefixes:A.NONE,value:101325,offset:0},bar:{name:"bar",base:C.PRESSURE,prefixes:A.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:C.PRESSURE,prefixes:A.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:C.PRESSURE,prefixes:A.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:C.PRESSURE,prefixes:A.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:C.PRESSURE,prefixes:A.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:C.ELECTRIC_CHARGE,prefixes:A.LONG,value:1,offset:0},C:{name:"C",base:C.ELECTRIC_CHARGE,prefixes:A.SHORT,value:1,offset:0},farad:{name:"farad",base:C.ELECTRIC_CAPACITANCE,prefixes:A.LONG,value:1,offset:0},F:{name:"F",base:C.ELECTRIC_CAPACITANCE,prefixes:A.SHORT,value:1,offset:0},volt:{name:"volt",base:C.ELECTRIC_POTENTIAL,prefixes:A.LONG,value:1,offset:0},V:{name:"V",base:C.ELECTRIC_POTENTIAL,prefixes:A.SHORT,value:1,offset:0},ohm:{name:"ohm",base:C.ELECTRIC_RESISTANCE,prefixes:A.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:C.ELECTRIC_INDUCTANCE,prefixes:A.LONG,value:1,offset:0},H:{name:"H",base:C.ELECTRIC_INDUCTANCE,prefixes:A.SHORT,value:1,offset:0},siemens:{name:"siemens",base:C.ELECTRIC_CONDUCTANCE,prefixes:A.LONG,value:1,offset:0},S:{name:"S",base:C.ELECTRIC_CONDUCTANCE,prefixes:A.SHORT,value:1,offset:0},weber:{name:"weber",base:C.MAGNETIC_FLUX,prefixes:A.LONG,value:1,offset:0},Wb:{name:"Wb",base:C.MAGNETIC_FLUX,prefixes:A.SHORT,value:1,offset:0},tesla:{name:"tesla",base:C.MAGNETIC_FLUX_DENSITY,prefixes:A.LONG,value:1,offset:0},T:{name:"T",base:C.MAGNETIC_FLUX_DENSITY,prefixes:A.SHORT,value:1,offset:0},b:{name:"b",base:C.BIT,prefixes:A.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:C.BIT,prefixes:A.BINARY_LONG,value:1,offset:0},B:{name:"B",base:C.BIT,prefixes:A.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:C.BIT,prefixes:A.BINARY_LONG,value:8,offset:0}},U={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 F(e){"BigNumber"===e.number?(e=fn(N),_.rad.value=new N(1),_.deg.value=e.div(180),_.grad.value=e.div(200),_.cycle.value=e.times(2),_.arcsec.value=e.div(648e3),_.arcmin.value=e.div(10800)):(_.rad.value=1,_.deg.value=Math.PI/180,_.grad.value=Math.PI/200,_.cycle.value=2*Math.PI,_.arcsec.value=Math.PI/648e3,_.arcmin.value=Math.PI/10800),_.radian.value=_.rad.value,_.degree.value=_.deg.value,_.gradian.value=_.grad.value}F(v),e&&e("config",function(e,t){e.number!==t.number&&F(e)});var P,j,L,y={si:{NONE:{unit:R,prefix:A.NONE[""]},LENGTH:{unit:_.m,prefix:A.SHORT[""]},MASS:{unit:_.g,prefix:A.SHORT.k},TIME:{unit:_.s,prefix:A.SHORT[""]},CURRENT:{unit:_.A,prefix:A.SHORT[""]},TEMPERATURE:{unit:_.K,prefix:A.SHORT[""]},LUMINOUS_INTENSITY:{unit:_.cd,prefix:A.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:_.mol,prefix:A.SHORT[""]},ANGLE:{unit:_.rad,prefix:A.SHORT[""]},BIT:{unit:_.bits,prefix:A.SHORT[""]},FORCE:{unit:_.N,prefix:A.SHORT[""]},ENERGY:{unit:_.J,prefix:A.SHORT[""]},POWER:{unit:_.W,prefix:A.SHORT[""]},PRESSURE:{unit:_.Pa,prefix:A.SHORT[""]},ELECTRIC_CHARGE:{unit:_.C,prefix:A.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:_.F,prefix:A.SHORT[""]},ELECTRIC_POTENTIAL:{unit:_.V,prefix:A.SHORT[""]},ELECTRIC_RESISTANCE:{unit:_.ohm,prefix:A.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:_.H,prefix:A.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:_.S,prefix:A.SHORT[""]},MAGNETIC_FLUX:{unit:_.Wb,prefix:A.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:_.T,prefix:A.SHORT[""]},FREQUENCY:{unit:_.Hz,prefix:A.SHORT[""]}}},T=(y.cgs=JSON.parse(JSON.stringify(y.si)),y.cgs.LENGTH={unit:_.m,prefix:A.SHORT.c},y.cgs.MASS={unit:_.g,prefix:A.SHORT[""]},y.cgs.FORCE={unit:_.dyn,prefix:A.SHORT[""]},y.cgs.ENERGY={unit:_.erg,prefix:A.NONE[""]},y.us=JSON.parse(JSON.stringify(y.si)),y.us.LENGTH={unit:_.ft,prefix:A.NONE[""]},y.us.MASS={unit:_.lbm,prefix:A.NONE[""]},y.us.TEMPERATURE={unit:_.degF,prefix:A.NONE[""]},y.us.FORCE={unit:_.lbf,prefix:A.NONE[""]},y.us.ENERGY={unit:_.BTU,prefix:A.BTU[""]},y.us.POWER={unit:_.hp,prefix:A.NONE[""]},y.us.PRESSURE={unit:_.psi,prefix:A.NONE[""]},y.auto=JSON.parse(JSON.stringify(y.si)),y.auto);for(P in S.setUnitSystem=function(e){if(!ie(y,e))throw new Error("Unit system "+e+" does not exist. Choices are: "+Object.keys(y).join(", "));T=y[e]},S.getUnitSystem=function(){for(var e in y)if(ie(y,e)&&y[e]===T)return e},S.typeConverters={BigNumber:function(e){return new N(e+"")},Fraction:function(e){return new M(e)},Complex:function(e){return e},number:function(e){return e}},S._getNumberConverter=function(e){if(!S.typeConverters[e])throw new TypeError('Unsupported type "'+e+'"');return S.typeConverters[e]},_)ie(_,P)&&((j=_[P]).dimensions=j.base.dimensions);for(L in U)if(ie(U,L)){var H,$=_[U[L]],G={};for(H in $)ie($,H)&&(G[H]=$[H]);G.name=L,_[L]=G}return S.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)},S.createUnit=function(e,t){if("object"!=typeof e)throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(t&&t.override)for(var r in e)if(ie(e,r)&&S.deleteUnit(r),e[r].aliases)for(var n=0;n{var{typed:e,Unit:i}=e;return e(of,{"Object, Object":function(e,t){return i.createUnit(e,t)},Object:function(e){return i.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,t,r){var n={};return n[e]=t,i.createUnit(n,r)},"string, Unit | string | Object":function(e,t){var r={};return r[e]=t,i.createUnit(r,{})},string:function(e){var t={};return t[e]={},i.createUnit(t,{})}})})({Unit:i,typed:r}),ni=ni({BigNumber:t,Unit:i,config:e}),jf=a("dotPow",["typed","equalScalar","matrix","pow","DenseMatrix"],e=>{var{typed:e,equalScalar:t,matrix:r,pow:n,DenseMatrix:i}=e,a=ou({typed:e}),o=Mu({typed:e,DenseMatrix:i}),s=uu({typed:e,equalScalar:t}),u=cu({typed:e,DenseMatrix:i}),l=lu({typed:e}),c=fu({typed:e});return e("dotPow",{"any, any":n,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,n,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,n,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,n,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,n)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return u(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})})({DenseMatrix:Ui,equalScalar:No,matrix:n,pow:dl,typed:r}),Pn=Pn({BigNumber:t,Unit:i,config:e}),Hn=Hn({BigNumber:t,Unit:i,config:e}),Lf=a(sf,["typed","gamma"],e=>{var{typed:e,gamma:t}=e;return e(sf,{number:function(e){if(e<0)throw new Error("Value must be non-negative");return t(e+1)},BigNumber:function(e){if(e.isNegative())throw new Error("Value must be non-negative");return t(e.plus(1))},"Array | Matrix":function(e){return ae(e,this)}})})({gamma:Bf,typed:r}),Kn=Kn({BigNumber:t,Unit:i,config:e}),yi=yi({BigNumber:t,Unit:i,config:e}),Si=Si({BigNumber:t,Unit:i,config:e}),Hf=a("intersect",["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],e=>{var{typed:e,config:A,abs:O,add:C,addScalar:g,matrix:i,multiply:_,multiplyScalar:v,divideScalar:x,subtract:b,smaller:T,equalScalar:w,flatten:t,isZero:B,isNumeric:m}=e;return e("intersect",{"Array, Array, Array":n,"Array, Array, Array, Array":a,"Matrix, Matrix, Matrix":function(e,t,r){e=n(e.valueOf(),t.valueOf(),r.valueOf());return null===e?null:i(e)},"Matrix, Matrix, Matrix, Matrix":function(e,t,r,n){e=a(e.valueOf(),t.valueOf(),r.valueOf(),n.valueOf());return null===e?null:i(e)}});function n(e,t,r){if(e=N(e),t=N(t),r=N(r),!E(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!E(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!(4===(n=r).length&&m(n[0])&&m(n[1])&&m(n[2])&&m(n[3])))throw new TypeError("Array with 4 numbers expected as third argument");var n,i,l,f,a,o,s,u,c,p;return n=e[0],i=e[1],e=e[2],l=t[0],f=t[1],t=t[2],a=r[0],o=r[1],s=r[2],r=r[3],u=v(n,a),a=v(l,a),c=v(i,o),o=v(f,o),p=v(e,s),s=v(t,s),r=b(b(b(r,u),c),p),a=b(b(b(g(g(a,o),s),u),c),p),o=x(r,a),s=g(n,v(o,b(l,n))),u=g(i,v(o,b(f,i))),c=g(e,v(o,b(t,e))),[s,u,c]}function a(e,t,r,n){if(e=N(e),t=N(t),r=N(r),n=N(n),2===e.length){if(!M(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!M(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!M(r))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!M(n))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");var i=e,a=r,o=n,s=b(i,s=t),o=b(a,o),u=b(v(s[0],o[1]),v(o[0],s[1]));if(B(u))return null;if(T(O(u),A.epsilon))return null;var c=v(o[0],i[1]),l=v(o[1],i[0]),f=v(o[0],a[1]),o=v(o[1],a[0]),a=x(g(b(b(c,l),f),o),u);return C(_(s,a),i)}if(3!==e.length)throw new TypeError("Arrays with two or thee dimensional points expected");if(!E(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!E(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!E(r))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!E(n))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");var c=e[0],l=e[1],f=e[2],o=t[0],u=t[1],s=t[2],a=r[0],i=r[1],e=r[2],t=n[0],r=n[1],n=n[2],p=S(c,a,t,a,l,i,r,i,f,e,n,e),m=S(t,a,o,c,r,i,u,l,n,e,s,f),h=S(c,a,o,c,l,i,u,l,f,e,s,f),d=S(t,a,t,a,r,i,r,i,n,e,n,e),y=S(o,c,o,c,u,l,u,l,s,f,s,f),h=b(v(p,m),v(h,d)),y=b(v(y,d),v(m,m));return B(y)?null:(h=x(h,y),y=x(g(p,v(h,m)),d),p=g(c,v(h,b(o,c))),m=g(l,v(h,b(u,l))),d=g(f,v(h,b(s,f))),o=g(a,v(y,b(t,a))),c=g(i,v(y,b(r,i))),u=g(e,v(y,b(n,e))),w(p,o)&&w(m,c)&&w(d,u)?[p,m,d]:null)}function N(e){return 1===e.length?e[0]:1Array.isArray(e)&&1===e.length)?t(e):e}function M(e){return 2===e.length&&m(e[0])&&m(e[1])}function E(e){return 3===e.length&&m(e[0])&&m(e[1])&&m(e[2])}function S(e,t,r,n,i,a,o,s,u,c,l,f){e=v(b(e,t),b(r,n)),t=v(b(i,a),b(o,s)),r=v(b(u,c),b(l,f));return g(g(e,t),r)}})({abs:Vi,add:Lc,addScalar:Da,config:e,divideScalar:Yu,equalScalar:No,flatten:tc,isNumeric:ru,isZero:Xo,matrix:n,multiply:hl,multiplyScalar:rs,smaller:Su,subtract:Tu,typed:r}),Vn=Vn({BigNumber:t,Unit:i,config:e}),Yn=Yn({BigNumber:t,Unit:i,config:e}),di=di({BigNumber:t,Unit:i,config:e}),Fn=Fn({BigNumber:t,Unit:i,config:e}),Mi=Mi({BigNumber:t,Unit:i,config:e}),gi=gi({BigNumber:t,Unit:i,config:e}),ii=ii({BigNumber:t,Unit:i,config:e}),Wn=Wn({BigNumber:t,Unit:i,config:e}),$f=a(uf,["typed","factorial"],e=>{var{typed:e,factorial:t}=e;return e(uf,{"number | BigNumber":t,"number, number":function(e,t){if(!O(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!O(t)||t<0)throw new TypeError("Positive integer value expected in function permutations");if(e{var{typed:e,size:s,subset:u,compareNatural:c,Index:l,DenseMatrix:f}=e;return e(lf,{"Array | Matrix, Array | Matrix":function(e,t){if(0===u(s(e),new l(0))||0===u(s(t),new l(0)))i=[];else for(var r=ut(rt(Array.isArray(e)?e:e.toArray()).sort(c)),n=ut(rt(Array.isArray(t)?t:t.toArray()).sort(c)),i=[],a=0;a{var{typed:e,size:r,concat:n,subset:i,setIntersect:a,setSymDifference:o,Index:s}=e;return e(ff,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new s(0)))return rt(t);if(0===i(r(t),new s(0)))return rt(e);e=rt(e),t=rt(t);return n(o(e,t),a(e,t))}})})({Index:uc,concat:Ef,setIntersect:Gf,setSymDifference:Uf,size:Nu,subset:Mf,typed:r}),Zf=a("Spa",["addScalar","equalScalar","FibonacciHeap"],e=>{var{addScalar:n,equalScalar:c,FibonacciHeap:t}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new t}return r.prototype.type="Spa",r.prototype.isSpa=!0,r.prototype.set=function(e,t){this._values[e]?this._values[e].value=t:(t=this._heap.insert(e,t),this._values[e]=t)},r.prototype.get=function(e){e=this._values[e];return e?e.value:0},r.prototype.accumulate=function(e,t){var r=this._values[e];r?r.value=n(r.value,t):(r=this._heap.insert(e,t),this._values[e]=r)},r.prototype.forEach=function(e,t,r){var n=this._heap,i=this._values,a=[];for((s=n.extractMinimum())&&a.push(s);s&&s.key<=t;)s.key>=e&&(c(s.value,0)||r(s.key,s.value,this)),(s=n.extractMinimum())&&a.push(s);for(var o=0;o{var{typed:e,Unit:r}=e;return e("unit",{Unit:function(e){return e.clone()},string:function(e){return r.isValuelessUnit(e)?new r(null,e):r.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string":function(e,t){return new r(e,t)},"Array | Matrix":function(e){return ae(e,this)}})})({Unit:i,typed:r}),fi=fi({BigNumber:t,Unit:i,config:e}),Jn=Jn({BigNumber:t,Unit:i,config:e}),Ln=Ln({BigNumber:t,Unit:i,config:e}),Qn=Qn({BigNumber:t,Unit:i,config:e}),mi=mi({BigNumber:t,Unit:i,config:e}),ti=ti({BigNumber:t,Unit:i,config:e}),Yf=a("log1p",["typed","config","divideScalar","log","Complex"],e=>{var{typed:e,config:r,divideScalar:n,log:i,Complex:a}=e;return e("log1p",{number:function(e){return-1<=e||r.predictable?G(e):o(new a(e,0))},Complex:o,BigNumber:function(e){var t=e.plus(1);return!t.isNegative()||r.predictable?t.ln():o(new a(e.toNumber(),0))},"Array | Matrix":function(e){return ae(e,this)},"any, any":function(e,t){return n(this(e),i(t))}});function o(e){var t=e.re+1;return new a(Math.log(Math.sqrt(t*t+e.im*e.im)),Math.atan2(e.im,t))}})({Complex:un,config:e,divideScalar:Yu,log:ul,typed:r}),Zn=Zn({BigNumber:t,Unit:i,config:e}),Ei=Ei({BigNumber:t,Unit:i,config:e}),_i=_i({BigNumber:t,Unit:i,config:e}),Ti=Ti({BigNumber:t,Unit:i,config:e}),bi=bi({BigNumber:t,Unit:i,config:e}),kn=kn({BigNumber:t,Unit:i,config:e}),Jf=a(pf,["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","larger"],e=>{var{typed:e,addScalar:u,subtract:c,multiplyScalar:l,divideScalar:f,pow:p,factorial:m,combinations:h,isNegative:d,isInteger:y,larger:g}=e;return e(pf,{"number | BigNumber, number | BigNumber":function(e,t){if(!y(e)||d(e)||!y(t)||d(t))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(g(t,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");for(var r=m(t),n=0,i=0;i<=t;i++)var a=p(-1,c(t,i)),o=h(t,i),s=p(i,e),n=u(n,l(l(o,s),a));return f(n,r)}})})({addScalar:Da,combinations:fo,divideScalar:Yu,factorial:Lf,isInteger:Lo,isNegative:Ho,larger:sl,multiplyScalar:rs,pow:dl,subtract:Tu,typed:r}),Xf=a(mf,["typed","addScalar","isNegative","isInteger","stirlingS2"],e=>{var{typed:e,addScalar:n,isNegative:i,isInteger:a,stirlingS2:o}=e;return e(mf,{"number | BigNumber":function(e){if(!a(e)||i(e))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var t=0,r=0;r<=e;r++)t=n(t,o(e,r));return t}})})({addScalar:Da,isInteger:Lo,isNegative:Ho,stirlingS2:Jf,typed:r}),hi=hi({BigNumber:t,Unit:i,config:e}),Qf=a("lup",["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],e=>{var{typed:e,matrix:t,abs:A,addScalar:N,divideScalar:O,multiplyScalar:C,subtract:M,larger:_,equalScalar:T,unaryMinus:q,DenseMatrix:w,SparseMatrix:B,Spa:I}=e;return e("lup",{DenseMatrix:r,SparseMatrix:function(e){var c,l,f,p=e._size[0],t=e._size[1],r=Math.min(p,t),v=e._values,x=e._index,b=e._ptr,m=[],h=[],d=[],w=[p,r],y=[],N=[],M=[],E=[r,t],g=[],S=[];for(c=0;c{var{typed:e,compareNatural:a}=e;return e(hf,{"Array | Matrix":function(e){return(Array.isArray(e)?rt(e):rt(e.toArray())).length},"Array | Matrix, boolean":function(e,t){if(!1===t||0===e.length)return(Array.isArray(e)?rt(e):rt(e.toArray())).length;for(var r=rt(Array.isArray(e)?e:e.toArray()).sort(a),n=1,i=1;i{var{typed:e,matrix:m,subtract:h,multiply:d,unaryMinus:y,lup:g}=e;return e("det",{any:X,"Array | Matrix":function(e){var t=q(e)?e.size():Array.isArray(e)?(e=m(e)).size():[];switch(t.length){case 0:return X(e);case 1:if(1===t[0])return X(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+Ee(t)+")");case 2:var l=t[0],r=t[1];if(l!==r)throw new RangeError("Matrix must be square (size: "+Ee(t)+")");var r=e.clone().valueOf(),n=l;if(1===n)return X(r[0][0]);if(2===n)return h(d(r[0][0],r[1][1]),d(r[1][0],r[0][1]));for(var i=g(r),a=i.U[0][0],o=1;o{var{typed:e,matrix:i,divideScalar:g,addScalar:v,multiply:x,unaryMinus:b,det:w,identity:N,abs:M}=e;return e("inv",{"Array | Matrix":function(e){var t=q(e)?e.size():Ze(e);switch(t.length){case 1:if(1===t[0])return q(e)?i([g(1,e.valueOf()[0])]):[g(1,e[0])];throw new RangeError("Matrix must be square (size: "+Ee(t)+")");case 2:var r=t[0],n=t[1];if(r===n)return q(e)?i(a(e.valueOf(),r,n),e.storage()):a(e,r,n);throw new RangeError("Matrix must be square (size: "+Ee(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+Ee(t)+")")}},any:function(e){return g(1,e)}});function a(e,t,l){var r,n,f;if(1===t){if(0===(i=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero");return[[g(1,i)]]}if(2===t){var i=w(e);if(0===i)throw Error("Cannot calculate inverse, determinant is zero");return[[g(e[1][1],i),g(b(e[0][1]),i)],[g(b(e[1][0]),i),g(e[0][0],i)]]}var a=e.concat();for(u=0;up&&(p=M(a[u][s]),m=u),u++;if(0===p)throw Error("Cannot calculate inverse, determinant is zero");(u=m)!==s&&(f=a[s],a[s]=a[u],a[u]=f,f=o[s],o[s]=o[u],o[u]=f);var h=a[s],d=o[s];for(u=0;u{var{typed:e,matrix:r,lup:n,slu:i,usolve:a,lsolve:o,DenseMatrix:t}=e,s=dc({DenseMatrix:t});return e(yf,{"Array, Array | Matrix":function(e,t){e=r(e);e=n(e);return c(e.L,e.U,e.p,null,t).valueOf()},"DenseMatrix, Array | Matrix":function(e,t){e=n(e);return c(e.L,e.U,e.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){e=n(e);return c(e.L,e.U,e.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,r,n){e=i(e,r,n);return c(e.L,e.U,e.p,e.q,t)},"Object, Array | Matrix":function(e,t){return c(e.L,e.U,e.p,e.q,t)}});function u(e){if(q(e))return e;if(x(e))return r(e);throw new TypeError("Invalid Matrix LU decomposition")}function c(e,t,r,n,i){e=u(e),t=u(t),r&&((i=s(e,i,!0))._data=df(r,i._data));r=o(e,i),e=a(t,r);return n&&(e._data=df(n,e._data)),e}})({DenseMatrix:Ui,lsolve:yc,lup:Qf,matrix:n,slu:Dl,typed:r,usolve:Pc}),np=a("sqrtm",["typed","abs","add","multiply","sqrt","subtract","inv","size","max","identity"],e=>{var{typed:e,abs:o,add:s,multiply:u,sqrt:c,subtract:l,inv:f,size:p,max:m,identity:h}=e;return e("sqrtm",{"Array | Matrix":function(e){var t=q(e)?e.size():Ze(e);switch(t.length){case 1:if(1===t[0])return c(e);throw new RangeError("Matrix must be square (size: "+Ee(t)+")");case 2:if(t[0]!==t[1])throw new RangeError("Matrix must be square (size: "+Ee(t)+")");var r=0,n=e,i=h(p(e));do{var a=n,n=u(.5,s(a,f(i))),i=u(.5,s(i,f(a)));if(1e-6<(a=m(o(l(n,a))))&&1e3<++r)throw new Error("computing square root of matrix: iterative method could not converge")}while(1e-6{var{typed:e,matrix:r,multiply:n,equalScalar:t,divideScalar:i,inv:a}=e,o=uu({typed:e,equalScalar:t}),s=fu({typed:e});return e("divide",Ce({"Array | Matrix, Array | Matrix":function(e,t){return n(e,a(t))},"DenseMatrix, any":function(e,t){return s(e,t,i,!1)},"SparseMatrix, any":function(e,t){return o(e,t,i,!1)},"Array, any":function(e,t){return s(r(e),t,i,!1).valueOf()},"any, Array | Matrix":function(e,t){return n(e,a(t))}},i.signatures))})({divideScalar:Yu,equalScalar:No,inv:tp,matrix:n,multiply:hl,typed:r}),ap=a("expm",["typed","abs","add","identity","inv","multiply"],e=>{var{typed:e,abs:h,add:d,identity:y,inv:g,multiply:v}=e;return e("expm",{Matrix:function(e){var t=e.size();if(2!==t.length||t[0]!==t[1])throw new RangeError("Matrix must be square (size: "+Ee(t)+")");for(var t=t[0],l=function(e,t){for(var r=0;r<30;r++)for(var n=0;n<=r;n++){var i=r-n;if(function(e,t,r){for(var n=1,i=2;i<=t;i++)n*=i;for(var a=n,o=t+1;o<=2*t;o++)a*=o;var s=a*(2*t+1);return 8*Math.pow(e/Math.pow(2,r),2*t)*n*n/(a*s)}(e,n,i){var{typed:e,matrix:r,divide:i,sum:a,multiply:o,dotDivide:s,log:u,isNumeric:c}=e;return e(gf,{"Array, Array":function(e,t){return n(r(e),r(t))},"Matrix, Array":function(e,t){return n(e,r(t))},"Array, Matrix":function(e,t){return n(r(e),t)},"Matrix, Matrix":n});function n(e,t){var r=t.size().length,n=e.size().length;if(1{var{typed:e,add:r,divide:n,compare:s,partitionSelect:u}=e;function t(e){try{var t,r=(e=rt(e.valueOf())).length;if(0===r)throw new Error("Cannot calculate median of an empty array");if(r%2!=0)return t=u(e,(r-1)/2),c(t);for(var n=r/2-1,i=u(e,1+n),a=e[n],o=0;o{var{config:c,typed:e,matrix:r,addScalar:t,subtract:l,equal:i,abs:f,atan:a,cos:o,sin:s,multiplyScalar:u,divideScalar:m,inv:h,bignumber:d,multiply:g,add:v,larger:p,column:x,flatten:b,number:w,complex:y,sqrt:N,diag:M,qr:E,usolve:S,usolveAll:A,im:O,re:C,smaller:_,matrixFromColumns:T,dot:B}=e,q=xf({config:c,addScalar:t,subtract:l,column:x,flatten:b,equal:i,abs:f,atan:a,cos:o,sin:s,multiplyScalar:u,inv:h,bignumber:d,complex:y,multiply:g,add:v}),I=vf({config:c,addScalar:t,subtract:l,multiply:g,multiplyScalar:u,flatten:b,divideScalar:m,sqrt:N,abs:f,bignumber:d,diag:M,qr:E,inv:h,usolve:S,usolveAll:A,equal:i,complex:y,larger:p,smaller:_,matrixFromColumns:T,dot:B});return e("eigs",{Array:function(e){return n(r(e))},"Array, number|BigNumber":function(e,t){return n(r(e),t)},Matrix:function(e){var{values:e,vectors:t}=n(e);return{values:r(e),vectors:r(t)}},"Matrix, number|BigNumber":function(e,t){var{values:e,vectors:t}=n(e,t);return{values:r(e),vectors:r(t)}}});function n(e,t){void 0===t&&(t=c.epsilon);var r=e.size();if(2!==r.length||r[0]!==r[1])throw new RangeError("Matrix must be square (size: "+Ee(r)+")");var n=e.toArray(),r=r[0];if(function(e,t,r){for(var n=0;n{var{typed:e,add:n,divide:i,multiply:a,factorial:o,isInteger:s,isPositive:u}=e;return e(bf,{"Array | Matrix":function(e){var t=0,r=1;return Lt(e,function(e){if(!s(e)||!u(e))throw new TypeError("Positive integer value expected in function multinomial");t=n(t,e),r=a(r,o(e))}),i(o(t),r)}})})({add:Lc,divide:ip,factorial:Lf,isInteger:Lo,isPositive:Jo,multiply:hl,typed:r}),mp=a("mad",["typed","abs","map","median","subtract"],e=>{var{typed:e,abs:r,map:n,median:i,subtract:a}=e;return e("mad",{"Array | Matrix":t,"...":t});function t(e){if(0===(e=rt(e.valueOf())).length)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var t=i(e);return i(n(e,function(e){return r(a(e,t))}))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf("median")?new TypeError(e.message.replace("median","mad")):Rr(e,"mad")}}})({abs:Vi,map:es,median:up,subtract:Tu,typed:r}),hp=a("norm",["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],e=>{var{typed:e,abs:s,add:u,pow:a,conj:c,sqrt:l,multiply:f,equalScalar:m,larger:p,smaller:h,matrix:r,ctranspose:d,eigs:y}=e;return e("norm",{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},boolean:function(e){return Math.abs(e)},Array:function(e){return o(r(e),2)},Matrix:function(e){return o(e,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(e){return this(e)},"Array, number | BigNumber | string":function(e,t){return o(r(e),t)},"Matrix, number | BigNumber | string":o});function n(e,t){if(t===Number.POSITIVE_INFINITY||"inf"===t)return r=0,e.forEach(function(e){e=s(e);p(e,r)&&(r=e)},!0),r;var r,n,i;if(t===Number.NEGATIVE_INFINITY||"-inf"===t)return e.forEach(function(e){e=s(e);n&&!h(e,n)||(n=e)},!0),n||0;if("fro"===t)return o(e,2);if("number"!=typeof t||isNaN(t))throw new Error("Unsupported parameter value");return m(t,0)?Number.POSITIVE_INFINITY:(i=0,e.forEach(function(e){i=u(a(s(e),t),i)},!0),a(i,1/t))}function i(e,t){if(1===t)return r=[],n=0,e.forEach(function(e,t){t=t[1],e=u(r[t]||0,s(e));p(e,n)&&(n=e),r[t]=e},!0),n;var r,n,i,a,o;if(t===Number.POSITIVE_INFINITY||"inf"===t)return i=[],a=0,e.forEach(function(e,t){t=t[0],e=u(i[t]||0,s(e));p(e,a)&&(a=e),i[t]=e},!0),a;if("fro"===t)return o=0,e.forEach(function(e,t){o=u(o,f(e,c(e)))}),s(l(o));if(2!==t)throw new Error("Unsupported parameter value "+t);t=e,e=t.size();if(e[0]!==e[1])throw new RangeError("Invalid matrix dimensions");return e=d(t),e=f(e,t),t=y(e).values.toArray(),e=t[t.length-1],s(l(e))}function o(e,t){var r=e.size();if(1===r.length)return n(e,t);if(2===r.length){if(r[0]&&r[1])return i(e,t);throw new RangeError("Invalid matrix dimensions")}}})({abs:Vi,add:Lc,conj:ho,ctranspose:Vu,eigs:fp,equalScalar:No,larger:sl,matrix:n,multiply:hl,pow:dl,smaller:Su,sqrt:Ws,typed:r}),dp=a(wf,["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],e=>{var{typed:e,config:n,multiplyScalar:i,addScalar:c,unaryMinus:m,norm:h,BigNumber:l,matrix:a,DenseMatrix:r,SparseMatrix:u,cos:f,sin:d}=e;return e(wf,{"":function(){return"Matrix"===n.matrix?a([]):[]},string:function(e){return a(e)},"number | BigNumber | Complex | Unit":function(e){return t(e,"Matrix"===n.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":t,"number | BigNumber | Complex | Unit, Array":function(e,t){t=a(t);return o(t),s(e,t,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,t){o(t);var r=t.storage()||("Matrix"===n.matrix?"dense":void 0);return s(e,t,r)},"number | BigNumber | Complex | Unit, Array, string":function(e,t,r){t=a(t);return o(t),s(e,t,r)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,t,r){return o(t),s(e,t,r)}});function t(e,t){var r=D(e)?new l(-1):-1,n=f(e),e=d(e);return y([[n,i(r,e)],[e,n]],t)}function o(e){e=e.size();if(e.length<1||3!==e[0])throw new RangeError("Vector must be of dimensions 1x3")}function p(e){return e.reduce((e,t)=>i(e,t))}function y(e,t){if(t){if("sparse"===t)return new u(e);if("dense"===t)return new r(e);throw new TypeError('Unknown matrix type "'.concat(t,'"'))}return e}function s(e,t,r){var n=h(t);if(0===n)throw new RangeError("Rotation around zero vector");var i=D(e)?l:null,a=i?new i(1):1,o=i?new i(-1):-1,s=i?new i(t.get([0])/n):t.get([0])/n,u=i?new i(t.get([1])/n):t.get([1])/n,i=i?new i(t.get([2])/n):t.get([2])/n,t=f(e),n=c(a,m(t)),a=d(e);return y([[c(t,p([s,s,n])),c(p([s,u,n]),p([o,i,a])),c(p([s,i,n]),p([u,a]))],[c(p([s,u,n]),p([i,a])),c(t,p([u,u,n])),c(p([u,i,n]),p([o,s,a]))],[c(p([s,i,n]),p([o,u,a])),c(p([u,i,n]),p([s,a])),c(t,p([i,i,n]))]],r)}})({BigNumber:t,DenseMatrix:Ui,SparseMatrix:Es,addScalar:Da,config:e,cos:Us,matrix:n,multiplyScalar:rs,norm:hp,sin:Ms,typed:r,unaryMinus:Xs}),yp=a("rotate",["typed","multiply","rotationMatrix"],e=>{var{typed:e,multiply:n,rotationMatrix:i}=e;return e("rotate",{"Array , number | BigNumber | Complex | Unit":function(e,t){return a(e,2),n(i(t),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,t){return a(e,2),n(i(t),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,r){return a(e,3),n(i(t,r),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,r){return a(e,3),n(i(t,r),e)}});function a(e,t){e=Array.isArray(e)?Ze(e):e.size();if(2
AC
+/-
%
÷
7
8
9
X
4
5
6
-
1
2
3
+
0
,
=
',document.createElement("style"));Bp.innerHTML=o.Z.toString();var qp=new WeakMap,Ip=new WeakMap,zp=new WeakMap,kp=new WeakMap,Dp=new WeakMap,Rp=new WeakMap,Up=new WeakMap,Fp=new WeakMap,Pp=new WeakMap,jp=new WeakMap,Lp=new WeakSet,Hp=new WeakSet,$p=new WeakSet,Gp=new WeakSet,Vp=new WeakSet,Zp=new WeakSet,Wp=new WeakSet,Yp=new WeakSet,Jp=new WeakSet,Xp=new WeakSet;class Qp extends HTMLElement{static get observedAttributes(){return[]}constructor(){super(),wp(this,Xp),wp(this,Jp),wp(this,Yp),wp(this,Wp),wp(this,Zp),wp(this,Vp),wp(this,Gp),wp(this,$p),wp(this,Hp),wp(this,Lp),Np(this,qp,{writable:!0,value:""}),Np(this,Ip,{writable:!0,value:""}),Np(this,zp,{writable:!0,value:""}),Np(this,kp,{writable:!0,value:""}),Np(this,Dp,{writable:!0,value:void 0}),Np(this,Rp,{writable:!0,value:void 0}),Np(this,Up,{writable:!0,value:void 0}),Np(this,Fp,{writable:!0,value:void 0}),Np(this,Pp,{writable:!0,value:void 0}),Np(this,jp,{writable:!0,value:void 0});const e=this.attachShadow({mode:"open"});e.appendChild(Bp.cloneNode(!0)),e.appendChild(Tp.content.cloneNode(!0)),Cp(this,Dp,e.querySelector(".calc-solution")),Cp(this,Rp,e.getElementById("reset")),Cp(this,Up,e.getElementById("plus-minus")),Cp(this,Fp,e.getElementById("percentage")),Cp(this,Pp,Array.from(e.querySelectorAll(".calc-button-operand"))),Cp(this,jp,Array.from(e.querySelectorAll(".calc-button-digit"))),Ap(this,Rp).addEventListener("click",Sp(this,Lp,Kp).bind(this)),Ap(this,Up).addEventListener("click",Sp(this,Hp,em).bind(this)),Ap(this,Fp).addEventListener("click",Sp(this,$p,tm).bind(this)),Ap(this,Pp).forEach(e=>e.addEventListener("click",()=>Sp(this,Vp,nm).call(this,e))),Ap(this,jp).forEach(e=>e.addEventListener("click",()=>Sp(this,Gp,rm).call(this,e)))}connectedCallback(){this.shadowRoot&&Sp(this,Xp,um).call(this)}attributeChangedCallback(e,t,r){}}function Kp(){const e=Ap(this,Rp).querySelector("span");"AC"===e.textContent?(Cp(this,Ip,""),Cp(this,qp,""),Ap(this,Pp).forEach(Sp(this,Wp,am))):(Cp(this,Ip,"0"),e.textContent="AC"),Sp(this,Xp,um).call(this)}function em(){let e="0";00&&o();break;case"number":r.im=0,r.re=e;break;default:o()}return isNaN(r.re)||isNaN(r.im),r}(e,t);this.re=r.re,this.im=r.im}u.prototype={re:0,im:0,sign:function(){var e=this.abs();return new u(this.re/e,this.im/e)},add:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:new u(this.re+r.re,this.im+r.im)},sub:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:new u(this.re-r.re,this.im-r.im)},mul:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isZero()||this.isZero()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:0===r.im&&0===this.im?new u(this.re*r.re,0):new u(this.re*r.re-this.im*r.im,this.re*r.im+this.im*r.re)},div:function(e,t){var r=new u(e,t);if(this.isZero()&&r.isZero()||this.isInfinite()&&r.isInfinite())return u.NAN;if(this.isInfinite()||r.isZero())return u.INFINITY;if(this.isZero()||r.isInfinite())return u.ZERO;e=this.re,t=this.im;var n,i,a=r.re,o=r.im;return 0===o?new u(e/a,t/a):Math.abs(a)0)return new u(Math.pow(e,r.re),0);if(0===e)switch((r.re%4+4)%4){case 0:return new u(Math.pow(t,r.re),0);case 1:return new u(0,Math.pow(t,r.re));case 2:return new u(-Math.pow(t,r.re),0);case 3:return new u(0,-Math.pow(t,r.re))}}if(0===e&&0===t&&r.re>0&&r.im>=0)return u.ZERO;var n=Math.atan2(t,e),i=s(e,t);return e=Math.exp(r.re*i-r.im*n),t=r.im*i+r.re*n,new u(e*Math.cos(t),e*Math.sin(t))},sqrt:function(){var e,t,r=this.re,n=this.im,i=this.abs();if(r>=0){if(0===n)return new u(Math.sqrt(r),0);e=.5*Math.sqrt(2*(i+r))}else e=Math.abs(n)/Math.sqrt(2*(i-r));return t=r<=0?.5*Math.sqrt(2*(i-r)):Math.abs(n)/Math.sqrt(2*(i+r)),new u(e,n<0?-t:t)},exp:function(){var e=Math.exp(this.re);return this.im,new u(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){var e=this.re,t=this.im;return new u(Math.expm1(e)*Math.cos(t)+function(e){var t=Math.PI/4;if(-t>e||e>t)return Math.cos(e)-1;var r=e*e;return r*(r*(r*(r*(r*(r*(r*(r/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-.5)}(t),Math.exp(e)*Math.sin(t))},log:function(){var e=this.re,t=this.im;return new u(s(e,t),Math.atan2(t,e))},abs:function(){return e=this.re,t=this.im,r=Math.abs(e),n=Math.abs(t),r<3e3&&n<3e3?Math.sqrt(r*r+n*n):(r1&&0===t,n=1-e,i=1+e,a=n*n+t*t,o=0!==a?new u((i*n-t*t)/a,(t*n+i*t)/a):new u(-1!==e?e/0:0,0!==t?t/0:0),c=o.re;return o.re=s(o.re,o.im)/2,o.im=Math.atan2(o.im,c)/2,r&&(o.im=-o.im),o},acoth:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new u(0,Math.PI/2);var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).atanh():new u(0!==e?e/0:0,0!==t?-t/0:0).atanh()},acsch:function(){var e=this.re,t=this.im;if(0===t)return new u(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).asinh():new u(0!==e?e/0:0,0!==t?-t/0:0).asinh()},asech:function(){var e=this.re,t=this.im;if(this.isZero())return u.INFINITY;var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).acosh():new u(0!==e?e/0:0,0!==t?-t/0:0).acosh()},inverse:function(){if(this.isZero())return u.INFINITY;if(this.isInfinite())return u.ZERO;var e=this.re,t=this.im,r=e*e+t*t;return new u(e/r,-t/r)},conjugate:function(){return new u(this.re,-this.im)},neg:function(){return new u(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new u(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new u(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new u(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){var r=new u(e,t);return Math.abs(r.re-this.re)<=u.EPSILON&&Math.abs(r.im-this.im)<=u.EPSILON},clone:function(){return new u(this.re,this.im)},toString:function(){var e=this.re,t=this.im,r="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)span{display:inline-flex;place-items:center;place-content:center;text-align:center;height:3rem;width:3rem;line-height:3rem}.calc .calc-buttons-container .calc-button:hover{opacity:1}.calc .calc-buttons-container .calc-button:active:after{opacity:1;transition:0s}.calc .calc-buttons-container .calc-button:after{content:"";background:rgba(255,255,255,.25);display:block;position:absolute;inset:0;opacity:0;transition:all .8s;border-radius:inherit}.calc .calc-buttons-container .calc-button.calc-button-double{grid-column:span 2;border-radius:5rem;justify-content:start}.calc .calc-buttons-container .calc-button.calc-button-digit{background-color:#444}.calc .calc-buttons-container .calc-button.calc-button-operand{background-color:orange}.calc .calc-buttons-container .calc-button.calc-button-operand.active{opacity:1;background-color:#fff;color:orange}.calc .calc-buttons-container .calc-button.calc-button-func{background-color:#afafaf;color:#000}',""]),t.Z=o},645:function(e){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var r="",n=void 0!==t[5];return t[4]&&(r+="@supports (".concat(t[4],") {")),t[2]&&(r+="@media ".concat(t[2]," {")),n&&(r+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),r+=e(t),n&&(r+="}"),t[2]&&(r+="}"),t[4]&&(r+="}"),r})).join("")},t.i=function(e,r,n,i,a){"string"==typeof e&&(e=[[null,e,void 0]]);var o={};if(n)for(var s=0;s0?" ".concat(l[5]):""," {").concat(l[1],"}")),l[5]=a),r&&(l[2]?(l[1]="@media ".concat(l[2]," {").concat(l[1],"}"),l[2]=r):l[2]=r),i&&(l[4]?(l[1]="@supports (".concat(l[4],") {").concat(l[1],"}"),l[4]=i):l[4]="".concat(i)),t.push(l))}},t}},81:function(e){"use strict";e.exports=function(e){return e[1]}},776:function(e,t,r){var n;!function(i){"use strict";var a,o,s,u=9e15,c=1e9,l="0123456789abcdef",f="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",p="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",m={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-u,maxE:u,crypto:!1},h=!0,d="[DecimalError] ",y=d+"Invalid argument: ",g=d+"Precision limit exceeded",v=d+"crypto unavailable",x="[object Decimal]",b=Math.floor,w=Math.pow,N=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,M=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,S=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,E=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,A=1e7,O=f.length-1,C=p.length-1,_={toStringTag:x};function T(e){var t,r,n,i=e.length-1,a="",o=e[0];if(i>0){for(a+=o,t=1;tr)throw Error(y+e)}function q(e,t,r,n){var i,a,o,s;for(a=e[0];a>=10;a/=10)--t;return--t<0?(t+=7,i=0):(i=Math.ceil((t+1)/7),t%=7),a=w(10,7-t),s=e[i]%a|0,null==n?t<3?(0==t?s=s/100|0:1==t&&(s=s/10|0),o=r<4&&99999==s||r>3&&49999==s||5e4==s||0==s):o=(r<4&&s+1==a||r>3&&s+1==a/2)&&(e[i+1]/a/100|0)==w(10,t-2)-1||(s==a/2||0==s)&&0==(e[i+1]/a/100|0):t<4?(0==t?s=s/1e3|0:1==t?s=s/100|0:2==t&&(s=s/10|0),o=(n||r<4)&&9999==s||!n&&r>3&&4999==s):o=((n||r<4)&&s+1==a||!n&&r>3&&s+1==a/2)&&(e[i+1]/a/1e3|0)==w(10,t-3)-1,o}function z(e,t,r){for(var n,i,a=[0],o=0,s=e.length;or-1&&(void 0===a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/r|0,a[n]%=r)}return a.reverse()}_.absoluteValue=_.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),I(e)},_.ceil=function(){return I(new this.constructor(this),this.e+1,2)},_.clampedTo=_.clamp=function(e,t){var r=this,n=r.constructor;if(e=new n(e),t=new n(t),!e.s||!t.s)return new n(NaN);if(e.gt(t))throw Error(y+t);return r.cmp(e)<0?e:r.cmp(t)>0?t:new n(r)},_.comparedTo=_.cmp=function(e){var t,r,n,i,a=this,o=a.d,s=(e=new a.constructor(e)).d,u=a.s,c=e.s;if(!o||!s)return u&&c?u!==c?u:o===s?0:!o^u<0?1:-1:NaN;if(!o[0]||!s[0])return o[0]?u:s[0]?-c:0;if(u!==c)return u;if(a.e!==e.e)return a.e>e.e^u<0?1:-1;for(t=0,r=(n=o.length)<(i=s.length)?n:i;ts[t]^u<0?1:-1;return n===i?0:n>i^u<0?1:-1},_.cosine=_.cos=function(){var e,t,r=this,n=r.constructor;return r.d?r.d[0]?(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(e,t){var r,n,i;if(t.isZero())return t;(n=t.d.length)<32?i=(1/X(4,r=Math.ceil(n/3))).toString():(r=16,i="2.3283064365386962890625e-10");e.precision+=r,t=J(e,1,t.times(i),new e(1));for(var a=r;a--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=r,t}(n,Q(n,r)),n.precision=e,n.rounding=t,I(2==s||3==s?r.neg():r,e,t,!0)):new n(1):new n(NaN)},_.cubeRoot=_.cbrt=function(){var e,t,r,n,i,a,o,s,u,c,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(h=!1,(a=l.s*w(l.s*l,1/3))&&Math.abs(a)!=1/0?n=new f(a.toString()):(r=T(l.d),(a=((e=l.e)-r.length+1)%3)&&(r+=1==a||-2==a?"0":"00"),a=w(r,1/3),e=b((e+1)/3)-(e%3==(e<0?-1:2)),(n=new f(r=a==1/0?"5e"+e:(r=a.toExponential()).slice(0,r.indexOf("e")+1)+e)).s=l.s),o=(e=f.precision)+3;;)if(c=(u=(s=n).times(s).times(s)).plus(l),n=k(c.plus(l).times(s),c.plus(u),o+2,1),T(s.d).slice(0,o)===(r=T(n.d)).slice(0,o)){if("9999"!=(r=r.slice(o-3,o+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(I(n,e+1,1),t=!n.times(n).times(n).eq(l));break}if(!i&&(I(s,e+1,0),s.times(s).times(s).eq(l))){n=s;break}o+=4,i=1}return h=!0,I(n,e,f.rounding,t)},_.decimalPlaces=_.dp=function(){var e,t=this.d,r=NaN;if(t){if(r=7*((e=t.length-1)-b(this.e/7)),e=t[e])for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r},_.dividedBy=_.div=function(e){return k(this,new this.constructor(e))},_.dividedToIntegerBy=_.divToInt=function(e){var t=this.constructor;return I(k(this,new t(e),0,1,1),t.precision,t.rounding)},_.equals=_.eq=function(e){return 0===this.cmp(e)},_.floor=function(){return I(new this.constructor(this),this.e+1,3)},_.greaterThan=_.gt=function(e){return this.cmp(e)>0},_.greaterThanOrEqualTo=_.gte=function(e){var t=this.cmp(e);return 1==t||0===t},_.hyperbolicCosine=_.cosh=function(){var e,t,r,n,i,a=this,o=a.constructor,s=new o(1);if(!a.isFinite())return new o(a.s?1/0:NaN);if(a.isZero())return s;r=o.precision,n=o.rounding,o.precision=r+Math.max(a.e,a.sd())+4,o.rounding=1,(i=a.d.length)<32?t=(1/X(4,e=Math.ceil(i/3))).toString():(e=16,t="2.3283064365386962890625e-10"),a=J(o,1,a.times(t),new o(1),!0);for(var u,c=e,l=new o(8);c--;)u=a.times(a),a=s.minus(u.times(l.minus(u.times(l))));return I(a,o.precision=r,o.rounding=n,!0)},_.hyperbolicSine=_.sinh=function(){var e,t,r,n,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.precision,r=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,(n=i.d.length)<3)i=J(a,2,i,i,!0);else{e=(e=1.4*Math.sqrt(n))>16?16:0|e,i=J(a,2,i=i.times(1/X(5,e)),i,!0);for(var o,s=new a(5),u=new a(16),c=new a(20);e--;)o=i.times(i),i=i.times(s.plus(o.times(u.times(o).plus(c))))}return a.precision=t,a.rounding=r,I(i,t,r,!0)},_.hyperbolicTangent=_.tanh=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+7,n.rounding=1,k(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)},_.inverseCosine=_.acos=function(){var e,t=this,r=t.constructor,n=t.abs().cmp(1),i=r.precision,a=r.rounding;return-1!==n?0===n?t.isNeg()?F(r,i,a):new r(0):new r(NaN):t.isZero()?F(r,i+4,a).times(.5):(r.precision=i+6,r.rounding=1,t=t.asin(),e=F(r,i+4,a).times(.5),r.precision=i,r.rounding=a,e.minus(t))},_.inverseHyperbolicCosine=_.acosh=function(){var e,t,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(e=n.precision,t=n.rounding,n.precision=e+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,h=!1,r=r.times(r).minus(1).sqrt().plus(r),h=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)},_.inverseHyperbolicSine=_.asinh=function(){var e,t,r=this,n=r.constructor;return!r.isFinite()||r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,h=!1,r=r.times(r).plus(1).sqrt().plus(r),h=!0,n.precision=e,n.rounding=t,r.ln())},_.inverseHyperbolicTangent=_.atanh=function(){var e,t,r,n,i=this,a=i.constructor;return i.isFinite()?i.e>=0?new a(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=a.precision,t=a.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?I(new a(i),e,t,!0):(a.precision=r=n-i.e,i=k(i.plus(1),new a(1).minus(i),r+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=t,i.times(.5))):new a(NaN)},_.inverseSine=_.asin=function(){var e,t,r,n,i=this,a=i.constructor;return i.isZero()?new a(i):(t=i.abs().cmp(1),r=a.precision,n=a.rounding,-1!==t?0===t?((e=F(a,r+4,n).times(.5)).s=i.s,e):new a(NaN):(a.precision=r+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=r,a.rounding=n,i.times(2)))},_.inverseTangent=_.atan=function(){var e,t,r,n,i,a,o,s,u,c=this,l=c.constructor,f=l.precision,p=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&f+4<=C)return(o=F(l,f+4,p).times(.25)).s=c.s,o}else{if(!c.s)return new l(NaN);if(f+4<=C)return(o=F(l,f+4,p).times(.5)).s=c.s,o}for(l.precision=s=f+10,l.rounding=1,e=r=Math.min(28,s/7+2|0);e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(h=!1,t=Math.ceil(s/7),n=1,u=c.times(c),o=new l(c),i=c;-1!==e;)if(i=i.times(u),a=o.minus(i.div(n+=2)),i=i.times(u),void 0!==(o=a.plus(i.div(n+=2))).d[t])for(e=t;o.d[e]===a.d[e]&&e--;);return r&&(o=o.times(2<this.d.length-2},_.isNaN=function(){return!this.s},_.isNegative=_.isNeg=function(){return this.s<0},_.isPositive=_.isPos=function(){return this.s>0},_.isZero=function(){return!!this.d&&0===this.d[0]},_.lessThan=_.lt=function(e){return this.cmp(e)<0},_.lessThanOrEqualTo=_.lte=function(e){return this.cmp(e)<1},_.logarithm=_.log=function(e){var t,r,n,i,a,o,s,u,c=this,l=c.constructor,f=l.precision,p=l.rounding;if(null==e)e=new l(10),t=!0;else{if(r=(e=new l(e)).d,e.s<0||!r||!r[0]||e.eq(1))return new l(NaN);t=e.eq(10)}if(r=c.d,c.s<0||!r||!r[0]||c.eq(1))return new l(r&&!r[0]?-1/0:1!=c.s?NaN:r?0:1/0);if(t)if(r.length>1)a=!0;else{for(i=r[0];i%10==0;)i/=10;a=1!==i}if(h=!1,o=V(c,s=f+5),n=t?U(l,s+10):V(e,s),q((u=k(o,n,s,1)).d,i=f,p))do{if(o=V(c,s+=10),n=t?U(l,s+10):V(e,s),u=k(o,n,s,1),!a){+T(u.d).slice(i+1,i+15)+1==1e14&&(u=I(u,f+1,0));break}}while(q(u.d,i+=10,p));return h=!0,I(u,f,p)},_.minus=_.sub=function(e){var t,r,n,i,a,o,s,u,c,l,f,p,m=this,d=m.constructor;if(e=new d(e),!m.d||!e.d)return m.s&&e.s?m.d?e.s=-e.s:e=new d(e.d||m.s!==e.s?m:NaN):e=new d(NaN),e;if(m.s!=e.s)return e.s=-e.s,m.plus(e);if(c=m.d,p=e.d,s=d.precision,u=d.rounding,!c[0]||!p[0]){if(p[0])e.s=-e.s;else{if(!c[0])return new d(3===u?-0:0);e=new d(m)}return h?I(e,s,u):e}if(r=b(e.e/7),l=b(m.e/7),c=c.slice(),a=l-r){for((f=a<0)?(t=c,a=-a,o=p.length):(t=p,r=l,o=c.length),a>(n=Math.max(Math.ceil(s/7),o)+2)&&(a=n,t.length=1),t.reverse(),n=a;n--;)t.push(0);t.reverse()}else{for((f=(n=c.length)<(o=p.length))&&(o=n),n=0;n0;--n)c[o++]=0;for(n=p.length;n>a;){if(c[--n](o=(a=Math.ceil(s/7))>o?a+1:o+1)&&(i=o,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for((o=c.length)-(i=l.length)<0&&(i=o,r=l,l=c,c=r),t=0;i;)t=(c[--i]=c[i]+l[i]+t)/A|0,c[i]%=A;for(t&&(c.unshift(t),++n),o=c.length;0==c[--o];)c.pop();return e.d=c,e.e=R(c,n),h?I(e,s,u):e},_.precision=_.sd=function(e){var t,r=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(y+e);return r.d?(t=P(r.d),e&&r.e+1>t&&(t=r.e+1)):t=NaN,t},_.round=function(){var e=this,t=e.constructor;return I(new t(e),e.e+1,t.rounding)},_.sine=_.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(e,t){var r,n=t.d.length;if(n<3)return t.isZero()?t:J(e,2,t,t);r=(r=1.4*Math.sqrt(n))>16?16:0|r,t=t.times(1/X(5,r)),t=J(e,2,t,t);for(var i,a=new e(5),o=new e(16),s=new e(20);r--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}(n,Q(n,r)),n.precision=e,n.rounding=t,I(s>2?r.neg():r,e,t,!0)):new n(NaN)},_.squareRoot=_.sqrt=function(){var e,t,r,n,i,a,o=this,s=o.d,u=o.e,c=o.s,l=o.constructor;if(1!==c||!s||!s[0])return new l(!c||c<0&&(!s||s[0])?NaN:s?o:1/0);for(h=!1,0==(c=Math.sqrt(+o))||c==1/0?(((t=T(s)).length+u)%2==0&&(t+="0"),c=Math.sqrt(t),u=b((u+1)/2)-(u<0||u%2),n=new l(t=c==1/0?"5e"+u:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+u)):n=new l(c.toString()),r=(u=l.precision)+3;;)if(n=(a=n).plus(k(o,a,r+2,1)).times(.5),T(a.d).slice(0,r)===(t=T(n.d)).slice(0,r)){if("9999"!=(t=t.slice(r-3,r+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(I(n,u+1,1),e=!n.times(n).eq(o));break}if(!i&&(I(a,u+1,0),a.times(a).eq(o))){n=a;break}r+=4,i=1}return h=!0,I(n,u,l.rounding,e)},_.tangent=_.tan=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+10,n.rounding=1,(r=r.sin()).s=1,r=k(r,new n(1).minus(r.times(r)).sqrt(),e+10,0),n.precision=e,n.rounding=t,I(2==s||4==s?r.neg():r,e,t,!0)):new n(NaN)},_.times=_.mul=function(e){var t,r,n,i,a,o,s,u,c,l=this,f=l.constructor,p=l.d,m=(e=new f(e)).d;if(e.s*=l.s,!(p&&p[0]&&m&&m[0]))return new f(!e.s||p&&!p[0]&&!m||m&&!m[0]&&!p?NaN:p&&m?0*e.s:e.s/0);for(r=b(l.e/7)+b(e.e/7),(u=p.length)<(c=m.length)&&(a=p,p=m,m=a,o=u,u=c,c=o),a=[],n=o=u+c;n--;)a.push(0);for(n=c;--n>=0;){for(t=0,i=u+n;i>n;)s=a[i]+m[n]*p[i-n-1]+t,a[i--]=s%A|0,t=s/A|0;a[i]=(a[i]+t)%A|0}for(;!a[--o];)a.pop();return t?++r:a.shift(),e.d=a,e.e=R(a,r),h?I(e,f.precision,f.rounding):e},_.toBinary=function(e,t){return K(this,2,e,t)},_.toDecimalPlaces=_.toDP=function(e,t){var r=this,n=r.constructor;return r=new n(r),void 0===e?r:(B(e,0,c),void 0===t?t=n.rounding:B(t,0,8),I(r,e+r.e+1,t))},_.toExponential=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=D(n,!0):(B(e,0,c),void 0===t?t=i.rounding:B(t,0,8),r=D(n=I(new i(n),e+1,t),!0,e+1)),n.isNeg()&&!n.isZero()?"-"+r:r},_.toFixed=function(e,t){var r,n,i=this,a=i.constructor;return void 0===e?r=D(i):(B(e,0,c),void 0===t?t=a.rounding:B(t,0,8),r=D(n=I(new a(i),e+i.e+1,t),!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r},_.toFraction=function(e){var t,r,n,i,a,o,s,u,c,l,f,p,m=this,d=m.d,g=m.constructor;if(!d)return new g(m);if(c=r=new g(1),n=u=new g(0),o=(a=(t=new g(n)).e=P(d)-m.e-1)%7,t.d[0]=w(10,o<0?7+o:o),null==e)e=a>0?t:c;else{if(!(s=new g(e)).isInt()||s.lt(c))throw Error(y+s);e=s.gt(t)?a>0?t:c:s}for(h=!1,s=new g(T(d)),l=g.precision,g.precision=a=7*d.length*2;f=k(s,t,0,1,1),1!=(i=r.plus(f.times(n))).cmp(e);)r=n,n=i,i=c,c=u.plus(f.times(i)),u=i,i=t,t=s.minus(f.times(i)),s=i;return i=k(e.minus(r),n,0,1,1),u=u.plus(i.times(c)),r=r.plus(i.times(n)),u.s=c.s=m.s,p=k(c,n,a,1).minus(m).abs().cmp(k(u,r,a,1).minus(m).abs())<1?[c,n]:[u,r],g.precision=l,h=!0,p},_.toHexadecimal=_.toHex=function(e,t){return K(this,16,e,t)},_.toNearest=function(e,t){var r=this,n=r.constructor;if(r=new n(r),null==e){if(!r.d)return r;e=new n(1),t=n.rounding}else{if(e=new n(e),void 0===t?t=n.rounding:B(t,0,8),!r.d)return e.s?r:e;if(!e.d)return e.s&&(e.s=r.s),e}return e.d[0]?(h=!1,r=k(r,e,0,t,1).times(e),h=!0,I(r)):(e.s=r.s,r=e),r},_.toNumber=function(){return+this},_.toOctal=function(e,t){return K(this,8,e,t)},_.toPower=_.pow=function(e){var t,r,n,i,a,o,s=this,u=s.constructor,c=+(e=new u(e));if(!(s.d&&e.d&&s.d[0]&&e.d[0]))return new u(w(+s,c));if((s=new u(s)).eq(1))return s;if(n=u.precision,a=u.rounding,e.eq(1))return I(s,n,a);if((t=b(e.e/7))>=e.d.length-1&&(r=c<0?-c:c)<=9007199254740991)return i=L(u,s,r,n),e.s<0?new u(1).div(i):I(i,n,a);if((o=s.s)<0){if(tu.maxE+1||t0?o/0:0):(h=!1,u.rounding=s.s=1,r=Math.min(12,(t+"").length),(i=G(e.times(V(s,n+r)),n)).d&&q((i=I(i,n+5,1)).d,n,a)&&(t=n+10,+T((i=I(G(e.times(V(s,t+r)),t),t+5,1)).d).slice(n+1,n+15)+1==1e14&&(i=I(i,n+1,0))),i.s=o,h=!0,u.rounding=a,I(i,n,a))},_.toPrecision=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=D(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(B(e,1,c),void 0===t?t=i.rounding:B(t,0,8),r=D(n=I(new i(n),e,t),e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+r:r},_.toSignificantDigits=_.toSD=function(e,t){var r=this.constructor;return void 0===e?(e=r.precision,t=r.rounding):(B(e,1,c),void 0===t?t=r.rounding:B(t,0,8)),I(new r(this),e,t)},_.toString=function(){var e=this,t=e.constructor,r=D(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r},_.truncated=_.trunc=function(){return I(new this.constructor(this),this.e+1,1)},_.valueOf=_.toJSON=function(){var e=this,t=e.constructor,r=D(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};var k=function(){function e(e,t,r){var n,i=0,a=e.length;for(e=e.slice();a--;)n=e[a]*t+i,e[a]=n%r|0,i=n/r|0;return i&&e.unshift(i),e}function t(e,t,r,n){var i,a;if(r!=n)a=r>n?1:-1;else for(i=a=0;it[i]?1:-1;break}return a}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]1;)e.shift()}return function(n,i,a,s,u,c){var l,f,p,m,h,d,y,g,v,x,w,N,M,S,E,O,C,_,T,B,q=n.constructor,z=n.s==i.s?1:-1,k=n.d,D=i.d;if(!(k&&k[0]&&D&&D[0]))return new q(n.s&&i.s&&(k?!D||k[0]!=D[0]:D)?k&&0==k[0]||!D?0*z:z/0:NaN);for(c?(h=1,f=n.e-i.e):(c=A,h=7,f=b(n.e/h)-b(i.e/h)),T=D.length,C=k.length,x=(v=new q(z)).d=[],p=0;D[p]==(k[p]||0);p++);if(D[p]>(k[p]||0)&&f--,null==a?(S=a=q.precision,s=q.rounding):S=u?a+(n.e-i.e)+1:a,S<0)x.push(1),d=!0;else{if(S=S/h+2|0,p=0,1==T){for(m=0,D=D[0],S++;(p1&&(D=e(D,m,c),k=e(k,m,c),T=D.length,C=k.length),O=T,N=(w=k.slice(0,T)).length;N=c/2&&++_;do{m=0,(l=t(D,w,T,N))<0?(M=w[0],T!=N&&(M=M*c+(w[1]||0)),(m=M/_|0)>1?(m>=c&&(m=c-1),1==(l=t(y=e(D,m,c),w,g=y.length,N=w.length))&&(m--,r(y,T=10;m/=10)p++;v.e=p+f*h-1,I(v,u?a+v.e+1:a,s,d)}return v}}();function I(e,t,r,n){var i,a,o,s,u,c,l,f,p,m=e.constructor;e:if(null!=t){if(!(f=e.d))return e;for(i=1,s=f[0];s>=10;s/=10)i++;if((a=t-i)<0)a+=7,o=t,u=(l=f[p=0])/w(10,i-o-1)%10|0;else if((p=Math.ceil((a+1)/7))>=(s=f.length)){if(!n)break e;for(;s++<=p;)f.push(0);l=u=0,i=1,o=(a%=7)-7+1}else{for(l=s=f[p],i=1;s>=10;s/=10)i++;u=(o=(a%=7)-7+i)<0?0:l/w(10,i-o-1)%10|0}if(n=n||t<0||void 0!==f[p+1]||(o<0?l:l%w(10,i-o-1)),c=r<4?(u||n)&&(0==r||r==(e.s<0?3:2)):u>5||5==u&&(4==r||n||6==r&&(a>0?o>0?l/w(10,i-o):0:f[p-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,c?(t-=e.e+1,f[0]=w(10,(7-t%7)%7),e.e=-t||0):f[0]=e.e=0,e;if(0==a?(f.length=p,s=1,p--):(f.length=p+1,s=w(10,7-a),f[p]=o>0?(l/w(10,i-o)%w(10,o)|0)*s:0),c)for(;;){if(0==p){for(a=1,o=f[0];o>=10;o/=10)a++;for(o=f[0]+=s,s=1;o>=10;o/=10)s++;a!=s&&(e.e++,f[0]==A&&(f[0]=1));break}if(f[p]+=s,f[p]!=A)break;f[p--]=0,s=1}for(a=f.length;0===f[--a];)f.pop()}return h&&(e.e>m.maxE?(e.d=null,e.e=NaN):e.e0?a=a.charAt(0)+"."+a.slice(1)+j(n):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(e.e<0?"e":"e+")+e.e):i<0?(a="0."+j(-i-1)+a,r&&(n=r-o)>0&&(a+=j(n))):i>=o?(a+=j(i+1-o),r&&(n=r-i-1)>0&&(a=a+"."+j(n))):((n=i+1)0&&(i+1===o&&(a+="."),a+=j(n))),a}function R(e,t){var r=e[0];for(t*=7;r>=10;r/=10)t++;return t}function U(e,t,r){if(t>O)throw h=!0,r&&(e.precision=r),Error(g);return I(new e(f),t,1,!0)}function F(e,t,r){if(t>C)throw Error(g);return I(new e(p),t,r,!0)}function P(e){var t=e.length-1,r=7*t+1;if(t=e[t]){for(;t%10==0;t/=10)r--;for(t=e[0];t>=10;t/=10)r++}return r}function j(e){for(var t="";e--;)t+="0";return t}function L(e,t,r,n){var i,a=new e(1),o=Math.ceil(n/7+4);for(h=!1;;){if(r%2&&ee((a=a.times(t)).d,o)&&(i=!0),0===(r=b(r/2))){r=a.d.length-1,i&&0===a.d[r]&&++a.d[r];break}ee((t=t.times(t)).d,o)}return h=!0,a}function H(e){return 1&e.d[e.d.length-1]}function $(e,t,r){for(var n,i=new e(t[0]),a=0;++a17)return new p(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(h=!1,u=d):u=t,s=new p(.03125);e.e>-2;)e=e.times(s),f+=5;for(u+=n=Math.log(w(2,f))/Math.LN10*2+5|0,r=a=o=new p(1),p.precision=u;;){if(a=I(a.times(e),u,1),r=r.times(++l),T((s=o.plus(k(a,r,u,1))).d).slice(0,u)===T(o.d).slice(0,u)){for(i=f;i--;)o=I(o.times(o),u,1);if(null!=t)return p.precision=d,o;if(!(c<3&&q(o.d,u-n,m,c)))return I(o,p.precision=d,m,h=!0);p.precision=u+=10,r=a=s=new p(1),l=0,c++}o=s}}function V(e,t){var r,n,i,a,o,s,u,c,l,f,p,m=1,d=e,y=d.d,g=d.constructor,v=g.rounding,x=g.precision;if(d.s<0||!y||!y[0]||!d.e&&1==y[0]&&1==y.length)return new g(y&&!y[0]?-1/0:1!=d.s?NaN:y?0:d);if(null==t?(h=!1,l=x):l=t,g.precision=l+=10,n=(r=T(y)).charAt(0),!(Math.abs(a=d.e)<15e14))return c=U(g,l+2,x).times(a+""),d=V(new g(n+"."+r.slice(1)),l-10).plus(c),g.precision=x,null==t?I(d,x,v,h=!0):d;for(;n<7&&1!=n||1==n&&r.charAt(1)>3;)n=(r=T((d=d.times(e)).d)).charAt(0),m++;for(a=d.e,n>1?(d=new g("0."+r),a++):d=new g(n+"."+r.slice(1)),f=d,u=o=d=k(d.minus(1),d.plus(1),l,1),p=I(d.times(d),l,1),i=3;;){if(o=I(o.times(p),l,1),T((c=u.plus(k(o,new g(i),l,1))).d).slice(0,l)===T(u.d).slice(0,l)){if(u=u.times(2),0!==a&&(u=u.plus(U(g,l+2,x).times(a+""))),u=k(u,new g(m),l,1),null!=t)return g.precision=x,u;if(!q(u.d,l-10,v,s))return I(u,g.precision=x,v,h=!0);g.precision=l+=10,c=o=d=k(f.minus(1),f.plus(1),l,1),p=I(d.times(d),l,1),i=s=1}u=c,i+=2}}function Z(e){return String(e.s*e.s/0)}function W(e,t){var r,n,i;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;48===t.charCodeAt(n);n++);for(i=t.length;48===t.charCodeAt(i-1);--i);if(t=t.slice(n,i)){if(i-=n,e.e=r=r-n-1,e.d=[],n=(r+1)%7,r<0&&(n+=7),ne.constructor.maxE?(e.d=null,e.e=NaN):e.e-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),E.test(t))return W(e,t)}else if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(M.test(t))r=16,t=t.toLowerCase();else if(N.test(t))r=2;else{if(!S.test(t))throw Error(y+t);r=8}for((o=t.search(/p/i))>0?(c=+t.slice(o+1),t=t.substring(2,o)):t=t.slice(2),s=(o=t.indexOf("."))>=0,n=e.constructor,s&&(o=(u=(t=t.replace(".","")).length)-o,i=L(n,new n(r),o,2*o)),o=f=(l=z(t,r,A)).length-1;0===l[o];--o)l.pop();return o<0?new n(0*e.s):(e.e=R(l,f),e.d=l,h=!1,s&&(e=k(e,i,4*u)),c&&(e=e.times(Math.abs(c)<54?w(2,c):a.pow(2,c))),h=!0,e)}function J(e,t,r,n,i){var a,o,s,u,c=e.precision,l=Math.ceil(c/7);for(h=!1,u=r.times(r),s=new e(n);;){if(o=k(s.times(u),new e(t++*t++),c,1),s=i?n.plus(o):n.minus(o),n=k(o.times(u),new e(t++*t++),c,1),void 0!==(o=s.plus(n)).d[l]){for(a=l;o.d[a]===s.d[a]&&a--;);if(-1==a)break}a=s,s=n,n=o,o=a}return h=!0,o.d.length=l+1,o}function X(e,t){for(var r=e;--t;)r*=e;return r}function Q(e,t){var r,n=t.s<0,i=F(e,e.precision,1),a=i.times(.5);if((t=t.abs()).lte(a))return s=n?4:1,t;if((r=t.divToInt(i)).isZero())s=n?3:2;else{if((t=t.minus(r.times(i))).lte(a))return s=H(r)?n?2:3:n?4:1,t;s=H(r)?n?1:4:n?3:2}return t.minus(i).abs()}function K(e,t,r,n){var i,a,s,u,f,p,m,h,d,y=e.constructor,g=void 0!==r;if(g?(B(r,1,c),void 0===n?n=y.rounding:B(n,0,8)):(r=y.precision,n=y.rounding),e.isFinite()){for(g?(i=2,16==t?r=4*r-3:8==t&&(r=3*r-2)):i=t,(s=(m=D(e)).indexOf("."))>=0&&(m=m.replace(".",""),(d=new y(1)).e=m.length-s,d.d=z(D(d),10,i),d.e=d.d.length),a=f=(h=z(m,10,i)).length;0==h[--f];)h.pop();if(h[0]){if(s<0?a--:((e=new y(e)).d=h,e.e=a,h=(e=k(e,d,r,n,0,i)).d,a=e.e,p=o),s=h[r],u=i/2,p=p||void 0!==h[r+1],p=n<4?(void 0!==s||p)&&(0===n||n===(e.s<0?3:2)):s>u||s===u&&(4===n||p||6===n&&1&h[r-1]||n===(e.s<0?8:7)),h.length=r,p)for(;++h[--r]>i-1;)h[r]=0,r||(++a,h.unshift(1));for(f=h.length;!h[f-1];--f);for(s=0,m="";s1)if(16==t||8==t){for(s=16==t?4:3,--f;f%s;f++)m+="0";for(f=(h=z(m,i,t)).length;!h[f-1];--f);for(s=1,m="1.";sf)for(a-=f;a--;)m+="0";else at)return e.length=t,!0}function te(e){return new this(e).abs()}function re(e){return new this(e).acos()}function ne(e){return new this(e).acosh()}function ie(e,t){return new this(e).plus(t)}function ae(e){return new this(e).asin()}function oe(e){return new this(e).asinh()}function se(e){return new this(e).atan()}function ue(e){return new this(e).atanh()}function ce(e,t){e=new this(e),t=new this(t);var r,n=this.precision,i=this.rounding,a=n+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(r=t.s<0?F(this,n,i):new this(0)).s=e.s:!e.d||t.isZero()?(r=F(this,a,1).times(.5)).s=e.s:t.s<0?(this.precision=a,this.rounding=1,r=this.atan(k(e,t,a,1)),t=F(this,a,1),this.precision=n,this.rounding=i,r=e.s<0?r.minus(t):r.plus(t)):r=this.atan(k(e,t,a,1)):(r=F(this,a,1).times(t.s>0?.25:.75)).s=e.s:r=new this(NaN),r}function le(e){return new this(e).cbrt()}function fe(e){return I(e=new this(e),e.e+1,2)}function pe(e,t,r){return new this(e).clamp(t,r)}function me(e){if(!e||"object"!=typeof e)throw Error(d+"Object expected");var t,r,n,i=!0===e.defaults,a=["precision",1,c,"rounding",0,8,"toExpNeg",-u,0,"toExpPos",0,u,"maxE",0,u,"minE",-u,0,"modulo",0,9];for(t=0;t=a[t+1]&&n<=a[t+2]))throw Error(y+r+": "+n);this[r]=n}if(r="crypto",i&&(this[r]=m[r]),void 0!==(n=e[r])){if(!0!==n&&!1!==n&&0!==n&&1!==n)throw Error(y+r+": "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(v);this[r]=!0}else this[r]=!1}return this}function he(e){return new this(e).cos()}function de(e){return new this(e).cosh()}function ye(e,t){return new this(e).div(t)}function ge(e){return new this(e).exp()}function ve(e){return I(e=new this(e),e.e+1,3)}function xe(){var e,t,r=new this(0);for(h=!1,e=0;e=429e7?t[a]=crypto.getRandomValues(new Uint32Array(1))[0]:s[a++]=i%1e7;else{if(!crypto.randomBytes)throw Error(v);for(t=crypto.randomBytes(n*=4);a=214e7?crypto.randomBytes(4).copy(t,a):(s.push(i%1e7),a+=4);a=n/4}else for(;a=10;i/=10)n++;n<7&&(r-=7-n)}return o.e=r,o.d=s,o}function Be(e){return I(e=new this(e),e.e+1,this.rounding)}function qe(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function ze(e){return new this(e).sin()}function ke(e){return new this(e).sinh()}function Ie(e){return new this(e).sqrt()}function De(e,t){return new this(e).sub(t)}function Re(){var e=0,t=arguments,r=new this(t[e]);for(h=!1;r.s&&++ea.maxE?(i.e=NaN,i.d=null):e.e=10;r/=10)t++;return void(h?t>a.maxE?(i.e=NaN,i.d=null):t1&&void 0!==arguments[1]?arguments[1]:{},o=a.preserveFormatting,s=void 0!==o&&o,u=a.escapeMapFn,c=void 0===u?i:u,l=String(e),f="",p=c(t({},r),s?t({},n):{}),m=Object.keys(p),h=function(){var e=!1;m.forEach((function(t,r){e||l.length>=t.length&&l.slice(0,t.length)===t&&(f+=p[m[r]],l=l.slice(t.length,l.length),e=!0)})),e||(f+=l.slice(0,1),l=l.slice(1,l.length))};l;)h();return f}},628:function(e,t){var r;!function(n){"use strict";var i={s:1,n:0,d:1};function a(e){function t(){var t=Error.apply(this,arguments);t.name=this.name=e,this.stack=t.stack,this.message=t.message}function r(){}return r.prototype=Error.prototype,t.prototype=new r,t}var o=m.DivisionByZero=a("DivisionByZero"),s=m.InvalidParameter=a("InvalidParameter");function u(e,t){return isNaN(e=parseInt(e,10))&&c(),e*t}function c(){throw new s}function l(e){for(var t={},r=e,n=2,i=4;i<=r;){for(;r%n==0;)r/=n,t[n]=(t[n]||0)+1;i+=1+2*n++}return r!==e?r>1&&(t[r]=(t[r]||0)+1):t[e]=(t[e]||0)+1,t}var f=function(e,t){var r,n=0,a=1,s=1,l=0,f=0,p=0,m=1,h=1,d=0,y=1,g=1,v=1,x=1e7;if(null==e);else if(void 0!==t)s=(n=e)*(a=t);else switch(typeof e){case"object":"d"in e&&"n"in e?(n=e.n,a=e.d,"s"in e&&(n*=e.s)):0 in e?(n=e[0],1 in e&&(a=e[1])):c(),s=n*a;break;case"number":if(e<0&&(s=e,e=-e),e%1==0)n=e;else if(e>0){for(e>=1&&(e/=h=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)));y<=x&&v<=x;){if(e===(r=(d+g)/(y+v))){y+v<=x?(n=d+g,a=y+v):v>y?(n=g,a=v):(n=d,a=y);break}e>r?(d+=g,y+=v):(g+=d,v+=y),y>x?(n=g,a=v):(n=d,a=y)}n*=h}else(isNaN(e)||isNaN(t))&&(a=n=NaN);break;case"string":if(null===(y=e.match(/\d+|./g))&&c(),"-"===y[d]?(s=-1,d++):"+"===y[d]&&d++,y.length===d+1?f=u(y[d++],s):"."===y[d+1]||"."===y[d]?("."!==y[d]&&(l=u(y[d++],s)),(++d+1===y.length||"("===y[d+1]&&")"===y[d+3]||"'"===y[d+1]&&"'"===y[d+3])&&(f=u(y[d],s),m=Math.pow(10,y[d].length),d++),("("===y[d]&&")"===y[d+2]||"'"===y[d]&&"'"===y[d+2])&&(p=u(y[d+1],s),h=Math.pow(10,y[d+1].length)-1,d+=3)):"/"===y[d+1]||":"===y[d+1]?(f=u(y[d],s),m=u(y[d+2],1),d+=3):"/"===y[d+3]&&" "===y[d+1]&&(l=u(y[d],s),f=u(y[d+2],s),m=u(y[d+4],1),d+=5),y.length<=d){s=n=p+(a=m*h)*l+h*f;break}default:c()}if(0===a)throw new o;i.s=s<0?-1:1,i.n=Math.abs(n),i.d=Math.abs(a)};function p(e,t){if(!e)return t;if(!t)return e;for(;;){if(!(e%=t))return t;if(!(t%=e))return e}}function m(e,t){if(!(this instanceof m))return new m(e,t);f(e,t),e=p(i.d,i.n),this.s=i.s,this.n=i.n/e,this.d=i.d/e}m.prototype={s:1,n:0,d:1,abs:function(){return new m(this.n,this.d)},neg:function(){return new m(-this.s*this.n,this.d)},add:function(e,t){return f(e,t),new m(this.s*this.n*i.d+i.s*this.d*i.n,this.d*i.d)},sub:function(e,t){return f(e,t),new m(this.s*this.n*i.d-i.s*this.d*i.n,this.d*i.d)},mul:function(e,t){return f(e,t),new m(this.s*i.s*this.n*i.n,this.d*i.d)},div:function(e,t){return f(e,t),new m(this.s*i.s*this.n*i.d,this.d*i.n)},clone:function(){return new m(this)},mod:function(e,t){return isNaN(this.n)||isNaN(this.d)?new m(NaN):void 0===e?new m(this.s*this.n%this.d,1):(f(e,t),0===i.n&&0===this.d&&m(0,0),new m(this.s*(i.d*this.n)%(i.n*this.d),i.d*this.d))},gcd:function(e,t){return f(e,t),new m(p(i.n,this.n)*p(i.d,this.d),i.d*this.d)},lcm:function(e,t){return f(e,t),0===i.n&&0===this.n?new m:new m(i.n*this.n,p(i.n,this.n)*p(i.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.round(e*this.s*this.n/this.d),e)},inverse:function(){return new m(this.s*this.d,this.n)},pow:function(e,t){if(f(e,t),1===i.d)return i.s<0?new m(Math.pow(this.s*this.d,i.n),Math.pow(this.n,i.n)):new m(Math.pow(this.s*this.n,i.n),Math.pow(this.d,i.n));if(this.s<0)return null;var r=l(this.n),n=l(this.d),a=1,o=1;for(var s in r)if("1"!==s){if("0"===s){a=0;break}if(r[s]*=i.n,r[s]%i.d!=0)return null;r[s]/=i.d,a*=Math.pow(s,r[s])}for(var s in n)if("1"!==s){if(n[s]*=i.n,n[s]%i.d!=0)return null;n[s]/=i.d,o*=Math.pow(s,n[s])}return i.s<0?new m(o,a):new m(a,o)},equals:function(e,t){return f(e,t),this.s*this.n*i.d==i.s*i.n*this.d},compare:function(e,t){f(e,t);var r=this.s*this.n*i.d-i.s*i.n*this.d;return(00&&(r+=t,r+=" ",n%=i),r+=n,r+="/",r+=i),r},toLatex:function(e){var t,r="",n=this.n,i=this.d;return this.s<0&&(r+="-"),1===i?r+=n:(e&&(t=Math.floor(n/i))>0&&(r+=t,n%=i),r+="\\frac{",r+=n,r+="}{",r+=i,r+="}"),r},toContinued:function(){var e,t=this.n,r=this.d,n=[];if(isNaN(t)||isNaN(r))return n;do{n.push(Math.floor(t/r)),e=t%r,t=r,r=e}while(1!==t);return n},toString:function(e){var t=this.n,r=this.d;if(isNaN(t)||isNaN(r))return"NaN";e=e||15;var n=function(e,t){for(;t%2==0;t/=2);for(;t%5==0;t/=5);if(1===t)return 0;for(var r=10%t,n=1;1!==r;n++)if(r=10*r%t,n>2e3)return 0;return n}(0,r),i=function(e,t,r){for(var n=1,i=function(e,t,r){for(var n=1;t>0;e=e*e%r,t>>=1)1&t&&(n=n*e%r);return n}(10,r,t),a=0;a<300;a++){if(n===i)return a;n=10*n%t,i=10*i%t}return 0}(0,r,n),a=-1===this.s?"-":"";if(a+=t/r|0,t%=r,(t*=10)&&(a+="."),n){for(var o=i;o--;)a+=t/r|0,t%=r,t*=10;a+="(";for(o=n;o--;)a+=t/r|0,t%=r,t*=10;a+=")"}else for(o=e;t&&o--;)a+=t/r|0,t%=r,t*=10;return a}},void 0===(r=function(){return m}.apply(t,[]))||(e.exports=r)}()},228:function(e){e.exports=function e(t,r){"use strict";var n,i,a=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,o=/(^[ ]*|[ ]*$)/g,s=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,u=/^0x[0-9a-f]+$/i,c=/^0/,l=function(t){return e.insensitive&&(""+t).toLowerCase()||""+t},f=l(t).replace(o,"")||"",p=l(r).replace(o,"")||"",m=f.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),h=p.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),d=parseInt(f.match(u),16)||1!==m.length&&f.match(s)&&Date.parse(f),y=parseInt(p.match(u),16)||d&&p.match(s)&&Date.parse(p)||null;if(y){if(dy)return 1}for(var g=0,v=Math.max(m.length,h.length);gi)return 1}return 0}},377:function(e,t,r){var n=r(832),i=r(652),a=r(801),o=r(30),s=r(618),u=r(49),c=r(971);c.alea=n,c.xor128=i,c.xorwow=a,c.xorshift7=o,c.xor4096=s,c.tychei=u,e.exports=c},832:function(e,t,r){var n;!function(e,i,a){function o(e){var t,r=this,n=(t=4022871197,function(e){e=String(e);for(var r=0;r>>0,t=(n*=t)>>>0,t+=4294967296*(n-=t)}return 2.3283064365386963e-10*(t>>>0)});r.next=function(){var e=2091639*r.s0+2.3283064365386963e-10*r.c;return r.s0=r.s1,r.s1=r.s2,r.s2=e-(r.c=0|e)},r.c=1,r.s0=n(" "),r.s1=n(" "),r.s2=n(" "),r.s0-=n(e),r.s0<0&&(r.s0+=1),r.s1-=n(e),r.s1<0&&(r.s1+=1),r.s2-=n(e),r.s2<0&&(r.s2+=1),n=null}function s(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function u(e,t){var r=new o(e),n=t&&t.state,i=r.next;return i.int32=function(){return 4294967296*r.next()|0},i.double=function(){return i()+11102230246251565e-32*(2097152*i()|0)},i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.alea=u}(0,e=r.nmd(e),r.amdD)},49:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.next=function(){var e=t.b,r=t.c,n=t.d,i=t.a;return e=e<<25^e>>>7^r,r=r-n|0,n=n<<24^n>>>8^i,i=i-e|0,t.b=e=e<<20^e>>>12^r,t.c=r=r-n|0,t.d=n<<16^r>>>16^i,t.a=i-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):r+=e;for(var n=0;n>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.tychei=u}(0,e=r.nmd(e),r.amdD)},652:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:r+=e;for(var n=0;n>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xor128=u}(0,e=r.nmd(e),r.amdD)},618:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this;t.next=function(){var e,r,n=t.w,i=t.X,a=t.i;return t.w=n=n+1640531527|0,r=i[a+34&127],e=i[a=a+1&127],r^=r<<13,e^=e<<17,r^=r>>>15,e^=e>>>12,r=i[a]=r^e,t.i=a,r+(n^n>>>16)|0},function(e,t){var r,n,i,a,o,s=[],u=128;for(t===(0|t)?(n=t,t=null):(t+="\0",n=0,u=Math.max(u,t.length)),i=0,a=-32;a>>15,n^=n<<4,n^=n>>>13,a>=0&&(o=o+1640531527|0,i=0==(r=s[127&a]^=n+o)?i+1:0);for(i>=128&&(s[127&(t&&t.length||0)]=-1),i=127,a=512;a>0;--a)n=s[i+34&127],r=s[i=i+1&127],n^=n<<13,r^=r<<17,n^=n>>>15,r^=r>>>12,s[i]=n^r;e.w=o,e.X=s,e.i=i}(t,e)}function s(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function u(e,t){null==e&&(e=+new Date);var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&(n.X&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xor4096=u}(0,e=r.nmd(e),r.amdD)},30:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this;t.next=function(){var e,r,n=t.x,i=t.i;return e=n[i],r=(e^=e>>>7)^e<<24,r^=(e=n[i+1&7])^e>>>10,r^=(e=n[i+3&7])^e>>>3,r^=(e=n[i+4&7])^e<<7,e=n[i+7&7],r^=(e^=e<<13)^e<<9,n[i]=r,t.i=i+1&7,r},function(e,t){var r,n=[];if(t===(0|t))n[0]=t;else for(t=""+t,r=0;r0;--r)e.next()}(t,e)}function s(e,t){return t.x=e.x.slice(),t.i=e.i,t}function u(e,t){null==e&&(e=+new Date);var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&(n.x&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xorshift7=u}(0,e=r.nmd(e),r.amdD)},801:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:r+=e;for(var n=0;n>>4),t.next()}function s(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function u(e,t){var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xorwow=u}(0,e=r.nmd(e),r.amdD)},971:function(e,t,r){var n;!function(i,a,o){var s,u=256,c=o.pow(u,6),l=o.pow(2,52),f=2*l,p=255;function m(e,t,r){var n=[],p=g(y((t=1==t?{entropy:!0}:t||{}).entropy?[e,v(a)]:null==e?function(){try{var e;return s&&(e=s.randomBytes)?e=e(u):(e=new Uint8Array(u),(i.crypto||i.msCrypto).getRandomValues(e)),v(e)}catch(e){var t=i.navigator,r=t&&t.plugins;return[+new Date,i,r,i.screen,v(a)]}}():e,3),n),m=new h(n),x=function(){for(var e=m.g(6),t=c,r=0;e=f;)e/=2,t/=2,r>>>=1;return(e+r)/t};return x.int32=function(){return 0|m.g(4)},x.quick=function(){return m.g(4)/4294967296},x.double=x,g(v(m.S),a),(t.pass||r||function(e,t,r,n){return n&&(n.S&&d(n,m),e.state=function(){return d(m,{})}),r?(o.random=e,t):e})(x,p,"global"in t?t.global:this==o,t.state)}function h(e){var t,r=e.length,n=this,i=0,a=n.i=n.j=0,o=n.S=[];for(r||(e=[r++]);i3?e.slice(3):"any":e).split("|").map(F).filter(P).filter(U),i=B(t,n),a=n.map((function(e){var t=c(e);return{name:e,typeIndex:l(t),test:t.test,conversion:null,conversionIndex:-1}})),o=i.map((function(e){var r=c(e.from);return{name:e.from,typeIndex:l(r),test:r.test,conversion:e,conversionIndex:t.indexOf(e)}}));return{types:a.concat(o),restParam:r}}function y(e,t,r){var n=[];return""!==e.trim()&&(n=e.split(",").map(F).map((function(e,t,n){var i=d(e,r);if(i.restParam&&t!==n.length-1)throw new SyntaxError('Unexpected rest parameter "'+e+'": only allowed for the last parameter');return i}))),n.some(L)?null:{params:n,fn:t}}function g(e){var t=$(e);return!!t&&t.restParam}function v(e){return e.types.some((function(e){return null!=e.conversion}))}function x(t){if(t&&0!==t.types.length){if(1===t.types.length)return c(t.types[0].name).test;if(2===t.types.length){var r=c(t.types[0].name).test,n=c(t.types[1].name).test;return function(e){return r(e)||n(e)}}var i=t.types.map((function(e){return c(e.name).test}));return function(e){for(var t=0;t=i+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(r=x(e[0]),function(e){return r(e[0])&&1===e.length}):2===e.length?(r=x(e[0]),n=x(e[1]),function(e){return r(e[0])&&n(e[1])&&2===e.length}):(t=e.map(x),function(e){for(var r=0;r0){var c=f(t[a]);return(n=new TypeError("Unexpected type of argument in function "+o+" (expected: "+i.join(" or ")+", actual: "+c+", index: "+a+")")).data={category:"wrongType",fn:o,index:a,actual:c,expected:i},n}}else s=u}var l=s.map((function(e){return g(e.params)?1/0:e.params.length}));if(t.lengthp?((n=new TypeError("Too many arguments in function "+o+" (expected: "+p+", actual: "+t.length+")")).data={category:"tooManyArgs",fn:o,index:t.length,expectedLength:p},n):((n=new TypeError('Arguments of type "'+t.join(", ")+'" do not match any of the defined signatures of function '+o+".")).data={category:"mismatch",actual:t.map(f)},n)}function O(e){for(var t=999,r=0;r=i:s?i>=a:i===a}function R(e,n){if(0===Object.keys(n).length)throw new SyntaxError("No signatures provided");var i=[];Object.keys(n).map((function(e){return y(e,n[e],u.conversions)})).filter(j).forEach((function(e){var t=W(i,(function(t){return D(t,e)}));if(t)throw new TypeError('Conflicting signatures "'+h(t.params)+'" and "'+h(e.params)+'".');i.push(e)}));var a=J(i,(function(e){return(e?I(e.params,!1):[]).map((function(t){return{params:t,fn:e.fn}}))})).filter(j);a.sort(T);var o=a[0]&&a[0].params.length<=2&&!g(a[0].params),s=a[1]&&a[1].params.length<=2&&!g(a[1].params),c=a[2]&&a[2].params.length<=2&&!g(a[2].params),l=a[3]&&a[3].params.length<=2&&!g(a[3].params),f=a[4]&&a[4].params.length<=2&&!g(a[4].params),p=a[5]&&a[5].params.length<=2&&!g(a[5].params),m=o&&s&&c&&l&&f&&p,d=a.map((function(e){return b(e.params)})),v=o?x(a[0].params[0]):t,w=s?x(a[1].params[0]):t,N=c?x(a[2].params[0]):t,M=l?x(a[3].params[0]):t,S=f?x(a[4].params[0]):t,E=p?x(a[5].params[0]):t,O=o?x(a[0].params[1]):t,C=s?x(a[1].params[1]):t,_=c?x(a[2].params[1]):t,B=l?x(a[3].params[1]):t,z=f?x(a[4].params[1]):t,R=p?x(a[5].params[1]):t,U=a.map((function(e){return q(e.params,e.fn)})),F=o?U[0]:r,P=s?U[1]:r,L=c?U[2]:r,H=l?U[3]:r,$=f?U[4]:r,G=p?U[5]:r,V=o?a[0].params.length:-1,Z=s?a[1].params.length:-1,Y=c?a[2].params.length:-1,X=l?a[3].params.length:-1,Q=f?a[4].params.length:-1,K=p?a[5].params.length:-1,ee=m?6:0,te=a.length,re=function(){for(var t=ee;t0?1:e<0?-1:0},W=Math.log2||function(e){return Math.log(e)/Math.LN2},Y=Math.log10||function(e){return Math.log(e)/Math.LN10},J=Math.log1p||function(e){return Math.log(e+1)},X=Math.cbrt||function(e){if(0===e)return e;var t,r=e<0;return r&&(e=-e),t=isFinite(e)?(e/((t=Math.exp(Math.log(e)/3))*t)+2*t)/3:e,r?-t:t},Q=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function K(e,t,r){var n={2:"0b",8:"0o",16:"0x"}[t],i="";if(r){if(r<1)throw new Error("size must be in greater than 0");if(!V(r))throw new Error("size must be an integer");if(e>2**(r-1)-1||e<-(2**(r-1)))throw new Error("Value must be in range [-2^".concat(r-1,", 2^").concat(r-1,"-1]"));if(!V(e))throw new Error("Value must be an integer");e<0&&(e+=2**r),i="i".concat(r)}var a="";return e<0&&(e=-e,a="-"),"".concat(a).concat(n).concat(e.toString(t)).concat(i)}function ee(e,t){if("function"==typeof t)return t(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var r,n,i="auto";if(t&&(t.notation&&(i=t.notation),s(t)?r=t:s(t.precision)&&(r=t.precision),t.wordSize&&"number"!=typeof(n=t.wordSize)))throw new Error('Option "wordSize" must be a number');switch(i){case"fixed":return re(e,r);case"exponential":return ne(e,r);case"engineering":return function(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=ie(te(e),t),n=r.exponent,i=r.coefficients,a=n%3==0?n:n<0?n-3-n%3:n-n%3;if(s(t))for(;t>i.length||n-a+1>i.length;)i.push(0);else for(var o=Math.abs(n-a)-(i.length-1),u=0;u0;)l++,c--;var f=i.slice(l).join(""),p=s(t)&&f.length||f.match(/[1-9]/)?"."+f:"",m=i.slice(0,l).join("")+p+"e"+(n>=0?"+":"")+a.toString();return r.sign+m}(e,r);case"bin":return K(e,2,n);case"oct":return K(e,8,n);case"hex":return K(e,16,n);case"auto":return function(e,t,r){if(isNaN(e)||!isFinite(e))return String(e);var n=r&&void 0!==r.lowerExp?r.lowerExp:-3,i=r&&void 0!==r.upperExp?r.upperExp:5,a=te(e),o=t?ie(a,t):a;if(o.exponent=i)return ne(e,t);var s=o.coefficients,u=o.exponent;s.length0?u:0;return c<(s=ae(-u).concat(s)).length-1&&s.splice(c+1,0,"."),o.sign+s.join("")}(e,r,t&&t).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t}));default:throw new Error('Unknown notation "'+i+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function te(e){var t=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+e);var r=t[1],n=t[2],i=parseFloat(t[4]||"0"),a=n.indexOf(".");i+=-1!==a?a-1:n.length-1;var o=n.replace(".","").replace(/^0*/,(function(e){return i-=e.length,""})).replace(/0*$/,"").split("").map((function(e){return parseInt(e)}));return 0===o.length&&(o.push(0),i++),{sign:r,coefficients:o,exponent:i}}function re(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=te(e),n="number"==typeof t?ie(r,r.exponent+1+t):r,i=n.coefficients,a=n.exponent+1,o=a+(t||0);return i.length0?"."+i.join(""):"")+"e"+(a>=0?"+":"")+a}function ie(e,t){for(var r={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},n=r.coefficients;t<=0;)n.unshift(0),r.exponent++,t++;if(n.length>t&&n.splice(t,n.length-t)[0]>=5){var i=t-1;for(n[i]++;10===n[i];)n.pop(),0===i&&(n.unshift(0),r.exponent++,i++),n[--i]++}return r}function ae(e){for(var t=[],r=0;r=0?"+":"")+n.toString()}(e,r);case"bin":return he(e,2,n);case"oct":return he(e,8,n);case"hex":return he(e,16,n);case"auto":var a=t&&void 0!==t.lowerExp?t.lowerExp:-3,o=t&&void 0!==t.upperExp?t.upperExp:5;if(e.isZero())return"0";var s=e.toSignificantDigits(r),u=s.e;return(u>=a&&u'"'+r+'": '+ve(e[r],t))).join(", ")+"}":String(e)}function xe(e){for(var t=String(e),r="",n=0;n/g,">")}function we(e,t){if(Array.isArray(e)){for(var r="[",n=e.length,i=0;it?1:-1}function Me(e){var t=typeof e;if("number"===t||"string"===t||"boolean"===t||null==e)return e;if("function"==typeof e.clone)return e.clone();if(Array.isArray(e))return e.map((function(e){return Me(e)}));if(e instanceof Date)return new Date(e.valueOf());if(u(e))return e;if(e instanceof RegExp)throw new TypeError("Cannot clone "+e);return function(e,t){var r={};for(var n in e)Ae(e,n)&&(r[n]=t(e[n]));return r}(e,Me)}function Se(e,t){for(var r in t)Ae(t,r)&&(e[r]=t[r]);return e}function Ee(e,t){var r,n,i;if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(n=0,i=e.length;n!function(e){return e&&"?"===e[0]}(e))).every((e=>void 0!==r[e]))){var n=t.filter((e=>void 0===r[e]));throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(n.map((e=>'"'.concat(e,'"'))).join(", "),"."))}}(e,t,n),r(i)}return i.isFactory=!0,i.fn=e,i.dependencies=t.slice().sort(),n&&(i.meta=n),i}function Ce(e){return e&&"?"===e[0]?e.slice(1):e}var _e=Oe("Chain",["?on","math"],(e=>{var{on:t,math:r}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");$(e)?this.value=e.value:this.value=e}function i(e,t){var r,i,o,s,u;r=n.prototype,i=e,o=function(){var e=t();if("function"==typeof e)return a(e)},u=!0,Object.defineProperty(r,i,{get:function(){return u&&(s=o(),u=!1),s},set:function(e){s=e,u=!1},configurable:!0,enumerable:!0})}function a(e){return function(){for(var t=[this.value],r=0;re[t]))};for(var s in e)r(s)}var u,c};var o={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return n.createProxy(r),t&&t("import",(function(e,t,r){r||i(e,t)})),n}),{isClass:!0}),Te=new Set(["end"]);function Be(e,t){if(Ie(e)&&ze(e,t))return e[t];if("function"==typeof e[t]&&ke(e,t))throw new Error('Cannot access method "'+t+'" as a property');throw new Error('No access to property "'+t+'"')}function qe(e,t,r){if(Ie(e)&&ze(e,t))return e[t]=r,r;throw new Error('No access to property "'+t+'"')}function ze(e,t){return!(!e||"object"!=typeof e)&&(!!Ae(De,t)||!(t in Object.prototype)&&!(t in Function.prototype))}function ke(e,t){return null!=e&&"function"==typeof e[t]&&(!(Ae(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e))&&(!!Ae(Re,t)||!(t in Object.prototype)&&!(t in Function.prototype)))}function Ie(e){return"object"==typeof e&&e&&e.constructor===Object}var De={length:!0,name:!0},Re={toString:!0,valueOf:!0,toLocaleString:!0};class Ue{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return Be(this.wrappedObject,e)}set(e,t){return qe(this.wrappedObject,e,t),this}has(e){return t=this.wrappedObject,e in t;var t}}function Fe(){return new Map}function Pe(e){if(!e)return Fe();if(je(e))return e;if(A(e))return new Ue(e);throw new Error("createMap can create maps from objects or Maps")}function je(e){return!!e&&(e instanceof Map||e instanceof Ue||"function"==typeof e.set&&"function"==typeof e.get&&"function"==typeof e.keys&&"function"==typeof e.has)}function Le(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{var{mathWithTransform:t}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator")}return r.prototype.evaluate=function(e){return this.compile().evaluate(e)},r.prototype.type="Node",r.prototype.isNode=!0,r.prototype.comment="",r.prototype.compile=function(){var e=this._compile(t,{}),r={};return{evaluate:function(t){var n=Pe(t);return function(e){for(var t of[...Te])if(e.has(t))throw new Error('Scope contains an illegal symbol, "'+t+'" is a reserved keyword')}(n),e(n,r,null)}}},r.prototype._compile=function(e,t){throw new Error("Method _compile should be implemented by type "+this.type)},r.prototype.forEach=function(e){throw new Error("Cannot run forEach on a Node interface")},r.prototype.map=function(e){throw new Error("Cannot run map on a Node interface")},r.prototype._ifNode=function(e){if(!U(e))throw new TypeError("Callback function must return a Node");return e},r.prototype.traverse=function(e){e(this,null,null),function e(t,r){t.forEach((function(t,n,i){r(t,n,i),e(t,r)}))}(this,e)},r.prototype.transform=function(e){return function t(r,n,i){var a=e(r,n,i);return a!==r?a:r.map(t)}(this,null,null)},r.prototype.filter=function(e){var t=[];return this.traverse((function(r,n,i){e(r,n,i)&&t.push(r)})),t},r.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},r.prototype.cloneDeep=function(){return this.map((function(e){return e.cloneDeep()}))},r.prototype.equals=function(e){return!!e&&Ee(this,e)},r.prototype.toString=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toString(e)},r.prototype.toJSON=function(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)},r.prototype.toHTML=function(e){var t=this._getCustomString(e);return void 0!==t?t:this.toHTML(e)},r.prototype._toString=function(){throw new Error("_toString not implemented for "+this.type)},r.prototype.toTex=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toTex(e)},r.prototype._toTex=function(e){throw new Error("_toTex not implemented for "+this.type)},r.prototype._getCustomString=function(e){if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":return;case"function":return e.handler(this,e);default:throw new TypeError("Object or function expected as callback")}},r.prototype.getIdentifier=function(){return this.type},r.prototype.getContent=function(){return this},r}),{isClass:!0,isNode:!0}),$e=Oe("ObjectNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=e||{},e&&("object"!=typeof e||!Object.keys(e).every((function(t){return U(e[t])}))))throw new TypeError("Object containing Nodes expected")}return r.prototype=new t,r.prototype.type="ObjectNode",r.prototype.isObjectNode=!0,r.prototype._compile=function(e,t){var r={};for(var n in this.properties)if(Ae(this.properties,n)){var i=xe(n),a=JSON.parse(i);if(!ze(this.properties,a))throw new Error('No access to property "'+a+'"');r[a]=this.properties[n]._compile(e,t)}return function(e,t,n){var i={};for(var a in r)Ae(r,a)&&(i[a]=r[a](e,t,n));return i}},r.prototype.forEach=function(e){for(var t in this.properties)Ae(this.properties,t)&&e(this.properties[t],"properties["+xe(t)+"]",this)},r.prototype.map=function(e){var t={};for(var n in this.properties)Ae(this.properties,n)&&(t[n]=this._ifNode(e(this.properties[n],"properties["+xe(n)+"]",this)));return new r(t)},r.prototype.clone=function(){var e={};for(var t in this.properties)Ae(this.properties,t)&&(e[t]=this.properties[t]);return new r(e)},r.prototype._toString=function(e){var t=[];for(var r in this.properties)Ae(this.properties,r)&&t.push(xe(r)+": "+this.properties[r].toString(e));return"{"+t.join(", ")+"}"},r.prototype.toJSON=function(){return{mathjs:"ObjectNode",properties:this.properties}},r.fromJSON=function(e){return new r(e.properties)},r.prototype.toHTML=function(e){var t=[];for(var r in this.properties)Ae(this.properties,r)&&t.push(''+be(r)+':'+this.properties[r].toHTML(e));return'{'+t.join(',')+'}'},r.prototype._toTex=function(e){var t=[];for(var r in this.properties)Ae(this.properties,r)&&t.push("\\mathbf{"+r+":} & "+this.properties[r].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(t.join("\n"),"\\end{array}\\right\\}")},r}),{isClass:!0,isNode:!0});function Ge(e,t,r){if(!(this instanceof Ge))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=t,this.relation=r,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=(new Error).stack}function Ve(e,t,r){if(!(this instanceof Ve))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=r),void 0!==this.min&&this.index=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}function Ze(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function We(e,t,r){var n,i=e.length;if(i!==t[r])throw new Ge(i,t[r]);if(r")}function Ye(e,t){if(0===t.length){if(Array.isArray(e))throw new Ge(e.length,0)}else We(e,t,0)}function Je(e,t){if(!s(e)||!V(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&e>=t)throw new Ve(e,t)}function Xe(e,t,r){if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");return t.forEach((function(e){if(!s(e)||!V(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+ve(t)+")")})),Qe(e,t,0,void 0!==r?r:0),e}function Qe(e,t,r,n){var i,a,o=e.length,s=t[r],u=Math.min(o,s);if(e.length=s,r=0){if(!(t%r==0))throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-r);n[i]=-t/r}return n}function tt(e){return e.reduce(((e,t)=>e*t),1)}function rt(e,t){for(var r=t||Ze(e);Array.isArray(e)&&1===e.length;)e=e[0],r.shift();for(var n=r.length;1===r[n-1];)n--;return nt.test(e)))}function ft(e,t){return Array.prototype.join.call(e,t)}function pt(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;var t=[],r=0;t[0]={value:e[0],identifier:0};for(var n=1;n>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},Nt={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(wt.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(wt.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(wt.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(wt.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(wt.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(wt.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(wt.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(wt.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(wt.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(wt.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(wt.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(wt.bitAnd,"${args[1]}\\right)")},bitNot:{1:wt.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(wt.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(wt.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(wt.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(wt.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(wt.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(wt.and,"${args[1]}\\right)")},not:{1:wt.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(wt.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(wt.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(wt.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}"},sqrtm:{1:"{${args[0]}}".concat(wt.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(wt.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(wt.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(wt.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(wt.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(wt.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(wt.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(wt.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(wt.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(wt.to,"${args[1]}\\right)")},numeric:function(e,t){return e.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(bt.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)"}},Mt={deg:"^\\circ"};function St(e){return xt(e,{preserveFormatting:!0})}function Et(e,t){return(t=void 0!==t&&t)?Ae(Mt,e)?Mt[e]:"\\mathrm{"+St(e)+"}":Ae(bt,e)?bt[e]:St(e)}var At=Oe("OperatorNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n,i,a){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('string expected for parameter "op"');if("string"!=typeof t)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(n)||!n.every(U))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=!0===i,this.isPercentage=!0===a,this.op=e,this.fn=t,this.args=n||[]}function n(e,t,r,n,i){var a,o=yt(e,t),s=gt(e,t);if("all"===t||n.length>2&&"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier())return n.map((function(e){switch(e.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}}));switch(n.length){case 0:a=[];break;case 1:var u=yt(n[0],t);if(i&&null!==u){var c,l;if("keep"===t?(c=n[0].getIdentifier(),l=e.getIdentifier()):(c=n[0].getContent().getIdentifier(),l=e.getContent().getIdentifier()),!1===dt[o][l].latexLeftParens){a=[!1];break}if(!1===dt[u][c].latexParens){a=[!1];break}}if(null===u){a=[!1];break}if(u<=o){a=[!0];break}a=[!1];break;case 2:var f,p,m=yt(n[0],t),h=vt(e,n[0],t);f=null!==m&&(m===o&&"right"===s&&!h||m=2&&"OperatorNode:multiply"===e.getIdentifier()&&e.implicit&&"auto"===t&&"hide"===r&&(a=n.map((function(e,t){var r="ParenthesisNode"===e.getIdentifier();return!(!a[t]&&!r)}))),a}return r.prototype=new t,r.prototype.type="OperatorNode",r.prototype.isOperatorNode=!0,r.prototype._compile=function(e,t){if("string"!=typeof this.fn||!ke(e,this.fn))throw e[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var r=Be(e,this.fn),n=st(this.args,(function(r){return r._compile(e,t)}));if(1===n.length){var i=n[0];return function(e,t,n){return r(i(e,t,n))}}if(2===n.length){var a=n[0],o=n[1];return function(e,t,n){return r(a(e,t,n),o(e,t,n))}}return function(e,t,i){return r.apply(null,st(n,(function(r){return r(e,t,i)})))}},r.prototype.forEach=function(e){for(var t=0;t2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var f=i.map((function(t,r){return t=t.toString(e),a[r]&&(t="("+t+")"),t}));return this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?f.join(" "):f.join(" "+this.op+" ")}return this.fn+"("+this.args.join(", ")+")"},r.prototype.toJSON=function(){return{mathjs:"OperatorNode",op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}},r.fromJSON=function(e){return new r(e.op,e.fn,e.args,e.implicit,e.isPercentage)},r.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,t,r,i,!1);if(1===i.length){var o=gt(this,t),s=i[0].toHTML(e);return a[0]&&(s='('+s+')'),"right"===o?''+be(this.op)+""+s:s+''+be(this.op)+""}if(2===i.length){var u=i[0].toHTML(e),c=i[1].toHTML(e);return a[0]&&(u='('+u+')'),a[1]&&(c='('+c+')'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?u+''+c:u+''+be(this.op)+""+c}var l=i.map((function(t,r){return t=t.toHTML(e),a[r]&&(t='('+t+')'),t}));return i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())?this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?l.join(''):l.join(''+be(this.op)+""):''+be(this.fn)+'('+l.join(',')+')'},r.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,t,r,i,!0),o=wt[this.fn];if(o=void 0===o?this.op:o,1===i.length){var s=gt(this,t),u=i[0].toTex(e);return a[0]&&(u="\\left(".concat(u,"\\right)")),"right"===s?o+u:u+o}if(2===i.length){var c=i[0],l=c.toTex(e);a[0]&&(l="\\left(".concat(l,"\\right)"));var f,p=i[1].toTex(e);switch(a[1]&&(p="\\left(".concat(p,"\\right)")),f="keep"===t?c.getIdentifier():c.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return o+"{"+l+"}{"+p+"}";case"OperatorNode:pow":switch(l="{"+l+"}",p="{"+p+"}",f){case"ConditionalNode":case"OperatorNode:divide":l="\\left(".concat(l,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&"hide"===r)return l+"~"+p}return l+o+p}if(i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var m=i.map((function(t,r){return t=t.toTex(e),a[r]&&(t="\\left(".concat(t,"\\right)")),t}));return"OperatorNode:multiply"===this.getIdentifier()&&this.implicit?m.join("~"):m.join(o)}return"\\mathrm{"+this.fn+"}\\left("+i.map((function(t){return t.toTex(e)})).join(",")+"\\right)"},r.prototype.getIdentifier=function(){return this.type+":"+this.fn},r}),{isClass:!0,isNode:!0}),Ot=Oe("ParenthesisNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!U(e))throw new TypeError('Node expected for parameter "content"');this.content=e}return r.prototype=new t,r.prototype.type="ParenthesisNode",r.prototype.isParenthesisNode=!0,r.prototype._compile=function(e,t){return this.content._compile(e,t)},r.prototype.getContent=function(){return this.content.getContent()},r.prototype.forEach=function(e){e(this.content,"content",this)},r.prototype.map=function(e){return new r(e(this.content,"content",this))},r.prototype.clone=function(){return new r(this.content)},r.prototype._toString=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)},r.prototype.toJSON=function(){return{mathjs:"ParenthesisNode",content:this.content}},r.fromJSON=function(e){return new r(e.content)},r.prototype.toHTML=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?'('+this.content.toHTML(e)+')':this.content.toHTML(e)},r.prototype._toTex=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)},r}),{isClass:!0,isNode:!0}),Ct=Oe("RelationalNode",["Node"],(e=>{var{Node:t}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(t))throw new TypeError("Parameter params must be an array");if(e.length!==t.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=t}return r.prototype=new t,r.prototype.type="RelationalNode",r.prototype.isRelationalNode=!0,r.prototype._compile=function(e,t){var r=this,n=this.params.map((r=>r._compile(e,t)));return function(t,i,a){for(var o,s=n[0](t,i,a),u=0;ue(t,"params["+r+"]",this)),this)},r.prototype.map=function(e){return new r(this.conditionals.slice(),this.params.map(((t,r)=>this._ifNode(e(t,"params["+r+"]",this))),this))},r.prototype.clone=function(){return new r(this.conditionals,this.params)},r.prototype._toString=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",r=yt(this,t),n=this.params.map((function(n,i){var a=yt(n,t);return"all"===t||null!==a&&a<=r?"("+n.toString(e)+")":n.toString(e)})),i={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},a=n[0],o=0;o('+n.toHTML(e)+')':n.toHTML(e)})),i={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},a=n[0],o=0;o'+be(i[this.conditionals[o]])+""+n[o+1];return a},r.prototype._toTex=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",r=yt(this,t),n=this.params.map((function(n,i){var a=yt(n,t);return"all"===t||null!==a&&a<=r?"\\left("+n.toTex(e)+"\right)":n.toTex(e)})),i=n[0],a=0;a{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=e||[],!Array.isArray(this.items)||!this.items.every(U))throw new TypeError("Array containing Nodes expected")}return r.prototype=new t,r.prototype.type="ArrayNode",r.prototype.isArrayNode=!0,r.prototype._compile=function(e,t){var r=st(this.items,(function(r){return r._compile(e,t)}));if("Array"!==e.config.matrix){var n=e.matrix;return function(e,t,i){return n(st(r,(function(r){return r(e,t,i)})))}}return function(e,t,n){return st(r,(function(r){return r(e,t,n)}))}},r.prototype.forEach=function(e){for(var t=0;t['+this.items.map((function(t){return t.toHTML(e)})).join(',')+']'},r.prototype._toTex=function(e){return function t(r,n){var i=r.some(T)&&!r.every(T),a=n||i,o=a?"&":"\\\\",s=r.map((function(r){return r.items?t(r.items,!n):r.toTex(e)})).join(o);return i||!a||a&&!n?"\\begin{bmatrix}"+s+"\\end{bmatrix}":s}(this.items,!1)},r}),{isClass:!0,isNode:!0}),Tt=Oe("BlockNode",["ResultSet","Node"],(e=>{var{ResultSet:t,Node:r}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map((function(e){var t=e&&e.node,r=!e||void 0===e.visible||e.visible;if(!U(t))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof r)throw new TypeError('Property "visible" must be a boolean');return{node:t,visible:r}}))}return n.prototype=new r,n.prototype.type="BlockNode",n.prototype.isBlockNode=!0,n.prototype._compile=function(e,r){var n=st(this.blocks,(function(t){return{evaluate:t.node._compile(e,r),visible:t.visible}}));return function(e,r,i){var a=[];return ut(n,(function(t){var n=t.evaluate(e,r,i);t.visible&&a.push(n)})),new t(a)}},n.prototype.forEach=function(e){for(var t=0;t;')})).join('
')},n.prototype._toTex=function(e){return this.blocks.map((function(t){return t.node.toTex(e)+(t.visible?"":";")})).join("\\;\\;\n")},n}),{isClass:!0,isNode:!0}),Bt=Oe("ConditionalNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!U(e))throw new TypeError("Parameter condition must be a Node");if(!U(t))throw new TypeError("Parameter trueExpr must be a Node");if(!U(n))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=t,this.falseExpr=n}return r.prototype=new t,r.prototype.type="ConditionalNode",r.prototype.isConditionalNode=!0,r.prototype._compile=function(e,t){var r=this.condition._compile(e,t),n=this.trueExpr._compile(e,t),i=this.falseExpr._compile(e,t);return function(e,t,a){return function(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return!!e;if(e){if(u(e))return!e.isZero();if(c(e))return!(!e.re&&!e.im);if(f(e))return!!e.value}if(null==e)return!1;throw new TypeError('Unsupported type of condition "'+G(e)+'"')}(r(e,t,a))?n(e,t,a):i(e,t,a)}},r.prototype.forEach=function(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)},r.prototype.map=function(e){return new r(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))},r.prototype.clone=function(){return new r(this.condition,this.trueExpr,this.falseExpr)},r.prototype._toString=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=yt(this,t),n=this.condition.toString(e),i=yt(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n="("+n+")");var a=this.trueExpr.toString(e),o=yt(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a="("+a+")");var s=this.falseExpr.toString(e),u=yt(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s="("+s+")"),n+" ? "+a+" : "+s},r.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},r.fromJSON=function(e){return new r(e.condition,e.trueExpr,e.falseExpr)},r.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=yt(this,t),n=this.condition.toHTML(e),i=yt(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n='('+n+')');var a=this.trueExpr.toHTML(e),o=yt(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a='('+a+')');var s=this.falseExpr.toHTML(e),u=yt(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s='('+s+')'),n+'?'+a+':'+s},r.prototype._toTex=function(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"},r}),{isClass:!0,isNode:!0}),qt=Oe("ConstantNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this.value=e}return r.prototype=new t,r.prototype.type="ConstantNode",r.prototype.isConstantNode=!0,r.prototype._compile=function(e,t){var r=this.value;return function(){return r}},r.prototype.forEach=function(e){},r.prototype.map=function(e){return this.clone()},r.prototype.clone=function(){return new r(this.value)},r.prototype._toString=function(e){return ve(this.value,e)},r.prototype.toHTML=function(e){var t=this._toString(e);switch(G(this.value)){case"number":case"BigNumber":case"Fraction":return''+t+"";case"string":return''+t+"";case"boolean":return''+t+"";case"null":return''+t+"";case"undefined":return''+t+"";default:return''+t+""}},r.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},r.fromJSON=function(e){return new r(e.value)},r.prototype._toTex=function(e){var t=this._toString(e);switch(G(this.value)){case"string":return"\\mathtt{"+St(t)+"}";case"number":case"BigNumber":if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var r=t.toLowerCase().indexOf("e");return-1!==r?t.substring(0,r)+"\\cdot10^{"+t.substring(r+1)+"}":t;case"Fraction":return this.value.toLatex();default:return t}},r}),{isClass:!0,isNode:!0}),zt=Oe("RangeNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!U(e))throw new TypeError("Node expected");if(!U(t))throw new TypeError("Node expected");if(n&&!U(n))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=e,this.end=t,this.step=n||null}function n(e,t){var r=yt(e,t),n={},i=yt(e.start,t);if(n.start=null!==i&&i<=r||"all"===t,e.step){var a=yt(e.step,t);n.step=null!==a&&a<=r||"all"===t}var o=yt(e.end,t);return n.end=null!==o&&o<=r||"all"===t,n}return r.prototype=new t,r.prototype.type="RangeNode",r.prototype.isRangeNode=!0,r.prototype.needsEnd=function(){return this.filter((function(e){return H(e)&&"end"===e.name})).length>0},r.prototype._compile=function(e,t){var r=e.range,n=this.start._compile(e,t),i=this.end._compile(e,t);if(this.step){var a=this.step._compile(e,t);return function(e,t,o){return r(n(e,t,o),i(e,t,o),a(e,t,o))}}return function(e,t,a){return r(n(e,t,a),i(e,t,a))}},r.prototype.forEach=function(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)},r.prototype.map=function(e){return new r(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))},r.prototype.clone=function(){return new r(this.start,this.end,this.step&&this.step)},r.prototype._toString=function(e){var t,r=n(this,e&&e.parenthesis?e.parenthesis:"keep"),i=this.start.toString(e);if(r.start&&(i="("+i+")"),t=i,this.step){var a=this.step.toString(e);r.step&&(a="("+a+")"),t+=":"+a}var o=this.end.toString(e);return r.end&&(o="("+o+")"),t+=":"+o},r.prototype.toJSON=function(){return{mathjs:"RangeNode",start:this.start,end:this.end,step:this.step}},r.fromJSON=function(e){return new r(e.start,e.end,e.step)},r.prototype.toHTML=function(e){var t,r=n(this,e&&e.parenthesis?e.parenthesis:"keep"),i=this.start.toHTML(e);if(r.start&&(i='('+i+')'),t=i,this.step){var a=this.step.toHTML(e);r.step&&(a='('+a+')'),t+=':'+a}var o=this.end.toHTML(e);return r.end&&(o='('+o+')'),t+=':'+o},r.prototype._toTex=function(e){var t=n(this,e&&e.parenthesis?e.parenthesis:"keep"),r=this.start.toTex(e);if(t.start&&(r="\\left(".concat(r,"\\right)")),this.step){var i=this.step.toTex(e);t.step&&(i="\\left(".concat(i,"\\right)")),r+=":"+i}var a=this.end.toTex(e);return t.end&&(a="\\left(".concat(a,"\\right)")),r+=":"+a},r}),{isClass:!0,isNode:!0}),kt=Oe("reviver",["classes"],(e=>{var{classes:t}=e;return function(e,r){var n=t[r&&r.mathjs];return n&&"function"==typeof n.fromJSON?n.fromJSON(r):r}})),It="chain",Dt=Oe(It,["typed","Chain"],(e=>{var{typed:t,Chain:r}=e;return t(It,{"":function(){return new r},any:function(e){return new r(e)}})})),Rt=Oe("FunctionAssignmentNode",["typed","Node"],(e=>{var{typed:t,Node:r}=e;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(t))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!U(r))throw new TypeError('Node expected for parameter "expr"');if(Te.has(e))throw new Error('Illegal function name, "'+e+'" is a reserved keyword');this.name=e,this.params=t.map((function(e){return e&&e.name||e})),this.types=t.map((function(e){return e&&e.type||"any"})),this.expr=r}function i(e,t){var r=yt(e,t),n=yt(e.expr,t);return"all"===t||null!==n&&n<=r}return n.prototype=new r,n.prototype.type="FunctionAssignmentNode",n.prototype.isFunctionAssignmentNode=!0,n.prototype._compile=function(e,r){var n=Object.create(r);ut(this.params,(function(e){n[e]=!0}));var i=this.expr._compile(e,n),a=this.name,o=this.params,s=ft(this.types,","),u=a+"("+ft(this.params,", ")+")";return function(e,r,n){var c={};c[s]=function(){for(var t=Object.create(r),a=0;a'+be(this.params[n])+"");var a=this.expr.toHTML(e);return i(this,t)&&(a='('+a+')'),''+be(this.name)+'('+r.join(',')+')='+a},n.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=this.expr.toTex(e);return i(this,t)&&(r="\\left(".concat(r,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(Et).join(",")+"\\right):="+r},n}),{isClass:!0,isNode:!0});function Ut(e){return e&&e.isIndexError?new Ve(e.index+1,e.min+1,void 0!==e.max?e.max+1:void 0):e}function Ft(e){var{subset:t}=e;return function(e,r){try{if(Array.isArray(e))return t(e,r);if(e&&"function"==typeof e.subset)return e.subset(r);if("string"==typeof e)return t(e,r);if("object"==typeof e){if(!r.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return Be(e,r.getObjectProperty())}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Ut(e)}}}var Pt=Oe("AccessorNode",["subset","Node"],(e=>{var{subset:t,Node:r}=e,n=Ft({subset:t});function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(!U(e))throw new TypeError('Node expected for parameter "object"');if(!R(t))throw new TypeError('IndexNode expected for parameter "index"');this.object=e||null,this.index=t,Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function a(e){return!(_(e)||T(e)||k(e)||D(e)||F(e)||j(e)||H(e))}return i.prototype=new r,i.prototype.type="AccessorNode",i.prototype.isAccessorNode=!0,i.prototype._compile=function(e,t){var r=this.object._compile(e,t),i=this.index._compile(e,t);if(this.index.isObjectProperty()){var a=this.index.getObjectProperty();return function(e,t,n){return Be(r(e,t,n),a)}}return function(e,t,a){var o=r(e,t,a),s=i(e,t,o);return n(o,s)}},i.prototype.forEach=function(e){e(this.object,"object",this),e(this.index,"index",this)},i.prototype.map=function(e){return new i(this._ifNode(e(this.object,"object",this)),this._ifNode(e(this.index,"index",this)))},i.prototype.clone=function(){return new i(this.object,this.index)},i.prototype._toString=function(e){var t=this.object.toString(e);return a(this.object)&&(t="("+t+")"),t+this.index.toString(e)},i.prototype.toHTML=function(e){var t=this.object.toHTML(e);return a(this.object)&&(t='('+t+')'),t+this.index.toHTML(e)},i.prototype._toTex=function(e){var t=this.object.toTex(e);return a(this.object)&&(t="\\left(' + object + '\\right)"),t+this.index.toTex(e)},i.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},i.fromJSON=function(e){return new i(e.object,e.index)},i}),{isClass:!0,isNode:!0});var jt=Oe("AssignmentNode",["subset","?matrix","Node"],(e=>{var{subset:t,matrix:r,Node:n}=e,i=Ft({subset:t}),a=function(e){var{subset:t,matrix:r}=e;return function(e,n,i){try{if(Array.isArray(e))return r(e).subset(n,i).valueOf();if(e&&"function"==typeof e.subset)return e.subset(n,i);if("string"==typeof e)return t(e,n,i);if("object"==typeof e){if(!n.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return qe(e,n.getObjectProperty(),i),e}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Ut(e)}}}({subset:t,matrix:r});function o(e,t,r){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=e,this.index=r?t:null,this.value=r||t,!H(e)&&!_(e))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(H(e)&&"end"===e.name)throw new Error('Cannot assign to symbol "end"');if(this.index&&!R(this.index))throw new TypeError('IndexNode expected as "index"');if(!U(this.value))throw new TypeError('Node expected as "value"');Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function s(e,t){t||(t="keep");var r=yt(e,t),n=yt(e.value,t);return"all"===t||null!==n&&n<=r}return o.prototype=new n,o.prototype.type="AssignmentNode",o.prototype.isAssignmentNode=!0,o.prototype._compile=function(e,t){var r=this.object._compile(e,t),n=this.index?this.index._compile(e,t):null,o=this.value._compile(e,t),s=this.object.name;if(this.index){if(this.index.isObjectProperty()){var u=this.index.getObjectProperty();return function(e,t,n){var i=r(e,t,n),a=o(e,t,n);return qe(i,u,a),a}}if(H(this.object))return function(e,t,i){var u=r(e,t,i),c=o(e,t,i),l=n(e,t,u);return e.set(s,a(u,l,c)),c};var c=this.object.object._compile(e,t);if(this.object.index.isObjectProperty()){var l=this.object.index.getObjectProperty();return function(e,t,r){var i=c(e,t,r),s=Be(i,l),u=n(e,t,s),f=o(e,t,r);return qe(i,l,a(s,u,f)),f}}var f=this.object.index._compile(e,t);return function(e,t,r){var s=c(e,t,r),u=f(e,t,s),l=i(s,u),p=n(e,t,l),m=o(e,t,r);return a(s,u,a(l,p,m)),m}}if(!H(this.object))throw new TypeError("SymbolNode expected as object");return function(e,t,r){var n=o(e,t,r);return e.set(s,n),n}},o.prototype.forEach=function(e){e(this.object,"object",this),this.index&&e(this.index,"index",this),e(this.value,"value",this)},o.prototype.map=function(e){return new o(this._ifNode(e(this.object,"object",this)),this.index?this._ifNode(e(this.index,"index",this)):null,this._ifNode(e(this.value,"value",this)))},o.prototype.clone=function(){return new o(this.object,this.index,this.value)},o.prototype._toString=function(e){var t=this.object.toString(e),r=this.index?this.index.toString(e):"",n=this.value.toString(e);return s(this,e&&e.parenthesis)&&(n="("+n+")"),t+r+" = "+n},o.prototype.toJSON=function(){return{mathjs:"AssignmentNode",object:this.object,index:this.index,value:this.value}},o.fromJSON=function(e){return new o(e.object,e.index,e.value)},o.prototype.toHTML=function(e){var t=this.object.toHTML(e),r=this.index?this.index.toHTML(e):"",n=this.value.toHTML(e);return s(this,e&&e.parenthesis)&&(n='('+n+')'),t+r+'='+n},o.prototype._toTex=function(e){var t=this.object.toTex(e),r=this.index?this.index.toTex(e):"",n=this.value.toTex(e);return s(this,e&&e.parenthesis)&&(n="\\left(".concat(n,"\\right)")),t+r+":="+n},o}),{isClass:!0,isNode:!0}),Lt=Oe("IndexNode",["Range","Node","size"],(e=>{var{Range:t,Node:r,size:n}=e;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(this.dimensions=e,this.dotNotation=t||!1,!Array.isArray(e)||!e.every(U))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}function a(e,r,n){return new t(u(e)?e.toNumber():e,u(r)?r.toNumber():r,u(n)?n.toNumber():n)}return i.prototype=new r,i.prototype.type="IndexNode",i.prototype.isIndexNode=!0,i.prototype._compile=function(e,t){var r=st(this.dimensions,(function(r,i){if(L(r)){if(r.needsEnd()){var o=Object.create(t);o.end=!0;var s=r.start._compile(e,o),u=r.end._compile(e,o),c=r.step?r.step._compile(e,o):function(){return 1};return function(e,t,r){var o=n(r).valueOf(),l=Object.create(t);return l.end=o[i],a(s(e,l,r),u(e,l,r),c(e,l,r))}}var l=r.start._compile(e,t),f=r.end._compile(e,t),p=r.step?r.step._compile(e,t):function(){return 1};return function(e,t,r){return a(l(e,t,r),f(e,t,r),p(e,t,r))}}if(H(r)&&"end"===r.name){var m=Object.create(t);m.end=!0;var h=r._compile(e,m);return function(e,t,r){var a=n(r).valueOf(),o=Object.create(t);return o.end=a[i],h(e,o,r)}}var d=r._compile(e,t);return function(e,t,r){return d(e,t,r)}})),i=Be(e,"index");return function(e,t,n){var a=st(r,(function(r){return r(e,t,n)}));return i(...a)}},i.prototype.forEach=function(e){for(var t=0;t.'+be(this.getObjectProperty())+"":'['+t.join(',')+']'},i.prototype._toTex=function(e){var t=this.dimensions.map((function(t){return t.toTex(e)}));return this.dotNotation?"."+this.getObjectProperty():"_{"+t.join(",")+"}"},i}),{isClass:!0,isNode:!0}),Ht=Oe("SymbolNode",["math","?Unit","Node"],(e=>{var{math:t,Unit:r,Node:n}=e;function i(e){return!!r&&r.isValuelessUnit(e)}function a(e){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');this.name=e}return a.prototype=new n,a.prototype.type="SymbolNode",a.prototype.isSymbolNode=!0,a.prototype._compile=function(e,t){var n=this.name;if(!0===t[n])return function(e,t,r){return t[n]};if(n in e)return function(t,r,i){return t.has(n)?t.get(n):Be(e,n)};var o=i(n);return function(e,t,i){return e.has(n)?e.get(n):o?new r(null,n):a.onUndefinedSymbol(n)}},a.prototype.forEach=function(e){},a.prototype.map=function(e){return this.clone()},a.onUndefinedSymbol=function(e){throw new Error("Undefined symbol "+e)},a.prototype.clone=function(){return new a(this.name)},a.prototype._toString=function(e){return this.name},a.prototype.toHTML=function(e){var t=be(this.name);return"true"===t||"false"===t?''+t+"":"i"===t?''+t+"":"Infinity"===t?''+t+"":"NaN"===t?''+t+"":"null"===t?''+t+"":"undefined"===t?''+t+"":''+t+""},a.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},a.fromJSON=function(e){return new a(e.name)},a.prototype._toTex=function(e){var r=!1;void 0===t[this.name]&&i(this.name)&&(r=!0);var n=Et(this.name,r);return"\\"===n[0]?n:" "+n},a}),{isClass:!0,isNode:!0});function $t(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{var{math:t,Node:r,SymbolNode:n}=e;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if("string"==typeof e&&(e=new n(e)),!U(e))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(t)||!t.every(U))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=e,this.args=t||[],Object.defineProperty(this,"name",{get:function(){return this.fn.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}i.prototype=new r,i.prototype.type="FunctionNode",i.prototype.isFunctionNode=!0,i.prototype._compile=function(e,t){if(!(this instanceof i))throw new TypeError("No valid FunctionNode");var r=this.args.map((r=>r._compile(e,t)));if(!H(this.fn)){if(_(this.fn)&&R(this.fn.index)&&this.fn.index.isObjectProperty()){var n=this.fn.object._compile(e,t),a=this.fn.index.getObjectProperty(),o=this.args;return function(t,i,s){var u=n(t,i,s);if(function(e,t){if(!ke(e,t))throw new Error('No access to method "'+t+'"')}(u,a),u[a]&&u[a].rawArgs)return u[a](o,e,$t(t,i),t);var c=r.map((e=>e(t,i,s)));return u[a].apply(u,c)}}var s=this.fn._compile(e,t),u=this.args;return function(t,n,i){var a=s(t,n,i);if(a&&a.rawArgs)return a(u,e,$t(t,n),t);var o=r.map((e=>e(t,n,i)));return a.apply(a,o)}}var c=this.fn.name,l=c in e?Be(e,c):void 0,f="function"==typeof l&&!0===l.rawArgs,p=t=>t.has(c)?t.get(c):c in e?Be(e,c):i.onUndefinedFunction(c);if(f){var m=this.args;return function(t,r,n){return p(t)(m,e,$t(t,r),t)}}switch(r.length){case 0:return function(e,t,r){return p(e)()};case 1:return function(e,t,n){return p(e)((0,r[0])(e,t,n))};case 2:return function(e,t,n){var i=p(e),a=r[0],o=r[1];return i(a(e,t,n),o(e,t,n))};default:return function(e,t,n){return p(e)(...r.map((r=>r(e,t,n))))}}},i.prototype.forEach=function(e){e(this.fn,"fn",this);for(var t=0;t'+be(this.fn)+'('+t.join(',')+')'};var s=i.prototype.toTex;return i.prototype.toTex=function(e){var t;return e&&"object"==typeof e.handler&&Ae(e.handler,this.name)&&(t=e.handler[this.name](this,e)),void 0!==t?t:s.call(this,e)},i.prototype._toTex=function(e){var r,n,i=this.args.map((function(t){return t.toTex(e)}));switch(Nt[this.name]&&(r=Nt[this.name]),!t[this.name]||"function"!=typeof t[this.name].toTex&&"object"!=typeof t[this.name].toTex&&"string"!=typeof t[this.name].toTex||(r=t[this.name].toTex),typeof r){case"function":n=r(this,e);break;case"string":n=o(r,this,e);break;case"object":switch(typeof r[i.length]){case"function":n=r[i.length](this,e);break;case"string":n=o(r[i.length],this,e)}}return void 0!==n?n:o("\\mathrm{${name}}\\left(${args}\\right)",this,e)},i.prototype.getIdentifier=function(){return this.type+":"+this.name},i}),{isClass:!0,isNode:!0});function Vt(e){for(var t=0;t=n.length)throw new Ve(t,n.length);return h(e)?e.create(Jt(e.valueOf(),t,r)):Jt(e,t,r)}function Jt(e,t,r){var n,i,a,o;if(t<=0){if(Array.isArray(e[0])){for(o=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r{var{typed:r,numeric:n,config:i,AccessorNode:a,ArrayNode:o,AssignmentNode:s,BlockNode:u,ConditionalNode:c,ConstantNode:l,FunctionAssignmentNode:f,FunctionNode:p,IndexNode:m,ObjectNode:h,OperatorNode:d,ParenthesisNode:y,RangeNode:g,RelationalNode:v,SymbolNode:x}=e,b=r(Qt,{string:function(e){return G(e,{})},"Array | Matrix":function(e){return w(e,{})},"string, Object":function(e,t){return G(e,void 0!==t.nodes?t.nodes:{})},"Array | Matrix, Object":w});function w(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=void 0!==t.nodes?t.nodes:{};return Wt(e,(function(e){if("string"!=typeof e)throw new TypeError("String expected");return G(e,r)}))}var N=0,M=1,S=2,E=3,A=4,O={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},C={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},T={true:!0,false:!1,null:null,undefined:void 0},B=["NaN","Infinity"];function q(e,t){return e.expression.substr(e.index,t)}function z(e){return q(e,1)}function I(e){e.index++}function R(e){return e.expression.charAt(e.index-1)}function U(e){return e.expression.charAt(e.index+1)}function F(e){for(e.tokenType=N,e.token="",e.comment="";b.isWhitespace(z(e),e.nestingLevel);)I(e);if("#"===z(e))for(;"\n"!==z(e)&&""!==z(e);)e.comment+=z(e),I(e);if(""!==z(e)){if("\n"===z(e)&&!e.nestingLevel)return e.tokenType=M,e.token=z(e),void I(e);var t=z(e),r=q(e,2),n=q(e,3);if(3===n.length&&O[n])return e.tokenType=M,e.token=n,I(e),I(e),void I(e);if(2===r.length&&O[r])return e.tokenType=M,e.token=r,I(e),void I(e);if(O[t])return e.tokenType=M,e.token=t,void I(e);if(b.isDigitDot(t)){e.tokenType=S;var i=q(e,2);if("0b"===i||"0o"===i||"0x"===i){for(e.token+=z(e),I(e),e.token+=z(e),I(e);b.isHexDigit(z(e));)e.token+=z(e),I(e);if("."===z(e))for(e.token+=".",I(e);b.isHexDigit(z(e));)e.token+=z(e),I(e);else if("i"===z(e))for(e.token+="i",I(e);b.isDigit(z(e));)e.token+=z(e),I(e);return}if("."===z(e)){if(e.token+=z(e),I(e),!b.isDigit(z(e)))return void(e.tokenType=M)}else{for(;b.isDigit(z(e));)e.token+=z(e),I(e);b.isDecimalMark(z(e),U(e))&&(e.token+=z(e),I(e))}for(;b.isDigit(z(e));)e.token+=z(e),I(e);if("E"===z(e)||"e"===z(e))if(b.isDigit(U(e))||"-"===U(e)||"+"===U(e)){if(e.token+=z(e),I(e),"+"!==z(e)&&"-"!==z(e)||(e.token+=z(e),I(e)),!b.isDigit(z(e)))throw me(e,'Digit expected, got "'+z(e)+'"');for(;b.isDigit(z(e));)e.token+=z(e),I(e);if(b.isDecimalMark(z(e),U(e)))throw me(e,'Digit expected, got "'+z(e)+'"')}else if("."===U(e))throw I(e),me(e,'Digit expected, got "'+z(e)+'"')}else{if(!b.isAlpha(z(e),R(e),U(e))){for(e.tokenType=A;""!==z(e);)e.token+=z(e),I(e);throw me(e,'Syntax error in part "'+e.token+'"')}for(;b.isAlpha(z(e),R(e),U(e))||b.isDigit(z(e));)e.token+=z(e),I(e);Ae(C,e.token)?e.tokenType=M:e.tokenType=E}}else e.tokenType=M}function j(e){do{F(e)}while("\n"===e.token)}function L(e){e.nestingLevel++}function $(e){e.nestingLevel--}function G(e,r){var n={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:N,nestingLevel:0,conditionalLevel:null};t(n,{expression:e,extraNodes:r}),F(n);var i=function(e){var t,r,n=[];""!==e.token&&"\n"!==e.token&&";"!==e.token&&((t=V(e)).comment=e.comment);for(;"\n"===e.token||";"===e.token;)0===n.length&&t&&(r=";"!==e.token,n.push({node:t,visible:r})),F(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&((t=V(e)).comment=e.comment,r=";"!==e.token,n.push({node:t,visible:r}));return n.length>0?new u(n):(t||((t=new l(void 0)).comment=e.comment),t)}(n);if(""!==n.token)throw n.tokenType===M?he(n,"Unexpected operator "+n.token):me(n,'Unexpected part "'+n.token+'"');return i}function V(e){var t,r,n,i,a=function(e){var t=function(e){var t=Z(e);for(;"or"===e.token;)j(e),t=new d("or","or",[t,Z(e)]);return t}(e);for(;"?"===e.token;){var r=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,j(e);var n=t,i=V(e);if(":"!==e.token)throw me(e,"False part of conditional expression expected");e.conditionalLevel=null,j(e);var a=V(e);t=new c(n,i,a),e.conditionalLevel=r}return t}(e);if("="===e.token){if(H(a))return t=a.name,j(e),n=V(e),new s(new x(t),n);if(_(a))return j(e),n=V(e),new s(a.object,a.index,n);if(D(a)&&H(a.fn)&&(i=!0,r=[],t=a.name,a.args.forEach((function(e,t){H(e)?r[t]=e.name:i=!1})),i))return j(e),n=V(e),new f(t,r,n);throw me(e,"Invalid left hand side of assignment operator =")}return a}function Z(e){for(var t=W(e);"xor"===e.token;)j(e),t=new d("xor","xor",[t,W(e)]);return t}function W(e){for(var t=Y(e);"and"===e.token;)j(e),t=new d("and","and",[t,Y(e)]);return t}function Y(e){for(var t=J(e);"|"===e.token;)j(e),t=new d("|","bitOr",[t,J(e)]);return t}function J(e){for(var t=X(e);"^|"===e.token;)j(e),t=new d("^|","bitXor",[t,X(e)]);return t}function X(e){for(var t=Q(e);"&"===e.token;)j(e),t=new d("&","bitAnd",[t,Q(e)]);return t}function Q(e){for(var t=[K(e)],r=[],n={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};Ae(n,e.token);){var i={name:e.token,fn:n[e.token]};r.push(i),j(e),t.push(K(e))}return 1===t.length?t[0]:2===t.length?new d(r[0].name,r[0].fn,t):new v(r.map((e=>e.fn)),t)}function K(e){var t,r,n,i;t=ee(e);for(var a={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Ae(a,e.token);)n=a[r=e.token],j(e),i=[t,ee(e)],t=new d(r,n,i);return t}function ee(e){var t,r,n,i;t=te(e);for(var a={to:"to",in:"to"};Ae(a,e.token);)n=a[r=e.token],j(e),"in"===r&&""===e.token?t=new d("*","multiply",[t,new x("in")],!0):(i=[t,te(e)],t=new d(r,n,i));return t}function te(e){var t,r=[];if(t=":"===e.token?new l(1):re(e),":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(r.push(t);":"===e.token&&r.length<3;)j(e),")"===e.token||"]"===e.token||","===e.token||""===e.token?r.push(new x("end")):r.push(re(e));t=3===r.length?new g(r[0],r[2],r[1]):new g(r[0],r[1])}return t}function re(e){var t,r,n,i;t=ne(e);for(var a={"+":"add","-":"subtract"};Ae(a,e.token);){n=a[r=e.token],j(e);var o=ne(e);i=o.isPercentage?[t,new d("*","multiply",[t,o])]:[t,o],t=new d(r,n,i)}return t}function ne(e){var t,r,n,i;r=t=ie(e);for(var a={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};Ae(a,e.token);)i=a[n=e.token],j(e),r=ie(e),t=new d(n,i,[t,r]);return t}function ie(e){var t,r;for(r=t=ae(e);e.tokenType===E||"in"===e.token&&k(t)||!(e.tokenType!==S||k(r)||P(r)&&"!"!==r.op)||"("===e.token;)r=ae(e),t=new d("*","multiply",[t,r],!0);return t}function ae(e){for(var r=oe(e),n=r,i=[];"/"===e.token&&k(n);){if(i.push(t({},e)),j(e),e.tokenType!==S){t(e,i.pop());break}if(i.push(t({},e)),j(e),e.tokenType!==E&&"("!==e.token){i.pop(),t(e,i.pop());break}t(e,i.pop()),i.pop(),n=oe(e),r=new d("/","divide",[r,n])}return r}function oe(e){var t,r,n,i;t=se(e);for(var a={"%":"mod",mod:"mod"};Ae(a,e.token);)n=a[r=e.token],j(e),"%"===r&&e.tokenType===M&&"("!==e.token?t=new d("/","divide",[t,new l(100)],!1,!0):(i=[t,se(e)],t=new d(r,n,i));return t}function se(e){var t,r,a,s={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Ae(s,e.token)?(a=s[e.token],t=e.token,j(e),r=[se(e)],new d(t,a,r)):function(e){var t,r,a,s;t=function(e){var t,r,a;t=function(e){var t=[];if(e.tokenType===E&&Ae(e.extraNodes,e.token)){var r=e.extraNodes[e.token];if(F(e),"("===e.token){if(t=[],L(e),F(e),")"!==e.token)for(t.push(V(e));","===e.token;)F(e),t.push(V(e));if(")"!==e.token)throw me(e,"Parenthesis ) expected");$(e),F(e)}return new r(t)}return function(e){var t;if(e.tokenType===E||e.tokenType===M&&e.token in C)return t=e.token,F(e),ue(e,Ae(T,t)?new l(T[t]):-1!==B.indexOf(t)?new l(n(t,"number")):new x(t));return function(e){var t;if('"'===e.token)return t=ce(e),ue(e,new l(t));return function(e){var t;if("'"===e.token)return t=le(e),ue(e,new l(t));return function(e){var t,r,a,s;if("["===e.token){if(L(e),F(e),"]"!==e.token){var u=fe(e);if(";"===e.token){for(a=1,r=[u];";"===e.token;)F(e),r[a]=fe(e),a++;if("]"!==e.token)throw me(e,"End of matrix ] expected");$(e),F(e),s=r[0].items.length;for(var c=1;c0},b.isDecimalMark=function(e,t){return"."===e&&"/"!==t&&"*"!==t&&"^"!==t},b.isDigitDot=function(e){return e>="0"&&e<="9"||"."===e},b.isDigit=function(e){return e>="0"&&e<="9"},b.isHexDigit=function(e){return e>="0"&&e<="9"||e>="a"&&e<="f"||e>="A"&&e<="F"},b})),er="compile",tr=Oe(er,["typed","parse"],(e=>{var{typed:t,parse:r}=e;return t(er,{string:function(e){return r(e).compile()},"Array | Matrix":function(e){return Wt(e,(function(e){return r(e).compile()}))}})})),rr="evaluate",nr=Oe(rr,["typed","parse"],(e=>{var{typed:t,parse:r}=e;return t(rr,{string:function(e){var t=Fe();return r(e).compile().evaluate(t)},"string, Map | Object":function(e,t){return r(e).compile().evaluate(t)},"Array | Matrix":function(e){var t=Fe();return Wt(e,(function(e){return r(e).compile().evaluate(t)}))},"Array | Matrix, Map | Object":function(e,t){return Wt(e,(function(e){return r(e).compile().evaluate(t)}))}})})),ir=Oe("Help",["parse"],(e=>{var{parse:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw new Error('Argument "doc" missing');this.doc=e}return r.prototype.type="Help",r.prototype.isHelp=!0,r.prototype.toString=function(){var e=this.doc||{},r="\n";if(e.name&&(r+="Name: "+e.name+"\n\n"),e.category&&(r+="Category: "+e.category+"\n\n"),e.description&&(r+="Description:\n "+e.description+"\n\n"),e.syntax&&(r+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){r+="Examples:\n";for(var n={},i=0;i"mathjs"!==e)).forEach((r=>{t[r]=e[r]})),new r(t)},r.prototype.valueOf=r.prototype.toString,r}),{isClass:!0}),ar=Oe("Parser",["evaluate"],(e=>{var{evaluate:t}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:Fe(),writable:!1})}return r.prototype.type="Parser",r.prototype.isParser=!0,r.prototype.evaluate=function(e){return t(e,this.scope)},r.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},r.prototype.getAll=function(){return function(e){if(e instanceof Ue)return e.wrappedObject;var t={};for(var r of e.keys())qe(t,r,e.get(r));return t}(this.scope)},r.prototype.getAllAsMap=function(){return this.scope},r.prototype.set=function(e,t){return this.scope.set(e,t),t},r.prototype.remove=function(e){this.scope.delete(e)},r.prototype.clear=function(){this.scope.clear()},r}),{isClass:!0}),or="parser",sr=Oe(or,["typed","Parser"],(e=>{var{typed:t,Parser:r}=e;return t(or,{"":function(){return new r}})})),ur=Oe("simplifyUtil",["FunctionNode","OperatorNode","SymbolNode"],(e=>{var{FunctionNode:t,OperatorNode:r,SymbolNode:n}=e,i={add:!0,multiply:!0},a={add:!0,multiply:!0};function o(e,t){if(!P(e))return!1;var r=e.fn.toString();return t&&Ae(t,r)&&Ae(t[r],"associative")?t[r].associative:a[r]||!1}function s(e){var t,r=[];return o(e)?(t=e.op,function e(n){for(var i=0;i2&&o(t)){for(var a=t.args.pop();t.args.length>0;)a=r([t.args.pop(),a]);t.args=a.args}}},unflattenl:function e(t){if(t.args&&0!==t.args.length){for(var r=u(t),n=t.args.length,i=0;i2&&o(t)){for(var a=t.args.shift();t.args.length>0;)a=r([a,t.args.shift()]);t.args=a.args}}}}})),cr=Oe("simplifyCore",["equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode"],(e=>{var{equal:t,isZero:r,add:n,subtract:i,multiply:a,divide:o,pow:s,AccessorNode:u,ArrayNode:c,ConstantNode:l,FunctionNode:f,IndexNode:p,ObjectNode:m,OperatorNode:h,ParenthesisNode:d}=e,y=new l(0),g=new l(1);function v(e){return e.map(x).map((function(e){return j(e)?e.content:e}))}function x(e){if(P(e)&&e.isUnary()){var b=x(e.args[0]);if("+"===e.op)return b;if("-"===e.op){if(P(b)){if(b.isUnary()&&"-"===b.op)return b.args[0];if(b.isBinary()&&"subtract"===b.fn)return new h("-","subtract",[b.args[1],b.args[0]])}return new h(e.op,e.fn,[b])}}else if(P(e)&&e.isBinary()){var w=x(e.args[0]),N=x(e.args[1]);if("+"===e.op){if(k(w)){if(r(w.value))return N;if(k(N))return new l(n(w.value,N.value))}return k(N)&&r(N.value)?w:P(N)&&N.isUnary()&&"-"===N.op?new h("-","subtract",[w,N.args[0]]):new h(e.op,e.fn,N?[w,N]:[w])}if("-"===e.op){if(k(w)&&N){if(k(N))return new l(i(w.value,N.value));if(r(w.value))return new h("-","unaryMinus",[N])}if("subtract"===e.fn)return k(N)&&r(N.value)?w:P(N)&&N.isUnary()&&"-"===N.op?x(new h("+","add",[w,N.args[0]])):new h(e.op,e.fn,[w,N])}else{if("*"===e.op){if(k(w)){if(r(w.value))return y;if(t(w.value,1))return N;if(k(N))return new l(a(w.value,N.value))}if(k(N)){if(r(N.value))return y;if(t(N.value,1))return w;if(P(w)&&w.isBinary()&&w.op===e.op){var M=w.args[0];if(k(M)){var S=new l(a(M.value,N.value));return new h(e.op,e.fn,[S,w.args[1]],e.implicit)}}return new h(e.op,e.fn,[N,w],e.implicit)}return new h(e.op,e.fn,[w,N],e.implicit)}if("/"===e.op){if(k(w)){if(r(w.value))return y;if(k(N)&&(t(N.value,1)||t(N.value,2)||t(N.value,4)))return new l(o(w.value,N.value))}return new h(e.op,e.fn,[w,N])}if("^"===e.op){if(k(N)){if(r(N.value))return g;if(t(N.value,1))return w;if(k(w))return new l(s(w.value,N.value));if(P(w)&&w.isBinary()&&"^"===w.op){var E=w.args[1];if(k(E))return new h(e.op,e.fn,[w.args[0],new l(a(E.value,N.value))])}}return new h(e.op,e.fn,[w,N])}}}else{if(j(e)){var A=x(e.content);return j(A)||H(A)||k(A)?A:new d(A)}if(D(e))return new f(x(e.fn),v(e.args));if(T(e))return new c(v(e.items));if(_(e)){var O=v(e.object);return j(O)&&(O=O.content),new u(O,x(e.index))}if(R(e))return new p(v(e.dimensions));if(F(e)){var C={};for(var B in e.properties)C[B]=x(e.properties[B]);return new m(C)}}return e}return x}));function lr(){throw new Error('No "bignumber" implementation available')}function fr(){throw new Error('No "fraction" implementation available')}function pr(){throw new Error('No "matrix" implementation available')}var mr=["typed","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],hr=Oe("simplifyConstant",mr,(e=>{var{typed:t,config:r,mathWithTransform:n,matrix:i,fraction:a,bignumber:o,AccessorNode:s,ArrayNode:u,ConstantNode:c,FunctionNode:f,IndexNode:p,ObjectNode:m,OperatorNode:d,SymbolNode:y}=e,{isCommutative:g,isAssociative:v,allChildren:x,createMakeNodeFunction:b}=ur({FunctionNode:f,OperatorNode:d,SymbolNode:y});function w(e,t){return E(B(e,t))}function N(e){return l(e)?e.valueOf():e instanceof Array?e.map(N):h(e)?i(N(e.valueOf())):e}function M(e,t,r){try{return n[e].apply(null,t)}catch(i){return t=t.map(N),O(n[e].apply(null,t),r)}}var S=t({Fraction:function(e){var t,r=e.s*e.n;t=r<0?new d("-","unaryMinus",[new c(-r)]):new c(r);if(1===e.d)return t;return new d("/","divide",[t,new c(e.d)])},number:function(e){return e<0?C(new c(-e)):new c(e)},BigNumber:function(e){return e<0?C(new c(-e)):new c(e)},Complex:function(e){throw new Error("Cannot convert Complex number to Node")},string:function(e){return new c(e)},Matrix:function(e){return new u(e.valueOf().map((e=>S(e))))}});function E(e){return U(e)?e:S(e)}function A(e,t){if(t&&!1!==t.exactFractions&&isFinite(e)&&a){var r=a(e),n=t&&"number"==typeof t.fractionsLimit?t.fractionsLimit:1/0;if(r.valueOf()===e&&r.nB(e,t)));if(!r.some(U))try{return M(e.name,r,t)}catch(e){}if("size"===e.name&&1===r.length&&T(r[0])){for(var a=[],o=r[0];T(o);)a.push(o.items.length),o=o.items[0];return i(a)}return new f(e.name,r.map(E))}case"OperatorNode":var l,d,y=e.fn.toString(),N=b(e);if(P(e)&&e.isUnary())d=U((l=[B(e.args[0],t)])[0])?N(l):M(y,l,t);else if(v(e))if(l=(l=x(e)).map((e=>B(e,t))),g(y)){for(var S=[],A=[],C=0;C1?(d=_(y,S,N,t),A.unshift(d),d=_(y,A,N,t)):d=_(y,l,N,t)}else d=_(y,l,N,t);else l=e.args.map((e=>B(e,t))),d=_(y,l,N,t);return d;case"ParenthesisNode":return B(e.content,t);case"AccessorNode":return function(e,t,r){if(!R(t))return new s(E(e),E(t));if(T(e)||h(e)){for(var n=Array.from(t.dimensions);n.length>0;)if(k(n[0])&&"string"!=typeof n[0].value){var a=O(n.shift().value,r);T(e)?e=e.items[a-1]:(e=e.valueOf()[a-1])instanceof Array&&(e=i(e))}else{if(!(n.length>1&&k(n[1])&&"string"!=typeof n[1].value))break;var o=O(n[1].value,r),l=[],f=T(e)?e.items:e.valueOf();for(var m of f)if(T(m))l.push(m.items[o-1]);else{if(!h(e))break;l.push(m[o-1])}if(l.length!==f.length)break;e=T(e)?new u(l):i(l),n.splice(1,1)}return n.length===t.dimensions.length?new s(E(e),t):n.length>0?(t=new p(n),new s(E(e),t)):e}if(F(e)&&1===t.dimensions.length&&k(t.dimensions[0])){var d=t.dimensions[0].value;return d in e.properties?e.properties[d]:new c}return new s(E(e),t)}(B(e.object,t),B(e.index,t),t);case"ArrayNode":var q=e.items.map((e=>B(e,t)));return q.some(U)?new u(q.map(E)):i(q);case"IndexNode":return new p(e.dimensions.map((e=>w(e,t))));case"ObjectNode":var z={};for(var I in e.properties)z[I]=w(e.properties[I],t);return new m(z);default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(e.type))}}return w})),dr=["parse","FunctionNode","OperatorNode","ParenthesisNode"],yr=Oe("resolve",dr,(e=>{var{parse:t,FunctionNode:r,OperatorNode:n,ParenthesisNode:i}=e;return function e(a,o){if(!o)return a;if(je(o)||(o=Pe(o)),H(a)){var s=o.get(a.name);if(U(s))return e(s,o);if("number"==typeof s)return t(String(s))}else{if(P(a)){var u=a.args.map((function(t){return e(t,o)}));return new n(a.op,a.fn,u,a.implicit)}if(j(a))return new i(e(a.content,o));if(D(a)){var c=a.args.map((function(t){return e(t,o)}));return new r(a.name,c)}}return a}})),gr=["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","?fraction","?bignumber","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],vr=Oe("simplify",gr,(e=>{var{config:t,typed:r,parse:n,add:i,subtract:a,multiply:o,divide:s,pow:u,isZero:c,equal:l,fraction:f,bignumber:p,mathWithTransform:m,matrix:h,AccessorNode:d,ArrayNode:y,ConstantNode:g,FunctionNode:v,IndexNode:x,ObjectNode:b,OperatorNode:w,ParenthesisNode:N,SymbolNode:M}=e,S=hr({typed:r,config:t,mathWithTransform:m,matrix:h,fraction:f,bignumber:p,AccessorNode:d,ArrayNode:y,ConstantNode:g,FunctionNode:v,IndexNode:x,ObjectNode:b,OperatorNode:w,SymbolNode:M}),E=cr({equal:l,isZero:c,add:i,subtract:a,multiply:o,divide:s,pow:u,AccessorNode:d,ArrayNode:y,ConstantNode:g,FunctionNode:v,IndexNode:x,ObjectNode:b,OperatorNode:w,ParenthesisNode:N}),A=yr({parse:n,FunctionNode:v,OperatorNode:w,ParenthesisNode:N}),{isCommutative:O,isAssociative:C,flatten:_,unflattenr:T,unflattenl:B,createMakeNodeFunction:q}=ur({FunctionNode:v,OperatorNode:w,SymbolNode:M}),z=r("simplify",{string:function(e){return this(n(e),this.rules,Fe(),{})},"string, Map | Object":function(e,t){return this(n(e),this.rules,t,{})},"string, Map | Object, Object":function(e,t,r){return this(n(e),this.rules,t,r)},"string, Array":function(e,t){return this(n(e),t,Fe(),{})},"string, Array, Map | Object":function(e,t,r){return this(n(e),t,r,{})},"string, Array, Map | Object, Object":function(e,t,r,i){return this(n(e),t,r,i)},"Node, Map | Object":function(e,t){return this(e,this.rules,t,{})},"Node, Map | Object, Object":function(e,t,r){return this(e,this.rules,t,r)},Node:function(e){return this(e,this.rules,Fe(),{})},"Node, Array":function(e,t){return this(e,t,Fe(),{})},"Node, Array, Map | Object":function(e,t,r){return this(e,t,r,{})},"Node, Array, Object, Object":function(e,t,r,n){return this(e,t,Pe(r),n)},"Node, Array, Map, Object":function(e,t,r,i){var a=i.consoleDebug;t=function(e){for(var t=[],r=0;r");if(2!==s.length)throw SyntaxError("Could not parse rule: "+i);i={l:s[0],r:s[1]};case"object":if(a={l:I(n(i.l)),r:I(n(i.r))},i.context&&(a.context=i.context),i.evaluate&&(a.evaluate=n(i.evaluate)),C(a.l)){var u=q(a.l),c=U();a.expanded={},a.expanded.l=u([a.l.clone(),c]),_(a.expanded.l),T(a.expanded.l),a.expanded.r=u([a.r,c])}break;case"function":a=i;break;default:throw TypeError("Unsupported type of rule: "+o)}t.push(a)}return t}(t);for(var o=A(e,r),s={},u=(o=I(o)).toString({parenthesis:"all"});!s[u];){s[u]=!0,R=0;var c=u;a&&console.log("Working on: ",u);for(var l=0;l ").concat(t[l].r.toString()))),a){var p=o.toString({parenthesis:"all"});p!==c&&(console.log("Applying",f,"produced",p),c=p)}B(o)}u=o.toString({parenthesis:"all"})}return o}});function I(e){return e.transform((function(e,t,r){return j(e)?I(e.content):e}))}z.simplifyCore=E,z.resolve=A;var D={true:!0,false:!0,e:!0,i:!0,Infinity:!0,LN2:!0,LN10:!0,LOG2E:!0,LOG10E:!0,NaN:!0,phi:!0,pi:!0,SQRT1_2:!0,SQRT2:!0,tau:!0};z.rules=[E,{l:"log(e)",r:"1"},{l:"n-n1",r:"n+-n1"},{l:"-(c*v)",r:"v * (-c)"},{l:"-v",r:"v * (-1)"},{l:"n/n1^n2",r:"n*n1^-n2"},{l:"n/n1",r:"n*n1^-1"},S,{l:"(n ^ n1) ^ n2",r:"n ^ (n1 * n2)"},{l:"n*n",r:"n^2"},{l:"n * n^n1",r:"n^(n1+1)"},{l:"n^n1 * n^n2",r:"n^(n1+n2)"},{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},{l:"v*n + v",r:"v*(n+1)"},{l:"n3*n1 + n3*n2",r:"n3*(n1+n2)"},{l:"n*c + c",r:"(n+1)*c"},{l:"n1 + (n2 + n3)*(-1)",r:"n1 + n2*(-1) + n3*(-1)"},{l:"(-n)*n1",r:"-(n*n1)"},{l:"c+v",r:"v+c",context:{add:{commutative:!1}}},{l:"v*c",r:"c*v",context:{multiply:{commutative:!1}}},{l:"n+-n1",r:"n-n1"},{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:"n-(n1+n2)",r:"n-n1-n2"},{l:"1*n",r:"n"},{l:"n1/(n2/n3)",r:"(n1*n3)/n2"},{l:"n1/(-n2)",r:"-n1/n2"}];var R=0;function U(){return new M("_p"+R++)}function F(e,t){if(e)for(var r=0;r=2&&2===e.args.length){for(var i=function(e,t){var r,n,i=[],a=q(e);if(O(e,t))for(var o=0;o2)throw Error("Unexpected non-binary associative function: "+e.toString());return[]}for(var u=[],c=0;c{var{typed:t,config:r,parse:n,simplify:i,equal:a,isZero:o,numeric:s,ConstantNode:u,FunctionNode:c,OperatorNode:l,ParenthesisNode:f,SymbolNode:p}=e,m=t("derivative",{"Node, SymbolNode, Object":function(e,t,r){var n={};d(n,e,t.name);var a=y(e,n);return r.simplify?i(a):a},"Node, SymbolNode":function(e,t){return this(e,t,{simplify:!0})},"string, SymbolNode":function(e,t){return this(n(e),t)},"string, SymbolNode, Object":function(e,t,r){return this(n(e),t,r)},"string, string":function(e,t){return this(n(e),n(t))},"string, string, Object":function(e,t,r){return this(n(e),n(t),r)},"Node, string":function(e,t){return this(e,n(t))},"Node, string, Object":function(e,t,r){return this(e,n(t),r)}});m._simplify=!0,m.toTex=function(e){return h.apply(null,e.args)};var h=t("_derivTex",{"Node, SymbolNode":function(e,t){return k(e)&&"string"===G(e.value)?h(n(e.value).toString(),t.toString(),1):h(e.toString(),t.toString(),1)},"Node, ConstantNode":function(e,t){if("string"===G(t.value))return h(e,n(t.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(e,t,r){return h(e.toString(),t.name,r.value)},"string, string, number":function(e,t,r){return(1===r?"{d\\over d"+t+"}":"{d^{"+r+"}\\over d"+t+"^{"+r+"}}")+"\\left[".concat(e,"\\right]")}}),d=t("constTag",{"Object, ConstantNode, string":function(e,t){return e[t]=!0,!0},"Object, SymbolNode, string":function(e,t,r){return t.name!==r&&(e[t]=!0,!0)},"Object, ParenthesisNode, string":function(e,t,r){return d(e,t.content,r)},"Object, FunctionAssignmentNode, string":function(e,t,r){return-1===t.params.indexOf(r)?(e[t]=!0,!0):d(e,t.expr,r)},"Object, FunctionNode | OperatorNode, string":function(e,t,r){if(t.args.length>0){for(var n=d(e,t.args[0],r),i=1;i0){var n=e.args.filter((function(e){return void 0===t[e]})),i=1===n.length?n[0]:new l("*","multiply",n),s=r.concat(y(i,t));return new l("*","multiply",s)}return new l("+","add",e.args.map((function(r){return new l("*","multiply",e.args.map((function(e){return e===r?y(e,t):e.clone()})))})))}if("/"===e.op&&e.isBinary()){var u=e.args[0],f=e.args[1];return void 0!==t[f]?new l("/","divide",[y(u,t),f]):void 0!==t[u]?new l("*","multiply",[new l("-","unaryMinus",[u]),new l("/","divide",[y(f,t),new l("^","pow",[f.clone(),g(2)])])]):new l("/","divide",[new l("-","subtract",[new l("*","multiply",[y(u,t),f.clone()]),new l("*","multiply",[u.clone(),y(f,t)])]),new l("^","pow",[f.clone(),g(2)])])}if("^"===e.op&&e.isBinary()){var p=e.args[0],m=e.args[1];if(void 0!==t[p])return k(p)&&(o(p.value)||a(p.value,1))?g(0):new l("*","multiply",[e,new l("*","multiply",[new c("log",[p.clone()]),y(m.clone(),t)])]);if(void 0!==t[m]){if(k(m)){if(o(m.value))return g(0);if(a(m.value,1))return y(p,t)}var h=new l("^","pow",[p.clone(),new l("-","subtract",[m,g(1)])]);return new l("*","multiply",[m.clone(),new l("*","multiply",[y(p,t),h])])}return new l("*","multiply",[new l("^","pow",[p.clone(),m.clone()]),new l("+","add",[new l("*","multiply",[y(p,t),new l("/","divide",[m.clone(),p.clone()])]),new l("*","multiply",[y(m,t),new c("log",[p.clone()])])])])}throw new Error('Operator "'+e.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function g(e,t){return new u(s(e,t||r.number))}return m})),wr={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"]},Nr={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"]},Mr={bignumber:{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"]},boolean:{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"]},complex:{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"]},createUnit:{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"]},fraction:{name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(num,den)"],description:"Create a fraction from a number or from a numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},index:{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[0:2, 0:2] = ones(2, 2)"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]},matrix:{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"]},number:{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"]},sparse:{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"]},splitUnit:{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"]},string:{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"]},unit:{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"]},e:Nr,E:Nr,false:{name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},i:{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:[]},Infinity:{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:[]},LN2:{name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},LN10:{name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},LOG2E:{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:[]},LOG10E:{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:[]},NaN:{name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},null:{name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},pi:wr,PI:wr,phi:{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:[]},SQRT1_2:{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:[]},SQRT2:{name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},tau:{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"]},true:{name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},version:{name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},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:{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"]},lsolve:{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"]},lsolveAll:{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"]},lup:{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"]},lusolve:{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"]},simplify:{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:["derivative","parse","evaluate"]},rationalize:{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"]},slu:{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"]},usolve:{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"]},usolveAll:{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"]},qr:{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"]},abs:{name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},add:{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"]},cbrt:{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"]},ceil:{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"]},cube:{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"]},divide:{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"]},dotDivide:{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"]},dotMultiply:{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"]},dotPow:{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"]},exp:{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"]},expm:{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"]},expm1:{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"]},fix:{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"]},floor:{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"]},gcd:{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"]},hypot:{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"]},lcm:{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"]},log:{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"]},log2:{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"]},log1p:{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"]},log10:{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"]},mod:{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"]},multiply:{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"]},norm:{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")']},nthRoot:{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"]},nthRoots:{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"]},pow:{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)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},round:{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"]},sign:{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"]},sqrt:{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"]},sqrtm:{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([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},square:{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"]},subtract:{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"]},unaryMinus:{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"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{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"]},invmod:{name:"invmod",category:"Arithmetic",syntax:["invmod(a, b)"],description:"Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)",examples:["invmod(8, 12)=NaN","invmod(7, 13)=2","math.invmod(15151, 15122)=10429"],seealso:["gcd","xgcd"]},bitAnd:{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"]},bitNot:{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"]},bitOr:{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"]},bitXor:{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"]},leftShift:{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"]},rightArithShift:{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"]},rightLogShift:{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"]},bellNumbers:{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"]},catalan:{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"]},composition:{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"]},stirlingS2:{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"]},config:{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:[]},import:{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:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number, number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},arg:{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"]},conj:{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"]},re:{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"]},im:{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"]},evaluate:{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:[]},help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},distance:{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:[]},intersect:{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:[]},and:{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"]},not:{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"]},or:{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"]},xor:{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"]},concat:{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"]},count:{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"]},cross:{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"]},column:{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"]},ctranspose:{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"]},det:{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"]},diag:{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"]},diff:{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"]},dot:{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"]},getMatrixDataType:{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"]},identity:{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"]},filter:{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"]},flatten:{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"]},forEach:{name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:[],seealso:["map","sort","filter"]},inv:{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"]},eigs:{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"]},kron:{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"]},matrixFromFunction:{name:"matrixFromFunction",category:"Matrix",syntax:["math.matrixFromFunction(size, fn)","math.matrixFromFunction(size, fn, format)","math.matrixFromFunction(size, fn, format, datatype)","math.matrixFromFunction(size, format, fn)","math.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"]},matrixFromRows:{name:"matrixFromRows",category:"Matrix",syntax:["math.matrixFromRows(...arr)","math.matrixFromRows(row1, row2)","math.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"]},matrixFromColumns:{name:"matrixFromColumns",category:"Matrix",syntax:["math.matrixFromColumns(...arr)","math.matrixFromColumns(row1, row2)","math.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"]},map:{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"]},ones:{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"]},partitionSelect:{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"]},range:{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"]},resize:{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"]},reshape:{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])"],seealso:["size","squeeze","resize"]},rotate:{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], math.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"]},rotationMatrix:{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"]},row:{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"]},size:{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"]},sort:{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"])',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},squeeze:{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"]},subset:{name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of a matrix or string. Indexes are one-based. Both the ranges lower-bound and upper-bound are included.",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]"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},trace:{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"]},transpose:{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"]},zeros:{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"]},combinations:{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"]},combinationsWithRep:{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"]},factorial:{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"]},gamma:{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"]},kldivergence:{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:[]},multinomial:{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"]},permutations:{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"]},pickRandom:{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"]},random:{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"]},randomInt:{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"]},compare:{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"]},compareNatural:{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"]},compareText:{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"]},deepEqual:{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"]},equal:{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"]},equalText:{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"]},larger:{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"]},largerEq:{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"]},smaller:{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"]},smallerEq:{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"]},unequal:{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"]},setCartesian:{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"]},setDifference:{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"]},setDistinct:{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"]},setIntersect:{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"]},setIsSubset:{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"]},setMultiplicity:{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"]},setPowerset:{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"]},setSize:{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"]},setSymDifference:{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"]},setUnion:{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"]},erf:{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:[]},mad:{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"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],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"]},mean:{name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],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"]},median:{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"]},min:{name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],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"]},mode:{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"]},prod:{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"]},quantileSeq:{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"]},std:{name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, 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"]},sum:{name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],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"]},variance:{name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, 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"]},acos:{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"]},acosh:{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"]},acot:{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"]},acoth:{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"]},acsc:{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"]},acsch:{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"]},asec:{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"]},asech:{name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},asin:{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"]},asinh:{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"]},atan:{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"]},atanh:{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"]},atan2:{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"]},cos:{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"]},cosh:{name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},cot:{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"]},coth:{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"]},csc:{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"]},csch:{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"]},sec:{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"]},sech:{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"]},sin:{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"]},sinh:{name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},tan:{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"]},tanh:{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"]},to:{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:[]},clone:{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:[]},format:{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"]},bin:{name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},oct:{name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},hex:{name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},isNaN:{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"]},isInteger:{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"]},isNegative:{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"]},isNumeric:{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"]},hasNumericValue:{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"]},isPositive:{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"]},isPrime:{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"]},isZero:{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"]},print:{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"]},typeOf:{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"]},numeric:{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"]}},Sr="help",Er=Oe(Sr,["typed","mathWithTransform","Help"],(e=>{var{typed:t,mathWithTransform:r,Help:n}=e;return t(Sr,{any:function(e){var t,i=e;if("string"!=typeof e)for(t in r)if(Ae(r,t)&&e===r[t]){i=t;break}var a=Be(Mr,i);if(!a){var o="function"==typeof i?i.name:i;throw new Error('No documentation found on "'+o+'"')}return new n(a)}})})),Ar="rationalize",Or=Oe(Ar,["config","typed","equal","isZero","add","subtract","multiply","divide","pow","parse","simplify","?bignumber","?fraction","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode","ParenthesisNode"],(e=>{var{config:t,typed:r,equal:n,isZero:i,add:a,subtract:o,multiply:s,divide:u,pow:c,parse:l,simplify:f,fraction:p,bignumber:m,mathWithTransform:h,matrix:d,AccessorNode:y,ArrayNode:g,ConstantNode:v,FunctionNode:x,IndexNode:b,ObjectNode:w,OperatorNode:N,SymbolNode:M,ParenthesisNode:S}=e,E=hr({typed:r,config:t,mathWithTransform:h,matrix:d,fraction:p,bignumber:m,AccessorNode:y,ArrayNode:g,ConstantNode:v,FunctionNode:x,IndexNode:b,ObjectNode:w,OperatorNode:N,SymbolNode:M}),A=cr({equal:n,isZero:i,add:a,subtract:o,multiply:s,divide:u,pow:c,AccessorNode:y,ArrayNode:g,ConstantNode:v,FunctionNode:x,IndexNode:b,ObjectNode:w,OperatorNode:N,ParenthesisNode:S});return r(Ar,{string:function(e){return this(l(e),{},!1)},"string, boolean":function(e,t){return this(l(e),{},t)},"string, Object":function(e,t){return this(l(e),t,!1)},"string, Object, boolean":function(e,t,r){return this(l(e),t,r)},Node:function(e){return this(e,{},!1)},"Node, boolean":function(e,t){return this(e,{},t)},"Node, Object":function(e,t){return this(e,t,!1)},"Node, Object, boolean":function(e,t,r){var n=function(){var e=[A,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},E,{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"}],t=[{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)"}],r=[{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)"}],n=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],i={};return i.firstRules=e.concat(t,n),i.distrDivRules=r,i.sucDivRules=n,i.firstRulesAgain=e.concat(t),i.finalRules=[A,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},E,{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))"}],i}(),i=function(e,t,r,n){var i=[],a=f(e,n,t,{exactFractions:!1}),o="+-*"+((r=!!r)?"/":"");u(a);var s={};return s.expression=a,s.variables=i,s;function u(e){var t=e.type;if("FunctionNode"===t)throw new Error("There is an unsolved function call");if("OperatorNode"===t)if("^"===e.op){if("ConstantNode"!==e.args[1].type||!V(parseFloat(e.args[1].value)))throw new Error("There is a non-integer exponent");u(e.args[0])}else{if(-1===o.indexOf(e.op))throw new Error("Operator "+e.op+" invalid in polynomial expression");for(var r=0;r=1){var o,s;e=O(e);var u,c=!0,l=!1;for(e=f(e,n.firstRules,{},{exactFractions:!1});s=c?n.distrDivRules:n.sucDivRules,c=!c,(u=(e=f(e,s)).toString())!==o;)l=!0,o=u;l&&(e=f(e,n.firstRulesAgain,{},{exactFractions:!1})),e=f(e,n.finalRules,{},{exactFractions:!1})}var p=[],m={};return"OperatorNode"===e.type&&e.isBinary()&&"/"===e.op?(1===a&&(e.args[0]=C(e.args[0],p),e.args[1]=C(e.args[1])),r&&(m.numerator=e.args[0],m.denominator=e.args[1])):(1===a&&(e=C(e,p)),r&&(m.numerator=e,m.denominator=null)),r?(m.coefficients=p,m.variables=i.variables,m.expression=e,m):e}});function O(e,t,r){var n=e.type,i=arguments.length>1;if("OperatorNode"===n&&e.isBinary()){var a,o=!1;if("^"===e.op&&("ParenthesisNode"!==e.args[0].type&&"OperatorNode"!==e.args[0].type||"ConstantNode"!==e.args[1].type||(o=(a=parseFloat(e.args[1].value))>=2&&V(a))),o){if(a>2){var s=e.args[0],u=new N("^","pow",[e.args[0].cloneDeep(),new v(a-1)]);e=new N("*","multiply",[s,u])}else e=new N("*","multiply",[e.args[0],e.args[0].cloneDeep()]);i&&("content"===r?t.content=e:t.args[r]=e)}}if("ParenthesisNode"===n)O(e.content,e,"content");else if("ConstantNode"!==n&&"SymbolNode"!==n)for(var c=0;cn&&(t[c]=0),t[c]+=o.cte*("+"===o.oper?1:-1),void(n=Math.max(c,n))}o.cte=c,""===o.fire&&(t[0]+=o.cte*("+"===o.oper?1:-1))}}(e,null,r);for(var a,o=!0,s=n=t.length-1;s>=0;s--)if(0!==t[s]){var u=new v(o?t[s]:Math.abs(t[s])),c=t[s]<0?"-":"+";if(s>0){var l=new M(i);if(s>1){var f=new v(s);l=new N("^","pow",[l,f])}u=-1===t[s]&&o?new N("-","unaryMinus",[l]):1===Math.abs(t[s])?l:new N("*","multiply",[u,l])}a=o?u:"+"===c?new N("+","add",[a,u]):new N("-","subtract",[a,u]),o=!1}return o?new v(0):a}}));function Cr(e){var t=0,r=1,n=Object.create(null),i=Object.create(null),a=0,o=function(e){var o=i[e];if(o&&(delete n[o],delete i[e],--t,r===o)){if(!t)return a=0,void(r=1);for(;!hasOwnProperty.call(n,++r););}};return e=Math.abs(e),{hit:function(s){var u=i[s],c=++a;if(n[c]=s,i[s]=c,!u){if(++t<=e)return;return s=n[r],o(s),s}if(delete n[u],r===u)for(;!hasOwnProperty.call(n,++r););},delete:o,clear:function(){t=a=0,r=1,n=Object.create(null),i=Object.create(null)}}}function _r(e){var{hasher:t,limit:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r=null==r?Number.POSITIVE_INFINITY:r,t=null==t?JSON.stringify:t,function n(){"object"!=typeof n.cache&&(n.cache={values:new Map,lru:Cr(r||Number.POSITIVE_INFINITY)});for(var i=[],a=0;a{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=H(e[1])||I(e[1])?e[1].compile().evaluate(r):Br(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("filter",{"Array, function":zr,"Matrix, function":function(e,t){return e.create(zr(e.toArray(),t))},"Array, RegExp":lt,"Matrix, RegExp":function(e,t){return e.create(lt(e.toArray(),t))}});return r}),{isTransformFunction:!0});function zr(e,t){var r=Tr(t);return ct(e,(function(e,n,i){return 1===r?t(e):2===r?t(e,[n+1]):t(e,[n+1],i)}))}var kr=Oe("forEach",["typed"],(e=>{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=H(e[1])||I(e[1])?e[1].compile().evaluate(r):Br(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("forEach",{"Array | Matrix, function":function(e,t){var r=Tr(t);!function n(i,a){Array.isArray(i)?ut(i,(function(e,t){n(e,a.concat(t+1))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e.valueOf(),[])}});return r}),{isTransformFunction:!0}),Ir=Oe("map",["typed"],(e=>{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=H(e[1])||I(e[1])?e[1].compile().evaluate(r):Br(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("map",{"Array, function":function(e,t){return Dr(e,t,e)},"Matrix, function":function(e,t){return e.create(Dr(e.valueOf(),t,e))}});return r}),{isTransformFunction:!0});function Dr(e,t,r){var n=Tr(t);return function e(i,a){return Array.isArray(i)?st(i,(function(t,r){return e(t,a.concat(r+1))})):1===n?t(i):2===n?t(i,a):t(i,a,r)}(e,[])}var Rr="apply",Ur=Oe(Rr,["typed","isInteger"],(e=>{var{typed:t,isInteger:r}=e;return t(Rr,{"Array | Matrix, number | BigNumber, function":function(e,t,n){if(!r(t))throw new TypeError("Integer number expected for dimension");var i=Array.isArray(e)?Ze(e):e.size();if(t<0||t>=i.length)throw new Ve(t,i.length);return h(e)?e.create(Fr(e.valueOf(),t,n)):Fr(e,t,n)}})}));function Fr(e,t,r){var n,i,a;if(t<=0){if(Array.isArray(e[0])){for(a=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r{var{typed:t,isInteger:r}=e,n=Ur({typed:t,isInteger:r});return t("apply",{"...any":function(e){var t=e[1];s(t)?e[1]=t-1:u(t)&&(e[1]=t.minus(1));try{return n.apply(null,e)}catch(e){throw Ut(e)}}})}),{isTransformFunction:!0}),jr="diff",Lr=Oe(jr,["typed","matrix","subtract","number"],(e=>{var{typed:t,matrix:r,subtract:n,number:i}=e;return t(jr,{"Array | Matrix":function(e){return h(e)?r(o(e.toArray())):o(e)},"Array | Matrix, number":function(e,t){if(!V(t))throw new RangeError("Dimension must be a whole number");return h(e)?r(a(e.toArray(),t)):a(e,t)},"Array | Matrix, BigNumber":function(e,t){return this(e,i(t))}});function a(e,t){if(h(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError("Array/Matrix does not have that many dimensions");if(t>0){var r=[];return e.forEach((e=>{r.push(a(e,t-1))})),r}if(0===t)return o(e);throw RangeError("Cannot have negative dimension")}function o(e){var t=[],r=e.length;if(r<2)return e;for(var n=1;n{var{typed:t,matrix:r,subtract:n,number:i,bignumber:a}=e,o=Lr({typed:t,matrix:r,subtract:n,number:i,bignumber:a});return t($r,{"...any":function(e){e=Hr(e);try{return o.apply(null,e)}catch(e){throw Ut(e)}}})}),{isTransformFunction:!0}),Vr=Oe("index",["Index"],(e=>{var{Index:t}=e;return function(){for(var e=[],r=0,n=arguments.length;r0?0:2;else if(i&&!0===i.isSet)i=i.map((function(e){return e-1}));else if(m(i)||h(i))i=i.map((function(e){return e-1}));else if(s(i))i--;else if(u(i))i=i.toNumber()-1;else if("string"!=typeof i)throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");e[r]=i}var a=new t;return t.apply(a,e),a}}),{isTransformFunction:!0}),Zr="subset",Wr=Oe(Zr,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t(Zr,{"Array, Index":function(e,t){var n=r(e).subset(t);return t.isScalar()?n:n.valueOf()},"Matrix, Index":function(e,t){return e.subset(t)},"Object, Index":Xr,"string, Index":Yr,"Array, Index, any":function(e,t,n){return r(Me(e)).subset(t,n,void 0).valueOf()},"Array, Index, any, any":function(e,t,n,i){return r(Me(e)).subset(t,n,i).valueOf()},"Matrix, Index, any":function(e,t,r){return e.clone().subset(t,r)},"Matrix, Index, any, any":function(e,t,r,n){return e.clone().subset(t,r,n)},"string, Index, string":Jr,"string, Index, string, string":Jr,"Object, Index, any":Qr})}));function Yr(e,t){if(!x(t))throw new TypeError("Index expected");if(1!==t.size().length)throw new Ge(t.size().length,1);var r=e.length;Je(t.min()[0],r),Je(t.max()[0],r);var n=t.dimension(0),i="";return n.forEach((function(t){i+=e.charAt(t)})),i}function Jr(e,t,r,n){if(!t||!0!==t.isIndex)throw new TypeError("Index expected");if(1!==t.size().length)throw new Ge(t.size().length,1);if(void 0!==n){if("string"!=typeof n||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";var i=t.dimension(0);if(i.size()[0]!==r.length)throw new Ge(i.size()[0],r.length);var a=e.length;Je(t.min()[0]),Je(t.max()[0]);for(var o=[],s=0;sa)for(var u=a-1,c=o.length;u{var{typed:t,matrix:r}=e,n=Wr({typed:t,matrix:r});return t("subset",{"...any":function(e){try{return n.apply(null,e)}catch(e){throw Ut(e)}}})}),{isTransformFunction:!0}),en="concat",tn=Oe(en,["typed","matrix","isInteger"],(e=>{var{typed:t,matrix:r,isInteger:n}=e;return t(en,{"...Array | Matrix | number | BigNumber":function(e){var t,i,a=e.length,o=-1,c=!1,l=[];for(t=0;t0&&o>i)throw new Ve(o,i+1)}else{var p=Me(f).valueOf(),m=Ze(p);if(l[t]=p,i=o,o=m.length-1,t>0&&o!==i)throw new Ge(i+1,o+1)}}if(0===l.length)throw new SyntaxError("At least one matrix expected");for(var d=l.shift();l.length;)d=rn(d,l.shift(),o,0);return c?r(d):d},"...string":function(e){return e.join("")}})}));function rn(e,t,r,n){if(n{var{typed:t,matrix:r,isInteger:n}=e,i=tn({typed:t,matrix:r,isInteger:n});return t("concat",{"...any":function(e){var t=e.length-1,r=e[t];s(r)?e[t]=r-1:u(r)&&(e[t]=r.minus(1));try{return i.apply(null,e)}catch(e){throw Ut(e)}}})}),{isTransformFunction:!0});function an(e,t,r){var n;return-1!==String(e).indexOf("Unexpected type")?(n=arguments.length>2?" (type: "+G(r)+", value: "+JSON.stringify(r)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+n)):-1!==String(e).indexOf("complex numbers")?(n=arguments.length>2?" (type: "+G(r)+", value: "+JSON.stringify(r)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+n)):e}var on=Oe("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:r,numeric:n,larger:i}=e;return t("max",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){return Yt(e,t.valueOf(),a)},"...":function(e){if(Vt(e))throw new TypeError("Scalar values expected in function max");return o(e)}});function a(e,t){try{return i(e,t)?e:t}catch(e){throw an(e,"max",t)}}function o(e){var t;if(Zt(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw an(t,"max",e)}})),void 0===t)throw new Error("Cannot calculate max of an empty array");return"string"==typeof t&&(t=n(t,r.number)),t}})),sn=Oe("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:r,numeric:n,larger:i}=e,a=on({typed:t,config:r,numeric:n,larger:i});return t("max",{"...any":function(e){e=Hr(e);try{return a.apply(null,e)}catch(e){throw Ut(e)}}})}),{isTransformFunction:!0}),un=Oe("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:r,numeric:n,smaller:i}=e;return t("min",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){return Yt(e,t.valueOf(),a)},"...":function(e){if(Vt(e))throw new TypeError("Scalar values expected in function min");return o(e)}});function a(e,t){try{return i(e,t)?e:t}catch(e){throw an(e,"min",t)}}function o(e){var t;if(Zt(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw an(t,"min",e)}})),void 0===t)throw new Error("Cannot calculate min of an empty array");return"string"==typeof t&&(t=n(t,r.number)),t}})),cn=Oe("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:r,numeric:n,smaller:i}=e,a=un({typed:t,config:r,numeric:n,smaller:i});return t("min",{"...any":function(e){e=Hr(e);try{return a.apply(null,e)}catch(e){throw Ut(e)}}})}),{isTransformFunction:!0}),ln="range",fn=Oe(ln,["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u}=e;return t(ln,{string:l,"string, boolean":l,"number, number":function(e,t){return c(f(e,t,1))},"number, number, number":function(e,t,r){return c(f(e,t,r))},"number, number, boolean":function(e,t,r){return c(r?p(e,t,1):f(e,t,1))},"number, number, number, boolean":function(e,t,r,n){return c(n?p(e,t,r):f(e,t,r))},"BigNumber, BigNumber":function(e,t){return c(m(e,t,new(0,e.constructor)(1)))},"BigNumber, BigNumber, BigNumber":function(e,t,r){return c(m(e,t,r))},"BigNumber, BigNumber, boolean":function(e,t,r){var n=e.constructor;return c(r?h(e,t,new n(1)):m(e,t,new n(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,r,n){return c(n?h(e,t,r):m(e,t,r))}});function c(e){return"Matrix"===r.matrix?n?n(e):pr():e}function l(e,t){var n=function(e){var t=e.split(":").map((function(e){return Number(e)}));if(t.some((function(e){return isNaN(e)})))return null;switch(t.length){case 2:return{start:t[0],end:t[1],step:1};case 3:return{start:t[0],end:t[2],step:t[1]};default:return null}}(e);if(!n)throw new SyntaxError('String "'+e+'" is no valid range');return"BigNumber"===r.number?(void 0===i&&lr(),c((t?h:m)(i(n.start),i(n.end),i(n.step)))):c((t?p:f)(n.start,n.end,n.step))}function f(e,t,r){var n=[],i=e;if(r>0)for(;a(i,t);)n.push(i),i+=r;else if(r<0)for(;s(i,t);)n.push(i),i+=r;return n}function p(e,t,r){var n=[],i=e;if(r>0)for(;o(i,t);)n.push(i),i+=r;else if(r<0)for(;u(i,t);)n.push(i),i+=r;return n}function m(e,t,r){var n=i(0),o=[],u=e;if(r.gt(n))for(;a(u,t);)o.push(u),u=u.plus(r);else if(r.lt(n))for(;s(u,t);)o.push(u),u=u.plus(r);return o}function h(e,t,r){var n=i(0),a=[],s=e;if(r.gt(n))for(;o(s,t);)a.push(s),s=s.plus(r);else if(r.lt(n))for(;u(s,t);)a.push(s),s=s.plus(r);return a}})),pn=Oe("range",["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u}=e,c=fn({typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u});return t("range",{"...any":function(e){return"boolean"!=typeof e[e.length-1]&&e.push(!0),c.apply(null,e)}})}),{isTransformFunction:!0}),mn=Oe("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e;return t("row",{"Matrix, number":a,"Array, number":function(e,t){return a(n(Me(e)),t).valueOf()}});function a(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");Je(t,e.size()[0]);var n=i(0,e.size()[1]),a=new r(t,n);return e.subset(a)}})),hn=Oe("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e,a=mn({typed:t,Index:r,matrix:n,range:i});return t("row",{"...any":function(e){var t=e.length-1,r=e[t];s(r)&&(e[t]=r-1);try{return a.apply(null,e)}catch(e){throw Ut(e)}}})}),{isTransformFunction:!0}),dn=Oe("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:r,add:n,numeric:i}=e;return t("sum",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){try{return Yt(e,t,n)}catch(e){throw an(e,"sum")}},"...":function(e){if(Vt(e))throw new TypeError("Scalar values expected in function sum");return a(e)}});function a(e){var t;return Zt(e,(function(e){try{t=void 0===t?e:n(t,e)}catch(t){throw an(t,"sum",e)}})),void 0===t&&(t=i(0,r.number)),"string"==typeof t&&(t=i(t,r.number)),t}})),yn=Oe("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:r,add:n,numeric:i}=e,a=dn({typed:t,config:r,add:n,numeric:i});return t("sum",{"...any":function(e){e=Hr(e);try{return a.apply(null,e)}catch(e){throw Ut(e)}}})}),{isTransformFunction:!0}),gn="column",vn=Oe(gn,["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e;return t(gn,{"Matrix, number":a,"Array, number":function(e,t){return a(n(Me(e)),t).valueOf()}});function a(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");Je(t,e.size()[1]);var n=i(0,e.size()[0]),a=new r(n,t);return e.subset(a)}})),xn=Oe("column",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e,a=vn({typed:t,Index:r,matrix:n,range:i});return t("column",{"...any":function(e){var t=e.length-1,r=e[t];s(r)&&(e[t]=r-1);try{return a.apply(null,e)}catch(e){throw Ut(e)}}})}),{isTransformFunction:!0}),bn="mean",wn=Oe(bn,["typed","add","divide"],(e=>{var{typed:t,add:r,divide:n}=e;return t(bn,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,t){try{var i=Yt(e,t,r),a=Array.isArray(e)?Ze(e):e.size();return n(i,a[t])}catch(e){throw an(e,"mean")}},"...":function(e){if(Vt(e))throw new TypeError("Scalar values expected in function mean");return i(e)}});function i(e){var t,i=0;if(Zt(e,(function(e){try{t=void 0===t?e:r(t,e),i++}catch(t){throw an(t,"mean",e)}})),0===i)throw new Error("Cannot calculate the mean of an empty array");return n(t,i)}})),Nn=Oe("mean",["typed","add","divide"],(e=>{var{typed:t,add:r,divide:n}=e,i=wn({typed:t,add:r,divide:n});return t("mean",{"...any":function(e){e=Hr(e);try{return i.apply(null,e)}catch(e){throw Ut(e)}}})}),{isTransformFunction:!0}),Mn="unbiased",Sn="variance",En=Oe(Sn,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:r,subtract:n,multiply:i,divide:a,apply:o,isNaN:s}=e;return t(Sn,{"Array | Matrix":function(e){return c(e,Mn)},"Array | Matrix, string":c,"Array | Matrix, number | BigNumber":function(e,t){return l(e,t,Mn)},"Array | Matrix, number | BigNumber, string":l,"...":function(e){return c(e,Mn)}});function c(e,t){var o,c=0;if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Zt(e,(function(e){try{o=void 0===o?e:r(o,e),c++}catch(t){throw an(t,"variance",e)}})),0===c)throw new Error("Cannot calculate variance of an empty array");var l=a(o,c);if(o=void 0,Zt(e,(function(e){var t=n(e,l);o=void 0===o?i(t,t):r(o,i(t,t))})),s(o))return o;switch(t){case"uncorrected":return a(o,c);case"biased":return a(o,c+1);case"unbiased":var f=u(o)?o.mul(0):0;return 1===c?f:a(o,c-1);default:throw new Error('Unknown normalization "'+t+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function l(e,t,r){try{if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return o(e,t,(e=>c(e,r)))}catch(e){throw an(e,"variance")}}})),An="variance",On=Oe(An,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:r,subtract:n,multiply:i,divide:a,apply:o,isNaN:s}=e,u=En({typed:t,add:r,subtract:n,multiply:i,divide:a,apply:o,isNaN:s});return t(An,{"...any":function(e){e=Hr(e);try{return u.apply(null,e)}catch(e){throw Ut(e)}}})}),{isTransformFunction:!0}),Cn=Oe("std",["typed","sqrt","variance"],(e=>{var{typed:t,sqrt:r,variance:n}=e;return t("std",{"Array | Matrix":i,"Array | Matrix, string":i,"Array | Matrix, number | BigNumber":i,"Array | Matrix, number | BigNumber, string":i,"...":function(e){return i(e)}});function i(e,t){if(0===e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{return r(n.apply(null,arguments))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf(" variance")?new TypeError(e.message.replace(" variance"," std")):e}}})),_n=Oe("std",["typed","sqrt","variance"],(e=>{var{typed:t,sqrt:r,variance:n}=e,i=Cn({typed:t,sqrt:r,variance:n});return t("std",{"...any":function(e){e=Hr(e);try{return i.apply(null,e)}catch(e){throw Ut(e)}}})}),{isTransformFunction:!0}),Tn=r(776),Bn=Oe("BigNumber",["?on","config"],(e=>{var{on:t,config:r}=e,n=Tn.clone({precision:r.precision,modulo:Tn.EUCLID});return n.prototype=Object.create(n.prototype),n.prototype.type="BigNumber",n.prototype.isBigNumber=!0,n.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},n.fromJSON=function(e){return new n(e.value)},t&&t("config",(function(e,t){e.precision!==t.precision&&n.config({precision:e.precision})})),n}),{isClass:!0}),qn=r(977),zn=Oe("Complex",[],(()=>(qn.prototype.type="Complex",qn.prototype.isComplex=!0,qn.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},qn.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},qn.prototype.format=function(e){var t=this.im,r=this.re,n=ee(this.re,e),i=ee(this.im,e),a=s(e)?e:e?e.precision:null;if(null!==a){var o=Math.pow(10,-a);Math.abs(r/t)t.re?1:e.ret.im?1:e.im!0)),Hn=Oe("false",[],(()=>!1)),$n=Oe("null",[],(()=>null)),Gn=ai("Infinity",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1/0):1/0})),Vn=ai("NaN",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(NaN):NaN})),Zn=ai("pi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?Dn(r):Fn})),Wn=ai("tau",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?Rn(r):Pn})),Yn=ai("e",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?kn(r):jn})),Jn=ai("phi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?In(r):1.618033988749895})),Xn=ai("LN2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(2).ln():Math.LN2})),Qn=ai("LN10",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(10).ln():Math.LN10})),Kn=ai("LOG2E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1).div(new r(2).ln()):Math.LOG2E})),ei=ai("LOG10E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1).div(new r(10).ln()):Math.LOG10E})),ti=ai("SQRT1_2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r("0.5").sqrt():Math.SQRT1_2})),ri=ai("SQRT2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(2).sqrt():Math.SQRT2})),ni=ai("i",["Complex"],(e=>{var{Complex:t}=e;return t.I})),ii=Oe("version",[],(()=>"10.1.1"));function ai(e,t,r){return Oe(e,t,r,{recreateOnConfigChange:!0})}var oi=ra("speedOfLight","299792458","m s^-1"),si=ra("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),ui=ra("planckConstant","6.62607015e-34","J s"),ci=ra("reducedPlanckConstant","1.0545718176461565e-34","J s"),li=ra("magneticConstant","1.25663706212e-6","N A^-2"),fi=ra("electricConstant","8.8541878128e-12","F m^-1"),pi=ra("vacuumImpedance","376.730313667","ohm"),mi=ra("coulomb","8.987551792261171e9","N m^2 C^-2"),hi=ra("elementaryCharge","1.602176634e-19","C"),di=ra("bohrMagneton","9.2740100783e-24","J T^-1"),yi=ra("conductanceQuantum","7.748091729863649e-5","S"),gi=ra("inverseConductanceQuantum","12906.403729652257","ohm"),vi=ra("magneticFluxQuantum","2.0678338484619295e-15","Wb"),xi=ra("nuclearMagneton","5.0507837461e-27","J T^-1"),bi=ra("klitzing","25812.807459304513","ohm"),wi=ra("bohrRadius","5.29177210903e-11","m"),Ni=ra("classicalElectronRadius","2.8179403262e-15","m"),Mi=ra("electronMass","9.1093837015e-31","kg"),Si=ra("fermiCoupling","1.1663787e-5","GeV^-2"),Ei=na("fineStructure",.0072973525693),Ai=ra("hartreeEnergy","4.3597447222071e-18","J"),Oi=ra("protonMass","1.67262192369e-27","kg"),Ci=ra("deuteronMass","3.3435830926e-27","kg"),_i=ra("neutronMass","1.6749271613e-27","kg"),Ti=ra("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),Bi=ra("rydberg","10973731.568160","m^-1"),qi=ra("thomsonCrossSection","6.6524587321e-29","m^2"),zi=na("weakMixingAngle",.2229),ki=na("efimovFactor",22.7),Ii=ra("atomicMass","1.66053906660e-27","kg"),Di=ra("avogadro","6.02214076e23","mol^-1"),Ri=ra("boltzmann","1.380649e-23","J K^-1"),Ui=ra("faraday","96485.33212331001","C mol^-1"),Fi=ra("firstRadiation","3.7417718521927573e-16","W m^2"),Pi=ra("loschmidt","2.686780111798444e25","m^-3"),ji=ra("gasConstant","8.31446261815324","J K^-1 mol^-1"),Li=ra("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),Hi=ra("molarVolume","0.022413969545014137","m^3 mol^-1"),$i=na("sackurTetrode",-1.16487052358),Gi=ra("secondRadiation","0.014387768775039337","m K"),Vi=ra("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),Zi=ra("wienDisplacement","2.897771955e-3","m K"),Wi=ra("molarMass","0.99999999965e-3","kg mol^-1"),Yi=ra("molarMassC12","11.9999999958e-3","kg mol^-1"),Ji=ra("gravity","9.80665","m s^-2"),Xi=ra("planckLength","1.616255e-35","m"),Qi=ra("planckMass","2.176435e-8","kg"),Ki=ra("planckTime","5.391245e-44","s"),ea=ra("planckCharge","1.87554603778e-18","C"),ta=ra("planckTemperature","1.416785e+32","K");function ra(e,t,r){return Oe(e,["config","Unit","BigNumber"],(e=>{var{config:n,Unit:i,BigNumber:a}=e,o=new i("BigNumber"===n.number?new a(t):parseFloat(t),r);return o.fixPrefix=!0,o}))}function na(e,t){return Oe(e,["config","BigNumber"],(e=>{var{config:r,BigNumber:n}=e;return"BigNumber"===r.number?new n(t):t}))}var ia=r(628),aa=Oe("Fraction",[],(()=>(ia.prototype.type="Fraction",ia.prototype.isFraction=!0,ia.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},ia.fromJSON=function(e){return new ia(e)},ia)),{isClass:!0}),oa=Oe("Matrix",[],(()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(e,t,r){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(e,t,r){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e}),{isClass:!0}),sa=Oe("Range",[],(()=>{function e(t,r,n){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var i=null!=t,a=null!=r,o=null!=n;if(i)if(u(t))t=t.toNumber();else if("number"!=typeof t)throw new TypeError("Parameter start must be a number");if(a)if(u(r))r=r.toNumber();else if("number"!=typeof r)throw new TypeError("Parameter end must be a number");if(o)if(u(n))n=n.toNumber();else if("number"!=typeof n)throw new TypeError("Parameter step must be a number");this.start=i?parseFloat(t):0,this.end=a?parseFloat(r):0,this.step=o?parseFloat(n):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(t){if("string"!=typeof t)return null;var r=t.split(":").map((function(e){return parseFloat(e)}));if(r.some((function(e){return isNaN(e)})))return null;switch(r.length){case 2:return new e(r[0],r[1]);case 3:return new e(r[0],r[2],r[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var e=0,t=this.start,r=this.step,n=this.end-t;return Z(r)===Z(n)?e=Math.ceil(n/r):0===n&&(e=0),isNaN(e)&&(e=0),[e]},e.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},e.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},e.prototype.forEach=function(e){var t=this.start,r=this.step,n=this.end,i=0;if(r>0)for(;tn;)e(t,[i],this),t+=r,i++},e.prototype.map=function(e){var t=[];return this.forEach((function(r,n,i){t[n[0]]=e(r,n,i)})),t},e.prototype.toArray=function(){var e=[];return this.forEach((function(t,r){e[r[0]]=t})),e},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(e){var t=ee(this.start,e);return 1!==this.step&&(t+=":"+ee(this.step,e)),t+=":"+ee(this.end,e)},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},e.fromJSON=function(t){return new e(t.start,t.end,t.step)},e}),{isClass:!0}),ua=Oe("ResultSet",[],(()=>{function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=t||[]}return e.prototype.type="ResultSet",e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},e.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},e.fromJSON=function(t){return new e(t.entries)},e}),{isClass:!0}),ca=Oe("DenseMatrix",["Matrix"],(e=>{var{Matrix:t}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!p(t))throw new Error("Invalid datatype: "+t);if(h(e))"DenseMatrix"===e.type?(this._data=Me(e._data),this._size=Me(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&m(e.data)&&m(e.size))this._data=e.data,this._size=e.size,Ye(this._data,this._size),this._datatype=t||e.datatype;else if(m(e))this._data=f(e),this._size=Ze(this._data),Ye(this._data,this._size),this._datatype=t;else{if(e)throw new TypeError("Unsupported type of data ("+G(e)+")");this._data=[],this._size=[0],this._datatype=t}}function n(e,t){if(!x(t))throw new TypeError("Invalid index");if(t.isScalar())return e.get(t.min());var n=t.size();if(n.length!==e._size.length)throw new Ge(n.length,e._size.length);for(var a=t.min(),o=t.max(),s=0,u=e._size.length;s");var f=t.max().map((function(e){return e+1}));l(e,f,n);var p=a.length;o(e._data,t,r,p,0)}return e}function o(e,t,r,n,i){var a=i===n-1,s=t.dimension(i);a?s.forEach((function(t,n){Je(t),e[t]=r[n[0]]})):s.forEach((function(a,s){Je(a),o(e[a],t,r[s[0]],n,i+1)}))}function c(e,t,r){if(0===t.length){for(var n=e._data;m(n);)n=n[0];return n}return e._size=t.slice(0),e._data=Xe(e._data,e._size,r),e}function l(e,t,r){for(var n=e._size.slice(0),i=!1;n.lengthn[a]&&(n[a]=t[a],i=!0);i&&c(e,n,r)}function f(e){for(var t=0,r=e.length;tArray.isArray(e)&&1===e.length?e[0]:e));return c(r?this.clone():this,n,t)},r.prototype.reshape=function(e,t){var r=t?this.clone():this;r._data=Ke(r._data,e);var n=r._size.reduce(((e,t)=>e*t));return r._size=et(e,n),r},r.prototype.clone=function(){return new r({data:Me(this._data),size:Me(this._size),datatype:this._datatype})},r.prototype.size=function(){return this._size.slice(0)},r.prototype.map=function(e){var t=this,n=function r(n,i){return m(n)?n.map((function(e,t){return r(e,i.concat(t))})):e(n,i,t)}(this._data,[]);return new r(n,void 0!==this._datatype?ht(n,G):void 0)},r.prototype.forEach=function(e){var t=this;!function r(n,i){m(n)?n.forEach((function(e,t){r(e,i.concat(t))})):e(n,i,t)}(this._data,[])},r.prototype[Symbol.iterator]=function*(){yield*function*e(t,r){if(m(t))for(var n=0;n[e[n]]));t.push(new r(a,e._datatype))},o=0;o0?e:0,n=e<0?-e:0,i=this._size[0],a=this._size[1],o=Math.min(i-n,a-t),c=[],l=0;l0?n:0,c=n<0?-n:0,l=e[0],f=e[1],p=Math.min(l-c,f-o);if(m(t)){if(t.length!==p)throw new Error("Invalid value array length");a=function(e){return t[e]}}else if(h(t)){var d=t.size();if(1!==d.length||d[0]!==p)throw new Error("Invalid matrix length");a=function(e){return t.get([e])}}else a=function(){return t};i||(i=u(a(0))?a(0).mul(0):0);var y=[];if(e.length>0){y=Xe(y,e,i);for(var g=0;gfunction(e,t){return"number"!=typeof t||isFinite(t)&&!isNaN(t)?t:{mathjs:"number",value:String(t)}})),fa=r(287),pa=function(){return pa=fa.create,fa},ma=Oe("typed",["?BigNumber","?Complex","?DenseMatrix","?Fraction"],(function(e){var{BigNumber:t,Complex:r,DenseMatrix:n,Fraction:i}=e,a=pa();return a.types=[{name:"number",test:s},{name:"Complex",test:c},{name:"BigNumber",test:u},{name:"Fraction",test:l},{name:"Unit",test:f},{name:"string",test:p},{name:"Chain",test:$},{name:"Array",test:m},{name:"Matrix",test:h},{name:"DenseMatrix",test:y},{name:"SparseMatrix",test:g},{name:"Range",test:v},{name:"Index",test:x},{name:"boolean",test:b},{name:"ResultSet",test:w},{name:"Help",test:N},{name:"function",test:M},{name:"Date",test:S},{name:"RegExp",test:E},{name:"null",test:O},{name:"undefined",test:C},{name:"AccessorNode",test:_},{name:"ArrayNode",test:T},{name:"AssignmentNode",test:B},{name:"BlockNode",test:q},{name:"ConditionalNode",test:z},{name:"ConstantNode",test:k},{name:"FunctionNode",test:D},{name:"FunctionAssignmentNode",test:I},{name:"IndexNode",test:R},{name:"Node",test:U},{name:"ObjectNode",test:F},{name:"OperatorNode",test:P},{name:"ParenthesisNode",test:j},{name:"RangeNode",test:L},{name:"SymbolNode",test:H},{name:"Map",test:je},{name:"Object",test:A}],a.conversions=[{from:"number",to:"BigNumber",convert:function(e){if(t||ha(e),e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new t(e)}},{from:"number",to:"Complex",convert:function(e){return r||da(e),new r(e,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(e){return r||da(e),new r(e.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(e){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(e){return r||da(e),new r(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){i||ya(e);var t=new i(e);if(t.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return t}},{from:"string",to:"number",convert:function(e){var t=Number(e);if(isNaN(t))throw new Error('Cannot convert "'+e+'" to a number');return t}},{from:"string",to:"BigNumber",convert:function(e){t||ha(e);try{return new t(e)}catch(t){throw new Error('Cannot convert "'+e+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(e){i||ya(e);try{return new i(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(e){r||da(e);try{return new r(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return t||ha(e),new t(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return i||ya(e),new i(+e)}},{from:"boolean",to:"string",convert:function(e){return String(e)}},{from:"Array",to:"Matrix",convert:function(e){return n||function(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}(),new n(e)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}],a}));function ha(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function da(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function ya(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var ga="number",va="number, number";function xa(e){return Math.abs(e)}function ba(e,t){return e+t}function wa(e,t){return e*t}function Na(e){return-e}function Ma(e){return e}function Sa(e){return X(e)}function Ea(e){return Math.ceil(e)}function Aa(e){return e*e*e}function Oa(e){return Math.exp(e)}function Ca(e){return Q(e)}function _a(e,t){if(!V(e)||!V(t))throw new Error("Parameters in function gcd must be integer numbers");for(var r;0!==t;)r=e%t,e=t,t=r;return e<0?-e:e}function Ta(e,t){if(!V(e)||!V(t))throw new Error("Parameters in function lcm must be integer numbers");if(0===e||0===t)return 0;for(var r,n=e*t;0!==t;)t=e%(r=t),e=r;return Math.abs(n/e)}function Ba(e){return Math.log(e)}function qa(e){return Y(e)}function za(e){return W(e)}function ka(e,t){if(t>0)return e-t*Math.floor(e/t);if(0===t)return e;throw new Error("Cannot calculate mod for a negative divisor")}function Ia(e,t){var r=t<0;if(r&&(t=-t),0===t)throw new Error("Root must be non-zero");if(e<0&&Math.abs(t)%2!=1)throw new Error("Root must be odd when a is negative.");if(0===e)return r?1/0:0;if(!isFinite(e))return r?0:e;var n=Math.pow(Math.abs(e),1/t);return n=e<0?-n:n,r?1/n:n}function Da(e){return Z(e)}function Ra(e){return e*e}function Ua(e,t){var r,n,i,a=0,o=1,s=1,u=0;if(!V(e)||!V(t))throw new Error("Parameters in function xgcd must be integer numbers");for(;t;)i=e-(n=Math.floor(e/t))*t,r=a,a=o-n*a,o=r,r=s,s=u-n*s,u=r,e=t,t=i;return e<0?[-e,-o,-u]:[e,e?o:0,u]}function Fa(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:Math.pow(e,t)}function Pa(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return parseFloat(re(e,t))}xa.signature=ga,ba.signature=va,wa.signature=va,Na.signature=ga,Ma.signature=ga,Sa.signature=ga,Ea.signature=ga,Aa.signature=ga,Oa.signature=ga,Ca.signature=ga,_a.signature=va,Ta.signature=va,Ba.signature=ga,qa.signature=ga,za.signature=ga,ka.signature=va,Ia.signature=va,Da.signature=ga,Ra.signature=ga,Ua.signature=va,Fa.signature=va,Pa.signature=va;var ja="unaryPlus",La=Oe(ja,["typed","config","BigNumber"],(e=>{var{typed:t,config:r,BigNumber:n}=e;return t(ja,{number:Ma,Complex:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":function(e){return Wt(e,this,!0)},"boolean | string":function(e){return"BigNumber"===r.number?new n(+e):+e}})})),Ha=Oe("abs",["typed"],(e=>{var{typed:t}=e;return t("abs",{number:xa,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},Fraction:function(e){return e.abs()},"Array | Matrix":function(e){return Wt(e,this,!0)},Unit:function(e){return e.abs()}})})),$a="acos",Ga=Oe($a,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t($a,{number:function(e){return e>=-1&&e<=1||r.predictable?Math.acos(e):new n(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()},"Array | Matrix":function(e){return Wt(e,this)}})})),Va="number";function Za(e){return ue(e)}function Wa(e){return Math.atan(1/e)}function Ya(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}function Ja(e){return Math.asin(1/e)}function Xa(e){var t=1/e;return Math.log(t+Math.sqrt(t*t+1))}function Qa(e){return Math.acos(1/e)}function Ka(e){var t=1/e,r=Math.sqrt(t*t-1);return Math.log(r+t)}function eo(e){return ce(e)}function to(e){return le(e)}function ro(e){return 1/Math.tan(e)}function no(e){var t=Math.exp(2*e);return(t+1)/(t-1)}function io(e){return 1/Math.sin(e)}function ao(e){return 0===e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*Z(e)}function oo(e){return 1/Math.cos(e)}function so(e){return 2/(Math.exp(e)+Math.exp(-e))}function uo(e){return pe(e)}Za.signature=Va,Wa.signature=Va,Ya.signature=Va,Ja.signature=Va,Xa.signature=Va,Qa.signature=Va,Ka.signature=Va,eo.signature=Va,to.signature=Va,ro.signature=Va,no.signature=Va,io.signature=Va,ao.signature=Va,oo.signature=Va,so.signature=Va,uo.signature=Va;var co="acot",lo=Oe(co,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(co,{number:Wa,Complex:function(e){return e.acot()},BigNumber:function(e){return new r(1).div(e).atan()},"Array | Matrix":function(e){return Wt(e,this)}})})),fo="acsc",po=Oe(fo,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(fo,{number:function(e){return e<=-1||e>=1||r.predictable?Ja(e):new n(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new i(1).div(e).asin()},"Array | Matrix":function(e){return Wt(e,this)}})})),mo="addScalar",ho=Oe(mo,["typed"],(e=>{var{typed:t}=e;return t(mo,{"number, number":ba,"Complex, Complex":function(e,t){return e.add(t)},"BigNumber, BigNumber":function(e,t){return e.plus(t)},"Fraction, Fraction":function(e,t){return e.add(t)},"Unit, Unit":function(e,t){if(null===e.value||void 0===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value||void 0===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var r=e.clone();return r.value=this(r.value,t.value),r.fixPrefix=!1,r}})})),yo=Oe("arg",["typed"],(e=>{var{typed:t}=e;return t("arg",{number:function(e){return Math.atan2(0,e)},BigNumber:function(e){return e.constructor.atan2(0,e)},Complex:function(e){return e.arg()},"Array | Matrix":function(e){return Wt(e,this)}})})),go="asech",vo=Oe(go,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(go,{number:function(e){if(e<=1&&e>=-1||r.predictable){var t=1/e;if(t>0||r.predictable)return Ka(e);var i=Math.sqrt(t*t-1);return new n(Math.log(i-t),Math.PI)}return new n(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new i(1).div(e).acosh()},"Array | Matrix":function(e){return Wt(e,this)}})})),xo=Oe("asinh",["typed"],(e=>{var{typed:t}=e;return t("asinh",{number:eo,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()},"Array | Matrix":function(e){return Wt(e,this,!0)}})})),bo=Oe("atan",["typed"],(e=>{var{typed:t}=e;return t("atan",{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()},"Array | Matrix":function(e){return Wt(e,this,!0)}})})),wo="atanh",No=Oe(wo,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(wo,{number:function(e){return e<=1&&e>=-1||r.predictable?to(e):new n(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()},"Array | Matrix":function(e){return Wt(e,this,!0)}})})),Mo=Oe("bignumber",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("bignumber",{"":function(){return new r(0)},number:function(e){return new r(e+"")},string:function(e){var t=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(t){var n=t[2],i=r(t[1]),a=new r(2).pow(Number(n));if(i.gt(a.sub(1)))throw new SyntaxError('String "'.concat(e,'" is out of range'));var o=new r(2).pow(Number(n)-1);return i.gte(o)?i.sub(a):i}return new r(e)},BigNumber:function(e){return e},Fraction:function(e){return new r(e.n).div(e.d).times(e.s)},null:function(e){return new r(0)},"Array | Matrix":function(e){return Wt(e,this)}})}));function So(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitAnd");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero()||t.eq(-1)||e.eq(t))return e;if(t.isZero()||e.eq(-1))return t;if(!e.isFinite()||!t.isFinite()){if(!e.isFinite()&&!t.isFinite())return e.isNegative()===t.isNegative()?e:new r(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new r(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new r(0):e}return Oo(e,t,(function(e,t){return e&t}))}function Eo(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var t=e.constructor,r=t.precision;t.config({precision:1e9});var n=e.plus(new t(1));return n.s=-n.s||null,t.config({precision:r}),n}function Ao(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitOr");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);var n=new r(-1);return e.isZero()||t.eq(n)||e.eq(t)?t:t.isZero()||e.eq(n)?e:e.isFinite()&&t.isFinite()?Oo(e,t,(function(e,t){return e|t})):!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?n:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e}function Oo(e,t,r){var n,i,a,o,s,u=e.constructor,c=+(e.s<0),l=+(t.s<0);if(c){n=Co(Eo(e));for(var f=0;f0;)r(a[--m],o[--h])===d&&(y=y.plus(g)),g=g.times(v);for(;h>0;)r(s,o[--h])===d&&(y=y.plus(g)),g=g.times(v);return u.config({precision:x}),0===d&&(y.s=-y.s),y}function Co(e){for(var t=e.d,r=t[0]+"",n=1;n0)if(++s>c)for(s-=c;s--;)u+="0";else s1&&(null!==l[m+1]&&void 0!==l[m+1]||(l[m+1]=0),l[m+1]+=l[m]>>1,l[m]&=1)}return l.reverse()}function _o(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new r(0);var n=new r(-1);return e.eq(n)?Eo(t):t.eq(n)?Eo(e):e.isFinite()&&t.isFinite()?Oo(e,t,(function(e,t){return e^t})):e.isFinite()||t.isFinite()?new r(e.isNegative()===t.isNegative()?1/0:-1/0):n}function To(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:e.isFinite()||t.isFinite()?t.lt(55)?e.times(Math.pow(2,t.toNumber())+""):e.times(new r(2).pow(t)):new r(NaN)}function Bo(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(Math.pow(2,t.toNumber())+"").floor():e.div(new r(2).pow(t)).floor():e.isNegative()?new r(-1):e.isFinite()?new r(0):new r(NaN)}var qo="number, number";function zo(e,t){if(!V(e)||!V(t))throw new Error("Integers expected in function bitAnd");return e&t}function ko(e){if(!V(e))throw new Error("Integer expected in function bitNot");return~e}function Io(e,t){if(!V(e)||!V(t))throw new Error("Integers expected in function bitOr");return e|t}function Do(e,t){if(!V(e)||!V(t))throw new Error("Integers expected in function bitXor");return e^t}function Ro(e,t){if(!V(e)||!V(t))throw new Error("Integers expected in function leftShift");return e<>t}function Fo(e,t){if(!V(e)||!V(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}zo.signature=qo,ko.signature="number",Io.signature=qo,Do.signature=qo,Ro.signature=qo,Uo.signature=qo,Fo.signature=qo;var Po="bitNot",jo=Oe(Po,["typed"],(e=>{var{typed:t}=e;return t(Po,{number:ko,BigNumber:Eo,"Array | Matrix":function(e){return Wt(e,this)}})})),Lo="boolean",Ho=Oe(Lo,["typed"],(e=>{var{typed:t}=e;return t(Lo,{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(e){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;var r=Number(e);if(""!==e&&!isNaN(r))return!!r;throw new Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":function(e){return Wt(e,this)}})})),$o="clone",Go=Oe($o,["typed"],(e=>{var{typed:t}=e;return t($o,{any:Me})}));function Vo(e,t){if(t>1;return Vo(e,r)*Vo(r+1,t)}function Zo(e,t){if(!V(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!V(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(t>e)throw new TypeError("k must be less than or equal to n");var r=e-t;return t{var{typed:t}=e;return t(Wo,{"number, number":Zo,"BigNumber, BigNumber":function(e,t){var r,n,i=e.constructor,a=e.minus(t),o=new i(1);if(!Jo(e)||!Jo(t))throw new TypeError("Positive integer value expected in function combinations");if(t.gt(e))throw new TypeError("k must be less than n in function combinations");if(r=o,t.lt(a))for(n=o;n.lte(a);n=n.plus(o))r=r.times(t.plus(n)).dividedBy(n);else for(n=o;n.lte(t);n=n.plus(o))r=r.times(a.plus(n)).dividedBy(n);return r}})}));function Jo(e){return e.isInteger()&&e.gte(0)}var Xo=Oe("complex",["typed","Complex"],(e=>{var{typed:t,Complex:r}=e;return t("complex",{"":function(){return r.ZERO},number:function(e){return new r(e,0)},"number, number":function(e,t){return new r(e,t)},"BigNumber, BigNumber":function(e,t){return new r(e.toNumber(),t.toNumber())},Fraction:function(e){return new r(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return r(e)},null:function(e){return r(0)},Object:function(e){if("re"in e&&"im"in e)return new r(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new r(e);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(e){return Wt(e,this)}})})),Qo="conj",Ko=Oe(Qo,["typed"],(e=>{var{typed:t}=e;return t(Qo,{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.conjugate()},"Array | Matrix":function(e){return Wt(e,this)}})})),es="cosh",ts=Oe(es,["typed"],(e=>{var{typed:t}=e;return t(es,{number:fe,Complex:function(e){return e.cosh()},BigNumber:function(e){return e.cosh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(e.value)},"Array | Matrix":function(e){return Wt(e,this)}})})),rs="coth",ns=Oe(rs,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(rs,{number:no,Complex:function(e){return e.coth()},BigNumber:function(e){return new r(1).div(e.tanh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(e.value)},"Array | Matrix":function(e){return Wt(e,this)}})})),is=Oe("csc",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("csc",{number:io,Complex:function(e){return e.csc()},BigNumber:function(e){return new r(1).div(e.sin())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(e.value)},"Array | Matrix":function(e){return Wt(e,this)}})})),as="cube",os=Oe(as,["typed"],(e=>{var{typed:t}=e;return t(as,{number:Aa,Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},Fraction:function(e){return e.pow(3)},"Array | Matrix":function(e){return Wt(e,this,!0)},Unit:function(e){return e.pow(3)}})}));function ss(e,t,r){if(null==r)return e.eq(t);if(e.eq(t))return!0;if(e.isNaN()||t.isNaN())return!1;if(e.isFinite()&&t.isFinite()){var n=e.minus(t).abs();if(n.isZero())return!0;var i=e.constructor.max(e.abs(),t.abs());return n.lte(i.times(r))}return!1}var us="equalScalar",cs=Oe(us,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(us,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||ss(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return e.equals(t)},"Complex, Complex":function(e,t){return function(e,t,r){return se(e.re,t.re,r)&&se(e.im,t.im,r)}(e,t,r.epsilon)},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)}})})),ls=(Oe(us,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(us,{"number, number":function(e,t){return se(e,t,r.epsilon)}})})),Oe("erf",["typed"],(e=>{var{typed:t}=e;return t("name",{number:function(e){var t=Math.abs(e);return t>=ds?Z(e):t<=fs?Z(e)*function(e){var t,r=e*e,n=ms[0][4]*r,i=r;for(t=0;t<3;t+=1)n=(n+ms[0][t])*r,i=(i+hs[0][t])*r;return e*(n+ms[0][3])/(i+hs[0][3])}(t):t<=4?Z(e)*(1-function(e){var t,r=ms[1][8]*e,n=e;for(t=0;t<7;t+=1)r=(r+ms[1][t])*e,n=(n+hs[1][t])*e;var i=(r+ms[1][7])/(n+hs[1][7]),a=parseInt(16*e)/16,o=(e-a)*(e+a);return Math.exp(-a*a)*Math.exp(-o)*i}(t)):Z(e)*(1-function(e){var t,r=1/(e*e),n=ms[2][5]*r,i=r;for(t=0;t<4;t+=1)n=(n+ms[2][t])*r,i=(i+hs[2][t])*r;var a=r*(n+ms[2][4])/(i+hs[2][4]);a=(ps-a)/e,r=parseInt(16*e)/16;var o=(e-r)*(e+r);return Math.exp(-r*r)*Math.exp(-o)*a}(t))},"Array | Matrix":function(e){return Wt(e,this)}})}))),fs=.46875,ps=.5641895835477563,ms=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],hs=[[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,.5279051029514285,.06051834131244132,.0023352049762686918]],ds=Math.pow(2,53),ys=Oe("exp",["typed"],(e=>{var{typed:t}=e;return t("exp",{number:Oa,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()},"Array | Matrix":function(e){return Wt(e,this)}})})),gs="expm1",vs=Oe(gs,["typed","Complex"],(e=>{var{typed:t,Complex:r}=e;return t(gs,{number:Ca,Complex:function(e){var t=Math.exp(e.re);return new r(t*Math.cos(e.im)-1,t*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)},"Array | Matrix":function(e){return Wt(e,this)}})})),xs=Oe("filter",["typed"],(e=>{var{typed:t}=e;return t("filter",{"Array, function":bs,"Matrix, function":function(e,t){return e.create(bs(e.toArray(),t))},"Array, RegExp":lt,"Matrix, RegExp":function(e,t){return e.create(lt(e.toArray(),t))}})}));function bs(e,t){var r=Tr(t);return ct(e,(function(e,n,i){return 1===r?t(e):2===r?t(e,[n]):t(e,[n],i)}))}var ws="forEach",Ns=Oe(ws,["typed"],(e=>{var{typed:t}=e;return t(ws,{"Array, function":Ms,"Matrix, function":function(e,t){return e.forEach(t)}})}));function Ms(e,t){var r=Tr(t);!function n(i,a){Array.isArray(i)?ut(i,(function(e,t){n(e,a.concat(t))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e,[])}var Ss="format",Es=Oe(Ss,["typed"],(e=>{var{typed:t}=e;return t(Ss,{any:ve,"any, Object | function | number":ve})})),As="getMatrixDataType",Os=Oe(As,["typed"],(e=>{var{typed:t}=e;return t(As,{Array:function(e){return ht(e,G)},Matrix:function(e){return e.getDataType()}})})),Cs=Oe("hex",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("hex",{"number | BigNumber":function(e){return r(e,{notation:"hex"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"hex",wordSize:t})}})})),_s=Oe("im",["typed"],(e=>{var{typed:t}=e;return t("im",{number:function(e){return 0},BigNumber:function(e){return e.mul(0)},Fraction:function(e){return e.mul(0)},Complex:function(e){return e.im},"Array | Matrix":function(e){return Wt(e,this)}})})),Ts="isInteger",Bs=Oe(Ts,["typed"],(e=>{var{typed:t}=e;return t(Ts,{number:V,BigNumber:function(e){return e.isInt()},Fraction:function(e){return 1===e.d&&isFinite(e.n)},"Array | Matrix":function(e){return Wt(e,this)}})})),qs="number";function zs(e){return e<0}function ks(e){return e>0}function Is(e){return 0===e}function Ds(e){return Number.isNaN(e)}zs.signature=qs,ks.signature=qs,Is.signature=qs,Ds.signature=qs;var Rs="isNegative",Us=Oe(Rs,["typed"],(e=>{var{typed:t}=e;return t(Rs,{number:zs,BigNumber:function(e){return e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s<0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return Wt(e,this)}})})),Fs="isPositive",Ps=Oe(Fs,["typed"],(e=>{var{typed:t}=e;return t(Fs,{number:ks,BigNumber:function(e){return!e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s>0&&e.n>0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return Wt(e,this)}})})),js="isZero",Ls=Oe(js,["typed"],(e=>{var{typed:t}=e;return t(js,{number:Is,BigNumber:function(e){return e.isZero()},Complex:function(e){return 0===e.re&&0===e.im},Fraction:function(e){return 1===e.d&&0===e.n},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return Wt(e,this)}})})),Hs="log10",$s=Oe(Hs,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(Hs,{number:function(e){return e>=0||r.predictable?qa(e):new n(e,0).log().div(Math.LN10)},Complex:function(e){return new n(e).log().div(Math.LN10)},BigNumber:function(e){return!e.isNegative()||r.predictable?e.log():new n(e.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(e){return Wt(e,this)}})})),Gs="log2",Vs=Oe(Gs,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(Gs,{number:function(e){return e>=0||r.predictable?za(e):i(new n(e,0))},Complex:i,BigNumber:function(e){return!e.isNegative()||r.predictable?e.log(2):i(new n(e.toNumber(),0))},"Array | Matrix":function(e){return Wt(e,this)}});function i(e){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new n(Math.log2?Math.log2(t):Math.log(t)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}})),Zs=Oe("map",["typed"],(e=>{var{typed:t}=e;return t("map",{"Array, function":Ws,"Matrix, function":function(e,t){return e.map(t)}})}));function Ws(e,t){var r=Tr(t);return function n(i,a){return Array.isArray(i)?i.map((function(e,t){return n(e,a.concat(t))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e,[])}var Ys=Oe("multiplyScalar",["typed"],(e=>{var{typed:t}=e;return t("multiplyScalar",{"number, number":wa,"Complex, Complex":function(e,t){return e.mul(t)},"BigNumber, BigNumber":function(e,t){return e.times(t)},"Fraction, Fraction":function(e,t){return e.mul(t)},"number | Fraction | BigNumber | Complex, Unit":function(e,t){var r=t.clone();return r.value=null===r.value?r._normalize(e):this(r.value,e),r},"Unit, number | Fraction | BigNumber | Complex":function(e,t){var r=e.clone();return r.value=null===r.value?r._normalize(t):this(r.value,t),r},"Unit, Unit":function(e,t){return e.multiply(t)}})})),Js="number, number";function Xs(e){return!e}function Qs(e,t){return!(!e&&!t)}function Ks(e,t){return!!e!=!!t}function eu(e,t){return!(!e||!t)}Xs.signature="number",Qs.signature=Js,Ks.signature=Js,eu.signature=Js;var tu=Oe("not",["typed"],(e=>{var{typed:t}=e;return t("not",{number:Xs,Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},Unit:function(e){return null===e.value||this(e.value)},"Array | Matrix":function(e){return Wt(e,this)}})}));var ru=Oe("number",["typed"],(e=>{var{typed:t}=e,r=t("number",{"":function(){return 0},number:function(e){return e},string:function(e){if("NaN"===e)return NaN;var t,r,n=(r=(t=e).match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/))?{input:t,radix:{"0b":2,"0o":8,"0x":16}[r[1]],integerPart:r[2],fractionalPart:r[3]}:null;if(n)return function(e){for(var t=parseInt(e.integerPart,e.radix),r=0,n=0;n2**i-1)throw new SyntaxError('String "'.concat(e,'" is out of range'));o>=2**(i-1)&&(o-=2**i)}return o},BigNumber:function(e){return e.toNumber()},Fraction:function(e){return e.valueOf()},Unit:function(e){throw new Error("Second argument with valueless unit expected")},null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":function(e){return Wt(e,this)}});return r.fromJSON=function(e){return parseFloat(e.value)},r})),nu=Oe("oct",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("oct",{"number | BigNumber":function(e){return r(e,{notation:"oct"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"oct",wordSize:t})}})})),iu=r(377),au=iu(Date.now());function ou(e){var t,r;return t=null===(r=e)?au:iu(String(r)),function(){return t()}}var su="pickRandom",uu=Oe(su,["typed","config","?on"],(e=>{var{typed:t,config:r,on:n}=e,i=ou(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(i=ou(e.randomSeed))})),t(su,{"Array | Matrix":function(e){return a(e,{})},"Array | Matrix, Object":function(e,t){return a(e,t)},"Array | Matrix, number":function(e,t){return a(e,{number:t})},"Array | Matrix, Array | Matrix":function(e,t){return a(e,{weights:t})},"Array | Matrix, Array | Matrix, number":function(e,t,r){return a(e,{number:r,weights:t})},"Array | Matrix, number, Array | Matrix":function(e,t,r){return a(e,{number:t,weights:r})}});function a(e,t){var{number:r,weights:n,elementWise:a=!0}=t,o=void 0===r;o&&(r=1);var u=h(e)?e.create:h(n)?n.create:null;e=e.valueOf(),n&&(n=n.valueOf()),!0===a&&(e=ot(e),n=ot(n));var c=0;if(void 0!==n){if(n.length!==e.length)throw new Error("Weights must have the same length as possibles");for(var l=0,f=n.length;l{var{typed:t}=e;return t(cu,{"string, Object | Array":fu,"string, Object | Array, number | Object":fu})}));function fu(e,t,r){return e.replace(/\$([\w.]+)/g,(function(e,n){for(var i=n.split("."),a=t[i.shift()];i.length&&void 0!==a;){var o=i.shift();a=o?a[o]:a+"."}return void 0!==a?p(a)?a:ve(a,r):e}))}function pu(e,t){var r=[];if((e=e.slice(0)).length>1)for(var n=0,i=e.shift();n{var{typed:t,config:r,on:n}=e,i=ou(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(i=ou(e.randomSeed))})),t(mu,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,t)=>o(e,t),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,t)=>a(e,0,t),"Array | Matrix, number, number":(e,t,r)=>a(e,t,r)});function a(e,t,r){var n=pu(e.valueOf(),(()=>o(t,r)));return h(e)?e.create(n):n}function o(e,t){return e+i()*(t-e)}})),du=Oe("re",["typed"],(e=>{var{typed:t}=e;return t("re",{number:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Complex:function(e){return e.re},"Array | Matrix":function(e){return Wt(e,this)}})})),yu=Oe("sec",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("sec",{number:oo,Complex:function(e){return e.sec()},BigNumber:function(e){return new r(1).div(e.cos())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return this(e.value)},"Array | Matrix":function(e){return Wt(e,this)}})})),gu="sign",vu=Oe(gu,["typed","BigNumber","Fraction","complex"],(e=>{var{typed:t,BigNumber:r,complex:n,Fraction:i}=e;return t(gu,{number:Da,Complex:function(e){return 0===e.im?n(Da(e.re)):e.sign()},BigNumber:function(e){return new r(e.cmp(0))},Fraction:function(e){return new i(e.s,1)},"Array | Matrix":function(e){return Wt(e,this,!0)},Unit:function(e){return this(e.value)}})})),xu=Oe("sin",["typed"],(e=>{var{typed:t}=e;return t("sin",{number:Math.sin,Complex:function(e){return e.sin()},BigNumber:function(e){return e.sin()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(e.value)},"Array | Matrix":function(e){return Wt(e,this,!0)}})})),bu=Oe("SparseMatrix",["typed","equalScalar","Matrix"],(e=>{var{typed:t,equalScalar:r,Matrix:n}=e;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!p(t))throw new Error("Invalid datatype: "+t);if(h(e))!function(e,t,r){"SparseMatrix"===t.type?(e._values=t._values?Me(t._values):void 0,e._index=Me(t._index),e._ptr=Me(t._ptr),e._size=Me(t._size),e._datatype=r||t._datatype):a(e,t.valueOf(),r||t._datatype)}(this,e,t);else if(e&&m(e.index)&&m(e.ptr)&&m(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=t||e.datatype;else if(m(e))a(this,e,t);else{if(e)throw new TypeError("Unsupported type of data ("+G(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=t}}function a(e,n,i){e._values=[],e._index=[],e._ptr=[],e._datatype=i;var a=n.length,o=0,s=r,u=0;if(p(i)&&(s=t.find(r,[i,i])||r,u=t.convert(0,i)),a>0){var c=0;do{e._ptr.push(e._index.length);for(var l=0;l");if(1===a.length){t.dimension(0).forEach((function(t,i){Je(t),e.set([t,0],r[i[0]],n)}))}else{var c=t.dimension(0),l=t.dimension(1);c.forEach((function(t,i){Je(t),l.forEach((function(a,o){Je(a),e.set([t,a],r[i[0]][o[0]],n)}))}))}}return e}function l(e,t,r,n){if(r-t==0)return r;for(var i=t;id){for(l=d;lh){if(m){var y=0;for(l=0;ln-1&&(e._values.splice(f,1),e._index.splice(f,1),v++)}e._ptr[l]=e._values.length}return e._size[0]=n,e._size[1]=i,e}function g(e,t,r,n,i){var a,o,s=n[0],u=n[1],c=[];for(a=0;as-1||o>u-1)&&(y(this,Math.max(a+1,s),Math.max(o+1,u),i),s=this._size[0],u=this._size[1]),Je(a,s),Je(o,u);var d=l(a,this._ptr[o],this._ptr[o+1],this._index);return dArray.isArray(e)&&1===e.length?e[0]:e));if(2!==n.length)throw new Error("Only two dimensions matrix are supported");return n.forEach((function(e){if(!s(e)||!V(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+ve(n)+")")})),y(r?this.clone():this,n[0],n[1],t)},i.prototype.reshape=function(e,t){if(!m(e))throw new TypeError("Array expected");if(2!==e.length)throw new Error("Sparse matrices can only be reshaped in two dimensions");e.forEach((function(t){if(!s(t)||!V(t)||t<=-2||0===t)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+ve(e)+")")}));var r=this._size[0]*this._size[1];if(r!==(e=et(e,r))[0]*e[1])throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var n=t?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return n;for(var i=[],a=0;a=n&&w<=a&&y(e._values[b],w-n,g-o)}else{for(var N={},M=v;M "+(this._values?ve(this._values[u],e):"X")}return i},i.prototype.toString=function(){return ve(this.toArray())},i.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},i.prototype.diagonal=function(e){if(e){if(u(e)&&(e=e.toNumber()),!s(e)||!V(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var t=e>0?e:0,r=e<0?-e:0,n=this._size[0],a=this._size[1],o=Math.min(n-r,a-t),c=[],l=[],f=[];f[0]=0;for(var p=t;p0?a:0,g=a<0?-a:0,v=e[0],x=e[1],b=Math.min(v-g,x-y);if(m(n)){if(n.length!==b)throw new Error("Invalid value array length");d=function(e){return n[e]}}else if(h(n)){var w=n.size();if(1!==w.length||w[0]!==b)throw new Error("Invalid matrix length");d=function(e){return n.get([e])}}else d=function(){return n};for(var N=[],M=[],S=[],E=0;E=0&&A=u||i[f]!==t)){var m=n?n[c]:void 0;i.splice(f,0,t),n&&n.splice(f,0,m),i.splice(f<=c?c+1:c,1),n&&n.splice(f<=c?c+1:c,1)}else if(f=u||i[c]!==e)){var h=n?n[f]:void 0;i.splice(c,0,e),n&&n.splice(c,0,h),i.splice(c<=f?f+1:f,1),n&&n.splice(c<=f?f+1:f,1)}}},i}),{isClass:!0}),wu="splitUnit",Nu=Oe(wu,["typed"],(e=>{var{typed:t}=e;return t(wu,{"Unit, Array":function(e,t){return e.splitUnit(t)}})})),Mu="square",Su=Oe(Mu,["typed"],(e=>{var{typed:t}=e;return t(Mu,{number:Ra,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},Fraction:function(e){return e.mul(e)},"Array | Matrix":function(e){return Wt(e,this,!0)},Unit:function(e){return e.pow(2)}})})),Eu="string",Au=Oe(Eu,["typed"],(e=>{var{typed:t}=e;return t(Eu,{"":function(){return""},number:ee,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":function(e){return Wt(e,this)},any:function(e){return String(e)}})})),Ou=Oe("tan",["typed"],(e=>{var{typed:t}=e;return t("tan",{number:Math.tan,Complex:function(e){return e.tan()},BigNumber:function(e){return e.tan()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(e.value)},"Array | Matrix":function(e){return Wt(e,this,!0)}})})),Cu="typeOf",_u=Oe(Cu,["typed"],(e=>{var{typed:t}=e;return t(Cu,{any:G})})),Tu="acosh",Bu=Oe(Tu,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(Tu,{number:function(e){return e>=1||r.predictable?Za(e):e<=-1?new n(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new n(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()},"Array | Matrix":function(e){return Wt(e,this)}})})),qu="acsch",zu=Oe(qu,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(qu,{number:Xa,Complex:function(e){return e.acsch()},BigNumber:function(e){return new r(1).div(e).asinh()},"Array | Matrix":function(e){return Wt(e,this)}})})),ku="asec",Iu=Oe(ku,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(ku,{number:function(e){return e<=-1||e>=1||r.predictable?Qa(e):new n(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new i(1).div(e).acos()},"Array | Matrix":function(e){return Wt(e,this)}})})),Du=Oe("bin",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("bin",{"number | BigNumber":function(e){return r(e,{notation:"bin"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"bin",wordSize:t})}})})),Ru="combinationsWithRep",Uu=Oe(Ru,["typed"],(e=>{var{typed:t}=e;return t(Ru,{"number, number":function(e,t){if(!V(e)||e<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!V(t)||t<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e<1)throw new TypeError("k must be less than or equal to n + k - 1");return t{var{typed:t}=e;return t("cos",{number:Math.cos,Complex:function(e){return e.cos()},BigNumber:function(e){return e.cos()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return this(e.value)},"Array | Matrix":function(e){return Wt(e,this)}})})),ju="csch",Lu=Oe(ju,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(ju,{number:ao,Complex:function(e){return e.csch()},BigNumber:function(e){return new r(1).div(e.sinh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(e.value)},"Array | Matrix":function(e){return Wt(e,this)}})})),Hu="isNaN",$u=Oe(Hu,["typed"],(e=>{var{typed:t}=e;return t(Hu,{number:Ds,BigNumber:function(e){return e.isNaN()},Fraction:function(e){return!1},Complex:function(e){return e.isNaN()},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":function(e){return Wt(e,Number.isNaN)}})})),Gu="isPrime",Vu=Oe(Gu,["typed"],(e=>{var{typed:t}=e;return t(Gu,{number:function(e){if(0*e!=0)return!1;if(e<=3)return e>1;if(e%2==0||e%3==0)return!1;for(var t=5;t*t<=e;t+=6)if(e%t==0||e%(t+2)==0)return!1;return!0},BigNumber:function(e){if(0*e.toNumber()!=0)return!1;if(e.lte(3))return e.gt(1);if(e.mod(2).eq(0)||e.mod(3).eq(0))return!1;if(e.lt(Math.pow(2,32))){for(var t=e.toNumber(),r=5;r*r<=t;r+=6)if(t%r==0||t%(r+2)==0)return!1;return!0}function n(e,t,r){for(var n=1;!t.eq(0);)t.mod(2).eq(0)?(t=t.div(2),e=e.mul(e).mod(r)):(t=t.sub(1),n=e.mul(n).mod(r));return n}for(var i=e.constructor.clone({precision:2*e.toFixed(0).length}),a=0,o=(e=new i(e)).sub(1);o.mod(2).eq(0);)o=o.div(2),a+=1;var s=null;if(e.lt("3317044064679887385961981"))s=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter((t=>t{var{typed:t,config:r,on:n}=e,i=ou(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(i=ou(e.randomSeed))})),t(Zu,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,t)=>o(e,t),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,t)=>a(e,0,t),"Array | Matrix, number, number":(e,t,r)=>a(e,t,r)});function a(e,t,r){var n=pu(e.valueOf(),(()=>o(t,r)));return h(e)?e.create(n):n}function o(e,t){return Math.floor(e+i()*(t-e))}})),Yu="sech",Ju=Oe(Yu,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Yu,{number:so,Complex:function(e){return e.sech()},BigNumber:function(e){return new r(1).div(e.cosh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return this(e.value)},"Array | Matrix":function(e){return Wt(e,this)}})})),Xu="sinh",Qu=Oe(Xu,["typed"],(e=>{var{typed:t}=e;return t(Xu,{number:uo,Complex:function(e){return e.sinh()},BigNumber:function(e){return e.sinh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(e.value)},"Array | Matrix":function(e){return Wt(e,this,!0)}})})),Ku="sparse",ec=Oe(Ku,["typed","SparseMatrix"],(e=>{var{typed:t,SparseMatrix:r}=e;return t(Ku,{"":function(){return new r([])},string:function(e){return new r([],e)},"Array | Matrix":function(e){return new r(e)},"Array | Matrix, string":function(e,t){return new r(e,t)}})})),tc=Oe("sqrt",["config","typed","Complex"],(e=>{var{config:t,typed:r,Complex:n}=e;return r("sqrt",{number:i,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.sqrt():i(e.toNumber())},"Array | Matrix":function(e){return Wt(e,this,!0)},Unit:function(e){return e.pow(.5)}});function i(e){return isNaN(e)?NaN:e>=0||t.predictable?Math.sqrt(e):new n(e,0).sqrt()}})),rc=Oe("tanh",["typed"],(e=>{var{typed:t}=e;return t("tanh",{number:me,Complex:function(e){return e.tanh()},BigNumber:function(e){return e.tanh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(e.value)},"Array | Matrix":function(e){return Wt(e,this,!0)}})})),nc="unaryMinus",ic=Oe(nc,["typed"],(e=>{var{typed:t}=e;return t(nc,{number:Na,Complex:function(e){return e.neg()},BigNumber:function(e){return e.neg()},Fraction:function(e){return e.neg()},Unit:function(e){var t=e.clone();return t.value=this(e.value),t},"Array | Matrix":function(e){return Wt(e,this,!0)}})})),ac="acoth",oc=Oe(ac,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(ac,{number:function(e){return e>=1||e<=-1||r.predictable?Ya(e):new n(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new i(1).div(e).atanh()},"Array | Matrix":function(e){return Wt(e,this)}})})),sc=Oe("cot",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("cot",{number:ro,Complex:function(e){return e.cot()},BigNumber:function(e){return new r(1).div(e.tan())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(e.value)},"Array | Matrix":function(e){return Wt(e,this)}})})),uc=Oe("fraction",["typed","Fraction"],(e=>{var{typed:t,Fraction:r}=e;return t("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw new Error(e+" cannot be represented as a fraction");return new r(e)},string:function(e){return new r(e)},"number, number":function(e,t){return new r(e,t)},null:function(e){return new r(0)},BigNumber:function(e){return new r(e.toString())},Fraction:function(e){return e},Object:function(e){return new r(e)},"Array | Matrix":function(e){return Wt(e,this)}})})),cc="isNumeric",lc=Oe(cc,["typed"],(e=>{var{typed:t}=e;return t(cc,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(e){return Wt(e,this)}})})),fc="matrix",pc=Oe(fc,["typed","Matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,Matrix:r,DenseMatrix:n,SparseMatrix:i}=e;return t(fc,{"":function(){return a([])},string:function(e){return a([],e)},"string, string":function(e,t){return a([],e,t)},Array:function(e){return a(e)},Matrix:function(e){return a(e,e.storage())},"Array | Matrix, string":a,"Array | Matrix, string, string":a});function a(e,t,r){if("dense"===t||"default"===t||void 0===t)return new n(e,r);if("sparse"===t)return new i(e,r);throw new TypeError("Unknown matrix type "+JSON.stringify(t)+".")}})),mc="matrixFromFunction",hc=Oe(mc,["typed","matrix","isZero"],(e=>{var{typed:t,matrix:r,isZero:n}=e;return t(mc,{"Array | Matrix, function, string, string":function(e,t,r,n){return i(e,t,r,n)},"Array | Matrix, function, string":function(e,t,r){return i(e,t,r)},"Matrix, function":function(e,t){return i(e,t,"dense")},"Array, function":function(e,t){return i(e,t,"dense").toArray()},"Array | Matrix, string, function":function(e,t,r){return i(e,r,t)},"Array | Matrix, string, string, function":function(e,t,r,n){return i(e,n,t,r)}});function i(e,t,i,a){var o;return(o=void 0!==a?r(i,a):r(i)).resize(e),o.forEach((function(e,r){var i=t(r);n(i)||o.set(r,i)})),o}})),dc=Oe("algorithm02",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i,a){var o=e._data,s=e._size,u=e._datatype,c=n._values,l=n._index,f=n._ptr,p=n._size,m=n._datatype;if(s.length!==p.length)throw new Ge(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h,d=s[0],y=s[1],g=r,v=0,x=i;"string"==typeof u&&u===m&&(h=u,g=t.find(r,[h,h]),v=t.convert(0,h),x=t.find(i,[h,h]));for(var b=[],w=[],N=[],M=0;M{var{typed:t}=e;return function(e,r,n,i){var a=e._data,o=e._size,s=e._datatype,u=r._values,c=r._index,l=r._ptr,f=r._size,p=r._datatype;if(o.length!==f.length)throw new Ge(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m,h=o[0],d=o[1],y=0,g=n;"string"==typeof s&&s===p&&(m=s,y=t.convert(0,m),g=t.find(n,[m,m]));for(var v=[],x=0;x{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ge(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E=a&&l?[]:void 0,A=[],O=[],C=E?[]:void 0,_=E?[]:void 0,T=[],B=[];for(N=0;N{var{typed:t,equalScalar:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=r,d=0,y=i;"string"==typeof l&&(f=l,h=t.find(r,[f,f]),d=t.convert(0,f),n=t.convert(n,f),y=t.find(i,[f,f]));for(var g=[],v=[],x=[],b=0;b{var{typed:t,DenseMatrix:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=i;"string"==typeof l&&(f=l,n=t.convert(n,f),h=t.find(i,[f,f]));for(var d=[],y=[],g=[],v=0;v{var{typed:t}=e;return function(e,n,i){var a,o=e._data,s=e._size,u=e._datatype,c=n._data,l=n._size,f=n._datatype,p=[];if(s.length!==l.length)throw new Ge(s.length,l.length);for(var m=0;m0?r(h,0,p,p[0],o,c):[];return e.createDenseMatrix({data:d,size:p,datatype:a})};function r(e,t,n,i,a,o){var s=[];if(t===n.length-1)for(var u=0;u{var{typed:t}=e;return function(e,n,i,a){var o,s=e._data,u=e._size,c=e._datatype,l=i;"string"==typeof c&&(o=c,n=t.convert(n,o),l=t.find(i,[o,o]));var f=u.length>0?r(l,0,u,u[0],s,n,a):[];return e.createDenseMatrix({data:f,size:Me(u),datatype:o})};function r(e,t,n,i,a,o,s){var u=[];if(t===n.length-1)for(var c=0;c{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=dc({typed:t,equalScalar:n}),o=yc({typed:t}),s=gc({typed:t,equalScalar:n}),u=vc({typed:t,equalScalar:n}),c=xc({typed:t,DenseMatrix:i}),l=bc({typed:t}),f=wc({typed:t});return t("mod",{"number, number":ka,"BigNumber, BigNumber":function(e,t){if(t.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return t.isZero()?e:e.mod(t)},"Fraction, Fraction":function(e,t){if(t.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return e.compare(0)>=0?e.mod(t):e.mod(t).add(t).mod(t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return f(e,t,this,!1)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return f(t,e,this,!0)},"Array, any":function(e,t){return f(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return f(r(t),e,this,!0).valueOf()}})})),Mc=Oe("algorithm01",["typed"],(e=>{var{typed:t}=e;return function(e,r,n,i){var a=e._data,o=e._size,s=e._datatype,u=r._values,c=r._index,l=r._ptr,f=r._size,p=r._datatype;if(o.length!==f.length)throw new Ge(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m,h,d=o[0],y=o[1],g="string"==typeof s&&s===p?s:void 0,v=g?t.find(n,[g,g]):n,x=[];for(m=0;m{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._size,s=e._datatype,u=n._values,c=n._size,l=n._datatype;if(o.length!==c.length)throw new Ge(o.length,c.length);if(o[0]!==c[0]||o[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+c+")");var f,p=o[0],m=o[1],h=r,d=0,y=i;"string"==typeof s&&s===l&&(f=s,h=t.find(r,[f,f]),d=t.convert(0,f),y=t.find(i,[f,f]));for(var g=a&&u?[]:void 0,v=[],x=[],b=g?[]:void 0,w=[],N=[],M=0;M{var{typed:t,matrix:r,equalScalar:n,BigNumber:i}=e,a=Mc({typed:t}),o=dc({typed:t,equalScalar:n}),s=Sc({typed:t,equalScalar:n}),u=vc({typed:t,equalScalar:n}),c=bc({typed:t}),l=wc({typed:t}),f="Complex number not supported in function nthRoot. Use nthRoots instead.";return t(Ec,{number:function(e){return Ia(e,2)},"number, number":Ia,BigNumber:function(e){return p(e,new i(2))},Complex:function(e){throw new Error(f)},"Complex, number":function(e,t){throw new Error(f)},"BigNumber, BigNumber":p,"Array | Matrix":function(e){return this(e,2)},"SparseMatrix, SparseMatrix":function(e,t){if(1===t.density())return s(e,t,this);throw new Error("Root must be non-zero")},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){if(1===t.density())return a(e,t,this,!1);throw new Error("Root must be non-zero")},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){if(1===t.density())return u(t,e,this,!0);throw new Error("Root must be non-zero")},"number | BigNumber, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}});function p(e,t){var r=i.precision,n=i.clone({precision:r+2}),a=new i(0),o=new n(1),s=t.isNegative();if(s&&(t=t.neg()),t.isZero())throw new Error("Root must be non-zero");if(e.isNegative()&&!t.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(e.isZero())return s?new n(1/0):0;if(!e.isFinite())return s?a:e;var u=e.abs().pow(o.div(t));return u=e.isNeg()?u.neg():u,new i((s?o.div(u):u).toPrecision(r))}})),Oc=Oe("numeric",["number","?bignumber","?fraction"],(e=>{var{number:t,bignumber:r,fraction:n}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},a={number:e=>t(e),BigNumber:r?e=>r(e):lr,Fraction:n?e=>n(e):fr};return function(e,t){var r=G(e);if(!(r in i))throw new TypeError("Cannot convert "+e+' of type "'+r+'"; valid input types are '+Object.keys(i).join(", "));if(!(t in a))throw new TypeError("Cannot convert "+e+' to type "'+t+'"; valid output types are '+Object.keys(a).join(", "));return t===r?e:a[t](e)}})),Cc=Oe("or",["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=yc({typed:t}),o=gc({typed:t,equalScalar:n}),s=xc({typed:t,DenseMatrix:i}),u=bc({typed:t}),c=wc({typed:t});return t("or",{"number, number":Qs,"Complex, Complex":function(e,t){return 0!==e.re||0!==e.im||0!==t.re||0!==t.im},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!e.isNaN()||!t.isZero()&&!t.isNaN()},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})})),_c="prod",Tc=Oe(_c,["typed","config","multiplyScalar","numeric"],(e=>{var{typed:t,config:r,multiplyScalar:n,numeric:i}=e;return t(_c,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("prod(A, dim) is not yet supported")},"...":function(e){return a(e)}});function a(e){var t;if(Zt(e,(function(e){try{t=void 0===t?e:n(t,e)}catch(t){throw an(t,"prod",e)}})),"string"==typeof t&&(t=i(t,r.number)),void 0===t)throw new Error("Cannot calculate prod of an empty array");return t}})),Bc="reshape",qc=Oe(Bc,["typed","isInteger","matrix"],(e=>{var{typed:t,isInteger:r}=e;return t(Bc,{"Matrix, Array":function(e,t){return e.reshape(t)},"Array, Array":function(e,t){return t.forEach((function(e){if(!r(e))throw new TypeError("Invalid size for dimension: "+e)})),Ke(e,t)}})})),zc="size",kc=Oe(zc,["typed","config","?matrix"],(e=>{var{typed:t,config:r,matrix:n}=e;return t(zc,{Matrix:function(e){return e.create(e.size())},Array:Ze,string:function(e){return"Array"===r.matrix?[e.length]:n([e.length])},"number | Complex | BigNumber | Unit | boolean | null":function(e){return"Array"===r.matrix?[]:n?n([]):pr()}})})),Ic=Oe("algorithm07",["typed","DenseMatrix"],(e=>{var{typed:t,DenseMatrix:r}=e;return function(e,i,a){var o=e._size,s=e._datatype,u=i._size,c=i._datatype;if(o.length!==u.length)throw new Ge(o.length,u.length);if(o[0]!==u[0]||o[1]!==u[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+u+")");var l,f,p,m=o[0],h=o[1],d=0,y=a;"string"==typeof s&&s===c&&(l=s,d=t.convert(0,l),y=t.find(a,[l,l]));var g=[];for(f=0;f{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=yc({typed:t}),o=Ic({typed:t,DenseMatrix:i}),s=xc({typed:t,DenseMatrix:i}),u=bc({typed:t}),c=wc({typed:t});return t(Dc,{"boolean, boolean":function(e,t){return e{var{typed:t,matrix:r}=e;return t(Uc,{Array:function(e){return rt(Me(e))},Matrix:function(e){var t=rt(e.toArray());return Array.isArray(t)?r(t):t},any:function(e){return Me(e)}})})),Pc=Oe("algorithm10",["typed","DenseMatrix"],(e=>{var{typed:t,DenseMatrix:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=i;"string"==typeof l&&(f=l,n=t.convert(n,f),h=t.find(i,[f,f]));for(var d=[],y=[],g=[],v=0;v{var{typed:t,matrix:r,equalScalar:n,addScalar:i,unaryMinus:a,DenseMatrix:o}=e,s=Mc({typed:t}),u=yc({typed:t}),c=gc({typed:t,equalScalar:n}),l=Pc({typed:t,DenseMatrix:o}),f=bc({typed:t}),p=wc({typed:t});return t(jc,{"number, number":function(e,t){return e-t},"Complex, Complex":function(e,t){return e.sub(t)},"BigNumber, BigNumber":function(e,t){return e.minus(t)},"Fraction, Fraction":function(e,t){return e.sub(t)},"Unit, Unit":function(e,t){if(null===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var r=e.clone();return r.value=this(r.value,t.value),r.fixPrefix=!1,r},"SparseMatrix, SparseMatrix":function(e,t){return Hc(e,t),c(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return Hc(e,t),u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return Hc(e,t),s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return Hc(e,t),f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return l(e,a(t),i)},"DenseMatrix, any":function(e,t){return p(e,t,this)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(r(t),e,this,!0).valueOf()}})}));function Hc(e,t){var r=e.size(),n=t.size();if(r.length!==n.length)throw new Ge(r.length,n.length)}var $c=Oe("to",["typed","matrix"],(e=>{var{typed:t,matrix:r}=e,n=bc({typed:t}),i=wc({typed:t});return t("to",{"Unit, Unit | string":function(e,t){return e.to(t)},"Matrix, Matrix":function(e,t){return n(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"Matrix, any":function(e,t){return i(e,t,this,!1)},"any, Matrix":function(e,t){return i(t,e,this,!0)},"Array, any":function(e,t){return i(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return i(r(t),e,this,!0).valueOf()}})})),Gc=Oe("transpose",["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t("transpose",{Array:function(e){return this(r(e)).valueOf()},Matrix:function(e){var t,r=e.size();switch(r.length){case 1:t=e.clone();break;case 2:var n=r[0],i=r[1];if(0===i)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+ve(r)+")");switch(e.storage()){case"dense":t=function(e,t,r){for(var n,i=e._data,a=[],o=0;o{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t(Vc,{"number, number":function(e,t){var i=Ua(e,t);return"Array"===r.matrix?i:n(i)},"BigNumber, BigNumber":function(e,t){var a,o,s,u,c=new i(0),l=new i(1),f=c,p=l,m=l,h=c;if(!e.isInt()||!t.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!t.isZero();)o=e.div(t).floor(),s=e.mod(t),a=f,f=p.minus(o.times(f)),p=a,a=m,m=h.minus(o.times(m)),h=a,e=t,t=s;u=e.lt(c)?[e.neg(),p.neg(),h.neg()]:[e,e.isZero()?0:p,h];return"Array"===r.matrix?u:n(u)}})})),Wc="zeros",Yc=Oe(Wc,["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t(Wc,{"":function(){return"Array"===r.matrix?a([]):a([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return a(e,t)}return"Array"===r.matrix?a(e):a(e,"default")},Array:a,Matrix:function(e){var t=e.storage();return a(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return a(e.valueOf(),t)}});function a(e,t){var r=function(e){var t=!1;return e.forEach((function(e,r,n){u(e)&&(t=!0,n[r]=e.toNumber())})),t}(e),a=r?new i(0):0;if(function(e){e.forEach((function(e){if("number"!=typeof e||!V(e)||e<0)throw new Error("Parameters in function zeros must be positive integers")}))}(e),t){var o=n(t);return e.length>0?o.resize(e,a):o}var s=[];return e.length>0?Xe(s,e,a):s}})),Jc=Oe("and",["typed","matrix","equalScalar","zeros","not"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,not:a}=e,o=dc({typed:t,equalScalar:n}),s=Sc({typed:t,equalScalar:n}),u=vc({typed:t,equalScalar:n}),c=bc({typed:t}),l=wc({typed:t});return t("and",{"number, number":eu,"Complex, Complex":function(e,t){return!(0===e.re&&0===e.im||0===t.re&&0===t.im)},"BigNumber, BigNumber":function(e,t){return!(e.isZero()||t.isZero()||e.isNaN()||t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return a(t)?i(e.size(),e.storage()):u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return a(t)?i(e.size(),e.storage()):l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return a(e)?i(e.size(),e.storage()):u(t,e,this,!0)},"any, DenseMatrix":function(e,t){return a(e)?i(e.size(),e.storage()):l(t,e,this,!0)},"Array, any":function(e,t){return this(r(e),t).valueOf()},"any, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Xc="bitAnd",Qc=Oe(Xc,["typed","matrix","equalScalar"],(e=>{var{typed:t,matrix:r,equalScalar:n}=e,i=dc({typed:t,equalScalar:n}),a=Sc({typed:t,equalScalar:n}),o=vc({typed:t,equalScalar:n}),s=bc({typed:t}),u=wc({typed:t});return t(Xc,{"number, number":zo,"BigNumber, BigNumber":So,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),Kc="bitXor",el=Oe(Kc,["typed","matrix","DenseMatrix"],(e=>{var{typed:t,matrix:r,DenseMatrix:n}=e,i=yc({typed:t}),a=Ic({typed:t,DenseMatrix:n}),o=xc({typed:t,DenseMatrix:n}),s=bc({typed:t}),u=wc({typed:t});return t(Kc,{"number, number":Do,"BigNumber, BigNumber":_o,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),tl="cbrt",rl=Oe(tl,["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],(e=>{var{config:t,typed:r,isNegative:n,unaryMinus:i,matrix:a,Complex:o,BigNumber:s,Fraction:f}=e;return r(tl,{number:Sa,Complex:p,"Complex, boolean":p,BigNumber:function(e){return e.cbrt()},Unit:function(e){if(e.value&&c(e.value)){var t=e.clone();return t.value=1,(t=t.pow(1/3)).value=p(e.value),t}var r,a=n(e.value);a&&(e.value=i(e.value)),r=u(e.value)?new s(1).div(3):l(e.value)?new f(1,3):1/3;var o=e.pow(r);return a&&(o.value=i(o.value)),o},"Array | Matrix":function(e){return Wt(e,this,!0)}});function p(e,r){var n=e.arg()/3,i=e.abs(),s=new o(Sa(i),0).mul(new o(0,n).exp());if(r){var u=[s,new o(Sa(i),0).mul(new o(0,n+2*Math.PI/3).exp()),new o(Sa(i),0).mul(new o(0,n-2*Math.PI/3).exp())];return"Array"===t.matrix?u:a(u)}return s}})),nl="compare",il=Oe(nl,["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],(e=>{var{typed:t,config:r,equalScalar:n,matrix:i,BigNumber:a,Fraction:o,DenseMatrix:s}=e,u=yc({typed:t}),c=gc({typed:t,equalScalar:n}),l=xc({typed:t,DenseMatrix:s}),f=bc({typed:t}),p=wc({typed:t});return t(nl,{"boolean, boolean":function(e,t){return e===t?0:e>t?1:-1},"number, number":function(e,t){return se(e,t,r.epsilon)?0:e>t?1:-1},"BigNumber, BigNumber":function(e,t){return ss(e,t,r.epsilon)?new a(0):new a(e.cmp(t))},"Fraction, Fraction":function(e,t){return new o(e.compare(t))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return c(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(i(e),i(t)).valueOf()},"Array, Matrix":function(e,t){return this(i(e),t)},"Matrix, Array":function(e,t){return this(e,i(t))},"SparseMatrix, any":function(e,t){return l(e,t,this,!1)},"DenseMatrix, any":function(e,t){return p(e,t,this,!1)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(i(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(i(t),e,this,!0).valueOf()}})})),al="compareText",ol=Oe(al,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e,n=bc({typed:t}),i=wc({typed:t});return t(al,{"any, any":Ne,"DenseMatrix, DenseMatrix":function(e,t){return n(e,t,Ne)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"DenseMatrix, any":function(e,t){return i(e,t,Ne,!1)},"any, DenseMatrix":function(e,t){return i(t,e,Ne,!0)},"Array, any":function(e,t){return i(r(e),t,Ne,!1).valueOf()},"any, Array":function(e,t){return i(r(t),e,Ne,!0).valueOf()}})})),sl="count",ul=Oe(sl,["typed","size","prod"],(e=>{var{typed:t,size:r,prod:n}=e;return t(sl,{string:function(e){return e.length},"Matrix | Array":function(e){return n(r(e))}})})),cl="ctranspose",ll=Oe(cl,["typed","transpose","conj"],(e=>{var{typed:t,transpose:r,conj:n}=e;return t(cl,{any:function(e){return n(r(e))}})})),fl="diag",pl=Oe(fl,["typed","matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:r,DenseMatrix:n,SparseMatrix:i}=e;return t(fl,{Array:function(e){return a(e,0,Ze(e),null)},"Array, number":function(e,t){return a(e,t,Ze(e),null)},"Array, BigNumber":function(e,t){return a(e,t.toNumber(),Ze(e),null)},"Array, string":function(e,t){return a(e,0,Ze(e),t)},"Array, number, string":function(e,t,r){return a(e,t,Ze(e),r)},"Array, BigNumber, string":function(e,t,r){return a(e,t.toNumber(),Ze(e),r)},Matrix:function(e){return a(e,0,e.size(),e.storage())},"Matrix, number":function(e,t){return a(e,t,e.size(),e.storage())},"Matrix, BigNumber":function(e,t){return a(e,t.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,t){return a(e,0,e.size(),t)},"Matrix, number, string":function(e,t,r){return a(e,t,e.size(),r)},"Matrix, BigNumber, string":function(e,t,r){return a(e,t.toNumber(),e.size(),r)}});function a(e,t,a,o){if(!V(t))throw new TypeError("Second parameter in function diag must be an integer");var s=t>0?t:0,u=t<0?-t:0;switch(a.length){case 1:return function(e,t,r,a,o,s){var u=[a+o,a+s];if(r&&"sparse"!==r&&"dense"!==r)throw new TypeError("Unknown matrix type ".concat(r,'"'));var c="sparse"===r?i.diagonal(u,e,t):n.diagonal(u,e,t);return null!==r?c:c.valueOf()}(e,t,o,a[0],u,s);case 2:return function(e,t,n,i,a,o){if(h(e)){var s=e.diagonal(t);return null!==n?n!==s.storage()?r(s,n):s:s.valueOf()}for(var u=Math.min(i[0]-a,i[1]-o),c=[],l=0;l{var{typed:t,numeric:r}=e;return t(ml,{"number, number":function(e,t){return e/t},"Complex, Complex":function(e,t){return e.div(t)},"BigNumber, BigNumber":function(e,t){return e.div(t)},"Fraction, Fraction":function(e,t){return e.div(t)},"Unit, number | Fraction | BigNumber":function(e,t){var n=e.clone(),i=r(1,G(t));return n.value=this(null===n.value?n._normalize(i):n.value,t),n},"number | Fraction | BigNumber, Unit":function(e,t){var n=t.clone();n=n.pow(-1);var i=r(1,G(e));return n.value=this(e,null===t.value?t._normalize(i):t.value),n},"Unit, Unit":function(e,t){return e.divide(t)}})})),dl="dotDivide",yl=Oe(dl,["typed","matrix","equalScalar","divideScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,divideScalar:i,DenseMatrix:a}=e,o=dc({typed:t,equalScalar:n}),s=yc({typed:t}),u=Ic({typed:t,DenseMatrix:a}),c=vc({typed:t,equalScalar:n}),l=xc({typed:t,DenseMatrix:a}),f=bc({typed:t}),p=wc({typed:t});return t(dl,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,i)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return c(e,t,i,!1)},"DenseMatrix, any":function(e,t){return p(e,t,i,!1)},"any, SparseMatrix":function(e,t){return l(t,e,i,!0)},"any, DenseMatrix":function(e,t){return p(t,e,i,!0)},"Array, any":function(e,t){return p(r(e),t,i,!1).valueOf()},"any, Array":function(e,t){return p(r(t),e,i,!0).valueOf()}})})),gl="equal",vl=Oe(gl,["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=yc({typed:t}),o=Ic({typed:t,DenseMatrix:i}),s=xc({typed:t,DenseMatrix:i}),u=bc({typed:t}),c=wc({typed:t});return t(gl,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:n(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,n)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,n,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,n,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,n)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,n,!1)},"DenseMatrix, any":function(e,t){return c(e,t,n,!1)},"any, SparseMatrix":function(e,t){return s(t,e,n,!0)},"any, DenseMatrix":function(e,t){return c(t,e,n,!0)},"Array, any":function(e,t){return c(r(e),t,n,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,n,!0).valueOf()}})})),xl=(Oe(gl,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return t(gl,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:r(e,t)}})})),"flatten"),bl=Oe(xl,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t(xl,{Array:function(e){return ot(Me(e))},Matrix:function(e){var t=ot(Me(e.toArray()));return r(t)}})})),wl=Oe("algorithm04",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ge(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E,A=a&&l?[]:void 0,O=[],C=[],_=a&&l?[]:void 0,T=a&&l?[]:void 0,B=[],q=[];for(N=0;N{var{typed:t,matrix:r,equalScalar:n,BigNumber:i,DenseMatrix:a}=e,o=Mc({typed:t}),s=wl({typed:t,equalScalar:n}),u=Pc({typed:t,DenseMatrix:a}),c=bc({typed:t}),l=wc({typed:t});return t("gcd",{"number, number":_a,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function gcd must be integer numbers");var r=new i(0);for(;!t.isZero();){var n=e.mod(t);e=t,t=n}return e.lt(r)?e.neg():e},"Fraction, Fraction":function(e,t){return e.gcd(t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return u(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return l(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return l(r(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,isNumeric:r}=e;return t(Ml,{string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return r(e)}})})),El="hypot",Al=Oe(El,["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],(e=>{var{typed:t,abs:r,addScalar:n,divideScalar:i,multiplyScalar:a,sqrt:o,smaller:s,isPositive:u}=e;return t(El,{"... number | BigNumber":function(e){for(var t=0,c=0,l=0;l{var{smaller:t,DenseMatrix:r}=e;function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!p(t))throw new Error("Invalid datatype: "+t);if(h(e)||m(e)){var i=new r(e,t);this._data=i._data,this._size=i._size,this._datatype=i._datatype,this._min=null,this._max=null}else if(e&&m(e.data)&&m(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=void 0!==e.min?e.min:null,this._max=void 0!==e.max?e.max:null;else{if(e)throw new TypeError("Unsupported type of data ("+G(e)+")");this._data=[],this._size=[0],this._datatype=t,this._min=null,this._max=null}}return n.prototype=new r,n.prototype.type="ImmutableDenseMatrix",n.prototype.isImmutableDenseMatrix=!0,n.prototype.subset=function(e){switch(arguments.length){case 1:var t=r.prototype.subset.call(this,e);return h(t)?new n({data:t._data,size:t._size,datatype:t._datatype}):t;case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},n.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},n.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},n.prototype.clone=function(){return new n({data:Me(this._data),size:Me(this._size),datatype:this._datatype})},n.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.fromJSON=function(e){return new n(e)},n.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},n.prototype.min=function(){if(null===this._min){var e=null;this.forEach((function(r){(null===e||t(r,e))&&(e=r)})),this._min=null!==e?e:void 0}return this._min},n.prototype.max=function(){if(null===this._max){var e=null;this.forEach((function(r){(null===e||t(e,r))&&(e=r)})),this._max=null!==e?e:void 0}return this._max},n}),{isClass:!0}),Cl=Oe("Index",["ImmutableDenseMatrix"],(e=>{var{ImmutableDenseMatrix:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var t=0,i=arguments.length;t{var{typed:t,matrix:r,multiplyScalar:n}=e;return t(_l,{"Matrix, Matrix":function(e,t){return r(i(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(i(e.toArray(),t))},"Array, Matrix":function(e,t){return r(i(e,t.toArray()))},"Array, Array":i});function i(e,t){if(1===Ze(e).length&&(e=[e]),1===Ze(t).length&&(t=[t]),Ze(e).length>2||Ze(t).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(e.length)+", y = "+JSON.stringify(t.length)+")");var r=[],i=[];return e.map((function(e){return t.map((function(t){return i=[],r.push(i),e.map((function(e){return t.map((function(t){return i.push(n(e,t))}))}))}))}))&&r}})),Bl="largerEq",ql=Oe(Bl,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=yc({typed:t}),o=Ic({typed:t,DenseMatrix:i}),s=xc({typed:t,DenseMatrix:i}),u=bc({typed:t}),c=wc({typed:t});return t(Bl,{"boolean, boolean":function(e,t){return e>=t},"number, number":function(e,t){return e>=t||se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gte(t)||ss(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return-1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),zl=Oe("algorithm08",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ge(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");if(!a||!l)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));for(var w,N,M,S,E=[],A=[],O=[],C=[],_=[],T=0;T{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Mc({typed:t}),s=dc({typed:t,equalScalar:n}),u=zl({typed:t,equalScalar:n}),c=Pc({typed:t,DenseMatrix:a}),l=vc({typed:t,equalScalar:n}),f=bc({typed:t}),p=wc({typed:t});return t(kl,{"number, number":Ro,"BigNumber, BigNumber":To,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})}));function Dl(e){var{DenseMatrix:t}=e;return function(e,r,n){var i=e.size();if(2!==i.length)throw new RangeError("Matrix must be two dimensional (size: "+ve(i)+")");var a=i[0];if(a!==i[1])throw new RangeError("Matrix must be square (size: "+ve(i)+")");var o=[];if(h(r)){var s=r.size(),u=r._data;if(1===s.length){if(s[0]!==a)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var c=0;c{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=Dl({DenseMatrix:s});return t(Rl,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=(t=u(e,t,!0))._data,c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=[],d=0;dd&&(v.push(f[N]),x.push(M))}if(o(g,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var S=n(y,g),E=0,A=x.length;E{var{typed:t,matrix:r,flatten:n,size:i}=e;return t(Fl,{"...Array":function(e){return a(e)},"...Matrix":function(e){return r(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one column is needed to construct a matrix.");for(var t=o(e[0]),r=[],i=0;i{var{typed:t,isNaN:r,isNumeric:n}=e;return t(jl,{"Array | Matrix":i,"...":function(e){return i(e)}});function i(e){if(0===(e=ot(e.valueOf())).length)throw new Error("Cannot calculate mode of an empty array");for(var t={},i=[],a=0,o=0;oa&&(a=t[s],i=[s])}return i}})),Hl="nthRoots",$l=Oe(Hl,["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,Complex:i}=e,a=[function(e){return new i(e,0)},function(e){return new i(0,e)},function(e){return new i(-e,0)},function(e){return new i(0,-e)}];function o(e,t){if(t<0)throw new Error("Root must be greater than zero");if(0===t)throw new Error("Root must be non-zero");if(t%1!=0)throw new Error("Root must be an integer");if(0===e||0===e.abs())return[new i(0,0)];var r,n="number"==typeof e;(n||0===e.re||0===e.im)&&(r=n?2*+(e<0):0===e.im?2*+(e.re<0):2*+(e.im<0)+1);for(var o=e.arg(),s=e.abs(),u=[],c=Math.pow(s,1/t),l=0;l{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t("ones",{"":function(){return"Array"===r.matrix?a([]):a([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return a(e,t)}return"Array"===r.matrix?a(e):a(e,"default")},Array:a,Matrix:function(e){var t=e.storage();return a(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return a(e.valueOf(),t)}});function a(e,t){var r=function(e){var t=!1;return e.forEach((function(e,r,n){u(e)&&(t=!0,n[r]=e.toNumber())})),t}(e),a=r?new i(1):1;if(function(e){e.forEach((function(e){if("number"!=typeof e||!V(e)||e<0)throw new Error("Parameters in function ones must be positive integers")}))}(e),t){var o=n(t);return e.length>0?o.resize(e,a):o}var s=[];return e.length>0?Xe(s,e,a):s}})),Vl="partitionSelect",Zl=Oe(Vl,["typed","isNumeric","isNaN","compare"],(e=>{var{typed:t,isNumeric:r,isNaN:n,compare:i}=e,a=i,o=(e,t)=>-i(e,t);return t(Vl,{"Array | Matrix, number":function(e,t){return s(e,t,a)},"Array | Matrix, number, string":function(e,t,r){if("asc"===r)return s(e,t,a);if("desc"===r)return s(e,t,o);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":s});function s(e,t,r){if(!V(t)||t<0)throw new Error("k must be a non-negative integer");if(h(e)){if(e.size().length>1)throw new Error("Only one dimensional matrices supported");return u(e.valueOf(),t,r)}if(Array.isArray(e))return u(e,t,r)}function u(e,t,i){if(t>=e.length)throw new Error("k out of bounds");for(var a=0;a=0){var f=e[c];e[c]=e[u],e[u]=f,--c}else++u;i(e[u],l)>0&&--u,t<=u?s=u:o=u+1}return e[t]}}));function Wl(e,t,r,n){if(!(this instanceof Wl))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=t,this.min=r,this.max=n,this.message="Wrong number of arguments in function "+e+" ("+t+" provided, "+r+(null!=n?"-"+n:"")+" expected)",this.stack=(new Error).stack}Wl.prototype=new Error,Wl.prototype.constructor=Error,Wl.prototype.name="ArgumentsError",Wl.prototype.isArgumentsError=!0;var Yl=Oe("resize",["config","matrix"],(e=>{var{config:t,matrix:r}=e;return function(e,i,a){if(2!==arguments.length&&3!==arguments.length)throw new Wl("resize",arguments.length,2,3);if(h(i)&&(i=i.valueOf()),u(i[0])&&(i=i.map((function(e){return u(e)?e.toNumber():e}))),h(e))return e.resize(i,a,!0);if("string"==typeof e)return n(e,i,a);var o=!Array.isArray(e)&&"Array"!==t.matrix;if(0===i.length){for(;Array.isArray(e);)e=e[0];return Me(e)}Array.isArray(e)||(e=[e]);var s=Xe(e=Me(e),i,a);return o?r(s):s};function n(e,t,r){if(void 0!==r){if("string"!=typeof r||1!==r.length)throw new TypeError("Single character expected as defaultValue")}else r=" ";if(1!==t.length)throw new Ge(t.length,1);var n=t[0];if("number"!=typeof n||!V(n))throw new TypeError("Invalid size, must contain positive integers (size: "+ve(t)+")");if(e.length>n)return e.substring(0,n);if(e.length{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Mc({typed:t}),s=dc({typed:t,equalScalar:n}),u=zl({typed:t,equalScalar:n}),c=Pc({typed:t,DenseMatrix:a}),l=vc({typed:t,equalScalar:n}),f=bc({typed:t}),p=wc({typed:t});return t(Jl,{"number, number":Fo,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})}));function Ql(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Kl(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ef(e){for(var t=1;t{var{typed:t,matrix:r,equalScalar:n,zeros:i,BigNumber:a,DenseMatrix:o}=e,s=vc({typed:t,equalScalar:n}),u=xc({typed:t,DenseMatrix:o}),c=wc({typed:t});return t(rf,ef(ef({},af),{},{Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw new TypeError(tf);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(tf);var r=t.toNumber();return e.round(r)},"number, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(tf);return new a(e).toDecimalPlaces(t.toNumber())},BigNumber:function(e){return e.toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(tf);return e.toDecimalPlaces(t.toNumber())},Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw new TypeError(tf);return e.round(t)},"Array | Matrix":function(e){return Wt(e,this,!0)},"SparseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | Complex | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):u(t,e,this,!0)},"number | Complex | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return c(r(e),t,this,!1).valueOf()},"number | Complex | BigNumber, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}}))})),af={number:Pa,"number, number":function(e,t){if(!V(t))throw new TypeError(tf);if(t<0||t>15)throw new Error("Number of decimals in function round must be in the range of 0-15");return Pa(e,t)}},of="smallerEq",sf=Oe(of,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=yc({typed:t}),o=Ic({typed:t,DenseMatrix:i}),s=xc({typed:t,DenseMatrix:i}),u=bc({typed:t}),c=wc({typed:t});return t(of,{"boolean, boolean":function(e,t){return e<=t},"number, number":function(e,t){return e<=t||se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.lte(t)||ss(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return 1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),uf="unequal",cf=Oe(uf,["typed","config","equalScalar","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,equalScalar:n,matrix:i,DenseMatrix:a}=e,o=yc({typed:t}),s=Ic({typed:t,DenseMatrix:a}),u=xc({typed:t,DenseMatrix:a}),c=bc({typed:t}),l=wc({typed:t});return t("unequal",{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:f(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,f)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,f,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,f,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,f)},"Array, Array":function(e,t){return this(i(e),i(t)).valueOf()},"Array, Matrix":function(e,t){return this(i(e),t)},"Matrix, Array":function(e,t){return this(e,i(t))},"SparseMatrix, any":function(e,t){return u(e,t,f,!1)},"DenseMatrix, any":function(e,t){return l(e,t,f,!1)},"any, SparseMatrix":function(e,t){return u(t,e,f,!0)},"any, DenseMatrix":function(e,t){return l(t,e,f,!0)},"Array, any":function(e,t){return l(i(e),t,f,!1).valueOf()},"any, Array":function(e,t){return l(i(t),e,f,!0).valueOf()}});function f(e,t){return!n(e,t)}})),lf=(Oe(uf,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return t(uf,{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:!r(e,t)}})})),"usolve"),ff=Oe(lf,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=Dl({DenseMatrix:s});return t(lf,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=(t=u(e,t,!0))._data,c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=[],d=l-1;d>=0;d--){var y=r[d][0]||0;if(o(y,0))h[d]=[0];else{for(var g=0,v=[],x=[],b=m[d],w=m[d+1]-1;w>=b;w--){var N=p[w];N===d?g=f[w]:N=0;m--){var h=r[m][0]||0,d=void 0;if(o(h,0))d=0;else{var y=p[m][m];if(o(y,0))throw new Error("Linear system cannot be solved since matrix is singular");d=n(h,y);for(var g=m-1;g>=0;g--)r[g]=[a(r[g][0]||0,i(d,p[g][m]))]}f[m]=[d]}return new s({data:f,size:[c,1]})}})),pf=Oe("xor",["typed","matrix","DenseMatrix"],(e=>{var{typed:t,matrix:r,DenseMatrix:n}=e,i=yc({typed:t}),a=Ic({typed:t,DenseMatrix:n}),o=xc({typed:t,DenseMatrix:n}),s=bc({typed:t}),u=wc({typed:t});return t("xor",{"number, number":Ks,"Complex, Complex":function(e,t){return(0!==e.re||0!==e.im)!=(0!==t.re||0!==t.im)},"BigNumber, BigNumber":function(e,t){return(!e.isZero()&&!e.isNaN())!=(!t.isZero()&&!t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),mf=Oe("add",["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:r,addScalar:n,equalScalar:i,DenseMatrix:a,SparseMatrix:o}=e,s=Mc({typed:t}),u=wl({typed:t,equalScalar:i}),c=Pc({typed:t,DenseMatrix:a}),l=bc({typed:t}),f=wc({typed:t});return t("add",Se({"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,n)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,n,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,n,!0)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,n)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"DenseMatrix, any":function(e,t){return f(e,t,n,!1)},"SparseMatrix, any":function(e,t){return c(e,t,n,!1)},"any, DenseMatrix":function(e,t){return f(t,e,n,!0)},"any, SparseMatrix":function(e,t){return c(t,e,n,!0)},"Array, any":function(e,t){return f(r(e),t,n,!1).valueOf()},"any, Array":function(e,t){return f(r(t),e,n,!0).valueOf()},"any, any":n,"any, any, ...any":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ge(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E,A=a&&l?[]:void 0,O=[],C=[],_=A?[]:void 0,T=[];for(N=0;N{var{typed:t,matrix:r,equalScalar:n,BigNumber:i,DenseMatrix:a}=e,o=dc({typed:t,equalScalar:n}),s=yc({typed:t}),u=hf({typed:t,equalScalar:n}),c=vc({typed:t,equalScalar:n}),l=xc({typed:t,DenseMatrix:a}),f=bc({typed:t}),p=wc({typed:t});return t(df,{"number, number":Math.atan2,"BigNumber, BigNumber":function(e,t){return i.atan2(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return l(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return p(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return p(r(t),e,this,!0).valueOf()}})})),gf="bitOr",vf=Oe(gf,["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=Mc({typed:t}),o=wl({typed:t,equalScalar:n}),s=Pc({typed:t,DenseMatrix:i}),u=bc({typed:t}),c=wc({typed:t});return t(gf,{"number, number":Io,"BigNumber, BigNumber":Ao,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})})),xf="catalan",bf=Oe(xf,["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],(e=>{var{typed:t,addScalar:r,divideScalar:n,multiplyScalar:i,combinations:a,isNegative:o,isInteger:s}=e;return t(xf,{"number | BigNumber":function(e){if(!s(e)||o(e))throw new TypeError("Non-negative integer value expected in function catalan");return n(a(i(e,2),e),r(e,1))}})})),wf=r(228),Nf="compareNatural",Mf=Oe(Nf,["typed","compare"],(e=>{var{typed:t,compare:r}=e,n=r.signatures["boolean,boolean"];return t(Nf,{"any, any":function(e,t){var o,s=G(e),u=G(t);if(!("number"!==s&&"BigNumber"!==s&&"Fraction"!==s||"number"!==u&&"BigNumber"!==u&&"Fraction"!==u))return"0"!==(o=r(e,t)).toString()?o>0?1:-1:wf(s,u);if("Array"===s||"Matrix"===s||"Array"===u||"Matrix"===u)return 0!==(o=i(this,e,t))?o:wf(s,u);if(s!==u)return wf(s,u);if("Complex"===s)return function(e,t){if(e.re>t.re)return 1;if(e.ret.im)return 1;if(e.imr.length?1:t.length{var{typed:t,equal:r}=e;return t(Sf,{"any, any":function(e,t){return n(e.valueOf(),t.valueOf())}});function n(e,t){if(Array.isArray(e)){if(Array.isArray(t)){var i=e.length;if(i!==t.length)return!1;for(var a=0;a{var{typed:t,addScalar:r,multiplyScalar:n,conj:i,size:a}=e;return t("dot",{"Array | DenseMatrix, Array | DenseMatrix":function(e,a){var u=o(e,a),c=h(e)?e._data:e,l=h(e)?e._datatype:void 0,f=h(a)?a._data:a,p=h(a)?a._datatype:void 0,m=2===s(e).length,d=2===s(a).length,y=r,g=n;if(l&&p&&l===p&&"string"==typeof l){var v=l;y=t.find(r,[v,v]),g=t.find(n,[v,v])}if(!m&&!d){for(var x=g(i(c[0]),f[0]),b=1;bd?m++:h===d&&(c=l(c,f(a[p],u[m])),p++,m++)}return c}});function o(e,t){var r,n,i=s(e),a=s(t);if(1===i.length)r=i[0];else{if(2!==i.length||1!==i[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+i.join(", ")+")");r=i[0]}if(1===a.length)n=a[0];else{if(2!==a.length||1!==a[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+a.join(", ")+")");n=a[0]}if(r!==n)throw new RangeError("Vectors must have equal length ("+r+" != "+n+")");if(0===r)throw new RangeError("Cannot calculate the dot product of empty vectors");return r}function s(e){return h(e)?e.size():a(e)}})),Of="equalText",Cf=Oe(Of,["typed","compareText","isZero"],(e=>{var{typed:t,compareText:r,isZero:n}=e;return t(Of,{"any, any":function(e,t){return n(r(e,t))}})})),_f=Oe("floor",["typed","config","round","matrix","equalScalar"],(e=>{var{typed:t,config:r,round:n,matrix:i,equalScalar:a}=e,o=vc({typed:t,equalScalar:a}),s=wc({typed:t});return t("floor",{number:function(e){return se(e,n(e),r.epsilon)?n(e):Math.floor(e)},"number, number":function(e,t){if(se(e,n(e,t),r.epsilon))return n(e,t);var[i,a]="".concat(e,"e").split("e"),o=Math.floor(Number("".concat(i,"e").concat(Number(a)+t)));return[i,a]="".concat(o,"e").split("e"),Number("".concat(i,"e").concat(Number(a)-t))},Complex:function(e){return e.floor()},"Complex, number":function(e,t){return e.floor(t)},BigNumber:function(e){return ss(e,n(e),r.epsilon)?n(e):e.floor()},"BigNumber, BigNumber":function(e,t){return ss(e,n(e,t),r.epsilon)?n(e,t):e.toDecimalPlaces(t.toNumber(),Tn.ROUND_FLOOR)},Fraction:function(e){return e.floor()},"Fraction, number":function(e,t){return e.floor(t)},"Array | Matrix":function(e){return Wt(e,this,!0)},"Array | Matrix, number":function(e,t){return Wt(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"number | Complex | BigNumber, Array":function(e,t){return s(i(t),e,this,!0).valueOf()}})})),Tf="identity",Bf=Oe(Tf,["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,config:r,matrix:n,BigNumber:i,DenseMatrix:a,SparseMatrix:o}=e;return t(Tf,{"":function(){return"Matrix"===r.matrix?n([]):[]},string:function(e){return n(e)},"number | BigNumber":function(e){return c(e,e,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, string":function(e,t){return c(e,e,t)},"number | BigNumber, number | BigNumber":function(e,t){return c(e,t,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(e,t,r){return c(e,t,r)},Array:function(e){return s(e)},"Array, string":function(e,t){return s(e,t)},Matrix:function(e){return s(e.valueOf(),e.storage())},"Matrix, string":function(e,t){return s(e.valueOf(),t)}});function s(e,t){switch(e.length){case 0:return t?n(t):[];case 1:return c(e[0],e[0],t);case 2:return c(e[0],e[1],t);default:throw new Error("Vector containing two values expected")}}function c(e,t,r){var n=u(e)||u(t)?i:null;if(u(e)&&(e=e.toNumber()),u(t)&&(t=t.toNumber()),!V(e)||e<1)throw new Error("Parameters in function identity must be positive integers");if(!V(t)||t<1)throw new Error("Parameters in function identity must be positive integers");var s=n?new i(1):1,c=n?new n(0):0,l=[e,t];if(r){if("sparse"===r)return o.diagonal(l,s,0,c);if("dense"===r)return a.diagonal(l,s,0,c);throw new TypeError('Unknown matrix type "'.concat(r,'"'))}for(var f=Xe([],l,c),p=e{var{typed:t,config:r,BigNumber:n,xgcd:i,equal:a,smaller:o,mod:s,add:u,isInteger:c}=e;return t(qf,{"number, number":l,"BigNumber, BigNumber":l});function l(e,t){if(!c(e)||!c(t))throw new Error("Parameters in function invmod must be integer numbers");if(e=s(e,t),a(t,0))throw new Error("Divisor must be non zero");var r=i(e,t);r=r.valueOf();var[l,f]=r;return a(l,n(1))?(f=s(f,t),o(f,n(0))&&(f=u(f,t)),f):NaN}})),kf="larger",If=Oe(kf,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=yc({typed:t}),o=Ic({typed:t,DenseMatrix:i}),s=xc({typed:t,DenseMatrix:i}),u=bc({typed:t}),c=wc({typed:t});return t(kf,{"boolean, boolean":function(e,t){return e>t},"number, number":function(e,t){return e>t&&!se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gt(t)&&!ss(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return 1===e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),Df=Oe("log",["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,Complex:i}=e;return t("log",{number:function(e){return e>=0||r.predictable?Ba(e):new i(e,0).log()},Complex:function(e){return e.log()},BigNumber:function(e){return!e.isNegative()||r.predictable?e.ln():new i(e.toNumber(),0).log()},"Array | Matrix":function(e){return Wt(e,this)},"any, any":function(e,t){return n(this(e),this(t))}})})),Rf="lsolveAll",Uf=Oe(Rf,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=Dl({DenseMatrix:s});return t(Rf,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=0;hh&&(v.push(f[M]),x.push(S))}if(o(N,0))if(o(g[h],0)){if(0===y){var E=[...g];E[h]=1;for(var A=0,O=x.length;Anew s({data:e.map((e=>[e])),size:[c,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(r(e),t).map((e=>e.valueOf()))}});function c(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1],p=0;pnew s({data:e.map((e=>[e])),size:[l,1]})))}})),Ff="matrixFromRows",Pf=Oe(Ff,["typed","matrix","flatten","size"],(e=>{var{typed:t,matrix:r,flatten:n,size:i}=e;return t(Ff,{"...Array":function(e){return a(e)},"...Matrix":function(e){return r(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one row is needed to construct a matrix.");var t=o(e[0]),r=[];for(var i of e){var a=o(i);if(a!==t)throw new TypeError("The vectors had different length: "+(0|t)+" ≠ "+(0|a));r.push(n(i))}return r}function o(e){var t=i(e);if(1===t.length)return t[0];if(2===t.length){if(1===t[0])return t[1];if(1===t[1])return t[0];throw new TypeError("At least one of the arguments is not a vector.")}throw new TypeError("Only one- or two-dimensional vectors are supported.")}})),jf="multiply",Lf=Oe(jf,["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],(e=>{var{typed:t,matrix:r,addScalar:n,multiplyScalar:i,equalScalar:a,dot:o}=e,s=vc({typed:t,equalScalar:a}),u=wc({typed:t});function c(e,t){switch(e.length){case 1:switch(t.length){case 1:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;case 2:switch(t.length){case 1:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+t[0]+")");break;case 2:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}}function l(e,r){if("dense"!==r.storage())throw new Error("Support for SparseMatrix not implemented");return function(e,r){var a,o=e._data,s=e._size,u=e._datatype,c=r._data,l=r._size,f=r._datatype,p=s[0],m=l[1],h=n,d=i;u&&f&&u===f&&"string"==typeof u&&(a=u,h=t.find(n,[a,a]),d=t.find(i,[a,a]));for(var y=[],g=0;gA)for(var C=0,_=0;_{var{typed:t,config:r,identity:n,multiply:i,matrix:a,number:o,fraction:s,Complex:u}=e;return t("pow",{"number, number":c,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(e,t){return t.isInteger()||e>=0||r.predictable?e.pow(t):new u(e.toNumber(),0).pow(t.toNumber(),0)},"Fraction, Fraction":function(e,t){var n=e.pow(t);if(null!=n)return n;if(r.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return c(e.valueOf(),t.valueOf())},"Array, number":l,"Array, BigNumber":function(e,t){return l(e,t.toNumber())},"Matrix, number":f,"Matrix, BigNumber":function(e,t){return f(e,t.toNumber())},"Unit, number | BigNumber":function(e,t){return e.pow(t)}});function c(e,t){if(r.predictable&&!V(t)&&e<0)try{var n=s(t),i=o(n);if((t===i||Math.abs((t-i)/t)<1e-14)&&n.d%2==1)return(n.n%2==0?1:-1)*Math.pow(-e,t)}catch(e){}return r.predictable&&(e<-1&&t===1/0||e>-1&&e<0&&t===-1/0)?NaN:V(t)||e>=0||r.predictable?Fa(e,t):e*e<1&&t===1/0||e*e>1&&t===-1/0?0:new u(e,0).pow(t,0)}function l(e,t){if(!V(t)||t<0)throw new TypeError("For A^b, b must be a positive integer (value is "+t+")");var r=Ze(e);if(2!==r.length)throw new Error("For A^b, A must be 2 dimensional (A has "+r.length+" dimensions)");if(r[0]!==r[1])throw new Error("For A^b, A must be square (size is "+r[0]+"x"+r[1]+")");for(var a=n(r[0]).valueOf(),o=e;t>=1;)1==(1&t)&&(a=i(o,a)),t>>=1,o=i(o,o);return a}function f(e,t){return a(l(e.valueOf(),t))}})),$f=Oe("qr",["typed","matrix","zeros","identity","isZero","equal","sign","sqrt","conj","unaryMinus","addScalar","divideScalar","multiplyScalar","subtract","complex"],(e=>{var{typed:r,matrix:n,zeros:i,identity:a,isZero:o,equal:s,sign:u,sqrt:c,conj:l,unaryMinus:f,addScalar:p,divideScalar:m,multiplyScalar:h,subtract:d,complex:y}=e;return t(r("qr",{DenseMatrix:function(e){return v(e)},SparseMatrix:function(e){return function(e){throw new Error("qr not implemented for sparse matrices yet")}()},Array:function(e){var t=v(n(e));return{Q:t.Q.valueOf(),R:t.R.valueOf()}}}),{_denseQRimpl:g});function g(e){var t,r,n,y=e._size[0],g=e._size[1],v=a([y],"dense"),x=v._data,b=e.clone(),w=b._data,N=i([y],"");for(n=0;n0)for(var n="Complex"===r[0][0].type?y(0):0,i=0;i{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Mc({typed:t}),s=dc({typed:t,equalScalar:n}),u=zl({typed:t,equalScalar:n}),c=Pc({typed:t,DenseMatrix:a}),l=vc({typed:t,equalScalar:n}),f=bc({typed:t}),p=wc({typed:t});return t(Gf,{"number, number":Uo,"BigNumber, BigNumber":Bo,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Zf="setCartesian",Wf=Oe(Zf,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Zf,{"Array | Matrix, Array | Matrix":function(e,t){var s=[];if(0!==n(r(e),new a(0))&&0!==n(r(t),new a(0))){var u=ot(Array.isArray(e)?e:e.toArray()).sort(i),c=ot(Array.isArray(t)?t:t.toArray()).sort(i);s=[];for(var l=0;l{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Yf,{"Array | Matrix":function(e){var t;if(0===n(r(e),new a(0)))t=[];else{var s=ot(Array.isArray(e)?e:e.toArray()).sort(i);(t=[]).push(s[0]);for(var u=1;u{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(Xf,{"Array | Matrix, Array | Matrix":function(e,t){if(0===n(r(e),new a(0)))return!0;if(0===n(r(t),new a(0)))return!1;for(var o,s=pt(ot(Array.isArray(e)?e:e.toArray()).sort(i)),u=pt(ot(Array.isArray(t)?t:t.toArray()).sort(i)),c=0;c{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(Kf,{"Array | Matrix":function(e){if(0===n(r(e),new a(0)))return[];for(var t=ot(Array.isArray(e)?e:e.toArray()).sort(i),s=[],u=0;u.toString(2).length<=t.length;)s.push(o(t,u.toString(2).split("").reverse())),u++;return function(e){for(var t=[],r=e.length-1;r>0;r--)for(var n=0;ne[n+1].length&&(t=e[n],e[n]=e[n+1],e[n+1]=t);return e}(s)}});function o(e,t){for(var r=[],n=0;n=0;){var u=r[o+s],c=r[n+u];-1===c?(s--,a[t++]=u):(r[n+u]=r[i+c],r[o+ ++s]=c)}return t}function rp(e){return-e-2}var np=Oe("csAmd",["add","multiply","transpose"],(e=>{var{add:t,multiply:r,transpose:n}=e;return function(e,o){if(!o||e<=0||e>3)return null;var s=o._size,u=s[0],c=s[1],l=0,f=Math.max(16,10*Math.sqrt(c)),p=function(e,i,a,o,s){var u=n(i);if(1===e&&o===a)return t(i,u);if(2===e){for(var c=u._index,l=u._ptr,f=0,p=0;ps))for(var h=l[p+1];mo)r[s+p]=0,r[i+p]=-1,f++,t[p]=rp(e),r[s+e]++;else{var h=r[u+m];-1!==h&&(c[h]=p),r[l+p]=r[u+m],r[u+m]=p}}return f}(c,T,z,U,R,F,f,k,D,j,I),$=0;HG?(v=d,x=W,b=z[0+d]-G):(x=T[v=_[W++]],b=z[0+v]),g=1;g<=b;g++)(w=z[k+(m=_[x++])])<=0||(Z+=w,z[k+m]=-w,_[J++]=m,-1!==z[I+m]&&(j[z[I+m]]=j[m]),-1!==j[m]?z[I+j[m]]=z[I+m]:z[D+z[U+m]]=z[I+m]);v!==d&&(T[v]=rp(d),z[F+v]=0)}for(0!==G&&(B=J),z[U+d]=Z,T[d]=Y,z[0+d]=J-Y,z[R+d]=-2,L=i(L,l,z,F,c),N=Y;N=L?z[F+v]-=w:0!==z[F+v]&&(z[F+v]=z[U+v]+X)}for(N=Y;N0?(C+=Q,_[A++]=v,O+=v):(T[v]=rp(d),z[F+v]=0)}z[R+m]=A-S+1;var K=A,ee=S+z[0+m];for(W=E+1;W=0))for(m=z[P+(O=j[m])],z[P+O]=-1;-1!==m&&-1!==z[I+m];m=z[I+m],L++){for(b=z[0+m],M=z[R+m],W=T[m]+1;W<=T[m]+b-1;W++)z[F+_[W]]=L;var re=m;for(h=z[I+m];-1!==h;){var ne=z[0+h]===b&&z[R+h]===M;for(W=T[h]+1;ne&&W<=T[h]+b-1;W++)z[F+_[W]]!==L&&(ne=0);ne?(T[h]=rp(m),z[k+m]+=z[k+h],z[k+h]=0,z[R+h]=-1,h=z[I+h],z[I+re]=h):(re=h,h=z[I+h])}}for(W=Y,N=Y;N=0;h--)z[k+h]>0||(z[I+h]=z[D+T[h]],z[D+T[h]]=h);for(v=c;v>=0;v--)z[k+v]<=0||-1!==T[v]&&(z[I+v]=z[D+T[v]],z[D+T[v]]=v);for(d=0,m=0;m<=c;m++)-1===T[m]&&(d=tp(m,d,z,D,I,q,F));return q.splice(q.length-1,1),q};function i(e,t,r,n,i){if(e<2||e+t<0){for(var a=0;a{var{transpose:t}=e;return function(e,r,n,i){if(!e||!r||!n)return null;var a,o,s,u,c,l,f,p=e._size,m=p[0],h=p[1],d=4*h+(i?h+m+1:0),y=[],g=h,v=2*h,x=3*h,b=4*h,w=5*h+1;for(s=0;s=1&&N[o]++,2===A.jleaf&&N[A.q]--}-1!==r[o]&&(y[0+o]=r[o])}for(o=0;o{var{add:t,multiply:r,transpose:n}=e,i=np({add:t,multiply:r,transpose:n}),a=ap({transpose:n});return function(e,t,r){var n,o=t._ptr,s=t._size[1],u={};if(u.q=i(e,t),e&&!u.q)return null;if(r){var c=e?function(e,t,r,n){for(var i=e._values,a=e._index,o=e._ptr,s=e._size,u=e._datatype,c=s[0],l=s[1],f=n&&e._values?[]:null,p=[],m=[],h=0,d=0;d=0;r--)-1!==e[r]&&(a[o+r]=a[0+e[r]],a[0+e[r]]=r);for(r=0;r=0;u--)for(l=r[u],f=r[u+1],c=l;c=0;s--)m[s]=-1,-1!==(u=h[s])&&(0==d[x+u]++&&(d[v+u]=s),d[y+s]=d[g+u],d[g+u]=s);for(t.lnz=0,t.m2=a,u=0;u=0;){e=n[f];var p=i?i[e]:e;sp(c,e)||(up(c,e),n[l+f]=p<0?0:cp(c[p]));var m=1;for(o=n[l+f],s=p<0?0:cp(c[p+1]);o{var{divideScalar:t,multiply:r,subtract:n}=e;return function(e,i,a,o,s,u,c){var l,f,p,m,h=e._values,d=e._index,y=e._ptr,g=e._size[1],v=i._values,x=i._index,b=i._ptr,w=function(e,t,r,n,i){var a,o,s,u=e._ptr,c=e._size,l=t._index,f=t._ptr,p=c[1],m=p;for(o=f[r],s=f[r+1],a=o;a{var{abs:t,divideScalar:r,multiply:n,subtract:i,larger:a,largerEq:o,SparseMatrix:s}=e,u=fp({divideScalar:r,multiply:n,subtract:i});return function(e,i,c){if(!e)return null;var l,f=e._size[1],p=100,m=100;i&&(l=i.q,p=i.lnz||p,m=i.unz||m);var h,d,y=[],g=[],v=[],x=new s({values:y,index:g,ptr:v,size:[f,f]}),b=[],w=[],N=[],M=new s({values:b,index:w,ptr:N,size:[f,f]}),S=[],E=[],A=[];for(h=0;h{var{typed:t,abs:r,add:n,multiply:i,transpose:a,divideScalar:o,subtract:s,larger:u,largerEq:c,SparseMatrix:l}=e,f=op({add:n,multiply:i,transpose:a}),p=pp({abs:r,divideScalar:o,multiply:i,subtract:s,larger:u,largerEq:c,SparseMatrix:l});return t("slu",{"SparseMatrix, number, number":function(e,t,r){if(!V(t)||t<0||t>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(r<0||r>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var n=f(t,e,!1),i=p(e,n,r);return{L:i.L,U:i.U,p:i.pinv,q:n.q,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\np: "+this.p.toString()+(this.q?"\nq: "+this.q.toString():"")+"\n"}}}})})),hp=Oe("trace",["typed","matrix","add"],(e=>{var{typed:t,matrix:r,add:n}=e;return t("trace",{Array:function(e){return i(r(e))},SparseMatrix:function(e){var t=e._values,r=e._index,i=e._ptr,a=e._size,o=a[0],s=a[1];if(o===s){var u=0;if(t.length>0)for(var c=0;cc)break}return u}throw new RangeError("Matrix must be square (size: "+ve(a)+")")},DenseMatrix:i,any:Me});function i(e){var t=e._size,r=e._data;switch(t.length){case 1:if(1===t[0])return Me(r[0]);throw new RangeError("Matrix must be square (size: "+ve(t)+")");case 2:var i=t[0];if(i===t[1]){for(var a=0,o=0;o{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=Dl({DenseMatrix:s});return t(dp,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=l-1;h>=0;h--)for(var d=r.length,y=0;y=b;N--){var M=p[N];M===h?w=f[N]:Mnew s({data:e.map((e=>[e])),size:[c,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(r(e),t).map((e=>e.valueOf()))}});function c(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1]-1;f>=0;f--)for(var p=r.length,m=0;m=0;y--)d[y]=a(d[y],c[y][f]);r.push(d)}}else{if(0===m)return[];r.splice(m,1),m-=1,p-=1}else{h[f]=n(h[f],c[f][f]);for(var g=f-1;g>=0;g--)h[g]=a(h[g],i(h[f],c[g][f]))}}return r.map((e=>new s({data:e.map((e=>[e])),size:[l,1]})))}})),gp="asin",vp=Oe(gp,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(gp,{number:function(e){return e>=-1&&e<=1||r.predictable?Math.asin(e):new n(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()},"Array | Matrix":function(e){return Wt(e,this,!0)}})})),xp=Oe("ceil",["typed","config","round","matrix","equalScalar"],(e=>{var{typed:t,config:r,round:n,matrix:i,equalScalar:a}=e,o=vc({typed:t,equalScalar:a}),s=wc({typed:t});return t("ceil",{number:function(e){return se(e,n(e),r.epsilon)?n(e):Ea(e)},"number, number":function(e,t){if(se(e,n(e,t),r.epsilon))return n(e,t);var[i,a]="".concat(e,"e").split("e"),o=Math.ceil(Number("".concat(i,"e").concat(Number(a)+t)));return[i,a]="".concat(o,"e").split("e"),Number("".concat(i,"e").concat(Number(a)-t))},Complex:function(e){return e.ceil()},"Complex, number":function(e,t){return e.ceil(t)},BigNumber:function(e){return ss(e,n(e),r.epsilon)?n(e):e.ceil()},"BigNumber, BigNumber":function(e,t){return ss(e,n(e,t),r.epsilon)?n(e,t):e.toDecimalPlaces(t.toNumber(),Tn.ROUND_CEIL)},Fraction:function(e){return e.ceil()},"Fraction, number":function(e,t){return e.ceil(t)},"Array | Matrix":function(e){return Wt(e,this,!0)},"Array | Matrix, number":function(e,t){return Wt(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"number | Complex | BigNumber, Array":function(e,t){return s(i(t),e,this,!0).valueOf()}})})),bp="composition",wp=Oe(bp,["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],(e=>{var{typed:t,addScalar:r,combinations:n,isPositive:i,isNegative:a,isInteger:o,larger:s}=e;return t(bp,{"number | BigNumber, number | BigNumber":function(e,t){if(!(o(e)&&i(e)&&o(t)&&i(t)))throw new TypeError("Positive integer value expected in function composition");if(s(t,e))throw new TypeError("k must be less than or equal to n in function composition");return n(r(e,-1),r(t,-1))}})})),Np="cross",Mp=Oe(Np,["typed","matrix","subtract","multiply"],(e=>{var{typed:t,matrix:r,subtract:n,multiply:i}=e;return t(Np,{"Matrix, Matrix":function(e,t){return r(a(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(a(e.toArray(),t))},"Array, Matrix":function(e,t){return r(a(e,t.toArray()))},"Array, Array":a});function a(e,t){var r=Math.max(Ze(e).length,Ze(t).length);e=rt(e),t=rt(t);var a=Ze(e),o=Ze(t);if(1!==a.length||1!==o.length||3!==a[0]||3!==o[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+a.join(", ")+"], B = ["+o.join(", ")+"])");var s=[n(i(e[1],t[2]),i(e[2],t[1])),n(i(e[2],t[0]),i(e[0],t[2])),n(i(e[0],t[1]),i(e[1],t[0]))];return r>1?[s]:s}})),Sp="distance",Ep=Oe(Sp,["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],(e=>{var{typed:t,addScalar:r,subtract:n,multiplyScalar:i,divideScalar:a,unaryMinus:o,sqrt:s,abs:c}=e;return t(Sp,{"Array, Array, Array":function(e,t,r){if(2===e.length&&2===t.length&&2===r.length){if(!f(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!f(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!f(r))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var s=a(n(r[1],r[0]),n(t[1],t[0])),u=i(i(s,s),t[0]),c=o(i(s,t[0])),l=e[1];return y(e[0],e[1],u,c,l)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(e,t,r){if(2===Object.keys(e).length&&2===Object.keys(t).length&&2===Object.keys(r).length){if(!f(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!f(t))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!f(r))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"lineOnePtX"in t&&"lineOnePtY"in t&&"lineTwoPtX"in r&&"lineTwoPtY"in r){var s=a(n(r.lineTwoPtY,r.lineTwoPtX),n(t.lineOnePtY,t.lineOnePtX)),u=i(i(s,s),t.lineOnePtX),c=o(i(s,t.lineOnePtX)),l=e.pointX;return y(e.pointX,e.pointY,u,c,l)}throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(e,t){if(2===e.length&&3===t.length){if(!f(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!p(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return y(e[0],e[1],t[0],t[1],t[2])}if(3===e.length&&6===t.length){if(!p(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!h(t))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return g(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}if(e.length===t.length&&e.length>0){if(!m(e))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!m(t))throw new TypeError("All values of an array should be numbers or BigNumbers");return v(e,t)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,t){if(2===Object.keys(e).length&&3===Object.keys(t).length){if(!f(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"xCoeffLine"in t&&"yCoeffLine"in t&&"constant"in t)return y(e.pointX,e.pointY,t.xCoeffLine,t.yCoeffLine,t.constant);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&6===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!h(t))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"x0"in t&&"y0"in t&&"z0"in t&&"a"in t&&"b"in t&&"c"in t)return g(e.pointX,e.pointY,e.pointZ,t.x0,t.y0,t.z0,t.a,t.b,t.c);throw new TypeError("Key names do not match")}if(2===Object.keys(e).length&&2===Object.keys(t).length){if(!f(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!f(t))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointTwoX"in t&&"pointTwoY"in t)return v([e.pointOneX,e.pointOneY],[t.pointTwoX,t.pointTwoY]);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&3===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointOneZ"in e&&"pointTwoX"in t&&"pointTwoY"in t&&"pointTwoZ"in t)return v([e.pointOneX,e.pointOneY,e.pointOneZ],[t.pointTwoX,t.pointTwoY,t.pointTwoZ]);throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},Array:function(e){if(!function(e){if(2===e[0].length&&l(e[0][0])&&l(e[0][1])){if(e.some((e=>2!==e.length||!l(e[0])||!l(e[1]))))return!1}else{if(!(3===e[0].length&&l(e[0][0])&&l(e[0][1])&&l(e[0][2])))return!1;if(e.some((e=>3!==e.length||!l(e[0])||!l(e[1])||!l(e[2]))))return!1}return!0}(e))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return function(e){for(var t=[],r=[],n=[],i=0;i{var{typed:t,matrix:r,equalScalar:n,multiplyScalar:i}=e,a=dc({typed:t,equalScalar:n}),o=hf({typed:t,equalScalar:n}),s=vc({typed:t,equalScalar:n}),u=bc({typed:t}),c=wc({typed:t});return t(Ap,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,i)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,i,!1)},"DenseMatrix, any":function(e,t){return c(e,t,i,!1)},"any, SparseMatrix":function(e,t){return s(t,e,i,!0)},"any, DenseMatrix":function(e,t){return c(t,e,i,!0)},"Array, any":function(e,t){return c(r(e),t,i,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,i,!0).valueOf()}})})),Cp=Oe("FibonacciHeap",["smaller","larger"],(e=>{var{smaller:t,larger:r}=e,n=1/Math.log((1+Math.sqrt(5))/2);function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}function a(e,t,r){t.left.right=t.right,t.right.left=t.left,r.degree--,r.child===t&&(r.child=t.right),0===r.degree&&(r.child=null),t.left=e,t.right=e.right,e.right=t,t.right.left=t,t.parent=null,t.mark=!1}function o(e,t){var r=t.parent;r&&(t.mark?(a(e,t,r),o(r)):t.mark=!0)}i.prototype.type="FibonacciHeap",i.prototype.isFibonacciHeap=!0,i.prototype.insert=function(e,r){var n={key:e,value:r,degree:0};if(this._minimum){var i=this._minimum;n.left=i,n.right=i.right,i.right=n,n.right.left=n,t(e,i.key)&&(this._minimum=n)}else n.left=n,n.right=n,this._minimum=n;return this._size++,n},i.prototype.size=function(){return this._size},i.prototype.clear=function(){this._minimum=null,this._size=0},i.prototype.isEmpty=function(){return 0===this._size},i.prototype.extractMinimum=function(){var e=this._minimum;if(null===e)return e;for(var i=this._minimum,a=e.degree,o=e.child;a>0;){var u=o.right;o.left.right=o.right,o.right.left=o.left,o.left=i,o.right=i.right,i.right=o,o.right.left=o,o.parent=null,o=u,a--}return e.left.right=e.right,e.right.left=e.left,i=e===e.right?null:function(e,i){var a,o=Math.floor(Math.log(i)*n)+1,u=new Array(o),c=0,l=e;if(l)for(c++,l=l.right;l!==e;)c++,l=l.right;for(;c>0;){for(var f=l.degree,p=l.right;a=u[f];){if(r(l.key,a.key)){var m=a;a=l,l=m}s(a,l),u[f]=null,f++}u[f]=l,l=p,c--}e=null;for(var h=0;h{var{typed:t,Complex:r,matrix:n,ceil:i,floor:a}=e,o=wc({typed:t});return t("fix",{number:function(e){return e>0?a(e):i(e)},"number, number | BigNumber":function(e,t){return e>0?a(e,t):i(e,t)},Complex:function(e){return new r(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},"Complex, number | BigNumber":function(e,t){return new r(e.re>0?a(e.re,t):i(e.re,t),e.im>0?a(e.im,t):i(e.im,t))},BigNumber:function(e){return e.isNegative()?i(e):a(e)},"BigNumber, number | BigNumber":function(e,t){return e.isNegative()?i(e,t):a(e,t)},Fraction:function(e){return e.s<0?e.ceil():e.floor()},"Fraction, number | BigNumber":function(e,t){return e.s<0?e.ceil(t):e.floor(t)},"Array | Matrix":function(e){return Wt(e,this,!0)},"Array | Matrix, number | BigNumber":function(e,t){return Wt(e,(e=>this(e,t)),!0)},"number | Complex | BigNumber, Array":function(e,t){return o(n(t),e,this,!0).valueOf()}})}));function Tp(e){var t;if(V(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:Vo(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*Tp(1-e));if(e>=171.35)return 1/0;if(e>85){var r=e*e,n=r*e,i=n*e,a=i*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*r)-139/(51840*n)-571/(2488320*i)+163879/(209018880*a)+5246819/(75246796800*a*e))}--e,t=qp[0];for(var o=1;o{var{typed:t,config:r,multiplyScalar:n,pow:i,BigNumber:a,Complex:o}=e;return t(zp,{number:Tp,Complex:function(e){if(0===e.im)return this(e.re);if(e.re<.5){var t=new o(1-e.re,-e.im),r=new o(Math.PI*e.re,Math.PI*e.im);return new o(Math.PI).div(r.sin()).div(this(t))}e=new o(e.re-1,e.im);for(var n=new o(qp[0],0),i=1;i2;)u+=i-=2,o=o.times(u);return new a(o.toPrecision(a.precision))}})),Ip="index",Dp=Oe(Ip,["typed","Index"],(e=>{var{typed:t,Index:r}=e;return t(Ip,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var t=e.map((function(e){return u(e)?e.toNumber():Array.isArray(e)||h(e)?e.map((function(e){return u(e)?e.toNumber():e})):e})),n=new r;return r.apply(n,t),n}})})),Rp=Oe("lcm",["typed","matrix","equalScalar"],(e=>{var{typed:t,matrix:r,equalScalar:n}=e,i=dc({typed:t,equalScalar:n}),a=Sc({typed:t,equalScalar:n}),o=vc({typed:t,equalScalar:n}),s=bc({typed:t}),u=wc({typed:t});return t("lcm",{"number, number":Ta,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(e.isZero())return e;if(t.isZero())return t;var r=e.times(t);for(;!t.isZero();){var n=t;t=e.mod(n),e=n}return r.div(e).abs()},"Fraction, Fraction":function(e,t){return e.lcm(t)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return o(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return u(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return u(r(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,add:r,multiply:n,partitionSelect:i,compare:a}=e;function o(e,t,o){var u=ot(e),l=u.length;if(0===l)throw new Error("Cannot calculate quantile of an empty sequence");if(s(t)){var f=t*(l-1),p=f%1;if(0===p){var m=o?u[f]:i(u,f);return c(m),m}var h,d,y=Math.floor(f);if(o)h=u[y],d=u[y+1];else{d=i(u,y+1),h=u[y];for(var g=0;g0&&(h=u[g])}return c(h),c(d),r(n(h,1-p),n(d,p))}var v=t.times(l-1);if(v.isInteger()){v=v.toNumber();var x=o?u[v]:i(u,v);return c(x),x}var b,w,N=v.floor(),M=v.minus(N),S=N.toNumber();if(o)b=u[S],w=u[S+1];else{w=i(u,S+1),b=u[S];for(var E=0;E0&&(b=u[E])}c(b),c(w);var A=new M.constructor(1);return r(n(b,A.minus(M)),n(w,M))}var c=t({"number | BigNumber | Unit":function(e){return e}});return function(e,t,r){var n,i,a;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(d(e)){if("boolean"==typeof(r=r||!1)){if(i=e.valueOf(),s(t)){if(t<0)throw new Error("N/prob must be non-negative");if(t<=1)return o(i,t,r);if(t>1){if(!V(t))throw new Error("N must be a positive integer");var c=t+1;n=new Array(t);for(var l=0;l4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var m=new f(p+1);n=new Array(p);for(var h=0;h1)throw new Error("Probability must be between 0 and 1, inclusive")}else{if(!u(g))throw new TypeError("Unexpected type of argument in function quantileSeq");if(a=new g.constructor(1),g.isNegative()||g.gt(a))throw new Error("Probability must be between 0 and 1, inclusive")}n[y]=o(i,g,r)}return n}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")}})),Fp="setDifference",Pp=Oe(Fp,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Fp,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(0===n(r(e),new a(0)))s=[];else{if(0===n(r(t),new a(0)))return ot(e.toArray());var u,c=pt(ot(Array.isArray(e)?e:e.toArray()).sort(i)),l=pt(ot(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var f=0;f{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(jp,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,t){if(0===n(r(t),new a(0)))return 0;for(var o=ot(Array.isArray(t)?t:t.toArray()),s=0,u=0;u{var{typed:t,size:r,concat:n,subset:i,setDifference:a,Index:o}=e;return t(Hp,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new o(0)))return ot(t);if(0===i(r(t),new o(0)))return ot(e);var s=ot(e),u=ot(t);return n(a(s,u),a(u,s))}})})),Gp="sort",Vp=Oe(Gp,["typed","matrix","compare","compareNatural"],(e=>{var{typed:t,matrix:r,compare:n,compareNatural:i}=e,a=n,o=(e,t)=>-n(e,t);return t(Gp,{Array:function(e){return u(e),e.sort(a)},Matrix:function(e){return c(e),r(e.toArray().sort(a),e.storage())},"Array, function":function(e,t){return u(e),e.sort(t)},"Matrix, function":function(e,t){return c(e),r(e.toArray().sort(t),e.storage())},"Array, string":function(e,t){return u(e),e.sort(s(t))},"Matrix, string":function(e,t){return c(e),r(e.toArray().sort(s(t)),e.storage())}});function s(e){if("asc"===e)return a;if("desc"===e)return o;if("natural"===e)return i;throw new Error('String "asc", "desc", or "natural" expected')}function u(e){if(1!==Ze(e).length)throw new Error("One dimensional array expected")}function c(e){if(1!==e.size().length)throw new Error("One dimensional matrix expected")}}));function Zp(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Wp(e){for(var t=1;t{var r,n,i,{on:a,config:o,addScalar:s,subtract:u,multiplyScalar:l,divideScalar:p,pow:m,abs:h,fix:d,round:y,equal:g,isNumeric:v,format:x,number:b,Complex:w,BigNumber:N,Fraction:M}=e,S=b;function E(e,t){if(!(this instanceof E))throw new Error("Constructor must be called with the new operator");if(null!=e&&!v(e)&&!c(e))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(void 0!==t&&("string"!=typeof t||""===t))throw new TypeError("Second parameter in Unit constructor must be a string");if(void 0!==t){var r=E.parse(t);this.units=r.units,this.dimensions=r.dimensions}else{this.units=[{unit:F,prefix:I.NONE,power:0}],this.dimensions=[];for(var n=0;n="0"&&e<="9"}function C(){n++,i=r.charAt(n)}function _(e){n=e,i=r.charAt(n)}function T(){var e="",t=n;if("+"===i?C():"-"===i&&(e+=i,C()),!function(e){return e>="0"&&e<="9"||"."===e}(i))return _(t),null;if("."===i){if(e+=i,C(),!O(i))return _(t),null}else{for(;O(i);)e+=i,C();"."===i&&(e+=i,C())}for(;O(i);)e+=i,C();if("E"===i||"e"===i){var r="",a=n;if(r+=i,C(),"+"!==i&&"-"!==i||(r+=i,C()),!O(i))return _(a),e;for(e+=r;O(i);)e+=i,C()}return e}function B(){for(var e="";O(i)||E.isValidAlpha(i);)e+=i,C();var t=e.charAt(0);return E.isValidAlpha(t)?e:null}function q(e){return i===e?(C(),e):null}E.prototype.type="Unit",E.prototype.isUnit=!0,E.parse=function(e,t){if(t=t||{},n=-1,i="","string"!=typeof(r=e))throw new TypeError("Invalid argument in Unit.parse, string expected");var a=new E;a.units=[];var s=1,u=!1;C(),A();var c=T(),l=null;if(c){if("BigNumber"===o.number)l=new N(c);else if("Fraction"===o.number)try{l=new M(c)}catch(e){l=parseFloat(c)}else l=parseFloat(c);A(),q("*")?(s=1,u=!0):q("/")&&(s=-1,u=!0)}for(var f=[],p=1;;){for(A();"("===i;)f.push(s),p*=s,s=1,C(),A();var m=void 0;if(!i)break;var h=i;if(null===(m=B()))throw new SyntaxError('Unexpected "'+h+'" in "'+r+'" at index '+n.toString());var d=z(m);if(null===d)throw new SyntaxError('Unit "'+m+'" not found.');var y=s*p;if(A(),q("^")){A();var g=T();if(null===g)throw new SyntaxError('In "'+e+'", "^" must be followed by a floating-point number');y*=g}a.units.push({unit:d.unit,prefix:d.prefix,power:y});for(var v=0;v1||Math.abs(this.units[0].power-1)>1e-15)},E.prototype._normalize=function(e){var t,r,n,i,a;if(null==e||0===this.units.length)return e;if(this._isDerived()){var o=e;a=E._getNumberConverter(G(e));for(var u=0;u{if(Ae(P,e)){var t=P[e];return{unit:t,prefix:t.prefixes[""]}}for(var r in P)if(Ae(P,r)&&ge(e,r)){var n=P[r],i=e.length-r.length,a=e.substring(0,i),o=Ae(n.prefixes,a)?n.prefixes[a]:void 0;if(void 0!==o)return{unit:n,prefix:o}}return null}),{hasher:e=>e[0],limit:100});function k(e){return e.equalBase(R.NONE)&&null!==e.value&&!o.predictable?e.value:e}E.isValuelessUnit=function(e){return null!==z(e)},E.prototype.hasBase=function(e){if("string"==typeof e&&(e=R[e]),!e)return!1;for(var t=0;t1e-12)return!1;return!0},E.prototype.equalBase=function(e){for(var t=0;t1e-12)return!1;return!0},E.prototype.equals=function(e){return this.equalBase(e)&&g(this.value,e.value)},E.prototype.multiply=function(e){for(var t=this.clone(),r=0;r1e-12&&(Ae($,s)?n.push({unit:$[s].unit,prefix:$[s].prefix,power:r.dimensions[o]||0}):a=!0)}n.length1e-12){if(!Ae(H.si,n))throw new Error("Cannot express custom unit "+n+" in SI units");t.push({unit:H.si[n].unit,prefix:H.si[n].prefix,power:e.dimensions[r]||0})}}return e.units=t,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,e},E.prototype.formatUnits=function(){for(var e="",t="",r=0,n=0,i=0;i0?(r++,e+=" "+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power-1)>1e-15&&(e+="^"+this.units[i].power)):this.units[i].power<0&&n++;if(n>0)for(var a=0;a0?(t+=" "+this.units[a].prefix.name+this.units[a].unit.name,Math.abs(this.units[a].power+1)>1e-15&&(t+="^"+-this.units[a].power)):(t+=" "+this.units[a].prefix.name+this.units[a].unit.name,t+="^"+this.units[a].power));e=e.substr(1),t=t.substr(1),r>1&&n>0&&(e="("+e+")"),n>1&&r>0&&(t="("+t+")");var o=e;return r>0&&n>0&&(o+=" / "),o+=t},E.prototype.format=function(e){var t=this.skipAutomaticSimplification||null===this.value?this.clone():this.simplify(),r=!1;for(var n in void 0!==t.value&&null!==t.value&&c(t.value)&&(r=Math.abs(t.value.re)<1e-14),t.units)Ae(t.units,n)&&t.units[n].unit&&("VA"===t.units[n].unit.name&&r?t.units[n].unit=P.VAR:"VAR"!==t.units[n].unit.name||r||(t.units[n].unit=P.VA));1!==t.units.length||t.fixPrefix||Math.abs(t.units[0].power-Math.round(t.units[0].power))<1e-14&&(t.units[0].prefix=t._bestPrefix());var i=t._denormalize(t.value),a=null!==t.value?x(i,e||{}):"",o=t.formatUnits();return t.value&&c(t.value)&&(a="("+a+")"),o.length>0&&a.length>0&&(a+=" "),a+=o},E.prototype._bestPrefix=function(){if(1!==this.units.length)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 e=null!==this.value?h(this.value):0,t=h(this.units[0].unit.value),r=this.units[0].prefix;if(0===e)return r;var n=this.units[0].power,i=Math.log(e/Math.pow(r.value*t,n))/Math.LN10-1.2;if(i>-2.200001&&i<1.800001)return r;i=Math.abs(i);var a=this.units[0].unit.prefixes;for(var o in a)if(Ae(a,o)){var s=a[o];if(s.scientific){var u=Math.abs(Math.log(e/Math.pow(s.value*t,n))/Math.LN10-1.2);(u0))},P={meter:{name:"meter",base:R.LENGTH,prefixes:I.LONG,value:1,offset:0},inch:{name:"inch",base:R.LENGTH,prefixes:I.NONE,value:.0254,offset:0},foot:{name:"foot",base:R.LENGTH,prefixes:I.NONE,value:.3048,offset:0},yard:{name:"yard",base:R.LENGTH,prefixes:I.NONE,value:.9144,offset:0},mile:{name:"mile",base:R.LENGTH,prefixes:I.NONE,value:1609.344,offset:0},link:{name:"link",base:R.LENGTH,prefixes:I.NONE,value:.201168,offset:0},rod:{name:"rod",base:R.LENGTH,prefixes:I.NONE,value:5.0292,offset:0},chain:{name:"chain",base:R.LENGTH,prefixes:I.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:R.LENGTH,prefixes:I.NONE,value:1e-10,offset:0},m:{name:"m",base:R.LENGTH,prefixes:I.SHORT,value:1,offset:0},in:{name:"in",base:R.LENGTH,prefixes:I.NONE,value:.0254,offset:0},ft:{name:"ft",base:R.LENGTH,prefixes:I.NONE,value:.3048,offset:0},yd:{name:"yd",base:R.LENGTH,prefixes:I.NONE,value:.9144,offset:0},mi:{name:"mi",base:R.LENGTH,prefixes:I.NONE,value:1609.344,offset:0},li:{name:"li",base:R.LENGTH,prefixes:I.NONE,value:.201168,offset:0},rd:{name:"rd",base:R.LENGTH,prefixes:I.NONE,value:5.02921,offset:0},ch:{name:"ch",base:R.LENGTH,prefixes:I.NONE,value:20.1168,offset:0},mil:{name:"mil",base:R.LENGTH,prefixes:I.NONE,value:254e-7,offset:0},m2:{name:"m2",base:R.SURFACE,prefixes:I.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:R.SURFACE,prefixes:I.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:R.SURFACE,prefixes:I.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:R.SURFACE,prefixes:I.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:R.SURFACE,prefixes:I.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:R.SURFACE,prefixes:I.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:R.SURFACE,prefixes:I.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:R.SURFACE,prefixes:I.NONE,value:6.4516e-10,offset:0},acre:{name:"acre",base:R.SURFACE,prefixes:I.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:R.SURFACE,prefixes:I.NONE,value:1e4,offset:0},m3:{name:"m3",base:R.VOLUME,prefixes:I.CUBIC,value:1,offset:0},L:{name:"L",base:R.VOLUME,prefixes:I.SHORT,value:.001,offset:0},l:{name:"l",base:R.VOLUME,prefixes:I.SHORT,value:.001,offset:0},litre:{name:"litre",base:R.VOLUME,prefixes:I.LONG,value:.001,offset:0},cuin:{name:"cuin",base:R.VOLUME,prefixes:I.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:R.VOLUME,prefixes:I.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:R.VOLUME,prefixes:I.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:R.VOLUME,prefixes:I.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:R.VOLUME,prefixes:I.NONE,value:15e-6,offset:0},drop:{name:"drop",base:R.VOLUME,prefixes:I.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:R.VOLUME,prefixes:I.NONE,value:5e-8,offset:0},minim:{name:"minim",base:R.VOLUME,prefixes:I.NONE,value:6.161152e-8,offset:0},fluiddram:{name:"fluiddram",base:R.VOLUME,prefixes:I.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:R.VOLUME,prefixes:I.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:R.VOLUME,prefixes:I.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:R.VOLUME,prefixes:I.NONE,value:1e-6,offset:0},cup:{name:"cup",base:R.VOLUME,prefixes:I.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:R.VOLUME,prefixes:I.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:R.VOLUME,prefixes:I.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:R.VOLUME,prefixes:I.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:R.VOLUME,prefixes:I.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:R.VOLUME,prefixes:I.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:R.VOLUME,prefixes:I.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:R.VOLUME,prefixes:I.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:R.VOLUME,prefixes:I.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:R.VOLUME,prefixes:I.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:R.VOLUME,prefixes:I.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:R.VOLUME,prefixes:I.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:R.VOLUME,prefixes:I.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:R.VOLUME,prefixes:I.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:R.VOLUME,prefixes:I.NONE,value:.1173478,offset:0},obl:{name:"obl",base:R.VOLUME,prefixes:I.NONE,value:.1589873,offset:0},g:{name:"g",base:R.MASS,prefixes:I.SHORT,value:.001,offset:0},gram:{name:"gram",base:R.MASS,prefixes:I.LONG,value:.001,offset:0},ton:{name:"ton",base:R.MASS,prefixes:I.SHORT,value:907.18474,offset:0},t:{name:"t",base:R.MASS,prefixes:I.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:R.MASS,prefixes:I.LONG,value:1e3,offset:0},grain:{name:"grain",base:R.MASS,prefixes:I.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:R.MASS,prefixes:I.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:R.MASS,prefixes:I.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:R.MASS,prefixes:I.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:R.MASS,prefixes:I.NONE,value:45.359237,offset:0},stick:{name:"stick",base:R.MASS,prefixes:I.NONE,value:.115,offset:0},stone:{name:"stone",base:R.MASS,prefixes:I.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:R.MASS,prefixes:I.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:R.MASS,prefixes:I.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:R.MASS,prefixes:I.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:R.MASS,prefixes:I.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:R.MASS,prefixes:I.NONE,value:45.359237,offset:0},s:{name:"s",base:R.TIME,prefixes:I.SHORT,value:1,offset:0},min:{name:"min",base:R.TIME,prefixes:I.NONE,value:60,offset:0},h:{name:"h",base:R.TIME,prefixes:I.NONE,value:3600,offset:0},second:{name:"second",base:R.TIME,prefixes:I.LONG,value:1,offset:0},sec:{name:"sec",base:R.TIME,prefixes:I.LONG,value:1,offset:0},minute:{name:"minute",base:R.TIME,prefixes:I.NONE,value:60,offset:0},hour:{name:"hour",base:R.TIME,prefixes:I.NONE,value:3600,offset:0},day:{name:"day",base:R.TIME,prefixes:I.NONE,value:86400,offset:0},week:{name:"week",base:R.TIME,prefixes:I.NONE,value:604800,offset:0},month:{name:"month",base:R.TIME,prefixes:I.NONE,value:2629800,offset:0},year:{name:"year",base:R.TIME,prefixes:I.NONE,value:31557600,offset:0},decade:{name:"decade",base:R.TIME,prefixes:I.NONE,value:315576e3,offset:0},century:{name:"century",base:R.TIME,prefixes:I.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:R.TIME,prefixes:I.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:R.FREQUENCY,prefixes:I.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:R.FREQUENCY,prefixes:I.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:R.ANGLE,prefixes:I.SHORT,value:1,offset:0},radian:{name:"radian",base:R.ANGLE,prefixes:I.LONG,value:1,offset:0},deg:{name:"deg",base:R.ANGLE,prefixes:I.SHORT,value:null,offset:0},degree:{name:"degree",base:R.ANGLE,prefixes:I.LONG,value:null,offset:0},grad:{name:"grad",base:R.ANGLE,prefixes:I.SHORT,value:null,offset:0},gradian:{name:"gradian",base:R.ANGLE,prefixes:I.LONG,value:null,offset:0},cycle:{name:"cycle",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},A:{name:"A",base:R.CURRENT,prefixes:I.SHORT,value:1,offset:0},ampere:{name:"ampere",base:R.CURRENT,prefixes:I.LONG,value:1,offset:0},K:{name:"K",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:0},degC:{name:"degC",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:273.15},degF:{name:"degF",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:0},celsius:{name:"celsius",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:R.AMOUNT_OF_SUBSTANCE,prefixes:I.SHORT,value:1,offset:0},mole:{name:"mole",base:R.AMOUNT_OF_SUBSTANCE,prefixes:I.LONG,value:1,offset:0},cd:{name:"cd",base:R.LUMINOUS_INTENSITY,prefixes:I.SHORT,value:1,offset:0},candela:{name:"candela",base:R.LUMINOUS_INTENSITY,prefixes:I.LONG,value:1,offset:0},N:{name:"N",base:R.FORCE,prefixes:I.SHORT,value:1,offset:0},newton:{name:"newton",base:R.FORCE,prefixes:I.LONG,value:1,offset:0},dyn:{name:"dyn",base:R.FORCE,prefixes:I.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:R.FORCE,prefixes:I.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:R.FORCE,prefixes:I.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:R.FORCE,prefixes:I.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:R.FORCE,prefixes:I.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:R.FORCE,prefixes:I.NONE,value:9.80665,offset:0},J:{name:"J",base:R.ENERGY,prefixes:I.SHORT,value:1,offset:0},joule:{name:"joule",base:R.ENERGY,prefixes:I.SHORT,value:1,offset:0},erg:{name:"erg",base:R.ENERGY,prefixes:I.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:R.ENERGY,prefixes:I.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:R.ENERGY,prefixes:I.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:R.ENERGY,prefixes:I.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:R.ENERGY,prefixes:I.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:R.POWER,prefixes:I.SHORT,value:1,offset:0},watt:{name:"watt",base:R.POWER,prefixes:I.LONG,value:1,offset:0},hp:{name:"hp",base:R.POWER,prefixes:I.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:R.POWER,prefixes:I.SHORT,value:w.I,offset:0},VA:{name:"VA",base:R.POWER,prefixes:I.SHORT,value:1,offset:0},Pa:{name:"Pa",base:R.PRESSURE,prefixes:I.SHORT,value:1,offset:0},psi:{name:"psi",base:R.PRESSURE,prefixes:I.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:R.PRESSURE,prefixes:I.NONE,value:101325,offset:0},bar:{name:"bar",base:R.PRESSURE,prefixes:I.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:R.PRESSURE,prefixes:I.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:R.PRESSURE,prefixes:I.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:R.PRESSURE,prefixes:I.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:R.PRESSURE,prefixes:I.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:R.ELECTRIC_CHARGE,prefixes:I.LONG,value:1,offset:0},C:{name:"C",base:R.ELECTRIC_CHARGE,prefixes:I.SHORT,value:1,offset:0},farad:{name:"farad",base:R.ELECTRIC_CAPACITANCE,prefixes:I.LONG,value:1,offset:0},F:{name:"F",base:R.ELECTRIC_CAPACITANCE,prefixes:I.SHORT,value:1,offset:0},volt:{name:"volt",base:R.ELECTRIC_POTENTIAL,prefixes:I.LONG,value:1,offset:0},V:{name:"V",base:R.ELECTRIC_POTENTIAL,prefixes:I.SHORT,value:1,offset:0},ohm:{name:"ohm",base:R.ELECTRIC_RESISTANCE,prefixes:I.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:R.ELECTRIC_INDUCTANCE,prefixes:I.LONG,value:1,offset:0},H:{name:"H",base:R.ELECTRIC_INDUCTANCE,prefixes:I.SHORT,value:1,offset:0},siemens:{name:"siemens",base:R.ELECTRIC_CONDUCTANCE,prefixes:I.LONG,value:1,offset:0},S:{name:"S",base:R.ELECTRIC_CONDUCTANCE,prefixes:I.SHORT,value:1,offset:0},weber:{name:"weber",base:R.MAGNETIC_FLUX,prefixes:I.LONG,value:1,offset:0},Wb:{name:"Wb",base:R.MAGNETIC_FLUX,prefixes:I.SHORT,value:1,offset:0},tesla:{name:"tesla",base:R.MAGNETIC_FLUX_DENSITY,prefixes:I.LONG,value:1,offset:0},T:{name:"T",base:R.MAGNETIC_FLUX_DENSITY,prefixes:I.SHORT,value:1,offset:0},b:{name:"b",base:R.BIT,prefixes:I.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:R.BIT,prefixes:I.BINARY_LONG,value:1,offset:0},B:{name:"B",base:R.BIT,prefixes:I.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:R.BIT,prefixes:I.BINARY_LONG,value:8,offset:0}},j={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 L(e){if("BigNumber"===e.number){var t=Dn(N);P.rad.value=new N(1),P.deg.value=t.div(180),P.grad.value=t.div(200),P.cycle.value=t.times(2),P.arcsec.value=t.div(648e3),P.arcmin.value=t.div(10800)}else P.rad.value=1,P.deg.value=Math.PI/180,P.grad.value=Math.PI/200,P.cycle.value=2*Math.PI,P.arcsec.value=Math.PI/648e3,P.arcmin.value=Math.PI/10800;P.radian.value=P.rad.value,P.degree.value=P.deg.value,P.gradian.value=P.grad.value}L(o),a&&a("config",(function(e,t){e.number!==t.number&&L(e)}));var H={si:{NONE:{unit:F,prefix:I.NONE[""]},LENGTH:{unit:P.m,prefix:I.SHORT[""]},MASS:{unit:P.g,prefix:I.SHORT.k},TIME:{unit:P.s,prefix:I.SHORT[""]},CURRENT:{unit:P.A,prefix:I.SHORT[""]},TEMPERATURE:{unit:P.K,prefix:I.SHORT[""]},LUMINOUS_INTENSITY:{unit:P.cd,prefix:I.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:P.mol,prefix:I.SHORT[""]},ANGLE:{unit:P.rad,prefix:I.SHORT[""]},BIT:{unit:P.bits,prefix:I.SHORT[""]},FORCE:{unit:P.N,prefix:I.SHORT[""]},ENERGY:{unit:P.J,prefix:I.SHORT[""]},POWER:{unit:P.W,prefix:I.SHORT[""]},PRESSURE:{unit:P.Pa,prefix:I.SHORT[""]},ELECTRIC_CHARGE:{unit:P.C,prefix:I.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:P.F,prefix:I.SHORT[""]},ELECTRIC_POTENTIAL:{unit:P.V,prefix:I.SHORT[""]},ELECTRIC_RESISTANCE:{unit:P.ohm,prefix:I.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:P.H,prefix:I.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:P.S,prefix:I.SHORT[""]},MAGNETIC_FLUX:{unit:P.Wb,prefix:I.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:P.T,prefix:I.SHORT[""]},FREQUENCY:{unit:P.Hz,prefix:I.SHORT[""]}}};H.cgs=JSON.parse(JSON.stringify(H.si)),H.cgs.LENGTH={unit:P.m,prefix:I.SHORT.c},H.cgs.MASS={unit:P.g,prefix:I.SHORT[""]},H.cgs.FORCE={unit:P.dyn,prefix:I.SHORT[""]},H.cgs.ENERGY={unit:P.erg,prefix:I.NONE[""]},H.us=JSON.parse(JSON.stringify(H.si)),H.us.LENGTH={unit:P.ft,prefix:I.NONE[""]},H.us.MASS={unit:P.lbm,prefix:I.NONE[""]},H.us.TEMPERATURE={unit:P.degF,prefix:I.NONE[""]},H.us.FORCE={unit:P.lbf,prefix:I.NONE[""]},H.us.ENERGY={unit:P.BTU,prefix:I.BTU[""]},H.us.POWER={unit:P.hp,prefix:I.NONE[""]},H.us.PRESSURE={unit:P.psi,prefix:I.NONE[""]},H.auto=JSON.parse(JSON.stringify(H.si));var $=H.auto;for(var V in E.setUnitSystem=function(e){if(!Ae(H,e))throw new Error("Unit system "+e+" does not exist. Choices are: "+Object.keys(H).join(", "));$=H[e]},E.getUnitSystem=function(){for(var e in H)if(Ae(H,e)&&H[e]===$)return e},E.typeConverters={BigNumber:function(e){return new N(e+"")},Fraction:function(e){return new M(e)},Complex:function(e){return e},number:function(e){return e}},E._getNumberConverter=function(e){if(!E.typeConverters[e])throw new TypeError('Unsupported type "'+e+'"');return E.typeConverters[e]},P)if(Ae(P,V)){var Z=P[V];Z.dimensions=Z.base.dimensions}for(var W in j)if(Ae(j,W)){var Y=P[j[W]],J={};for(var X in Y)Ae(Y,X)&&(J[X]=Y[X]);J.name=W,P[W]=J}return E.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)},E.createUnit=function(e,t){if("object"!=typeof e)throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(t&&t.override)for(var r in e)if(Ae(e,r)&&E.deleteUnit(r),e[r].aliases)for(var n=0;n0&&!E.isValidAlpha(i)&&!O(i))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+e+'"')}}(e);var n,a,o,s=null,u=[],c=0;if(t&&"Unit"===t.type)s=t.clone();else if("string"==typeof t)""!==t&&(n=t);else{if("object"!=typeof t)throw new TypeError('Cannot create unit "'+e+'" from "'+t.toString()+'": expecting "string" or "Unit" or "Object"');n=t.definition,a=t.prefixes,c=t.offset,o=t.baseName,t.aliases&&(u=t.aliases.valueOf())}if(u)for(var l=0;l1e-12){h=!1;break}if(h){p=!0,f.base=R[m];break}}if(!p){o=o||e+"_STUFF";var y={dimensions:s.dimensions.slice(0)};y.key=o,R[o]=y,$[o]={unit:f,prefix:I.NONE[""]},f.base=R[o]}}else{if(o=o||e+"_STUFF",D.indexOf(o)>=0)throw new Error('Cannot create new base unit "'+e+'": a base unit with that name already exists (and cannot be overridden)');for(var g in D.push(o),R)Ae(R,g)&&(R[g].dimensions[D.length-1]=0);for(var v={dimensions:[]},x=0;x{var{typed:t,Unit:r}=e;return t(Jp,{"Object, Object":function(e,t){return r.createUnit(e,t)},Object:function(e){return r.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,t,n){var i={};return i[e]=t,r.createUnit(i,n)},"string, Unit | string | Object":function(e,t){var n={};return n[e]=t,r.createUnit(n,{})},string:function(e){var t={};return t[e]={},r.createUnit(t,{})}})})),Qp="dotPow",Kp=Oe(Qp,["typed","equalScalar","matrix","pow","DenseMatrix"],(e=>{var{typed:t,equalScalar:r,matrix:n,pow:i,DenseMatrix:a}=e,o=yc({typed:t}),s=Ic({typed:t,DenseMatrix:a}),u=vc({typed:t,equalScalar:r}),c=xc({typed:t,DenseMatrix:a}),l=bc({typed:t}),f=wc({typed:t});return t(Qp,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,i)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return f(e,t,this,!1)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return f(t,e,this,!0)},"Array, any":function(e,t){return f(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return f(n(t),e,this,!0).valueOf()}})})),em="factorial",tm=Oe(em,["typed","gamma"],(e=>{var{typed:t,gamma:r}=e;return t(em,{number:function(e){if(e<0)throw new Error("Value must be non-negative");return r(e+1)},BigNumber:function(e){if(e.isNegative())throw new Error("Value must be non-negative");return r(e.plus(1))},"Array | Matrix":function(e){return Wt(e,this)}})})),rm=Oe("intersect",["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],(e=>{var{typed:t,config:r,abs:n,add:i,addScalar:a,matrix:o,multiply:s,multiplyScalar:u,divideScalar:c,subtract:l,smaller:f,equalScalar:p,flatten:m,isZero:h,isNumeric:d}=e;return t("intersect",{"Array, Array, Array":y,"Array, Array, Array, Array":g,"Matrix, Matrix, Matrix":function(e,t,r){var n=y(e.valueOf(),t.valueOf(),r.valueOf());return null===n?null:o(n)},"Matrix, Matrix, Matrix, Matrix":function(e,t,r,n){var i=g(e.valueOf(),t.valueOf(),r.valueOf(),n.valueOf());return null===i?null:o(i)}});function y(e,t,r){if(e=v(e),t=v(t),r=v(r),!b(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!b(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!function(e){return 4===e.length&&d(e[0])&&d(e[1])&&d(e[2])&&d(e[3])}(r))throw new TypeError("Array with 4 numbers expected as third argument");return function(e,t,r,n,i,o,s,f,p,m){var h=u(e,s),d=u(n,s),y=u(t,f),g=u(i,f),v=u(r,p),x=u(o,p),b=l(l(l(m,h),y),v),w=l(l(l(a(a(d,g),x),h),y),v),N=c(b,w),M=a(e,u(N,l(n,e))),S=a(t,u(N,l(i,t))),E=a(r,u(N,l(o,r)));return[M,S,E]}(e[0],e[1],e[2],t[0],t[1],t[2],r[0],r[1],r[2],r[3])}function g(e,t,o,m){if(e=v(e),t=v(t),o=v(o),m=v(m),2===e.length){if(!x(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!x(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!x(o))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!x(m))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return function(e,t,o,p){var m=e,d=o,y=l(m,t),g=l(d,p),v=l(u(y[0],g[1]),u(g[0],y[1]));if(h(v))return null;if(f(n(v),r.epsilon))return null;var x=u(g[0],m[1]),b=u(g[1],m[0]),w=u(g[0],d[1]),N=u(g[1],d[0]),M=c(a(l(l(x,b),w),N),v);return i(s(y,M),m)}(e,t,o,m)}if(3===e.length){if(!b(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!b(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!b(o))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!b(m))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return function(e,t,r,n,i,o,s,f,m,d,y,g){var v=w(e,s,d,s,t,f,y,f,r,m,g,m),x=w(d,s,n,e,y,f,i,t,g,m,o,r),b=w(e,s,n,e,t,f,i,t,r,m,o,r),N=w(d,s,d,s,y,f,y,f,g,m,g,m),M=w(n,e,n,e,i,t,i,t,o,r,o,r),S=l(u(v,x),u(b,N)),E=l(u(M,N),u(x,x));if(h(E))return null;var A=c(S,E),O=c(a(v,u(A,x)),N),C=a(e,u(A,l(n,e))),_=a(t,u(A,l(i,t))),T=a(r,u(A,l(o,r))),B=a(s,u(O,l(d,s))),q=a(f,u(O,l(y,f))),z=a(m,u(O,l(g,m)));return p(C,B)&&p(_,q)&&p(T,z)?[C,_,T]:null}(e[0],e[1],e[2],t[0],t[1],t[2],o[0],o[1],o[2],m[0],m[1],m[2])}throw new TypeError("Arrays with two or thee dimensional points expected")}function v(e){return 1===e.length?e[0]:e.length>1&&Array.isArray(e[0])&&e.every((e=>Array.isArray(e)&&1===e.length))?m(e):e}function x(e){return 2===e.length&&d(e[0])&&d(e[1])}function b(e){return 3===e.length&&d(e[0])&&d(e[1])&&d(e[2])}function w(e,t,r,n,i,o,s,c,f,p,m,h){var d=u(l(e,t),l(r,n)),y=u(l(i,o),l(s,c)),g=u(l(f,p),l(m,h));return a(a(d,y),g)}})),nm="permutations",im=Oe(nm,["typed","factorial"],(e=>{var{typed:t,factorial:r}=e;return t(nm,{"number | BigNumber":r,"number, number":function(e,t){if(!V(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!V(t)||t<0)throw new TypeError("Positive integer value expected in function permutations");if(t>e)throw new TypeError("second argument k must be less than or equal to first argument n");return Vo(e-t+1,e)},"BigNumber, BigNumber":function(e,t){var r,n;if(!am(e)||!am(t))throw new TypeError("Positive integer value expected in function permutations");if(t.gt(e))throw new TypeError("second argument k must be less than or equal to first argument n");for(r=e.mul(0).add(1),n=e.minus(t).plus(1);n.lte(e);n=n.plus(1))r=r.times(n);return r}})}));function am(e){return e.isInteger()&&e.gte(0)}var om="setIntersect",sm=Oe(om,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(om,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(0===n(r(e),new a(0))||0===n(r(t),new a(0)))s=[];else{var u=pt(ot(Array.isArray(e)?e:e.toArray()).sort(i)),c=pt(ot(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var l=0;l{var{typed:t,size:r,concat:n,subset:i,setIntersect:a,setSymDifference:o,Index:s}=e;return t(um,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new s(0)))return ot(t);if(0===i(r(t),new s(0)))return ot(e);var u=ot(e),c=ot(t);return n(o(u,c),a(u,c))}})})),lm=Oe("Spa",["addScalar","equalScalar","FibonacciHeap"],(e=>{var{addScalar:t,equalScalar:r,FibonacciHeap:n}=e;function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new n}return i.prototype.type="Spa",i.prototype.isSpa=!0,i.prototype.set=function(e,t){if(this._values[e])this._values[e].value=t;else{var r=this._heap.insert(e,t);this._values[e]=r}},i.prototype.get=function(e){var t=this._values[e];return t?t.value:0},i.prototype.accumulate=function(e,r){var n=this._values[e];n?n.value=t(n.value,r):(n=this._heap.insert(e,r),this._values[e]=n)},i.prototype.forEach=function(e,t,n){var i=this._heap,a=this._values,o=[],s=i.extractMinimum();for(s&&o.push(s);s&&s.key<=t;)s.key>=e&&(r(s.value,0)||n(s.key,s.value,this)),(s=i.extractMinimum())&&o.push(s);for(var u=0;u{var{typed:t,Unit:r}=e;return t(fm,{Unit:function(e){return e.clone()},string:function(e){return r.isValuelessUnit(e)?new r(null,e):r.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string":function(e,t){return new r(e,t)},"Array | Matrix":function(e){return Wt(e,this)}})})),mm="log1p",hm=Oe(mm,["typed","config","divideScalar","log","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,log:i,Complex:a}=e;return t(mm,{number:function(e){return e>=-1||r.predictable?J(e):o(new a(e,0))},Complex:o,BigNumber:function(e){var t=e.plus(1);return!t.isNegative()||r.predictable?t.ln():o(new a(e.toNumber(),0))},"Array | Matrix":function(e){return Wt(e,this)},"any, any":function(e,t){return n(this(e),i(t))}});function o(e){var t=e.re+1;return new a(Math.log(Math.sqrt(t*t+e.im*e.im)),Math.atan2(e.im,t))}})),dm="stirlingS2",ym=Oe(dm,["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","larger"],(e=>{var{typed:t,addScalar:r,subtract:n,multiplyScalar:i,divideScalar:a,pow:o,factorial:s,combinations:u,isNegative:c,isInteger:l,larger:f}=e;return t(dm,{"number | BigNumber, number | BigNumber":function(e,t){if(!l(e)||c(e)||!l(t)||c(t))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(f(t,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");for(var p=s(t),m=0,h=0;h<=t;h++){var d=o(-1,n(t,h)),y=u(t,h),g=o(h,e);m=r(m,i(i(y,g),d))}return a(m,p)}})})),gm="bellNumbers",vm=Oe(gm,["typed","addScalar","isNegative","isInteger","stirlingS2"],(e=>{var{typed:t,addScalar:r,isNegative:n,isInteger:i,stirlingS2:a}=e;return t(gm,{"number | BigNumber":function(e){if(!i(e)||n(e))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var t=0,o=0;o<=e;o++)t=r(t,a(e,o));return t}})})),xm=Oe("lup",["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],(e=>{var{typed:t,matrix:r,abs:n,addScalar:i,divideScalar:a,multiplyScalar:o,subtract:s,larger:u,equalScalar:c,unaryMinus:l,DenseMatrix:f,SparseMatrix:p,Spa:m}=e;return t("lup",{DenseMatrix:function(e){return h(e)},SparseMatrix:function(e){return d(e)},Array:function(e){var t=h(r(e));return{L:t.L.valueOf(),U:t.U.valueOf(),p:t.p}}});function h(e){var t,r,l,p=e._size[0],m=e._size[1],h=Math.min(p,m),d=Me(e._data),y=[],g=[p,h],v=[],x=[h,m],b=[];for(t=0;t0)for(t=0;t0&&e.forEach(0,r-1,(function(t,r){p._forEachRow(t,v,x,b,(function(n,i){n>t&&e.accumulate(n,l(o(i,r)))}))}));var C,_,T,B,q=r,z=e.get(r),k=n(z);e.forEach(r+1,s-1,(function(e,t){var r=n(t);u(r,k)&&(q=e,k=r,z=t)})),r!==q&&(p._swapRows(r,q,w[1],v,x,b),p._swapRows(r,q,E[1],N,M,S),e.swap(r,q),_=q,T=O[C=r],B=O[_],A[T]=_,A[B]=C,O[C]=B,O[_]=T),e.forEach(0,s-1,(function(e,t){e<=r?(N.push(t),M.push(e)):(t=a(t,z),c(t,0)||(v.push(t),x.push(e)))}))};for(r=0;r{var{typed:t,compareNatural:r}=e;return t(bm,{"Array | Matrix":function(e){return Array.isArray(e)?ot(e).length:ot(e.toArray()).length},"Array | Matrix, boolean":function(e,t){if(!1===t||0===e.length)return Array.isArray(e)?ot(e).length:ot(e.toArray()).length;for(var n=ot(Array.isArray(e)?e:e.toArray()).sort(r),i=1,a=1;a{var{typed:t,matrix:r,subtract:n,multiply:i,unaryMinus:a,lup:o}=e;return t("det",{any:function(e){return Me(e)},"Array | Matrix":function(e){var t;switch((t=h(e)?e.size():Array.isArray(e)?(e=r(e)).size():[]).length){case 0:return Me(e);case 1:if(1===t[0])return Me(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+ve(t)+")");case 2:var s=t[0],u=t[1];if(s===u)return function(e,t,r){if(1===t)return Me(e[0][0]);if(2===t)return n(i(e[0][0],e[1][1]),i(e[1][0],e[0][1]));for(var s=o(e),u=s.U[0][0],c=1;c=t)break;for(var m=f,h=0;!p[s.p[m]];)p[s.p[m]]=!0,m=s.p[m],h++;h%2==0&&l++}return l%2==0?u:a(u)}(e.clone().valueOf(),s);throw new RangeError("Matrix must be square (size: "+ve(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+ve(t)+")")}}})})),Mm=Oe("inv",["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],(e=>{var{typed:t,matrix:r,divideScalar:n,addScalar:i,multiply:a,unaryMinus:o,det:s,identity:u,abs:c}=e;return t("inv",{"Array | Matrix":function(e){var t=h(e)?e.size():Ze(e);switch(t.length){case 1:if(1===t[0])return h(e)?r([n(1,e.valueOf()[0])]):[n(1,e[0])];throw new RangeError("Matrix must be square (size: "+ve(t)+")");case 2:var i=t[0],a=t[1];if(i===a)return h(e)?r(l(e.valueOf(),i,a),e.storage()):l(e,i,a);throw new RangeError("Matrix must be square (size: "+ve(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+ve(t)+")")}},any:function(e){return n(1,e)}});function l(e,t,r){var l,f,p,m,h;if(1===t){if(0===(m=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero");return[[n(1,m)]]}if(2===t){var d=s(e);if(0===d)throw Error("Cannot calculate inverse, determinant is zero");return[[n(e[1][1],d),n(o(e[0][1]),d)],[n(o(e[1][0]),d),n(e[0][0],d)]]}var y=e.concat();for(l=0;lx&&(x=c(y[l][v]),b=l),l++;if(0===x)throw Error("Cannot calculate inverse, determinant is zero");(l=b)!==v&&(h=y[v],y[v]=y[l],y[l]=h,h=g[v],g[v]=g[l],g[l]=h);var w=y[v],N=g[v];for(l=0;l{var{typed:t,matrix:r,lup:n,slu:i,usolve:a,lsolve:o,DenseMatrix:s}=e,u=Dl({DenseMatrix:s});return t(Em,{"Array, Array | Matrix":function(e,t){e=r(e);var i=n(e);return l(i.L,i.U,i.p,null,t).valueOf()},"DenseMatrix, Array | Matrix":function(e,t){var r=n(e);return l(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){var r=n(e);return l(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,r,n){var a=i(e,r,n);return l(a.L,a.U,a.p,a.q,t)},"Object, Array | Matrix":function(e,t){return l(e.L,e.U,e.p,e.q,t)}});function c(e){if(h(e))return e;if(m(e))return r(e);throw new TypeError("Invalid Matrix LU decomposition")}function l(e,t,r,n,i){e=c(e),t=c(t),r&&((i=u(e,i,!0))._data=Sm(r,i._data));var s=o(e,i),l=a(t,s);return n&&(l._data=Sm(n,l._data)),l}})),Om="sqrtm",Cm=Oe(Om,["typed","abs","add","multiply","sqrt","subtract","inv","size","max","identity"],(e=>{var{typed:t,abs:r,add:n,multiply:i,sqrt:a,subtract:o,inv:s,size:u,max:c,identity:l}=e,f=1e-6;function p(e){var t,a=0,p=e,m=l(u(e));do{var h=p;if(p=i(.5,n(h,s(m))),m=i(.5,n(m,s(h))),(t=c(r(o(p,h))))>f&&++a>1e3)throw new Error("computing square root of matrix: iterative method could not converge")}while(t>f);return p}return t(Om,{"Array | Matrix":function(e){var t=h(e)?e.size():Ze(e);switch(t.length){case 1:if(1===t[0])return a(e);throw new RangeError("Matrix must be square (size: "+ve(t)+")");case 2:if(t[0]===t[1])return p(e);throw new RangeError("Matrix must be square (size: "+ve(t)+")");default:throw new RangeError("Matrix must be at most two dimensional (size: "+ve(t)+")")}}})})),_m=Oe("divide",["typed","matrix","multiply","equalScalar","divideScalar","inv"],(e=>{var{typed:t,matrix:r,multiply:n,equalScalar:i,divideScalar:a,inv:o}=e,s=vc({typed:t,equalScalar:i}),u=wc({typed:t});return t("divide",Se({"Array | Matrix, Array | Matrix":function(e,t){return n(e,o(t))},"DenseMatrix, any":function(e,t){return u(e,t,a,!1)},"SparseMatrix, any":function(e,t){return s(e,t,a,!1)},"Array, any":function(e,t){return u(r(e),t,a,!1).valueOf()},"any, Array | Matrix":function(e,t){return n(e,o(t))}},a.signatures))})),Tm="expm",Bm=Oe(Tm,["typed","abs","add","identity","inv","multiply"],(e=>{var{typed:t,abs:r,add:n,identity:i,inv:a,multiply:o}=e;return t(Tm,{Matrix:function(e){var t=e.size();if(2!==t.length||t[0]!==t[1])throw new RangeError("Matrix must be square (size: "+ve(t)+")");for(var u=t[0],c=function(e){for(var t=e.size()[0],n=0,i=0;i1&&(v=o(v,m),x=-x),h=n(h,o(y=y*(f-b+1)/((2*f-b+1)*b),v)),d=n(d,o(y*x,v));for(var w=o(a(d),h),N=0;N{var{typed:t,matrix:r,divide:n,sum:i,multiply:a,dotDivide:o,log:s,isNumeric:u}=e;return t(qm,{"Array, Array":function(e,t){return c(r(e),r(t))},"Matrix, Array":function(e,t){return c(e,r(t))},"Array, Matrix":function(e,t){return c(r(e),t)},"Matrix, Matrix":function(e,t){return c(e,t)}});function c(e,t){var r=t.size().length,c=e.size().length;if(r>1)throw new Error("first object must be one dimensional");if(c>1)throw new Error("second object must be one dimensional");if(r!==c)throw new Error("Length of two vectors must be equal");if(0===i(e))throw new Error("Sum of elements in first object must be non zero");if(0===i(t))throw new Error("Sum of elements in second object must be non zero");var l=n(e,i(e)),f=n(t,i(t)),p=i(a(l,s(o(l,f))));return u(p)?p:Number.NaN}})),km="median",Im=Oe(km,["typed","add","divide","compare","partitionSelect"],(e=>{var{typed:t,add:r,divide:n,compare:i,partitionSelect:a}=e;function o(e){try{var t=(e=ot(e.valueOf())).length;if(0===t)throw new Error("Cannot calculate median of an empty array");if(t%2==0){for(var r=t/2-1,n=a(e,r+1),o=e[r],c=0;c0&&(o=e[c]);return u(o,n)}var l=a(e,(t-1)/2);return s(l)}catch(e){throw an(e,"median")}}var s=t({"number | BigNumber | Complex | Unit":function(e){return e}}),u=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,t){return n(r(e,t),2)}});return t(km,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("median(A, dim) is not yet supported")},"...":function(e){if(Vt(e))throw new TypeError("Scalar values expected in function median");return o(e)}})}));function Dm(e){var{addScalar:t,subtract:r,flatten:n,multiply:i,multiplyScalar:a,divideScalar:o,sqrt:s,abs:u,bignumber:c,diag:l,inv:f,qr:p,usolve:m,usolveAll:h,equal:d,complex:y,larger:g,smaller:v,matrixFromColumns:x,dot:b}=e;function w(e,n,i,o){var u=t(e,o),c=r(a(e,o),a(n,i)),l=a(u,.5),f=a(s(r(a(u,u),a(4,c))),.5);return[t(l,f),r(l,f)]}function N(e,t,n,i,a,o,s,l){var f="BigNumber"===l,p="Complex"===l,m=f?c(0):p?y(0):0,h=f?c(1):p?y(1):1;if(v(u(n),s))return[[h,m],[m,h]];if(g(u(r(a,o)),s))return[[r(a,i),r(o,i)],[n,n]];var d=r(e,a),x=r(t,a),b=r(n,a),w=r(i,a);return v(u(x),s)?[[d,h],[b,m]]:[[x,m],[w,h]]}function M(e,t){for(var r=0;r=5)return null;for(s=0;;){var u=m(e,a);if(v(C(O(a,[u])),n))break;if(++s>=10)return null;a=_(u)}return a}function A(e,t,r){var n="BigNumber"===r,i="Complex"===r,a=Array(e).fill(0).map((e=>2*Math.random()-1));return n&&(a=a.map((e=>c(e)))),i&&(a=a.map((e=>y(e)))),_(a=O(a,t),r)}function O(e,t){for(var n of t)e=r(e,i(o(b(n,e),b(n,n)),n));return e}function C(e){return u(s(b(e,e)))}function _(e,t){var r="Complex"===t,n="BigNumber"===t?c(1):r?y(1):1;return i(o(n,C(e)),e)}return function(e,s,m,b,A){void 0===A&&(A=!0);var O=function(e,r,n,i,s){var f,p="BigNumber"===i,m="Complex"===i,h=p?c(0):m?y(0):0,x=p?c(1):m?y(1):1,b=p?c(10):2,w=a(b,b);s&&(f=Array(r).fill(x));var N=!1;for(;!N;){N=!0;for(var M=0;M1&&(E=l(Array(x-1).fill(h)))),x-=1,d.pop();for(var q=0;q2&&(E=l(Array(x-2).fill(h)))),x-=2,d.pop(),d.pop();for(var k=0;k+r(u(e),u(t)))),A>100){var I=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+g.join(", "));throw I.values=g,I.vectors=[],I}var D=s?i(S,function(e,t){for(var r=[],n=0;ni(a,e)))).shift();I.lengthn(e))))}if(0!==B.length){var R=new Error("Failed to find eigenvectors for the following eigenvalues: "+B.join(", "));throw R.values=o,R.vectors=O,R}return O}(e,s,T,_,m,b),C=x(...C)),{values:_,vectors:C}}}var Rm=["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"],Um=Oe("eigs",Rm,(e=>{var{config:t,typed:r,matrix:n,addScalar:i,subtract:a,equal:o,abs:f,atan:p,cos:m,sin:h,multiplyScalar:d,divideScalar:y,inv:g,bignumber:v,multiply:x,add:b,larger:w,column:N,flatten:M,number:S,complex:E,sqrt:A,diag:O,qr:C,usolve:_,usolveAll:T,im:B,re:q,smaller:z,matrixFromColumns:k,dot:I}=e,D=function(e){var{config:t,addScalar:r,subtract:n,abs:i,atan:a,cos:o,sin:s,multiplyScalar:u,inv:c,bignumber:l,multiply:f,add:p}=e;function m(e,t){for(var r,n=e.length,i=Math.abs(t/n),a=new Array(n),o=0;o=Math.abs(i);){var u=s[0][0],c=s[0][1];e=b(e,r=d(e[u][u],e[c][c],e[u][c]),u,c),a=g(a,r,u,c),s=w(e)}for(var l=S(n,0),f=0;f=i(a);){var c=u[0][0],l=u[0][1];e=x(e,r=y(e[c][c],e[l][l],e[c][l]),c,l),o=v(o,r,c,l),u=N(e)}for(var f=S(n,0),p=0;p2&&void 0!==arguments[2]?arguments[2]:t.epsilon,i=arguments.length>3?arguments[3]:void 0;if("number"===i)return m(e,n);if("BigNumber"===i)return h(e,n);throw TypeError("Unsupported data type: "+i)}}({config:t,addScalar:i,subtract:a,column:N,flatten:M,equal:o,abs:f,atan:p,cos:m,sin:h,multiplyScalar:d,inv:g,bignumber:v,complex:E,multiply:x,add:b}),R=Dm({config:t,addScalar:i,subtract:a,multiply:x,multiplyScalar:d,flatten:M,divideScalar:y,sqrt:A,abs:f,bignumber:v,diag:O,qr:C,inv:g,usolve:_,usolveAll:T,equal:o,complex:E,larger:w,smaller:z,matrixFromColumns:k,dot:I});return r("eigs",{Array:function(e){return U(n(e))},"Array, number|BigNumber":function(e,t){return U(n(e),t)},Matrix:function(e){var{values:t,vectors:r}=U(e);return{values:n(t),vectors:n(r)}},"Matrix, number|BigNumber":function(e,t){var{values:r,vectors:i}=U(e,t);return{values:n(r),vectors:n(i)}}});function U(e,r){void 0===r&&(r=t.epsilon);var n=e.size();if(2!==n.length||n[0]!==n[1])throw new RangeError("Matrix must be square (size: "+ve(n)+")");var i=e.toArray(),o=n[0];if(function(e,t,r){for(var n=0;n{var{typed:t,add:r,divide:n,multiply:i,factorial:a,isInteger:o,isPositive:s}=e;return t(Fm,{"Array | Matrix":function(e){var t=0,u=1;return Zt(e,(function(e){if(!o(e)||!s(e))throw new TypeError("Positive integer value expected in function multinomial");t=r(t,e),u=i(u,a(e))})),n(a(t),u)}})})),Lm=["typed","abs","map","median","subtract"],Hm=Oe("mad",Lm,(e=>{var{typed:t,abs:r,map:n,median:i,subtract:a}=e;return t("mad",{"Array | Matrix":o,"...":function(e){return o(e)}});function o(e){if(0===(e=ot(e.valueOf())).length)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var t=i(e);return i(n(e,(function(e){return r(a(e,t))})))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf("median")?new TypeError(e.message.replace("median","mad")):an(e,"mad")}}})),$m="norm",Gm=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],Vm=Oe($m,Gm,(e=>{var{typed:t,abs:r,add:n,pow:i,conj:a,sqrt:o,multiply:s,equalScalar:u,larger:c,smaller:l,matrix:f,ctranspose:p,eigs:m}=e;return t($m,{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},boolean:function(e){return Math.abs(e)},Array:function(e){return y(f(e),2)},Matrix:function(e){return y(e,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(e){return this(e)},"Array, number | BigNumber | string":function(e,t){return y(f(e),t)},"Matrix, number | BigNumber | string":function(e,t){return y(e,t)}});function h(e,t){if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=0;return e.forEach((function(e){var n=r(e);c(n,t)&&(t=n)}),!0),t}(e);if(t===Number.NEGATIVE_INFINITY||"-inf"===t)return function(e){var t;return e.forEach((function(e){var n=r(e);t&&!l(n,t)||(t=n)}),!0),t||0}(e);if("fro"===t)return y(e,2);if("number"==typeof t&&!isNaN(t)){if(!u(t,0)){var a=0;return e.forEach((function(e){a=n(i(r(e),t),a)}),!0),i(a,1/t)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}function d(e,t){if(1===t)return function(e){var t=[],i=0;return e.forEach((function(e,a){var o=a[1],s=n(t[o]||0,r(e));c(s,i)&&(i=s),t[o]=s}),!0),i}(e);if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=[],i=0;return e.forEach((function(e,a){var o=a[0],s=n(t[o]||0,r(e));c(s,i)&&(i=s),t[o]=s}),!0),i}(e);if("fro"===t)return function(e){var t=0;return e.forEach((function(e,r){t=n(t,s(e,a(e)))})),r(o(t))}(e);if(2===t)return function(e){var t=e.size();if(t[0]!==t[1])throw new RangeError("Invalid matrix dimensions");var n=p(e),i=s(n,e),a=m(i).values.toArray(),u=a[a.length-1];return r(o(u))}(e);throw new Error("Unsupported parameter value "+t)}function y(e,t){var r=e.size();if(1===r.length)return h(e,t);if(2===r.length){if(r[0]&&r[1])return d(e,t);throw new RangeError("Invalid matrix dimensions")}}})),Zm="rotationMatrix",Wm=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],Ym=Oe(Zm,Wm,(e=>{var{typed:t,config:r,multiplyScalar:n,addScalar:i,unaryMinus:a,norm:o,BigNumber:s,matrix:c,DenseMatrix:l,SparseMatrix:f,cos:p,sin:m}=e;return t(Zm,{"":function(){return"Matrix"===r.matrix?c([]):[]},string:function(e){return c(e)},"number | BigNumber | Complex | Unit":function(e){return h(e,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(e,t){return h(e,t)},"number | BigNumber | Complex | Unit, Array":function(e,t){var r=c(t);return d(r),v(e,r,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,t){d(t);var n=t.storage()||("Matrix"===r.matrix?"dense":void 0);return v(e,t,n)},"number | BigNumber | Complex | Unit, Array, string":function(e,t,r){var n=c(t);return d(n),v(e,n,r)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,t,r){return d(t),v(e,t,r)}});function h(e,t){var r=u(e)?new s(-1):-1,i=p(e),a=m(e);return g([[i,n(r,a)],[a,i]],t)}function d(e){var t=e.size();if(t.length<1||3!==t[0])throw new RangeError("Vector must be of dimensions 1x3")}function y(e){return e.reduce(((e,t)=>n(e,t)))}function g(e,t){if(t){if("sparse"===t)return new f(e);if("dense"===t)return new l(e);throw new TypeError('Unknown matrix type "'.concat(t,'"'))}return e}function v(e,t,r){var n=o(t);if(0===n)throw new RangeError("Rotation around zero vector");var c=u(e)?s:null,l=c?new c(1):1,f=c?new c(-1):-1,h=c?new c(t.get([0])/n):t.get([0])/n,d=c?new c(t.get([1])/n):t.get([1])/n,v=c?new c(t.get([2])/n):t.get([2])/n,x=p(e),b=i(l,a(x)),w=m(e);return g([[i(x,y([h,h,b])),i(y([h,d,b]),y([f,v,w])),i(y([h,v,b]),y([d,w]))],[i(y([h,d,b]),y([v,w])),i(x,y([d,d,b])),i(y([d,v,b]),y([f,h,w]))],[i(y([h,v,b]),y([f,d,w])),i(y([d,v,b]),y([h,w])),i(x,y([v,v,b]))]],r)}})),Jm="rotate",Xm=["typed","multiply","rotationMatrix"],Qm=Oe(Jm,Xm,(e=>{var{typed:t,multiply:r,rotationMatrix:n}=e;return t(Jm,{"Array , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),r(n(t),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),r(n(t),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),r(n(t,a),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),r(n(t,a),e)}});function i(e,t){var r=Array.isArray(e)?Ze(e):e.size();if(r.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(t));if(2===r.length&&1!==r[1])throw new RangeError("Vector must be of dimensions 1x".concat(t));if(r[0]!==t)throw new RangeError("Vector must be of dimensions 1x".concat(t))}})),Km=Bn({config:o}),eh=zn({}),th=Yn({BigNumber:Km,config:o}),rh=Hn({}),nh=Ei({BigNumber:Km,config:o}),ih=aa({}),ah=ni({Complex:eh}),oh=Gn({BigNumber:Km,config:o}),sh=Qn({BigNumber:Km,config:o}),uh=ei({BigNumber:Km,config:o}),ch=oa({}),lh=Vn({BigNumber:Km,config:o}),fh=$n({}),ph=Jn({BigNumber:Km,config:o}),mh=sa({}),hh=ua({}),dh=ti({BigNumber:Km,config:o}),yh=$i({BigNumber:Km,config:o}),gh=Wn({BigNumber:Km,config:o}),vh=Ln({}),xh=ii({}),bh=ca({Matrix:ch}),wh=ki({BigNumber:Km,config:o}),Nh=Xn({BigNumber:Km,config:o}),Mh=Zn({BigNumber:Km,config:o}),Sh=la({}),Eh=ri({BigNumber:Km,config:o}),Ah=ma({BigNumber:Km,Complex:eh,DenseMatrix:bh,Fraction:ih}),Oh=La({BigNumber:Km,config:o,typed:Ah}),Ch=zi({BigNumber:Km,config:o}),_h=Ha({typed:Ah}),Th=Ga({Complex:eh,config:o,typed:Ah}),Bh=lo({BigNumber:Km,typed:Ah}),qh=po({BigNumber:Km,Complex:eh,config:o,typed:Ah}),zh=ho({typed:Ah}),kh=yo({typed:Ah}),Ih=vo({BigNumber:Km,Complex:eh,config:o,typed:Ah}),Dh=xo({typed:Ah}),Rh=bo({typed:Ah}),Uh=No({Complex:eh,config:o,typed:Ah}),Fh=Mo({BigNumber:Km,typed:Ah}),Ph=jo({typed:Ah}),jh=Ho({typed:Ah}),Lh=Go({typed:Ah}),Hh=Yo({typed:Ah}),$h=Xo({Complex:eh,typed:Ah}),Gh=Ko({typed:Ah}),Vh=ts({typed:Ah}),Zh=ns({BigNumber:Km,typed:Ah}),Wh=is({BigNumber:Km,typed:Ah}),Yh=os({typed:Ah}),Jh=cs({config:o,typed:Ah}),Xh=ls({typed:Ah}),Qh=ys({typed:Ah}),Kh=vs({Complex:eh,typed:Ah}),ed=xs({typed:Ah}),td=Ns({typed:Ah}),rd=Es({typed:Ah}),nd=Os({typed:Ah}),id=Cs({format:rd,typed:Ah}),ad=_s({typed:Ah}),od=Bs({typed:Ah}),sd=Us({typed:Ah}),ud=Ps({typed:Ah}),cd=Ls({typed:Ah}),ld=Kn({BigNumber:Km,config:o}),fd=$s({Complex:eh,config:o,typed:Ah}),pd=Vs({Complex:eh,config:o,typed:Ah}),md=Zs({typed:Ah}),hd=Ys({typed:Ah}),dd=tu({typed:Ah}),yd=ru({typed:Ah}),gd=nu({format:rd,typed:Ah}),vd=uu({config:o,typed:Ah}),xd=lu({typed:Ah}),bd=hu({config:o,typed:Ah}),wd=du({typed:Ah}),Nd=yu({BigNumber:Km,typed:Ah}),Md=vu({BigNumber:Km,Fraction:ih,complex:$h,typed:Ah}),Sd=xu({typed:Ah}),Ed=bu({Matrix:ch,equalScalar:Jh,typed:Ah}),Ad=Nu({typed:Ah}),Od=Su({typed:Ah}),Cd=Au({typed:Ah}),_d=Ou({typed:Ah}),Td=_u({typed:Ah}),Bd=Bu({Complex:eh,config:o,typed:Ah}),qd=zu({BigNumber:Km,typed:Ah}),zd=Ur({isInteger:od,typed:Ah}),kd=Iu({BigNumber:Km,Complex:eh,config:o,typed:Ah}),Id=Du({format:rd,typed:Ah}),Dd=Uu({typed:Ah}),Rd=Pu({typed:Ah}),Ud=Lu({BigNumber:Km,typed:Ah}),Fd=$u({typed:Ah}),Pd=Vu({typed:Ah}),jd=Wu({config:o,typed:Ah}),Ld=Ju({BigNumber:Km,typed:Ah}),Hd=Qu({typed:Ah}),$d=ec({SparseMatrix:Ed,typed:Ah}),Gd=tc({Complex:eh,config:o,typed:Ah}),Vd=rc({typed:Ah}),Zd=ic({typed:Ah}),Wd=oc({BigNumber:Km,Complex:eh,config:o,typed:Ah}),Yd=sc({BigNumber:Km,typed:Ah}),Jd=uc({Fraction:ih,typed:Ah}),Xd=lc({typed:Ah}),Qd=pc({DenseMatrix:bh,Matrix:ch,SparseMatrix:Ed,typed:Ah}),Kd=hc({isZero:cd,matrix:Qd,typed:Ah}),ey=Nc({DenseMatrix:bh,equalScalar:Jh,matrix:Qd,typed:Ah}),ty=Ac({BigNumber:Km,equalScalar:Jh,matrix:Qd,typed:Ah}),ry=Oc({bignumber:Fh,fraction:Jd,number:yd}),ny=Cc({DenseMatrix:bh,equalScalar:Jh,matrix:Qd,typed:Ah}),iy=Tc({config:o,multiplyScalar:hd,numeric:ry,typed:Ah}),ay=qc({isInteger:od,matrix:Qd,typed:Ah}),oy=kc({matrix:Qd,config:o,typed:Ah}),sy=Rc({DenseMatrix:bh,config:o,matrix:Qd,typed:Ah}),uy=Fc({matrix:Qd,typed:Ah}),cy=Wr({matrix:Qd,typed:Ah}),ly=Lc({DenseMatrix:bh,addScalar:zh,equalScalar:Jh,matrix:Qd,typed:Ah,unaryMinus:Zd}),fy=$c({matrix:Qd,typed:Ah}),py=Gc({matrix:Qd,typed:Ah}),my=Zc({BigNumber:Km,config:o,matrix:Qd,typed:Ah}),hy=Yc({BigNumber:Km,config:o,matrix:Qd,typed:Ah}),dy=Jc({equalScalar:Jh,matrix:Qd,not:dd,typed:Ah,zeros:hy}),yy=Qc({equalScalar:Jh,matrix:Qd,typed:Ah}),gy=el({DenseMatrix:bh,matrix:Qd,typed:Ah}),vy=rl({BigNumber:Km,Complex:eh,Fraction:ih,config:o,isNegative:sd,matrix:Qd,typed:Ah,unaryMinus:Zd}),xy=il({BigNumber:Km,DenseMatrix:bh,Fraction:ih,config:o,equalScalar:Jh,matrix:Qd,typed:Ah}),by=ol({matrix:Qd,typed:Ah}),wy=tn({isInteger:od,matrix:Qd,typed:Ah}),Ny=ul({prod:iy,size:oy,typed:Ah}),My=ll({conj:Gh,transpose:py,typed:Ah}),Sy=pl({DenseMatrix:bh,SparseMatrix:Ed,matrix:Qd,typed:Ah}),Ey=hl({numeric:ry,typed:Ah}),Ay=yl({DenseMatrix:bh,divideScalar:Ey,equalScalar:Jh,matrix:Qd,typed:Ah}),Oy=vl({DenseMatrix:bh,equalScalar:Jh,matrix:Qd,typed:Ah}),Cy=bl({matrix:Qd,typed:Ah}),_y=Nl({BigNumber:Km,DenseMatrix:bh,equalScalar:Jh,matrix:Qd,typed:Ah}),Ty=Sl({isNumeric:Xd,typed:Ah}),By=Al({abs:_h,addScalar:zh,divideScalar:Ey,isPositive:ud,multiplyScalar:hd,smaller:sy,sqrt:Gd,typed:Ah}),qy=Ol({DenseMatrix:bh,smaller:sy}),zy=Cl({ImmutableDenseMatrix:qy}),ky=Tl({matrix:Qd,multiplyScalar:hd,typed:Ah}),Iy=ql({DenseMatrix:bh,config:o,matrix:Qd,typed:Ah}),Dy=Il({DenseMatrix:bh,equalScalar:Jh,matrix:Qd,typed:Ah,zeros:hy}),Ry=Ul({DenseMatrix:bh,divideScalar:Ey,equalScalar:Jh,matrix:Qd,multiplyScalar:hd,subtract:ly,typed:Ah}),Uy=Pl({flatten:Cy,matrix:Qd,size:oy,typed:Ah}),Fy=un({config:o,numeric:ry,smaller:sy,typed:Ah}),Py=Ll({isNaN:Fd,isNumeric:Xd,typed:Ah}),jy=$l({Complex:eh,config:o,divideScalar:Ey,typed:Ah}),Ly=Gl({BigNumber:Km,config:o,matrix:Qd,typed:Ah}),Hy=Zl({compare:xy,isNaN:Fd,isNumeric:Xd,typed:Ah}),$y=Yl({config:o,matrix:Qd}),Gy=Xl({DenseMatrix:bh,equalScalar:Jh,matrix:Qd,typed:Ah,zeros:hy}),Vy=nf({BigNumber:Km,DenseMatrix:bh,equalScalar:Jh,matrix:Qd,typed:Ah,zeros:hy}),Zy=sf({DenseMatrix:bh,config:o,matrix:Qd,typed:Ah}),Wy=cf({DenseMatrix:bh,config:o,equalScalar:Jh,matrix:Qd,typed:Ah}),Yy=ff({DenseMatrix:bh,divideScalar:Ey,equalScalar:Jh,matrix:Qd,multiplyScalar:hd,subtract:ly,typed:Ah}),Jy=pf({DenseMatrix:bh,matrix:Qd,typed:Ah}),Xy=mf({DenseMatrix:bh,SparseMatrix:Ed,addScalar:zh,equalScalar:Jh,matrix:Qd,typed:Ah}),Qy=yf({BigNumber:Km,DenseMatrix:bh,equalScalar:Jh,matrix:Qd,typed:Ah}),Ky=vf({DenseMatrix:bh,equalScalar:Jh,matrix:Qd,typed:Ah}),eg=bf({addScalar:zh,combinations:Hh,divideScalar:Ey,isInteger:od,isNegative:sd,multiplyScalar:hd,typed:Ah}),tg=Mf({compare:xy,typed:Ah}),rg=Ef({equal:Oy,typed:Ah}),ng=Lr({matrix:Qd,number:yd,subtract:ly,typed:Ah}),ig=Af({addScalar:zh,conj:Gh,multiplyScalar:hd,size:oy,typed:Ah}),ag=Cf({compareText:by,isZero:cd,typed:Ah}),og=_f({config:o,equalScalar:Jh,matrix:Qd,round:Vy,typed:Ah}),sg=Bf({BigNumber:Km,DenseMatrix:bh,SparseMatrix:Ed,config:o,matrix:Qd,typed:Ah}),ug=zf({BigNumber:Km,add:Xy,config:o,equal:Oy,isInteger:od,mod:ey,smaller:sy,typed:Ah,xgcd:my}),cg=If({DenseMatrix:bh,config:o,matrix:Qd,typed:Ah}),lg=Df({Complex:eh,config:o,divideScalar:Ey,typed:Ah}),fg=Uf({DenseMatrix:bh,divideScalar:Ey,equalScalar:Jh,matrix:Qd,multiplyScalar:hd,subtract:ly,typed:Ah}),pg=Pf({flatten:Cy,matrix:Qd,size:oy,typed:Ah}),mg=Lf({addScalar:zh,dot:ig,equalScalar:Jh,matrix:Qd,multiplyScalar:hd,typed:Ah}),hg=Hf({Complex:eh,config:o,fraction:Jd,identity:sg,matrix:Qd,multiply:mg,number:yd,typed:Ah}),dg=$f({addScalar:zh,complex:$h,conj:Gh,divideScalar:Ey,equal:Oy,identity:sg,isZero:cd,matrix:Qd,multiplyScalar:hd,sign:Md,sqrt:Gd,subtract:ly,typed:Ah,unaryMinus:Zd,zeros:hy}),yg=fn({bignumber:Fh,matrix:Qd,config:o,larger:cg,largerEq:Iy,smaller:sy,smallerEq:Zy,typed:Ah}),gg=Vf({DenseMatrix:bh,equalScalar:Jh,matrix:Qd,typed:Ah,zeros:hy}),vg=mn({Index:zy,matrix:Qd,range:yg,typed:Ah}),xg=Wf({DenseMatrix:bh,Index:zy,compareNatural:tg,size:oy,subset:cy,typed:Ah}),bg=Jf({DenseMatrix:bh,Index:zy,compareNatural:tg,size:oy,subset:cy,typed:Ah}),wg=Qf({Index:zy,compareNatural:tg,size:oy,subset:cy,typed:Ah}),Ng=ep({Index:zy,compareNatural:tg,size:oy,subset:cy,typed:Ah}),Mg=mp({SparseMatrix:Ed,abs:_h,add:Xy,divideScalar:Ey,larger:cg,largerEq:Iy,multiply:mg,subtract:ly,transpose:py,typed:Ah}),Sg=dn({add:Xy,config:o,numeric:ry,typed:Ah}),Eg=hp({add:Xy,matrix:Qd,typed:Ah}),Ag=yp({DenseMatrix:bh,divideScalar:Ey,equalScalar:Jh,matrix:Qd,multiplyScalar:hd,subtract:ly,typed:Ah}),Og=vp({Complex:eh,config:o,typed:Ah}),Cg=xp({config:o,equalScalar:Jh,matrix:Qd,round:Vy,typed:Ah}),_g=vn({Index:zy,matrix:Qd,range:yg,typed:Ah}),Tg=wp({addScalar:zh,combinations:Hh,isInteger:od,isNegative:sd,isPositive:ud,larger:cg,typed:Ah}),Bg=Mp({matrix:Qd,multiply:mg,subtract:ly,typed:Ah}),qg=Ep({abs:_h,addScalar:zh,divideScalar:Ey,multiplyScalar:hd,sqrt:Gd,subtract:ly,typed:Ah,unaryMinus:Zd}),zg=Op({equalScalar:Jh,matrix:Qd,multiplyScalar:hd,typed:Ah}),kg=Cp({larger:cg,smaller:sy}),Ig=_p({Complex:eh,ceil:Cg,floor:og,matrix:Qd,typed:Ah}),Dg=kp({BigNumber:Km,Complex:eh,config:o,multiplyScalar:hd,pow:hg,typed:Ah}),Rg=Dp({Index:zy,typed:Ah}),Ug=Rp({equalScalar:Jh,matrix:Qd,typed:Ah}),Fg=on({config:o,larger:cg,numeric:ry,typed:Ah}),Pg=Up({add:Xy,compare:xy,multiply:mg,partitionSelect:Hy,typed:Ah}),jg=Pp({DenseMatrix:bh,Index:zy,compareNatural:tg,size:oy,subset:cy,typed:Ah}),Lg=Lp({Index:zy,compareNatural:tg,size:oy,subset:cy,typed:Ah}),Hg=$p({Index:zy,concat:wy,setDifference:jg,size:oy,subset:cy,typed:Ah}),$g=Vp({compare:xy,compareNatural:tg,matrix:Qd,typed:Ah}),Gg=Yp({BigNumber:Km,Complex:eh,Fraction:ih,abs:_h,addScalar:zh,config:o,divideScalar:Ey,equal:Oy,fix:Ig,format:rd,isNumeric:Xd,multiplyScalar:hd,number:yd,pow:hg,round:Vy,subtract:ly}),Vg=pi({BigNumber:Km,Unit:Gg,config:o}),Zg=Zi({BigNumber:Km,Unit:Gg,config:o}),Wg=Ii({BigNumber:Km,Unit:Gg,config:o}),Yg=di({BigNumber:Km,Unit:Gg,config:o}),Jg=Ri({BigNumber:Km,Unit:Gg,config:o}),Xg=yi({BigNumber:Km,Unit:Gg,config:o}),Qg=Xp({Unit:Gg,typed:Ah}),Kg=Ci({BigNumber:Km,Unit:Gg,config:o}),ev=Kp({DenseMatrix:bh,equalScalar:Jh,matrix:Qd,pow:hg,typed:Ah}),tv=fi({BigNumber:Km,Unit:Gg,config:o}),rv=hi({BigNumber:Km,Unit:Gg,config:o}),nv=tm({gamma:Dg,typed:Ah}),iv=Si({BigNumber:Km,Unit:Gg,config:o}),av=ji({BigNumber:Km,Unit:Gg,config:o}),ov=Ji({BigNumber:Km,Unit:Gg,config:o}),sv=rm({abs:_h,add:Xy,addScalar:zh,config:o,divideScalar:Ey,equalScalar:Jh,flatten:Cy,isNumeric:Xd,isZero:cd,matrix:Qd,multiply:mg,multiplyScalar:hd,smaller:sy,subtract:ly,typed:Ah}),uv=gi({BigNumber:Km,Unit:Gg,config:o}),cv=bi({BigNumber:Km,Unit:Gg,config:o}),lv=Pi({BigNumber:Km,Unit:Gg,config:o}),fv=li({BigNumber:Km,Unit:Gg,config:o}),pv=Wi({BigNumber:Km,Unit:Gg,config:o}),mv=Li({BigNumber:Km,Unit:Gg,config:o}),hv=_i({BigNumber:Km,Unit:Gg,config:o}),dv=xi({BigNumber:Km,Unit:Gg,config:o}),yv=im({factorial:nv,typed:Ah}),gv=ui({BigNumber:Km,Unit:Gg,config:o}),vv=Qi({BigNumber:Km,Unit:Gg,config:o}),xv=Ki({BigNumber:Km,Unit:Gg,config:o}),bv=Ti({BigNumber:Km,Unit:Gg,config:o}),wv=ci({BigNumber:Km,Unit:Gg,config:o}),Nv=Bi({BigNumber:Km,Unit:Gg,config:o}),Mv=sm({DenseMatrix:bh,Index:zy,compareNatural:tg,size:oy,subset:cy,typed:Ah}),Sv=cm({Index:zy,concat:wy,setIntersect:Mv,setSymDifference:Hg,size:oy,subset:cy,typed:Ah}),Ev=lm({FibonacciHeap:kg,addScalar:zh,equalScalar:Jh}),Av=Vi({BigNumber:Km,Unit:Gg,config:o}),Ov=pm({Unit:Gg,typed:Ah}),Cv=Di({BigNumber:Km,Unit:Gg,config:o}),_v=wi({BigNumber:Km,Unit:Gg,config:o}),Tv=mi({BigNumber:Km,Unit:Gg,config:o}),Bv=Mi({BigNumber:Km,Unit:Gg,config:o}),qv=Ui({BigNumber:Km,Unit:Gg,config:o}),zv=Ai({BigNumber:Km,Unit:Gg,config:o}),kv=hm({Complex:eh,config:o,divideScalar:Ey,log:lg,typed:Ah}),Iv=vi({BigNumber:Km,Unit:Gg,config:o}),Dv=Yi({BigNumber:Km,Unit:Gg,config:o}),Rv=ea({BigNumber:Km,Unit:Gg,config:o}),Uv=ta({BigNumber:Km,Unit:Gg,config:o}),Fv=Gi({BigNumber:Km,Unit:Gg,config:o}),Pv=oi({BigNumber:Km,Unit:Gg,config:o}),jv=ym({addScalar:zh,combinations:Hh,divideScalar:Ey,factorial:nv,isInteger:od,isNegative:sd,larger:cg,multiplyScalar:hd,pow:hg,subtract:ly,typed:Ah}),Lv=vm({addScalar:zh,isInteger:od,isNegative:sd,stirlingS2:jv,typed:Ah}),Hv=Fi({BigNumber:Km,Unit:Gg,config:o}),$v=xm({DenseMatrix:bh,Spa:Ev,SparseMatrix:Ed,abs:_h,addScalar:zh,divideScalar:Ey,equalScalar:Jh,larger:cg,matrix:Qd,multiplyScalar:hd,subtract:ly,typed:Ah,unaryMinus:Zd}),Gv=Hi({BigNumber:Km,Unit:Gg,config:o}),Vv=Oi({BigNumber:Km,Unit:Gg,config:o}),Zv=wm({compareNatural:tg,typed:Ah}),Wv=qi({BigNumber:Km,Unit:Gg,config:o}),Yv=Ni({BigNumber:Km,Unit:Gg,config:o}),Jv=Nm({lup:$v,matrix:Qd,multiply:mg,subtract:ly,typed:Ah,unaryMinus:Zd}),Xv=si({BigNumber:Km,Unit:Gg,config:o}),Qv=Mm({abs:_h,addScalar:zh,det:Jv,divideScalar:Ey,identity:sg,matrix:Qd,multiply:mg,typed:Ah,unaryMinus:Zd}),Kv=Am({DenseMatrix:bh,lsolve:Ry,lup:$v,matrix:Qd,slu:Mg,typed:Ah,usolve:Yy}),ex=Cm({abs:_h,add:Xy,identity:sg,inv:Qv,max:Fg,multiply:mg,size:oy,sqrt:Gd,subtract:ly,typed:Ah}),tx=_m({divideScalar:Ey,equalScalar:Jh,inv:Qv,matrix:Qd,multiply:mg,typed:Ah}),rx=Bm({abs:_h,add:Xy,identity:sg,inv:Qv,multiply:mg,typed:Ah}),nx=zm({divide:tx,dotDivide:Ay,isNumeric:Xd,log:lg,matrix:Qd,multiply:mg,sum:Sg,typed:Ah}),ix=wn({add:Xy,divide:tx,typed:Ah}),ax=Im({add:Xy,compare:xy,divide:tx,partitionSelect:Hy,typed:Ah}),ox=Xi({BigNumber:Km,Unit:Gg,config:o}),sx=En({add:Xy,apply:zd,divide:tx,isNaN:Fd,multiply:mg,subtract:ly,typed:Ah}),ux=Cn({sqrt:Gd,typed:Ah,variance:sx}),cx=Um({abs:_h,add:Xy,addScalar:zh,atan:Rh,bignumber:Fh,column:_g,complex:$h,config:o,cos:Rd,diag:Sy,divideScalar:Ey,dot:ig,equal:Oy,flatten:Cy,im:ad,inv:Qv,larger:cg,matrix:Qd,matrixFromColumns:Uy,multiply:mg,multiplyScalar:hd,number:yd,qr:dg,re:wd,sin:Sd,smaller:sy,sqrt:Gd,subtract:ly,typed:Ah,usolve:Yy,usolveAll:Ag}),lx=jm({add:Xy,divide:tx,factorial:nv,isInteger:od,isPositive:ud,multiply:mg,typed:Ah}),fx=Hm({abs:_h,map:md,median:ax,subtract:ly,typed:Ah}),px=Vm({abs:_h,add:Xy,conj:Gh,ctranspose:My,eigs:cx,equalScalar:Jh,larger:cg,matrix:Qd,multiply:mg,pow:hg,smaller:sy,sqrt:Gd,typed:Ah}),mx=Ym({BigNumber:Km,DenseMatrix:bh,SparseMatrix:Ed,addScalar:zh,config:o,cos:Rd,matrix:Qd,multiplyScalar:hd,norm:px,sin:Sd,typed:Ah,unaryMinus:Zd}),hx=Qm({multiply:mg,rotationMatrix:mx,typed:Ah}),dx={},yx={},gx={},vx=_e({math:dx}),xx=He({mathWithTransform:yx}),bx=$e({Node:xx}),wx=At({Node:xx}),Nx=Ot({Node:xx}),Mx=Ct({Node:xx}),Sx=_t({Node:xx}),Ex=Tt({Node:xx,ResultSet:hh}),Ax=Bt({Node:xx}),Ox=qt({Node:xx}),Cx=zt({Node:xx}),_x=kt({classes:gx}),Tx=Dt({Chain:vx,typed:Ah}),Bx=Rt({Node:xx,typed:Ah}),qx=Pt({Node:xx,subset:cy}),zx=jt({matrix:Qd,Node:xx,subset:cy}),kx=Lt({Node:xx,Range:mh,size:oy}),Ix=Ht({Unit:Gg,Node:xx,math:dx}),Dx=Gt({Node:xx,SymbolNode:Ix,math:dx}),Rx=Kt({AccessorNode:qx,ArrayNode:Sx,AssignmentNode:zx,BlockNode:Ex,ConditionalNode:Ax,ConstantNode:Ox,FunctionAssignmentNode:Bx,FunctionNode:Dx,IndexNode:kx,ObjectNode:bx,OperatorNode:wx,ParenthesisNode:Nx,RangeNode:Cx,RelationalNode:Mx,SymbolNode:Ix,config:o,numeric:ry,typed:Ah}),Ux=tr({parse:Rx,typed:Ah}),Fx=nr({parse:Rx,typed:Ah}),Px=ir({parse:Rx}),jx=ar({evaluate:Fx}),Lx=sr({Parser:jx,typed:Ah}),Hx=vr({bignumber:Fh,fraction:Jd,AccessorNode:qx,ArrayNode:Sx,ConstantNode:Ox,FunctionNode:Dx,IndexNode:kx,ObjectNode:bx,OperatorNode:wx,ParenthesisNode:Nx,SymbolNode:Ix,add:Xy,config:o,divide:tx,equal:Oy,isZero:cd,mathWithTransform:yx,matrix:Qd,multiply:mg,parse:Rx,pow:hg,subtract:ly,typed:Ah}),$x=br({ConstantNode:Ox,FunctionNode:Dx,OperatorNode:wx,ParenthesisNode:Nx,SymbolNode:Ix,config:o,equal:Oy,isZero:cd,numeric:ry,parse:Rx,simplify:Hx,typed:Ah}),Gx=Er({Help:Px,mathWithTransform:yx,typed:Ah}),Vx=Or({bignumber:Fh,fraction:Jd,AccessorNode:qx,ArrayNode:Sx,ConstantNode:Ox,FunctionNode:Dx,IndexNode:kx,ObjectNode:bx,OperatorNode:wx,ParenthesisNode:Nx,SymbolNode:Ix,add:Xy,config:o,divide:tx,equal:Oy,isZero:cd,mathWithTransform:yx,matrix:Qd,multiply:mg,parse:Rx,pow:hg,simplify:Hx,subtract:ly,typed:Ah});function Zx(e,t){Yx(e,t),t.add(e)}function Wx(e,t,r){Yx(e,t),t.set(e,r)}function Yx(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Jx(e,t,r){return function(e,t){if(e!==t)throw new TypeError("Private static access of wrong provenance")}(e,t),function(e,t){if(void 0===e)throw new TypeError("attempted to "+t+" private static field before its declaration")}(r,"get"),Kx(e,r)}function Xx(e,t,r){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return r}function Qx(e,t){return Kx(e,tb(e,t,"get"))}function Kx(e,t){return t.get?t.get.call(e):t.value}function eb(e,t,r){return function(e,t,r){if(t.set)t.set.call(e,r);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=r}}(e,tb(e,t,"set"),r),r}function tb(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}t(dx,{e:th,false:rh,fineStructure:nh,i:ah,Infinity:oh,LN10:sh,LOG10E:uh,NaN:lh,null:fh,phi:ph,SQRT1_2:dh,sackurTetrode:yh,tau:gh,true:vh,E:th,version:xh,efimovFactor:wh,LN2:Nh,pi:Mh,replacer:Sh,reviver:_x,SQRT2:Eh,typed:Ah,unaryPlus:Oh,PI:Mh,weakMixingAngle:Ch,abs:_h,acos:Th,acot:Bh,acsc:qh,addScalar:zh,arg:kh,asech:Ih,asinh:Dh,atan:Rh,atanh:Uh,bignumber:Fh,bitNot:Ph,boolean:jh,chain:Tx,clone:Lh,combinations:Hh,complex:$h,conj:Gh,cosh:Vh,coth:Zh,csc:Wh,cube:Yh,equalScalar:Jh,erf:Xh,exp:Qh,expm1:Kh,filter:ed,forEach:td,format:rd,getMatrixDataType:nd,hex:id,im:ad,isInteger:od,isNegative:sd,isPositive:ud,isZero:cd,LOG2E:ld,log10:fd,log2:pd,map:md,multiplyScalar:hd,not:dd,number:yd,oct:gd,pickRandom:vd,print:xd,random:bd,re:wd,sec:Nd,sign:Md,sin:Sd,splitUnit:Ad,square:Od,string:Cd,tan:_d,typeOf:Td,acosh:Bd,acsch:qd,apply:zd,asec:kd,bin:Id,combinationsWithRep:Dd,cos:Rd,csch:Ud,isNaN:Fd,isPrime:Pd,randomInt:jd,sech:Ld,sinh:Hd,sparse:$d,sqrt:Gd,tanh:Vd,unaryMinus:Zd,acoth:Wd,cot:Yd,fraction:Jd,isNumeric:Xd,matrix:Qd,matrixFromFunction:Kd,mod:ey,nthRoot:ty,numeric:ry,or:ny,prod:iy,reshape:ay,size:oy,smaller:sy,squeeze:uy,subset:cy,subtract:ly,to:fy,transpose:py,xgcd:my,zeros:hy,and:dy,bitAnd:yy,bitXor:gy,cbrt:vy,compare:xy,compareText:by,concat:wy,count:Ny,ctranspose:My,diag:Sy,divideScalar:Ey,dotDivide:Ay,equal:Oy,flatten:Cy,gcd:_y,hasNumericValue:Ty,hypot:By,kron:ky,largerEq:Iy,leftShift:Dy,lsolve:Ry,matrixFromColumns:Uy,min:Fy,mode:Py,nthRoots:jy,ones:Ly,partitionSelect:Hy,resize:$y,rightLogShift:Gy,round:Vy,smallerEq:Zy,unequal:Wy,usolve:Yy,xor:Jy,add:Xy,atan2:Qy,bitOr:Ky,catalan:eg,compareNatural:tg,deepEqual:rg,diff:ng,dot:ig,equalText:ag,floor:og,identity:sg,invmod:ug,larger:cg,log:lg,lsolveAll:fg,matrixFromRows:pg,multiply:mg,pow:hg,qr:dg,range:yg,rightArithShift:gg,row:vg,setCartesian:xg,setDistinct:bg,setIsSubset:wg,setPowerset:Ng,slu:Mg,sum:Sg,trace:Eg,usolveAll:Ag,asin:Og,ceil:Cg,column:_g,composition:Tg,cross:Bg,distance:qg,dotMultiply:zg,fix:Ig,gamma:Dg,index:Rg,lcm:Ug,max:Fg,quantileSeq:Pg,setDifference:jg,setMultiplicity:Lg,setSymDifference:Hg,sort:$g,vacuumImpedance:Vg,wienDisplacement:Zg,atomicMass:Wg,bohrMagneton:Yg,boltzmann:Jg,conductanceQuantum:Xg,createUnit:Qg,deuteronMass:Kg,dotPow:ev,electricConstant:tv,elementaryCharge:rv,factorial:nv,fermiCoupling:iv,gasConstant:av,gravity:ov,intersect:sv,inverseConductanceQuantum:uv,klitzing:cv,loschmidt:lv,magneticConstant:fv,molarMass:pv,molarPlanckConstant:mv,neutronMass:hv,nuclearMagneton:dv,permutations:yv,planckConstant:gv,planckMass:vv,planckTime:xv,quantumOfCirculation:bv,reducedPlanckConstant:wv,rydberg:Nv,setIntersect:Mv,setUnion:Sv,stefanBoltzmann:Av,unit:Ov,avogadro:Cv,bohrRadius:_v,coulomb:Tv,electronMass:Bv,faraday:qv,hartreeEnergy:zv,log1p:kv,magneticFluxQuantum:Iv,molarMassC12:Dv,parse:Rx,planckCharge:Rv,planckTemperature:Uv,secondRadiation:Fv,speedOfLight:Pv,stirlingS2:jv,bellNumbers:Lv,compile:Ux,evaluate:Fx,firstRadiation:Hv,lup:$v,molarVolume:Gv,protonMass:Vv,setSize:Zv,thomsonCrossSection:Wv,classicalElectronRadius:Yv,det:Jv,gravitationConstant:Xv,inv:Qv,lusolve:Kv,parser:Lx,sqrtm:ex,divide:tx,expm:rx,kldivergence:nx,mean:ix,median:ax,planckLength:ox,simplify:Hx,variance:sx,derivative:$x,help:Gx,rationalize:Vx,std:ux,eigs:cx,multinomial:lx,mad:fx,norm:px,rotationMatrix:mx,rotate:hx,config:o}),t(yx,dx,{filter:qr({typed:Ah}),forEach:kr({typed:Ah}),map:Ir({typed:Ah}),apply:Pr({isInteger:od,typed:Ah}),diff:Gr({bignumber:Fh,matrix:Qd,number:yd,subtract:ly,typed:Ah}),index:Vr({Index:zy}),subset:Kr({matrix:Qd,typed:Ah}),concat:nn({isInteger:od,matrix:Qd,typed:Ah}),max:sn({config:o,larger:cg,numeric:ry,typed:Ah}),min:cn({config:o,numeric:ry,smaller:sy,typed:Ah}),range:pn({bignumber:Fh,matrix:Qd,config:o,larger:cg,largerEq:Iy,smaller:sy,smallerEq:Zy,typed:Ah}),row:hn({Index:zy,matrix:Qd,range:yg,typed:Ah}),sum:yn({add:Xy,config:o,numeric:ry,typed:Ah}),column:xn({Index:zy,matrix:Qd,range:yg,typed:Ah}),mean:Nn({add:Xy,divide:tx,typed:Ah}),variance:On({add:Xy,apply:zd,divide:tx,isNaN:Fd,multiply:mg,subtract:ly,typed:Ah}),std:_n({sqrt:Gd,typed:Ah,variance:sx})}),t(gx,{BigNumber:Km,Chain:vx,Complex:eh,Fraction:ih,Matrix:ch,Node:xx,ObjectNode:bx,OperatorNode:wx,ParenthesisNode:Nx,Range:mh,RelationalNode:Mx,ResultSet:hh,ArrayNode:Sx,BlockNode:Ex,ConditionalNode:Ax,ConstantNode:Ox,DenseMatrix:bh,RangeNode:Cx,FunctionAssignmentNode:Bx,SparseMatrix:Ed,AccessorNode:qx,AssignmentNode:zx,ImmutableDenseMatrix:qy,Index:zy,IndexNode:kx,FibonacciHeap:kg,Unit:Gg,Spa:Ev,SymbolNode:Ix,FunctionNode:Dx,Help:Px,Parser:jx}),vx.createProxy(dx);const rb=document.createElement("template");rb.innerHTML='
AC
+/-
%
÷
7
8
9
X
4
5
6
-
1
2
3
+
0
,
=
';const nb=document.createElement("style");nb.innerHTML=e.Z.toString();var ib=new WeakMap,ab=new WeakMap,ob=new WeakMap,sb=new WeakMap,ub=new WeakMap,cb=new WeakMap,lb=new WeakMap,fb=new WeakMap,pb=new WeakMap,mb=new WeakMap,hb=new WeakSet,db=new WeakSet,yb=new WeakSet,gb=new WeakSet,vb=new WeakSet,xb=new WeakSet,bb=new WeakSet,wb=new WeakSet,Nb=new WeakSet,Mb=new WeakSet;class Sb extends HTMLElement{static get observedAttributes(){return[]}constructor(){super(),Zx(this,Mb),Zx(this,Nb),Zx(this,wb),Zx(this,bb),Zx(this,xb),Zx(this,vb),Zx(this,gb),Zx(this,yb),Zx(this,db),Zx(this,hb),Wx(this,ib,{writable:!0,value:""}),Wx(this,ab,{writable:!0,value:""}),Wx(this,ob,{writable:!0,value:""}),Wx(this,sb,{writable:!0,value:""}),Wx(this,ub,{writable:!0,value:void 0}),Wx(this,cb,{writable:!0,value:void 0}),Wx(this,lb,{writable:!0,value:void 0}),Wx(this,fb,{writable:!0,value:void 0}),Wx(this,pb,{writable:!0,value:void 0}),Wx(this,mb,{writable:!0,value:void 0});const e=this.attachShadow({mode:"open"});e.appendChild(nb.cloneNode(!0)),e.appendChild(rb.content.cloneNode(!0)),eb(this,ub,e.querySelector(".calc-solution")),eb(this,cb,e.getElementById("reset")),eb(this,lb,e.getElementById("plus-minus")),eb(this,fb,e.getElementById("percentage")),eb(this,pb,Array.from(e.querySelectorAll(".calc-button-operand"))),eb(this,mb,Array.from(e.querySelectorAll(".calc-button-digit"))),Qx(this,cb).addEventListener("click",Xx(this,hb,Eb).bind(this)),Qx(this,lb).addEventListener("click",Xx(this,db,Ab).bind(this)),Qx(this,fb).addEventListener("click",Xx(this,yb,Ob).bind(this)),Qx(this,pb).forEach((e=>e.addEventListener("click",(t=>Xx(this,vb,_b).call(this,t,e))))),Qx(this,mb).forEach((e=>e.addEventListener("click",(t=>Xx(this,gb,Cb).call(this,t,e)))))}connectedCallback(){this.shadowRoot&&Xx(this,Mb,kb).call(this)}attributeChangedCallback(e,t,r){}}function Eb(e){e.preventDefault();const t=Qx(this,cb).querySelector("span");"AC"===t.textContent?(eb(this,ab,""),eb(this,ib,""),Qx(this,pb).forEach(Xx(this,bb,Bb))):(eb(this,ab,"0"),t.textContent="AC"),Xx(this,Mb,kb).call(this)}function Ab(e){e.preventDefault();let t="0";Qx(this,ab).length>0?t=Qx(this,ab):Qx(this,ib).length>0&&(t=Xx(this,Nb,zb).call(this)),t.startsWith(Jx(Sb,Sb,Ib).NEGATIVE)?eb(this,ab,t.slice(1)):eb(this,ab,Jx(Sb,Sb,Ib).NEGATIVE+t),Xx(this,Mb,kb).call(this)}function Ob(e){e.preventDefault();let t="0";Qx(this,ab).length>0?t=Qx(this,ab):Qx(this,ib).length>0&&(t=Xx(this,Nb,zb).call(this));let r=t.replace(/,/g,".");r+="/100",eb(this,ab,String(Fx(r))),eb(this,ab,Qx(this,ab).replace(".",Jx(Sb,Sb,Ib).COMMA)),Xx(this,Mb,kb).call(this)}function Cb(e,t){e.preventDefault();const r=t.dataset.digit||"";r===Jx(Sb,Sb,Ib).NEGATIVE&&Qx(this,ab).includes(Jx(Sb,Sb,Ib).NEGATIVE)||(Xx(this,wb,qb).call(this,Qx(this,ib))||eb(this,ib,""),Qx(this,cb).querySelector("span").textContent="C",""===Qx(this,ab)&&r===Jx(Sb,Sb,Ib).COMMA?eb(this,ab,"0"+Jx(Sb,Sb,Ib).COMMA):"0"===Qx(this,ab)&&r!==Jx(Sb,Sb,Ib).COMMA?eb(this,ab,r):Qx(this,ab)===`${Jx(Sb,Sb,Ib).NEGATIVE}0`&&r!==Jx(Sb,Sb,Ib).COMMA?eb(this,ab,Jx(Sb,Sb,Ib).NEGATIVE+r):eb(this,ab,Qx(this,ab)+r),Xx(this,Mb,kb).call(this))}function _b(e,t){e.preventDefault(),Qx(this,pb).forEach(Xx(this,bb,Bb));const r=t.dataset.operand;if(Qx(this,ab)&&eb(this,ib,Qx(this,ib)+Qx(this,ab)),0===Qx(this,ib).length&&eb(this,ib,"0"),Xx(this,wb,qb).call(this,Qx(this,ib))&&eb(this,ib,Qx(this,ib).slice(0,-1)),r!==Jx(Sb,Sb,Ib).EQUALS)eb(this,ib,Qx(this,ib)+r),Xx(this,xb,Tb).call(this,t);else{if(Qx(this,ib).endsWith(")")){let e=-1;for(let t=Qx(this,ib).length-1;t>0;t--)if(Xx(this,wb,qb).call(this,Qx(this,ib)[t])){e=t;break}-1!==e&&eb(this,ib,Qx(this,ib)+Qx(this,ib).slice(e,-1))}eb(this,ib,`(${Qx(this,ib)})`)}eb(this,ab,""),Xx(this,Mb,kb).call(this)}function Tb(e){e.classList.add("active")}function Bb(e){e.classList.remove("active")}function qb(e){const t=e.slice(-1);return[Jx(Sb,Sb,Ib).PLUS,Jx(Sb,Sb,Ib).MINUS,Jx(Sb,Sb,Ib).DIVIDE,Jx(Sb,Sb,Ib).MULTIPLY].includes(t)}function zb(){let e=Qx(this,ib)||"0";Xx(this,wb,qb).call(this,e)&&(e=e.slice(0,-1)),e=e.replace(/,/g,".");try{return Fx(e).toString()}catch(e){return console.error(e),"Error"}}function kb(){let e;if(Qx(this,ab).length>0)Qx(this,pb).forEach(Xx(this,bb,Bb)),e=Qx(this,ab);else if(Qx(this,ib).length>0){let t=Qx(this,ib)||"0";Xx(this,wb,qb).call(this,t)||Qx(this,pb).forEach(Xx(this,bb,Bb)),e=Xx(this,Nb,zb).call(this)}else e="0";e=e.replace(".",Jx(Sb,Sb,Ib).COMMA),Qx(this,ub).textContent=e}var Ib={writable:!0,value:{PLUS:"+",MINUS:"-",MULTIPLY:"*",DIVIDE:"/",EQUALS:"=",NEGATIVE:"-",COMMA:","}};window.customElements.define("ios-calculator",Sb)}()}(); \ No newline at end of file diff --git a/dist/ios-calculator.min.js.LICENSE.txt b/dist/ios-calculator.min.js.LICENSE.txt new file mode 100644 index 0000000..9e98834 --- /dev/null +++ b/dist/ios-calculator.min.js.LICENSE.txt @@ -0,0 +1,14 @@ +/** + * @license Complex.js v2.0.15 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.1.3 23/05/2021 + * 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. + **/ diff --git a/src/iOSCalculator.js b/src/iOSCalculator.js index aa9a65c..53c4a47 100644 --- a/src/iOSCalculator.js +++ b/src/iOSCalculator.js @@ -1,30 +1,30 @@ -import html from "./ios-calculator.html"; -import shadowCss from "./ios-calculator.scss"; -import { evaluate } from "mathjs"; +import html from './ios-calculator.html'; +import shadowCss from './ios-calculator.scss'; +import { evaluate } from 'mathjs'; -const template = document.createElement("template"); +const template = document.createElement('template'); template.innerHTML = html; -const sheet = document.createElement("style"); +const sheet = document.createElement('style'); sheet.innerHTML = shadowCss.toString(); export class iOSCalculator extends HTMLElement { static #CHARACTERS = { - PLUS: "+", - MINUS: "-", - MULTIPLY: "*", - DIVIDE: "/", - EQUALS: "=", - NEGATIVE: "-", - COMMA: ",", + PLUS: '+', + MINUS: '-', + MULTIPLY: '*', + DIVIDE: '/', + EQUALS: '=', + NEGATIVE: '-', + COMMA: ',', }; - #currentExpression = ""; - #currentInput = ""; + #currentExpression = ''; + #currentInput = ''; // TODO: use these - #suggestedInput = ""; - #lastOperand = ""; + #suggestedInput = ''; + #lastOperand = ''; /** @type {HTMLElement} */ #calcSolution; @@ -45,27 +45,41 @@ export class iOSCalculator extends HTMLElement { constructor() { super(); - const shadowRoot = this.attachShadow({ mode: "open" }); + const shadowRoot = this.attachShadow({ mode: 'open' }); shadowRoot.appendChild(sheet.cloneNode(true)); shadowRoot.appendChild(template.content.cloneNode(true)); - this.#calcSolution = shadowRoot.querySelector(".calc-solution"); + this.#calcSolution = shadowRoot.querySelector('.calc-solution'); - this.#resetButton = shadowRoot.getElementById("reset"); - this.#plusMinusButton = shadowRoot.getElementById("plus-minus"); - this.#percentageButton = shadowRoot.getElementById("percentage"); + this.#resetButton = shadowRoot.getElementById('reset'); + this.#plusMinusButton = shadowRoot.getElementById('plus-minus'); + this.#percentageButton = shadowRoot.getElementById('percentage'); - this.#operandButtons = Array.from(shadowRoot.querySelectorAll(".calc-button-operand")); - this.#digitButtons = Array.from(shadowRoot.querySelectorAll(".calc-button-digit")); + this.#operandButtons = Array.from( + shadowRoot.querySelectorAll('.calc-button-operand') + ); + this.#digitButtons = Array.from( + shadowRoot.querySelectorAll('.calc-button-digit') + ); - this.#resetButton.addEventListener("click", this.#onResetClick.bind(this)); - this.#plusMinusButton.addEventListener("click", this.#onPlusMinusClick.bind(this)); - this.#percentageButton.addEventListener("click", this.#onPercentageClick.bind(this)); - this.#operandButtons.forEach((operandButton) => - operandButton.addEventListener("click", () => this.#onOperandClick(operandButton)) + this.#resetButton.addEventListener('click', this.#onResetClick.bind(this)); + this.#plusMinusButton.addEventListener( + 'click', + this.#onPlusMinusClick.bind(this) + ); + this.#percentageButton.addEventListener( + 'click', + this.#onPercentageClick.bind(this) ); - this.#digitButtons.forEach((digitButton) => - digitButton.addEventListener("click", () => this.#onDigitClick(digitButton)) + this.#operandButtons.forEach(operandButton => + operandButton.addEventListener('click', event => + this.#onOperandClick(event, operandButton) + ) + ); + this.#digitButtons.forEach(digitButton => + digitButton.addEventListener('click', event => + this.#onDigitClick(event, digitButton) + ) ); } @@ -75,25 +89,33 @@ export class iOSCalculator extends HTMLElement { } } - #onResetClick() { - const textSpan = this.#resetButton.querySelector("span"); + /** + * @param {PointerEvent} event + */ + #onResetClick(event) { + event.preventDefault(); + const textSpan = this.#resetButton.querySelector('span'); - if (textSpan.textContent === "AC") { + if (textSpan.textContent === 'AC') { // AC - this.#currentInput = ""; - this.#currentExpression = ""; + this.#currentInput = ''; + this.#currentExpression = ''; this.#operandButtons.forEach(this.#removeActiveState); } else { // C - this.#currentInput = "0"; - textSpan.textContent = "AC"; + this.#currentInput = '0'; + textSpan.textContent = 'AC'; } this.#displaySolution(); } - #onPlusMinusClick() { - let number = "0"; + /** + * @param {PointerEvent} event + */ + #onPlusMinusClick(event) { + event.preventDefault(); + let number = '0'; if (this.#currentInput.length > 0) { number = this.#currentInput; @@ -110,8 +132,12 @@ export class iOSCalculator extends HTMLElement { this.#displaySolution(); } - #onPercentageClick() { - let number = "0"; + /** + * @param {PointerEvent} event + */ + #onPercentageClick(event) { + event.preventDefault(); + let number = '0'; if (this.#currentInput.length > 0) { number = this.#currentInput; @@ -119,20 +145,24 @@ export class iOSCalculator extends HTMLElement { number = this.#getCurrentSolution(); } - let intermediateInput = number.replace(/,/g, "."); - intermediateInput += "/100"; + let intermediateInput = number.replace(/,/g, '.'); + intermediateInput += '/100'; this.#currentInput = String(evaluate(intermediateInput)); - this.#currentInput = this.#currentInput.replace(".", iOSCalculator.#CHARACTERS.COMMA); + this.#currentInput = this.#currentInput.replace( + '.', + iOSCalculator.#CHARACTERS.COMMA + ); this.#displaySolution(); } /** - * - * @param {HTMLElement} digitButton - * @returns + * @param {PointerEvent} event + * @param {HTMLElement} digitButton + * @returns */ - #onDigitClick(digitButton) { - const clickedDigit = digitButton.dataset.digit || ""; + #onDigitClick(event, digitButton) { + event.preventDefault(); + const clickedDigit = digitButton.dataset.digit || ''; if ( clickedDigit === iOSCalculator.#CHARACTERS.NEGATIVE && @@ -145,16 +175,25 @@ export class iOSCalculator extends HTMLElement { if (!this.#endsWithOperand(this.#currentExpression)) { // reset expression if user starts a new calculations // -> clicking a number with clicking an operand beforehand - this.#currentExpression = ""; + this.#currentExpression = ''; } - this.#resetButton.querySelector("span").textContent = "C"; - - if (this.#currentInput === "" && clickedDigit === iOSCalculator.#CHARACTERS.COMMA) { - this.#currentInput = "0" + iOSCalculator.#CHARACTERS.COMMA; - } else if (this.#currentInput === "0" && clickedDigit !== iOSCalculator.#CHARACTERS.COMMA) { + this.#resetButton.querySelector('span').textContent = 'C'; + + if ( + this.#currentInput === '' && + clickedDigit === iOSCalculator.#CHARACTERS.COMMA + ) { + this.#currentInput = '0' + iOSCalculator.#CHARACTERS.COMMA; + } else if ( + this.#currentInput === '0' && + clickedDigit !== iOSCalculator.#CHARACTERS.COMMA + ) { this.#currentInput = clickedDigit; - } else if (this.#currentInput === `${iOSCalculator.#CHARACTERS.NEGATIVE}0` && clickedDigit !== iOSCalculator.#CHARACTERS.COMMA) { + } else if ( + this.#currentInput === `${iOSCalculator.#CHARACTERS.NEGATIVE}0` && + clickedDigit !== iOSCalculator.#CHARACTERS.COMMA + ) { this.#currentInput = iOSCalculator.#CHARACTERS.NEGATIVE + clickedDigit; } else { this.#currentInput += clickedDigit; @@ -164,10 +203,11 @@ export class iOSCalculator extends HTMLElement { } /** - * - * @param {HTMLElement} operandButton + * @param {PointerEvent} event + * @param {HTMLElement} operandButton */ - #onOperandClick(operandButton) { + #onOperandClick(event, operandButton) { + event.preventDefault(); this.#operandButtons.forEach(this.#removeActiveState); const clickedOperand = operandButton.dataset.operand; @@ -178,7 +218,7 @@ export class iOSCalculator extends HTMLElement { if (this.#currentExpression.length === 0) { // in case user starts his calculation directly with an operand - this.#currentExpression = "0"; + this.#currentExpression = '0'; } if (this.#endsWithOperand(this.#currentExpression)) { @@ -190,10 +230,14 @@ export class iOSCalculator extends HTMLElement { this.#currentExpression += clickedOperand; this.#addActiveState(operandButton); } else { - if (this.#currentExpression.endsWith(")")) { + if (this.#currentExpression.endsWith(')')) { // clicking = multiple times in a row let latestOperandIndex = -1; - for (let index = this.#currentExpression.length - 1; index > 0; index--) { + for ( + let index = this.#currentExpression.length - 1; + index > 0; + index-- + ) { if (this.#endsWithOperand(this.#currentExpression[index])) { latestOperandIndex = index; break; @@ -201,38 +245,41 @@ export class iOSCalculator extends HTMLElement { } if (latestOperandIndex !== -1) { - this.#currentExpression += this.#currentExpression.slice(latestOperandIndex, -1); + this.#currentExpression += this.#currentExpression.slice( + latestOperandIndex, + -1 + ); } } this.#currentExpression = `(${this.#currentExpression})`; } - this.#currentInput = ""; + this.#currentInput = ''; this.#displaySolution(); } /** - * - * @param {HTMLElement} elem + * + * @param {HTMLElement} elem */ #addActiveState(elem) { - elem.classList.add("active"); + elem.classList.add('active'); } /** - * - * @param {HTMLElement} elem + * + * @param {HTMLElement} elem */ #removeActiveState(elem) { - elem.classList.remove("active"); + elem.classList.remove('active'); } /** - * - * @param {string} str - * @returns + * + * @param {string} str + * @returns */ #endsWithOperand(str) { const lastChar = str.slice(-1); @@ -245,19 +292,19 @@ export class iOSCalculator extends HTMLElement { } #getCurrentSolution() { - let expressionToEvaluate = this.#currentExpression || "0"; + let expressionToEvaluate = this.#currentExpression || '0'; if (this.#endsWithOperand(expressionToEvaluate)) { expressionToEvaluate = expressionToEvaluate.slice(0, -1); } - expressionToEvaluate = expressionToEvaluate.replace(/,/g, "."); + expressionToEvaluate = expressionToEvaluate.replace(/,/g, '.'); try { return evaluate(expressionToEvaluate).toString(); } catch (err) { console.error(err); - return "Error"; + return 'Error'; } } @@ -268,7 +315,7 @@ export class iOSCalculator extends HTMLElement { this.#operandButtons.forEach(this.#removeActiveState); integerToDisplay = this.#currentInput; } else if (this.#currentExpression.length > 0) { - let expressionToDisplay = this.#currentExpression || "0"; + let expressionToDisplay = this.#currentExpression || '0'; if (!this.#endsWithOperand(expressionToDisplay)) { this.#operandButtons.forEach(this.#removeActiveState); @@ -276,18 +323,21 @@ export class iOSCalculator extends HTMLElement { integerToDisplay = this.#getCurrentSolution(); } else { - integerToDisplay = "0"; + integerToDisplay = '0'; } - integerToDisplay = integerToDisplay.replace(".", iOSCalculator.#CHARACTERS.COMMA); + integerToDisplay = integerToDisplay.replace( + '.', + iOSCalculator.#CHARACTERS.COMMA + ); this.#calcSolution.textContent = integerToDisplay; } /** - * @param {string} name - * @param {string} oldValue - * @param {string} newValue + * @param {string} name + * @param {string} oldValue + * @param {string} newValue */ attributeChangedCallback(name, oldValue, newValue) { if (newValue != oldValue) { diff --git a/src/ios-calculator.scss b/src/ios-calculator.scss index f300d77..a8c006f 100644 --- a/src/ios-calculator.scss +++ b/src/ios-calculator.scss @@ -71,17 +71,18 @@ $buttonsGap: 0.625rem; &:active:after { opacity: 1; - transition: 0s + transition: 0s; } &:after { - content: ""; + content: ''; background: rgba(255, 255, 255, 0.25); display: block; position: absolute; inset: 0; opacity: 0; - transition: all 0.8s + transition: all 0.8s; + border-radius: inherit; } &.calc-button-double {