@tachybase/plugin-evaluator-mathjs 1.6.22 → 1.6.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,53 +1,53 @@
1
- (function(fr,pr){typeof exports=="object"&&typeof module!="undefined"?pr(exports,require("@tachybase/client"),require("@tego/client")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tego/client"],pr):(fr=typeof globalThis!="undefined"?globalThis:fr||self,pr(fr["@tachybase/plugin-evaluator-mathjs"]={},fr["@tachybase/client"],fr["@tego/client"]))})(this,function(fr,pr,Qr){"use strict";var ao=(fr,pr)=>(pr=Symbol[fr])?pr:Symbol.for("Symbol."+fr),c$=fr=>{throw TypeError(fr)},en=Math.pow;var Np=(fr,pr,Qr)=>new Promise((ar,kr)=>{var Be=yr=>{try{Or(Qr.next(yr))}catch(ht){kr(ht)}},_e=yr=>{try{Or(Qr.throw(yr))}catch(ht){kr(ht)}},Or=yr=>yr.done?ar(yr.value):Promise.resolve(yr.value).then(Be,_e);Or((Qr=Qr.apply(fr,pr)).next())}),f$=function(fr,pr){this[0]=fr,this[1]=pr};var io=fr=>{var pr=fr[ao("asyncIterator")],Qr=!1,ar,kr={};return pr==null?(pr=fr[ao("iterator")](),ar=Be=>kr[Be]=_e=>pr[Be](_e)):(pr=pr.call(fr),ar=Be=>kr[Be]=_e=>{if(Qr){if(Qr=!1,Be==="throw")throw _e;return _e}return Qr=!0,{done:!1,value:new f$(new Promise(Or=>{var yr=pr[Be](_e);yr instanceof Object||c$("Object expected"),Or(yr)}),1)}}),kr[ao("iterator")]=()=>kr,ar("next"),"throw"in pr?ar("throw"):kr.throw=Be=>{throw Be},"return"in pr&&ar("return"),kr};function ar(){return ar=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var t in a)({}).hasOwnProperty.call(a,t)&&(e[t]=a[t])}return e},ar.apply(null,arguments)}var kr={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function Be(e){return typeof e=="number"}function _e(e){return!e||typeof e!="object"||typeof e.constructor!="function"?!1:e.isBigNumber===!0&&typeof e.constructor.prototype=="object"&&e.constructor.prototype.isBigNumber===!0||typeof e.constructor.isDecimal=="function"&&e.constructor.isDecimal(e)===!0}function Or(e){return e&&typeof e=="object"&&Object.getPrototypeOf(e).isComplex===!0||!1}function yr(e){return e&&typeof e=="object"&&Object.getPrototypeOf(e).isFraction===!0||!1}function ht(e){return e&&e.constructor.prototype.isUnit===!0||!1}function _r(e){return typeof e=="string"}var Xe=Array.isArray;function Oe(e){return e&&e.constructor.prototype.isMatrix===!0||!1}function rn(e){return Array.isArray(e)||Oe(e)}function Qn(e){return e&&e.isDenseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function Ut(e){return e&&e.isSparseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function Kn(e){return e&&e.constructor.prototype.isRange===!0||!1}function En(e){return e&&e.constructor.prototype.isIndex===!0||!1}function Mp(e){return typeof e=="boolean"}function oo(e){return e&&e.constructor.prototype.isResultSet===!0||!1}function Wa(e){return e&&e.constructor.prototype.isHelp===!0||!1}function Ap(e){return typeof e=="function"}function Sp(e){return e instanceof Date}function Ep(e){return e instanceof RegExp}function Ja(e){return!!(e&&typeof e=="object"&&e.constructor===Object&&!Or(e)&&!yr(e))}function Cp(e){return e===null}function Op(e){return e===void 0}function Lt(e){return e&&e.isAccessorNode===!0&&e.constructor.prototype.isNode===!0||!1}function Hr(e){return e&&e.isArrayNode===!0&&e.constructor.prototype.isNode===!0||!1}function Dp(e){return e&&e.isAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function Tp(e){return e&&e.isBlockNode===!0&&e.constructor.prototype.isNode===!0||!1}function Bp(e){return e&&e.isConditionalNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ye(e){return e&&e.isConstantNode===!0&&e.constructor.prototype.isNode===!0||!1}function Cn(e){return e&&e.isFunctionAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function kt(e){return e&&e.isFunctionNode===!0&&e.constructor.prototype.isNode===!0||!1}function tn(e){return e&&e.isIndexNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ve(e){return e&&e.isNode===!0&&e.constructor.prototype.isNode===!0||!1}function jn(e){return e&&e.isObjectNode===!0&&e.constructor.prototype.isNode===!0||!1}function $r(e){return e&&e.isOperatorNode===!0&&e.constructor.prototype.isNode===!0||!1}function On(e){return e&&e.isParenthesisNode===!0&&e.constructor.prototype.isNode===!0||!1}function _p(e){return e&&e.isRangeNode===!0&&e.constructor.prototype.isNode===!0||!1}function xr(e){return e&&e.isSymbolNode===!0&&e.constructor.prototype.isNode===!0||!1}function Qa(e){return e&&e.constructor.prototype.isChain===!0||!1}function Ke(e){var n=typeof e;return n==="object"?e===null?"null":Array.isArray(e)?"Array":e instanceof Date?"Date":e instanceof RegExp?"RegExp":_e(e)?"BigNumber":Or(e)?"Complex":yr(e)?"Fraction":Oe(e)?"Matrix":ht(e)?"Unit":En(e)?"Index":Kn(e)?"Range":oo(e)?"ResultSet":Ve(e)?e.type:Qa(e)?"Chain":Wa(e)?"Help":"Object":n==="function"?"Function":n}function Ce(e){var n=typeof e;if(n==="number"||n==="string"||n==="boolean"||e===null||e===void 0)return e;if(typeof e.clone=="function")return e.clone();if(Array.isArray(e))return e.map(function(a){return Ce(a)});if(e instanceof Date)return new Date(e.valueOf());if(_e(e))return e;if(e instanceof RegExp)throw new TypeError("Cannot clone "+e);return $p(e,Ce)}function $p(e,n){var a={};for(var t in e)Me(e,t)&&(a[t]=n(e[t]));return a}function Ka(e,n){for(var a in n)Me(n,a)&&(e[a]=n[a]);return e}function Dn(e,n){var a,t,r;if(Array.isArray(e)){if(!Array.isArray(n)||e.length!==n.length)return!1;for(t=0,r=e.length;t<r;t++)if(!Dn(e[t],n[t]))return!1;return!0}else{if(typeof e=="function")return e===n;if(e instanceof Object){if(Array.isArray(n)||!(n instanceof Object))return!1;for(a in e)if(!(a in n)||!Dn(e[a],n[a]))return!1;for(a in n)if(!(a in e))return!1;return!0}else return e===n}}function Ip(e,n,a){var t=!0,r;Object.defineProperty(e,n,{get:function(){return t&&(r=a(),t=!1),r},set:function(l){r=l,t=!1},configurable:!0,enumerable:!0})}function Me(e,n){return e&&Object.hasOwnProperty.call(e,n)}function qp(e,n){for(var a={},t=0;t<n.length;t++){var r=n[t],i=e[r];i!==void 0&&(a[r]=i)}return a}var Rp=["Matrix","Array"],Fp=["number","BigNumber","Fraction"],oe=function(n){if(n)throw new Error(`The global config is readonly.
1
+ (function(lr,vr){typeof exports=="object"&&typeof module!="undefined"?vr(exports,require("@tachybase/client"),require("@tego/client")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tego/client"],vr):(lr=typeof globalThis!="undefined"?globalThis:lr||self,vr(lr["@tachybase/plugin-evaluator-mathjs"]={},lr["@tachybase/client"],lr["@tego/client"]))})(this,function(lr,vr,Hr){"use strict";var co=(lr,vr)=>(vr=Symbol[lr])?vr:Symbol.for("Symbol."+lr),p_=lr=>{throw TypeError(lr)},nn=Math.pow;var Ep=(lr,vr,Hr)=>new Promise((ir,Gr)=>{var $e=xr=>{try{Tr(Hr.next(xr))}catch(gt){Gr(gt)}},_e=xr=>{try{Tr(Hr.throw(xr))}catch(gt){Gr(gt)}},Tr=xr=>xr.done?ir(xr.value):Promise.resolve(xr.value).then($e,_e);Tr((Hr=Hr.apply(lr,vr)).next())}),v_=function(lr,vr){this[0]=lr,this[1]=vr};var fo=lr=>{var vr=lr[co("asyncIterator")],Hr=!1,ir,Gr={};return vr==null?(vr=lr[co("iterator")](),ir=$e=>Gr[$e]=_e=>vr[$e](_e)):(vr=vr.call(lr),ir=$e=>Gr[$e]=_e=>{if(Hr){if(Hr=!1,$e==="throw")throw _e;return _e}return Hr=!0,{done:!1,value:new v_(new Promise(Tr=>{var xr=vr[$e](_e);xr instanceof Object||p_("Object expected"),Tr(xr)}),1)}}),Gr[co("iterator")]=()=>Gr,ir("next"),"throw"in vr?ir("throw"):Gr.throw=$e=>{throw $e},"return"in vr&&ir("return"),Gr};function ir(){return ir=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},ir.apply(null,arguments)}var Gr={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function $e(e){return typeof e=="number"}function _e(e){return!e||typeof e!="object"||typeof e.constructor!="function"?!1:e.isBigNumber===!0&&typeof e.constructor.prototype=="object"&&e.constructor.prototype.isBigNumber===!0||typeof e.constructor.isDecimal=="function"&&e.constructor.isDecimal(e)===!0}function Tr(e){return e&&typeof e=="object"&&Object.getPrototypeOf(e).isComplex===!0||!1}function xr(e){return e&&typeof e=="object"&&Object.getPrototypeOf(e).isFraction===!0||!1}function gt(e){return e&&e.constructor.prototype.isUnit===!0||!1}function Ir(e){return typeof e=="string"}var Ye=Array.isArray;function De(e){return e&&e.constructor.prototype.isMatrix===!0||!1}function an(e){return Array.isArray(e)||De(e)}function ea(e){return e&&e.isDenseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function kt(e){return e&&e.isSparseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function ra(e){return e&&e.constructor.prototype.isRange===!0||!1}function Tn(e){return e&&e.constructor.prototype.isIndex===!0||!1}function Cp(e){return typeof e=="boolean"}function lo(e){return e&&e.constructor.prototype.isResultSet===!0||!1}function ja(e){return e&&e.constructor.prototype.isHelp===!0||!1}function Op(e){return typeof e=="function"}function Dp(e){return e instanceof Date}function Tp(e){return e instanceof RegExp}function ei(e){return!!(e&&typeof e=="object"&&e.constructor===Object&&!Tr(e)&&!xr(e))}function Bp(e){return e===null}function $p(e){return e===void 0}function Ht(e){return e&&e.isAccessorNode===!0&&e.constructor.prototype.isNode===!0||!1}function Vr(e){return e&&e.isArrayNode===!0&&e.constructor.prototype.isNode===!0||!1}function _p(e){return e&&e.isAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ip(e){return e&&e.isBlockNode===!0&&e.constructor.prototype.isNode===!0||!1}function qp(e){return e&&e.isConditionalNode===!0&&e.constructor.prototype.isNode===!0||!1}function We(e){return e&&e.isConstantNode===!0&&e.constructor.prototype.isNode===!0||!1}function Bn(e){return e&&e.isFunctionAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function Gt(e){return e&&e.isFunctionNode===!0&&e.constructor.prototype.isNode===!0||!1}function on(e){return e&&e.isIndexNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ze(e){return e&&e.isNode===!0&&e.constructor.prototype.isNode===!0||!1}function ta(e){return e&&e.isObjectNode===!0&&e.constructor.prototype.isNode===!0||!1}function qr(e){return e&&e.isOperatorNode===!0&&e.constructor.prototype.isNode===!0||!1}function $n(e){return e&&e.isParenthesisNode===!0&&e.constructor.prototype.isNode===!0||!1}function Rp(e){return e&&e.isRangeNode===!0&&e.constructor.prototype.isNode===!0||!1}function br(e){return e&&e.isSymbolNode===!0&&e.constructor.prototype.isNode===!0||!1}function ri(e){return e&&e.constructor.prototype.isChain===!0||!1}function je(e){var t=typeof e;return t==="object"?e===null?"null":Array.isArray(e)?"Array":e instanceof Date?"Date":e instanceof RegExp?"RegExp":_e(e)?"BigNumber":Tr(e)?"Complex":xr(e)?"Fraction":De(e)?"Matrix":gt(e)?"Unit":Tn(e)?"Index":ra(e)?"Range":lo(e)?"ResultSet":Ze(e)?e.type:ri(e)?"Chain":ja(e)?"Help":"Object":t==="function"?"Function":t}function Oe(e){var t=typeof e;if(t==="number"||t==="string"||t==="boolean"||e===null||e===void 0)return e;if(typeof e.clone=="function")return e.clone();if(Array.isArray(e))return e.map(function(n){return Oe(n)});if(e instanceof Date)return new Date(e.valueOf());if(_e(e))return e;if(e instanceof RegExp)throw new TypeError("Cannot clone "+e);return Fp(e,Oe)}function Fp(e,t){var n={};for(var a in e)Ae(e,a)&&(n[a]=t(e[a]));return n}function ti(e,t){for(var n in t)Ae(t,n)&&(e[n]=t[n]);return e}function _n(e,t){var n,a,r;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(a=0,r=e.length;a<r;a++)if(!_n(e[a],t[a]))return!1;return!0}else{if(typeof e=="function")return e===t;if(e instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(n in e)if(!(n in t)||!_n(e[n],t[n]))return!1;for(n in t)if(!(n in e))return!1;return!0}else return e===t}}function zp(e,t,n){var a=!0,r;Object.defineProperty(e,t,{get:function(){return a&&(r=n(),a=!1),r},set:function(u){r=u,a=!1},configurable:!0,enumerable:!0})}function Ae(e,t){return e&&Object.hasOwnProperty.call(e,t)}function Pp(e,t){for(var n={},a=0;a<t.length;a++){var r=t[a],i=e[r];i!==void 0&&(n[r]=i)}return n}var Up=["Matrix","Array"],Lp=["number","BigNumber","Fraction"],se=function(t){if(t)throw new Error(`The global config is readonly.
2
2
  Please create a mathjs instance if you want to change the default configuration.
3
3
  Example:
4
4
 
5
5
  import { create, all } from 'mathjs';
6
6
  const mathjs = create(all);
7
7
  mathjs.config({ number: 'BigNumber' });
8
- `);return Object.freeze(kr)};ar(oe,kr,{MATRIX_OPTIONS:Rp,NUMBER_OPTIONS:Fp});function Tn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function zp(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var n=e.default;if(typeof n=="function"){var a=function t(){var r=!1;try{r=this instanceof t}catch(i){}return r?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};a.prototype=n.prototype}else a={};return Object.defineProperty(a,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),a}var ea={exports:{}},Pp=ea.exports,so;function Up(){return so||(so=1,function(e,n){(function(a,t){e.exports=t()})(Pp,function(){function a(){return!0}function t(){return!1}function r(){}function i(){var l=[{name:"number",test:function(q){return typeof q=="number"}},{name:"string",test:function(q){return typeof q=="string"}},{name:"boolean",test:function(q){return typeof q=="boolean"}},{name:"Function",test:function(q){return typeof q=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(q){return q instanceof Date}},{name:"RegExp",test:function(q){return q instanceof RegExp}},{name:"Object",test:function(q){return typeof q=="object"&&q!==null&&q.constructor===Object}},{name:"null",test:function(q){return q===null}},{name:"undefined",test:function(q){return q===void 0}}],m={name:"any",test:a},f=[],c=[],s={types:l,conversions:c,ignore:f};function o(q){var P=F(s.types,function(L){return L.name===q});if(P)return P;if(q==="any")return m;var Q=F(s.types,function(L){return L.name.toLowerCase()===q.toLowerCase()});throw new TypeError('Unknown type "'+q+'"'+(Q?'. Did you mean "'+Q.name+'"?':""))}function u(q){return q===m?999:s.types.indexOf(q)}function p(q){var P=F(s.types,function(Q){return Q.test(q)});if(P)return P.name;throw new TypeError("Value has unknown type. Value: "+q)}function v(q,P){if(!q.signatures)throw new TypeError("Function is no typed-function");var Q;if(typeof P=="string"){Q=P.split(",");for(var L=0;L<Q.length;L++)Q[L]=Q[L].trim()}else if(Array.isArray(P))Q=P;else throw new TypeError("String array or a comma separated string expected");var se=Q.join(","),fe=q.signatures[se];if(fe)return fe;throw new TypeError("Signature not found (signature: "+(q.name||"unnamed")+"("+Q.join(", ")+"))")}function h(q,P){var Q=p(q);if(P===Q)return q;for(var L=0;L<s.conversions.length;L++){var se=s.conversions[L];if(se.from===Q&&se.to===P)return se.convert(q)}throw new Error("Cannot convert from "+Q+" to "+P)}function b(q){return q.map(function(P){var Q=P.types.map(O);return(P.restParam?"...":"")+Q.join("|")}).join(",")}function w(q,P){var Q=q.indexOf("...")===0,L=Q?q.length>3?q.slice(3):"any":q,se=L.split("|").map(re).filter(ie).filter(te),fe=B(P,se),ge=se.map(function(ve){var Ne=o(ve);return{name:ve,typeIndex:u(Ne),test:Ne.test,conversion:null,conversionIndex:-1}}),pe=fe.map(function(ve){var Ne=o(ve.from);return{name:ve.from,typeIndex:u(Ne),test:Ne.test,conversion:ve,conversionIndex:P.indexOf(ve)}});return{types:ge.concat(pe),restParam:Q}}function N(q,P,Q){var L=[];return q.trim()!==""&&(L=q.split(",").map(re).map(function(se,fe,ge){var pe=w(se,Q);if(pe.restParam&&fe!==ge.length-1)throw new SyntaxError('Unexpected rest parameter "'+se+'": only allowed for the last parameter');return pe})),L.some(ue)?null:{params:L,fn:P}}function g(q){var P=ye(q);return P?P.restParam:!1}function y(q){return q.types.some(function(P){return P.conversion!=null})}function x(q){if(!q||q.types.length===0)return a;if(q.types.length===1)return o(q.types[0].name).test;if(q.types.length===2){var P=o(q.types[0].name).test,Q=o(q.types[1].name).test;return function(fe){return P(fe)||Q(fe)}}else{var L=q.types.map(function(se){return o(se.name).test});return function(fe){for(var ge=0;ge<L.length;ge++)if(L[ge](fe))return!0;return!1}}}function d(q){var P,Q,L;if(g(q)){P=ee(q).map(x);var se=P.length,fe=x(ye(q)),ge=function(pe){for(var ve=se;ve<pe.length;ve++)if(!fe(pe[ve]))return!1;return!0};return function(ve){for(var Ne=0;Ne<P.length;Ne++)if(!P[Ne](ve[Ne]))return!1;return ge(ve)&&ve.length>=se+1}}else return q.length===0?function(ve){return ve.length===0}:q.length===1?(Q=x(q[0]),function(ve){return Q(ve[0])&&ve.length===1}):q.length===2?(Q=x(q[0]),L=x(q[1]),function(ve){return Q(ve[0])&&L(ve[1])&&ve.length===2}):(P=q.map(x),function(ve){for(var Ne=0;Ne<P.length;Ne++)if(!P[Ne](ve[Ne]))return!1;return ve.length===P.length})}function A(q,P){return P<q.params.length?q.params[P]:g(q.params)?ye(q.params):null}function S(q,P,Q){var L=A(q,P),se=L?Q?L.types.filter(M):L.types:[];return se.map(O)}function O(q){return q.name}function M(q){return q.conversion===null||q.conversion===void 0}function _(q,P){var Q=Y(k(q,function(L){return S(L,P,!1)}));return Q.indexOf("any")!==-1?["any"]:Q}function E(q,P,Q){var L,se,fe=q||"unnamed",ge=Q,pe;for(pe=0;pe<P.length;pe++){var ve=ge.filter(function(tr){var Jr=x(A(tr,pe));return(pe<tr.params.length||g(tr.params))&&Jr(P[pe])});if(ve.length===0){if(se=_(ge,pe),se.length>0){var Ne=p(P[pe]);return L=new TypeError("Unexpected type of argument in function "+fe+" (expected: "+se.join(" or ")+", actual: "+Ne+", index: "+pe+")"),L.data={category:"wrongType",fn:fe,index:pe,actual:Ne,expected:se},L}}else ge=ve}var Qe=ge.map(function(tr){return g(tr.params)?1/0:tr.params.length});if(P.length<Math.min.apply(null,Qe))return se=_(ge,pe),L=new TypeError("Too few arguments in function "+fe+" (expected: "+se.join(" or ")+", index: "+P.length+")"),L.data={category:"tooFewArgs",fn:fe,index:P.length,expected:se},L;var cr=Math.max.apply(null,Qe);return P.length>cr?(L=new TypeError("Too many arguments in function "+fe+" (expected: "+cr+", actual: "+P.length+")"),L.data={category:"tooManyArgs",fn:fe,index:P.length,expectedLength:cr},L):(L=new TypeError('Arguments of type "'+P.join(", ")+'" do not match any of the defined signatures of function '+fe+"."),L.data={category:"mismatch",actual:P.map(p)},L)}function $(q){for(var P=999,Q=0;Q<q.types.length;Q++)M(q.types[Q])&&(P=Math.min(P,q.types[Q].typeIndex));return P}function z(q){for(var P=999,Q=0;Q<q.types.length;Q++)M(q.types[Q])||(P=Math.min(P,q.types[Q].conversionIndex));return P}function I(q,P){var Q;return Q=q.restParam-P.restParam,Q!==0||(Q=y(q)-y(P),Q!==0)||(Q=$(q)-$(P),Q!==0)?Q:z(q)-z(P)}function T(q,P){var Q=Math.min(q.params.length,P.params.length),L,se;if(se=q.params.some(y)-P.params.some(y),se!==0)return se;for(L=0;L<Q;L++)if(se=y(q.params[L])-y(P.params[L]),se!==0)return se;for(L=0;L<Q;L++)if(se=I(q.params[L],P.params[L]),se!==0)return se;return q.params.length-P.params.length}function B(q,P){var Q={};return q.forEach(function(L){P.indexOf(L.from)===-1&&P.indexOf(L.to)!==-1&&!Q[L.from]&&(Q[L.from]=L)}),Object.keys(Q).map(function(L){return Q[L]})}function G(q,P){var Q=P;if(q.some(y)){var L=g(q),se=q.map(D);Q=function(){for(var ve=[],Ne=L?arguments.length-1:arguments.length,Qe=0;Qe<Ne;Qe++)ve[Qe]=se[Qe](arguments[Qe]);return L&&(ve[Ne]=arguments[Ne].map(se[Ne])),P.apply(this,ve)}}var fe=Q;if(g(q)){var ge=q.length-1;fe=function(){return Q.apply(this,we(arguments,0,ge).concat([we(arguments,ge)]))}}return fe}function D(q){var P,Q,L,se,fe=[],ge=[];switch(q.types.forEach(function(pe){pe.conversion&&(fe.push(o(pe.conversion.from).test),ge.push(pe.conversion.convert))}),ge.length){case 0:return function(ve){return ve};case 1:return P=fe[0],L=ge[0],function(ve){return P(ve)?L(ve):ve};case 2:return P=fe[0],Q=fe[1],L=ge[0],se=ge[1],function(ve){return P(ve)?L(ve):Q(ve)?se(ve):ve};default:return function(ve){for(var Ne=0;Ne<ge.length;Ne++)if(fe[Ne](ve))return ge[Ne](ve);return ve}}}function H(q){var P={};return q.forEach(function(Q){Q.params.some(y)||W(Q.params,!0).forEach(function(L){P[b(L)]=Q.fn})}),P}function W(q,P){function Q(L,se,fe){if(se<L.length){var ge=L[se],pe=P?ge.types.filter(M):ge.types,ve;if(ge.restParam){var Ne=pe.filter(M);ve=Ne.length<pe.length?[Ne,pe]:[pe]}else ve=pe.map(function(cr){return[cr]});return k(ve,function(cr){return Q(L,se+1,fe.concat([cr]))})}else{var Qe=fe.map(function(cr,tr){return{types:cr,restParam:tr===L.length-1&&g(L)}});return[Qe]}}return Q(q,0,[])}function j(q,P){for(var Q=Math.max(q.params.length,P.params.length),L=0;L<Q;L++){var se=S(q,L,!0),fe=S(P,L,!0);if(!xe(se,fe))return!1}var ge=q.params.length,pe=P.params.length,ve=g(q.params),Ne=g(P.params);return ve?Ne?ge===pe:pe>=ge:Ne?ge>=pe:ge===pe}function V(q,P){if(Object.keys(P).length===0)throw new SyntaxError("No signatures provided");var Q=[];Object.keys(P).map(function(nr){return N(nr,P[nr],s.conversions)}).filter(ne).forEach(function(nr){var Cr=F(Q,function(vt){return j(vt,nr)});if(Cr)throw new TypeError('Conflicting signatures "'+b(Cr.params)+'" and "'+b(nr.params)+'".');Q.push(nr)});var L=k(Q,function(nr){var Cr=nr?W(nr.params,!1):[];return Cr.map(function(vt){return{params:vt,fn:nr.fn}})}).filter(ne);L.sort(T);var se=L[0]&&L[0].params.length<=2&&!g(L[0].params),fe=L[1]&&L[1].params.length<=2&&!g(L[1].params),ge=L[2]&&L[2].params.length<=2&&!g(L[2].params),pe=L[3]&&L[3].params.length<=2&&!g(L[3].params),ve=L[4]&&L[4].params.length<=2&&!g(L[4].params),Ne=L[5]&&L[5].params.length<=2&&!g(L[5].params),Qe=se&&fe&&ge&&pe&&ve&&Ne,cr=L.map(function(nr){return d(nr.params)}),tr=se?x(L[0].params[0]):t,Jr=fe?x(L[1].params[0]):t,Lr=ge?x(L[2].params[0]):t,Ot=pe?x(L[3].params[0]):t,Ze=ve?x(L[4].params[0]):t,Pt=Ne?x(L[5].params[0]):t,C=se?x(L[0].params[1]):t,X=fe?x(L[1].params[1]):t,ae=ge?x(L[2].params[1]):t,he=pe?x(L[3].params[1]):t,qe=ve?x(L[4].params[1]):t,Ue=Ne?x(L[5].params[1]):t,dr=L.map(function(nr){return G(nr.params,nr.fn)}),to=se?dr[0]:r,W_=fe?dr[1]:r,J_=ge?dr[2]:r,Q_=pe?dr[3]:r,K_=ve?dr[4]:r,j_=Ne?dr[5]:r,e$=se?L[0].params.length:-1,r$=fe?L[1].params.length:-1,t$=ge?L[2].params.length:-1,n$=pe?L[3].params.length:-1,a$=ve?L[4].params.length:-1,i$=Ne?L[5].params.length:-1,o$=Qe?6:0,s$=L.length,u$=function(){for(var Cr=o$;Cr<s$;Cr++)if(cr[Cr](arguments))return dr[Cr].apply(this,arguments);return s.onMismatch(q,arguments,L)},no=function nr(Cr,vt){return arguments.length===e$&&tr(Cr)&&C(vt)?to.apply(nr,arguments):arguments.length===r$&&Jr(Cr)&&X(vt)?W_.apply(nr,arguments):arguments.length===t$&&Lr(Cr)&&ae(vt)?J_.apply(nr,arguments):arguments.length===n$&&Ot(Cr)&&he(vt)?Q_.apply(nr,arguments):arguments.length===a$&&Ze(Cr)&&qe(vt)?K_.apply(nr,arguments):arguments.length===i$&&Pt(Cr)&&Ue(vt)?j_.apply(nr,arguments):u$.apply(nr,arguments)};try{Object.defineProperty(no,"name",{value:q})}catch(nr){}return no.signatures=H(L),no}function K(q,P,Q){throw E(q,P,Q)}function te(q){return s.ignore.indexOf(q)===-1}function re(q){return q.trim()}function ie(q){return!!q}function ne(q){return q!==null}function ue(q){return q.types.length===0}function ee(q){return q.slice(0,q.length-1)}function ye(q){return q[q.length-1]}function we(q,P,Q){return Array.prototype.slice.call(q,P,Q)}function me(q,P){return q.indexOf(P)!==-1}function xe(q,P){for(var Q=0;Q<q.length;Q++)if(me(P,q[Q]))return!0;return!1}function F(q,P){for(var Q=0;Q<q.length;Q++)if(P(q[Q]))return q[Q]}function Y(q){for(var P={},Q=0;Q<q.length;Q++)P[q[Q]]=!0;return Object.keys(P)}function k(q,P){return Array.prototype.concat.apply([],q.map(P))}function U(q){for(var P="",Q=0;Q<q.length;Q++){var L=q[Q];if((typeof L.signatures=="object"||typeof L.signature=="string")&&L.name!==""){if(P==="")P=L.name;else if(P!==L.name){var se=new Error("Function names do not match (expected: "+P+", actual: "+L.name+")");throw se.data={actual:L.name,expected:P},se}}}return P}function J(q){var P,Q={};function L(pe,ve){if(Q.hasOwnProperty(pe)&&ve!==Q[pe])throw P=new Error('Signature "'+pe+'" is defined twice'),P.data={signature:pe},P}for(var se=0;se<q.length;se++){var fe=q[se];if(typeof fe.signatures=="object")for(var ge in fe.signatures)fe.signatures.hasOwnProperty(ge)&&(L(ge,fe.signatures[ge]),Q[ge]=fe.signatures[ge]);else if(typeof fe.signature=="string")L(fe.signature,fe),Q[fe.signature]=fe;else throw P=new TypeError("Function is no typed-function (index: "+se+")"),P.data={index:se},P}return Q}return s=V("typed",{"string, Object":V,Object:function(q){var P=[];for(var Q in q)q.hasOwnProperty(Q)&&P.push(q[Q]);var L=U(P);return V(L,q)},"...Function":function(q){return V(U(q),J(q))},"string, ...Function":function(q,P){return V(q,J(P))}}),s.create=i,s.types=l,s.conversions=c,s.ignore=f,s.onMismatch=K,s.throwMismatchError=K,s.createError=E,s.convert=h,s.find=v,s.addType=function(q,P){if(!q||typeof q.name!="string"||typeof q.test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");if(P!==!1){for(var Q=0;Q<s.types.length;Q++)if(s.types[Q].name==="Object"){s.types.splice(Q,0,q);return}}s.types.push(q)},s.addConversion=function(q){if(!q||typeof q.from!="string"||typeof q.to!="string"||typeof q.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");s.conversions.push(q)},s}return i()})}(ea)),ea.exports}var Lp=Up();const uo=Tn(Lp);function Ae(e){return typeof e=="boolean"?!0:isFinite(e)?e===Math.round(e):!1}var Dt=Math.sign||function(e){return e>0?1:e<0?-1:0},kp=Math.log2||function(n){return Math.log(n)/Math.LN2},Hp=Math.log10||function(n){return Math.log(n)/Math.LN10},Gp=Math.log1p||function(e){return Math.log(e+1)},Vp=Math.cbrt||function(n){if(n===0)return n;var a=n<0,t;return a&&(n=-n),isFinite(n)?(t=Math.exp(Math.log(n)/3),t=(n/(t*t)+2*t)/3):t=n,a?-t:t},Zp=Math.expm1||function(n){return n>=2e-4||n<=-2e-4?Math.exp(n)-1:n+n*n/2+n*n*n/6};function ja(e,n,a){var t={2:"0b",8:"0o",16:"0x"},r=t[n],i="";if(a){if(a<1)throw new Error("size must be in greater than 0");if(!Ae(a))throw new Error("size must be an integer");if(e>en(2,a-1)-1||e<-en(2,a-1))throw new Error("Value must be in range [-2^".concat(a-1,", 2^").concat(a-1,"-1]"));if(!Ae(e))throw new Error("Value must be an integer");e<0&&(e=e+en(2,a)),i="i".concat(a)}var l="";return e<0&&(e=-e,l="-"),"".concat(l).concat(r).concat(e.toString(n)).concat(i)}function Ht(e,n){if(typeof n=="function")return n(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var a="auto",t,r;if(n&&(n.notation&&(a=n.notation),Be(n)?t=n:Be(n.precision)&&(t=n.precision),n.wordSize&&(r=n.wordSize,typeof r!="number")))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return co(e,t);case"exponential":return fo(e,t);case"engineering":return Xp(e,t);case"bin":return ja(e,2,r);case"oct":return ja(e,8,r);case"hex":return ja(e,16,r);case"auto":return Yp(e,t,n&&n).replace(/((\.\d*?)(0+))($|e)/,function(){var i=arguments[2],l=arguments[4];return i!=="."?i+l:l});default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function ra(e){var n=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!n)throw new SyntaxError("Invalid number "+e);var a=n[1],t=n[2],r=parseFloat(n[4]||"0"),i=t.indexOf(".");r+=i!==-1?i-1:t.length-1;var l=t.replace(".","").replace(/^0*/,function(m){return r-=m.length,""}).replace(/0*$/,"").split("").map(function(m){return parseInt(m)});return l.length===0&&(l.push(0),r++),{sign:a,coefficients:l,exponent:r}}function Xp(e,n){if(isNaN(e)||!isFinite(e))return String(e);var a=ra(e),t=ta(a,n),r=t.exponent,i=t.coefficients,l=r%3===0?r:r<0?r-3-r%3:r-r%3;if(Be(n))for(;n>i.length||r-l+1>i.length;)i.push(0);else for(var m=Math.abs(r-l)-(i.length-1),f=0;f<m;f++)i.push(0);for(var c=Math.abs(r-l),s=1;c>0;)s++,c--;var o=i.slice(s).join(""),u=Be(n)&&o.length||o.match(/[1-9]/)?"."+o:"",p=i.slice(0,s).join("")+u+"e"+(r>=0?"+":"")+l.toString();return t.sign+p}function co(e,n){if(isNaN(e)||!isFinite(e))return String(e);var a=ra(e),t=typeof n=="number"?ta(a,a.exponent+1+n):a,r=t.coefficients,i=t.exponent+1,l=i+(n||0);return r.length<l&&(r=r.concat(nn(l-r.length))),i<0&&(r=nn(-i+1).concat(r),i=1),i<r.length&&r.splice(i,0,i===0?"0.":"."),t.sign+r.join("")}function fo(e,n){if(isNaN(e)||!isFinite(e))return String(e);var a=ra(e),t=n?ta(a,n):a,r=t.coefficients,i=t.exponent;r.length<n&&(r=r.concat(nn(n-r.length)));var l=r.shift();return t.sign+l+(r.length>0?"."+r.join(""):"")+"e"+(i>=0?"+":"")+i}function Yp(e,n,a){if(isNaN(e)||!isFinite(e))return String(e);var t=a&&a.lowerExp!==void 0?a.lowerExp:-3,r=a&&a.upperExp!==void 0?a.upperExp:5,i=ra(e),l=n?ta(i,n):i;if(l.exponent<t||l.exponent>=r)return fo(e,n);var m=l.coefficients,f=l.exponent;m.length<n&&(m=m.concat(nn(n-m.length))),m=m.concat(nn(f-m.length+1+(m.length<n?n-m.length:0))),m=nn(-f).concat(m);var c=f>0?f:0;return c<m.length-1&&m.splice(c+1,0,"."),l.sign+m.join("")}function ta(e,n){for(var a={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},t=a.coefficients;n<=0;)t.unshift(0),a.exponent++,n++;if(t.length>n){var r=t.splice(n,t.length-n);if(r[0]>=5){var i=n-1;for(t[i]++;t[i]===10;)t.pop(),i===0&&(t.unshift(0),a.exponent++,i++),i--,t[i]++}}return a}function nn(e){for(var n=[],a=0;a<e;a++)n.push(0);return n}function Wp(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var Jp=Number.EPSILON||2220446049250313e-31;function Rr(e,n,a){if(a==null)return e===n;if(e===n)return!0;if(isNaN(e)||isNaN(n))return!1;if(isFinite(e)&&isFinite(n)){var t=Math.abs(e-n);return t<Jp?!0:t<=Math.max(Math.abs(e),Math.abs(n))*a}return!1}var Qp=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)},Kp=Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},jp=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2},ev=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2},rv=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2},tv=Math.tanh||function(e){var n=Math.exp(2*e);return(n-1)/(n+1)};function nv(e,n){var a=!0,t=n>0?!0:n<0?!1:1/n===1/0;return a^t?-e:e}function ei(e,n,a){var t=e.constructor,r=new t(2),i="";if(a){if(a<1)throw new Error("size must be in greater than 0");if(!Ae(a))throw new Error("size must be an integer");if(e.greaterThan(r.pow(a-1).sub(1))||e.lessThan(r.pow(a-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(a-1,", 2^").concat(a-1,"-1]"));if(!e.isInteger())throw new Error("Value must be an integer");e.lessThan(0)&&(e=e.add(r.pow(a))),i="i".concat(a)}switch(n){case 2:return"".concat(e.toBinary()).concat(i);case 8:return"".concat(e.toOctal()).concat(i);case 16:return"".concat(e.toHexadecimal()).concat(i);default:throw new Error("Base ".concat(n," not supported "))}}function av(e,n){if(typeof n=="function")return n(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var a="auto",t,r;if(n!==void 0&&(n.notation&&(a=n.notation),typeof n=="number"?t=n:n.precision&&(t=n.precision),n.wordSize&&(r=n.wordSize,typeof r!="number")))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return ov(e,t);case"exponential":return lo(e,t);case"engineering":return iv(e,t);case"bin":return ei(e,2,r);case"oct":return ei(e,8,r);case"hex":return ei(e,16,r);case"auto":{var i=n&&n.lowerExp!==void 0?n.lowerExp:-3,l=n&&n.upperExp!==void 0?n.upperExp:5;if(e.isZero())return"0";var m,f=e.toSignificantDigits(t),c=f.e;return c>=i&&c<l?m=f.toFixed():m=lo(e,t),m.replace(/((\.\d*?)(0+))($|e)/,function(){var s=arguments[2],o=arguments[4];return s!=="."?s+o:o})}default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function iv(e,n){var a=e.e,t=a%3===0?a:a<0?a-3-a%3:a-a%3,r=e.mul(Math.pow(10,-t)),i=r.toPrecision(n);return i.indexOf("e")!==-1&&(i=r.toString()),i+"e"+(a>=0?"+":"")+t.toString()}function lo(e,n){return n!==void 0?e.toExponential(n-1):e.toExponential()}function ov(e,n){return e.toFixed(n)}function sv(e,n){var a=e.length-n.length,t=e.length;return e.substring(a,t)===n}function Re(e,n){var a=uv(e,n);return n&&typeof n=="object"&&"truncate"in n&&a.length>n.truncate?a.substring(0,n.truncate-3)+"...":a}function uv(e,n){if(typeof e=="number")return Ht(e,n);if(_e(e))return av(e,n);if(cv(e))return!n||n.fraction!=="decimal"?e.s*e.n+"/"+e.d:e.toString();if(Array.isArray(e))return mo(e,n);if(_r(e))return'"'+e+'"';if(typeof e=="function")return e.syntax?String(e.syntax):"function";if(e&&typeof e=="object"){if(typeof e.format=="function")return e.format(n);if(e&&e.toString(n)!=={}.toString())return e.toString(n);var a=Object.keys(e).map(t=>'"'+t+'": '+Re(e[t],n));return"{"+a.join(", ")+"}"}return String(e)}function na(e){for(var n=String(e),a="",t=0;t<n.length;){var r=n.charAt(t);r==="\\"?(a+=r,t++,r=n.charAt(t),(r===""||'"\\/bfnrtu'.indexOf(r)===-1)&&(a+="\\"),a+=r):r==='"'?a+='\\"':a+=r,t++}return'"'+a+'"'}function Gr(e){var n=String(e);return n=n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),n}function mo(e,n){if(Array.isArray(e)){for(var a="[",t=e.length,r=0;r<t;r++)r!==0&&(a+=", "),a+=mo(e[r],n);return a+="]",a}else return Re(e,n)}function cv(e){return e&&typeof e=="object"&&typeof e.s=="number"&&typeof e.n=="number"&&typeof e.d=="number"||!1}function an(e,n){if(!_r(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Ke(e)+", index: 0)");if(!_r(n))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Ke(n)+", index: 1)");return e===n?0:e>n?1:-1}function Fe(e,n,a){if(!(this instanceof Fe))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=n,this.relation=a,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(n)?"["+n.join(", ")+"]":n)+")",this.stack=new Error().stack}Fe.prototype=new RangeError,Fe.prototype.constructor=RangeError,Fe.prototype.name="DimensionError",Fe.prototype.isDimensionError=!0;function Kr(e,n,a){if(!(this instanceof Kr))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=n):(this.min=n,this.max=a),this.min!==void 0&&this.index<this.min?this.message="Index out of range ("+this.index+" < "+this.min+")":this.max!==void 0&&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}Kr.prototype=new RangeError,Kr.prototype.constructor=RangeError,Kr.prototype.name="IndexError",Kr.prototype.isIndexError=!0;function Pe(e){for(var n=[];Array.isArray(e);)n.push(e.length),e=e[0];return n}function po(e,n,a){var t,r=e.length;if(r!==n[a])throw new Fe(r,n[a]);if(a<n.length-1){var i=a+1;for(t=0;t<r;t++){var l=e[t];if(!Array.isArray(l))throw new Fe(n.length-1,n.length,"<");po(e[t],n,i)}}else for(t=0;t<r;t++)if(Array.isArray(e[t]))throw new Fe(n.length+1,n.length,">")}function vo(e,n){var a=n.length===0;if(a){if(Array.isArray(e))throw new Fe(e.length,0)}else po(e,n,0)}function We(e,n){if(!Be(e)||!Ae(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||typeof n=="number"&&e>=n)throw new Kr(e,n)}function on(e,n,a){if(!Array.isArray(e)||!Array.isArray(n))throw new TypeError("Array expected");if(n.length===0)throw new Error("Resizing to scalar is not supported");n.forEach(function(r){if(!Be(r)||!Ae(r)||r<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Re(n)+")")});var t=a!==void 0?a:0;return ri(e,n,0,t),e}function ri(e,n,a,t){var r,i,l=e.length,m=n[a],f=Math.min(l,m);if(e.length=m,a<n.length-1){var c=a+1;for(r=0;r<f;r++)i=e[r],Array.isArray(i)||(i=[i],e[r]=i),ri(i,n,c,t);for(r=f;r<m;r++)i=[],e[r]=i,ri(i,n,c,t)}else{for(r=0;r<f;r++)for(;Array.isArray(e[r]);)e[r]=e[r][0];for(r=f;r<m;r++)e[r]=t}}function ho(e,n){var a=Le(e),t=a.length;if(!Array.isArray(e)||!Array.isArray(n))throw new TypeError("Array expected");if(n.length===0)throw new Fe(0,t,"!=");n=ti(n,t);var r=go(n);if(t!==r)throw new Fe(r,t,"!=");try{return fv(a,n)}catch(i){throw i instanceof Fe?new Fe(r,t,"!="):i}}function ti(e,n){var a=go(e),t=e.slice(),r=-1,i=e.indexOf(r),l=e.indexOf(r,i+1)>=0;if(l)throw new Error("More than one wildcard in sizes");var m=i>=0,f=n%a===0;if(m)if(f)t[i]=-n/a;else throw new Error("Could not replace wildcard, since "+n+" is no multiple of "+-a);return t}function go(e){return e.reduce((n,a)=>n*a,1)}function fv(e,n){for(var a=e,t,r=n.length-1;r>0;r--){var i=n[r];t=[];for(var l=a.length/i,m=0;m<l;m++)t.push(a.slice(m*i,(m+1)*i));a=t}return a}function aa(e,n){for(var a=Pe(e);Array.isArray(e)&&e.length===1;)e=e[0],a.shift();for(var t=a.length;a[t-1]===1;)t--;return t<a.length&&(e=yo(e,t,0),a.length=t),e}function yo(e,n,a){var t,r;if(a<n){var i=a+1;for(t=0,r=e.length;t<r;t++)e[t]=yo(e[t],n,i)}else for(;Array.isArray(e);)e=e[0];return e}function xo(e,n,a,t){var r=t||Pe(e);if(a)for(var i=0;i<a;i++)e=[e],r.unshift(1);for(e=bo(e,n,0);r.length<n;)r.push(1);return e}function bo(e,n,a){var t,r;if(Array.isArray(e)){var i=a+1;for(t=0,r=e.length;t<r;t++)e[t]=bo(e[t],n,i)}else for(var l=a;l<n;l++)e=[e];return e}function Le(e){if(!Array.isArray(e))return e;var n=[];return e.forEach(function a(t){Array.isArray(t)?t.forEach(a):n.push(t)}),n}function dt(e,n){return Array.prototype.map.call(e,n)}function ia(e,n){Array.prototype.forEach.call(e,n)}function wo(e,n){if(Pe(e).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,n)}function oa(e,n){if(Pe(e).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,a=>n.test(a))}function No(e,n){return Array.prototype.join.call(e,n)}function sn(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(e.length===0)return e;var n=[],a=0;n[0]={value:e[0],identifier:0};for(var t=1;t<e.length;t++)e[t]===e[t-1]?a++:a=0,n.push({value:e[t],identifier:a});return n}function sa(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(e.length===0)return e;for(var n=[],a=0;a<e.length;a++)n.push(e[a].value);return n}function Bn(e,n){for(var a,t=0,r=0;r<e.length;r++){var i=e[r],l=Array.isArray(i);if(r===0&&l&&(t=i.length),l&&i.length!==t)return;var m=l?Bn(i,n):n(i);if(a===void 0)a=m;else if(a!==m)return"mixed"}return a}function R(e,n,a,t){function r(i){var l=qp(i,n.map(pv));return lv(e,n,i),a(l)}return r.isFactory=!0,r.fn=e,r.dependencies=n.slice().sort(),t&&(r.meta=t),r}function lv(e,n,a){var t=n.filter(i=>!mv(i)).every(i=>a[i]!==void 0);if(!t){var r=n.filter(i=>a[i]===void 0);throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(r.map(i=>'"'.concat(i,'"')).join(", "),"."))}}function mv(e){return e&&e[0]==="?"}function pv(e){return e&&e[0]==="?"?e.slice(1):e}function Vr(e,n){if(Mo(e)&&ni(e,n))return e[n];throw typeof e[n]=="function"&&ai(e,n)?new Error('Cannot access method "'+n+'" as a property'):new Error('No access to property "'+n+'"')}function un(e,n,a){if(Mo(e)&&ni(e,n))return e[n]=a,a;throw new Error('No access to property "'+n+'"')}function vv(e,n){return n in e}function ni(e,n){return!e||typeof e!="object"?!1:Me(dv,n)?!0:!(n in Object.prototype||n in Function.prototype)}function hv(e,n){if(!ai(e,n))throw new Error('No access to method "'+n+'"')}function ai(e,n){return e==null||typeof e[n]!="function"||Me(e,n)&&Object.getPrototypeOf&&n in Object.getPrototypeOf(e)?!1:Me(gv,n)?!0:!(n in Object.prototype||n in Function.prototype)}function Mo(e){return typeof e=="object"&&e&&e.constructor===Object}var dv={length:!0,name:!0},gv={toString:!0,valueOf:!0,toLocaleString:!0};class ii{constructor(n){this.wrappedObject=n}keys(){return Object.keys(this.wrappedObject)}get(n){return Vr(this.wrappedObject,n)}set(n,a){return un(this.wrappedObject,n,a),this}has(n){return vv(this.wrappedObject,n)}}function gt(){return new Map}function oi(e){if(!e)return gt();if(ua(e))return e;if(Ja(e))return new ii(e);throw new Error("createMap can create maps from objects or Maps")}function yv(e){if(e instanceof ii)return e.wrappedObject;var n={};for(var a of e.keys()){var t=e.get(a);un(n,a,t)}return n}function ua(e){return e?e instanceof Map||e instanceof ii||typeof e.set=="function"&&typeof e.get=="function"&&typeof e.keys=="function"&&typeof e.has=="function":!1}function Ao(e){for(var n=arguments.length,a=new Array(n>1?n-1:0),t=1;t<n;t++)a[t-1]=arguments[t];for(var r of a)if(r){if(ua(r))for(var i of r.keys())e.set(i,r.get(i));else if(Ja(r))for(var l of Object.keys(r))e.set(l,r[l])}return e}var So=function(){return So=uo.create,uo},xv=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],bv=R("typed",xv,function(n){var{BigNumber:a,Complex:t,DenseMatrix:r,Fraction:i}=n,l=So();return l.types=[{name:"number",test:Be},{name:"Complex",test:Or},{name:"BigNumber",test:_e},{name:"Fraction",test:yr},{name:"Unit",test:ht},{name:"string",test:_r},{name:"Chain",test:Qa},{name:"Array",test:Xe},{name:"Matrix",test:Oe},{name:"DenseMatrix",test:Qn},{name:"SparseMatrix",test:Ut},{name:"Range",test:Kn},{name:"Index",test:En},{name:"boolean",test:Mp},{name:"ResultSet",test:oo},{name:"Help",test:Wa},{name:"function",test:Ap},{name:"Date",test:Sp},{name:"RegExp",test:Ep},{name:"null",test:Cp},{name:"undefined",test:Op},{name:"AccessorNode",test:Lt},{name:"ArrayNode",test:Hr},{name:"AssignmentNode",test:Dp},{name:"BlockNode",test:Tp},{name:"ConditionalNode",test:Bp},{name:"ConstantNode",test:Ye},{name:"FunctionNode",test:kt},{name:"FunctionAssignmentNode",test:Cn},{name:"IndexNode",test:tn},{name:"Node",test:Ve},{name:"ObjectNode",test:jn},{name:"OperatorNode",test:$r},{name:"ParenthesisNode",test:On},{name:"RangeNode",test:_p},{name:"SymbolNode",test:xr},{name:"Map",test:ua},{name:"Object",test:Ja}],l.conversions=[{from:"number",to:"BigNumber",convert:function(f){if(a||si(f),Wp(f)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+f+"). Use function bignumber(x) to convert to BigNumber.");return new a(f)}},{from:"number",to:"Complex",convert:function(f){return t||ca(f),new t(f,0)}},{from:"number",to:"string",convert:function(f){return f+""}},{from:"BigNumber",to:"Complex",convert:function(f){return t||ca(f),new t(f.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(f){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(f){return t||ca(f),new t(f.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(f){i||ui(f);var c=new i(f);if(c.valueOf()!==f)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+f+"). Use function fraction(x) to convert to Fraction.");return c}},{from:"string",to:"number",convert:function(f){var c=Number(f);if(isNaN(c))throw new Error('Cannot convert "'+f+'" to a number');return c}},{from:"string",to:"BigNumber",convert:function(f){a||si(f);try{return new a(f)}catch(c){throw new Error('Cannot convert "'+f+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(f){i||ui(f);try{return new i(f)}catch(c){throw new Error('Cannot convert "'+f+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(f){t||ca(f);try{return new t(f)}catch(c){throw new Error('Cannot convert "'+f+'" to Complex')}}},{from:"boolean",to:"number",convert:function(f){return+f}},{from:"boolean",to:"BigNumber",convert:function(f){return a||si(f),new a(+f)}},{from:"boolean",to:"Fraction",convert:function(f){return i||ui(f),new i(+f)}},{from:"boolean",to:"string",convert:function(f){return String(f)}},{from:"Array",to:"Matrix",convert:function(f){return r||wv(),new r(f)}},{from:"Matrix",to:"Array",convert:function(f){return f.valueOf()}}],l});function si(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function ca(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function wv(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function ui(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var Nv="ResultSet",Mv=[],Av=R(Nv,Mv,()=>{function e(n){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=n||[]}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(n){return new e(n.entries)},e},{isClass:!0});var cn=9e15,Tt=1e9,ci="0123456789abcdef",fa="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",la="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",fi={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-cn,maxE:cn,crypto:!1},Eo,yt,$e=!0,ma="[DecimalError] ",Bt=ma+"Invalid argument: ",Co=ma+"Precision limit exceeded",Oo=ma+"crypto unavailable",Do="[object Decimal]",Nr=Math.floor,hr=Math.pow,Sv=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Ev=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Cv=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,To=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,jr=1e7,De=7,Ov=9007199254740991,Dv=fa.length-1,li=la.length-1,ce={toStringTag:Do};ce.absoluteValue=ce.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),Ee(e)},ce.ceil=function(){return Ee(new this.constructor(this),this.e+1,2)},ce.clampedTo=ce.clamp=function(e,n){var a,t=this,r=t.constructor;if(e=new r(e),n=new r(n),!e.s||!n.s)return new r(NaN);if(e.gt(n))throw Error(Bt+n);return a=t.cmp(e),a<0?e:t.cmp(n)>0?n:new r(t)},ce.comparedTo=ce.cmp=function(e){var n,a,t,r,i=this,l=i.d,m=(e=new i.constructor(e)).d,f=i.s,c=e.s;if(!l||!m)return!f||!c?NaN:f!==c?f:l===m?0:!l^f<0?1:-1;if(!l[0]||!m[0])return l[0]?f:m[0]?-c:0;if(f!==c)return f;if(i.e!==e.e)return i.e>e.e^f<0?1:-1;for(t=l.length,r=m.length,n=0,a=t<r?t:r;n<a;++n)if(l[n]!==m[n])return l[n]>m[n]^f<0?1:-1;return t===r?0:t>r^f<0?1:-1},ce.cosine=ce.cos=function(){var e,n,a=this,t=a.constructor;return a.d?a.d[0]?(e=t.precision,n=t.rounding,t.precision=e+Math.max(a.e,a.sd())+De,t.rounding=1,a=Tv(t,Ro(t,a)),t.precision=e,t.rounding=n,Ee(yt==2||yt==3?a.neg():a,e,n,!0)):new t(1):new t(NaN)},ce.cubeRoot=ce.cbrt=function(){var e,n,a,t,r,i,l,m,f,c,s=this,o=s.constructor;if(!s.isFinite()||s.isZero())return new o(s);for($e=!1,i=s.s*hr(s.s*s,1/3),!i||Math.abs(i)==1/0?(a=br(s.d),e=s.e,(i=(e-a.length+1)%3)&&(a+=i==1||i==-2?"0":"00"),i=hr(a,1/3),e=Nr((e+1)/3)-(e%3==(e<0?-1:2)),i==1/0?a="5e"+e:(a=i.toExponential(),a=a.slice(0,a.indexOf("e")+1)+e),t=new o(a),t.s=s.s):t=new o(i.toString()),l=(e=o.precision)+3;;)if(m=t,f=m.times(m).times(m),c=f.plus(s),t=er(c.plus(s).times(m),c.plus(f),l+2,1),br(m.d).slice(0,l)===(a=br(t.d)).slice(0,l))if(a=a.slice(l-3,l+1),a=="9999"||!r&&a=="4999"){if(!r&&(Ee(m,e+1,0),m.times(m).times(m).eq(s))){t=m;break}l+=4,r=1}else{(!+a||!+a.slice(1)&&a.charAt(0)=="5")&&(Ee(t,e+1,1),n=!t.times(t).times(t).eq(s));break}return $e=!0,Ee(t,e,o.rounding,n)},ce.decimalPlaces=ce.dp=function(){var e,n=this.d,a=NaN;if(n){if(e=n.length-1,a=(e-Nr(this.e/De))*De,e=n[e],e)for(;e%10==0;e/=10)a--;a<0&&(a=0)}return a},ce.dividedBy=ce.div=function(e){return er(this,new this.constructor(e))},ce.dividedToIntegerBy=ce.divToInt=function(e){var n=this,a=n.constructor;return Ee(er(n,new a(e),0,1,1),a.precision,a.rounding)},ce.equals=ce.eq=function(e){return this.cmp(e)===0},ce.floor=function(){return Ee(new this.constructor(this),this.e+1,3)},ce.greaterThan=ce.gt=function(e){return this.cmp(e)>0},ce.greaterThanOrEqualTo=ce.gte=function(e){var n=this.cmp(e);return n==1||n===0},ce.hyperbolicCosine=ce.cosh=function(){var e,n,a,t,r,i=this,l=i.constructor,m=new l(1);if(!i.isFinite())return new l(i.s?1/0:NaN);if(i.isZero())return m;a=l.precision,t=l.rounding,l.precision=a+Math.max(i.e,i.sd())+4,l.rounding=1,r=i.d.length,r<32?(e=Math.ceil(r/3),n=(1/ga(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),i=fn(l,1,i.times(n),new l(1),!0);for(var f,c=e,s=new l(8);c--;)f=i.times(i),i=m.minus(f.times(s.minus(f.times(s))));return Ee(i,l.precision=a,l.rounding=t,!0)},ce.hyperbolicSine=ce.sinh=function(){var e,n,a,t,r=this,i=r.constructor;if(!r.isFinite()||r.isZero())return new i(r);if(n=i.precision,a=i.rounding,i.precision=n+Math.max(r.e,r.sd())+4,i.rounding=1,t=r.d.length,t<3)r=fn(i,2,r,r,!0);else{e=1.4*Math.sqrt(t),e=e>16?16:e|0,r=r.times(1/ga(5,e)),r=fn(i,2,r,r,!0);for(var l,m=new i(5),f=new i(16),c=new i(20);e--;)l=r.times(r),r=r.times(m.plus(l.times(f.times(l).plus(c))))}return i.precision=n,i.rounding=a,Ee(r,n,a,!0)},ce.hyperbolicTangent=ce.tanh=function(){var e,n,a=this,t=a.constructor;return a.isFinite()?a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+7,t.rounding=1,er(a.sinh(),a.cosh(),t.precision=e,t.rounding=n)):new t(a.s)},ce.inverseCosine=ce.acos=function(){var e=this,n=e.constructor,a=e.abs().cmp(1),t=n.precision,r=n.rounding;return a!==-1?a===0?e.isNeg()?ot(n,t,r):new n(0):new n(NaN):e.isZero()?ot(n,t+4,r).times(.5):(n.precision=t+6,n.rounding=1,e=new n(1).minus(e).div(e.plus(1)).sqrt().atan(),n.precision=t,n.rounding=r,e.times(2))},ce.inverseHyperbolicCosine=ce.acosh=function(){var e,n,a=this,t=a.constructor;return a.lte(1)?new t(a.eq(1)?0:NaN):a.isFinite()?(e=t.precision,n=t.rounding,t.precision=e+Math.max(Math.abs(a.e),a.sd())+4,t.rounding=1,$e=!1,a=a.times(a).minus(1).sqrt().plus(a),$e=!0,t.precision=e,t.rounding=n,a.ln()):new t(a)},ce.inverseHyperbolicSine=ce.asinh=function(){var e,n,a=this,t=a.constructor;return!a.isFinite()||a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+2*Math.max(Math.abs(a.e),a.sd())+6,t.rounding=1,$e=!1,a=a.times(a).plus(1).sqrt().plus(a),$e=!0,t.precision=e,t.rounding=n,a.ln())},ce.inverseHyperbolicTangent=ce.atanh=function(){var e,n,a,t,r=this,i=r.constructor;return r.isFinite()?r.e>=0?new i(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(e=i.precision,n=i.rounding,t=r.sd(),Math.max(t,e)<2*-r.e-1?Ee(new i(r),e,n,!0):(i.precision=a=t-r.e,r=er(r.plus(1),new i(1).minus(r),a+e,1),i.precision=e+4,i.rounding=1,r=r.ln(),i.precision=e,i.rounding=n,r.times(.5))):new i(NaN)},ce.inverseSine=ce.asin=function(){var e,n,a,t,r=this,i=r.constructor;return r.isZero()?new i(r):(n=r.abs().cmp(1),a=i.precision,t=i.rounding,n!==-1?n===0?(e=ot(i,a+4,t).times(.5),e.s=r.s,e):new i(NaN):(i.precision=a+6,i.rounding=1,r=r.div(new i(1).minus(r.times(r)).sqrt().plus(1)).atan(),i.precision=a,i.rounding=t,r.times(2)))},ce.inverseTangent=ce.atan=function(){var e,n,a,t,r,i,l,m,f,c=this,s=c.constructor,o=s.precision,u=s.rounding;if(c.isFinite()){if(c.isZero())return new s(c);if(c.abs().eq(1)&&o+4<=li)return l=ot(s,o+4,u).times(.25),l.s=c.s,l}else{if(!c.s)return new s(NaN);if(o+4<=li)return l=ot(s,o+4,u).times(.5),l.s=c.s,l}for(s.precision=m=o+10,s.rounding=1,a=Math.min(28,m/De+2|0),e=a;e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for($e=!1,n=Math.ceil(m/De),t=1,f=c.times(c),l=new s(c),r=c;e!==-1;)if(r=r.times(f),i=l.minus(r.div(t+=2)),r=r.times(f),l=i.plus(r.div(t+=2)),l.d[n]!==void 0)for(e=n;l.d[e]===i.d[e]&&e--;);return a&&(l=l.times(2<<a-1)),$e=!0,Ee(l,s.precision=o,s.rounding=u,!0)},ce.isFinite=function(){return!!this.d},ce.isInteger=ce.isInt=function(){return!!this.d&&Nr(this.e/De)>this.d.length-2},ce.isNaN=function(){return!this.s},ce.isNegative=ce.isNeg=function(){return this.s<0},ce.isPositive=ce.isPos=function(){return this.s>0},ce.isZero=function(){return!!this.d&&this.d[0]===0},ce.lessThan=ce.lt=function(e){return this.cmp(e)<0},ce.lessThanOrEqualTo=ce.lte=function(e){return this.cmp(e)<1},ce.logarithm=ce.log=function(e){var n,a,t,r,i,l,m,f,c=this,s=c.constructor,o=s.precision,u=s.rounding,p=5;if(e==null)e=new s(10),n=!0;else{if(e=new s(e),a=e.d,e.s<0||!a||!a[0]||e.eq(1))return new s(NaN);n=e.eq(10)}if(a=c.d,c.s<0||!a||!a[0]||c.eq(1))return new s(a&&!a[0]?-1/0:c.s!=1?NaN:a?0:1/0);if(n)if(a.length>1)i=!0;else{for(r=a[0];r%10===0;)r/=10;i=r!==1}if($e=!1,m=o+p,l=$t(c,m),t=n?ha(s,m+10):$t(e,m),f=er(l,t,m,1),_n(f.d,r=o,u))do if(m+=10,l=$t(c,m),t=n?ha(s,m+10):$t(e,m),f=er(l,t,m,1),!i){+br(f.d).slice(r+1,r+15)+1==1e14&&(f=Ee(f,o+1,0));break}while(_n(f.d,r+=10,u));return $e=!0,Ee(f,o,u)},ce.minus=ce.sub=function(e){var n,a,t,r,i,l,m,f,c,s,o,u,p=this,v=p.constructor;if(e=new v(e),!p.d||!e.d)return!p.s||!e.s?e=new v(NaN):p.d?e.s=-e.s:e=new v(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(c=p.d,u=e.d,m=v.precision,f=v.rounding,!c[0]||!u[0]){if(u[0])e.s=-e.s;else if(c[0])e=new v(p);else return new v(f===3?-0:0);return $e?Ee(e,m,f):e}if(a=Nr(e.e/De),s=Nr(p.e/De),c=c.slice(),i=s-a,i){for(o=i<0,o?(n=c,i=-i,l=u.length):(n=u,a=s,l=c.length),t=Math.max(Math.ceil(m/De),l)+2,i>t&&(i=t,n.length=1),n.reverse(),t=i;t--;)n.push(0);n.reverse()}else{for(t=c.length,l=u.length,o=t<l,o&&(l=t),t=0;t<l;t++)if(c[t]!=u[t]){o=c[t]<u[t];break}i=0}for(o&&(n=c,c=u,u=n,e.s=-e.s),l=c.length,t=u.length-l;t>0;--t)c[l++]=0;for(t=u.length;t>i;){if(c[--t]<u[t]){for(r=t;r&&c[--r]===0;)c[r]=jr-1;--c[r],c[t]+=jr}c[t]-=u[t]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--a;return c[0]?(e.d=c,e.e=va(c,a),$e?Ee(e,m,f):e):new v(f===3?-0:0)},ce.modulo=ce.mod=function(e){var n,a=this,t=a.constructor;return e=new t(e),!a.d||!e.s||e.d&&!e.d[0]?new t(NaN):!e.d||a.d&&!a.d[0]?Ee(new t(a),t.precision,t.rounding):($e=!1,t.modulo==9?(n=er(a,e.abs(),0,3,1),n.s*=e.s):n=er(a,e,0,t.modulo,1),n=n.times(e),$e=!0,a.minus(n))},ce.naturalExponential=ce.exp=function(){return mi(this)},ce.naturalLogarithm=ce.ln=function(){return $t(this)},ce.negated=ce.neg=function(){var e=new this.constructor(this);return e.s=-e.s,Ee(e)},ce.plus=ce.add=function(e){var n,a,t,r,i,l,m,f,c,s,o=this,u=o.constructor;if(e=new u(e),!o.d||!e.d)return!o.s||!e.s?e=new u(NaN):o.d||(e=new u(e.d||o.s===e.s?o:NaN)),e;if(o.s!=e.s)return e.s=-e.s,o.minus(e);if(c=o.d,s=e.d,m=u.precision,f=u.rounding,!c[0]||!s[0])return s[0]||(e=new u(o)),$e?Ee(e,m,f):e;if(i=Nr(o.e/De),t=Nr(e.e/De),c=c.slice(),r=i-t,r){for(r<0?(a=c,r=-r,l=s.length):(a=s,t=i,l=c.length),i=Math.ceil(m/De),l=i>l?i+1:l+1,r>l&&(r=l,a.length=1),a.reverse();r--;)a.push(0);a.reverse()}for(l=c.length,r=s.length,l-r<0&&(r=l,a=s,s=c,c=a),n=0;r;)n=(c[--r]=c[r]+s[r]+n)/jr|0,c[r]%=jr;for(n&&(c.unshift(n),++t),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=va(c,t),$e?Ee(e,m,f):e},ce.precision=ce.sd=function(e){var n,a=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Bt+e);return a.d?(n=Bo(a.d),e&&a.e+1>n&&(n=a.e+1)):n=NaN,n},ce.round=function(){var e=this,n=e.constructor;return Ee(new n(e),e.e+1,n.rounding)},ce.sine=ce.sin=function(){var e,n,a=this,t=a.constructor;return a.isFinite()?a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+Math.max(a.e,a.sd())+De,t.rounding=1,a=_v(t,Ro(t,a)),t.precision=e,t.rounding=n,Ee(yt>2?a.neg():a,e,n,!0)):new t(NaN)},ce.squareRoot=ce.sqrt=function(){var e,n,a,t,r,i,l=this,m=l.d,f=l.e,c=l.s,s=l.constructor;if(c!==1||!m||!m[0])return new s(!c||c<0&&(!m||m[0])?NaN:m?l:1/0);for($e=!1,c=Math.sqrt(+l),c==0||c==1/0?(n=br(m),(n.length+f)%2==0&&(n+="0"),c=Math.sqrt(n),f=Nr((f+1)/2)-(f<0||f%2),c==1/0?n="5e"+f:(n=c.toExponential(),n=n.slice(0,n.indexOf("e")+1)+f),t=new s(n)):t=new s(c.toString()),a=(f=s.precision)+3;;)if(i=t,t=i.plus(er(l,i,a+2,1)).times(.5),br(i.d).slice(0,a)===(n=br(t.d)).slice(0,a))if(n=n.slice(a-3,a+1),n=="9999"||!r&&n=="4999"){if(!r&&(Ee(i,f+1,0),i.times(i).eq(l))){t=i;break}a+=4,r=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(Ee(t,f+1,1),e=!t.times(t).eq(l));break}return $e=!0,Ee(t,f,s.rounding,e)},ce.tangent=ce.tan=function(){var e,n,a=this,t=a.constructor;return a.isFinite()?a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+10,t.rounding=1,a=a.sin(),a.s=1,a=er(a,new t(1).minus(a.times(a)).sqrt(),e+10,0),t.precision=e,t.rounding=n,Ee(yt==2||yt==4?a.neg():a,e,n,!0)):new t(NaN)},ce.times=ce.mul=function(e){var n,a,t,r,i,l,m,f,c,s=this,o=s.constructor,u=s.d,p=(e=new o(e)).d;if(e.s*=s.s,!u||!u[0]||!p||!p[0])return new o(!e.s||u&&!u[0]&&!p||p&&!p[0]&&!u?NaN:!u||!p?e.s/0:e.s*0);for(a=Nr(s.e/De)+Nr(e.e/De),f=u.length,c=p.length,f<c&&(i=u,u=p,p=i,l=f,f=c,c=l),i=[],l=f+c,t=l;t--;)i.push(0);for(t=c;--t>=0;){for(n=0,r=f+t;r>t;)m=i[r]+p[t]*u[r-t-1]+n,i[r--]=m%jr|0,n=m/jr|0;i[r]=(i[r]+n)%jr|0}for(;!i[--l];)i.pop();return n?++a:i.shift(),e.d=i,e.e=va(i,a),$e?Ee(e,o.precision,o.rounding):e},ce.toBinary=function(e,n){return pi(this,2,e,n)},ce.toDecimalPlaces=ce.toDP=function(e,n){var a=this,t=a.constructor;return a=new t(a),e===void 0?a:(Ir(e,0,Tt),n===void 0?n=t.rounding:Ir(n,0,8),Ee(a,e+a.e+1,n))},ce.toExponential=function(e,n){var a,t=this,r=t.constructor;return e===void 0?a=it(t,!0):(Ir(e,0,Tt),n===void 0?n=r.rounding:Ir(n,0,8),t=Ee(new r(t),e+1,n),a=it(t,!0,e+1)),t.isNeg()&&!t.isZero()?"-"+a:a},ce.toFixed=function(e,n){var a,t,r=this,i=r.constructor;return e===void 0?a=it(r):(Ir(e,0,Tt),n===void 0?n=i.rounding:Ir(n,0,8),t=Ee(new i(r),e+r.e+1,n),a=it(t,!1,e+t.e+1)),r.isNeg()&&!r.isZero()?"-"+a:a},ce.toFraction=function(e){var n,a,t,r,i,l,m,f,c,s,o,u,p=this,v=p.d,h=p.constructor;if(!v)return new h(p);if(c=a=new h(1),t=f=new h(0),n=new h(t),i=n.e=Bo(v)-p.e-1,l=i%De,n.d[0]=hr(10,l<0?De+l:l),e==null)e=i>0?n:c;else{if(m=new h(e),!m.isInt()||m.lt(c))throw Error(Bt+m);e=m.gt(n)?i>0?n:c:m}for($e=!1,m=new h(br(v)),s=h.precision,h.precision=i=v.length*De*2;o=er(m,n,0,1,1),r=a.plus(o.times(t)),r.cmp(e)!=1;)a=t,t=r,r=c,c=f.plus(o.times(r)),f=r,r=n,n=m.minus(o.times(r)),m=r;return r=er(e.minus(a),t,0,1,1),f=f.plus(r.times(c)),a=a.plus(r.times(t)),f.s=c.s=p.s,u=er(c,t,i,1).minus(p).abs().cmp(er(f,a,i,1).minus(p).abs())<1?[c,t]:[f,a],h.precision=s,$e=!0,u},ce.toHexadecimal=ce.toHex=function(e,n){return pi(this,16,e,n)},ce.toNearest=function(e,n){var a=this,t=a.constructor;if(a=new t(a),e==null){if(!a.d)return a;e=new t(1),n=t.rounding}else{if(e=new t(e),n===void 0?n=t.rounding:Ir(n,0,8),!a.d)return e.s?a:e;if(!e.d)return e.s&&(e.s=a.s),e}return e.d[0]?($e=!1,a=er(a,e,0,n,1).times(e),$e=!0,Ee(a)):(e.s=a.s,a=e),a},ce.toNumber=function(){return+this},ce.toOctal=function(e,n){return pi(this,8,e,n)},ce.toPower=ce.pow=function(e){var n,a,t,r,i,l,m=this,f=m.constructor,c=+(e=new f(e));if(!m.d||!e.d||!m.d[0]||!e.d[0])return new f(hr(+m,c));if(m=new f(m),m.eq(1))return m;if(t=f.precision,i=f.rounding,e.eq(1))return Ee(m,t,i);if(n=Nr(e.e/De),n>=e.d.length-1&&(a=c<0?-c:c)<=Ov)return r=_o(f,m,a,t),e.s<0?new f(1).div(r):Ee(r,t,i);if(l=m.s,l<0){if(n<e.d.length-1)return new f(NaN);if((e.d[n]&1)==0&&(l=1),m.e==0&&m.d[0]==1&&m.d.length==1)return m.s=l,m}return a=hr(+m,c),n=a==0||!isFinite(a)?Nr(c*(Math.log("0."+br(m.d))/Math.LN10+m.e+1)):new f(a+"").e,n>f.maxE+1||n<f.minE-1?new f(n>0?l/0:0):($e=!1,f.rounding=m.s=1,a=Math.min(12,(n+"").length),r=mi(e.times($t(m,t+a)),t),r.d&&(r=Ee(r,t+5,1),_n(r.d,t,i)&&(n=t+10,r=Ee(mi(e.times($t(m,n+a)),n),n+5,1),+br(r.d).slice(t+1,t+15)+1==1e14&&(r=Ee(r,t+1,0)))),r.s=l,$e=!0,f.rounding=i,Ee(r,t,i))},ce.toPrecision=function(e,n){var a,t=this,r=t.constructor;return e===void 0?a=it(t,t.e<=r.toExpNeg||t.e>=r.toExpPos):(Ir(e,1,Tt),n===void 0?n=r.rounding:Ir(n,0,8),t=Ee(new r(t),e,n),a=it(t,e<=t.e||t.e<=r.toExpNeg,e)),t.isNeg()&&!t.isZero()?"-"+a:a},ce.toSignificantDigits=ce.toSD=function(e,n){var a=this,t=a.constructor;return e===void 0?(e=t.precision,n=t.rounding):(Ir(e,1,Tt),n===void 0?n=t.rounding:Ir(n,0,8)),Ee(new t(a),e,n)},ce.toString=function(){var e=this,n=e.constructor,a=it(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()&&!e.isZero()?"-"+a:a},ce.truncated=ce.trunc=function(){return Ee(new this.constructor(this),this.e+1,1)},ce.valueOf=ce.toJSON=function(){var e=this,n=e.constructor,a=it(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()?"-"+a:a};function br(e){var n,a,t,r=e.length-1,i="",l=e[0];if(r>0){for(i+=l,n=1;n<r;n++)t=e[n]+"",a=De-t.length,a&&(i+=_t(a)),i+=t;l=e[n],t=l+"",a=De-t.length,a&&(i+=_t(a))}else if(l===0)return"0";for(;l%10===0;)l/=10;return i+l}function Ir(e,n,a){if(e!==~~e||e<n||e>a)throw Error(Bt+e)}function _n(e,n,a,t){var r,i,l,m;for(i=e[0];i>=10;i/=10)--n;return--n<0?(n+=De,r=0):(r=Math.ceil((n+1)/De),n%=De),i=hr(10,De-n),m=e[r]%i|0,t==null?n<3?(n==0?m=m/100|0:n==1&&(m=m/10|0),l=a<4&&m==99999||a>3&&m==49999||m==5e4||m==0):l=(a<4&&m+1==i||a>3&&m+1==i/2)&&(e[r+1]/i/100|0)==hr(10,n-2)-1||(m==i/2||m==0)&&(e[r+1]/i/100|0)==0:n<4?(n==0?m=m/1e3|0:n==1?m=m/100|0:n==2&&(m=m/10|0),l=(t||a<4)&&m==9999||!t&&a>3&&m==4999):l=((t||a<4)&&m+1==i||!t&&a>3&&m+1==i/2)&&(e[r+1]/i/1e3|0)==hr(10,n-3)-1,l}function pa(e,n,a){for(var t,r=[0],i,l=0,m=e.length;l<m;){for(i=r.length;i--;)r[i]*=n;for(r[0]+=ci.indexOf(e.charAt(l++)),t=0;t<r.length;t++)r[t]>a-1&&(r[t+1]===void 0&&(r[t+1]=0),r[t+1]+=r[t]/a|0,r[t]%=a)}return r.reverse()}function Tv(e,n){var a,t,r;if(n.isZero())return n;t=n.d.length,t<32?(a=Math.ceil(t/3),r=(1/ga(4,a)).toString()):(a=16,r="2.3283064365386962890625e-10"),e.precision+=a,n=fn(e,1,n.times(r),new e(1));for(var i=a;i--;){var l=n.times(n);n=l.times(l).minus(l).times(8).plus(1)}return e.precision-=a,n}var er=function(){function e(t,r,i){var l,m=0,f=t.length;for(t=t.slice();f--;)l=t[f]*r+m,t[f]=l%i|0,m=l/i|0;return m&&t.unshift(m),t}function n(t,r,i,l){var m,f;if(i!=l)f=i>l?1:-1;else for(m=f=0;m<i;m++)if(t[m]!=r[m]){f=t[m]>r[m]?1:-1;break}return f}function a(t,r,i,l){for(var m=0;i--;)t[i]-=m,m=t[i]<r[i]?1:0,t[i]=m*l+t[i]-r[i];for(;!t[0]&&t.length>1;)t.shift()}return function(t,r,i,l,m,f){var c,s,o,u,p,v,h,b,w,N,g,y,x,d,A,S,O,M,_,E,$=t.constructor,z=t.s==r.s?1:-1,I=t.d,T=r.d;if(!I||!I[0]||!T||!T[0])return new $(!t.s||!r.s||(I?T&&I[0]==T[0]:!T)?NaN:I&&I[0]==0||!T?z*0:z/0);for(f?(p=1,s=t.e-r.e):(f=jr,p=De,s=Nr(t.e/p)-Nr(r.e/p)),_=T.length,O=I.length,w=new $(z),N=w.d=[],o=0;T[o]==(I[o]||0);o++);if(T[o]>(I[o]||0)&&s--,i==null?(d=i=$.precision,l=$.rounding):m?d=i+(t.e-r.e)+1:d=i,d<0)N.push(1),v=!0;else{if(d=d/p+2|0,o=0,_==1){for(u=0,T=T[0],d++;(o<O||u)&&d--;o++)A=u*f+(I[o]||0),N[o]=A/T|0,u=A%T|0;v=u||o<O}else{for(u=f/(T[0]+1)|0,u>1&&(T=e(T,u,f),I=e(I,u,f),_=T.length,O=I.length),S=_,g=I.slice(0,_),y=g.length;y<_;)g[y++]=0;E=T.slice(),E.unshift(0),M=T[0],T[1]>=f/2&&++M;do u=0,c=n(T,g,_,y),c<0?(x=g[0],_!=y&&(x=x*f+(g[1]||0)),u=x/M|0,u>1?(u>=f&&(u=f-1),h=e(T,u,f),b=h.length,y=g.length,c=n(h,g,b,y),c==1&&(u--,a(h,_<b?E:T,b,f))):(u==0&&(c=u=1),h=T.slice()),b=h.length,b<y&&h.unshift(0),a(g,h,y,f),c==-1&&(y=g.length,c=n(T,g,_,y),c<1&&(u++,a(g,_<y?E:T,y,f))),y=g.length):c===0&&(u++,g=[0]),N[o++]=u,c&&g[0]?g[y++]=I[S]||0:(g=[I[S]],y=1);while((S++<O||g[0]!==void 0)&&d--);v=g[0]!==void 0}N[0]||N.shift()}if(p==1)w.e=s,Eo=v;else{for(o=1,u=N[0];u>=10;u/=10)o++;w.e=o+s*p-1,Ee(w,m?i+w.e+1:i,l,v)}return w}}();function Ee(e,n,a,t){var r,i,l,m,f,c,s,o,u,p=e.constructor;e:if(n!=null){if(o=e.d,!o)return e;for(r=1,m=o[0];m>=10;m/=10)r++;if(i=n-r,i<0)i+=De,l=n,s=o[u=0],f=s/hr(10,r-l-1)%10|0;else if(u=Math.ceil((i+1)/De),m=o.length,u>=m)if(t){for(;m++<=u;)o.push(0);s=f=0,r=1,i%=De,l=i-De+1}else break e;else{for(s=m=o[u],r=1;m>=10;m/=10)r++;i%=De,l=i-De+r,f=l<0?0:s/hr(10,r-l-1)%10|0}if(t=t||n<0||o[u+1]!==void 0||(l<0?s:s%hr(10,r-l-1)),c=a<4?(f||t)&&(a==0||a==(e.s<0?3:2)):f>5||f==5&&(a==4||t||a==6&&(i>0?l>0?s/hr(10,r-l):0:o[u-1])%10&1||a==(e.s<0?8:7)),n<1||!o[0])return o.length=0,c?(n-=e.e+1,o[0]=hr(10,(De-n%De)%De),e.e=-n||0):o[0]=e.e=0,e;if(i==0?(o.length=u,m=1,u--):(o.length=u+1,m=hr(10,De-i),o[u]=l>0?(s/hr(10,r-l)%hr(10,l)|0)*m:0),c)for(;;)if(u==0){for(i=1,l=o[0];l>=10;l/=10)i++;for(l=o[0]+=m,m=1;l>=10;l/=10)m++;i!=m&&(e.e++,o[0]==jr&&(o[0]=1));break}else{if(o[u]+=m,o[u]!=jr)break;o[u--]=0,m=1}for(i=o.length;o[--i]===0;)o.pop()}return $e&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function it(e,n,a){if(!e.isFinite())return qo(e);var t,r=e.e,i=br(e.d),l=i.length;return n?(a&&(t=a-l)>0?i=i.charAt(0)+"."+i.slice(1)+_t(t):l>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(e.e<0?"e":"e+")+e.e):r<0?(i="0."+_t(-r-1)+i,a&&(t=a-l)>0&&(i+=_t(t))):r>=l?(i+=_t(r+1-l),a&&(t=a-r-1)>0&&(i=i+"."+_t(t))):((t=r+1)<l&&(i=i.slice(0,t)+"."+i.slice(t)),a&&(t=a-l)>0&&(r+1===l&&(i+="."),i+=_t(t))),i}function va(e,n){var a=e[0];for(n*=De;a>=10;a/=10)n++;return n}function ha(e,n,a){if(n>Dv)throw $e=!0,a&&(e.precision=a),Error(Co);return Ee(new e(fa),n,1,!0)}function ot(e,n,a){if(n>li)throw Error(Co);return Ee(new e(la),n,a,!0)}function Bo(e){var n=e.length-1,a=n*De+1;if(n=e[n],n){for(;n%10==0;n/=10)a--;for(n=e[0];n>=10;n/=10)a++}return a}function _t(e){for(var n="";e--;)n+="0";return n}function _o(e,n,a,t){var r,i=new e(1),l=Math.ceil(t/De+4);for($e=!1;;){if(a%2&&(i=i.times(n),Fo(i.d,l)&&(r=!0)),a=Nr(a/2),a===0){a=i.d.length-1,r&&i.d[a]===0&&++i.d[a];break}n=n.times(n),Fo(n.d,l)}return $e=!0,i}function $o(e){return e.d[e.d.length-1]&1}function Io(e,n,a){for(var t,r,i=new e(n[0]),l=0;++l<n.length;){if(r=new e(n[l]),!r.s){i=r;break}t=i.cmp(r),(t===a||t===0&&i.s===a)&&(i=r)}return i}function mi(e,n){var a,t,r,i,l,m,f,c=0,s=0,o=0,u=e.constructor,p=u.rounding,v=u.precision;if(!e.d||!e.d[0]||e.e>17)return new u(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(n==null?($e=!1,f=v):f=n,m=new u(.03125);e.e>-2;)e=e.times(m),o+=5;for(t=Math.log(hr(2,o))/Math.LN10*2+5|0,f+=t,a=i=l=new u(1),u.precision=f;;){if(i=Ee(i.times(e),f,1),a=a.times(++s),m=l.plus(er(i,a,f,1)),br(m.d).slice(0,f)===br(l.d).slice(0,f)){for(r=o;r--;)l=Ee(l.times(l),f,1);if(n==null)if(c<3&&_n(l.d,f-t,p,c))u.precision=f+=10,a=i=m=new u(1),s=0,c++;else return Ee(l,u.precision=v,p,$e=!0);else return u.precision=v,l}l=m}}function $t(e,n){var a,t,r,i,l,m,f,c,s,o,u,p=1,v=10,h=e,b=h.d,w=h.constructor,N=w.rounding,g=w.precision;if(h.s<0||!b||!b[0]||!h.e&&b[0]==1&&b.length==1)return new w(b&&!b[0]?-1/0:h.s!=1?NaN:b?0:h);if(n==null?($e=!1,s=g):s=n,w.precision=s+=v,a=br(b),t=a.charAt(0),Math.abs(i=h.e)<15e14){for(;t<7&&t!=1||t==1&&a.charAt(1)>3;)h=h.times(e),a=br(h.d),t=a.charAt(0),p++;i=h.e,t>1?(h=new w("0."+a),i++):h=new w(t+"."+a.slice(1))}else return c=ha(w,s+2,g).times(i+""),h=$t(new w(t+"."+a.slice(1)),s-v).plus(c),w.precision=g,n==null?Ee(h,g,N,$e=!0):h;for(o=h,f=l=h=er(h.minus(1),h.plus(1),s,1),u=Ee(h.times(h),s,1),r=3;;){if(l=Ee(l.times(u),s,1),c=f.plus(er(l,new w(r),s,1)),br(c.d).slice(0,s)===br(f.d).slice(0,s))if(f=f.times(2),i!==0&&(f=f.plus(ha(w,s+2,g).times(i+""))),f=er(f,new w(p),s,1),n==null)if(_n(f.d,s-v,N,m))w.precision=s+=v,c=l=h=er(o.minus(1),o.plus(1),s,1),u=Ee(h.times(h),s,1),r=m=1;else return Ee(f,w.precision=g,N,$e=!0);else return w.precision=g,f;f=c,r+=2}}function qo(e){return String(e.s*e.s/0)}function da(e,n){var a,t,r;for((a=n.indexOf("."))>-1&&(n=n.replace(".","")),(t=n.search(/e/i))>0?(a<0&&(a=t),a+=+n.slice(t+1),n=n.substring(0,t)):a<0&&(a=n.length),t=0;n.charCodeAt(t)===48;t++);for(r=n.length;n.charCodeAt(r-1)===48;--r);if(n=n.slice(t,r),n){if(r-=t,e.e=a=a-t-1,e.d=[],t=(a+1)%De,a<0&&(t+=De),t<r){for(t&&e.d.push(+n.slice(0,t)),r-=De;t<r;)e.d.push(+n.slice(t,t+=De));n=n.slice(t),t=De-n.length}else t-=r;for(;t--;)n+="0";e.d.push(+n),$e&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function Bv(e,n){var a,t,r,i,l,m,f,c,s;if(n.indexOf("_")>-1){if(n=n.replace(/(\d)_(?=\d)/g,"$1"),To.test(n))return da(e,n)}else if(n==="Infinity"||n==="NaN")return+n||(e.s=NaN),e.e=NaN,e.d=null,e;if(Ev.test(n))a=16,n=n.toLowerCase();else if(Sv.test(n))a=2;else if(Cv.test(n))a=8;else throw Error(Bt+n);for(i=n.search(/p/i),i>0?(f=+n.slice(i+1),n=n.substring(2,i)):n=n.slice(2),i=n.indexOf("."),l=i>=0,t=e.constructor,l&&(n=n.replace(".",""),m=n.length,i=m-i,r=_o(t,new t(a),i,i*2)),c=pa(n,a,jr),s=c.length-1,i=s;c[i]===0;--i)c.pop();return i<0?new t(e.s*0):(e.e=va(c,s),e.d=c,$e=!1,l&&(e=er(e,r,m*4)),f&&(e=e.times(Math.abs(f)<54?hr(2,f):It.pow(2,f))),$e=!0,e)}function _v(e,n){var a,t=n.d.length;if(t<3)return n.isZero()?n:fn(e,2,n,n);a=1.4*Math.sqrt(t),a=a>16?16:a|0,n=n.times(1/ga(5,a)),n=fn(e,2,n,n);for(var r,i=new e(5),l=new e(16),m=new e(20);a--;)r=n.times(n),n=n.times(i.plus(r.times(l.times(r).minus(m))));return n}function fn(e,n,a,t,r){var i,l,m,f,c=e.precision,s=Math.ceil(c/De);for($e=!1,f=a.times(a),m=new e(t);;){if(l=er(m.times(f),new e(n++*n++),c,1),m=r?t.plus(l):t.minus(l),t=er(l.times(f),new e(n++*n++),c,1),l=m.plus(t),l.d[s]!==void 0){for(i=s;l.d[i]===m.d[i]&&i--;);if(i==-1)break}i=m,m=t,t=l,l=i}return $e=!0,l.d.length=s+1,l}function ga(e,n){for(var a=e;--n;)a*=e;return a}function Ro(e,n){var a,t=n.s<0,r=ot(e,e.precision,1),i=r.times(.5);if(n=n.abs(),n.lte(i))return yt=t?4:1,n;if(a=n.divToInt(r),a.isZero())yt=t?3:2;else{if(n=n.minus(a.times(r)),n.lte(i))return yt=$o(a)?t?2:3:t?4:1,n;yt=$o(a)?t?1:4:t?3:2}return n.minus(r).abs()}function pi(e,n,a,t){var r,i,l,m,f,c,s,o,u,p=e.constructor,v=a!==void 0;if(v?(Ir(a,1,Tt),t===void 0?t=p.rounding:Ir(t,0,8)):(a=p.precision,t=p.rounding),!e.isFinite())s=qo(e);else{for(s=it(e),l=s.indexOf("."),v?(r=2,n==16?a=a*4-3:n==8&&(a=a*3-2)):r=n,l>=0&&(s=s.replace(".",""),u=new p(1),u.e=s.length-l,u.d=pa(it(u),10,r),u.e=u.d.length),o=pa(s,10,r),i=f=o.length;o[--f]==0;)o.pop();if(!o[0])s=v?"0p+0":"0";else{if(l<0?i--:(e=new p(e),e.d=o,e.e=i,e=er(e,u,a,t,0,r),o=e.d,i=e.e,c=Eo),l=o[a],m=r/2,c=c||o[a+1]!==void 0,c=t<4?(l!==void 0||c)&&(t===0||t===(e.s<0?3:2)):l>m||l===m&&(t===4||c||t===6&&o[a-1]&1||t===(e.s<0?8:7)),o.length=a,c)for(;++o[--a]>r-1;)o[a]=0,a||(++i,o.unshift(1));for(f=o.length;!o[f-1];--f);for(l=0,s="";l<f;l++)s+=ci.charAt(o[l]);if(v){if(f>1)if(n==16||n==8){for(l=n==16?4:3,--f;f%l;f++)s+="0";for(o=pa(s,r,n),f=o.length;!o[f-1];--f);for(l=1,s="1.";l<f;l++)s+=ci.charAt(o[l])}else s=s.charAt(0)+"."+s.slice(1);s=s+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)s="0"+s;s="0."+s}else if(++i>f)for(i-=f;i--;)s+="0";else i<f&&(s=s.slice(0,i)+"."+s.slice(i))}s=(n==16?"0x":n==2?"0b":n==8?"0o":"")+s}return e.s<0?"-"+s:s}function Fo(e,n){if(e.length>n)return e.length=n,!0}function $v(e){return new this(e).abs()}function Iv(e){return new this(e).acos()}function qv(e){return new this(e).acosh()}function Rv(e,n){return new this(e).plus(n)}function Fv(e){return new this(e).asin()}function zv(e){return new this(e).asinh()}function Pv(e){return new this(e).atan()}function Uv(e){return new this(e).atanh()}function Lv(e,n){e=new this(e),n=new this(n);var a,t=this.precision,r=this.rounding,i=t+4;return!e.s||!n.s?a=new this(NaN):!e.d&&!n.d?(a=ot(this,i,1).times(n.s>0?.25:.75),a.s=e.s):!n.d||e.isZero()?(a=n.s<0?ot(this,t,r):new this(0),a.s=e.s):!e.d||n.isZero()?(a=ot(this,i,1).times(.5),a.s=e.s):n.s<0?(this.precision=i,this.rounding=1,a=this.atan(er(e,n,i,1)),n=ot(this,i,1),this.precision=t,this.rounding=r,a=e.s<0?a.minus(n):a.plus(n)):a=this.atan(er(e,n,i,1)),a}function kv(e){return new this(e).cbrt()}function Hv(e){return Ee(e=new this(e),e.e+1,2)}function Gv(e,n,a){return new this(e).clamp(n,a)}function Vv(e){if(!e||typeof e!="object")throw Error(ma+"Object expected");var n,a,t,r=e.defaults===!0,i=["precision",1,Tt,"rounding",0,8,"toExpNeg",-cn,0,"toExpPos",0,cn,"maxE",0,cn,"minE",-cn,0,"modulo",0,9];for(n=0;n<i.length;n+=3)if(a=i[n],r&&(this[a]=fi[a]),(t=e[a])!==void 0)if(Nr(t)===t&&t>=i[n+1]&&t<=i[n+2])this[a]=t;else throw Error(Bt+a+": "+t);if(a="crypto",r&&(this[a]=fi[a]),(t=e[a])!==void 0)if(t===!0||t===!1||t===0||t===1)if(t)if(typeof crypto!="undefined"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[a]=!0;else throw Error(Oo);else this[a]=!1;else throw Error(Bt+a+": "+t);return this}function Zv(e){return new this(e).cos()}function Xv(e){return new this(e).cosh()}function zo(e){var n,a,t;function r(i){var l,m,f,c=this;if(!(c instanceof r))return new r(i);if(c.constructor=r,Po(i)){c.s=i.s,$e?!i.d||i.e>r.maxE?(c.e=NaN,c.d=null):i.e<r.minE?(c.e=0,c.d=[0]):(c.e=i.e,c.d=i.d.slice()):(c.e=i.e,c.d=i.d?i.d.slice():i.d);return}if(f=typeof i,f==="number"){if(i===0){c.s=1/i<0?-1:1,c.e=0,c.d=[0];return}if(i<0?(i=-i,c.s=-1):c.s=1,i===~~i&&i<1e7){for(l=0,m=i;m>=10;m/=10)l++;$e?l>r.maxE?(c.e=NaN,c.d=null):l<r.minE?(c.e=0,c.d=[0]):(c.e=l,c.d=[i]):(c.e=l,c.d=[i]);return}if(i*0!==0){i||(c.s=NaN),c.e=NaN,c.d=null;return}return da(c,i.toString())}if(f==="string")return(m=i.charCodeAt(0))===45?(i=i.slice(1),c.s=-1):(m===43&&(i=i.slice(1)),c.s=1),To.test(i)?da(c,i):Bv(c,i);if(f==="bigint")return i<0?(i=-i,c.s=-1):c.s=1,da(c,i.toString());throw Error(Bt+i)}if(r.prototype=ce,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=Vv,r.clone=zo,r.isDecimal=Po,r.abs=$v,r.acos=Iv,r.acosh=qv,r.add=Rv,r.asin=Fv,r.asinh=zv,r.atan=Pv,r.atanh=Uv,r.atan2=Lv,r.cbrt=kv,r.ceil=Hv,r.clamp=Gv,r.cos=Zv,r.cosh=Xv,r.div=Yv,r.exp=Wv,r.floor=Jv,r.hypot=Qv,r.ln=Kv,r.log=jv,r.log10=rh,r.log2=eh,r.max=th,r.min=nh,r.mod=ah,r.mul=ih,r.pow=oh,r.random=sh,r.round=uh,r.sign=ch,r.sin=fh,r.sinh=lh,r.sqrt=mh,r.sub=ph,r.sum=vh,r.tan=hh,r.tanh=dh,r.trunc=gh,e===void 0&&(e={}),e&&e.defaults!==!0)for(t=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],n=0;n<t.length;)e.hasOwnProperty(a=t[n++])||(e[a]=this[a]);return r.config(e),r}function Yv(e,n){return new this(e).div(n)}function Wv(e){return new this(e).exp()}function Jv(e){return Ee(e=new this(e),e.e+1,3)}function Qv(){var e,n,a=new this(0);for($e=!1,e=0;e<arguments.length;)if(n=new this(arguments[e++]),n.d)a.d&&(a=a.plus(n.times(n)));else{if(n.s)return $e=!0,new this(1/0);a=n}return $e=!0,a.sqrt()}function Po(e){return e instanceof It||e&&e.toStringTag===Do||!1}function Kv(e){return new this(e).ln()}function jv(e,n){return new this(e).log(n)}function eh(e){return new this(e).log(2)}function rh(e){return new this(e).log(10)}function th(){return Io(this,arguments,-1)}function nh(){return Io(this,arguments,1)}function ah(e,n){return new this(e).mod(n)}function ih(e,n){return new this(e).mul(n)}function oh(e,n){return new this(e).pow(n)}function sh(e){var n,a,t,r,i=0,l=new this(1),m=[];if(e===void 0?e=this.precision:Ir(e,1,Tt),t=Math.ceil(e/De),this.crypto)if(crypto.getRandomValues)for(n=crypto.getRandomValues(new Uint32Array(t));i<t;)r=n[i],r>=429e7?n[i]=crypto.getRandomValues(new Uint32Array(1))[0]:m[i++]=r%1e7;else if(crypto.randomBytes){for(n=crypto.randomBytes(t*=4);i<t;)r=n[i]+(n[i+1]<<8)+(n[i+2]<<16)+((n[i+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(n,i):(m.push(r%1e7),i+=4);i=t/4}else throw Error(Oo);else for(;i<t;)m[i++]=Math.random()*1e7|0;for(t=m[--i],e%=De,t&&e&&(r=hr(10,De-e),m[i]=(t/r|0)*r);m[i]===0;i--)m.pop();if(i<0)a=0,m=[0];else{for(a=-1;m[0]===0;a-=De)m.shift();for(t=1,r=m[0];r>=10;r/=10)t++;t<De&&(a-=De-t)}return l.e=a,l.d=m,l}function uh(e){return Ee(e=new this(e),e.e+1,this.rounding)}function ch(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function fh(e){return new this(e).sin()}function lh(e){return new this(e).sinh()}function mh(e){return new this(e).sqrt()}function ph(e,n){return new this(e).sub(n)}function vh(){var e=0,n=arguments,a=new this(n[e]);for($e=!1;a.s&&++e<n.length;)a=a.plus(n[e]);return $e=!0,Ee(a,this.precision,this.rounding)}function hh(e){return new this(e).tan()}function dh(e){return new this(e).tanh()}function gh(e){return Ee(e=new this(e),e.e+1,1)}ce[Symbol.for("nodejs.util.inspect.custom")]=ce.toString,ce[Symbol.toStringTag]="Decimal";var It=ce.constructor=zo(fi);fa=new It(fa),la=new It(la);var yh="BigNumber",xh=["?on","config"],bh=R(yh,xh,e=>{var{on:n,config:a}=e,t=It.clone({precision:a.precision,modulo:It.EUCLID});return t.prototype=Object.create(t.prototype),t.prototype.type="BigNumber",t.prototype.isBigNumber=!0,t.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},t.fromJSON=function(r){return new t(r.value)},n&&n("config",function(r,i){r.precision!==i.precision&&t.config({precision:r.precision})}),t},{isClass:!0}),vi={exports:{}};var Uo;function wh(){return Uo||(Uo=1,function(e,n){(function(a){var t=Math.cosh||function(o){return Math.abs(o)<1e-9?1-o:(Math.exp(o)+Math.exp(-o))*.5},r=Math.sinh||function(o){return Math.abs(o)<1e-9?o:(Math.exp(o)-Math.exp(-o))*.5},i=function(o){var u=Math.PI/4;if(-u>o||o>u)return Math.cos(o)-1;var p=o*o;return p*(p*(p*(p*(p*(p*(p*(p/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},l=function(o,u){var p=Math.abs(o),v=Math.abs(u);return p<3e3&&v<3e3?Math.sqrt(p*p+v*v):(p<v?(p=v,v=o/u):v=u/o,p*Math.sqrt(1+v*v))},m=function(){throw SyntaxError("Invalid Param")};function f(o,u){var p=Math.abs(o),v=Math.abs(u);return o===0?Math.log(v):u===0?Math.log(p):p<3e3&&v<3e3?Math.log(o*o+u*u)*.5:(o=o/2,u=u/2,.5*Math.log(o*o+u*u)+Math.LN2)}var c=function(o,u){var p={re:0,im:0};if(o==null)p.re=p.im=0;else if(u!==void 0)p.re=o,p.im=u;else switch(typeof o){case"object":if("im"in o&&"re"in o)p.re=o.re,p.im=o.im;else if("abs"in o&&"arg"in o){if(!Number.isFinite(o.abs)&&Number.isFinite(o.arg))return s.INFINITY;p.re=o.abs*Math.cos(o.arg),p.im=o.abs*Math.sin(o.arg)}else if("r"in o&&"phi"in o){if(!Number.isFinite(o.r)&&Number.isFinite(o.phi))return s.INFINITY;p.re=o.r*Math.cos(o.phi),p.im=o.r*Math.sin(o.phi)}else o.length===2?(p.re=o[0],p.im=o[1]):m();break;case"string":p.im=p.re=0;var v=o.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),h=1,b=0;v===null&&m();for(var w=0;w<v.length;w++){var N=v[w];N===" "||N===" "||N===`
9
- `||(N==="+"?h++:N==="-"?b++:N==="i"||N==="I"?(h+b===0&&m(),v[w+1]!==" "&&!isNaN(v[w+1])?(p.im+=parseFloat((b%2?"-":"")+v[w+1]),w++):p.im+=parseFloat((b%2?"-":"")+"1"),h=b=0):((h+b===0||isNaN(N))&&m(),v[w+1]==="i"||v[w+1]==="I"?(p.im+=parseFloat((b%2?"-":"")+N),w++):p.re+=parseFloat((b%2?"-":"")+N),h=b=0))}h+b>0&&m();break;case"number":p.im=0,p.re=o;break;default:m()}return isNaN(p.re)||isNaN(p.im),p};function s(o,u){if(!(this instanceof s))return new s(o,u);var p=c(o,u);this.re=p.re,this.im=p.im}s.prototype={re:0,im:0,sign:function(){var o=this.abs();return new s(this.re/o,this.im/o)},add:function(o,u){var p=new s(o,u);return this.isInfinite()&&p.isInfinite()?s.NAN:this.isInfinite()||p.isInfinite()?s.INFINITY:new s(this.re+p.re,this.im+p.im)},sub:function(o,u){var p=new s(o,u);return this.isInfinite()&&p.isInfinite()?s.NAN:this.isInfinite()||p.isInfinite()?s.INFINITY:new s(this.re-p.re,this.im-p.im)},mul:function(o,u){var p=new s(o,u);return this.isInfinite()&&p.isZero()||this.isZero()&&p.isInfinite()?s.NAN:this.isInfinite()||p.isInfinite()?s.INFINITY:p.im===0&&this.im===0?new s(this.re*p.re,0):new s(this.re*p.re-this.im*p.im,this.re*p.im+this.im*p.re)},div:function(o,u){var p=new s(o,u);if(this.isZero()&&p.isZero()||this.isInfinite()&&p.isInfinite())return s.NAN;if(this.isInfinite()||p.isZero())return s.INFINITY;if(this.isZero()||p.isInfinite())return s.ZERO;o=this.re,u=this.im;var v=p.re,h=p.im,b,w;return h===0?new s(o/v,u/v):Math.abs(v)<Math.abs(h)?(w=v/h,b=v*w+h,new s((o*w+u)/b,(u*w-o)/b)):(w=h/v,b=h*w+v,new s((o+u*w)/b,(u-o*w)/b))},pow:function(o,u){var p=new s(o,u);if(o=this.re,u=this.im,p.isZero())return s.ONE;if(p.im===0){if(u===0&&o>0)return new s(Math.pow(o,p.re),0);if(o===0)switch((p.re%4+4)%4){case 0:return new s(Math.pow(u,p.re),0);case 1:return new s(0,Math.pow(u,p.re));case 2:return new s(-Math.pow(u,p.re),0);case 3:return new s(0,-Math.pow(u,p.re))}}if(o===0&&u===0&&p.re>0&&p.im>=0)return s.ZERO;var v=Math.atan2(u,o),h=f(o,u);return o=Math.exp(p.re*h-p.im*v),u=p.im*h+p.re*v,new s(o*Math.cos(u),o*Math.sin(u))},sqrt:function(){var o=this.re,u=this.im,p=this.abs(),v,h;if(o>=0){if(u===0)return new s(Math.sqrt(o),0);v=.5*Math.sqrt(2*(p+o))}else v=Math.abs(u)/Math.sqrt(2*(p-o));return o<=0?h=.5*Math.sqrt(2*(p-o)):h=Math.abs(u)/Math.sqrt(2*(p+o)),new s(v,u<0?-h:h)},exp:function(){var o=Math.exp(this.re);return this.im,new s(o*Math.cos(this.im),o*Math.sin(this.im))},expm1:function(){var o=this.re,u=this.im;return new s(Math.expm1(o)*Math.cos(u)+i(u),Math.exp(o)*Math.sin(u))},log:function(){var o=this.re,u=this.im;return new s(f(o,u),Math.atan2(u,o))},abs:function(){return l(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var o=this.re,u=this.im;return new s(Math.sin(o)*t(u),Math.cos(o)*r(u))},cos:function(){var o=this.re,u=this.im;return new s(Math.cos(o)*t(u),-Math.sin(o)*r(u))},tan:function(){var o=2*this.re,u=2*this.im,p=Math.cos(o)+t(u);return new s(Math.sin(o)/p,r(u)/p)},cot:function(){var o=2*this.re,u=2*this.im,p=Math.cos(o)-t(u);return new s(-Math.sin(o)/p,r(u)/p)},sec:function(){var o=this.re,u=this.im,p=.5*t(2*u)+.5*Math.cos(2*o);return new s(Math.cos(o)*t(u)/p,Math.sin(o)*r(u)/p)},csc:function(){var o=this.re,u=this.im,p=.5*t(2*u)-.5*Math.cos(2*o);return new s(Math.sin(o)*t(u)/p,-Math.cos(o)*r(u)/p)},asin:function(){var o=this.re,u=this.im,p=new s(u*u-o*o+1,-2*o*u).sqrt(),v=new s(p.re-u,p.im+o).log();return new s(v.im,-v.re)},acos:function(){var o=this.re,u=this.im,p=new s(u*u-o*o+1,-2*o*u).sqrt(),v=new s(p.re-u,p.im+o).log();return new s(Math.PI/2-v.im,v.re)},atan:function(){var o=this.re,u=this.im;if(o===0){if(u===1)return new s(0,1/0);if(u===-1)return new s(0,-1/0)}var p=o*o+(1-u)*(1-u),v=new s((1-u*u-o*o)/p,-2*o/p).log();return new s(-.5*v.im,.5*v.re)},acot:function(){var o=this.re,u=this.im;if(u===0)return new s(Math.atan2(1,o),0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).atan():new s(o!==0?o/0:0,u!==0?-u/0:0).atan()},asec:function(){var o=this.re,u=this.im;if(o===0&&u===0)return new s(0,1/0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).acos():new s(o!==0?o/0:0,u!==0?-u/0:0).acos()},acsc:function(){var o=this.re,u=this.im;if(o===0&&u===0)return new s(Math.PI/2,1/0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).asin():new s(o!==0?o/0:0,u!==0?-u/0:0).asin()},sinh:function(){var o=this.re,u=this.im;return new s(r(o)*Math.cos(u),t(o)*Math.sin(u))},cosh:function(){var o=this.re,u=this.im;return new s(t(o)*Math.cos(u),r(o)*Math.sin(u))},tanh:function(){var o=2*this.re,u=2*this.im,p=t(o)+Math.cos(u);return new s(r(o)/p,Math.sin(u)/p)},coth:function(){var o=2*this.re,u=2*this.im,p=t(o)-Math.cos(u);return new s(r(o)/p,-Math.sin(u)/p)},csch:function(){var o=this.re,u=this.im,p=Math.cos(2*u)-t(2*o);return new s(-2*r(o)*Math.cos(u)/p,2*t(o)*Math.sin(u)/p)},sech:function(){var o=this.re,u=this.im,p=Math.cos(2*u)+t(2*o);return new s(2*t(o)*Math.cos(u)/p,-2*r(o)*Math.sin(u)/p)},asinh:function(){var o=this.im;this.im=-this.re,this.re=o;var u=this.asin();return this.re=-this.im,this.im=o,o=u.re,u.re=-u.im,u.im=o,u},acosh:function(){var o=this.acos();if(o.im<=0){var u=o.re;o.re=-o.im,o.im=u}else{var u=o.im;o.im=-o.re,o.re=u}return o},atanh:function(){var o=this.re,u=this.im,p=o>1&&u===0,v=1-o,h=1+o,b=v*v+u*u,w=b!==0?new s((h*v-u*u)/b,(u*v+h*u)/b):new s(o!==-1?o/0:0,u!==0?u/0:0),N=w.re;return w.re=f(w.re,w.im)/2,w.im=Math.atan2(w.im,N)/2,p&&(w.im=-w.im),w},acoth:function(){var o=this.re,u=this.im;if(o===0&&u===0)return new s(0,Math.PI/2);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).atanh():new s(o!==0?o/0:0,u!==0?-u/0:0).atanh()},acsch:function(){var o=this.re,u=this.im;if(u===0)return new s(o!==0?Math.log(o+Math.sqrt(o*o+1)):1/0,0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).asinh():new s(o!==0?o/0:0,u!==0?-u/0:0).asinh()},asech:function(){var o=this.re,u=this.im;if(this.isZero())return s.INFINITY;var p=o*o+u*u;return p!==0?new s(o/p,-u/p).acosh():new s(o!==0?o/0:0,u!==0?-u/0:0).acosh()},inverse:function(){if(this.isZero())return s.INFINITY;if(this.isInfinite())return s.ZERO;var o=this.re,u=this.im,p=o*o+u*u;return new s(o/p,-u/p)},conjugate:function(){return new s(this.re,-this.im)},neg:function(){return new s(-this.re,-this.im)},ceil:function(o){return o=Math.pow(10,o||0),new s(Math.ceil(this.re*o)/o,Math.ceil(this.im*o)/o)},floor:function(o){return o=Math.pow(10,o||0),new s(Math.floor(this.re*o)/o,Math.floor(this.im*o)/o)},round:function(o){return o=Math.pow(10,o||0),new s(Math.round(this.re*o)/o,Math.round(this.im*o)/o)},equals:function(o,u){var p=new s(o,u);return Math.abs(p.re-this.re)<=s.EPSILON&&Math.abs(p.im-this.im)<=s.EPSILON},clone:function(){return new s(this.re,this.im)},toString:function(){var o=this.re,u=this.im,p="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(o)<s.EPSILON&&(o=0),Math.abs(u)<s.EPSILON&&(u=0),u===0?p+o:(o!==0?(p+=o,p+=" ",u<0?(u=-u,p+="-"):p+="+",p+=" "):u<0&&(u=-u,p+="-"),u!==1&&(p+=u),p+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return this.im===0?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return this.im===0&&this.re===0},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!(this.isNaN()||this.isFinite())}},s.ZERO=new s(0,0),s.ONE=new s(1,0),s.I=new s(0,1),s.PI=new s(Math.PI,0),s.E=new s(Math.E,0),s.INFINITY=new s(1/0,1/0),s.NAN=new s(NaN,NaN),s.EPSILON=1e-15,Object.defineProperty(s,"__esModule",{value:!0}),s.default=s,s.Complex=s,e.exports=s})()}(vi)),vi.exports}var Nh=wh();const qr=Tn(Nh);var Mh="Complex",Ah=[],Sh=R(Mh,Ah,()=>(qr.prototype.type="Complex",qr.prototype.isComplex=!0,qr.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},qr.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},qr.prototype.format=function(e){var n="",a=this.im,t=this.re,r=Ht(this.re,e),i=Ht(this.im,e),l=Be(e)?e:e?e.precision:null;if(l!==null){var m=Math.pow(10,-l);Math.abs(t/a)<m&&(t=0),Math.abs(a/t)<m&&(a=0)}return a===0?n=r:t===0?a===1?n="i":a===-1?n="-i":n=i+"i":a<0?a===-1?n=r+" - i":n=r+" - "+i.substring(1)+"i":a===1?n=r+" + i":n=r+" + "+i+"i",n},qr.fromPolar=function(e){switch(arguments.length){case 1:{var n=arguments[0];if(typeof n=="object")return qr(n);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var a=arguments[0],t=arguments[1];if(Be(a)){if(ht(t)&&t.hasBase("ANGLE")&&(t=t.toNumber("rad")),Be(t))return new qr({r:a,phi:t});throw new TypeError("Phi is not a number nor an angle unit.")}else throw new TypeError("Radius r is not a number.")}default:throw new SyntaxError("Wrong number of arguments in function fromPolar")}},qr.prototype.valueOf=qr.prototype.toString,qr.fromJSON=function(e){return new qr(e)},qr.compare=function(e,n){return e.re>n.re?1:e.re<n.re?-1:e.im>n.im?1:e.im<n.im?-1:0},qr),{isClass:!0});var Eh=2e3,Se={s:1,n:0,d:1};function xt(e,n){if(isNaN(e=parseInt(e,10)))throw ya();return e*n}function ur(e,n){if(n===0)throw hi();var a=Object.create(zr.prototype);a.s=e<0?-1:1,e=e<0?-e:e;var t=ln(e,n);return a.n=e/t,a.d=n/t,a}function Lo(e){for(var n={},a=e,t=2,r=4;r<=a;){for(;a%t===0;)a/=t,n[t]=(n[t]||0)+1;r+=1+2*t++}return a!==e?a>1&&(n[a]=(n[a]||0)+1):n[e]=(n[e]||0)+1,n}var Fr=function(e,n){var a=0,t=1,r=1,i=0,l=0,m=0,f=1,c=1,s=0,o=1,u=1,p=1,v=1e7,h;if(e!=null)if(n!==void 0){if(a=e,t=n,r=a*t,a%1!==0||t%1!==0)throw Th()}else switch(typeof e){case"object":{if("d"in e&&"n"in e)a=e.n,t=e.d,"s"in e&&(a*=e.s);else if(0 in e)a=e[0],1 in e&&(t=e[1]);else throw ya();r=a*t;break}case"number":{if(e<0&&(r=e,e=-e),e%1===0)a=e;else if(e>0){for(e>=1&&(c=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)),e/=c);o<=v&&p<=v;)if(h=(s+u)/(o+p),e===h){o+p<=v?(a=s+u,t=o+p):p>o?(a=u,t=p):(a=s,t=o);break}else e>h?(s+=u,o+=p):(u+=s,p+=o),o>v?(a=u,t=p):(a=s,t=o);a*=c}else(isNaN(e)||isNaN(n))&&(t=a=NaN);break}case"string":{if(o=e.match(/\d+|./g),o===null)throw ya();if(o[s]==="-"?(r=-1,s++):o[s]==="+"&&s++,o.length===s+1?l=xt(o[s++],r):o[s+1]==="."||o[s]==="."?(o[s]!=="."&&(i=xt(o[s++],r)),s++,(s+1===o.length||o[s+1]==="("&&o[s+3]===")"||o[s+1]==="'"&&o[s+3]==="'")&&(l=xt(o[s],r),f=Math.pow(10,o[s].length),s++),(o[s]==="("&&o[s+2]===")"||o[s]==="'"&&o[s+2]==="'")&&(m=xt(o[s+1],r),c=Math.pow(10,o[s+1].length)-1,s+=3)):o[s+1]==="/"||o[s+1]===":"?(l=xt(o[s],r),f=xt(o[s+2],1),s+=3):o[s+3]==="/"&&o[s+1]===" "&&(i=xt(o[s],r),l=xt(o[s+2],r),f=xt(o[s+4],1),s+=5),o.length<=s){t=f*c,r=a=m+t*i+c*l;break}}default:throw ya()}if(t===0)throw hi();Se.s=r<0?-1:1,Se.n=Math.abs(a),Se.d=Math.abs(t)};function Ch(e,n,a){for(var t=1;n>0;e=e*e%a,n>>=1)n&1&&(t=t*e%a);return t}function Oh(e,n){for(;n%2===0;n/=2);for(;n%5===0;n/=5);if(n===1)return 0;for(var a=10%n,t=1;a!==1;t++)if(a=a*10%n,t>Eh)return 0;return t}function Dh(e,n,a){for(var t=1,r=Ch(10,a,n),i=0;i<300;i++){if(t===r)return i;t=t*10%n,r=r*10%n}return 0}function ln(e,n){if(!e)return n;if(!n)return e;for(;;){if(e%=n,!e)return n;if(n%=e,!n)return e}}function zr(e,n){if(Fr(e,n),this instanceof zr)e=ln(Se.d,Se.n),this.s=Se.s,this.n=Se.n/e,this.d=Se.d/e;else return ur(Se.s*Se.n,Se.d)}var hi=function(){return new Error("Division by Zero")},ya=function(){return new Error("Invalid argument")},Th=function(){return new Error("Parameters must be integer")};zr.prototype={s:1,n:0,d:1,abs:function(){return ur(this.n,this.d)},neg:function(){return ur(-this.s*this.n,this.d)},add:function(e,n){return Fr(e,n),ur(this.s*this.n*Se.d+Se.s*this.d*Se.n,this.d*Se.d)},sub:function(e,n){return Fr(e,n),ur(this.s*this.n*Se.d-Se.s*this.d*Se.n,this.d*Se.d)},mul:function(e,n){return Fr(e,n),ur(this.s*Se.s*this.n*Se.n,this.d*Se.d)},div:function(e,n){return Fr(e,n),ur(this.s*Se.s*this.n*Se.d,this.d*Se.n)},clone:function(){return ur(this.s*this.n,this.d)},mod:function(e,n){if(isNaN(this.n)||isNaN(this.d))return new zr(NaN);if(e===void 0)return ur(this.s*this.n%this.d,1);if(Fr(e,n),Se.n===0&&this.d===0)throw hi();return ur(this.s*(Se.d*this.n)%(Se.n*this.d),Se.d*this.d)},gcd:function(e,n){return Fr(e,n),ur(ln(Se.n,this.n)*ln(Se.d,this.d),Se.d*this.d)},lcm:function(e,n){return Fr(e,n),Se.n===0&&this.n===0?ur(0,1):ur(Se.n*this.n,ln(Se.n,this.n)*ln(Se.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new zr(NaN):ur(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 zr(NaN):ur(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 zr(NaN):ur(Math.round(e*this.s*this.n/this.d),e)},roundTo:function(e,n){return Fr(e,n),ur(this.s*Math.round(this.n*Se.d/(this.d*Se.n))*Se.n,Se.d)},inverse:function(){return ur(this.s*this.d,this.n)},pow:function(e,n){if(Fr(e,n),Se.d===1)return Se.s<0?ur(Math.pow(this.s*this.d,Se.n),Math.pow(this.n,Se.n)):ur(Math.pow(this.s*this.n,Se.n),Math.pow(this.d,Se.n));if(this.s<0)return null;var a=Lo(this.n),t=Lo(this.d),r=1,i=1;for(var l in a)if(l!=="1"){if(l==="0"){r=0;break}if(a[l]*=Se.n,a[l]%Se.d===0)a[l]/=Se.d;else return null;r*=Math.pow(l,a[l])}for(var l in t)if(l!=="1"){if(t[l]*=Se.n,t[l]%Se.d===0)t[l]/=Se.d;else return null;i*=Math.pow(l,t[l])}return Se.s<0?ur(i,r):ur(r,i)},equals:function(e,n){return Fr(e,n),this.s*this.n*Se.d===Se.s*Se.n*this.d},compare:function(e,n){Fr(e,n);var a=this.s*this.n*Se.d-Se.s*Se.n*this.d;return(0<a)-(a<0)},simplify:function(e){if(isNaN(this.n)||isNaN(this.d))return this;e=e||.001;for(var n=this.abs(),a=n.toContinued(),t=1;t<a.length;t++){for(var r=ur(a[t-1],1),i=t-2;i>=0;i--)r=r.inverse().add(a[i]);if(Math.abs(r.sub(n).valueOf())<e)return r.mul(this.s)}return this},divisible:function(e,n){return Fr(e,n),!(!(Se.n*this.d)||this.n*Se.d%(Se.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(e){var n,a="",t=this.n,r=this.d;return this.s<0&&(a+="-"),r===1?a+=t:(e&&(n=Math.floor(t/r))>0&&(a+=n,a+=" ",t%=r),a+=t,a+="/",a+=r),a},toLatex:function(e){var n,a="",t=this.n,r=this.d;return this.s<0&&(a+="-"),r===1?a+=t:(e&&(n=Math.floor(t/r))>0&&(a+=n,t%=r),a+="\\frac{",a+=t,a+="}{",a+=r,a+="}"),a},toContinued:function(){var e,n=this.n,a=this.d,t=[];if(isNaN(n)||isNaN(a))return t;do t.push(Math.floor(n/a)),e=n%a,n=a,a=e;while(n!==1);return t},toString:function(e){var n=this.n,a=this.d;if(isNaN(n)||isNaN(a))return"NaN";e=e||15;var t=Oh(n,a),r=Dh(n,a,t),i=this.s<0?"-":"";if(i+=n/a|0,n%=a,n*=10,n&&(i+="."),t){for(var l=r;l--;)i+=n/a|0,n%=a,n*=10;i+="(";for(var l=t;l--;)i+=n/a|0,n%=a,n*=10;i+=")"}else for(var l=e;n&&l--;)i+=n/a|0,n%=a,n*=10;return i}};var Bh="Fraction",_h=[],$h=R(Bh,_h,()=>(zr.prototype.type="Fraction",zr.prototype.isFraction=!0,zr.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},zr.fromJSON=function(e){return new zr(e)},zr),{isClass:!0}),Ih="Range",qh=[],Rh=R(Ih,qh,()=>{function e(n,a,t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var r=n!=null,i=a!=null,l=t!=null;if(r){if(_e(n))n=n.toNumber();else if(typeof n!="number")throw new TypeError("Parameter start must be a number")}if(i){if(_e(a))a=a.toNumber();else if(typeof a!="number")throw new TypeError("Parameter end must be a number")}if(l){if(_e(t))t=t.toNumber();else if(typeof t!="number")throw new TypeError("Parameter step must be a number")}this.start=r?parseFloat(n):0,this.end=i?parseFloat(a):0,this.step=l?parseFloat(t):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(n){if(typeof n!="string")return null;var a=n.split(":"),t=a.map(function(i){return parseFloat(i)}),r=t.some(function(i){return isNaN(i)});if(r)return null;switch(t.length){case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[2],t[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var n=0,a=this.start,t=this.step,r=this.end,i=r-a;return Dt(t)===Dt(i)?n=Math.ceil(i/t):i===0&&(n=0),isNaN(n)&&(n=0),[n]},e.prototype.min=function(){var n=this.size()[0];if(n>0)return this.step>0?this.start:this.start+(n-1)*this.step},e.prototype.max=function(){var n=this.size()[0];if(n>0)return this.step>0?this.start+(n-1)*this.step:this.start},e.prototype.forEach=function(n){var a=this.start,t=this.step,r=this.end,i=0;if(t>0)for(;a<r;)n(a,[i],this),a+=t,i++;else if(t<0)for(;a>r;)n(a,[i],this),a+=t,i++},e.prototype.map=function(n){var a=[];return this.forEach(function(t,r,i){a[r[0]]=n(t,r,i)}),a},e.prototype.toArray=function(){var n=[];return this.forEach(function(a,t){n[t[0]]=a}),n},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(n){var a=Ht(this.start,n);return this.step!==1&&(a+=":"+Ht(this.step,n)),a+=":"+Ht(this.end,n),a},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(n){return new e(n.start,n.end,n.step)},e},{isClass:!0}),Fh="Matrix",zh=[],Ph=R(Fh,zh,()=>{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(n,a){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(n,a,t){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(n){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(n,a,t){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(n,a){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(n,a){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(n,a){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(n){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(n){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}),Uh="DenseMatrix",Lh=["Matrix"],kh=R(Uh,Lh,e=>{var{Matrix:n}=e;function a(s,o){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(o&&!_r(o))throw new Error("Invalid datatype: "+o);if(Oe(s))s.type==="DenseMatrix"?(this._data=Ce(s._data),this._size=Ce(s._size),this._datatype=o||s._datatype):(this._data=s.toArray(),this._size=s.size(),this._datatype=o||s._datatype);else if(s&&Xe(s.data)&&Xe(s.size))this._data=s.data,this._size=s.size,vo(this._data,this._size),this._datatype=o||s.datatype;else if(Xe(s))this._data=c(s),this._size=Pe(this._data),vo(this._data,this._size),this._datatype=o;else{if(s)throw new TypeError("Unsupported type of data ("+Ke(s)+")");this._data=[],this._size=[0],this._datatype=o}}a.prototype=new n,a.prototype.createDenseMatrix=function(s,o){return new a(s,o)},a.prototype.type="DenseMatrix",a.prototype.isDenseMatrix=!0,a.prototype.getDataType=function(){return Bn(this._data,Ke)},a.prototype.storage=function(){return"dense"},a.prototype.datatype=function(){return this._datatype},a.prototype.create=function(s,o){return new a(s,o)},a.prototype.subset=function(s,o,u){switch(arguments.length){case 1:return t(this,s);case 2:case 3:return i(this,s,o,u);default:throw new SyntaxError("Wrong number of arguments")}},a.prototype.get=function(s){if(!Xe(s))throw new TypeError("Array expected");if(s.length!==this._size.length)throw new Fe(s.length,this._size.length);for(var o=0;o<s.length;o++)We(s[o],this._size[o]);for(var u=this._data,p=0,v=s.length;p<v;p++){var h=s[p];We(h,u.length),u=u[h]}return u},a.prototype.set=function(s,o,u){if(!Xe(s))throw new TypeError("Array expected");if(s.length<this._size.length)throw new Fe(s.length,this._size.length,"<");var p,v,h,b=s.map(function(N){return N+1});f(this,b,u);var w=this._data;for(p=0,v=s.length-1;p<v;p++)h=s[p],We(h,w.length),w=w[h];return h=s[s.length-1],We(h,w.length),w[h]=o,this};function t(s,o){if(!En(o))throw new TypeError("Invalid index");var u=o.isScalar();if(u)return s.get(o.min());var p=o.size();if(p.length!==s._size.length)throw new Fe(p.length,s._size.length);for(var v=o.min(),h=o.max(),b=0,w=s._size.length;b<w;b++)We(v[b],s._size[b]),We(h[b],s._size[b]);return new a(r(s._data,o,p.length,0),s._datatype)}function r(s,o,u,p){var v=p===u-1,h=o.dimension(p);return v?h.map(function(b){return We(b,s.length),s[b]}).valueOf():h.map(function(b){We(b,s.length);var w=s[b];return r(w,o,u,p+1)}).valueOf()}function i(s,o,u,p){if(!o||o.isIndex!==!0)throw new TypeError("Invalid index");var v=o.size(),h=o.isScalar(),b;if(Oe(u)?(b=u.size(),u=u.valueOf()):b=Pe(u),h){if(b.length!==0)throw new TypeError("Scalar expected");s.set(o.min(),u,p)}else{if(v.length<s._size.length)throw new Fe(v.length,s._size.length,"<");if(b.length<v.length){for(var w=0,N=0;v[w]===1&&b[w]===1;)w++;for(;v[w]===1;)N++,w++;u=xo(u,v.length,N,b)}if(!Dn(v,b))throw new Fe(v,b,">");var g=o.max().map(function(d){return d+1});f(s,g,p);var y=v.length,x=0;l(s._data,o,u,y,x)}return s}function l(s,o,u,p,v){var h=v===p-1,b=o.dimension(v);h?b.forEach(function(w,N){We(w),s[w]=u[N[0]]}):b.forEach(function(w,N){We(w),l(s[w],o,u[N[0]],p,v+1)})}a.prototype.resize=function(s,o,u){if(!rn(s))throw new TypeError("Array or Matrix expected");var p=s.valueOf().map(h=>Array.isArray(h)&&h.length===1?h[0]:h),v=u?this.clone():this;return m(v,p,o)};function m(s,o,u){if(o.length===0){for(var p=s._data;Xe(p);)p=p[0];return p}return s._size=o.slice(0),s._data=on(s._data,s._size,u),s}a.prototype.reshape=function(s,o){var u=o?this.clone():this;u._data=ho(u._data,s);var p=u._size.reduce((v,h)=>v*h);return u._size=ti(s,p),u};function f(s,o,u){for(var p=s._size.slice(0),v=!1;p.length<o.length;)p.push(0),v=!0;for(var h=0,b=o.length;h<b;h++)o[h]>p[h]&&(p[h]=o[h],v=!0);v&&m(s,p,u)}a.prototype.clone=function(){var s=new a({data:Ce(this._data),size:Ce(this._size),datatype:this._datatype});return s},a.prototype.size=function(){return this._size.slice(0)},a.prototype.map=function(s){var o=this,u=function h(b,w){return Xe(b)?b.map(function(N,g){return h(N,w.concat(g))}):s(b,w,o)},p=u(this._data,[]),v=this._datatype!==void 0?Bn(p,Ke):void 0;return new a(p,v)},a.prototype.forEach=function(s){var o=this,u=function p(v,h){Xe(v)?v.forEach(function(b,w){p(b,h.concat(w))}):s(v,h,o)};u(this._data,[])},a.prototype[Symbol.iterator]=function*(){var s=function*o(u,p){if(Xe(u))for(var v=0;v<u.length;v++)yield*io(o(u[v],p.concat(v)));else yield{value:u,index:p}};yield*io(s(this._data,[]))},a.prototype.rows=function(){var s=[],o=this.size();if(o.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var u=this._data;for(var p of u)s.push(new a([p],this._datatype));return s},a.prototype.columns=function(){var s=this,o=[],u=this.size();if(u.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var p=this._data,v=function(w){var N=p.map(g=>[g[w]]);o.push(new a(N,s._datatype))},h=0;h<u[1];h++)v(h);return o},a.prototype.toArray=function(){return Ce(this._data)},a.prototype.valueOf=function(){return this._data},a.prototype.format=function(s){return Re(this._data,s)},a.prototype.toString=function(){return Re(this._data)},a.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},a.prototype.diagonal=function(s){if(s){if(_e(s)&&(s=s.toNumber()),!Be(s)||!Ae(s))throw new TypeError("The parameter k must be an integer number")}else s=0;for(var o=s>0?s:0,u=s<0?-s:0,p=this._size[0],v=this._size[1],h=Math.min(p-u,v-o),b=[],w=0;w<h;w++)b[w]=this._data[w+u][w+o];return new a({data:b,size:[h],datatype:this._datatype})},a.diagonal=function(s,o,u,p){if(!Xe(s))throw new TypeError("Array expected, size parameter");if(s.length!==2)throw new Error("Only two dimensions matrix are supported");if(s=s.map(function(A){if(_e(A)&&(A=A.toNumber()),!Be(A)||!Ae(A)||A<1)throw new Error("Size values must be positive integers");return A}),u){if(_e(u)&&(u=u.toNumber()),!Be(u)||!Ae(u))throw new TypeError("The parameter k must be an integer number")}else u=0;var v=u>0?u:0,h=u<0?-u:0,b=s[0],w=s[1],N=Math.min(b-h,w-v),g;if(Xe(o)){if(o.length!==N)throw new Error("Invalid value array length");g=function(S){return o[S]}}else if(Oe(o)){var y=o.size();if(y.length!==1||y[0]!==N)throw new Error("Invalid matrix length");g=function(S){return o.get([S])}}else g=function(){return o};p||(p=_e(g(0))?g(0).mul(0):0);var x=[];if(s.length>0){x=on(x,s,p);for(var d=0;d<N;d++)x[d+h][d+v]=g(d)}return new a({data:x,size:[b,w]})},a.fromJSON=function(s){return new a(s)},a.prototype.swapRows=function(s,o){if(!Be(s)||!Ae(s)||!Be(o)||!Ae(o))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return We(s,this._size[0]),We(o,this._size[0]),a._swapRows(s,o,this._data),this},a._swapRows=function(s,o,u){var p=u[s];u[s]=u[o],u[o]=p};function c(s){for(var o=0,u=s.length;o<u;o++){var p=s[o];Xe(p)?s[o]=c(p):p&&p.isMatrix===!0&&(s[o]=c(p.valueOf()))}return s}return a},{isClass:!0}),ko="clone",Hh=["typed"],Gh=R(ko,Hh,e=>{var{typed:n}=e;return n(ko,{any:Ce})});function Ho(e){var n=e.length,a=e[0].length,t,r,i=[];for(r=0;r<a;r++){var l=[];for(t=0;t<n;t++)l.push(e[t][r]);i.push(l)}return i}function mn(e){for(var n=0;n<e.length;n++)if(rn(e[n]))return!0;return!1}function bt(e,n){Oe(e)&&(e=e.valueOf());for(var a=0,t=e.length;a<t;a++){var r=e[a];Array.isArray(r)?bt(r,n):n(r)}}function be(e,n,a){return e&&typeof e.map=="function"?e.map(function(t){return be(t,n)}):n(e)}function xa(e,n,a){var t=Array.isArray(e)?Pe(e):e.size();if(n<0||n>=t.length)throw new Kr(n,t.length);return Oe(e)?e.create(ba(e.valueOf(),n,a)):ba(e,n,a)}function ba(e,n,a){var t,r,i,l;if(n<=0)if(Array.isArray(e[0])){for(l=Ho(e),r=[],t=0;t<l.length;t++)r[t]=ba(l[t],n-1,a);return r}else{for(i=e[0],t=1;t<e.length;t++)i=a(i,e[t]);return i}else{for(r=[],t=0;t<e.length;t++)r[t]=ba(e[t],n-1,a);return r}}function Go(e,n,a,t,r,i,l,m,f,c,s){var o=e._values,u=e._index,p=e._ptr,v,h,b,w;if(t)for(h=p[n],b=p[n+1],v=h;v<b;v++)w=u[v],a[w]!==i?(a[w]=i,l.push(w),t[w]=o[v]):(t[w]=m(t[w],o[v]),r[w]=i);else for(h=p[n],b=p[n+1],v=h;v<b;v++)w=u[v],a[w]!==i?(a[w]=i,l.push(w)):r[w]=i}var Vo="isInteger",Vh=["typed"],Zh=R(Vo,Vh,e=>{var{typed:n}=e;return n(Vo,{number:Ae,BigNumber:function(t){return t.isInt()},Fraction:function(t){return t.d===1&&isFinite(t.n)},"Array | Matrix":function(t){return be(t,this)}})}),et="number",Gt="number, number";function Zo(e){return Math.abs(e)}Zo.signature=et;function Xo(e,n){return e+n}Xo.signature=Gt;function Yo(e,n){return e*n}Yo.signature=Gt;function Wo(e){return-e}Wo.signature=et;function Jo(e){return e}Jo.signature=et;function $n(e){return Vp(e)}$n.signature=et;function Qo(e){return e*e*e}Qo.signature=et;function Ko(e){return Math.exp(e)}Ko.signature=et;function jo(e){return Zp(e)}jo.signature=et;function es(e,n){if(!Ae(e)||!Ae(n))throw new Error("Parameters in function gcd must be integer numbers");for(var a;n!==0;)a=e%n,e=n,n=a;return e<0?-e:e}es.signature=Gt;function rs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Parameters in function lcm must be integer numbers");if(e===0||n===0)return 0;for(var a,t=e*n;n!==0;)a=n,n=e%a,e=a;return Math.abs(t/e)}rs.signature=Gt;function Xh(e,n){return Math.log(e)}function ts(e){return Hp(e)}ts.signature=et;function ns(e){return kp(e)}ns.signature=et;function as(e,n){if(n>0)return e-n*Math.floor(e/n);if(n===0)return e;throw new Error("Cannot calculate mod for a negative divisor")}as.signature=Gt;function is(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,a=n<0;if(a&&(n=-n),n===0)throw new Error("Root must be non-zero");if(e<0&&Math.abs(n)%2!==1)throw new Error("Root must be odd when a is negative.");if(e===0)return a?1/0:0;if(!isFinite(e))return a?0:e;var t=Math.pow(Math.abs(e),1/n);return t=e<0?-t:t,a?1/t:t}function di(e){return Dt(e)}di.signature=et;function os(e){return e*e}os.signature=et;function ss(e,n){var a,t,r,i=0,l=1,m=1,f=0;if(!Ae(e)||!Ae(n))throw new Error("Parameters in function xgcd must be integer numbers");for(;n;)t=Math.floor(e/n),r=e-t*n,a=i,i=l-t*i,l=a,a=m,m=f-t*m,f=a,e=n,n=r;var c;return e<0?c=[-e,-l,-f]:c=[e,e?l:0,f],c}ss.signature=Gt;function us(e,n){return e*e<1&&n===1/0||e*e>1&&n===-1/0?0:Math.pow(e,n)}us.signature=Gt;function cs(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!Ae(n)||n<0||n>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(co(e,n))}var Yh="number",pn="number, number";function fs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function bitAnd");return e&n}fs.signature=pn;function ls(e){if(!Ae(e))throw new Error("Integer expected in function bitNot");return~e}ls.signature=Yh;function ms(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function bitOr");return e|n}ms.signature=pn;function ps(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function bitXor");return e^n}ps.signature=pn;function vs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function leftShift");return e<<n}vs.signature=pn;function hs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function rightArithShift");return e>>n}hs.signature=pn;function ds(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function rightLogShift");return e>>>n}ds.signature=pn;function wt(e,n){if(n<e)return 1;if(n===e)return n;var a=n+e>>1;return wt(e,a)*wt(a+1,n)}function gs(e,n){if(!Ae(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!Ae(n)||n<0)throw new TypeError("Positive integer value expected in function combinations");if(n>e)throw new TypeError("k must be less than or equal to n");for(var a=e-n,t=1,r=n<a?a+1:n+1,i=2,l=n<a?n:a,m=r;m<=e;++m)for(t*=m;i<=l&&t%i===0;)t/=i,++i;return i<=l&&(t/=wt(i,l)),t}gs.signature="number, number";var Wh=Math.PI,Jh=2*Math.PI,Qh=Math.E,Kh=1.618033988749895,jh="number",gi="number, number";function ys(e){return!e}ys.signature=jh;function xs(e,n){return!!(e||n)}xs.signature=gi;function bs(e,n){return!!e!=!!n}bs.signature=gi;function ws(e,n){return!!(e&&n)}ws.signature=gi;function yi(e){var n;if(Ae(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:wt(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*yi(1-e));if(e>=171.35)return 1/0;if(e>85){var a=e*e,t=a*e,r=t*e,i=r*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*a)-139/(51840*t)-571/(2488320*r)+163879/(209018880*i)+5246819/(75246796800*i*e))}--e,n=vn[0];for(var l=1;l<vn.length;++l)n+=vn[l]/(e+l);var m=e+Ns+.5;return Math.sqrt(2*Math.PI)*Math.pow(m,e+.5)*Math.exp(-m)*n}yi.signature="number";var Ns=4.7421875,vn=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],Ms=.9189385332046728,ed=5,rd=7,As=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function wa(e){if(e<0)return NaN;if(e===0)return 1/0;if(!isFinite(e))return e;if(e<.5)return Math.log(Math.PI/Math.sin(Math.PI*e))-wa(1-e);e=e-1;for(var n=e+ed+.5,a=As[0],t=rd-1;t>=1;t--)a+=As[t]/(e+t);return Ms+(e+.5)*Math.log(n)-n+Math.log(a)}wa.signature="number";var Mr="number";function Ss(e){return Qp(e)}Ss.signature=Mr;function Es(e){return Math.atan(1/e)}Es.signature=Mr;function Cs(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}Cs.signature=Mr;function Os(e){return Math.asin(1/e)}Os.signature=Mr;function Ds(e){var n=1/e;return Math.log(n+Math.sqrt(n*n+1))}Ds.signature=Mr;function Ts(e){return Math.acos(1/e)}Ts.signature=Mr;function Bs(e){var n=1/e,a=Math.sqrt(n*n-1);return Math.log(a+n)}Bs.signature=Mr;function _s(e){return Kp(e)}_s.signature=Mr;function $s(e){return jp(e)}$s.signature=Mr;function Is(e){return 1/Math.tan(e)}Is.signature=Mr;function qs(e){var n=Math.exp(2*e);return(n+1)/(n-1)}qs.signature=Mr;function Rs(e){return 1/Math.sin(e)}Rs.signature=Mr;function Fs(e){return e===0?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*Dt(e)}Fs.signature=Mr;function zs(e){return 1/Math.cos(e)}zs.signature=Mr;function Ps(e){return 2/(Math.exp(e)+Math.exp(-e))}Ps.signature=Mr;function Us(e){return rv(e)}Us.signature=Mr;var Na="number";function Ls(e){return e<0}Ls.signature=Na;function ks(e){return e>0}ks.signature=Na;function Hs(e){return e===0}Hs.signature=Na;function Gs(e){return Number.isNaN(e)}Gs.signature=Na;var Vs="isNegative",td=["typed"],nd=R(Vs,td,e=>{var{typed:n}=e;return n(Vs,{number:Ls,BigNumber:function(t){return t.isNeg()&&!t.isZero()&&!t.isNaN()},Fraction:function(t){return t.s<0},Unit:function(t){return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Zs="isNumeric",ad=["typed"],id=R(Zs,ad,e=>{var{typed:n}=e;return n(Zs,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(t){return be(t,this)}})}),Xs="hasNumericValue",od=["typed","isNumeric"],sd=R(Xs,od,e=>{var{typed:n,isNumeric:a}=e;return n(Xs,{string:function(r){return r.trim().length>0&&!isNaN(Number(r))},any:function(r){return a(r)}})}),Ys="isPositive",ud=["typed"],cd=R(Ys,ud,e=>{var{typed:n}=e;return n(Ys,{number:ks,BigNumber:function(t){return!t.isNeg()&&!t.isZero()&&!t.isNaN()},Fraction:function(t){return t.s>0&&t.n>0},Unit:function(t){return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Ws="isZero",fd=["typed"],ld=R(Ws,fd,e=>{var{typed:n}=e;return n(Ws,{number:Hs,BigNumber:function(t){return t.isZero()},Complex:function(t){return t.re===0&&t.im===0},Fraction:function(t){return t.d===1&&t.n===0},Unit:function(t){return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Js="isNaN",md=["typed"],pd=R(Js,md,e=>{var{typed:n}=e;return n(Js,{number:Gs,BigNumber:function(t){return t.isNaN()},Fraction:function(t){return!1},Complex:function(t){return t.isNaN()},Unit:function(t){return Number.isNaN(t.value)},"Array | Matrix":function(t){return be(t,Number.isNaN)}})}),Qs="typeOf",vd=["typed"],hd=R(Qs,vd,e=>{var{typed:n}=e;return n(Qs,{any:Ke})});function st(e,n,a){if(a==null)return e.eq(n);if(e.eq(n))return!0;if(e.isNaN()||n.isNaN())return!1;if(e.isFinite()&&n.isFinite()){var t=e.minus(n).abs();if(t.isZero())return!0;var r=e.constructor.max(e.abs(),n.abs());return t.lte(r.times(a))}return!1}function dd(e,n,a){return Rr(e.re,n.re,a)&&Rr(e.im,n.im,a)}var Ma="equalScalar",gd=["typed","config"],yd=R(Ma,gd,e=>{var{typed:n,config:a}=e;return n(Ma,{"boolean, boolean":function(r,i){return r===i},"number, number":function(r,i){return Rr(r,i,a.epsilon)},"BigNumber, BigNumber":function(r,i){return r.eq(i)||st(r,i,a.epsilon)},"Fraction, Fraction":function(r,i){return r.equals(i)},"Complex, Complex":function(r,i){return dd(r,i,a.epsilon)},"Unit, Unit":function(r,i){if(!r.equalBase(i))throw new Error("Cannot compare units with different base");return this(r.value,i.value)}})});R(Ma,["typed","config"],e=>{var{typed:n,config:a}=e;return n(Ma,{"number, number":function(r,i){return Rr(r,i,a.epsilon)}})});var xd="SparseMatrix",bd=["typed","equalScalar","Matrix"],wd=R(xd,bd,e=>{var{typed:n,equalScalar:a,Matrix:t}=e;function r(h,b){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(b&&!_r(b))throw new Error("Invalid datatype: "+b);if(Oe(h))i(this,h,b);else if(h&&Xe(h.index)&&Xe(h.ptr)&&Xe(h.size))this._values=h.values,this._index=h.index,this._ptr=h.ptr,this._size=h.size,this._datatype=b||h.datatype;else if(Xe(h))l(this,h,b);else{if(h)throw new TypeError("Unsupported type of data ("+Ke(h)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=b}}function i(h,b,w){b.type==="SparseMatrix"?(h._values=b._values?Ce(b._values):void 0,h._index=Ce(b._index),h._ptr=Ce(b._ptr),h._size=Ce(b._size),h._datatype=w||b._datatype):l(h,b.valueOf(),w||b._datatype)}function l(h,b,w){h._values=[],h._index=[],h._ptr=[],h._datatype=w;var N=b.length,g=0,y=a,x=0;if(_r(w)&&(y=n.find(a,[w,w])||a,x=n.convert(0,w)),N>0){var d=0;do{h._ptr.push(h._index.length);for(var A=0;A<N;A++){var S=b[A];if(Xe(S)){if(d===0&&g<S.length&&(g=S.length),d<S.length){var O=S[d];y(O,x)||(h._values.push(O),h._index.push(A))}}else d===0&&g<1&&(g=1),y(S,x)||(h._values.push(S),h._index.push(A))}d++}while(d<g)}h._ptr.push(h._index.length),h._size=[N,g]}r.prototype=new t,r.prototype.createSparseMatrix=function(h,b){return new r(h,b)},r.prototype.type="SparseMatrix",r.prototype.isSparseMatrix=!0,r.prototype.getDataType=function(){return Bn(this._values,Ke)},r.prototype.storage=function(){return"sparse"},r.prototype.datatype=function(){return this._datatype},r.prototype.create=function(h,b){return new r(h,b)},r.prototype.density=function(){var h=this._size[0],b=this._size[1];return h!==0&&b!==0?this._index.length/(h*b):0},r.prototype.subset=function(h,b,w){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return m(this,h);case 2:case 3:return f(this,h,b,w);default:throw new SyntaxError("Wrong number of arguments")}};function m(h,b){if(!En(b))throw new TypeError("Invalid index");var w=b.isScalar();if(w)return h.get(b.min());var N=b.size();if(N.length!==h._size.length)throw new Fe(N.length,h._size.length);var g,y,x,d,A=b.min(),S=b.max();for(g=0,y=h._size.length;g<y;g++)We(A[g],h._size[g]),We(S[g],h._size[g]);var O=h._values,M=h._index,_=h._ptr,E=b.dimension(0),$=b.dimension(1),z=[],I=[];E.forEach(function(D,H){I[D]=H[0],z[D]=!0});var T=O?[]:void 0,B=[],G=[];return $.forEach(function(D){for(G.push(B.length),x=_[D],d=_[D+1];x<d;x++)g=M[x],z[g]===!0&&(B.push(I[g]),T&&T.push(O[x]))}),G.push(B.length),new r({values:T,index:B,ptr:G,size:N,datatype:h._datatype})}function f(h,b,w,N){if(!b||b.isIndex!==!0)throw new TypeError("Invalid index");var g=b.size(),y=b.isScalar(),x;if(Oe(w)?(x=w.size(),w=w.toArray()):x=Pe(w),y){if(x.length!==0)throw new TypeError("Scalar expected");h.set(b.min(),w,N)}else{if(g.length!==1&&g.length!==2)throw new Fe(g.length,h._size.length,"<");if(x.length<g.length){for(var d=0,A=0;g[d]===1&&x[d]===1;)d++;for(;g[d]===1;)A++,d++;w=xo(w,g.length,A,x)}if(!Dn(g,x))throw new Fe(g,x,">");if(g.length===1){var S=b.dimension(0);S.forEach(function(_,E){We(_),h.set([_,0],w[E[0]],N)})}else{var O=b.dimension(0),M=b.dimension(1);O.forEach(function(_,E){We(_),M.forEach(function($,z){We($),h.set([_,$],w[E[0]][z[0]],N)})})}}return h}r.prototype.get=function(h){if(!Xe(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new Fe(h.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var b=h[0],w=h[1];We(b,this._size[0]),We(w,this._size[1]);var N=c(b,this._ptr[w],this._ptr[w+1],this._index);return N<this._ptr[w+1]&&this._index[N]===b?this._values[N]:0},r.prototype.set=function(h,b,w){if(!Xe(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new Fe(h.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var N=h[0],g=h[1],y=this._size[0],x=this._size[1],d=a,A=0;_r(this._datatype)&&(d=n.find(a,[this._datatype,this._datatype])||a,A=n.convert(0,this._datatype)),(N>y-1||g>x-1)&&(u(this,Math.max(N+1,y),Math.max(g+1,x),w),y=this._size[0],x=this._size[1]),We(N,y),We(g,x);var S=c(N,this._ptr[g],this._ptr[g+1],this._index);return S<this._ptr[g+1]&&this._index[S]===N?d(b,A)?s(S,g,this._values,this._index,this._ptr):this._values[S]=b:o(S,N,g,b,this._values,this._index,this._ptr),this};function c(h,b,w,N){if(w-b===0)return w;for(var g=b;g<w;g++)if(N[g]===h)return g;return b}function s(h,b,w,N,g){w.splice(h,1),N.splice(h,1);for(var y=b+1;y<g.length;y++)g[y]--}function o(h,b,w,N,g,y,x){g.splice(h,0,N),y.splice(h,0,b);for(var d=w+1;d<x.length;d++)x[d]++}r.prototype.resize=function(h,b,w){if(!rn(h))throw new TypeError("Array or Matrix expected");var N=h.valueOf().map(y=>Array.isArray(y)&&y.length===1?y[0]:y);if(N.length!==2)throw new Error("Only two dimensions matrix are supported");N.forEach(function(y){if(!Be(y)||!Ae(y)||y<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Re(N)+")")});var g=w?this.clone():this;return u(g,N[0],N[1],b)};function u(h,b,w,N){var g=N||0,y=a,x=0;_r(h._datatype)&&(y=n.find(a,[h._datatype,h._datatype])||a,x=n.convert(0,h._datatype),g=n.convert(g,h._datatype));var d=!y(g,x),A=h._size[0],S=h._size[1],O,M,_;if(w>S){for(M=S;M<w;M++)if(h._ptr[M]=h._values.length,d)for(O=0;O<A;O++)h._values.push(g),h._index.push(O);h._ptr[w]=h._values.length}else w<S&&(h._ptr.splice(w+1,S-w),h._values.splice(h._ptr[w],h._values.length),h._index.splice(h._ptr[w],h._index.length));if(S=w,b>A){if(d){var E=0;for(M=0;M<S;M++){h._ptr[M]=h._ptr[M]+E,_=h._ptr[M+1]+E;var $=0;for(O=A;O<b;O++,$++)h._values.splice(_+$,0,g),h._index.splice(_+$,0,O),E++}h._ptr[S]=h._values.length}}else if(b<A){var z=0;for(M=0;M<S;M++){h._ptr[M]=h._ptr[M]-z;var I=h._ptr[M],T=h._ptr[M+1]-z;for(_=I;_<T;_++)O=h._index[_],O>b-1&&(h._values.splice(_,1),h._index.splice(_,1),z++)}h._ptr[M]=h._values.length}return h._size[0]=b,h._size[1]=w,h}r.prototype.reshape=function(h,b){if(!Xe(h))throw new TypeError("Array expected");if(h.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");h.forEach(function(D){if(!Be(D)||!Ae(D)||D<=-2||D===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Re(h)+")")});var w=this._size[0]*this._size[1];h=ti(h,w);var N=h[0]*h[1];if(w!==N)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var g=b?this.clone():this;if(this._size[0]===h[0]&&this._size[1]===h[1])return g;for(var y=[],x=0;x<g._ptr.length;x++)for(var d=0;d<g._ptr[x+1]-g._ptr[x];d++)y.push(x);for(var A=g._values.slice(),S=g._index.slice(),O=0;O<g._index.length;O++){var M=S[O],_=y[O],E=M*g._size[1]+_;y[O]=E%h[1],S[O]=Math.floor(E/h[1])}g._values.length=0,g._index.length=0,g._ptr.length=h[1]+1,g._size=h.slice();for(var $=0;$<g._ptr.length;$++)g._ptr[$]=0;for(var z=0;z<A.length;z++){var I=S[z],T=y[z],B=A[z],G=c(I,g._ptr[T],g._ptr[T+1],g._index);o(G,I,T,B,g._values,g._index,g._ptr)}return g},r.prototype.clone=function(){var h=new r({values:this._values?Ce(this._values):void 0,index:Ce(this._index),ptr:Ce(this._ptr),size:Ce(this._size),datatype:this._datatype});return h},r.prototype.size=function(){return this._size.slice(0)},r.prototype.map=function(h,b){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var w=this,N=this._size[0],g=this._size[1],y=function(d,A,S){return h(d,[A,S],w)};return p(this,0,N-1,0,g-1,y,b)};function p(h,b,w,N,g,y,x){var d=[],A=[],S=[],O=a,M=0;_r(h._datatype)&&(O=n.find(a,[h._datatype,h._datatype])||a,M=n.convert(0,h._datatype));for(var _=function(V,K,te){V=y(V,K,te),O(V,M)||(d.push(V),A.push(K))},E=N;E<=g;E++){S.push(d.length);var $=h._ptr[E],z=h._ptr[E+1];if(x)for(var I=$;I<z;I++){var T=h._index[I];T>=b&&T<=w&&_(h._values[I],T-b,E-N)}else{for(var B={},G=$;G<z;G++){var D=h._index[G];B[D]=h._values[G]}for(var H=b;H<=w;H++){var W=H in B?B[H]:0;_(W,H-b,E-N)}}}return S.push(d.length),new r({values:d,index:A,ptr:S,size:[w-b+1,g-N+1]})}r.prototype.forEach=function(h,b){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var w=this,N=this._size[0],g=this._size[1],y=0;y<g;y++){var x=this._ptr[y],d=this._ptr[y+1];if(b)for(var A=x;A<d;A++){var S=this._index[A];h(this._values[A],[S,y],w)}else{for(var O={},M=x;M<d;M++){var _=this._index[M];O[_]=this._values[M]}for(var E=0;E<N;E++){var $=E in O?O[E]:0;h($,[E,y],w)}}}},r.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var h=this._size[1],b=0;b<h;b++)for(var w=this._ptr[b],N=this._ptr[b+1],g=w;g<N;g++){var y=this._index[g];yield{value:this._values[g],index:[y,b]}}},r.prototype.toArray=function(){return v(this._values,this._index,this._ptr,this._size,!0)},r.prototype.valueOf=function(){return v(this._values,this._index,this._ptr,this._size,!1)};function v(h,b,w,N,g){var y=N[0],x=N[1],d=[],A,S;for(A=0;A<y;A++)for(d[A]=[],S=0;S<x;S++)d[A][S]=0;for(S=0;S<x;S++)for(var O=w[S],M=w[S+1],_=O;_<M;_++)A=b[_],d[A][S]=h?g?Ce(h[_]):h[_]:1;return d}return r.prototype.format=function(h){for(var b=this._size[0],w=this._size[1],N=this.density(),g="Sparse Matrix ["+Re(b,h)+" x "+Re(w,h)+"] density: "+Re(N,h)+`
8
+ `);return Object.freeze(Gr)};ir(se,Gr,{MATRIX_OPTIONS:Up,NUMBER_OPTIONS:Lp});function na(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function kp(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function a(){var r=!1;try{r=this instanceof a}catch(i){}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(a){var r=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:function(){return e[a]}})}),n}var aa={exports:{}},Hp=aa.exports,mo;function Gp(){return mo||(mo=1,function(e,t){(function(n,a){e.exports=a()})(Hp,function(){function n(){return!0}function a(){return!1}function r(){}function i(){var u=[{name:"number",test:function(q){return typeof q=="number"}},{name:"string",test:function(q){return typeof q=="string"}},{name:"boolean",test:function(q){return typeof q=="boolean"}},{name:"Function",test:function(q){return typeof q=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(q){return q instanceof Date}},{name:"RegExp",test:function(q){return q instanceof RegExp}},{name:"Object",test:function(q){return typeof q=="object"&&q!==null&&q.constructor===Object}},{name:"null",test:function(q){return q===null}},{name:"undefined",test:function(q){return q===void 0}}],l={name:"any",test:n},f=[],c=[],o={types:u,conversions:c,ignore:f};function s(q){var P=F(o.types,function(L){return L.name===q});if(P)return P;if(q==="any")return l;var Q=F(o.types,function(L){return L.name.toLowerCase()===q.toLowerCase()});throw new TypeError('Unknown type "'+q+'"'+(Q?'. Did you mean "'+Q.name+'"?':""))}function m(q){return q===l?999:o.types.indexOf(q)}function p(q){var P=F(o.types,function(Q){return Q.test(q)});if(P)return P.name;throw new TypeError("Value has unknown type. Value: "+q)}function v(q,P){if(!q.signatures)throw new TypeError("Function is no typed-function");var Q;if(typeof P=="string"){Q=P.split(",");for(var L=0;L<Q.length;L++)Q[L]=Q[L].trim()}else if(Array.isArray(P))Q=P;else throw new TypeError("String array or a comma separated string expected");var ue=Q.join(","),le=q.signatures[ue];if(le)return le;throw new TypeError("Signature not found (signature: "+(q.name||"unnamed")+"("+Q.join(", ")+"))")}function h(q,P){var Q=p(q);if(P===Q)return q;for(var L=0;L<o.conversions.length;L++){var ue=o.conversions[L];if(ue.from===Q&&ue.to===P)return ue.convert(q)}throw new Error("Cannot convert from "+Q+" to "+P)}function b(q){return q.map(function(P){var Q=P.types.map(O);return(P.restParam?"...":"")+Q.join("|")}).join(",")}function w(q,P){var Q=q.indexOf("...")===0,L=Q?q.length>3?q.slice(3):"any":q,ue=L.split("|").map(re).filter(oe).filter(te),le=B(P,ue),ye=ue.map(function(he){var Me=s(he);return{name:he,typeIndex:m(Me),test:Me.test,conversion:null,conversionIndex:-1}}),ve=le.map(function(he){var Me=s(he.from);return{name:he.from,typeIndex:m(Me),test:Me.test,conversion:he,conversionIndex:P.indexOf(he)}});return{types:ye.concat(ve),restParam:Q}}function N(q,P,Q){var L=[];return q.trim()!==""&&(L=q.split(",").map(re).map(function(ue,le,ye){var ve=w(ue,Q);if(ve.restParam&&le!==ye.length-1)throw new SyntaxError('Unexpected rest parameter "'+ue+'": only allowed for the last parameter');return ve})),L.some(ce)?null:{params:L,fn:P}}function g(q){var P=xe(q);return P?P.restParam:!1}function y(q){return q.types.some(function(P){return P.conversion!=null})}function x(q){if(!q||q.types.length===0)return n;if(q.types.length===1)return s(q.types[0].name).test;if(q.types.length===2){var P=s(q.types[0].name).test,Q=s(q.types[1].name).test;return function(le){return P(le)||Q(le)}}else{var L=q.types.map(function(ue){return s(ue.name).test});return function(le){for(var ye=0;ye<L.length;ye++)if(L[ye](le))return!0;return!1}}}function d(q){var P,Q,L;if(g(q)){P=ee(q).map(x);var ue=P.length,le=x(xe(q)),ye=function(ve){for(var he=ue;he<ve.length;he++)if(!le(ve[he]))return!1;return!0};return function(he){for(var Me=0;Me<P.length;Me++)if(!P[Me](he[Me]))return!1;return ye(he)&&he.length>=ue+1}}else return q.length===0?function(he){return he.length===0}:q.length===1?(Q=x(q[0]),function(he){return Q(he[0])&&he.length===1}):q.length===2?(Q=x(q[0]),L=x(q[1]),function(he){return Q(he[0])&&L(he[1])&&he.length===2}):(P=q.map(x),function(he){for(var Me=0;Me<P.length;Me++)if(!P[Me](he[Me]))return!1;return he.length===P.length})}function A(q,P){return P<q.params.length?q.params[P]:g(q.params)?xe(q.params):null}function S(q,P,Q){var L=A(q,P),ue=L?Q?L.types.filter(M):L.types:[];return ue.map(O)}function O(q){return q.name}function M(q){return q.conversion===null||q.conversion===void 0}function $(q,P){var Q=Y(k(q,function(L){return S(L,P,!1)}));return Q.indexOf("any")!==-1?["any"]:Q}function E(q,P,Q){var L,ue,le=q||"unnamed",ye=Q,ve;for(ve=0;ve<P.length;ve++){var he=ye.filter(function(nr){var jr=x(A(nr,ve));return(ve<nr.params.length||g(nr.params))&&jr(P[ve])});if(he.length===0){if(ue=$(ye,ve),ue.length>0){var Me=p(P[ve]);return L=new TypeError("Unexpected type of argument in function "+le+" (expected: "+ue.join(" or ")+", actual: "+Me+", index: "+ve+")"),L.data={category:"wrongType",fn:le,index:ve,actual:Me,expected:ue},L}}else ye=he}var Ke=ye.map(function(nr){return g(nr.params)?1/0:nr.params.length});if(P.length<Math.min.apply(null,Ke))return ue=$(ye,ve),L=new TypeError("Too few arguments in function "+le+" (expected: "+ue.join(" or ")+", index: "+P.length+")"),L.data={category:"tooFewArgs",fn:le,index:P.length,expected:ue},L;var fr=Math.max.apply(null,Ke);return P.length>fr?(L=new TypeError("Too many arguments in function "+le+" (expected: "+fr+", actual: "+P.length+")"),L.data={category:"tooManyArgs",fn:le,index:P.length,expectedLength:fr},L):(L=new TypeError('Arguments of type "'+P.join(", ")+'" do not match any of the defined signatures of function '+le+"."),L.data={category:"mismatch",actual:P.map(p)},L)}function _(q){for(var P=999,Q=0;Q<q.types.length;Q++)M(q.types[Q])&&(P=Math.min(P,q.types[Q].typeIndex));return P}function z(q){for(var P=999,Q=0;Q<q.types.length;Q++)M(q.types[Q])||(P=Math.min(P,q.types[Q].conversionIndex));return P}function I(q,P){var Q;return Q=q.restParam-P.restParam,Q!==0||(Q=y(q)-y(P),Q!==0)||(Q=_(q)-_(P),Q!==0)?Q:z(q)-z(P)}function T(q,P){var Q=Math.min(q.params.length,P.params.length),L,ue;if(ue=q.params.some(y)-P.params.some(y),ue!==0)return ue;for(L=0;L<Q;L++)if(ue=y(q.params[L])-y(P.params[L]),ue!==0)return ue;for(L=0;L<Q;L++)if(ue=I(q.params[L],P.params[L]),ue!==0)return ue;return q.params.length-P.params.length}function B(q,P){var Q={};return q.forEach(function(L){P.indexOf(L.from)===-1&&P.indexOf(L.to)!==-1&&!Q[L.from]&&(Q[L.from]=L)}),Object.keys(Q).map(function(L){return Q[L]})}function G(q,P){var Q=P;if(q.some(y)){var L=g(q),ue=q.map(D);Q=function(){for(var he=[],Me=L?arguments.length-1:arguments.length,Ke=0;Ke<Me;Ke++)he[Ke]=ue[Ke](arguments[Ke]);return L&&(he[Me]=arguments[Me].map(ue[Me])),P.apply(this,he)}}var le=Q;if(g(q)){var ye=q.length-1;le=function(){return Q.apply(this,Ne(arguments,0,ye).concat([Ne(arguments,ye)]))}}return le}function D(q){var P,Q,L,ue,le=[],ye=[];switch(q.types.forEach(function(ve){ve.conversion&&(le.push(s(ve.conversion.from).test),ye.push(ve.conversion.convert))}),ye.length){case 0:return function(he){return he};case 1:return P=le[0],L=ye[0],function(he){return P(he)?L(he):he};case 2:return P=le[0],Q=le[1],L=ye[0],ue=ye[1],function(he){return P(he)?L(he):Q(he)?ue(he):he};default:return function(he){for(var Me=0;Me<ye.length;Me++)if(le[Me](he))return ye[Me](he);return he}}}function H(q){var P={};return q.forEach(function(Q){Q.params.some(y)||W(Q.params,!0).forEach(function(L){P[b(L)]=Q.fn})}),P}function W(q,P){function Q(L,ue,le){if(ue<L.length){var ye=L[ue],ve=P?ye.types.filter(M):ye.types,he;if(ye.restParam){var Me=ve.filter(M);he=Me.length<ve.length?[Me,ve]:[ve]}else he=ve.map(function(fr){return[fr]});return k(he,function(fr){return Q(L,ue+1,le.concat([fr]))})}else{var Ke=le.map(function(fr,nr){return{types:fr,restParam:nr===L.length-1&&g(L)}});return[Ke]}}return Q(q,0,[])}function j(q,P){for(var Q=Math.max(q.params.length,P.params.length),L=0;L<Q;L++){var ue=S(q,L,!0),le=S(P,L,!0);if(!be(ue,le))return!1}var ye=q.params.length,ve=P.params.length,he=g(q.params),Me=g(P.params);return he?Me?ye===ve:ve>=ye:Me?ye>=ve:ye===ve}function V(q,P){if(Object.keys(P).length===0)throw new SyntaxError("No signatures provided");var Q=[];Object.keys(P).map(function(ar){return N(ar,P[ar],o.conversions)}).filter(ae).forEach(function(ar){var Dr=F(Q,function(dt){return j(dt,ar)});if(Dr)throw new TypeError('Conflicting signatures "'+b(Dr.params)+'" and "'+b(ar.params)+'".');Q.push(ar)});var L=k(Q,function(ar){var Dr=ar?W(ar.params,!1):[];return Dr.map(function(dt){return{params:dt,fn:ar.fn}})}).filter(ae);L.sort(T);var ue=L[0]&&L[0].params.length<=2&&!g(L[0].params),le=L[1]&&L[1].params.length<=2&&!g(L[1].params),ye=L[2]&&L[2].params.length<=2&&!g(L[2].params),ve=L[3]&&L[3].params.length<=2&&!g(L[3].params),he=L[4]&&L[4].params.length<=2&&!g(L[4].params),Me=L[5]&&L[5].params.length<=2&&!g(L[5].params),Ke=ue&&le&&ye&&ve&&he&&Me,fr=L.map(function(ar){return d(ar.params)}),nr=ue?x(L[0].params[0]):a,jr=le?x(L[1].params[0]):a,kr=ye?x(L[2].params[0]):a,Tt=ve?x(L[3].params[0]):a,Xe=he?x(L[4].params[0]):a,Lt=Me?x(L[5].params[0]):a,C=ue?x(L[0].params[1]):a,X=le?x(L[1].params[1]):a,ie=ye?x(L[2].params[1]):a,de=ve?x(L[3].params[1]):a,Re=he?x(L[4].params[1]):a,Le=Me?x(L[5].params[1]):a,gr=L.map(function(ar){return G(ar.params,ar.fn)}),so=ue?gr[0]:r,j$=le?gr[1]:r,e_=ye?gr[2]:r,r_=ve?gr[3]:r,t_=he?gr[4]:r,n_=Me?gr[5]:r,a_=ue?L[0].params.length:-1,i_=le?L[1].params.length:-1,o_=ye?L[2].params.length:-1,s_=ve?L[3].params.length:-1,u_=he?L[4].params.length:-1,c_=Me?L[5].params.length:-1,f_=Ke?6:0,l_=L.length,m_=function(){for(var Dr=f_;Dr<l_;Dr++)if(fr[Dr](arguments))return gr[Dr].apply(this,arguments);return o.onMismatch(q,arguments,L)},uo=function ar(Dr,dt){return arguments.length===a_&&nr(Dr)&&C(dt)?so.apply(ar,arguments):arguments.length===i_&&jr(Dr)&&X(dt)?j$.apply(ar,arguments):arguments.length===o_&&kr(Dr)&&ie(dt)?e_.apply(ar,arguments):arguments.length===s_&&Tt(Dr)&&de(dt)?r_.apply(ar,arguments):arguments.length===u_&&Xe(Dr)&&Re(dt)?t_.apply(ar,arguments):arguments.length===c_&&Lt(Dr)&&Le(dt)?n_.apply(ar,arguments):m_.apply(ar,arguments)};try{Object.defineProperty(uo,"name",{value:q})}catch(ar){}return uo.signatures=H(L),uo}function K(q,P,Q){throw E(q,P,Q)}function te(q){return o.ignore.indexOf(q)===-1}function re(q){return q.trim()}function oe(q){return!!q}function ae(q){return q!==null}function ce(q){return q.types.length===0}function ee(q){return q.slice(0,q.length-1)}function xe(q){return q[q.length-1]}function Ne(q,P,Q){return Array.prototype.slice.call(q,P,Q)}function pe(q,P){return q.indexOf(P)!==-1}function be(q,P){for(var Q=0;Q<q.length;Q++)if(pe(P,q[Q]))return!0;return!1}function F(q,P){for(var Q=0;Q<q.length;Q++)if(P(q[Q]))return q[Q]}function Y(q){for(var P={},Q=0;Q<q.length;Q++)P[q[Q]]=!0;return Object.keys(P)}function k(q,P){return Array.prototype.concat.apply([],q.map(P))}function U(q){for(var P="",Q=0;Q<q.length;Q++){var L=q[Q];if((typeof L.signatures=="object"||typeof L.signature=="string")&&L.name!==""){if(P==="")P=L.name;else if(P!==L.name){var ue=new Error("Function names do not match (expected: "+P+", actual: "+L.name+")");throw ue.data={actual:L.name,expected:P},ue}}}return P}function J(q){var P,Q={};function L(ve,he){if(Q.hasOwnProperty(ve)&&he!==Q[ve])throw P=new Error('Signature "'+ve+'" is defined twice'),P.data={signature:ve},P}for(var ue=0;ue<q.length;ue++){var le=q[ue];if(typeof le.signatures=="object")for(var ye in le.signatures)le.signatures.hasOwnProperty(ye)&&(L(ye,le.signatures[ye]),Q[ye]=le.signatures[ye]);else if(typeof le.signature=="string")L(le.signature,le),Q[le.signature]=le;else throw P=new TypeError("Function is no typed-function (index: "+ue+")"),P.data={index:ue},P}return Q}return o=V("typed",{"string, Object":V,Object:function(q){var P=[];for(var Q in q)q.hasOwnProperty(Q)&&P.push(q[Q]);var L=U(P);return V(L,q)},"...Function":function(q){return V(U(q),J(q))},"string, ...Function":function(q,P){return V(q,J(P))}}),o.create=i,o.types=u,o.conversions=c,o.ignore=f,o.onMismatch=K,o.throwMismatchError=K,o.createError=E,o.convert=h,o.find=v,o.addType=function(q,P){if(!q||typeof q.name!="string"||typeof q.test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");if(P!==!1){for(var Q=0;Q<o.types.length;Q++)if(o.types[Q].name==="Object"){o.types.splice(Q,0,q);return}}o.types.push(q)},o.addConversion=function(q){if(!q||typeof q.from!="string"||typeof q.to!="string"||typeof q.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");o.conversions.push(q)},o}return i()})}(aa)),aa.exports}var Vp=Gp();const po=na(Vp);function Se(e){return typeof e=="boolean"?!0:isFinite(e)?e===Math.round(e):!1}var Bt=Math.sign||function(e){return e>0?1:e<0?-1:0},Zp=Math.log2||function(t){return Math.log(t)/Math.LN2},Xp=Math.log10||function(t){return Math.log(t)/Math.LN10},Yp=Math.log1p||function(e){return Math.log(e+1)},Wp=Math.cbrt||function(t){if(t===0)return t;var n=t<0,a;return n&&(t=-t),isFinite(t)?(a=Math.exp(Math.log(t)/3),a=(t/(a*a)+2*a)/3):a=t,n?-a:a},Jp=Math.expm1||function(t){return t>=2e-4||t<=-2e-4?Math.exp(t)-1:t+t*t/2+t*t*t/6};function ni(e,t,n){var a={2:"0b",8:"0o",16:"0x"},r=a[t],i="";if(n){if(n<1)throw new Error("size must be in greater than 0");if(!Se(n))throw new Error("size must be an integer");if(e>nn(2,n-1)-1||e<-nn(2,n-1))throw new Error("Value must be in range [-2^".concat(n-1,", 2^").concat(n-1,"-1]"));if(!Se(e))throw new Error("Value must be an integer");e<0&&(e=e+nn(2,n)),i="i".concat(n)}var u="";return e<0&&(e=-e,u="-"),"".concat(u).concat(r).concat(e.toString(t)).concat(i)}function Vt(e,t){if(typeof t=="function")return t(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var n="auto",a,r;if(t&&(t.notation&&(n=t.notation),$e(t)?a=t:$e(t.precision)&&(a=t.precision),t.wordSize&&(r=t.wordSize,typeof r!="number")))throw new Error('Option "wordSize" must be a number');switch(n){case"fixed":return vo(e,a);case"exponential":return ho(e,a);case"engineering":return Qp(e,a);case"bin":return ni(e,2,r);case"oct":return ni(e,8,r);case"hex":return ni(e,16,r);case"auto":return Kp(e,a,t&&t).replace(/((\.\d*?)(0+))($|e)/,function(){var i=arguments[2],u=arguments[4];return i!=="."?i+u:u});default:throw new Error('Unknown notation "'+n+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function ia(e){var t=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+e);var n=t[1],a=t[2],r=parseFloat(t[4]||"0"),i=a.indexOf(".");r+=i!==-1?i-1:a.length-1;var u=a.replace(".","").replace(/^0*/,function(l){return r-=l.length,""}).replace(/0*$/,"").split("").map(function(l){return parseInt(l)});return u.length===0&&(u.push(0),r++),{sign:n,coefficients:u,exponent:r}}function Qp(e,t){if(isNaN(e)||!isFinite(e))return String(e);var n=ia(e),a=oa(n,t),r=a.exponent,i=a.coefficients,u=r%3===0?r:r<0?r-3-r%3:r-r%3;if($e(t))for(;t>i.length||r-u+1>i.length;)i.push(0);else for(var l=Math.abs(r-u)-(i.length-1),f=0;f<l;f++)i.push(0);for(var c=Math.abs(r-u),o=1;c>0;)o++,c--;var s=i.slice(o).join(""),m=$e(t)&&s.length||s.match(/[1-9]/)?"."+s:"",p=i.slice(0,o).join("")+m+"e"+(r>=0?"+":"")+u.toString();return a.sign+p}function vo(e,t){if(isNaN(e)||!isFinite(e))return String(e);var n=ia(e),a=typeof t=="number"?oa(n,n.exponent+1+t):n,r=a.coefficients,i=a.exponent+1,u=i+(t||0);return r.length<u&&(r=r.concat(sn(u-r.length))),i<0&&(r=sn(-i+1).concat(r),i=1),i<r.length&&r.splice(i,0,i===0?"0.":"."),a.sign+r.join("")}function ho(e,t){if(isNaN(e)||!isFinite(e))return String(e);var n=ia(e),a=t?oa(n,t):n,r=a.coefficients,i=a.exponent;r.length<t&&(r=r.concat(sn(t-r.length)));var u=r.shift();return a.sign+u+(r.length>0?"."+r.join(""):"")+"e"+(i>=0?"+":"")+i}function Kp(e,t,n){if(isNaN(e)||!isFinite(e))return String(e);var a=n&&n.lowerExp!==void 0?n.lowerExp:-3,r=n&&n.upperExp!==void 0?n.upperExp:5,i=ia(e),u=t?oa(i,t):i;if(u.exponent<a||u.exponent>=r)return ho(e,t);var l=u.coefficients,f=u.exponent;l.length<t&&(l=l.concat(sn(t-l.length))),l=l.concat(sn(f-l.length+1+(l.length<t?t-l.length:0))),l=sn(-f).concat(l);var c=f>0?f:0;return c<l.length-1&&l.splice(c+1,0,"."),u.sign+l.join("")}function oa(e,t){for(var n={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},a=n.coefficients;t<=0;)a.unshift(0),n.exponent++,t++;if(a.length>t){var r=a.splice(t,a.length-t);if(r[0]>=5){var i=t-1;for(a[i]++;a[i]===10;)a.pop(),i===0&&(a.unshift(0),n.exponent++,i++),i--,a[i]++}}return n}function sn(e){for(var t=[],n=0;n<e;n++)t.push(0);return t}function jp(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var ev=Number.EPSILON||2220446049250313e-31;function Fr(e,t,n){if(n==null)return e===t;if(e===t)return!0;if(isNaN(e)||isNaN(t))return!1;if(isFinite(e)&&isFinite(t)){var a=Math.abs(e-t);return a<ev?!0:a<=Math.max(Math.abs(e),Math.abs(t))*n}return!1}var rv=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)},tv=Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},nv=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2},av=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2},iv=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2},ov=Math.tanh||function(e){var t=Math.exp(2*e);return(t-1)/(t+1)};function sv(e,t){var n=!0,a=t>0?!0:t<0?!1:1/t===1/0;return n^a?-e:e}function ai(e,t,n){var a=e.constructor,r=new a(2),i="";if(n){if(n<1)throw new Error("size must be in greater than 0");if(!Se(n))throw new Error("size must be an integer");if(e.greaterThan(r.pow(n-1).sub(1))||e.lessThan(r.pow(n-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(n-1,", 2^").concat(n-1,"-1]"));if(!e.isInteger())throw new Error("Value must be an integer");e.lessThan(0)&&(e=e.add(r.pow(n))),i="i".concat(n)}switch(t){case 2:return"".concat(e.toBinary()).concat(i);case 8:return"".concat(e.toOctal()).concat(i);case 16:return"".concat(e.toHexadecimal()).concat(i);default:throw new Error("Base ".concat(t," not supported "))}}function uv(e,t){if(typeof t=="function")return t(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var n="auto",a,r;if(t!==void 0&&(t.notation&&(n=t.notation),typeof t=="number"?a=t:t.precision&&(a=t.precision),t.wordSize&&(r=t.wordSize,typeof r!="number")))throw new Error('Option "wordSize" must be a number');switch(n){case"fixed":return fv(e,a);case"exponential":return go(e,a);case"engineering":return cv(e,a);case"bin":return ai(e,2,r);case"oct":return ai(e,8,r);case"hex":return ai(e,16,r);case"auto":{var i=t&&t.lowerExp!==void 0?t.lowerExp:-3,u=t&&t.upperExp!==void 0?t.upperExp:5;if(e.isZero())return"0";var l,f=e.toSignificantDigits(a),c=f.e;return c>=i&&c<u?l=f.toFixed():l=go(e,a),l.replace(/((\.\d*?)(0+))($|e)/,function(){var o=arguments[2],s=arguments[4];return o!=="."?o+s:s})}default:throw new Error('Unknown notation "'+n+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function cv(e,t){var n=e.e,a=n%3===0?n:n<0?n-3-n%3:n-n%3,r=e.mul(Math.pow(10,-a)),i=r.toPrecision(t);return i.indexOf("e")!==-1&&(i=r.toString()),i+"e"+(n>=0?"+":"")+a.toString()}function go(e,t){return t!==void 0?e.toExponential(t-1):e.toExponential()}function fv(e,t){return e.toFixed(t)}function lv(e,t){var n=e.length-t.length,a=e.length;return e.substring(n,a)===t}function Fe(e,t){var n=mv(e,t);return t&&typeof t=="object"&&"truncate"in t&&n.length>t.truncate?n.substring(0,t.truncate-3)+"...":n}function mv(e,t){if(typeof e=="number")return Vt(e,t);if(_e(e))return uv(e,t);if(pv(e))return!t||t.fraction!=="decimal"?e.s*e.n+"/"+e.d:e.toString();if(Array.isArray(e))return yo(e,t);if(Ir(e))return'"'+e+'"';if(typeof e=="function")return e.syntax?String(e.syntax):"function";if(e&&typeof e=="object"){if(typeof e.format=="function")return e.format(t);if(e&&e.toString(t)!=={}.toString())return e.toString(t);var n=Object.keys(e).map(a=>'"'+a+'": '+Fe(e[a],t));return"{"+n.join(", ")+"}"}return String(e)}function sa(e){for(var t=String(e),n="",a=0;a<t.length;){var r=t.charAt(a);r==="\\"?(n+=r,a++,r=t.charAt(a),(r===""||'"\\/bfnrtu'.indexOf(r)===-1)&&(n+="\\"),n+=r):r==='"'?n+='\\"':n+=r,a++}return'"'+n+'"'}function Zr(e){var t=String(e);return t=t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),t}function yo(e,t){if(Array.isArray(e)){for(var n="[",a=e.length,r=0;r<a;r++)r!==0&&(n+=", "),n+=yo(e[r],t);return n+="]",n}else return Fe(e,t)}function pv(e){return e&&typeof e=="object"&&typeof e.s=="number"&&typeof e.n=="number"&&typeof e.d=="number"||!1}function un(e,t){if(!Ir(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+je(e)+", index: 0)");if(!Ir(t))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+je(t)+", index: 1)");return e===t?0:e>t?1:-1}function ze(e,t,n){if(!(this instanceof ze))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=t,this.relation=n,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=new Error().stack}ze.prototype=new RangeError,ze.prototype.constructor=RangeError,ze.prototype.name="DimensionError",ze.prototype.isDimensionError=!0;function et(e,t,n){if(!(this instanceof et))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=n),this.min!==void 0&&this.index<this.min?this.message="Index out of range ("+this.index+" < "+this.min+")":this.max!==void 0&&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}et.prototype=new RangeError,et.prototype.constructor=RangeError,et.prototype.name="IndexError",et.prototype.isIndexError=!0;function Ue(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function xo(e,t,n){var a,r=e.length;if(r!==t[n])throw new ze(r,t[n]);if(n<t.length-1){var i=n+1;for(a=0;a<r;a++){var u=e[a];if(!Array.isArray(u))throw new ze(t.length-1,t.length,"<");xo(e[a],t,i)}}else for(a=0;a<r;a++)if(Array.isArray(e[a]))throw new ze(t.length+1,t.length,">")}function bo(e,t){var n=t.length===0;if(n){if(Array.isArray(e))throw new ze(e.length,0)}else xo(e,t,0)}function Je(e,t){if(!$e(e)||!Se(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||typeof t=="number"&&e>=t)throw new et(e,t)}function cn(e,t,n){if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(t.length===0)throw new Error("Resizing to scalar is not supported");t.forEach(function(r){if(!$e(r)||!Se(r)||r<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Fe(t)+")")});var a=n!==void 0?n:0;return ii(e,t,0,a),e}function ii(e,t,n,a){var r,i,u=e.length,l=t[n],f=Math.min(u,l);if(e.length=l,n<t.length-1){var c=n+1;for(r=0;r<f;r++)i=e[r],Array.isArray(i)||(i=[i],e[r]=i),ii(i,t,c,a);for(r=f;r<l;r++)i=[],e[r]=i,ii(i,t,c,a)}else{for(r=0;r<f;r++)for(;Array.isArray(e[r]);)e[r]=e[r][0];for(r=f;r<l;r++)e[r]=a}}function wo(e,t){var n=ke(e),a=n.length;if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(t.length===0)throw new ze(0,a,"!=");t=oi(t,a);var r=No(t);if(a!==r)throw new ze(r,a,"!=");try{return vv(n,t)}catch(i){throw i instanceof ze?new ze(r,a,"!="):i}}function oi(e,t){var n=No(e),a=e.slice(),r=-1,i=e.indexOf(r),u=e.indexOf(r,i+1)>=0;if(u)throw new Error("More than one wildcard in sizes");var l=i>=0,f=t%n===0;if(l)if(f)a[i]=-t/n;else throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-n);return a}function No(e){return e.reduce((t,n)=>t*n,1)}function vv(e,t){for(var n=e,a,r=t.length-1;r>0;r--){var i=t[r];a=[];for(var u=n.length/i,l=0;l<u;l++)a.push(n.slice(l*i,(l+1)*i));n=a}return n}function ua(e,t){for(var n=Ue(e);Array.isArray(e)&&e.length===1;)e=e[0],n.shift();for(var a=n.length;n[a-1]===1;)a--;return a<n.length&&(e=Mo(e,a,0),n.length=a),e}function Mo(e,t,n){var a,r;if(n<t){var i=n+1;for(a=0,r=e.length;a<r;a++)e[a]=Mo(e[a],t,i)}else for(;Array.isArray(e);)e=e[0];return e}function Ao(e,t,n,a){var r=a||Ue(e);if(n)for(var i=0;i<n;i++)e=[e],r.unshift(1);for(e=So(e,t,0);r.length<t;)r.push(1);return e}function So(e,t,n){var a,r;if(Array.isArray(e)){var i=n+1;for(a=0,r=e.length;a<r;a++)e[a]=So(e[a],t,i)}else for(var u=n;u<t;u++)e=[e];return e}function ke(e){if(!Array.isArray(e))return e;var t=[];return e.forEach(function n(a){Array.isArray(a)?a.forEach(n):t.push(a)}),t}function yt(e,t){return Array.prototype.map.call(e,t)}function ca(e,t){Array.prototype.forEach.call(e,t)}function Eo(e,t){if(Ue(e).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,t)}function fa(e,t){if(Ue(e).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,n=>t.test(n))}function Co(e,t){return Array.prototype.join.call(e,t)}function fn(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(e.length===0)return e;var t=[],n=0;t[0]={value:e[0],identifier:0};for(var a=1;a<e.length;a++)e[a]===e[a-1]?n++:n=0,t.push({value:e[a],identifier:n});return t}function la(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(e.length===0)return e;for(var t=[],n=0;n<e.length;n++)t.push(e[n].value);return t}function In(e,t){for(var n,a=0,r=0;r<e.length;r++){var i=e[r],u=Array.isArray(i);if(r===0&&u&&(a=i.length),u&&i.length!==a)return;var l=u?In(i,t):t(i);if(n===void 0)n=l;else if(n!==l)return"mixed"}return n}function R(e,t,n,a){function r(i){var u=Pp(i,t.map(gv));return hv(e,t,i),n(u)}return r.isFactory=!0,r.fn=e,r.dependencies=t.slice().sort(),a&&(r.meta=a),r}function hv(e,t,n){var a=t.filter(i=>!dv(i)).every(i=>n[i]!==void 0);if(!a){var r=t.filter(i=>n[i]===void 0);throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(r.map(i=>'"'.concat(i,'"')).join(", "),"."))}}function dv(e){return e&&e[0]==="?"}function gv(e){return e&&e[0]==="?"?e.slice(1):e}function Xr(e,t){if(Oo(e)&&si(e,t))return e[t];throw typeof e[t]=="function"&&ui(e,t)?new Error('Cannot access method "'+t+'" as a property'):new Error('No access to property "'+t+'"')}function ln(e,t,n){if(Oo(e)&&si(e,t))return e[t]=n,n;throw new Error('No access to property "'+t+'"')}function yv(e,t){return t in e}function si(e,t){return!e||typeof e!="object"?!1:Ae(bv,t)?!0:!(t in Object.prototype||t in Function.prototype)}function xv(e,t){if(!ui(e,t))throw new Error('No access to method "'+t+'"')}function ui(e,t){return e==null||typeof e[t]!="function"||Ae(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e)?!1:Ae(wv,t)?!0:!(t in Object.prototype||t in Function.prototype)}function Oo(e){return typeof e=="object"&&e&&e.constructor===Object}var bv={length:!0,name:!0},wv={toString:!0,valueOf:!0,toLocaleString:!0};class ci{constructor(t){this.wrappedObject=t}keys(){return Object.keys(this.wrappedObject)}get(t){return Xr(this.wrappedObject,t)}set(t,n){return ln(this.wrappedObject,t,n),this}has(t){return yv(this.wrappedObject,t)}}function xt(){return new Map}function fi(e){if(!e)return xt();if(ma(e))return e;if(ei(e))return new ci(e);throw new Error("createMap can create maps from objects or Maps")}function Nv(e){if(e instanceof ci)return e.wrappedObject;var t={};for(var n of e.keys()){var a=e.get(n);ln(t,n,a)}return t}function ma(e){return e?e instanceof Map||e instanceof ci||typeof e.set=="function"&&typeof e.get=="function"&&typeof e.keys=="function"&&typeof e.has=="function":!1}function Do(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];for(var r of n)if(r){if(ma(r))for(var i of r.keys())e.set(i,r.get(i));else if(ei(r))for(var u of Object.keys(r))e.set(u,r[u])}return e}var To=function(){return To=po.create,po},Mv=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],Av=R("typed",Mv,function(t){var{BigNumber:n,Complex:a,DenseMatrix:r,Fraction:i}=t,u=To();return u.types=[{name:"number",test:$e},{name:"Complex",test:Tr},{name:"BigNumber",test:_e},{name:"Fraction",test:xr},{name:"Unit",test:gt},{name:"string",test:Ir},{name:"Chain",test:ri},{name:"Array",test:Ye},{name:"Matrix",test:De},{name:"DenseMatrix",test:ea},{name:"SparseMatrix",test:kt},{name:"Range",test:ra},{name:"Index",test:Tn},{name:"boolean",test:Cp},{name:"ResultSet",test:lo},{name:"Help",test:ja},{name:"function",test:Op},{name:"Date",test:Dp},{name:"RegExp",test:Tp},{name:"null",test:Bp},{name:"undefined",test:$p},{name:"AccessorNode",test:Ht},{name:"ArrayNode",test:Vr},{name:"AssignmentNode",test:_p},{name:"BlockNode",test:Ip},{name:"ConditionalNode",test:qp},{name:"ConstantNode",test:We},{name:"FunctionNode",test:Gt},{name:"FunctionAssignmentNode",test:Bn},{name:"IndexNode",test:on},{name:"Node",test:Ze},{name:"ObjectNode",test:ta},{name:"OperatorNode",test:qr},{name:"ParenthesisNode",test:$n},{name:"RangeNode",test:Rp},{name:"SymbolNode",test:br},{name:"Map",test:ma},{name:"Object",test:ei}],u.conversions=[{from:"number",to:"BigNumber",convert:function(f){if(n||li(f),jp(f)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+f+"). Use function bignumber(x) to convert to BigNumber.");return new n(f)}},{from:"number",to:"Complex",convert:function(f){return a||pa(f),new a(f,0)}},{from:"number",to:"string",convert:function(f){return f+""}},{from:"BigNumber",to:"Complex",convert:function(f){return a||pa(f),new a(f.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(f){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(f){return a||pa(f),new a(f.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(f){i||mi(f);var c=new i(f);if(c.valueOf()!==f)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+f+"). Use function fraction(x) to convert to Fraction.");return c}},{from:"string",to:"number",convert:function(f){var c=Number(f);if(isNaN(c))throw new Error('Cannot convert "'+f+'" to a number');return c}},{from:"string",to:"BigNumber",convert:function(f){n||li(f);try{return new n(f)}catch(c){throw new Error('Cannot convert "'+f+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(f){i||mi(f);try{return new i(f)}catch(c){throw new Error('Cannot convert "'+f+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(f){a||pa(f);try{return new a(f)}catch(c){throw new Error('Cannot convert "'+f+'" to Complex')}}},{from:"boolean",to:"number",convert:function(f){return+f}},{from:"boolean",to:"BigNumber",convert:function(f){return n||li(f),new n(+f)}},{from:"boolean",to:"Fraction",convert:function(f){return i||mi(f),new i(+f)}},{from:"boolean",to:"string",convert:function(f){return String(f)}},{from:"Array",to:"Matrix",convert:function(f){return r||Sv(),new r(f)}},{from:"Matrix",to:"Array",convert:function(f){return f.valueOf()}}],u});function li(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function pa(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function Sv(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function mi(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var Ev="ResultSet",Cv=[],Ov=R(Ev,Cv,()=>{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});var mn=9e15,$t=1e9,pi="0123456789abcdef",va="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",ha="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",vi={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-mn,maxE:mn,crypto:!1},Bo,bt,Ie=!0,da="[DecimalError] ",_t=da+"Invalid argument: ",$o=da+"Precision limit exceeded",_o=da+"crypto unavailable",Io="[object Decimal]",Mr=Math.floor,dr=Math.pow,Dv=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Tv=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Bv=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,qo=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,rt=1e7,Te=7,$v=9007199254740991,_v=va.length-1,hi=ha.length-1,fe={toStringTag:Io};fe.absoluteValue=fe.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),Ce(e)},fe.ceil=function(){return Ce(new this.constructor(this),this.e+1,2)},fe.clampedTo=fe.clamp=function(e,t){var n,a=this,r=a.constructor;if(e=new r(e),t=new r(t),!e.s||!t.s)return new r(NaN);if(e.gt(t))throw Error(_t+t);return n=a.cmp(e),n<0?e:a.cmp(t)>0?t:new r(a)},fe.comparedTo=fe.cmp=function(e){var t,n,a,r,i=this,u=i.d,l=(e=new i.constructor(e)).d,f=i.s,c=e.s;if(!u||!l)return!f||!c?NaN:f!==c?f:u===l?0:!u^f<0?1:-1;if(!u[0]||!l[0])return u[0]?f:l[0]?-c:0;if(f!==c)return f;if(i.e!==e.e)return i.e>e.e^f<0?1:-1;for(a=u.length,r=l.length,t=0,n=a<r?a:r;t<n;++t)if(u[t]!==l[t])return u[t]>l[t]^f<0?1:-1;return a===r?0:a>r^f<0?1:-1},fe.cosine=fe.cos=function(){var e,t,n=this,a=n.constructor;return n.d?n.d[0]?(e=a.precision,t=a.rounding,a.precision=e+Math.max(n.e,n.sd())+Te,a.rounding=1,n=Iv(a,Lo(a,n)),a.precision=e,a.rounding=t,Ce(bt==2||bt==3?n.neg():n,e,t,!0)):new a(1):new a(NaN)},fe.cubeRoot=fe.cbrt=function(){var e,t,n,a,r,i,u,l,f,c,o=this,s=o.constructor;if(!o.isFinite()||o.isZero())return new s(o);for(Ie=!1,i=o.s*dr(o.s*o,1/3),!i||Math.abs(i)==1/0?(n=wr(o.d),e=o.e,(i=(e-n.length+1)%3)&&(n+=i==1||i==-2?"0":"00"),i=dr(n,1/3),e=Mr((e+1)/3)-(e%3==(e<0?-1:2)),i==1/0?n="5e"+e:(n=i.toExponential(),n=n.slice(0,n.indexOf("e")+1)+e),a=new s(n),a.s=o.s):a=new s(i.toString()),u=(e=s.precision)+3;;)if(l=a,f=l.times(l).times(l),c=f.plus(o),a=rr(c.plus(o).times(l),c.plus(f),u+2,1),wr(l.d).slice(0,u)===(n=wr(a.d)).slice(0,u))if(n=n.slice(u-3,u+1),n=="9999"||!r&&n=="4999"){if(!r&&(Ce(l,e+1,0),l.times(l).times(l).eq(o))){a=l;break}u+=4,r=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(Ce(a,e+1,1),t=!a.times(a).times(a).eq(o));break}return Ie=!0,Ce(a,e,s.rounding,t)},fe.decimalPlaces=fe.dp=function(){var e,t=this.d,n=NaN;if(t){if(e=t.length-1,n=(e-Mr(this.e/Te))*Te,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n},fe.dividedBy=fe.div=function(e){return rr(this,new this.constructor(e))},fe.dividedToIntegerBy=fe.divToInt=function(e){var t=this,n=t.constructor;return Ce(rr(t,new n(e),0,1,1),n.precision,n.rounding)},fe.equals=fe.eq=function(e){return this.cmp(e)===0},fe.floor=function(){return Ce(new this.constructor(this),this.e+1,3)},fe.greaterThan=fe.gt=function(e){return this.cmp(e)>0},fe.greaterThanOrEqualTo=fe.gte=function(e){var t=this.cmp(e);return t==1||t===0},fe.hyperbolicCosine=fe.cosh=function(){var e,t,n,a,r,i=this,u=i.constructor,l=new u(1);if(!i.isFinite())return new u(i.s?1/0:NaN);if(i.isZero())return l;n=u.precision,a=u.rounding,u.precision=n+Math.max(i.e,i.sd())+4,u.rounding=1,r=i.d.length,r<32?(e=Math.ceil(r/3),t=(1/wa(4,e)).toString()):(e=16,t="2.3283064365386962890625e-10"),i=pn(u,1,i.times(t),new u(1),!0);for(var f,c=e,o=new u(8);c--;)f=i.times(i),i=l.minus(f.times(o.minus(f.times(o))));return Ce(i,u.precision=n,u.rounding=a,!0)},fe.hyperbolicSine=fe.sinh=function(){var e,t,n,a,r=this,i=r.constructor;if(!r.isFinite()||r.isZero())return new i(r);if(t=i.precision,n=i.rounding,i.precision=t+Math.max(r.e,r.sd())+4,i.rounding=1,a=r.d.length,a<3)r=pn(i,2,r,r,!0);else{e=1.4*Math.sqrt(a),e=e>16?16:e|0,r=r.times(1/wa(5,e)),r=pn(i,2,r,r,!0);for(var u,l=new i(5),f=new i(16),c=new i(20);e--;)u=r.times(r),r=r.times(l.plus(u.times(f.times(u).plus(c))))}return i.precision=t,i.rounding=n,Ce(r,t,n,!0)},fe.hyperbolicTangent=fe.tanh=function(){var e,t,n=this,a=n.constructor;return n.isFinite()?n.isZero()?new a(n):(e=a.precision,t=a.rounding,a.precision=e+7,a.rounding=1,rr(n.sinh(),n.cosh(),a.precision=e,a.rounding=t)):new a(n.s)},fe.inverseCosine=fe.acos=function(){var e=this,t=e.constructor,n=e.abs().cmp(1),a=t.precision,r=t.rounding;return n!==-1?n===0?e.isNeg()?ut(t,a,r):new t(0):new t(NaN):e.isZero()?ut(t,a+4,r).times(.5):(t.precision=a+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=a,t.rounding=r,e.times(2))},fe.inverseHyperbolicCosine=fe.acosh=function(){var e,t,n=this,a=n.constructor;return n.lte(1)?new a(n.eq(1)?0:NaN):n.isFinite()?(e=a.precision,t=a.rounding,a.precision=e+Math.max(Math.abs(n.e),n.sd())+4,a.rounding=1,Ie=!1,n=n.times(n).minus(1).sqrt().plus(n),Ie=!0,a.precision=e,a.rounding=t,n.ln()):new a(n)},fe.inverseHyperbolicSine=fe.asinh=function(){var e,t,n=this,a=n.constructor;return!n.isFinite()||n.isZero()?new a(n):(e=a.precision,t=a.rounding,a.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,a.rounding=1,Ie=!1,n=n.times(n).plus(1).sqrt().plus(n),Ie=!0,a.precision=e,a.rounding=t,n.ln())},fe.inverseHyperbolicTangent=fe.atanh=function(){var e,t,n,a,r=this,i=r.constructor;return r.isFinite()?r.e>=0?new i(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(e=i.precision,t=i.rounding,a=r.sd(),Math.max(a,e)<2*-r.e-1?Ce(new i(r),e,t,!0):(i.precision=n=a-r.e,r=rr(r.plus(1),new i(1).minus(r),n+e,1),i.precision=e+4,i.rounding=1,r=r.ln(),i.precision=e,i.rounding=t,r.times(.5))):new i(NaN)},fe.inverseSine=fe.asin=function(){var e,t,n,a,r=this,i=r.constructor;return r.isZero()?new i(r):(t=r.abs().cmp(1),n=i.precision,a=i.rounding,t!==-1?t===0?(e=ut(i,n+4,a).times(.5),e.s=r.s,e):new i(NaN):(i.precision=n+6,i.rounding=1,r=r.div(new i(1).minus(r.times(r)).sqrt().plus(1)).atan(),i.precision=n,i.rounding=a,r.times(2)))},fe.inverseTangent=fe.atan=function(){var e,t,n,a,r,i,u,l,f,c=this,o=c.constructor,s=o.precision,m=o.rounding;if(c.isFinite()){if(c.isZero())return new o(c);if(c.abs().eq(1)&&s+4<=hi)return u=ut(o,s+4,m).times(.25),u.s=c.s,u}else{if(!c.s)return new o(NaN);if(s+4<=hi)return u=ut(o,s+4,m).times(.5),u.s=c.s,u}for(o.precision=l=s+10,o.rounding=1,n=Math.min(28,l/Te+2|0),e=n;e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(Ie=!1,t=Math.ceil(l/Te),a=1,f=c.times(c),u=new o(c),r=c;e!==-1;)if(r=r.times(f),i=u.minus(r.div(a+=2)),r=r.times(f),u=i.plus(r.div(a+=2)),u.d[t]!==void 0)for(e=t;u.d[e]===i.d[e]&&e--;);return n&&(u=u.times(2<<n-1)),Ie=!0,Ce(u,o.precision=s,o.rounding=m,!0)},fe.isFinite=function(){return!!this.d},fe.isInteger=fe.isInt=function(){return!!this.d&&Mr(this.e/Te)>this.d.length-2},fe.isNaN=function(){return!this.s},fe.isNegative=fe.isNeg=function(){return this.s<0},fe.isPositive=fe.isPos=function(){return this.s>0},fe.isZero=function(){return!!this.d&&this.d[0]===0},fe.lessThan=fe.lt=function(e){return this.cmp(e)<0},fe.lessThanOrEqualTo=fe.lte=function(e){return this.cmp(e)<1},fe.logarithm=fe.log=function(e){var t,n,a,r,i,u,l,f,c=this,o=c.constructor,s=o.precision,m=o.rounding,p=5;if(e==null)e=new o(10),t=!0;else{if(e=new o(e),n=e.d,e.s<0||!n||!n[0]||e.eq(1))return new o(NaN);t=e.eq(10)}if(n=c.d,c.s<0||!n||!n[0]||c.eq(1))return new o(n&&!n[0]?-1/0:c.s!=1?NaN:n?0:1/0);if(t)if(n.length>1)i=!0;else{for(r=n[0];r%10===0;)r/=10;i=r!==1}if(Ie=!1,l=s+p,u=qt(c,l),a=t?xa(o,l+10):qt(e,l),f=rr(u,a,l,1),qn(f.d,r=s,m))do if(l+=10,u=qt(c,l),a=t?xa(o,l+10):qt(e,l),f=rr(u,a,l,1),!i){+wr(f.d).slice(r+1,r+15)+1==1e14&&(f=Ce(f,s+1,0));break}while(qn(f.d,r+=10,m));return Ie=!0,Ce(f,s,m)},fe.minus=fe.sub=function(e){var t,n,a,r,i,u,l,f,c,o,s,m,p=this,v=p.constructor;if(e=new v(e),!p.d||!e.d)return!p.s||!e.s?e=new v(NaN):p.d?e.s=-e.s:e=new v(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(c=p.d,m=e.d,l=v.precision,f=v.rounding,!c[0]||!m[0]){if(m[0])e.s=-e.s;else if(c[0])e=new v(p);else return new v(f===3?-0:0);return Ie?Ce(e,l,f):e}if(n=Mr(e.e/Te),o=Mr(p.e/Te),c=c.slice(),i=o-n,i){for(s=i<0,s?(t=c,i=-i,u=m.length):(t=m,n=o,u=c.length),a=Math.max(Math.ceil(l/Te),u)+2,i>a&&(i=a,t.length=1),t.reverse(),a=i;a--;)t.push(0);t.reverse()}else{for(a=c.length,u=m.length,s=a<u,s&&(u=a),a=0;a<u;a++)if(c[a]!=m[a]){s=c[a]<m[a];break}i=0}for(s&&(t=c,c=m,m=t,e.s=-e.s),u=c.length,a=m.length-u;a>0;--a)c[u++]=0;for(a=m.length;a>i;){if(c[--a]<m[a]){for(r=a;r&&c[--r]===0;)c[r]=rt-1;--c[r],c[a]+=rt}c[a]-=m[a]}for(;c[--u]===0;)c.pop();for(;c[0]===0;c.shift())--n;return c[0]?(e.d=c,e.e=ya(c,n),Ie?Ce(e,l,f):e):new v(f===3?-0:0)},fe.modulo=fe.mod=function(e){var t,n=this,a=n.constructor;return e=new a(e),!n.d||!e.s||e.d&&!e.d[0]?new a(NaN):!e.d||n.d&&!n.d[0]?Ce(new a(n),a.precision,a.rounding):(Ie=!1,a.modulo==9?(t=rr(n,e.abs(),0,3,1),t.s*=e.s):t=rr(n,e,0,a.modulo,1),t=t.times(e),Ie=!0,n.minus(t))},fe.naturalExponential=fe.exp=function(){return di(this)},fe.naturalLogarithm=fe.ln=function(){return qt(this)},fe.negated=fe.neg=function(){var e=new this.constructor(this);return e.s=-e.s,Ce(e)},fe.plus=fe.add=function(e){var t,n,a,r,i,u,l,f,c,o,s=this,m=s.constructor;if(e=new m(e),!s.d||!e.d)return!s.s||!e.s?e=new m(NaN):s.d||(e=new m(e.d||s.s===e.s?s:NaN)),e;if(s.s!=e.s)return e.s=-e.s,s.minus(e);if(c=s.d,o=e.d,l=m.precision,f=m.rounding,!c[0]||!o[0])return o[0]||(e=new m(s)),Ie?Ce(e,l,f):e;if(i=Mr(s.e/Te),a=Mr(e.e/Te),c=c.slice(),r=i-a,r){for(r<0?(n=c,r=-r,u=o.length):(n=o,a=i,u=c.length),i=Math.ceil(l/Te),u=i>u?i+1:u+1,r>u&&(r=u,n.length=1),n.reverse();r--;)n.push(0);n.reverse()}for(u=c.length,r=o.length,u-r<0&&(r=u,n=o,o=c,c=n),t=0;r;)t=(c[--r]=c[r]+o[r]+t)/rt|0,c[r]%=rt;for(t&&(c.unshift(t),++a),u=c.length;c[--u]==0;)c.pop();return e.d=c,e.e=ya(c,a),Ie?Ce(e,l,f):e},fe.precision=fe.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(_t+e);return n.d?(t=Ro(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},fe.round=function(){var e=this,t=e.constructor;return Ce(new t(e),e.e+1,t.rounding)},fe.sine=fe.sin=function(){var e,t,n=this,a=n.constructor;return n.isFinite()?n.isZero()?new a(n):(e=a.precision,t=a.rounding,a.precision=e+Math.max(n.e,n.sd())+Te,a.rounding=1,n=Rv(a,Lo(a,n)),a.precision=e,a.rounding=t,Ce(bt>2?n.neg():n,e,t,!0)):new a(NaN)},fe.squareRoot=fe.sqrt=function(){var e,t,n,a,r,i,u=this,l=u.d,f=u.e,c=u.s,o=u.constructor;if(c!==1||!l||!l[0])return new o(!c||c<0&&(!l||l[0])?NaN:l?u:1/0);for(Ie=!1,c=Math.sqrt(+u),c==0||c==1/0?(t=wr(l),(t.length+f)%2==0&&(t+="0"),c=Math.sqrt(t),f=Mr((f+1)/2)-(f<0||f%2),c==1/0?t="5e"+f:(t=c.toExponential(),t=t.slice(0,t.indexOf("e")+1)+f),a=new o(t)):a=new o(c.toString()),n=(f=o.precision)+3;;)if(i=a,a=i.plus(rr(u,i,n+2,1)).times(.5),wr(i.d).slice(0,n)===(t=wr(a.d)).slice(0,n))if(t=t.slice(n-3,n+1),t=="9999"||!r&&t=="4999"){if(!r&&(Ce(i,f+1,0),i.times(i).eq(u))){a=i;break}n+=4,r=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Ce(a,f+1,1),e=!a.times(a).eq(u));break}return Ie=!0,Ce(a,f,o.rounding,e)},fe.tangent=fe.tan=function(){var e,t,n=this,a=n.constructor;return n.isFinite()?n.isZero()?new a(n):(e=a.precision,t=a.rounding,a.precision=e+10,a.rounding=1,n=n.sin(),n.s=1,n=rr(n,new a(1).minus(n.times(n)).sqrt(),e+10,0),a.precision=e,a.rounding=t,Ce(bt==2||bt==4?n.neg():n,e,t,!0)):new a(NaN)},fe.times=fe.mul=function(e){var t,n,a,r,i,u,l,f,c,o=this,s=o.constructor,m=o.d,p=(e=new s(e)).d;if(e.s*=o.s,!m||!m[0]||!p||!p[0])return new s(!e.s||m&&!m[0]&&!p||p&&!p[0]&&!m?NaN:!m||!p?e.s/0:e.s*0);for(n=Mr(o.e/Te)+Mr(e.e/Te),f=m.length,c=p.length,f<c&&(i=m,m=p,p=i,u=f,f=c,c=u),i=[],u=f+c,a=u;a--;)i.push(0);for(a=c;--a>=0;){for(t=0,r=f+a;r>a;)l=i[r]+p[a]*m[r-a-1]+t,i[r--]=l%rt|0,t=l/rt|0;i[r]=(i[r]+t)%rt|0}for(;!i[--u];)i.pop();return t?++n:i.shift(),e.d=i,e.e=ya(i,n),Ie?Ce(e,s.precision,s.rounding):e},fe.toBinary=function(e,t){return gi(this,2,e,t)},fe.toDecimalPlaces=fe.toDP=function(e,t){var n=this,a=n.constructor;return n=new a(n),e===void 0?n:(Rr(e,0,$t),t===void 0?t=a.rounding:Rr(t,0,8),Ce(n,e+n.e+1,t))},fe.toExponential=function(e,t){var n,a=this,r=a.constructor;return e===void 0?n=st(a,!0):(Rr(e,0,$t),t===void 0?t=r.rounding:Rr(t,0,8),a=Ce(new r(a),e+1,t),n=st(a,!0,e+1)),a.isNeg()&&!a.isZero()?"-"+n:n},fe.toFixed=function(e,t){var n,a,r=this,i=r.constructor;return e===void 0?n=st(r):(Rr(e,0,$t),t===void 0?t=i.rounding:Rr(t,0,8),a=Ce(new i(r),e+r.e+1,t),n=st(a,!1,e+a.e+1)),r.isNeg()&&!r.isZero()?"-"+n:n},fe.toFraction=function(e){var t,n,a,r,i,u,l,f,c,o,s,m,p=this,v=p.d,h=p.constructor;if(!v)return new h(p);if(c=n=new h(1),a=f=new h(0),t=new h(a),i=t.e=Ro(v)-p.e-1,u=i%Te,t.d[0]=dr(10,u<0?Te+u:u),e==null)e=i>0?t:c;else{if(l=new h(e),!l.isInt()||l.lt(c))throw Error(_t+l);e=l.gt(t)?i>0?t:c:l}for(Ie=!1,l=new h(wr(v)),o=h.precision,h.precision=i=v.length*Te*2;s=rr(l,t,0,1,1),r=n.plus(s.times(a)),r.cmp(e)!=1;)n=a,a=r,r=c,c=f.plus(s.times(r)),f=r,r=t,t=l.minus(s.times(r)),l=r;return r=rr(e.minus(n),a,0,1,1),f=f.plus(r.times(c)),n=n.plus(r.times(a)),f.s=c.s=p.s,m=rr(c,a,i,1).minus(p).abs().cmp(rr(f,n,i,1).minus(p).abs())<1?[c,a]:[f,n],h.precision=o,Ie=!0,m},fe.toHexadecimal=fe.toHex=function(e,t){return gi(this,16,e,t)},fe.toNearest=function(e,t){var n=this,a=n.constructor;if(n=new a(n),e==null){if(!n.d)return n;e=new a(1),t=a.rounding}else{if(e=new a(e),t===void 0?t=a.rounding:Rr(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&(e.s=n.s),e}return e.d[0]?(Ie=!1,n=rr(n,e,0,t,1).times(e),Ie=!0,Ce(n)):(e.s=n.s,n=e),n},fe.toNumber=function(){return+this},fe.toOctal=function(e,t){return gi(this,8,e,t)},fe.toPower=fe.pow=function(e){var t,n,a,r,i,u,l=this,f=l.constructor,c=+(e=new f(e));if(!l.d||!e.d||!l.d[0]||!e.d[0])return new f(dr(+l,c));if(l=new f(l),l.eq(1))return l;if(a=f.precision,i=f.rounding,e.eq(1))return Ce(l,a,i);if(t=Mr(e.e/Te),t>=e.d.length-1&&(n=c<0?-c:c)<=$v)return r=Fo(f,l,n,a),e.s<0?new f(1).div(r):Ce(r,a,i);if(u=l.s,u<0){if(t<e.d.length-1)return new f(NaN);if((e.d[t]&1)==0&&(u=1),l.e==0&&l.d[0]==1&&l.d.length==1)return l.s=u,l}return n=dr(+l,c),t=n==0||!isFinite(n)?Mr(c*(Math.log("0."+wr(l.d))/Math.LN10+l.e+1)):new f(n+"").e,t>f.maxE+1||t<f.minE-1?new f(t>0?u/0:0):(Ie=!1,f.rounding=l.s=1,n=Math.min(12,(t+"").length),r=di(e.times(qt(l,a+n)),a),r.d&&(r=Ce(r,a+5,1),qn(r.d,a,i)&&(t=a+10,r=Ce(di(e.times(qt(l,t+n)),t),t+5,1),+wr(r.d).slice(a+1,a+15)+1==1e14&&(r=Ce(r,a+1,0)))),r.s=u,Ie=!0,f.rounding=i,Ce(r,a,i))},fe.toPrecision=function(e,t){var n,a=this,r=a.constructor;return e===void 0?n=st(a,a.e<=r.toExpNeg||a.e>=r.toExpPos):(Rr(e,1,$t),t===void 0?t=r.rounding:Rr(t,0,8),a=Ce(new r(a),e,t),n=st(a,e<=a.e||a.e<=r.toExpNeg,e)),a.isNeg()&&!a.isZero()?"-"+n:n},fe.toSignificantDigits=fe.toSD=function(e,t){var n=this,a=n.constructor;return e===void 0?(e=a.precision,t=a.rounding):(Rr(e,1,$t),t===void 0?t=a.rounding:Rr(t,0,8)),Ce(new a(n),e,t)},fe.toString=function(){var e=this,t=e.constructor,n=st(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n},fe.truncated=fe.trunc=function(){return Ce(new this.constructor(this),this.e+1,1)},fe.valueOf=fe.toJSON=function(){var e=this,t=e.constructor,n=st(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};function wr(e){var t,n,a,r=e.length-1,i="",u=e[0];if(r>0){for(i+=u,t=1;t<r;t++)a=e[t]+"",n=Te-a.length,n&&(i+=It(n)),i+=a;u=e[t],a=u+"",n=Te-a.length,n&&(i+=It(n))}else if(u===0)return"0";for(;u%10===0;)u/=10;return i+u}function Rr(e,t,n){if(e!==~~e||e<t||e>n)throw Error(_t+e)}function qn(e,t,n,a){var r,i,u,l;for(i=e[0];i>=10;i/=10)--t;return--t<0?(t+=Te,r=0):(r=Math.ceil((t+1)/Te),t%=Te),i=dr(10,Te-t),l=e[r]%i|0,a==null?t<3?(t==0?l=l/100|0:t==1&&(l=l/10|0),u=n<4&&l==99999||n>3&&l==49999||l==5e4||l==0):u=(n<4&&l+1==i||n>3&&l+1==i/2)&&(e[r+1]/i/100|0)==dr(10,t-2)-1||(l==i/2||l==0)&&(e[r+1]/i/100|0)==0:t<4?(t==0?l=l/1e3|0:t==1?l=l/100|0:t==2&&(l=l/10|0),u=(a||n<4)&&l==9999||!a&&n>3&&l==4999):u=((a||n<4)&&l+1==i||!a&&n>3&&l+1==i/2)&&(e[r+1]/i/1e3|0)==dr(10,t-3)-1,u}function ga(e,t,n){for(var a,r=[0],i,u=0,l=e.length;u<l;){for(i=r.length;i--;)r[i]*=t;for(r[0]+=pi.indexOf(e.charAt(u++)),a=0;a<r.length;a++)r[a]>n-1&&(r[a+1]===void 0&&(r[a+1]=0),r[a+1]+=r[a]/n|0,r[a]%=n)}return r.reverse()}function Iv(e,t){var n,a,r;if(t.isZero())return t;a=t.d.length,a<32?(n=Math.ceil(a/3),r=(1/wa(4,n)).toString()):(n=16,r="2.3283064365386962890625e-10"),e.precision+=n,t=pn(e,1,t.times(r),new e(1));for(var i=n;i--;){var u=t.times(t);t=u.times(u).minus(u).times(8).plus(1)}return e.precision-=n,t}var rr=function(){function e(a,r,i){var u,l=0,f=a.length;for(a=a.slice();f--;)u=a[f]*r+l,a[f]=u%i|0,l=u/i|0;return l&&a.unshift(l),a}function t(a,r,i,u){var l,f;if(i!=u)f=i>u?1:-1;else for(l=f=0;l<i;l++)if(a[l]!=r[l]){f=a[l]>r[l]?1:-1;break}return f}function n(a,r,i,u){for(var l=0;i--;)a[i]-=l,l=a[i]<r[i]?1:0,a[i]=l*u+a[i]-r[i];for(;!a[0]&&a.length>1;)a.shift()}return function(a,r,i,u,l,f){var c,o,s,m,p,v,h,b,w,N,g,y,x,d,A,S,O,M,$,E,_=a.constructor,z=a.s==r.s?1:-1,I=a.d,T=r.d;if(!I||!I[0]||!T||!T[0])return new _(!a.s||!r.s||(I?T&&I[0]==T[0]:!T)?NaN:I&&I[0]==0||!T?z*0:z/0);for(f?(p=1,o=a.e-r.e):(f=rt,p=Te,o=Mr(a.e/p)-Mr(r.e/p)),$=T.length,O=I.length,w=new _(z),N=w.d=[],s=0;T[s]==(I[s]||0);s++);if(T[s]>(I[s]||0)&&o--,i==null?(d=i=_.precision,u=_.rounding):l?d=i+(a.e-r.e)+1:d=i,d<0)N.push(1),v=!0;else{if(d=d/p+2|0,s=0,$==1){for(m=0,T=T[0],d++;(s<O||m)&&d--;s++)A=m*f+(I[s]||0),N[s]=A/T|0,m=A%T|0;v=m||s<O}else{for(m=f/(T[0]+1)|0,m>1&&(T=e(T,m,f),I=e(I,m,f),$=T.length,O=I.length),S=$,g=I.slice(0,$),y=g.length;y<$;)g[y++]=0;E=T.slice(),E.unshift(0),M=T[0],T[1]>=f/2&&++M;do m=0,c=t(T,g,$,y),c<0?(x=g[0],$!=y&&(x=x*f+(g[1]||0)),m=x/M|0,m>1?(m>=f&&(m=f-1),h=e(T,m,f),b=h.length,y=g.length,c=t(h,g,b,y),c==1&&(m--,n(h,$<b?E:T,b,f))):(m==0&&(c=m=1),h=T.slice()),b=h.length,b<y&&h.unshift(0),n(g,h,y,f),c==-1&&(y=g.length,c=t(T,g,$,y),c<1&&(m++,n(g,$<y?E:T,y,f))),y=g.length):c===0&&(m++,g=[0]),N[s++]=m,c&&g[0]?g[y++]=I[S]||0:(g=[I[S]],y=1);while((S++<O||g[0]!==void 0)&&d--);v=g[0]!==void 0}N[0]||N.shift()}if(p==1)w.e=o,Bo=v;else{for(s=1,m=N[0];m>=10;m/=10)s++;w.e=s+o*p-1,Ce(w,l?i+w.e+1:i,u,v)}return w}}();function Ce(e,t,n,a){var r,i,u,l,f,c,o,s,m,p=e.constructor;e:if(t!=null){if(s=e.d,!s)return e;for(r=1,l=s[0];l>=10;l/=10)r++;if(i=t-r,i<0)i+=Te,u=t,o=s[m=0],f=o/dr(10,r-u-1)%10|0;else if(m=Math.ceil((i+1)/Te),l=s.length,m>=l)if(a){for(;l++<=m;)s.push(0);o=f=0,r=1,i%=Te,u=i-Te+1}else break e;else{for(o=l=s[m],r=1;l>=10;l/=10)r++;i%=Te,u=i-Te+r,f=u<0?0:o/dr(10,r-u-1)%10|0}if(a=a||t<0||s[m+1]!==void 0||(u<0?o:o%dr(10,r-u-1)),c=n<4?(f||a)&&(n==0||n==(e.s<0?3:2)):f>5||f==5&&(n==4||a||n==6&&(i>0?u>0?o/dr(10,r-u):0:s[m-1])%10&1||n==(e.s<0?8:7)),t<1||!s[0])return s.length=0,c?(t-=e.e+1,s[0]=dr(10,(Te-t%Te)%Te),e.e=-t||0):s[0]=e.e=0,e;if(i==0?(s.length=m,l=1,m--):(s.length=m+1,l=dr(10,Te-i),s[m]=u>0?(o/dr(10,r-u)%dr(10,u)|0)*l:0),c)for(;;)if(m==0){for(i=1,u=s[0];u>=10;u/=10)i++;for(u=s[0]+=l,l=1;u>=10;u/=10)l++;i!=l&&(e.e++,s[0]==rt&&(s[0]=1));break}else{if(s[m]+=l,s[m]!=rt)break;s[m--]=0,l=1}for(i=s.length;s[--i]===0;)s.pop()}return Ie&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function st(e,t,n){if(!e.isFinite())return Uo(e);var a,r=e.e,i=wr(e.d),u=i.length;return t?(n&&(a=n-u)>0?i=i.charAt(0)+"."+i.slice(1)+It(a):u>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(e.e<0?"e":"e+")+e.e):r<0?(i="0."+It(-r-1)+i,n&&(a=n-u)>0&&(i+=It(a))):r>=u?(i+=It(r+1-u),n&&(a=n-r-1)>0&&(i=i+"."+It(a))):((a=r+1)<u&&(i=i.slice(0,a)+"."+i.slice(a)),n&&(a=n-u)>0&&(r+1===u&&(i+="."),i+=It(a))),i}function ya(e,t){var n=e[0];for(t*=Te;n>=10;n/=10)t++;return t}function xa(e,t,n){if(t>_v)throw Ie=!0,n&&(e.precision=n),Error($o);return Ce(new e(va),t,1,!0)}function ut(e,t,n){if(t>hi)throw Error($o);return Ce(new e(ha),t,n,!0)}function Ro(e){var t=e.length-1,n=t*Te+1;if(t=e[t],t){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function It(e){for(var t="";e--;)t+="0";return t}function Fo(e,t,n,a){var r,i=new e(1),u=Math.ceil(a/Te+4);for(Ie=!1;;){if(n%2&&(i=i.times(t),ko(i.d,u)&&(r=!0)),n=Mr(n/2),n===0){n=i.d.length-1,r&&i.d[n]===0&&++i.d[n];break}t=t.times(t),ko(t.d,u)}return Ie=!0,i}function zo(e){return e.d[e.d.length-1]&1}function Po(e,t,n){for(var a,r,i=new e(t[0]),u=0;++u<t.length;){if(r=new e(t[u]),!r.s){i=r;break}a=i.cmp(r),(a===n||a===0&&i.s===n)&&(i=r)}return i}function di(e,t){var n,a,r,i,u,l,f,c=0,o=0,s=0,m=e.constructor,p=m.rounding,v=m.precision;if(!e.d||!e.d[0]||e.e>17)return new m(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(t==null?(Ie=!1,f=v):f=t,l=new m(.03125);e.e>-2;)e=e.times(l),s+=5;for(a=Math.log(dr(2,s))/Math.LN10*2+5|0,f+=a,n=i=u=new m(1),m.precision=f;;){if(i=Ce(i.times(e),f,1),n=n.times(++o),l=u.plus(rr(i,n,f,1)),wr(l.d).slice(0,f)===wr(u.d).slice(0,f)){for(r=s;r--;)u=Ce(u.times(u),f,1);if(t==null)if(c<3&&qn(u.d,f-a,p,c))m.precision=f+=10,n=i=l=new m(1),o=0,c++;else return Ce(u,m.precision=v,p,Ie=!0);else return m.precision=v,u}u=l}}function qt(e,t){var n,a,r,i,u,l,f,c,o,s,m,p=1,v=10,h=e,b=h.d,w=h.constructor,N=w.rounding,g=w.precision;if(h.s<0||!b||!b[0]||!h.e&&b[0]==1&&b.length==1)return new w(b&&!b[0]?-1/0:h.s!=1?NaN:b?0:h);if(t==null?(Ie=!1,o=g):o=t,w.precision=o+=v,n=wr(b),a=n.charAt(0),Math.abs(i=h.e)<15e14){for(;a<7&&a!=1||a==1&&n.charAt(1)>3;)h=h.times(e),n=wr(h.d),a=n.charAt(0),p++;i=h.e,a>1?(h=new w("0."+n),i++):h=new w(a+"."+n.slice(1))}else return c=xa(w,o+2,g).times(i+""),h=qt(new w(a+"."+n.slice(1)),o-v).plus(c),w.precision=g,t==null?Ce(h,g,N,Ie=!0):h;for(s=h,f=u=h=rr(h.minus(1),h.plus(1),o,1),m=Ce(h.times(h),o,1),r=3;;){if(u=Ce(u.times(m),o,1),c=f.plus(rr(u,new w(r),o,1)),wr(c.d).slice(0,o)===wr(f.d).slice(0,o))if(f=f.times(2),i!==0&&(f=f.plus(xa(w,o+2,g).times(i+""))),f=rr(f,new w(p),o,1),t==null)if(qn(f.d,o-v,N,l))w.precision=o+=v,c=u=h=rr(s.minus(1),s.plus(1),o,1),m=Ce(h.times(h),o,1),r=l=1;else return Ce(f,w.precision=g,N,Ie=!0);else return w.precision=g,f;f=c,r+=2}}function Uo(e){return String(e.s*e.s/0)}function ba(e,t){var n,a,r;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(a=t.search(/e/i))>0?(n<0&&(n=a),n+=+t.slice(a+1),t=t.substring(0,a)):n<0&&(n=t.length),a=0;t.charCodeAt(a)===48;a++);for(r=t.length;t.charCodeAt(r-1)===48;--r);if(t=t.slice(a,r),t){if(r-=a,e.e=n=n-a-1,e.d=[],a=(n+1)%Te,n<0&&(a+=Te),a<r){for(a&&e.d.push(+t.slice(0,a)),r-=Te;a<r;)e.d.push(+t.slice(a,a+=Te));t=t.slice(a),a=Te-t.length}else a-=r;for(;a--;)t+="0";e.d.push(+t),Ie&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function qv(e,t){var n,a,r,i,u,l,f,c,o;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),qo.test(t))return ba(e,t)}else if(t==="Infinity"||t==="NaN")return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(Tv.test(t))n=16,t=t.toLowerCase();else if(Dv.test(t))n=2;else if(Bv.test(t))n=8;else throw Error(_t+t);for(i=t.search(/p/i),i>0?(f=+t.slice(i+1),t=t.substring(2,i)):t=t.slice(2),i=t.indexOf("."),u=i>=0,a=e.constructor,u&&(t=t.replace(".",""),l=t.length,i=l-i,r=Fo(a,new a(n),i,i*2)),c=ga(t,n,rt),o=c.length-1,i=o;c[i]===0;--i)c.pop();return i<0?new a(e.s*0):(e.e=ya(c,o),e.d=c,Ie=!1,u&&(e=rr(e,r,l*4)),f&&(e=e.times(Math.abs(f)<54?dr(2,f):Rt.pow(2,f))),Ie=!0,e)}function Rv(e,t){var n,a=t.d.length;if(a<3)return t.isZero()?t:pn(e,2,t,t);n=1.4*Math.sqrt(a),n=n>16?16:n|0,t=t.times(1/wa(5,n)),t=pn(e,2,t,t);for(var r,i=new e(5),u=new e(16),l=new e(20);n--;)r=t.times(t),t=t.times(i.plus(r.times(u.times(r).minus(l))));return t}function pn(e,t,n,a,r){var i,u,l,f,c=e.precision,o=Math.ceil(c/Te);for(Ie=!1,f=n.times(n),l=new e(a);;){if(u=rr(l.times(f),new e(t++*t++),c,1),l=r?a.plus(u):a.minus(u),a=rr(u.times(f),new e(t++*t++),c,1),u=l.plus(a),u.d[o]!==void 0){for(i=o;u.d[i]===l.d[i]&&i--;);if(i==-1)break}i=l,l=a,a=u,u=i}return Ie=!0,u.d.length=o+1,u}function wa(e,t){for(var n=e;--t;)n*=e;return n}function Lo(e,t){var n,a=t.s<0,r=ut(e,e.precision,1),i=r.times(.5);if(t=t.abs(),t.lte(i))return bt=a?4:1,t;if(n=t.divToInt(r),n.isZero())bt=a?3:2;else{if(t=t.minus(n.times(r)),t.lte(i))return bt=zo(n)?a?2:3:a?4:1,t;bt=zo(n)?a?1:4:a?3:2}return t.minus(r).abs()}function gi(e,t,n,a){var r,i,u,l,f,c,o,s,m,p=e.constructor,v=n!==void 0;if(v?(Rr(n,1,$t),a===void 0?a=p.rounding:Rr(a,0,8)):(n=p.precision,a=p.rounding),!e.isFinite())o=Uo(e);else{for(o=st(e),u=o.indexOf("."),v?(r=2,t==16?n=n*4-3:t==8&&(n=n*3-2)):r=t,u>=0&&(o=o.replace(".",""),m=new p(1),m.e=o.length-u,m.d=ga(st(m),10,r),m.e=m.d.length),s=ga(o,10,r),i=f=s.length;s[--f]==0;)s.pop();if(!s[0])o=v?"0p+0":"0";else{if(u<0?i--:(e=new p(e),e.d=s,e.e=i,e=rr(e,m,n,a,0,r),s=e.d,i=e.e,c=Bo),u=s[n],l=r/2,c=c||s[n+1]!==void 0,c=a<4?(u!==void 0||c)&&(a===0||a===(e.s<0?3:2)):u>l||u===l&&(a===4||c||a===6&&s[n-1]&1||a===(e.s<0?8:7)),s.length=n,c)for(;++s[--n]>r-1;)s[n]=0,n||(++i,s.unshift(1));for(f=s.length;!s[f-1];--f);for(u=0,o="";u<f;u++)o+=pi.charAt(s[u]);if(v){if(f>1)if(t==16||t==8){for(u=t==16?4:3,--f;f%u;f++)o+="0";for(s=ga(o,r,t),f=s.length;!s[f-1];--f);for(u=1,o="1.";u<f;u++)o+=pi.charAt(s[u])}else o=o.charAt(0)+"."+o.slice(1);o=o+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)o="0"+o;o="0."+o}else if(++i>f)for(i-=f;i--;)o+="0";else i<f&&(o=o.slice(0,i)+"."+o.slice(i))}o=(t==16?"0x":t==2?"0b":t==8?"0o":"")+o}return e.s<0?"-"+o:o}function ko(e,t){if(e.length>t)return e.length=t,!0}function Fv(e){return new this(e).abs()}function zv(e){return new this(e).acos()}function Pv(e){return new this(e).acosh()}function Uv(e,t){return new this(e).plus(t)}function Lv(e){return new this(e).asin()}function kv(e){return new this(e).asinh()}function Hv(e){return new this(e).atan()}function Gv(e){return new this(e).atanh()}function Vv(e,t){e=new this(e),t=new this(t);var n,a=this.precision,r=this.rounding,i=a+4;return!e.s||!t.s?n=new this(NaN):!e.d&&!t.d?(n=ut(this,i,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?ut(this,a,r):new this(0),n.s=e.s):!e.d||t.isZero()?(n=ut(this,i,1).times(.5),n.s=e.s):t.s<0?(this.precision=i,this.rounding=1,n=this.atan(rr(e,t,i,1)),t=ut(this,i,1),this.precision=a,this.rounding=r,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(rr(e,t,i,1)),n}function Zv(e){return new this(e).cbrt()}function Xv(e){return Ce(e=new this(e),e.e+1,2)}function Yv(e,t,n){return new this(e).clamp(t,n)}function Wv(e){if(!e||typeof e!="object")throw Error(da+"Object expected");var t,n,a,r=e.defaults===!0,i=["precision",1,$t,"rounding",0,8,"toExpNeg",-mn,0,"toExpPos",0,mn,"maxE",0,mn,"minE",-mn,0,"modulo",0,9];for(t=0;t<i.length;t+=3)if(n=i[t],r&&(this[n]=vi[n]),(a=e[n])!==void 0)if(Mr(a)===a&&a>=i[t+1]&&a<=i[t+2])this[n]=a;else throw Error(_t+n+": "+a);if(n="crypto",r&&(this[n]=vi[n]),(a=e[n])!==void 0)if(a===!0||a===!1||a===0||a===1)if(a)if(typeof crypto!="undefined"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(_o);else this[n]=!1;else throw Error(_t+n+": "+a);return this}function Jv(e){return new this(e).cos()}function Qv(e){return new this(e).cosh()}function Ho(e){var t,n,a;function r(i){var u,l,f,c=this;if(!(c instanceof r))return new r(i);if(c.constructor=r,Go(i)){c.s=i.s,Ie?!i.d||i.e>r.maxE?(c.e=NaN,c.d=null):i.e<r.minE?(c.e=0,c.d=[0]):(c.e=i.e,c.d=i.d.slice()):(c.e=i.e,c.d=i.d?i.d.slice():i.d);return}if(f=typeof i,f==="number"){if(i===0){c.s=1/i<0?-1:1,c.e=0,c.d=[0];return}if(i<0?(i=-i,c.s=-1):c.s=1,i===~~i&&i<1e7){for(u=0,l=i;l>=10;l/=10)u++;Ie?u>r.maxE?(c.e=NaN,c.d=null):u<r.minE?(c.e=0,c.d=[0]):(c.e=u,c.d=[i]):(c.e=u,c.d=[i]);return}if(i*0!==0){i||(c.s=NaN),c.e=NaN,c.d=null;return}return ba(c,i.toString())}if(f==="string")return(l=i.charCodeAt(0))===45?(i=i.slice(1),c.s=-1):(l===43&&(i=i.slice(1)),c.s=1),qo.test(i)?ba(c,i):qv(c,i);if(f==="bigint")return i<0?(i=-i,c.s=-1):c.s=1,ba(c,i.toString());throw Error(_t+i)}if(r.prototype=fe,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=Wv,r.clone=Ho,r.isDecimal=Go,r.abs=Fv,r.acos=zv,r.acosh=Pv,r.add=Uv,r.asin=Lv,r.asinh=kv,r.atan=Hv,r.atanh=Gv,r.atan2=Vv,r.cbrt=Zv,r.ceil=Xv,r.clamp=Yv,r.cos=Jv,r.cosh=Qv,r.div=Kv,r.exp=jv,r.floor=eh,r.hypot=rh,r.ln=th,r.log=nh,r.log10=ih,r.log2=ah,r.max=oh,r.min=sh,r.mod=uh,r.mul=ch,r.pow=fh,r.random=lh,r.round=mh,r.sign=ph,r.sin=vh,r.sinh=hh,r.sqrt=dh,r.sub=gh,r.sum=yh,r.tan=xh,r.tanh=bh,r.trunc=wh,e===void 0&&(e={}),e&&e.defaults!==!0)for(a=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<a.length;)e.hasOwnProperty(n=a[t++])||(e[n]=this[n]);return r.config(e),r}function Kv(e,t){return new this(e).div(t)}function jv(e){return new this(e).exp()}function eh(e){return Ce(e=new this(e),e.e+1,3)}function rh(){var e,t,n=new this(0);for(Ie=!1,e=0;e<arguments.length;)if(t=new this(arguments[e++]),t.d)n.d&&(n=n.plus(t.times(t)));else{if(t.s)return Ie=!0,new this(1/0);n=t}return Ie=!0,n.sqrt()}function Go(e){return e instanceof Rt||e&&e.toStringTag===Io||!1}function th(e){return new this(e).ln()}function nh(e,t){return new this(e).log(t)}function ah(e){return new this(e).log(2)}function ih(e){return new this(e).log(10)}function oh(){return Po(this,arguments,-1)}function sh(){return Po(this,arguments,1)}function uh(e,t){return new this(e).mod(t)}function ch(e,t){return new this(e).mul(t)}function fh(e,t){return new this(e).pow(t)}function lh(e){var t,n,a,r,i=0,u=new this(1),l=[];if(e===void 0?e=this.precision:Rr(e,1,$t),a=Math.ceil(e/Te),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(a));i<a;)r=t[i],r>=429e7?t[i]=crypto.getRandomValues(new Uint32Array(1))[0]:l[i++]=r%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(a*=4);i<a;)r=t[i]+(t[i+1]<<8)+(t[i+2]<<16)+((t[i+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(t,i):(l.push(r%1e7),i+=4);i=a/4}else throw Error(_o);else for(;i<a;)l[i++]=Math.random()*1e7|0;for(a=l[--i],e%=Te,a&&e&&(r=dr(10,Te-e),l[i]=(a/r|0)*r);l[i]===0;i--)l.pop();if(i<0)n=0,l=[0];else{for(n=-1;l[0]===0;n-=Te)l.shift();for(a=1,r=l[0];r>=10;r/=10)a++;a<Te&&(n-=Te-a)}return u.e=n,u.d=l,u}function mh(e){return Ce(e=new this(e),e.e+1,this.rounding)}function ph(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function vh(e){return new this(e).sin()}function hh(e){return new this(e).sinh()}function dh(e){return new this(e).sqrt()}function gh(e,t){return new this(e).sub(t)}function yh(){var e=0,t=arguments,n=new this(t[e]);for(Ie=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return Ie=!0,Ce(n,this.precision,this.rounding)}function xh(e){return new this(e).tan()}function bh(e){return new this(e).tanh()}function wh(e){return Ce(e=new this(e),e.e+1,1)}fe[Symbol.for("nodejs.util.inspect.custom")]=fe.toString,fe[Symbol.toStringTag]="Decimal";var Rt=fe.constructor=Ho(vi);va=new Rt(va),ha=new Rt(ha);var Nh="BigNumber",Mh=["?on","config"],Ah=R(Nh,Mh,e=>{var{on:t,config:n}=e,a=Rt.clone({precision:n.precision,modulo:Rt.EUCLID});return a.prototype=Object.create(a.prototype),a.prototype.type="BigNumber",a.prototype.isBigNumber=!0,a.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},a.fromJSON=function(r){return new a(r.value)},t&&t("config",function(r,i){r.precision!==i.precision&&a.config({precision:r.precision})}),a},{isClass:!0});const Ar=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:(Math.exp(e)+Math.exp(-e))*.5},Yr=Math.sinh||function(e){return Math.abs(e)<1e-9?e:(Math.exp(e)-Math.exp(-e))*.5},Sh=e=>{const t=Math.sin(.5*e);return-2*t*t},yi=function(e,t){return e=Math.abs(e),t=Math.abs(t),e<t&&([e,t]=[t,e]),e<1e8?Math.sqrt(e*e+t*t):(t/=e,e*Math.sqrt(1+t*t))},vn=function(){throw SyntaxError("Invalid Param")};function xi(e,t){const n=Math.abs(e),a=Math.abs(t);return e===0?Math.log(a):t===0?Math.log(n):n<3e3&&a<3e3?Math.log(e*e+t*t)*.5:(e=e*.5,t=t*.5,.5*Math.log(e*e+t*t)+Math.LN2)}const Eh={re:0,im:0},Zt=function(e,t){const n=Eh;if(e==null)n.re=n.im=0;else if(t!==void 0)n.re=e,n.im=t;else switch(typeof e){case"object":if("im"in e&&"re"in e)n.re=e.re,n.im=e.im;else if("abs"in e&&"arg"in e){if(!isFinite(e.abs)&&isFinite(e.arg))return ne.INFINITY;n.re=e.abs*Math.cos(e.arg),n.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!isFinite(e.r)&&isFinite(e.phi))return ne.INFINITY;n.re=e.r*Math.cos(e.phi),n.im=e.r*Math.sin(e.phi)}else e.length===2?(n.re=e[0],n.im=e[1]):vn();break;case"string":n.im=n.re=0;const a=e.replace(/_/g,"").match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g);let r=1,i=0;a===null&&vn();for(let u=0;u<a.length;u++){const l=a[u];l===" "||l===" "||l===`
9
+ `||(l==="+"?r++:l==="-"?i++:l==="i"||l==="I"?(r+i===0&&vn(),a[u+1]!==" "&&!isNaN(a[u+1])?(n.im+=parseFloat((i%2?"-":"")+a[u+1]),u++):n.im+=parseFloat((i%2?"-":"")+"1"),r=i=0):((r+i===0||isNaN(l))&&vn(),a[u+1]==="i"||a[u+1]==="I"?(n.im+=parseFloat((i%2?"-":"")+l),u++):n.re+=parseFloat((i%2?"-":"")+l),r=i=0))}r+i>0&&vn();break;case"number":n.im=0,n.re=e;break;default:vn()}return isNaN(n.re)||isNaN(n.im),n};function ne(e,t){if(!(this instanceof ne))return new ne(e,t);const n=Zt(e,t);this.re=n.re,this.im=n.im}ne.prototype={re:0,im:0,sign:function(){const e=yi(this.re,this.im);return new ne(this.re/e,this.im/e)},add:function(e,t){const n=Zt(e,t),a=this.isInfinite(),r=!(isFinite(n.re)&&isFinite(n.im));return a||r?a&&r?ne.NAN:ne.INFINITY:new ne(this.re+n.re,this.im+n.im)},sub:function(e,t){const n=Zt(e,t),a=this.isInfinite(),r=!(isFinite(n.re)&&isFinite(n.im));return a||r?a&&r?ne.NAN:ne.INFINITY:new ne(this.re-n.re,this.im-n.im)},mul:function(e,t){const n=Zt(e,t),a=this.isInfinite(),r=!(isFinite(n.re)&&isFinite(n.im)),i=this.re===0&&this.im===0,u=n.re===0&&n.im===0;return a&&u||r&&i?ne.NAN:a||r?ne.INFINITY:n.im===0&&this.im===0?new ne(this.re*n.re,0):new ne(this.re*n.re-this.im*n.im,this.re*n.im+this.im*n.re)},div:function(e,t){const n=Zt(e,t),a=this.isInfinite(),r=!(isFinite(n.re)&&isFinite(n.im)),i=this.re===0&&this.im===0,u=n.re===0&&n.im===0;if(i&&u||a&&r)return ne.NAN;if(u||a)return ne.INFINITY;if(i||r)return ne.ZERO;if(n.im===0)return new ne(this.re/n.re,this.im/n.re);if(Math.abs(n.re)<Math.abs(n.im)){const l=n.re/n.im,f=n.re*l+n.im;return new ne((this.re*l+this.im)/f,(this.im*l-this.re)/f)}else{const l=n.im/n.re,f=n.im*l+n.re;return new ne((this.re+this.im*l)/f,(this.im-this.re*l)/f)}},pow:function(e,t){const n=Zt(e,t),a=this.re===0&&this.im===0;if(n.re===0&&n.im===0)return ne.ONE;if(n.im===0){if(this.im===0&&this.re>0)return new ne(Math.pow(this.re,n.re),0);if(this.re===0)switch((n.re%4+4)%4){case 0:return new ne(Math.pow(this.im,n.re),0);case 1:return new ne(0,Math.pow(this.im,n.re));case 2:return new ne(-Math.pow(this.im,n.re),0);case 3:return new ne(0,-Math.pow(this.im,n.re))}}if(a&&n.re>0)return ne.ZERO;const i=Math.atan2(this.im,this.re),u=xi(this.re,this.im);let l=Math.exp(n.re*u-n.im*i),f=n.im*u+n.re*i;return new ne(l*Math.cos(f),l*Math.sin(f))},sqrt:function(){const e=this.re,t=this.im;if(t===0)return e>=0?new ne(Math.sqrt(e),0):new ne(0,Math.sqrt(-e));const n=yi(e,t);let a=Math.sqrt(.5*(n+Math.abs(e))),r=Math.abs(t)/(2*a);return e>=0?new ne(a,t<0?-r:r):new ne(r,t<0?-a:a)},exp:function(){const e=Math.exp(this.re);return this.im===0?new ne(e,0):new ne(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){const e=this.re,t=this.im;return new ne(Math.expm1(e)*Math.cos(t)+Sh(t),Math.exp(e)*Math.sin(t))},log:function(){const e=this.re,t=this.im;return t===0&&e>0?new ne(Math.log(e),0):new ne(xi(e,t),Math.atan2(t,e))},abs:function(){return yi(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){const e=this.re,t=this.im;return new ne(Math.sin(e)*Ar(t),Math.cos(e)*Yr(t))},cos:function(){const e=this.re,t=this.im;return new ne(Math.cos(e)*Ar(t),-Math.sin(e)*Yr(t))},tan:function(){const e=2*this.re,t=2*this.im,n=Math.cos(e)+Ar(t);return new ne(Math.sin(e)/n,Yr(t)/n)},cot:function(){const e=2*this.re,t=2*this.im,n=Math.cos(e)-Ar(t);return new ne(-Math.sin(e)/n,Yr(t)/n)},sec:function(){const e=this.re,t=this.im,n=.5*Ar(2*t)+.5*Math.cos(2*e);return new ne(Math.cos(e)*Ar(t)/n,Math.sin(e)*Yr(t)/n)},csc:function(){const e=this.re,t=this.im,n=.5*Ar(2*t)-.5*Math.cos(2*e);return new ne(Math.sin(e)*Ar(t)/n,-Math.cos(e)*Yr(t)/n)},asin:function(){const e=this.re,t=this.im,n=new ne(t*t-e*e+1,-2*e*t).sqrt(),a=new ne(n.re-t,n.im+e).log();return new ne(a.im,-a.re)},acos:function(){const e=this.re,t=this.im,n=new ne(t*t-e*e+1,-2*e*t).sqrt(),a=new ne(n.re-t,n.im+e).log();return new ne(Math.PI/2-a.im,a.re)},atan:function(){const e=this.re,t=this.im;if(e===0){if(t===1)return new ne(0,1/0);if(t===-1)return new ne(0,-1/0)}const n=e*e+(1-t)*(1-t),a=new ne((1-t*t-e*e)/n,-2*e/n).log();return new ne(-.5*a.im,.5*a.re)},acot:function(){const e=this.re,t=this.im;if(t===0)return new ne(Math.atan2(1,e),0);const n=e*e+t*t;return n!==0?new ne(e/n,-t/n).atan():new ne(e!==0?e/0:0,t!==0?-t/0:0).atan()},asec:function(){const e=this.re,t=this.im;if(e===0&&t===0)return new ne(0,1/0);const n=e*e+t*t;return n!==0?new ne(e/n,-t/n).acos():new ne(e!==0?e/0:0,t!==0?-t/0:0).acos()},acsc:function(){const e=this.re,t=this.im;if(e===0&&t===0)return new ne(Math.PI/2,1/0);const n=e*e+t*t;return n!==0?new ne(e/n,-t/n).asin():new ne(e!==0?e/0:0,t!==0?-t/0:0).asin()},sinh:function(){const e=this.re,t=this.im;return new ne(Yr(e)*Math.cos(t),Ar(e)*Math.sin(t))},cosh:function(){const e=this.re,t=this.im;return new ne(Ar(e)*Math.cos(t),Yr(e)*Math.sin(t))},tanh:function(){const e=2*this.re,t=2*this.im,n=Ar(e)+Math.cos(t);return new ne(Yr(e)/n,Math.sin(t)/n)},coth:function(){const e=2*this.re,t=2*this.im,n=Ar(e)-Math.cos(t);return new ne(Yr(e)/n,-Math.sin(t)/n)},csch:function(){const e=this.re,t=this.im,n=Math.cos(2*t)-Ar(2*e);return new ne(-2*Yr(e)*Math.cos(t)/n,2*Ar(e)*Math.sin(t)/n)},sech:function(){const e=this.re,t=this.im,n=Math.cos(2*t)+Ar(2*e);return new ne(2*Ar(e)*Math.cos(t)/n,-2*Yr(e)*Math.sin(t)/n)},asinh:function(){const e=this.re,t=this.im;if(t===0){if(e===0)return new ne(0,0);const i=Math.abs(e),u=Math.log(i+Math.sqrt(i*i+1));return new ne(e<0?-u:u,0)}const n=e*e-t*t+1,a=2*e*t,r=new ne(n,a).sqrt();return new ne(e+r.re,t+r.im).log()},acosh:function(){const e=this.re,t=this.im;if(t===0){if(e>1)return new ne(Math.log(e+Math.sqrt(e-1)*Math.sqrt(e+1)),0);if(e<-1){const r=Math.sqrt(e*e-1);return new ne(Math.log(-e+r),Math.PI)}return new ne(0,Math.acos(e))}const n=new ne(e-1,t).sqrt(),a=new ne(e+1,t).sqrt();return new ne(e+n.re*a.re-n.im*a.im,t+n.re*a.im+n.im*a.re).log()},atanh:function(){const e=this.re,t=this.im;if(t===0){if(e===0)return new ne(0,0);if(e===1)return new ne(1/0,0);if(e===-1)return new ne(-1/0,0);if(-1<e&&e<1)return new ne(.5*Math.log((1+e)/(1-e)),0);if(e>1){const f=(e+1)/(e-1);return new ne(.5*Math.log(f),-Math.PI/2)}const l=(1+e)/(1-e);return new ne(.5*Math.log(-l),Math.PI/2)}const n=1-e,a=1+e,r=n*n+t*t;if(r===0)return new ne(e!==-1?e/0:0,t!==0?t/0:0);const i=(a*n-t*t)/r,u=(t*n+a*t)/r;return new ne(xi(i,u)/2,Math.atan2(u,i)/2)},acoth:function(){const e=this.re,t=this.im;if(e===0&&t===0)return new ne(0,Math.PI/2);const n=e*e+t*t;return n!==0?new ne(e/n,-t/n).atanh():new ne(e!==0?e/0:0,t!==0?-t/0:0).atanh()},acsch:function(){const e=this.re,t=this.im;if(t===0){if(e===0)return new ne(1/0,0);const a=1/e;return new ne(Math.log(a+Math.sqrt(a*a+1)),0)}const n=e*e+t*t;return n!==0?new ne(e/n,-t/n).asinh():new ne(e!==0?e/0:0,t!==0?-t/0:0).asinh()},asech:function(){const e=this.re,t=this.im;if(this.isZero())return ne.INFINITY;const n=e*e+t*t;return n!==0?new ne(e/n,-t/n).acosh():new ne(e!==0?e/0:0,t!==0?-t/0:0).acosh()},inverse:function(){if(this.isZero())return ne.INFINITY;if(this.isInfinite())return ne.ZERO;const e=this.re,t=this.im,n=e*e+t*t;return new ne(e/n,-t/n)},conjugate:function(){return new ne(this.re,-this.im)},neg:function(){return new ne(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new ne(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new ne(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new ne(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){const n=Zt(e,t);return Math.abs(n.re-this.re)<=ne.EPSILON&&Math.abs(n.im-this.im)<=ne.EPSILON},clone:function(){return new ne(this.re,this.im)},toString:function(){let e=this.re,t=this.im,n="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<ne.EPSILON&&(e=0),Math.abs(t)<ne.EPSILON&&(t=0),t===0?n+e:(e!==0?(n+=e,n+=" ",t<0?(t=-t,n+="-"):n+="+",n+=" "):t<0&&(t=-t,n+="-"),t!==1&&(n+=t),n+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return this.im===0?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return this.im===0&&this.re===0},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!this.isFinite()}},ne.ZERO=new ne(0,0),ne.ONE=new ne(1,0),ne.I=new ne(0,1),ne.PI=new ne(Math.PI,0),ne.E=new ne(Math.E,0),ne.INFINITY=new ne(1/0,1/0),ne.NAN=new ne(NaN,NaN),ne.EPSILON=1e-15;var Ch="Complex",Oh=[],Dh=R(Ch,Oh,()=>(ne.prototype.type="Complex",ne.prototype.isComplex=!0,ne.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},ne.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},ne.prototype.format=function(e){var t="",n=this.im,a=this.re,r=Vt(this.re,e),i=Vt(this.im,e),u=$e(e)?e:e?e.precision:null;if(u!==null){var l=Math.pow(10,-u);Math.abs(a/n)<l&&(a=0),Math.abs(n/a)<l&&(n=0)}return n===0?t=r:a===0?n===1?t="i":n===-1?t="-i":t=i+"i":n<0?n===-1?t=r+" - i":t=r+" - "+i.substring(1)+"i":n===1?t=r+" + i":t=r+" + "+i+"i",t},ne.fromPolar=function(e){switch(arguments.length){case 1:{var t=arguments[0];if(typeof t=="object")return ne(t);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var n=arguments[0],a=arguments[1];if($e(n)){if(gt(a)&&a.hasBase("ANGLE")&&(a=a.toNumber("rad")),$e(a))return new ne({r:n,phi:a});throw new TypeError("Phi is not a number nor an angle unit.")}else throw new TypeError("Radius r is not a number.")}default:throw new SyntaxError("Wrong number of arguments in function fromPolar")}},ne.prototype.valueOf=ne.prototype.toString,ne.fromJSON=function(e){return new ne(e)},ne.compare=function(e,t){return e.re>t.re?1:e.re<t.re?-1:e.im>t.im?1:e.im<t.im?-1:0},ne),{isClass:!0});var Th=2e3,Ee={s:1,n:0,d:1};function wt(e,t){if(isNaN(e=parseInt(e,10)))throw Na();return e*t}function cr(e,t){if(t===0)throw bi();var n=Object.create(Pr.prototype);n.s=e<0?-1:1,e=e<0?-e:e;var a=hn(e,t);return n.n=e/a,n.d=t/a,n}function Vo(e){for(var t={},n=e,a=2,r=4;r<=n;){for(;n%a===0;)n/=a,t[a]=(t[a]||0)+1;r+=1+2*a++}return n!==e?n>1&&(t[n]=(t[n]||0)+1):t[e]=(t[e]||0)+1,t}var zr=function(e,t){var n=0,a=1,r=1,i=0,u=0,l=0,f=1,c=1,o=0,s=1,m=1,p=1,v=1e7,h;if(e!=null)if(t!==void 0){if(n=e,a=t,r=n*a,n%1!==0||a%1!==0)throw Ih()}else switch(typeof e){case"object":{if("d"in e&&"n"in e)n=e.n,a=e.d,"s"in e&&(n*=e.s);else if(0 in e)n=e[0],1 in e&&(a=e[1]);else throw Na();r=n*a;break}case"number":{if(e<0&&(r=e,e=-e),e%1===0)n=e;else if(e>0){for(e>=1&&(c=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)),e/=c);s<=v&&p<=v;)if(h=(o+m)/(s+p),e===h){s+p<=v?(n=o+m,a=s+p):p>s?(n=m,a=p):(n=o,a=s);break}else e>h?(o+=m,s+=p):(m+=o,p+=s),s>v?(n=m,a=p):(n=o,a=s);n*=c}else(isNaN(e)||isNaN(t))&&(a=n=NaN);break}case"string":{if(s=e.match(/\d+|./g),s===null)throw Na();if(s[o]==="-"?(r=-1,o++):s[o]==="+"&&o++,s.length===o+1?u=wt(s[o++],r):s[o+1]==="."||s[o]==="."?(s[o]!=="."&&(i=wt(s[o++],r)),o++,(o+1===s.length||s[o+1]==="("&&s[o+3]===")"||s[o+1]==="'"&&s[o+3]==="'")&&(u=wt(s[o],r),f=Math.pow(10,s[o].length),o++),(s[o]==="("&&s[o+2]===")"||s[o]==="'"&&s[o+2]==="'")&&(l=wt(s[o+1],r),c=Math.pow(10,s[o+1].length)-1,o+=3)):s[o+1]==="/"||s[o+1]===":"?(u=wt(s[o],r),f=wt(s[o+2],1),o+=3):s[o+3]==="/"&&s[o+1]===" "&&(i=wt(s[o],r),u=wt(s[o+2],r),f=wt(s[o+4],1),o+=5),s.length<=o){a=f*c,r=n=l+a*i+c*u;break}}default:throw Na()}if(a===0)throw bi();Ee.s=r<0?-1:1,Ee.n=Math.abs(n),Ee.d=Math.abs(a)};function Bh(e,t,n){for(var a=1;t>0;e=e*e%n,t>>=1)t&1&&(a=a*e%n);return a}function $h(e,t){for(;t%2===0;t/=2);for(;t%5===0;t/=5);if(t===1)return 0;for(var n=10%t,a=1;n!==1;a++)if(n=n*10%t,a>Th)return 0;return a}function _h(e,t,n){for(var a=1,r=Bh(10,n,t),i=0;i<300;i++){if(a===r)return i;a=a*10%t,r=r*10%t}return 0}function hn(e,t){if(!e)return t;if(!t)return e;for(;;){if(e%=t,!e)return t;if(t%=e,!t)return e}}function Pr(e,t){if(zr(e,t),this instanceof Pr)e=hn(Ee.d,Ee.n),this.s=Ee.s,this.n=Ee.n/e,this.d=Ee.d/e;else return cr(Ee.s*Ee.n,Ee.d)}var bi=function(){return new Error("Division by Zero")},Na=function(){return new Error("Invalid argument")},Ih=function(){return new Error("Parameters must be integer")};Pr.prototype={s:1,n:0,d:1,abs:function(){return cr(this.n,this.d)},neg:function(){return cr(-this.s*this.n,this.d)},add:function(e,t){return zr(e,t),cr(this.s*this.n*Ee.d+Ee.s*this.d*Ee.n,this.d*Ee.d)},sub:function(e,t){return zr(e,t),cr(this.s*this.n*Ee.d-Ee.s*this.d*Ee.n,this.d*Ee.d)},mul:function(e,t){return zr(e,t),cr(this.s*Ee.s*this.n*Ee.n,this.d*Ee.d)},div:function(e,t){return zr(e,t),cr(this.s*Ee.s*this.n*Ee.d,this.d*Ee.n)},clone:function(){return cr(this.s*this.n,this.d)},mod:function(e,t){if(isNaN(this.n)||isNaN(this.d))return new Pr(NaN);if(e===void 0)return cr(this.s*this.n%this.d,1);if(zr(e,t),Ee.n===0&&this.d===0)throw bi();return cr(this.s*(Ee.d*this.n)%(Ee.n*this.d),Ee.d*this.d)},gcd:function(e,t){return zr(e,t),cr(hn(Ee.n,this.n)*hn(Ee.d,this.d),Ee.d*this.d)},lcm:function(e,t){return zr(e,t),Ee.n===0&&this.n===0?cr(0,1):cr(Ee.n*this.n,hn(Ee.n,this.n)*hn(Ee.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new Pr(NaN):cr(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 Pr(NaN):cr(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 Pr(NaN):cr(Math.round(e*this.s*this.n/this.d),e)},roundTo:function(e,t){return zr(e,t),cr(this.s*Math.round(this.n*Ee.d/(this.d*Ee.n))*Ee.n,Ee.d)},inverse:function(){return cr(this.s*this.d,this.n)},pow:function(e,t){if(zr(e,t),Ee.d===1)return Ee.s<0?cr(Math.pow(this.s*this.d,Ee.n),Math.pow(this.n,Ee.n)):cr(Math.pow(this.s*this.n,Ee.n),Math.pow(this.d,Ee.n));if(this.s<0)return null;var n=Vo(this.n),a=Vo(this.d),r=1,i=1;for(var u in n)if(u!=="1"){if(u==="0"){r=0;break}if(n[u]*=Ee.n,n[u]%Ee.d===0)n[u]/=Ee.d;else return null;r*=Math.pow(u,n[u])}for(var u in a)if(u!=="1"){if(a[u]*=Ee.n,a[u]%Ee.d===0)a[u]/=Ee.d;else return null;i*=Math.pow(u,a[u])}return Ee.s<0?cr(i,r):cr(r,i)},equals:function(e,t){return zr(e,t),this.s*this.n*Ee.d===Ee.s*Ee.n*this.d},compare:function(e,t){zr(e,t);var n=this.s*this.n*Ee.d-Ee.s*Ee.n*this.d;return(0<n)-(n<0)},simplify:function(e){if(isNaN(this.n)||isNaN(this.d))return this;e=e||.001;for(var t=this.abs(),n=t.toContinued(),a=1;a<n.length;a++){for(var r=cr(n[a-1],1),i=a-2;i>=0;i--)r=r.inverse().add(n[i]);if(Math.abs(r.sub(t).valueOf())<e)return r.mul(this.s)}return this},divisible:function(e,t){return zr(e,t),!(!(Ee.n*this.d)||this.n*Ee.d%(Ee.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(e){var t,n="",a=this.n,r=this.d;return this.s<0&&(n+="-"),r===1?n+=a:(e&&(t=Math.floor(a/r))>0&&(n+=t,n+=" ",a%=r),n+=a,n+="/",n+=r),n},toLatex:function(e){var t,n="",a=this.n,r=this.d;return this.s<0&&(n+="-"),r===1?n+=a:(e&&(t=Math.floor(a/r))>0&&(n+=t,a%=r),n+="\\frac{",n+=a,n+="}{",n+=r,n+="}"),n},toContinued:function(){var e,t=this.n,n=this.d,a=[];if(isNaN(t)||isNaN(n))return a;do a.push(Math.floor(t/n)),e=t%n,t=n,n=e;while(t!==1);return a},toString:function(e){var t=this.n,n=this.d;if(isNaN(t)||isNaN(n))return"NaN";e=e||15;var a=$h(t,n),r=_h(t,n,a),i=this.s<0?"-":"";if(i+=t/n|0,t%=n,t*=10,t&&(i+="."),a){for(var u=r;u--;)i+=t/n|0,t%=n,t*=10;i+="(";for(var u=a;u--;)i+=t/n|0,t%=n,t*=10;i+=")"}else for(var u=e;t&&u--;)i+=t/n|0,t%=n,t*=10;return i}};var qh="Fraction",Rh=[],Fh=R(qh,Rh,()=>(Pr.prototype.type="Fraction",Pr.prototype.isFraction=!0,Pr.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},Pr.fromJSON=function(e){return new Pr(e)},Pr),{isClass:!0}),zh="Range",Ph=[],Uh=R(zh,Ph,()=>{function e(t,n,a){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var r=t!=null,i=n!=null,u=a!=null;if(r){if(_e(t))t=t.toNumber();else if(typeof t!="number")throw new TypeError("Parameter start must be a number")}if(i){if(_e(n))n=n.toNumber();else if(typeof n!="number")throw new TypeError("Parameter end must be a number")}if(u){if(_e(a))a=a.toNumber();else if(typeof a!="number")throw new TypeError("Parameter step must be a number")}this.start=r?parseFloat(t):0,this.end=i?parseFloat(n):0,this.step=u?parseFloat(a):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(t){if(typeof t!="string")return null;var n=t.split(":"),a=n.map(function(i){return parseFloat(i)}),r=a.some(function(i){return isNaN(i)});if(r)return null;switch(a.length){case 2:return new e(a[0],a[1]);case 3:return new e(a[0],a[2],a[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var t=0,n=this.start,a=this.step,r=this.end,i=r-n;return Bt(a)===Bt(i)?t=Math.ceil(i/a):i===0&&(t=0),isNaN(t)&&(t=0),[t]},e.prototype.min=function(){var t=this.size()[0];if(t>0)return this.step>0?this.start:this.start+(t-1)*this.step},e.prototype.max=function(){var t=this.size()[0];if(t>0)return this.step>0?this.start+(t-1)*this.step:this.start},e.prototype.forEach=function(t){var n=this.start,a=this.step,r=this.end,i=0;if(a>0)for(;n<r;)t(n,[i],this),n+=a,i++;else if(a<0)for(;n>r;)t(n,[i],this),n+=a,i++},e.prototype.map=function(t){var n=[];return this.forEach(function(a,r,i){n[r[0]]=t(a,r,i)}),n},e.prototype.toArray=function(){var t=[];return this.forEach(function(n,a){t[a[0]]=n}),t},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(t){var n=Vt(this.start,t);return this.step!==1&&(n+=":"+Vt(this.step,t)),n+=":"+Vt(this.end,t),n},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}),Lh="Matrix",kh=[],Hh=R(Lh,kh,()=>{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(t,n){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(t,n,a){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(t){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(t,n,a){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(t,n){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(t,n){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(t,n){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(t){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(t){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}),Gh="DenseMatrix",Vh=["Matrix"],Zh=R(Gh,Vh,e=>{var{Matrix:t}=e;function n(o,s){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(s&&!Ir(s))throw new Error("Invalid datatype: "+s);if(De(o))o.type==="DenseMatrix"?(this._data=Oe(o._data),this._size=Oe(o._size),this._datatype=s||o._datatype):(this._data=o.toArray(),this._size=o.size(),this._datatype=s||o._datatype);else if(o&&Ye(o.data)&&Ye(o.size))this._data=o.data,this._size=o.size,bo(this._data,this._size),this._datatype=s||o.datatype;else if(Ye(o))this._data=c(o),this._size=Ue(this._data),bo(this._data,this._size),this._datatype=s;else{if(o)throw new TypeError("Unsupported type of data ("+je(o)+")");this._data=[],this._size=[0],this._datatype=s}}n.prototype=new t,n.prototype.createDenseMatrix=function(o,s){return new n(o,s)},n.prototype.type="DenseMatrix",n.prototype.isDenseMatrix=!0,n.prototype.getDataType=function(){return In(this._data,je)},n.prototype.storage=function(){return"dense"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(o,s){return new n(o,s)},n.prototype.subset=function(o,s,m){switch(arguments.length){case 1:return a(this,o);case 2:case 3:return i(this,o,s,m);default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.get=function(o){if(!Ye(o))throw new TypeError("Array expected");if(o.length!==this._size.length)throw new ze(o.length,this._size.length);for(var s=0;s<o.length;s++)Je(o[s],this._size[s]);for(var m=this._data,p=0,v=o.length;p<v;p++){var h=o[p];Je(h,m.length),m=m[h]}return m},n.prototype.set=function(o,s,m){if(!Ye(o))throw new TypeError("Array expected");if(o.length<this._size.length)throw new ze(o.length,this._size.length,"<");var p,v,h,b=o.map(function(N){return N+1});f(this,b,m);var w=this._data;for(p=0,v=o.length-1;p<v;p++)h=o[p],Je(h,w.length),w=w[h];return h=o[o.length-1],Je(h,w.length),w[h]=s,this};function a(o,s){if(!Tn(s))throw new TypeError("Invalid index");var m=s.isScalar();if(m)return o.get(s.min());var p=s.size();if(p.length!==o._size.length)throw new ze(p.length,o._size.length);for(var v=s.min(),h=s.max(),b=0,w=o._size.length;b<w;b++)Je(v[b],o._size[b]),Je(h[b],o._size[b]);return new n(r(o._data,s,p.length,0),o._datatype)}function r(o,s,m,p){var v=p===m-1,h=s.dimension(p);return v?h.map(function(b){return Je(b,o.length),o[b]}).valueOf():h.map(function(b){Je(b,o.length);var w=o[b];return r(w,s,m,p+1)}).valueOf()}function i(o,s,m,p){if(!s||s.isIndex!==!0)throw new TypeError("Invalid index");var v=s.size(),h=s.isScalar(),b;if(De(m)?(b=m.size(),m=m.valueOf()):b=Ue(m),h){if(b.length!==0)throw new TypeError("Scalar expected");o.set(s.min(),m,p)}else{if(v.length<o._size.length)throw new ze(v.length,o._size.length,"<");if(b.length<v.length){for(var w=0,N=0;v[w]===1&&b[w]===1;)w++;for(;v[w]===1;)N++,w++;m=Ao(m,v.length,N,b)}if(!_n(v,b))throw new ze(v,b,">");var g=s.max().map(function(d){return d+1});f(o,g,p);var y=v.length,x=0;u(o._data,s,m,y,x)}return o}function u(o,s,m,p,v){var h=v===p-1,b=s.dimension(v);h?b.forEach(function(w,N){Je(w),o[w]=m[N[0]]}):b.forEach(function(w,N){Je(w),u(o[w],s,m[N[0]],p,v+1)})}n.prototype.resize=function(o,s,m){if(!an(o))throw new TypeError("Array or Matrix expected");var p=o.valueOf().map(h=>Array.isArray(h)&&h.length===1?h[0]:h),v=m?this.clone():this;return l(v,p,s)};function l(o,s,m){if(s.length===0){for(var p=o._data;Ye(p);)p=p[0];return p}return o._size=s.slice(0),o._data=cn(o._data,o._size,m),o}n.prototype.reshape=function(o,s){var m=s?this.clone():this;m._data=wo(m._data,o);var p=m._size.reduce((v,h)=>v*h);return m._size=oi(o,p),m};function f(o,s,m){for(var p=o._size.slice(0),v=!1;p.length<s.length;)p.push(0),v=!0;for(var h=0,b=s.length;h<b;h++)s[h]>p[h]&&(p[h]=s[h],v=!0);v&&l(o,p,m)}n.prototype.clone=function(){var o=new n({data:Oe(this._data),size:Oe(this._size),datatype:this._datatype});return o},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(o){var s=this,m=function h(b,w){return Ye(b)?b.map(function(N,g){return h(N,w.concat(g))}):o(b,w,s)},p=m(this._data,[]),v=this._datatype!==void 0?In(p,je):void 0;return new n(p,v)},n.prototype.forEach=function(o){var s=this,m=function p(v,h){Ye(v)?v.forEach(function(b,w){p(b,h.concat(w))}):o(v,h,s)};m(this._data,[])},n.prototype[Symbol.iterator]=function*(){var o=function*s(m,p){if(Ye(m))for(var v=0;v<m.length;v++)yield*fo(s(m[v],p.concat(v)));else yield{value:m,index:p}};yield*fo(o(this._data,[]))},n.prototype.rows=function(){var o=[],s=this.size();if(s.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var m=this._data;for(var p of m)o.push(new n([p],this._datatype));return o},n.prototype.columns=function(){var o=this,s=[],m=this.size();if(m.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var p=this._data,v=function(w){var N=p.map(g=>[g[w]]);s.push(new n(N,o._datatype))},h=0;h<m[1];h++)v(h);return s},n.prototype.toArray=function(){return Oe(this._data)},n.prototype.valueOf=function(){return this._data},n.prototype.format=function(o){return Fe(this._data,o)},n.prototype.toString=function(){return Fe(this._data)},n.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(o){if(o){if(_e(o)&&(o=o.toNumber()),!$e(o)||!Se(o))throw new TypeError("The parameter k must be an integer number")}else o=0;for(var s=o>0?o:0,m=o<0?-o:0,p=this._size[0],v=this._size[1],h=Math.min(p-m,v-s),b=[],w=0;w<h;w++)b[w]=this._data[w+m][w+s];return new n({data:b,size:[h],datatype:this._datatype})},n.diagonal=function(o,s,m,p){if(!Ye(o))throw new TypeError("Array expected, size parameter");if(o.length!==2)throw new Error("Only two dimensions matrix are supported");if(o=o.map(function(A){if(_e(A)&&(A=A.toNumber()),!$e(A)||!Se(A)||A<1)throw new Error("Size values must be positive integers");return A}),m){if(_e(m)&&(m=m.toNumber()),!$e(m)||!Se(m))throw new TypeError("The parameter k must be an integer number")}else m=0;var v=m>0?m:0,h=m<0?-m:0,b=o[0],w=o[1],N=Math.min(b-h,w-v),g;if(Ye(s)){if(s.length!==N)throw new Error("Invalid value array length");g=function(S){return s[S]}}else if(De(s)){var y=s.size();if(y.length!==1||y[0]!==N)throw new Error("Invalid matrix length");g=function(S){return s.get([S])}}else g=function(){return s};p||(p=_e(g(0))?g(0).mul(0):0);var x=[];if(o.length>0){x=cn(x,o,p);for(var d=0;d<N;d++)x[d+h][d+v]=g(d)}return new n({data:x,size:[b,w]})},n.fromJSON=function(o){return new n(o)},n.prototype.swapRows=function(o,s){if(!$e(o)||!Se(o)||!$e(s)||!Se(s))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return Je(o,this._size[0]),Je(s,this._size[0]),n._swapRows(o,s,this._data),this},n._swapRows=function(o,s,m){var p=m[o];m[o]=m[s],m[s]=p};function c(o){for(var s=0,m=o.length;s<m;s++){var p=o[s];Ye(p)?o[s]=c(p):p&&p.isMatrix===!0&&(o[s]=c(p.valueOf()))}return o}return n},{isClass:!0}),Zo="clone",Xh=["typed"],Yh=R(Zo,Xh,e=>{var{typed:t}=e;return t(Zo,{any:Oe})});function Xo(e){var t=e.length,n=e[0].length,a,r,i=[];for(r=0;r<n;r++){var u=[];for(a=0;a<t;a++)u.push(e[a][r]);i.push(u)}return i}function dn(e){for(var t=0;t<e.length;t++)if(an(e[t]))return!0;return!1}function Nt(e,t){De(e)&&(e=e.valueOf());for(var n=0,a=e.length;n<a;n++){var r=e[n];Array.isArray(r)?Nt(r,t):t(r)}}function we(e,t,n){return e&&typeof e.map=="function"?e.map(function(a){return we(a,t)}):t(e)}function Ma(e,t,n){var a=Array.isArray(e)?Ue(e):e.size();if(t<0||t>=a.length)throw new et(t,a.length);return De(e)?e.create(Aa(e.valueOf(),t,n)):Aa(e,t,n)}function Aa(e,t,n){var a,r,i,u;if(t<=0)if(Array.isArray(e[0])){for(u=Xo(e),r=[],a=0;a<u.length;a++)r[a]=Aa(u[a],t-1,n);return r}else{for(i=e[0],a=1;a<e.length;a++)i=n(i,e[a]);return i}else{for(r=[],a=0;a<e.length;a++)r[a]=Aa(e[a],t-1,n);return r}}function Yo(e,t,n,a,r,i,u,l,f,c,o){var s=e._values,m=e._index,p=e._ptr,v,h,b,w;if(a)for(h=p[t],b=p[t+1],v=h;v<b;v++)w=m[v],n[w]!==i?(n[w]=i,u.push(w),a[w]=s[v]):(a[w]=l(a[w],s[v]),r[w]=i);else for(h=p[t],b=p[t+1],v=h;v<b;v++)w=m[v],n[w]!==i?(n[w]=i,u.push(w)):r[w]=i}var Wo="isInteger",Wh=["typed"],Jh=R(Wo,Wh,e=>{var{typed:t}=e;return t(Wo,{number:Se,BigNumber:function(a){return a.isInt()},Fraction:function(a){return a.d===1&&isFinite(a.n)},"Array | Matrix":function(a){return we(a,this)}})}),tt="number",Xt="number, number";function Jo(e){return Math.abs(e)}Jo.signature=tt;function Qo(e,t){return e+t}Qo.signature=Xt;function Ko(e,t){return e*t}Ko.signature=Xt;function jo(e){return-e}jo.signature=tt;function es(e){return e}es.signature=tt;function Rn(e){return Wp(e)}Rn.signature=tt;function rs(e){return e*e*e}rs.signature=tt;function ts(e){return Math.exp(e)}ts.signature=tt;function ns(e){return Jp(e)}ns.signature=tt;function as(e,t){if(!Se(e)||!Se(t))throw new Error("Parameters in function gcd must be integer numbers");for(var n;t!==0;)n=e%t,e=t,t=n;return e<0?-e:e}as.signature=Xt;function is(e,t){if(!Se(e)||!Se(t))throw new Error("Parameters in function lcm must be integer numbers");if(e===0||t===0)return 0;for(var n,a=e*t;t!==0;)n=t,t=e%n,e=n;return Math.abs(a/e)}is.signature=Xt;function Qh(e,t){return Math.log(e)}function os(e){return Xp(e)}os.signature=tt;function ss(e){return Zp(e)}ss.signature=tt;function us(e,t){if(t>0)return e-t*Math.floor(e/t);if(t===0)return e;throw new Error("Cannot calculate mod for a negative divisor")}us.signature=Xt;function cs(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,n=t<0;if(n&&(t=-t),t===0)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(e===0)return n?1/0:0;if(!isFinite(e))return n?0:e;var a=Math.pow(Math.abs(e),1/t);return a=e<0?-a:a,n?1/a:a}function wi(e){return Bt(e)}wi.signature=tt;function fs(e){return e*e}fs.signature=tt;function ls(e,t){var n,a,r,i=0,u=1,l=1,f=0;if(!Se(e)||!Se(t))throw new Error("Parameters in function xgcd must be integer numbers");for(;t;)a=Math.floor(e/t),r=e-a*t,n=i,i=u-a*i,u=n,n=l,l=f-a*l,f=n,e=t,t=r;var c;return e<0?c=[-e,-u,-f]:c=[e,e?u:0,f],c}ls.signature=Xt;function ms(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:Math.pow(e,t)}ms.signature=Xt;function ps(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!Se(t)||t<0||t>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(vo(e,t))}var Kh="number",gn="number, number";function vs(e,t){if(!Se(e)||!Se(t))throw new Error("Integers expected in function bitAnd");return e&t}vs.signature=gn;function hs(e){if(!Se(e))throw new Error("Integer expected in function bitNot");return~e}hs.signature=Kh;function ds(e,t){if(!Se(e)||!Se(t))throw new Error("Integers expected in function bitOr");return e|t}ds.signature=gn;function gs(e,t){if(!Se(e)||!Se(t))throw new Error("Integers expected in function bitXor");return e^t}gs.signature=gn;function ys(e,t){if(!Se(e)||!Se(t))throw new Error("Integers expected in function leftShift");return e<<t}ys.signature=gn;function xs(e,t){if(!Se(e)||!Se(t))throw new Error("Integers expected in function rightArithShift");return e>>t}xs.signature=gn;function bs(e,t){if(!Se(e)||!Se(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}bs.signature=gn;function Mt(e,t){if(t<e)return 1;if(t===e)return t;var n=t+e>>1;return Mt(e,n)*Mt(n+1,t)}function ws(e,t){if(!Se(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!Se(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");for(var n=e-t,a=1,r=t<n?n+1:t+1,i=2,u=t<n?t:n,l=r;l<=e;++l)for(a*=l;i<=u&&a%i===0;)a/=i,++i;return i<=u&&(a/=Mt(i,u)),a}ws.signature="number, number";var jh=Math.PI,ed=2*Math.PI,rd=Math.E,td=1.618033988749895,nd="number",Ni="number, number";function Ns(e){return!e}Ns.signature=nd;function Ms(e,t){return!!(e||t)}Ms.signature=Ni;function As(e,t){return!!e!=!!t}As.signature=Ni;function Ss(e,t){return!!(e&&t)}Ss.signature=Ni;function Mi(e){var t;if(Se(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:Mt(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*Mi(1-e));if(e>=171.35)return 1/0;if(e>85){var n=e*e,a=n*e,r=a*e,i=r*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*n)-139/(51840*a)-571/(2488320*r)+163879/(209018880*i)+5246819/(75246796800*i*e))}--e,t=yn[0];for(var u=1;u<yn.length;++u)t+=yn[u]/(e+u);var l=e+Es+.5;return Math.sqrt(2*Math.PI)*Math.pow(l,e+.5)*Math.exp(-l)*t}Mi.signature="number";var Es=4.7421875,yn=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],Cs=.9189385332046728,ad=5,id=7,Os=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function Sa(e){if(e<0)return NaN;if(e===0)return 1/0;if(!isFinite(e))return e;if(e<.5)return Math.log(Math.PI/Math.sin(Math.PI*e))-Sa(1-e);e=e-1;for(var t=e+ad+.5,n=Os[0],a=id-1;a>=1;a--)n+=Os[a]/(e+a);return Cs+(e+.5)*Math.log(t)-t+Math.log(n)}Sa.signature="number";var Sr="number";function Ds(e){return rv(e)}Ds.signature=Sr;function Ts(e){return Math.atan(1/e)}Ts.signature=Sr;function Bs(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}Bs.signature=Sr;function $s(e){return Math.asin(1/e)}$s.signature=Sr;function _s(e){var t=1/e;return Math.log(t+Math.sqrt(t*t+1))}_s.signature=Sr;function Is(e){return Math.acos(1/e)}Is.signature=Sr;function qs(e){var t=1/e,n=Math.sqrt(t*t-1);return Math.log(n+t)}qs.signature=Sr;function Rs(e){return tv(e)}Rs.signature=Sr;function Fs(e){return nv(e)}Fs.signature=Sr;function zs(e){return 1/Math.tan(e)}zs.signature=Sr;function Ps(e){var t=Math.exp(2*e);return(t+1)/(t-1)}Ps.signature=Sr;function Us(e){return 1/Math.sin(e)}Us.signature=Sr;function Ls(e){return e===0?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*Bt(e)}Ls.signature=Sr;function ks(e){return 1/Math.cos(e)}ks.signature=Sr;function Hs(e){return 2/(Math.exp(e)+Math.exp(-e))}Hs.signature=Sr;function Gs(e){return iv(e)}Gs.signature=Sr;var Ea="number";function Vs(e){return e<0}Vs.signature=Ea;function Zs(e){return e>0}Zs.signature=Ea;function Xs(e){return e===0}Xs.signature=Ea;function Ys(e){return Number.isNaN(e)}Ys.signature=Ea;var Ws="isNegative",od=["typed"],sd=R(Ws,od,e=>{var{typed:t}=e;return t(Ws,{number:Vs,BigNumber:function(a){return a.isNeg()&&!a.isZero()&&!a.isNaN()},Fraction:function(a){return a.s<0},Unit:function(a){return this(a.value)},"Array | Matrix":function(a){return we(a,this)}})}),Js="isNumeric",ud=["typed"],cd=R(Js,ud,e=>{var{typed:t}=e;return t(Js,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(a){return we(a,this)}})}),Qs="hasNumericValue",fd=["typed","isNumeric"],ld=R(Qs,fd,e=>{var{typed:t,isNumeric:n}=e;return t(Qs,{string:function(r){return r.trim().length>0&&!isNaN(Number(r))},any:function(r){return n(r)}})}),Ks="isPositive",md=["typed"],pd=R(Ks,md,e=>{var{typed:t}=e;return t(Ks,{number:Zs,BigNumber:function(a){return!a.isNeg()&&!a.isZero()&&!a.isNaN()},Fraction:function(a){return a.s>0&&a.n>0},Unit:function(a){return this(a.value)},"Array | Matrix":function(a){return we(a,this)}})}),js="isZero",vd=["typed"],hd=R(js,vd,e=>{var{typed:t}=e;return t(js,{number:Xs,BigNumber:function(a){return a.isZero()},Complex:function(a){return a.re===0&&a.im===0},Fraction:function(a){return a.d===1&&a.n===0},Unit:function(a){return this(a.value)},"Array | Matrix":function(a){return we(a,this)}})}),eu="isNaN",dd=["typed"],gd=R(eu,dd,e=>{var{typed:t}=e;return t(eu,{number:Ys,BigNumber:function(a){return a.isNaN()},Fraction:function(a){return!1},Complex:function(a){return a.isNaN()},Unit:function(a){return Number.isNaN(a.value)},"Array | Matrix":function(a){return we(a,Number.isNaN)}})}),ru="typeOf",yd=["typed"],xd=R(ru,yd,e=>{var{typed:t}=e;return t(ru,{any:je})});function ct(e,t,n){if(n==null)return e.eq(t);if(e.eq(t))return!0;if(e.isNaN()||t.isNaN())return!1;if(e.isFinite()&&t.isFinite()){var a=e.minus(t).abs();if(a.isZero())return!0;var r=e.constructor.max(e.abs(),t.abs());return a.lte(r.times(n))}return!1}function bd(e,t,n){return Fr(e.re,t.re,n)&&Fr(e.im,t.im,n)}var Ca="equalScalar",wd=["typed","config"],Nd=R(Ca,wd,e=>{var{typed:t,config:n}=e;return t(Ca,{"boolean, boolean":function(r,i){return r===i},"number, number":function(r,i){return Fr(r,i,n.epsilon)},"BigNumber, BigNumber":function(r,i){return r.eq(i)||ct(r,i,n.epsilon)},"Fraction, Fraction":function(r,i){return r.equals(i)},"Complex, Complex":function(r,i){return bd(r,i,n.epsilon)},"Unit, Unit":function(r,i){if(!r.equalBase(i))throw new Error("Cannot compare units with different base");return this(r.value,i.value)}})});R(Ca,["typed","config"],e=>{var{typed:t,config:n}=e;return t(Ca,{"number, number":function(r,i){return Fr(r,i,n.epsilon)}})});var Md="SparseMatrix",Ad=["typed","equalScalar","Matrix"],Sd=R(Md,Ad,e=>{var{typed:t,equalScalar:n,Matrix:a}=e;function r(h,b){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(b&&!Ir(b))throw new Error("Invalid datatype: "+b);if(De(h))i(this,h,b);else if(h&&Ye(h.index)&&Ye(h.ptr)&&Ye(h.size))this._values=h.values,this._index=h.index,this._ptr=h.ptr,this._size=h.size,this._datatype=b||h.datatype;else if(Ye(h))u(this,h,b);else{if(h)throw new TypeError("Unsupported type of data ("+je(h)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=b}}function i(h,b,w){b.type==="SparseMatrix"?(h._values=b._values?Oe(b._values):void 0,h._index=Oe(b._index),h._ptr=Oe(b._ptr),h._size=Oe(b._size),h._datatype=w||b._datatype):u(h,b.valueOf(),w||b._datatype)}function u(h,b,w){h._values=[],h._index=[],h._ptr=[],h._datatype=w;var N=b.length,g=0,y=n,x=0;if(Ir(w)&&(y=t.find(n,[w,w])||n,x=t.convert(0,w)),N>0){var d=0;do{h._ptr.push(h._index.length);for(var A=0;A<N;A++){var S=b[A];if(Ye(S)){if(d===0&&g<S.length&&(g=S.length),d<S.length){var O=S[d];y(O,x)||(h._values.push(O),h._index.push(A))}}else d===0&&g<1&&(g=1),y(S,x)||(h._values.push(S),h._index.push(A))}d++}while(d<g)}h._ptr.push(h._index.length),h._size=[N,g]}r.prototype=new a,r.prototype.createSparseMatrix=function(h,b){return new r(h,b)},r.prototype.type="SparseMatrix",r.prototype.isSparseMatrix=!0,r.prototype.getDataType=function(){return In(this._values,je)},r.prototype.storage=function(){return"sparse"},r.prototype.datatype=function(){return this._datatype},r.prototype.create=function(h,b){return new r(h,b)},r.prototype.density=function(){var h=this._size[0],b=this._size[1];return h!==0&&b!==0?this._index.length/(h*b):0},r.prototype.subset=function(h,b,w){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return l(this,h);case 2:case 3:return f(this,h,b,w);default:throw new SyntaxError("Wrong number of arguments")}};function l(h,b){if(!Tn(b))throw new TypeError("Invalid index");var w=b.isScalar();if(w)return h.get(b.min());var N=b.size();if(N.length!==h._size.length)throw new ze(N.length,h._size.length);var g,y,x,d,A=b.min(),S=b.max();for(g=0,y=h._size.length;g<y;g++)Je(A[g],h._size[g]),Je(S[g],h._size[g]);var O=h._values,M=h._index,$=h._ptr,E=b.dimension(0),_=b.dimension(1),z=[],I=[];E.forEach(function(D,H){I[D]=H[0],z[D]=!0});var T=O?[]:void 0,B=[],G=[];return _.forEach(function(D){for(G.push(B.length),x=$[D],d=$[D+1];x<d;x++)g=M[x],z[g]===!0&&(B.push(I[g]),T&&T.push(O[x]))}),G.push(B.length),new r({values:T,index:B,ptr:G,size:N,datatype:h._datatype})}function f(h,b,w,N){if(!b||b.isIndex!==!0)throw new TypeError("Invalid index");var g=b.size(),y=b.isScalar(),x;if(De(w)?(x=w.size(),w=w.toArray()):x=Ue(w),y){if(x.length!==0)throw new TypeError("Scalar expected");h.set(b.min(),w,N)}else{if(g.length!==1&&g.length!==2)throw new ze(g.length,h._size.length,"<");if(x.length<g.length){for(var d=0,A=0;g[d]===1&&x[d]===1;)d++;for(;g[d]===1;)A++,d++;w=Ao(w,g.length,A,x)}if(!_n(g,x))throw new ze(g,x,">");if(g.length===1){var S=b.dimension(0);S.forEach(function($,E){Je($),h.set([$,0],w[E[0]],N)})}else{var O=b.dimension(0),M=b.dimension(1);O.forEach(function($,E){Je($),M.forEach(function(_,z){Je(_),h.set([$,_],w[E[0]][z[0]],N)})})}}return h}r.prototype.get=function(h){if(!Ye(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new ze(h.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var b=h[0],w=h[1];Je(b,this._size[0]),Je(w,this._size[1]);var N=c(b,this._ptr[w],this._ptr[w+1],this._index);return N<this._ptr[w+1]&&this._index[N]===b?this._values[N]:0},r.prototype.set=function(h,b,w){if(!Ye(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new ze(h.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var N=h[0],g=h[1],y=this._size[0],x=this._size[1],d=n,A=0;Ir(this._datatype)&&(d=t.find(n,[this._datatype,this._datatype])||n,A=t.convert(0,this._datatype)),(N>y-1||g>x-1)&&(m(this,Math.max(N+1,y),Math.max(g+1,x),w),y=this._size[0],x=this._size[1]),Je(N,y),Je(g,x);var S=c(N,this._ptr[g],this._ptr[g+1],this._index);return S<this._ptr[g+1]&&this._index[S]===N?d(b,A)?o(S,g,this._values,this._index,this._ptr):this._values[S]=b:s(S,N,g,b,this._values,this._index,this._ptr),this};function c(h,b,w,N){if(w-b===0)return w;for(var g=b;g<w;g++)if(N[g]===h)return g;return b}function o(h,b,w,N,g){w.splice(h,1),N.splice(h,1);for(var y=b+1;y<g.length;y++)g[y]--}function s(h,b,w,N,g,y,x){g.splice(h,0,N),y.splice(h,0,b);for(var d=w+1;d<x.length;d++)x[d]++}r.prototype.resize=function(h,b,w){if(!an(h))throw new TypeError("Array or Matrix expected");var N=h.valueOf().map(y=>Array.isArray(y)&&y.length===1?y[0]:y);if(N.length!==2)throw new Error("Only two dimensions matrix are supported");N.forEach(function(y){if(!$e(y)||!Se(y)||y<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Fe(N)+")")});var g=w?this.clone():this;return m(g,N[0],N[1],b)};function m(h,b,w,N){var g=N||0,y=n,x=0;Ir(h._datatype)&&(y=t.find(n,[h._datatype,h._datatype])||n,x=t.convert(0,h._datatype),g=t.convert(g,h._datatype));var d=!y(g,x),A=h._size[0],S=h._size[1],O,M,$;if(w>S){for(M=S;M<w;M++)if(h._ptr[M]=h._values.length,d)for(O=0;O<A;O++)h._values.push(g),h._index.push(O);h._ptr[w]=h._values.length}else w<S&&(h._ptr.splice(w+1,S-w),h._values.splice(h._ptr[w],h._values.length),h._index.splice(h._ptr[w],h._index.length));if(S=w,b>A){if(d){var E=0;for(M=0;M<S;M++){h._ptr[M]=h._ptr[M]+E,$=h._ptr[M+1]+E;var _=0;for(O=A;O<b;O++,_++)h._values.splice($+_,0,g),h._index.splice($+_,0,O),E++}h._ptr[S]=h._values.length}}else if(b<A){var z=0;for(M=0;M<S;M++){h._ptr[M]=h._ptr[M]-z;var I=h._ptr[M],T=h._ptr[M+1]-z;for($=I;$<T;$++)O=h._index[$],O>b-1&&(h._values.splice($,1),h._index.splice($,1),z++)}h._ptr[M]=h._values.length}return h._size[0]=b,h._size[1]=w,h}r.prototype.reshape=function(h,b){if(!Ye(h))throw new TypeError("Array expected");if(h.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");h.forEach(function(D){if(!$e(D)||!Se(D)||D<=-2||D===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Fe(h)+")")});var w=this._size[0]*this._size[1];h=oi(h,w);var N=h[0]*h[1];if(w!==N)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var g=b?this.clone():this;if(this._size[0]===h[0]&&this._size[1]===h[1])return g;for(var y=[],x=0;x<g._ptr.length;x++)for(var d=0;d<g._ptr[x+1]-g._ptr[x];d++)y.push(x);for(var A=g._values.slice(),S=g._index.slice(),O=0;O<g._index.length;O++){var M=S[O],$=y[O],E=M*g._size[1]+$;y[O]=E%h[1],S[O]=Math.floor(E/h[1])}g._values.length=0,g._index.length=0,g._ptr.length=h[1]+1,g._size=h.slice();for(var _=0;_<g._ptr.length;_++)g._ptr[_]=0;for(var z=0;z<A.length;z++){var I=S[z],T=y[z],B=A[z],G=c(I,g._ptr[T],g._ptr[T+1],g._index);s(G,I,T,B,g._values,g._index,g._ptr)}return g},r.prototype.clone=function(){var h=new r({values:this._values?Oe(this._values):void 0,index:Oe(this._index),ptr:Oe(this._ptr),size:Oe(this._size),datatype:this._datatype});return h},r.prototype.size=function(){return this._size.slice(0)},r.prototype.map=function(h,b){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var w=this,N=this._size[0],g=this._size[1],y=function(d,A,S){return h(d,[A,S],w)};return p(this,0,N-1,0,g-1,y,b)};function p(h,b,w,N,g,y,x){var d=[],A=[],S=[],O=n,M=0;Ir(h._datatype)&&(O=t.find(n,[h._datatype,h._datatype])||n,M=t.convert(0,h._datatype));for(var $=function(V,K,te){V=y(V,K,te),O(V,M)||(d.push(V),A.push(K))},E=N;E<=g;E++){S.push(d.length);var _=h._ptr[E],z=h._ptr[E+1];if(x)for(var I=_;I<z;I++){var T=h._index[I];T>=b&&T<=w&&$(h._values[I],T-b,E-N)}else{for(var B={},G=_;G<z;G++){var D=h._index[G];B[D]=h._values[G]}for(var H=b;H<=w;H++){var W=H in B?B[H]:0;$(W,H-b,E-N)}}}return S.push(d.length),new r({values:d,index:A,ptr:S,size:[w-b+1,g-N+1]})}r.prototype.forEach=function(h,b){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var w=this,N=this._size[0],g=this._size[1],y=0;y<g;y++){var x=this._ptr[y],d=this._ptr[y+1];if(b)for(var A=x;A<d;A++){var S=this._index[A];h(this._values[A],[S,y],w)}else{for(var O={},M=x;M<d;M++){var $=this._index[M];O[$]=this._values[M]}for(var E=0;E<N;E++){var _=E in O?O[E]:0;h(_,[E,y],w)}}}},r.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var h=this._size[1],b=0;b<h;b++)for(var w=this._ptr[b],N=this._ptr[b+1],g=w;g<N;g++){var y=this._index[g];yield{value:this._values[g],index:[y,b]}}},r.prototype.toArray=function(){return v(this._values,this._index,this._ptr,this._size,!0)},r.prototype.valueOf=function(){return v(this._values,this._index,this._ptr,this._size,!1)};function v(h,b,w,N,g){var y=N[0],x=N[1],d=[],A,S;for(A=0;A<y;A++)for(d[A]=[],S=0;S<x;S++)d[A][S]=0;for(S=0;S<x;S++)for(var O=w[S],M=w[S+1],$=O;$<M;$++)A=b[$],d[A][S]=h?g?Oe(h[$]):h[$]:1;return d}return r.prototype.format=function(h){for(var b=this._size[0],w=this._size[1],N=this.density(),g="Sparse Matrix ["+Fe(b,h)+" x "+Fe(w,h)+"] density: "+Fe(N,h)+`
10
10
  `,y=0;y<w;y++)for(var x=this._ptr[y],d=this._ptr[y+1],A=x;A<d;A++){var S=this._index[A];g+=`
11
- (`+Re(S,h)+", "+Re(y,h)+") ==> "+(this._values?Re(this._values[A],h):"X")}return g},r.prototype.toString=function(){return Re(this.toArray())},r.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},r.prototype.diagonal=function(h){if(h){if(_e(h)&&(h=h.toNumber()),!Be(h)||!Ae(h))throw new TypeError("The parameter k must be an integer number")}else h=0;var b=h>0?h:0,w=h<0?-h:0,N=this._size[0],g=this._size[1],y=Math.min(N-w,g-b),x=[],d=[],A=[];A[0]=0;for(var S=b;S<g&&x.length<y;S++)for(var O=this._ptr[S],M=this._ptr[S+1],_=O;_<M;_++){var E=this._index[_];if(E===S-b+w){x.push(this._values[_]),d[x.length-1]=E-w;break}}return A.push(x.length),new r({values:x,index:d,ptr:A,size:[y,1]})},r.fromJSON=function(h){return new r(h)},r.diagonal=function(h,b,w,N,g){if(!Xe(h))throw new TypeError("Array expected, size parameter");if(h.length!==2)throw new Error("Only two dimensions matrix are supported");if(h=h.map(function(D){if(_e(D)&&(D=D.toNumber()),!Be(D)||!Ae(D)||D<1)throw new Error("Size values must be positive integers");return D}),w){if(_e(w)&&(w=w.toNumber()),!Be(w)||!Ae(w))throw new TypeError("The parameter k must be an integer number")}else w=0;var y=a,x=0;_r(g)&&(y=n.find(a,[g,g])||a,x=n.convert(0,g));var d=w>0?w:0,A=w<0?-w:0,S=h[0],O=h[1],M=Math.min(S-A,O-d),_;if(Xe(b)){if(b.length!==M)throw new Error("Invalid value array length");_=function(H){return b[H]}}else if(Oe(b)){var E=b.size();if(E.length!==1||E[0]!==M)throw new Error("Invalid matrix length");_=function(H){return b.get([H])}}else _=function(){return b};for(var $=[],z=[],I=[],T=0;T<O;T++){I.push($.length);var B=T-d;if(B>=0&&B<M){var G=_(B);y(G,x)||(z.push(B+A),$.push(G))}}return I.push($.length),new r({values:$,index:z,ptr:I,size:[S,O]})},r.prototype.swapRows=function(h,b){if(!Be(h)||!Ae(h)||!Be(b)||!Ae(b))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return We(h,this._size[0]),We(b,this._size[0]),r._swapRows(h,b,this._size[1],this._values,this._index,this._ptr),this},r._forEachRow=function(h,b,w,N,g){for(var y=N[h],x=N[h+1],d=y;d<x;d++)g(w[d],b[d])},r._swapRows=function(h,b,w,N,g,y){for(var x=0;x<w;x++){var d=y[x],A=y[x+1],S=c(h,d,A,g),O=c(b,d,A,g);if(S<A&&O<A&&g[S]===h&&g[O]===b){if(N){var M=N[S];N[S]=N[O],N[O]=M}continue}if(S<A&&g[S]===h&&(O>=A||g[O]!==b)){var _=N?N[S]:void 0;g.splice(O,0,b),N&&N.splice(O,0,_),g.splice(O<=S?S+1:S,1),N&&N.splice(O<=S?S+1:S,1);continue}if(O<A&&g[O]===b&&(S>=A||g[S]!==h)){var E=N?N[O]:void 0;g.splice(S,0,h),N&&N.splice(S,0,E),g.splice(S<=O?O+1:O,1),N&&N.splice(S<=O?O+1:O,1)}}},r},{isClass:!0}),Nd="number",Md=["typed"];function Ad(e){var n=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(n){var a={"0b":2,"0o":8,"0x":16}[n[1]],t=n[2],r=n[3];return{input:e,radix:a,integerPart:t,fractionalPart:r}}else return null}function Sd(e){for(var n=parseInt(e.integerPart,e.radix),a=0,t=0;t<e.fractionalPart.length;t++){var r=parseInt(e.fractionalPart[t],e.radix);a+=r/Math.pow(e.radix,t+1)}var i=n+a;if(isNaN(i))throw new SyntaxError('String "'+e.input+'" is no valid number');return i}var Ed=R(Nd,Md,e=>{var{typed:n}=e,a=n("number",{"":function(){return 0},number:function(r){return r},string:function(r){if(r==="NaN")return NaN;var i=Ad(r);if(i)return Sd(i);var l=0,m=r.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);m&&(l=Number(m[2]),r=m[1]);var f=Number(r);if(isNaN(f))throw new SyntaxError('String "'+r+'" is no valid number');if(m){if(f>en(2,l)-1)throw new SyntaxError('String "'.concat(r,'" is out of range'));f>=en(2,l-1)&&(f=f-en(2,l))}return f},BigNumber:function(r){return r.toNumber()},Fraction:function(r){return r.valueOf()},Unit:function(r){throw new Error("Second argument with valueless unit expected")},null:function(r){return 0},"Unit, string | Unit":function(r,i){return r.toNumber(i)},"Array | Matrix":function(r){return be(r,this)}});return a.fromJSON=function(t){return parseFloat(t.value)},a}),Ks="string",Cd=["typed"],Od=R(Ks,Cd,e=>{var{typed:n}=e;return n(Ks,{"":function(){return""},number:Ht,null:function(t){return"null"},boolean:function(t){return t+""},string:function(t){return t},"Array | Matrix":function(t){return be(t,this)},any:function(t){return String(t)}})}),js="boolean",Dd=["typed"],Td=R(js,Dd,e=>{var{typed:n}=e;return n(js,{"":function(){return!1},boolean:function(t){return t},number:function(t){return!!t},null:function(t){return!1},BigNumber:function(t){return!t.isZero()},string:function(t){var r=t.toLowerCase();if(r==="true")return!0;if(r==="false")return!1;var i=Number(t);if(t!==""&&!isNaN(i))return!!i;throw new Error('Cannot convert "'+t+'" to a boolean')},"Array | Matrix":function(t){return be(t,this)}})}),Bd="bignumber",_d=["typed","BigNumber"],$d=R(Bd,_d,e=>{var{typed:n,BigNumber:a}=e;return n("bignumber",{"":function(){return new a(0)},number:function(r){return new a(r+"")},string:function(r){var i=r.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(i){var l=i[2],m=a(i[1]),f=new a(2).pow(Number(l));if(m.gt(f.sub(1)))throw new SyntaxError('String "'.concat(r,'" is out of range'));var c=new a(2).pow(Number(l)-1);return m.gte(c)?m.sub(f):m}return new a(r)},BigNumber:function(r){return r},Fraction:function(r){return new a(r.n).div(r.d).times(r.s)},null:function(r){return new a(0)},"Array | Matrix":function(r){return be(r,this)}})}),Id="complex",qd=["typed","Complex"],Rd=R(Id,qd,e=>{var{typed:n,Complex:a}=e;return n("complex",{"":function(){return a.ZERO},number:function(r){return new a(r,0)},"number, number":function(r,i){return new a(r,i)},"BigNumber, BigNumber":function(r,i){return new a(r.toNumber(),i.toNumber())},Fraction:function(r){return new a(r.valueOf(),0)},Complex:function(r){return r.clone()},string:function(r){return a(r)},null:function(r){return a(0)},Object:function(r){if("re"in r&&"im"in r)return new a(r.re,r.im);if("r"in r&&"phi"in r||"abs"in r&&"arg"in r)return new a(r);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(r){return be(r,this)}})}),Fd="fraction",zd=["typed","Fraction"],Pd=R(Fd,zd,e=>{var{typed:n,Fraction:a}=e;return n("fraction",{number:function(r){if(!isFinite(r)||isNaN(r))throw new Error(r+" cannot be represented as a fraction");return new a(r)},string:function(r){return new a(r)},"number, number":function(r,i){return new a(r,i)},null:function(r){return new a(0)},BigNumber:function(r){return new a(r.toString())},Fraction:function(r){return r},Object:function(r){return new a(r)},"Array | Matrix":function(r){return be(r,this)}})}),eu="matrix",Ud=["typed","Matrix","DenseMatrix","SparseMatrix"],Ld=R(eu,Ud,e=>{var{typed:n,Matrix:a,DenseMatrix:t,SparseMatrix:r}=e;return n(eu,{"":function(){return i([])},string:function(m){return i([],m)},"string, string":function(m,f){return i([],m,f)},Array:function(m){return i(m)},Matrix:function(m){return i(m,m.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(l,m,f){if(m==="dense"||m==="default"||m===void 0)return new t(l,f);if(m==="sparse")return new r(l,f);throw new TypeError("Unknown matrix type "+JSON.stringify(m)+".")}}),ru="matrixFromFunction",kd=["typed","matrix","isZero"],Hd=R(ru,kd,e=>{var{typed:n,matrix:a,isZero:t}=e;return n(ru,{"Array | Matrix, function, string, string":function(l,m,f,c){return r(l,m,f,c)},"Array | Matrix, function, string":function(l,m,f){return r(l,m,f)},"Matrix, function":function(l,m){return r(l,m,"dense")},"Array, function":function(l,m){return r(l,m,"dense").toArray()},"Array | Matrix, string, function":function(l,m,f){return r(l,f,m)},"Array | Matrix, string, string, function":function(l,m,f,c){return r(l,c,m,f)}});function r(i,l,m,f){var c;return f!==void 0?c=a(m,f):c=a(m),c.resize(i),c.forEach(function(s,o){var u=l(o);t(u)||c.set(o,u)}),c}}),tu="matrixFromRows",Gd=["typed","matrix","flatten","size"],Vd=R(tu,Gd,e=>{var{typed:n,matrix:a,flatten:t,size:r}=e;return n(tu,{"...Array":function(f){return i(f)},"...Matrix":function(f){return a(i(f.map(c=>c.toArray())))}});function i(m){if(m.length===0)throw new TypeError("At least one row is needed to construct a matrix.");var f=l(m[0]),c=[];for(var s of m){var o=l(s);if(o!==f)throw new TypeError("The vectors had different length: "+(f|0)+" ≠ "+(o|0));c.push(t(s))}return c}function l(m){var f=r(m);if(f.length===1)return f[0];if(f.length===2){if(f[0]===1)return f[1];if(f[1]===1)return f[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),nu="matrixFromColumns",Zd=["typed","matrix","flatten","size"],Xd=R(nu,Zd,e=>{var{typed:n,matrix:a,flatten:t,size:r}=e;return n(nu,{"...Array":function(f){return i(f)},"...Matrix":function(f){return a(i(f.map(c=>c.toArray())))}});function i(m){if(m.length===0)throw new TypeError("At least one column is needed to construct a matrix.");for(var f=l(m[0]),c=[],s=0;s<f;s++)c[s]=[];for(var o of m){var u=l(o);if(u!==f)throw new TypeError("The vectors had different length: "+(f|0)+" ≠ "+(u|0));for(var p=t(o),v=0;v<f;v++)c[v].push(p[v])}return c}function l(m){var f=r(m);if(f.length===1)return f[0];if(f.length===2){if(f[0]===1)return f[1];if(f[1]===1)return f[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),au="splitUnit",Yd=["typed"],Wd=R(au,Yd,e=>{var{typed:n}=e;return n(au,{"Unit, Array":function(t,r){return t.splitUnit(r)}})}),iu="unaryMinus",Jd=["typed"],Qd=R(iu,Jd,e=>{var{typed:n}=e;return n(iu,{number:Wo,Complex:function(t){return t.neg()},BigNumber:function(t){return t.neg()},Fraction:function(t){return t.neg()},Unit:function(t){var r=t.clone();return r.value=this(t.value),r},"Array | Matrix":function(t){return be(t,this)}})}),ou="unaryPlus",Kd=["typed","config","BigNumber"],jd=R(ou,Kd,e=>{var{typed:n,config:a,BigNumber:t}=e;return n(ou,{number:Jo,Complex:function(i){return i},BigNumber:function(i){return i},Fraction:function(i){return i},Unit:function(i){return i.clone()},"Array | Matrix":function(i){return be(i,this)},"boolean | string":function(i){return a.number==="BigNumber"?new t(+i):+i}})}),su="abs",eg=["typed"],rg=R(su,eg,e=>{var{typed:n}=e;return n(su,{number:Zo,Complex:function(t){return t.abs()},BigNumber:function(t){return t.abs()},Fraction:function(t){return t.abs()},"Array | Matrix":function(t){return be(t,this)},Unit:function(t){return t.abs()}})}),uu="apply",tg=["typed","isInteger"],cu=R(uu,tg,e=>{var{typed:n,isInteger:a}=e;return n(uu,{"Array | Matrix, number | BigNumber, function":function(r,i,l){if(!a(i))throw new TypeError("Integer number expected for dimension");var m=Array.isArray(r)?Pe(r):r.size();if(i<0||i>=m.length)throw new Kr(i,m.length);return Oe(r)?r.create(Aa(r.valueOf(),i,l)):Aa(r,i,l)}})});function Aa(e,n,a){var t,r,i;if(n<=0)if(Array.isArray(e[0])){for(i=ng(e),r=[],t=0;t<i.length;t++)r[t]=Aa(i[t],n-1,a);return r}else return a(e);else{for(r=[],t=0;t<e.length;t++)r[t]=Aa(e[t],n-1,a);return r}}function ng(e){var n=e.length,a=e[0].length,t,r,i=[];for(r=0;r<a;r++){var l=[];for(t=0;t<n;t++)l.push(e[t][r]);i.push(l)}return i}var fu="addScalar",ag=["typed"],ig=R(fu,ag,e=>{var{typed:n}=e;return n(fu,{"number, number":Xo,"Complex, Complex":function(t,r){return t.add(r)},"BigNumber, BigNumber":function(t,r){return t.plus(r)},"Fraction, Fraction":function(t,r){return t.add(r)},"Unit, Unit":function(t,r){if(t.value===null||t.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(r.value===null||r.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!t.equalBase(r))throw new Error("Units do not match");var i=t.clone();return i.value=this(i.value,r.value),i.fixPrefix=!1,i}})}),lu="cbrt",og=["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],sg=R(lu,og,e=>{var{config:n,typed:a,isNegative:t,unaryMinus:r,matrix:i,Complex:l,BigNumber:m,Fraction:f}=e;return a(lu,{number:$n,Complex:c,"Complex, boolean":c,BigNumber:function(u){return u.cbrt()},Unit:s,"Array | Matrix":function(u){return be(u,this)}});function c(o,u){var p=o.arg()/3,v=o.abs(),h=new l($n(v),0).mul(new l(0,p).exp());if(u){var b=[h,new l($n(v),0).mul(new l(0,p+Math.PI*2/3).exp()),new l($n(v),0).mul(new l(0,p-Math.PI*2/3).exp())];return n.matrix==="Array"?b:i(b)}else return h}function s(o){if(o.value&&Or(o.value)){var u=o.clone();return u.value=1,u=u.pow(1/3),u.value=c(o.value),u}else{var p=t(o.value);p&&(o.value=r(o.value));var v;_e(o.value)?v=new m(1).div(3):yr(o.value)?v=new f(1,3):v=1/3;var h=o.pow(v);return p&&(h.value=r(h.value)),h}}}),ug="algorithm11",cg=["typed","equalScalar"],wr=R(ug,cg,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l,m){var f=r._values,c=r._index,s=r._ptr,o=r._size,u=r._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=o[0],v=o[1],h,b=a,w=0,N=l;typeof u=="string"&&(h=u,b=n.find(a,[h,h]),w=n.convert(0,h),i=n.convert(i,h),N=n.find(l,[h,h]));for(var g=[],y=[],x=[],d=0;d<v;d++){x[d]=y.length;for(var A=s[d],S=s[d+1],O=A;O<S;O++){var M=c[O],_=m?N(i,f[O]):N(f[O],i);b(_,w)||(y.push(M),g.push(_))}}return x[v]=y.length,r.createSparseMatrix({values:g,index:y,ptr:x,size:[p,v],datatype:h})}}),fg="algorithm12",lg=["typed","DenseMatrix"],gr=R(fg,lg,e=>{var{typed:n,DenseMatrix:a}=e;return function(r,i,l,m){var f=r._values,c=r._index,s=r._ptr,o=r._size,u=r._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=o[0],v=o[1],h,b=l;typeof u=="string"&&(h=u,i=n.convert(i,h),b=n.find(l,[h,h]));for(var w=[],N=[],g=[],y=0;y<v;y++){for(var x=y+1,d=s[y],A=s[y+1],S=d;S<A;S++){var O=c[S];N[O]=f[S],g[O]=x}for(var M=0;M<p;M++)y===0&&(w[M]=[]),g[M]===x?w[M][y]=m?b(i,N[M]):b(N[M],i):w[M][y]=m?b(i,0):b(0,i)}return new a({data:w,size:[p,v],datatype:h})}}),mg="algorithm14",pg=["typed"],Ge=R(mg,pg,e=>{var{typed:n}=e;return function(r,i,l,m){var f=r._data,c=r._size,s=r._datatype,o,u=l;typeof s=="string"&&(o=s,i=n.convert(i,o),u=n.find(l,[o,o]));var p=c.length>0?a(u,0,c,c[0],f,i,m):[];return r.createDenseMatrix({data:p,size:Ce(c),datatype:o})};function a(t,r,i,l,m,f,c){var s=[];if(r===i.length-1)for(var o=0;o<l;o++)s[o]=c?t(f,m[o]):t(m[o],f);else for(var u=0;u<l;u++)s[u]=a(t,r+1,i,i[r+1],m[u],f,c);return s}}),xi="ceil",vg=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],hg=R(xi,["typed","config","round"],e=>{var{typed:n,config:a,round:t}=e;return n(xi,{number:function(i){return Rr(i,t(i),a.epsilon)?t(i):Math.ceil(i)},"number, number":function(i,l){if(Rr(i,t(i,l),a.epsilon))return t(i,l);var[m,f]="".concat(i,"e").split("e"),c=Math.ceil(Number("".concat(m,"e").concat(Number(f)+l)));return[m,f]="".concat(c,"e").split("e"),Number("".concat(m,"e").concat(Number(f)-l))}})}),dg=R(xi,vg,e=>{var{typed:n,config:a,round:t,matrix:r,equalScalar:i,zeros:l,DenseMatrix:m}=e,f=wr({typed:n,equalScalar:i}),c=gr({typed:n,DenseMatrix:m}),s=Ge({typed:n}),o=hg({typed:n,config:a,round:t});return n("ceil",{number:o.signatures.number,"number,number":o.signatures["number,number"],Complex:function(p){return p.ceil()},"Complex, number":function(p,v){return p.ceil(v)},"Complex, BigNumber":function(p,v){return p.ceil(v.toNumber())},BigNumber:function(p){return st(p,t(p),a.epsilon)?t(p):p.ceil()},"BigNumber, BigNumber":function(p,v){return st(p,t(p,v),a.epsilon)?t(p,v):p.toDecimalPlaces(v.toNumber(),It.ROUND_CEIL)},Fraction:function(p){return p.ceil()},"Fraction, number":function(p,v){return p.ceil(v)},"Fraction, BigNumber":function(p,v){return p.ceil(v.toNumber())},"Array | Matrix":function(p){return be(p,this)},"Array, number | BigNumber":function(p,v){return be(p,h=>this(h,v))},"SparseMatrix, number | BigNumber":function(p,v){return f(p,v,this,!1)},"DenseMatrix, number | BigNumber":function(p,v){return s(p,v,this,!1)},"number | Complex | Fraction | BigNumber, Array":function(p,v){return s(r(v),p,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(p,v){return i(p,0)?l(v.size(),v.storage()):v.storage()==="dense"?s(v,p,this,!0):c(v,p,this,!0)}})}),mu="cube",gg=["typed"],yg=R(mu,gg,e=>{var{typed:n}=e;return n(mu,{number:Qo,Complex:function(t){return t.mul(t).mul(t)},BigNumber:function(t){return t.times(t).times(t)},Fraction:function(t){return t.pow(3)},"Array | Matrix":function(t){return be(t,this)},Unit:function(t){return t.pow(3)}})}),pu="exp",xg=["typed"],bg=R(pu,xg,e=>{var{typed:n}=e;return n(pu,{number:Ko,Complex:function(t){return t.exp()},BigNumber:function(t){return t.exp()},"Array | Matrix":function(t){return be(t,this)}})}),vu="expm1",wg=["typed","Complex"],Ng=R(vu,wg,e=>{var{typed:n,Complex:a}=e;return n(vu,{number:jo,Complex:function(r){var i=Math.exp(r.re);return new a(i*Math.cos(r.im)-1,i*Math.sin(r.im))},BigNumber:function(r){return r.exp().minus(1)},"Array | Matrix":function(r){return be(r,this)}})}),bi="fix",Mg=["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],Ag=R(bi,["typed","ceil","floor"],e=>{var{typed:n,ceil:a,floor:t}=e;return n(bi,{number:function(i){return i>0?t(i):a(i)},"number, number":function(i,l){return i>0?t(i,l):a(i,l)}})}),Sg=R(bi,Mg,e=>{var{typed:n,Complex:a,matrix:t,ceil:r,floor:i,equalScalar:l,zeros:m,DenseMatrix:f}=e,c=gr({typed:n,DenseMatrix:f}),s=Ge({typed:n}),o=Ag({typed:n,ceil:r,floor:i});return n("fix",{number:o.signatures.number,"number, number | BigNumber":o.signatures["number,number"],Complex:function(p){return new a(p.re>0?Math.floor(p.re):Math.ceil(p.re),p.im>0?Math.floor(p.im):Math.ceil(p.im))},"Complex, number":function(p,v){return new a(p.re>0?i(p.re,v):r(p.re,v),p.im>0?i(p.im,v):r(p.im,v))},"Complex, BigNumber":function(p,v){var h=v.toNumber();return new a(p.re>0?i(p.re,h):r(p.re,h),p.im>0?i(p.im,h):r(p.im,h))},BigNumber:function(p){return p.isNegative()?r(p):i(p)},"BigNumber, number | BigNumber":function(p,v){return p.isNegative()?r(p,v):i(p,v)},Fraction:function(p){return p.s<0?p.ceil():p.floor()},"Fraction, number | BigNumber":function(p,v){return p.s<0?r(p,v):i(p,v)},"Array | Matrix":function(p){return be(p,this)},"Array | Matrix, number | BigNumber":function(p,v){return be(p,h=>this(h,v))},"number | Complex | Fraction | BigNumber, Array":function(p,v){return s(t(v),p,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(p,v){return l(p,0)?m(v.size(),v.storage()):v.storage()==="dense"?s(v,p,this,!0):c(v,p,this,!0)}})}),wi="floor",Eg=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],Cg=R(wi,["typed","config","round"],e=>{var{typed:n,config:a,round:t}=e;return n(wi,{number:function(i){return Rr(i,t(i),a.epsilon)?t(i):Math.floor(i)},"number, number":function(i,l){if(Rr(i,t(i,l),a.epsilon))return t(i,l);var[m,f]="".concat(i,"e").split("e"),c=Math.floor(Number("".concat(m,"e").concat(Number(f)+l)));return[m,f]="".concat(c,"e").split("e"),Number("".concat(m,"e").concat(Number(f)-l))}})}),Og=R(wi,Eg,e=>{var{typed:n,config:a,round:t,matrix:r,equalScalar:i,zeros:l,DenseMatrix:m}=e,f=wr({typed:n,equalScalar:i}),c=gr({typed:n,DenseMatrix:m}),s=Ge({typed:n}),o=Cg({typed:n,config:a,round:t});return n("floor",{number:o.signatures.number,"number,number":o.signatures["number,number"],Complex:function(p){return p.floor()},"Complex, number":function(p,v){return p.floor(v)},"Complex, BigNumber":function(p,v){return p.floor(v.toNumber())},BigNumber:function(p){return st(p,t(p),a.epsilon)?t(p):p.floor()},"BigNumber, BigNumber":function(p,v){return st(p,t(p,v),a.epsilon)?t(p,v):p.toDecimalPlaces(v.toNumber(),It.ROUND_FLOOR)},Fraction:function(p){return p.floor()},"Fraction, number":function(p,v){return p.floor(v)},"Fraction, BigNumber":function(p,v){return p.floor(v.toNumber())},"Array | Matrix":function(p){return be(p,this)},"Array, number | BigNumber":function(p,v){return be(p,h=>this(h,v))},"SparseMatrix, number | BigNumber":function(p,v){return f(p,v,this,!1)},"DenseMatrix, number | BigNumber":function(p,v){return s(p,v,this,!1)},"number | Complex | Fraction | BigNumber, Array":function(p,v){return s(r(v),p,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(p,v){return i(p,0)?l(v.size(),v.storage()):v.storage()==="dense"?s(v,p,this,!0):c(v,p,this,!0)}})}),Dg="algorithm01",Tg=["typed"],qt=R(Dg,Tg,e=>{var{typed:n}=e;return function(t,r,i,l){var m=t._data,f=t._size,c=t._datatype,s=r._values,o=r._index,u=r._ptr,p=r._size,v=r._datatype;if(f.length!==p.length)throw new Fe(f.length,p.length);if(f[0]!==p[0]||f[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+p+")");if(!s)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h=f[0],b=f[1],w=typeof c=="string"&&c===v?c:void 0,N=w?n.find(i,[w,w]):i,g,y,x=[];for(g=0;g<h;g++)x[g]=[];var d=[],A=[];for(y=0;y<b;y++){for(var S=y+1,O=u[y],M=u[y+1],_=O;_<M;_++)g=o[_],d[g]=l?N(s[_],m[g][y]):N(m[g][y],s[_]),A[g]=S;for(g=0;g<h;g++)A[g]===S?x[g][y]=d[g]:x[g][y]=m[g][y]}return t.createDenseMatrix({data:x,size:[h,b],datatype:w})}}),Bg="algorithm04",_g=["typed","equalScalar"],Ni=R(Bg,_g,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._index,c=r._ptr,s=r._size,o=r._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new Fe(s.length,h.length);if(s[0]!==h[0]||s[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+h+")");var w=s[0],N=s[1],g,y=a,x=0,d=l;typeof o=="string"&&o===b&&(g=o,y=n.find(a,[g,g]),x=n.convert(0,g),d=n.find(l,[g,g]));var A=m&&u?[]:void 0,S=[],O=[],M=m&&u?[]:void 0,_=m&&u?[]:void 0,E=[],$=[],z,I,T,B,G;for(I=0;I<N;I++){O[I]=S.length;var D=I+1;for(B=c[I],G=c[I+1],T=B;T<G;T++)z=f[T],S.push(z),E[z]=D,M&&(M[z]=m[T]);for(B=v[I],G=v[I+1],T=B;T<G;T++)if(z=p[T],E[z]===D){if(M){var H=d(M[z],u[T]);y(H,x)?E[z]=null:M[z]=H}}else S.push(z),$[z]=D,_&&(_[z]=u[T]);if(M&&_)for(T=O[I];T<S.length;)z=S[T],E[z]===D?(A[T]=M[z],T++):$[z]===D?(A[T]=_[z],T++):S.splice(T,1)}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),$g="algorithm10",Ig=["typed","DenseMatrix"],Vt=R($g,Ig,e=>{var{typed:n,DenseMatrix:a}=e;return function(r,i,l,m){var f=r._values,c=r._index,s=r._ptr,o=r._size,u=r._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=o[0],v=o[1],h,b=l;typeof u=="string"&&(h=u,i=n.convert(i,h),b=n.find(l,[h,h]));for(var w=[],N=[],g=[],y=0;y<v;y++){for(var x=y+1,d=s[y],A=s[y+1],S=d;S<A;S++){var O=c[S];N[O]=f[S],g[O]=x}for(var M=0;M<p;M++)y===0&&(w[M]=[]),g[M]===x?w[M][y]=m?b(i,N[M]):b(N[M],i):w[M][y]=i}return new a({data:w,size:[p,v],datatype:h})}}),qg="algorithm13",Rg=["typed"],je=R(qg,Rg,e=>{var{typed:n}=e;return function(r,i,l){var m=r._data,f=r._size,c=r._datatype,s=i._data,o=i._size,u=i._datatype,p=[];if(f.length!==o.length)throw new Fe(f.length,o.length);for(var v=0;v<f.length;v++){if(f[v]!==o[v])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+o+")");p[v]=f[v]}var h,b=l;typeof c=="string"&&c===u&&(h=c,b=n.find(l,[h,h]));var w=p.length>0?a(b,0,p,p[0],m,s):[];return r.createDenseMatrix({data:w,size:p,datatype:h})};function a(t,r,i,l,m,f){var c=[];if(r===i.length-1)for(var s=0;s<l;s++)c[s]=t(m[s],f[s]);else for(var o=0;o<l;o++)c[o]=a(t,r+1,i,i[r+1],m[o],f[o]);return c}}),hu="gcd",Fg=["typed","matrix","equalScalar","BigNumber","DenseMatrix"],zg=R(hu,Fg,e=>{var{typed:n,matrix:a,equalScalar:t,BigNumber:r,DenseMatrix:i}=e,l=qt({typed:n}),m=Ni({typed:n,equalScalar:t}),f=Vt({typed:n,DenseMatrix:i}),c=je({typed:n}),s=Ge({typed:n});return n(hu,{"number, number":es,"BigNumber, BigNumber":o,"Fraction, Fraction":function(p,v){return p.gcd(v)},"SparseMatrix, SparseMatrix":function(p,v){return m(p,v,this)},"SparseMatrix, DenseMatrix":function(p,v){return l(v,p,this,!0)},"DenseMatrix, SparseMatrix":function(p,v){return l(p,v,this,!1)},"DenseMatrix, DenseMatrix":function(p,v){return c(p,v,this)},"Array, Array":function(p,v){return this(a(p),a(v)).valueOf()},"Array, Matrix":function(p,v){return this(a(p),v)},"Matrix, Array":function(p,v){return this(p,a(v))},"SparseMatrix, number | BigNumber":function(p,v){return f(p,v,this,!1)},"DenseMatrix, number | BigNumber":function(p,v){return s(p,v,this,!1)},"number | BigNumber, SparseMatrix":function(p,v){return f(v,p,this,!0)},"number | BigNumber, DenseMatrix":function(p,v){return s(v,p,this,!0)},"Array, number | BigNumber":function(p,v){return s(a(p),v,this,!1).valueOf()},"number | BigNumber, Array":function(p,v){return s(a(v),p,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(p,v,h){for(var b=this(p,v),w=0;w<h.length;w++)b=this(b,h[w]);return b}});function o(u,p){if(!u.isInt()||!p.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var v=new r(0);!p.isZero();){var h=u.mod(p);u=p,p=h}return u.lt(v)?u.neg():u}}),Pg="algorithm02",Ug=["typed","equalScalar"],rt=R(Pg,Ug,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l,m){var f=r._data,c=r._size,s=r._datatype,o=i._values,u=i._index,p=i._ptr,v=i._size,h=i._datatype;if(c.length!==v.length)throw new Fe(c.length,v.length);if(c[0]!==v[0]||c[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+v+")");if(!o)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var b=c[0],w=c[1],N,g=a,y=0,x=l;typeof s=="string"&&s===h&&(N=s,g=n.find(a,[N,N]),y=n.convert(0,N),x=n.find(l,[N,N]));for(var d=[],A=[],S=[],O=0;O<w;O++){S[O]=A.length;for(var M=p[O],_=p[O+1],E=M;E<_;E++){var $=u[E],z=m?x(o[E],f[$][O]):x(f[$][O],o[E]);g(z,y)||(A.push($),d.push(z))}}return S[w]=A.length,i.createSparseMatrix({values:d,index:A,ptr:S,size:[b,w],datatype:N})}}),Lg="algorithm06",kg=["typed","equalScalar"],Sa=R(Lg,kg,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._size,c=r._datatype,s=i._values,o=i._size,u=i._datatype;if(f.length!==o.length)throw new Fe(f.length,o.length);if(f[0]!==o[0]||f[1]!==o[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+o+")");var p=f[0],v=f[1],h,b=a,w=0,N=l;typeof c=="string"&&c===u&&(h=c,b=n.find(a,[h,h]),w=n.convert(0,h),N=n.find(l,[h,h]));for(var g=m&&s?[]:void 0,y=[],x=[],d=g?[]:void 0,A=[],S=[],O=0;O<v;O++){x[O]=y.length;var M=O+1;if(Go(r,O,A,d,S,M,y,N),Go(i,O,A,d,S,M,y,N),d)for(var _=x[O];_<y.length;){var E=y[_];if(S[E]===M){var $=d[E];b($,w)?y.splice(_,1):(g.push($),_++)}else y.splice(_,1)}else for(var z=x[O];z<y.length;){var I=y[z];S[I]!==M?y.splice(z,1):z++}}return x[v]=y.length,r.createSparseMatrix({values:g,index:y,ptr:x,size:[p,v],datatype:h})}}),du="lcm",Hg=["typed","matrix","equalScalar"],Gg=R(du,Hg,e=>{var{typed:n,matrix:a,equalScalar:t}=e,r=rt({typed:n,equalScalar:t}),i=Sa({typed:n,equalScalar:t}),l=wr({typed:n,equalScalar:t}),m=je({typed:n}),f=Ge({typed:n});return n(du,{"number, number":rs,"BigNumber, BigNumber":c,"Fraction, Fraction":function(o,u){return o.lcm(u)},"SparseMatrix, SparseMatrix":function(o,u){return i(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return r(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return r(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return m(o,u,this)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, number | BigNumber":function(o,u){return l(o,u,this,!1)},"DenseMatrix, number | BigNumber":function(o,u){return f(o,u,this,!1)},"number | BigNumber, SparseMatrix":function(o,u){return l(u,o,this,!0)},"number | BigNumber, DenseMatrix":function(o,u){return f(u,o,this,!0)},"Array, number | BigNumber":function(o,u){return f(a(o),u,this,!1).valueOf()},"number | BigNumber, Array":function(o,u){return f(a(u),o,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(o,u,p){for(var v=this(o,u),h=0;h<p.length;h++)v=this(v,p[h]);return v}});function c(s,o){if(!s.isInt()||!o.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(s.isZero())return s;if(o.isZero())return o;for(var u=s.times(o);!o.isZero();){var p=o;o=s.mod(p),s=p}return u.div(s).abs()}}),gu="log10",Vg=["typed","config","Complex"],Zg=R(gu,Vg,e=>{var{typed:n,config:a,Complex:t}=e;return n(gu,{number:function(i){return i>=0||a.predictable?ts(i):new t(i,0).log().div(Math.LN10)},Complex:function(i){return new t(i).log().div(Math.LN10)},BigNumber:function(i){return!i.isNegative()||a.predictable?i.log():new t(i.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(i){return be(i,this)}})}),yu="log2",Xg=["typed","config","Complex"],Yg=R(yu,Xg,e=>{var{typed:n,config:a,Complex:t}=e;return n(yu,{number:function(l){return l>=0||a.predictable?ns(l):r(new t(l,0))},Complex:r,BigNumber:function(l){return!l.isNegative()||a.predictable?l.log(2):r(new t(l.toNumber(),0))},"Array | Matrix":function(l){return be(l,this)}});function r(i){var l=Math.sqrt(i.re*i.re+i.im*i.im);return new t(Math.log2?Math.log2(l):Math.log(l)/Math.LN2,Math.atan2(i.im,i.re)/Math.LN2)}}),Wg="algorithm03",Jg=["typed"],Dr=R(Wg,Jg,e=>{var{typed:n}=e;return function(t,r,i,l){var m=t._data,f=t._size,c=t._datatype,s=r._values,o=r._index,u=r._ptr,p=r._size,v=r._datatype;if(f.length!==p.length)throw new Fe(f.length,p.length);if(f[0]!==p[0]||f[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+p+")");if(!s)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h=f[0],b=f[1],w,N=0,g=i;typeof c=="string"&&c===v&&(w=c,N=n.convert(0,w),g=n.find(i,[w,w]));for(var y=[],x=0;x<h;x++)y[x]=[];for(var d=[],A=[],S=0;S<b;S++){for(var O=S+1,M=u[S],_=u[S+1],E=M;E<_;E++){var $=o[E];d[$]=l?g(s[E],m[$][S]):g(m[$][S],s[E]),A[$]=O}for(var z=0;z<h;z++)A[z]===O?y[z][S]=d[z]:y[z][S]=l?g(N,m[z][S]):g(m[z][S],N)}return t.createDenseMatrix({data:y,size:[h,b],datatype:w})}}),Qg="algorithm05",Kg=["typed","equalScalar"],Ea=R(Qg,Kg,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._index,c=r._ptr,s=r._size,o=r._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new Fe(s.length,h.length);if(s[0]!==h[0]||s[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+h+")");var w=s[0],N=s[1],g,y=a,x=0,d=l;typeof o=="string"&&o===b&&(g=o,y=n.find(a,[g,g]),x=n.convert(0,g),d=n.find(l,[g,g]));var A=m&&u?[]:void 0,S=[],O=[],M=A?[]:void 0,_=A?[]:void 0,E=[],$=[],z,I,T,B;for(I=0;I<N;I++){O[I]=S.length;var G=I+1;for(T=c[I],B=c[I+1];T<B;T++)z=f[T],S.push(z),E[z]=G,M&&(M[z]=m[T]);for(T=v[I],B=v[I+1];T<B;T++)z=p[T],E[z]!==G&&S.push(z),$[z]=G,_&&(_[z]=u[T]);if(A)for(T=O[I];T<S.length;){z=S[T];var D=E[z],H=$[z];if(D===G||H===G){var W=D===G?M[z]:x,j=H===G?_[z]:x,V=d(W,j);y(V,x)?S.splice(T,1):(A.push(V),T++)}}}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),xu="mod",jg=["typed","matrix","equalScalar","DenseMatrix"],ey=R(xu,jg,e=>{var{typed:n,matrix:a,equalScalar:t,DenseMatrix:r}=e,i=rt({typed:n,equalScalar:t}),l=Dr({typed:n}),m=Ea({typed:n,equalScalar:t}),f=wr({typed:n,equalScalar:t}),c=gr({typed:n,DenseMatrix:r}),s=je({typed:n}),o=Ge({typed:n});return n(xu,{"number, number":as,"BigNumber, BigNumber":function(p,v){if(v.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return v.isZero()?p:p.mod(v)},"Fraction, Fraction":function(p,v){if(v.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return p.compare(0)>=0?p.mod(v):p.mod(v).add(v).mod(v)},"SparseMatrix, SparseMatrix":function(p,v){return m(p,v,this,!1)},"SparseMatrix, DenseMatrix":function(p,v){return i(v,p,this,!0)},"DenseMatrix, SparseMatrix":function(p,v){return l(p,v,this,!1)},"DenseMatrix, DenseMatrix":function(p,v){return s(p,v,this)},"Array, Array":function(p,v){return this(a(p),a(v)).valueOf()},"Array, Matrix":function(p,v){return this(a(p),v)},"Matrix, Array":function(p,v){return this(p,a(v))},"SparseMatrix, any":function(p,v){return f(p,v,this,!1)},"DenseMatrix, any":function(p,v){return o(p,v,this,!1)},"any, SparseMatrix":function(p,v){return c(v,p,this,!0)},"any, DenseMatrix":function(p,v){return o(v,p,this,!0)},"Array, any":function(p,v){return o(a(p),v,this,!1).valueOf()},"any, Array":function(p,v){return o(a(v),p,this,!0).valueOf()}})}),ry="multiplyScalar",ty=["typed"],ny=R(ry,ty,e=>{var{typed:n}=e;return n("multiplyScalar",{"number, number":Yo,"Complex, Complex":function(t,r){return t.mul(r)},"BigNumber, BigNumber":function(t,r){return t.times(r)},"Fraction, Fraction":function(t,r){return t.mul(r)},"number | Fraction | BigNumber | Complex, Unit":function(t,r){var i=r.clone();return i.value=i.value===null?i._normalize(t):this(i.value,t),i},"Unit, number | Fraction | BigNumber | Complex":function(t,r){var i=t.clone();return i.value=i.value===null?i._normalize(r):this(i.value,r),i},"Unit, Unit":function(t,r){return t.multiply(r)}})}),bu="multiply",ay=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],iy=R(bu,ay,e=>{var{typed:n,matrix:a,addScalar:t,multiplyScalar:r,equalScalar:i,dot:l}=e,m=wr({typed:n,equalScalar:i}),f=Ge({typed:n});function c(x,d){switch(x.length){case 1:switch(d.length){case 1:if(x[0]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(x[0]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+x[0]+") must match Matrix rows ("+d[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+d.length+" dimensions)")}break;case 2:switch(d.length){case 1:if(x[1]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+x[1]+") must match Vector length ("+d[0]+")");break;case 2:if(x[1]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+x[1]+") must match Matrix B rows ("+d[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+d.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+x.length+" dimensions)")}}function s(x,d,A){if(A===0)throw new Error("Cannot multiply two empty vectors");return l(x,d)}function o(x,d){if(d.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return u(x,d)}function u(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._data,_=d._size,E=d._datatype,$=S[0],z=_[1],I,T=t,B=r;O&&E&&O===E&&typeof O=="string"&&(I=O,T=n.find(t,[I,I]),B=n.find(r,[I,I]));for(var G=[],D=0;D<z;D++){for(var H=B(A[0],M[0][D]),W=1;W<$;W++)H=T(H,B(A[W],M[W][D]));G[D]=H}return x.createDenseMatrix({data:G,size:[z],datatype:I})}var p=n("_multiplyMatrixVector",{"DenseMatrix, any":h,"SparseMatrix, any":N}),v=n("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":b,"DenseMatrix, SparseMatrix":w,"SparseMatrix, DenseMatrix":g,"SparseMatrix, SparseMatrix":y});function h(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._data,_=d._datatype,E=S[0],$=S[1],z,I=t,T=r;O&&_&&O===_&&typeof O=="string"&&(z=O,I=n.find(t,[z,z]),T=n.find(r,[z,z]));for(var B=[],G=0;G<E;G++){for(var D=A[G],H=T(D[0],M[0]),W=1;W<$;W++)H=I(H,T(D[W],M[W]));B[G]=H}return x.createDenseMatrix({data:B,size:[E],datatype:z})}function b(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._data,_=d._size,E=d._datatype,$=S[0],z=S[1],I=_[1],T,B=t,G=r;O&&E&&O===E&&typeof O=="string"&&(T=O,B=n.find(t,[T,T]),G=n.find(r,[T,T]));for(var D=[],H=0;H<$;H++){var W=A[H];D[H]=[];for(var j=0;j<I;j++){for(var V=G(W[0],M[0][j]),K=1;K<z;K++)V=B(V,G(W[K],M[K][j]));D[H][j]=V}}return x.createDenseMatrix({data:D,size:[$,I],datatype:T})}function w(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._values,_=d._index,E=d._ptr,$=d._size,z=d._datatype;if(!M)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var I=S[0],T=$[1],B,G=t,D=r,H=i,W=0;O&&z&&O===z&&typeof O=="string"&&(B=O,G=n.find(t,[B,B]),D=n.find(r,[B,B]),H=n.find(i,[B,B]),W=n.convert(0,B));for(var j=[],V=[],K=[],te=d.createSparseMatrix({values:j,index:V,ptr:K,size:[I,T],datatype:B}),re=0;re<T;re++){K[re]=V.length;var ie=E[re],ne=E[re+1];if(ne>ie)for(var ue=0,ee=0;ee<I;ee++){for(var ye=ee+1,we=void 0,me=ie;me<ne;me++){var xe=_[me];ue!==ye?(we=D(A[ee][xe],M[me]),ue=ye):we=G(we,D(A[ee][xe],M[me]))}ue===ye&&!H(we,W)&&(V.push(ee),j.push(we))}}return K[T]=V.length,te}function N(x,d){var A=x._values,S=x._index,O=x._ptr,M=x._datatype;if(!A)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var _=d._data,E=d._datatype,$=x._size[0],z=d._size[0],I=[],T=[],B=[],G,D=t,H=r,W=i,j=0;M&&E&&M===E&&typeof M=="string"&&(G=M,D=n.find(t,[G,G]),H=n.find(r,[G,G]),W=n.find(i,[G,G]),j=n.convert(0,G));var V=[],K=[];B[0]=0;for(var te=0;te<z;te++){var re=_[te];if(!W(re,j))for(var ie=O[te],ne=O[te+1],ue=ie;ue<ne;ue++){var ee=S[ue];K[ee]?V[ee]=D(V[ee],H(re,A[ue])):(K[ee]=!0,T.push(ee),V[ee]=H(re,A[ue]))}}for(var ye=T.length,we=0;we<ye;we++){var me=T[we];I[we]=V[me]}return B[1]=T.length,x.createSparseMatrix({values:I,index:T,ptr:B,size:[$,1],datatype:G})}function g(x,d){var A=x._values,S=x._index,O=x._ptr,M=x._datatype;if(!A)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var _=d._data,E=d._datatype,$=x._size[0],z=d._size[0],I=d._size[1],T,B=t,G=r,D=i,H=0;M&&E&&M===E&&typeof M=="string"&&(T=M,B=n.find(t,[T,T]),G=n.find(r,[T,T]),D=n.find(i,[T,T]),H=n.convert(0,T));for(var W=[],j=[],V=[],K=x.createSparseMatrix({values:W,index:j,ptr:V,size:[$,I],datatype:T}),te=[],re=[],ie=0;ie<I;ie++){V[ie]=j.length;for(var ne=ie+1,ue=0;ue<z;ue++){var ee=_[ue][ie];if(!D(ee,H))for(var ye=O[ue],we=O[ue+1],me=ye;me<we;me++){var xe=S[me];re[xe]!==ne?(re[xe]=ne,j.push(xe),te[xe]=G(ee,A[me])):te[xe]=B(te[xe],G(ee,A[me]))}}for(var F=V[ie],Y=j.length,k=F;k<Y;k++){var U=j[k];W[k]=te[U]}}return V[I]=j.length,K}function y(x,d){var A=x._values,S=x._index,O=x._ptr,M=x._datatype,_=d._values,E=d._index,$=d._ptr,z=d._datatype,I=x._size[0],T=d._size[1],B=A&&_,G,D=t,H=r;M&&z&&M===z&&typeof M=="string"&&(G=M,D=n.find(t,[G,G]),H=n.find(r,[G,G]));for(var W=B?[]:void 0,j=[],V=[],K=x.createSparseMatrix({values:W,index:j,ptr:V,size:[I,T],datatype:G}),te=B?[]:void 0,re=[],ie,ne,ue,ee,ye,we,me,xe,F=0;F<T;F++){V[F]=j.length;var Y=F+1;for(ye=$[F],we=$[F+1],ee=ye;ee<we;ee++)if(xe=E[ee],B)for(ne=O[xe],ue=O[xe+1],ie=ne;ie<ue;ie++)me=S[ie],re[me]!==Y?(re[me]=Y,j.push(me),te[me]=H(_[ee],A[ie])):te[me]=D(te[me],H(_[ee],A[ie]));else for(ne=O[xe],ue=O[xe+1],ie=ne;ie<ue;ie++)me=S[ie],re[me]!==Y&&(re[me]=Y,j.push(me));if(B)for(var k=V[F],U=j.length,J=k;J<U;J++){var q=j[J];W[J]=te[q]}}return V[T]=j.length,K}return n(bu,Ka({"Array, Array":function(d,A){c(Pe(d),Pe(A));var S=this(a(d),a(A));return Oe(S)?S.valueOf():S},"Matrix, Matrix":function(d,A){var S=d.size(),O=A.size();return c(S,O),S.length===1?O.length===1?s(d,A,S[0]):o(d,A):O.length===1?p(d,A):v(d,A)},"Matrix, Array":function(d,A){return this(d,a(A))},"Array, Matrix":function(d,A){return this(a(d,A.storage()),A)},"SparseMatrix, any":function(d,A){return m(d,A,r,!1)},"DenseMatrix, any":function(d,A){return f(d,A,r,!1)},"any, SparseMatrix":function(d,A){return m(A,d,r,!0)},"any, DenseMatrix":function(d,A){return f(A,d,r,!0)},"Array, any":function(d,A){return f(a(d),A,r,!1).valueOf()},"any, Array":function(d,A){return f(a(A),d,r,!0).valueOf()},"any, any":r,"any, any, ...any":function(d,A,S){for(var O=this(d,A),M=0;M<S.length;M++)O=this(O,S[M]);return O}},r.signatures))}),wu="nthRoot",oy=["typed","matrix","equalScalar","BigNumber"],sy=R(wu,oy,e=>{var{typed:n,matrix:a,equalScalar:t,BigNumber:r}=e,i=qt({typed:n}),l=rt({typed:n,equalScalar:t}),m=Sa({typed:n,equalScalar:t}),f=wr({typed:n,equalScalar:t}),c=je({typed:n}),s=Ge({typed:n}),o="Complex number not supported in function nthRoot. Use nthRoots instead.";return n(wu,{number:is,"number, number":is,BigNumber:function(v){return u(v,new r(2))},Complex:function(v){throw new Error(o)},"Complex, number":function(v,h){throw new Error(o)},"BigNumber, BigNumber":u,"Array | Matrix":function(v){return this(v,2)},"SparseMatrix, SparseMatrix":function(v,h){if(h.density()===1)return m(v,h,this);throw new Error("Root must be non-zero")},"SparseMatrix, DenseMatrix":function(v,h){return l(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){if(h.density()===1)return i(v,h,this,!1);throw new Error("Root must be non-zero")},"DenseMatrix, DenseMatrix":function(v,h){return c(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return f(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return s(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){if(h.density()===1)return f(h,v,this,!0);throw new Error("Root must be non-zero")},"number | BigNumber, DenseMatrix":function(v,h){return s(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(a(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,a(h)).valueOf()}});function u(p,v){var h=r.precision,b=r.clone({precision:h+2}),w=new r(0),N=new b(1),g=v.isNegative();if(g&&(v=v.neg()),v.isZero())throw new Error("Root must be non-zero");if(p.isNegative()&&!v.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(p.isZero())return g?new b(1/0):0;if(!p.isFinite())return g?w:p;var y=p.abs().pow(N.div(v));return y=p.isNeg()?y.neg():y,new r((g?N.div(y):y).toPrecision(h))}}),Nu="sign",uy=["typed","BigNumber","Fraction","complex"],cy=R(Nu,uy,e=>{var{typed:n,BigNumber:a,complex:t,Fraction:r}=e;return n(Nu,{number:di,Complex:function(l){return l.im===0?t(di(l.re)):l.sign()},BigNumber:function(l){return new a(l.cmp(0))},Fraction:function(l){return new r(l.s,1)},"Array | Matrix":function(l){return be(l,this)},Unit:function(l){if(!l._isDerived()&&l.units[0].unit.offset!==0)throw new TypeError("sign is ambiguous for units with offset");return this(l.value)}})}),fy="sqrt",ly=["config","typed","Complex"],my=R(fy,ly,e=>{var{config:n,typed:a,Complex:t}=e;return a("sqrt",{number:r,Complex:function(l){return l.sqrt()},BigNumber:function(l){return!l.isNegative()||n.predictable?l.sqrt():r(l.toNumber())},"Array | Matrix":function(l){return be(l,this)},Unit:function(l){return l.pow(.5)}});function r(i){return isNaN(i)?NaN:i>=0||n.predictable?Math.sqrt(i):new t(i,0).sqrt()}}),Mu="square",py=["typed"],vy=R(Mu,py,e=>{var{typed:n}=e;return n(Mu,{number:os,Complex:function(t){return t.mul(t)},BigNumber:function(t){return t.times(t)},Fraction:function(t){return t.mul(t)},"Array | Matrix":function(t){return be(t,this)},Unit:function(t){return t.pow(2)}})}),Au="subtract",hy=["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix"],dy=R(Au,hy,e=>{var{typed:n,matrix:a,equalScalar:t,addScalar:r,unaryMinus:i,DenseMatrix:l}=e,m=qt({typed:n}),f=Dr({typed:n}),c=Ea({typed:n,equalScalar:t}),s=Vt({typed:n,DenseMatrix:l}),o=je({typed:n}),u=Ge({typed:n});return n(Au,{"number, number":function(v,h){return v-h},"Complex, Complex":function(v,h){return v.sub(h)},"BigNumber, BigNumber":function(v,h){return v.minus(h)},"Fraction, Fraction":function(v,h){return v.sub(h)},"Unit, Unit":function(v,h){if(v.value===null)throw new Error("Parameter x contains a unit with undefined value");if(h.value===null)throw new Error("Parameter y contains a unit with undefined value");if(!v.equalBase(h))throw new Error("Units do not match");var b=v.clone();return b.value=this(b.value,h.value),b.fixPrefix=!1,b},"SparseMatrix, SparseMatrix":function(v,h){return Ca(v,h),c(v,h,this)},"SparseMatrix, DenseMatrix":function(v,h){return Ca(v,h),f(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return Ca(v,h),m(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return Ca(v,h),o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, any":function(v,h){return s(v,i(h),r)},"DenseMatrix, any":function(v,h){return u(v,h,this)},"any, SparseMatrix":function(v,h){return s(h,v,this,!0)},"any, DenseMatrix":function(v,h){return u(h,v,this,!0)},"Array, any":function(v,h){return u(a(v),h,this,!1).valueOf()},"any, Array":function(v,h){return u(a(h),v,this,!0).valueOf()}})});function Ca(e,n){var a=e.size(),t=n.size();if(a.length!==t.length)throw new Fe(a.length,t.length)}var Su="xgcd",gy=["typed","config","matrix","BigNumber"],yy=R(Su,gy,e=>{var{typed:n,config:a,matrix:t,BigNumber:r}=e;return n(Su,{"number, number":function(m,f){var c=ss(m,f);return a.matrix==="Array"?c:t(c)},"BigNumber, BigNumber":i});function i(l,m){var f,c,s,o=new r(0),u=new r(1),p=o,v=u,h=u,b=o;if(!l.isInt()||!m.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!m.isZero();)c=l.div(m).floor(),s=l.mod(m),f=p,p=v.minus(c.times(p)),v=f,f=h,h=b.minus(c.times(h)),b=f,l=m,m=s;var w;return l.lt(o)?w=[l.neg(),v.neg(),b.neg()]:w=[l,l.isZero()?0:v,b],a.matrix==="Array"?w:t(w)}}),Eu="invmod",xy=["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],by=R(Eu,xy,e=>{var{typed:n,config:a,BigNumber:t,xgcd:r,equal:i,smaller:l,mod:m,add:f,isInteger:c}=e;return n(Eu,{"number, number":s,"BigNumber, BigNumber":s});function s(o,u){if(!c(o)||!c(u))throw new Error("Parameters in function invmod must be integer numbers");if(o=m(o,u),i(u,0))throw new Error("Divisor must be non zero");var p=r(o,u);p=p.valueOf();var[v,h]=p;return i(v,t(1))?(h=m(h,u),l(h,t(0))&&(h=f(h,u)),h):NaN}}),wy="algorithm09",Ny=["typed","equalScalar"],Cu=R(wy,Ny,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._index,c=r._ptr,s=r._size,o=r._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new Fe(s.length,h.length);if(s[0]!==h[0]||s[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+h+")");var w=s[0],N=s[1],g,y=a,x=0,d=l;typeof o=="string"&&o===b&&(g=o,y=n.find(a,[g,g]),x=n.convert(0,g),d=n.find(l,[g,g]));var A=m&&u?[]:void 0,S=[],O=[],M=A?[]:void 0,_=[],E,$,z,I,T;for($=0;$<N;$++){O[$]=S.length;var B=$+1;if(M)for(I=v[$],T=v[$+1],z=I;z<T;z++)E=p[z],_[E]=B,M[E]=u[z];for(I=c[$],T=c[$+1],z=I;z<T;z++)if(E=f[z],M){var G=_[E]===B?M[E]:x,D=d(m[z],G);y(D,x)||(S.push(E),A.push(D))}else S.push(E)}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),Ou="dotMultiply",My=["typed","matrix","equalScalar","multiplyScalar"],Ay=R(Ou,My,e=>{var{typed:n,matrix:a,equalScalar:t,multiplyScalar:r}=e,i=rt({typed:n,equalScalar:t}),l=Cu({typed:n,equalScalar:t}),m=wr({typed:n,equalScalar:t}),f=je({typed:n}),c=Ge({typed:n});return n(Ou,{"any, any":r,"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,r,!1)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,r,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,r,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,r)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, any":function(o,u){return m(o,u,r,!1)},"DenseMatrix, any":function(o,u){return c(o,u,r,!1)},"any, SparseMatrix":function(o,u){return m(u,o,r,!0)},"any, DenseMatrix":function(o,u){return c(u,o,r,!0)},"Array, any":function(o,u){return c(a(o),u,r,!1).valueOf()},"any, Array":function(o,u){return c(a(u),o,r,!0).valueOf()}})});function Sy(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function bitAnd");var a=e.constructor;if(e.isNaN()||n.isNaN())return new a(NaN);if(e.isZero()||n.eq(-1)||e.eq(n))return e;if(n.isZero()||e.eq(-1))return n;if(!e.isFinite()||!n.isFinite()){if(!e.isFinite()&&!n.isFinite())return e.isNegative()===n.isNegative()?e:new a(0);if(!e.isFinite())return n.isNegative()?e:e.isNegative()?new a(0):n;if(!n.isFinite())return e.isNegative()?n:n.isNegative()?new a(0):e}return Mi(e,n,function(t,r){return t&r})}function In(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var n=e.constructor,a=n.precision;n.config({precision:1e9});var t=e.plus(new n(1));return t.s=-t.s||null,n.config({precision:a}),t}function Ey(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function bitOr");var a=e.constructor;if(e.isNaN()||n.isNaN())return new a(NaN);var t=new a(-1);return e.isZero()||n.eq(t)||e.eq(n)?n:n.isZero()||e.eq(t)?e:!e.isFinite()||!n.isFinite()?!e.isFinite()&&!e.isNegative()&&n.isNegative()||e.isNegative()&&!n.isNegative()&&!n.isFinite()?t:e.isNegative()&&n.isNegative()?e.isFinite()?e:n:e.isFinite()?n:e:Mi(e,n,function(r,i){return r|i})}function Mi(e,n,a){var t=e.constructor,r,i,l=+(e.s<0),m=+(n.s<0);if(l){r=Oa(In(e));for(var f=0;f<r.length;++f)r[f]^=1}else r=Oa(e);if(m){i=Oa(In(n));for(var c=0;c<i.length;++c)i[c]^=1}else i=Oa(n);var s,o,u;r.length<=i.length?(s=r,o=i,u=l):(s=i,o=r,u=m);var p=s.length,v=o.length,h=a(l,m)^1,b=new t(h^1),w=new t(1),N=new t(2),g=t.precision;for(t.config({precision:1e9});p>0;)a(s[--p],o[--v])===h&&(b=b.plus(w)),w=w.times(N);for(;v>0;)a(u,o[--v])===h&&(b=b.plus(w)),w=w.times(N);return t.config({precision:g}),h===0&&(b.s=-b.s),b}function Oa(e){for(var n=e.d,a=n[0]+"",t=1;t<n.length;++t){for(var r=n[t]+"",i=7-r.length;i--;)r="0"+r;a+=r}for(var l=a.length;a.charAt(l)==="0";)l--;var m=e.e,f=a.slice(0,l+1||1),c=f.length;if(m>0)if(++m>c)for(m-=c;m--;)f+="0";else m<c&&(f=f.slice(0,m)+"."+f.slice(m));for(var s=[0],o=0;o<f.length;){for(var u=s.length;u--;)s[u]*=10;s[0]+=parseInt(f.charAt(o++));for(var p=0;p<s.length;++p)s[p]>1&&((s[p+1]===null||s[p+1]===void 0)&&(s[p+1]=0),s[p+1]+=s[p]>>1,s[p]&=1)}return s.reverse()}function Cy(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function bitXor");var a=e.constructor;if(e.isNaN()||n.isNaN())return new a(NaN);if(e.isZero())return n;if(n.isZero())return e;if(e.eq(n))return new a(0);var t=new a(-1);return e.eq(t)?In(n):n.eq(t)?In(e):!e.isFinite()||!n.isFinite()?!e.isFinite()&&!n.isFinite()?t:new a(e.isNegative()===n.isNegative()?1/0:-1/0):Mi(e,n,function(r,i){return r^i})}function Oy(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function leftShift");var a=e.constructor;return e.isNaN()||n.isNaN()||n.isNegative()&&!n.isZero()?new a(NaN):e.isZero()||n.isZero()?e:!e.isFinite()&&!n.isFinite()?new a(NaN):n.lt(55)?e.times(Math.pow(2,n.toNumber())+""):e.times(new a(2).pow(n))}function Dy(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function rightArithShift");var a=e.constructor;return e.isNaN()||n.isNaN()||n.isNegative()&&!n.isZero()?new a(NaN):e.isZero()||n.isZero()?e:n.isFinite()?n.lt(55)?e.div(Math.pow(2,n.toNumber())+"").floor():e.div(new a(2).pow(n)).floor():e.isNegative()?new a(-1):e.isFinite()?new a(0):new a(NaN)}var Du="bitAnd",Ty=["typed","matrix","equalScalar"],By=R(Du,Ty,e=>{var{typed:n,matrix:a,equalScalar:t}=e,r=rt({typed:n,equalScalar:t}),i=Sa({typed:n,equalScalar:t}),l=wr({typed:n,equalScalar:t}),m=je({typed:n}),f=Ge({typed:n});return n(Du,{"number, number":fs,"BigNumber, BigNumber":Sy,"SparseMatrix, SparseMatrix":function(s,o){return i(s,o,this,!1)},"SparseMatrix, DenseMatrix":function(s,o){return r(o,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,o){return r(s,o,this,!1)},"DenseMatrix, DenseMatrix":function(s,o){return m(s,o,this)},"Array, Array":function(s,o){return this(a(s),a(o)).valueOf()},"Array, Matrix":function(s,o){return this(a(s),o)},"Matrix, Array":function(s,o){return this(s,a(o))},"SparseMatrix, any":function(s,o){return l(s,o,this,!1)},"DenseMatrix, any":function(s,o){return f(s,o,this,!1)},"any, SparseMatrix":function(s,o){return l(o,s,this,!0)},"any, DenseMatrix":function(s,o){return f(o,s,this,!0)},"Array, any":function(s,o){return f(a(s),o,this,!1).valueOf()},"any, Array":function(s,o){return f(a(o),s,this,!0).valueOf()}})}),Tu="bitNot",_y=["typed"],$y=R(Tu,_y,e=>{var{typed:n}=e;return n(Tu,{number:ls,BigNumber:In,"Array | Matrix":function(t){return be(t,this)}})}),Bu="bitOr",Iy=["typed","matrix","equalScalar","DenseMatrix"],qy=R(Bu,Iy,e=>{var{typed:n,matrix:a,equalScalar:t,DenseMatrix:r}=e,i=qt({typed:n}),l=Ni({typed:n,equalScalar:t}),m=Vt({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(Bu,{"number, number":ms,"BigNumber, BigNumber":Ey,"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(a(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(a(u),o,this,!0).valueOf()}})}),Ry="algorithm07",Fy=["typed","DenseMatrix"],ut=R(Ry,Fy,e=>{var{typed:n,DenseMatrix:a}=e;return function(i,l,m){var f=i._size,c=i._datatype,s=l._size,o=l._datatype;if(f.length!==s.length)throw new Fe(f.length,s.length);if(f[0]!==s[0]||f[1]!==s[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+s+")");var u=f[0],p=f[1],v,h=0,b=m;typeof c=="string"&&c===o&&(v=c,h=n.convert(0,v),b=n.find(m,[v,v]));var w,N,g=[];for(w=0;w<u;w++)g[w]=[];var y=[],x=[],d=[],A=[];for(N=0;N<p;N++){var S=N+1;for(t(i,N,d,y,S),t(l,N,A,x,S),w=0;w<u;w++){var O=d[w]===S?y[w]:h,M=A[w]===S?x[w]:h;g[w][N]=b(O,M)}}return new a({data:g,size:[u,p],datatype:v})};function t(r,i,l,m,f){for(var c=r._values,s=r._index,o=r._ptr,u=o[i],p=o[i+1];u<p;u++){var v=s[u];l[v]=f,m[v]=c[u]}}}),_u="bitXor",zy=["typed","matrix","DenseMatrix"],Py=R(_u,zy,e=>{var{typed:n,matrix:a,DenseMatrix:t}=e,r=Dr({typed:n}),i=ut({typed:n,DenseMatrix:t}),l=gr({typed:n,DenseMatrix:t}),m=je({typed:n}),f=Ge({typed:n});return n(_u,{"number, number":ps,"BigNumber, BigNumber":Cy,"SparseMatrix, SparseMatrix":function(s,o){return i(s,o,this)},"SparseMatrix, DenseMatrix":function(s,o){return r(o,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,o){return r(s,o,this,!1)},"DenseMatrix, DenseMatrix":function(s,o){return m(s,o,this)},"Array, Array":function(s,o){return this(a(s),a(o)).valueOf()},"Array, Matrix":function(s,o){return this(a(s),o)},"Matrix, Array":function(s,o){return this(s,a(o))},"SparseMatrix, any":function(s,o){return l(s,o,this,!1)},"DenseMatrix, any":function(s,o){return f(s,o,this,!1)},"any, SparseMatrix":function(s,o){return l(o,s,this,!0)},"any, DenseMatrix":function(s,o){return f(o,s,this,!0)},"Array, any":function(s,o){return f(a(s),o,this,!1).valueOf()},"any, Array":function(s,o){return f(a(o),s,this,!0).valueOf()}})}),$u="arg",Uy=["typed"],Ly=R($u,Uy,e=>{var{typed:n}=e;return n($u,{number:function(t){return Math.atan2(0,t)},BigNumber:function(t){return t.constructor.atan2(0,t)},Complex:function(t){return t.arg()},"Array | Matrix":function(t){return be(t,this)}})}),Iu="conj",ky=["typed"],Hy=R(Iu,ky,e=>{var{typed:n}=e;return n(Iu,{number:function(t){return t},BigNumber:function(t){return t},Complex:function(t){return t.conjugate()},"Array | Matrix":function(t){return be(t,this)}})}),qu="im",Gy=["typed"],Vy=R(qu,Gy,e=>{var{typed:n}=e;return n(qu,{number:function(t){return 0},BigNumber:function(t){return t.mul(0)},Fraction:function(t){return t.mul(0)},Complex:function(t){return t.im},"Array | Matrix":function(t){return be(t,this)}})}),Ru="re",Zy=["typed"],Xy=R(Ru,Zy,e=>{var{typed:n}=e;return n(Ru,{number:function(t){return t},BigNumber:function(t){return t},Fraction:function(t){return t},Complex:function(t){return t.re},"Array | Matrix":function(t){return be(t,this)}})}),Fu="not",Yy=["typed"],Wy=R(Fu,Yy,e=>{var{typed:n}=e;return n(Fu,{number:ys,Complex:function(t){return t.re===0&&t.im===0},BigNumber:function(t){return t.isZero()||t.isNaN()},Unit:function(t){return t.value!==null?this(t.value):!0},"Array | Matrix":function(t){return be(t,this)}})}),zu="or",Jy=["typed","matrix","equalScalar","DenseMatrix"],Qy=R(zu,Jy,e=>{var{typed:n,matrix:a,equalScalar:t,DenseMatrix:r}=e,i=Dr({typed:n}),l=Ea({typed:n,equalScalar:t}),m=gr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(zu,{"number, number":xs,"Complex, Complex":function(o,u){return o.re!==0||o.im!==0||u.re!==0||u.im!==0},"BigNumber, BigNumber":function(o,u){return!o.isZero()&&!o.isNaN()||!u.isZero()&&!u.isNaN()},"Unit, Unit":function(o,u){return this(o.value||0,u.value||0)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(a(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(a(u),o,this,!0).valueOf()}})}),Pu="xor",Ky=["typed","matrix","DenseMatrix"],jy=R(Pu,Ky,e=>{var{typed:n,matrix:a,DenseMatrix:t}=e,r=Dr({typed:n}),i=ut({typed:n,DenseMatrix:t}),l=gr({typed:n,DenseMatrix:t}),m=je({typed:n}),f=Ge({typed:n});return n(Pu,{"number, number":bs,"Complex, Complex":function(s,o){return(s.re!==0||s.im!==0)!=(o.re!==0||o.im!==0)},"BigNumber, BigNumber":function(s,o){return(!s.isZero()&&!s.isNaN())!=(!o.isZero()&&!o.isNaN())},"Unit, Unit":function(s,o){return this(s.value||0,o.value||0)},"SparseMatrix, SparseMatrix":function(s,o){return i(s,o,this)},"SparseMatrix, DenseMatrix":function(s,o){return r(o,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,o){return r(s,o,this,!1)},"DenseMatrix, DenseMatrix":function(s,o){return m(s,o,this)},"Array, Array":function(s,o){return this(a(s),a(o)).valueOf()},"Array, Matrix":function(s,o){return this(a(s),o)},"Matrix, Array":function(s,o){return this(s,a(o))},"SparseMatrix, any":function(s,o){return l(s,o,this,!1)},"DenseMatrix, any":function(s,o){return f(s,o,this,!1)},"any, SparseMatrix":function(s,o){return l(o,s,this,!0)},"any, DenseMatrix":function(s,o){return f(o,s,this,!0)},"Array, any":function(s,o){return f(a(s),o,this,!1).valueOf()},"any, Array":function(s,o){return f(a(o),s,this,!0).valueOf()}})}),Uu="concat",e0=["typed","matrix","isInteger"],Lu=R(Uu,e0,e=>{var{typed:n,matrix:a,isInteger:t}=e;return n(Uu,{"...Array | Matrix | number | BigNumber":function(i){var l,m=i.length,f=-1,c,s=!1,o=[];for(l=0;l<m;l++){var u=i[l];if(Oe(u)&&(s=!0),Be(u)||_e(u)){if(l!==m-1)throw new Error("Dimension must be specified as last argument");if(c=f,f=u.valueOf(),!t(f))throw new TypeError("Integer number expected for dimension");if(f<0||l>0&&f>c)throw new Kr(f,c+1)}else{var p=Ce(u).valueOf(),v=Pe(p);if(o[l]=p,c=f,f=v.length-1,l>0&&f!==c)throw new Fe(c+1,f+1)}}if(o.length===0)throw new SyntaxError("At least one matrix expected");for(var h=o.shift();o.length;)h=ku(h,o.shift(),f,0);return s?a(h):h},"...string":function(i){return i.join("")}})});function ku(e,n,a,t){if(t<a){if(e.length!==n.length)throw new Fe(e.length,n.length);for(var r=[],i=0;i<e.length;i++)r[i]=ku(e[i],n[i],a,t+1);return r}else return e.concat(n)}var Hu="column",r0=["typed","Index","matrix","range"],Gu=R(Hu,r0,e=>{var{typed:n,Index:a,matrix:t,range:r}=e;return n(Hu,{"Matrix, number":i,"Array, number":function(m,f){return i(t(Ce(m)),f).valueOf()}});function i(l,m){if(l.size().length!==2)throw new Error("Only two dimensional matrix is supported");We(m,l.size()[1]);var f=r(0,l.size()[0]),c=new a(f,m);return l.subset(c)}}),Vu="count",t0=["typed","size","prod"],n0=R(Vu,t0,e=>{var{typed:n,size:a,prod:t}=e;return n(Vu,{string:function(i){return i.length},"Matrix | Array":function(i){return t(a(i))}})}),Zu="cross",a0=["typed","matrix","subtract","multiply"],i0=R(Zu,a0,e=>{var{typed:n,matrix:a,subtract:t,multiply:r}=e;return n(Zu,{"Matrix, Matrix":function(m,f){return a(i(m.toArray(),f.toArray()))},"Matrix, Array":function(m,f){return a(i(m.toArray(),f))},"Array, Matrix":function(m,f){return a(i(m,f.toArray()))},"Array, Array":i});function i(l,m){var f=Math.max(Pe(l).length,Pe(m).length);l=aa(l),m=aa(m);var c=Pe(l),s=Pe(m);if(c.length!==1||s.length!==1||c[0]!==3||s[0]!==3)throw new RangeError("Vectors with length 3 expected (Size A = ["+c.join(", ")+"], B = ["+s.join(", ")+"])");var o=[t(r(l[1],m[2]),r(l[2],m[1])),t(r(l[2],m[0]),r(l[0],m[2])),t(r(l[0],m[1]),r(l[1],m[0]))];return f>1?[o]:o}}),Xu="diag",o0=["typed","matrix","DenseMatrix","SparseMatrix"],s0=R(Xu,o0,e=>{var{typed:n,matrix:a,DenseMatrix:t,SparseMatrix:r}=e;return n(Xu,{Array:function(c){return i(c,0,Pe(c),null)},"Array, number":function(c,s){return i(c,s,Pe(c),null)},"Array, BigNumber":function(c,s){return i(c,s.toNumber(),Pe(c),null)},"Array, string":function(c,s){return i(c,0,Pe(c),s)},"Array, number, string":function(c,s,o){return i(c,s,Pe(c),o)},"Array, BigNumber, string":function(c,s,o){return i(c,s.toNumber(),Pe(c),o)},Matrix:function(c){return i(c,0,c.size(),c.storage())},"Matrix, number":function(c,s){return i(c,s,c.size(),c.storage())},"Matrix, BigNumber":function(c,s){return i(c,s.toNumber(),c.size(),c.storage())},"Matrix, string":function(c,s){return i(c,0,c.size(),s)},"Matrix, number, string":function(c,s,o){return i(c,s,c.size(),o)},"Matrix, BigNumber, string":function(c,s,o){return i(c,s.toNumber(),c.size(),o)}});function i(f,c,s,o){if(!Ae(c))throw new TypeError("Second parameter in function diag must be an integer");var u=c>0?c:0,p=c<0?-c:0;switch(s.length){case 1:return l(f,c,o,s[0],p,u);case 2:return m(f,c,o,s,p,u)}throw new RangeError("Matrix for function diag must be 2 dimensional")}function l(f,c,s,o,u,p){var v=[o+u,o+p];if(s&&s!=="sparse"&&s!=="dense")throw new TypeError("Unknown matrix type ".concat(s,'"'));var h=s==="sparse"?r.diagonal(v,f,c):t.diagonal(v,f,c);return s!==null?h:h.valueOf()}function m(f,c,s,o,u,p){if(Oe(f)){var v=f.diagonal(c);return s!==null?s!==v.storage()?a(v,s):v:v.valueOf()}for(var h=Math.min(o[0]-u,o[1]-p),b=[],w=0;w<h;w++)b[w]=f[w+u][w+p];return s!==null?a(b):b}});function u0(e){var n=0,a=1,t=Object.create(null),r=Object.create(null),i=0,l=function(f){var c=r[f];if(c&&(delete t[c],delete r[f],--n,a===c)){if(!n){i=0,a=1;return}for(;!hasOwnProperty.call(t,++a););}};return e=Math.abs(e),{hit:function(f){var c=r[f],s=++i;if(t[s]=f,r[f]=s,!c)return++n,n<=e?void 0:(f=t[a],l(f),f);if(delete t[c],a===c)for(;!hasOwnProperty.call(t,++a););},delete:l,clear:function(){n=i=0,a=1,t=Object.create(null),r=Object.create(null)}}}function qn(e){var{hasher:n,limit:a}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return a=a==null?Number.POSITIVE_INFINITY:a,n=n==null?JSON.stringify:n,function t(){typeof t.cache!="object"&&(t.cache={values:new Map,lru:u0(a||Number.POSITIVE_INFINITY)});for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var l=n(r);if(t.cache.values.has(l))return t.cache.lru.hit(l),t.cache.values.get(l);var m=e.apply(e,r);return t.cache.values.set(l,m),t.cache.values.delete(t.cache.lru.hit(l)),m}}function hn(e){return Object.keys(e.signatures||{}).reduce(function(n,a){var t=(a.match(/,/g)||[]).length+1;return Math.max(n,t)},-1)}var c0="filter",f0=["typed"],l0=R(c0,f0,e=>{var{typed:n}=e;return n("filter",{"Array, function":Yu,"Matrix, function":function(t,r){return t.create(Yu(t.toArray(),r))},"Array, RegExp":oa,"Matrix, RegExp":function(t,r){return t.create(oa(t.toArray(),r))}})});function Yu(e,n){var a=hn(n);return wo(e,function(t,r,i){return a===1?n(t):a===2?n(t,[r]):n(t,[r],i)})}var Wu="flatten",m0=["typed","matrix"],p0=R(Wu,m0,e=>{var{typed:n,matrix:a}=e;return n(Wu,{Array:function(r){return Le(Ce(r))},Matrix:function(r){var i=Le(Ce(r.toArray()));return a(i)}})}),Ju="forEach",v0=["typed"],h0=R(Ju,v0,e=>{var{typed:n}=e;return n(Ju,{"Array, function":d0,"Matrix, function":function(t,r){return t.forEach(r)}})});function d0(e,n){var a=hn(n),t=function r(i,l){Array.isArray(i)?ia(i,function(m,f){r(m,l.concat(f))}):a===1?n(i):a===2?n(i,l):n(i,l,e)};t(e,[])}var Qu="getMatrixDataType",g0=["typed"],y0=R(Qu,g0,e=>{var{typed:n}=e;return n(Qu,{Array:function(t){return Bn(t,Ke)},Matrix:function(t){return t.getDataType()}})}),Ku="identity",x0=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],b0=R(Ku,x0,e=>{var{typed:n,config:a,matrix:t,BigNumber:r,DenseMatrix:i,SparseMatrix:l}=e;return n(Ku,{"":function(){return a.matrix==="Matrix"?t([]):[]},string:function(s){return t(s)},"number | BigNumber":function(s){return f(s,s,a.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(s,o){return f(s,s,o)},"number | BigNumber, number | BigNumber":function(s,o){return f(s,o,a.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(s,o,u){return f(s,o,u)},Array:function(s){return m(s)},"Array, string":function(s,o){return m(s,o)},Matrix:function(s){return m(s.valueOf(),s.storage())},"Matrix, string":function(s,o){return m(s.valueOf(),o)}});function m(c,s){switch(c.length){case 0:return s?t(s):[];case 1:return f(c[0],c[0],s);case 2:return f(c[0],c[1],s);default:throw new Error("Vector containing two values expected")}}function f(c,s,o){var u=_e(c)||_e(s)?r:null;if(_e(c)&&(c=c.toNumber()),_e(s)&&(s=s.toNumber()),!Ae(c)||c<1)throw new Error("Parameters in function identity must be positive integers");if(!Ae(s)||s<1)throw new Error("Parameters in function identity must be positive integers");var p=u?new r(1):1,v=u?new u(0):0,h=[c,s];if(o){if(o==="sparse")return l.diagonal(h,p,0,v);if(o==="dense")return i.diagonal(h,p,0,v);throw new TypeError('Unknown matrix type "'.concat(o,'"'))}for(var b=on([],h,v),w=c<s?c:s,N=0;N<w;N++)b[N][N]=p;return b}}),ju="kron",w0=["typed","matrix","multiplyScalar"],N0=R(ju,w0,e=>{var{typed:n,matrix:a,multiplyScalar:t}=e;return n(ju,{"Matrix, Matrix":function(l,m){return a(r(l.toArray(),m.toArray()))},"Matrix, Array":function(l,m){return a(r(l.toArray(),m))},"Array, Matrix":function(l,m){return a(r(l,m.toArray()))},"Array, Array":r});function r(i,l){if(Pe(i).length===1&&(i=[i]),Pe(l).length===1&&(l=[l]),Pe(i).length>2||Pe(l).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(i.length)+", y = "+JSON.stringify(l.length)+")");var m=[],f=[];return i.map(function(c){return l.map(function(s){return f=[],m.push(f),c.map(function(o){return s.map(function(u){return f.push(t(o,u))})})})})&&m}}),ec="map",M0=["typed"],A0=R(ec,M0,e=>{var{typed:n}=e;return n(ec,{"Array, function":S0,"Matrix, function":function(t,r){return t.map(r)}})});function S0(e,n){var a=hn(n),t=function r(i,l){if(Array.isArray(i))return i.map(function(c,s){return r(c,l.concat(s))});try{return a===1?n(i):a===2?n(i,l):n(i,l,e)}catch(c){if(c instanceof TypeError&&"data"in c&&c.data.category==="wrongType"){var m="map attempted to call '".concat(c.data.fn,"(").concat(i),f=JSON.stringify(l);throw a===2?m+=","+f:a!==1&&(m+=",".concat(f,",").concat(e)),m+=")' but argument ".concat(c.data.index+1," of type "),m+="".concat(c.data.actual," does not match expected type "),m+=c.data.expected.join(" or "),new TypeError(m)}throw c}};return t(e,[])}var rc="diff",E0=["typed","matrix","subtract","number"],tc=R(rc,E0,e=>{var{typed:n,matrix:a,subtract:t,number:r}=e;return n(rc,{"Array | Matrix":function(s){return Oe(s)?a(l(s.toArray())):l(s)},"Array | Matrix, number":function(s,o){if(!Ae(o))throw new RangeError("Dimension must be a whole number");return Oe(s)?a(i(s.toArray(),o)):i(s,o)},"Array | Matrix, BigNumber":function(s,o){return this(s,r(o))}});function i(c,s){if(Oe(c)&&(c=c.toArray()),!Array.isArray(c))throw RangeError("Array/Matrix does not have that many dimensions");if(s>0){var o=[];return c.forEach(u=>{o.push(i(u,s-1))}),o}else{if(s===0)return l(c);throw RangeError("Cannot have negative dimension")}}function l(c){var s=[],o=c.length;if(o<2)return c;for(var u=1;u<o;u++)s.push(m(c[u-1],c[u]));return s}function m(c,s){Oe(c)&&(c=c.toArray()),Oe(s)&&(s=s.toArray());var o=Array.isArray(c),u=Array.isArray(s);if(o&&u)return f(c,s);if(!o&&!u)return t(s,c);throw TypeError("Cannot calculate difference between 1 array and 1 non-array")}function f(c,s){if(c.length!==s.length)throw RangeError("Not all sub-arrays have the same length");for(var o=[],u=c.length,p=0;p<u;p++)o.push(m(c[p],s[p]));return o}}),C0="ones",O0=["typed","config","matrix","BigNumber"],D0=R(C0,O0,e=>{var{typed:n,config:a,matrix:t,BigNumber:r}=e;return n("ones",{"":function(){return a.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(c){var s=c[c.length-1];if(typeof s=="string"){var o=c.pop();return i(c,o)}else return a.matrix==="Array"?i(c):i(c,"default")},Array:i,Matrix:function(c){var s=c.storage();return i(c.valueOf(),s)},"Array | Matrix, string":function(c,s){return i(c.valueOf(),s)}});function i(f,c){var s=l(f),o=s?new r(1):1;if(m(f),c){var u=t(c);return f.length>0?u.resize(f,o):u}else{var p=[];return f.length>0?on(p,f,o):p}}function l(f){var c=!1;return f.forEach(function(s,o,u){_e(s)&&(c=!0,u[o]=s.toNumber())}),c}function m(f){f.forEach(function(c){if(typeof c!="number"||!Ae(c)||c<0)throw new Error("Parameters in function ones must be positive integers")})}});function Ai(){throw new Error('No "bignumber" implementation available')}function nc(){throw new Error('No "fraction" implementation available')}function ac(){throw new Error('No "matrix" implementation available')}var ic="range",T0=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],oc=R(ic,T0,e=>{var{typed:n,config:a,matrix:t,bignumber:r,smaller:i,smallerEq:l,larger:m,largerEq:f}=e;return n(ic,{string:s,"string, boolean":s,"number, number":function(w,N){return c(o(w,N,1))},"number, number, number":function(w,N,g){return c(o(w,N,g))},"number, number, boolean":function(w,N,g){return c(g?u(w,N,1):o(w,N,1))},"number, number, number, boolean":function(w,N,g,y){return c(y?u(w,N,g):o(w,N,g))},"BigNumber, BigNumber":function(w,N){var g=w.constructor;return c(p(w,N,new g(1)))},"BigNumber, BigNumber, BigNumber":function(w,N,g){return c(p(w,N,g))},"BigNumber, BigNumber, boolean":function(w,N,g){var y=w.constructor;return c(g?v(w,N,new y(1)):p(w,N,new y(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(w,N,g,y){return c(y?v(w,N,g):p(w,N,g))}});function c(b){return a.matrix==="Matrix"?t?t(b):ac():b}function s(b,w){var N=h(b);if(!N)throw new SyntaxError('String "'+b+'" is no valid range');var g;return a.number==="BigNumber"?(r===void 0&&Ai(),g=w?v:p,c(g(r(N.start),r(N.end),r(N.step)))):(g=w?u:o,c(g(N.start,N.end,N.step)))}function o(b,w,N){var g=[],y=b;if(N>0)for(;i(y,w);)g.push(y),y+=N;else if(N<0)for(;m(y,w);)g.push(y),y+=N;return g}function u(b,w,N){var g=[],y=b;if(N>0)for(;l(y,w);)g.push(y),y+=N;else if(N<0)for(;f(y,w);)g.push(y),y+=N;return g}function p(b,w,N){var g=r(0),y=[],x=b;if(N.gt(g))for(;i(x,w);)y.push(x),x=x.plus(N);else if(N.lt(g))for(;m(x,w);)y.push(x),x=x.plus(N);return y}function v(b,w,N){var g=r(0),y=[],x=b;if(N.gt(g))for(;l(x,w);)y.push(x),x=x.plus(N);else if(N.lt(g))for(;f(x,w);)y.push(x),x=x.plus(N);return y}function h(b){var w=b.split(":"),N=w.map(function(y){return Number(y)}),g=N.some(function(y){return isNaN(y)});if(g)return null;switch(N.length){case 2:return{start:N[0],end:N[1],step:1};case 3:return{start:N[0],end:N[2],step:N[1]};default:return null}}}),sc="reshape",B0=["typed","isInteger","matrix"],_0=R(sc,B0,e=>{var{typed:n,isInteger:a}=e;return n(sc,{"Matrix, Array":function(r,i){return r.reshape(i)},"Array, Array":function(r,i){return i.forEach(function(l){if(!a(l))throw new TypeError("Invalid size for dimension: "+l)}),ho(r,i)}})});function dn(e,n,a,t){if(!(this instanceof dn))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=n,this.min=a,this.max=t,this.message="Wrong number of arguments in function "+e+" ("+n+" provided, "+a+(t!=null?"-"+t:"")+" expected)",this.stack=new Error().stack}dn.prototype=new Error,dn.prototype.constructor=Error,dn.prototype.name="ArgumentsError",dn.prototype.isArgumentsError=!0;var $0="resize",I0=["config","matrix"],q0=R($0,I0,e=>{var{config:n,matrix:a}=e;return function(i,l,m){if(arguments.length!==2&&arguments.length!==3)throw new dn("resize",arguments.length,2,3);if(Oe(l)&&(l=l.valueOf()),_e(l[0])&&(l=l.map(function(s){return _e(s)?s.toNumber():s})),Oe(i))return i.resize(l,m,!0);if(typeof i=="string")return t(i,l,m);var f=Array.isArray(i)?!1:n.matrix!=="Array";if(l.length===0){for(;Array.isArray(i);)i=i[0];return Ce(i)}else{Array.isArray(i)||(i=[i]),i=Ce(i);var c=on(i,l,m);return f?a(c):c}};function t(r,i,l){if(l!==void 0){if(typeof l!="string"||l.length!==1)throw new TypeError("Single character expected as defaultValue")}else l=" ";if(i.length!==1)throw new Fe(i.length,1);var m=i[0];if(typeof m!="number"||!Ae(m))throw new TypeError("Invalid size, must contain positive integers (size: "+Re(i)+")");if(r.length>m)return r.substring(0,m);if(r.length<m){for(var f=r,c=0,s=m-r.length;c<s;c++)f+=l;return f}else return r}}),uc="rotate",R0=["typed","multiply","rotationMatrix"],F0=R(uc,R0,e=>{var{typed:n,multiply:a,rotationMatrix:t}=e;return n(uc,{"Array , number | BigNumber | Complex | Unit":function(l,m){r(l,2);var f=a(t(m),l);return f.toArray()},"Matrix , number | BigNumber | Complex | Unit":function(l,m){return r(l,2),a(t(m),l)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(l,m,f){r(l,3);var c=a(t(m,f),l);return c},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(l,m,f){return r(l,3),a(t(m,f),l)}});function r(i,l){var m=Array.isArray(i)?Pe(i):i.size();if(m.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(l));if(m.length===2&&m[1]!==1)throw new RangeError("Vector must be of dimensions 1x".concat(l));if(m[0]!==l)throw new RangeError("Vector must be of dimensions 1x".concat(l))}}),cc="rotationMatrix",z0=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],P0=R(cc,z0,e=>{var{typed:n,config:a,multiplyScalar:t,addScalar:r,unaryMinus:i,norm:l,BigNumber:m,matrix:f,DenseMatrix:c,SparseMatrix:s,cos:o,sin:u}=e;return n(cc,{"":function(){return a.matrix==="Matrix"?f([]):[]},string:function(g){return f(g)},"number | BigNumber | Complex | Unit":function(g){return p(g,a.matrix==="Matrix"?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(g,y){return p(g,y)},"number | BigNumber | Complex | Unit, Array":function(g,y){var x=f(y);return v(x),w(g,x,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(g,y){v(y);var x=y.storage()||(a.matrix==="Matrix"?"dense":void 0);return w(g,y,x)},"number | BigNumber | Complex | Unit, Array, string":function(g,y,x){var d=f(y);return v(d),w(g,d,x)},"number | BigNumber | Complex | Unit, Matrix, string":function(g,y,x){return v(y),w(g,y,x)}});function p(N,g){var y=_e(N),x=y?new m(-1):-1,d=o(N),A=u(N),S=[[d,t(x,A)],[A,d]];return b(S,g)}function v(N){var g=N.size();if(g.length<1||g[0]!==3)throw new RangeError("Vector must be of dimensions 1x3")}function h(N){return N.reduce((g,y)=>t(g,y))}function b(N,g){if(g){if(g==="sparse")return new s(N);if(g==="dense")return new c(N);throw new TypeError('Unknown matrix type "'.concat(g,'"'))}return N}function w(N,g,y){var x=l(g);if(x===0)throw new RangeError("Rotation around zero vector");var d=_e(N)?m:null,A=d?new d(1):1,S=d?new d(-1):-1,O=d?new d(g.get([0])/x):g.get([0])/x,M=d?new d(g.get([1])/x):g.get([1])/x,_=d?new d(g.get([2])/x):g.get([2])/x,E=o(N),$=r(A,i(E)),z=u(N),I=r(E,h([O,O,$])),T=r(h([O,M,$]),h([S,_,z])),B=r(h([O,_,$]),h([M,z])),G=r(h([O,M,$]),h([_,z])),D=r(E,h([M,M,$])),H=r(h([M,_,$]),h([S,O,z])),W=r(h([O,_,$]),h([S,M,z])),j=r(h([M,_,$]),h([O,z])),V=r(E,h([_,_,$])),K=[[I,T,B],[G,D,H],[W,j,V]];return b(K,y)}}),fc="row",U0=["typed","Index","matrix","range"],lc=R(fc,U0,e=>{var{typed:n,Index:a,matrix:t,range:r}=e;return n(fc,{"Matrix, number":i,"Array, number":function(m,f){return i(t(Ce(m)),f).valueOf()}});function i(l,m){if(l.size().length!==2)throw new Error("Only two dimensional matrix is supported");We(m,l.size()[0]);var f=r(0,l.size()[1]),c=new a(m,f);return l.subset(c)}}),mc="size",L0=["typed","config","?matrix"],k0=R(mc,L0,e=>{var{typed:n,config:a,matrix:t}=e;return n(mc,{Matrix:function(i){return i.create(i.size())},Array:Pe,string:function(i){return a.matrix==="Array"?[i.length]:t([i.length])},"number | Complex | BigNumber | Unit | boolean | null":function(i){return a.matrix==="Array"?[]:t?t([]):ac()}})}),pc="squeeze",H0=["typed","matrix"],G0=R(pc,H0,e=>{var{typed:n,matrix:a}=e;return n(pc,{Array:function(r){return aa(Ce(r))},Matrix:function(r){var i=aa(r.toArray());return Array.isArray(i)?a(i):i},any:function(r){return Ce(r)}})}),vc="subset",V0=["typed","matrix"],hc=R(vc,V0,e=>{var{typed:n,matrix:a}=e;return n(vc,{"Array, Index":function(r,i){var l=a(r),m=l.subset(i);return i.isScalar()?m:m.valueOf()},"Matrix, Index":function(r,i){return r.subset(i)},"Object, Index":X0,"string, Index":Z0,"Array, Index, any":function(r,i,l){return a(Ce(r)).subset(i,l,void 0).valueOf()},"Array, Index, any, any":function(r,i,l,m){return a(Ce(r)).subset(i,l,m).valueOf()},"Matrix, Index, any":function(r,i,l){return r.clone().subset(i,l)},"Matrix, Index, any, any":function(r,i,l,m){return r.clone().subset(i,l,m)},"string, Index, string":dc,"string, Index, string, string":dc,"Object, Index, any":Y0})});function Z0(e,n){if(!En(n))throw new TypeError("Index expected");if(n.size().length!==1)throw new Fe(n.size().length,1);var a=e.length;We(n.min()[0],a),We(n.max()[0],a);var t=n.dimension(0),r="";return t.forEach(function(i){r+=e.charAt(i)}),r}function dc(e,n,a,t){if(!n||n.isIndex!==!0)throw new TypeError("Index expected");if(n.size().length!==1)throw new Fe(n.size().length,1);if(t!==void 0){if(typeof t!="string"||t.length!==1)throw new TypeError("Single character expected as defaultValue")}else t=" ";var r=n.dimension(0),i=r.size()[0];if(i!==a.length)throw new Fe(r.size()[0],a.length);var l=e.length;We(n.min()[0]),We(n.max()[0]);for(var m=[],f=0;f<l;f++)m[f]=e.charAt(f);if(r.forEach(function(o,u){m[o]=a.charAt(u[0])}),m.length>l)for(var c=l-1,s=m.length;c<s;c++)m[c]||(m[c]=t);return m.join("")}function X0(e,n){if(n.size().length!==1)throw new Fe(n.size(),1);var a=n.dimension(0);if(typeof a!="string")throw new TypeError("String expected as index to retrieve an object property");return Vr(e,a)}function Y0(e,n,a){if(n.size().length!==1)throw new Fe(n.size(),1);var t=n.dimension(0);if(typeof t!="string")throw new TypeError("String expected as index to retrieve an object property");var r=Ce(e);return un(r,t,a),r}var W0="transpose",J0=["typed","matrix"],Q0=R(W0,J0,e=>{var{typed:n,matrix:a}=e;return n("transpose",{Array:function(l){return this(a(l)).valueOf()},Matrix:function(l){var m=l.size(),f;switch(m.length){case 1:f=l.clone();break;case 2:{var c=m[0],s=m[1];if(s===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+Re(m)+")");switch(l.storage()){case"dense":f=t(l,c,s);break;case"sparse":f=r(l,c,s);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+Re(this._size)+")")}return f},any:function(l){return Ce(l)}});function t(i,l,m){for(var f=i._data,c=[],s,o=0;o<m;o++){s=c[o]=[];for(var u=0;u<l;u++)s[u]=Ce(f[u][o])}return i.createDenseMatrix({data:c,size:[m,l],datatype:i._datatype})}function r(i,l,m){for(var f=i._values,c=i._index,s=i._ptr,o=f?[]:void 0,u=[],p=[],v=[],h=0;h<l;h++)v[h]=0;var b,w,N;for(b=0,w=c.length;b<w;b++)v[c[b]]++;for(var g=0,y=0;y<l;y++)p.push(g),g+=v[y],v[y]=p[y];for(p.push(g),N=0;N<m;N++)for(var x=s[N],d=s[N+1],A=x;A<d;A++){var S=v[c[A]]++;u[S]=N,f&&(o[S]=Ce(f[A]))}return i.createSparseMatrix({values:o,index:u,ptr:p,size:[m,l],datatype:i._datatype})}}),gc="ctranspose",K0=["typed","transpose","conj"],j0=R(gc,K0,e=>{var{typed:n,transpose:a,conj:t}=e;return n(gc,{any:function(i){return t(a(i))}})}),yc="zeros",e1=["typed","config","matrix","BigNumber"],r1=R(yc,e1,e=>{var{typed:n,config:a,matrix:t,BigNumber:r}=e;return n(yc,{"":function(){return a.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(c){var s=c[c.length-1];if(typeof s=="string"){var o=c.pop();return i(c,o)}else return a.matrix==="Array"?i(c):i(c,"default")},Array:i,Matrix:function(c){var s=c.storage();return i(c.valueOf(),s)},"Array | Matrix, string":function(c,s){return i(c.valueOf(),s)}});function i(f,c){var s=l(f),o=s?new r(0):0;if(m(f),c){var u=t(c);return f.length>0?u.resize(f,o):u}else{var p=[];return f.length>0?on(p,f,o):p}}function l(f){var c=!1;return f.forEach(function(s,o,u){_e(s)&&(c=!0,u[o]=s.toNumber())}),c}function m(f){f.forEach(function(c){if(typeof c!="number"||!Ae(c)||c<0)throw new Error("Parameters in function zeros must be positive integers")})}}),xc="fft",t1=["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i"],n1=R(xc,t1,e=>{var{typed:n,matrix:a,addScalar:t,multiplyScalar:r,divideScalar:i,exp:l,tau:m,i:f}=e;return n(xc,{Array:c,Matrix:function(p){return p.create(c(p.toArray()))}});function c(u){var p=Pe(u);return p.length===1?o(u,p[0]):s(u.map(v=>c(v,p.slice(1))),0)}function s(u,p){var v=Pe(u);if(p!==0)return new Array(v[0]).fill(0).map((b,w)=>s(u[w],p-1));if(v.length===1)return o(u);function h(b){var w=Pe(b);return new Array(w[1]).fill(0).map((N,g)=>new Array(w[0]).fill(0).map((y,x)=>b[x][g]))}return h(s(h(u),1))}function o(u){var p=u.length;if(p===1)return[u[0]];if(p%2===0){for(var v=[...o(u.filter((N,g)=>g%2===0)),...o(u.filter((N,g)=>g%2===1))],h=0;h<p/2;h++){var b=v[h],w=r(v[h+p/2],l(r(r(m,f),i(-h,p))));v[h]=t(b,w),v[h+p/2]=t(b,r(-1,w))}return v}throw new Error("Can only calculate FFT of power-of-two size")}}),bc="ifft",a1=["typed","fft","dotDivide","conj"],i1=R(bc,a1,e=>{var{typed:n,fft:a,dotDivide:t,conj:r}=e;return n(bc,{"Array | Matrix":function(l){var m=Oe(l)?l.size():Pe(l);return t(r(a(r(l))),m.reduce((f,c)=>f*c,1))}})}),o1="erf",s1=["typed"],u1=R(o1,s1,e=>{var{typed:n}=e;return n("name",{number:function(l){var m=Math.abs(l);return m>=l1?Dt(l):m<=c1?Dt(l)*a(m):m<=4?Dt(l)*(1-t(m)):Dt(l)*(1-r(m))},"Array | Matrix":function(l){return be(l,this)}});function a(i){var l=i*i,m=Nt[0][4]*l,f=l,c;for(c=0;c<3;c+=1)m=(m+Nt[0][c])*l,f=(f+gn[0][c])*l;return i*(m+Nt[0][3])/(f+gn[0][3])}function t(i){var l=Nt[1][8]*i,m=i,f;for(f=0;f<7;f+=1)l=(l+Nt[1][f])*i,m=(m+gn[1][f])*i;var c=(l+Nt[1][7])/(m+gn[1][7]),s=parseInt(i*16)/16,o=(i-s)*(i+s);return Math.exp(-s*s)*Math.exp(-o)*c}function r(i){var l=1/(i*i),m=Nt[2][5]*l,f=l,c;for(c=0;c<4;c+=1)m=(m+Nt[2][c])*l,f=(f+gn[2][c])*l;var s=l*(m+Nt[2][4])/(f+gn[2][4]);s=(f1-s)/i,l=parseInt(i*16)/16;var o=(i-l)*(i+l);return Math.exp(-l*l)*Math.exp(-o)*s}}),c1=.46875,f1=.5641895835477563,Nt=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,21531153547440383e-24],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],gn=[[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]],l1=Math.pow(2,53),wc="mode",m1=["typed","isNaN","isNumeric"],p1=R(wc,m1,e=>{var{typed:n,isNaN:a,isNumeric:t}=e;return n(wc,{"Array | Matrix":r,"...":function(l){return r(l)}});function r(i){i=Le(i.valueOf());var l=i.length;if(l===0)throw new Error("Cannot calculate mode of an empty array");for(var m={},f=[],c=0,s=0;s<i.length;s++){var o=i[s];if(t(o)&&a(o))throw new Error("Cannot calculate mode of an array containing NaN values");o in m||(m[o]=0),m[o]++,m[o]===c?f.push(o):m[o]>c&&(c=m[o],f=[o])}return f}});function Tr(e,n,a){var t;return String(e).indexOf("Unexpected type")!==-1?(t=arguments.length>2?" (type: "+Ke(a)+", value: "+JSON.stringify(a)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+n+", unexpected type of argument"+t)):String(e).indexOf("complex numbers")!==-1?(t=arguments.length>2?" (type: "+Ke(a)+", value: "+JSON.stringify(a)+")":"",new TypeError("Cannot calculate "+n+", no ordering relation is defined for complex numbers"+t)):e}var Nc="prod",v1=["typed","config","multiplyScalar","numeric"],h1=R(Nc,v1,e=>{var{typed:n,config:a,multiplyScalar:t,numeric:r}=e;return n(Nc,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(m,f){throw new Error("prod(A, dim) is not yet supported")},"...":function(m){return i(m)}});function i(l){var m;if(bt(l,function(f){try{m=m===void 0?f:t(m,f)}catch(c){throw Tr(c,"prod",f)}}),typeof m=="string"&&(m=r(m,a.number)),m===void 0)throw new Error("Cannot calculate prod of an empty array");return m}}),Mc="format",d1=["typed"],g1=R(Mc,d1,e=>{var{typed:n}=e;return n(Mc,{any:Re,"any, Object | function | number":Re})}),Ac="bin",y1=["typed","format"],x1=R(Ac,y1,e=>{var{typed:n,format:a}=e;return n(Ac,{"number | BigNumber":function(r){return a(r,{notation:"bin"})},"number | BigNumber, number":function(r,i){return a(r,{notation:"bin",wordSize:i})}})}),Sc="oct",b1=["typed","format"],w1=R(Sc,b1,e=>{var{typed:n,format:a}=e;return n(Sc,{"number | BigNumber":function(r){return a(r,{notation:"oct"})},"number | BigNumber, number":function(r,i){return a(r,{notation:"oct",wordSize:i})}})}),Ec="hex",N1=["typed","format"],M1=R(Ec,N1,e=>{var{typed:n,format:a}=e;return n(Ec,{"number | BigNumber":function(r){return a(r,{notation:"hex"})},"number | BigNumber, number":function(r,i){return a(r,{notation:"hex",wordSize:i})}})}),Cc="print",A1=["typed"],S1=R(Cc,A1,e=>{var{typed:n}=e;return n(Cc,{"string, Object | Array":Oc,"string, Object | Array, number | Object":Oc})});function Oc(e,n,a){return e.replace(/\$([\w.]+)/g,function(t,r){for(var i=r.split("."),l=n[i.shift()];i.length&&l!==void 0;){var m=i.shift();l=m?l[m]:l+"."}return l!==void 0?_r(l)?l:Re(l,a):t})}var Dc="to",E1=["typed","matrix"],C1=R(Dc,E1,e=>{var{typed:n,matrix:a}=e,t=je({typed:n}),r=Ge({typed:n});return n(Dc,{"Unit, Unit | string":function(l,m){return l.to(m)},"Matrix, Matrix":function(l,m){return t(l,m,this)},"Array, Array":function(l,m){return this(a(l),a(m)).valueOf()},"Array, Matrix":function(l,m){return this(a(l),m)},"Matrix, Array":function(l,m){return this(l,a(m))},"Matrix, any":function(l,m){return r(l,m,this,!1)},"any, Matrix":function(l,m){return r(m,l,this,!0)},"Array, any":function(l,m){return r(a(l),m,this,!1).valueOf()},"any, Array":function(l,m){return r(a(m),l,this,!0).valueOf()}})}),Tc="isPrime",O1=["typed"],D1=R(Tc,O1,e=>{var{typed:n}=e;return n(Tc,{number:function(t){if(t*0!==0)return!1;if(t<=3)return t>1;if(t%2===0||t%3===0)return!1;for(var r=5;r*r<=t;r+=6)if(t%r===0||t%(r+2)===0)return!1;return!0},BigNumber:function(t){if(t.toNumber()*0!==0)return!1;if(t.lte(3))return t.gt(1);if(t.mod(2).eq(0)||t.mod(3).eq(0))return!1;if(t.lt(Math.pow(2,32))){for(var r=t.toNumber(),i=5;i*i<=r;i+=6)if(r%i===0||r%(i+2)===0)return!1;return!0}function l(N,g,y){for(var x=1;!g.eq(0);)g.mod(2).eq(0)?(g=g.div(2),N=N.mul(N).mod(y)):(g=g.sub(1),x=N.mul(x).mod(y));return x}var m=t.constructor.clone({precision:t.toFixed(0).length*2});t=new m(t);for(var f=0,c=t.sub(1);c.mod(2).eq(0);)c=c.div(2),f+=1;var s=null;if(t.lt("3317044064679887385961981"))s=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter(N=>N<t);else{var o=Math.min(t.toNumber()-2,Math.floor(2*Math.pow(t.toFixed(0).length*Math.log(10),2)));s=[];for(var u=2;u<=o;u+=1)s.push(o)}for(var p=0;p<s.length;p+=1){var v=s[p],h=l(t.sub(t).add(v),c,t);if(!h.eq(1)){for(var b=0,w=h;!w.eq(t.sub(1));b+=1,w=w.mul(w).mod(t))if(b===f-1)return!1}}return!0},"Array | Matrix":function(t){return be(t,this)}})}),T1="numeric",B1=["number","?bignumber","?fraction"],_1=R(T1,B1,e=>{var{number:n,bignumber:a,fraction:t}=e,r={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:l=>n(l),BigNumber:a?l=>a(l):Ai,Fraction:t?l=>t(l):nc};return function(m,f){var c=Ke(m);if(!(c in r))throw new TypeError("Cannot convert "+m+' of type "'+c+'"; valid input types are '+Object.keys(r).join(", "));if(!(f in i))throw new TypeError("Cannot convert "+m+' to type "'+f+'"; valid output types are '+Object.keys(i).join(", "));return f===c?m:i[f](m)}}),Bc="divideScalar",$1=["typed","numeric"],I1=R(Bc,$1,e=>{var{typed:n,numeric:a}=e;return n(Bc,{"number, number":function(r,i){return r/i},"Complex, Complex":function(r,i){return r.div(i)},"BigNumber, BigNumber":function(r,i){return r.div(i)},"Fraction, Fraction":function(r,i){return r.div(i)},"Unit, number | Fraction | BigNumber":function(r,i){var l=r.clone(),m=a(1,Ke(i));return l.value=this(l.value===null?l._normalize(m):l.value,i),l},"number | Fraction | BigNumber, Unit":function(r,i){var l=i.clone();l=l.pow(-1);var m=a(1,Ke(r));return l.value=this(r,i.value===null?i._normalize(m):i.value),l},"Unit, Unit":function(r,i){return r.divide(i)}})}),_c="pow",q1=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],R1=R(_c,q1,e=>{var{typed:n,config:a,identity:t,multiply:r,matrix:i,inv:l,number:m,fraction:f,Complex:c}=e;return n(_c,{"number, number":s,"Complex, Complex":function(v,h){return v.pow(h)},"BigNumber, BigNumber":function(v,h){return h.isInteger()||v>=0||a.predictable?v.pow(h):new c(v.toNumber(),0).pow(h.toNumber(),0)},"Fraction, Fraction":function(v,h){var b=v.pow(h);if(b!=null)return b;if(a.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return s(v.valueOf(),h.valueOf())},"Array, number":o,"Array, BigNumber":function(v,h){return o(v,h.toNumber())},"Matrix, number":u,"Matrix, BigNumber":function(v,h){return u(v,h.toNumber())},"Unit, number | BigNumber":function(v,h){return v.pow(h)}});function s(p,v){if(a.predictable&&!Ae(v)&&p<0)try{var h=f(v),b=m(h);if((v===b||Math.abs((v-b)/v)<1e-14)&&h.d%2===1)return(h.n%2===0?1:-1)*Math.pow(-p,v)}catch(w){}return a.predictable&&(p<-1&&v===1/0||p>-1&&p<0&&v===-1/0)?NaN:Ae(v)||p>=0||a.predictable?us(p,v):p*p<1&&v===1/0||p*p>1&&v===-1/0?0:new c(p,0).pow(v,0)}function o(p,v){if(!Ae(v))throw new TypeError("For A^b, b must be an integer (value is "+v+")");var h=Pe(p);if(h.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+h.length+" dimensions)");if(h[0]!==h[1])throw new Error("For A^b, A must be square (size is "+h[0]+"x"+h[1]+")");if(v<0)try{return o(l(p),-v)}catch(N){throw N.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+v+")"):N}for(var b=t(h[0]).valueOf(),w=p;v>=1;)(v&1)===1&&(b=r(w,b)),v>>=1,w=r(w,w);return b}function u(p,v){return i(o(p.valueOf(),v))}}),yn="Number of decimals in function round must be an integer",$c="round",F1=["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],z1=R($c,F1,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,BigNumber:i,DenseMatrix:l}=e,m=wr({typed:n,equalScalar:t}),f=gr({typed:n,DenseMatrix:l}),c=Ge({typed:n});return n($c,{number:cs,"number, number":cs,"number, BigNumber":function(o,u){if(!u.isInteger())throw new TypeError(yn);return new i(o).toDecimalPlaces(u.toNumber())},Complex:function(o){return o.round()},"Complex, number":function(o,u){if(u%1)throw new TypeError(yn);return o.round(u)},"Complex, BigNumber":function(o,u){if(!u.isInteger())throw new TypeError(yn);var p=u.toNumber();return o.round(p)},BigNumber:function(o){return o.toDecimalPlaces(0)},"BigNumber, BigNumber":function(o,u){if(!u.isInteger())throw new TypeError(yn);return o.toDecimalPlaces(u.toNumber())},Fraction:function(o){return o.round()},"Fraction, number":function(o,u){if(u%1)throw new TypeError(yn);return o.round(u)},"Fraction, BigNumber":function(o,u){if(!u.isInteger())throw new TypeError(yn);return o.round(u.toNumber())},"Array | Matrix":function(o){return be(o,this)},"SparseMatrix, number | BigNumber":function(o,u){return m(o,u,this,!1)},"DenseMatrix, number | BigNumber":function(o,u){return c(o,u,this,!1)},"Array, number | BigNumber":function(o,u){return c(a(o),u,this,!1).valueOf()},"number | Complex | BigNumber | Fraction, SparseMatrix":function(o,u){return t(o,0)?r(u.size(),u.storage()):f(u,o,this,!0)},"number | Complex | BigNumber | Fraction, DenseMatrix":function(o,u){return t(o,0)?r(u.size(),u.storage()):c(u,o,this,!0)},"number | Complex | BigNumber | Fraction, Array":function(o,u){return c(a(u),o,this,!0).valueOf()}})}),Ic="log",P1=["config","typed","divideScalar","Complex"],U1=R(Ic,P1,e=>{var{typed:n,config:a,divideScalar:t,Complex:r}=e;return n(Ic,{number:function(l){return l>=0||a.predictable?Xh(l):new r(l,0).log()},Complex:function(l){return l.log()},BigNumber:function(l){return!l.isNegative()||a.predictable?l.ln():new r(l.toNumber(),0).log()},"Array | Matrix":function(l){return be(l,this)},"any, any":function(l,m){return t(this(l),this(m))}})}),qc="log1p",L1=["typed","config","divideScalar","log","Complex"],k1=R(qc,L1,e=>{var{typed:n,config:a,divideScalar:t,log:r,Complex:i}=e;return n(qc,{number:function(f){return f>=-1||a.predictable?Gp(f):l(new i(f,0))},Complex:l,BigNumber:function(f){var c=f.plus(1);return!c.isNegative()||a.predictable?c.ln():l(new i(f.toNumber(),0))},"Array | Matrix":function(f){return be(f,this)},"any, any":function(f,c){return t(this(f),r(c))}});function l(m){var f=m.re+1;return new i(Math.log(Math.sqrt(f*f+m.im*m.im)),Math.atan2(m.im,f))}}),Rc="nthRoots",H1=["config","typed","divideScalar","Complex"],G1=R(Rc,H1,e=>{var{typed:n,config:a,divideScalar:t,Complex:r}=e,i=[function(f){return new r(f,0)},function(f){return new r(0,f)},function(f){return new r(-f,0)},function(f){return new r(0,-f)}];function l(m,f){if(f<0)throw new Error("Root must be greater than zero");if(f===0)throw new Error("Root must be non-zero");if(f%1!==0)throw new Error("Root must be an integer");if(m===0||m.abs()===0)return[new r(0,0)];var c=typeof m=="number",s;(c||m.re===0||m.im===0)&&(c?s=2*+(m<0):m.im===0?s=2*+(m.re<0):s=2*+(m.im<0)+1);for(var o=m.arg(),u=m.abs(),p=[],v=Math.pow(u,1/f),h=0;h<f;h++){var b=(s+4*h)/f;if(b===Math.round(b)){p.push(i[b%4](v));continue}p.push(new r({r:v,phi:(o+2*Math.PI*h)/f}))}return p}return n(Rc,{Complex:function(f){return l(f,2)},"Complex, number":l})}),Fc="dotPow",V1=["typed","equalScalar","matrix","pow","DenseMatrix"],Z1=R(Fc,V1,e=>{var{typed:n,equalScalar:a,matrix:t,pow:r,DenseMatrix:i}=e,l=Dr({typed:n}),m=ut({typed:n,DenseMatrix:i}),f=wr({typed:n,equalScalar:a}),c=gr({typed:n,DenseMatrix:i}),s=je({typed:n}),o=Ge({typed:n});return n(Fc,{"any, any":r,"SparseMatrix, SparseMatrix":function(p,v){return m(p,v,r,!1)},"SparseMatrix, DenseMatrix":function(p,v){return l(v,p,r,!0)},"DenseMatrix, SparseMatrix":function(p,v){return l(p,v,r,!1)},"DenseMatrix, DenseMatrix":function(p,v){return s(p,v,r)},"Array, Array":function(p,v){return this(t(p),t(v)).valueOf()},"Array, Matrix":function(p,v){return this(t(p),v)},"Matrix, Array":function(p,v){return this(p,t(v))},"SparseMatrix, any":function(p,v){return f(p,v,this,!1)},"DenseMatrix, any":function(p,v){return o(p,v,this,!1)},"any, SparseMatrix":function(p,v){return c(v,p,this,!0)},"any, DenseMatrix":function(p,v){return o(v,p,this,!0)},"Array, any":function(p,v){return o(t(p),v,this,!1).valueOf()},"any, Array":function(p,v){return o(t(v),p,this,!0).valueOf()}})}),zc="dotDivide",X1=["typed","matrix","equalScalar","divideScalar","DenseMatrix"],Y1=R(zc,X1,e=>{var{typed:n,matrix:a,equalScalar:t,divideScalar:r,DenseMatrix:i}=e,l=rt({typed:n,equalScalar:t}),m=Dr({typed:n}),f=ut({typed:n,DenseMatrix:i}),c=wr({typed:n,equalScalar:t}),s=gr({typed:n,DenseMatrix:i}),o=je({typed:n}),u=Ge({typed:n});return n(zc,{"any, any":r,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,r,!1)},"SparseMatrix, DenseMatrix":function(v,h){return l(h,v,r,!0)},"DenseMatrix, SparseMatrix":function(v,h){return m(v,h,r,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,r)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, any":function(v,h){return c(v,h,r,!1)},"DenseMatrix, any":function(v,h){return u(v,h,r,!1)},"any, SparseMatrix":function(v,h){return s(h,v,r,!0)},"any, DenseMatrix":function(v,h){return u(h,v,r,!0)},"Array, any":function(v,h){return u(a(v),h,r,!1).valueOf()},"any, Array":function(v,h){return u(a(h),v,r,!0).valueOf()}})});function Rn(e){var{DenseMatrix:n}=e;return function(t,r,i){var l=t.size();if(l.length!==2)throw new RangeError("Matrix must be two dimensional (size: "+Re(l)+")");var m=l[0],f=l[1];if(m!==f)throw new RangeError("Matrix must be square (size: "+Re(l)+")");var c=[];if(Oe(r)){var s=r.size(),o=r._data;if(s.length===1){if(s[0]!==m)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var u=0;u<m;u++)c[u]=[o[u]];return new n({data:c,size:[m,1],datatype:r._datatype})}if(s.length===2){if(s[0]!==m||s[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");if(Qn(r)){if(i){c=[];for(var p=0;p<m;p++)c[p]=[o[p][0]];return new n({data:c,size:[m,1],datatype:r._datatype})}return r}if(Ut(r)){for(var v=0;v<m;v++)c[v]=[0];for(var h=r._values,b=r._index,w=r._ptr,N=w[1],g=w[0];g<N;g++){var y=b[g];c[y][0]=h[g]}return new n({data:c,size:[m,1],datatype:r._datatype})}}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}if(Xe(r)){var x=Pe(r);if(x.length===1){if(x[0]!==m)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var d=0;d<m;d++)c[d]=[r[d]];return new n({data:c,size:[m,1]})}if(x.length===2){if(x[0]!==m||x[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var A=0;A<m;A++)c[A]=[r[A][0]];return new n({data:c,size:[m,1]})}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}}}var Pc="lsolve",W1=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],J1=R(Pc,W1,e=>{var{typed:n,matrix:a,divideScalar:t,multiplyScalar:r,subtract:i,equalScalar:l,DenseMatrix:m}=e,f=Rn({DenseMatrix:m});return n(Pc,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return c(u,p)},"Array, Array | Matrix":function(u,p){var v=a(u),h=c(v,p);return h.valueOf()}});function c(o,u){u=f(o,u,!0);for(var p=u._data,v=o._size[0],h=o._size[1],b=[],w=o._data,N=0;N<h;N++){var g=p[N][0]||0,y=void 0;if(l(g,0))y=0;else{var x=w[N][N];if(l(x,0))throw new Error("Linear system cannot be solved since matrix is singular");y=t(g,x);for(var d=N+1;d<v;d++)p[d]=[i(p[d][0]||0,r(y,w[d][N]))]}b[N]=[y]}return new m({data:b,size:[v,1]})}function s(o,u){u=f(o,u,!0);for(var p=u._data,v=o._size[0],h=o._size[1],b=o._values,w=o._index,N=o._ptr,g=[],y=0;y<h;y++){var x=p[y][0]||0;if(l(x,0))g[y]=[0];else{for(var d=0,A=[],S=[],O=N[y],M=N[y+1],_=O;_<M;_++){var E=w[_];E===y?d=b[_]:E>y&&(A.push(b[_]),S.push(E))}if(l(d,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var $=t(x,d),z=0,I=S.length;z<I;z++){var T=S[z];p[T]=[i(p[T][0]||0,r($,A[z]))]}g[y]=[$]}}return new m({data:g,size:[v,1]})}}),Uc="usolve",Q1=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],K1=R(Uc,Q1,e=>{var{typed:n,matrix:a,divideScalar:t,multiplyScalar:r,subtract:i,equalScalar:l,DenseMatrix:m}=e,f=Rn({DenseMatrix:m});return n(Uc,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return c(u,p)},"Array, Array | Matrix":function(u,p){var v=a(u),h=c(v,p);return h.valueOf()}});function c(o,u){u=f(o,u,!0);for(var p=u._data,v=o._size[0],h=o._size[1],b=[],w=o._data,N=h-1;N>=0;N--){var g=p[N][0]||0,y=void 0;if(l(g,0))y=0;else{var x=w[N][N];if(l(x,0))throw new Error("Linear system cannot be solved since matrix is singular");y=t(g,x);for(var d=N-1;d>=0;d--)p[d]=[i(p[d][0]||0,r(y,w[d][N]))]}b[N]=[y]}return new m({data:b,size:[v,1]})}function s(o,u){u=f(o,u,!0);for(var p=u._data,v=o._size[0],h=o._size[1],b=o._values,w=o._index,N=o._ptr,g=[],y=h-1;y>=0;y--){var x=p[y][0]||0;if(l(x,0))g[y]=[0];else{for(var d=0,A=[],S=[],O=N[y],M=N[y+1],_=M-1;_>=O;_--){var E=w[_];E===y?d=b[_]:E<y&&(A.push(b[_]),S.push(E))}if(l(d,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var $=t(x,d),z=0,I=S.length;z<I;z++){var T=S[z];p[T]=[i(p[T][0],r($,A[z]))]}g[y]=[$]}}return new m({data:g,size:[v,1]})}}),Lc="lsolveAll",j1=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],ex=R(Lc,j1,e=>{var{typed:n,matrix:a,divideScalar:t,multiplyScalar:r,subtract:i,equalScalar:l,DenseMatrix:m}=e,f=Rn({DenseMatrix:m});return n(Lc,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return c(u,p)},"Array, Array | Matrix":function(u,p){var v=a(u),h=c(v,p);return h.map(b=>b.valueOf())}});function c(o,u){for(var p=[f(o,u,!0)._data.map(S=>S[0])],v=o._data,h=o._size[0],b=o._size[1],w=0;w<b;w++)for(var N=p.length,g=0;g<N;g++){var y=p[g];if(l(v[w][w],0))if(l(y[w],0)){if(g===0){var d=[...y];d[w]=1;for(var A=w+1;A<b;A++)d[A]=i(d[A],v[A][w]);p.push(d)}}else{if(g===0)return[];p.splice(g,1),g-=1,N-=1}else{y[w]=t(y[w],v[w][w]);for(var x=w+1;x<b;x++)y[x]=i(y[x],r(y[w],v[x][w]))}}return p.map(S=>new m({data:S.map(O=>[O]),size:[h,1]}))}function s(o,u){for(var p=[f(o,u,!0)._data.map(W=>W[0])],v=o._size[0],h=o._size[1],b=o._values,w=o._index,N=o._ptr,g=0;g<h;g++)for(var y=p.length,x=0;x<y;x++){for(var d=p[x],A=[],S=[],O=N[g],M=N[g+1],_=0,E=O;E<M;E++){var $=w[E];$===g?_=b[E]:$>g&&(A.push(b[E]),S.push($))}if(l(_,0))if(l(d[g],0)){if(x===0){var B=[...d];B[g]=1;for(var G=0,D=S.length;G<D;G++){var H=S[G];B[H]=i(B[H],A[G])}p.push(B)}}else{if(x===0)return[];p.splice(x,1),x-=1,y-=1}else{d[g]=t(d[g],_);for(var z=0,I=S.length;z<I;z++){var T=S[z];d[T]=i(d[T],r(d[g],A[z]))}}}return p.map(W=>new m({data:W.map(j=>[j]),size:[v,1]}))}}),kc="usolveAll",rx=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],tx=R(kc,rx,e=>{var{typed:n,matrix:a,divideScalar:t,multiplyScalar:r,subtract:i,equalScalar:l,DenseMatrix:m}=e,f=Rn({DenseMatrix:m});return n(kc,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return c(u,p)},"Array, Array | Matrix":function(u,p){var v=a(u),h=c(v,p);return h.map(b=>b.valueOf())}});function c(o,u){for(var p=[f(o,u,!0)._data.map(S=>S[0])],v=o._data,h=o._size[0],b=o._size[1],w=b-1;w>=0;w--)for(var N=p.length,g=0;g<N;g++){var y=p[g];if(l(v[w][w],0))if(l(y[w],0)){if(g===0){var d=[...y];d[w]=1;for(var A=w-1;A>=0;A--)d[A]=i(d[A],v[A][w]);p.push(d)}}else{if(g===0)return[];p.splice(g,1),g-=1,N-=1}else{y[w]=t(y[w],v[w][w]);for(var x=w-1;x>=0;x--)y[x]=i(y[x],r(y[w],v[x][w]))}}return p.map(S=>new m({data:S.map(O=>[O]),size:[h,1]}))}function s(o,u){for(var p=[f(o,u,!0)._data.map(W=>W[0])],v=o._size[0],h=o._size[1],b=o._values,w=o._index,N=o._ptr,g=h-1;g>=0;g--)for(var y=p.length,x=0;x<y;x++){for(var d=p[x],A=[],S=[],O=N[g],M=N[g+1],_=0,E=M-1;E>=O;E--){var $=w[E];$===g?_=b[E]:$<g&&(A.push(b[E]),S.push($))}if(l(_,0))if(l(d[g],0)){if(x===0){var B=[...d];B[g]=1;for(var G=0,D=S.length;G<D;G++){var H=S[G];B[H]=i(B[H],A[G])}p.push(B)}}else{if(x===0)return[];p.splice(x,1),x-=1,y-=1}else{d[g]=t(d[g],_);for(var z=0,I=S.length;z<I;z++){var T=S[z];d[T]=i(d[T],r(d[g],A[z]))}}}return p.map(W=>new m({data:W.map(j=>[j]),size:[v,1]}))}}),nx="algorithm08",ax=["typed","equalScalar"],Si=R(nx,ax,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._index,c=r._ptr,s=r._size,o=r._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new Fe(s.length,h.length);if(s[0]!==h[0]||s[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+h+")");if(!m||!u)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var w=s[0],N=s[1],g,y=a,x=0,d=l;typeof o=="string"&&o===b&&(g=o,y=n.find(a,[g,g]),x=n.convert(0,g),d=n.find(l,[g,g]));for(var A=[],S=[],O=[],M=[],_=[],E,$,z,I,T=0;T<N;T++){O[T]=S.length;var B=T+1;for($=c[T],z=c[T+1],E=$;E<z;E++)I=f[E],_[I]=B,M[I]=m[E],S.push(I);for($=v[T],z=v[T+1],E=$;E<z;E++)I=p[E],_[I]===B&&(M[I]=d(M[I],u[E]));for(E=O[T];E<S.length;){I=S[E];var G=M[I];y(G,x)?S.splice(E,1):(A.push(G),E++)}}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),Hc="leftShift",ix=["typed","matrix","equalScalar","zeros","DenseMatrix"],ox=R(Hc,ix,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,DenseMatrix:i}=e,l=qt({typed:n}),m=rt({typed:n,equalScalar:t}),f=Si({typed:n,equalScalar:t}),c=Vt({typed:n,DenseMatrix:i}),s=wr({typed:n,equalScalar:t}),o=je({typed:n}),u=Ge({typed:n});return n(Hc,{"number, number":vs,"BigNumber, BigNumber":Oy,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return m(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return l(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():s(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():u(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):c(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):u(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(a(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,a(h)).valueOf()}})}),Gc="rightArithShift",sx=["typed","matrix","equalScalar","zeros","DenseMatrix"],ux=R(Gc,sx,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,DenseMatrix:i}=e,l=qt({typed:n}),m=rt({typed:n,equalScalar:t}),f=Si({typed:n,equalScalar:t}),c=Vt({typed:n,DenseMatrix:i}),s=wr({typed:n,equalScalar:t}),o=je({typed:n}),u=Ge({typed:n});return n(Gc,{"number, number":hs,"BigNumber, BigNumber":Dy,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return m(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return l(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():s(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():u(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):c(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):u(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(a(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,a(h)).valueOf()}})}),Vc="rightLogShift",cx=["typed","matrix","equalScalar","zeros","DenseMatrix"],fx=R(Vc,cx,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,DenseMatrix:i}=e,l=qt({typed:n}),m=rt({typed:n,equalScalar:t}),f=Si({typed:n,equalScalar:t}),c=Vt({typed:n,DenseMatrix:i}),s=wr({typed:n,equalScalar:t}),o=je({typed:n}),u=Ge({typed:n});return n(Vc,{"number, number":ds,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return m(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return l(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():s(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():u(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):c(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):u(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(a(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,a(h)).valueOf()}})}),Zc="and",lx=["typed","matrix","equalScalar","zeros","not"],mx=R(Zc,lx,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,not:i}=e,l=rt({typed:n,equalScalar:t}),m=Sa({typed:n,equalScalar:t}),f=wr({typed:n,equalScalar:t}),c=je({typed:n}),s=Ge({typed:n});return n(Zc,{"number, number":ws,"Complex, Complex":function(u,p){return(u.re!==0||u.im!==0)&&(p.re!==0||p.im!==0)},"BigNumber, BigNumber":function(u,p){return!u.isZero()&&!p.isZero()&&!u.isNaN()&&!p.isNaN()},"Unit, Unit":function(u,p){return this(u.value||0,p.value||0)},"SparseMatrix, SparseMatrix":function(u,p){return m(u,p,this,!1)},"SparseMatrix, DenseMatrix":function(u,p){return l(p,u,this,!0)},"DenseMatrix, SparseMatrix":function(u,p){return l(u,p,this,!1)},"DenseMatrix, DenseMatrix":function(u,p){return c(u,p,this)},"Array, Array":function(u,p){return this(a(u),a(p)).valueOf()},"Array, Matrix":function(u,p){return this(a(u),p)},"Matrix, Array":function(u,p){return this(u,a(p))},"SparseMatrix, any":function(u,p){return i(p)?r(u.size(),u.storage()):f(u,p,this,!1)},"DenseMatrix, any":function(u,p){return i(p)?r(u.size(),u.storage()):s(u,p,this,!1)},"any, SparseMatrix":function(u,p){return i(u)?r(u.size(),u.storage()):f(p,u,this,!0)},"any, DenseMatrix":function(u,p){return i(u)?r(u.size(),u.storage()):s(p,u,this,!0)},"Array, any":function(u,p){return this(a(u),p).valueOf()},"any, Array":function(u,p){return this(u,a(p)).valueOf()}})}),Xc="compare",px=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],vx=R(Xc,px,e=>{var{typed:n,config:a,equalScalar:t,matrix:r,BigNumber:i,Fraction:l,DenseMatrix:m}=e,f=Dr({typed:n}),c=Ea({typed:n,equalScalar:t}),s=gr({typed:n,DenseMatrix:m}),o=je({typed:n}),u=Ge({typed:n});return n(Xc,{"boolean, boolean":function(v,h){return v===h?0:v>h?1:-1},"number, number":function(v,h){return Rr(v,h,a.epsilon)?0:v>h?1:-1},"BigNumber, BigNumber":function(v,h){return st(v,h,a.epsilon)?new i(0):new i(v.cmp(h))},"Fraction, Fraction":function(v,h){return new l(v.compare(h))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(v,h){if(!v.equalBase(h))throw new Error("Cannot compare units with different base");return this(v.value,h.value)},"SparseMatrix, SparseMatrix":function(v,h){return c(v,h,this)},"SparseMatrix, DenseMatrix":function(v,h){return f(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(r(v),r(h)).valueOf()},"Array, Matrix":function(v,h){return this(r(v),h)},"Matrix, Array":function(v,h){return this(v,r(h))},"SparseMatrix, any":function(v,h){return s(v,h,this,!1)},"DenseMatrix, any":function(v,h){return u(v,h,this,!1)},"any, SparseMatrix":function(v,h){return s(h,v,this,!0)},"any, DenseMatrix":function(v,h){return u(h,v,this,!0)},"Array, any":function(v,h){return u(r(v),h,this,!1).valueOf()},"any, Array":function(v,h){return u(r(h),v,this,!0).valueOf()}})}),Ei,Yc;function hx(){return Yc||(Yc=1,Ei=function e(n,a){var t=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,r=/(^[ ]*|[ ]*$)/g,i=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,l=/^0x[0-9a-f]+$/i,m=/^0/,f=function(g){return e.insensitive&&(""+g).toLowerCase()||""+g},c=f(n).replace(r,"")||"",s=f(a).replace(r,"")||"",o=c.replace(t,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),u=s.replace(t,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),p=parseInt(c.match(l),16)||o.length!==1&&c.match(i)&&Date.parse(c),v=parseInt(s.match(l),16)||p&&s.match(i)&&Date.parse(s)||null,h,b;if(v){if(p<v)return-1;if(p>v)return 1}for(var w=0,N=Math.max(o.length,u.length);w<N;w++){if(h=!(o[w]||"").match(m)&&parseFloat(o[w])||o[w]||0,b=!(u[w]||"").match(m)&&parseFloat(u[w])||u[w]||0,isNaN(h)!==isNaN(b))return isNaN(h)?1:-1;if(typeof h!=typeof b&&(h+="",b+=""),h<b)return-1;if(h>b)return 1}return 0}),Ei}var dx=hx();const xn=Tn(dx);var Wc="compareNatural",gx=["typed","compare"],yx=R(Wc,gx,e=>{var{typed:n,compare:a}=e,t=a.signatures["boolean,boolean"];return n(Wc,{"any, any":function(f,c){var s=Ke(f),o=Ke(c),u;if((s==="number"||s==="BigNumber"||s==="Fraction")&&(o==="number"||o==="BigNumber"||o==="Fraction"))return u=a(f,c),u.toString()!=="0"?u>0?1:-1:xn(s,o);if(s==="Array"||s==="Matrix"||o==="Array"||o==="Matrix")return u=r(this,f,c),u!==0?u:xn(s,o);if(s!==o)return xn(s,o);if(s==="Complex")return xx(f,c);if(s==="Unit")return f.equalBase(c)?this(f.value,c.value):i(this,f.formatUnits(),c.formatUnits());if(s==="boolean")return t(f,c);if(s==="string")return xn(f,c);if(s==="Object")return l(this,f,c);if(s==="null"||s==="undefined")return 0;throw new TypeError('Unsupported type of value "'+s+'"')}});function r(m,f,c){return Ut(f)&&Ut(c)?i(m,f.toJSON().values,c.toJSON().values):Ut(f)?r(m,f.toArray(),c):Ut(c)?r(m,f,c.toArray()):Qn(f)?r(m,f.toJSON().data,c):Qn(c)?r(m,f,c.toJSON().data):Array.isArray(f)?Array.isArray(c)?i(m,f,c):r(m,f,[c]):r(m,[f],c)}function i(m,f,c){for(var s=0,o=Math.min(f.length,c.length);s<o;s++){var u=m(f[s],c[s]);if(u!==0)return u}return f.length>c.length?1:f.length<c.length?-1:0}function l(m,f,c){var s=Object.keys(f),o=Object.keys(c);s.sort(xn),o.sort(xn);var u=i(m,s,o);if(u!==0)return u;for(var p=0;p<s.length;p++){var v=m(f[s[p]],c[o[p]]);if(v!==0)return v}return 0}});function xx(e,n){return e.re>n.re?1:e.re<n.re?-1:e.im>n.im?1:e.im<n.im?-1:0}var Jc="compareText",bx=["typed","matrix"],wx=R(Jc,bx,e=>{var{typed:n,matrix:a}=e,t=je({typed:n}),r=Ge({typed:n});return n(Jc,{"any, any":an,"DenseMatrix, DenseMatrix":function(l,m){return t(l,m,an)},"Array, Array":function(l,m){return this(a(l),a(m)).valueOf()},"Array, Matrix":function(l,m){return this(a(l),m)},"Matrix, Array":function(l,m){return this(l,a(m))},"DenseMatrix, any":function(l,m){return r(l,m,an,!1)},"any, DenseMatrix":function(l,m){return r(m,l,an,!0)},"Array, any":function(l,m){return r(a(l),m,an,!1).valueOf()},"any, Array":function(l,m){return r(a(m),l,an,!0).valueOf()}})}),Da="equal",Nx=["typed","matrix","equalScalar","DenseMatrix"],Mx=R(Da,Nx,e=>{var{typed:n,matrix:a,equalScalar:t,DenseMatrix:r}=e,i=Dr({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=gr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(Da,{"any, any":function(o,u){return o===null?u===null:u===null?o===null:o===void 0?u===void 0:u===void 0?o===void 0:t(o,u)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,t)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,t,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,t,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,t)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, any":function(o,u){return m(o,u,t,!1)},"DenseMatrix, any":function(o,u){return c(o,u,t,!1)},"any, SparseMatrix":function(o,u){return m(u,o,t,!0)},"any, DenseMatrix":function(o,u){return c(u,o,t,!0)},"Array, any":function(o,u){return c(a(o),u,t,!1).valueOf()},"any, Array":function(o,u){return c(a(u),o,t,!0).valueOf()}})});R(Da,["typed","equalScalar"],e=>{var{typed:n,equalScalar:a}=e;return n(Da,{"any, any":function(r,i){return r===null?i===null:i===null?r===null:r===void 0?i===void 0:i===void 0?r===void 0:a(r,i)}})});var Qc="equalText",Ax=["typed","compareText","isZero"],Sx=R(Qc,Ax,e=>{var{typed:n,compareText:a,isZero:t}=e;return n(Qc,{"any, any":function(i,l){return t(a(i,l))}})}),Kc="smaller",Ex=["typed","config","matrix","DenseMatrix"],Cx=R(Kc,Ex,e=>{var{typed:n,config:a,matrix:t,DenseMatrix:r}=e,i=Dr({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=gr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(Kc,{"boolean, boolean":function(o,u){return o<u},"number, number":function(o,u){return o<u&&!Rr(o,u,a.epsilon)},"BigNumber, BigNumber":function(o,u){return o.lt(u)&&!st(o,u,a.epsilon)},"Fraction, Fraction":function(o,u){return o.compare(u)===-1},"Complex, Complex":function(o,u){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(o,u){if(!o.equalBase(u))throw new Error("Cannot compare units with different base");return this(o.value,u.value)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(t(o),t(u)).valueOf()},"Array, Matrix":function(o,u){return this(t(o),u)},"Matrix, Array":function(o,u){return this(o,t(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(t(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(t(u),o,this,!0).valueOf()}})}),jc="smallerEq",Ox=["typed","config","matrix","DenseMatrix"],Dx=R(jc,Ox,e=>{var{typed:n,config:a,matrix:t,DenseMatrix:r}=e,i=Dr({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=gr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(jc,{"boolean, boolean":function(o,u){return o<=u},"number, number":function(o,u){return o<=u||Rr(o,u,a.epsilon)},"BigNumber, BigNumber":function(o,u){return o.lte(u)||st(o,u,a.epsilon)},"Fraction, Fraction":function(o,u){return o.compare(u)!==1},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(o,u){if(!o.equalBase(u))throw new Error("Cannot compare units with different base");return this(o.value,u.value)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(t(o),t(u)).valueOf()},"Array, Matrix":function(o,u){return this(t(o),u)},"Matrix, Array":function(o,u){return this(o,t(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(t(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(t(u),o,this,!0).valueOf()}})}),ef="larger",Tx=["typed","config","matrix","DenseMatrix"],Bx=R(ef,Tx,e=>{var{typed:n,config:a,matrix:t,DenseMatrix:r}=e,i=Dr({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=gr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(ef,{"boolean, boolean":function(o,u){return o>u},"number, number":function(o,u){return o>u&&!Rr(o,u,a.epsilon)},"BigNumber, BigNumber":function(o,u){return o.gt(u)&&!st(o,u,a.epsilon)},"Fraction, Fraction":function(o,u){return o.compare(u)===1},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(o,u){if(!o.equalBase(u))throw new Error("Cannot compare units with different base");return this(o.value,u.value)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(t(o),t(u)).valueOf()},"Array, Matrix":function(o,u){return this(t(o),u)},"Matrix, Array":function(o,u){return this(o,t(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(t(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(t(u),o,this,!0).valueOf()}})}),rf="largerEq",_x=["typed","config","matrix","DenseMatrix"],$x=R(rf,_x,e=>{var{typed:n,config:a,matrix:t,DenseMatrix:r}=e,i=Dr({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=gr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(rf,{"boolean, boolean":function(o,u){return o>=u},"number, number":function(o,u){return o>=u||Rr(o,u,a.epsilon)},"BigNumber, BigNumber":function(o,u){return o.gte(u)||st(o,u,a.epsilon)},"Fraction, Fraction":function(o,u){return o.compare(u)!==-1},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(o,u){if(!o.equalBase(u))throw new Error("Cannot compare units with different base");return this(o.value,u.value)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(t(o),t(u)).valueOf()},"Array, Matrix":function(o,u){return this(t(o),u)},"Matrix, Array":function(o,u){return this(o,t(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(t(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(t(u),o,this,!0).valueOf()}})}),tf="deepEqual",Ix=["typed","equal"],qx=R(tf,Ix,e=>{var{typed:n,equal:a}=e;return n(tf,{"any, any":function(i,l){return t(i.valueOf(),l.valueOf())}});function t(r,i){if(Array.isArray(r))if(Array.isArray(i)){var l=r.length;if(l!==i.length)return!1;for(var m=0;m<l;m++)if(!t(r[m],i[m]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:a(r,i)}}),Ci="unequal",Rx=["typed","config","equalScalar","matrix","DenseMatrix"],Fx=R(Ci,Rx,e=>{var{typed:n,config:a,equalScalar:t,matrix:r,DenseMatrix:i}=e,l=Dr({typed:n}),m=ut({typed:n,DenseMatrix:i}),f=gr({typed:n,DenseMatrix:i}),c=je({typed:n}),s=Ge({typed:n});return n("unequal",{"any, any":function(p,v){return p===null?v!==null:v===null?p!==null:p===void 0?v!==void 0:v===void 0?p!==void 0:o(p,v)},"SparseMatrix, SparseMatrix":function(p,v){return m(p,v,o)},"SparseMatrix, DenseMatrix":function(p,v){return l(v,p,o,!0)},"DenseMatrix, SparseMatrix":function(p,v){return l(p,v,o,!1)},"DenseMatrix, DenseMatrix":function(p,v){return c(p,v,o)},"Array, Array":function(p,v){return this(r(p),r(v)).valueOf()},"Array, Matrix":function(p,v){return this(r(p),v)},"Matrix, Array":function(p,v){return this(p,r(v))},"SparseMatrix, any":function(p,v){return f(p,v,o,!1)},"DenseMatrix, any":function(p,v){return s(p,v,o,!1)},"any, SparseMatrix":function(p,v){return f(v,p,o,!0)},"any, DenseMatrix":function(p,v){return s(v,p,o,!0)},"Array, any":function(p,v){return s(r(p),v,o,!1).valueOf()},"any, Array":function(p,v){return s(r(v),p,o,!0).valueOf()}});function o(u,p){return!t(u,p)}});R(Ci,["typed","equalScalar"],e=>{var{typed:n,equalScalar:a}=e;return n(Ci,{"any, any":function(r,i){return r===null?i!==null:i===null?r!==null:r===void 0?i!==void 0:i===void 0?r!==void 0:!a(r,i)}})});var nf="partitionSelect",zx=["typed","isNumeric","isNaN","compare"],Px=R(nf,zx,e=>{var{typed:n,isNumeric:a,isNaN:t,compare:r}=e,i=r,l=(c,s)=>-r(c,s);return n(nf,{"Array | Matrix, number":function(s,o){return m(s,o,i)},"Array | Matrix, number, string":function(s,o,u){if(u==="asc")return m(s,o,i);if(u==="desc")return m(s,o,l);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":m});function m(c,s,o){if(!Ae(s)||s<0)throw new Error("k must be a non-negative integer");if(Oe(c)){var u=c.size();if(u.length>1)throw new Error("Only one dimensional matrices supported");return f(c.valueOf(),s,o)}if(Array.isArray(c))return f(c,s,o)}function f(c,s,o){if(s>=c.length)throw new Error("k out of bounds");for(var u=0;u<c.length;u++)if(a(c[u])&&t(c[u]))return c[u];for(var p=0,v=c.length-1;p<v;){for(var h=p,b=v,w=c[Math.floor(Math.random()*(v-p+1))+p];h<b;)if(o(c[h],w)>=0){var N=c[b];c[b]=c[h],c[h]=N,--b}else++h;o(c[h],w)>0&&--h,s<=h?v=h:p=h+1}return c[s]}}),af="sort",Ux=["typed","matrix","compare","compareNatural"],Lx=R(af,Ux,e=>{var{typed:n,matrix:a,compare:t,compareNatural:r}=e,i=t,l=(s,o)=>-t(s,o);return n(af,{Array:function(o){return f(o),o.sort(i)},Matrix:function(o){return c(o),a(o.toArray().sort(i),o.storage())},"Array, function":function(o,u){return f(o),o.sort(u)},"Matrix, function":function(o,u){return c(o),a(o.toArray().sort(u),o.storage())},"Array, string":function(o,u){return f(o),o.sort(m(u))},"Matrix, string":function(o,u){return c(o),a(o.toArray().sort(m(u)),o.storage())}});function m(s){if(s==="asc")return i;if(s==="desc")return l;if(s==="natural")return r;throw new Error('String "asc", "desc", or "natural" expected')}function f(s){if(Pe(s).length!==1)throw new Error("One dimensional array expected")}function c(s){if(s.size().length!==1)throw new Error("One dimensional matrix expected")}}),of="max",kx=["typed","config","numeric","larger"],sf=R(of,kx,e=>{var{typed:n,config:a,numeric:t,larger:r}=e;return n(of,{"Array | Matrix":l,"Array | Matrix, number | BigNumber":function(f,c){return xa(f,c.valueOf(),i)},"...":function(f){if(mn(f))throw new TypeError("Scalar values expected in function max");return l(f)}});function i(m,f){try{return r(m,f)?m:f}catch(c){throw Tr(c,"max",f)}}function l(m){var f;if(bt(m,function(c){try{isNaN(c)&&typeof c=="number"?f=NaN:(f===void 0||r(c,f))&&(f=c)}catch(s){throw Tr(s,"max",c)}}),f===void 0)throw new Error("Cannot calculate max of an empty array");return typeof f=="string"&&(f=t(f,a.number)),f}}),uf="min",Hx=["typed","config","numeric","smaller"],cf=R(uf,Hx,e=>{var{typed:n,config:a,numeric:t,smaller:r}=e;return n(uf,{"Array | Matrix":l,"Array | Matrix, number | BigNumber":function(f,c){return xa(f,c.valueOf(),i)},"...":function(f){if(mn(f))throw new TypeError("Scalar values expected in function min");return l(f)}});function i(m,f){try{return r(m,f)?m:f}catch(c){throw Tr(c,"min",f)}}function l(m){var f;if(bt(m,function(c){try{isNaN(c)&&typeof c=="number"?f=NaN:(f===void 0||r(c,f))&&(f=c)}catch(s){throw Tr(s,"min",c)}}),f===void 0)throw new Error("Cannot calculate min of an empty array");return typeof f=="string"&&(f=t(f,a.number)),f}}),Gx="ImmutableDenseMatrix",Vx=["smaller","DenseMatrix"],Zx=R(Gx,Vx,e=>{var{smaller:n,DenseMatrix:a}=e;function t(r,i){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(i&&!_r(i))throw new Error("Invalid datatype: "+i);if(Oe(r)||Xe(r)){var l=new a(r,i);this._data=l._data,this._size=l._size,this._datatype=l._datatype,this._min=null,this._max=null}else if(r&&Xe(r.data)&&Xe(r.size))this._data=r.data,this._size=r.size,this._datatype=r.datatype,this._min=typeof r.min!="undefined"?r.min:null,this._max=typeof r.max!="undefined"?r.max:null;else{if(r)throw new TypeError("Unsupported type of data ("+Ke(r)+")");this._data=[],this._size=[0],this._datatype=i,this._min=null,this._max=null}}return t.prototype=new a,t.prototype.type="ImmutableDenseMatrix",t.prototype.isImmutableDenseMatrix=!0,t.prototype.subset=function(r){switch(arguments.length){case 1:{var i=a.prototype.subset.call(this,r);return Oe(i)?new t({data:i._data,size:i._size,datatype:i._datatype}):i}case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},t.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},t.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},t.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},t.prototype.clone=function(){return new t({data:Ce(this._data),size:Ce(this._size),datatype:this._datatype})},t.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},t.fromJSON=function(r){return new t(r)},t.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},t.prototype.min=function(){if(this._min===null){var r=null;this.forEach(function(i){(r===null||n(i,r))&&(r=i)}),this._min=r!==null?r:void 0}return this._min},t.prototype.max=function(){if(this._max===null){var r=null;this.forEach(function(i){(r===null||n(r,i))&&(r=i)}),this._max=r!==null?r:void 0}return this._max},t},{isClass:!0}),Xx="Index",Yx=["ImmutableDenseMatrix"],Wx=R(Xx,Yx,e=>{var{ImmutableDenseMatrix:n}=e;function a(r){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var i=0,l=arguments.length;i<l;i++){var m=arguments[i];if(Kn(m))this._dimensions.push(m),this._isScalar=!1;else if(Array.isArray(m)||Oe(m)){var f=t(m.valueOf());this._dimensions.push(f);var c=f.size();(c.length!==1||c[0]!==1)&&(this._isScalar=!1)}else if(typeof m=="number")this._dimensions.push(t([m]));else if(typeof m=="string")this._dimensions.push(m);else throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range")}}a.prototype.type="Index",a.prototype.isIndex=!0;function t(r){for(var i=0,l=r.length;i<l;i++)if(typeof r[i]!="number"||!Ae(r[i]))throw new TypeError("Index parameters must be positive integer numbers");return new n(r)}return a.prototype.clone=function(){var r=new a;return r._dimensions=Ce(this._dimensions),r._isScalar=this._isScalar,r},a.create=function(r){var i=new a;return a.apply(i,r),i},a.prototype.size=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];r[i]=typeof m=="string"?1:m.size()[0]}return r},a.prototype.max=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];r[i]=typeof m=="string"?m:m.max()}return r},a.prototype.min=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];r[i]=typeof m=="string"?m:m.min()}return r},a.prototype.forEach=function(r){for(var i=0,l=this._dimensions.length;i<l;i++)r(this._dimensions[i],i,this)},a.prototype.dimension=function(r){return this._dimensions[r]||null},a.prototype.isObjectProperty=function(){return this._dimensions.length===1&&typeof this._dimensions[0]=="string"},a.prototype.getObjectProperty=function(){return this.isObjectProperty()?this._dimensions[0]:null},a.prototype.isScalar=function(){return this._isScalar},a.prototype.toArray=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];r.push(typeof m=="string"?m:m.toArray())}return r},a.prototype.valueOf=a.prototype.toArray,a.prototype.toString=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];typeof m=="string"?r.push(JSON.stringify(m)):r.push(m.toString())}return"["+r.join(", ")+"]"},a.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},a.fromJSON=function(r){return a.create(r.dimensions)},a},{isClass:!0}),Jx="FibonacciHeap",Qx=["smaller","larger"],Kx=R(Jx,Qx,e=>{var{smaller:n,larger:a}=e,t=1/Math.log((1+Math.sqrt(5))/2);function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}r.prototype.type="FibonacciHeap",r.prototype.isFibonacciHeap=!0,r.prototype.insert=function(s,o){var u={key:s,value:o,degree:0};if(this._minimum){var p=this._minimum;u.left=p,u.right=p.right,p.right=u,u.right.left=u,n(s,p.key)&&(this._minimum=u)}else u.left=u,u.right=u,this._minimum=u;return this._size++,u},r.prototype.size=function(){return this._size},r.prototype.clear=function(){this._minimum=null,this._size=0},r.prototype.isEmpty=function(){return this._size===0},r.prototype.extractMinimum=function(){var s=this._minimum;if(s===null)return s;for(var o=this._minimum,u=s.degree,p=s.child;u>0;){var v=p.right;p.left.right=p.right,p.right.left=p.left,p.left=o,p.right=o.right,o.right=p,p.right.left=p,p.parent=null,p=v,u--}return s.left.right=s.right,s.right.left=s.left,s===s.right?o=null:(o=s.right,o=c(o,this._size)),this._size--,this._minimum=o,s},r.prototype.remove=function(s){this._minimum=i(this._minimum,s,-1),this.extractMinimum()};function i(s,o,u){o.key=u;var p=o.parent;return p&&n(o.key,p.key)&&(l(s,o,p),m(s,p)),n(o.key,s.key)&&(s=o),s}function l(s,o,u){o.left.right=o.right,o.right.left=o.left,u.degree--,u.child===o&&(u.child=o.right),u.degree===0&&(u.child=null),o.left=s,o.right=s.right,s.right=o,o.right.left=o,o.parent=null,o.mark=!1}function m(s,o){var u=o.parent;u&&(o.mark?(l(s,o,u),m(u)):o.mark=!0)}var f=function(o,u){o.left.right=o.right,o.right.left=o.left,o.parent=u,u.child?(o.left=u.child,o.right=u.child.right,u.child.right=o,o.right.left=o):(u.child=o,o.right=o,o.left=o),u.degree++,o.mark=!1};function c(s,o){var u=Math.floor(Math.log(o)*t)+1,p=new Array(u),v=0,h=s;if(h)for(v++,h=h.right;h!==s;)v++,h=h.right;for(var b;v>0;){for(var w=h.degree,N=h.right;b=p[w],!!b;){if(a(h.key,b.key)){var g=b;b=h,h=g}f(b,h),p[w]=null,w++}p[w]=h,h=N,v--}s=null;for(var y=0;y<u;y++)b=p[y],b&&(s?(b.left.right=b.right,b.right.left=b.left,b.left=s,b.right=s.right,s.right=b,b.right.left=b,n(b.key,s.key)&&(s=b)):s=b);return s}return r},{isClass:!0}),jx="Spa",eb=["addScalar","equalScalar","FibonacciHeap"],rb=R(jx,eb,e=>{var{addScalar:n,equalScalar:a,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(i,l){if(this._values[i])this._values[i].value=l;else{var m=this._heap.insert(i,l);this._values[i]=m}},r.prototype.get=function(i){var l=this._values[i];return l?l.value:0},r.prototype.accumulate=function(i,l){var m=this._values[i];m?m.value=n(m.value,l):(m=this._heap.insert(i,l),this._values[i]=m)},r.prototype.forEach=function(i,l,m){var f=this._heap,c=this._values,s=[],o=f.extractMinimum();for(o&&s.push(o);o&&o.key<=l;)o.key>=i&&(a(o.value,0)||m(o.key,o.value,this)),o=f.extractMinimum(),o&&s.push(o);for(var u=0;u<s.length;u++){var p=s[u];o=f.insert(p.key,p.value),c[o.key]=o}},r.prototype.swap=function(i,l){var m=this._values[i],f=this._values[l];if(!m&&f)m=this._heap.insert(i,f.value),this._heap.remove(f),this._values[i]=m,this._values[l]=void 0;else if(m&&!f)f=this._heap.insert(l,m.value),this._heap.remove(m),this._values[l]=f,this._values[i]=void 0;else if(m&&f){var c=m.value;m.value=f.value,f.value=c}},r},{isClass:!0});function Fn(e){"@babel/helpers - typeof";return Fn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Fn(e)}function tb(e,n){if(Fn(e)!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var t=a.call(e,n);if(Fn(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function nb(e){var n=tb(e,"string");return Fn(n)=="symbol"?n:n+""}function ff(e,n,a){return(n=nb(n))in e?Object.defineProperty(e,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[n]=a,e}var ab=qn(function(e){return new e(1).exp()},{hasher:Ta}),ib=qn(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},{hasher:Ta}),Oi=qn(function(e){return e.acos(-1)},{hasher:Ta}),ob=qn(function(e){return Oi(e).times(2)},{hasher:Ta});function Ta(e){return e[0].precision}function lf(e,n){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),a.push.apply(a,t)}return a}function Di(e){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?lf(Object(a),!0).forEach(function(t){ff(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):lf(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var sb="Unit",ub=["?on","config","addScalar","subtract","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","number","Complex","BigNumber","Fraction"],cb=R(sb,ub,e=>{var{on:n,config:a,addScalar:t,subtract:r,multiplyScalar:i,divideScalar:l,pow:m,abs:f,fix:c,round:s,equal:o,isNumeric:u,format:p,number:v,Complex:h,BigNumber:b,Fraction:w}=e,N=v;function g(F,Y){if(!(this instanceof g))throw new Error("Constructor must be called with the new operator");if(!(F==null||u(F)||Or(F)))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(Y!==void 0&&(typeof Y!="string"||Y===""))throw new TypeError("Second parameter in Unit constructor must be a string");if(Y!==void 0){var k=g.parse(Y);this.units=k.units,this.dimensions=k.dimensions}else{this.units=[{unit:j,prefix:B.NONE,power:0}],this.dimensions=[];for(var U=0;U<G.length;U++)this.dimensions[U]=0}this.value=F!=null?this._normalize(F):null,this.fixPrefix=!1,this.skipAutomaticSimplification=!0}g.prototype.type="Unit",g.prototype.isUnit=!0;var y,x,d;function A(){for(;d===" "||d===" ";)M()}function S(F){return F>="0"&&F<="9"||F==="."}function O(F){return F>="0"&&F<="9"}function M(){x++,d=y.charAt(x)}function _(F){x=F,d=y.charAt(x)}function E(){var F="",Y=x;if(d==="+"?M():d==="-"&&(F+=d,M()),!S(d))return _(Y),null;if(d==="."){if(F+=d,M(),!O(d))return _(Y),null}else{for(;O(d);)F+=d,M();d==="."&&(F+=d,M())}for(;O(d);)F+=d,M();if(d==="E"||d==="e"){var k="",U=x;if(k+=d,M(),(d==="+"||d==="-")&&(k+=d,M()),!O(d))return _(U),F;for(F=F+k;O(d);)F+=d,M()}return F}function $(){for(var F="";O(d)||g.isValidAlpha(d);)F+=d,M();var Y=F.charAt(0);return g.isValidAlpha(Y)?F:null}function z(F){return d===F?(M(),F):null}g.parse=function(F,Y){if(Y=Y||{},y=F,x=-1,d="",typeof y!="string")throw new TypeError("Invalid argument in Unit.parse, string expected");var k=new g;k.units=[];var U=1,J=!1;M(),A();var q=E(),P=null;if(q){if(a.number==="BigNumber")P=new b(q);else if(a.number==="Fraction")try{P=new w(q)}catch(cr){P=parseFloat(q)}else P=parseFloat(q);A(),z("*")?(U=1,J=!0):z("/")&&(U=-1,J=!0)}for(var Q=[],L=1;;){for(A();d==="(";)Q.push(U),L*=U,U=1,M(),A();var se=void 0;if(d){var fe=d;if(se=$(),se===null)throw new SyntaxError('Unexpected "'+fe+'" in "'+y+'" at index '+x.toString())}else break;var ge=I(se);if(ge===null)throw new SyntaxError('Unit "'+se+'" not found.');var pe=U*L;if(A(),z("^")){A();var ve=E();if(ve===null)throw new SyntaxError('In "'+F+'", "^" must be followed by a floating-point number');pe*=ve}k.units.push({unit:ge.unit,prefix:ge.prefix,power:pe});for(var Ne=0;Ne<G.length;Ne++)k.dimensions[Ne]+=(ge.unit.dimensions[Ne]||0)*pe;for(A();d===")";){if(Q.length===0)throw new SyntaxError('Unmatched ")" in "'+y+'" at index '+x.toString());L/=Q.pop(),M(),A()}if(J=!1,z("*")?(U=1,J=!0):z("/")?(U=-1,J=!0):U=1,ge.unit.base){var Qe=ge.unit.base.key;re.auto[Qe]={unit:ge.unit,prefix:ge.prefix}}}if(A(),d)throw new SyntaxError('Could not parse: "'+F+'"');if(J)throw new SyntaxError('Trailing characters: "'+F+'"');if(Q.length!==0)throw new SyntaxError('Unmatched "(" in "'+y+'"');if(k.units.length===0&&!Y.allowNoUnits)throw new SyntaxError('"'+F+'" contains no units');return k.value=P!==void 0?k._normalize(P):null,k},g.prototype.clone=function(){var F=new g;F.fixPrefix=this.fixPrefix,F.skipAutomaticSimplification=this.skipAutomaticSimplification,F.value=Ce(this.value),F.dimensions=this.dimensions.slice(0),F.units=[];for(var Y=0;Y<this.units.length;Y++){F.units[Y]={};for(var k in this.units[Y])Me(this.units[Y],k)&&(F.units[Y][k]=this.units[Y][k])}return F},g.prototype._isDerived=function(){return this.units.length===0?!1:this.units.length>1||Math.abs(this.units[0].power-1)>1e-15},g.prototype._normalize=function(F){if(F==null||this.units.length===0)return F;for(var Y=F,k=g._getNumberConverter(Ke(F)),U=0;U<this.units.length;U++){var J=k(this.units[U].unit.value),q=k(this.units[U].prefix.value),P=k(this.units[U].power);Y=i(Y,m(i(J,q),P))}return Y},g.prototype._denormalize=function(F,Y){if(F==null||this.units.length===0)return F;for(var k=F,U=g._getNumberConverter(Ke(F)),J=0;J<this.units.length;J++){var q=U(this.units[J].unit.value),P=U(this.units[J].prefix.value),Q=U(this.units[J].power);k=l(k,m(i(q,P),Q))}return k};var I=qn(F=>{if(Me(V,F)){var Y=V[F],k=Y.prefixes[""];return{unit:Y,prefix:k}}for(var U in V)if(Me(V,U)&&sv(F,U)){var J=V[U],q=F.length-U.length,P=F.substring(0,q),Q=Me(J.prefixes,P)?J.prefixes[P]:void 0;if(Q!==void 0)return{unit:J,prefix:Q}}return null},{hasher:F=>F[0],limit:100});g.isValuelessUnit=function(F){return I(F)!==null},g.prototype.hasBase=function(F){if(typeof F=="string"&&(F=D[F]),!F)return!1;for(var Y=0;Y<G.length;Y++)if(Math.abs((this.dimensions[Y]||0)-(F.dimensions[Y]||0))>1e-12)return!1;return!0},g.prototype.equalBase=function(F){for(var Y=0;Y<G.length;Y++)if(Math.abs((this.dimensions[Y]||0)-(F.dimensions[Y]||0))>1e-12)return!1;return!0},g.prototype.equals=function(F){return this.equalBase(F)&&o(this.value,F.value)},g.prototype.multiply=function(F){for(var Y=this.clone(),k=0;k<G.length;k++)Y.dimensions[k]=(this.dimensions[k]||0)+(F.dimensions[k]||0);for(var U=0;U<F.units.length;U++){var J=Di({},F.units[U]);Y.units.push(J)}if(this.value!==null||F.value!==null){var q=this.value===null?this._normalize(1):this.value,P=F.value===null?F._normalize(1):F.value;Y.value=i(q,P)}else Y.value=null;return Y.skipAutomaticSimplification=!1,T(Y)},g.prototype.divide=function(F){for(var Y=this.clone(),k=0;k<G.length;k++)Y.dimensions[k]=(this.dimensions[k]||0)-(F.dimensions[k]||0);for(var U=0;U<F.units.length;U++){var J=Di(Di({},F.units[U]),{},{power:-F.units[U].power});Y.units.push(J)}if(this.value!==null||F.value!==null){var q=this.value===null?this._normalize(1):this.value,P=F.value===null?F._normalize(1):F.value;Y.value=l(q,P)}else Y.value=null;return Y.skipAutomaticSimplification=!1,T(Y)},g.prototype.pow=function(F){for(var Y=this.clone(),k=0;k<G.length;k++)Y.dimensions[k]=(this.dimensions[k]||0)*F;for(var U=0;U<Y.units.length;U++)Y.units[U].power*=F;return Y.value!==null?Y.value=m(Y.value,F):Y.value=null,Y.skipAutomaticSimplification=!1,T(Y)};function T(F){return F.equalBase(D.NONE)&&F.value!==null&&!a.predictable?F.value:F}g.prototype.abs=function(){var F=this.clone();if(F.value!==null)if(F._isDerived()||F.units[0].unit.offset===0)F.value=f(F.value);else{var Y=g._getNumberConverter(Ke(F.value)),k=Y(F.units[0].unit.value),U=Y(F.units[0].unit.offset),J=i(k,U);F.value=r(f(t(F.value,J)),J)}for(var q in F.units)(F.units[q].unit.name==="VA"||F.units[q].unit.name==="VAR")&&(F.units[q].unit=V.W);return F},g.prototype.to=function(F){var Y=this.value===null?this._normalize(1):this.value,k;if(typeof F=="string")k=g.parse(F);else if(ht(F))k=F.clone();else throw new Error("String or Unit expected as parameter");if(!this.equalBase(k))throw new Error("Units do not match ('".concat(k.toString(),"' != '").concat(this.toString(),"')"));if(k.value!==null)throw new Error("Cannot convert to a unit with a value");if(this.value===null||this._isDerived()||this.units[0].unit.offset===k.units[0].unit.offset)k.value=Ce(Y);else{var U=g._getNumberConverter(Ke(Y)),J=U(this.units[0].unit.value),q=U(this.units[0].unit.offset),P=i(J,q),Q=U(k.units[0].unit.value),L=U(k.units[0].unit.offset),se=i(Q,L);k.value=r(t(Y,P),se)}return k.fixPrefix=!0,k.skipAutomaticSimplification=!0,k},g.prototype.toNumber=function(F){return N(this.toNumeric(F))},g.prototype.toNumeric=function(F){var Y;return F?Y=this.to(F):Y=this.clone(),Y._isDerived()||Y.units.length===0?Y._denormalize(Y.value):Y._denormalize(Y.value,Y.units[0].prefix.value)},g.prototype.toString=function(){return this.format()},g.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.formatUnits(),fixPrefix:this.fixPrefix}},g.fromJSON=function(F){var Y=new g(F.value,F.unit);return Y.fixPrefix=F.fixPrefix||!1,Y},g.prototype.valueOf=g.prototype.toString,g.prototype.simplify=function(){var F=this.clone(),Y=[],k;for(var U in ie)if(Me(ie,U)&&F.hasBase(D[U])){k=U;break}if(k==="NONE")F.units=[];else{var J;if(k&&Me(ie,k)&&(J=ie[k]),J)F.units=[{unit:J.unit,prefix:J.prefix,power:1}];else{for(var q=!1,P=0;P<G.length;P++){var Q=G[P];Math.abs(F.dimensions[P]||0)>1e-12&&(Me(ie,Q)?Y.push({unit:ie[Q].unit,prefix:ie[Q].prefix,power:F.dimensions[P]||0}):q=!0)}Y.length<F.units.length&&!q&&(F.units=Y)}}return F},g.prototype.toSI=function(){for(var F=this.clone(),Y=[],k=0;k<G.length;k++){var U=G[k];if(Math.abs(F.dimensions[k]||0)>1e-12)if(Me(re.si,U))Y.push({unit:re.si[U].unit,prefix:re.si[U].prefix,power:F.dimensions[k]||0});else throw new Error("Cannot express custom unit "+U+" in SI units")}return F.units=Y,F.fixPrefix=!0,F.skipAutomaticSimplification=!0,F},g.prototype.formatUnits=function(){for(var F="",Y="",k=0,U=0,J=0;J<this.units.length;J++)this.units[J].power>0?(k++,F+=" "+this.units[J].prefix.name+this.units[J].unit.name,Math.abs(this.units[J].power-1)>1e-15&&(F+="^"+this.units[J].power)):this.units[J].power<0&&U++;if(U>0)for(var q=0;q<this.units.length;q++)this.units[q].power<0&&(k>0?(Y+=" "+this.units[q].prefix.name+this.units[q].unit.name,Math.abs(this.units[q].power+1)>1e-15&&(Y+="^"+-this.units[q].power)):(Y+=" "+this.units[q].prefix.name+this.units[q].unit.name,Y+="^"+this.units[q].power));F=F.substr(1),Y=Y.substr(1),k>1&&U>0&&(F="("+F+")"),U>1&&k>0&&(Y="("+Y+")");var P=F;return k>0&&U>0&&(P+=" / "),P+=Y,P},g.prototype.format=function(F){var Y=this.skipAutomaticSimplification||this.value===null?this.clone():this.simplify(),k=!1;typeof Y.value!="undefined"&&Y.value!==null&&Or(Y.value)&&(k=Math.abs(Y.value.re)<1e-14);for(var U in Y.units)Me(Y.units,U)&&Y.units[U].unit&&(Y.units[U].unit.name==="VA"&&k?Y.units[U].unit=V.VAR:Y.units[U].unit.name==="VAR"&&!k&&(Y.units[U].unit=V.VA));Y.units.length===1&&!Y.fixPrefix&&Math.abs(Y.units[0].power-Math.round(Y.units[0].power))<1e-14&&(Y.units[0].prefix=Y._bestPrefix());var J=Y._denormalize(Y.value),q=Y.value!==null?p(J,F||{}):"",P=Y.formatUnits();return Y.value&&Or(Y.value)&&(q="("+q+")"),P.length>0&&q.length>0&&(q+=" "),q+=P,q},g.prototype._bestPrefix=function(){if(this.units.length!==1)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var F=this.value!==null?f(this.value):0,Y=f(this.units[0].unit.value),k=this.units[0].prefix;if(F===0)return k;var U=this.units[0].power,J=Math.log(F/Math.pow(k.value*Y,U))/Math.LN10-1.2;if(J>-2.200001&&J<1.800001)return k;J=Math.abs(J);var q=this.units[0].unit.prefixes;for(var P in q)if(Me(q,P)){var Q=q[P];if(Q.scientific){var L=Math.abs(Math.log(F/Math.pow(Q.value*Y,U))/Math.LN10-1.2);(L<J||L===J&&Q.name.length<k.name.length)&&(k=Q,J=L)}}return k},g.prototype.splitUnit=function(F){for(var Y=this.clone(),k=[],U=0;U<F.length&&(Y=Y.to(F[U]),U!==F.length-1);U++){var J=Y.toNumeric(),q=s(J),P=void 0,Q=o(q,J);Q?P=q:P=c(Y.toNumeric());var L=new g(P,F[U].toString());k.push(L),Y=r(Y,L)}for(var se=0,fe=0;fe<k.length;fe++)se=t(se,k[fe].value);return o(se,this.value)&&(Y.value=0),k.push(Y),k};var B={NONE:{"":{name:"",value:1,scientific:!0}},SHORT:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:10,scientific:!1},h:{name:"h",value:100,scientific:!1},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0},d:{name:"d",value:.1,scientific:!1},c:{name:"c",value:.01,scientific:!1},m:{name:"m",value:.001,scientific:!0},u:{name:"u",value:1e-6,scientific:!0},n:{name:"n",value:1e-9,scientific:!0},p:{name:"p",value:1e-12,scientific:!0},f:{name:"f",value:1e-15,scientific:!0},a:{name:"a",value:1e-18,scientific:!0},z:{name:"z",value:1e-21,scientific:!0},y:{name:"y",value:1e-24,scientific:!0}},LONG:{"":{name:"",value:1,scientific:!0},deca:{name:"deca",value:10,scientific:!1},hecto:{name:"hecto",value:100,scientific:!1},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0},deci:{name:"deci",value:.1,scientific:!1},centi:{name:"centi",value:.01,scientific:!1},milli:{name:"milli",value:.001,scientific:!0},micro:{name:"micro",value:1e-6,scientific:!0},nano:{name:"nano",value:1e-9,scientific:!0},pico:{name:"pico",value:1e-12,scientific:!0},femto:{name:"femto",value:1e-15,scientific:!0},atto:{name:"atto",value:1e-18,scientific:!0},zepto:{name:"zepto",value:1e-21,scientific:!0},yocto:{name:"yocto",value:1e-24,scientific:!0}},SQUARED:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:100,scientific:!1},h:{name:"h",value:1e4,scientific:!1},k:{name:"k",value:1e6,scientific:!0},M:{name:"M",value:1e12,scientific:!0},G:{name:"G",value:1e18,scientific:!0},T:{name:"T",value:1e24,scientific:!0},P:{name:"P",value:1e30,scientific:!0},E:{name:"E",value:1e36,scientific:!0},Z:{name:"Z",value:1e42,scientific:!0},Y:{name:"Y",value:1e48,scientific:!0},d:{name:"d",value:.01,scientific:!1},c:{name:"c",value:1e-4,scientific:!1},m:{name:"m",value:1e-6,scientific:!0},u:{name:"u",value:1e-12,scientific:!0},n:{name:"n",value:1e-18,scientific:!0},p:{name:"p",value:1e-24,scientific:!0},f:{name:"f",value:1e-30,scientific:!0},a:{name:"a",value:1e-36,scientific:!0},z:{name:"z",value:1e-42,scientific:!0},y:{name:"y",value:1e-48,scientific:!0}},CUBIC:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:1e3,scientific:!1},h:{name:"h",value:1e6,scientific:!1},k:{name:"k",value:1e9,scientific:!0},M:{name:"M",value:1e18,scientific:!0},G:{name:"G",value:1e27,scientific:!0},T:{name:"T",value:1e36,scientific:!0},P:{name:"P",value:1e45,scientific:!0},E:{name:"E",value:1e54,scientific:!0},Z:{name:"Z",value:1e63,scientific:!0},Y:{name:"Y",value:1e72,scientific:!0},d:{name:"d",value:.001,scientific:!1},c:{name:"c",value:1e-6,scientific:!1},m:{name:"m",value:1e-9,scientific:!0},u:{name:"u",value:1e-18,scientific:!0},n:{name:"n",value:1e-27,scientific:!0},p:{name:"p",value:1e-36,scientific:!0},f:{name:"f",value:1e-45,scientific:!0},a:{name:"a",value:1e-54,scientific:!0},z:{name:"z",value:1e-63,scientific:!0},y:{name:"y",value:1e-72,scientific:!0}},BINARY_SHORT_SI:{"":{name:"",value:1,scientific:!0},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0}},BINARY_SHORT_IEC:{"":{name:"",value:1,scientific:!0},Ki:{name:"Ki",value:1024,scientific:!0},Mi:{name:"Mi",value:Math.pow(1024,2),scientific:!0},Gi:{name:"Gi",value:Math.pow(1024,3),scientific:!0},Ti:{name:"Ti",value:Math.pow(1024,4),scientific:!0},Pi:{name:"Pi",value:Math.pow(1024,5),scientific:!0},Ei:{name:"Ei",value:Math.pow(1024,6),scientific:!0},Zi:{name:"Zi",value:Math.pow(1024,7),scientific:!0},Yi:{name:"Yi",value:Math.pow(1024,8),scientific:!0}},BINARY_LONG_SI:{"":{name:"",value:1,scientific:!0},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0}},BINARY_LONG_IEC:{"":{name:"",value:1,scientific:!0},kibi:{name:"kibi",value:1024,scientific:!0},mebi:{name:"mebi",value:Math.pow(1024,2),scientific:!0},gibi:{name:"gibi",value:Math.pow(1024,3),scientific:!0},tebi:{name:"tebi",value:Math.pow(1024,4),scientific:!0},pebi:{name:"pebi",value:Math.pow(1024,5),scientific:!0},exi:{name:"exi",value:Math.pow(1024,6),scientific:!0},zebi:{name:"zebi",value:Math.pow(1024,7),scientific:!0},yobi:{name:"yobi",value:Math.pow(1024,8),scientific:!0}},BTU:{"":{name:"",value:1,scientific:!0},MM:{name:"MM",value:1e6,scientific:!0}}};B.SHORTLONG=ar({},B.SHORT,B.LONG),B.BINARY_SHORT=ar({},B.BINARY_SHORT_SI,B.BINARY_SHORT_IEC),B.BINARY_LONG=ar({},B.BINARY_LONG_SI,B.BINARY_LONG_IEC);var G=["MASS","LENGTH","TIME","CURRENT","TEMPERATURE","LUMINOUS_INTENSITY","AMOUNT_OF_SUBSTANCE","ANGLE","BIT"],D={NONE:{dimensions:[0,0,0,0,0,0,0,0,0]},MASS:{dimensions:[1,0,0,0,0,0,0,0,0]},LENGTH:{dimensions:[0,1,0,0,0,0,0,0,0]},TIME:{dimensions:[0,0,1,0,0,0,0,0,0]},CURRENT:{dimensions:[0,0,0,1,0,0,0,0,0]},TEMPERATURE:{dimensions:[0,0,0,0,1,0,0,0,0]},LUMINOUS_INTENSITY:{dimensions:[0,0,0,0,0,1,0,0,0]},AMOUNT_OF_SUBSTANCE:{dimensions:[0,0,0,0,0,0,1,0,0]},FORCE:{dimensions:[1,1,-2,0,0,0,0,0,0]},SURFACE:{dimensions:[0,2,0,0,0,0,0,0,0]},VOLUME:{dimensions:[0,3,0,0,0,0,0,0,0]},ENERGY:{dimensions:[1,2,-2,0,0,0,0,0,0]},POWER:{dimensions:[1,2,-3,0,0,0,0,0,0]},PRESSURE:{dimensions:[1,-1,-2,0,0,0,0,0,0]},ELECTRIC_CHARGE:{dimensions:[0,0,1,1,0,0,0,0,0]},ELECTRIC_CAPACITANCE:{dimensions:[-1,-2,4,2,0,0,0,0,0]},ELECTRIC_POTENTIAL:{dimensions:[1,2,-3,-1,0,0,0,0,0]},ELECTRIC_RESISTANCE:{dimensions:[1,2,-3,-2,0,0,0,0,0]},ELECTRIC_INDUCTANCE:{dimensions:[1,2,-2,-2,0,0,0,0,0]},ELECTRIC_CONDUCTANCE:{dimensions:[-1,-2,3,2,0,0,0,0,0]},MAGNETIC_FLUX:{dimensions:[1,2,-2,-1,0,0,0,0,0]},MAGNETIC_FLUX_DENSITY:{dimensions:[1,0,-2,-1,0,0,0,0,0]},FREQUENCY:{dimensions:[0,0,-1,0,0,0,0,0,0]},ANGLE:{dimensions:[0,0,0,0,0,0,0,1,0]},BIT:{dimensions:[0,0,0,0,0,0,0,0,1]}};for(var H in D)Me(D,H)&&(D[H].key=H);var W={},j={name:"",base:W,value:1,offset:0,dimensions:G.map(F=>0)},V={meter:{name:"meter",base:D.LENGTH,prefixes:B.LONG,value:1,offset:0},inch:{name:"inch",base:D.LENGTH,prefixes:B.NONE,value:.0254,offset:0},foot:{name:"foot",base:D.LENGTH,prefixes:B.NONE,value:.3048,offset:0},yard:{name:"yard",base:D.LENGTH,prefixes:B.NONE,value:.9144,offset:0},mile:{name:"mile",base:D.LENGTH,prefixes:B.NONE,value:1609.344,offset:0},link:{name:"link",base:D.LENGTH,prefixes:B.NONE,value:.201168,offset:0},rod:{name:"rod",base:D.LENGTH,prefixes:B.NONE,value:5.0292,offset:0},chain:{name:"chain",base:D.LENGTH,prefixes:B.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:D.LENGTH,prefixes:B.NONE,value:1e-10,offset:0},m:{name:"m",base:D.LENGTH,prefixes:B.SHORT,value:1,offset:0},in:{name:"in",base:D.LENGTH,prefixes:B.NONE,value:.0254,offset:0},ft:{name:"ft",base:D.LENGTH,prefixes:B.NONE,value:.3048,offset:0},yd:{name:"yd",base:D.LENGTH,prefixes:B.NONE,value:.9144,offset:0},mi:{name:"mi",base:D.LENGTH,prefixes:B.NONE,value:1609.344,offset:0},li:{name:"li",base:D.LENGTH,prefixes:B.NONE,value:.201168,offset:0},rd:{name:"rd",base:D.LENGTH,prefixes:B.NONE,value:5.02921,offset:0},ch:{name:"ch",base:D.LENGTH,prefixes:B.NONE,value:20.1168,offset:0},mil:{name:"mil",base:D.LENGTH,prefixes:B.NONE,value:254e-7,offset:0},m2:{name:"m2",base:D.SURFACE,prefixes:B.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:D.SURFACE,prefixes:B.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:D.SURFACE,prefixes:B.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:D.SURFACE,prefixes:B.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:D.SURFACE,prefixes:B.NONE,value:2589988110336e-6,offset:0},sqrd:{name:"sqrd",base:D.SURFACE,prefixes:B.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:D.SURFACE,prefixes:B.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:D.SURFACE,prefixes:B.NONE,value:64516e-14,offset:0},acre:{name:"acre",base:D.SURFACE,prefixes:B.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:D.SURFACE,prefixes:B.NONE,value:1e4,offset:0},m3:{name:"m3",base:D.VOLUME,prefixes:B.CUBIC,value:1,offset:0},L:{name:"L",base:D.VOLUME,prefixes:B.SHORT,value:.001,offset:0},l:{name:"l",base:D.VOLUME,prefixes:B.SHORT,value:.001,offset:0},litre:{name:"litre",base:D.VOLUME,prefixes:B.LONG,value:.001,offset:0},cuin:{name:"cuin",base:D.VOLUME,prefixes:B.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:D.VOLUME,prefixes:B.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:D.VOLUME,prefixes:B.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:D.VOLUME,prefixes:B.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:D.VOLUME,prefixes:B.NONE,value:15e-6,offset:0},drop:{name:"drop",base:D.VOLUME,prefixes:B.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:D.VOLUME,prefixes:B.NONE,value:5e-8,offset:0},minim:{name:"minim",base:D.VOLUME,prefixes:B.NONE,value:6161152e-14,offset:0},fluiddram:{name:"fluiddram",base:D.VOLUME,prefixes:B.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:D.VOLUME,prefixes:B.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:D.VOLUME,prefixes:B.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:D.VOLUME,prefixes:B.NONE,value:1e-6,offset:0},cup:{name:"cup",base:D.VOLUME,prefixes:B.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:D.VOLUME,prefixes:B.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:D.VOLUME,prefixes:B.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:D.VOLUME,prefixes:B.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:D.VOLUME,prefixes:B.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:D.VOLUME,prefixes:B.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:D.VOLUME,prefixes:B.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:D.VOLUME,prefixes:B.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:D.VOLUME,prefixes:B.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:D.VOLUME,prefixes:B.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:D.VOLUME,prefixes:B.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:D.VOLUME,prefixes:B.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:D.VOLUME,prefixes:B.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:D.VOLUME,prefixes:B.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:D.VOLUME,prefixes:B.NONE,value:.1173478,offset:0},obl:{name:"obl",base:D.VOLUME,prefixes:B.NONE,value:.1589873,offset:0},g:{name:"g",base:D.MASS,prefixes:B.SHORT,value:.001,offset:0},gram:{name:"gram",base:D.MASS,prefixes:B.LONG,value:.001,offset:0},ton:{name:"ton",base:D.MASS,prefixes:B.SHORT,value:907.18474,offset:0},t:{name:"t",base:D.MASS,prefixes:B.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:D.MASS,prefixes:B.LONG,value:1e3,offset:0},grain:{name:"grain",base:D.MASS,prefixes:B.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:D.MASS,prefixes:B.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:D.MASS,prefixes:B.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:D.MASS,prefixes:B.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:D.MASS,prefixes:B.NONE,value:45.359237,offset:0},stick:{name:"stick",base:D.MASS,prefixes:B.NONE,value:.115,offset:0},stone:{name:"stone",base:D.MASS,prefixes:B.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:D.MASS,prefixes:B.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:D.MASS,prefixes:B.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:D.MASS,prefixes:B.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:D.MASS,prefixes:B.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:D.MASS,prefixes:B.NONE,value:45.359237,offset:0},s:{name:"s",base:D.TIME,prefixes:B.SHORT,value:1,offset:0},min:{name:"min",base:D.TIME,prefixes:B.NONE,value:60,offset:0},h:{name:"h",base:D.TIME,prefixes:B.NONE,value:3600,offset:0},second:{name:"second",base:D.TIME,prefixes:B.LONG,value:1,offset:0},sec:{name:"sec",base:D.TIME,prefixes:B.LONG,value:1,offset:0},minute:{name:"minute",base:D.TIME,prefixes:B.NONE,value:60,offset:0},hour:{name:"hour",base:D.TIME,prefixes:B.NONE,value:3600,offset:0},day:{name:"day",base:D.TIME,prefixes:B.NONE,value:86400,offset:0},week:{name:"week",base:D.TIME,prefixes:B.NONE,value:7*86400,offset:0},month:{name:"month",base:D.TIME,prefixes:B.NONE,value:2629800,offset:0},year:{name:"year",base:D.TIME,prefixes:B.NONE,value:31557600,offset:0},decade:{name:"decade",base:D.TIME,prefixes:B.NONE,value:315576e3,offset:0},century:{name:"century",base:D.TIME,prefixes:B.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:D.TIME,prefixes:B.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:D.FREQUENCY,prefixes:B.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:D.FREQUENCY,prefixes:B.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:D.ANGLE,prefixes:B.SHORT,value:1,offset:0},radian:{name:"radian",base:D.ANGLE,prefixes:B.LONG,value:1,offset:0},deg:{name:"deg",base:D.ANGLE,prefixes:B.SHORT,value:null,offset:0},degree:{name:"degree",base:D.ANGLE,prefixes:B.LONG,value:null,offset:0},grad:{name:"grad",base:D.ANGLE,prefixes:B.SHORT,value:null,offset:0},gradian:{name:"gradian",base:D.ANGLE,prefixes:B.LONG,value:null,offset:0},cycle:{name:"cycle",base:D.ANGLE,prefixes:B.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:D.ANGLE,prefixes:B.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:D.ANGLE,prefixes:B.NONE,value:null,offset:0},A:{name:"A",base:D.CURRENT,prefixes:B.SHORT,value:1,offset:0},ampere:{name:"ampere",base:D.CURRENT,prefixes:B.LONG,value:1,offset:0},K:{name:"K",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:0},degC:{name:"degC",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:273.15},degF:{name:"degF",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:0},celsius:{name:"celsius",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:D.AMOUNT_OF_SUBSTANCE,prefixes:B.SHORT,value:1,offset:0},mole:{name:"mole",base:D.AMOUNT_OF_SUBSTANCE,prefixes:B.LONG,value:1,offset:0},cd:{name:"cd",base:D.LUMINOUS_INTENSITY,prefixes:B.SHORT,value:1,offset:0},candela:{name:"candela",base:D.LUMINOUS_INTENSITY,prefixes:B.LONG,value:1,offset:0},N:{name:"N",base:D.FORCE,prefixes:B.SHORT,value:1,offset:0},newton:{name:"newton",base:D.FORCE,prefixes:B.LONG,value:1,offset:0},dyn:{name:"dyn",base:D.FORCE,prefixes:B.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:D.FORCE,prefixes:B.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:D.FORCE,prefixes:B.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:D.FORCE,prefixes:B.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:D.FORCE,prefixes:B.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:D.FORCE,prefixes:B.NONE,value:9.80665,offset:0},J:{name:"J",base:D.ENERGY,prefixes:B.SHORT,value:1,offset:0},joule:{name:"joule",base:D.ENERGY,prefixes:B.SHORT,value:1,offset:0},erg:{name:"erg",base:D.ENERGY,prefixes:B.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:D.ENERGY,prefixes:B.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:D.ENERGY,prefixes:B.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:D.ENERGY,prefixes:B.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:D.ENERGY,prefixes:B.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:D.POWER,prefixes:B.SHORT,value:1,offset:0},watt:{name:"watt",base:D.POWER,prefixes:B.LONG,value:1,offset:0},hp:{name:"hp",base:D.POWER,prefixes:B.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:D.POWER,prefixes:B.SHORT,value:h.I,offset:0},VA:{name:"VA",base:D.POWER,prefixes:B.SHORT,value:1,offset:0},Pa:{name:"Pa",base:D.PRESSURE,prefixes:B.SHORT,value:1,offset:0},psi:{name:"psi",base:D.PRESSURE,prefixes:B.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:D.PRESSURE,prefixes:B.NONE,value:101325,offset:0},bar:{name:"bar",base:D.PRESSURE,prefixes:B.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:D.PRESSURE,prefixes:B.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:D.PRESSURE,prefixes:B.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:D.PRESSURE,prefixes:B.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:D.PRESSURE,prefixes:B.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:D.ELECTRIC_CHARGE,prefixes:B.LONG,value:1,offset:0},C:{name:"C",base:D.ELECTRIC_CHARGE,prefixes:B.SHORT,value:1,offset:0},farad:{name:"farad",base:D.ELECTRIC_CAPACITANCE,prefixes:B.LONG,value:1,offset:0},F:{name:"F",base:D.ELECTRIC_CAPACITANCE,prefixes:B.SHORT,value:1,offset:0},volt:{name:"volt",base:D.ELECTRIC_POTENTIAL,prefixes:B.LONG,value:1,offset:0},V:{name:"V",base:D.ELECTRIC_POTENTIAL,prefixes:B.SHORT,value:1,offset:0},ohm:{name:"ohm",base:D.ELECTRIC_RESISTANCE,prefixes:B.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:D.ELECTRIC_INDUCTANCE,prefixes:B.LONG,value:1,offset:0},H:{name:"H",base:D.ELECTRIC_INDUCTANCE,prefixes:B.SHORT,value:1,offset:0},siemens:{name:"siemens",base:D.ELECTRIC_CONDUCTANCE,prefixes:B.LONG,value:1,offset:0},S:{name:"S",base:D.ELECTRIC_CONDUCTANCE,prefixes:B.SHORT,value:1,offset:0},weber:{name:"weber",base:D.MAGNETIC_FLUX,prefixes:B.LONG,value:1,offset:0},Wb:{name:"Wb",base:D.MAGNETIC_FLUX,prefixes:B.SHORT,value:1,offset:0},tesla:{name:"tesla",base:D.MAGNETIC_FLUX_DENSITY,prefixes:B.LONG,value:1,offset:0},T:{name:"T",base:D.MAGNETIC_FLUX_DENSITY,prefixes:B.SHORT,value:1,offset:0},b:{name:"b",base:D.BIT,prefixes:B.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:D.BIT,prefixes:B.BINARY_LONG,value:1,offset:0},B:{name:"B",base:D.BIT,prefixes:B.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:D.BIT,prefixes:B.BINARY_LONG,value:8,offset:0}},K={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 te(F){if(F.number==="BigNumber"){var Y=Oi(b);V.rad.value=new b(1),V.deg.value=Y.div(180),V.grad.value=Y.div(200),V.cycle.value=Y.times(2),V.arcsec.value=Y.div(648e3),V.arcmin.value=Y.div(10800)}else V.rad.value=1,V.deg.value=Math.PI/180,V.grad.value=Math.PI/200,V.cycle.value=Math.PI*2,V.arcsec.value=Math.PI/648e3,V.arcmin.value=Math.PI/10800;V.radian.value=V.rad.value,V.degree.value=V.deg.value,V.gradian.value=V.grad.value}te(a),n&&n("config",function(F,Y){F.number!==Y.number&&te(F)});var re={si:{NONE:{unit:j,prefix:B.NONE[""]},LENGTH:{unit:V.m,prefix:B.SHORT[""]},MASS:{unit:V.g,prefix:B.SHORT.k},TIME:{unit:V.s,prefix:B.SHORT[""]},CURRENT:{unit:V.A,prefix:B.SHORT[""]},TEMPERATURE:{unit:V.K,prefix:B.SHORT[""]},LUMINOUS_INTENSITY:{unit:V.cd,prefix:B.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:V.mol,prefix:B.SHORT[""]},ANGLE:{unit:V.rad,prefix:B.SHORT[""]},BIT:{unit:V.bits,prefix:B.SHORT[""]},FORCE:{unit:V.N,prefix:B.SHORT[""]},ENERGY:{unit:V.J,prefix:B.SHORT[""]},POWER:{unit:V.W,prefix:B.SHORT[""]},PRESSURE:{unit:V.Pa,prefix:B.SHORT[""]},ELECTRIC_CHARGE:{unit:V.C,prefix:B.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:V.F,prefix:B.SHORT[""]},ELECTRIC_POTENTIAL:{unit:V.V,prefix:B.SHORT[""]},ELECTRIC_RESISTANCE:{unit:V.ohm,prefix:B.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:V.H,prefix:B.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:V.S,prefix:B.SHORT[""]},MAGNETIC_FLUX:{unit:V.Wb,prefix:B.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:V.T,prefix:B.SHORT[""]},FREQUENCY:{unit:V.Hz,prefix:B.SHORT[""]}}};re.cgs=JSON.parse(JSON.stringify(re.si)),re.cgs.LENGTH={unit:V.m,prefix:B.SHORT.c},re.cgs.MASS={unit:V.g,prefix:B.SHORT[""]},re.cgs.FORCE={unit:V.dyn,prefix:B.SHORT[""]},re.cgs.ENERGY={unit:V.erg,prefix:B.NONE[""]},re.us=JSON.parse(JSON.stringify(re.si)),re.us.LENGTH={unit:V.ft,prefix:B.NONE[""]},re.us.MASS={unit:V.lbm,prefix:B.NONE[""]},re.us.TEMPERATURE={unit:V.degF,prefix:B.NONE[""]},re.us.FORCE={unit:V.lbf,prefix:B.NONE[""]},re.us.ENERGY={unit:V.BTU,prefix:B.BTU[""]},re.us.POWER={unit:V.hp,prefix:B.NONE[""]},re.us.PRESSURE={unit:V.psi,prefix:B.NONE[""]},re.auto=JSON.parse(JSON.stringify(re.si));var ie=re.auto;g.setUnitSystem=function(F){if(Me(re,F))ie=re[F];else throw new Error("Unit system "+F+" does not exist. Choices are: "+Object.keys(re).join(", "))},g.getUnitSystem=function(){for(var F in re)if(Me(re,F)&&re[F]===ie)return F},g.typeConverters={BigNumber:function(Y){return new b(Y+"")},Fraction:function(Y){return new w(Y)},Complex:function(Y){return Y},number:function(Y){return Y}},g._getNumberConverter=function(F){if(!g.typeConverters[F])throw new TypeError('Unsupported type "'+F+'"');return g.typeConverters[F]};for(var ne in V)if(Me(V,ne)){var ue=V[ne];ue.dimensions=ue.base.dimensions}for(var ee in K)if(Me(K,ee)){var ye=V[K[ee]],we={};for(var me in ye)Me(ye,me)&&(we[me]=ye[me]);we.name=ee,V[ee]=we}g.isValidAlpha=function(Y){return/^[a-zA-Z]$/.test(Y)};function xe(F){for(var Y=0;Y<F.length;Y++){if(d=F.charAt(Y),Y===0&&!g.isValidAlpha(d))throw new Error('Invalid unit name (must begin with alpha character): "'+F+'"');if(Y>0&&!(g.isValidAlpha(d)||O(d)))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+F+'"')}}return g.createUnit=function(F,Y){if(typeof F!="object")throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(Y&&Y.override){for(var k in F)if(Me(F,k)&&g.deleteUnit(k),F[k].aliases)for(var U=0;U<F[k].aliases.length;U++)g.deleteUnit(F[k].aliases[U])}var J;for(var q in F)Me(F,q)&&(J=g.createUnitSingle(q,F[q]));return J},g.createUnitSingle=function(F,Y,k){if((typeof Y=="undefined"||Y===null)&&(Y={}),typeof F!="string")throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");if(Me(V,F))throw new Error('Cannot create unit "'+F+'": a unit with that name already exists');xe(F);var U=null,J=[],q=0,P,Q,L;if(Y&&Y.type==="Unit")U=Y.clone();else if(typeof Y=="string")Y!==""&&(P=Y);else if(typeof Y=="object")P=Y.definition,Q=Y.prefixes,q=Y.offset,L=Y.baseName,Y.aliases&&(J=Y.aliases.valueOf());else throw new TypeError('Cannot create unit "'+F+'" from "'+Y.toString()+'": expecting "string" or "Unit" or "Object"');if(J){for(var se=0;se<J.length;se++)if(Me(V,J[se]))throw new Error('Cannot create alias "'+J[se]+'": a unit with that name already exists')}if(P&&typeof P=="string"&&!U)try{U=g.parse(P,{allowNoUnits:!0})}catch(C){throw C.message='Could not create unit "'+F+'" from "'+P+'": '+C.message,C}else P&&P.type==="Unit"&&(U=P.clone());J=J||[],q=q||0,Q&&Q.toUpperCase?Q=B[Q.toUpperCase()]||B.NONE:Q=B.NONE;var fe={};if(U){fe={name:F,value:U.value,dimensions:U.dimensions.slice(0),prefixes:Q,offset:q};var Ne=!1;for(var Qe in D)if(Me(D,Qe)){for(var cr=!0,tr=0;tr<G.length;tr++)if(Math.abs((fe.dimensions[tr]||0)-(D[Qe].dimensions[tr]||0))>1e-12){cr=!1;break}if(cr){Ne=!0,fe.base=D[Qe];break}}if(!Ne){L=L||F+"_STUFF";var Jr={dimensions:U.dimensions.slice(0)};Jr.key=L,D[L]=Jr,ie[L]={unit:fe,prefix:B.NONE[""]},fe.base=D[L]}}else{if(L=L||F+"_STUFF",G.indexOf(L)>=0)throw new Error('Cannot create new base unit "'+F+'": a base unit with that name already exists (and cannot be overridden)');G.push(L);for(var ge in D)Me(D,ge)&&(D[ge].dimensions[G.length-1]=0);for(var pe={dimensions:[]},ve=0;ve<G.length;ve++)pe.dimensions[ve]=0;pe.dimensions[G.length-1]=1,pe.key=L,D[L]=pe,fe={name:F,value:1,dimensions:D[L].dimensions.slice(0),prefixes:Q,offset:q,base:D[L]},ie[L]={unit:fe,prefix:B.NONE[""]}}g.UNITS[F]=fe;for(var Lr=0;Lr<J.length;Lr++){var Ot=J[Lr],Ze={};for(var Pt in fe)Me(fe,Pt)&&(Ze[Pt]=fe[Pt]);Ze.name=Ot,g.UNITS[Ot]=Ze}return delete I.cache,new g(null,F)},g.deleteUnit=function(F){delete g.UNITS[F]},g.PREFIXES=B,g.BASE_DIMENSIONS=G,g.BASE_UNITS=D,g.UNIT_SYSTEMS=re,g.UNITS=V,g},{isClass:!0}),mf="unit",fb=["typed","Unit"],lb=R(mf,fb,e=>{var{typed:n,Unit:a}=e;return n(mf,{Unit:function(r){return r.clone()},string:function(r){return a.isValuelessUnit(r)?new a(null,r):a.parse(r,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string":function(r,i){return new a(r,i)},"Array | Matrix":function(r){return be(r,this)}})}),pf="sparse",mb=["typed","SparseMatrix"],pb=R(pf,mb,e=>{var{typed:n,SparseMatrix:a}=e;return n(pf,{"":function(){return new a([])},string:function(r){return new a([],r)},"Array | Matrix":function(r){return new a(r)},"Array | Matrix, string":function(r,i){return new a(r,i)}})}),vf="createUnit",vb=["typed","Unit"],hb=R(vf,vb,e=>{var{typed:n,Unit:a}=e;return n(vf,{"Object, Object":function(r,i){return a.createUnit(r,i)},Object:function(r){return a.createUnit(r,{})},"string, Unit | string | Object, Object":function(r,i,l){var m={};return m[r]=i,a.createUnit(m,l)},"string, Unit | string | Object":function(r,i){var l={};return l[r]=i,a.createUnit(l,{})},string:function(r){var i={};return i[r]={},a.createUnit(i,{})}})}),hf="acos",db=["typed","config","Complex"],gb=R(hf,db,e=>{var{typed:n,config:a,Complex:t}=e;return n(hf,{number:function(i){return i>=-1&&i<=1||a.predictable?Math.acos(i):new t(i,0).acos()},Complex:function(i){return i.acos()},BigNumber:function(i){return i.acos()},"Array | Matrix":function(i){return be(i,this)}})}),df="acosh",yb=["typed","config","Complex"],xb=R(df,yb,e=>{var{typed:n,config:a,Complex:t}=e;return n(df,{number:function(i){return i>=1||a.predictable?Ss(i):i<=-1?new t(Math.log(Math.sqrt(i*i-1)-i),Math.PI):new t(i,0).acosh()},Complex:function(i){return i.acosh()},BigNumber:function(i){return i.acosh()},"Array | Matrix":function(i){return be(i,this)}})}),gf="acot",bb=["typed","BigNumber"],wb=R(gf,bb,e=>{var{typed:n,BigNumber:a}=e;return n(gf,{number:Es,Complex:function(r){return r.acot()},BigNumber:function(r){return new a(1).div(r).atan()},"Array | Matrix":function(r){return be(r,this)}})}),yf="acoth",Nb=["typed","config","Complex","BigNumber"],Mb=R(yf,Nb,e=>{var{typed:n,config:a,Complex:t,BigNumber:r}=e;return n(yf,{number:function(l){return l>=1||l<=-1||a.predictable?Cs(l):new t(l,0).acoth()},Complex:function(l){return l.acoth()},BigNumber:function(l){return new r(1).div(l).atanh()},"Array | Matrix":function(l){return be(l,this)}})}),xf="acsc",Ab=["typed","config","Complex","BigNumber"],Sb=R(xf,Ab,e=>{var{typed:n,config:a,Complex:t,BigNumber:r}=e;return n(xf,{number:function(l){return l<=-1||l>=1||a.predictable?Os(l):new t(l,0).acsc()},Complex:function(l){return l.acsc()},BigNumber:function(l){return new r(1).div(l).asin()},"Array | Matrix":function(l){return be(l,this)}})}),bf="acsch",Eb=["typed","BigNumber"],Cb=R(bf,Eb,e=>{var{typed:n,BigNumber:a}=e;return n(bf,{number:Ds,Complex:function(r){return r.acsch()},BigNumber:function(r){return new a(1).div(r).asinh()},"Array | Matrix":function(r){return be(r,this)}})}),wf="asec",Ob=["typed","config","Complex","BigNumber"],Db=R(wf,Ob,e=>{var{typed:n,config:a,Complex:t,BigNumber:r}=e;return n(wf,{number:function(l){return l<=-1||l>=1||a.predictable?Ts(l):new t(l,0).asec()},Complex:function(l){return l.asec()},BigNumber:function(l){return new r(1).div(l).acos()},"Array | Matrix":function(l){return be(l,this)}})}),Nf="asech",Tb=["typed","config","Complex","BigNumber"],Bb=R(Nf,Tb,e=>{var{typed:n,config:a,Complex:t,BigNumber:r}=e;return n(Nf,{number:function(l){if(l<=1&&l>=-1||a.predictable){var m=1/l;if(m>0||a.predictable)return Bs(l);var f=Math.sqrt(m*m-1);return new t(Math.log(f-m),Math.PI)}return new t(l,0).asech()},Complex:function(l){return l.asech()},BigNumber:function(l){return new r(1).div(l).acosh()},"Array | Matrix":function(l){return be(l,this)}})}),Mf="asin",_b=["typed","config","Complex"],$b=R(Mf,_b,e=>{var{typed:n,config:a,Complex:t}=e;return n(Mf,{number:function(i){return i>=-1&&i<=1||a.predictable?Math.asin(i):new t(i,0).asin()},Complex:function(i){return i.asin()},BigNumber:function(i){return i.asin()},"Array | Matrix":function(i){return be(i,this)}})}),Ib="asinh",qb=["typed"],Rb=R(Ib,qb,e=>{var{typed:n}=e;return n("asinh",{number:_s,Complex:function(t){return t.asinh()},BigNumber:function(t){return t.asinh()},"Array | Matrix":function(t){return be(t,this)}})}),Fb="atan",zb=["typed"],Pb=R(Fb,zb,e=>{var{typed:n}=e;return n("atan",{number:function(t){return Math.atan(t)},Complex:function(t){return t.atan()},BigNumber:function(t){return t.atan()},"Array | Matrix":function(t){return be(t,this)}})}),Af="atan2",Ub=["typed","matrix","equalScalar","BigNumber","DenseMatrix"],Lb=R(Af,Ub,e=>{var{typed:n,matrix:a,equalScalar:t,BigNumber:r,DenseMatrix:i}=e,l=rt({typed:n,equalScalar:t}),m=Dr({typed:n}),f=Cu({typed:n,equalScalar:t}),c=wr({typed:n,equalScalar:t}),s=gr({typed:n,DenseMatrix:i}),o=je({typed:n}),u=Ge({typed:n});return n(Af,{"number, number":Math.atan2,"BigNumber, BigNumber":function(v,h){return r.atan2(v,h)},"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return l(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return m(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return c(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return u(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return s(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return u(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return u(a(v),h,this,!1).valueOf()},"number | BigNumber, Array":function(v,h){return u(a(h),v,this,!0).valueOf()}})}),Sf="atanh",kb=["typed","config","Complex"],Hb=R(Sf,kb,e=>{var{typed:n,config:a,Complex:t}=e;return n(Sf,{number:function(i){return i<=1&&i>=-1||a.predictable?$s(i):new t(i,0).atanh()},Complex:function(i){return i.atanh()},BigNumber:function(i){return i.atanh()},"Array | Matrix":function(i){return be(i,this)}})}),Ef="cos",Gb=["typed"],Vb=R(Ef,Gb,e=>{var{typed:n}=e;return n(Ef,{number:Math.cos,Complex:function(t){return t.cos()},BigNumber:function(t){return t.cos()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Cf="cosh",Zb=["typed"],Xb=R(Cf,Zb,e=>{var{typed:n}=e;return n(Cf,{number:ev,Complex:function(t){return t.cosh()},BigNumber:function(t){return t.cosh()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Of="cot",Yb=["typed","BigNumber"],Wb=R(Of,Yb,e=>{var{typed:n,BigNumber:a}=e;return n(Of,{number:Is,Complex:function(r){return r.cot()},BigNumber:function(r){return new a(1).div(r.tan())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),Df="coth",Jb=["typed","BigNumber"],Qb=R(Df,Jb,e=>{var{typed:n,BigNumber:a}=e;return n(Df,{number:qs,Complex:function(r){return r.coth()},BigNumber:function(r){return new a(1).div(r.tanh())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),Tf="csc",Kb=["typed","BigNumber"],jb=R(Tf,Kb,e=>{var{typed:n,BigNumber:a}=e;return n(Tf,{number:Rs,Complex:function(r){return r.csc()},BigNumber:function(r){return new a(1).div(r.sin())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),Bf="csch",ew=["typed","BigNumber"],rw=R(Bf,ew,e=>{var{typed:n,BigNumber:a}=e;return n(Bf,{number:Fs,Complex:function(r){return r.csch()},BigNumber:function(r){return new a(1).div(r.sinh())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),_f="sec",tw=["typed","BigNumber"],nw=R(_f,tw,e=>{var{typed:n,BigNumber:a}=e;return n(_f,{number:zs,Complex:function(r){return r.sec()},BigNumber:function(r){return new a(1).div(r.cos())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),$f="sech",aw=["typed","BigNumber"],iw=R($f,aw,e=>{var{typed:n,BigNumber:a}=e;return n($f,{number:Ps,Complex:function(r){return r.sech()},BigNumber:function(r){return new a(1).div(r.cosh())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),If="sin",ow=["typed"],sw=R(If,ow,e=>{var{typed:n}=e;return n(If,{number:Math.sin,Complex:function(t){return t.sin()},BigNumber:function(t){return t.sin()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),qf="sinh",uw=["typed"],cw=R(qf,uw,e=>{var{typed:n}=e;return n(qf,{number:Us,Complex:function(t){return t.sinh()},BigNumber:function(t){return t.sinh()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Rf="tan",fw=["typed"],lw=R(Rf,fw,e=>{var{typed:n}=e;return n(Rf,{number:Math.tan,Complex:function(t){return t.tan()},BigNumber:function(t){return t.tan()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),mw="tanh",pw=["typed"],vw=R(mw,pw,e=>{var{typed:n}=e;return n("tanh",{number:tv,Complex:function(t){return t.tanh()},BigNumber:function(t){return t.tanh()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Ff="setCartesian",hw=["typed","size","subset","compareNatural","Index","DenseMatrix"],dw=R(Ff,hw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i,DenseMatrix:l}=e;return n(Ff,{"Array | Matrix, Array | Matrix":function(f,c){var s=[];if(t(a(f),new i(0))!==0&&t(a(c),new i(0))!==0){var o=Le(Array.isArray(f)?f:f.toArray()).sort(r),u=Le(Array.isArray(c)?c:c.toArray()).sort(r);s=[];for(var p=0;p<o.length;p++)for(var v=0;v<u.length;v++)s.push([o[p],u[v]])}return Array.isArray(f)&&Array.isArray(c)?s:new l(s)}})}),zf="setDifference",gw=["typed","size","subset","compareNatural","Index","DenseMatrix"],yw=R(zf,gw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i,DenseMatrix:l}=e;return n(zf,{"Array | Matrix, Array | Matrix":function(f,c){var s;if(t(a(f),new i(0))===0)s=[];else{if(t(a(c),new i(0))===0)return Le(f.toArray());var o=sn(Le(Array.isArray(f)?f:f.toArray()).sort(r)),u=sn(Le(Array.isArray(c)?c:c.toArray()).sort(r));s=[];for(var p,v=0;v<o.length;v++){p=!1;for(var h=0;h<u.length;h++)if(r(o[v].value,u[h].value)===0&&o[v].identifier===u[h].identifier){p=!0;break}p||s.push(o[v])}}return Array.isArray(f)&&Array.isArray(c)?sa(s):new l(sa(s))}})}),Pf="setDistinct",xw=["typed","size","subset","compareNatural","Index","DenseMatrix"],bw=R(Pf,xw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i,DenseMatrix:l}=e;return n(Pf,{"Array | Matrix":function(f){var c;if(t(a(f),new i(0))===0)c=[];else{var s=Le(Array.isArray(f)?f:f.toArray()).sort(r);c=[],c.push(s[0]);for(var o=1;o<s.length;o++)r(s[o],s[o-1])!==0&&c.push(s[o])}return Array.isArray(f)?c:new l(c)}})}),Uf="setIntersect",ww=["typed","size","subset","compareNatural","Index","DenseMatrix"],Nw=R(Uf,ww,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i,DenseMatrix:l}=e;return n(Uf,{"Array | Matrix, Array | Matrix":function(f,c){var s;if(t(a(f),new i(0))===0||t(a(c),new i(0))===0)s=[];else{var o=sn(Le(Array.isArray(f)?f:f.toArray()).sort(r)),u=sn(Le(Array.isArray(c)?c:c.toArray()).sort(r));s=[];for(var p=0;p<o.length;p++)for(var v=0;v<u.length;v++)if(r(o[p].value,u[v].value)===0&&o[p].identifier===u[v].identifier){s.push(o[p]);break}}return Array.isArray(f)&&Array.isArray(c)?sa(s):new l(sa(s))}})}),Lf="setIsSubset",Mw=["typed","size","subset","compareNatural","Index"],Aw=R(Lf,Mw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i}=e;return n(Lf,{"Array | Matrix, Array | Matrix":function(m,f){if(t(a(m),new i(0))===0)return!0;if(t(a(f),new i(0))===0)return!1;for(var c=sn(Le(Array.isArray(m)?m:m.toArray()).sort(r)),s=sn(Le(Array.isArray(f)?f:f.toArray()).sort(r)),o,u=0;u<c.length;u++){o=!1;for(var p=0;p<s.length;p++)if(r(c[u].value,s[p].value)===0&&c[u].identifier===s[p].identifier){o=!0;break}if(o===!1)return!1}return!0}})}),kf="setMultiplicity",Sw=["typed","size","subset","compareNatural","Index"],Ew=R(kf,Sw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i}=e;return n(kf,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(m,f){if(t(a(f),new i(0))===0)return 0;for(var c=Le(Array.isArray(f)?f:f.toArray()),s=0,o=0;o<c.length;o++)r(c[o],m)===0&&s++;return s}})}),Hf="setPowerset",Cw=["typed","size","subset","compareNatural","Index"],Ow=R(Hf,Cw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i}=e;return n(Hf,{"Array | Matrix":function(c){if(t(a(c),new i(0))===0)return[];for(var s=Le(Array.isArray(c)?c:c.toArray()).sort(r),o=[],u=0;u.toString(2).length<=s.length;)o.push(l(s,u.toString(2).split("").reverse())),u++;return m(o)}});function l(f,c){for(var s=[],o=0;o<c.length;o++)c[o]==="1"&&s.push(f[o]);return s}function m(f){for(var c=[],s=f.length-1;s>0;s--)for(var o=0;o<s;o++)f[o].length>f[o+1].length&&(c=f[o],f[o]=f[o+1],f[o+1]=c);return f}}),Gf="setSize",Dw=["typed","compareNatural"],Tw=R(Gf,Dw,e=>{var{typed:n,compareNatural:a}=e;return n(Gf,{"Array | Matrix":function(r){return Array.isArray(r)?Le(r).length:Le(r.toArray()).length},"Array | Matrix, boolean":function(r,i){if(i===!1||r.length===0)return Array.isArray(r)?Le(r).length:Le(r.toArray()).length;for(var l=Le(Array.isArray(r)?r:r.toArray()).sort(a),m=1,f=1;f<l.length;f++)a(l[f],l[f-1])!==0&&m++;return m}})}),Vf="setSymDifference",Bw=["typed","size","concat","subset","setDifference","Index"],_w=R(Vf,Bw,e=>{var{typed:n,size:a,concat:t,subset:r,setDifference:i,Index:l}=e;return n(Vf,{"Array | Matrix, Array | Matrix":function(f,c){if(r(a(f),new l(0))===0)return Le(c);if(r(a(c),new l(0))===0)return Le(f);var s=Le(f),o=Le(c);return t(i(s,o),i(o,s))}})}),Zf="setUnion",$w=["typed","size","concat","subset","setIntersect","setSymDifference","Index"],Iw=R(Zf,$w,e=>{var{typed:n,size:a,concat:t,subset:r,setIntersect:i,setSymDifference:l,Index:m}=e;return n(Zf,{"Array | Matrix, Array | Matrix":function(c,s){if(r(a(c),new m(0))===0)return Le(s);if(r(a(s),new m(0))===0)return Le(c);var o=Le(c),u=Le(s);return t(l(o,u),i(o,u))}})}),Xf="add",qw=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],Rw=R(Xf,qw,e=>{var{typed:n,matrix:a,addScalar:t,equalScalar:r,DenseMatrix:i,SparseMatrix:l}=e,m=qt({typed:n}),f=Ni({typed:n,equalScalar:r}),c=Vt({typed:n,DenseMatrix:i}),s=je({typed:n}),o=Ge({typed:n});return n(Xf,Ka({"DenseMatrix, DenseMatrix":function(p,v){return s(p,v,t)},"DenseMatrix, SparseMatrix":function(p,v){return m(p,v,t,!1)},"SparseMatrix, DenseMatrix":function(p,v){return m(v,p,t,!0)},"SparseMatrix, SparseMatrix":function(p,v){return f(p,v,t)},"Array, Array":function(p,v){return this(a(p),a(v)).valueOf()},"Array, Matrix":function(p,v){return this(a(p),v)},"Matrix, Array":function(p,v){return this(p,a(v))},"DenseMatrix, any":function(p,v){return o(p,v,t,!1)},"SparseMatrix, any":function(p,v){return c(p,v,t,!1)},"any, DenseMatrix":function(p,v){return o(v,p,t,!0)},"any, SparseMatrix":function(p,v){return c(v,p,t,!0)},"Array, any":function(p,v){return o(a(p),v,t,!1).valueOf()},"any, Array":function(p,v){return o(a(v),p,t,!0).valueOf()},"any, any":t,"any, any, ...any":function(p,v,h){for(var b=this(p,v),w=0;w<h.length;w++)b=this(b,h[w]);return b}},t.signatures))}),Yf="hypot",Fw=["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],zw=R(Yf,Fw,e=>{var{typed:n,abs:a,addScalar:t,divideScalar:r,multiplyScalar:i,sqrt:l,smaller:m,isPositive:f}=e;return n(Yf,{"... number | BigNumber":c,Array:function(o){return this.apply(this,Le(o))},Matrix:function(o){return this.apply(this,Le(o.toArray()))}});function c(s){for(var o=0,u=0,p=0;p<s.length;p++){var v=a(s[p]);m(u,v)?(o=i(o,i(r(u,v),r(u,v))),o=t(o,1),u=v):o=t(o,f(v)?i(r(v,u),r(v,u)):v)}return i(u,l(o))}}),Wf="norm",Pw=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],Uw=R(Wf,Pw,e=>{var{typed:n,abs:a,add:t,pow:r,conj:i,sqrt:l,multiply:m,equalScalar:f,larger:c,smaller:s,matrix:o,ctranspose:u,eigs:p}=e;return n(Wf,{number:Math.abs,Complex:function(S){return S.abs()},BigNumber:function(S){return S.abs()},boolean:function(S){return Math.abs(S)},Array:function(S){return d(o(S),2)},Matrix:function(S){return d(S,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(S){return this(S)},"Array, number | BigNumber | string":function(S,O){return d(o(S),O)},"Matrix, number | BigNumber | string":function(S,O){return d(S,O)}});function v(A){var S=0;return A.forEach(function(O){var M=a(O);c(M,S)&&(S=M)},!0),S}function h(A){var S;return A.forEach(function(O){var M=a(O);(!S||s(M,S))&&(S=M)},!0),S||0}function b(A,S){if(S===Number.POSITIVE_INFINITY||S==="inf")return v(A);if(S===Number.NEGATIVE_INFINITY||S==="-inf")return h(A);if(S==="fro")return d(A,2);if(typeof S=="number"&&!isNaN(S)){if(!f(S,0)){var O=0;return A.forEach(function(M){O=t(r(a(M),S),O)},!0),r(O,1/S)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}function w(A){var S=0;return A.forEach(function(O,M){S=t(S,m(O,i(O)))}),a(l(S))}function N(A){var S=[],O=0;return A.forEach(function(M,_){var E=_[1],$=t(S[E]||0,a(M));c($,O)&&(O=$),S[E]=$},!0),O}function g(A){var S=A.size();if(S[0]!==S[1])throw new RangeError("Invalid matrix dimensions");var O=u(A),M=m(O,A),_=p(M).values.toArray(),E=_[_.length-1];return a(l(E))}function y(A){var S=[],O=0;return A.forEach(function(M,_){var E=_[0],$=t(S[E]||0,a(M));c($,O)&&(O=$),S[E]=$},!0),O}function x(A,S){if(S===1)return N(A);if(S===Number.POSITIVE_INFINITY||S==="inf")return y(A);if(S==="fro")return w(A);if(S===2)return g(A);throw new Error("Unsupported parameter value "+S)}function d(A,S){var O=A.size();if(O.length===1)return b(A,S);if(O.length===2){if(O[0]&&O[1])return x(A,S);throw new RangeError("Invalid matrix dimensions")}}}),Jf="dot",Lw=["typed","addScalar","multiplyScalar","conj","size"],kw=R(Jf,Lw,e=>{var{typed:n,addScalar:a,multiplyScalar:t,conj:r,size:i}=e;return n(Jf,{"Array | DenseMatrix, Array | DenseMatrix":m,"SparseMatrix, SparseMatrix":f});function l(s,o){var u=c(s),p=c(o),v,h;if(u.length===1)v=u[0];else if(u.length===2&&u[1]===1)v=u[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+u.join(", ")+")");if(p.length===1)h=p[0];else if(p.length===2&&p[1]===1)h=p[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+p.join(", ")+")");if(v!==h)throw new RangeError("Vectors must have equal length ("+v+" != "+h+")");if(v===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return v}function m(s,o){var u=l(s,o),p=Oe(s)?s._data:s,v=Oe(s)?s._datatype:void 0,h=Oe(o)?o._data:o,b=Oe(o)?o._datatype:void 0,w=c(s).length===2,N=c(o).length===2,g=a,y=t;if(v&&b&&v===b&&typeof v=="string"){var x=v;g=n.find(a,[x,x]),y=n.find(t,[x,x])}if(!w&&!N){for(var d=y(r(p[0]),h[0]),A=1;A<u;A++)d=g(d,y(r(p[A]),h[A]));return d}if(!w&&N){for(var S=y(r(p[0]),h[0][0]),O=1;O<u;O++)S=g(S,y(r(p[O]),h[O][0]));return S}if(w&&!N){for(var M=y(r(p[0][0]),h[0]),_=1;_<u;_++)M=g(M,y(r(p[_][0]),h[_]));return M}if(w&&N){for(var E=y(r(p[0][0]),h[0][0]),$=1;$<u;$++)E=g(E,y(r(p[$][0]),h[$][0]));return E}}function f(s,o){l(s,o);for(var u=s._index,p=s._values,v=o._index,h=o._values,b=0,w=a,N=t,g=0,y=0;g<u.length&&y<v.length;){var x=u[g],d=v[y];if(x<d){g++;continue}if(x>d){y++;continue}x===d&&(b=w(b,N(p[g],h[y])),g++,y++)}return b}function c(s){return Oe(s)?s.size():i(s)}}),Hw="trace",Gw=["typed","matrix","add"],Vw=R(Hw,Gw,e=>{var{typed:n,matrix:a,add:t}=e;return n("trace",{Array:function(m){return r(a(m))},SparseMatrix:i,DenseMatrix:r,any:Ce});function r(l){var m=l._size,f=l._data;switch(m.length){case 1:if(m[0]===1)return Ce(f[0]);throw new RangeError("Matrix must be square (size: "+Re(m)+")");case 2:{var c=m[0],s=m[1];if(c===s){for(var o=0,u=0;u<c;u++)o=t(o,f[u][u]);return o}else throw new RangeError("Matrix must be square (size: "+Re(m)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Re(m)+")")}}function i(l){var m=l._values,f=l._index,c=l._ptr,s=l._size,o=s[0],u=s[1];if(o===u){var p=0;if(m.length>0)for(var v=0;v<u;v++)for(var h=c[v],b=c[v+1],w=h;w<b;w++){var N=f[w];if(N===v){p=t(p,m[w]);break}if(N>v)break}return p}throw new RangeError("Matrix must be square (size: "+Re(s)+")")}}),Qf="index",Zw=["typed","Index"],Xw=R(Qf,Zw,e=>{var{typed:n,Index:a}=e;return n(Qf,{"...number | string | BigNumber | Range | Array | Matrix":function(r){var i=r.map(function(m){return _e(m)?m.toNumber():Array.isArray(m)||Oe(m)?m.map(function(f){return _e(f)?f.toNumber():f}):m}),l=new a;return a.apply(l,i),l}})}),Kf=new Set(["end"]),Yw="Node",Ww=["mathWithTransform"],Jw=R(Yw,Ww,e=>{var{mathWithTransform:n}=e;function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator")}a.prototype.evaluate=function(r){return this.compile().evaluate(r)},a.prototype.type="Node",a.prototype.isNode=!0,a.prototype.comment="",a.prototype.compile=function(){var r=this._compile(n,{}),i={},l=null;function m(f){var c=oi(f);return t(c),r(c,i,l)}return{evaluate:m}},a.prototype._compile=function(r,i){throw new Error("Method _compile should be implemented by type "+this.type)},a.prototype.forEach=function(r){throw new Error("Cannot run forEach on a Node interface")},a.prototype.map=function(r){throw new Error("Cannot run map on a Node interface")},a.prototype._ifNode=function(r){if(!Ve(r))throw new TypeError("Callback function must return a Node");return r},a.prototype.traverse=function(r){r(this,null,null);function i(l,m){l.forEach(function(f,c,s){m(f,c,s),i(f,m)})}i(this,r)},a.prototype.transform=function(r){function i(l,m,f){var c=r(l,m,f);return c!==l?c:l.map(i)}return i(this,null,null)},a.prototype.filter=function(r){var i=[];return this.traverse(function(l,m,f){r(l,m,f)&&i.push(l)}),i},a.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},a.prototype.cloneDeep=function(){return this.map(function(r){return r.cloneDeep()})},a.prototype.equals=function(r){return r?Dn(this,r):!1},a.prototype.toString=function(r){var i=this._getCustomString(r);return typeof i!="undefined"?i:this._toString(r)},a.prototype.toJSON=function(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)},a.prototype.toHTML=function(r){var i=this._getCustomString(r);return typeof i!="undefined"?i:this.toHTML(r)},a.prototype._toString=function(){throw new Error("_toString not implemented for "+this.type)},a.prototype.toTex=function(r){var i=this._getCustomString(r);return typeof i!="undefined"?i:this._toTex(r)},a.prototype._toTex=function(r){throw new Error("_toTex not implemented for "+this.type)},a.prototype._getCustomString=function(r){if(r&&typeof r=="object")switch(typeof r.handler){case"object":case"undefined":return;case"function":return r.handler(this,r);default:throw new TypeError("Object or function expected as callback")}},a.prototype.getIdentifier=function(){return this.type},a.prototype.getContent=function(){return this};function t(r){for(var i of[...Kf])if(r.has(i))throw new Error('Scope contains an illegal symbol, "'+i+'" is a reserved keyword')}return a},{isClass:!0,isNode:!0});function Br(e){return e&&e.isIndexError?new Kr(e.index+1,e.min+1,e.max!==void 0?e.max+1:void 0):e}function jf(e){var{subset:n}=e;return function(t,r){try{if(Array.isArray(t))return n(t,r);if(t&&typeof t.subset=="function")return t.subset(r);if(typeof t=="string")return n(t,r);if(typeof t=="object"){if(!r.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return Vr(t,r.getObjectProperty())}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(i){throw Br(i)}}}var Qw="AccessorNode",Kw=["subset","Node"],jw=R(Qw,Kw,e=>{var{subset:n,Node:a}=e,t=jf({subset:n});function r(l,m){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!Ve(l))throw new TypeError('Node expected for parameter "object"');if(!tn(m))throw new TypeError('IndexNode expected for parameter "index"');this.object=l||null,this.index=m,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")}})}r.prototype=new a,r.prototype.type="AccessorNode",r.prototype.isAccessorNode=!0,r.prototype._compile=function(l,m){var f=this.object._compile(l,m),c=this.index._compile(l,m);if(this.index.isObjectProperty()){var s=this.index.getObjectProperty();return function(u,p,v){return Vr(f(u,p,v),s)}}else return function(u,p,v){var h=f(u,p,v),b=c(u,p,h);return t(h,b)}},r.prototype.forEach=function(l){l(this.object,"object",this),l(this.index,"index",this)},r.prototype.map=function(l){return new r(this._ifNode(l(this.object,"object",this)),this._ifNode(l(this.index,"index",this)))},r.prototype.clone=function(){return new r(this.object,this.index)},r.prototype._toString=function(l){var m=this.object.toString(l);return i(this.object)&&(m="("+m+")"),m+this.index.toString(l)},r.prototype.toHTML=function(l){var m=this.object.toHTML(l);return i(this.object)&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>'),m+this.index.toHTML(l)},r.prototype._toTex=function(l){var m=this.object.toTex(l);return i(this.object)&&(m="\\left(' + object + '\\right)"),m+this.index.toTex(l)},r.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},r.fromJSON=function(l){return new r(l.object,l.index)};function i(l){return!(Lt(l)||Hr(l)||Ye(l)||kt(l)||jn(l)||On(l)||xr(l))}return r},{isClass:!0,isNode:!0}),eN="ArrayNode",rN=["Node"],tN=R(eN,rN,e=>{var{Node:n}=e;function a(t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=t||[],!Array.isArray(this.items)||!this.items.every(Ve))throw new TypeError("Array containing Nodes expected")}return a.prototype=new n,a.prototype.type="ArrayNode",a.prototype.isArrayNode=!0,a.prototype._compile=function(t,r){var i=dt(this.items,function(f){return f._compile(t,r)}),l=t.config.matrix!=="Array";if(l){var m=t.matrix;return function(c,s,o){return m(dt(i,function(u){return u(c,s,o)}))}}else return function(c,s,o){return dt(i,function(u){return u(c,s,o)})}},a.prototype.forEach=function(t){for(var r=0;r<this.items.length;r++){var i=this.items[r];t(i,"items["+r+"]",this)}},a.prototype.map=function(t){for(var r=[],i=0;i<this.items.length;i++)r[i]=this._ifNode(t(this.items[i],"items["+i+"]",this));return new a(r)},a.prototype.clone=function(){return new a(this.items.slice(0))},a.prototype._toString=function(t){var r=this.items.map(function(i){return i.toString(t)});return"["+r.join(", ")+"]"},a.prototype.toJSON=function(){return{mathjs:"ArrayNode",items:this.items}},a.fromJSON=function(t){return new a(t.items)},a.prototype.toHTML=function(t){var r=this.items.map(function(i){return i.toHTML(t)});return'<span class="math-parenthesis math-square-parenthesis">[</span>'+r.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'},a.prototype._toTex=function(t){function r(i,l){var m=i.some(Hr)&&!i.every(Hr),f=l||m,c=f?"&":"\\\\",s=i.map(function(o){return o.items?r(o.items,!l):o.toTex(t)}).join(c);return m||!f||f&&!l?"\\begin{bmatrix}"+s+"\\end{bmatrix}":s}return r(this.items,!1)},a},{isClass:!0,isNode:!0});function nN(e){var{subset:n,matrix:a}=e;return function(r,i,l){try{if(Array.isArray(r))return a(r).subset(i,l).valueOf();if(r&&typeof r.subset=="function")return r.subset(i,l);if(typeof r=="string")return n(r,i,l);if(typeof r=="object"){if(!i.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return un(r,i.getObjectProperty(),l),r}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(m){throw Br(m)}}}var ct=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{associativity:"left",associativeWith:[]}},{"OperatorNode:and":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{associativity:"left",associativeWith:[]},"OperatorNode:unequal":{associativity:"left",associativeWith:[]},"OperatorNode:smaller":{associativity:"left",associativeWith:[]},"OperatorNode:larger":{associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{associativity:"left",associativeWith:[]}},{"OperatorNode:to":{associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{associativity:"left",associativeWith:[]},"OperatorNode:mod":{associativity:"left",associativeWith:[]}},{"OperatorNode:unaryPlus":{associativity:"right"},"OperatorNode:unaryMinus":{associativity:"right"},"OperatorNode:bitNot":{associativity:"right"},"OperatorNode:not":{associativity:"right"}},{"OperatorNode:pow":{associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{associativity:"left"}},{"OperatorNode:transpose":{associativity:"left"}}];function Je(e,n){var a=e;n!=="keep"&&(a=e.getContent());for(var t=a.getIdentifier(),r=0;r<ct.length;r++)if(t in ct[r])return r;return null}function zn(e,n){var a=e;n!=="keep"&&(a=e.getContent());var t=a.getIdentifier(),r=Je(a,n);if(r===null)return null;var i=ct[r][t];if(Me(i,"associativity")){if(i.associativity==="left")return"left";if(i.associativity==="right")return"right";throw Error("'"+t+"' has the invalid associativity '"+i.associativity+"'.")}return null}function Ti(e,n,a){var t=a!=="keep"?e.getContent():e,r=a!=="keep"?e.getContent():n,i=t.getIdentifier(),l=r.getIdentifier(),m=Je(t,a);if(m===null)return null;var f=ct[m][i];if(Me(f,"associativeWith")&&f.associativeWith instanceof Array){for(var c=0;c<f.associativeWith.length;c++)if(f.associativeWith[c]===l)return!0;return!1}return null}var aN="AssignmentNode",iN=["subset","?matrix","Node"],oN=R(aN,iN,e=>{var{subset:n,matrix:a,Node:t}=e,r=jf({subset:n}),i=nN({subset:n,matrix:a});function l(f,c,s){if(!(this instanceof l))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=f,this.index=s?c:null,this.value=s||c,!xr(f)&&!Lt(f))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(xr(f)&&f.name==="end")throw new Error('Cannot assign to symbol "end"');if(this.index&&!tn(this.index))throw new TypeError('IndexNode expected as "index"');if(!Ve(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")}})}l.prototype=new t,l.prototype.type="AssignmentNode",l.prototype.isAssignmentNode=!0,l.prototype._compile=function(f,c){var s=this.object._compile(f,c),o=this.index?this.index._compile(f,c):null,u=this.value._compile(f,c),p=this.object.name;if(this.index)if(this.index.isObjectProperty()){var v=this.index.getObjectProperty();return function(g,y,x){var d=s(g,y,x),A=u(g,y,x);return un(d,v,A),A}}else{if(xr(this.object))return function(g,y,x){var d=s(g,y,x),A=u(g,y,x),S=o(g,y,d);return g.set(p,i(d,S,A)),A};var h=this.object.object._compile(f,c);if(this.object.index.isObjectProperty()){var b=this.object.index.getObjectProperty();return function(g,y,x){var d=h(g,y,x),A=Vr(d,b),S=o(g,y,A),O=u(g,y,x);return un(d,b,i(A,S,O)),O}}else{var w=this.object.index._compile(f,c);return function(g,y,x){var d=h(g,y,x),A=w(g,y,d),S=r(d,A),O=o(g,y,S),M=u(g,y,x);return i(d,A,i(S,O,M)),M}}}else{if(!xr(this.object))throw new TypeError("SymbolNode expected as object");return function(g,y,x){var d=u(g,y,x);return g.set(p,d),d}}},l.prototype.forEach=function(f){f(this.object,"object",this),this.index&&f(this.index,"index",this),f(this.value,"value",this)},l.prototype.map=function(f){var c=this._ifNode(f(this.object,"object",this)),s=this.index?this._ifNode(f(this.index,"index",this)):null,o=this._ifNode(f(this.value,"value",this));return new l(c,s,o)},l.prototype.clone=function(){return new l(this.object,this.index,this.value)};function m(f,c){c||(c="keep");var s=Je(f,c),o=Je(f.value,c);return c==="all"||o!==null&&o<=s}return l.prototype._toString=function(f){var c=this.object.toString(f),s=this.index?this.index.toString(f):"",o=this.value.toString(f);return m(this,f&&f.parenthesis)&&(o="("+o+")"),c+s+" = "+o},l.prototype.toJSON=function(){return{mathjs:"AssignmentNode",object:this.object,index:this.index,value:this.value}},l.fromJSON=function(f){return new l(f.object,f.index,f.value)},l.prototype.toHTML=function(f){var c=this.object.toHTML(f),s=this.index?this.index.toHTML(f):"",o=this.value.toHTML(f);return m(this,f&&f.parenthesis)&&(o='<span class="math-paranthesis math-round-parenthesis">(</span>'+o+'<span class="math-paranthesis math-round-parenthesis">)</span>'),c+s+'<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+o},l.prototype._toTex=function(f){var c=this.object.toTex(f),s=this.index?this.index.toTex(f):"",o=this.value.toTex(f);return m(this,f&&f.parenthesis)&&(o="\\left(".concat(o,"\\right)")),c+s+":="+o},l},{isClass:!0,isNode:!0}),sN="BlockNode",uN=["ResultSet","Node"],cN=R(sN,uN,e=>{var{ResultSet:n,Node:a}=e;function t(r){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(r))throw new Error("Array expected");this.blocks=r.map(function(i){var l=i&&i.node,m=i&&i.visible!==void 0?i.visible:!0;if(!Ve(l))throw new TypeError('Property "node" must be a Node');if(typeof m!="boolean")throw new TypeError('Property "visible" must be a boolean');return{node:l,visible:m}})}return t.prototype=new a,t.prototype.type="BlockNode",t.prototype.isBlockNode=!0,t.prototype._compile=function(r,i){var l=dt(this.blocks,function(m){return{evaluate:m.node._compile(r,i),visible:m.visible}});return function(f,c,s){var o=[];return ia(l,function(p){var v=p.evaluate(f,c,s);p.visible&&o.push(v)}),new n(o)}},t.prototype.forEach=function(r){for(var i=0;i<this.blocks.length;i++)r(this.blocks[i].node,"blocks["+i+"].node",this)},t.prototype.map=function(r){for(var i=[],l=0;l<this.blocks.length;l++){var m=this.blocks[l],f=this._ifNode(r(m.node,"blocks["+l+"].node",this));i[l]={node:f,visible:m.visible}}return new t(i)},t.prototype.clone=function(){var r=this.blocks.map(function(i){return{node:i.node,visible:i.visible}});return new t(r)},t.prototype._toString=function(r){return this.blocks.map(function(i){return i.node.toString(r)+(i.visible?"":";")}).join(`
12
- `)},t.prototype.toJSON=function(){return{mathjs:"BlockNode",blocks:this.blocks}},t.fromJSON=function(r){return new t(r.blocks)},t.prototype.toHTML=function(r){return this.blocks.map(function(i){return i.node.toHTML(r)+(i.visible?"":'<span class="math-separator">;</span>')}).join('<span class="math-separator"><br /></span>')},t.prototype._toTex=function(r){return this.blocks.map(function(i){return i.node.toTex(r)+(i.visible?"":";")}).join(`\\;\\;
13
- `)},t},{isClass:!0,isNode:!0}),fN="ConditionalNode",lN=["Node"],mN=R(fN,lN,e=>{var{Node:n}=e;function a(r,i,l){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Ve(r))throw new TypeError("Parameter condition must be a Node");if(!Ve(i))throw new TypeError("Parameter trueExpr must be a Node");if(!Ve(l))throw new TypeError("Parameter falseExpr must be a Node");this.condition=r,this.trueExpr=i,this.falseExpr=l}a.prototype=new n,a.prototype.type="ConditionalNode",a.prototype.isConditionalNode=!0,a.prototype._compile=function(r,i){var l=this.condition._compile(r,i),m=this.trueExpr._compile(r,i),f=this.falseExpr._compile(r,i);return function(s,o,u){return t(l(s,o,u))?m(s,o,u):f(s,o,u)}},a.prototype.forEach=function(r){r(this.condition,"condition",this),r(this.trueExpr,"trueExpr",this),r(this.falseExpr,"falseExpr",this)},a.prototype.map=function(r){return new a(this._ifNode(r(this.condition,"condition",this)),this._ifNode(r(this.trueExpr,"trueExpr",this)),this._ifNode(r(this.falseExpr,"falseExpr",this)))},a.prototype.clone=function(){return new a(this.condition,this.trueExpr,this.falseExpr)},a.prototype._toString=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=Je(this,i),m=this.condition.toString(r),f=Je(this.condition,i);(i==="all"||this.condition.type==="OperatorNode"||f!==null&&f<=l)&&(m="("+m+")");var c=this.trueExpr.toString(r),s=Je(this.trueExpr,i);(i==="all"||this.trueExpr.type==="OperatorNode"||s!==null&&s<=l)&&(c="("+c+")");var o=this.falseExpr.toString(r),u=Je(this.falseExpr,i);return(i==="all"||this.falseExpr.type==="OperatorNode"||u!==null&&u<=l)&&(o="("+o+")"),m+" ? "+c+" : "+o},a.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},a.fromJSON=function(r){return new a(r.condition,r.trueExpr,r.falseExpr)},a.prototype.toHTML=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=Je(this,i),m=this.condition.toHTML(r),f=Je(this.condition,i);(i==="all"||this.condition.type==="OperatorNode"||f!==null&&f<=l)&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>');var c=this.trueExpr.toHTML(r),s=Je(this.trueExpr,i);(i==="all"||this.trueExpr.type==="OperatorNode"||s!==null&&s<=l)&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>');var o=this.falseExpr.toHTML(r),u=Je(this.falseExpr,i);return(i==="all"||this.falseExpr.type==="OperatorNode"||u!==null&&u<=l)&&(o='<span class="math-parenthesis math-round-parenthesis">(</span>'+o+'<span class="math-parenthesis math-round-parenthesis">)</span>'),m+'<span class="math-operator math-conditional-operator">?</span>'+c+'<span class="math-operator math-conditional-operator">:</span>'+o},a.prototype._toTex=function(r){return"\\begin{cases} {"+this.trueExpr.toTex(r)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(r)+"}\\\\{"+this.falseExpr.toTex(r)+"}, &\\quad{\\text{otherwise}}\\end{cases}"};function t(r){if(typeof r=="number"||typeof r=="boolean"||typeof r=="string")return!!r;if(r){if(_e(r))return!r.isZero();if(Or(r))return!!(r.re||r.im);if(ht(r))return!!r.value}if(r==null)return!1;throw new TypeError('Unsupported type of condition "'+Ke(r)+'"')}return a},{isClass:!0,isNode:!0}),Bi,el;function pN(){if(el)return Bi;el=1;var e=Object.assign||function(r){for(var i=1;i<arguments.length;i++){var l=arguments[i];for(var m in l)Object.prototype.hasOwnProperty.call(l,m)&&(r[m]=l[m])}return r},n={"{":"\\{","}":"\\}","\\":"\\textbackslash{}","#":"\\#",$:"\\$","%":"\\%","&":"\\&","^":"\\textasciicircum{}",_:"\\_","~":"\\textasciitilde{}"},a={"–":"\\--","—":"\\---"," ":"~"," ":"\\qquad{}","\r\n":"\\newline{}","\n":"\\newline{}"},t=function(i,l){return e({},i,l)};return Bi=function(r){for(var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=i.preserveFormatting,m=l===void 0?!1:l,f=i.escapeMapFn,c=f===void 0?t:f,s=String(r),o="",u=c(e({},n),m?e({},a):{}),p=Object.keys(u),v=function(){var b=!1;p.forEach(function(w,N){b||s.length>=w.length&&s.slice(0,w.length)===w&&(o+=u[p[N]],s=s.slice(w.length,s.length),b=!0)}),b||(o+=s.slice(0,1),s=s.slice(1,s.length))};s;)v();return o},Bi}var vN=pN();const hN=Tn(vN);var _i={Alpha:"A",alpha:"\\alpha",Beta:"B",beta:"\\beta",Gamma:"\\Gamma",gamma:"\\gamma",Delta:"\\Delta",delta:"\\delta",Epsilon:"E",epsilon:"\\epsilon",varepsilon:"\\varepsilon",Zeta:"Z",zeta:"\\zeta",Eta:"H",eta:"\\eta",Theta:"\\Theta",theta:"\\theta",vartheta:"\\vartheta",Iota:"I",iota:"\\iota",Kappa:"K",kappa:"\\kappa",varkappa:"\\varkappa",Lambda:"\\Lambda",lambda:"\\lambda",Mu:"M",mu:"\\mu",Nu:"N",nu:"\\nu",Xi:"\\Xi",xi:"\\xi",Omicron:"O",omicron:"o",Pi:"\\Pi",pi:"\\pi",varpi:"\\varpi",Rho:"P",rho:"\\rho",varrho:"\\varrho",Sigma:"\\Sigma",sigma:"\\sigma",varsigma:"\\varsigma",Tau:"T",tau:"\\tau",Upsilon:"\\Upsilon",upsilon:"\\upsilon",Phi:"\\Phi",phi:"\\phi",varphi:"\\varphi",Chi:"X",chi:"\\chi",Psi:"\\Psi",psi:"\\psi",Omega:"\\Omega",omega:"\\omega",true:"\\mathrm{True}",false:"\\mathrm{False}",i:"i",inf:"\\infty",Inf:"\\infty",infinity:"\\infty",Infinity:"\\infty",oo:"\\infty",lim:"\\lim",undefined:"\\mathbf{?}"},He={transpose:"^\\top",ctranspose:"^H",factorial:"!",pow:"^",dotPow:".^\\wedge",unaryPlus:"+",unaryMinus:"-",bitNot:"\\~",not:"\\neg",multiply:"\\cdot",divide:"\\frac",dotMultiply:".\\cdot",dotDivide:".:",mod:"\\mod",add:"+",subtract:"-",to:"\\rightarrow",leftShift:"<<",rightArithShift:">>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},rl={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(He.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(He.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(He.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(He.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(He.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(He.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(He.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(He.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(He.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(He.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(He.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(He.bitAnd,"${args[1]}\\right)")},bitNot:{1:He.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(He.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(He.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(He.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(He.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(He.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(He.and,"${args[1]}\\right)")},not:{1:He.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(He.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(He.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(He.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},pinv:{1:"\\left(${args[0]}\\right)^{+}"},sqrtm:{1:"{${args[0]}}".concat(He.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(He.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(He.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(He.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(He.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(He.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(He.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(He.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(He.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(He.to,"${args[1]}\\right)")},numeric:function(n,a){return n.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(_i.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)"}},dN="\\mathrm{${name}}\\left(${args}\\right)",tl={deg:"^\\circ"};function $i(e){return hN(e,{preserveFormatting:!0})}function nl(e,n){return n=typeof n=="undefined"?!1:n,n?Me(tl,e)?tl[e]:"\\mathrm{"+$i(e)+"}":Me(_i,e)?_i[e]:$i(e)}var gN="ConstantNode",yN=["Node"],xN=R(gN,yN,e=>{var{Node:n}=e;function a(t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this.value=t}return a.prototype=new n,a.prototype.type="ConstantNode",a.prototype.isConstantNode=!0,a.prototype._compile=function(t,r){var i=this.value;return function(){return i}},a.prototype.forEach=function(t){},a.prototype.map=function(t){return this.clone()},a.prototype.clone=function(){return new a(this.value)},a.prototype._toString=function(t){return Re(this.value,t)},a.prototype.toHTML=function(t){var r=this._toString(t);switch(Ke(this.value)){case"number":case"BigNumber":case"Fraction":return'<span class="math-number">'+r+"</span>";case"string":return'<span class="math-string">'+r+"</span>";case"boolean":return'<span class="math-boolean">'+r+"</span>";case"null":return'<span class="math-null-symbol">'+r+"</span>";case"undefined":return'<span class="math-undefined">'+r+"</span>";default:return'<span class="math-symbol">'+r+"</span>"}},a.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},a.fromJSON=function(t){return new a(t.value)},a.prototype._toTex=function(t){var r=this._toString(t);switch(Ke(this.value)){case"string":return"\\mathtt{"+$i(r)+"}";case"number":case"BigNumber":{if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var i=r.toLowerCase().indexOf("e");if(i!==-1)return r.substring(0,i)+"\\cdot10^{"+r.substring(i+1)+"}"}return r;case"Fraction":return this.value.toLatex();default:return r}},a},{isClass:!0,isNode:!0}),bN="FunctionAssignmentNode",wN=["typed","Node"],NN=R(bN,wN,e=>{var{typed:n,Node:a}=e;function t(i,l,m){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(typeof i!="string")throw new TypeError('String expected for parameter "name"');if(!Array.isArray(l))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!Ve(m))throw new TypeError('Node expected for parameter "expr"');if(Kf.has(i))throw new Error('Illegal function name, "'+i+'" is a reserved keyword');this.name=i,this.params=l.map(function(f){return f&&f.name||f}),this.types=l.map(function(f){return f&&f.type||"any"}),this.expr=m}t.prototype=new a,t.prototype.type="FunctionAssignmentNode",t.prototype.isFunctionAssignmentNode=!0,t.prototype._compile=function(i,l){var m=Object.create(l);ia(this.params,function(p){m[p]=!0});var f=this.expr._compile(i,m),c=this.name,s=this.params,o=No(this.types,","),u=c+"("+No(this.params,", ")+")";return function(v,h,b){var w={};w[o]=function(){for(var g=Object.create(h),y=0;y<s.length;y++)g[s[y]]=arguments[y];return f(v,g,b)};var N=n(c,w);return N.syntax=u,v.set(c,N),N}},t.prototype.forEach=function(i){i(this.expr,"expr",this)},t.prototype.map=function(i){var l=this._ifNode(i(this.expr,"expr",this));return new t(this.name,this.params.slice(0),l)},t.prototype.clone=function(){return new t(this.name,this.params.slice(0),this.expr)};function r(i,l){var m=Je(i,l),f=Je(i.expr,l);return l==="all"||f!==null&&f<=m}return t.prototype._toString=function(i){var l=i&&i.parenthesis?i.parenthesis:"keep",m=this.expr.toString(i);return r(this,l)&&(m="("+m+")"),this.name+"("+this.params.join(", ")+") = "+m},t.prototype.toJSON=function(){var i=this.types;return{mathjs:"FunctionAssignmentNode",name:this.name,params:this.params.map(function(l,m){return{name:l,type:i[m]}}),expr:this.expr}},t.fromJSON=function(i){return new t(i.name,i.params,i.expr)},t.prototype.toHTML=function(i){for(var l=i&&i.parenthesis?i.parenthesis:"keep",m=[],f=0;f<this.params.length;f++)m.push('<span class="math-symbol math-parameter">'+Gr(this.params[f])+"</span>");var c=this.expr.toHTML(i);return r(this,l)&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>'),'<span class="math-function">'+Gr(this.name)+'</span><span class="math-parenthesis math-round-parenthesis">(</span>'+m.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-round-parenthesis">)</span><span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+c},t.prototype._toTex=function(i){var l=i&&i.parenthesis?i.parenthesis:"keep",m=this.expr.toTex(i);return r(this,l)&&(m="\\left(".concat(m,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(nl).join(",")+"\\right):="+m},t},{isClass:!0,isNode:!0}),MN="IndexNode",AN=["Node","size"],SN=R(MN,AN,e=>{var{Node:n,size:a}=e;function t(r,i){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(this.dimensions=r,this.dotNotation=i||!1,!Array.isArray(r)||!r.every(Ve))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}return t.prototype=new n,t.prototype.type="IndexNode",t.prototype.isIndexNode=!0,t.prototype._compile=function(r,i){var l=dt(this.dimensions,function(f,c){var s=f.filter(p=>p.isSymbolNode&&p.name==="end").length>0;if(s){var o=Object.create(i);o.end=!0;var u=f._compile(r,o);return function(v,h,b){if(!Oe(b)&&!Xe(b)&&!_r(b))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+Ke(b));var w=a(b).valueOf(),N=Object.create(h);return N.end=w[c],u(v,N,b)}}else return f._compile(r,i)}),m=Vr(r,"index");return function(c,s,o){var u=dt(l,function(p){return p(c,s,o)});return m(...u)}},t.prototype.forEach=function(r){for(var i=0;i<this.dimensions.length;i++)r(this.dimensions[i],"dimensions["+i+"]",this)},t.prototype.map=function(r){for(var i=[],l=0;l<this.dimensions.length;l++)i[l]=this._ifNode(r(this.dimensions[l],"dimensions["+l+"]",this));return new t(i,this.dotNotation)},t.prototype.clone=function(){return new t(this.dimensions.slice(0),this.dotNotation)},t.prototype.isObjectProperty=function(){return this.dimensions.length===1&&Ye(this.dimensions[0])&&typeof this.dimensions[0].value=="string"},t.prototype.getObjectProperty=function(){return this.isObjectProperty()?this.dimensions[0].value:null},t.prototype._toString=function(r){return this.dotNotation?"."+this.getObjectProperty():"["+this.dimensions.join(", ")+"]"},t.prototype.toJSON=function(){return{mathjs:"IndexNode",dimensions:this.dimensions,dotNotation:this.dotNotation}},t.fromJSON=function(r){return new t(r.dimensions,r.dotNotation)},t.prototype.toHTML=function(r){for(var i=[],l=0;l<this.dimensions.length;l++)i[l]=this.dimensions[l].toHTML();return this.dotNotation?'<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">'+Gr(this.getObjectProperty())+"</span>":'<span class="math-parenthesis math-square-parenthesis">[</span>'+i.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'},t.prototype._toTex=function(r){var i=this.dimensions.map(function(l){return l.toTex(r)});return this.dotNotation?"."+this.getObjectProperty():"_{"+i.join(",")+"}"},t},{isClass:!0,isNode:!0}),EN="ObjectNode",CN=["Node"],ON=R(EN,CN,e=>{var{Node:n}=e;function a(t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=t||{},t&&(typeof t!="object"||!Object.keys(t).every(function(r){return Ve(t[r])})))throw new TypeError("Object containing Nodes expected")}return a.prototype=new n,a.prototype.type="ObjectNode",a.prototype.isObjectNode=!0,a.prototype._compile=function(t,r){var i={};for(var l in this.properties)if(Me(this.properties,l)){var m=na(l),f=JSON.parse(m);if(!ni(this.properties,f))throw new Error('No access to property "'+f+'"');i[f]=this.properties[l]._compile(t,r)}return function(s,o,u){var p={};for(var v in i)Me(i,v)&&(p[v]=i[v](s,o,u));return p}},a.prototype.forEach=function(t){for(var r in this.properties)Me(this.properties,r)&&t(this.properties[r],"properties["+na(r)+"]",this)},a.prototype.map=function(t){var r={};for(var i in this.properties)Me(this.properties,i)&&(r[i]=this._ifNode(t(this.properties[i],"properties["+na(i)+"]",this)));return new a(r)},a.prototype.clone=function(){var t={};for(var r in this.properties)Me(this.properties,r)&&(t[r]=this.properties[r]);return new a(t)},a.prototype._toString=function(t){var r=[];for(var i in this.properties)Me(this.properties,i)&&r.push(na(i)+": "+this.properties[i].toString(t));return"{"+r.join(", ")+"}"},a.prototype.toJSON=function(){return{mathjs:"ObjectNode",properties:this.properties}},a.fromJSON=function(t){return new a(t.properties)},a.prototype.toHTML=function(t){var r=[];for(var i in this.properties)Me(this.properties,i)&&r.push('<span class="math-symbol math-property">'+Gr(i)+'</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>'+this.properties[i].toHTML(t));return'<span class="math-parenthesis math-curly-parenthesis">{</span>'+r.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-curly-parenthesis">}</span>'},a.prototype._toTex=function(t){var r=[];for(var i in this.properties)Me(this.properties,i)&&r.push("\\mathbf{"+i+":} & "+this.properties[i].toTex(t)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(r.join(`
14
- `),"\\end{array}\\right\\}")},a},{isClass:!0,isNode:!0}),DN="OperatorNode",TN=["Node"],BN=R(DN,TN,e=>{var{Node:n}=e;function a(r,i,l,m,f){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(typeof r!="string")throw new TypeError('string expected for parameter "op"');if(typeof i!="string")throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(l)||!l.every(Ve))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=m===!0,this.isPercentage=f===!0,this.op=r,this.fn=i,this.args=l||[]}a.prototype=new n,a.prototype.type="OperatorNode",a.prototype.isOperatorNode=!0,a.prototype._compile=function(r,i){if(typeof this.fn!="string"||!ai(r,this.fn))throw r[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var l=Vr(r,this.fn),m=dt(this.args,function(o){return o._compile(r,i)});if(m.length===1){var f=m[0];return function(u,p,v){return l(f(u,p,v))}}else if(m.length===2){var c=m[0],s=m[1];return function(u,p,v){return l(c(u,p,v),s(u,p,v))}}else return function(u,p,v){return l.apply(null,dt(m,function(h){return h(u,p,v)}))}},a.prototype.forEach=function(r){for(var i=0;i<this.args.length;i++)r(this.args[i],"args["+i+"]",this)},a.prototype.map=function(r){for(var i=[],l=0;l<this.args.length;l++)i[l]=this._ifNode(r(this.args[l],"args["+l+"]",this));return new a(this.op,this.fn,i,this.implicit,this.isPercentage)},a.prototype.clone=function(){return new a(this.op,this.fn,this.args.slice(0),this.implicit,this.isPercentage)},a.prototype.isUnary=function(){return this.args.length===1},a.prototype.isBinary=function(){return this.args.length===2};function t(r,i,l,m,f){var c=Je(r,i),s=zn(r,i);if(i==="all"||m.length>2&&r.getIdentifier()!=="OperatorNode:add"&&r.getIdentifier()!=="OperatorNode:multiply")return m.map(function(S){switch(S.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}});var o;switch(m.length){case 0:o=[];break;case 1:{var u=Je(m[0],i);if(f&&u!==null){var p,v;if(i==="keep"?(p=m[0].getIdentifier(),v=r.getIdentifier()):(p=m[0].getContent().getIdentifier(),v=r.getContent().getIdentifier()),ct[c][v].latexLeftParens===!1){o=[!1];break}if(ct[u][p].latexParens===!1){o=[!1];break}}if(u===null){o=[!1];break}if(u<=c){o=[!0];break}o=[!1]}break;case 2:{var h,b=Je(m[0],i),w=Ti(r,m[0],i);b===null?h=!1:b===c&&s==="right"&&!w||b<c?h=!0:h=!1;var N,g=Je(m[1],i),y=Ti(r,m[1],i);if(g===null?N=!1:g===c&&s==="left"&&!y||g<c?N=!0:N=!1,f){var x,d,A;i==="keep"?(x=r.getIdentifier(),d=r.args[0].getIdentifier(),A=r.args[1].getIdentifier()):(x=r.getContent().getIdentifier(),d=r.args[0].getContent().getIdentifier(),A=r.args[1].getContent().getIdentifier()),b!==null&&(ct[c][x].latexLeftParens===!1&&(h=!1),ct[b][d].latexParens===!1&&(h=!1)),g!==null&&(ct[c][x].latexRightParens===!1&&(N=!1),ct[g][A].latexParens===!1&&(N=!1))}o=[h,N]}break;default:(r.getIdentifier()==="OperatorNode:add"||r.getIdentifier()==="OperatorNode:multiply")&&(o=m.map(function(S){var O=Je(S,i),M=Ti(r,S,i),_=zn(S,i);return O===null?!1:c===O&&s===_&&!M?!0:O<c}));break}return m.length>=2&&r.getIdentifier()==="OperatorNode:multiply"&&r.implicit&&i==="auto"&&l==="hide"&&(o=m.map(function(S,O){var M=S.getIdentifier()==="ParenthesisNode";return!!(o[O]||M)})),o}return a.prototype._toString=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=r&&r.implicit?r.implicit:"hide",m=this.args,f=t(this,i,l,m,!1);if(m.length===1){var c=zn(this,i),s=m[0].toString(r);f[0]&&(s="("+s+")");var o=/[a-zA-Z]+/.test(this.op);return c==="right"?this.op+(o?" ":"")+s:c==="left"?s+(o?" ":"")+this.op:s+this.op}else if(m.length===2){var u=m[0].toString(r),p=m[1].toString(r);return f[0]&&(u="("+u+")"),f[1]&&(p="("+p+")"),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?u+" "+p:u+" "+this.op+" "+p}else if(m.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var v=m.map(function(h,b){return h=h.toString(r),f[b]&&(h="("+h+")"),h});return this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?v.join(" "):v.join(" "+this.op+" ")}else return this.fn+"("+this.args.join(", ")+")"},a.prototype.toJSON=function(){return{mathjs:"OperatorNode",op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}},a.fromJSON=function(r){return new a(r.op,r.fn,r.args,r.implicit,r.isPercentage)},a.prototype.toHTML=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=r&&r.implicit?r.implicit:"hide",m=this.args,f=t(this,i,l,m,!1);if(m.length===1){var c=zn(this,i),s=m[0].toHTML(r);return f[0]&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),c==="right"?'<span class="math-operator math-unary-operator math-lefthand-unary-operator">'+Gr(this.op)+"</span>"+s:s+'<span class="math-operator math-unary-operator math-righthand-unary-operator">'+Gr(this.op)+"</span>"}else if(m.length===2){var o=m[0].toHTML(r),u=m[1].toHTML(r);return f[0]&&(o='<span class="math-parenthesis math-round-parenthesis">(</span>'+o+'<span class="math-parenthesis math-round-parenthesis">)</span>'),f[1]&&(u='<span class="math-parenthesis math-round-parenthesis">(</span>'+u+'<span class="math-parenthesis math-round-parenthesis">)</span>'),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?o+'<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'+u:o+'<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Gr(this.op)+"</span>"+u}else{var p=m.map(function(v,h){return v=v.toHTML(r),f[h]&&(v='<span class="math-parenthesis math-round-parenthesis">(</span>'+v+'<span class="math-parenthesis math-round-parenthesis">)</span>'),v});return m.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")?this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&l==="hide"?p.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'):p.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Gr(this.op)+"</span>"):'<span class="math-function">'+Gr(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+p.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}},a.prototype._toTex=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=r&&r.implicit?r.implicit:"hide",m=this.args,f=t(this,i,l,m,!0),c=He[this.fn];if(c=typeof c=="undefined"?this.op:c,m.length===1){var s=zn(this,i),o=m[0].toTex(r);return f[0]&&(o="\\left(".concat(o,"\\right)")),s==="right"?c+o:o+c}else if(m.length===2){var u=m[0],p=u.toTex(r);f[0]&&(p="\\left(".concat(p,"\\right)"));var v=m[1],h=v.toTex(r);f[1]&&(h="\\left(".concat(h,"\\right)"));var b;switch(i==="keep"?b=u.getIdentifier():b=u.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return c+"{"+p+"}{"+h+"}";case"OperatorNode:pow":switch(p="{"+p+"}",h="{"+h+"}",b){case"ConditionalNode":case"OperatorNode:divide":p="\\left(".concat(p,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&l==="hide")return p+"~"+h}return p+c+h}else if(m.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var w=m.map(function(N,g){return N=N.toTex(r),f[g]&&(N="\\left(".concat(N,"\\right)")),N});return this.getIdentifier()==="OperatorNode:multiply"&&this.implicit?w.join("~"):w.join(c)}else return"\\mathrm{"+this.fn+"}\\left("+m.map(function(N){return N.toTex(r)}).join(",")+"\\right)"},a.prototype.getIdentifier=function(){return this.type+":"+this.fn},a},{isClass:!0,isNode:!0}),_N="ParenthesisNode",$N=["Node"],IN=R(_N,$N,e=>{var{Node:n}=e;function a(t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Ve(t))throw new TypeError('Node expected for parameter "content"');this.content=t}return a.prototype=new n,a.prototype.type="ParenthesisNode",a.prototype.isParenthesisNode=!0,a.prototype._compile=function(t,r){return this.content._compile(t,r)},a.prototype.getContent=function(){return this.content.getContent()},a.prototype.forEach=function(t){t(this.content,"content",this)},a.prototype.map=function(t){var r=t(this.content,"content",this);return new a(r)},a.prototype.clone=function(){return new a(this.content)},a.prototype._toString=function(t){return!t||t&&!t.parenthesis||t&&t.parenthesis==="keep"?"("+this.content.toString(t)+")":this.content.toString(t)},a.prototype.toJSON=function(){return{mathjs:"ParenthesisNode",content:this.content}},a.fromJSON=function(t){return new a(t.content)},a.prototype.toHTML=function(t){return!t||t&&!t.parenthesis||t&&t.parenthesis==="keep"?'<span class="math-parenthesis math-round-parenthesis">(</span>'+this.content.toHTML(t)+'<span class="math-parenthesis math-round-parenthesis">)</span>':this.content.toHTML(t)},a.prototype._toTex=function(t){return!t||t&&!t.parenthesis||t&&t.parenthesis==="keep"?"\\left(".concat(this.content.toTex(t),"\\right)"):this.content.toTex(t)},a},{isClass:!0,isNode:!0}),qN="RangeNode",RN=["Node"],FN=R(qN,RN,e=>{var{Node:n}=e;function a(r,i,l){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Ve(r))throw new TypeError("Node expected");if(!Ve(i))throw new TypeError("Node expected");if(l&&!Ve(l))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=r,this.end=i,this.step=l||null}a.prototype=new n,a.prototype.type="RangeNode",a.prototype.isRangeNode=!0,a.prototype.needsEnd=function(){var r=this.filter(function(i){return xr(i)&&i.name==="end"});return r.length>0},a.prototype._compile=function(r,i){var l=r.range,m=this.start._compile(r,i),f=this.end._compile(r,i);if(this.step){var c=this.step._compile(r,i);return function(o,u,p){return l(m(o,u,p),f(o,u,p),c(o,u,p))}}else return function(o,u,p){return l(m(o,u,p),f(o,u,p))}},a.prototype.forEach=function(r){r(this.start,"start",this),r(this.end,"end",this),this.step&&r(this.step,"step",this)},a.prototype.map=function(r){return new a(this._ifNode(r(this.start,"start",this)),this._ifNode(r(this.end,"end",this)),this.step&&this._ifNode(r(this.step,"step",this)))},a.prototype.clone=function(){return new a(this.start,this.end,this.step&&this.step)};function t(r,i){var l=Je(r,i),m={},f=Je(r.start,i);if(m.start=f!==null&&f<=l||i==="all",r.step){var c=Je(r.step,i);m.step=c!==null&&c<=l||i==="all"}var s=Je(r.end,i);return m.end=s!==null&&s<=l||i==="all",m}return a.prototype._toString=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=t(this,i),m,f=this.start.toString(r);if(l.start&&(f="("+f+")"),m=f,this.step){var c=this.step.toString(r);l.step&&(c="("+c+")"),m+=":"+c}var s=this.end.toString(r);return l.end&&(s="("+s+")"),m+=":"+s,m},a.prototype.toJSON=function(){return{mathjs:"RangeNode",start:this.start,end:this.end,step:this.step}},a.fromJSON=function(r){return new a(r.start,r.end,r.step)},a.prototype.toHTML=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=t(this,i),m,f=this.start.toHTML(r);if(l.start&&(f='<span class="math-parenthesis math-round-parenthesis">(</span>'+f+'<span class="math-parenthesis math-round-parenthesis">)</span>'),m=f,this.step){var c=this.step.toHTML(r);l.step&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>'),m+='<span class="math-operator math-range-operator">:</span>'+c}var s=this.end.toHTML(r);return l.end&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),m+='<span class="math-operator math-range-operator">:</span>'+s,m},a.prototype._toTex=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",l=t(this,i),m=this.start.toTex(r);if(l.start&&(m="\\left(".concat(m,"\\right)")),this.step){var f=this.step.toTex(r);l.step&&(f="\\left(".concat(f,"\\right)")),m+=":"+f}var c=this.end.toTex(r);return l.end&&(c="\\left(".concat(c,"\\right)")),m+=":"+c,m},a},{isClass:!0,isNode:!0}),zN="RelationalNode",PN=["Node"],UN=R(zN,PN,e=>{var{Node:n}=e;function a(t,r){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(t))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(r))throw new TypeError("Parameter params must be an array");if(t.length!==r.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=t,this.params=r}return a.prototype=new n,a.prototype.type="RelationalNode",a.prototype.isRelationalNode=!0,a.prototype._compile=function(t,r){var i=this,l=this.params.map(m=>m._compile(t,r));return function(f,c,s){for(var o,u=l[0](f,c,s),p=0;p<i.conditionals.length;p++){o=u,u=l[p+1](f,c,s);var v=Vr(t,i.conditionals[p]);if(!v(o,u))return!1}return!0}},a.prototype.forEach=function(t){this.params.forEach((r,i)=>t(r,"params["+i+"]",this),this)},a.prototype.map=function(t){return new a(this.conditionals.slice(),this.params.map((r,i)=>this._ifNode(t(r,"params["+i+"]",this)),this))},a.prototype.clone=function(){return new a(this.conditionals,this.params)},a.prototype._toString=function(t){for(var r=t&&t.parenthesis?t.parenthesis:"keep",i=Je(this,r),l=this.params.map(function(s,o){var u=Je(s,r);return r==="all"||u!==null&&u<=i?"("+s.toString(t)+")":s.toString(t)}),m={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},f=l[0],c=0;c<this.conditionals.length;c++)f+=" "+m[this.conditionals[c]]+" "+l[c+1];return f},a.prototype.toJSON=function(){return{mathjs:"RelationalNode",conditionals:this.conditionals,params:this.params}},a.fromJSON=function(t){return new a(t.conditionals,t.params)},a.prototype.toHTML=function(t){for(var r=t&&t.parenthesis?t.parenthesis:"keep",i=Je(this,r),l=this.params.map(function(s,o){var u=Je(s,r);return r==="all"||u!==null&&u<=i?'<span class="math-parenthesis math-round-parenthesis">(</span>'+s.toHTML(t)+'<span class="math-parenthesis math-round-parenthesis">)</span>':s.toHTML(t)}),m={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},f=l[0],c=0;c<this.conditionals.length;c++)f+='<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Gr(m[this.conditionals[c]])+"</span>"+l[c+1];return f},a.prototype._toTex=function(t){for(var r=t&&t.parenthesis?t.parenthesis:"keep",i=Je(this,r),l=this.params.map(function(c,s){var o=Je(c,r);return r==="all"||o!==null&&o<=i?"\\left("+c.toTex(t)+"\right)":c.toTex(t)}),m=l[0],f=0;f<this.conditionals.length;f++)m+=He[this.conditionals[f]]+l[f+1];return m},a},{isClass:!0,isNode:!0}),LN="SymbolNode",kN=["math","?Unit","Node"],HN=R(LN,kN,e=>{var{math:n,Unit:a,Node:t}=e;function r(l){return a?a.isValuelessUnit(l):!1}function i(l){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(typeof l!="string")throw new TypeError('String expected for parameter "name"');this.name=l}return i.prototype=new t,i.prototype.type="SymbolNode",i.prototype.isSymbolNode=!0,i.prototype._compile=function(l,m){var f=this.name;if(m[f]===!0)return function(s,o,u){return o[f]};if(f in l)return function(s,o,u){return s.has(f)?s.get(f):Vr(l,f)};var c=r(f);return function(s,o,u){return s.has(f)?s.get(f):c?new a(null,f):i.onUndefinedSymbol(f)}},i.prototype.forEach=function(l){},i.prototype.map=function(l){return this.clone()},i.onUndefinedSymbol=function(l){throw new Error("Undefined symbol "+l)},i.prototype.clone=function(){return new i(this.name)},i.prototype._toString=function(l){return this.name},i.prototype.toHTML=function(l){var m=Gr(this.name);return m==="true"||m==="false"?'<span class="math-symbol math-boolean">'+m+"</span>":m==="i"?'<span class="math-symbol math-imaginary-symbol">'+m+"</span>":m==="Infinity"?'<span class="math-symbol math-infinity-symbol">'+m+"</span>":m==="NaN"?'<span class="math-symbol math-nan-symbol">'+m+"</span>":m==="null"?'<span class="math-symbol math-null-symbol">'+m+"</span>":m==="undefined"?'<span class="math-symbol math-undefined-symbol">'+m+"</span>":'<span class="math-symbol">'+m+"</span>"},i.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},i.fromJSON=function(l){return new i(l.name)},i.prototype._toTex=function(l){var m=!1;typeof n[this.name]=="undefined"&&r(this.name)&&(m=!0);var f=nl(this.name,m);return f[0]==="\\"?f:" "+f},i},{isClass:!0,isNode:!0});function Pn(e){for(var n=arguments.length,a=new Array(n>1?n-1:0),t=1;t<n;t++)a[t-1]=arguments[t];return typeof e.createSubScope=="function"?Ao(e.createSubScope(),...a):Ao(gt(),e,...a)}var GN="FunctionNode",VN=["math","Node","SymbolNode"],ZN=R(GN,VN,e=>{var{math:n,Node:a,SymbolNode:t}=e;function r(c,s){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(typeof c=="string"&&(c=new t(c)),!Ve(c))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(s)||!s.every(Ve))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=c,this.args=s||[],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")}})}r.prototype=new a,r.prototype.type="FunctionNode",r.prototype.isFunctionNode=!0;var i=c=>Re(c,{truncate:78});r.prototype._compile=function(c,s){if(!(this instanceof r))throw new TypeError("No valid FunctionNode");var o=this.args.map(S=>S._compile(c,s));if(xr(this.fn)){var u=this.fn.name;if(s[u]){var w=this.args;return function(O,M,_){var E=M[u];if(typeof E!="function")throw new TypeError("Argument '".concat(u,"' was not a function; received: ").concat(i(E)));if(E.rawArgs)return E(w,c,Pn(O,M),O);var $=o.map(z=>z(O,M,_));return E.apply(E,$)}}else{var p=u in c?Vr(c,u):void 0,v=typeof p=="function"&&p.rawArgs===!0,h=S=>{var O;if(S.has(u))O=S.get(u);else if(u in c)O=Vr(c,u);else return r.onUndefinedFunction(u);if(typeof O=="function")return O;throw new TypeError("'".concat(u,`' is not a function; its value is:
15
- `).concat(i(O)))};if(v){var b=this.args;return function(O,M,_){var E=h(O);return E(b,c,Pn(O,M),O)}}else switch(o.length){case 0:return function(O,M,_){var E=h(O);return E()};case 1:return function(O,M,_){var E=h(O),$=o[0];return E($(O,M,_))};case 2:return function(O,M,_){var E=h(O),$=o[0],z=o[1];return E($(O,M,_),z(O,M,_))};default:return function(O,M,_){var E=h(O),$=o.map(z=>z(O,M,_));return E(...$)}}}}else if(Lt(this.fn)&&tn(this.fn.index)&&this.fn.index.isObjectProperty()){var N=this.fn.object._compile(c,s),g=this.fn.index.getObjectProperty(),y=this.args;return function(O,M,_){var E=N(O,M,_);hv(E,g);var $=E[g]&&E[g].rawArgs;if($)return E[g](y,c,Pn(O,M),O);var z=o.map(I=>I(O,M,_));return E[g].apply(E,z)}}else{var x=this.fn.toString(),d=this.fn._compile(c,s),A=this.args;return function(O,M,_){var E=d(O,M,_);if(typeof E!="function")throw new TypeError("Expression '".concat(x,"' did not evaluate to a function; value is:")+`
16
- `.concat(i(E)));if(E.rawArgs)return E(A,c,Pn(O,M),O);var $=o.map(z=>z(O,M,_));return E.apply(E,$)}}},r.prototype.forEach=function(c){c(this.fn,"fn",this);for(var s=0;s<this.args.length;s++)c(this.args[s],"args["+s+"]",this)},r.prototype.map=function(c){for(var s=this._ifNode(c(this.fn,"fn",this)),o=[],u=0;u<this.args.length;u++)o[u]=this._ifNode(c(this.args[u],"args["+u+"]",this));return new r(s,o)},r.prototype.clone=function(){return new r(this.fn,this.args.slice(0))},r.onUndefinedFunction=function(c){throw new Error("Undefined function "+c)};var l=r.prototype.toString;r.prototype.toString=function(c){var s,o=this.fn.toString(c);return c&&typeof c.handler=="object"&&Me(c.handler,o)&&(s=c.handler[o](this,c)),typeof s!="undefined"?s:l.call(this,c)},r.prototype._toString=function(c){var s=this.args.map(function(u){return u.toString(c)}),o=Cn(this.fn)?"("+this.fn.toString(c)+")":this.fn.toString(c);return o+"("+s.join(", ")+")"},r.prototype.toJSON=function(){return{mathjs:"FunctionNode",fn:this.fn,args:this.args}},r.fromJSON=function(c){return new r(c.fn,c.args)},r.prototype.toHTML=function(c){var s=this.args.map(function(o){return o.toHTML(c)});return'<span class="math-function">'+Gr(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+s.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'};function m(c,s,o){for(var u="",p=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,v=0,h;(h=p.exec(c))!==null;)if(u+=c.substring(v,h.index),v=h.index,h[0]==="$$")u+="$",v++;else{v+=h[0].length;var b=s[h[1]];if(!b)throw new ReferenceError("Template: Property "+h[1]+" does not exist.");if(h[2]===void 0)switch(typeof b){case"string":u+=b;break;case"object":if(Ve(b))u+=b.toTex(o);else if(Array.isArray(b))u+=b.map(function(w,N){if(Ve(w))return w.toTex(o);throw new TypeError("Template: "+h[1]+"["+N+"] is not a Node.")}).join(",");else throw new TypeError("Template: "+h[1]+" has to be a Node, String or array of Nodes");break;default:throw new TypeError("Template: "+h[1]+" has to be a Node, String or array of Nodes")}else if(Ve(b[h[2]]&&b[h[2]]))u+=b[h[2]].toTex(o);else throw new TypeError("Template: "+h[1]+"["+h[2]+"] is not a Node.")}return u+=c.slice(v),u}var f=r.prototype.toTex;return r.prototype.toTex=function(c){var s;return c&&typeof c.handler=="object"&&Me(c.handler,this.name)&&(s=c.handler[this.name](this,c)),typeof s!="undefined"?s:f.call(this,c)},r.prototype._toTex=function(c){var s=this.args.map(function(p){return p.toTex(c)}),o;rl[this.name]&&(o=rl[this.name]),n[this.name]&&(typeof n[this.name].toTex=="function"||typeof n[this.name].toTex=="object"||typeof n[this.name].toTex=="string")&&(o=n[this.name].toTex);var u;switch(typeof o){case"function":u=o(this,c);break;case"string":u=m(o,this,c);break;case"object":switch(typeof o[s.length]){case"function":u=o[s.length](this,c);break;case"string":u=m(o[s.length],this,c);break}}return typeof u!="undefined"?u:m(dN,this,c)},r.prototype.getIdentifier=function(){return this.type+":"+this.name},r},{isClass:!0,isNode:!0}),al="parse",XN=["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],YN=R(al,XN,e=>{var{typed:n,numeric:a,config:t,AccessorNode:r,ArrayNode:i,AssignmentNode:l,BlockNode:m,ConditionalNode:f,ConstantNode:c,FunctionAssignmentNode:s,FunctionNode:o,IndexNode:u,ObjectNode:p,OperatorNode:v,ParenthesisNode:h,RangeNode:b,RelationalNode:w,SymbolNode:N}=e,g=n(al,{string:function(X){return H(X,{})},"Array | Matrix":function(X){return y(X,{})},"string, Object":function(X,ae){var he=ae.nodes!==void 0?ae.nodes:{};return H(X,he)},"Array | Matrix, Object":y});function y(C){var X=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ae=X.nodes!==void 0?X.nodes:{};return be(C,function(he){if(typeof he!="string")throw new TypeError("String expected");return H(he,ae)})}var x={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},d={",":!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},A={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},S={true:!0,false:!1,null:null,undefined:void 0},O=["NaN","Infinity"];function M(){return{extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:x.NULL,nestingLevel:0,conditionalLevel:null}}function _(C,X){return C.expression.substr(C.index,X)}function E(C){return _(C,1)}function $(C){C.index++}function z(C){return C.expression.charAt(C.index-1)}function I(C){return C.expression.charAt(C.index+1)}function T(C){for(C.tokenType=x.NULL,C.token="",C.comment="";;){if(E(C)==="#")for(;E(C)!==`
17
- `&&E(C)!=="";)C.comment+=E(C),$(C);if(g.isWhitespace(E(C),C.nestingLevel))$(C);else break}if(E(C)===""){C.tokenType=x.DELIMITER;return}if(E(C)===`
18
- `&&!C.nestingLevel){C.tokenType=x.DELIMITER,C.token=E(C),$(C);return}var X=E(C),ae=_(C,2),he=_(C,3);if(he.length===3&&d[he]){C.tokenType=x.DELIMITER,C.token=he,$(C),$(C),$(C);return}if(ae.length===2&&d[ae]){C.tokenType=x.DELIMITER,C.token=ae,$(C),$(C);return}if(d[X]){C.tokenType=x.DELIMITER,C.token=X,$(C);return}if(g.isDigitDot(X)){C.tokenType=x.NUMBER;var qe=_(C,2);if(qe==="0b"||qe==="0o"||qe==="0x"){for(C.token+=E(C),$(C),C.token+=E(C),$(C);g.isHexDigit(E(C));)C.token+=E(C),$(C);if(E(C)===".")for(C.token+=".",$(C);g.isHexDigit(E(C));)C.token+=E(C),$(C);else if(E(C)==="i")for(C.token+="i",$(C);g.isDigit(E(C));)C.token+=E(C),$(C);return}if(E(C)==="."){if(C.token+=E(C),$(C),!g.isDigit(E(C))){C.tokenType=x.DELIMITER;return}}else{for(;g.isDigit(E(C));)C.token+=E(C),$(C);g.isDecimalMark(E(C),I(C))&&(C.token+=E(C),$(C))}for(;g.isDigit(E(C));)C.token+=E(C),$(C);if(E(C)==="E"||E(C)==="e"){if(g.isDigit(I(C))||I(C)==="-"||I(C)==="+"){if(C.token+=E(C),$(C),(E(C)==="+"||E(C)==="-")&&(C.token+=E(C),$(C)),!g.isDigit(E(C)))throw Ze(C,'Digit expected, got "'+E(C)+'"');for(;g.isDigit(E(C));)C.token+=E(C),$(C);if(g.isDecimalMark(E(C),I(C)))throw Ze(C,'Digit expected, got "'+E(C)+'"')}else if(I(C)===".")throw $(C),Ze(C,'Digit expected, got "'+E(C)+'"')}return}if(g.isAlpha(E(C),z(C),I(C))){for(;g.isAlpha(E(C),z(C),I(C))||g.isDigit(E(C));)C.token+=E(C),$(C);Me(A,C.token)?C.tokenType=x.DELIMITER:C.tokenType=x.SYMBOL;return}for(C.tokenType=x.UNKNOWN;E(C)!=="";)C.token+=E(C),$(C);throw Ze(C,'Syntax error in part "'+C.token+'"')}function B(C){do T(C);while(C.token===`
19
- `)}function G(C){C.nestingLevel++}function D(C){C.nestingLevel--}g.isAlpha=function(X,ae,he){return g.isValidLatinOrGreek(X)||g.isValidMathSymbol(X,he)||g.isValidMathSymbol(ae,X)},g.isValidLatinOrGreek=function(X){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(X)},g.isValidMathSymbol=function(X,ae){return/^[\uD835]$/.test(X)&&/^[\uDC00-\uDFFF]$/.test(ae)&&/^[^\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDFCC\uDFCD]$/.test(ae)},g.isWhitespace=function(X,ae){return X===" "||X===" "||X===`
20
- `&&ae>0},g.isDecimalMark=function(X,ae){return X==="."&&ae!=="/"&&ae!=="*"&&ae!=="^"},g.isDigitDot=function(X){return X>="0"&&X<="9"||X==="."},g.isDigit=function(X){return X>="0"&&X<="9"},g.isHexDigit=function(X){return X>="0"&&X<="9"||X>="a"&&X<="f"||X>="A"&&X<="F"};function H(C,X){var ae=M();ar(ae,{expression:C,extraNodes:X}),T(ae);var he=W(ae);if(ae.token!=="")throw ae.tokenType===x.DELIMITER?Pt(ae,"Unexpected operator "+ae.token):Ze(ae,'Unexpected part "'+ae.token+'"');return he}function W(C){var X,ae=[],he;for(C.token!==""&&C.token!==`
11
+ (`+Fe(S,h)+", "+Fe(y,h)+") ==> "+(this._values?Fe(this._values[A],h):"X")}return g},r.prototype.toString=function(){return Fe(this.toArray())},r.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},r.prototype.diagonal=function(h){if(h){if(_e(h)&&(h=h.toNumber()),!$e(h)||!Se(h))throw new TypeError("The parameter k must be an integer number")}else h=0;var b=h>0?h:0,w=h<0?-h:0,N=this._size[0],g=this._size[1],y=Math.min(N-w,g-b),x=[],d=[],A=[];A[0]=0;for(var S=b;S<g&&x.length<y;S++)for(var O=this._ptr[S],M=this._ptr[S+1],$=O;$<M;$++){var E=this._index[$];if(E===S-b+w){x.push(this._values[$]),d[x.length-1]=E-w;break}}return A.push(x.length),new r({values:x,index:d,ptr:A,size:[y,1]})},r.fromJSON=function(h){return new r(h)},r.diagonal=function(h,b,w,N,g){if(!Ye(h))throw new TypeError("Array expected, size parameter");if(h.length!==2)throw new Error("Only two dimensions matrix are supported");if(h=h.map(function(D){if(_e(D)&&(D=D.toNumber()),!$e(D)||!Se(D)||D<1)throw new Error("Size values must be positive integers");return D}),w){if(_e(w)&&(w=w.toNumber()),!$e(w)||!Se(w))throw new TypeError("The parameter k must be an integer number")}else w=0;var y=n,x=0;Ir(g)&&(y=t.find(n,[g,g])||n,x=t.convert(0,g));var d=w>0?w:0,A=w<0?-w:0,S=h[0],O=h[1],M=Math.min(S-A,O-d),$;if(Ye(b)){if(b.length!==M)throw new Error("Invalid value array length");$=function(H){return b[H]}}else if(De(b)){var E=b.size();if(E.length!==1||E[0]!==M)throw new Error("Invalid matrix length");$=function(H){return b.get([H])}}else $=function(){return b};for(var _=[],z=[],I=[],T=0;T<O;T++){I.push(_.length);var B=T-d;if(B>=0&&B<M){var G=$(B);y(G,x)||(z.push(B+A),_.push(G))}}return I.push(_.length),new r({values:_,index:z,ptr:I,size:[S,O]})},r.prototype.swapRows=function(h,b){if(!$e(h)||!Se(h)||!$e(b)||!Se(b))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return Je(h,this._size[0]),Je(b,this._size[0]),r._swapRows(h,b,this._size[1],this._values,this._index,this._ptr),this},r._forEachRow=function(h,b,w,N,g){for(var y=N[h],x=N[h+1],d=y;d<x;d++)g(w[d],b[d])},r._swapRows=function(h,b,w,N,g,y){for(var x=0;x<w;x++){var d=y[x],A=y[x+1],S=c(h,d,A,g),O=c(b,d,A,g);if(S<A&&O<A&&g[S]===h&&g[O]===b){if(N){var M=N[S];N[S]=N[O],N[O]=M}continue}if(S<A&&g[S]===h&&(O>=A||g[O]!==b)){var $=N?N[S]:void 0;g.splice(O,0,b),N&&N.splice(O,0,$),g.splice(O<=S?S+1:S,1),N&&N.splice(O<=S?S+1:S,1);continue}if(O<A&&g[O]===b&&(S>=A||g[S]!==h)){var E=N?N[O]:void 0;g.splice(S,0,h),N&&N.splice(S,0,E),g.splice(S<=O?O+1:O,1),N&&N.splice(S<=O?O+1:O,1)}}},r},{isClass:!0}),Ed="number",Cd=["typed"];function Od(e){var t=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(t){var n={"0b":2,"0o":8,"0x":16}[t[1]],a=t[2],r=t[3];return{input:e,radix:n,integerPart:a,fractionalPart:r}}else return null}function Dd(e){for(var t=parseInt(e.integerPart,e.radix),n=0,a=0;a<e.fractionalPart.length;a++){var r=parseInt(e.fractionalPart[a],e.radix);n+=r/Math.pow(e.radix,a+1)}var i=t+n;if(isNaN(i))throw new SyntaxError('String "'+e.input+'" is no valid number');return i}var Td=R(Ed,Cd,e=>{var{typed:t}=e,n=t("number",{"":function(){return 0},number:function(r){return r},string:function(r){if(r==="NaN")return NaN;var i=Od(r);if(i)return Dd(i);var u=0,l=r.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);l&&(u=Number(l[2]),r=l[1]);var f=Number(r);if(isNaN(f))throw new SyntaxError('String "'+r+'" is no valid number');if(l){if(f>nn(2,u)-1)throw new SyntaxError('String "'.concat(r,'" is out of range'));f>=nn(2,u-1)&&(f=f-nn(2,u))}return f},BigNumber:function(r){return r.toNumber()},Fraction:function(r){return r.valueOf()},Unit:function(r){throw new Error("Second argument with valueless unit expected")},null:function(r){return 0},"Unit, string | Unit":function(r,i){return r.toNumber(i)},"Array | Matrix":function(r){return we(r,this)}});return n.fromJSON=function(a){return parseFloat(a.value)},n}),tu="string",Bd=["typed"],$d=R(tu,Bd,e=>{var{typed:t}=e;return t(tu,{"":function(){return""},number:Vt,null:function(a){return"null"},boolean:function(a){return a+""},string:function(a){return a},"Array | Matrix":function(a){return we(a,this)},any:function(a){return String(a)}})}),nu="boolean",_d=["typed"],Id=R(nu,_d,e=>{var{typed:t}=e;return t(nu,{"":function(){return!1},boolean:function(a){return a},number:function(a){return!!a},null:function(a){return!1},BigNumber:function(a){return!a.isZero()},string:function(a){var r=a.toLowerCase();if(r==="true")return!0;if(r==="false")return!1;var i=Number(a);if(a!==""&&!isNaN(i))return!!i;throw new Error('Cannot convert "'+a+'" to a boolean')},"Array | Matrix":function(a){return we(a,this)}})}),qd="bignumber",Rd=["typed","BigNumber"],Fd=R(qd,Rd,e=>{var{typed:t,BigNumber:n}=e;return t("bignumber",{"":function(){return new n(0)},number:function(r){return new n(r+"")},string:function(r){var i=r.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(i){var u=i[2],l=n(i[1]),f=new n(2).pow(Number(u));if(l.gt(f.sub(1)))throw new SyntaxError('String "'.concat(r,'" is out of range'));var c=new n(2).pow(Number(u)-1);return l.gte(c)?l.sub(f):l}return new n(r)},BigNumber:function(r){return r},Fraction:function(r){return new n(r.n).div(r.d).times(r.s)},null:function(r){return new n(0)},"Array | Matrix":function(r){return we(r,this)}})}),zd="complex",Pd=["typed","Complex"],Ud=R(zd,Pd,e=>{var{typed:t,Complex:n}=e;return t("complex",{"":function(){return n.ZERO},number:function(r){return new n(r,0)},"number, number":function(r,i){return new n(r,i)},"BigNumber, BigNumber":function(r,i){return new n(r.toNumber(),i.toNumber())},Fraction:function(r){return new n(r.valueOf(),0)},Complex:function(r){return r.clone()},string:function(r){return n(r)},null:function(r){return n(0)},Object:function(r){if("re"in r&&"im"in r)return new n(r.re,r.im);if("r"in r&&"phi"in r||"abs"in r&&"arg"in r)return new n(r);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(r){return we(r,this)}})}),Ld="fraction",kd=["typed","Fraction"],Hd=R(Ld,kd,e=>{var{typed:t,Fraction:n}=e;return t("fraction",{number:function(r){if(!isFinite(r)||isNaN(r))throw new Error(r+" cannot be represented as a fraction");return new n(r)},string:function(r){return new n(r)},"number, number":function(r,i){return new n(r,i)},null:function(r){return new n(0)},BigNumber:function(r){return new n(r.toString())},Fraction:function(r){return r},Object:function(r){return new n(r)},"Array | Matrix":function(r){return we(r,this)}})}),au="matrix",Gd=["typed","Matrix","DenseMatrix","SparseMatrix"],Vd=R(au,Gd,e=>{var{typed:t,Matrix:n,DenseMatrix:a,SparseMatrix:r}=e;return t(au,{"":function(){return i([])},string:function(l){return i([],l)},"string, string":function(l,f){return i([],l,f)},Array:function(l){return i(l)},Matrix:function(l){return i(l,l.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(u,l,f){if(l==="dense"||l==="default"||l===void 0)return new a(u,f);if(l==="sparse")return new r(u,f);throw new TypeError("Unknown matrix type "+JSON.stringify(l)+".")}}),iu="matrixFromFunction",Zd=["typed","matrix","isZero"],Xd=R(iu,Zd,e=>{var{typed:t,matrix:n,isZero:a}=e;return t(iu,{"Array | Matrix, function, string, string":function(u,l,f,c){return r(u,l,f,c)},"Array | Matrix, function, string":function(u,l,f){return r(u,l,f)},"Matrix, function":function(u,l){return r(u,l,"dense")},"Array, function":function(u,l){return r(u,l,"dense").toArray()},"Array | Matrix, string, function":function(u,l,f){return r(u,f,l)},"Array | Matrix, string, string, function":function(u,l,f,c){return r(u,c,l,f)}});function r(i,u,l,f){var c;return f!==void 0?c=n(l,f):c=n(l),c.resize(i),c.forEach(function(o,s){var m=u(s);a(m)||c.set(s,m)}),c}}),ou="matrixFromRows",Yd=["typed","matrix","flatten","size"],Wd=R(ou,Yd,e=>{var{typed:t,matrix:n,flatten:a,size:r}=e;return t(ou,{"...Array":function(f){return i(f)},"...Matrix":function(f){return n(i(f.map(c=>c.toArray())))}});function i(l){if(l.length===0)throw new TypeError("At least one row is needed to construct a matrix.");var f=u(l[0]),c=[];for(var o of l){var s=u(o);if(s!==f)throw new TypeError("The vectors had different length: "+(f|0)+" ≠ "+(s|0));c.push(a(o))}return c}function u(l){var f=r(l);if(f.length===1)return f[0];if(f.length===2){if(f[0]===1)return f[1];if(f[1]===1)return f[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),su="matrixFromColumns",Jd=["typed","matrix","flatten","size"],Qd=R(su,Jd,e=>{var{typed:t,matrix:n,flatten:a,size:r}=e;return t(su,{"...Array":function(f){return i(f)},"...Matrix":function(f){return n(i(f.map(c=>c.toArray())))}});function i(l){if(l.length===0)throw new TypeError("At least one column is needed to construct a matrix.");for(var f=u(l[0]),c=[],o=0;o<f;o++)c[o]=[];for(var s of l){var m=u(s);if(m!==f)throw new TypeError("The vectors had different length: "+(f|0)+" ≠ "+(m|0));for(var p=a(s),v=0;v<f;v++)c[v].push(p[v])}return c}function u(l){var f=r(l);if(f.length===1)return f[0];if(f.length===2){if(f[0]===1)return f[1];if(f[1]===1)return f[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),uu="splitUnit",Kd=["typed"],jd=R(uu,Kd,e=>{var{typed:t}=e;return t(uu,{"Unit, Array":function(a,r){return a.splitUnit(r)}})}),cu="unaryMinus",eg=["typed"],rg=R(cu,eg,e=>{var{typed:t}=e;return t(cu,{number:jo,Complex:function(a){return a.neg()},BigNumber:function(a){return a.neg()},Fraction:function(a){return a.neg()},Unit:function(a){var r=a.clone();return r.value=this(a.value),r},"Array | Matrix":function(a){return we(a,this)}})}),fu="unaryPlus",tg=["typed","config","BigNumber"],ng=R(fu,tg,e=>{var{typed:t,config:n,BigNumber:a}=e;return t(fu,{number:es,Complex:function(i){return i},BigNumber:function(i){return i},Fraction:function(i){return i},Unit:function(i){return i.clone()},"Array | Matrix":function(i){return we(i,this)},"boolean | string":function(i){return n.number==="BigNumber"?new a(+i):+i}})}),lu="abs",ag=["typed"],ig=R(lu,ag,e=>{var{typed:t}=e;return t(lu,{number:Jo,Complex:function(a){return a.abs()},BigNumber:function(a){return a.abs()},Fraction:function(a){return a.abs()},"Array | Matrix":function(a){return we(a,this)},Unit:function(a){return a.abs()}})}),mu="apply",og=["typed","isInteger"],pu=R(mu,og,e=>{var{typed:t,isInteger:n}=e;return t(mu,{"Array | Matrix, number | BigNumber, function":function(r,i,u){if(!n(i))throw new TypeError("Integer number expected for dimension");var l=Array.isArray(r)?Ue(r):r.size();if(i<0||i>=l.length)throw new et(i,l.length);return De(r)?r.create(Oa(r.valueOf(),i,u)):Oa(r,i,u)}})});function Oa(e,t,n){var a,r,i;if(t<=0)if(Array.isArray(e[0])){for(i=sg(e),r=[],a=0;a<i.length;a++)r[a]=Oa(i[a],t-1,n);return r}else return n(e);else{for(r=[],a=0;a<e.length;a++)r[a]=Oa(e[a],t-1,n);return r}}function sg(e){var t=e.length,n=e[0].length,a,r,i=[];for(r=0;r<n;r++){var u=[];for(a=0;a<t;a++)u.push(e[a][r]);i.push(u)}return i}var vu="addScalar",ug=["typed"],cg=R(vu,ug,e=>{var{typed:t}=e;return t(vu,{"number, number":Qo,"Complex, Complex":function(a,r){return a.add(r)},"BigNumber, BigNumber":function(a,r){return a.plus(r)},"Fraction, Fraction":function(a,r){return a.add(r)},"Unit, Unit":function(a,r){if(a.value===null||a.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(r.value===null||r.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!a.equalBase(r))throw new Error("Units do not match");var i=a.clone();return i.value=this(i.value,r.value),i.fixPrefix=!1,i}})}),hu="cbrt",fg=["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],lg=R(hu,fg,e=>{var{config:t,typed:n,isNegative:a,unaryMinus:r,matrix:i,Complex:u,BigNumber:l,Fraction:f}=e;return n(hu,{number:Rn,Complex:c,"Complex, boolean":c,BigNumber:function(m){return m.cbrt()},Unit:o,"Array | Matrix":function(m){return we(m,this)}});function c(s,m){var p=s.arg()/3,v=s.abs(),h=new u(Rn(v),0).mul(new u(0,p).exp());if(m){var b=[h,new u(Rn(v),0).mul(new u(0,p+Math.PI*2/3).exp()),new u(Rn(v),0).mul(new u(0,p-Math.PI*2/3).exp())];return t.matrix==="Array"?b:i(b)}else return h}function o(s){if(s.value&&Tr(s.value)){var m=s.clone();return m.value=1,m=m.pow(1/3),m.value=c(s.value),m}else{var p=a(s.value);p&&(s.value=r(s.value));var v;_e(s.value)?v=new l(1).div(3):xr(s.value)?v=new f(1,3):v=1/3;var h=s.pow(v);return p&&(h.value=r(h.value)),h}}}),mg="algorithm11",pg=["typed","equalScalar"],Nr=R(mg,pg,e=>{var{typed:t,equalScalar:n}=e;return function(r,i,u,l){var f=r._values,c=r._index,o=r._ptr,s=r._size,m=r._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=s[0],v=s[1],h,b=n,w=0,N=u;typeof m=="string"&&(h=m,b=t.find(n,[h,h]),w=t.convert(0,h),i=t.convert(i,h),N=t.find(u,[h,h]));for(var g=[],y=[],x=[],d=0;d<v;d++){x[d]=y.length;for(var A=o[d],S=o[d+1],O=A;O<S;O++){var M=c[O],$=l?N(i,f[O]):N(f[O],i);b($,w)||(y.push(M),g.push($))}}return x[v]=y.length,r.createSparseMatrix({values:g,index:y,ptr:x,size:[p,v],datatype:h})}}),vg="algorithm12",hg=["typed","DenseMatrix"],yr=R(vg,hg,e=>{var{typed:t,DenseMatrix:n}=e;return function(r,i,u,l){var f=r._values,c=r._index,o=r._ptr,s=r._size,m=r._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=s[0],v=s[1],h,b=u;typeof m=="string"&&(h=m,i=t.convert(i,h),b=t.find(u,[h,h]));for(var w=[],N=[],g=[],y=0;y<v;y++){for(var x=y+1,d=o[y],A=o[y+1],S=d;S<A;S++){var O=c[S];N[O]=f[S],g[O]=x}for(var M=0;M<p;M++)y===0&&(w[M]=[]),g[M]===x?w[M][y]=l?b(i,N[M]):b(N[M],i):w[M][y]=l?b(i,0):b(0,i)}return new n({data:w,size:[p,v],datatype:h})}}),dg="algorithm14",gg=["typed"],Ve=R(dg,gg,e=>{var{typed:t}=e;return function(r,i,u,l){var f=r._data,c=r._size,o=r._datatype,s,m=u;typeof o=="string"&&(s=o,i=t.convert(i,s),m=t.find(u,[s,s]));var p=c.length>0?n(m,0,c,c[0],f,i,l):[];return r.createDenseMatrix({data:p,size:Oe(c),datatype:s})};function n(a,r,i,u,l,f,c){var o=[];if(r===i.length-1)for(var s=0;s<u;s++)o[s]=c?a(f,l[s]):a(l[s],f);else for(var m=0;m<u;m++)o[m]=n(a,r+1,i,i[r+1],l[m],f,c);return o}}),Ai="ceil",yg=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],xg=R(Ai,["typed","config","round"],e=>{var{typed:t,config:n,round:a}=e;return t(Ai,{number:function(i){return Fr(i,a(i),n.epsilon)?a(i):Math.ceil(i)},"number, number":function(i,u){if(Fr(i,a(i,u),n.epsilon))return a(i,u);var[l,f]="".concat(i,"e").split("e"),c=Math.ceil(Number("".concat(l,"e").concat(Number(f)+u)));return[l,f]="".concat(c,"e").split("e"),Number("".concat(l,"e").concat(Number(f)-u))}})}),bg=R(Ai,yg,e=>{var{typed:t,config:n,round:a,matrix:r,equalScalar:i,zeros:u,DenseMatrix:l}=e,f=Nr({typed:t,equalScalar:i}),c=yr({typed:t,DenseMatrix:l}),o=Ve({typed:t}),s=xg({typed:t,config:n,round:a});return t("ceil",{number:s.signatures.number,"number,number":s.signatures["number,number"],Complex:function(p){return p.ceil()},"Complex, number":function(p,v){return p.ceil(v)},"Complex, BigNumber":function(p,v){return p.ceil(v.toNumber())},BigNumber:function(p){return ct(p,a(p),n.epsilon)?a(p):p.ceil()},"BigNumber, BigNumber":function(p,v){return ct(p,a(p,v),n.epsilon)?a(p,v):p.toDecimalPlaces(v.toNumber(),Rt.ROUND_CEIL)},Fraction:function(p){return p.ceil()},"Fraction, number":function(p,v){return p.ceil(v)},"Fraction, BigNumber":function(p,v){return p.ceil(v.toNumber())},"Array | Matrix":function(p){return we(p,this)},"Array, number | BigNumber":function(p,v){return we(p,h=>this(h,v))},"SparseMatrix, number | BigNumber":function(p,v){return f(p,v,this,!1)},"DenseMatrix, number | BigNumber":function(p,v){return o(p,v,this,!1)},"number | Complex | Fraction | BigNumber, Array":function(p,v){return o(r(v),p,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(p,v){return i(p,0)?u(v.size(),v.storage()):v.storage()==="dense"?o(v,p,this,!0):c(v,p,this,!0)}})}),du="cube",wg=["typed"],Ng=R(du,wg,e=>{var{typed:t}=e;return t(du,{number:rs,Complex:function(a){return a.mul(a).mul(a)},BigNumber:function(a){return a.times(a).times(a)},Fraction:function(a){return a.pow(3)},"Array | Matrix":function(a){return we(a,this)},Unit:function(a){return a.pow(3)}})}),gu="exp",Mg=["typed"],Ag=R(gu,Mg,e=>{var{typed:t}=e;return t(gu,{number:ts,Complex:function(a){return a.exp()},BigNumber:function(a){return a.exp()},"Array | Matrix":function(a){return we(a,this)}})}),yu="expm1",Sg=["typed","Complex"],Eg=R(yu,Sg,e=>{var{typed:t,Complex:n}=e;return t(yu,{number:ns,Complex:function(r){var i=Math.exp(r.re);return new n(i*Math.cos(r.im)-1,i*Math.sin(r.im))},BigNumber:function(r){return r.exp().minus(1)},"Array | Matrix":function(r){return we(r,this)}})}),Si="fix",Cg=["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],Og=R(Si,["typed","ceil","floor"],e=>{var{typed:t,ceil:n,floor:a}=e;return t(Si,{number:function(i){return i>0?a(i):n(i)},"number, number":function(i,u){return i>0?a(i,u):n(i,u)}})}),Dg=R(Si,Cg,e=>{var{typed:t,Complex:n,matrix:a,ceil:r,floor:i,equalScalar:u,zeros:l,DenseMatrix:f}=e,c=yr({typed:t,DenseMatrix:f}),o=Ve({typed:t}),s=Og({typed:t,ceil:r,floor:i});return t("fix",{number:s.signatures.number,"number, number | BigNumber":s.signatures["number,number"],Complex:function(p){return new n(p.re>0?Math.floor(p.re):Math.ceil(p.re),p.im>0?Math.floor(p.im):Math.ceil(p.im))},"Complex, number":function(p,v){return new n(p.re>0?i(p.re,v):r(p.re,v),p.im>0?i(p.im,v):r(p.im,v))},"Complex, BigNumber":function(p,v){var h=v.toNumber();return new n(p.re>0?i(p.re,h):r(p.re,h),p.im>0?i(p.im,h):r(p.im,h))},BigNumber:function(p){return p.isNegative()?r(p):i(p)},"BigNumber, number | BigNumber":function(p,v){return p.isNegative()?r(p,v):i(p,v)},Fraction:function(p){return p.s<0?p.ceil():p.floor()},"Fraction, number | BigNumber":function(p,v){return p.s<0?r(p,v):i(p,v)},"Array | Matrix":function(p){return we(p,this)},"Array | Matrix, number | BigNumber":function(p,v){return we(p,h=>this(h,v))},"number | Complex | Fraction | BigNumber, Array":function(p,v){return o(a(v),p,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(p,v){return u(p,0)?l(v.size(),v.storage()):v.storage()==="dense"?o(v,p,this,!0):c(v,p,this,!0)}})}),Ei="floor",Tg=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],Bg=R(Ei,["typed","config","round"],e=>{var{typed:t,config:n,round:a}=e;return t(Ei,{number:function(i){return Fr(i,a(i),n.epsilon)?a(i):Math.floor(i)},"number, number":function(i,u){if(Fr(i,a(i,u),n.epsilon))return a(i,u);var[l,f]="".concat(i,"e").split("e"),c=Math.floor(Number("".concat(l,"e").concat(Number(f)+u)));return[l,f]="".concat(c,"e").split("e"),Number("".concat(l,"e").concat(Number(f)-u))}})}),$g=R(Ei,Tg,e=>{var{typed:t,config:n,round:a,matrix:r,equalScalar:i,zeros:u,DenseMatrix:l}=e,f=Nr({typed:t,equalScalar:i}),c=yr({typed:t,DenseMatrix:l}),o=Ve({typed:t}),s=Bg({typed:t,config:n,round:a});return t("floor",{number:s.signatures.number,"number,number":s.signatures["number,number"],Complex:function(p){return p.floor()},"Complex, number":function(p,v){return p.floor(v)},"Complex, BigNumber":function(p,v){return p.floor(v.toNumber())},BigNumber:function(p){return ct(p,a(p),n.epsilon)?a(p):p.floor()},"BigNumber, BigNumber":function(p,v){return ct(p,a(p,v),n.epsilon)?a(p,v):p.toDecimalPlaces(v.toNumber(),Rt.ROUND_FLOOR)},Fraction:function(p){return p.floor()},"Fraction, number":function(p,v){return p.floor(v)},"Fraction, BigNumber":function(p,v){return p.floor(v.toNumber())},"Array | Matrix":function(p){return we(p,this)},"Array, number | BigNumber":function(p,v){return we(p,h=>this(h,v))},"SparseMatrix, number | BigNumber":function(p,v){return f(p,v,this,!1)},"DenseMatrix, number | BigNumber":function(p,v){return o(p,v,this,!1)},"number | Complex | Fraction | BigNumber, Array":function(p,v){return o(r(v),p,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(p,v){return i(p,0)?u(v.size(),v.storage()):v.storage()==="dense"?o(v,p,this,!0):c(v,p,this,!0)}})}),_g="algorithm01",Ig=["typed"],Ft=R(_g,Ig,e=>{var{typed:t}=e;return function(a,r,i,u){var l=a._data,f=a._size,c=a._datatype,o=r._values,s=r._index,m=r._ptr,p=r._size,v=r._datatype;if(f.length!==p.length)throw new ze(f.length,p.length);if(f[0]!==p[0]||f[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+p+")");if(!o)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h=f[0],b=f[1],w=typeof c=="string"&&c===v?c:void 0,N=w?t.find(i,[w,w]):i,g,y,x=[];for(g=0;g<h;g++)x[g]=[];var d=[],A=[];for(y=0;y<b;y++){for(var S=y+1,O=m[y],M=m[y+1],$=O;$<M;$++)g=s[$],d[g]=u?N(o[$],l[g][y]):N(l[g][y],o[$]),A[g]=S;for(g=0;g<h;g++)A[g]===S?x[g][y]=d[g]:x[g][y]=l[g][y]}return a.createDenseMatrix({data:x,size:[h,b],datatype:w})}}),qg="algorithm04",Rg=["typed","equalScalar"],Ci=R(qg,Rg,e=>{var{typed:t,equalScalar:n}=e;return function(r,i,u){var l=r._values,f=r._index,c=r._ptr,o=r._size,s=r._datatype,m=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(o.length!==h.length)throw new ze(o.length,h.length);if(o[0]!==h[0]||o[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+h+")");var w=o[0],N=o[1],g,y=n,x=0,d=u;typeof s=="string"&&s===b&&(g=s,y=t.find(n,[g,g]),x=t.convert(0,g),d=t.find(u,[g,g]));var A=l&&m?[]:void 0,S=[],O=[],M=l&&m?[]:void 0,$=l&&m?[]:void 0,E=[],_=[],z,I,T,B,G;for(I=0;I<N;I++){O[I]=S.length;var D=I+1;for(B=c[I],G=c[I+1],T=B;T<G;T++)z=f[T],S.push(z),E[z]=D,M&&(M[z]=l[T]);for(B=v[I],G=v[I+1],T=B;T<G;T++)if(z=p[T],E[z]===D){if(M){var H=d(M[z],m[T]);y(H,x)?E[z]=null:M[z]=H}}else S.push(z),_[z]=D,$&&($[z]=m[T]);if(M&&$)for(T=O[I];T<S.length;)z=S[T],E[z]===D?(A[T]=M[z],T++):_[z]===D?(A[T]=$[z],T++):S.splice(T,1)}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),Fg="algorithm10",zg=["typed","DenseMatrix"],Yt=R(Fg,zg,e=>{var{typed:t,DenseMatrix:n}=e;return function(r,i,u,l){var f=r._values,c=r._index,o=r._ptr,s=r._size,m=r._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=s[0],v=s[1],h,b=u;typeof m=="string"&&(h=m,i=t.convert(i,h),b=t.find(u,[h,h]));for(var w=[],N=[],g=[],y=0;y<v;y++){for(var x=y+1,d=o[y],A=o[y+1],S=d;S<A;S++){var O=c[S];N[O]=f[S],g[O]=x}for(var M=0;M<p;M++)y===0&&(w[M]=[]),g[M]===x?w[M][y]=l?b(i,N[M]):b(N[M],i):w[M][y]=i}return new n({data:w,size:[p,v],datatype:h})}}),Pg="algorithm13",Ug=["typed"],er=R(Pg,Ug,e=>{var{typed:t}=e;return function(r,i,u){var l=r._data,f=r._size,c=r._datatype,o=i._data,s=i._size,m=i._datatype,p=[];if(f.length!==s.length)throw new ze(f.length,s.length);for(var v=0;v<f.length;v++){if(f[v]!==s[v])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+s+")");p[v]=f[v]}var h,b=u;typeof c=="string"&&c===m&&(h=c,b=t.find(u,[h,h]));var w=p.length>0?n(b,0,p,p[0],l,o):[];return r.createDenseMatrix({data:w,size:p,datatype:h})};function n(a,r,i,u,l,f){var c=[];if(r===i.length-1)for(var o=0;o<u;o++)c[o]=a(l[o],f[o]);else for(var s=0;s<u;s++)c[s]=n(a,r+1,i,i[r+1],l[s],f[s]);return c}}),xu="gcd",Lg=["typed","matrix","equalScalar","BigNumber","DenseMatrix"],kg=R(xu,Lg,e=>{var{typed:t,matrix:n,equalScalar:a,BigNumber:r,DenseMatrix:i}=e,u=Ft({typed:t}),l=Ci({typed:t,equalScalar:a}),f=Yt({typed:t,DenseMatrix:i}),c=er({typed:t}),o=Ve({typed:t});return t(xu,{"number, number":as,"BigNumber, BigNumber":s,"Fraction, Fraction":function(p,v){return p.gcd(v)},"SparseMatrix, SparseMatrix":function(p,v){return l(p,v,this)},"SparseMatrix, DenseMatrix":function(p,v){return u(v,p,this,!0)},"DenseMatrix, SparseMatrix":function(p,v){return u(p,v,this,!1)},"DenseMatrix, DenseMatrix":function(p,v){return c(p,v,this)},"Array, Array":function(p,v){return this(n(p),n(v)).valueOf()},"Array, Matrix":function(p,v){return this(n(p),v)},"Matrix, Array":function(p,v){return this(p,n(v))},"SparseMatrix, number | BigNumber":function(p,v){return f(p,v,this,!1)},"DenseMatrix, number | BigNumber":function(p,v){return o(p,v,this,!1)},"number | BigNumber, SparseMatrix":function(p,v){return f(v,p,this,!0)},"number | BigNumber, DenseMatrix":function(p,v){return o(v,p,this,!0)},"Array, number | BigNumber":function(p,v){return o(n(p),v,this,!1).valueOf()},"number | BigNumber, Array":function(p,v){return o(n(v),p,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(p,v,h){for(var b=this(p,v),w=0;w<h.length;w++)b=this(b,h[w]);return b}});function s(m,p){if(!m.isInt()||!p.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var v=new r(0);!p.isZero();){var h=m.mod(p);m=p,p=h}return m.lt(v)?m.neg():m}}),Hg="algorithm02",Gg=["typed","equalScalar"],nt=R(Hg,Gg,e=>{var{typed:t,equalScalar:n}=e;return function(r,i,u,l){var f=r._data,c=r._size,o=r._datatype,s=i._values,m=i._index,p=i._ptr,v=i._size,h=i._datatype;if(c.length!==v.length)throw new ze(c.length,v.length);if(c[0]!==v[0]||c[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+v+")");if(!s)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var b=c[0],w=c[1],N,g=n,y=0,x=u;typeof o=="string"&&o===h&&(N=o,g=t.find(n,[N,N]),y=t.convert(0,N),x=t.find(u,[N,N]));for(var d=[],A=[],S=[],O=0;O<w;O++){S[O]=A.length;for(var M=p[O],$=p[O+1],E=M;E<$;E++){var _=m[E],z=l?x(s[E],f[_][O]):x(f[_][O],s[E]);g(z,y)||(A.push(_),d.push(z))}}return S[w]=A.length,i.createSparseMatrix({values:d,index:A,ptr:S,size:[b,w],datatype:N})}}),Vg="algorithm06",Zg=["typed","equalScalar"],Da=R(Vg,Zg,e=>{var{typed:t,equalScalar:n}=e;return function(r,i,u){var l=r._values,f=r._size,c=r._datatype,o=i._values,s=i._size,m=i._datatype;if(f.length!==s.length)throw new ze(f.length,s.length);if(f[0]!==s[0]||f[1]!==s[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+s+")");var p=f[0],v=f[1],h,b=n,w=0,N=u;typeof c=="string"&&c===m&&(h=c,b=t.find(n,[h,h]),w=t.convert(0,h),N=t.find(u,[h,h]));for(var g=l&&o?[]:void 0,y=[],x=[],d=g?[]:void 0,A=[],S=[],O=0;O<v;O++){x[O]=y.length;var M=O+1;if(Yo(r,O,A,d,S,M,y,N),Yo(i,O,A,d,S,M,y,N),d)for(var $=x[O];$<y.length;){var E=y[$];if(S[E]===M){var _=d[E];b(_,w)?y.splice($,1):(g.push(_),$++)}else y.splice($,1)}else for(var z=x[O];z<y.length;){var I=y[z];S[I]!==M?y.splice(z,1):z++}}return x[v]=y.length,r.createSparseMatrix({values:g,index:y,ptr:x,size:[p,v],datatype:h})}}),bu="lcm",Xg=["typed","matrix","equalScalar"],Yg=R(bu,Xg,e=>{var{typed:t,matrix:n,equalScalar:a}=e,r=nt({typed:t,equalScalar:a}),i=Da({typed:t,equalScalar:a}),u=Nr({typed:t,equalScalar:a}),l=er({typed:t}),f=Ve({typed:t});return t(bu,{"number, number":is,"BigNumber, BigNumber":c,"Fraction, Fraction":function(s,m){return s.lcm(m)},"SparseMatrix, SparseMatrix":function(s,m){return i(s,m,this)},"SparseMatrix, DenseMatrix":function(s,m){return r(m,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,m){return r(s,m,this,!1)},"DenseMatrix, DenseMatrix":function(s,m){return l(s,m,this)},"Array, Array":function(s,m){return this(n(s),n(m)).valueOf()},"Array, Matrix":function(s,m){return this(n(s),m)},"Matrix, Array":function(s,m){return this(s,n(m))},"SparseMatrix, number | BigNumber":function(s,m){return u(s,m,this,!1)},"DenseMatrix, number | BigNumber":function(s,m){return f(s,m,this,!1)},"number | BigNumber, SparseMatrix":function(s,m){return u(m,s,this,!0)},"number | BigNumber, DenseMatrix":function(s,m){return f(m,s,this,!0)},"Array, number | BigNumber":function(s,m){return f(n(s),m,this,!1).valueOf()},"number | BigNumber, Array":function(s,m){return f(n(m),s,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(s,m,p){for(var v=this(s,m),h=0;h<p.length;h++)v=this(v,p[h]);return v}});function c(o,s){if(!o.isInt()||!s.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(o.isZero())return o;if(s.isZero())return s;for(var m=o.times(s);!s.isZero();){var p=s;s=o.mod(p),o=p}return m.div(o).abs()}}),wu="log10",Wg=["typed","config","Complex"],Jg=R(wu,Wg,e=>{var{typed:t,config:n,Complex:a}=e;return t(wu,{number:function(i){return i>=0||n.predictable?os(i):new a(i,0).log().div(Math.LN10)},Complex:function(i){return new a(i).log().div(Math.LN10)},BigNumber:function(i){return!i.isNegative()||n.predictable?i.log():new a(i.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(i){return we(i,this)}})}),Nu="log2",Qg=["typed","config","Complex"],Kg=R(Nu,Qg,e=>{var{typed:t,config:n,Complex:a}=e;return t(Nu,{number:function(u){return u>=0||n.predictable?ss(u):r(new a(u,0))},Complex:r,BigNumber:function(u){return!u.isNegative()||n.predictable?u.log(2):r(new a(u.toNumber(),0))},"Array | Matrix":function(u){return we(u,this)}});function r(i){var u=Math.sqrt(i.re*i.re+i.im*i.im);return new a(Math.log2?Math.log2(u):Math.log(u)/Math.LN2,Math.atan2(i.im,i.re)/Math.LN2)}}),jg="algorithm03",ey=["typed"],Br=R(jg,ey,e=>{var{typed:t}=e;return function(a,r,i,u){var l=a._data,f=a._size,c=a._datatype,o=r._values,s=r._index,m=r._ptr,p=r._size,v=r._datatype;if(f.length!==p.length)throw new ze(f.length,p.length);if(f[0]!==p[0]||f[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+p+")");if(!o)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h=f[0],b=f[1],w,N=0,g=i;typeof c=="string"&&c===v&&(w=c,N=t.convert(0,w),g=t.find(i,[w,w]));for(var y=[],x=0;x<h;x++)y[x]=[];for(var d=[],A=[],S=0;S<b;S++){for(var O=S+1,M=m[S],$=m[S+1],E=M;E<$;E++){var _=s[E];d[_]=u?g(o[E],l[_][S]):g(l[_][S],o[E]),A[_]=O}for(var z=0;z<h;z++)A[z]===O?y[z][S]=d[z]:y[z][S]=u?g(N,l[z][S]):g(l[z][S],N)}return a.createDenseMatrix({data:y,size:[h,b],datatype:w})}}),ry="algorithm05",ty=["typed","equalScalar"],Ta=R(ry,ty,e=>{var{typed:t,equalScalar:n}=e;return function(r,i,u){var l=r._values,f=r._index,c=r._ptr,o=r._size,s=r._datatype,m=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(o.length!==h.length)throw new ze(o.length,h.length);if(o[0]!==h[0]||o[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+h+")");var w=o[0],N=o[1],g,y=n,x=0,d=u;typeof s=="string"&&s===b&&(g=s,y=t.find(n,[g,g]),x=t.convert(0,g),d=t.find(u,[g,g]));var A=l&&m?[]:void 0,S=[],O=[],M=A?[]:void 0,$=A?[]:void 0,E=[],_=[],z,I,T,B;for(I=0;I<N;I++){O[I]=S.length;var G=I+1;for(T=c[I],B=c[I+1];T<B;T++)z=f[T],S.push(z),E[z]=G,M&&(M[z]=l[T]);for(T=v[I],B=v[I+1];T<B;T++)z=p[T],E[z]!==G&&S.push(z),_[z]=G,$&&($[z]=m[T]);if(A)for(T=O[I];T<S.length;){z=S[T];var D=E[z],H=_[z];if(D===G||H===G){var W=D===G?M[z]:x,j=H===G?$[z]:x,V=d(W,j);y(V,x)?S.splice(T,1):(A.push(V),T++)}}}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),Mu="mod",ny=["typed","matrix","equalScalar","DenseMatrix"],ay=R(Mu,ny,e=>{var{typed:t,matrix:n,equalScalar:a,DenseMatrix:r}=e,i=nt({typed:t,equalScalar:a}),u=Br({typed:t}),l=Ta({typed:t,equalScalar:a}),f=Nr({typed:t,equalScalar:a}),c=yr({typed:t,DenseMatrix:r}),o=er({typed:t}),s=Ve({typed:t});return t(Mu,{"number, number":us,"BigNumber, BigNumber":function(p,v){if(v.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return v.isZero()?p:p.mod(v)},"Fraction, Fraction":function(p,v){if(v.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return p.compare(0)>=0?p.mod(v):p.mod(v).add(v).mod(v)},"SparseMatrix, SparseMatrix":function(p,v){return l(p,v,this,!1)},"SparseMatrix, DenseMatrix":function(p,v){return i(v,p,this,!0)},"DenseMatrix, SparseMatrix":function(p,v){return u(p,v,this,!1)},"DenseMatrix, DenseMatrix":function(p,v){return o(p,v,this)},"Array, Array":function(p,v){return this(n(p),n(v)).valueOf()},"Array, Matrix":function(p,v){return this(n(p),v)},"Matrix, Array":function(p,v){return this(p,n(v))},"SparseMatrix, any":function(p,v){return f(p,v,this,!1)},"DenseMatrix, any":function(p,v){return s(p,v,this,!1)},"any, SparseMatrix":function(p,v){return c(v,p,this,!0)},"any, DenseMatrix":function(p,v){return s(v,p,this,!0)},"Array, any":function(p,v){return s(n(p),v,this,!1).valueOf()},"any, Array":function(p,v){return s(n(v),p,this,!0).valueOf()}})}),iy="multiplyScalar",oy=["typed"],sy=R(iy,oy,e=>{var{typed:t}=e;return t("multiplyScalar",{"number, number":Ko,"Complex, Complex":function(a,r){return a.mul(r)},"BigNumber, BigNumber":function(a,r){return a.times(r)},"Fraction, Fraction":function(a,r){return a.mul(r)},"number | Fraction | BigNumber | Complex, Unit":function(a,r){var i=r.clone();return i.value=i.value===null?i._normalize(a):this(i.value,a),i},"Unit, number | Fraction | BigNumber | Complex":function(a,r){var i=a.clone();return i.value=i.value===null?i._normalize(r):this(i.value,r),i},"Unit, Unit":function(a,r){return a.multiply(r)}})}),Au="multiply",uy=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],cy=R(Au,uy,e=>{var{typed:t,matrix:n,addScalar:a,multiplyScalar:r,equalScalar:i,dot:u}=e,l=Nr({typed:t,equalScalar:i}),f=Ve({typed:t});function c(x,d){switch(x.length){case 1:switch(d.length){case 1:if(x[0]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(x[0]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+x[0]+") must match Matrix rows ("+d[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+d.length+" dimensions)")}break;case 2:switch(d.length){case 1:if(x[1]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+x[1]+") must match Vector length ("+d[0]+")");break;case 2:if(x[1]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+x[1]+") must match Matrix B rows ("+d[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+d.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+x.length+" dimensions)")}}function o(x,d,A){if(A===0)throw new Error("Cannot multiply two empty vectors");return u(x,d)}function s(x,d){if(d.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return m(x,d)}function m(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._data,$=d._size,E=d._datatype,_=S[0],z=$[1],I,T=a,B=r;O&&E&&O===E&&typeof O=="string"&&(I=O,T=t.find(a,[I,I]),B=t.find(r,[I,I]));for(var G=[],D=0;D<z;D++){for(var H=B(A[0],M[0][D]),W=1;W<_;W++)H=T(H,B(A[W],M[W][D]));G[D]=H}return x.createDenseMatrix({data:G,size:[z],datatype:I})}var p=t("_multiplyMatrixVector",{"DenseMatrix, any":h,"SparseMatrix, any":N}),v=t("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":b,"DenseMatrix, SparseMatrix":w,"SparseMatrix, DenseMatrix":g,"SparseMatrix, SparseMatrix":y});function h(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._data,$=d._datatype,E=S[0],_=S[1],z,I=a,T=r;O&&$&&O===$&&typeof O=="string"&&(z=O,I=t.find(a,[z,z]),T=t.find(r,[z,z]));for(var B=[],G=0;G<E;G++){for(var D=A[G],H=T(D[0],M[0]),W=1;W<_;W++)H=I(H,T(D[W],M[W]));B[G]=H}return x.createDenseMatrix({data:B,size:[E],datatype:z})}function b(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._data,$=d._size,E=d._datatype,_=S[0],z=S[1],I=$[1],T,B=a,G=r;O&&E&&O===E&&typeof O=="string"&&(T=O,B=t.find(a,[T,T]),G=t.find(r,[T,T]));for(var D=[],H=0;H<_;H++){var W=A[H];D[H]=[];for(var j=0;j<I;j++){for(var V=G(W[0],M[0][j]),K=1;K<z;K++)V=B(V,G(W[K],M[K][j]));D[H][j]=V}}return x.createDenseMatrix({data:D,size:[_,I],datatype:T})}function w(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._values,$=d._index,E=d._ptr,_=d._size,z=d._datatype;if(!M)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var I=S[0],T=_[1],B,G=a,D=r,H=i,W=0;O&&z&&O===z&&typeof O=="string"&&(B=O,G=t.find(a,[B,B]),D=t.find(r,[B,B]),H=t.find(i,[B,B]),W=t.convert(0,B));for(var j=[],V=[],K=[],te=d.createSparseMatrix({values:j,index:V,ptr:K,size:[I,T],datatype:B}),re=0;re<T;re++){K[re]=V.length;var oe=E[re],ae=E[re+1];if(ae>oe)for(var ce=0,ee=0;ee<I;ee++){for(var xe=ee+1,Ne=void 0,pe=oe;pe<ae;pe++){var be=$[pe];ce!==xe?(Ne=D(A[ee][be],M[pe]),ce=xe):Ne=G(Ne,D(A[ee][be],M[pe]))}ce===xe&&!H(Ne,W)&&(V.push(ee),j.push(Ne))}}return K[T]=V.length,te}function N(x,d){var A=x._values,S=x._index,O=x._ptr,M=x._datatype;if(!A)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var $=d._data,E=d._datatype,_=x._size[0],z=d._size[0],I=[],T=[],B=[],G,D=a,H=r,W=i,j=0;M&&E&&M===E&&typeof M=="string"&&(G=M,D=t.find(a,[G,G]),H=t.find(r,[G,G]),W=t.find(i,[G,G]),j=t.convert(0,G));var V=[],K=[];B[0]=0;for(var te=0;te<z;te++){var re=$[te];if(!W(re,j))for(var oe=O[te],ae=O[te+1],ce=oe;ce<ae;ce++){var ee=S[ce];K[ee]?V[ee]=D(V[ee],H(re,A[ce])):(K[ee]=!0,T.push(ee),V[ee]=H(re,A[ce]))}}for(var xe=T.length,Ne=0;Ne<xe;Ne++){var pe=T[Ne];I[Ne]=V[pe]}return B[1]=T.length,x.createSparseMatrix({values:I,index:T,ptr:B,size:[_,1],datatype:G})}function g(x,d){var A=x._values,S=x._index,O=x._ptr,M=x._datatype;if(!A)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var $=d._data,E=d._datatype,_=x._size[0],z=d._size[0],I=d._size[1],T,B=a,G=r,D=i,H=0;M&&E&&M===E&&typeof M=="string"&&(T=M,B=t.find(a,[T,T]),G=t.find(r,[T,T]),D=t.find(i,[T,T]),H=t.convert(0,T));for(var W=[],j=[],V=[],K=x.createSparseMatrix({values:W,index:j,ptr:V,size:[_,I],datatype:T}),te=[],re=[],oe=0;oe<I;oe++){V[oe]=j.length;for(var ae=oe+1,ce=0;ce<z;ce++){var ee=$[ce][oe];if(!D(ee,H))for(var xe=O[ce],Ne=O[ce+1],pe=xe;pe<Ne;pe++){var be=S[pe];re[be]!==ae?(re[be]=ae,j.push(be),te[be]=G(ee,A[pe])):te[be]=B(te[be],G(ee,A[pe]))}}for(var F=V[oe],Y=j.length,k=F;k<Y;k++){var U=j[k];W[k]=te[U]}}return V[I]=j.length,K}function y(x,d){var A=x._values,S=x._index,O=x._ptr,M=x._datatype,$=d._values,E=d._index,_=d._ptr,z=d._datatype,I=x._size[0],T=d._size[1],B=A&&$,G,D=a,H=r;M&&z&&M===z&&typeof M=="string"&&(G=M,D=t.find(a,[G,G]),H=t.find(r,[G,G]));for(var W=B?[]:void 0,j=[],V=[],K=x.createSparseMatrix({values:W,index:j,ptr:V,size:[I,T],datatype:G}),te=B?[]:void 0,re=[],oe,ae,ce,ee,xe,Ne,pe,be,F=0;F<T;F++){V[F]=j.length;var Y=F+1;for(xe=_[F],Ne=_[F+1],ee=xe;ee<Ne;ee++)if(be=E[ee],B)for(ae=O[be],ce=O[be+1],oe=ae;oe<ce;oe++)pe=S[oe],re[pe]!==Y?(re[pe]=Y,j.push(pe),te[pe]=H($[ee],A[oe])):te[pe]=D(te[pe],H($[ee],A[oe]));else for(ae=O[be],ce=O[be+1],oe=ae;oe<ce;oe++)pe=S[oe],re[pe]!==Y&&(re[pe]=Y,j.push(pe));if(B)for(var k=V[F],U=j.length,J=k;J<U;J++){var q=j[J];W[J]=te[q]}}return V[T]=j.length,K}return t(Au,ti({"Array, Array":function(d,A){c(Ue(d),Ue(A));var S=this(n(d),n(A));return De(S)?S.valueOf():S},"Matrix, Matrix":function(d,A){var S=d.size(),O=A.size();return c(S,O),S.length===1?O.length===1?o(d,A,S[0]):s(d,A):O.length===1?p(d,A):v(d,A)},"Matrix, Array":function(d,A){return this(d,n(A))},"Array, Matrix":function(d,A){return this(n(d,A.storage()),A)},"SparseMatrix, any":function(d,A){return l(d,A,r,!1)},"DenseMatrix, any":function(d,A){return f(d,A,r,!1)},"any, SparseMatrix":function(d,A){return l(A,d,r,!0)},"any, DenseMatrix":function(d,A){return f(A,d,r,!0)},"Array, any":function(d,A){return f(n(d),A,r,!1).valueOf()},"any, Array":function(d,A){return f(n(A),d,r,!0).valueOf()},"any, any":r,"any, any, ...any":function(d,A,S){for(var O=this(d,A),M=0;M<S.length;M++)O=this(O,S[M]);return O}},r.signatures))}),Su="nthRoot",fy=["typed","matrix","equalScalar","BigNumber"],ly=R(Su,fy,e=>{var{typed:t,matrix:n,equalScalar:a,BigNumber:r}=e,i=Ft({typed:t}),u=nt({typed:t,equalScalar:a}),l=Da({typed:t,equalScalar:a}),f=Nr({typed:t,equalScalar:a}),c=er({typed:t}),o=Ve({typed:t}),s="Complex number not supported in function nthRoot. Use nthRoots instead.";return t(Su,{number:cs,"number, number":cs,BigNumber:function(v){return m(v,new r(2))},Complex:function(v){throw new Error(s)},"Complex, number":function(v,h){throw new Error(s)},"BigNumber, BigNumber":m,"Array | Matrix":function(v){return this(v,2)},"SparseMatrix, SparseMatrix":function(v,h){if(h.density()===1)return l(v,h,this);throw new Error("Root must be non-zero")},"SparseMatrix, DenseMatrix":function(v,h){return u(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){if(h.density()===1)return i(v,h,this,!1);throw new Error("Root must be non-zero")},"DenseMatrix, DenseMatrix":function(v,h){return c(v,h,this)},"Array, Array":function(v,h){return this(n(v),n(h)).valueOf()},"Array, Matrix":function(v,h){return this(n(v),h)},"Matrix, Array":function(v,h){return this(v,n(h))},"SparseMatrix, number | BigNumber":function(v,h){return f(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return o(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){if(h.density()===1)return f(h,v,this,!0);throw new Error("Root must be non-zero")},"number | BigNumber, DenseMatrix":function(v,h){return o(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(n(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,n(h)).valueOf()}});function m(p,v){var h=r.precision,b=r.clone({precision:h+2}),w=new r(0),N=new b(1),g=v.isNegative();if(g&&(v=v.neg()),v.isZero())throw new Error("Root must be non-zero");if(p.isNegative()&&!v.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(p.isZero())return g?new b(1/0):0;if(!p.isFinite())return g?w:p;var y=p.abs().pow(N.div(v));return y=p.isNeg()?y.neg():y,new r((g?N.div(y):y).toPrecision(h))}}),Eu="sign",my=["typed","BigNumber","Fraction","complex"],py=R(Eu,my,e=>{var{typed:t,BigNumber:n,complex:a,Fraction:r}=e;return t(Eu,{number:wi,Complex:function(u){return u.im===0?a(wi(u.re)):u.sign()},BigNumber:function(u){return new n(u.cmp(0))},Fraction:function(u){return new r(u.s,1)},"Array | Matrix":function(u){return we(u,this)},Unit:function(u){if(!u._isDerived()&&u.units[0].unit.offset!==0)throw new TypeError("sign is ambiguous for units with offset");return this(u.value)}})}),vy="sqrt",hy=["config","typed","Complex"],dy=R(vy,hy,e=>{var{config:t,typed:n,Complex:a}=e;return n("sqrt",{number:r,Complex:function(u){return u.sqrt()},BigNumber:function(u){return!u.isNegative()||t.predictable?u.sqrt():r(u.toNumber())},"Array | Matrix":function(u){return we(u,this)},Unit:function(u){return u.pow(.5)}});function r(i){return isNaN(i)?NaN:i>=0||t.predictable?Math.sqrt(i):new a(i,0).sqrt()}}),Cu="square",gy=["typed"],yy=R(Cu,gy,e=>{var{typed:t}=e;return t(Cu,{number:fs,Complex:function(a){return a.mul(a)},BigNumber:function(a){return a.times(a)},Fraction:function(a){return a.mul(a)},"Array | Matrix":function(a){return we(a,this)},Unit:function(a){return a.pow(2)}})}),Ou="subtract",xy=["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix"],by=R(Ou,xy,e=>{var{typed:t,matrix:n,equalScalar:a,addScalar:r,unaryMinus:i,DenseMatrix:u}=e,l=Ft({typed:t}),f=Br({typed:t}),c=Ta({typed:t,equalScalar:a}),o=Yt({typed:t,DenseMatrix:u}),s=er({typed:t}),m=Ve({typed:t});return t(Ou,{"number, number":function(v,h){return v-h},"Complex, Complex":function(v,h){return v.sub(h)},"BigNumber, BigNumber":function(v,h){return v.minus(h)},"Fraction, Fraction":function(v,h){return v.sub(h)},"Unit, Unit":function(v,h){if(v.value===null)throw new Error("Parameter x contains a unit with undefined value");if(h.value===null)throw new Error("Parameter y contains a unit with undefined value");if(!v.equalBase(h))throw new Error("Units do not match");var b=v.clone();return b.value=this(b.value,h.value),b.fixPrefix=!1,b},"SparseMatrix, SparseMatrix":function(v,h){return Ba(v,h),c(v,h,this)},"SparseMatrix, DenseMatrix":function(v,h){return Ba(v,h),f(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return Ba(v,h),l(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return Ba(v,h),s(v,h,this)},"Array, Array":function(v,h){return this(n(v),n(h)).valueOf()},"Array, Matrix":function(v,h){return this(n(v),h)},"Matrix, Array":function(v,h){return this(v,n(h))},"SparseMatrix, any":function(v,h){return o(v,i(h),r)},"DenseMatrix, any":function(v,h){return m(v,h,this)},"any, SparseMatrix":function(v,h){return o(h,v,this,!0)},"any, DenseMatrix":function(v,h){return m(h,v,this,!0)},"Array, any":function(v,h){return m(n(v),h,this,!1).valueOf()},"any, Array":function(v,h){return m(n(h),v,this,!0).valueOf()}})});function Ba(e,t){var n=e.size(),a=t.size();if(n.length!==a.length)throw new ze(n.length,a.length)}var Du="xgcd",wy=["typed","config","matrix","BigNumber"],Ny=R(Du,wy,e=>{var{typed:t,config:n,matrix:a,BigNumber:r}=e;return t(Du,{"number, number":function(l,f){var c=ls(l,f);return n.matrix==="Array"?c:a(c)},"BigNumber, BigNumber":i});function i(u,l){var f,c,o,s=new r(0),m=new r(1),p=s,v=m,h=m,b=s;if(!u.isInt()||!l.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!l.isZero();)c=u.div(l).floor(),o=u.mod(l),f=p,p=v.minus(c.times(p)),v=f,f=h,h=b.minus(c.times(h)),b=f,u=l,l=o;var w;return u.lt(s)?w=[u.neg(),v.neg(),b.neg()]:w=[u,u.isZero()?0:v,b],n.matrix==="Array"?w:a(w)}}),Tu="invmod",My=["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],Ay=R(Tu,My,e=>{var{typed:t,config:n,BigNumber:a,xgcd:r,equal:i,smaller:u,mod:l,add:f,isInteger:c}=e;return t(Tu,{"number, number":o,"BigNumber, BigNumber":o});function o(s,m){if(!c(s)||!c(m))throw new Error("Parameters in function invmod must be integer numbers");if(s=l(s,m),i(m,0))throw new Error("Divisor must be non zero");var p=r(s,m);p=p.valueOf();var[v,h]=p;return i(v,a(1))?(h=l(h,m),u(h,a(0))&&(h=f(h,m)),h):NaN}}),Sy="algorithm09",Ey=["typed","equalScalar"],Bu=R(Sy,Ey,e=>{var{typed:t,equalScalar:n}=e;return function(r,i,u){var l=r._values,f=r._index,c=r._ptr,o=r._size,s=r._datatype,m=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(o.length!==h.length)throw new ze(o.length,h.length);if(o[0]!==h[0]||o[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+h+")");var w=o[0],N=o[1],g,y=n,x=0,d=u;typeof s=="string"&&s===b&&(g=s,y=t.find(n,[g,g]),x=t.convert(0,g),d=t.find(u,[g,g]));var A=l&&m?[]:void 0,S=[],O=[],M=A?[]:void 0,$=[],E,_,z,I,T;for(_=0;_<N;_++){O[_]=S.length;var B=_+1;if(M)for(I=v[_],T=v[_+1],z=I;z<T;z++)E=p[z],$[E]=B,M[E]=m[z];for(I=c[_],T=c[_+1],z=I;z<T;z++)if(E=f[z],M){var G=$[E]===B?M[E]:x,D=d(l[z],G);y(D,x)||(S.push(E),A.push(D))}else S.push(E)}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),$u="dotMultiply",Cy=["typed","matrix","equalScalar","multiplyScalar"],Oy=R($u,Cy,e=>{var{typed:t,matrix:n,equalScalar:a,multiplyScalar:r}=e,i=nt({typed:t,equalScalar:a}),u=Bu({typed:t,equalScalar:a}),l=Nr({typed:t,equalScalar:a}),f=er({typed:t}),c=Ve({typed:t});return t($u,{"any, any":r,"SparseMatrix, SparseMatrix":function(s,m){return u(s,m,r,!1)},"SparseMatrix, DenseMatrix":function(s,m){return i(m,s,r,!0)},"DenseMatrix, SparseMatrix":function(s,m){return i(s,m,r,!1)},"DenseMatrix, DenseMatrix":function(s,m){return f(s,m,r)},"Array, Array":function(s,m){return this(n(s),n(m)).valueOf()},"Array, Matrix":function(s,m){return this(n(s),m)},"Matrix, Array":function(s,m){return this(s,n(m))},"SparseMatrix, any":function(s,m){return l(s,m,r,!1)},"DenseMatrix, any":function(s,m){return c(s,m,r,!1)},"any, SparseMatrix":function(s,m){return l(m,s,r,!0)},"any, DenseMatrix":function(s,m){return c(m,s,r,!0)},"Array, any":function(s,m){return c(n(s),m,r,!1).valueOf()},"any, Array":function(s,m){return c(n(m),s,r,!0).valueOf()}})});function Dy(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitAnd");var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(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 n(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new n(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new n(0):e}return Oi(e,t,function(a,r){return a&r})}function Fn(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var t=e.constructor,n=t.precision;t.config({precision:1e9});var a=e.plus(new t(1));return a.s=-a.s||null,t.config({precision:n}),a}function Ty(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitOr");var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);var a=new n(-1);return e.isZero()||t.eq(a)||e.eq(t)?t:t.isZero()||e.eq(a)?e:!e.isFinite()||!t.isFinite()?!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?a:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e:Oi(e,t,function(r,i){return r|i})}function Oi(e,t,n){var a=e.constructor,r,i,u=+(e.s<0),l=+(t.s<0);if(u){r=$a(Fn(e));for(var f=0;f<r.length;++f)r[f]^=1}else r=$a(e);if(l){i=$a(Fn(t));for(var c=0;c<i.length;++c)i[c]^=1}else i=$a(t);var o,s,m;r.length<=i.length?(o=r,s=i,m=u):(o=i,s=r,m=l);var p=o.length,v=s.length,h=n(u,l)^1,b=new a(h^1),w=new a(1),N=new a(2),g=a.precision;for(a.config({precision:1e9});p>0;)n(o[--p],s[--v])===h&&(b=b.plus(w)),w=w.times(N);for(;v>0;)n(m,s[--v])===h&&(b=b.plus(w)),w=w.times(N);return a.config({precision:g}),h===0&&(b.s=-b.s),b}function $a(e){for(var t=e.d,n=t[0]+"",a=1;a<t.length;++a){for(var r=t[a]+"",i=7-r.length;i--;)r="0"+r;n+=r}for(var u=n.length;n.charAt(u)==="0";)u--;var l=e.e,f=n.slice(0,u+1||1),c=f.length;if(l>0)if(++l>c)for(l-=c;l--;)f+="0";else l<c&&(f=f.slice(0,l)+"."+f.slice(l));for(var o=[0],s=0;s<f.length;){for(var m=o.length;m--;)o[m]*=10;o[0]+=parseInt(f.charAt(s++));for(var p=0;p<o.length;++p)o[p]>1&&((o[p+1]===null||o[p+1]===void 0)&&(o[p+1]=0),o[p+1]+=o[p]>>1,o[p]&=1)}return o.reverse()}function By(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new n(0);var a=new n(-1);return e.eq(a)?Fn(t):t.eq(a)?Fn(e):!e.isFinite()||!t.isFinite()?!e.isFinite()&&!t.isFinite()?a:new n(e.isNegative()===t.isNegative()?1/0:-1/0):Oi(e,t,function(r,i){return r^i})}function $y(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");var n=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new n(NaN):e.isZero()||t.isZero()?e:!e.isFinite()&&!t.isFinite()?new n(NaN):t.lt(55)?e.times(Math.pow(2,t.toNumber())+""):e.times(new n(2).pow(t))}function _y(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");var n=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new n(NaN):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(Math.pow(2,t.toNumber())+"").floor():e.div(new n(2).pow(t)).floor():e.isNegative()?new n(-1):e.isFinite()?new n(0):new n(NaN)}var _u="bitAnd",Iy=["typed","matrix","equalScalar"],qy=R(_u,Iy,e=>{var{typed:t,matrix:n,equalScalar:a}=e,r=nt({typed:t,equalScalar:a}),i=Da({typed:t,equalScalar:a}),u=Nr({typed:t,equalScalar:a}),l=er({typed:t}),f=Ve({typed:t});return t(_u,{"number, number":vs,"BigNumber, BigNumber":Dy,"SparseMatrix, SparseMatrix":function(o,s){return i(o,s,this,!1)},"SparseMatrix, DenseMatrix":function(o,s){return r(s,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,s){return r(o,s,this,!1)},"DenseMatrix, DenseMatrix":function(o,s){return l(o,s,this)},"Array, Array":function(o,s){return this(n(o),n(s)).valueOf()},"Array, Matrix":function(o,s){return this(n(o),s)},"Matrix, Array":function(o,s){return this(o,n(s))},"SparseMatrix, any":function(o,s){return u(o,s,this,!1)},"DenseMatrix, any":function(o,s){return f(o,s,this,!1)},"any, SparseMatrix":function(o,s){return u(s,o,this,!0)},"any, DenseMatrix":function(o,s){return f(s,o,this,!0)},"Array, any":function(o,s){return f(n(o),s,this,!1).valueOf()},"any, Array":function(o,s){return f(n(s),o,this,!0).valueOf()}})}),Iu="bitNot",Ry=["typed"],Fy=R(Iu,Ry,e=>{var{typed:t}=e;return t(Iu,{number:hs,BigNumber:Fn,"Array | Matrix":function(a){return we(a,this)}})}),qu="bitOr",zy=["typed","matrix","equalScalar","DenseMatrix"],Py=R(qu,zy,e=>{var{typed:t,matrix:n,equalScalar:a,DenseMatrix:r}=e,i=Ft({typed:t}),u=Ci({typed:t,equalScalar:a}),l=Yt({typed:t,DenseMatrix:r}),f=er({typed:t}),c=Ve({typed:t});return t(qu,{"number, number":ds,"BigNumber, BigNumber":Ty,"SparseMatrix, SparseMatrix":function(s,m){return u(s,m,this)},"SparseMatrix, DenseMatrix":function(s,m){return i(m,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,m){return i(s,m,this,!1)},"DenseMatrix, DenseMatrix":function(s,m){return f(s,m,this)},"Array, Array":function(s,m){return this(n(s),n(m)).valueOf()},"Array, Matrix":function(s,m){return this(n(s),m)},"Matrix, Array":function(s,m){return this(s,n(m))},"SparseMatrix, any":function(s,m){return l(s,m,this,!1)},"DenseMatrix, any":function(s,m){return c(s,m,this,!1)},"any, SparseMatrix":function(s,m){return l(m,s,this,!0)},"any, DenseMatrix":function(s,m){return c(m,s,this,!0)},"Array, any":function(s,m){return c(n(s),m,this,!1).valueOf()},"any, Array":function(s,m){return c(n(m),s,this,!0).valueOf()}})}),Uy="algorithm07",Ly=["typed","DenseMatrix"],ft=R(Uy,Ly,e=>{var{typed:t,DenseMatrix:n}=e;return function(i,u,l){var f=i._size,c=i._datatype,o=u._size,s=u._datatype;if(f.length!==o.length)throw new ze(f.length,o.length);if(f[0]!==o[0]||f[1]!==o[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+o+")");var m=f[0],p=f[1],v,h=0,b=l;typeof c=="string"&&c===s&&(v=c,h=t.convert(0,v),b=t.find(l,[v,v]));var w,N,g=[];for(w=0;w<m;w++)g[w]=[];var y=[],x=[],d=[],A=[];for(N=0;N<p;N++){var S=N+1;for(a(i,N,d,y,S),a(u,N,A,x,S),w=0;w<m;w++){var O=d[w]===S?y[w]:h,M=A[w]===S?x[w]:h;g[w][N]=b(O,M)}}return new n({data:g,size:[m,p],datatype:v})};function a(r,i,u,l,f){for(var c=r._values,o=r._index,s=r._ptr,m=s[i],p=s[i+1];m<p;m++){var v=o[m];u[v]=f,l[v]=c[m]}}}),Ru="bitXor",ky=["typed","matrix","DenseMatrix"],Hy=R(Ru,ky,e=>{var{typed:t,matrix:n,DenseMatrix:a}=e,r=Br({typed:t}),i=ft({typed:t,DenseMatrix:a}),u=yr({typed:t,DenseMatrix:a}),l=er({typed:t}),f=Ve({typed:t});return t(Ru,{"number, number":gs,"BigNumber, BigNumber":By,"SparseMatrix, SparseMatrix":function(o,s){return i(o,s,this)},"SparseMatrix, DenseMatrix":function(o,s){return r(s,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,s){return r(o,s,this,!1)},"DenseMatrix, DenseMatrix":function(o,s){return l(o,s,this)},"Array, Array":function(o,s){return this(n(o),n(s)).valueOf()},"Array, Matrix":function(o,s){return this(n(o),s)},"Matrix, Array":function(o,s){return this(o,n(s))},"SparseMatrix, any":function(o,s){return u(o,s,this,!1)},"DenseMatrix, any":function(o,s){return f(o,s,this,!1)},"any, SparseMatrix":function(o,s){return u(s,o,this,!0)},"any, DenseMatrix":function(o,s){return f(s,o,this,!0)},"Array, any":function(o,s){return f(n(o),s,this,!1).valueOf()},"any, Array":function(o,s){return f(n(s),o,this,!0).valueOf()}})}),Fu="arg",Gy=["typed"],Vy=R(Fu,Gy,e=>{var{typed:t}=e;return t(Fu,{number:function(a){return Math.atan2(0,a)},BigNumber:function(a){return a.constructor.atan2(0,a)},Complex:function(a){return a.arg()},"Array | Matrix":function(a){return we(a,this)}})}),zu="conj",Zy=["typed"],Xy=R(zu,Zy,e=>{var{typed:t}=e;return t(zu,{number:function(a){return a},BigNumber:function(a){return a},Complex:function(a){return a.conjugate()},"Array | Matrix":function(a){return we(a,this)}})}),Pu="im",Yy=["typed"],Wy=R(Pu,Yy,e=>{var{typed:t}=e;return t(Pu,{number:function(a){return 0},BigNumber:function(a){return a.mul(0)},Fraction:function(a){return a.mul(0)},Complex:function(a){return a.im},"Array | Matrix":function(a){return we(a,this)}})}),Uu="re",Jy=["typed"],Qy=R(Uu,Jy,e=>{var{typed:t}=e;return t(Uu,{number:function(a){return a},BigNumber:function(a){return a},Fraction:function(a){return a},Complex:function(a){return a.re},"Array | Matrix":function(a){return we(a,this)}})}),Lu="not",Ky=["typed"],jy=R(Lu,Ky,e=>{var{typed:t}=e;return t(Lu,{number:Ns,Complex:function(a){return a.re===0&&a.im===0},BigNumber:function(a){return a.isZero()||a.isNaN()},Unit:function(a){return a.value!==null?this(a.value):!0},"Array | Matrix":function(a){return we(a,this)}})}),ku="or",e0=["typed","matrix","equalScalar","DenseMatrix"],r0=R(ku,e0,e=>{var{typed:t,matrix:n,equalScalar:a,DenseMatrix:r}=e,i=Br({typed:t}),u=Ta({typed:t,equalScalar:a}),l=yr({typed:t,DenseMatrix:r}),f=er({typed:t}),c=Ve({typed:t});return t(ku,{"number, number":Ms,"Complex, Complex":function(s,m){return s.re!==0||s.im!==0||m.re!==0||m.im!==0},"BigNumber, BigNumber":function(s,m){return!s.isZero()&&!s.isNaN()||!m.isZero()&&!m.isNaN()},"Unit, Unit":function(s,m){return this(s.value||0,m.value||0)},"SparseMatrix, SparseMatrix":function(s,m){return u(s,m,this)},"SparseMatrix, DenseMatrix":function(s,m){return i(m,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,m){return i(s,m,this,!1)},"DenseMatrix, DenseMatrix":function(s,m){return f(s,m,this)},"Array, Array":function(s,m){return this(n(s),n(m)).valueOf()},"Array, Matrix":function(s,m){return this(n(s),m)},"Matrix, Array":function(s,m){return this(s,n(m))},"SparseMatrix, any":function(s,m){return l(s,m,this,!1)},"DenseMatrix, any":function(s,m){return c(s,m,this,!1)},"any, SparseMatrix":function(s,m){return l(m,s,this,!0)},"any, DenseMatrix":function(s,m){return c(m,s,this,!0)},"Array, any":function(s,m){return c(n(s),m,this,!1).valueOf()},"any, Array":function(s,m){return c(n(m),s,this,!0).valueOf()}})}),Hu="xor",t0=["typed","matrix","DenseMatrix"],n0=R(Hu,t0,e=>{var{typed:t,matrix:n,DenseMatrix:a}=e,r=Br({typed:t}),i=ft({typed:t,DenseMatrix:a}),u=yr({typed:t,DenseMatrix:a}),l=er({typed:t}),f=Ve({typed:t});return t(Hu,{"number, number":As,"Complex, Complex":function(o,s){return(o.re!==0||o.im!==0)!=(s.re!==0||s.im!==0)},"BigNumber, BigNumber":function(o,s){return(!o.isZero()&&!o.isNaN())!=(!s.isZero()&&!s.isNaN())},"Unit, Unit":function(o,s){return this(o.value||0,s.value||0)},"SparseMatrix, SparseMatrix":function(o,s){return i(o,s,this)},"SparseMatrix, DenseMatrix":function(o,s){return r(s,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,s){return r(o,s,this,!1)},"DenseMatrix, DenseMatrix":function(o,s){return l(o,s,this)},"Array, Array":function(o,s){return this(n(o),n(s)).valueOf()},"Array, Matrix":function(o,s){return this(n(o),s)},"Matrix, Array":function(o,s){return this(o,n(s))},"SparseMatrix, any":function(o,s){return u(o,s,this,!1)},"DenseMatrix, any":function(o,s){return f(o,s,this,!1)},"any, SparseMatrix":function(o,s){return u(s,o,this,!0)},"any, DenseMatrix":function(o,s){return f(s,o,this,!0)},"Array, any":function(o,s){return f(n(o),s,this,!1).valueOf()},"any, Array":function(o,s){return f(n(s),o,this,!0).valueOf()}})}),Gu="concat",a0=["typed","matrix","isInteger"],Vu=R(Gu,a0,e=>{var{typed:t,matrix:n,isInteger:a}=e;return t(Gu,{"...Array | Matrix | number | BigNumber":function(i){var u,l=i.length,f=-1,c,o=!1,s=[];for(u=0;u<l;u++){var m=i[u];if(De(m)&&(o=!0),$e(m)||_e(m)){if(u!==l-1)throw new Error("Dimension must be specified as last argument");if(c=f,f=m.valueOf(),!a(f))throw new TypeError("Integer number expected for dimension");if(f<0||u>0&&f>c)throw new et(f,c+1)}else{var p=Oe(m).valueOf(),v=Ue(p);if(s[u]=p,c=f,f=v.length-1,u>0&&f!==c)throw new ze(c+1,f+1)}}if(s.length===0)throw new SyntaxError("At least one matrix expected");for(var h=s.shift();s.length;)h=Zu(h,s.shift(),f,0);return o?n(h):h},"...string":function(i){return i.join("")}})});function Zu(e,t,n,a){if(a<n){if(e.length!==t.length)throw new ze(e.length,t.length);for(var r=[],i=0;i<e.length;i++)r[i]=Zu(e[i],t[i],n,a+1);return r}else return e.concat(t)}var Xu="column",i0=["typed","Index","matrix","range"],Yu=R(Xu,i0,e=>{var{typed:t,Index:n,matrix:a,range:r}=e;return t(Xu,{"Matrix, number":i,"Array, number":function(l,f){return i(a(Oe(l)),f).valueOf()}});function i(u,l){if(u.size().length!==2)throw new Error("Only two dimensional matrix is supported");Je(l,u.size()[1]);var f=r(0,u.size()[0]),c=new n(f,l);return u.subset(c)}}),Wu="count",o0=["typed","size","prod"],s0=R(Wu,o0,e=>{var{typed:t,size:n,prod:a}=e;return t(Wu,{string:function(i){return i.length},"Matrix | Array":function(i){return a(n(i))}})}),Ju="cross",u0=["typed","matrix","subtract","multiply"],c0=R(Ju,u0,e=>{var{typed:t,matrix:n,subtract:a,multiply:r}=e;return t(Ju,{"Matrix, Matrix":function(l,f){return n(i(l.toArray(),f.toArray()))},"Matrix, Array":function(l,f){return n(i(l.toArray(),f))},"Array, Matrix":function(l,f){return n(i(l,f.toArray()))},"Array, Array":i});function i(u,l){var f=Math.max(Ue(u).length,Ue(l).length);u=ua(u),l=ua(l);var c=Ue(u),o=Ue(l);if(c.length!==1||o.length!==1||c[0]!==3||o[0]!==3)throw new RangeError("Vectors with length 3 expected (Size A = ["+c.join(", ")+"], B = ["+o.join(", ")+"])");var s=[a(r(u[1],l[2]),r(u[2],l[1])),a(r(u[2],l[0]),r(u[0],l[2])),a(r(u[0],l[1]),r(u[1],l[0]))];return f>1?[s]:s}}),Qu="diag",f0=["typed","matrix","DenseMatrix","SparseMatrix"],l0=R(Qu,f0,e=>{var{typed:t,matrix:n,DenseMatrix:a,SparseMatrix:r}=e;return t(Qu,{Array:function(c){return i(c,0,Ue(c),null)},"Array, number":function(c,o){return i(c,o,Ue(c),null)},"Array, BigNumber":function(c,o){return i(c,o.toNumber(),Ue(c),null)},"Array, string":function(c,o){return i(c,0,Ue(c),o)},"Array, number, string":function(c,o,s){return i(c,o,Ue(c),s)},"Array, BigNumber, string":function(c,o,s){return i(c,o.toNumber(),Ue(c),s)},Matrix:function(c){return i(c,0,c.size(),c.storage())},"Matrix, number":function(c,o){return i(c,o,c.size(),c.storage())},"Matrix, BigNumber":function(c,o){return i(c,o.toNumber(),c.size(),c.storage())},"Matrix, string":function(c,o){return i(c,0,c.size(),o)},"Matrix, number, string":function(c,o,s){return i(c,o,c.size(),s)},"Matrix, BigNumber, string":function(c,o,s){return i(c,o.toNumber(),c.size(),s)}});function i(f,c,o,s){if(!Se(c))throw new TypeError("Second parameter in function diag must be an integer");var m=c>0?c:0,p=c<0?-c:0;switch(o.length){case 1:return u(f,c,s,o[0],p,m);case 2:return l(f,c,s,o,p,m)}throw new RangeError("Matrix for function diag must be 2 dimensional")}function u(f,c,o,s,m,p){var v=[s+m,s+p];if(o&&o!=="sparse"&&o!=="dense")throw new TypeError("Unknown matrix type ".concat(o,'"'));var h=o==="sparse"?r.diagonal(v,f,c):a.diagonal(v,f,c);return o!==null?h:h.valueOf()}function l(f,c,o,s,m,p){if(De(f)){var v=f.diagonal(c);return o!==null?o!==v.storage()?n(v,o):v:v.valueOf()}for(var h=Math.min(s[0]-m,s[1]-p),b=[],w=0;w<h;w++)b[w]=f[w+m][w+p];return o!==null?n(b):b}});function m0(e){var t=0,n=1,a=Object.create(null),r=Object.create(null),i=0,u=function(f){var c=r[f];if(c&&(delete a[c],delete r[f],--t,n===c)){if(!t){i=0,n=1;return}for(;!hasOwnProperty.call(a,++n););}};return e=Math.abs(e),{hit:function(f){var c=r[f],o=++i;if(a[o]=f,r[f]=o,!c)return++t,t<=e?void 0:(f=a[n],u(f),f);if(delete a[c],n===c)for(;!hasOwnProperty.call(a,++n););},delete:u,clear:function(){t=i=0,n=1,a=Object.create(null),r=Object.create(null)}}}function zn(e){var{hasher:t,limit:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return n=n==null?Number.POSITIVE_INFINITY:n,t=t==null?JSON.stringify:t,function a(){typeof a.cache!="object"&&(a.cache={values:new Map,lru:m0(n||Number.POSITIVE_INFINITY)});for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var u=t(r);if(a.cache.values.has(u))return a.cache.lru.hit(u),a.cache.values.get(u);var l=e.apply(e,r);return a.cache.values.set(u,l),a.cache.values.delete(a.cache.lru.hit(u)),l}}function xn(e){return Object.keys(e.signatures||{}).reduce(function(t,n){var a=(n.match(/,/g)||[]).length+1;return Math.max(t,a)},-1)}var p0="filter",v0=["typed"],h0=R(p0,v0,e=>{var{typed:t}=e;return t("filter",{"Array, function":Ku,"Matrix, function":function(a,r){return a.create(Ku(a.toArray(),r))},"Array, RegExp":fa,"Matrix, RegExp":function(a,r){return a.create(fa(a.toArray(),r))}})});function Ku(e,t){var n=xn(t);return Eo(e,function(a,r,i){return n===1?t(a):n===2?t(a,[r]):t(a,[r],i)})}var ju="flatten",d0=["typed","matrix"],g0=R(ju,d0,e=>{var{typed:t,matrix:n}=e;return t(ju,{Array:function(r){return ke(Oe(r))},Matrix:function(r){var i=ke(Oe(r.toArray()));return n(i)}})}),ec="forEach",y0=["typed"],x0=R(ec,y0,e=>{var{typed:t}=e;return t(ec,{"Array, function":b0,"Matrix, function":function(a,r){return a.forEach(r)}})});function b0(e,t){var n=xn(t),a=function r(i,u){Array.isArray(i)?ca(i,function(l,f){r(l,u.concat(f))}):n===1?t(i):n===2?t(i,u):t(i,u,e)};a(e,[])}var rc="getMatrixDataType",w0=["typed"],N0=R(rc,w0,e=>{var{typed:t}=e;return t(rc,{Array:function(a){return In(a,je)},Matrix:function(a){return a.getDataType()}})}),tc="identity",M0=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],A0=R(tc,M0,e=>{var{typed:t,config:n,matrix:a,BigNumber:r,DenseMatrix:i,SparseMatrix:u}=e;return t(tc,{"":function(){return n.matrix==="Matrix"?a([]):[]},string:function(o){return a(o)},"number | BigNumber":function(o){return f(o,o,n.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(o,s){return f(o,o,s)},"number | BigNumber, number | BigNumber":function(o,s){return f(o,s,n.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(o,s,m){return f(o,s,m)},Array:function(o){return l(o)},"Array, string":function(o,s){return l(o,s)},Matrix:function(o){return l(o.valueOf(),o.storage())},"Matrix, string":function(o,s){return l(o.valueOf(),s)}});function l(c,o){switch(c.length){case 0:return o?a(o):[];case 1:return f(c[0],c[0],o);case 2:return f(c[0],c[1],o);default:throw new Error("Vector containing two values expected")}}function f(c,o,s){var m=_e(c)||_e(o)?r:null;if(_e(c)&&(c=c.toNumber()),_e(o)&&(o=o.toNumber()),!Se(c)||c<1)throw new Error("Parameters in function identity must be positive integers");if(!Se(o)||o<1)throw new Error("Parameters in function identity must be positive integers");var p=m?new r(1):1,v=m?new m(0):0,h=[c,o];if(s){if(s==="sparse")return u.diagonal(h,p,0,v);if(s==="dense")return i.diagonal(h,p,0,v);throw new TypeError('Unknown matrix type "'.concat(s,'"'))}for(var b=cn([],h,v),w=c<o?c:o,N=0;N<w;N++)b[N][N]=p;return b}}),nc="kron",S0=["typed","matrix","multiplyScalar"],E0=R(nc,S0,e=>{var{typed:t,matrix:n,multiplyScalar:a}=e;return t(nc,{"Matrix, Matrix":function(u,l){return n(r(u.toArray(),l.toArray()))},"Matrix, Array":function(u,l){return n(r(u.toArray(),l))},"Array, Matrix":function(u,l){return n(r(u,l.toArray()))},"Array, Array":r});function r(i,u){if(Ue(i).length===1&&(i=[i]),Ue(u).length===1&&(u=[u]),Ue(i).length>2||Ue(u).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(i.length)+", y = "+JSON.stringify(u.length)+")");var l=[],f=[];return i.map(function(c){return u.map(function(o){return f=[],l.push(f),c.map(function(s){return o.map(function(m){return f.push(a(s,m))})})})})&&l}}),ac="map",C0=["typed"],O0=R(ac,C0,e=>{var{typed:t}=e;return t(ac,{"Array, function":D0,"Matrix, function":function(a,r){return a.map(r)}})});function D0(e,t){var n=xn(t),a=function r(i,u){if(Array.isArray(i))return i.map(function(c,o){return r(c,u.concat(o))});try{return n===1?t(i):n===2?t(i,u):t(i,u,e)}catch(c){if(c instanceof TypeError&&"data"in c&&c.data.category==="wrongType"){var l="map attempted to call '".concat(c.data.fn,"(").concat(i),f=JSON.stringify(u);throw n===2?l+=","+f:n!==1&&(l+=",".concat(f,",").concat(e)),l+=")' but argument ".concat(c.data.index+1," of type "),l+="".concat(c.data.actual," does not match expected type "),l+=c.data.expected.join(" or "),new TypeError(l)}throw c}};return a(e,[])}var ic="diff",T0=["typed","matrix","subtract","number"],oc=R(ic,T0,e=>{var{typed:t,matrix:n,subtract:a,number:r}=e;return t(ic,{"Array | Matrix":function(o){return De(o)?n(u(o.toArray())):u(o)},"Array | Matrix, number":function(o,s){if(!Se(s))throw new RangeError("Dimension must be a whole number");return De(o)?n(i(o.toArray(),s)):i(o,s)},"Array | Matrix, BigNumber":function(o,s){return this(o,r(s))}});function i(c,o){if(De(c)&&(c=c.toArray()),!Array.isArray(c))throw RangeError("Array/Matrix does not have that many dimensions");if(o>0){var s=[];return c.forEach(m=>{s.push(i(m,o-1))}),s}else{if(o===0)return u(c);throw RangeError("Cannot have negative dimension")}}function u(c){var o=[],s=c.length;if(s<2)return c;for(var m=1;m<s;m++)o.push(l(c[m-1],c[m]));return o}function l(c,o){De(c)&&(c=c.toArray()),De(o)&&(o=o.toArray());var s=Array.isArray(c),m=Array.isArray(o);if(s&&m)return f(c,o);if(!s&&!m)return a(o,c);throw TypeError("Cannot calculate difference between 1 array and 1 non-array")}function f(c,o){if(c.length!==o.length)throw RangeError("Not all sub-arrays have the same length");for(var s=[],m=c.length,p=0;p<m;p++)s.push(l(c[p],o[p]));return s}}),B0="ones",$0=["typed","config","matrix","BigNumber"],_0=R(B0,$0,e=>{var{typed:t,config:n,matrix:a,BigNumber:r}=e;return t("ones",{"":function(){return n.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(c){var o=c[c.length-1];if(typeof o=="string"){var s=c.pop();return i(c,s)}else return n.matrix==="Array"?i(c):i(c,"default")},Array:i,Matrix:function(c){var o=c.storage();return i(c.valueOf(),o)},"Array | Matrix, string":function(c,o){return i(c.valueOf(),o)}});function i(f,c){var o=u(f),s=o?new r(1):1;if(l(f),c){var m=a(c);return f.length>0?m.resize(f,s):m}else{var p=[];return f.length>0?cn(p,f,s):p}}function u(f){var c=!1;return f.forEach(function(o,s,m){_e(o)&&(c=!0,m[s]=o.toNumber())}),c}function l(f){f.forEach(function(c){if(typeof c!="number"||!Se(c)||c<0)throw new Error("Parameters in function ones must be positive integers")})}});function Di(){throw new Error('No "bignumber" implementation available')}function sc(){throw new Error('No "fraction" implementation available')}function uc(){throw new Error('No "matrix" implementation available')}var cc="range",I0=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],fc=R(cc,I0,e=>{var{typed:t,config:n,matrix:a,bignumber:r,smaller:i,smallerEq:u,larger:l,largerEq:f}=e;return t(cc,{string:o,"string, boolean":o,"number, number":function(w,N){return c(s(w,N,1))},"number, number, number":function(w,N,g){return c(s(w,N,g))},"number, number, boolean":function(w,N,g){return c(g?m(w,N,1):s(w,N,1))},"number, number, number, boolean":function(w,N,g,y){return c(y?m(w,N,g):s(w,N,g))},"BigNumber, BigNumber":function(w,N){var g=w.constructor;return c(p(w,N,new g(1)))},"BigNumber, BigNumber, BigNumber":function(w,N,g){return c(p(w,N,g))},"BigNumber, BigNumber, boolean":function(w,N,g){var y=w.constructor;return c(g?v(w,N,new y(1)):p(w,N,new y(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(w,N,g,y){return c(y?v(w,N,g):p(w,N,g))}});function c(b){return n.matrix==="Matrix"?a?a(b):uc():b}function o(b,w){var N=h(b);if(!N)throw new SyntaxError('String "'+b+'" is no valid range');var g;return n.number==="BigNumber"?(r===void 0&&Di(),g=w?v:p,c(g(r(N.start),r(N.end),r(N.step)))):(g=w?m:s,c(g(N.start,N.end,N.step)))}function s(b,w,N){var g=[],y=b;if(N>0)for(;i(y,w);)g.push(y),y+=N;else if(N<0)for(;l(y,w);)g.push(y),y+=N;return g}function m(b,w,N){var g=[],y=b;if(N>0)for(;u(y,w);)g.push(y),y+=N;else if(N<0)for(;f(y,w);)g.push(y),y+=N;return g}function p(b,w,N){var g=r(0),y=[],x=b;if(N.gt(g))for(;i(x,w);)y.push(x),x=x.plus(N);else if(N.lt(g))for(;l(x,w);)y.push(x),x=x.plus(N);return y}function v(b,w,N){var g=r(0),y=[],x=b;if(N.gt(g))for(;u(x,w);)y.push(x),x=x.plus(N);else if(N.lt(g))for(;f(x,w);)y.push(x),x=x.plus(N);return y}function h(b){var w=b.split(":"),N=w.map(function(y){return Number(y)}),g=N.some(function(y){return isNaN(y)});if(g)return null;switch(N.length){case 2:return{start:N[0],end:N[1],step:1};case 3:return{start:N[0],end:N[2],step:N[1]};default:return null}}}),lc="reshape",q0=["typed","isInteger","matrix"],R0=R(lc,q0,e=>{var{typed:t,isInteger:n}=e;return t(lc,{"Matrix, Array":function(r,i){return r.reshape(i)},"Array, Array":function(r,i){return i.forEach(function(u){if(!n(u))throw new TypeError("Invalid size for dimension: "+u)}),wo(r,i)}})});function bn(e,t,n,a){if(!(this instanceof bn))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=t,this.min=n,this.max=a,this.message="Wrong number of arguments in function "+e+" ("+t+" provided, "+n+(a!=null?"-"+a:"")+" expected)",this.stack=new Error().stack}bn.prototype=new Error,bn.prototype.constructor=Error,bn.prototype.name="ArgumentsError",bn.prototype.isArgumentsError=!0;var F0="resize",z0=["config","matrix"],P0=R(F0,z0,e=>{var{config:t,matrix:n}=e;return function(i,u,l){if(arguments.length!==2&&arguments.length!==3)throw new bn("resize",arguments.length,2,3);if(De(u)&&(u=u.valueOf()),_e(u[0])&&(u=u.map(function(o){return _e(o)?o.toNumber():o})),De(i))return i.resize(u,l,!0);if(typeof i=="string")return a(i,u,l);var f=Array.isArray(i)?!1:t.matrix!=="Array";if(u.length===0){for(;Array.isArray(i);)i=i[0];return Oe(i)}else{Array.isArray(i)||(i=[i]),i=Oe(i);var c=cn(i,u,l);return f?n(c):c}};function a(r,i,u){if(u!==void 0){if(typeof u!="string"||u.length!==1)throw new TypeError("Single character expected as defaultValue")}else u=" ";if(i.length!==1)throw new ze(i.length,1);var l=i[0];if(typeof l!="number"||!Se(l))throw new TypeError("Invalid size, must contain positive integers (size: "+Fe(i)+")");if(r.length>l)return r.substring(0,l);if(r.length<l){for(var f=r,c=0,o=l-r.length;c<o;c++)f+=u;return f}else return r}}),mc="rotate",U0=["typed","multiply","rotationMatrix"],L0=R(mc,U0,e=>{var{typed:t,multiply:n,rotationMatrix:a}=e;return t(mc,{"Array , number | BigNumber | Complex | Unit":function(u,l){r(u,2);var f=n(a(l),u);return f.toArray()},"Matrix , number | BigNumber | Complex | Unit":function(u,l){return r(u,2),n(a(l),u)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(u,l,f){r(u,3);var c=n(a(l,f),u);return c},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(u,l,f){return r(u,3),n(a(l,f),u)}});function r(i,u){var l=Array.isArray(i)?Ue(i):i.size();if(l.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(u));if(l.length===2&&l[1]!==1)throw new RangeError("Vector must be of dimensions 1x".concat(u));if(l[0]!==u)throw new RangeError("Vector must be of dimensions 1x".concat(u))}}),pc="rotationMatrix",k0=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],H0=R(pc,k0,e=>{var{typed:t,config:n,multiplyScalar:a,addScalar:r,unaryMinus:i,norm:u,BigNumber:l,matrix:f,DenseMatrix:c,SparseMatrix:o,cos:s,sin:m}=e;return t(pc,{"":function(){return n.matrix==="Matrix"?f([]):[]},string:function(g){return f(g)},"number | BigNumber | Complex | Unit":function(g){return p(g,n.matrix==="Matrix"?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(g,y){return p(g,y)},"number | BigNumber | Complex | Unit, Array":function(g,y){var x=f(y);return v(x),w(g,x,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(g,y){v(y);var x=y.storage()||(n.matrix==="Matrix"?"dense":void 0);return w(g,y,x)},"number | BigNumber | Complex | Unit, Array, string":function(g,y,x){var d=f(y);return v(d),w(g,d,x)},"number | BigNumber | Complex | Unit, Matrix, string":function(g,y,x){return v(y),w(g,y,x)}});function p(N,g){var y=_e(N),x=y?new l(-1):-1,d=s(N),A=m(N),S=[[d,a(x,A)],[A,d]];return b(S,g)}function v(N){var g=N.size();if(g.length<1||g[0]!==3)throw new RangeError("Vector must be of dimensions 1x3")}function h(N){return N.reduce((g,y)=>a(g,y))}function b(N,g){if(g){if(g==="sparse")return new o(N);if(g==="dense")return new c(N);throw new TypeError('Unknown matrix type "'.concat(g,'"'))}return N}function w(N,g,y){var x=u(g);if(x===0)throw new RangeError("Rotation around zero vector");var d=_e(N)?l:null,A=d?new d(1):1,S=d?new d(-1):-1,O=d?new d(g.get([0])/x):g.get([0])/x,M=d?new d(g.get([1])/x):g.get([1])/x,$=d?new d(g.get([2])/x):g.get([2])/x,E=s(N),_=r(A,i(E)),z=m(N),I=r(E,h([O,O,_])),T=r(h([O,M,_]),h([S,$,z])),B=r(h([O,$,_]),h([M,z])),G=r(h([O,M,_]),h([$,z])),D=r(E,h([M,M,_])),H=r(h([M,$,_]),h([S,O,z])),W=r(h([O,$,_]),h([S,M,z])),j=r(h([M,$,_]),h([O,z])),V=r(E,h([$,$,_])),K=[[I,T,B],[G,D,H],[W,j,V]];return b(K,y)}}),vc="row",G0=["typed","Index","matrix","range"],hc=R(vc,G0,e=>{var{typed:t,Index:n,matrix:a,range:r}=e;return t(vc,{"Matrix, number":i,"Array, number":function(l,f){return i(a(Oe(l)),f).valueOf()}});function i(u,l){if(u.size().length!==2)throw new Error("Only two dimensional matrix is supported");Je(l,u.size()[0]);var f=r(0,u.size()[1]),c=new n(l,f);return u.subset(c)}}),dc="size",V0=["typed","config","?matrix"],Z0=R(dc,V0,e=>{var{typed:t,config:n,matrix:a}=e;return t(dc,{Matrix:function(i){return i.create(i.size())},Array:Ue,string:function(i){return n.matrix==="Array"?[i.length]:a([i.length])},"number | Complex | BigNumber | Unit | boolean | null":function(i){return n.matrix==="Array"?[]:a?a([]):uc()}})}),gc="squeeze",X0=["typed","matrix"],Y0=R(gc,X0,e=>{var{typed:t,matrix:n}=e;return t(gc,{Array:function(r){return ua(Oe(r))},Matrix:function(r){var i=ua(r.toArray());return Array.isArray(i)?n(i):i},any:function(r){return Oe(r)}})}),yc="subset",W0=["typed","matrix"],xc=R(yc,W0,e=>{var{typed:t,matrix:n}=e;return t(yc,{"Array, Index":function(r,i){var u=n(r),l=u.subset(i);return i.isScalar()?l:l.valueOf()},"Matrix, Index":function(r,i){return r.subset(i)},"Object, Index":Q0,"string, Index":J0,"Array, Index, any":function(r,i,u){return n(Oe(r)).subset(i,u,void 0).valueOf()},"Array, Index, any, any":function(r,i,u,l){return n(Oe(r)).subset(i,u,l).valueOf()},"Matrix, Index, any":function(r,i,u){return r.clone().subset(i,u)},"Matrix, Index, any, any":function(r,i,u,l){return r.clone().subset(i,u,l)},"string, Index, string":bc,"string, Index, string, string":bc,"Object, Index, any":K0})});function J0(e,t){if(!Tn(t))throw new TypeError("Index expected");if(t.size().length!==1)throw new ze(t.size().length,1);var n=e.length;Je(t.min()[0],n),Je(t.max()[0],n);var a=t.dimension(0),r="";return a.forEach(function(i){r+=e.charAt(i)}),r}function bc(e,t,n,a){if(!t||t.isIndex!==!0)throw new TypeError("Index expected");if(t.size().length!==1)throw new ze(t.size().length,1);if(a!==void 0){if(typeof a!="string"||a.length!==1)throw new TypeError("Single character expected as defaultValue")}else a=" ";var r=t.dimension(0),i=r.size()[0];if(i!==n.length)throw new ze(r.size()[0],n.length);var u=e.length;Je(t.min()[0]),Je(t.max()[0]);for(var l=[],f=0;f<u;f++)l[f]=e.charAt(f);if(r.forEach(function(s,m){l[s]=n.charAt(m[0])}),l.length>u)for(var c=u-1,o=l.length;c<o;c++)l[c]||(l[c]=a);return l.join("")}function Q0(e,t){if(t.size().length!==1)throw new ze(t.size(),1);var n=t.dimension(0);if(typeof n!="string")throw new TypeError("String expected as index to retrieve an object property");return Xr(e,n)}function K0(e,t,n){if(t.size().length!==1)throw new ze(t.size(),1);var a=t.dimension(0);if(typeof a!="string")throw new TypeError("String expected as index to retrieve an object property");var r=Oe(e);return ln(r,a,n),r}var j0="transpose",e1=["typed","matrix"],r1=R(j0,e1,e=>{var{typed:t,matrix:n}=e;return t("transpose",{Array:function(u){return this(n(u)).valueOf()},Matrix:function(u){var l=u.size(),f;switch(l.length){case 1:f=u.clone();break;case 2:{var c=l[0],o=l[1];if(o===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+Fe(l)+")");switch(u.storage()){case"dense":f=a(u,c,o);break;case"sparse":f=r(u,c,o);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+Fe(this._size)+")")}return f},any:function(u){return Oe(u)}});function a(i,u,l){for(var f=i._data,c=[],o,s=0;s<l;s++){o=c[s]=[];for(var m=0;m<u;m++)o[m]=Oe(f[m][s])}return i.createDenseMatrix({data:c,size:[l,u],datatype:i._datatype})}function r(i,u,l){for(var f=i._values,c=i._index,o=i._ptr,s=f?[]:void 0,m=[],p=[],v=[],h=0;h<u;h++)v[h]=0;var b,w,N;for(b=0,w=c.length;b<w;b++)v[c[b]]++;for(var g=0,y=0;y<u;y++)p.push(g),g+=v[y],v[y]=p[y];for(p.push(g),N=0;N<l;N++)for(var x=o[N],d=o[N+1],A=x;A<d;A++){var S=v[c[A]]++;m[S]=N,f&&(s[S]=Oe(f[A]))}return i.createSparseMatrix({values:s,index:m,ptr:p,size:[l,u],datatype:i._datatype})}}),wc="ctranspose",t1=["typed","transpose","conj"],n1=R(wc,t1,e=>{var{typed:t,transpose:n,conj:a}=e;return t(wc,{any:function(i){return a(n(i))}})}),Nc="zeros",a1=["typed","config","matrix","BigNumber"],i1=R(Nc,a1,e=>{var{typed:t,config:n,matrix:a,BigNumber:r}=e;return t(Nc,{"":function(){return n.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(c){var o=c[c.length-1];if(typeof o=="string"){var s=c.pop();return i(c,s)}else return n.matrix==="Array"?i(c):i(c,"default")},Array:i,Matrix:function(c){var o=c.storage();return i(c.valueOf(),o)},"Array | Matrix, string":function(c,o){return i(c.valueOf(),o)}});function i(f,c){var o=u(f),s=o?new r(0):0;if(l(f),c){var m=a(c);return f.length>0?m.resize(f,s):m}else{var p=[];return f.length>0?cn(p,f,s):p}}function u(f){var c=!1;return f.forEach(function(o,s,m){_e(o)&&(c=!0,m[s]=o.toNumber())}),c}function l(f){f.forEach(function(c){if(typeof c!="number"||!Se(c)||c<0)throw new Error("Parameters in function zeros must be positive integers")})}}),Mc="fft",o1=["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i"],s1=R(Mc,o1,e=>{var{typed:t,matrix:n,addScalar:a,multiplyScalar:r,divideScalar:i,exp:u,tau:l,i:f}=e;return t(Mc,{Array:c,Matrix:function(p){return p.create(c(p.toArray()))}});function c(m){var p=Ue(m);return p.length===1?s(m,p[0]):o(m.map(v=>c(v,p.slice(1))),0)}function o(m,p){var v=Ue(m);if(p!==0)return new Array(v[0]).fill(0).map((b,w)=>o(m[w],p-1));if(v.length===1)return s(m);function h(b){var w=Ue(b);return new Array(w[1]).fill(0).map((N,g)=>new Array(w[0]).fill(0).map((y,x)=>b[x][g]))}return h(o(h(m),1))}function s(m){var p=m.length;if(p===1)return[m[0]];if(p%2===0){for(var v=[...s(m.filter((N,g)=>g%2===0)),...s(m.filter((N,g)=>g%2===1))],h=0;h<p/2;h++){var b=v[h],w=r(v[h+p/2],u(r(r(l,f),i(-h,p))));v[h]=a(b,w),v[h+p/2]=a(b,r(-1,w))}return v}throw new Error("Can only calculate FFT of power-of-two size")}}),Ac="ifft",u1=["typed","fft","dotDivide","conj"],c1=R(Ac,u1,e=>{var{typed:t,fft:n,dotDivide:a,conj:r}=e;return t(Ac,{"Array | Matrix":function(u){var l=De(u)?u.size():Ue(u);return a(r(n(r(u))),l.reduce((f,c)=>f*c,1))}})}),f1="erf",l1=["typed"],m1=R(f1,l1,e=>{var{typed:t}=e;return t("name",{number:function(u){var l=Math.abs(u);return l>=h1?Bt(u):l<=p1?Bt(u)*n(l):l<=4?Bt(u)*(1-a(l)):Bt(u)*(1-r(l))},"Array | Matrix":function(u){return we(u,this)}});function n(i){var u=i*i,l=At[0][4]*u,f=u,c;for(c=0;c<3;c+=1)l=(l+At[0][c])*u,f=(f+wn[0][c])*u;return i*(l+At[0][3])/(f+wn[0][3])}function a(i){var u=At[1][8]*i,l=i,f;for(f=0;f<7;f+=1)u=(u+At[1][f])*i,l=(l+wn[1][f])*i;var c=(u+At[1][7])/(l+wn[1][7]),o=parseInt(i*16)/16,s=(i-o)*(i+o);return Math.exp(-o*o)*Math.exp(-s)*c}function r(i){var u=1/(i*i),l=At[2][5]*u,f=u,c;for(c=0;c<4;c+=1)l=(l+At[2][c])*u,f=(f+wn[2][c])*u;var o=u*(l+At[2][4])/(f+wn[2][4]);o=(v1-o)/i,u=parseInt(i*16)/16;var s=(i-u)*(i+u);return Math.exp(-u*u)*Math.exp(-s)*o}}),p1=.46875,v1=.5641895835477563,At=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,21531153547440383e-24],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],wn=[[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]],h1=Math.pow(2,53),Sc="mode",d1=["typed","isNaN","isNumeric"],g1=R(Sc,d1,e=>{var{typed:t,isNaN:n,isNumeric:a}=e;return t(Sc,{"Array | Matrix":r,"...":function(u){return r(u)}});function r(i){i=ke(i.valueOf());var u=i.length;if(u===0)throw new Error("Cannot calculate mode of an empty array");for(var l={},f=[],c=0,o=0;o<i.length;o++){var s=i[o];if(a(s)&&n(s))throw new Error("Cannot calculate mode of an array containing NaN values");s in l||(l[s]=0),l[s]++,l[s]===c?f.push(s):l[s]>c&&(c=l[s],f=[s])}return f}});function $r(e,t,n){var a;return String(e).indexOf("Unexpected type")!==-1?(a=arguments.length>2?" (type: "+je(n)+", value: "+JSON.stringify(n)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+a)):String(e).indexOf("complex numbers")!==-1?(a=arguments.length>2?" (type: "+je(n)+", value: "+JSON.stringify(n)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+a)):e}var Ec="prod",y1=["typed","config","multiplyScalar","numeric"],x1=R(Ec,y1,e=>{var{typed:t,config:n,multiplyScalar:a,numeric:r}=e;return t(Ec,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(l,f){throw new Error("prod(A, dim) is not yet supported")},"...":function(l){return i(l)}});function i(u){var l;if(Nt(u,function(f){try{l=l===void 0?f:a(l,f)}catch(c){throw $r(c,"prod",f)}}),typeof l=="string"&&(l=r(l,n.number)),l===void 0)throw new Error("Cannot calculate prod of an empty array");return l}}),Cc="format",b1=["typed"],w1=R(Cc,b1,e=>{var{typed:t}=e;return t(Cc,{any:Fe,"any, Object | function | number":Fe})}),Oc="bin",N1=["typed","format"],M1=R(Oc,N1,e=>{var{typed:t,format:n}=e;return t(Oc,{"number | BigNumber":function(r){return n(r,{notation:"bin"})},"number | BigNumber, number":function(r,i){return n(r,{notation:"bin",wordSize:i})}})}),Dc="oct",A1=["typed","format"],S1=R(Dc,A1,e=>{var{typed:t,format:n}=e;return t(Dc,{"number | BigNumber":function(r){return n(r,{notation:"oct"})},"number | BigNumber, number":function(r,i){return n(r,{notation:"oct",wordSize:i})}})}),Tc="hex",E1=["typed","format"],C1=R(Tc,E1,e=>{var{typed:t,format:n}=e;return t(Tc,{"number | BigNumber":function(r){return n(r,{notation:"hex"})},"number | BigNumber, number":function(r,i){return n(r,{notation:"hex",wordSize:i})}})}),Bc="print",O1=["typed"],D1=R(Bc,O1,e=>{var{typed:t}=e;return t(Bc,{"string, Object | Array":$c,"string, Object | Array, number | Object":$c})});function $c(e,t,n){return e.replace(/\$([\w.]+)/g,function(a,r){for(var i=r.split("."),u=t[i.shift()];i.length&&u!==void 0;){var l=i.shift();u=l?u[l]:u+"."}return u!==void 0?Ir(u)?u:Fe(u,n):a})}var _c="to",T1=["typed","matrix"],B1=R(_c,T1,e=>{var{typed:t,matrix:n}=e,a=er({typed:t}),r=Ve({typed:t});return t(_c,{"Unit, Unit | string":function(u,l){return u.to(l)},"Matrix, Matrix":function(u,l){return a(u,l,this)},"Array, Array":function(u,l){return this(n(u),n(l)).valueOf()},"Array, Matrix":function(u,l){return this(n(u),l)},"Matrix, Array":function(u,l){return this(u,n(l))},"Matrix, any":function(u,l){return r(u,l,this,!1)},"any, Matrix":function(u,l){return r(l,u,this,!0)},"Array, any":function(u,l){return r(n(u),l,this,!1).valueOf()},"any, Array":function(u,l){return r(n(l),u,this,!0).valueOf()}})}),Ic="isPrime",$1=["typed"],_1=R(Ic,$1,e=>{var{typed:t}=e;return t(Ic,{number:function(a){if(a*0!==0)return!1;if(a<=3)return a>1;if(a%2===0||a%3===0)return!1;for(var r=5;r*r<=a;r+=6)if(a%r===0||a%(r+2)===0)return!1;return!0},BigNumber:function(a){if(a.toNumber()*0!==0)return!1;if(a.lte(3))return a.gt(1);if(a.mod(2).eq(0)||a.mod(3).eq(0))return!1;if(a.lt(Math.pow(2,32))){for(var r=a.toNumber(),i=5;i*i<=r;i+=6)if(r%i===0||r%(i+2)===0)return!1;return!0}function u(N,g,y){for(var x=1;!g.eq(0);)g.mod(2).eq(0)?(g=g.div(2),N=N.mul(N).mod(y)):(g=g.sub(1),x=N.mul(x).mod(y));return x}var l=a.constructor.clone({precision:a.toFixed(0).length*2});a=new l(a);for(var f=0,c=a.sub(1);c.mod(2).eq(0);)c=c.div(2),f+=1;var o=null;if(a.lt("3317044064679887385961981"))o=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter(N=>N<a);else{var s=Math.min(a.toNumber()-2,Math.floor(2*Math.pow(a.toFixed(0).length*Math.log(10),2)));o=[];for(var m=2;m<=s;m+=1)o.push(s)}for(var p=0;p<o.length;p+=1){var v=o[p],h=u(a.sub(a).add(v),c,a);if(!h.eq(1)){for(var b=0,w=h;!w.eq(a.sub(1));b+=1,w=w.mul(w).mod(a))if(b===f-1)return!1}}return!0},"Array | Matrix":function(a){return we(a,this)}})}),I1="numeric",q1=["number","?bignumber","?fraction"],R1=R(I1,q1,e=>{var{number:t,bignumber:n,fraction:a}=e,r={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:u=>t(u),BigNumber:n?u=>n(u):Di,Fraction:a?u=>a(u):sc};return function(l,f){var c=je(l);if(!(c in r))throw new TypeError("Cannot convert "+l+' of type "'+c+'"; valid input types are '+Object.keys(r).join(", "));if(!(f in i))throw new TypeError("Cannot convert "+l+' to type "'+f+'"; valid output types are '+Object.keys(i).join(", "));return f===c?l:i[f](l)}}),qc="divideScalar",F1=["typed","numeric"],z1=R(qc,F1,e=>{var{typed:t,numeric:n}=e;return t(qc,{"number, number":function(r,i){return r/i},"Complex, Complex":function(r,i){return r.div(i)},"BigNumber, BigNumber":function(r,i){return r.div(i)},"Fraction, Fraction":function(r,i){return r.div(i)},"Unit, number | Fraction | BigNumber":function(r,i){var u=r.clone(),l=n(1,je(i));return u.value=this(u.value===null?u._normalize(l):u.value,i),u},"number | Fraction | BigNumber, Unit":function(r,i){var u=i.clone();u=u.pow(-1);var l=n(1,je(r));return u.value=this(r,i.value===null?i._normalize(l):i.value),u},"Unit, Unit":function(r,i){return r.divide(i)}})}),Rc="pow",P1=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],U1=R(Rc,P1,e=>{var{typed:t,config:n,identity:a,multiply:r,matrix:i,inv:u,number:l,fraction:f,Complex:c}=e;return t(Rc,{"number, number":o,"Complex, Complex":function(v,h){return v.pow(h)},"BigNumber, BigNumber":function(v,h){return h.isInteger()||v>=0||n.predictable?v.pow(h):new c(v.toNumber(),0).pow(h.toNumber(),0)},"Fraction, Fraction":function(v,h){var b=v.pow(h);if(b!=null)return b;if(n.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return o(v.valueOf(),h.valueOf())},"Array, number":s,"Array, BigNumber":function(v,h){return s(v,h.toNumber())},"Matrix, number":m,"Matrix, BigNumber":function(v,h){return m(v,h.toNumber())},"Unit, number | BigNumber":function(v,h){return v.pow(h)}});function o(p,v){if(n.predictable&&!Se(v)&&p<0)try{var h=f(v),b=l(h);if((v===b||Math.abs((v-b)/v)<1e-14)&&h.d%2===1)return(h.n%2===0?1:-1)*Math.pow(-p,v)}catch(w){}return n.predictable&&(p<-1&&v===1/0||p>-1&&p<0&&v===-1/0)?NaN:Se(v)||p>=0||n.predictable?ms(p,v):p*p<1&&v===1/0||p*p>1&&v===-1/0?0:new c(p,0).pow(v,0)}function s(p,v){if(!Se(v))throw new TypeError("For A^b, b must be an integer (value is "+v+")");var h=Ue(p);if(h.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+h.length+" dimensions)");if(h[0]!==h[1])throw new Error("For A^b, A must be square (size is "+h[0]+"x"+h[1]+")");if(v<0)try{return s(u(p),-v)}catch(N){throw N.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+v+")"):N}for(var b=a(h[0]).valueOf(),w=p;v>=1;)(v&1)===1&&(b=r(w,b)),v>>=1,w=r(w,w);return b}function m(p,v){return i(s(p.valueOf(),v))}}),Nn="Number of decimals in function round must be an integer",Fc="round",L1=["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],k1=R(Fc,L1,e=>{var{typed:t,matrix:n,equalScalar:a,zeros:r,BigNumber:i,DenseMatrix:u}=e,l=Nr({typed:t,equalScalar:a}),f=yr({typed:t,DenseMatrix:u}),c=Ve({typed:t});return t(Fc,{number:ps,"number, number":ps,"number, BigNumber":function(s,m){if(!m.isInteger())throw new TypeError(Nn);return new i(s).toDecimalPlaces(m.toNumber())},Complex:function(s){return s.round()},"Complex, number":function(s,m){if(m%1)throw new TypeError(Nn);return s.round(m)},"Complex, BigNumber":function(s,m){if(!m.isInteger())throw new TypeError(Nn);var p=m.toNumber();return s.round(p)},BigNumber:function(s){return s.toDecimalPlaces(0)},"BigNumber, BigNumber":function(s,m){if(!m.isInteger())throw new TypeError(Nn);return s.toDecimalPlaces(m.toNumber())},Fraction:function(s){return s.round()},"Fraction, number":function(s,m){if(m%1)throw new TypeError(Nn);return s.round(m)},"Fraction, BigNumber":function(s,m){if(!m.isInteger())throw new TypeError(Nn);return s.round(m.toNumber())},"Array | Matrix":function(s){return we(s,this)},"SparseMatrix, number | BigNumber":function(s,m){return l(s,m,this,!1)},"DenseMatrix, number | BigNumber":function(s,m){return c(s,m,this,!1)},"Array, number | BigNumber":function(s,m){return c(n(s),m,this,!1).valueOf()},"number | Complex | BigNumber | Fraction, SparseMatrix":function(s,m){return a(s,0)?r(m.size(),m.storage()):f(m,s,this,!0)},"number | Complex | BigNumber | Fraction, DenseMatrix":function(s,m){return a(s,0)?r(m.size(),m.storage()):c(m,s,this,!0)},"number | Complex | BigNumber | Fraction, Array":function(s,m){return c(n(m),s,this,!0).valueOf()}})}),zc="log",H1=["config","typed","divideScalar","Complex"],G1=R(zc,H1,e=>{var{typed:t,config:n,divideScalar:a,Complex:r}=e;return t(zc,{number:function(u){return u>=0||n.predictable?Qh(u):new r(u,0).log()},Complex:function(u){return u.log()},BigNumber:function(u){return!u.isNegative()||n.predictable?u.ln():new r(u.toNumber(),0).log()},"Array | Matrix":function(u){return we(u,this)},"any, any":function(u,l){return a(this(u),this(l))}})}),Pc="log1p",V1=["typed","config","divideScalar","log","Complex"],Z1=R(Pc,V1,e=>{var{typed:t,config:n,divideScalar:a,log:r,Complex:i}=e;return t(Pc,{number:function(f){return f>=-1||n.predictable?Yp(f):u(new i(f,0))},Complex:u,BigNumber:function(f){var c=f.plus(1);return!c.isNegative()||n.predictable?c.ln():u(new i(f.toNumber(),0))},"Array | Matrix":function(f){return we(f,this)},"any, any":function(f,c){return a(this(f),r(c))}});function u(l){var f=l.re+1;return new i(Math.log(Math.sqrt(f*f+l.im*l.im)),Math.atan2(l.im,f))}}),Uc="nthRoots",X1=["config","typed","divideScalar","Complex"],Y1=R(Uc,X1,e=>{var{typed:t,config:n,divideScalar:a,Complex:r}=e,i=[function(f){return new r(f,0)},function(f){return new r(0,f)},function(f){return new r(-f,0)},function(f){return new r(0,-f)}];function u(l,f){if(f<0)throw new Error("Root must be greater than zero");if(f===0)throw new Error("Root must be non-zero");if(f%1!==0)throw new Error("Root must be an integer");if(l===0||l.abs()===0)return[new r(0,0)];var c=typeof l=="number",o;(c||l.re===0||l.im===0)&&(c?o=2*+(l<0):l.im===0?o=2*+(l.re<0):o=2*+(l.im<0)+1);for(var s=l.arg(),m=l.abs(),p=[],v=Math.pow(m,1/f),h=0;h<f;h++){var b=(o+4*h)/f;if(b===Math.round(b)){p.push(i[b%4](v));continue}p.push(new r({r:v,phi:(s+2*Math.PI*h)/f}))}return p}return t(Uc,{Complex:function(f){return u(f,2)},"Complex, number":u})}),Lc="dotPow",W1=["typed","equalScalar","matrix","pow","DenseMatrix"],J1=R(Lc,W1,e=>{var{typed:t,equalScalar:n,matrix:a,pow:r,DenseMatrix:i}=e,u=Br({typed:t}),l=ft({typed:t,DenseMatrix:i}),f=Nr({typed:t,equalScalar:n}),c=yr({typed:t,DenseMatrix:i}),o=er({typed:t}),s=Ve({typed:t});return t(Lc,{"any, any":r,"SparseMatrix, SparseMatrix":function(p,v){return l(p,v,r,!1)},"SparseMatrix, DenseMatrix":function(p,v){return u(v,p,r,!0)},"DenseMatrix, SparseMatrix":function(p,v){return u(p,v,r,!1)},"DenseMatrix, DenseMatrix":function(p,v){return o(p,v,r)},"Array, Array":function(p,v){return this(a(p),a(v)).valueOf()},"Array, Matrix":function(p,v){return this(a(p),v)},"Matrix, Array":function(p,v){return this(p,a(v))},"SparseMatrix, any":function(p,v){return f(p,v,this,!1)},"DenseMatrix, any":function(p,v){return s(p,v,this,!1)},"any, SparseMatrix":function(p,v){return c(v,p,this,!0)},"any, DenseMatrix":function(p,v){return s(v,p,this,!0)},"Array, any":function(p,v){return s(a(p),v,this,!1).valueOf()},"any, Array":function(p,v){return s(a(v),p,this,!0).valueOf()}})}),kc="dotDivide",Q1=["typed","matrix","equalScalar","divideScalar","DenseMatrix"],K1=R(kc,Q1,e=>{var{typed:t,matrix:n,equalScalar:a,divideScalar:r,DenseMatrix:i}=e,u=nt({typed:t,equalScalar:a}),l=Br({typed:t}),f=ft({typed:t,DenseMatrix:i}),c=Nr({typed:t,equalScalar:a}),o=yr({typed:t,DenseMatrix:i}),s=er({typed:t}),m=Ve({typed:t});return t(kc,{"any, any":r,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,r,!1)},"SparseMatrix, DenseMatrix":function(v,h){return u(h,v,r,!0)},"DenseMatrix, SparseMatrix":function(v,h){return l(v,h,r,!1)},"DenseMatrix, DenseMatrix":function(v,h){return s(v,h,r)},"Array, Array":function(v,h){return this(n(v),n(h)).valueOf()},"Array, Matrix":function(v,h){return this(n(v),h)},"Matrix, Array":function(v,h){return this(v,n(h))},"SparseMatrix, any":function(v,h){return c(v,h,r,!1)},"DenseMatrix, any":function(v,h){return m(v,h,r,!1)},"any, SparseMatrix":function(v,h){return o(h,v,r,!0)},"any, DenseMatrix":function(v,h){return m(h,v,r,!0)},"Array, any":function(v,h){return m(n(v),h,r,!1).valueOf()},"any, Array":function(v,h){return m(n(h),v,r,!0).valueOf()}})});function Pn(e){var{DenseMatrix:t}=e;return function(a,r,i){var u=a.size();if(u.length!==2)throw new RangeError("Matrix must be two dimensional (size: "+Fe(u)+")");var l=u[0],f=u[1];if(l!==f)throw new RangeError("Matrix must be square (size: "+Fe(u)+")");var c=[];if(De(r)){var o=r.size(),s=r._data;if(o.length===1){if(o[0]!==l)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var m=0;m<l;m++)c[m]=[s[m]];return new t({data:c,size:[l,1],datatype:r._datatype})}if(o.length===2){if(o[0]!==l||o[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");if(ea(r)){if(i){c=[];for(var p=0;p<l;p++)c[p]=[s[p][0]];return new t({data:c,size:[l,1],datatype:r._datatype})}return r}if(kt(r)){for(var v=0;v<l;v++)c[v]=[0];for(var h=r._values,b=r._index,w=r._ptr,N=w[1],g=w[0];g<N;g++){var y=b[g];c[y][0]=h[g]}return new t({data:c,size:[l,1],datatype:r._datatype})}}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}if(Ye(r)){var x=Ue(r);if(x.length===1){if(x[0]!==l)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var d=0;d<l;d++)c[d]=[r[d]];return new t({data:c,size:[l,1]})}if(x.length===2){if(x[0]!==l||x[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var A=0;A<l;A++)c[A]=[r[A][0]];return new t({data:c,size:[l,1]})}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}}}var Hc="lsolve",j1=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],ex=R(Hc,j1,e=>{var{typed:t,matrix:n,divideScalar:a,multiplyScalar:r,subtract:i,equalScalar:u,DenseMatrix:l}=e,f=Pn({DenseMatrix:l});return t(Hc,{"SparseMatrix, Array | Matrix":function(m,p){return o(m,p)},"DenseMatrix, Array | Matrix":function(m,p){return c(m,p)},"Array, Array | Matrix":function(m,p){var v=n(m),h=c(v,p);return h.valueOf()}});function c(s,m){m=f(s,m,!0);for(var p=m._data,v=s._size[0],h=s._size[1],b=[],w=s._data,N=0;N<h;N++){var g=p[N][0]||0,y=void 0;if(u(g,0))y=0;else{var x=w[N][N];if(u(x,0))throw new Error("Linear system cannot be solved since matrix is singular");y=a(g,x);for(var d=N+1;d<v;d++)p[d]=[i(p[d][0]||0,r(y,w[d][N]))]}b[N]=[y]}return new l({data:b,size:[v,1]})}function o(s,m){m=f(s,m,!0);for(var p=m._data,v=s._size[0],h=s._size[1],b=s._values,w=s._index,N=s._ptr,g=[],y=0;y<h;y++){var x=p[y][0]||0;if(u(x,0))g[y]=[0];else{for(var d=0,A=[],S=[],O=N[y],M=N[y+1],$=O;$<M;$++){var E=w[$];E===y?d=b[$]:E>y&&(A.push(b[$]),S.push(E))}if(u(d,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var _=a(x,d),z=0,I=S.length;z<I;z++){var T=S[z];p[T]=[i(p[T][0]||0,r(_,A[z]))]}g[y]=[_]}}return new l({data:g,size:[v,1]})}}),Gc="usolve",rx=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],tx=R(Gc,rx,e=>{var{typed:t,matrix:n,divideScalar:a,multiplyScalar:r,subtract:i,equalScalar:u,DenseMatrix:l}=e,f=Pn({DenseMatrix:l});return t(Gc,{"SparseMatrix, Array | Matrix":function(m,p){return o(m,p)},"DenseMatrix, Array | Matrix":function(m,p){return c(m,p)},"Array, Array | Matrix":function(m,p){var v=n(m),h=c(v,p);return h.valueOf()}});function c(s,m){m=f(s,m,!0);for(var p=m._data,v=s._size[0],h=s._size[1],b=[],w=s._data,N=h-1;N>=0;N--){var g=p[N][0]||0,y=void 0;if(u(g,0))y=0;else{var x=w[N][N];if(u(x,0))throw new Error("Linear system cannot be solved since matrix is singular");y=a(g,x);for(var d=N-1;d>=0;d--)p[d]=[i(p[d][0]||0,r(y,w[d][N]))]}b[N]=[y]}return new l({data:b,size:[v,1]})}function o(s,m){m=f(s,m,!0);for(var p=m._data,v=s._size[0],h=s._size[1],b=s._values,w=s._index,N=s._ptr,g=[],y=h-1;y>=0;y--){var x=p[y][0]||0;if(u(x,0))g[y]=[0];else{for(var d=0,A=[],S=[],O=N[y],M=N[y+1],$=M-1;$>=O;$--){var E=w[$];E===y?d=b[$]:E<y&&(A.push(b[$]),S.push(E))}if(u(d,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var _=a(x,d),z=0,I=S.length;z<I;z++){var T=S[z];p[T]=[i(p[T][0],r(_,A[z]))]}g[y]=[_]}}return new l({data:g,size:[v,1]})}}),Vc="lsolveAll",nx=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],ax=R(Vc,nx,e=>{var{typed:t,matrix:n,divideScalar:a,multiplyScalar:r,subtract:i,equalScalar:u,DenseMatrix:l}=e,f=Pn({DenseMatrix:l});return t(Vc,{"SparseMatrix, Array | Matrix":function(m,p){return o(m,p)},"DenseMatrix, Array | Matrix":function(m,p){return c(m,p)},"Array, Array | Matrix":function(m,p){var v=n(m),h=c(v,p);return h.map(b=>b.valueOf())}});function c(s,m){for(var p=[f(s,m,!0)._data.map(S=>S[0])],v=s._data,h=s._size[0],b=s._size[1],w=0;w<b;w++)for(var N=p.length,g=0;g<N;g++){var y=p[g];if(u(v[w][w],0))if(u(y[w],0)){if(g===0){var d=[...y];d[w]=1;for(var A=w+1;A<b;A++)d[A]=i(d[A],v[A][w]);p.push(d)}}else{if(g===0)return[];p.splice(g,1),g-=1,N-=1}else{y[w]=a(y[w],v[w][w]);for(var x=w+1;x<b;x++)y[x]=i(y[x],r(y[w],v[x][w]))}}return p.map(S=>new l({data:S.map(O=>[O]),size:[h,1]}))}function o(s,m){for(var p=[f(s,m,!0)._data.map(W=>W[0])],v=s._size[0],h=s._size[1],b=s._values,w=s._index,N=s._ptr,g=0;g<h;g++)for(var y=p.length,x=0;x<y;x++){for(var d=p[x],A=[],S=[],O=N[g],M=N[g+1],$=0,E=O;E<M;E++){var _=w[E];_===g?$=b[E]:_>g&&(A.push(b[E]),S.push(_))}if(u($,0))if(u(d[g],0)){if(x===0){var B=[...d];B[g]=1;for(var G=0,D=S.length;G<D;G++){var H=S[G];B[H]=i(B[H],A[G])}p.push(B)}}else{if(x===0)return[];p.splice(x,1),x-=1,y-=1}else{d[g]=a(d[g],$);for(var z=0,I=S.length;z<I;z++){var T=S[z];d[T]=i(d[T],r(d[g],A[z]))}}}return p.map(W=>new l({data:W.map(j=>[j]),size:[v,1]}))}}),Zc="usolveAll",ix=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],ox=R(Zc,ix,e=>{var{typed:t,matrix:n,divideScalar:a,multiplyScalar:r,subtract:i,equalScalar:u,DenseMatrix:l}=e,f=Pn({DenseMatrix:l});return t(Zc,{"SparseMatrix, Array | Matrix":function(m,p){return o(m,p)},"DenseMatrix, Array | Matrix":function(m,p){return c(m,p)},"Array, Array | Matrix":function(m,p){var v=n(m),h=c(v,p);return h.map(b=>b.valueOf())}});function c(s,m){for(var p=[f(s,m,!0)._data.map(S=>S[0])],v=s._data,h=s._size[0],b=s._size[1],w=b-1;w>=0;w--)for(var N=p.length,g=0;g<N;g++){var y=p[g];if(u(v[w][w],0))if(u(y[w],0)){if(g===0){var d=[...y];d[w]=1;for(var A=w-1;A>=0;A--)d[A]=i(d[A],v[A][w]);p.push(d)}}else{if(g===0)return[];p.splice(g,1),g-=1,N-=1}else{y[w]=a(y[w],v[w][w]);for(var x=w-1;x>=0;x--)y[x]=i(y[x],r(y[w],v[x][w]))}}return p.map(S=>new l({data:S.map(O=>[O]),size:[h,1]}))}function o(s,m){for(var p=[f(s,m,!0)._data.map(W=>W[0])],v=s._size[0],h=s._size[1],b=s._values,w=s._index,N=s._ptr,g=h-1;g>=0;g--)for(var y=p.length,x=0;x<y;x++){for(var d=p[x],A=[],S=[],O=N[g],M=N[g+1],$=0,E=M-1;E>=O;E--){var _=w[E];_===g?$=b[E]:_<g&&(A.push(b[E]),S.push(_))}if(u($,0))if(u(d[g],0)){if(x===0){var B=[...d];B[g]=1;for(var G=0,D=S.length;G<D;G++){var H=S[G];B[H]=i(B[H],A[G])}p.push(B)}}else{if(x===0)return[];p.splice(x,1),x-=1,y-=1}else{d[g]=a(d[g],$);for(var z=0,I=S.length;z<I;z++){var T=S[z];d[T]=i(d[T],r(d[g],A[z]))}}}return p.map(W=>new l({data:W.map(j=>[j]),size:[v,1]}))}}),sx="algorithm08",ux=["typed","equalScalar"],Ti=R(sx,ux,e=>{var{typed:t,equalScalar:n}=e;return function(r,i,u){var l=r._values,f=r._index,c=r._ptr,o=r._size,s=r._datatype,m=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(o.length!==h.length)throw new ze(o.length,h.length);if(o[0]!==h[0]||o[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+h+")");if(!l||!m)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var w=o[0],N=o[1],g,y=n,x=0,d=u;typeof s=="string"&&s===b&&(g=s,y=t.find(n,[g,g]),x=t.convert(0,g),d=t.find(u,[g,g]));for(var A=[],S=[],O=[],M=[],$=[],E,_,z,I,T=0;T<N;T++){O[T]=S.length;var B=T+1;for(_=c[T],z=c[T+1],E=_;E<z;E++)I=f[E],$[I]=B,M[I]=l[E],S.push(I);for(_=v[T],z=v[T+1],E=_;E<z;E++)I=p[E],$[I]===B&&(M[I]=d(M[I],m[E]));for(E=O[T];E<S.length;){I=S[E];var G=M[I];y(G,x)?S.splice(E,1):(A.push(G),E++)}}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),Xc="leftShift",cx=["typed","matrix","equalScalar","zeros","DenseMatrix"],fx=R(Xc,cx,e=>{var{typed:t,matrix:n,equalScalar:a,zeros:r,DenseMatrix:i}=e,u=Ft({typed:t}),l=nt({typed:t,equalScalar:a}),f=Ti({typed:t,equalScalar:a}),c=Yt({typed:t,DenseMatrix:i}),o=Nr({typed:t,equalScalar:a}),s=er({typed:t}),m=Ve({typed:t});return t(Xc,{"number, number":ys,"BigNumber, BigNumber":$y,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return l(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return u(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return s(v,h,this)},"Array, Array":function(v,h){return this(n(v),n(h)).valueOf()},"Array, Matrix":function(v,h){return this(n(v),h)},"Matrix, Array":function(v,h){return this(v,n(h))},"SparseMatrix, number | BigNumber":function(v,h){return a(h,0)?v.clone():o(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return a(h,0)?v.clone():m(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return a(v,0)?r(h.size(),h.storage()):c(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return a(v,0)?r(h.size(),h.storage()):m(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(n(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,n(h)).valueOf()}})}),Yc="rightArithShift",lx=["typed","matrix","equalScalar","zeros","DenseMatrix"],mx=R(Yc,lx,e=>{var{typed:t,matrix:n,equalScalar:a,zeros:r,DenseMatrix:i}=e,u=Ft({typed:t}),l=nt({typed:t,equalScalar:a}),f=Ti({typed:t,equalScalar:a}),c=Yt({typed:t,DenseMatrix:i}),o=Nr({typed:t,equalScalar:a}),s=er({typed:t}),m=Ve({typed:t});return t(Yc,{"number, number":xs,"BigNumber, BigNumber":_y,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return l(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return u(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return s(v,h,this)},"Array, Array":function(v,h){return this(n(v),n(h)).valueOf()},"Array, Matrix":function(v,h){return this(n(v),h)},"Matrix, Array":function(v,h){return this(v,n(h))},"SparseMatrix, number | BigNumber":function(v,h){return a(h,0)?v.clone():o(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return a(h,0)?v.clone():m(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return a(v,0)?r(h.size(),h.storage()):c(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return a(v,0)?r(h.size(),h.storage()):m(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(n(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,n(h)).valueOf()}})}),Wc="rightLogShift",px=["typed","matrix","equalScalar","zeros","DenseMatrix"],vx=R(Wc,px,e=>{var{typed:t,matrix:n,equalScalar:a,zeros:r,DenseMatrix:i}=e,u=Ft({typed:t}),l=nt({typed:t,equalScalar:a}),f=Ti({typed:t,equalScalar:a}),c=Yt({typed:t,DenseMatrix:i}),o=Nr({typed:t,equalScalar:a}),s=er({typed:t}),m=Ve({typed:t});return t(Wc,{"number, number":bs,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return l(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return u(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return s(v,h,this)},"Array, Array":function(v,h){return this(n(v),n(h)).valueOf()},"Array, Matrix":function(v,h){return this(n(v),h)},"Matrix, Array":function(v,h){return this(v,n(h))},"SparseMatrix, number | BigNumber":function(v,h){return a(h,0)?v.clone():o(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return a(h,0)?v.clone():m(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return a(v,0)?r(h.size(),h.storage()):c(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return a(v,0)?r(h.size(),h.storage()):m(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(n(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,n(h)).valueOf()}})}),Jc="and",hx=["typed","matrix","equalScalar","zeros","not"],dx=R(Jc,hx,e=>{var{typed:t,matrix:n,equalScalar:a,zeros:r,not:i}=e,u=nt({typed:t,equalScalar:a}),l=Da({typed:t,equalScalar:a}),f=Nr({typed:t,equalScalar:a}),c=er({typed:t}),o=Ve({typed:t});return t(Jc,{"number, number":Ss,"Complex, Complex":function(m,p){return(m.re!==0||m.im!==0)&&(p.re!==0||p.im!==0)},"BigNumber, BigNumber":function(m,p){return!m.isZero()&&!p.isZero()&&!m.isNaN()&&!p.isNaN()},"Unit, Unit":function(m,p){return this(m.value||0,p.value||0)},"SparseMatrix, SparseMatrix":function(m,p){return l(m,p,this,!1)},"SparseMatrix, DenseMatrix":function(m,p){return u(p,m,this,!0)},"DenseMatrix, SparseMatrix":function(m,p){return u(m,p,this,!1)},"DenseMatrix, DenseMatrix":function(m,p){return c(m,p,this)},"Array, Array":function(m,p){return this(n(m),n(p)).valueOf()},"Array, Matrix":function(m,p){return this(n(m),p)},"Matrix, Array":function(m,p){return this(m,n(p))},"SparseMatrix, any":function(m,p){return i(p)?r(m.size(),m.storage()):f(m,p,this,!1)},"DenseMatrix, any":function(m,p){return i(p)?r(m.size(),m.storage()):o(m,p,this,!1)},"any, SparseMatrix":function(m,p){return i(m)?r(m.size(),m.storage()):f(p,m,this,!0)},"any, DenseMatrix":function(m,p){return i(m)?r(m.size(),m.storage()):o(p,m,this,!0)},"Array, any":function(m,p){return this(n(m),p).valueOf()},"any, Array":function(m,p){return this(m,n(p)).valueOf()}})}),Qc="compare",gx=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],yx=R(Qc,gx,e=>{var{typed:t,config:n,equalScalar:a,matrix:r,BigNumber:i,Fraction:u,DenseMatrix:l}=e,f=Br({typed:t}),c=Ta({typed:t,equalScalar:a}),o=yr({typed:t,DenseMatrix:l}),s=er({typed:t}),m=Ve({typed:t});return t(Qc,{"boolean, boolean":function(v,h){return v===h?0:v>h?1:-1},"number, number":function(v,h){return Fr(v,h,n.epsilon)?0:v>h?1:-1},"BigNumber, BigNumber":function(v,h){return ct(v,h,n.epsilon)?new i(0):new i(v.cmp(h))},"Fraction, Fraction":function(v,h){return new u(v.compare(h))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(v,h){if(!v.equalBase(h))throw new Error("Cannot compare units with different base");return this(v.value,h.value)},"SparseMatrix, SparseMatrix":function(v,h){return c(v,h,this)},"SparseMatrix, DenseMatrix":function(v,h){return f(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return s(v,h,this)},"Array, Array":function(v,h){return this(r(v),r(h)).valueOf()},"Array, Matrix":function(v,h){return this(r(v),h)},"Matrix, Array":function(v,h){return this(v,r(h))},"SparseMatrix, any":function(v,h){return o(v,h,this,!1)},"DenseMatrix, any":function(v,h){return m(v,h,this,!1)},"any, SparseMatrix":function(v,h){return o(h,v,this,!0)},"any, DenseMatrix":function(v,h){return m(h,v,this,!0)},"Array, any":function(v,h){return m(r(v),h,this,!1).valueOf()},"any, Array":function(v,h){return m(r(h),v,this,!0).valueOf()}})}),Bi,Kc;function xx(){return Kc||(Kc=1,Bi=function e(t,n){var a=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,r=/(^[ ]*|[ ]*$)/g,i=/(^([\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,l=/^0/,f=function(g){return e.insensitive&&(""+g).toLowerCase()||""+g},c=f(t).replace(r,"")||"",o=f(n).replace(r,"")||"",s=c.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),m=o.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),p=parseInt(c.match(u),16)||s.length!==1&&c.match(i)&&Date.parse(c),v=parseInt(o.match(u),16)||p&&o.match(i)&&Date.parse(o)||null,h,b;if(v){if(p<v)return-1;if(p>v)return 1}for(var w=0,N=Math.max(s.length,m.length);w<N;w++){if(h=!(s[w]||"").match(l)&&parseFloat(s[w])||s[w]||0,b=!(m[w]||"").match(l)&&parseFloat(m[w])||m[w]||0,isNaN(h)!==isNaN(b))return isNaN(h)?1:-1;if(typeof h!=typeof b&&(h+="",b+=""),h<b)return-1;if(h>b)return 1}return 0}),Bi}var bx=xx();const Mn=na(bx);var jc="compareNatural",wx=["typed","compare"],Nx=R(jc,wx,e=>{var{typed:t,compare:n}=e,a=n.signatures["boolean,boolean"];return t(jc,{"any, any":function(f,c){var o=je(f),s=je(c),m;if((o==="number"||o==="BigNumber"||o==="Fraction")&&(s==="number"||s==="BigNumber"||s==="Fraction"))return m=n(f,c),m.toString()!=="0"?m>0?1:-1:Mn(o,s);if(o==="Array"||o==="Matrix"||s==="Array"||s==="Matrix")return m=r(this,f,c),m!==0?m:Mn(o,s);if(o!==s)return Mn(o,s);if(o==="Complex")return Mx(f,c);if(o==="Unit")return f.equalBase(c)?this(f.value,c.value):i(this,f.formatUnits(),c.formatUnits());if(o==="boolean")return a(f,c);if(o==="string")return Mn(f,c);if(o==="Object")return u(this,f,c);if(o==="null"||o==="undefined")return 0;throw new TypeError('Unsupported type of value "'+o+'"')}});function r(l,f,c){return kt(f)&&kt(c)?i(l,f.toJSON().values,c.toJSON().values):kt(f)?r(l,f.toArray(),c):kt(c)?r(l,f,c.toArray()):ea(f)?r(l,f.toJSON().data,c):ea(c)?r(l,f,c.toJSON().data):Array.isArray(f)?Array.isArray(c)?i(l,f,c):r(l,f,[c]):r(l,[f],c)}function i(l,f,c){for(var o=0,s=Math.min(f.length,c.length);o<s;o++){var m=l(f[o],c[o]);if(m!==0)return m}return f.length>c.length?1:f.length<c.length?-1:0}function u(l,f,c){var o=Object.keys(f),s=Object.keys(c);o.sort(Mn),s.sort(Mn);var m=i(l,o,s);if(m!==0)return m;for(var p=0;p<o.length;p++){var v=l(f[o[p]],c[s[p]]);if(v!==0)return v}return 0}});function Mx(e,t){return e.re>t.re?1:e.re<t.re?-1:e.im>t.im?1:e.im<t.im?-1:0}var ef="compareText",Ax=["typed","matrix"],Sx=R(ef,Ax,e=>{var{typed:t,matrix:n}=e,a=er({typed:t}),r=Ve({typed:t});return t(ef,{"any, any":un,"DenseMatrix, DenseMatrix":function(u,l){return a(u,l,un)},"Array, Array":function(u,l){return this(n(u),n(l)).valueOf()},"Array, Matrix":function(u,l){return this(n(u),l)},"Matrix, Array":function(u,l){return this(u,n(l))},"DenseMatrix, any":function(u,l){return r(u,l,un,!1)},"any, DenseMatrix":function(u,l){return r(l,u,un,!0)},"Array, any":function(u,l){return r(n(u),l,un,!1).valueOf()},"any, Array":function(u,l){return r(n(l),u,un,!0).valueOf()}})}),_a="equal",Ex=["typed","matrix","equalScalar","DenseMatrix"],Cx=R(_a,Ex,e=>{var{typed:t,matrix:n,equalScalar:a,DenseMatrix:r}=e,i=Br({typed:t}),u=ft({typed:t,DenseMatrix:r}),l=yr({typed:t,DenseMatrix:r}),f=er({typed:t}),c=Ve({typed:t});return t(_a,{"any, any":function(s,m){return s===null?m===null:m===null?s===null:s===void 0?m===void 0:m===void 0?s===void 0:a(s,m)},"SparseMatrix, SparseMatrix":function(s,m){return u(s,m,a)},"SparseMatrix, DenseMatrix":function(s,m){return i(m,s,a,!0)},"DenseMatrix, SparseMatrix":function(s,m){return i(s,m,a,!1)},"DenseMatrix, DenseMatrix":function(s,m){return f(s,m,a)},"Array, Array":function(s,m){return this(n(s),n(m)).valueOf()},"Array, Matrix":function(s,m){return this(n(s),m)},"Matrix, Array":function(s,m){return this(s,n(m))},"SparseMatrix, any":function(s,m){return l(s,m,a,!1)},"DenseMatrix, any":function(s,m){return c(s,m,a,!1)},"any, SparseMatrix":function(s,m){return l(m,s,a,!0)},"any, DenseMatrix":function(s,m){return c(m,s,a,!0)},"Array, any":function(s,m){return c(n(s),m,a,!1).valueOf()},"any, Array":function(s,m){return c(n(m),s,a,!0).valueOf()}})});R(_a,["typed","equalScalar"],e=>{var{typed:t,equalScalar:n}=e;return t(_a,{"any, any":function(r,i){return r===null?i===null:i===null?r===null:r===void 0?i===void 0:i===void 0?r===void 0:n(r,i)}})});var rf="equalText",Ox=["typed","compareText","isZero"],Dx=R(rf,Ox,e=>{var{typed:t,compareText:n,isZero:a}=e;return t(rf,{"any, any":function(i,u){return a(n(i,u))}})}),tf="smaller",Tx=["typed","config","matrix","DenseMatrix"],Bx=R(tf,Tx,e=>{var{typed:t,config:n,matrix:a,DenseMatrix:r}=e,i=Br({typed:t}),u=ft({typed:t,DenseMatrix:r}),l=yr({typed:t,DenseMatrix:r}),f=er({typed:t}),c=Ve({typed:t});return t(tf,{"boolean, boolean":function(s,m){return s<m},"number, number":function(s,m){return s<m&&!Fr(s,m,n.epsilon)},"BigNumber, BigNumber":function(s,m){return s.lt(m)&&!ct(s,m,n.epsilon)},"Fraction, Fraction":function(s,m){return s.compare(m)===-1},"Complex, Complex":function(s,m){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(s,m){if(!s.equalBase(m))throw new Error("Cannot compare units with different base");return this(s.value,m.value)},"SparseMatrix, SparseMatrix":function(s,m){return u(s,m,this)},"SparseMatrix, DenseMatrix":function(s,m){return i(m,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,m){return i(s,m,this,!1)},"DenseMatrix, DenseMatrix":function(s,m){return f(s,m,this)},"Array, Array":function(s,m){return this(a(s),a(m)).valueOf()},"Array, Matrix":function(s,m){return this(a(s),m)},"Matrix, Array":function(s,m){return this(s,a(m))},"SparseMatrix, any":function(s,m){return l(s,m,this,!1)},"DenseMatrix, any":function(s,m){return c(s,m,this,!1)},"any, SparseMatrix":function(s,m){return l(m,s,this,!0)},"any, DenseMatrix":function(s,m){return c(m,s,this,!0)},"Array, any":function(s,m){return c(a(s),m,this,!1).valueOf()},"any, Array":function(s,m){return c(a(m),s,this,!0).valueOf()}})}),nf="smallerEq",$x=["typed","config","matrix","DenseMatrix"],_x=R(nf,$x,e=>{var{typed:t,config:n,matrix:a,DenseMatrix:r}=e,i=Br({typed:t}),u=ft({typed:t,DenseMatrix:r}),l=yr({typed:t,DenseMatrix:r}),f=er({typed:t}),c=Ve({typed:t});return t(nf,{"boolean, boolean":function(s,m){return s<=m},"number, number":function(s,m){return s<=m||Fr(s,m,n.epsilon)},"BigNumber, BigNumber":function(s,m){return s.lte(m)||ct(s,m,n.epsilon)},"Fraction, Fraction":function(s,m){return s.compare(m)!==1},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(s,m){if(!s.equalBase(m))throw new Error("Cannot compare units with different base");return this(s.value,m.value)},"SparseMatrix, SparseMatrix":function(s,m){return u(s,m,this)},"SparseMatrix, DenseMatrix":function(s,m){return i(m,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,m){return i(s,m,this,!1)},"DenseMatrix, DenseMatrix":function(s,m){return f(s,m,this)},"Array, Array":function(s,m){return this(a(s),a(m)).valueOf()},"Array, Matrix":function(s,m){return this(a(s),m)},"Matrix, Array":function(s,m){return this(s,a(m))},"SparseMatrix, any":function(s,m){return l(s,m,this,!1)},"DenseMatrix, any":function(s,m){return c(s,m,this,!1)},"any, SparseMatrix":function(s,m){return l(m,s,this,!0)},"any, DenseMatrix":function(s,m){return c(m,s,this,!0)},"Array, any":function(s,m){return c(a(s),m,this,!1).valueOf()},"any, Array":function(s,m){return c(a(m),s,this,!0).valueOf()}})}),af="larger",Ix=["typed","config","matrix","DenseMatrix"],qx=R(af,Ix,e=>{var{typed:t,config:n,matrix:a,DenseMatrix:r}=e,i=Br({typed:t}),u=ft({typed:t,DenseMatrix:r}),l=yr({typed:t,DenseMatrix:r}),f=er({typed:t}),c=Ve({typed:t});return t(af,{"boolean, boolean":function(s,m){return s>m},"number, number":function(s,m){return s>m&&!Fr(s,m,n.epsilon)},"BigNumber, BigNumber":function(s,m){return s.gt(m)&&!ct(s,m,n.epsilon)},"Fraction, Fraction":function(s,m){return s.compare(m)===1},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(s,m){if(!s.equalBase(m))throw new Error("Cannot compare units with different base");return this(s.value,m.value)},"SparseMatrix, SparseMatrix":function(s,m){return u(s,m,this)},"SparseMatrix, DenseMatrix":function(s,m){return i(m,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,m){return i(s,m,this,!1)},"DenseMatrix, DenseMatrix":function(s,m){return f(s,m,this)},"Array, Array":function(s,m){return this(a(s),a(m)).valueOf()},"Array, Matrix":function(s,m){return this(a(s),m)},"Matrix, Array":function(s,m){return this(s,a(m))},"SparseMatrix, any":function(s,m){return l(s,m,this,!1)},"DenseMatrix, any":function(s,m){return c(s,m,this,!1)},"any, SparseMatrix":function(s,m){return l(m,s,this,!0)},"any, DenseMatrix":function(s,m){return c(m,s,this,!0)},"Array, any":function(s,m){return c(a(s),m,this,!1).valueOf()},"any, Array":function(s,m){return c(a(m),s,this,!0).valueOf()}})}),of="largerEq",Rx=["typed","config","matrix","DenseMatrix"],Fx=R(of,Rx,e=>{var{typed:t,config:n,matrix:a,DenseMatrix:r}=e,i=Br({typed:t}),u=ft({typed:t,DenseMatrix:r}),l=yr({typed:t,DenseMatrix:r}),f=er({typed:t}),c=Ve({typed:t});return t(of,{"boolean, boolean":function(s,m){return s>=m},"number, number":function(s,m){return s>=m||Fr(s,m,n.epsilon)},"BigNumber, BigNumber":function(s,m){return s.gte(m)||ct(s,m,n.epsilon)},"Fraction, Fraction":function(s,m){return s.compare(m)!==-1},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(s,m){if(!s.equalBase(m))throw new Error("Cannot compare units with different base");return this(s.value,m.value)},"SparseMatrix, SparseMatrix":function(s,m){return u(s,m,this)},"SparseMatrix, DenseMatrix":function(s,m){return i(m,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,m){return i(s,m,this,!1)},"DenseMatrix, DenseMatrix":function(s,m){return f(s,m,this)},"Array, Array":function(s,m){return this(a(s),a(m)).valueOf()},"Array, Matrix":function(s,m){return this(a(s),m)},"Matrix, Array":function(s,m){return this(s,a(m))},"SparseMatrix, any":function(s,m){return l(s,m,this,!1)},"DenseMatrix, any":function(s,m){return c(s,m,this,!1)},"any, SparseMatrix":function(s,m){return l(m,s,this,!0)},"any, DenseMatrix":function(s,m){return c(m,s,this,!0)},"Array, any":function(s,m){return c(a(s),m,this,!1).valueOf()},"any, Array":function(s,m){return c(a(m),s,this,!0).valueOf()}})}),sf="deepEqual",zx=["typed","equal"],Px=R(sf,zx,e=>{var{typed:t,equal:n}=e;return t(sf,{"any, any":function(i,u){return a(i.valueOf(),u.valueOf())}});function a(r,i){if(Array.isArray(r))if(Array.isArray(i)){var u=r.length;if(u!==i.length)return!1;for(var l=0;l<u;l++)if(!a(r[l],i[l]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:n(r,i)}}),$i="unequal",Ux=["typed","config","equalScalar","matrix","DenseMatrix"],Lx=R($i,Ux,e=>{var{typed:t,config:n,equalScalar:a,matrix:r,DenseMatrix:i}=e,u=Br({typed:t}),l=ft({typed:t,DenseMatrix:i}),f=yr({typed:t,DenseMatrix:i}),c=er({typed:t}),o=Ve({typed:t});return t("unequal",{"any, any":function(p,v){return p===null?v!==null:v===null?p!==null:p===void 0?v!==void 0:v===void 0?p!==void 0:s(p,v)},"SparseMatrix, SparseMatrix":function(p,v){return l(p,v,s)},"SparseMatrix, DenseMatrix":function(p,v){return u(v,p,s,!0)},"DenseMatrix, SparseMatrix":function(p,v){return u(p,v,s,!1)},"DenseMatrix, DenseMatrix":function(p,v){return c(p,v,s)},"Array, Array":function(p,v){return this(r(p),r(v)).valueOf()},"Array, Matrix":function(p,v){return this(r(p),v)},"Matrix, Array":function(p,v){return this(p,r(v))},"SparseMatrix, any":function(p,v){return f(p,v,s,!1)},"DenseMatrix, any":function(p,v){return o(p,v,s,!1)},"any, SparseMatrix":function(p,v){return f(v,p,s,!0)},"any, DenseMatrix":function(p,v){return o(v,p,s,!0)},"Array, any":function(p,v){return o(r(p),v,s,!1).valueOf()},"any, Array":function(p,v){return o(r(v),p,s,!0).valueOf()}});function s(m,p){return!a(m,p)}});R($i,["typed","equalScalar"],e=>{var{typed:t,equalScalar:n}=e;return t($i,{"any, any":function(r,i){return r===null?i!==null:i===null?r!==null:r===void 0?i!==void 0:i===void 0?r!==void 0:!n(r,i)}})});var uf="partitionSelect",kx=["typed","isNumeric","isNaN","compare"],Hx=R(uf,kx,e=>{var{typed:t,isNumeric:n,isNaN:a,compare:r}=e,i=r,u=(c,o)=>-r(c,o);return t(uf,{"Array | Matrix, number":function(o,s){return l(o,s,i)},"Array | Matrix, number, string":function(o,s,m){if(m==="asc")return l(o,s,i);if(m==="desc")return l(o,s,u);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":l});function l(c,o,s){if(!Se(o)||o<0)throw new Error("k must be a non-negative integer");if(De(c)){var m=c.size();if(m.length>1)throw new Error("Only one dimensional matrices supported");return f(c.valueOf(),o,s)}if(Array.isArray(c))return f(c,o,s)}function f(c,o,s){if(o>=c.length)throw new Error("k out of bounds");for(var m=0;m<c.length;m++)if(n(c[m])&&a(c[m]))return c[m];for(var p=0,v=c.length-1;p<v;){for(var h=p,b=v,w=c[Math.floor(Math.random()*(v-p+1))+p];h<b;)if(s(c[h],w)>=0){var N=c[b];c[b]=c[h],c[h]=N,--b}else++h;s(c[h],w)>0&&--h,o<=h?v=h:p=h+1}return c[o]}}),cf="sort",Gx=["typed","matrix","compare","compareNatural"],Vx=R(cf,Gx,e=>{var{typed:t,matrix:n,compare:a,compareNatural:r}=e,i=a,u=(o,s)=>-a(o,s);return t(cf,{Array:function(s){return f(s),s.sort(i)},Matrix:function(s){return c(s),n(s.toArray().sort(i),s.storage())},"Array, function":function(s,m){return f(s),s.sort(m)},"Matrix, function":function(s,m){return c(s),n(s.toArray().sort(m),s.storage())},"Array, string":function(s,m){return f(s),s.sort(l(m))},"Matrix, string":function(s,m){return c(s),n(s.toArray().sort(l(m)),s.storage())}});function l(o){if(o==="asc")return i;if(o==="desc")return u;if(o==="natural")return r;throw new Error('String "asc", "desc", or "natural" expected')}function f(o){if(Ue(o).length!==1)throw new Error("One dimensional array expected")}function c(o){if(o.size().length!==1)throw new Error("One dimensional matrix expected")}}),ff="max",Zx=["typed","config","numeric","larger"],lf=R(ff,Zx,e=>{var{typed:t,config:n,numeric:a,larger:r}=e;return t(ff,{"Array | Matrix":u,"Array | Matrix, number | BigNumber":function(f,c){return Ma(f,c.valueOf(),i)},"...":function(f){if(dn(f))throw new TypeError("Scalar values expected in function max");return u(f)}});function i(l,f){try{return r(l,f)?l:f}catch(c){throw $r(c,"max",f)}}function u(l){var f;if(Nt(l,function(c){try{isNaN(c)&&typeof c=="number"?f=NaN:(f===void 0||r(c,f))&&(f=c)}catch(o){throw $r(o,"max",c)}}),f===void 0)throw new Error("Cannot calculate max of an empty array");return typeof f=="string"&&(f=a(f,n.number)),f}}),mf="min",Xx=["typed","config","numeric","smaller"],pf=R(mf,Xx,e=>{var{typed:t,config:n,numeric:a,smaller:r}=e;return t(mf,{"Array | Matrix":u,"Array | Matrix, number | BigNumber":function(f,c){return Ma(f,c.valueOf(),i)},"...":function(f){if(dn(f))throw new TypeError("Scalar values expected in function min");return u(f)}});function i(l,f){try{return r(l,f)?l:f}catch(c){throw $r(c,"min",f)}}function u(l){var f;if(Nt(l,function(c){try{isNaN(c)&&typeof c=="number"?f=NaN:(f===void 0||r(c,f))&&(f=c)}catch(o){throw $r(o,"min",c)}}),f===void 0)throw new Error("Cannot calculate min of an empty array");return typeof f=="string"&&(f=a(f,n.number)),f}}),Yx="ImmutableDenseMatrix",Wx=["smaller","DenseMatrix"],Jx=R(Yx,Wx,e=>{var{smaller:t,DenseMatrix:n}=e;function a(r,i){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(i&&!Ir(i))throw new Error("Invalid datatype: "+i);if(De(r)||Ye(r)){var u=new n(r,i);this._data=u._data,this._size=u._size,this._datatype=u._datatype,this._min=null,this._max=null}else if(r&&Ye(r.data)&&Ye(r.size))this._data=r.data,this._size=r.size,this._datatype=r.datatype,this._min=typeof r.min!="undefined"?r.min:null,this._max=typeof r.max!="undefined"?r.max:null;else{if(r)throw new TypeError("Unsupported type of data ("+je(r)+")");this._data=[],this._size=[0],this._datatype=i,this._min=null,this._max=null}}return a.prototype=new n,a.prototype.type="ImmutableDenseMatrix",a.prototype.isImmutableDenseMatrix=!0,a.prototype.subset=function(r){switch(arguments.length){case 1:{var i=n.prototype.subset.call(this,r);return De(i)?new a({data:i._data,size:i._size,datatype:i._datatype}):i}case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},a.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},a.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},a.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},a.prototype.clone=function(){return new a({data:Oe(this._data),size:Oe(this._size),datatype:this._datatype})},a.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},a.fromJSON=function(r){return new a(r)},a.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},a.prototype.min=function(){if(this._min===null){var r=null;this.forEach(function(i){(r===null||t(i,r))&&(r=i)}),this._min=r!==null?r:void 0}return this._min},a.prototype.max=function(){if(this._max===null){var r=null;this.forEach(function(i){(r===null||t(r,i))&&(r=i)}),this._max=r!==null?r:void 0}return this._max},a},{isClass:!0}),Qx="Index",Kx=["ImmutableDenseMatrix"],jx=R(Qx,Kx,e=>{var{ImmutableDenseMatrix:t}=e;function n(r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var i=0,u=arguments.length;i<u;i++){var l=arguments[i];if(ra(l))this._dimensions.push(l),this._isScalar=!1;else if(Array.isArray(l)||De(l)){var f=a(l.valueOf());this._dimensions.push(f);var c=f.size();(c.length!==1||c[0]!==1)&&(this._isScalar=!1)}else if(typeof l=="number")this._dimensions.push(a([l]));else if(typeof l=="string")this._dimensions.push(l);else throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range")}}n.prototype.type="Index",n.prototype.isIndex=!0;function a(r){for(var i=0,u=r.length;i<u;i++)if(typeof r[i]!="number"||!Se(r[i]))throw new TypeError("Index parameters must be positive integer numbers");return new t(r)}return n.prototype.clone=function(){var r=new n;return r._dimensions=Oe(this._dimensions),r._isScalar=this._isScalar,r},n.create=function(r){var i=new n;return n.apply(i,r),i},n.prototype.size=function(){for(var r=[],i=0,u=this._dimensions.length;i<u;i++){var l=this._dimensions[i];r[i]=typeof l=="string"?1:l.size()[0]}return r},n.prototype.max=function(){for(var r=[],i=0,u=this._dimensions.length;i<u;i++){var l=this._dimensions[i];r[i]=typeof l=="string"?l:l.max()}return r},n.prototype.min=function(){for(var r=[],i=0,u=this._dimensions.length;i<u;i++){var l=this._dimensions[i];r[i]=typeof l=="string"?l:l.min()}return r},n.prototype.forEach=function(r){for(var i=0,u=this._dimensions.length;i<u;i++)r(this._dimensions[i],i,this)},n.prototype.dimension=function(r){return this._dimensions[r]||null},n.prototype.isObjectProperty=function(){return this._dimensions.length===1&&typeof this._dimensions[0]=="string"},n.prototype.getObjectProperty=function(){return this.isObjectProperty()?this._dimensions[0]:null},n.prototype.isScalar=function(){return this._isScalar},n.prototype.toArray=function(){for(var r=[],i=0,u=this._dimensions.length;i<u;i++){var l=this._dimensions[i];r.push(typeof l=="string"?l:l.toArray())}return r},n.prototype.valueOf=n.prototype.toArray,n.prototype.toString=function(){for(var r=[],i=0,u=this._dimensions.length;i<u;i++){var l=this._dimensions[i];typeof l=="string"?r.push(JSON.stringify(l)):r.push(l.toString())}return"["+r.join(", ")+"]"},n.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},n.fromJSON=function(r){return n.create(r.dimensions)},n},{isClass:!0}),eb="FibonacciHeap",rb=["smaller","larger"],tb=R(eb,rb,e=>{var{smaller:t,larger:n}=e,a=1/Math.log((1+Math.sqrt(5))/2);function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}r.prototype.type="FibonacciHeap",r.prototype.isFibonacciHeap=!0,r.prototype.insert=function(o,s){var m={key:o,value:s,degree:0};if(this._minimum){var p=this._minimum;m.left=p,m.right=p.right,p.right=m,m.right.left=m,t(o,p.key)&&(this._minimum=m)}else m.left=m,m.right=m,this._minimum=m;return this._size++,m},r.prototype.size=function(){return this._size},r.prototype.clear=function(){this._minimum=null,this._size=0},r.prototype.isEmpty=function(){return this._size===0},r.prototype.extractMinimum=function(){var o=this._minimum;if(o===null)return o;for(var s=this._minimum,m=o.degree,p=o.child;m>0;){var v=p.right;p.left.right=p.right,p.right.left=p.left,p.left=s,p.right=s.right,s.right=p,p.right.left=p,p.parent=null,p=v,m--}return o.left.right=o.right,o.right.left=o.left,o===o.right?s=null:(s=o.right,s=c(s,this._size)),this._size--,this._minimum=s,o},r.prototype.remove=function(o){this._minimum=i(this._minimum,o,-1),this.extractMinimum()};function i(o,s,m){s.key=m;var p=s.parent;return p&&t(s.key,p.key)&&(u(o,s,p),l(o,p)),t(s.key,o.key)&&(o=s),o}function u(o,s,m){s.left.right=s.right,s.right.left=s.left,m.degree--,m.child===s&&(m.child=s.right),m.degree===0&&(m.child=null),s.left=o,s.right=o.right,o.right=s,s.right.left=s,s.parent=null,s.mark=!1}function l(o,s){var m=s.parent;m&&(s.mark?(u(o,s,m),l(m)):s.mark=!0)}var f=function(s,m){s.left.right=s.right,s.right.left=s.left,s.parent=m,m.child?(s.left=m.child,s.right=m.child.right,m.child.right=s,s.right.left=s):(m.child=s,s.right=s,s.left=s),m.degree++,s.mark=!1};function c(o,s){var m=Math.floor(Math.log(s)*a)+1,p=new Array(m),v=0,h=o;if(h)for(v++,h=h.right;h!==o;)v++,h=h.right;for(var b;v>0;){for(var w=h.degree,N=h.right;b=p[w],!!b;){if(n(h.key,b.key)){var g=b;b=h,h=g}f(b,h),p[w]=null,w++}p[w]=h,h=N,v--}o=null;for(var y=0;y<m;y++)b=p[y],b&&(o?(b.left.right=b.right,b.right.left=b.left,b.left=o,b.right=o.right,o.right=b,b.right.left=b,t(b.key,o.key)&&(o=b)):o=b);return o}return r},{isClass:!0}),nb="Spa",ab=["addScalar","equalScalar","FibonacciHeap"],ib=R(nb,ab,e=>{var{addScalar:t,equalScalar:n,FibonacciHeap:a}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new a}return r.prototype.type="Spa",r.prototype.isSpa=!0,r.prototype.set=function(i,u){if(this._values[i])this._values[i].value=u;else{var l=this._heap.insert(i,u);this._values[i]=l}},r.prototype.get=function(i){var u=this._values[i];return u?u.value:0},r.prototype.accumulate=function(i,u){var l=this._values[i];l?l.value=t(l.value,u):(l=this._heap.insert(i,u),this._values[i]=l)},r.prototype.forEach=function(i,u,l){var f=this._heap,c=this._values,o=[],s=f.extractMinimum();for(s&&o.push(s);s&&s.key<=u;)s.key>=i&&(n(s.value,0)||l(s.key,s.value,this)),s=f.extractMinimum(),s&&o.push(s);for(var m=0;m<o.length;m++){var p=o[m];s=f.insert(p.key,p.value),c[s.key]=s}},r.prototype.swap=function(i,u){var l=this._values[i],f=this._values[u];if(!l&&f)l=this._heap.insert(i,f.value),this._heap.remove(f),this._values[i]=l,this._values[u]=void 0;else if(l&&!f)f=this._heap.insert(u,l.value),this._heap.remove(l),this._values[u]=f,this._values[i]=void 0;else if(l&&f){var c=l.value;l.value=f.value,f.value=c}},r},{isClass:!0});function Un(e){"@babel/helpers - typeof";return Un=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Un(e)}function ob(e,t){if(Un(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var a=n.call(e,t);if(Un(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function sb(e){var t=ob(e,"string");return Un(t)=="symbol"?t:t+""}function vf(e,t,n){return(t=sb(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ub=zn(function(e){return new e(1).exp()},{hasher:Ia}),cb=zn(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},{hasher:Ia}),_i=zn(function(e){return e.acos(-1)},{hasher:Ia}),fb=zn(function(e){return _i(e).times(2)},{hasher:Ia});function Ia(e){return e[0].precision}function hf(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,a)}return n}function Ii(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?hf(Object(n),!0).forEach(function(a){vf(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hf(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}var lb="Unit",mb=["?on","config","addScalar","subtract","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","number","Complex","BigNumber","Fraction"],pb=R(lb,mb,e=>{var{on:t,config:n,addScalar:a,subtract:r,multiplyScalar:i,divideScalar:u,pow:l,abs:f,fix:c,round:o,equal:s,isNumeric:m,format:p,number:v,Complex:h,BigNumber:b,Fraction:w}=e,N=v;function g(F,Y){if(!(this instanceof g))throw new Error("Constructor must be called with the new operator");if(!(F==null||m(F)||Tr(F)))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(Y!==void 0&&(typeof Y!="string"||Y===""))throw new TypeError("Second parameter in Unit constructor must be a string");if(Y!==void 0){var k=g.parse(Y);this.units=k.units,this.dimensions=k.dimensions}else{this.units=[{unit:j,prefix:B.NONE,power:0}],this.dimensions=[];for(var U=0;U<G.length;U++)this.dimensions[U]=0}this.value=F!=null?this._normalize(F):null,this.fixPrefix=!1,this.skipAutomaticSimplification=!0}g.prototype.type="Unit",g.prototype.isUnit=!0;var y,x,d;function A(){for(;d===" "||d===" ";)M()}function S(F){return F>="0"&&F<="9"||F==="."}function O(F){return F>="0"&&F<="9"}function M(){x++,d=y.charAt(x)}function $(F){x=F,d=y.charAt(x)}function E(){var F="",Y=x;if(d==="+"?M():d==="-"&&(F+=d,M()),!S(d))return $(Y),null;if(d==="."){if(F+=d,M(),!O(d))return $(Y),null}else{for(;O(d);)F+=d,M();d==="."&&(F+=d,M())}for(;O(d);)F+=d,M();if(d==="E"||d==="e"){var k="",U=x;if(k+=d,M(),(d==="+"||d==="-")&&(k+=d,M()),!O(d))return $(U),F;for(F=F+k;O(d);)F+=d,M()}return F}function _(){for(var F="";O(d)||g.isValidAlpha(d);)F+=d,M();var Y=F.charAt(0);return g.isValidAlpha(Y)?F:null}function z(F){return d===F?(M(),F):null}g.parse=function(F,Y){if(Y=Y||{},y=F,x=-1,d="",typeof y!="string")throw new TypeError("Invalid argument in Unit.parse, string expected");var k=new g;k.units=[];var U=1,J=!1;M(),A();var q=E(),P=null;if(q){if(n.number==="BigNumber")P=new b(q);else if(n.number==="Fraction")try{P=new w(q)}catch(fr){P=parseFloat(q)}else P=parseFloat(q);A(),z("*")?(U=1,J=!0):z("/")&&(U=-1,J=!0)}for(var Q=[],L=1;;){for(A();d==="(";)Q.push(U),L*=U,U=1,M(),A();var ue=void 0;if(d){var le=d;if(ue=_(),ue===null)throw new SyntaxError('Unexpected "'+le+'" in "'+y+'" at index '+x.toString())}else break;var ye=I(ue);if(ye===null)throw new SyntaxError('Unit "'+ue+'" not found.');var ve=U*L;if(A(),z("^")){A();var he=E();if(he===null)throw new SyntaxError('In "'+F+'", "^" must be followed by a floating-point number');ve*=he}k.units.push({unit:ye.unit,prefix:ye.prefix,power:ve});for(var Me=0;Me<G.length;Me++)k.dimensions[Me]+=(ye.unit.dimensions[Me]||0)*ve;for(A();d===")";){if(Q.length===0)throw new SyntaxError('Unmatched ")" in "'+y+'" at index '+x.toString());L/=Q.pop(),M(),A()}if(J=!1,z("*")?(U=1,J=!0):z("/")?(U=-1,J=!0):U=1,ye.unit.base){var Ke=ye.unit.base.key;re.auto[Ke]={unit:ye.unit,prefix:ye.prefix}}}if(A(),d)throw new SyntaxError('Could not parse: "'+F+'"');if(J)throw new SyntaxError('Trailing characters: "'+F+'"');if(Q.length!==0)throw new SyntaxError('Unmatched "(" in "'+y+'"');if(k.units.length===0&&!Y.allowNoUnits)throw new SyntaxError('"'+F+'" contains no units');return k.value=P!==void 0?k._normalize(P):null,k},g.prototype.clone=function(){var F=new g;F.fixPrefix=this.fixPrefix,F.skipAutomaticSimplification=this.skipAutomaticSimplification,F.value=Oe(this.value),F.dimensions=this.dimensions.slice(0),F.units=[];for(var Y=0;Y<this.units.length;Y++){F.units[Y]={};for(var k in this.units[Y])Ae(this.units[Y],k)&&(F.units[Y][k]=this.units[Y][k])}return F},g.prototype._isDerived=function(){return this.units.length===0?!1:this.units.length>1||Math.abs(this.units[0].power-1)>1e-15},g.prototype._normalize=function(F){if(F==null||this.units.length===0)return F;for(var Y=F,k=g._getNumberConverter(je(F)),U=0;U<this.units.length;U++){var J=k(this.units[U].unit.value),q=k(this.units[U].prefix.value),P=k(this.units[U].power);Y=i(Y,l(i(J,q),P))}return Y},g.prototype._denormalize=function(F,Y){if(F==null||this.units.length===0)return F;for(var k=F,U=g._getNumberConverter(je(F)),J=0;J<this.units.length;J++){var q=U(this.units[J].unit.value),P=U(this.units[J].prefix.value),Q=U(this.units[J].power);k=u(k,l(i(q,P),Q))}return k};var I=zn(F=>{if(Ae(V,F)){var Y=V[F],k=Y.prefixes[""];return{unit:Y,prefix:k}}for(var U in V)if(Ae(V,U)&&lv(F,U)){var J=V[U],q=F.length-U.length,P=F.substring(0,q),Q=Ae(J.prefixes,P)?J.prefixes[P]:void 0;if(Q!==void 0)return{unit:J,prefix:Q}}return null},{hasher:F=>F[0],limit:100});g.isValuelessUnit=function(F){return I(F)!==null},g.prototype.hasBase=function(F){if(typeof F=="string"&&(F=D[F]),!F)return!1;for(var Y=0;Y<G.length;Y++)if(Math.abs((this.dimensions[Y]||0)-(F.dimensions[Y]||0))>1e-12)return!1;return!0},g.prototype.equalBase=function(F){for(var Y=0;Y<G.length;Y++)if(Math.abs((this.dimensions[Y]||0)-(F.dimensions[Y]||0))>1e-12)return!1;return!0},g.prototype.equals=function(F){return this.equalBase(F)&&s(this.value,F.value)},g.prototype.multiply=function(F){for(var Y=this.clone(),k=0;k<G.length;k++)Y.dimensions[k]=(this.dimensions[k]||0)+(F.dimensions[k]||0);for(var U=0;U<F.units.length;U++){var J=Ii({},F.units[U]);Y.units.push(J)}if(this.value!==null||F.value!==null){var q=this.value===null?this._normalize(1):this.value,P=F.value===null?F._normalize(1):F.value;Y.value=i(q,P)}else Y.value=null;return Y.skipAutomaticSimplification=!1,T(Y)},g.prototype.divide=function(F){for(var Y=this.clone(),k=0;k<G.length;k++)Y.dimensions[k]=(this.dimensions[k]||0)-(F.dimensions[k]||0);for(var U=0;U<F.units.length;U++){var J=Ii(Ii({},F.units[U]),{},{power:-F.units[U].power});Y.units.push(J)}if(this.value!==null||F.value!==null){var q=this.value===null?this._normalize(1):this.value,P=F.value===null?F._normalize(1):F.value;Y.value=u(q,P)}else Y.value=null;return Y.skipAutomaticSimplification=!1,T(Y)},g.prototype.pow=function(F){for(var Y=this.clone(),k=0;k<G.length;k++)Y.dimensions[k]=(this.dimensions[k]||0)*F;for(var U=0;U<Y.units.length;U++)Y.units[U].power*=F;return Y.value!==null?Y.value=l(Y.value,F):Y.value=null,Y.skipAutomaticSimplification=!1,T(Y)};function T(F){return F.equalBase(D.NONE)&&F.value!==null&&!n.predictable?F.value:F}g.prototype.abs=function(){var F=this.clone();if(F.value!==null)if(F._isDerived()||F.units[0].unit.offset===0)F.value=f(F.value);else{var Y=g._getNumberConverter(je(F.value)),k=Y(F.units[0].unit.value),U=Y(F.units[0].unit.offset),J=i(k,U);F.value=r(f(a(F.value,J)),J)}for(var q in F.units)(F.units[q].unit.name==="VA"||F.units[q].unit.name==="VAR")&&(F.units[q].unit=V.W);return F},g.prototype.to=function(F){var Y=this.value===null?this._normalize(1):this.value,k;if(typeof F=="string")k=g.parse(F);else if(gt(F))k=F.clone();else throw new Error("String or Unit expected as parameter");if(!this.equalBase(k))throw new Error("Units do not match ('".concat(k.toString(),"' != '").concat(this.toString(),"')"));if(k.value!==null)throw new Error("Cannot convert to a unit with a value");if(this.value===null||this._isDerived()||this.units[0].unit.offset===k.units[0].unit.offset)k.value=Oe(Y);else{var U=g._getNumberConverter(je(Y)),J=U(this.units[0].unit.value),q=U(this.units[0].unit.offset),P=i(J,q),Q=U(k.units[0].unit.value),L=U(k.units[0].unit.offset),ue=i(Q,L);k.value=r(a(Y,P),ue)}return k.fixPrefix=!0,k.skipAutomaticSimplification=!0,k},g.prototype.toNumber=function(F){return N(this.toNumeric(F))},g.prototype.toNumeric=function(F){var Y;return F?Y=this.to(F):Y=this.clone(),Y._isDerived()||Y.units.length===0?Y._denormalize(Y.value):Y._denormalize(Y.value,Y.units[0].prefix.value)},g.prototype.toString=function(){return this.format()},g.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.formatUnits(),fixPrefix:this.fixPrefix}},g.fromJSON=function(F){var Y=new g(F.value,F.unit);return Y.fixPrefix=F.fixPrefix||!1,Y},g.prototype.valueOf=g.prototype.toString,g.prototype.simplify=function(){var F=this.clone(),Y=[],k;for(var U in oe)if(Ae(oe,U)&&F.hasBase(D[U])){k=U;break}if(k==="NONE")F.units=[];else{var J;if(k&&Ae(oe,k)&&(J=oe[k]),J)F.units=[{unit:J.unit,prefix:J.prefix,power:1}];else{for(var q=!1,P=0;P<G.length;P++){var Q=G[P];Math.abs(F.dimensions[P]||0)>1e-12&&(Ae(oe,Q)?Y.push({unit:oe[Q].unit,prefix:oe[Q].prefix,power:F.dimensions[P]||0}):q=!0)}Y.length<F.units.length&&!q&&(F.units=Y)}}return F},g.prototype.toSI=function(){for(var F=this.clone(),Y=[],k=0;k<G.length;k++){var U=G[k];if(Math.abs(F.dimensions[k]||0)>1e-12)if(Ae(re.si,U))Y.push({unit:re.si[U].unit,prefix:re.si[U].prefix,power:F.dimensions[k]||0});else throw new Error("Cannot express custom unit "+U+" in SI units")}return F.units=Y,F.fixPrefix=!0,F.skipAutomaticSimplification=!0,F},g.prototype.formatUnits=function(){for(var F="",Y="",k=0,U=0,J=0;J<this.units.length;J++)this.units[J].power>0?(k++,F+=" "+this.units[J].prefix.name+this.units[J].unit.name,Math.abs(this.units[J].power-1)>1e-15&&(F+="^"+this.units[J].power)):this.units[J].power<0&&U++;if(U>0)for(var q=0;q<this.units.length;q++)this.units[q].power<0&&(k>0?(Y+=" "+this.units[q].prefix.name+this.units[q].unit.name,Math.abs(this.units[q].power+1)>1e-15&&(Y+="^"+-this.units[q].power)):(Y+=" "+this.units[q].prefix.name+this.units[q].unit.name,Y+="^"+this.units[q].power));F=F.substr(1),Y=Y.substr(1),k>1&&U>0&&(F="("+F+")"),U>1&&k>0&&(Y="("+Y+")");var P=F;return k>0&&U>0&&(P+=" / "),P+=Y,P},g.prototype.format=function(F){var Y=this.skipAutomaticSimplification||this.value===null?this.clone():this.simplify(),k=!1;typeof Y.value!="undefined"&&Y.value!==null&&Tr(Y.value)&&(k=Math.abs(Y.value.re)<1e-14);for(var U in Y.units)Ae(Y.units,U)&&Y.units[U].unit&&(Y.units[U].unit.name==="VA"&&k?Y.units[U].unit=V.VAR:Y.units[U].unit.name==="VAR"&&!k&&(Y.units[U].unit=V.VA));Y.units.length===1&&!Y.fixPrefix&&Math.abs(Y.units[0].power-Math.round(Y.units[0].power))<1e-14&&(Y.units[0].prefix=Y._bestPrefix());var J=Y._denormalize(Y.value),q=Y.value!==null?p(J,F||{}):"",P=Y.formatUnits();return Y.value&&Tr(Y.value)&&(q="("+q+")"),P.length>0&&q.length>0&&(q+=" "),q+=P,q},g.prototype._bestPrefix=function(){if(this.units.length!==1)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var F=this.value!==null?f(this.value):0,Y=f(this.units[0].unit.value),k=this.units[0].prefix;if(F===0)return k;var U=this.units[0].power,J=Math.log(F/Math.pow(k.value*Y,U))/Math.LN10-1.2;if(J>-2.200001&&J<1.800001)return k;J=Math.abs(J);var q=this.units[0].unit.prefixes;for(var P in q)if(Ae(q,P)){var Q=q[P];if(Q.scientific){var L=Math.abs(Math.log(F/Math.pow(Q.value*Y,U))/Math.LN10-1.2);(L<J||L===J&&Q.name.length<k.name.length)&&(k=Q,J=L)}}return k},g.prototype.splitUnit=function(F){for(var Y=this.clone(),k=[],U=0;U<F.length&&(Y=Y.to(F[U]),U!==F.length-1);U++){var J=Y.toNumeric(),q=o(J),P=void 0,Q=s(q,J);Q?P=q:P=c(Y.toNumeric());var L=new g(P,F[U].toString());k.push(L),Y=r(Y,L)}for(var ue=0,le=0;le<k.length;le++)ue=a(ue,k[le].value);return s(ue,this.value)&&(Y.value=0),k.push(Y),k};var B={NONE:{"":{name:"",value:1,scientific:!0}},SHORT:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:10,scientific:!1},h:{name:"h",value:100,scientific:!1},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0},d:{name:"d",value:.1,scientific:!1},c:{name:"c",value:.01,scientific:!1},m:{name:"m",value:.001,scientific:!0},u:{name:"u",value:1e-6,scientific:!0},n:{name:"n",value:1e-9,scientific:!0},p:{name:"p",value:1e-12,scientific:!0},f:{name:"f",value:1e-15,scientific:!0},a:{name:"a",value:1e-18,scientific:!0},z:{name:"z",value:1e-21,scientific:!0},y:{name:"y",value:1e-24,scientific:!0}},LONG:{"":{name:"",value:1,scientific:!0},deca:{name:"deca",value:10,scientific:!1},hecto:{name:"hecto",value:100,scientific:!1},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0},deci:{name:"deci",value:.1,scientific:!1},centi:{name:"centi",value:.01,scientific:!1},milli:{name:"milli",value:.001,scientific:!0},micro:{name:"micro",value:1e-6,scientific:!0},nano:{name:"nano",value:1e-9,scientific:!0},pico:{name:"pico",value:1e-12,scientific:!0},femto:{name:"femto",value:1e-15,scientific:!0},atto:{name:"atto",value:1e-18,scientific:!0},zepto:{name:"zepto",value:1e-21,scientific:!0},yocto:{name:"yocto",value:1e-24,scientific:!0}},SQUARED:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:100,scientific:!1},h:{name:"h",value:1e4,scientific:!1},k:{name:"k",value:1e6,scientific:!0},M:{name:"M",value:1e12,scientific:!0},G:{name:"G",value:1e18,scientific:!0},T:{name:"T",value:1e24,scientific:!0},P:{name:"P",value:1e30,scientific:!0},E:{name:"E",value:1e36,scientific:!0},Z:{name:"Z",value:1e42,scientific:!0},Y:{name:"Y",value:1e48,scientific:!0},d:{name:"d",value:.01,scientific:!1},c:{name:"c",value:1e-4,scientific:!1},m:{name:"m",value:1e-6,scientific:!0},u:{name:"u",value:1e-12,scientific:!0},n:{name:"n",value:1e-18,scientific:!0},p:{name:"p",value:1e-24,scientific:!0},f:{name:"f",value:1e-30,scientific:!0},a:{name:"a",value:1e-36,scientific:!0},z:{name:"z",value:1e-42,scientific:!0},y:{name:"y",value:1e-48,scientific:!0}},CUBIC:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:1e3,scientific:!1},h:{name:"h",value:1e6,scientific:!1},k:{name:"k",value:1e9,scientific:!0},M:{name:"M",value:1e18,scientific:!0},G:{name:"G",value:1e27,scientific:!0},T:{name:"T",value:1e36,scientific:!0},P:{name:"P",value:1e45,scientific:!0},E:{name:"E",value:1e54,scientific:!0},Z:{name:"Z",value:1e63,scientific:!0},Y:{name:"Y",value:1e72,scientific:!0},d:{name:"d",value:.001,scientific:!1},c:{name:"c",value:1e-6,scientific:!1},m:{name:"m",value:1e-9,scientific:!0},u:{name:"u",value:1e-18,scientific:!0},n:{name:"n",value:1e-27,scientific:!0},p:{name:"p",value:1e-36,scientific:!0},f:{name:"f",value:1e-45,scientific:!0},a:{name:"a",value:1e-54,scientific:!0},z:{name:"z",value:1e-63,scientific:!0},y:{name:"y",value:1e-72,scientific:!0}},BINARY_SHORT_SI:{"":{name:"",value:1,scientific:!0},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0}},BINARY_SHORT_IEC:{"":{name:"",value:1,scientific:!0},Ki:{name:"Ki",value:1024,scientific:!0},Mi:{name:"Mi",value:Math.pow(1024,2),scientific:!0},Gi:{name:"Gi",value:Math.pow(1024,3),scientific:!0},Ti:{name:"Ti",value:Math.pow(1024,4),scientific:!0},Pi:{name:"Pi",value:Math.pow(1024,5),scientific:!0},Ei:{name:"Ei",value:Math.pow(1024,6),scientific:!0},Zi:{name:"Zi",value:Math.pow(1024,7),scientific:!0},Yi:{name:"Yi",value:Math.pow(1024,8),scientific:!0}},BINARY_LONG_SI:{"":{name:"",value:1,scientific:!0},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0}},BINARY_LONG_IEC:{"":{name:"",value:1,scientific:!0},kibi:{name:"kibi",value:1024,scientific:!0},mebi:{name:"mebi",value:Math.pow(1024,2),scientific:!0},gibi:{name:"gibi",value:Math.pow(1024,3),scientific:!0},tebi:{name:"tebi",value:Math.pow(1024,4),scientific:!0},pebi:{name:"pebi",value:Math.pow(1024,5),scientific:!0},exi:{name:"exi",value:Math.pow(1024,6),scientific:!0},zebi:{name:"zebi",value:Math.pow(1024,7),scientific:!0},yobi:{name:"yobi",value:Math.pow(1024,8),scientific:!0}},BTU:{"":{name:"",value:1,scientific:!0},MM:{name:"MM",value:1e6,scientific:!0}}};B.SHORTLONG=ir({},B.SHORT,B.LONG),B.BINARY_SHORT=ir({},B.BINARY_SHORT_SI,B.BINARY_SHORT_IEC),B.BINARY_LONG=ir({},B.BINARY_LONG_SI,B.BINARY_LONG_IEC);var G=["MASS","LENGTH","TIME","CURRENT","TEMPERATURE","LUMINOUS_INTENSITY","AMOUNT_OF_SUBSTANCE","ANGLE","BIT"],D={NONE:{dimensions:[0,0,0,0,0,0,0,0,0]},MASS:{dimensions:[1,0,0,0,0,0,0,0,0]},LENGTH:{dimensions:[0,1,0,0,0,0,0,0,0]},TIME:{dimensions:[0,0,1,0,0,0,0,0,0]},CURRENT:{dimensions:[0,0,0,1,0,0,0,0,0]},TEMPERATURE:{dimensions:[0,0,0,0,1,0,0,0,0]},LUMINOUS_INTENSITY:{dimensions:[0,0,0,0,0,1,0,0,0]},AMOUNT_OF_SUBSTANCE:{dimensions:[0,0,0,0,0,0,1,0,0]},FORCE:{dimensions:[1,1,-2,0,0,0,0,0,0]},SURFACE:{dimensions:[0,2,0,0,0,0,0,0,0]},VOLUME:{dimensions:[0,3,0,0,0,0,0,0,0]},ENERGY:{dimensions:[1,2,-2,0,0,0,0,0,0]},POWER:{dimensions:[1,2,-3,0,0,0,0,0,0]},PRESSURE:{dimensions:[1,-1,-2,0,0,0,0,0,0]},ELECTRIC_CHARGE:{dimensions:[0,0,1,1,0,0,0,0,0]},ELECTRIC_CAPACITANCE:{dimensions:[-1,-2,4,2,0,0,0,0,0]},ELECTRIC_POTENTIAL:{dimensions:[1,2,-3,-1,0,0,0,0,0]},ELECTRIC_RESISTANCE:{dimensions:[1,2,-3,-2,0,0,0,0,0]},ELECTRIC_INDUCTANCE:{dimensions:[1,2,-2,-2,0,0,0,0,0]},ELECTRIC_CONDUCTANCE:{dimensions:[-1,-2,3,2,0,0,0,0,0]},MAGNETIC_FLUX:{dimensions:[1,2,-2,-1,0,0,0,0,0]},MAGNETIC_FLUX_DENSITY:{dimensions:[1,0,-2,-1,0,0,0,0,0]},FREQUENCY:{dimensions:[0,0,-1,0,0,0,0,0,0]},ANGLE:{dimensions:[0,0,0,0,0,0,0,1,0]},BIT:{dimensions:[0,0,0,0,0,0,0,0,1]}};for(var H in D)Ae(D,H)&&(D[H].key=H);var W={},j={name:"",base:W,value:1,offset:0,dimensions:G.map(F=>0)},V={meter:{name:"meter",base:D.LENGTH,prefixes:B.LONG,value:1,offset:0},inch:{name:"inch",base:D.LENGTH,prefixes:B.NONE,value:.0254,offset:0},foot:{name:"foot",base:D.LENGTH,prefixes:B.NONE,value:.3048,offset:0},yard:{name:"yard",base:D.LENGTH,prefixes:B.NONE,value:.9144,offset:0},mile:{name:"mile",base:D.LENGTH,prefixes:B.NONE,value:1609.344,offset:0},link:{name:"link",base:D.LENGTH,prefixes:B.NONE,value:.201168,offset:0},rod:{name:"rod",base:D.LENGTH,prefixes:B.NONE,value:5.0292,offset:0},chain:{name:"chain",base:D.LENGTH,prefixes:B.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:D.LENGTH,prefixes:B.NONE,value:1e-10,offset:0},m:{name:"m",base:D.LENGTH,prefixes:B.SHORT,value:1,offset:0},in:{name:"in",base:D.LENGTH,prefixes:B.NONE,value:.0254,offset:0},ft:{name:"ft",base:D.LENGTH,prefixes:B.NONE,value:.3048,offset:0},yd:{name:"yd",base:D.LENGTH,prefixes:B.NONE,value:.9144,offset:0},mi:{name:"mi",base:D.LENGTH,prefixes:B.NONE,value:1609.344,offset:0},li:{name:"li",base:D.LENGTH,prefixes:B.NONE,value:.201168,offset:0},rd:{name:"rd",base:D.LENGTH,prefixes:B.NONE,value:5.02921,offset:0},ch:{name:"ch",base:D.LENGTH,prefixes:B.NONE,value:20.1168,offset:0},mil:{name:"mil",base:D.LENGTH,prefixes:B.NONE,value:254e-7,offset:0},m2:{name:"m2",base:D.SURFACE,prefixes:B.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:D.SURFACE,prefixes:B.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:D.SURFACE,prefixes:B.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:D.SURFACE,prefixes:B.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:D.SURFACE,prefixes:B.NONE,value:2589988110336e-6,offset:0},sqrd:{name:"sqrd",base:D.SURFACE,prefixes:B.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:D.SURFACE,prefixes:B.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:D.SURFACE,prefixes:B.NONE,value:64516e-14,offset:0},acre:{name:"acre",base:D.SURFACE,prefixes:B.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:D.SURFACE,prefixes:B.NONE,value:1e4,offset:0},m3:{name:"m3",base:D.VOLUME,prefixes:B.CUBIC,value:1,offset:0},L:{name:"L",base:D.VOLUME,prefixes:B.SHORT,value:.001,offset:0},l:{name:"l",base:D.VOLUME,prefixes:B.SHORT,value:.001,offset:0},litre:{name:"litre",base:D.VOLUME,prefixes:B.LONG,value:.001,offset:0},cuin:{name:"cuin",base:D.VOLUME,prefixes:B.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:D.VOLUME,prefixes:B.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:D.VOLUME,prefixes:B.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:D.VOLUME,prefixes:B.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:D.VOLUME,prefixes:B.NONE,value:15e-6,offset:0},drop:{name:"drop",base:D.VOLUME,prefixes:B.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:D.VOLUME,prefixes:B.NONE,value:5e-8,offset:0},minim:{name:"minim",base:D.VOLUME,prefixes:B.NONE,value:6161152e-14,offset:0},fluiddram:{name:"fluiddram",base:D.VOLUME,prefixes:B.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:D.VOLUME,prefixes:B.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:D.VOLUME,prefixes:B.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:D.VOLUME,prefixes:B.NONE,value:1e-6,offset:0},cup:{name:"cup",base:D.VOLUME,prefixes:B.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:D.VOLUME,prefixes:B.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:D.VOLUME,prefixes:B.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:D.VOLUME,prefixes:B.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:D.VOLUME,prefixes:B.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:D.VOLUME,prefixes:B.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:D.VOLUME,prefixes:B.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:D.VOLUME,prefixes:B.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:D.VOLUME,prefixes:B.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:D.VOLUME,prefixes:B.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:D.VOLUME,prefixes:B.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:D.VOLUME,prefixes:B.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:D.VOLUME,prefixes:B.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:D.VOLUME,prefixes:B.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:D.VOLUME,prefixes:B.NONE,value:.1173478,offset:0},obl:{name:"obl",base:D.VOLUME,prefixes:B.NONE,value:.1589873,offset:0},g:{name:"g",base:D.MASS,prefixes:B.SHORT,value:.001,offset:0},gram:{name:"gram",base:D.MASS,prefixes:B.LONG,value:.001,offset:0},ton:{name:"ton",base:D.MASS,prefixes:B.SHORT,value:907.18474,offset:0},t:{name:"t",base:D.MASS,prefixes:B.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:D.MASS,prefixes:B.LONG,value:1e3,offset:0},grain:{name:"grain",base:D.MASS,prefixes:B.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:D.MASS,prefixes:B.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:D.MASS,prefixes:B.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:D.MASS,prefixes:B.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:D.MASS,prefixes:B.NONE,value:45.359237,offset:0},stick:{name:"stick",base:D.MASS,prefixes:B.NONE,value:.115,offset:0},stone:{name:"stone",base:D.MASS,prefixes:B.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:D.MASS,prefixes:B.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:D.MASS,prefixes:B.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:D.MASS,prefixes:B.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:D.MASS,prefixes:B.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:D.MASS,prefixes:B.NONE,value:45.359237,offset:0},s:{name:"s",base:D.TIME,prefixes:B.SHORT,value:1,offset:0},min:{name:"min",base:D.TIME,prefixes:B.NONE,value:60,offset:0},h:{name:"h",base:D.TIME,prefixes:B.NONE,value:3600,offset:0},second:{name:"second",base:D.TIME,prefixes:B.LONG,value:1,offset:0},sec:{name:"sec",base:D.TIME,prefixes:B.LONG,value:1,offset:0},minute:{name:"minute",base:D.TIME,prefixes:B.NONE,value:60,offset:0},hour:{name:"hour",base:D.TIME,prefixes:B.NONE,value:3600,offset:0},day:{name:"day",base:D.TIME,prefixes:B.NONE,value:86400,offset:0},week:{name:"week",base:D.TIME,prefixes:B.NONE,value:7*86400,offset:0},month:{name:"month",base:D.TIME,prefixes:B.NONE,value:2629800,offset:0},year:{name:"year",base:D.TIME,prefixes:B.NONE,value:31557600,offset:0},decade:{name:"decade",base:D.TIME,prefixes:B.NONE,value:315576e3,offset:0},century:{name:"century",base:D.TIME,prefixes:B.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:D.TIME,prefixes:B.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:D.FREQUENCY,prefixes:B.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:D.FREQUENCY,prefixes:B.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:D.ANGLE,prefixes:B.SHORT,value:1,offset:0},radian:{name:"radian",base:D.ANGLE,prefixes:B.LONG,value:1,offset:0},deg:{name:"deg",base:D.ANGLE,prefixes:B.SHORT,value:null,offset:0},degree:{name:"degree",base:D.ANGLE,prefixes:B.LONG,value:null,offset:0},grad:{name:"grad",base:D.ANGLE,prefixes:B.SHORT,value:null,offset:0},gradian:{name:"gradian",base:D.ANGLE,prefixes:B.LONG,value:null,offset:0},cycle:{name:"cycle",base:D.ANGLE,prefixes:B.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:D.ANGLE,prefixes:B.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:D.ANGLE,prefixes:B.NONE,value:null,offset:0},A:{name:"A",base:D.CURRENT,prefixes:B.SHORT,value:1,offset:0},ampere:{name:"ampere",base:D.CURRENT,prefixes:B.LONG,value:1,offset:0},K:{name:"K",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:0},degC:{name:"degC",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:273.15},degF:{name:"degF",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:0},celsius:{name:"celsius",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:D.AMOUNT_OF_SUBSTANCE,prefixes:B.SHORT,value:1,offset:0},mole:{name:"mole",base:D.AMOUNT_OF_SUBSTANCE,prefixes:B.LONG,value:1,offset:0},cd:{name:"cd",base:D.LUMINOUS_INTENSITY,prefixes:B.SHORT,value:1,offset:0},candela:{name:"candela",base:D.LUMINOUS_INTENSITY,prefixes:B.LONG,value:1,offset:0},N:{name:"N",base:D.FORCE,prefixes:B.SHORT,value:1,offset:0},newton:{name:"newton",base:D.FORCE,prefixes:B.LONG,value:1,offset:0},dyn:{name:"dyn",base:D.FORCE,prefixes:B.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:D.FORCE,prefixes:B.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:D.FORCE,prefixes:B.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:D.FORCE,prefixes:B.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:D.FORCE,prefixes:B.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:D.FORCE,prefixes:B.NONE,value:9.80665,offset:0},J:{name:"J",base:D.ENERGY,prefixes:B.SHORT,value:1,offset:0},joule:{name:"joule",base:D.ENERGY,prefixes:B.SHORT,value:1,offset:0},erg:{name:"erg",base:D.ENERGY,prefixes:B.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:D.ENERGY,prefixes:B.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:D.ENERGY,prefixes:B.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:D.ENERGY,prefixes:B.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:D.ENERGY,prefixes:B.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:D.POWER,prefixes:B.SHORT,value:1,offset:0},watt:{name:"watt",base:D.POWER,prefixes:B.LONG,value:1,offset:0},hp:{name:"hp",base:D.POWER,prefixes:B.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:D.POWER,prefixes:B.SHORT,value:h.I,offset:0},VA:{name:"VA",base:D.POWER,prefixes:B.SHORT,value:1,offset:0},Pa:{name:"Pa",base:D.PRESSURE,prefixes:B.SHORT,value:1,offset:0},psi:{name:"psi",base:D.PRESSURE,prefixes:B.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:D.PRESSURE,prefixes:B.NONE,value:101325,offset:0},bar:{name:"bar",base:D.PRESSURE,prefixes:B.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:D.PRESSURE,prefixes:B.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:D.PRESSURE,prefixes:B.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:D.PRESSURE,prefixes:B.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:D.PRESSURE,prefixes:B.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:D.ELECTRIC_CHARGE,prefixes:B.LONG,value:1,offset:0},C:{name:"C",base:D.ELECTRIC_CHARGE,prefixes:B.SHORT,value:1,offset:0},farad:{name:"farad",base:D.ELECTRIC_CAPACITANCE,prefixes:B.LONG,value:1,offset:0},F:{name:"F",base:D.ELECTRIC_CAPACITANCE,prefixes:B.SHORT,value:1,offset:0},volt:{name:"volt",base:D.ELECTRIC_POTENTIAL,prefixes:B.LONG,value:1,offset:0},V:{name:"V",base:D.ELECTRIC_POTENTIAL,prefixes:B.SHORT,value:1,offset:0},ohm:{name:"ohm",base:D.ELECTRIC_RESISTANCE,prefixes:B.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:D.ELECTRIC_INDUCTANCE,prefixes:B.LONG,value:1,offset:0},H:{name:"H",base:D.ELECTRIC_INDUCTANCE,prefixes:B.SHORT,value:1,offset:0},siemens:{name:"siemens",base:D.ELECTRIC_CONDUCTANCE,prefixes:B.LONG,value:1,offset:0},S:{name:"S",base:D.ELECTRIC_CONDUCTANCE,prefixes:B.SHORT,value:1,offset:0},weber:{name:"weber",base:D.MAGNETIC_FLUX,prefixes:B.LONG,value:1,offset:0},Wb:{name:"Wb",base:D.MAGNETIC_FLUX,prefixes:B.SHORT,value:1,offset:0},tesla:{name:"tesla",base:D.MAGNETIC_FLUX_DENSITY,prefixes:B.LONG,value:1,offset:0},T:{name:"T",base:D.MAGNETIC_FLUX_DENSITY,prefixes:B.SHORT,value:1,offset:0},b:{name:"b",base:D.BIT,prefixes:B.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:D.BIT,prefixes:B.BINARY_LONG,value:1,offset:0},B:{name:"B",base:D.BIT,prefixes:B.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:D.BIT,prefixes:B.BINARY_LONG,value:8,offset:0}},K={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 te(F){if(F.number==="BigNumber"){var Y=_i(b);V.rad.value=new b(1),V.deg.value=Y.div(180),V.grad.value=Y.div(200),V.cycle.value=Y.times(2),V.arcsec.value=Y.div(648e3),V.arcmin.value=Y.div(10800)}else V.rad.value=1,V.deg.value=Math.PI/180,V.grad.value=Math.PI/200,V.cycle.value=Math.PI*2,V.arcsec.value=Math.PI/648e3,V.arcmin.value=Math.PI/10800;V.radian.value=V.rad.value,V.degree.value=V.deg.value,V.gradian.value=V.grad.value}te(n),t&&t("config",function(F,Y){F.number!==Y.number&&te(F)});var re={si:{NONE:{unit:j,prefix:B.NONE[""]},LENGTH:{unit:V.m,prefix:B.SHORT[""]},MASS:{unit:V.g,prefix:B.SHORT.k},TIME:{unit:V.s,prefix:B.SHORT[""]},CURRENT:{unit:V.A,prefix:B.SHORT[""]},TEMPERATURE:{unit:V.K,prefix:B.SHORT[""]},LUMINOUS_INTENSITY:{unit:V.cd,prefix:B.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:V.mol,prefix:B.SHORT[""]},ANGLE:{unit:V.rad,prefix:B.SHORT[""]},BIT:{unit:V.bits,prefix:B.SHORT[""]},FORCE:{unit:V.N,prefix:B.SHORT[""]},ENERGY:{unit:V.J,prefix:B.SHORT[""]},POWER:{unit:V.W,prefix:B.SHORT[""]},PRESSURE:{unit:V.Pa,prefix:B.SHORT[""]},ELECTRIC_CHARGE:{unit:V.C,prefix:B.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:V.F,prefix:B.SHORT[""]},ELECTRIC_POTENTIAL:{unit:V.V,prefix:B.SHORT[""]},ELECTRIC_RESISTANCE:{unit:V.ohm,prefix:B.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:V.H,prefix:B.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:V.S,prefix:B.SHORT[""]},MAGNETIC_FLUX:{unit:V.Wb,prefix:B.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:V.T,prefix:B.SHORT[""]},FREQUENCY:{unit:V.Hz,prefix:B.SHORT[""]}}};re.cgs=JSON.parse(JSON.stringify(re.si)),re.cgs.LENGTH={unit:V.m,prefix:B.SHORT.c},re.cgs.MASS={unit:V.g,prefix:B.SHORT[""]},re.cgs.FORCE={unit:V.dyn,prefix:B.SHORT[""]},re.cgs.ENERGY={unit:V.erg,prefix:B.NONE[""]},re.us=JSON.parse(JSON.stringify(re.si)),re.us.LENGTH={unit:V.ft,prefix:B.NONE[""]},re.us.MASS={unit:V.lbm,prefix:B.NONE[""]},re.us.TEMPERATURE={unit:V.degF,prefix:B.NONE[""]},re.us.FORCE={unit:V.lbf,prefix:B.NONE[""]},re.us.ENERGY={unit:V.BTU,prefix:B.BTU[""]},re.us.POWER={unit:V.hp,prefix:B.NONE[""]},re.us.PRESSURE={unit:V.psi,prefix:B.NONE[""]},re.auto=JSON.parse(JSON.stringify(re.si));var oe=re.auto;g.setUnitSystem=function(F){if(Ae(re,F))oe=re[F];else throw new Error("Unit system "+F+" does not exist. Choices are: "+Object.keys(re).join(", "))},g.getUnitSystem=function(){for(var F in re)if(Ae(re,F)&&re[F]===oe)return F},g.typeConverters={BigNumber:function(Y){return new b(Y+"")},Fraction:function(Y){return new w(Y)},Complex:function(Y){return Y},number:function(Y){return Y}},g._getNumberConverter=function(F){if(!g.typeConverters[F])throw new TypeError('Unsupported type "'+F+'"');return g.typeConverters[F]};for(var ae in V)if(Ae(V,ae)){var ce=V[ae];ce.dimensions=ce.base.dimensions}for(var ee in K)if(Ae(K,ee)){var xe=V[K[ee]],Ne={};for(var pe in xe)Ae(xe,pe)&&(Ne[pe]=xe[pe]);Ne.name=ee,V[ee]=Ne}g.isValidAlpha=function(Y){return/^[a-zA-Z]$/.test(Y)};function be(F){for(var Y=0;Y<F.length;Y++){if(d=F.charAt(Y),Y===0&&!g.isValidAlpha(d))throw new Error('Invalid unit name (must begin with alpha character): "'+F+'"');if(Y>0&&!(g.isValidAlpha(d)||O(d)))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+F+'"')}}return g.createUnit=function(F,Y){if(typeof F!="object")throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(Y&&Y.override){for(var k in F)if(Ae(F,k)&&g.deleteUnit(k),F[k].aliases)for(var U=0;U<F[k].aliases.length;U++)g.deleteUnit(F[k].aliases[U])}var J;for(var q in F)Ae(F,q)&&(J=g.createUnitSingle(q,F[q]));return J},g.createUnitSingle=function(F,Y,k){if((typeof Y=="undefined"||Y===null)&&(Y={}),typeof F!="string")throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");if(Ae(V,F))throw new Error('Cannot create unit "'+F+'": a unit with that name already exists');be(F);var U=null,J=[],q=0,P,Q,L;if(Y&&Y.type==="Unit")U=Y.clone();else if(typeof Y=="string")Y!==""&&(P=Y);else if(typeof Y=="object")P=Y.definition,Q=Y.prefixes,q=Y.offset,L=Y.baseName,Y.aliases&&(J=Y.aliases.valueOf());else throw new TypeError('Cannot create unit "'+F+'" from "'+Y.toString()+'": expecting "string" or "Unit" or "Object"');if(J){for(var ue=0;ue<J.length;ue++)if(Ae(V,J[ue]))throw new Error('Cannot create alias "'+J[ue]+'": a unit with that name already exists')}if(P&&typeof P=="string"&&!U)try{U=g.parse(P,{allowNoUnits:!0})}catch(C){throw C.message='Could not create unit "'+F+'" from "'+P+'": '+C.message,C}else P&&P.type==="Unit"&&(U=P.clone());J=J||[],q=q||0,Q&&Q.toUpperCase?Q=B[Q.toUpperCase()]||B.NONE:Q=B.NONE;var le={};if(U){le={name:F,value:U.value,dimensions:U.dimensions.slice(0),prefixes:Q,offset:q};var Me=!1;for(var Ke in D)if(Ae(D,Ke)){for(var fr=!0,nr=0;nr<G.length;nr++)if(Math.abs((le.dimensions[nr]||0)-(D[Ke].dimensions[nr]||0))>1e-12){fr=!1;break}if(fr){Me=!0,le.base=D[Ke];break}}if(!Me){L=L||F+"_STUFF";var jr={dimensions:U.dimensions.slice(0)};jr.key=L,D[L]=jr,oe[L]={unit:le,prefix:B.NONE[""]},le.base=D[L]}}else{if(L=L||F+"_STUFF",G.indexOf(L)>=0)throw new Error('Cannot create new base unit "'+F+'": a base unit with that name already exists (and cannot be overridden)');G.push(L);for(var ye in D)Ae(D,ye)&&(D[ye].dimensions[G.length-1]=0);for(var ve={dimensions:[]},he=0;he<G.length;he++)ve.dimensions[he]=0;ve.dimensions[G.length-1]=1,ve.key=L,D[L]=ve,le={name:F,value:1,dimensions:D[L].dimensions.slice(0),prefixes:Q,offset:q,base:D[L]},oe[L]={unit:le,prefix:B.NONE[""]}}g.UNITS[F]=le;for(var kr=0;kr<J.length;kr++){var Tt=J[kr],Xe={};for(var Lt in le)Ae(le,Lt)&&(Xe[Lt]=le[Lt]);Xe.name=Tt,g.UNITS[Tt]=Xe}return delete I.cache,new g(null,F)},g.deleteUnit=function(F){delete g.UNITS[F]},g.PREFIXES=B,g.BASE_DIMENSIONS=G,g.BASE_UNITS=D,g.UNIT_SYSTEMS=re,g.UNITS=V,g},{isClass:!0}),df="unit",vb=["typed","Unit"],hb=R(df,vb,e=>{var{typed:t,Unit:n}=e;return t(df,{Unit:function(r){return r.clone()},string:function(r){return n.isValuelessUnit(r)?new n(null,r):n.parse(r,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string":function(r,i){return new n(r,i)},"Array | Matrix":function(r){return we(r,this)}})}),gf="sparse",db=["typed","SparseMatrix"],gb=R(gf,db,e=>{var{typed:t,SparseMatrix:n}=e;return t(gf,{"":function(){return new n([])},string:function(r){return new n([],r)},"Array | Matrix":function(r){return new n(r)},"Array | Matrix, string":function(r,i){return new n(r,i)}})}),yf="createUnit",yb=["typed","Unit"],xb=R(yf,yb,e=>{var{typed:t,Unit:n}=e;return t(yf,{"Object, Object":function(r,i){return n.createUnit(r,i)},Object:function(r){return n.createUnit(r,{})},"string, Unit | string | Object, Object":function(r,i,u){var l={};return l[r]=i,n.createUnit(l,u)},"string, Unit | string | Object":function(r,i){var u={};return u[r]=i,n.createUnit(u,{})},string:function(r){var i={};return i[r]={},n.createUnit(i,{})}})}),xf="acos",bb=["typed","config","Complex"],wb=R(xf,bb,e=>{var{typed:t,config:n,Complex:a}=e;return t(xf,{number:function(i){return i>=-1&&i<=1||n.predictable?Math.acos(i):new a(i,0).acos()},Complex:function(i){return i.acos()},BigNumber:function(i){return i.acos()},"Array | Matrix":function(i){return we(i,this)}})}),bf="acosh",Nb=["typed","config","Complex"],Mb=R(bf,Nb,e=>{var{typed:t,config:n,Complex:a}=e;return t(bf,{number:function(i){return i>=1||n.predictable?Ds(i):i<=-1?new a(Math.log(Math.sqrt(i*i-1)-i),Math.PI):new a(i,0).acosh()},Complex:function(i){return i.acosh()},BigNumber:function(i){return i.acosh()},"Array | Matrix":function(i){return we(i,this)}})}),wf="acot",Ab=["typed","BigNumber"],Sb=R(wf,Ab,e=>{var{typed:t,BigNumber:n}=e;return t(wf,{number:Ts,Complex:function(r){return r.acot()},BigNumber:function(r){return new n(1).div(r).atan()},"Array | Matrix":function(r){return we(r,this)}})}),Nf="acoth",Eb=["typed","config","Complex","BigNumber"],Cb=R(Nf,Eb,e=>{var{typed:t,config:n,Complex:a,BigNumber:r}=e;return t(Nf,{number:function(u){return u>=1||u<=-1||n.predictable?Bs(u):new a(u,0).acoth()},Complex:function(u){return u.acoth()},BigNumber:function(u){return new r(1).div(u).atanh()},"Array | Matrix":function(u){return we(u,this)}})}),Mf="acsc",Ob=["typed","config","Complex","BigNumber"],Db=R(Mf,Ob,e=>{var{typed:t,config:n,Complex:a,BigNumber:r}=e;return t(Mf,{number:function(u){return u<=-1||u>=1||n.predictable?$s(u):new a(u,0).acsc()},Complex:function(u){return u.acsc()},BigNumber:function(u){return new r(1).div(u).asin()},"Array | Matrix":function(u){return we(u,this)}})}),Af="acsch",Tb=["typed","BigNumber"],Bb=R(Af,Tb,e=>{var{typed:t,BigNumber:n}=e;return t(Af,{number:_s,Complex:function(r){return r.acsch()},BigNumber:function(r){return new n(1).div(r).asinh()},"Array | Matrix":function(r){return we(r,this)}})}),Sf="asec",$b=["typed","config","Complex","BigNumber"],_b=R(Sf,$b,e=>{var{typed:t,config:n,Complex:a,BigNumber:r}=e;return t(Sf,{number:function(u){return u<=-1||u>=1||n.predictable?Is(u):new a(u,0).asec()},Complex:function(u){return u.asec()},BigNumber:function(u){return new r(1).div(u).acos()},"Array | Matrix":function(u){return we(u,this)}})}),Ef="asech",Ib=["typed","config","Complex","BigNumber"],qb=R(Ef,Ib,e=>{var{typed:t,config:n,Complex:a,BigNumber:r}=e;return t(Ef,{number:function(u){if(u<=1&&u>=-1||n.predictable){var l=1/u;if(l>0||n.predictable)return qs(u);var f=Math.sqrt(l*l-1);return new a(Math.log(f-l),Math.PI)}return new a(u,0).asech()},Complex:function(u){return u.asech()},BigNumber:function(u){return new r(1).div(u).acosh()},"Array | Matrix":function(u){return we(u,this)}})}),Cf="asin",Rb=["typed","config","Complex"],Fb=R(Cf,Rb,e=>{var{typed:t,config:n,Complex:a}=e;return t(Cf,{number:function(i){return i>=-1&&i<=1||n.predictable?Math.asin(i):new a(i,0).asin()},Complex:function(i){return i.asin()},BigNumber:function(i){return i.asin()},"Array | Matrix":function(i){return we(i,this)}})}),zb="asinh",Pb=["typed"],Ub=R(zb,Pb,e=>{var{typed:t}=e;return t("asinh",{number:Rs,Complex:function(a){return a.asinh()},BigNumber:function(a){return a.asinh()},"Array | Matrix":function(a){return we(a,this)}})}),Lb="atan",kb=["typed"],Hb=R(Lb,kb,e=>{var{typed:t}=e;return t("atan",{number:function(a){return Math.atan(a)},Complex:function(a){return a.atan()},BigNumber:function(a){return a.atan()},"Array | Matrix":function(a){return we(a,this)}})}),Of="atan2",Gb=["typed","matrix","equalScalar","BigNumber","DenseMatrix"],Vb=R(Of,Gb,e=>{var{typed:t,matrix:n,equalScalar:a,BigNumber:r,DenseMatrix:i}=e,u=nt({typed:t,equalScalar:a}),l=Br({typed:t}),f=Bu({typed:t,equalScalar:a}),c=Nr({typed:t,equalScalar:a}),o=yr({typed:t,DenseMatrix:i}),s=er({typed:t}),m=Ve({typed:t});return t(Of,{"number, number":Math.atan2,"BigNumber, BigNumber":function(v,h){return r.atan2(v,h)},"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return u(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return l(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return s(v,h,this)},"Array, Array":function(v,h){return this(n(v),n(h)).valueOf()},"Array, Matrix":function(v,h){return this(n(v),h)},"Matrix, Array":function(v,h){return this(v,n(h))},"SparseMatrix, number | BigNumber":function(v,h){return c(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return m(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return o(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return m(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return m(n(v),h,this,!1).valueOf()},"number | BigNumber, Array":function(v,h){return m(n(h),v,this,!0).valueOf()}})}),Df="atanh",Zb=["typed","config","Complex"],Xb=R(Df,Zb,e=>{var{typed:t,config:n,Complex:a}=e;return t(Df,{number:function(i){return i<=1&&i>=-1||n.predictable?Fs(i):new a(i,0).atanh()},Complex:function(i){return i.atanh()},BigNumber:function(i){return i.atanh()},"Array | Matrix":function(i){return we(i,this)}})}),Tf="cos",Yb=["typed"],Wb=R(Tf,Yb,e=>{var{typed:t}=e;return t(Tf,{number:Math.cos,Complex:function(a){return a.cos()},BigNumber:function(a){return a.cos()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return this(a.value)},"Array | Matrix":function(a){return we(a,this)}})}),Bf="cosh",Jb=["typed"],Qb=R(Bf,Jb,e=>{var{typed:t}=e;return t(Bf,{number:av,Complex:function(a){return a.cosh()},BigNumber:function(a){return a.cosh()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(a.value)},"Array | Matrix":function(a){return we(a,this)}})}),$f="cot",Kb=["typed","BigNumber"],jb=R($f,Kb,e=>{var{typed:t,BigNumber:n}=e;return t($f,{number:zs,Complex:function(r){return r.cot()},BigNumber:function(r){return new n(1).div(r.tan())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(r.value)},"Array | Matrix":function(r){return we(r,this)}})}),_f="coth",ew=["typed","BigNumber"],rw=R(_f,ew,e=>{var{typed:t,BigNumber:n}=e;return t(_f,{number:Ps,Complex:function(r){return r.coth()},BigNumber:function(r){return new n(1).div(r.tanh())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(r.value)},"Array | Matrix":function(r){return we(r,this)}})}),If="csc",tw=["typed","BigNumber"],nw=R(If,tw,e=>{var{typed:t,BigNumber:n}=e;return t(If,{number:Us,Complex:function(r){return r.csc()},BigNumber:function(r){return new n(1).div(r.sin())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(r.value)},"Array | Matrix":function(r){return we(r,this)}})}),qf="csch",aw=["typed","BigNumber"],iw=R(qf,aw,e=>{var{typed:t,BigNumber:n}=e;return t(qf,{number:Ls,Complex:function(r){return r.csch()},BigNumber:function(r){return new n(1).div(r.sinh())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(r.value)},"Array | Matrix":function(r){return we(r,this)}})}),Rf="sec",ow=["typed","BigNumber"],sw=R(Rf,ow,e=>{var{typed:t,BigNumber:n}=e;return t(Rf,{number:ks,Complex:function(r){return r.sec()},BigNumber:function(r){return new n(1).div(r.cos())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return this(r.value)},"Array | Matrix":function(r){return we(r,this)}})}),Ff="sech",uw=["typed","BigNumber"],cw=R(Ff,uw,e=>{var{typed:t,BigNumber:n}=e;return t(Ff,{number:Hs,Complex:function(r){return r.sech()},BigNumber:function(r){return new n(1).div(r.cosh())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return this(r.value)},"Array | Matrix":function(r){return we(r,this)}})}),zf="sin",fw=["typed"],lw=R(zf,fw,e=>{var{typed:t}=e;return t(zf,{number:Math.sin,Complex:function(a){return a.sin()},BigNumber:function(a){return a.sin()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(a.value)},"Array | Matrix":function(a){return we(a,this)}})}),Pf="sinh",mw=["typed"],pw=R(Pf,mw,e=>{var{typed:t}=e;return t(Pf,{number:Gs,Complex:function(a){return a.sinh()},BigNumber:function(a){return a.sinh()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(a.value)},"Array | Matrix":function(a){return we(a,this)}})}),Uf="tan",vw=["typed"],hw=R(Uf,vw,e=>{var{typed:t}=e;return t(Uf,{number:Math.tan,Complex:function(a){return a.tan()},BigNumber:function(a){return a.tan()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(a.value)},"Array | Matrix":function(a){return we(a,this)}})}),dw="tanh",gw=["typed"],yw=R(dw,gw,e=>{var{typed:t}=e;return t("tanh",{number:ov,Complex:function(a){return a.tanh()},BigNumber:function(a){return a.tanh()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(a.value)},"Array | Matrix":function(a){return we(a,this)}})}),Lf="setCartesian",xw=["typed","size","subset","compareNatural","Index","DenseMatrix"],bw=R(Lf,xw,e=>{var{typed:t,size:n,subset:a,compareNatural:r,Index:i,DenseMatrix:u}=e;return t(Lf,{"Array | Matrix, Array | Matrix":function(f,c){var o=[];if(a(n(f),new i(0))!==0&&a(n(c),new i(0))!==0){var s=ke(Array.isArray(f)?f:f.toArray()).sort(r),m=ke(Array.isArray(c)?c:c.toArray()).sort(r);o=[];for(var p=0;p<s.length;p++)for(var v=0;v<m.length;v++)o.push([s[p],m[v]])}return Array.isArray(f)&&Array.isArray(c)?o:new u(o)}})}),kf="setDifference",ww=["typed","size","subset","compareNatural","Index","DenseMatrix"],Nw=R(kf,ww,e=>{var{typed:t,size:n,subset:a,compareNatural:r,Index:i,DenseMatrix:u}=e;return t(kf,{"Array | Matrix, Array | Matrix":function(f,c){var o;if(a(n(f),new i(0))===0)o=[];else{if(a(n(c),new i(0))===0)return ke(f.toArray());var s=fn(ke(Array.isArray(f)?f:f.toArray()).sort(r)),m=fn(ke(Array.isArray(c)?c:c.toArray()).sort(r));o=[];for(var p,v=0;v<s.length;v++){p=!1;for(var h=0;h<m.length;h++)if(r(s[v].value,m[h].value)===0&&s[v].identifier===m[h].identifier){p=!0;break}p||o.push(s[v])}}return Array.isArray(f)&&Array.isArray(c)?la(o):new u(la(o))}})}),Hf="setDistinct",Mw=["typed","size","subset","compareNatural","Index","DenseMatrix"],Aw=R(Hf,Mw,e=>{var{typed:t,size:n,subset:a,compareNatural:r,Index:i,DenseMatrix:u}=e;return t(Hf,{"Array | Matrix":function(f){var c;if(a(n(f),new i(0))===0)c=[];else{var o=ke(Array.isArray(f)?f:f.toArray()).sort(r);c=[],c.push(o[0]);for(var s=1;s<o.length;s++)r(o[s],o[s-1])!==0&&c.push(o[s])}return Array.isArray(f)?c:new u(c)}})}),Gf="setIntersect",Sw=["typed","size","subset","compareNatural","Index","DenseMatrix"],Ew=R(Gf,Sw,e=>{var{typed:t,size:n,subset:a,compareNatural:r,Index:i,DenseMatrix:u}=e;return t(Gf,{"Array | Matrix, Array | Matrix":function(f,c){var o;if(a(n(f),new i(0))===0||a(n(c),new i(0))===0)o=[];else{var s=fn(ke(Array.isArray(f)?f:f.toArray()).sort(r)),m=fn(ke(Array.isArray(c)?c:c.toArray()).sort(r));o=[];for(var p=0;p<s.length;p++)for(var v=0;v<m.length;v++)if(r(s[p].value,m[v].value)===0&&s[p].identifier===m[v].identifier){o.push(s[p]);break}}return Array.isArray(f)&&Array.isArray(c)?la(o):new u(la(o))}})}),Vf="setIsSubset",Cw=["typed","size","subset","compareNatural","Index"],Ow=R(Vf,Cw,e=>{var{typed:t,size:n,subset:a,compareNatural:r,Index:i}=e;return t(Vf,{"Array | Matrix, Array | Matrix":function(l,f){if(a(n(l),new i(0))===0)return!0;if(a(n(f),new i(0))===0)return!1;for(var c=fn(ke(Array.isArray(l)?l:l.toArray()).sort(r)),o=fn(ke(Array.isArray(f)?f:f.toArray()).sort(r)),s,m=0;m<c.length;m++){s=!1;for(var p=0;p<o.length;p++)if(r(c[m].value,o[p].value)===0&&c[m].identifier===o[p].identifier){s=!0;break}if(s===!1)return!1}return!0}})}),Zf="setMultiplicity",Dw=["typed","size","subset","compareNatural","Index"],Tw=R(Zf,Dw,e=>{var{typed:t,size:n,subset:a,compareNatural:r,Index:i}=e;return t(Zf,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(l,f){if(a(n(f),new i(0))===0)return 0;for(var c=ke(Array.isArray(f)?f:f.toArray()),o=0,s=0;s<c.length;s++)r(c[s],l)===0&&o++;return o}})}),Xf="setPowerset",Bw=["typed","size","subset","compareNatural","Index"],$w=R(Xf,Bw,e=>{var{typed:t,size:n,subset:a,compareNatural:r,Index:i}=e;return t(Xf,{"Array | Matrix":function(c){if(a(n(c),new i(0))===0)return[];for(var o=ke(Array.isArray(c)?c:c.toArray()).sort(r),s=[],m=0;m.toString(2).length<=o.length;)s.push(u(o,m.toString(2).split("").reverse())),m++;return l(s)}});function u(f,c){for(var o=[],s=0;s<c.length;s++)c[s]==="1"&&o.push(f[s]);return o}function l(f){for(var c=[],o=f.length-1;o>0;o--)for(var s=0;s<o;s++)f[s].length>f[s+1].length&&(c=f[s],f[s]=f[s+1],f[s+1]=c);return f}}),Yf="setSize",_w=["typed","compareNatural"],Iw=R(Yf,_w,e=>{var{typed:t,compareNatural:n}=e;return t(Yf,{"Array | Matrix":function(r){return Array.isArray(r)?ke(r).length:ke(r.toArray()).length},"Array | Matrix, boolean":function(r,i){if(i===!1||r.length===0)return Array.isArray(r)?ke(r).length:ke(r.toArray()).length;for(var u=ke(Array.isArray(r)?r:r.toArray()).sort(n),l=1,f=1;f<u.length;f++)n(u[f],u[f-1])!==0&&l++;return l}})}),Wf="setSymDifference",qw=["typed","size","concat","subset","setDifference","Index"],Rw=R(Wf,qw,e=>{var{typed:t,size:n,concat:a,subset:r,setDifference:i,Index:u}=e;return t(Wf,{"Array | Matrix, Array | Matrix":function(f,c){if(r(n(f),new u(0))===0)return ke(c);if(r(n(c),new u(0))===0)return ke(f);var o=ke(f),s=ke(c);return a(i(o,s),i(s,o))}})}),Jf="setUnion",Fw=["typed","size","concat","subset","setIntersect","setSymDifference","Index"],zw=R(Jf,Fw,e=>{var{typed:t,size:n,concat:a,subset:r,setIntersect:i,setSymDifference:u,Index:l}=e;return t(Jf,{"Array | Matrix, Array | Matrix":function(c,o){if(r(n(c),new l(0))===0)return ke(o);if(r(n(o),new l(0))===0)return ke(c);var s=ke(c),m=ke(o);return a(u(s,m),i(s,m))}})}),Qf="add",Pw=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],Uw=R(Qf,Pw,e=>{var{typed:t,matrix:n,addScalar:a,equalScalar:r,DenseMatrix:i,SparseMatrix:u}=e,l=Ft({typed:t}),f=Ci({typed:t,equalScalar:r}),c=Yt({typed:t,DenseMatrix:i}),o=er({typed:t}),s=Ve({typed:t});return t(Qf,ti({"DenseMatrix, DenseMatrix":function(p,v){return o(p,v,a)},"DenseMatrix, SparseMatrix":function(p,v){return l(p,v,a,!1)},"SparseMatrix, DenseMatrix":function(p,v){return l(v,p,a,!0)},"SparseMatrix, SparseMatrix":function(p,v){return f(p,v,a)},"Array, Array":function(p,v){return this(n(p),n(v)).valueOf()},"Array, Matrix":function(p,v){return this(n(p),v)},"Matrix, Array":function(p,v){return this(p,n(v))},"DenseMatrix, any":function(p,v){return s(p,v,a,!1)},"SparseMatrix, any":function(p,v){return c(p,v,a,!1)},"any, DenseMatrix":function(p,v){return s(v,p,a,!0)},"any, SparseMatrix":function(p,v){return c(v,p,a,!0)},"Array, any":function(p,v){return s(n(p),v,a,!1).valueOf()},"any, Array":function(p,v){return s(n(v),p,a,!0).valueOf()},"any, any":a,"any, any, ...any":function(p,v,h){for(var b=this(p,v),w=0;w<h.length;w++)b=this(b,h[w]);return b}},a.signatures))}),Kf="hypot",Lw=["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],kw=R(Kf,Lw,e=>{var{typed:t,abs:n,addScalar:a,divideScalar:r,multiplyScalar:i,sqrt:u,smaller:l,isPositive:f}=e;return t(Kf,{"... number | BigNumber":c,Array:function(s){return this.apply(this,ke(s))},Matrix:function(s){return this.apply(this,ke(s.toArray()))}});function c(o){for(var s=0,m=0,p=0;p<o.length;p++){var v=n(o[p]);l(m,v)?(s=i(s,i(r(m,v),r(m,v))),s=a(s,1),m=v):s=a(s,f(v)?i(r(v,m),r(v,m)):v)}return i(m,u(s))}}),jf="norm",Hw=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],Gw=R(jf,Hw,e=>{var{typed:t,abs:n,add:a,pow:r,conj:i,sqrt:u,multiply:l,equalScalar:f,larger:c,smaller:o,matrix:s,ctranspose:m,eigs:p}=e;return t(jf,{number:Math.abs,Complex:function(S){return S.abs()},BigNumber:function(S){return S.abs()},boolean:function(S){return Math.abs(S)},Array:function(S){return d(s(S),2)},Matrix:function(S){return d(S,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(S){return this(S)},"Array, number | BigNumber | string":function(S,O){return d(s(S),O)},"Matrix, number | BigNumber | string":function(S,O){return d(S,O)}});function v(A){var S=0;return A.forEach(function(O){var M=n(O);c(M,S)&&(S=M)},!0),S}function h(A){var S;return A.forEach(function(O){var M=n(O);(!S||o(M,S))&&(S=M)},!0),S||0}function b(A,S){if(S===Number.POSITIVE_INFINITY||S==="inf")return v(A);if(S===Number.NEGATIVE_INFINITY||S==="-inf")return h(A);if(S==="fro")return d(A,2);if(typeof S=="number"&&!isNaN(S)){if(!f(S,0)){var O=0;return A.forEach(function(M){O=a(r(n(M),S),O)},!0),r(O,1/S)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}function w(A){var S=0;return A.forEach(function(O,M){S=a(S,l(O,i(O)))}),n(u(S))}function N(A){var S=[],O=0;return A.forEach(function(M,$){var E=$[1],_=a(S[E]||0,n(M));c(_,O)&&(O=_),S[E]=_},!0),O}function g(A){var S=A.size();if(S[0]!==S[1])throw new RangeError("Invalid matrix dimensions");var O=m(A),M=l(O,A),$=p(M).values.toArray(),E=$[$.length-1];return n(u(E))}function y(A){var S=[],O=0;return A.forEach(function(M,$){var E=$[0],_=a(S[E]||0,n(M));c(_,O)&&(O=_),S[E]=_},!0),O}function x(A,S){if(S===1)return N(A);if(S===Number.POSITIVE_INFINITY||S==="inf")return y(A);if(S==="fro")return w(A);if(S===2)return g(A);throw new Error("Unsupported parameter value "+S)}function d(A,S){var O=A.size();if(O.length===1)return b(A,S);if(O.length===2){if(O[0]&&O[1])return x(A,S);throw new RangeError("Invalid matrix dimensions")}}}),el="dot",Vw=["typed","addScalar","multiplyScalar","conj","size"],Zw=R(el,Vw,e=>{var{typed:t,addScalar:n,multiplyScalar:a,conj:r,size:i}=e;return t(el,{"Array | DenseMatrix, Array | DenseMatrix":l,"SparseMatrix, SparseMatrix":f});function u(o,s){var m=c(o),p=c(s),v,h;if(m.length===1)v=m[0];else if(m.length===2&&m[1]===1)v=m[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+m.join(", ")+")");if(p.length===1)h=p[0];else if(p.length===2&&p[1]===1)h=p[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+p.join(", ")+")");if(v!==h)throw new RangeError("Vectors must have equal length ("+v+" != "+h+")");if(v===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return v}function l(o,s){var m=u(o,s),p=De(o)?o._data:o,v=De(o)?o._datatype:void 0,h=De(s)?s._data:s,b=De(s)?s._datatype:void 0,w=c(o).length===2,N=c(s).length===2,g=n,y=a;if(v&&b&&v===b&&typeof v=="string"){var x=v;g=t.find(n,[x,x]),y=t.find(a,[x,x])}if(!w&&!N){for(var d=y(r(p[0]),h[0]),A=1;A<m;A++)d=g(d,y(r(p[A]),h[A]));return d}if(!w&&N){for(var S=y(r(p[0]),h[0][0]),O=1;O<m;O++)S=g(S,y(r(p[O]),h[O][0]));return S}if(w&&!N){for(var M=y(r(p[0][0]),h[0]),$=1;$<m;$++)M=g(M,y(r(p[$][0]),h[$]));return M}if(w&&N){for(var E=y(r(p[0][0]),h[0][0]),_=1;_<m;_++)E=g(E,y(r(p[_][0]),h[_][0]));return E}}function f(o,s){u(o,s);for(var m=o._index,p=o._values,v=s._index,h=s._values,b=0,w=n,N=a,g=0,y=0;g<m.length&&y<v.length;){var x=m[g],d=v[y];if(x<d){g++;continue}if(x>d){y++;continue}x===d&&(b=w(b,N(p[g],h[y])),g++,y++)}return b}function c(o){return De(o)?o.size():i(o)}}),Xw="trace",Yw=["typed","matrix","add"],Ww=R(Xw,Yw,e=>{var{typed:t,matrix:n,add:a}=e;return t("trace",{Array:function(l){return r(n(l))},SparseMatrix:i,DenseMatrix:r,any:Oe});function r(u){var l=u._size,f=u._data;switch(l.length){case 1:if(l[0]===1)return Oe(f[0]);throw new RangeError("Matrix must be square (size: "+Fe(l)+")");case 2:{var c=l[0],o=l[1];if(c===o){for(var s=0,m=0;m<c;m++)s=a(s,f[m][m]);return s}else throw new RangeError("Matrix must be square (size: "+Fe(l)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Fe(l)+")")}}function i(u){var l=u._values,f=u._index,c=u._ptr,o=u._size,s=o[0],m=o[1];if(s===m){var p=0;if(l.length>0)for(var v=0;v<m;v++)for(var h=c[v],b=c[v+1],w=h;w<b;w++){var N=f[w];if(N===v){p=a(p,l[w]);break}if(N>v)break}return p}throw new RangeError("Matrix must be square (size: "+Fe(o)+")")}}),rl="index",Jw=["typed","Index"],Qw=R(rl,Jw,e=>{var{typed:t,Index:n}=e;return t(rl,{"...number | string | BigNumber | Range | Array | Matrix":function(r){var i=r.map(function(l){return _e(l)?l.toNumber():Array.isArray(l)||De(l)?l.map(function(f){return _e(f)?f.toNumber():f}):l}),u=new n;return n.apply(u,i),u}})}),tl=new Set(["end"]),Kw="Node",jw=["mathWithTransform"],eN=R(Kw,jw,e=>{var{mathWithTransform:t}=e;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator")}n.prototype.evaluate=function(r){return this.compile().evaluate(r)},n.prototype.type="Node",n.prototype.isNode=!0,n.prototype.comment="",n.prototype.compile=function(){var r=this._compile(t,{}),i={},u=null;function l(f){var c=fi(f);return a(c),r(c,i,u)}return{evaluate:l}},n.prototype._compile=function(r,i){throw new Error("Method _compile should be implemented by type "+this.type)},n.prototype.forEach=function(r){throw new Error("Cannot run forEach on a Node interface")},n.prototype.map=function(r){throw new Error("Cannot run map on a Node interface")},n.prototype._ifNode=function(r){if(!Ze(r))throw new TypeError("Callback function must return a Node");return r},n.prototype.traverse=function(r){r(this,null,null);function i(u,l){u.forEach(function(f,c,o){l(f,c,o),i(f,l)})}i(this,r)},n.prototype.transform=function(r){function i(u,l,f){var c=r(u,l,f);return c!==u?c:u.map(i)}return i(this,null,null)},n.prototype.filter=function(r){var i=[];return this.traverse(function(u,l,f){r(u,l,f)&&i.push(u)}),i},n.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},n.prototype.cloneDeep=function(){return this.map(function(r){return r.cloneDeep()})},n.prototype.equals=function(r){return r?_n(this,r):!1},n.prototype.toString=function(r){var i=this._getCustomString(r);return typeof i!="undefined"?i:this._toString(r)},n.prototype.toJSON=function(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)},n.prototype.toHTML=function(r){var i=this._getCustomString(r);return typeof i!="undefined"?i:this.toHTML(r)},n.prototype._toString=function(){throw new Error("_toString not implemented for "+this.type)},n.prototype.toTex=function(r){var i=this._getCustomString(r);return typeof i!="undefined"?i:this._toTex(r)},n.prototype._toTex=function(r){throw new Error("_toTex not implemented for "+this.type)},n.prototype._getCustomString=function(r){if(r&&typeof r=="object")switch(typeof r.handler){case"object":case"undefined":return;case"function":return r.handler(this,r);default:throw new TypeError("Object or function expected as callback")}},n.prototype.getIdentifier=function(){return this.type},n.prototype.getContent=function(){return this};function a(r){for(var i of[...tl])if(r.has(i))throw new Error('Scope contains an illegal symbol, "'+i+'" is a reserved keyword')}return n},{isClass:!0,isNode:!0});function _r(e){return e&&e.isIndexError?new et(e.index+1,e.min+1,e.max!==void 0?e.max+1:void 0):e}function nl(e){var{subset:t}=e;return function(a,r){try{if(Array.isArray(a))return t(a,r);if(a&&typeof a.subset=="function")return a.subset(r);if(typeof a=="string")return t(a,r);if(typeof a=="object"){if(!r.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return Xr(a,r.getObjectProperty())}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(i){throw _r(i)}}}var rN="AccessorNode",tN=["subset","Node"],nN=R(rN,tN,e=>{var{subset:t,Node:n}=e,a=nl({subset:t});function r(u,l){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!Ze(u))throw new TypeError('Node expected for parameter "object"');if(!on(l))throw new TypeError('IndexNode expected for parameter "index"');this.object=u||null,this.index=l,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")}})}r.prototype=new n,r.prototype.type="AccessorNode",r.prototype.isAccessorNode=!0,r.prototype._compile=function(u,l){var f=this.object._compile(u,l),c=this.index._compile(u,l);if(this.index.isObjectProperty()){var o=this.index.getObjectProperty();return function(m,p,v){return Xr(f(m,p,v),o)}}else return function(m,p,v){var h=f(m,p,v),b=c(m,p,h);return a(h,b)}},r.prototype.forEach=function(u){u(this.object,"object",this),u(this.index,"index",this)},r.prototype.map=function(u){return new r(this._ifNode(u(this.object,"object",this)),this._ifNode(u(this.index,"index",this)))},r.prototype.clone=function(){return new r(this.object,this.index)},r.prototype._toString=function(u){var l=this.object.toString(u);return i(this.object)&&(l="("+l+")"),l+this.index.toString(u)},r.prototype.toHTML=function(u){var l=this.object.toHTML(u);return i(this.object)&&(l='<span class="math-parenthesis math-round-parenthesis">(</span>'+l+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+this.index.toHTML(u)},r.prototype._toTex=function(u){var l=this.object.toTex(u);return i(this.object)&&(l="\\left(' + object + '\\right)"),l+this.index.toTex(u)},r.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},r.fromJSON=function(u){return new r(u.object,u.index)};function i(u){return!(Ht(u)||Vr(u)||We(u)||Gt(u)||ta(u)||$n(u)||br(u))}return r},{isClass:!0,isNode:!0}),aN="ArrayNode",iN=["Node"],oN=R(aN,iN,e=>{var{Node:t}=e;function n(a){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=a||[],!Array.isArray(this.items)||!this.items.every(Ze))throw new TypeError("Array containing Nodes expected")}return n.prototype=new t,n.prototype.type="ArrayNode",n.prototype.isArrayNode=!0,n.prototype._compile=function(a,r){var i=yt(this.items,function(f){return f._compile(a,r)}),u=a.config.matrix!=="Array";if(u){var l=a.matrix;return function(c,o,s){return l(yt(i,function(m){return m(c,o,s)}))}}else return function(c,o,s){return yt(i,function(m){return m(c,o,s)})}},n.prototype.forEach=function(a){for(var r=0;r<this.items.length;r++){var i=this.items[r];a(i,"items["+r+"]",this)}},n.prototype.map=function(a){for(var r=[],i=0;i<this.items.length;i++)r[i]=this._ifNode(a(this.items[i],"items["+i+"]",this));return new n(r)},n.prototype.clone=function(){return new n(this.items.slice(0))},n.prototype._toString=function(a){var r=this.items.map(function(i){return i.toString(a)});return"["+r.join(", ")+"]"},n.prototype.toJSON=function(){return{mathjs:"ArrayNode",items:this.items}},n.fromJSON=function(a){return new n(a.items)},n.prototype.toHTML=function(a){var r=this.items.map(function(i){return i.toHTML(a)});return'<span class="math-parenthesis math-square-parenthesis">[</span>'+r.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'},n.prototype._toTex=function(a){function r(i,u){var l=i.some(Vr)&&!i.every(Vr),f=u||l,c=f?"&":"\\\\",o=i.map(function(s){return s.items?r(s.items,!u):s.toTex(a)}).join(c);return l||!f||f&&!u?"\\begin{bmatrix}"+o+"\\end{bmatrix}":o}return r(this.items,!1)},n},{isClass:!0,isNode:!0});function sN(e){var{subset:t,matrix:n}=e;return function(r,i,u){try{if(Array.isArray(r))return n(r).subset(i,u).valueOf();if(r&&typeof r.subset=="function")return r.subset(i,u);if(typeof r=="string")return t(r,i,u);if(typeof r=="object"){if(!i.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return ln(r,i.getObjectProperty(),u),r}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(l){throw _r(l)}}}var lt=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{associativity:"left",associativeWith:[]}},{"OperatorNode:and":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{associativity:"left",associativeWith:[]},"OperatorNode:unequal":{associativity:"left",associativeWith:[]},"OperatorNode:smaller":{associativity:"left",associativeWith:[]},"OperatorNode:larger":{associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{associativity:"left",associativeWith:[]}},{"OperatorNode:to":{associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{associativity:"left",associativeWith:[]},"OperatorNode:mod":{associativity:"left",associativeWith:[]}},{"OperatorNode:unaryPlus":{associativity:"right"},"OperatorNode:unaryMinus":{associativity:"right"},"OperatorNode:bitNot":{associativity:"right"},"OperatorNode:not":{associativity:"right"}},{"OperatorNode:pow":{associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{associativity:"left"}},{"OperatorNode:transpose":{associativity:"left"}}];function Qe(e,t){var n=e;t!=="keep"&&(n=e.getContent());for(var a=n.getIdentifier(),r=0;r<lt.length;r++)if(a in lt[r])return r;return null}function Ln(e,t){var n=e;t!=="keep"&&(n=e.getContent());var a=n.getIdentifier(),r=Qe(n,t);if(r===null)return null;var i=lt[r][a];if(Ae(i,"associativity")){if(i.associativity==="left")return"left";if(i.associativity==="right")return"right";throw Error("'"+a+"' has the invalid associativity '"+i.associativity+"'.")}return null}function qi(e,t,n){var a=n!=="keep"?e.getContent():e,r=n!=="keep"?e.getContent():t,i=a.getIdentifier(),u=r.getIdentifier(),l=Qe(a,n);if(l===null)return null;var f=lt[l][i];if(Ae(f,"associativeWith")&&f.associativeWith instanceof Array){for(var c=0;c<f.associativeWith.length;c++)if(f.associativeWith[c]===u)return!0;return!1}return null}var uN="AssignmentNode",cN=["subset","?matrix","Node"],fN=R(uN,cN,e=>{var{subset:t,matrix:n,Node:a}=e,r=nl({subset:t}),i=sN({subset:t,matrix:n});function u(f,c,o){if(!(this instanceof u))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=f,this.index=o?c:null,this.value=o||c,!br(f)&&!Ht(f))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(br(f)&&f.name==="end")throw new Error('Cannot assign to symbol "end"');if(this.index&&!on(this.index))throw new TypeError('IndexNode expected as "index"');if(!Ze(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")}})}u.prototype=new a,u.prototype.type="AssignmentNode",u.prototype.isAssignmentNode=!0,u.prototype._compile=function(f,c){var o=this.object._compile(f,c),s=this.index?this.index._compile(f,c):null,m=this.value._compile(f,c),p=this.object.name;if(this.index)if(this.index.isObjectProperty()){var v=this.index.getObjectProperty();return function(g,y,x){var d=o(g,y,x),A=m(g,y,x);return ln(d,v,A),A}}else{if(br(this.object))return function(g,y,x){var d=o(g,y,x),A=m(g,y,x),S=s(g,y,d);return g.set(p,i(d,S,A)),A};var h=this.object.object._compile(f,c);if(this.object.index.isObjectProperty()){var b=this.object.index.getObjectProperty();return function(g,y,x){var d=h(g,y,x),A=Xr(d,b),S=s(g,y,A),O=m(g,y,x);return ln(d,b,i(A,S,O)),O}}else{var w=this.object.index._compile(f,c);return function(g,y,x){var d=h(g,y,x),A=w(g,y,d),S=r(d,A),O=s(g,y,S),M=m(g,y,x);return i(d,A,i(S,O,M)),M}}}else{if(!br(this.object))throw new TypeError("SymbolNode expected as object");return function(g,y,x){var d=m(g,y,x);return g.set(p,d),d}}},u.prototype.forEach=function(f){f(this.object,"object",this),this.index&&f(this.index,"index",this),f(this.value,"value",this)},u.prototype.map=function(f){var c=this._ifNode(f(this.object,"object",this)),o=this.index?this._ifNode(f(this.index,"index",this)):null,s=this._ifNode(f(this.value,"value",this));return new u(c,o,s)},u.prototype.clone=function(){return new u(this.object,this.index,this.value)};function l(f,c){c||(c="keep");var o=Qe(f,c),s=Qe(f.value,c);return c==="all"||s!==null&&s<=o}return u.prototype._toString=function(f){var c=this.object.toString(f),o=this.index?this.index.toString(f):"",s=this.value.toString(f);return l(this,f&&f.parenthesis)&&(s="("+s+")"),c+o+" = "+s},u.prototype.toJSON=function(){return{mathjs:"AssignmentNode",object:this.object,index:this.index,value:this.value}},u.fromJSON=function(f){return new u(f.object,f.index,f.value)},u.prototype.toHTML=function(f){var c=this.object.toHTML(f),o=this.index?this.index.toHTML(f):"",s=this.value.toHTML(f);return l(this,f&&f.parenthesis)&&(s='<span class="math-paranthesis math-round-parenthesis">(</span>'+s+'<span class="math-paranthesis math-round-parenthesis">)</span>'),c+o+'<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+s},u.prototype._toTex=function(f){var c=this.object.toTex(f),o=this.index?this.index.toTex(f):"",s=this.value.toTex(f);return l(this,f&&f.parenthesis)&&(s="\\left(".concat(s,"\\right)")),c+o+":="+s},u},{isClass:!0,isNode:!0}),lN="BlockNode",mN=["ResultSet","Node"],pN=R(lN,mN,e=>{var{ResultSet:t,Node:n}=e;function a(r){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(r))throw new Error("Array expected");this.blocks=r.map(function(i){var u=i&&i.node,l=i&&i.visible!==void 0?i.visible:!0;if(!Ze(u))throw new TypeError('Property "node" must be a Node');if(typeof l!="boolean")throw new TypeError('Property "visible" must be a boolean');return{node:u,visible:l}})}return a.prototype=new n,a.prototype.type="BlockNode",a.prototype.isBlockNode=!0,a.prototype._compile=function(r,i){var u=yt(this.blocks,function(l){return{evaluate:l.node._compile(r,i),visible:l.visible}});return function(f,c,o){var s=[];return ca(u,function(p){var v=p.evaluate(f,c,o);p.visible&&s.push(v)}),new t(s)}},a.prototype.forEach=function(r){for(var i=0;i<this.blocks.length;i++)r(this.blocks[i].node,"blocks["+i+"].node",this)},a.prototype.map=function(r){for(var i=[],u=0;u<this.blocks.length;u++){var l=this.blocks[u],f=this._ifNode(r(l.node,"blocks["+u+"].node",this));i[u]={node:f,visible:l.visible}}return new a(i)},a.prototype.clone=function(){var r=this.blocks.map(function(i){return{node:i.node,visible:i.visible}});return new a(r)},a.prototype._toString=function(r){return this.blocks.map(function(i){return i.node.toString(r)+(i.visible?"":";")}).join(`
12
+ `)},a.prototype.toJSON=function(){return{mathjs:"BlockNode",blocks:this.blocks}},a.fromJSON=function(r){return new a(r.blocks)},a.prototype.toHTML=function(r){return this.blocks.map(function(i){return i.node.toHTML(r)+(i.visible?"":'<span class="math-separator">;</span>')}).join('<span class="math-separator"><br /></span>')},a.prototype._toTex=function(r){return this.blocks.map(function(i){return i.node.toTex(r)+(i.visible?"":";")}).join(`\\;\\;
13
+ `)},a},{isClass:!0,isNode:!0}),vN="ConditionalNode",hN=["Node"],dN=R(vN,hN,e=>{var{Node:t}=e;function n(r,i,u){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Ze(r))throw new TypeError("Parameter condition must be a Node");if(!Ze(i))throw new TypeError("Parameter trueExpr must be a Node");if(!Ze(u))throw new TypeError("Parameter falseExpr must be a Node");this.condition=r,this.trueExpr=i,this.falseExpr=u}n.prototype=new t,n.prototype.type="ConditionalNode",n.prototype.isConditionalNode=!0,n.prototype._compile=function(r,i){var u=this.condition._compile(r,i),l=this.trueExpr._compile(r,i),f=this.falseExpr._compile(r,i);return function(o,s,m){return a(u(o,s,m))?l(o,s,m):f(o,s,m)}},n.prototype.forEach=function(r){r(this.condition,"condition",this),r(this.trueExpr,"trueExpr",this),r(this.falseExpr,"falseExpr",this)},n.prototype.map=function(r){return new n(this._ifNode(r(this.condition,"condition",this)),this._ifNode(r(this.trueExpr,"trueExpr",this)),this._ifNode(r(this.falseExpr,"falseExpr",this)))},n.prototype.clone=function(){return new n(this.condition,this.trueExpr,this.falseExpr)},n.prototype._toString=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",u=Qe(this,i),l=this.condition.toString(r),f=Qe(this.condition,i);(i==="all"||this.condition.type==="OperatorNode"||f!==null&&f<=u)&&(l="("+l+")");var c=this.trueExpr.toString(r),o=Qe(this.trueExpr,i);(i==="all"||this.trueExpr.type==="OperatorNode"||o!==null&&o<=u)&&(c="("+c+")");var s=this.falseExpr.toString(r),m=Qe(this.falseExpr,i);return(i==="all"||this.falseExpr.type==="OperatorNode"||m!==null&&m<=u)&&(s="("+s+")"),l+" ? "+c+" : "+s},n.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},n.fromJSON=function(r){return new n(r.condition,r.trueExpr,r.falseExpr)},n.prototype.toHTML=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",u=Qe(this,i),l=this.condition.toHTML(r),f=Qe(this.condition,i);(i==="all"||this.condition.type==="OperatorNode"||f!==null&&f<=u)&&(l='<span class="math-parenthesis math-round-parenthesis">(</span>'+l+'<span class="math-parenthesis math-round-parenthesis">)</span>');var c=this.trueExpr.toHTML(r),o=Qe(this.trueExpr,i);(i==="all"||this.trueExpr.type==="OperatorNode"||o!==null&&o<=u)&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>');var s=this.falseExpr.toHTML(r),m=Qe(this.falseExpr,i);return(i==="all"||this.falseExpr.type==="OperatorNode"||m!==null&&m<=u)&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+'<span class="math-operator math-conditional-operator">?</span>'+c+'<span class="math-operator math-conditional-operator">:</span>'+s},n.prototype._toTex=function(r){return"\\begin{cases} {"+this.trueExpr.toTex(r)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(r)+"}\\\\{"+this.falseExpr.toTex(r)+"}, &\\quad{\\text{otherwise}}\\end{cases}"};function a(r){if(typeof r=="number"||typeof r=="boolean"||typeof r=="string")return!!r;if(r){if(_e(r))return!r.isZero();if(Tr(r))return!!(r.re||r.im);if(gt(r))return!!r.value}if(r==null)return!1;throw new TypeError('Unsupported type of condition "'+je(r)+'"')}return n},{isClass:!0,isNode:!0}),Ri,al;function gN(){if(al)return Ri;al=1;var e=Object.assign||function(r){for(var i=1;i<arguments.length;i++){var u=arguments[i];for(var l in u)Object.prototype.hasOwnProperty.call(u,l)&&(r[l]=u[l])}return r},t={"{":"\\{","}":"\\}","\\":"\\textbackslash{}","#":"\\#",$:"\\$","%":"\\%","&":"\\&","^":"\\textasciicircum{}",_:"\\_","~":"\\textasciitilde{}"},n={"–":"\\--","—":"\\---"," ":"~"," ":"\\qquad{}","\r\n":"\\newline{}","\n":"\\newline{}"},a=function(i,u){return e({},i,u)};return Ri=function(r){for(var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=i.preserveFormatting,l=u===void 0?!1:u,f=i.escapeMapFn,c=f===void 0?a:f,o=String(r),s="",m=c(e({},t),l?e({},n):{}),p=Object.keys(m),v=function(){var b=!1;p.forEach(function(w,N){b||o.length>=w.length&&o.slice(0,w.length)===w&&(s+=m[p[N]],o=o.slice(w.length,o.length),b=!0)}),b||(s+=o.slice(0,1),o=o.slice(1,o.length))};o;)v();return s},Ri}var yN=gN();const xN=na(yN);var Fi={Alpha:"A",alpha:"\\alpha",Beta:"B",beta:"\\beta",Gamma:"\\Gamma",gamma:"\\gamma",Delta:"\\Delta",delta:"\\delta",Epsilon:"E",epsilon:"\\epsilon",varepsilon:"\\varepsilon",Zeta:"Z",zeta:"\\zeta",Eta:"H",eta:"\\eta",Theta:"\\Theta",theta:"\\theta",vartheta:"\\vartheta",Iota:"I",iota:"\\iota",Kappa:"K",kappa:"\\kappa",varkappa:"\\varkappa",Lambda:"\\Lambda",lambda:"\\lambda",Mu:"M",mu:"\\mu",Nu:"N",nu:"\\nu",Xi:"\\Xi",xi:"\\xi",Omicron:"O",omicron:"o",Pi:"\\Pi",pi:"\\pi",varpi:"\\varpi",Rho:"P",rho:"\\rho",varrho:"\\varrho",Sigma:"\\Sigma",sigma:"\\sigma",varsigma:"\\varsigma",Tau:"T",tau:"\\tau",Upsilon:"\\Upsilon",upsilon:"\\upsilon",Phi:"\\Phi",phi:"\\phi",varphi:"\\varphi",Chi:"X",chi:"\\chi",Psi:"\\Psi",psi:"\\psi",Omega:"\\Omega",omega:"\\omega",true:"\\mathrm{True}",false:"\\mathrm{False}",i:"i",inf:"\\infty",Inf:"\\infty",infinity:"\\infty",Infinity:"\\infty",oo:"\\infty",lim:"\\lim",undefined:"\\mathbf{?}"},Ge={transpose:"^\\top",ctranspose:"^H",factorial:"!",pow:"^",dotPow:".^\\wedge",unaryPlus:"+",unaryMinus:"-",bitNot:"\\~",not:"\\neg",multiply:"\\cdot",divide:"\\frac",dotMultiply:".\\cdot",dotDivide:".:",mod:"\\mod",add:"+",subtract:"-",to:"\\rightarrow",leftShift:"<<",rightArithShift:">>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},il={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(Ge.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(Ge.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(Ge.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(Ge.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(Ge.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(Ge.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(Ge.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(Ge.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(Ge.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(Ge.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(Ge.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(Ge.bitAnd,"${args[1]}\\right)")},bitNot:{1:Ge.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(Ge.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(Ge.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(Ge.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(Ge.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(Ge.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(Ge.and,"${args[1]}\\right)")},not:{1:Ge.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(Ge.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(Ge.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(Ge.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},pinv:{1:"\\left(${args[0]}\\right)^{+}"},sqrtm:{1:"{${args[0]}}".concat(Ge.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(Ge.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(Ge.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(Ge.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(Ge.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(Ge.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(Ge.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(Ge.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(Ge.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(Ge.to,"${args[1]}\\right)")},numeric:function(t,n){return t.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(Fi.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)"}},bN="\\mathrm{${name}}\\left(${args}\\right)",ol={deg:"^\\circ"};function zi(e){return xN(e,{preserveFormatting:!0})}function sl(e,t){return t=typeof t=="undefined"?!1:t,t?Ae(ol,e)?ol[e]:"\\mathrm{"+zi(e)+"}":Ae(Fi,e)?Fi[e]:zi(e)}var wN="ConstantNode",NN=["Node"],MN=R(wN,NN,e=>{var{Node:t}=e;function n(a){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.value=a}return n.prototype=new t,n.prototype.type="ConstantNode",n.prototype.isConstantNode=!0,n.prototype._compile=function(a,r){var i=this.value;return function(){return i}},n.prototype.forEach=function(a){},n.prototype.map=function(a){return this.clone()},n.prototype.clone=function(){return new n(this.value)},n.prototype._toString=function(a){return Fe(this.value,a)},n.prototype.toHTML=function(a){var r=this._toString(a);switch(je(this.value)){case"number":case"BigNumber":case"Fraction":return'<span class="math-number">'+r+"</span>";case"string":return'<span class="math-string">'+r+"</span>";case"boolean":return'<span class="math-boolean">'+r+"</span>";case"null":return'<span class="math-null-symbol">'+r+"</span>";case"undefined":return'<span class="math-undefined">'+r+"</span>";default:return'<span class="math-symbol">'+r+"</span>"}},n.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},n.fromJSON=function(a){return new n(a.value)},n.prototype._toTex=function(a){var r=this._toString(a);switch(je(this.value)){case"string":return"\\mathtt{"+zi(r)+"}";case"number":case"BigNumber":{if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var i=r.toLowerCase().indexOf("e");if(i!==-1)return r.substring(0,i)+"\\cdot10^{"+r.substring(i+1)+"}"}return r;case"Fraction":return this.value.toLatex();default:return r}},n},{isClass:!0,isNode:!0}),AN="FunctionAssignmentNode",SN=["typed","Node"],EN=R(AN,SN,e=>{var{typed:t,Node:n}=e;function a(i,u,l){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(typeof i!="string")throw new TypeError('String expected for parameter "name"');if(!Array.isArray(u))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!Ze(l))throw new TypeError('Node expected for parameter "expr"');if(tl.has(i))throw new Error('Illegal function name, "'+i+'" is a reserved keyword');this.name=i,this.params=u.map(function(f){return f&&f.name||f}),this.types=u.map(function(f){return f&&f.type||"any"}),this.expr=l}a.prototype=new n,a.prototype.type="FunctionAssignmentNode",a.prototype.isFunctionAssignmentNode=!0,a.prototype._compile=function(i,u){var l=Object.create(u);ca(this.params,function(p){l[p]=!0});var f=this.expr._compile(i,l),c=this.name,o=this.params,s=Co(this.types,","),m=c+"("+Co(this.params,", ")+")";return function(v,h,b){var w={};w[s]=function(){for(var g=Object.create(h),y=0;y<o.length;y++)g[o[y]]=arguments[y];return f(v,g,b)};var N=t(c,w);return N.syntax=m,v.set(c,N),N}},a.prototype.forEach=function(i){i(this.expr,"expr",this)},a.prototype.map=function(i){var u=this._ifNode(i(this.expr,"expr",this));return new a(this.name,this.params.slice(0),u)},a.prototype.clone=function(){return new a(this.name,this.params.slice(0),this.expr)};function r(i,u){var l=Qe(i,u),f=Qe(i.expr,u);return u==="all"||f!==null&&f<=l}return a.prototype._toString=function(i){var u=i&&i.parenthesis?i.parenthesis:"keep",l=this.expr.toString(i);return r(this,u)&&(l="("+l+")"),this.name+"("+this.params.join(", ")+") = "+l},a.prototype.toJSON=function(){var i=this.types;return{mathjs:"FunctionAssignmentNode",name:this.name,params:this.params.map(function(u,l){return{name:u,type:i[l]}}),expr:this.expr}},a.fromJSON=function(i){return new a(i.name,i.params,i.expr)},a.prototype.toHTML=function(i){for(var u=i&&i.parenthesis?i.parenthesis:"keep",l=[],f=0;f<this.params.length;f++)l.push('<span class="math-symbol math-parameter">'+Zr(this.params[f])+"</span>");var c=this.expr.toHTML(i);return r(this,u)&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>'),'<span class="math-function">'+Zr(this.name)+'</span><span class="math-parenthesis math-round-parenthesis">(</span>'+l.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-round-parenthesis">)</span><span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+c},a.prototype._toTex=function(i){var u=i&&i.parenthesis?i.parenthesis:"keep",l=this.expr.toTex(i);return r(this,u)&&(l="\\left(".concat(l,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(sl).join(",")+"\\right):="+l},a},{isClass:!0,isNode:!0}),CN="IndexNode",ON=["Node","size"],DN=R(CN,ON,e=>{var{Node:t,size:n}=e;function a(r,i){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(this.dimensions=r,this.dotNotation=i||!1,!Array.isArray(r)||!r.every(Ze))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}return a.prototype=new t,a.prototype.type="IndexNode",a.prototype.isIndexNode=!0,a.prototype._compile=function(r,i){var u=yt(this.dimensions,function(f,c){var o=f.filter(p=>p.isSymbolNode&&p.name==="end").length>0;if(o){var s=Object.create(i);s.end=!0;var m=f._compile(r,s);return function(v,h,b){if(!De(b)&&!Ye(b)&&!Ir(b))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+je(b));var w=n(b).valueOf(),N=Object.create(h);return N.end=w[c],m(v,N,b)}}else return f._compile(r,i)}),l=Xr(r,"index");return function(c,o,s){var m=yt(u,function(p){return p(c,o,s)});return l(...m)}},a.prototype.forEach=function(r){for(var i=0;i<this.dimensions.length;i++)r(this.dimensions[i],"dimensions["+i+"]",this)},a.prototype.map=function(r){for(var i=[],u=0;u<this.dimensions.length;u++)i[u]=this._ifNode(r(this.dimensions[u],"dimensions["+u+"]",this));return new a(i,this.dotNotation)},a.prototype.clone=function(){return new a(this.dimensions.slice(0),this.dotNotation)},a.prototype.isObjectProperty=function(){return this.dimensions.length===1&&We(this.dimensions[0])&&typeof this.dimensions[0].value=="string"},a.prototype.getObjectProperty=function(){return this.isObjectProperty()?this.dimensions[0].value:null},a.prototype._toString=function(r){return this.dotNotation?"."+this.getObjectProperty():"["+this.dimensions.join(", ")+"]"},a.prototype.toJSON=function(){return{mathjs:"IndexNode",dimensions:this.dimensions,dotNotation:this.dotNotation}},a.fromJSON=function(r){return new a(r.dimensions,r.dotNotation)},a.prototype.toHTML=function(r){for(var i=[],u=0;u<this.dimensions.length;u++)i[u]=this.dimensions[u].toHTML();return this.dotNotation?'<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">'+Zr(this.getObjectProperty())+"</span>":'<span class="math-parenthesis math-square-parenthesis">[</span>'+i.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'},a.prototype._toTex=function(r){var i=this.dimensions.map(function(u){return u.toTex(r)});return this.dotNotation?"."+this.getObjectProperty():"_{"+i.join(",")+"}"},a},{isClass:!0,isNode:!0}),TN="ObjectNode",BN=["Node"],$N=R(TN,BN,e=>{var{Node:t}=e;function n(a){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=a||{},a&&(typeof a!="object"||!Object.keys(a).every(function(r){return Ze(a[r])})))throw new TypeError("Object containing Nodes expected")}return n.prototype=new t,n.prototype.type="ObjectNode",n.prototype.isObjectNode=!0,n.prototype._compile=function(a,r){var i={};for(var u in this.properties)if(Ae(this.properties,u)){var l=sa(u),f=JSON.parse(l);if(!si(this.properties,f))throw new Error('No access to property "'+f+'"');i[f]=this.properties[u]._compile(a,r)}return function(o,s,m){var p={};for(var v in i)Ae(i,v)&&(p[v]=i[v](o,s,m));return p}},n.prototype.forEach=function(a){for(var r in this.properties)Ae(this.properties,r)&&a(this.properties[r],"properties["+sa(r)+"]",this)},n.prototype.map=function(a){var r={};for(var i in this.properties)Ae(this.properties,i)&&(r[i]=this._ifNode(a(this.properties[i],"properties["+sa(i)+"]",this)));return new n(r)},n.prototype.clone=function(){var a={};for(var r in this.properties)Ae(this.properties,r)&&(a[r]=this.properties[r]);return new n(a)},n.prototype._toString=function(a){var r=[];for(var i in this.properties)Ae(this.properties,i)&&r.push(sa(i)+": "+this.properties[i].toString(a));return"{"+r.join(", ")+"}"},n.prototype.toJSON=function(){return{mathjs:"ObjectNode",properties:this.properties}},n.fromJSON=function(a){return new n(a.properties)},n.prototype.toHTML=function(a){var r=[];for(var i in this.properties)Ae(this.properties,i)&&r.push('<span class="math-symbol math-property">'+Zr(i)+'</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>'+this.properties[i].toHTML(a));return'<span class="math-parenthesis math-curly-parenthesis">{</span>'+r.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-curly-parenthesis">}</span>'},n.prototype._toTex=function(a){var r=[];for(var i in this.properties)Ae(this.properties,i)&&r.push("\\mathbf{"+i+":} & "+this.properties[i].toTex(a)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(r.join(`
14
+ `),"\\end{array}\\right\\}")},n},{isClass:!0,isNode:!0}),_N="OperatorNode",IN=["Node"],qN=R(_N,IN,e=>{var{Node:t}=e;function n(r,i,u,l,f){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(typeof r!="string")throw new TypeError('string expected for parameter "op"');if(typeof i!="string")throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(u)||!u.every(Ze))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=l===!0,this.isPercentage=f===!0,this.op=r,this.fn=i,this.args=u||[]}n.prototype=new t,n.prototype.type="OperatorNode",n.prototype.isOperatorNode=!0,n.prototype._compile=function(r,i){if(typeof this.fn!="string"||!ui(r,this.fn))throw r[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var u=Xr(r,this.fn),l=yt(this.args,function(s){return s._compile(r,i)});if(l.length===1){var f=l[0];return function(m,p,v){return u(f(m,p,v))}}else if(l.length===2){var c=l[0],o=l[1];return function(m,p,v){return u(c(m,p,v),o(m,p,v))}}else return function(m,p,v){return u.apply(null,yt(l,function(h){return h(m,p,v)}))}},n.prototype.forEach=function(r){for(var i=0;i<this.args.length;i++)r(this.args[i],"args["+i+"]",this)},n.prototype.map=function(r){for(var i=[],u=0;u<this.args.length;u++)i[u]=this._ifNode(r(this.args[u],"args["+u+"]",this));return new n(this.op,this.fn,i,this.implicit,this.isPercentage)},n.prototype.clone=function(){return new n(this.op,this.fn,this.args.slice(0),this.implicit,this.isPercentage)},n.prototype.isUnary=function(){return this.args.length===1},n.prototype.isBinary=function(){return this.args.length===2};function a(r,i,u,l,f){var c=Qe(r,i),o=Ln(r,i);if(i==="all"||l.length>2&&r.getIdentifier()!=="OperatorNode:add"&&r.getIdentifier()!=="OperatorNode:multiply")return l.map(function(S){switch(S.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}});var s;switch(l.length){case 0:s=[];break;case 1:{var m=Qe(l[0],i);if(f&&m!==null){var p,v;if(i==="keep"?(p=l[0].getIdentifier(),v=r.getIdentifier()):(p=l[0].getContent().getIdentifier(),v=r.getContent().getIdentifier()),lt[c][v].latexLeftParens===!1){s=[!1];break}if(lt[m][p].latexParens===!1){s=[!1];break}}if(m===null){s=[!1];break}if(m<=c){s=[!0];break}s=[!1]}break;case 2:{var h,b=Qe(l[0],i),w=qi(r,l[0],i);b===null?h=!1:b===c&&o==="right"&&!w||b<c?h=!0:h=!1;var N,g=Qe(l[1],i),y=qi(r,l[1],i);if(g===null?N=!1:g===c&&o==="left"&&!y||g<c?N=!0:N=!1,f){var x,d,A;i==="keep"?(x=r.getIdentifier(),d=r.args[0].getIdentifier(),A=r.args[1].getIdentifier()):(x=r.getContent().getIdentifier(),d=r.args[0].getContent().getIdentifier(),A=r.args[1].getContent().getIdentifier()),b!==null&&(lt[c][x].latexLeftParens===!1&&(h=!1),lt[b][d].latexParens===!1&&(h=!1)),g!==null&&(lt[c][x].latexRightParens===!1&&(N=!1),lt[g][A].latexParens===!1&&(N=!1))}s=[h,N]}break;default:(r.getIdentifier()==="OperatorNode:add"||r.getIdentifier()==="OperatorNode:multiply")&&(s=l.map(function(S){var O=Qe(S,i),M=qi(r,S,i),$=Ln(S,i);return O===null?!1:c===O&&o===$&&!M?!0:O<c}));break}return l.length>=2&&r.getIdentifier()==="OperatorNode:multiply"&&r.implicit&&i==="auto"&&u==="hide"&&(s=l.map(function(S,O){var M=S.getIdentifier()==="ParenthesisNode";return!!(s[O]||M)})),s}return n.prototype._toString=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",u=r&&r.implicit?r.implicit:"hide",l=this.args,f=a(this,i,u,l,!1);if(l.length===1){var c=Ln(this,i),o=l[0].toString(r);f[0]&&(o="("+o+")");var s=/[a-zA-Z]+/.test(this.op);return c==="right"?this.op+(s?" ":"")+o:c==="left"?o+(s?" ":"")+this.op:o+this.op}else if(l.length===2){var m=l[0].toString(r),p=l[1].toString(r);return f[0]&&(m="("+m+")"),f[1]&&(p="("+p+")"),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&u==="hide"?m+" "+p:m+" "+this.op+" "+p}else if(l.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var v=l.map(function(h,b){return h=h.toString(r),f[b]&&(h="("+h+")"),h});return this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&u==="hide"?v.join(" "):v.join(" "+this.op+" ")}else return this.fn+"("+this.args.join(", ")+")"},n.prototype.toJSON=function(){return{mathjs:"OperatorNode",op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}},n.fromJSON=function(r){return new n(r.op,r.fn,r.args,r.implicit,r.isPercentage)},n.prototype.toHTML=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",u=r&&r.implicit?r.implicit:"hide",l=this.args,f=a(this,i,u,l,!1);if(l.length===1){var c=Ln(this,i),o=l[0].toHTML(r);return f[0]&&(o='<span class="math-parenthesis math-round-parenthesis">(</span>'+o+'<span class="math-parenthesis math-round-parenthesis">)</span>'),c==="right"?'<span class="math-operator math-unary-operator math-lefthand-unary-operator">'+Zr(this.op)+"</span>"+o:o+'<span class="math-operator math-unary-operator math-righthand-unary-operator">'+Zr(this.op)+"</span>"}else if(l.length===2){var s=l[0].toHTML(r),m=l[1].toHTML(r);return f[0]&&(s='<span class="math-parenthesis math-round-parenthesis">(</span>'+s+'<span class="math-parenthesis math-round-parenthesis">)</span>'),f[1]&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>'),this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&u==="hide"?s+'<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'+m:s+'<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Zr(this.op)+"</span>"+m}else{var p=l.map(function(v,h){return v=v.toHTML(r),f[h]&&(v='<span class="math-parenthesis math-round-parenthesis">(</span>'+v+'<span class="math-parenthesis math-round-parenthesis">)</span>'),v});return l.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")?this.implicit&&this.getIdentifier()==="OperatorNode:multiply"&&u==="hide"?p.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>'):p.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Zr(this.op)+"</span>"):'<span class="math-function">'+Zr(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+p.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'}},n.prototype._toTex=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",u=r&&r.implicit?r.implicit:"hide",l=this.args,f=a(this,i,u,l,!0),c=Ge[this.fn];if(c=typeof c=="undefined"?this.op:c,l.length===1){var o=Ln(this,i),s=l[0].toTex(r);return f[0]&&(s="\\left(".concat(s,"\\right)")),o==="right"?c+s:s+c}else if(l.length===2){var m=l[0],p=m.toTex(r);f[0]&&(p="\\left(".concat(p,"\\right)"));var v=l[1],h=v.toTex(r);f[1]&&(h="\\left(".concat(h,"\\right)"));var b;switch(i==="keep"?b=m.getIdentifier():b=m.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return c+"{"+p+"}{"+h+"}";case"OperatorNode:pow":switch(p="{"+p+"}",h="{"+h+"}",b){case"ConditionalNode":case"OperatorNode:divide":p="\\left(".concat(p,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&u==="hide")return p+"~"+h}return p+c+h}else if(l.length>2&&(this.getIdentifier()==="OperatorNode:add"||this.getIdentifier()==="OperatorNode:multiply")){var w=l.map(function(N,g){return N=N.toTex(r),f[g]&&(N="\\left(".concat(N,"\\right)")),N});return this.getIdentifier()==="OperatorNode:multiply"&&this.implicit?w.join("~"):w.join(c)}else return"\\mathrm{"+this.fn+"}\\left("+l.map(function(N){return N.toTex(r)}).join(",")+"\\right)"},n.prototype.getIdentifier=function(){return this.type+":"+this.fn},n},{isClass:!0,isNode:!0}),RN="ParenthesisNode",FN=["Node"],zN=R(RN,FN,e=>{var{Node:t}=e;function n(a){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Ze(a))throw new TypeError('Node expected for parameter "content"');this.content=a}return n.prototype=new t,n.prototype.type="ParenthesisNode",n.prototype.isParenthesisNode=!0,n.prototype._compile=function(a,r){return this.content._compile(a,r)},n.prototype.getContent=function(){return this.content.getContent()},n.prototype.forEach=function(a){a(this.content,"content",this)},n.prototype.map=function(a){var r=a(this.content,"content",this);return new n(r)},n.prototype.clone=function(){return new n(this.content)},n.prototype._toString=function(a){return!a||a&&!a.parenthesis||a&&a.parenthesis==="keep"?"("+this.content.toString(a)+")":this.content.toString(a)},n.prototype.toJSON=function(){return{mathjs:"ParenthesisNode",content:this.content}},n.fromJSON=function(a){return new n(a.content)},n.prototype.toHTML=function(a){return!a||a&&!a.parenthesis||a&&a.parenthesis==="keep"?'<span class="math-parenthesis math-round-parenthesis">(</span>'+this.content.toHTML(a)+'<span class="math-parenthesis math-round-parenthesis">)</span>':this.content.toHTML(a)},n.prototype._toTex=function(a){return!a||a&&!a.parenthesis||a&&a.parenthesis==="keep"?"\\left(".concat(this.content.toTex(a),"\\right)"):this.content.toTex(a)},n},{isClass:!0,isNode:!0}),PN="RangeNode",UN=["Node"],LN=R(PN,UN,e=>{var{Node:t}=e;function n(r,i,u){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Ze(r))throw new TypeError("Node expected");if(!Ze(i))throw new TypeError("Node expected");if(u&&!Ze(u))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=r,this.end=i,this.step=u||null}n.prototype=new t,n.prototype.type="RangeNode",n.prototype.isRangeNode=!0,n.prototype.needsEnd=function(){var r=this.filter(function(i){return br(i)&&i.name==="end"});return r.length>0},n.prototype._compile=function(r,i){var u=r.range,l=this.start._compile(r,i),f=this.end._compile(r,i);if(this.step){var c=this.step._compile(r,i);return function(s,m,p){return u(l(s,m,p),f(s,m,p),c(s,m,p))}}else return function(s,m,p){return u(l(s,m,p),f(s,m,p))}},n.prototype.forEach=function(r){r(this.start,"start",this),r(this.end,"end",this),this.step&&r(this.step,"step",this)},n.prototype.map=function(r){return new n(this._ifNode(r(this.start,"start",this)),this._ifNode(r(this.end,"end",this)),this.step&&this._ifNode(r(this.step,"step",this)))},n.prototype.clone=function(){return new n(this.start,this.end,this.step&&this.step)};function a(r,i){var u=Qe(r,i),l={},f=Qe(r.start,i);if(l.start=f!==null&&f<=u||i==="all",r.step){var c=Qe(r.step,i);l.step=c!==null&&c<=u||i==="all"}var o=Qe(r.end,i);return l.end=o!==null&&o<=u||i==="all",l}return n.prototype._toString=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",u=a(this,i),l,f=this.start.toString(r);if(u.start&&(f="("+f+")"),l=f,this.step){var c=this.step.toString(r);u.step&&(c="("+c+")"),l+=":"+c}var o=this.end.toString(r);return u.end&&(o="("+o+")"),l+=":"+o,l},n.prototype.toJSON=function(){return{mathjs:"RangeNode",start:this.start,end:this.end,step:this.step}},n.fromJSON=function(r){return new n(r.start,r.end,r.step)},n.prototype.toHTML=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",u=a(this,i),l,f=this.start.toHTML(r);if(u.start&&(f='<span class="math-parenthesis math-round-parenthesis">(</span>'+f+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l=f,this.step){var c=this.step.toHTML(r);u.step&&(c='<span class="math-parenthesis math-round-parenthesis">(</span>'+c+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+='<span class="math-operator math-range-operator">:</span>'+c}var o=this.end.toHTML(r);return u.end&&(o='<span class="math-parenthesis math-round-parenthesis">(</span>'+o+'<span class="math-parenthesis math-round-parenthesis">)</span>'),l+='<span class="math-operator math-range-operator">:</span>'+o,l},n.prototype._toTex=function(r){var i=r&&r.parenthesis?r.parenthesis:"keep",u=a(this,i),l=this.start.toTex(r);if(u.start&&(l="\\left(".concat(l,"\\right)")),this.step){var f=this.step.toTex(r);u.step&&(f="\\left(".concat(f,"\\right)")),l+=":"+f}var c=this.end.toTex(r);return u.end&&(c="\\left(".concat(c,"\\right)")),l+=":"+c,l},n},{isClass:!0,isNode:!0}),kN="RelationalNode",HN=["Node"],GN=R(kN,HN,e=>{var{Node:t}=e;function n(a,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(a))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(r))throw new TypeError("Parameter params must be an array");if(a.length!==r.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=a,this.params=r}return n.prototype=new t,n.prototype.type="RelationalNode",n.prototype.isRelationalNode=!0,n.prototype._compile=function(a,r){var i=this,u=this.params.map(l=>l._compile(a,r));return function(f,c,o){for(var s,m=u[0](f,c,o),p=0;p<i.conditionals.length;p++){s=m,m=u[p+1](f,c,o);var v=Xr(a,i.conditionals[p]);if(!v(s,m))return!1}return!0}},n.prototype.forEach=function(a){this.params.forEach((r,i)=>a(r,"params["+i+"]",this),this)},n.prototype.map=function(a){return new n(this.conditionals.slice(),this.params.map((r,i)=>this._ifNode(a(r,"params["+i+"]",this)),this))},n.prototype.clone=function(){return new n(this.conditionals,this.params)},n.prototype._toString=function(a){for(var r=a&&a.parenthesis?a.parenthesis:"keep",i=Qe(this,r),u=this.params.map(function(o,s){var m=Qe(o,r);return r==="all"||m!==null&&m<=i?"("+o.toString(a)+")":o.toString(a)}),l={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},f=u[0],c=0;c<this.conditionals.length;c++)f+=" "+l[this.conditionals[c]]+" "+u[c+1];return f},n.prototype.toJSON=function(){return{mathjs:"RelationalNode",conditionals:this.conditionals,params:this.params}},n.fromJSON=function(a){return new n(a.conditionals,a.params)},n.prototype.toHTML=function(a){for(var r=a&&a.parenthesis?a.parenthesis:"keep",i=Qe(this,r),u=this.params.map(function(o,s){var m=Qe(o,r);return r==="all"||m!==null&&m<=i?'<span class="math-parenthesis math-round-parenthesis">(</span>'+o.toHTML(a)+'<span class="math-parenthesis math-round-parenthesis">)</span>':o.toHTML(a)}),l={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},f=u[0],c=0;c<this.conditionals.length;c++)f+='<span class="math-operator math-binary-operator math-explicit-binary-operator">'+Zr(l[this.conditionals[c]])+"</span>"+u[c+1];return f},n.prototype._toTex=function(a){for(var r=a&&a.parenthesis?a.parenthesis:"keep",i=Qe(this,r),u=this.params.map(function(c,o){var s=Qe(c,r);return r==="all"||s!==null&&s<=i?"\\left("+c.toTex(a)+"\right)":c.toTex(a)}),l=u[0],f=0;f<this.conditionals.length;f++)l+=Ge[this.conditionals[f]]+u[f+1];return l},n},{isClass:!0,isNode:!0}),VN="SymbolNode",ZN=["math","?Unit","Node"],XN=R(VN,ZN,e=>{var{math:t,Unit:n,Node:a}=e;function r(u){return n?n.isValuelessUnit(u):!1}function i(u){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(typeof u!="string")throw new TypeError('String expected for parameter "name"');this.name=u}return i.prototype=new a,i.prototype.type="SymbolNode",i.prototype.isSymbolNode=!0,i.prototype._compile=function(u,l){var f=this.name;if(l[f]===!0)return function(o,s,m){return s[f]};if(f in u)return function(o,s,m){return o.has(f)?o.get(f):Xr(u,f)};var c=r(f);return function(o,s,m){return o.has(f)?o.get(f):c?new n(null,f):i.onUndefinedSymbol(f)}},i.prototype.forEach=function(u){},i.prototype.map=function(u){return this.clone()},i.onUndefinedSymbol=function(u){throw new Error("Undefined symbol "+u)},i.prototype.clone=function(){return new i(this.name)},i.prototype._toString=function(u){return this.name},i.prototype.toHTML=function(u){var l=Zr(this.name);return l==="true"||l==="false"?'<span class="math-symbol math-boolean">'+l+"</span>":l==="i"?'<span class="math-symbol math-imaginary-symbol">'+l+"</span>":l==="Infinity"?'<span class="math-symbol math-infinity-symbol">'+l+"</span>":l==="NaN"?'<span class="math-symbol math-nan-symbol">'+l+"</span>":l==="null"?'<span class="math-symbol math-null-symbol">'+l+"</span>":l==="undefined"?'<span class="math-symbol math-undefined-symbol">'+l+"</span>":'<span class="math-symbol">'+l+"</span>"},i.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},i.fromJSON=function(u){return new i(u.name)},i.prototype._toTex=function(u){var l=!1;typeof t[this.name]=="undefined"&&r(this.name)&&(l=!0);var f=sl(this.name,l);return f[0]==="\\"?f:" "+f},i},{isClass:!0,isNode:!0});function kn(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];return typeof e.createSubScope=="function"?Do(e.createSubScope(),...n):Do(xt(),e,...n)}var YN="FunctionNode",WN=["math","Node","SymbolNode"],JN=R(YN,WN,e=>{var{math:t,Node:n,SymbolNode:a}=e;function r(c,o){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(typeof c=="string"&&(c=new a(c)),!Ze(c))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(o)||!o.every(Ze))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=c,this.args=o||[],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")}})}r.prototype=new n,r.prototype.type="FunctionNode",r.prototype.isFunctionNode=!0;var i=c=>Fe(c,{truncate:78});r.prototype._compile=function(c,o){if(!(this instanceof r))throw new TypeError("No valid FunctionNode");var s=this.args.map(S=>S._compile(c,o));if(br(this.fn)){var m=this.fn.name;if(o[m]){var w=this.args;return function(O,M,$){var E=M[m];if(typeof E!="function")throw new TypeError("Argument '".concat(m,"' was not a function; received: ").concat(i(E)));if(E.rawArgs)return E(w,c,kn(O,M),O);var _=s.map(z=>z(O,M,$));return E.apply(E,_)}}else{var p=m in c?Xr(c,m):void 0,v=typeof p=="function"&&p.rawArgs===!0,h=S=>{var O;if(S.has(m))O=S.get(m);else if(m in c)O=Xr(c,m);else return r.onUndefinedFunction(m);if(typeof O=="function")return O;throw new TypeError("'".concat(m,`' is not a function; its value is:
15
+ `).concat(i(O)))};if(v){var b=this.args;return function(O,M,$){var E=h(O);return E(b,c,kn(O,M),O)}}else switch(s.length){case 0:return function(O,M,$){var E=h(O);return E()};case 1:return function(O,M,$){var E=h(O),_=s[0];return E(_(O,M,$))};case 2:return function(O,M,$){var E=h(O),_=s[0],z=s[1];return E(_(O,M,$),z(O,M,$))};default:return function(O,M,$){var E=h(O),_=s.map(z=>z(O,M,$));return E(..._)}}}}else if(Ht(this.fn)&&on(this.fn.index)&&this.fn.index.isObjectProperty()){var N=this.fn.object._compile(c,o),g=this.fn.index.getObjectProperty(),y=this.args;return function(O,M,$){var E=N(O,M,$);xv(E,g);var _=E[g]&&E[g].rawArgs;if(_)return E[g](y,c,kn(O,M),O);var z=s.map(I=>I(O,M,$));return E[g].apply(E,z)}}else{var x=this.fn.toString(),d=this.fn._compile(c,o),A=this.args;return function(O,M,$){var E=d(O,M,$);if(typeof E!="function")throw new TypeError("Expression '".concat(x,"' did not evaluate to a function; value is:")+`
16
+ `.concat(i(E)));if(E.rawArgs)return E(A,c,kn(O,M),O);var _=s.map(z=>z(O,M,$));return E.apply(E,_)}}},r.prototype.forEach=function(c){c(this.fn,"fn",this);for(var o=0;o<this.args.length;o++)c(this.args[o],"args["+o+"]",this)},r.prototype.map=function(c){for(var o=this._ifNode(c(this.fn,"fn",this)),s=[],m=0;m<this.args.length;m++)s[m]=this._ifNode(c(this.args[m],"args["+m+"]",this));return new r(o,s)},r.prototype.clone=function(){return new r(this.fn,this.args.slice(0))},r.onUndefinedFunction=function(c){throw new Error("Undefined function "+c)};var u=r.prototype.toString;r.prototype.toString=function(c){var o,s=this.fn.toString(c);return c&&typeof c.handler=="object"&&Ae(c.handler,s)&&(o=c.handler[s](this,c)),typeof o!="undefined"?o:u.call(this,c)},r.prototype._toString=function(c){var o=this.args.map(function(m){return m.toString(c)}),s=Bn(this.fn)?"("+this.fn.toString(c)+")":this.fn.toString(c);return s+"("+o.join(", ")+")"},r.prototype.toJSON=function(){return{mathjs:"FunctionNode",fn:this.fn,args:this.args}},r.fromJSON=function(c){return new r(c.fn,c.args)},r.prototype.toHTML=function(c){var o=this.args.map(function(s){return s.toHTML(c)});return'<span class="math-function">'+Zr(this.fn)+'</span><span class="math-paranthesis math-round-parenthesis">(</span>'+o.join('<span class="math-separator">,</span>')+'<span class="math-paranthesis math-round-parenthesis">)</span>'};function l(c,o,s){for(var m="",p=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,v=0,h;(h=p.exec(c))!==null;)if(m+=c.substring(v,h.index),v=h.index,h[0]==="$$")m+="$",v++;else{v+=h[0].length;var b=o[h[1]];if(!b)throw new ReferenceError("Template: Property "+h[1]+" does not exist.");if(h[2]===void 0)switch(typeof b){case"string":m+=b;break;case"object":if(Ze(b))m+=b.toTex(s);else if(Array.isArray(b))m+=b.map(function(w,N){if(Ze(w))return w.toTex(s);throw new TypeError("Template: "+h[1]+"["+N+"] is not a Node.")}).join(",");else throw new TypeError("Template: "+h[1]+" has to be a Node, String or array of Nodes");break;default:throw new TypeError("Template: "+h[1]+" has to be a Node, String or array of Nodes")}else if(Ze(b[h[2]]&&b[h[2]]))m+=b[h[2]].toTex(s);else throw new TypeError("Template: "+h[1]+"["+h[2]+"] is not a Node.")}return m+=c.slice(v),m}var f=r.prototype.toTex;return r.prototype.toTex=function(c){var o;return c&&typeof c.handler=="object"&&Ae(c.handler,this.name)&&(o=c.handler[this.name](this,c)),typeof o!="undefined"?o:f.call(this,c)},r.prototype._toTex=function(c){var o=this.args.map(function(p){return p.toTex(c)}),s;il[this.name]&&(s=il[this.name]),t[this.name]&&(typeof t[this.name].toTex=="function"||typeof t[this.name].toTex=="object"||typeof t[this.name].toTex=="string")&&(s=t[this.name].toTex);var m;switch(typeof s){case"function":m=s(this,c);break;case"string":m=l(s,this,c);break;case"object":switch(typeof s[o.length]){case"function":m=s[o.length](this,c);break;case"string":m=l(s[o.length],this,c);break}}return typeof m!="undefined"?m:l(bN,this,c)},r.prototype.getIdentifier=function(){return this.type+":"+this.name},r},{isClass:!0,isNode:!0}),ul="parse",QN=["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],KN=R(ul,QN,e=>{var{typed:t,numeric:n,config:a,AccessorNode:r,ArrayNode:i,AssignmentNode:u,BlockNode:l,ConditionalNode:f,ConstantNode:c,FunctionAssignmentNode:o,FunctionNode:s,IndexNode:m,ObjectNode:p,OperatorNode:v,ParenthesisNode:h,RangeNode:b,RelationalNode:w,SymbolNode:N}=e,g=t(ul,{string:function(X){return H(X,{})},"Array | Matrix":function(X){return y(X,{})},"string, Object":function(X,ie){var de=ie.nodes!==void 0?ie.nodes:{};return H(X,de)},"Array | Matrix, Object":y});function y(C){var X=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ie=X.nodes!==void 0?X.nodes:{};return we(C,function(de){if(typeof de!="string")throw new TypeError("String expected");return H(de,ie)})}var x={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},d={",":!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},A={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},S={true:!0,false:!1,null:null,undefined:void 0},O=["NaN","Infinity"];function M(){return{extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:x.NULL,nestingLevel:0,conditionalLevel:null}}function $(C,X){return C.expression.substr(C.index,X)}function E(C){return $(C,1)}function _(C){C.index++}function z(C){return C.expression.charAt(C.index-1)}function I(C){return C.expression.charAt(C.index+1)}function T(C){for(C.tokenType=x.NULL,C.token="",C.comment="";;){if(E(C)==="#")for(;E(C)!==`
17
+ `&&E(C)!=="";)C.comment+=E(C),_(C);if(g.isWhitespace(E(C),C.nestingLevel))_(C);else break}if(E(C)===""){C.tokenType=x.DELIMITER;return}if(E(C)===`
18
+ `&&!C.nestingLevel){C.tokenType=x.DELIMITER,C.token=E(C),_(C);return}var X=E(C),ie=$(C,2),de=$(C,3);if(de.length===3&&d[de]){C.tokenType=x.DELIMITER,C.token=de,_(C),_(C),_(C);return}if(ie.length===2&&d[ie]){C.tokenType=x.DELIMITER,C.token=ie,_(C),_(C);return}if(d[X]){C.tokenType=x.DELIMITER,C.token=X,_(C);return}if(g.isDigitDot(X)){C.tokenType=x.NUMBER;var Re=$(C,2);if(Re==="0b"||Re==="0o"||Re==="0x"){for(C.token+=E(C),_(C),C.token+=E(C),_(C);g.isHexDigit(E(C));)C.token+=E(C),_(C);if(E(C)===".")for(C.token+=".",_(C);g.isHexDigit(E(C));)C.token+=E(C),_(C);else if(E(C)==="i")for(C.token+="i",_(C);g.isDigit(E(C));)C.token+=E(C),_(C);return}if(E(C)==="."){if(C.token+=E(C),_(C),!g.isDigit(E(C))){C.tokenType=x.DELIMITER;return}}else{for(;g.isDigit(E(C));)C.token+=E(C),_(C);g.isDecimalMark(E(C),I(C))&&(C.token+=E(C),_(C))}for(;g.isDigit(E(C));)C.token+=E(C),_(C);if(E(C)==="E"||E(C)==="e"){if(g.isDigit(I(C))||I(C)==="-"||I(C)==="+"){if(C.token+=E(C),_(C),(E(C)==="+"||E(C)==="-")&&(C.token+=E(C),_(C)),!g.isDigit(E(C)))throw Xe(C,'Digit expected, got "'+E(C)+'"');for(;g.isDigit(E(C));)C.token+=E(C),_(C);if(g.isDecimalMark(E(C),I(C)))throw Xe(C,'Digit expected, got "'+E(C)+'"')}else if(I(C)===".")throw _(C),Xe(C,'Digit expected, got "'+E(C)+'"')}return}if(g.isAlpha(E(C),z(C),I(C))){for(;g.isAlpha(E(C),z(C),I(C))||g.isDigit(E(C));)C.token+=E(C),_(C);Ae(A,C.token)?C.tokenType=x.DELIMITER:C.tokenType=x.SYMBOL;return}for(C.tokenType=x.UNKNOWN;E(C)!=="";)C.token+=E(C),_(C);throw Xe(C,'Syntax error in part "'+C.token+'"')}function B(C){do T(C);while(C.token===`
19
+ `)}function G(C){C.nestingLevel++}function D(C){C.nestingLevel--}g.isAlpha=function(X,ie,de){return g.isValidLatinOrGreek(X)||g.isValidMathSymbol(X,de)||g.isValidMathSymbol(ie,X)},g.isValidLatinOrGreek=function(X){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(X)},g.isValidMathSymbol=function(X,ie){return/^[\uD835]$/.test(X)&&/^[\uDC00-\uDFFF]$/.test(ie)&&/^[^\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDFCC\uDFCD]$/.test(ie)},g.isWhitespace=function(X,ie){return X===" "||X===" "||X===`
20
+ `&&ie>0},g.isDecimalMark=function(X,ie){return X==="."&&ie!=="/"&&ie!=="*"&&ie!=="^"},g.isDigitDot=function(X){return X>="0"&&X<="9"||X==="."},g.isDigit=function(X){return X>="0"&&X<="9"},g.isHexDigit=function(X){return X>="0"&&X<="9"||X>="a"&&X<="f"||X>="A"&&X<="F"};function H(C,X){var ie=M();ir(ie,{expression:C,extraNodes:X}),T(ie);var de=W(ie);if(ie.token!=="")throw ie.tokenType===x.DELIMITER?Lt(ie,"Unexpected operator "+ie.token):Xe(ie,'Unexpected part "'+ie.token+'"');return de}function W(C){var X,ie=[],de;for(C.token!==""&&C.token!==`
21
21
  `&&C.token!==";"&&(X=j(C),X.comment=C.comment);C.token===`
22
- `||C.token===";";)ae.length===0&&X&&(he=C.token!==";",ae.push({node:X,visible:he})),T(C),C.token!==`
23
- `&&C.token!==";"&&C.token!==""&&(X=j(C),X.comment=C.comment,he=C.token!==";",ae.push({node:X,visible:he}));return ae.length>0?new m(ae):(X||(X=new c(void 0),X.comment=C.comment),X)}function j(C){var X,ae,he,qe,Ue=V(C);if(C.token==="="){if(xr(Ue))return X=Ue.name,B(C),he=j(C),new l(new N(X),he);if(Lt(Ue))return B(C),he=j(C),new l(Ue.object,Ue.index,he);if(kt(Ue)&&xr(Ue.fn)&&(qe=!0,ae=[],X=Ue.name,Ue.args.forEach(function(dr,to){xr(dr)?ae[to]=dr.name:qe=!1}),qe))return B(C),he=j(C),new s(X,ae,he);throw Ze(C,"Invalid left hand side of assignment operator =")}return Ue}function V(C){for(var X=K(C);C.token==="?";){var ae=C.conditionalLevel;C.conditionalLevel=C.nestingLevel,B(C);var he=X,qe=j(C);if(C.token!==":")throw Ze(C,"False part of conditional expression expected");C.conditionalLevel=null,B(C);var Ue=j(C);X=new f(he,qe,Ue),C.conditionalLevel=ae}return X}function K(C){for(var X=te(C);C.token==="or";)B(C),X=new v("or","or",[X,te(C)]);return X}function te(C){for(var X=re(C);C.token==="xor";)B(C),X=new v("xor","xor",[X,re(C)]);return X}function re(C){for(var X=ie(C);C.token==="and";)B(C),X=new v("and","and",[X,ie(C)]);return X}function ie(C){for(var X=ne(C);C.token==="|";)B(C),X=new v("|","bitOr",[X,ne(C)]);return X}function ne(C){for(var X=ue(C);C.token==="^|";)B(C),X=new v("^|","bitXor",[X,ue(C)]);return X}function ue(C){for(var X=ee(C);C.token==="&";)B(C),X=new v("&","bitAnd",[X,ee(C)]);return X}function ee(C){for(var X=[ye(C)],ae=[],he={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};Me(he,C.token);){var qe={name:C.token,fn:he[C.token]};ae.push(qe),B(C),X.push(ye(C))}return X.length===1?X[0]:X.length===2?new v(ae[0].name,ae[0].fn,X):new w(ae.map(Ue=>Ue.fn),X)}function ye(C){var X,ae,he,qe;X=we(C);for(var Ue={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Me(Ue,C.token);)ae=C.token,he=Ue[ae],B(C),qe=[X,we(C)],X=new v(ae,he,qe);return X}function we(C){var X,ae,he,qe;X=me(C);for(var Ue={to:"to",in:"to"};Me(Ue,C.token);)ae=C.token,he=Ue[ae],B(C),ae==="in"&&C.token===""?X=new v("*","multiply",[X,new N("in")],!0):(qe=[X,me(C)],X=new v(ae,he,qe));return X}function me(C){var X,ae=[];if(C.token===":"?X=new c(1):X=xe(C),C.token===":"&&C.conditionalLevel!==C.nestingLevel){for(ae.push(X);C.token===":"&&ae.length<3;)B(C),C.token===")"||C.token==="]"||C.token===","||C.token===""?ae.push(new N("end")):ae.push(xe(C));ae.length===3?X=new b(ae[0],ae[2],ae[1]):X=new b(ae[0],ae[1])}return X}function xe(C){var X,ae,he,qe;X=F(C);for(var Ue={"+":"add","-":"subtract"};Me(Ue,C.token);){ae=C.token,he=Ue[ae],B(C);var dr=F(C);dr.isPercentage?qe=[X,new v("*","multiply",[X,dr])]:qe=[X,dr],X=new v(ae,he,qe)}return X}function F(C){var X,ae,he,qe;X=Y(C),ae=X;for(var Ue={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};Me(Ue,C.token);)he=C.token,qe=Ue[he],B(C),ae=Y(C),X=new v(he,qe,[X,ae]);return X}function Y(C){var X,ae;for(X=k(C),ae=X;C.tokenType===x.SYMBOL||C.token==="in"&&Ye(X)||C.tokenType===x.NUMBER&&!Ye(ae)&&(!$r(ae)||ae.op==="!")||C.token==="(";)ae=k(C),X=new v("*","multiply",[X,ae],!0);return X}function k(C){for(var X=U(C),ae=X,he=[];C.token==="/"&&Ye(ae);)if(he.push(ar({},C)),B(C),C.tokenType===x.NUMBER)if(he.push(ar({},C)),B(C),C.tokenType===x.SYMBOL||C.token==="(")ar(C,he.pop()),he.pop(),ae=U(C),X=new v("/","divide",[X,ae]);else{he.pop(),ar(C,he.pop());break}else{ar(C,he.pop());break}return X}function U(C){var X,ae,he,qe;X=J(C);for(var Ue={"%":"mod",mod:"mod"};Me(Ue,C.token);)ae=C.token,he=Ue[ae],B(C),ae==="%"&&C.tokenType===x.DELIMITER&&C.token!=="("?X=new v("/","divide",[X,new c(100)],!1,!0):(qe=[X,J(C)],X=new v(ae,he,qe));return X}function J(C){var X,ae,he,qe={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Me(qe,C.token)?(he=qe[C.token],X=C.token,B(C),ae=[J(C)],new v(X,he,ae)):q(C)}function q(C){var X,ae,he,qe;return X=P(C),(C.token==="^"||C.token===".^")&&(ae=C.token,he=ae==="^"?"pow":"dotPow",B(C),qe=[X,J(C)],X=new v(ae,he,qe)),X}function P(C){var X,ae,he,qe;X=Q(C);for(var Ue={"!":"factorial","'":"ctranspose"};Me(Ue,C.token);)ae=C.token,he=Ue[ae],T(C),qe=[X],X=new v(ae,he,qe),X=se(C,X);return X}function Q(C){var X=[];if(C.tokenType===x.SYMBOL&&Me(C.extraNodes,C.token)){var ae=C.extraNodes[C.token];if(T(C),C.token==="("){if(X=[],G(C),T(C),C.token!==")")for(X.push(j(C));C.token===",";)T(C),X.push(j(C));if(C.token!==")")throw Ze(C,"Parenthesis ) expected");D(C),T(C)}return new ae(X)}return L(C)}function L(C){var X,ae;return C.tokenType===x.SYMBOL||C.tokenType===x.DELIMITER&&C.token in A?(ae=C.token,T(C),Me(S,ae)?X=new c(S[ae]):O.indexOf(ae)!==-1?X=new c(a(ae,"number")):X=new N(ae),X=se(C,X),X):fe(C)}function se(C,X,ae){for(var he;C.token==="("||C.token==="["||C.token===".";)if(he=[],C.token==="(")if(xr(X)||Lt(X)){if(G(C),T(C),C.token!==")")for(he.push(j(C));C.token===",";)T(C),he.push(j(C));if(C.token!==")")throw Ze(C,"Parenthesis ) expected");D(C),T(C),X=new o(X,he)}else return X;else if(C.token==="["){if(G(C),T(C),C.token!=="]")for(he.push(j(C));C.token===",";)T(C),he.push(j(C));if(C.token!=="]")throw Ze(C,"Parenthesis ] expected");D(C),T(C),X=new r(X,new u(he))}else{if(T(C),C.tokenType!==x.SYMBOL)throw Ze(C,"Property name expected after dot");he.push(new c(C.token)),T(C);var qe=!0;X=new r(X,new u(he,qe))}return X}function fe(C){var X,ae;return C.token==='"'?(ae=ge(C),X=new c(ae),X=se(C,X),X):pe(C)}function ge(C){for(var X="";E(C)!==""&&E(C)!=='"';)E(C)==="\\"&&(X+=E(C),$(C)),X+=E(C),$(C);if(T(C),C.token!=='"')throw Ze(C,'End of string " expected');return T(C),JSON.parse('"'+X+'"')}function pe(C){var X,ae;return C.token==="'"?(ae=ve(C),X=new c(ae),X=se(C,X),X):Ne(C)}function ve(C){for(var X="";E(C)!==""&&E(C)!=="'";)E(C)==="\\"&&(X+=E(C),$(C)),X+=E(C),$(C);if(T(C),C.token!=="'")throw Ze(C,"End of string ' expected");return T(C),JSON.parse('"'+X+'"')}function Ne(C){var X,ae,he,qe;if(C.token==="["){if(G(C),T(C),C.token!=="]"){var Ue=Qe(C);if(C.token===";"){for(he=1,ae=[Ue];C.token===";";)T(C),ae[he]=Qe(C),he++;if(C.token!=="]")throw Ze(C,"End of matrix ] expected");D(C),T(C),qe=ae[0].items.length;for(var dr=1;dr<he;dr++)if(ae[dr].items.length!==qe)throw Pt(C,"Column dimensions mismatch ("+ae[dr].items.length+" !== "+qe+")");X=new i(ae)}else{if(C.token!=="]")throw Ze(C,"End of matrix ] expected");D(C),T(C),X=Ue}}else D(C),T(C),X=new i([]);return se(C,X)}return cr(C)}function Qe(C){for(var X=[j(C)],ae=1;C.token===",";)T(C),X[ae]=j(C),ae++;return new i(X)}function cr(C){if(C.token==="{"){G(C);var X,ae={};do if(T(C),C.token!=="}"){if(C.token==='"')X=ge(C);else if(C.token==="'")X=ve(C);else if(C.tokenType===x.SYMBOL||C.tokenType===x.DELIMITER&&C.token in A)X=C.token,T(C);else throw Ze(C,"Symbol or string expected as object key");if(C.token!==":")throw Ze(C,"Colon : expected after object key");T(C),ae[X]=j(C)}while(C.token===",");if(C.token!=="}")throw Ze(C,"Comma , or bracket } expected after object value");D(C),T(C);var he=new p(ae);return he=se(C,he),he}return tr(C)}function tr(C){var X;return C.tokenType===x.NUMBER?(X=C.token,T(C),new c(a(X,t.number))):Jr(C)}function Jr(C){var X;if(C.token==="("){if(G(C),T(C),X=j(C),C.token!==")")throw Ze(C,"Parenthesis ) expected");return D(C),T(C),X=new h(X),X=se(C,X),X}return Lr(C)}function Lr(C){throw C.token===""?Ze(C,"Unexpected end of expression"):Ze(C,"Value expected")}function Ot(C){return C.index-C.token.length+1}function Ze(C,X){var ae=Ot(C),he=new SyntaxError(X+" (char "+ae+")");return he.char=ae,he}function Pt(C,X){var ae=Ot(C),he=new SyntaxError(X+" (char "+ae+")");return he.char=ae,he}return g}),il="compile",WN=["typed","parse"],JN=R(il,WN,e=>{var{typed:n,parse:a}=e;return n(il,{string:function(r){return a(r).compile()},"Array | Matrix":function(r){return be(r,function(i){return a(i).compile()})}})}),ol="evaluate",QN=["typed","parse"],KN=R(ol,QN,e=>{var{typed:n,parse:a}=e;return n(ol,{string:function(r){var i=gt();return a(r).compile().evaluate(i)},"string, Map | Object":function(r,i){return a(r).compile().evaluate(i)},"Array | Matrix":function(r){var i=gt();return be(r,function(l){return a(l).compile().evaluate(i)})},"Array | Matrix, Map | Object":function(r,i){return be(r,function(l){return a(l).compile().evaluate(i)})}})}),jN="Parser",eM=["evaluate"],rM=R(jN,eM,e=>{var{evaluate:n}=e;function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:gt(),writable:!1})}return a.prototype.type="Parser",a.prototype.isParser=!0,a.prototype.evaluate=function(t){return n(t,this.scope)},a.prototype.get=function(t){if(this.scope.has(t))return this.scope.get(t)},a.prototype.getAll=function(){return yv(this.scope)},a.prototype.getAllAsMap=function(){return this.scope},a.prototype.set=function(t,r){return this.scope.set(t,r),r},a.prototype.remove=function(t){this.scope.delete(t)},a.prototype.clear=function(){this.scope.clear()},a},{isClass:!0}),sl="parser",tM=["typed","Parser"],nM=R(sl,tM,e=>{var{typed:n,Parser:a}=e;return n(sl,{"":function(){return new a}})}),ul="lup",aM=["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],iM=R(ul,aM,e=>{var{typed:n,matrix:a,abs:t,addScalar:r,divideScalar:i,multiplyScalar:l,subtract:m,larger:f,equalScalar:c,unaryMinus:s,DenseMatrix:o,SparseMatrix:u,Spa:p}=e;return n(ul,{DenseMatrix:function(w){return v(w)},SparseMatrix:function(w){return h(w)},Array:function(w){var N=a(w),g=v(N);return{L:g.L.valueOf(),U:g.U.valueOf(),p:g.p}}});function v(b){var w=b._size[0],N=b._size[1],g=Math.min(w,N),y=Ce(b._data),x=[],d=[w,g],A=[],S=[g,N],O,M,_,E=[];for(O=0;O<w;O++)E[O]=O;for(M=0;M<N;M++){if(M>0)for(O=0;O<w;O++){var $=Math.min(O,M),z=0;for(_=0;_<$;_++)z=r(z,l(y[O][_],y[_][M]));y[O][M]=m(y[O][M],z)}var I=M,T=0,B=0;for(O=M;O<w;O++){var G=y[O][M],D=t(G);f(D,T)&&(I=O,T=D,B=G)}if(M!==I&&(E[M]=[E[I],E[I]=E[M]][0],o._swapRows(M,I,y)),M<w)for(O=M+1;O<w;O++){var H=y[O][M];c(H,0)||(y[O][M]=i(y[O][M],B))}}for(M=0;M<N;M++)for(O=0;O<w;O++){if(M===0&&(O<N&&(A[O]=[]),x[O]=[]),O<M){O<N&&(A[O][M]=y[O][M]),M<w&&(x[O][M]=0);continue}if(O===M){O<N&&(A[O][M]=y[O][M]),M<w&&(x[O][M]=1);continue}O<N&&(A[O][M]=0),M<w&&(x[O][M]=y[O][M])}var W=new o({data:x,size:d}),j=new o({data:A,size:S}),V=[];for(O=0,g=E.length;O<g;O++)V[E[O]]=O;return{L:W,U:j,p:V,toString:function(){return"L: "+this.L.toString()+`
22
+ `||C.token===";";)ie.length===0&&X&&(de=C.token!==";",ie.push({node:X,visible:de})),T(C),C.token!==`
23
+ `&&C.token!==";"&&C.token!==""&&(X=j(C),X.comment=C.comment,de=C.token!==";",ie.push({node:X,visible:de}));return ie.length>0?new l(ie):(X||(X=new c(void 0),X.comment=C.comment),X)}function j(C){var X,ie,de,Re,Le=V(C);if(C.token==="="){if(br(Le))return X=Le.name,B(C),de=j(C),new u(new N(X),de);if(Ht(Le))return B(C),de=j(C),new u(Le.object,Le.index,de);if(Gt(Le)&&br(Le.fn)&&(Re=!0,ie=[],X=Le.name,Le.args.forEach(function(gr,so){br(gr)?ie[so]=gr.name:Re=!1}),Re))return B(C),de=j(C),new o(X,ie,de);throw Xe(C,"Invalid left hand side of assignment operator =")}return Le}function V(C){for(var X=K(C);C.token==="?";){var ie=C.conditionalLevel;C.conditionalLevel=C.nestingLevel,B(C);var de=X,Re=j(C);if(C.token!==":")throw Xe(C,"False part of conditional expression expected");C.conditionalLevel=null,B(C);var Le=j(C);X=new f(de,Re,Le),C.conditionalLevel=ie}return X}function K(C){for(var X=te(C);C.token==="or";)B(C),X=new v("or","or",[X,te(C)]);return X}function te(C){for(var X=re(C);C.token==="xor";)B(C),X=new v("xor","xor",[X,re(C)]);return X}function re(C){for(var X=oe(C);C.token==="and";)B(C),X=new v("and","and",[X,oe(C)]);return X}function oe(C){for(var X=ae(C);C.token==="|";)B(C),X=new v("|","bitOr",[X,ae(C)]);return X}function ae(C){for(var X=ce(C);C.token==="^|";)B(C),X=new v("^|","bitXor",[X,ce(C)]);return X}function ce(C){for(var X=ee(C);C.token==="&";)B(C),X=new v("&","bitAnd",[X,ee(C)]);return X}function ee(C){for(var X=[xe(C)],ie=[],de={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};Ae(de,C.token);){var Re={name:C.token,fn:de[C.token]};ie.push(Re),B(C),X.push(xe(C))}return X.length===1?X[0]:X.length===2?new v(ie[0].name,ie[0].fn,X):new w(ie.map(Le=>Le.fn),X)}function xe(C){var X,ie,de,Re;X=Ne(C);for(var Le={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Ae(Le,C.token);)ie=C.token,de=Le[ie],B(C),Re=[X,Ne(C)],X=new v(ie,de,Re);return X}function Ne(C){var X,ie,de,Re;X=pe(C);for(var Le={to:"to",in:"to"};Ae(Le,C.token);)ie=C.token,de=Le[ie],B(C),ie==="in"&&C.token===""?X=new v("*","multiply",[X,new N("in")],!0):(Re=[X,pe(C)],X=new v(ie,de,Re));return X}function pe(C){var X,ie=[];if(C.token===":"?X=new c(1):X=be(C),C.token===":"&&C.conditionalLevel!==C.nestingLevel){for(ie.push(X);C.token===":"&&ie.length<3;)B(C),C.token===")"||C.token==="]"||C.token===","||C.token===""?ie.push(new N("end")):ie.push(be(C));ie.length===3?X=new b(ie[0],ie[2],ie[1]):X=new b(ie[0],ie[1])}return X}function be(C){var X,ie,de,Re;X=F(C);for(var Le={"+":"add","-":"subtract"};Ae(Le,C.token);){ie=C.token,de=Le[ie],B(C);var gr=F(C);gr.isPercentage?Re=[X,new v("*","multiply",[X,gr])]:Re=[X,gr],X=new v(ie,de,Re)}return X}function F(C){var X,ie,de,Re;X=Y(C),ie=X;for(var Le={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};Ae(Le,C.token);)de=C.token,Re=Le[de],B(C),ie=Y(C),X=new v(de,Re,[X,ie]);return X}function Y(C){var X,ie;for(X=k(C),ie=X;C.tokenType===x.SYMBOL||C.token==="in"&&We(X)||C.tokenType===x.NUMBER&&!We(ie)&&(!qr(ie)||ie.op==="!")||C.token==="(";)ie=k(C),X=new v("*","multiply",[X,ie],!0);return X}function k(C){for(var X=U(C),ie=X,de=[];C.token==="/"&&We(ie);)if(de.push(ir({},C)),B(C),C.tokenType===x.NUMBER)if(de.push(ir({},C)),B(C),C.tokenType===x.SYMBOL||C.token==="(")ir(C,de.pop()),de.pop(),ie=U(C),X=new v("/","divide",[X,ie]);else{de.pop(),ir(C,de.pop());break}else{ir(C,de.pop());break}return X}function U(C){var X,ie,de,Re;X=J(C);for(var Le={"%":"mod",mod:"mod"};Ae(Le,C.token);)ie=C.token,de=Le[ie],B(C),ie==="%"&&C.tokenType===x.DELIMITER&&C.token!=="("?X=new v("/","divide",[X,new c(100)],!1,!0):(Re=[X,J(C)],X=new v(ie,de,Re));return X}function J(C){var X,ie,de,Re={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Ae(Re,C.token)?(de=Re[C.token],X=C.token,B(C),ie=[J(C)],new v(X,de,ie)):q(C)}function q(C){var X,ie,de,Re;return X=P(C),(C.token==="^"||C.token===".^")&&(ie=C.token,de=ie==="^"?"pow":"dotPow",B(C),Re=[X,J(C)],X=new v(ie,de,Re)),X}function P(C){var X,ie,de,Re;X=Q(C);for(var Le={"!":"factorial","'":"ctranspose"};Ae(Le,C.token);)ie=C.token,de=Le[ie],T(C),Re=[X],X=new v(ie,de,Re),X=ue(C,X);return X}function Q(C){var X=[];if(C.tokenType===x.SYMBOL&&Ae(C.extraNodes,C.token)){var ie=C.extraNodes[C.token];if(T(C),C.token==="("){if(X=[],G(C),T(C),C.token!==")")for(X.push(j(C));C.token===",";)T(C),X.push(j(C));if(C.token!==")")throw Xe(C,"Parenthesis ) expected");D(C),T(C)}return new ie(X)}return L(C)}function L(C){var X,ie;return C.tokenType===x.SYMBOL||C.tokenType===x.DELIMITER&&C.token in A?(ie=C.token,T(C),Ae(S,ie)?X=new c(S[ie]):O.indexOf(ie)!==-1?X=new c(n(ie,"number")):X=new N(ie),X=ue(C,X),X):le(C)}function ue(C,X,ie){for(var de;C.token==="("||C.token==="["||C.token===".";)if(de=[],C.token==="(")if(br(X)||Ht(X)){if(G(C),T(C),C.token!==")")for(de.push(j(C));C.token===",";)T(C),de.push(j(C));if(C.token!==")")throw Xe(C,"Parenthesis ) expected");D(C),T(C),X=new s(X,de)}else return X;else if(C.token==="["){if(G(C),T(C),C.token!=="]")for(de.push(j(C));C.token===",";)T(C),de.push(j(C));if(C.token!=="]")throw Xe(C,"Parenthesis ] expected");D(C),T(C),X=new r(X,new m(de))}else{if(T(C),C.tokenType!==x.SYMBOL)throw Xe(C,"Property name expected after dot");de.push(new c(C.token)),T(C);var Re=!0;X=new r(X,new m(de,Re))}return X}function le(C){var X,ie;return C.token==='"'?(ie=ye(C),X=new c(ie),X=ue(C,X),X):ve(C)}function ye(C){for(var X="";E(C)!==""&&E(C)!=='"';)E(C)==="\\"&&(X+=E(C),_(C)),X+=E(C),_(C);if(T(C),C.token!=='"')throw Xe(C,'End of string " expected');return T(C),JSON.parse('"'+X+'"')}function ve(C){var X,ie;return C.token==="'"?(ie=he(C),X=new c(ie),X=ue(C,X),X):Me(C)}function he(C){for(var X="";E(C)!==""&&E(C)!=="'";)E(C)==="\\"&&(X+=E(C),_(C)),X+=E(C),_(C);if(T(C),C.token!=="'")throw Xe(C,"End of string ' expected");return T(C),JSON.parse('"'+X+'"')}function Me(C){var X,ie,de,Re;if(C.token==="["){if(G(C),T(C),C.token!=="]"){var Le=Ke(C);if(C.token===";"){for(de=1,ie=[Le];C.token===";";)T(C),ie[de]=Ke(C),de++;if(C.token!=="]")throw Xe(C,"End of matrix ] expected");D(C),T(C),Re=ie[0].items.length;for(var gr=1;gr<de;gr++)if(ie[gr].items.length!==Re)throw Lt(C,"Column dimensions mismatch ("+ie[gr].items.length+" !== "+Re+")");X=new i(ie)}else{if(C.token!=="]")throw Xe(C,"End of matrix ] expected");D(C),T(C),X=Le}}else D(C),T(C),X=new i([]);return ue(C,X)}return fr(C)}function Ke(C){for(var X=[j(C)],ie=1;C.token===",";)T(C),X[ie]=j(C),ie++;return new i(X)}function fr(C){if(C.token==="{"){G(C);var X,ie={};do if(T(C),C.token!=="}"){if(C.token==='"')X=ye(C);else if(C.token==="'")X=he(C);else if(C.tokenType===x.SYMBOL||C.tokenType===x.DELIMITER&&C.token in A)X=C.token,T(C);else throw Xe(C,"Symbol or string expected as object key");if(C.token!==":")throw Xe(C,"Colon : expected after object key");T(C),ie[X]=j(C)}while(C.token===",");if(C.token!=="}")throw Xe(C,"Comma , or bracket } expected after object value");D(C),T(C);var de=new p(ie);return de=ue(C,de),de}return nr(C)}function nr(C){var X;return C.tokenType===x.NUMBER?(X=C.token,T(C),new c(n(X,a.number))):jr(C)}function jr(C){var X;if(C.token==="("){if(G(C),T(C),X=j(C),C.token!==")")throw Xe(C,"Parenthesis ) expected");return D(C),T(C),X=new h(X),X=ue(C,X),X}return kr(C)}function kr(C){throw C.token===""?Xe(C,"Unexpected end of expression"):Xe(C,"Value expected")}function Tt(C){return C.index-C.token.length+1}function Xe(C,X){var ie=Tt(C),de=new SyntaxError(X+" (char "+ie+")");return de.char=ie,de}function Lt(C,X){var ie=Tt(C),de=new SyntaxError(X+" (char "+ie+")");return de.char=ie,de}return g}),cl="compile",jN=["typed","parse"],eM=R(cl,jN,e=>{var{typed:t,parse:n}=e;return t(cl,{string:function(r){return n(r).compile()},"Array | Matrix":function(r){return we(r,function(i){return n(i).compile()})}})}),fl="evaluate",rM=["typed","parse"],tM=R(fl,rM,e=>{var{typed:t,parse:n}=e;return t(fl,{string:function(r){var i=xt();return n(r).compile().evaluate(i)},"string, Map | Object":function(r,i){return n(r).compile().evaluate(i)},"Array | Matrix":function(r){var i=xt();return we(r,function(u){return n(u).compile().evaluate(i)})},"Array | Matrix, Map | Object":function(r,i){return we(r,function(u){return n(u).compile().evaluate(i)})}})}),nM="Parser",aM=["evaluate"],iM=R(nM,aM,e=>{var{evaluate:t}=e;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:xt(),writable:!1})}return n.prototype.type="Parser",n.prototype.isParser=!0,n.prototype.evaluate=function(a){return t(a,this.scope)},n.prototype.get=function(a){if(this.scope.has(a))return this.scope.get(a)},n.prototype.getAll=function(){return Nv(this.scope)},n.prototype.getAllAsMap=function(){return this.scope},n.prototype.set=function(a,r){return this.scope.set(a,r),r},n.prototype.remove=function(a){this.scope.delete(a)},n.prototype.clear=function(){this.scope.clear()},n},{isClass:!0}),ll="parser",oM=["typed","Parser"],sM=R(ll,oM,e=>{var{typed:t,Parser:n}=e;return t(ll,{"":function(){return new n}})}),ml="lup",uM=["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],cM=R(ml,uM,e=>{var{typed:t,matrix:n,abs:a,addScalar:r,divideScalar:i,multiplyScalar:u,subtract:l,larger:f,equalScalar:c,unaryMinus:o,DenseMatrix:s,SparseMatrix:m,Spa:p}=e;return t(ml,{DenseMatrix:function(w){return v(w)},SparseMatrix:function(w){return h(w)},Array:function(w){var N=n(w),g=v(N);return{L:g.L.valueOf(),U:g.U.valueOf(),p:g.p}}});function v(b){var w=b._size[0],N=b._size[1],g=Math.min(w,N),y=Oe(b._data),x=[],d=[w,g],A=[],S=[g,N],O,M,$,E=[];for(O=0;O<w;O++)E[O]=O;for(M=0;M<N;M++){if(M>0)for(O=0;O<w;O++){var _=Math.min(O,M),z=0;for($=0;$<_;$++)z=r(z,u(y[O][$],y[$][M]));y[O][M]=l(y[O][M],z)}var I=M,T=0,B=0;for(O=M;O<w;O++){var G=y[O][M],D=a(G);f(D,T)&&(I=O,T=D,B=G)}if(M!==I&&(E[M]=[E[I],E[I]=E[M]][0],s._swapRows(M,I,y)),M<w)for(O=M+1;O<w;O++){var H=y[O][M];c(H,0)||(y[O][M]=i(y[O][M],B))}}for(M=0;M<N;M++)for(O=0;O<w;O++){if(M===0&&(O<N&&(A[O]=[]),x[O]=[]),O<M){O<N&&(A[O][M]=y[O][M]),M<w&&(x[O][M]=0);continue}if(O===M){O<N&&(A[O][M]=y[O][M]),M<w&&(x[O][M]=1);continue}O<N&&(A[O][M]=0),M<w&&(x[O][M]=y[O][M])}var W=new s({data:x,size:d}),j=new s({data:A,size:S}),V=[];for(O=0,g=E.length;O<g;O++)V[E[O]]=O;return{L:W,U:j,p:V,toString:function(){return"L: "+this.L.toString()+`
24
24
  U: `+this.U.toString()+`
25
- P: `+this.p}}}function h(b){var w=b._size[0],N=b._size[1],g=Math.min(w,N),y=b._values,x=b._index,d=b._ptr,A=[],S=[],O=[],M=[w,g],_=[],E=[],$=[],z=[g,N],I,T,B,G=[],D=[];for(I=0;I<w;I++)G[I]=I,D[I]=I;var H=function(V,K){var te=D[V],re=D[K];G[te]=K,G[re]=V,D[V]=re,D[K]=te},W=function(){var V=new p;T<w&&(O.push(A.length),A.push(1),S.push(T)),$.push(_.length);var K=d[T],te=d[T+1];for(B=K;B<te;B++)I=x[B],V.set(G[I],y[B]);T>0&&V.forEach(0,T-1,function(ue,ee){u._forEachRow(ue,A,S,O,function(ye,we){ye>ue&&V.accumulate(ye,s(l(we,ee)))})});var re=T,ie=V.get(T),ne=t(ie);V.forEach(T+1,w-1,function(ue,ee){var ye=t(ee);f(ye,ne)&&(re=ue,ne=ye,ie=ee)}),T!==re&&(u._swapRows(T,re,M[1],A,S,O),u._swapRows(T,re,z[1],_,E,$),V.swap(T,re),H(T,re)),V.forEach(0,w-1,function(ue,ee){ue<=T?(_.push(ee),E.push(ue)):(ee=i(ee,ie),c(ee,0)||(A.push(ee),S.push(ue)))})};for(T=0;T<N;T++)W();return $.push(_.length),O.push(A.length),{L:new u({values:A,index:S,ptr:O,size:M}),U:new u({values:_,index:E,ptr:$,size:z}),p:G,toString:function(){return"L: "+this.L.toString()+`
25
+ P: `+this.p}}}function h(b){var w=b._size[0],N=b._size[1],g=Math.min(w,N),y=b._values,x=b._index,d=b._ptr,A=[],S=[],O=[],M=[w,g],$=[],E=[],_=[],z=[g,N],I,T,B,G=[],D=[];for(I=0;I<w;I++)G[I]=I,D[I]=I;var H=function(V,K){var te=D[V],re=D[K];G[te]=K,G[re]=V,D[V]=re,D[K]=te},W=function(){var V=new p;T<w&&(O.push(A.length),A.push(1),S.push(T)),_.push($.length);var K=d[T],te=d[T+1];for(B=K;B<te;B++)I=x[B],V.set(G[I],y[B]);T>0&&V.forEach(0,T-1,function(ce,ee){m._forEachRow(ce,A,S,O,function(xe,Ne){xe>ce&&V.accumulate(xe,o(u(Ne,ee)))})});var re=T,oe=V.get(T),ae=a(oe);V.forEach(T+1,w-1,function(ce,ee){var xe=a(ee);f(xe,ae)&&(re=ce,ae=xe,oe=ee)}),T!==re&&(m._swapRows(T,re,M[1],A,S,O),m._swapRows(T,re,z[1],$,E,_),V.swap(T,re),H(T,re)),V.forEach(0,w-1,function(ce,ee){ce<=T?($.push(ee),E.push(ce)):(ee=i(ee,oe),c(ee,0)||(A.push(ee),S.push(ce)))})};for(T=0;T<N;T++)W();return _.push($.length),O.push(A.length),{L:new m({values:A,index:S,ptr:O,size:M}),U:new m({values:$,index:E,ptr:_,size:z}),p:G,toString:function(){return"L: "+this.L.toString()+`
26
26
  U: `+this.U.toString()+`
27
- P: `+this.p}}}}),cl="qr",oM=["typed","matrix","zeros","identity","isZero","equal","sign","sqrt","conj","unaryMinus","addScalar","divideScalar","multiplyScalar","subtract","complex"],sM=R(cl,oM,e=>{var{typed:n,matrix:a,zeros:t,identity:r,isZero:i,equal:l,sign:m,sqrt:f,conj:c,unaryMinus:s,addScalar:o,divideScalar:u,multiplyScalar:p,subtract:v,complex:h}=e;return ar(n(cl,{DenseMatrix:function(y){return w(y)},SparseMatrix:function(y){return N()},Array:function(y){var x=a(y),d=w(x);return{Q:d.Q.valueOf(),R:d.R.valueOf()}}}),{_denseQRimpl:b});function b(g){var y=g._size[0],x=g._size[1],d=r([y],"dense"),A=d._data,S=g.clone(),O=S._data,M,_,E,$=t([y],"");for(E=0;E<Math.min(x,y);++E){var z=O[E][E],I=s(l(z,0)?1:m(z)),T=c(I),B=0;for(M=E;M<y;M++)B=o(B,p(O[M][E],c(O[M][E])));var G=p(I,f(B));if(!i(G)){var D=v(z,G);for($[E]=1,M=E+1;M<y;M++)$[M]=u(O[M][E],D);var H=s(c(u(D,G))),W=void 0;for(_=E;_<x;_++){for(W=0,M=E;M<y;M++)W=o(W,p(c($[M]),O[M][_]));for(W=p(W,H),M=E;M<y;M++)O[M][_]=p(v(O[M][_],p($[M],W)),T)}for(M=0;M<y;M++){for(W=0,_=E;_<y;_++)W=o(W,p(A[M][_],$[_]));for(W=p(W,H),_=E;_<y;++_)A[M][_]=u(v(A[M][_],p(W,c($[_]))),T)}}}return{Q:d,R:S,toString:function(){return"Q: "+this.Q.toString()+`
28
- R: `+this.R.toString()}}}function w(g){var y=b(g),x=y.R._data;if(g._data.length>0)for(var d=x[0][0].type==="Complex"?h(0):0,A=0;A<x.length;++A)for(var S=0;S<A&&S<(x[0]||[]).length;++S)x[A][S]=d;return y}function N(g){throw new Error("qr not implemented for sparse matrices yet")}});function uM(e,n,a,t){e._values;for(var r=e._index,i=e._ptr,l=e._size,m=e._datatype,f=l[0],c=l[1],s=null,o=[],u=[],p=0,v=0;v<c;v++){u[v]=p;for(var h=a?a[v]:v,b=i[h],w=i[h+1],N=b;N<w;N++){var g=r[N];o[p]=g,p++}}return u[c]=p,e.createSparseMatrix({values:s,index:o,ptr:u,size:[f,c],datatype:m})}function fl(e,n,a,t,r,i,l){var m=0;for(a[l]=e;m>=0;){var f=a[l+m],c=a[t+f];c===-1?(m--,i[n++]=f):(a[t+f]=a[r+c],++m,a[l+m]=c)}return n}function cM(e,n){if(!e)return null;var a=0,t,r=[],i=[],l=0,m=n,f=2*n;for(t=0;t<n;t++)i[l+t]=-1;for(t=n-1;t>=0;t--)e[t]!==-1&&(i[m+t]=i[l+e[t]],i[l+e[t]]=t);for(t=0;t<n;t++)e[t]===-1&&(a=fl(t,a,i,l,m,r,f));return r}function fM(e,n){if(!e)return null;var a=e._index,t=e._ptr,r=e._size,i=r[0],l=r[1],m=[],f=[],c=0,s=l,o,u;for(o=0;o<i;o++)f[s+o]=-1;for(var p=0;p<l;p++){m[p]=-1,f[c+p]=-1;for(var v=t[p],h=t[p+1],b=v;b<h;b++){var w=a[b];for(o=f[s+w];o!==-1&&o<p;o=u)u=f[c+o],f[c+o]=p,u===-1&&(m[o]=p);f[s+w]=p}}return m}function lM(e,n,a){for(var t=e._values,r=e._index,i=e._ptr,l=e._size,m=l[1],f=0,c=0;c<m;c++){var s=i[c];for(i[c]=f;s<i[c+1];s++)n(r[s],c,t?t[s]:1,a)&&(r[f]=r[s],t&&(t[f]=t[s]),f++)}return i[m]=f,r.splice(f,r.length-f),t&&t.splice(f,t.length-f),f}function Rt(e){return-e-2}var mM="csAmd",pM=["add","multiply","transpose"],vM=R(mM,pM,e=>{var{add:n,multiply:a,transpose:t}=e;return function(s,o){if(!o||s<=0||s>3)return null;var u=o._size,p=u[0],v=u[1],h=0,b=Math.max(16,10*Math.sqrt(v));b=Math.min(v-2,b);var w=r(s,o,p,v,b);lM(w,f,null);for(var N=w._index,g=w._ptr,y=g[v],x=[],d=[],A=0,S=v+1,O=2*(v+1),M=3*(v+1),_=4*(v+1),E=5*(v+1),$=6*(v+1),z=7*(v+1),I=x,T=i(v,g,d,A,M,I,O,z,S,$,_,E),B=l(v,g,d,E,_,$,b,S,M,I,O),G=0,D,H,W,j,V,K,te,re,ie,ne,ue,ee,ye,we,me,xe;B<v;){for(W=-1;G<v&&(W=d[M+G])===-1;G++);d[O+W]!==-1&&(I[d[O+W]]=-1),d[M+G]=d[O+W];var F=d[_+W],Y=d[S+W];B+=Y;var k=0;d[S+W]=-Y;var U=g[W],J=F===0?U:y,q=J;for(j=1;j<=F+1;j++){for(j>F?(K=W,te=U,re=d[A+W]-F):(K=N[U++],te=g[K],re=d[A+K]),V=1;V<=re;V++)D=N[te++],!((ie=d[S+D])<=0)&&(k+=ie,d[S+D]=-ie,N[q++]=D,d[O+D]!==-1&&(I[d[O+D]]=I[D]),I[D]!==-1?d[O+I[D]]=d[O+D]:d[M+d[E+D]]=d[O+D]);K!==W&&(g[K]=Rt(W),d[$+K]=0)}for(F!==0&&(y=q),d[E+W]=k,g[W]=J,d[A+W]=q-J,d[_+W]=-2,T=m(T,h,d,$,v),ne=J;ne<q;ne++)if(D=N[ne],!((ue=d[_+D])<=0)){ie=-d[S+D];var P=T-ie;for(U=g[D],ee=g[D]+ue-1;U<=ee;U++)K=N[U],d[$+K]>=T?d[$+K]-=ie:d[$+K]!==0&&(d[$+K]=d[E+K]+P)}for(ne=J;ne<q;ne++){for(D=N[ne],ee=g[D],ye=ee+d[_+D]-1,we=ee,me=0,xe=0,U=ee;U<=ye;U++)if(K=N[U],d[$+K]!==0){var Q=d[$+K]-T;Q>0?(xe+=Q,N[we++]=K,me+=K):(g[K]=Rt(W),d[$+K]=0)}d[_+D]=we-ee+1;var L=we,se=ee+d[A+D];for(U=ye+1;U<se;U++){H=N[U];var fe=d[S+H];fe<=0||(xe+=fe,N[we++]=H,me+=H)}xe===0?(g[D]=Rt(W),ie=-d[S+D],k-=ie,Y+=ie,B+=ie,d[S+D]=0,d[_+D]=-1):(d[E+D]=Math.min(d[E+D],xe),N[we]=N[L],N[L]=N[ee],N[ee]=W,d[A+D]=we-ee+1,me=(me<0?-me:me)%v,d[O+D]=d[z+me],d[z+me]=D,I[D]=me)}for(d[E+W]=k,h=Math.max(h,k),T=m(T+h,h,d,$,v),ne=J;ne<q;ne++)if(D=N[ne],!(d[S+D]>=0))for(me=I[D],D=d[z+me],d[z+me]=-1;D!==-1&&d[O+D]!==-1;D=d[O+D],T++){for(re=d[A+D],ue=d[_+D],U=g[D]+1;U<=g[D]+re-1;U++)d[$+N[U]]=T;var ge=D;for(H=d[O+D];H!==-1;){var pe=d[A+H]===re&&d[_+H]===ue;for(U=g[H]+1;pe&&U<=g[H]+re-1;U++)d[$+N[U]]!==T&&(pe=0);pe?(g[H]=Rt(D),d[S+D]+=d[S+H],d[S+H]=0,d[_+H]=-1,H=d[O+H],d[O+ge]=H):(ge=H,H=d[O+H])}}for(U=J,ne=J;ne<q;ne++)D=N[ne],!((ie=-d[S+D])<=0)&&(d[S+D]=ie,xe=d[E+D]+k-ie,xe=Math.min(xe,v-B-ie),d[M+xe]!==-1&&(I[d[M+xe]]=D),d[O+D]=d[M+xe],I[D]=-1,d[M+xe]=D,G=Math.min(G,xe),d[E+D]=xe,N[U++]=D);d[S+W]=Y,(d[A+W]=U-J)===0&&(g[W]=-1,d[$+W]=0),F!==0&&(y=U)}for(D=0;D<v;D++)g[D]=Rt(g[D]);for(H=0;H<=v;H++)d[M+H]=-1;for(H=v;H>=0;H--)d[S+H]>0||(d[O+H]=d[M+g[H]],d[M+g[H]]=H);for(K=v;K>=0;K--)d[S+K]<=0||g[K]!==-1&&(d[O+K]=d[M+g[K]],d[M+g[K]]=K);for(W=0,D=0;D<=v;D++)g[D]===-1&&(W=fl(D,W,d,M,O,x,$));return x.splice(x.length-1,1),x};function r(c,s,o,u,p){var v=t(s);if(c===1&&u===o)return n(s,v);if(c===2){for(var h=v._index,b=v._ptr,w=0,N=0;N<o;N++){var g=b[N];if(b[N]=w,!(b[N+1]-g>p))for(var y=b[N+1];g<y;g++)h[w++]=h[g]}return b[o]=w,s=t(v),a(v,s)}return a(v,s)}function i(c,s,o,u,p,v,h,b,w,N,g,y){for(var x=0;x<c;x++)o[u+x]=s[x+1]-s[x];o[u+c]=0;for(var d=0;d<=c;d++)o[p+d]=-1,v[d]=-1,o[h+d]=-1,o[b+d]=-1,o[w+d]=1,o[N+d]=1,o[g+d]=0,o[y+d]=o[u+d];var A=m(0,0,o,N,c);return o[g+c]=-2,s[c]=-1,o[N+c]=0,A}function l(c,s,o,u,p,v,h,b,w,N,g){for(var y=0,x=0;x<c;x++){var d=o[u+x];if(d===0)o[p+x]=-2,y++,s[x]=-1,o[v+x]=0;else if(d>h)o[b+x]=0,o[p+x]=-1,y++,s[x]=Rt(c),o[b+c]++;else{var A=o[w+d];A!==-1&&(N[A]=x),o[g+x]=o[w+d],o[w+d]=x}}return y}function m(c,s,o,u,p){if(c<2||c+s<0){for(var v=0;v<p;v++)o[u+v]!==0&&(o[u+v]=1);c=2}return c}function f(c,s){return c!==s}});function hM(e,n,a,t,r,i,l){var m,f,c=0,s;if(e<=n||a[t+n]<=a[r+e])return-1;a[r+e]=a[t+n];var o=a[i+e];if(a[i+e]=n,o===-1)c=1,s=e;else{for(c=2,s=o;s!==a[l+s];s=a[l+s]);for(m=o;m!==s;m=f)f=a[l+m],a[l+m]=s}return{jleaf:c,q:s}}var dM="csCounts",gM=["transpose"],yM=R(dM,gM,e=>{var{transpose:n}=e;return function(a,t,r,i){if(!a||!t||!r)return null;var l=a._size,m=l[0],f=l[1],c,s,o,u,p,v,h,b=4*f+(i?f+m+1:0),w=[],N=0,g=f,y=2*f,x=3*f,d=4*f,A=5*f+1;for(o=0;o<b;o++)w[o]=-1;var S=[],O=n(a),M=O._index,_=O._ptr;for(o=0;o<f;o++)for(s=r[o],S[s]=w[x+s]===-1?1:0;s!==-1&&w[x+s]===-1;s=t[s])w[x+s]=o;if(i){for(o=0;o<f;o++)w[r[o]]=o;for(c=0;c<m;c++){for(o=f,v=_[c],h=_[c+1],p=v;p<h;p++)o=Math.min(o,w[M[p]]);w[A+c]=w[d+o],w[d+o]=c}}for(c=0;c<f;c++)w[N+c]=c;for(o=0;o<f;o++){for(s=r[o],t[s]!==-1&&S[t[s]]--,u=i?w[d+o]:s;u!==-1;u=i?w[A+u]:-1)for(p=_[u];p<_[u+1];p++){c=M[p];var E=hM(c,s,w,x,g,y,N);E.jleaf>=1&&S[s]++,E.jleaf===2&&S[E.q]--}t[s]!==-1&&(w[N+s]=t[s])}for(s=0;s<f;s++)t[s]!==-1&&(S[t[s]]+=S[s]);return S}}),xM="csSqr",bM=["add","multiply","transpose"],wM=R(xM,bM,e=>{var{add:n,multiply:a,transpose:t}=e,r=vM({add:n,multiply:a,transpose:t}),i=yM({transpose:t});return function(f,c,s){var o=c._ptr,u=c._size,p=u[1],v,h={};if(h.q=r(f,c),f&&!h.q)return null;if(s){var b=f?uM(c,null,h.q):c;h.parent=fM(b);var w=cM(h.parent,p);if(h.cp=i(b,h.parent,w,1),b&&h.parent&&h.cp&&l(b,h))for(h.unz=0,v=0;v<p;v++)h.unz+=h.cp[v]}else h.unz=4*o[p]+p,h.lnz=h.unz;return h};function l(m,f){var c=m._ptr,s=m._index,o=m._size,u=o[0],p=o[1];f.pinv=[],f.leftmost=[];var v=f.parent,h=f.pinv,b=f.leftmost,w=[],N=0,g=u,y=u+p,x=u+2*p,d,A,S,O,M;for(A=0;A<p;A++)w[g+A]=-1,w[y+A]=-1,w[x+A]=0;for(d=0;d<u;d++)b[d]=-1;for(A=p-1;A>=0;A--)for(O=c[A],M=c[A+1],S=O;S<M;S++)b[s[S]]=A;for(d=u-1;d>=0;d--)h[d]=-1,A=b[d],A!==-1&&(w[x+A]++===0&&(w[y+A]=d),w[N+d]=w[g+A],w[g+A]=d);for(f.lnz=0,f.m2=u,A=0;A<p;A++)if(d=w[g+A],f.lnz++,d<0&&(d=f.m2++),h[d]=A,!(--x[A]<=0)){f.lnz+=w[x+A];var _=v[A];_!==-1&&(w[x+_]===0&&(w[y+_]=w[y+A]),w[N+w[y+A]]=w[g+_],w[g+_]=w[N+d],w[x+_]+=w[x+A])}for(d=0;d<u;d++)h[d]<0&&(h[d]=A++);return!0}});function Ii(e,n){return e[n]<0}function ll(e,n){e[n]=Rt(e[n])}function ml(e){return e<0?Rt(e):e}function NM(e,n,a,t,r){var i=n._index,l=n._ptr,m=n._size,f=m[1],c,s,o,u=0;for(t[0]=e;u>=0;){e=t[u];var p=r?r[e]:e;Ii(l,e)||(ll(l,e),t[f+u]=p<0?0:ml(l[p]));var v=1;for(s=t[f+u],o=p<0?0:ml(l[p+1]);s<o;s++)if(c=i[s],!Ii(l,c)){t[f+u]=s,t[++u]=c,v=0;break}v&&(u--,t[--a]=e)}return a}function MM(e,n,a,t,r){var i=e._ptr,l=e._size,m=n._index,f=n._ptr,c=l[1],s,o,u,p=c;for(o=f[a],u=f[a+1],s=o;s<u;s++){var v=m[s];Ii(i,v)||(p=NM(v,e,p,t,r))}for(s=p;s<c;s++)ll(i,t[s]);return p}var AM="csSpsolve",SM=["divideScalar","multiply","subtract"],EM=R(AM,SM,e=>{var{divideScalar:n,multiply:a,subtract:t}=e;return function(i,l,m,f,c,s,o){var u=i._values,p=i._index,v=i._ptr,h=i._size,b=h[1],w=l._values,N=l._index,g=l._ptr,y,x,d,A,S=MM(i,l,m,f,s);for(y=S;y<b;y++)c[f[y]]=0;for(x=g[m],d=g[m+1],y=x;y<d;y++)c[N[y]]=w[y];for(var O=S;O<b;O++){var M=f[O],_=s?s[M]:M;if(!(_<0))for(x=v[_],d=v[_+1],c[M]=n(c[M],u[o?x:d-1]),y=o?x+1:x,A=o?d:d-1;y<A;y++){var E=p[y];c[E]=t(c[E],a(u[y],c[M]))}}return S}}),CM="csLu",OM=["abs","divideScalar","multiply","subtract","larger","largerEq","SparseMatrix"],DM=R(CM,OM,e=>{var{abs:n,divideScalar:a,multiply:t,subtract:r,larger:i,largerEq:l,SparseMatrix:m}=e,f=EM({divideScalar:a,multiply:t,subtract:r});return function(s,o,u){if(!s)return null;var p=s._size,v=p[1],h,b=100,w=100;o&&(h=o.q,b=o.lnz||b,w=o.unz||w);var N=[],g=[],y=[],x=new m({values:N,index:g,ptr:y,size:[v,v]}),d=[],A=[],S=[],O=new m({values:d,index:A,ptr:S,size:[v,v]}),M=[],_,E,$=[],z=[];for(_=0;_<v;_++)$[_]=0,M[_]=-1,y[_+1]=0;b=0,w=0;for(var I=0;I<v;I++){y[I]=b,S[I]=w;var T=h?h[I]:I,B=f(x,s,T,z,$,M,1),G=-1,D=-1;for(E=B;E<v;E++)if(_=z[E],M[_]<0){var H=n($[_]);i(H,D)&&(D=H,G=_)}else A[w]=M[_],d[w++]=$[_];if(G===-1||D<=0)return null;M[T]<0&&l(n($[T]),t(D,u))&&(G=T);var W=$[G];for(A[w]=I,d[w++]=W,M[G]=I,g[b]=G,N[b++]=1,E=B;E<v;E++)_=z[E],M[_]<0&&(g[b]=_,N[b++]=a($[_],W)),$[_]=0}for(y[v]=b,S[v]=w,E=0;E<b;E++)g[E]=M[g[E]];return N.splice(b,N.length-b),g.splice(b,g.length-b),d.splice(w,d.length-w),A.splice(w,A.length-w),{L:x,U:O,pinv:M}}}),pl="slu",TM=["typed","abs","add","multiply","transpose","divideScalar","subtract","larger","largerEq","SparseMatrix"],BM=R(pl,TM,e=>{var{typed:n,abs:a,add:t,multiply:r,transpose:i,divideScalar:l,subtract:m,larger:f,largerEq:c,SparseMatrix:s}=e,o=wM({add:t,multiply:r,transpose:i}),u=DM({abs:a,divideScalar:l,multiply:r,subtract:m,larger:f,largerEq:c,SparseMatrix:s});return n(pl,{"SparseMatrix, number, number":function(v,h,b){if(!Ae(h)||h<0||h>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(b<0||b>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var w=o(h,v,!1),N=u(v,w,b);return{L:N.L,U:N.U,p:N.pinv,q:w.q,toString:function(){return"L: "+this.L.toString()+`
27
+ P: `+this.p}}}}),pl="qr",fM=["typed","matrix","zeros","identity","isZero","equal","sign","sqrt","conj","unaryMinus","addScalar","divideScalar","multiplyScalar","subtract","complex"],lM=R(pl,fM,e=>{var{typed:t,matrix:n,zeros:a,identity:r,isZero:i,equal:u,sign:l,sqrt:f,conj:c,unaryMinus:o,addScalar:s,divideScalar:m,multiplyScalar:p,subtract:v,complex:h}=e;return ir(t(pl,{DenseMatrix:function(y){return w(y)},SparseMatrix:function(y){return N()},Array:function(y){var x=n(y),d=w(x);return{Q:d.Q.valueOf(),R:d.R.valueOf()}}}),{_denseQRimpl:b});function b(g){var y=g._size[0],x=g._size[1],d=r([y],"dense"),A=d._data,S=g.clone(),O=S._data,M,$,E,_=a([y],"");for(E=0;E<Math.min(x,y);++E){var z=O[E][E],I=o(u(z,0)?1:l(z)),T=c(I),B=0;for(M=E;M<y;M++)B=s(B,p(O[M][E],c(O[M][E])));var G=p(I,f(B));if(!i(G)){var D=v(z,G);for(_[E]=1,M=E+1;M<y;M++)_[M]=m(O[M][E],D);var H=o(c(m(D,G))),W=void 0;for($=E;$<x;$++){for(W=0,M=E;M<y;M++)W=s(W,p(c(_[M]),O[M][$]));for(W=p(W,H),M=E;M<y;M++)O[M][$]=p(v(O[M][$],p(_[M],W)),T)}for(M=0;M<y;M++){for(W=0,$=E;$<y;$++)W=s(W,p(A[M][$],_[$]));for(W=p(W,H),$=E;$<y;++$)A[M][$]=m(v(A[M][$],p(W,c(_[$]))),T)}}}return{Q:d,R:S,toString:function(){return"Q: "+this.Q.toString()+`
28
+ R: `+this.R.toString()}}}function w(g){var y=b(g),x=y.R._data;if(g._data.length>0)for(var d=x[0][0].type==="Complex"?h(0):0,A=0;A<x.length;++A)for(var S=0;S<A&&S<(x[0]||[]).length;++S)x[A][S]=d;return y}function N(g){throw new Error("qr not implemented for sparse matrices yet")}});function mM(e,t,n,a){e._values;for(var r=e._index,i=e._ptr,u=e._size,l=e._datatype,f=u[0],c=u[1],o=null,s=[],m=[],p=0,v=0;v<c;v++){m[v]=p;for(var h=n?n[v]:v,b=i[h],w=i[h+1],N=b;N<w;N++){var g=r[N];s[p]=g,p++}}return m[c]=p,e.createSparseMatrix({values:o,index:s,ptr:m,size:[f,c],datatype:l})}function vl(e,t,n,a,r,i,u){var l=0;for(n[u]=e;l>=0;){var f=n[u+l],c=n[a+f];c===-1?(l--,i[t++]=f):(n[a+f]=n[r+c],++l,n[u+l]=c)}return t}function pM(e,t){if(!e)return null;var n=0,a,r=[],i=[],u=0,l=t,f=2*t;for(a=0;a<t;a++)i[u+a]=-1;for(a=t-1;a>=0;a--)e[a]!==-1&&(i[l+a]=i[u+e[a]],i[u+e[a]]=a);for(a=0;a<t;a++)e[a]===-1&&(n=vl(a,n,i,u,l,r,f));return r}function vM(e,t){if(!e)return null;var n=e._index,a=e._ptr,r=e._size,i=r[0],u=r[1],l=[],f=[],c=0,o=u,s,m;for(s=0;s<i;s++)f[o+s]=-1;for(var p=0;p<u;p++){l[p]=-1,f[c+p]=-1;for(var v=a[p],h=a[p+1],b=v;b<h;b++){var w=n[b];for(s=f[o+w];s!==-1&&s<p;s=m)m=f[c+s],f[c+s]=p,m===-1&&(l[s]=p);f[o+w]=p}}return l}function hM(e,t,n){for(var a=e._values,r=e._index,i=e._ptr,u=e._size,l=u[1],f=0,c=0;c<l;c++){var o=i[c];for(i[c]=f;o<i[c+1];o++)t(r[o],c,a?a[o]:1,n)&&(r[f]=r[o],a&&(a[f]=a[o]),f++)}return i[l]=f,r.splice(f,r.length-f),a&&a.splice(f,a.length-f),f}function zt(e){return-e-2}var dM="csAmd",gM=["add","multiply","transpose"],yM=R(dM,gM,e=>{var{add:t,multiply:n,transpose:a}=e;return function(o,s){if(!s||o<=0||o>3)return null;var m=s._size,p=m[0],v=m[1],h=0,b=Math.max(16,10*Math.sqrt(v));b=Math.min(v-2,b);var w=r(o,s,p,v,b);hM(w,f,null);for(var N=w._index,g=w._ptr,y=g[v],x=[],d=[],A=0,S=v+1,O=2*(v+1),M=3*(v+1),$=4*(v+1),E=5*(v+1),_=6*(v+1),z=7*(v+1),I=x,T=i(v,g,d,A,M,I,O,z,S,_,$,E),B=u(v,g,d,E,$,_,b,S,M,I,O),G=0,D,H,W,j,V,K,te,re,oe,ae,ce,ee,xe,Ne,pe,be;B<v;){for(W=-1;G<v&&(W=d[M+G])===-1;G++);d[O+W]!==-1&&(I[d[O+W]]=-1),d[M+G]=d[O+W];var F=d[$+W],Y=d[S+W];B+=Y;var k=0;d[S+W]=-Y;var U=g[W],J=F===0?U:y,q=J;for(j=1;j<=F+1;j++){for(j>F?(K=W,te=U,re=d[A+W]-F):(K=N[U++],te=g[K],re=d[A+K]),V=1;V<=re;V++)D=N[te++],!((oe=d[S+D])<=0)&&(k+=oe,d[S+D]=-oe,N[q++]=D,d[O+D]!==-1&&(I[d[O+D]]=I[D]),I[D]!==-1?d[O+I[D]]=d[O+D]:d[M+d[E+D]]=d[O+D]);K!==W&&(g[K]=zt(W),d[_+K]=0)}for(F!==0&&(y=q),d[E+W]=k,g[W]=J,d[A+W]=q-J,d[$+W]=-2,T=l(T,h,d,_,v),ae=J;ae<q;ae++)if(D=N[ae],!((ce=d[$+D])<=0)){oe=-d[S+D];var P=T-oe;for(U=g[D],ee=g[D]+ce-1;U<=ee;U++)K=N[U],d[_+K]>=T?d[_+K]-=oe:d[_+K]!==0&&(d[_+K]=d[E+K]+P)}for(ae=J;ae<q;ae++){for(D=N[ae],ee=g[D],xe=ee+d[$+D]-1,Ne=ee,pe=0,be=0,U=ee;U<=xe;U++)if(K=N[U],d[_+K]!==0){var Q=d[_+K]-T;Q>0?(be+=Q,N[Ne++]=K,pe+=K):(g[K]=zt(W),d[_+K]=0)}d[$+D]=Ne-ee+1;var L=Ne,ue=ee+d[A+D];for(U=xe+1;U<ue;U++){H=N[U];var le=d[S+H];le<=0||(be+=le,N[Ne++]=H,pe+=H)}be===0?(g[D]=zt(W),oe=-d[S+D],k-=oe,Y+=oe,B+=oe,d[S+D]=0,d[$+D]=-1):(d[E+D]=Math.min(d[E+D],be),N[Ne]=N[L],N[L]=N[ee],N[ee]=W,d[A+D]=Ne-ee+1,pe=(pe<0?-pe:pe)%v,d[O+D]=d[z+pe],d[z+pe]=D,I[D]=pe)}for(d[E+W]=k,h=Math.max(h,k),T=l(T+h,h,d,_,v),ae=J;ae<q;ae++)if(D=N[ae],!(d[S+D]>=0))for(pe=I[D],D=d[z+pe],d[z+pe]=-1;D!==-1&&d[O+D]!==-1;D=d[O+D],T++){for(re=d[A+D],ce=d[$+D],U=g[D]+1;U<=g[D]+re-1;U++)d[_+N[U]]=T;var ye=D;for(H=d[O+D];H!==-1;){var ve=d[A+H]===re&&d[$+H]===ce;for(U=g[H]+1;ve&&U<=g[H]+re-1;U++)d[_+N[U]]!==T&&(ve=0);ve?(g[H]=zt(D),d[S+D]+=d[S+H],d[S+H]=0,d[$+H]=-1,H=d[O+H],d[O+ye]=H):(ye=H,H=d[O+H])}}for(U=J,ae=J;ae<q;ae++)D=N[ae],!((oe=-d[S+D])<=0)&&(d[S+D]=oe,be=d[E+D]+k-oe,be=Math.min(be,v-B-oe),d[M+be]!==-1&&(I[d[M+be]]=D),d[O+D]=d[M+be],I[D]=-1,d[M+be]=D,G=Math.min(G,be),d[E+D]=be,N[U++]=D);d[S+W]=Y,(d[A+W]=U-J)===0&&(g[W]=-1,d[_+W]=0),F!==0&&(y=U)}for(D=0;D<v;D++)g[D]=zt(g[D]);for(H=0;H<=v;H++)d[M+H]=-1;for(H=v;H>=0;H--)d[S+H]>0||(d[O+H]=d[M+g[H]],d[M+g[H]]=H);for(K=v;K>=0;K--)d[S+K]<=0||g[K]!==-1&&(d[O+K]=d[M+g[K]],d[M+g[K]]=K);for(W=0,D=0;D<=v;D++)g[D]===-1&&(W=vl(D,W,d,M,O,x,_));return x.splice(x.length-1,1),x};function r(c,o,s,m,p){var v=a(o);if(c===1&&m===s)return t(o,v);if(c===2){for(var h=v._index,b=v._ptr,w=0,N=0;N<s;N++){var g=b[N];if(b[N]=w,!(b[N+1]-g>p))for(var y=b[N+1];g<y;g++)h[w++]=h[g]}return b[s]=w,o=a(v),n(v,o)}return n(v,o)}function i(c,o,s,m,p,v,h,b,w,N,g,y){for(var x=0;x<c;x++)s[m+x]=o[x+1]-o[x];s[m+c]=0;for(var d=0;d<=c;d++)s[p+d]=-1,v[d]=-1,s[h+d]=-1,s[b+d]=-1,s[w+d]=1,s[N+d]=1,s[g+d]=0,s[y+d]=s[m+d];var A=l(0,0,s,N,c);return s[g+c]=-2,o[c]=-1,s[N+c]=0,A}function u(c,o,s,m,p,v,h,b,w,N,g){for(var y=0,x=0;x<c;x++){var d=s[m+x];if(d===0)s[p+x]=-2,y++,o[x]=-1,s[v+x]=0;else if(d>h)s[b+x]=0,s[p+x]=-1,y++,o[x]=zt(c),s[b+c]++;else{var A=s[w+d];A!==-1&&(N[A]=x),s[g+x]=s[w+d],s[w+d]=x}}return y}function l(c,o,s,m,p){if(c<2||c+o<0){for(var v=0;v<p;v++)s[m+v]!==0&&(s[m+v]=1);c=2}return c}function f(c,o){return c!==o}});function xM(e,t,n,a,r,i,u){var l,f,c=0,o;if(e<=t||n[a+t]<=n[r+e])return-1;n[r+e]=n[a+t];var s=n[i+e];if(n[i+e]=t,s===-1)c=1,o=e;else{for(c=2,o=s;o!==n[u+o];o=n[u+o]);for(l=s;l!==o;l=f)f=n[u+l],n[u+l]=o}return{jleaf:c,q:o}}var bM="csCounts",wM=["transpose"],NM=R(bM,wM,e=>{var{transpose:t}=e;return function(n,a,r,i){if(!n||!a||!r)return null;var u=n._size,l=u[0],f=u[1],c,o,s,m,p,v,h,b=4*f+(i?f+l+1:0),w=[],N=0,g=f,y=2*f,x=3*f,d=4*f,A=5*f+1;for(s=0;s<b;s++)w[s]=-1;var S=[],O=t(n),M=O._index,$=O._ptr;for(s=0;s<f;s++)for(o=r[s],S[o]=w[x+o]===-1?1:0;o!==-1&&w[x+o]===-1;o=a[o])w[x+o]=s;if(i){for(s=0;s<f;s++)w[r[s]]=s;for(c=0;c<l;c++){for(s=f,v=$[c],h=$[c+1],p=v;p<h;p++)s=Math.min(s,w[M[p]]);w[A+c]=w[d+s],w[d+s]=c}}for(c=0;c<f;c++)w[N+c]=c;for(s=0;s<f;s++){for(o=r[s],a[o]!==-1&&S[a[o]]--,m=i?w[d+s]:o;m!==-1;m=i?w[A+m]:-1)for(p=$[m];p<$[m+1];p++){c=M[p];var E=xM(c,o,w,x,g,y,N);E.jleaf>=1&&S[o]++,E.jleaf===2&&S[E.q]--}a[o]!==-1&&(w[N+o]=a[o])}for(o=0;o<f;o++)a[o]!==-1&&(S[a[o]]+=S[o]);return S}}),MM="csSqr",AM=["add","multiply","transpose"],SM=R(MM,AM,e=>{var{add:t,multiply:n,transpose:a}=e,r=yM({add:t,multiply:n,transpose:a}),i=NM({transpose:a});return function(f,c,o){var s=c._ptr,m=c._size,p=m[1],v,h={};if(h.q=r(f,c),f&&!h.q)return null;if(o){var b=f?mM(c,null,h.q):c;h.parent=vM(b);var w=pM(h.parent,p);if(h.cp=i(b,h.parent,w,1),b&&h.parent&&h.cp&&u(b,h))for(h.unz=0,v=0;v<p;v++)h.unz+=h.cp[v]}else h.unz=4*s[p]+p,h.lnz=h.unz;return h};function u(l,f){var c=l._ptr,o=l._index,s=l._size,m=s[0],p=s[1];f.pinv=[],f.leftmost=[];var v=f.parent,h=f.pinv,b=f.leftmost,w=[],N=0,g=m,y=m+p,x=m+2*p,d,A,S,O,M;for(A=0;A<p;A++)w[g+A]=-1,w[y+A]=-1,w[x+A]=0;for(d=0;d<m;d++)b[d]=-1;for(A=p-1;A>=0;A--)for(O=c[A],M=c[A+1],S=O;S<M;S++)b[o[S]]=A;for(d=m-1;d>=0;d--)h[d]=-1,A=b[d],A!==-1&&(w[x+A]++===0&&(w[y+A]=d),w[N+d]=w[g+A],w[g+A]=d);for(f.lnz=0,f.m2=m,A=0;A<p;A++)if(d=w[g+A],f.lnz++,d<0&&(d=f.m2++),h[d]=A,!(--x[A]<=0)){f.lnz+=w[x+A];var $=v[A];$!==-1&&(w[x+$]===0&&(w[y+$]=w[y+A]),w[N+w[y+A]]=w[g+$],w[g+$]=w[N+d],w[x+$]+=w[x+A])}for(d=0;d<m;d++)h[d]<0&&(h[d]=A++);return!0}});function Pi(e,t){return e[t]<0}function hl(e,t){e[t]=zt(e[t])}function dl(e){return e<0?zt(e):e}function EM(e,t,n,a,r){var i=t._index,u=t._ptr,l=t._size,f=l[1],c,o,s,m=0;for(a[0]=e;m>=0;){e=a[m];var p=r?r[e]:e;Pi(u,e)||(hl(u,e),a[f+m]=p<0?0:dl(u[p]));var v=1;for(o=a[f+m],s=p<0?0:dl(u[p+1]);o<s;o++)if(c=i[o],!Pi(u,c)){a[f+m]=o,a[++m]=c,v=0;break}v&&(m--,a[--n]=e)}return n}function CM(e,t,n,a,r){var i=e._ptr,u=e._size,l=t._index,f=t._ptr,c=u[1],o,s,m,p=c;for(s=f[n],m=f[n+1],o=s;o<m;o++){var v=l[o];Pi(i,v)||(p=EM(v,e,p,a,r))}for(o=p;o<c;o++)hl(i,a[o]);return p}var OM="csSpsolve",DM=["divideScalar","multiply","subtract"],TM=R(OM,DM,e=>{var{divideScalar:t,multiply:n,subtract:a}=e;return function(i,u,l,f,c,o,s){var m=i._values,p=i._index,v=i._ptr,h=i._size,b=h[1],w=u._values,N=u._index,g=u._ptr,y,x,d,A,S=CM(i,u,l,f,o);for(y=S;y<b;y++)c[f[y]]=0;for(x=g[l],d=g[l+1],y=x;y<d;y++)c[N[y]]=w[y];for(var O=S;O<b;O++){var M=f[O],$=o?o[M]:M;if(!($<0))for(x=v[$],d=v[$+1],c[M]=t(c[M],m[s?x:d-1]),y=s?x+1:x,A=s?d:d-1;y<A;y++){var E=p[y];c[E]=a(c[E],n(m[y],c[M]))}}return S}}),BM="csLu",$M=["abs","divideScalar","multiply","subtract","larger","largerEq","SparseMatrix"],_M=R(BM,$M,e=>{var{abs:t,divideScalar:n,multiply:a,subtract:r,larger:i,largerEq:u,SparseMatrix:l}=e,f=TM({divideScalar:n,multiply:a,subtract:r});return function(o,s,m){if(!o)return null;var p=o._size,v=p[1],h,b=100,w=100;s&&(h=s.q,b=s.lnz||b,w=s.unz||w);var N=[],g=[],y=[],x=new l({values:N,index:g,ptr:y,size:[v,v]}),d=[],A=[],S=[],O=new l({values:d,index:A,ptr:S,size:[v,v]}),M=[],$,E,_=[],z=[];for($=0;$<v;$++)_[$]=0,M[$]=-1,y[$+1]=0;b=0,w=0;for(var I=0;I<v;I++){y[I]=b,S[I]=w;var T=h?h[I]:I,B=f(x,o,T,z,_,M,1),G=-1,D=-1;for(E=B;E<v;E++)if($=z[E],M[$]<0){var H=t(_[$]);i(H,D)&&(D=H,G=$)}else A[w]=M[$],d[w++]=_[$];if(G===-1||D<=0)return null;M[T]<0&&u(t(_[T]),a(D,m))&&(G=T);var W=_[G];for(A[w]=I,d[w++]=W,M[G]=I,g[b]=G,N[b++]=1,E=B;E<v;E++)$=z[E],M[$]<0&&(g[b]=$,N[b++]=n(_[$],W)),_[$]=0}for(y[v]=b,S[v]=w,E=0;E<b;E++)g[E]=M[g[E]];return N.splice(b,N.length-b),g.splice(b,g.length-b),d.splice(w,d.length-w),A.splice(w,A.length-w),{L:x,U:O,pinv:M}}}),gl="slu",IM=["typed","abs","add","multiply","transpose","divideScalar","subtract","larger","largerEq","SparseMatrix"],qM=R(gl,IM,e=>{var{typed:t,abs:n,add:a,multiply:r,transpose:i,divideScalar:u,subtract:l,larger:f,largerEq:c,SparseMatrix:o}=e,s=SM({add:a,multiply:r,transpose:i}),m=_M({abs:n,divideScalar:u,multiply:r,subtract:l,larger:f,largerEq:c,SparseMatrix:o});return t(gl,{"SparseMatrix, number, number":function(v,h,b){if(!Se(h)||h<0||h>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(b<0||b>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var w=s(h,v,!1),N=m(v,w,b);return{L:N.L,U:N.U,p:N.pinv,q:w.q,toString:function(){return"L: "+this.L.toString()+`
29
29
  U: `+this.U.toString()+`
30
30
  p: `+this.p.toString()+(this.q?`
31
31
  q: `+this.q.toString():"")+`
32
- `}}}})});function vl(e,n){var a,t=n.length,r=[];if(e)for(a=0;a<t;a++)r[e[a]]=n[a];else for(a=0;a<t;a++)r[a]=n[a];return r}var hl="lusolve",_M=["typed","matrix","lup","slu","usolve","lsolve","DenseMatrix"],$M=R(hl,_M,e=>{var{typed:n,matrix:a,lup:t,slu:r,usolve:i,lsolve:l,DenseMatrix:m}=e,f=Rn({DenseMatrix:m});return n(hl,{"Array, Array | Matrix":function(u,p){u=a(u);var v=t(u),h=s(v.L,v.U,v.p,null,p);return h.valueOf()},"DenseMatrix, Array | Matrix":function(u,p){var v=t(u);return s(v.L,v.U,v.p,null,p)},"SparseMatrix, Array | Matrix":function(u,p){var v=t(u);return s(v.L,v.U,v.p,null,p)},"SparseMatrix, Array | Matrix, number, number":function(u,p,v,h){var b=r(u,v,h);return s(b.L,b.U,b.p,b.q,p)},"Object, Array | Matrix":function(u,p){return s(u.L,u.U,u.p,u.q,p)}});function c(o){if(Oe(o))return o;if(Xe(o))return a(o);throw new TypeError("Invalid Matrix LU decomposition")}function s(o,u,p,v,h){o=c(o),u=c(u),p&&(h=f(o,h,!0),h._data=vl(p,h._data));var b=l(o,h),w=i(u,b);return v&&(w._data=vl(v,w._data)),w}}),IM="Help",qM=["parse"],RM=R(IM,qM,e=>{var{parse:n}=e;function a(t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!t)throw new Error('Argument "doc" missing');this.doc=t}return a.prototype.type="Help",a.prototype.isHelp=!0,a.prototype.toString=function(){var t=this.doc||{},r=`
33
- `;if(t.name&&(r+="Name: "+t.name+`
32
+ `}}}})});function yl(e,t){var n,a=t.length,r=[];if(e)for(n=0;n<a;n++)r[e[n]]=t[n];else for(n=0;n<a;n++)r[n]=t[n];return r}var xl="lusolve",RM=["typed","matrix","lup","slu","usolve","lsolve","DenseMatrix"],FM=R(xl,RM,e=>{var{typed:t,matrix:n,lup:a,slu:r,usolve:i,lsolve:u,DenseMatrix:l}=e,f=Pn({DenseMatrix:l});return t(xl,{"Array, Array | Matrix":function(m,p){m=n(m);var v=a(m),h=o(v.L,v.U,v.p,null,p);return h.valueOf()},"DenseMatrix, Array | Matrix":function(m,p){var v=a(m);return o(v.L,v.U,v.p,null,p)},"SparseMatrix, Array | Matrix":function(m,p){var v=a(m);return o(v.L,v.U,v.p,null,p)},"SparseMatrix, Array | Matrix, number, number":function(m,p,v,h){var b=r(m,v,h);return o(b.L,b.U,b.p,b.q,p)},"Object, Array | Matrix":function(m,p){return o(m.L,m.U,m.p,m.q,p)}});function c(s){if(De(s))return s;if(Ye(s))return n(s);throw new TypeError("Invalid Matrix LU decomposition")}function o(s,m,p,v,h){s=c(s),m=c(m),p&&(h=f(s,h,!0),h._data=yl(p,h._data));var b=u(s,h),w=i(m,b);return v&&(w._data=yl(v,w._data)),w}}),zM="Help",PM=["parse"],UM=R(zM,PM,e=>{var{parse:t}=e;function n(a){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!a)throw new Error('Argument "doc" missing');this.doc=a}return n.prototype.type="Help",n.prototype.isHelp=!0,n.prototype.toString=function(){var a=this.doc||{},r=`
33
+ `;if(a.name&&(r+="Name: "+a.name+`
34
34
 
35
- `),t.category&&(r+="Category: "+t.category+`
35
+ `),a.category&&(r+="Category: "+a.category+`
36
36
 
37
- `),t.description&&(r+=`Description:
38
- `+t.description+`
37
+ `),a.description&&(r+=`Description:
38
+ `+a.description+`
39
39
 
40
- `),t.syntax&&(r+=`Syntax:
41
- `+t.syntax.join(`
40
+ `),a.syntax&&(r+=`Syntax:
41
+ `+a.syntax.join(`
42
42
  `)+`
43
43
 
44
- `),t.examples){r+=`Examples:
45
- `;for(var i={},l=0;l<t.examples.length;l++){var m=t.examples[l];r+=" "+m+`
46
- `;var f=void 0;try{f=n(m).compile().evaluate(i)}catch(c){f=c}f!==void 0&&!Wa(f)&&(r+=" "+Re(f,{precision:14})+`
44
+ `),a.examples){r+=`Examples:
45
+ `;for(var i={},u=0;u<a.examples.length;u++){var l=a.examples[u];r+=" "+l+`
46
+ `;var f=void 0;try{f=t(l).compile().evaluate(i)}catch(c){f=c}f!==void 0&&!ja(f)&&(r+=" "+Fe(f,{precision:14})+`
47
47
  `)}r+=`
48
- `}return t.mayThrow&&t.mayThrow.length&&(r+="Throws: "+t.mayThrow.join(", ")+`
48
+ `}return a.mayThrow&&a.mayThrow.length&&(r+="Throws: "+a.mayThrow.join(", ")+`
49
49
 
50
- `),t.seealso&&t.seealso.length&&(r+="See also: "+t.seealso.join(", ")+`
51
- `),r},a.prototype.toJSON=function(){var t=Ce(this.doc);return t.mathjs="Help",t},a.fromJSON=function(t){var r={};return Object.keys(t).filter(i=>i!=="mathjs").forEach(i=>{r[i]=t[i]}),new a(r)},a.prototype.valueOf=a.prototype.toString,a},{isClass:!0}),FM="Chain",zM=["?on","math"],PM=R(FM,zM,e=>{var{on:n,math:a}=e;function t(f){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");Qa(f)?this.value=f.value:this.value=f}t.prototype.type="Chain",t.prototype.isChain=!0,t.prototype.done=function(){return this.value},t.prototype.valueOf=function(){return this.value},t.prototype.toString=function(){return Re(this.value)},t.prototype.toJSON=function(){return{mathjs:"Chain",value:this.value}},t.fromJSON=function(f){return new t(f.value)};function r(f,c){typeof c=="function"&&(t.prototype[f]=l(c))}function i(f,c){Ip(t.prototype,f,function(){var o=c();if(typeof o=="function")return l(o)})}function l(f){return function(){for(var c=[this.value],s=0;s<arguments.length;s++)c[s+1]=arguments[s];return new t(f.apply(f,c))}}t.createProxy=function(f,c){if(typeof f=="string")r(f,c);else{var s=function(p){Me(f,p)&&m[p]===void 0&&i(p,()=>f[p])};for(var o in f)s(o)}};var m={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return t.createProxy(a),n&&n("import",function(f,c,s){s||i(f,c)}),t},{isClass:!0}),dl={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"]},UM={name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},LM={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:[]},kM={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:[]},HM={name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},GM={name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},VM={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:[]},ZM={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:[]},XM={name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},YM={name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},WM={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:[]},gl={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"]},JM={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:[]},QM={name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},KM={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"]},jM={name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},e2={name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},r2={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"]},t2={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"]},n2={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"]},a2={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"]},i2={name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(matrix)","fraction(num,den)","fraction({n: num, d: den})"],description:"Create a fraction from a number or from integer numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)","fraction({n: 333, d: 53})","fraction([sqrt(9), sqrt(10), sqrt(11)])"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},o2={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"]},s2={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"]},u2={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"]},c2={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"]},f2={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"]},l2={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"]},m2={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"]},p2={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:[]},v2={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:[]},h2={name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},d2={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"]},g2={name:"leafCount",category:"Algebra",syntax:["leafCount(expr)"],description:"Computes the number of leaves in the parse tree of the given expression",examples:['leafCount("e^(i*pi)-1")','leafCount(parse("{a: 22/7, b: 10^(1/2)}"))'],seealso:["simplify"]},y2={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"]},x2={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"]},b2={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"]},w2={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"]},N2={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"]},M2={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"]},A2={name:"resolve",category:"Algebra",syntax:["resolve(node, scope)"],description:"Recursively substitute variables in an expression tree.",examples:['resolve(parse("1 + x"), { x: 7 })','resolve(parse("size(text)"), { text: "Hello World" })','resolve(parse("x + y"), { x: parse("3z") })','resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })'],seealso:["simplify","evaluate"],mayThrow:["ReferenceError"]},S2={name:"simplify",category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["simplifyCore","derivative","evaluate","parse","rationalize","resolve"]},E2={name:"simplifyCore",category:"Algebra",syntax:["simplifyCore(node)"],description:"Perform simple one-pass simplifications on an expression tree.",examples:['simplifyCore(parse("0*x"))','simplifyCore(parse("(x+0)*2"))'],seealso:["simplify","evaluate"]},C2={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"]},O2={name:"symbolicEqual",category:"Algebra",syntax:["symbolicEqual(expr1, expr2)","symbolicEqual(expr1, expr2, options)"],description:"Returns true if the difference of the expressions simplifies to 0",examples:['symbolicEqual("x*y","y*x")','symbolicEqual("abs(x^2)", "x^2")','symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})'],seealso:["simplify","evaluate"]},D2={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"]},T2={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"]},B2={name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},_2={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"]},$2={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"]},I2={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"]},q2={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"]},R2={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"]},F2={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"]},z2={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"]},P2={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"]},U2={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"]},L2={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"]},k2={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"]},H2={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"]},G2={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"]},V2={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"]},Z2={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"]},X2={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"]},Y2={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"]},W2={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"]},J2={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"]},Q2={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"]},K2={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"]},j2={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"]},eA={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"]},rA={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")']},tA={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"]},nA={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"]},aA={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)","math.pow([[1, 2], [4, 3]], 2)","math.pow([[1, 2], [4, 3]], -1)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},iA={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"]},oA={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"]},sA={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"]},uA={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"]},cA={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"]},fA={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"]},lA={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"]},mA={name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},pA={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"]},vA={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"]},hA={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"]},dA={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"]},gA={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"]},yA={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"]},xA={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"]},bA={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"]},wA={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"]},NA={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"]},MA={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"]},AA={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"]},SA={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"]},EA={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"]},CA={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"]},OA={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"]},DA={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:[]},TA={name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},BA={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:[]},_A={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:[]},$A={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"]},IA={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"]},qA={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"]},RA={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"]},FA={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"]},zA={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"]},PA={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"]},UA={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"]},LA={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"]},kA={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"]},HA={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"]},GA={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"]},VA={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"]},ZA={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"]},XA={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"]},YA={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"]},WA={name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["numberOfPets = {}","addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;",'forEach(["Dog","Cat","Cat"], addPet)',"numberOfPets"],seealso:["map","sort","filter"]},JA={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"]},QA={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"]},KA={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"]},jA={name:"pinv",category:"Matrix",syntax:["pinv(x)"],description:"Calculate the Moore–Penrose inverse of a matrix",examples:["pinv([1, 2; 3, 4])","pinv([[1, 0], [0, 1], [0, 1]])","pinv(4)"],seealso:["inv"]},eS={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"]},rS={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"]},tS={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"]},nS={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"]},aS={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"]},iS={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"]},oS={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"]},sS={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"]},uS={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"]},cS={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"]},fS={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"]},lS={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"]},mS={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"]},pS={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"]},vS={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"]},hS={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"]},dS={name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation `l:u`. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]","f[[1,2], [1,3]] = [9, 10; 11, 12]","f"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},gS={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"]},yS={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"]},xS={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"]},bS={name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},wS={name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},NS={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"]},MS={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"]},AS={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"]},SS={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"]},ES={name:"lgamma",category:"Probability",syntax:["lgamma(n)"],description:"Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.",examples:["lgamma(4)","lgamma(1/2)","lgamma(math.i)","lgamma(complex(1.1, 2))"],seealso:["gamma"]},CS={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:[]},OS={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"]},DS={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"]},TS={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"]},BS={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"]},_S={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"]},$S={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"]},IS={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"]},qS={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"]},RS={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"]},FS={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"]},zS={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"]},PS={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"]},US={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"]},LS={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"]},kS={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"]},HS={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"]},GS={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"]},VS={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"]},ZS={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"]},XS={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"]},YS={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"]},WS={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"]},JS={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"]},QS={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"]},KS={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"]},jS={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"]},eE={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:[]},rE={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"]},tE={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"]},nE={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"]},aE={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"]},iE={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"]},oE={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"]},sE={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"]},uE={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.
50
+ `),a.seealso&&a.seealso.length&&(r+="See also: "+a.seealso.join(", ")+`
51
+ `),r},n.prototype.toJSON=function(){var a=Oe(this.doc);return a.mathjs="Help",a},n.fromJSON=function(a){var r={};return Object.keys(a).filter(i=>i!=="mathjs").forEach(i=>{r[i]=a[i]}),new n(r)},n.prototype.valueOf=n.prototype.toString,n},{isClass:!0}),LM="Chain",kM=["?on","math"],HM=R(LM,kM,e=>{var{on:t,math:n}=e;function a(f){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");ri(f)?this.value=f.value:this.value=f}a.prototype.type="Chain",a.prototype.isChain=!0,a.prototype.done=function(){return this.value},a.prototype.valueOf=function(){return this.value},a.prototype.toString=function(){return Fe(this.value)},a.prototype.toJSON=function(){return{mathjs:"Chain",value:this.value}},a.fromJSON=function(f){return new a(f.value)};function r(f,c){typeof c=="function"&&(a.prototype[f]=u(c))}function i(f,c){zp(a.prototype,f,function(){var s=c();if(typeof s=="function")return u(s)})}function u(f){return function(){for(var c=[this.value],o=0;o<arguments.length;o++)c[o+1]=arguments[o];return new a(f.apply(f,c))}}a.createProxy=function(f,c){if(typeof f=="string")r(f,c);else{var o=function(p){Ae(f,p)&&l[p]===void 0&&i(p,()=>f[p])};for(var s in f)o(s)}};var l={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return a.createProxy(n),t&&t("import",function(f,c,o){o||i(f,c)}),a},{isClass:!0}),bl={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"]},GM={name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},VM={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:[]},ZM={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:[]},XM={name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},YM={name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},WM={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:[]},JM={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:[]},QM={name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},KM={name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},jM={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:[]},wl={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"]},e2={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:[]},r2={name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},t2={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"]},n2={name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},a2={name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},i2={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"]},o2={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"]},s2={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"]},u2={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"]},c2={name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(matrix)","fraction(num,den)","fraction({n: num, d: den})"],description:"Create a fraction from a number or from integer numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)","fraction({n: 333, d: 53})","fraction([sqrt(9), sqrt(10), sqrt(11)])"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},f2={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"]},l2={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"]},m2={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"]},p2={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"]},v2={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"]},h2={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"]},d2={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"]},g2={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:[]},y2={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:[]},x2={name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},b2={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"]},w2={name:"leafCount",category:"Algebra",syntax:["leafCount(expr)"],description:"Computes the number of leaves in the parse tree of the given expression",examples:['leafCount("e^(i*pi)-1")','leafCount(parse("{a: 22/7, b: 10^(1/2)}"))'],seealso:["simplify"]},N2={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"]},M2={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"]},A2={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"]},S2={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"]},E2={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"]},C2={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"]},O2={name:"resolve",category:"Algebra",syntax:["resolve(node, scope)"],description:"Recursively substitute variables in an expression tree.",examples:['resolve(parse("1 + x"), { x: 7 })','resolve(parse("size(text)"), { text: "Hello World" })','resolve(parse("x + y"), { x: parse("3z") })','resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })'],seealso:["simplify","evaluate"],mayThrow:["ReferenceError"]},D2={name:"simplify",category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["simplifyCore","derivative","evaluate","parse","rationalize","resolve"]},T2={name:"simplifyCore",category:"Algebra",syntax:["simplifyCore(node)"],description:"Perform simple one-pass simplifications on an expression tree.",examples:['simplifyCore(parse("0*x"))','simplifyCore(parse("(x+0)*2"))'],seealso:["simplify","evaluate"]},B2={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"]},$2={name:"symbolicEqual",category:"Algebra",syntax:["symbolicEqual(expr1, expr2)","symbolicEqual(expr1, expr2, options)"],description:"Returns true if the difference of the expressions simplifies to 0",examples:['symbolicEqual("x*y","y*x")','symbolicEqual("abs(x^2)", "x^2")','symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})'],seealso:["simplify","evaluate"]},_2={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"]},I2={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"]},q2={name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},R2={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"]},F2={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"]},z2={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"]},P2={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"]},U2={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"]},L2={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"]},k2={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"]},H2={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"]},G2={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"]},V2={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"]},Z2={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"]},X2={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"]},Y2={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"]},W2={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"]},J2={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"]},Q2={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"]},K2={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"]},j2={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"]},eA={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"]},rA={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"]},tA={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"]},nA={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"]},aA={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"]},iA={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")']},oA={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"]},sA={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"]},uA={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)","math.pow([[1, 2], [4, 3]], 2)","math.pow([[1, 2], [4, 3]], -1)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},cA={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"]},fA={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"]},lA={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"]},mA={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"]},pA={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"]},vA={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"]},hA={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"]},dA={name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},gA={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"]},yA={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"]},xA={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"]},bA={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"]},wA={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"]},NA={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"]},MA={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"]},AA={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"]},SA={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"]},EA={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"]},CA={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"]},OA={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"]},DA={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"]},TA={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"]},BA={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"]},$A={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"]},_A={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:[]},IA={name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},qA={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:[]},RA={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:[]},FA={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"]},zA={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"]},PA={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"]},UA={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"]},LA={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"]},kA={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"]},HA={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"]},GA={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"]},VA={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"]},ZA={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"]},XA={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"]},YA={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"]},WA={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"]},JA={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"]},QA={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"]},KA={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"]},jA={name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["numberOfPets = {}","addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;",'forEach(["Dog","Cat","Cat"], addPet)',"numberOfPets"],seealso:["map","sort","filter"]},eS={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"]},rS={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"]},tS={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"]},nS={name:"pinv",category:"Matrix",syntax:["pinv(x)"],description:"Calculate the Moore–Penrose inverse of a matrix",examples:["pinv([1, 2; 3, 4])","pinv([[1, 0], [0, 1], [0, 1]])","pinv(4)"],seealso:["inv"]},aS={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"]},iS={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"]},oS={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"]},sS={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"]},uS={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"]},cS={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"]},fS={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"]},lS={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"]},mS={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"]},pS={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"]},vS={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"]},hS={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"]},dS={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"]},gS={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"]},yS={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"]},xS={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"]},bS={name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation `l:u`. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]","f[[1,2], [1,3]] = [9, 10; 11, 12]","f"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},wS={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"]},NS={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"]},MS={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"]},AS={name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},SS={name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},ES={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"]},CS={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"]},OS={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"]},DS={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"]},TS={name:"lgamma",category:"Probability",syntax:["lgamma(n)"],description:"Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.",examples:["lgamma(4)","lgamma(1/2)","lgamma(math.i)","lgamma(complex(1.1, 2))"],seealso:["gamma"]},BS={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:[]},$S={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"]},_S={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"]},IS={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"]},qS={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"]},RS={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"]},FS={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"]},zS={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"]},PS={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"]},US={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"]},LS={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"]},kS={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"]},HS={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"]},GS={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"]},VS={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"]},ZS={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"]},XS={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"]},YS={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"]},WS={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"]},JS={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"]},QS={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"]},KS={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"]},jS={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"]},eE={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"]},rE={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"]},tE={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"]},nE={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"]},aE={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:[]},iE={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"]},oE={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"]},sE={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"]},uE={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"]},cE={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"]},fE={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"]},lE={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"]},mE={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.
52
52
 
53
- In 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"]},cE={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"]},fE={name:"cumsum",category:"Statistics",syntax:["cumsum(a, b, c, ...)","cumsum(A)"],description:"Compute the cumulative sum of all values.",examples:["cumsum(2, 3, 4, 1)","cumsum([2, 3, 4, 1])","cumsum([1, 2; 3, 4])","cumsum([1, 2; 3, 4], 1)","cumsum([1, 2; 3, 4], 2)"],seealso:["max","mean","median","min","prod","std","sum","variance"]},lE={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"]},mE={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"]},pE={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"]},vE={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"]},hE={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"]},dE={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"]},gE={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"]},yE={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"]},xE={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"]},bE={name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},wE={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"]},NE={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"]},ME={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"]},AE={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"]},SE={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"]},EE={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"]},CE={name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},OE={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"]},DE={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"]},TE={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"]},BE={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"]},_E={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"]},$E={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"]},IE={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"]},qE={name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},RE={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"]},FE={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"]},zE={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:[]},PE={name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},UE={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:[]},LE={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"]},kE={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"]},HE={name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},GE={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"]},VE={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"]},ZE={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"]},XE={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"]},YE={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"]},WE={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"]},JE={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"]},QE={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"]},KE={name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},jE={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"]},eC={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"]},rC={bignumber:r2,boolean:t2,complex:n2,createUnit:a2,fraction:i2,index:o2,matrix:s2,number:u2,sparse:c2,splitUnit:f2,string:l2,unit:m2,e:dl,E:dl,false:UM,i:LM,Infinity:kM,LN2:GM,LN10:HM,LOG2E:ZM,LOG10E:VM,NaN:XM,null:YM,pi:gl,PI:gl,phi:WM,SQRT1_2:JM,SQRT2:QM,tau:KM,true:jM,version:e2,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:d2,lsolve:y2,lsolveAll:x2,lup:b2,lusolve:w2,leafCount:g2,resolve:A2,simplify:S2,simplifyCore:E2,symbolicEqual:O2,rationalize:M2,slu:C2,usolve:D2,usolveAll:T2,qr:N2,abs:B2,add:_2,cbrt:$2,ceil:I2,cube:q2,divide:R2,dotDivide:F2,dotMultiply:z2,dotPow:P2,exp:U2,expm:L2,expm1:k2,fix:H2,floor:G2,gcd:V2,hypot:Z2,lcm:Y2,log:W2,log2:K2,log1p:Q2,log10:J2,mod:j2,multiply:eA,norm:rA,nthRoot:tA,nthRoots:nA,pow:aA,round:iA,sign:oA,sqrt:sA,sqrtm:uA,square:cA,subtract:fA,unaryMinus:lA,unaryPlus:mA,xgcd:pA,invmod:X2,bitAnd:vA,bitNot:hA,bitOr:dA,bitXor:gA,leftShift:yA,rightArithShift:xA,rightLogShift:bA,bellNumbers:wA,catalan:NA,composition:MA,stirlingS2:AA,config:p2,import:v2,typed:h2,arg:SA,conj:EA,re:OA,im:CA,evaluate:DA,help:TA,distance:BA,intersect:_A,and:$A,not:IA,or:qA,xor:RA,concat:zA,count:PA,cross:UA,column:FA,ctranspose:LA,det:kA,diag:HA,diff:GA,dot:VA,getMatrixDataType:JA,identity:QA,filter:XA,flatten:YA,forEach:WA,inv:KA,pinv:jA,eigs:ZA,kron:eS,matrixFromFunction:nS,matrixFromRows:aS,matrixFromColumns:tS,map:rS,ones:iS,partitionSelect:oS,range:sS,resize:cS,reshape:uS,rotate:fS,rotationMatrix:lS,row:mS,size:pS,sort:vS,squeeze:hS,subset:dS,trace:gS,transpose:yS,zeros:xS,fft:bS,ifft:wS,combinations:NS,combinationsWithRep:MS,factorial:AS,gamma:SS,kldivergence:CS,lgamma:ES,multinomial:OS,permutations:DS,pickRandom:TS,random:BS,randomInt:_S,compare:$S,compareNatural:IS,compareText:qS,deepEqual:RS,equal:FS,equalText:zS,larger:PS,largerEq:US,smaller:LS,smallerEq:kS,unequal:HS,setCartesian:GS,setDifference:VS,setDistinct:ZS,setIntersect:XS,setIsSubset:YS,setMultiplicity:WS,setPowerset:JS,setSize:QS,setSymDifference:KS,setUnion:jS,erf:eE,cumsum:fE,mad:rE,max:tE,mean:nE,median:aE,min:iE,mode:oE,prod:sE,quantileSeq:uE,std:cE,sum:lE,variance:mE,acos:pE,acosh:vE,acot:hE,acoth:dE,acsc:gE,acsch:yE,asec:xE,asech:bE,asin:wE,asinh:NE,atan:ME,atanh:SE,atan2:AE,cos:EE,cosh:CE,cot:OE,coth:DE,csc:TE,csch:BE,sec:_E,sech:$E,sin:IE,sinh:qE,tan:RE,tanh:FE,to:zE,clone:UE,format:LE,bin:PE,oct:KE,hex:HE,isNaN:VE,isInteger:GE,isNegative:ZE,isNumeric:XE,hasNumericValue:kE,isPositive:YE,isPrime:WE,isZero:JE,print:jE,typeOf:eC,numeric:QE},yl="help",tC=["typed","mathWithTransform","Help"],nC=R(yl,tC,e=>{var{typed:n,mathWithTransform:a,Help:t}=e;return n(yl,{any:function(i){var l,m=i;if(typeof i!="string"){for(l in a)if(Me(a,l)&&i===a[l]){m=l;break}}var f=Vr(rC,m);if(!f){var c=typeof m=="function"?m.name:m;throw new Error('No documentation found on "'+c+'"')}return new t(f)}})}),xl="chain",aC=["typed","Chain"],iC=R(xl,aC,e=>{var{typed:n,Chain:a}=e;return n(xl,{"":function(){return new a},any:function(r){return new a(r)}})}),bl="det",oC=["typed","matrix","subtract","multiply","divideScalar","isZero","unaryMinus"],sC=R(bl,oC,e=>{var{typed:n,matrix:a,subtract:t,multiply:r,divideScalar:i,isZero:l,unaryMinus:m}=e;return n(bl,{any:function(s){return Ce(s)},"Array | Matrix":function(s){var o;switch(Oe(s)?o=s.size():Array.isArray(s)?(s=a(s),o=s.size()):o=[],o.length){case 0:return Ce(s);case 1:if(o[0]===1)return Ce(s.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+Re(o)+")");case 2:{var u=o[0],p=o[1];if(u===p)return f(s.clone().valueOf(),u);throw new RangeError("Matrix must be square (size: "+Re(o)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Re(o)+")")}}});function f(c,s,o){if(s===1)return Ce(c[0][0]);if(s===2)return t(r(c[0][0],c[1][1]),r(c[1][0],c[0][1]));for(var u=!1,p=new Array(s).fill(0).map((A,S)=>S),v=0;v<s;v++){var h=p[v];if(l(c[h][v])){var b=void 0;for(b=v+1;b<s;b++)if(!l(c[p[b]][v])){h=p[b],p[b]=p[v],p[v]=h,u=!u;break}if(b===s)return c[h][v]}for(var w=c[h][v],N=v===0?1:c[p[v-1]][v-1],g=v+1;g<s;g++)for(var y=p[g],x=v+1;x<s;x++)c[y][x]=i(t(r(c[y][x],w),r(c[y][v],c[h][x])),N)}var d=c[p[s-1]][s-1];return u?m(d):d}}),wl="inv",uC=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],cC=R(wl,uC,e=>{var{typed:n,matrix:a,divideScalar:t,addScalar:r,multiply:i,unaryMinus:l,det:m,identity:f,abs:c}=e;return n(wl,{"Array | Matrix":function(u){var p=Oe(u)?u.size():Pe(u);switch(p.length){case 1:if(p[0]===1)return Oe(u)?a([t(1,u.valueOf()[0])]):[t(1,u[0])];throw new RangeError("Matrix must be square (size: "+Re(p)+")");case 2:{var v=p[0],h=p[1];if(v===h)return Oe(u)?a(s(u.valueOf(),v,h),u.storage()):s(u,v,h);throw new RangeError("Matrix must be square (size: "+Re(p)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Re(p)+")")}},any:function(u){return t(1,u)}});function s(o,u,p){var v,h,b,w,N;if(u===1){if(w=o[0][0],w===0)throw Error("Cannot calculate inverse, determinant is zero");return[[t(1,w)]]}else if(u===2){var g=m(o);if(g===0)throw Error("Cannot calculate inverse, determinant is zero");return[[t(o[1][1],g),t(l(o[0][1]),g)],[t(l(o[1][0]),g),t(o[0][0],g)]]}else{var y=o.concat();for(v=0;v<u;v++)y[v]=y[v].concat();for(var x=f(u).valueOf(),d=0;d<p;d++){var A=c(y[d][d]),S=d;for(v=d+1;v<u;)c(y[v][d])>A&&(A=c(y[v][d]),S=v),v++;if(A===0)throw Error("Cannot calculate inverse, determinant is zero");v=S,v!==d&&(N=y[d],y[d]=y[v],y[v]=N,N=x[d],x[d]=x[v],x[v]=N);var O=y[d],M=x[d];for(v=0;v<u;v++){var _=y[v],E=x[v];if(v!==d){if(_[d]!==0){for(b=t(l(_[d]),O[d]),h=d;h<p;h++)_[h]=r(_[h],i(b,O[h]));for(h=0;h<p;h++)E[h]=r(E[h],i(b,M[h]))}}else{for(b=O[d],h=d;h<p;h++)_[h]=t(_[h],b);for(h=0;h<p;h++)E[h]=t(E[h],b)}}}return x}}}),Nl="pinv",fC=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],lC=R(Nl,fC,e=>{var{typed:n,matrix:a,inv:t,deepEqual:r,equal:i,dotDivide:l,dot:m,ctranspose:f,divideScalar:c,multiply:s,add:o,Complex:u}=e;return n(Nl,{"Array | Matrix":function(g){var y=Oe(g)?g.size():Pe(g);switch(y.length){case 1:return w(g)?f(g):y[0]===1?t(g):l(f(g),m(g,g));case 2:{if(w(g))return f(g);var x=y[0],d=y[1];if(x===d)try{return t(g)}catch(A){if(!(A instanceof Error&&A.message.match(/Cannot calculate inverse, determinant is zero/)))throw A}return Oe(g)?a(p(g.valueOf(),x,d),g.storage()):p(g,x,d)}default:throw new RangeError("Matrix must be two dimensional (size: "+Re(y)+")")}},any:function(g){return i(g,0)?Ce(g):c(1,g)}});function p(N,g,y){var{C:x,F:d}=h(N,g,y),A=s(t(s(f(x),x)),f(x)),S=s(f(d),t(s(d,f(d))));return s(S,A)}function v(N,g,y){for(var x=Ce(N),d=0,A=0;A<g;A++){if(y<=d)return x;for(var S=A;b(x[S][d]);)if(S++,g===S&&(S=A,d++,y===d))return x;[x[S],x[A]]=[x[A],x[S]];for(var O=x[A][d],M=0;M<y;M++)x[A][M]=l(x[A][M],O);for(var _=0;_<g;_++)if(_!==A){O=x[_][d];for(var E=0;E<y;E++)x[_][E]=o(x[_][E],s(-1,s(O,x[A][E])))}d++}return x}function h(N,g,y){var x=v(N,g,y),d=N.map((S,O)=>S.filter((M,_)=>_<g&&!b(m(x[_],x[_])))),A=x.filter((S,O)=>!b(m(x[O],x[O])));return{C:d,F:A}}function b(N){return i(o(N,u(1,1)),o(0,u(1,1)))}function w(N){return r(o(N,u(1,1)),o(s(N,0),u(1,1)))}});function mC(e){var{addScalar:n,subtract:a,flatten:t,multiply:r,multiplyScalar:i,divideScalar:l,sqrt:m,abs:f,bignumber:c,diag:s,inv:o,qr:u,usolve:p,usolveAll:v,equal:h,complex:b,larger:w,smaller:N,matrixFromColumns:g,dot:y}=e;function x(H,W,j,V,K){K===void 0&&(K=!0);var te=d(H,W,j,V,K);A(H,W,j,V,K,te);var{values:re,C:ie}=S(H,W,j,V,K),ne;return K&&(ne=O(H,W,ie,te,re,j,V),ne=g(...ne)),{values:re,vectors:ne}}function d(H,W,j,V,K){var te=V==="BigNumber",re=V==="Complex",ie=te?c(0):0,ne=te?c(1):re?b(1):1,ue=te?c(1):1,ee=te?c(10):2,ye=i(ee,ee),we;K&&(we=Array(W).fill(ne));for(var me=!1;!me;){me=!0;for(var xe=0;xe<W;xe++){for(var F=ie,Y=ie,k=0;k<W;k++)if(xe!==k){var U=f(H[xe][k]);F=n(F,U),Y=n(Y,U)}if(!h(F,0)&&!h(Y,0)){for(var J=ue,q=F,P=l(Y,ee),Q=i(Y,ee);N(q,P);)q=i(q,ye),J=i(J,ee);for(;w(q,Q);)q=l(q,ye),J=l(J,ee);var L=N(l(n(q,Y),J),i(n(F,Y),.95));if(L){me=!1;for(var se=l(1,J),fe=0;fe<W;fe++)xe!==fe&&(H[xe][fe]=i(H[xe][fe],J),H[fe][xe]=i(H[fe][xe],se));K&&(we[xe]=i(we[xe],J))}}}}return s(we)}function A(H,W,j,V,K,te){var re=V==="BigNumber",ie=V==="Complex",ne=re?c(0):ie?b(0):0;re&&(j=c(j));for(var ue=0;ue<W-2;ue++){for(var ee=0,ye=ne,we=ue+1;we<W;we++){var me=H[we][ue];N(f(ye),f(me))&&(ye=me,ee=we)}if(!N(f(ye),j)){if(ee!==ue+1){var xe=H[ee];H[ee]=H[ue+1],H[ue+1]=xe;for(var F=0;F<W;F++){var Y=H[F][ee];H[F][ee]=H[F][ue+1],H[F][ue+1]=Y}if(K){var k=te[ee];te[ee]=te[ue+1],te[ue+1]=k}}for(var U=ue+2;U<W;U++){var J=l(H[U][ue],ye);if(J!==0){for(var q=0;q<W;q++)H[U][q]=a(H[U][q],i(J,H[ue+1][q]));for(var P=0;P<W;P++)H[P][ue+1]=n(H[P][ue+1],i(J,H[P][U]));if(K)for(var Q=0;Q<W;Q++)te[U][Q]=a(te[U][Q],i(J,te[ue+1][Q]))}}}}return te}function S(H,W,j,V,K){var te=V==="BigNumber",re=V==="Complex",ie=te?c(1):re?b(1):1;te&&(j=c(j));for(var ne=Ce(H),ue=[],ee=W,ye=[],we=K?s(Array(W).fill(ie)):void 0,me=K?s(Array(ee).fill(ie)):void 0,xe=0;xe<=100;){xe+=1;for(var F=0,Y=0;Y<ee;Y++)ne[Y][Y]=a(ne[Y][Y],F);var{Q:k,R:U}=u(ne);ne=r(U,k);for(var J=0;J<ee;J++)ne[J][J]=n(ne[J][J],F);if(K&&(me=r(me,k)),ee===1||N(f(ne[ee-1][ee-2]),j)){xe=0,ue.push(ne[ee-1][ee-1]),K&&(ye.unshift([[1]]),E(me,W),we=r(we,me),ee>1&&(me=s(Array(ee-1).fill(ie)))),ee-=1,ne.pop();for(var q=0;q<ee;q++)ne[q].pop()}else if(ee===2||N(f(ne[ee-2][ee-3]),j)){xe=0;var P=M(ne[ee-2][ee-2],ne[ee-2][ee-1],ne[ee-1][ee-2],ne[ee-1][ee-1]);ue.push(...P),K&&(ye.unshift(_(ne[ee-2][ee-2],ne[ee-2][ee-1],ne[ee-1][ee-2],ne[ee-1][ee-1],P[0],P[1],j,V)),E(me,W),we=r(we,me),ee>2&&(me=s(Array(ee-2).fill(ie)))),ee-=2,ne.pop(),ne.pop();for(var Q=0;Q<ee;Q++)ne[Q].pop(),ne[Q].pop()}if(ee===0)break}if(ue.sort((fe,ge)=>+a(f(fe),f(ge))),xe>100){var L=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+ue.join(", "));throw L.values=ue,L.vectors=[],L}var se=K?r(we,$(ye,W)):void 0;return{values:ue,C:se}}function O(H,W,j,V,K,te,re){var ie=o(j),ne=r(ie,H,j),ue=re==="BigNumber",ee=re==="Complex",ye=ue?c(0):ee?b(0):0,we=ue?c(1):ee?b(1):1,me=[],xe=[];for(var F of K){var Y=z(me,F,h);Y===-1?(me.push(F),xe.push(1)):xe[Y]+=1}for(var k=[],U=me.length,J=Array(W).fill(ye),q=s(Array(W).fill(we)),P=[],Q=function(ge){var pe=me[ge],ve=a(ne,r(pe,q)),Ne=v(ve,J);for(Ne.shift();Ne.length<xe[ge];){var Qe=I(ve,W,Ne,te,re);if(Qe==null){P.push(pe);break}Ne.push(Qe)}var cr=r(o(V),j);Ne=Ne.map(tr=>r(cr,tr)),k.push(...Ne.map(tr=>t(tr)))},L=0;L<U;L++)Q(L);if(P.length!==0){var se=new Error("Failed to find eigenvectors for the following eigenvalues: "+P.join(", "));throw se.values=K,se.vectors=k,se}return k}function M(H,W,j,V){var K=n(H,V),te=a(i(H,V),i(W,j)),re=i(K,.5),ie=i(m(a(i(K,K),i(4,te))),.5);return[n(re,ie),a(re,ie)]}function _(H,W,j,V,K,te,re,ie){var ne=ie==="BigNumber",ue=ie==="Complex",ee=ne?c(0):ue?b(0):0,ye=ne?c(1):ue?b(1):1;if(N(f(j),re))return[[ye,ee],[ee,ye]];if(w(f(a(K,te)),re))return[[a(K,V),a(te,V)],[j,j]];var we=a(H,K),me=a(W,K),xe=a(j,K),F=a(V,K);return N(f(me),re)?[[we,ye],[xe,ee]]:[[me,ee],[F,ye]]}function E(H,W){for(var j=0;j<H.length;j++)H[j].push(...Array(W-H[j].length).fill(0));for(var V=H.length;V<W;V++)H.push(Array(W).fill(0)),H[V][V]=1;return H}function $(H,W){for(var j=[],V=0;V<W;V++)j[V]=Array(W).fill(0);var K=0;for(var te of H){for(var re=te.length,ie=0;ie<re;ie++)for(var ne=0;ne<re;ne++)j[K+ie][K+ne]=te[ie][ne];K+=re}return j}function z(H,W,j){for(var V=0;V<H.length;V++)if(j(H[V],W))return V;return-1}function I(H,W,j,V,K){for(var te=K==="BigNumber"?c(1e3):1e3,re,ie=0;re=T(W,j,K),re=p(H,re),!w(G(re),te);)if(++ie>=5)return null;for(ie=0;;){var ne=p(H,re);if(N(G(B(re,[ne])),V))break;if(++ie>=10)return null;re=D(ne)}return re}function T(H,W,j){var V=j==="BigNumber",K=j==="Complex",te=Array(H).fill(0).map(re=>2*Math.random()-1);return V&&(te=te.map(re=>c(re))),K&&(te=te.map(re=>b(re))),te=B(te,W),D(te,j)}function B(H,W){for(var j of W)H=a(H,r(l(y(j,H),y(j,j)),j));return H}function G(H){return f(m(y(H,H)))}function D(H,W){var j=W==="BigNumber",V=W==="Complex",K=j?c(1):V?b(1):1;return r(l(K,G(H)),H)}return x}function pC(e){var{config:n,addScalar:a,subtract:t,abs:r,atan:i,cos:l,sin:m,multiplyScalar:f,inv:c,bignumber:s,multiply:o,add:u}=e;function p(M,_){var E=arguments.length>2&&arguments[2]!==void 0?arguments[2]:n.epsilon,$=arguments.length>3?arguments[3]:void 0;if($==="number")return v(M,E);if($==="BigNumber")return h(M,E);throw TypeError("Unsupported data type: "+$)}function v(M,_){for(var E=M.length,$=Math.abs(_/E),z,I=new Array(E),T=0;T<E;T++)I[T]=O(E,0),I[T][T]=1;for(var B=d(M);Math.abs(B[1])>=Math.abs($);){var G=B[0][0],D=B[0][1];z=b(M[G][G],M[D][D],M[G][D]),M=x(M,z,G,D),I=N(I,z,G,D),B=d(M)}for(var H=O(E,0),W=0;W<E;W++)H[W]=M[W][W];return S(Ce(H),Ce(I))}function h(M,_){for(var E=M.length,$=r(_/E),z,I=new Array(E),T=0;T<E;T++)I[T]=O(E,0),I[T][T]=1;for(var B=A(M);r(B[1])>=r($);){var G=B[0][0],D=B[0][1];z=w(M[G][G],M[D][D],M[G][D]),M=y(M,z,G,D),I=g(I,z,G,D),B=A(M)}for(var H=O(E,0),W=0;W<E;W++)H[W]=M[W][W];return S(Ce(H),Ce(I))}function b(M,_,E){var $=_-M;return Math.abs($)<=n.epsilon?Math.PI/4:.5*Math.atan(2*E/(_-M))}function w(M,_,E){var $=t(_,M);return r($)<=n.epsilon?s(-1).acos().div(4):f(.5,i(o(2,E,c($))))}function N(M,_,E,$){for(var z=M.length,I=Math.cos(_),T=Math.sin(_),B=O(z,0),G=O(z,0),D=0;D<z;D++)B[D]=I*M[D][E]-T*M[D][$],G[D]=T*M[D][E]+I*M[D][$];for(var H=0;H<z;H++)M[H][E]=B[H],M[H][$]=G[H];return M}function g(M,_,E,$){for(var z=M.length,I=l(_),T=m(_),B=O(z,s(0)),G=O(z,s(0)),D=0;D<z;D++)B[D]=t(f(I,M[D][E]),f(T,M[D][$])),G[D]=a(f(T,M[D][E]),f(I,M[D][$]));for(var H=0;H<z;H++)M[H][E]=B[H],M[H][$]=G[H];return M}function y(M,_,E,$){for(var z=M.length,I=s(l(_)),T=s(m(_)),B=f(I,I),G=f(T,T),D=O(z,s(0)),H=O(z,s(0)),W=o(s(2),I,T,M[E][$]),j=a(t(f(B,M[E][E]),W),f(G,M[$][$])),V=u(f(G,M[E][E]),W,f(B,M[$][$])),K=0;K<z;K++)D[K]=t(f(I,M[E][K]),f(T,M[$][K])),H[K]=a(f(T,M[E][K]),f(I,M[$][K]));M[E][E]=j,M[$][$]=V,M[E][$]=s(0),M[$][E]=s(0);for(var te=0;te<z;te++)te!==E&&te!==$&&(M[E][te]=D[te],M[te][E]=D[te],M[$][te]=H[te],M[te][$]=H[te]);return M}function x(M,_,E,$){for(var z=M.length,I=Math.cos(_),T=Math.sin(_),B=I*I,G=T*T,D=O(z,0),H=O(z,0),W=B*M[E][E]-2*I*T*M[E][$]+G*M[$][$],j=G*M[E][E]+2*I*T*M[E][$]+B*M[$][$],V=0;V<z;V++)D[V]=I*M[E][V]-T*M[$][V],H[V]=T*M[E][V]+I*M[$][V];M[E][E]=W,M[$][$]=j,M[E][$]=0,M[$][E]=0;for(var K=0;K<z;K++)K!==E&&K!==$&&(M[E][K]=D[K],M[K][E]=D[K],M[$][K]=H[K],M[K][$]=H[K]);return M}function d(M){for(var _=M.length,E=0,$=[0,1],z=0;z<_;z++)for(var I=z+1;I<_;I++)Math.abs(E)<Math.abs(M[z][I])&&(E=Math.abs(M[z][I]),$=[z,I]);return[$,E]}function A(M){for(var _=M.length,E=0,$=[0,1],z=0;z<_;z++)for(var I=z+1;I<_;I++)r(E)<r(M[z][I])&&(E=r(M[z][I]),$=[z,I]);return[$,E]}function S(M,_){for(var E=M.length,$=Array(E),z=Array(E),I=0;I<E;I++)z[I]=Array(E);for(var T=0;T<E;T++){for(var B=0,G=M[0],D=0;D<M.length;D++)r(M[D])<r(G)&&(B=D,G=M[B]);$[T]=M.splice(B,1)[0];for(var H=0;H<E;H++)z[H][T]=_[H][B],_[H].splice(B,1)}return{values:$,vectors:z}}function O(M,_){for(var E=new Array(M),$=0;$<M;$++)E[$]=_;return E}return p}var vC="eigs",hC=["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"],dC=R(vC,hC,e=>{var{config:n,typed:a,matrix:t,addScalar:r,subtract:i,equal:l,abs:m,atan:f,cos:c,sin:s,multiplyScalar:o,divideScalar:u,inv:p,bignumber:v,multiply:h,add:b,larger:w,column:N,flatten:g,number:y,complex:x,sqrt:d,diag:A,qr:S,usolve:O,usolveAll:M,im:_,re:E,smaller:$,matrixFromColumns:z,dot:I}=e,T=pC({config:n,addScalar:r,subtract:i,abs:m,atan:f,cos:c,sin:s,multiplyScalar:o,inv:p,bignumber:v,multiply:h,add:b}),B=mC({addScalar:r,subtract:i,multiply:h,multiplyScalar:o,flatten:g,divideScalar:u,sqrt:d,abs:m,bignumber:v,diag:A,qr:S,inv:p,usolve:O,usolveAll:M,equal:l,complex:x,larger:w,smaller:$,matrixFromColumns:z,dot:I});return a("eigs",{Array:function(K){var te=t(K);return G(te)},"Array, number|BigNumber":function(K,te){var re=t(K);return G(re,te)},Matrix:function(K){var{values:te,vectors:re}=G(K);return{values:t(te),vectors:t(re)}},"Matrix, number|BigNumber":function(K,te){var{values:re,vectors:ie}=G(K,te);return{values:t(re),vectors:t(ie)}}});function G(V,K){K===void 0&&(K=n.epsilon);var te=V.size();if(te.length!==2||te[0]!==te[1])throw new RangeError("Matrix must be square (size: "+Re(te)+")");var re=V.toArray(),ie=te[0];if(H(re,ie,K)&&(W(re,ie),D(re,ie,K))){var ne=j(V,re,ie);return T(re,ie,K,ne)}var ue=j(V,re,ie);return B(re,ie,K,ue)}function D(V,K,te){for(var re=0;re<K;re++)for(var ie=re;ie<K;ie++)if(w(v(m(i(V[re][ie],V[ie][re]))),te))return!1;return!0}function H(V,K,te){for(var re=0;re<K;re++)for(var ie=0;ie<K;ie++)if(w(v(m(_(V[re][ie]))),te))return!1;return!0}function W(V,K){for(var te=0;te<K;te++)for(var re=0;re<K;re++)V[te][re]=E(V[te][re])}function j(V,K,te){var re=V.datatype();if(re==="number"||re==="BigNumber"||re==="Complex")return re;for(var ie=!1,ne=!1,ue=!1,ee=0;ee<te;ee++)for(var ye=0;ye<te;ye++){var we=K[ee][ye];if(Be(we)||yr(we))ie=!0;else if(_e(we))ne=!0;else if(Or(we))ue=!0;else throw TypeError("Unsupported type in Matrix: "+Ke(we))}if(ne&&ue&&console.warn("Complex BigNumbers not supported, this operation will lose precission."),ue){for(var me=0;me<te;me++)for(var xe=0;xe<te;xe++)K[me][xe]=x(K[me][xe]);return"Complex"}if(ne){for(var F=0;F<te;F++)for(var Y=0;Y<te;Y++)K[F][Y]=v(K[F][Y]);return"BigNumber"}if(ie){for(var k=0;k<te;k++)for(var U=0;U<te;U++)K[k][U]=y(K[k][U]);return"number"}else throw TypeError("Matrix contains unsupported types only.")}}),Ml="expm",gC=["typed","abs","add","identity","inv","multiply"],yC=R(Ml,gC,e=>{var{typed:n,abs:a,add:t,identity:r,inv:i,multiply:l}=e;return n(Ml,{Matrix:function(o){var u=o.size();if(u.length!==2||u[0]!==u[1])throw new RangeError("Matrix must be square (size: "+Re(u)+")");for(var p=u[0],v=1e-15,h=m(o),b=f(h,v),w=b.q,N=b.j,g=l(o,Math.pow(2,-N)),y=r(p),x=r(p),d=1,A=g,S=-1,O=1;O<=w;O++)O>1&&(A=l(A,g),S=-S),d=d*(w-O+1)/((2*w-O+1)*O),y=t(y,l(d,A)),x=t(x,l(d*S,A));for(var M=l(i(x),y),_=0;_<N;_++)M=l(M,M);return Ut(o)?o.createSparseMatrix(M):M}});function m(s){for(var o=s.size()[0],u=0,p=0;p<o;p++){for(var v=0,h=0;h<o;h++)v+=a(s.get([p,h]));u=Math.max(v,u)}return u}function f(s,o){for(var u=30,p=0;p<u;p++)for(var v=0;v<=p;v++){var h=p-v;if(c(s,v,h)<o)return{q:v,j:h}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}function c(s,o,u){for(var p=1,v=2;v<=o;v++)p*=v;for(var h=p,b=o+1;b<=2*o;b++)h*=b;var w=h*(2*o+1);return 8*Math.pow(s/Math.pow(2,u),2*o)*p*p/(h*w)}}),Al="sqrtm",xC=["typed","abs","add","multiply","sqrt","subtract","inv","size","max","identity"],bC=R(Al,xC,e=>{var{typed:n,abs:a,add:t,multiply:r,sqrt:i,subtract:l,inv:m,size:f,max:c,identity:s}=e,o=1e3,u=1e-6;function p(v){var h,b=0,w=v,N=s(f(v));do{var g=w;if(w=r(.5,t(g,m(N))),N=r(.5,t(N,m(g))),h=c(a(l(w,g))),h>u&&++b>o)throw new Error("computing square root of matrix: iterative method could not converge")}while(h>u);return w}return n(Al,{"Array | Matrix":function(h){var b=Oe(h)?h.size():Pe(h);switch(b.length){case 1:if(b[0]===1)return i(h);throw new RangeError("Matrix must be square (size: "+Re(b)+")");case 2:{var w=b[0],N=b[1];if(w===N)return p(h);throw new RangeError("Matrix must be square (size: "+Re(b)+")")}default:throw new RangeError("Matrix must be at most two dimensional (size: "+Re(b)+")")}}})}),wC="divide",NC=["typed","matrix","multiply","equalScalar","divideScalar","inv"],MC=R(wC,NC,e=>{var{typed:n,matrix:a,multiply:t,equalScalar:r,divideScalar:i,inv:l}=e,m=wr({typed:n,equalScalar:r}),f=Ge({typed:n});return n("divide",Ka({"Array | Matrix, Array | Matrix":function(s,o){return t(s,l(o))},"DenseMatrix, any":function(s,o){return f(s,o,i,!1)},"SparseMatrix, any":function(s,o){return m(s,o,i,!1)},"Array, any":function(s,o){return f(a(s),o,i,!1).valueOf()},"any, Array | Matrix":function(s,o){return t(s,l(o))}},i.signatures))}),Sl="distance",AC=["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],SC=R(Sl,AC,e=>{var{typed:n,addScalar:a,subtract:t,multiplyScalar:r,divideScalar:i,unaryMinus:l,sqrt:m,abs:f}=e;return n(Sl,{"Array, Array, Array":function(x,d,A){if(x.length===2&&d.length===2&&A.length===2){if(!s(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!s(d))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!s(A))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var S=i(t(A[1],A[0]),t(d[1],d[0])),O=r(r(S,S),d[0]),M=l(r(S,d[0])),_=x[1];return b(x[0],x[1],O,M,_)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(x,d,A){if(Object.keys(x).length===2&&Object.keys(d).length===2&&Object.keys(A).length===2){if(!s(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!s(d))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!s(A))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"lineOnePtX"in d&&"lineOnePtY"in d&&"lineTwoPtX"in A&&"lineTwoPtY"in A){var S=i(t(A.lineTwoPtY,A.lineTwoPtX),t(d.lineOnePtY,d.lineOnePtX)),O=r(r(S,S),d.lineOnePtX),M=l(r(S,d.lineOnePtX)),_=x.pointX;return b(x.pointX,x.pointY,O,M,_)}else throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(x,d){if(x.length===2&&d.length===3){if(!s(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!o(d))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return b(x[0],x[1],d[0],d[1],d[2])}else if(x.length===3&&d.length===6){if(!o(x))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!p(d))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return w(x[0],x[1],x[2],d[0],d[1],d[2],d[3],d[4],d[5])}else if(x.length===d.length&&x.length>0){if(!u(x))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!u(d))throw new TypeError("All values of an array should be numbers or BigNumbers");return N(x,d)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(x,d){if(Object.keys(x).length===2&&Object.keys(d).length===3){if(!s(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!o(d))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"xCoeffLine"in d&&"yCoeffLine"in d&&"constant"in d)return b(x.pointX,x.pointY,d.xCoeffLine,d.yCoeffLine,d.constant);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===3&&Object.keys(d).length===6){if(!o(x))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!p(d))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"x0"in d&&"y0"in d&&"z0"in d&&"a"in d&&"b"in d&&"c"in d)return w(x.pointX,x.pointY,x.pointZ,d.x0,d.y0,d.z0,d.a,d.b,d.c);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===2&&Object.keys(d).length===2){if(!s(x))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!s(d))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in x&&"pointOneY"in x&&"pointTwoX"in d&&"pointTwoY"in d)return N([x.pointOneX,x.pointOneY],[d.pointTwoX,d.pointTwoY]);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===3&&Object.keys(d).length===3){if(!o(x))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!o(d))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in x&&"pointOneY"in x&&"pointOneZ"in x&&"pointTwoX"in d&&"pointTwoY"in d&&"pointTwoZ"in d)return N([x.pointOneX,x.pointOneY,x.pointOneZ],[d.pointTwoX,d.pointTwoY,d.pointTwoZ]);throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},Array:function(x){if(!h(x))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return g(x)}});function c(y){return typeof y=="number"||_e(y)}function s(y){return y.constructor!==Array&&(y=v(y)),c(y[0])&&c(y[1])}function o(y){return y.constructor!==Array&&(y=v(y)),c(y[0])&&c(y[1])&&c(y[2])}function u(y){return Array.isArray(y)||(y=v(y)),y.every(c)}function p(y){return y.constructor!==Array&&(y=v(y)),c(y[0])&&c(y[1])&&c(y[2])&&c(y[3])&&c(y[4])&&c(y[5])}function v(y){for(var x=Object.keys(y),d=[],A=0;A<x.length;A++)d.push(y[x[A]]);return d}function h(y){if(y[0].length===2&&c(y[0][0])&&c(y[0][1])){if(y.some(x=>x.length!==2||!c(x[0])||!c(x[1])))return!1}else if(y[0].length===3&&c(y[0][0])&&c(y[0][1])&&c(y[0][2])){if(y.some(x=>x.length!==3||!c(x[0])||!c(x[1])||!c(x[2])))return!1}else return!1;return!0}function b(y,x,d,A,S){var O=f(a(a(r(d,y),r(A,x)),S)),M=m(a(r(d,d),r(A,A)));return i(O,M)}function w(y,x,d,A,S,O,M,_,E){var $=[t(r(t(S,x),E),r(t(O,d),_)),t(r(t(O,d),M),r(t(A,y),E)),t(r(t(A,y),_),r(t(S,x),M))];$=m(a(a(r($[0],$[0]),r($[1],$[1])),r($[2],$[2])));var z=m(a(a(r(M,M),r(_,_)),r(E,E)));return i($,z)}function N(y,x){for(var d=y.length,A=0,S=0,O=0;O<d;O++)S=t(y[O],x[O]),A=a(r(S,S),A);return m(A)}function g(y){for(var x=[],d=[],A=[],S=0;S<y.length-1;S++)for(var O=S+1;O<y.length;O++)y[0].length===2?(d=[y[S][0],y[S][1]],A=[y[O][0],y[O][1]]):y[0].length===3&&(d=[y[S][0],y[S][1],y[S][2]],A=[y[O][0],y[O][1],y[O][2]]),x.push(N(d,A));return x}}),EC="intersect",CC=["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],OC=R(EC,CC,e=>{var{typed:n,config:a,abs:t,add:r,addScalar:i,matrix:l,multiply:m,multiplyScalar:f,divideScalar:c,subtract:s,smaller:o,equalScalar:u,flatten:p,isZero:v,isNumeric:h}=e;return n("intersect",{"Array, Array, Array":b,"Array, Array, Array, Array":w,"Matrix, Matrix, Matrix":function(_,E,$){var z=b(_.valueOf(),E.valueOf(),$.valueOf());return z===null?null:l(z)},"Matrix, Matrix, Matrix, Matrix":function(_,E,$,z){var I=w(_.valueOf(),E.valueOf(),$.valueOf(),z.valueOf());return I===null?null:l(I)}});function b(M,_,E){if(M=N(M),_=N(_),E=N(E),!y(M))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!y(_))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!x(E))throw new TypeError("Array with 4 numbers expected as third argument");return O(M[0],M[1],M[2],_[0],_[1],_[2],E[0],E[1],E[2],E[3])}function w(M,_,E,$){if(M=N(M),_=N(_),E=N(E),$=N($),M.length===2){if(!g(M))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!g(_))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!g(E))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!g($))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return d(M,_,E,$)}else if(M.length===3){if(!y(M))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!y(_))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!y(E))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!y($))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return S(M[0],M[1],M[2],_[0],_[1],_[2],E[0],E[1],E[2],$[0],$[1],$[2])}else throw new TypeError("Arrays with two or thee dimensional points expected")}function N(M){return M.length===1?M[0]:M.length>1&&Array.isArray(M[0])&&M.every(_=>Array.isArray(_)&&_.length===1)?p(M):M}function g(M){return M.length===2&&h(M[0])&&h(M[1])}function y(M){return M.length===3&&h(M[0])&&h(M[1])&&h(M[2])}function x(M){return M.length===4&&h(M[0])&&h(M[1])&&h(M[2])&&h(M[3])}function d(M,_,E,$){var z=M,I=E,T=s(z,_),B=s(I,$),G=s(f(T[0],B[1]),f(B[0],T[1]));if(v(G)||o(t(G),a.epsilon))return null;var D=f(B[0],z[1]),H=f(B[1],z[0]),W=f(B[0],I[1]),j=f(B[1],I[0]),V=c(i(s(s(D,H),W),j),G);return r(m(T,V),z)}function A(M,_,E,$,z,I,T,B,G,D,H,W){var j=f(s(M,_),s(E,$)),V=f(s(z,I),s(T,B)),K=f(s(G,D),s(H,W));return i(i(j,V),K)}function S(M,_,E,$,z,I,T,B,G,D,H,W){var j=A(M,T,D,T,_,B,H,B,E,G,W,G),V=A(D,T,$,M,H,B,z,_,W,G,I,E),K=A(M,T,$,M,_,B,z,_,E,G,I,E),te=A(D,T,D,T,H,B,H,B,W,G,W,G),re=A($,M,$,M,z,_,z,_,I,E,I,E),ie=s(f(j,V),f(K,te)),ne=s(f(re,te),f(V,V));if(v(ne))return null;var ue=c(ie,ne),ee=c(i(j,f(ue,V)),te),ye=i(M,f(ue,s($,M))),we=i(_,f(ue,s(z,_))),me=i(E,f(ue,s(I,E))),xe=i(T,f(ee,s(D,T))),F=i(B,f(ee,s(H,B))),Y=i(G,f(ee,s(W,G)));return u(ye,xe)&&u(we,F)&&u(me,Y)?[ye,we,me]:null}function O(M,_,E,$,z,I,T,B,G,D){var H=f(M,T),W=f($,T),j=f(_,B),V=f(z,B),K=f(E,G),te=f(I,G),re=s(s(s(D,H),j),K),ie=s(s(s(i(i(W,V),te),H),j),K),ne=c(re,ie),ue=i(M,f(ne,s($,M))),ee=i(_,f(ne,s(z,_))),ye=i(E,f(ne,s(I,E)));return[ue,ee,ye]}}),El="sum",DC=["typed","config","add","numeric"],Cl=R(El,DC,e=>{var{typed:n,config:a,add:t,numeric:r}=e;return n(El,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":l,"...":function(f){if(mn(f))throw new TypeError("Scalar values expected in function sum");return i(f)}});function i(m){var f;return bt(m,function(c){try{f=f===void 0?c:t(f,c)}catch(s){throw Tr(s,"sum",c)}}),f===void 0&&(f=r(0,a.number)),typeof f=="string"&&(f=r(f,a.number)),f}function l(m,f){try{var c=xa(m,f,t);return c}catch(s){throw Tr(s,"sum")}}}),Ba="cumsum",TC=["typed","add","unaryPlus"],Ol=R(Ba,TC,e=>{var{typed:n,add:a,unaryPlus:t}=e;return n(Ba,{Array:r,Matrix:function(c){return c.create(r(c.valueOf()))},"Array, number | BigNumber":l,"Matrix, number | BigNumber":function(c,s){return c.create(l(c.valueOf(),s))},"...":function(c){if(mn(c))throw new TypeError("All values expected to be scalar in function cumsum");return r(c)}});function r(f){try{return i(f)}catch(c){throw Tr(c,Ba)}}function i(f){if(f.length===0)return[];for(var c=[t(f[0])],s=1;s<f.length;++s)c.push(a(c[s-1],f[s]));return c}function l(f,c){var s=Pe(f);if(c<0||c>=s.length)throw new Kr(c,s.length);try{return m(f,c)}catch(o){throw Tr(o,Ba)}}function m(f,c){var s,o,u;if(c<=0){var p=f[0][0];if(Array.isArray(p)){for(u=Ho(f),o=[],s=0;s<u.length;s++)o[s]=m(u[s],c-1);return o}else return i(f)}else{for(o=[],s=0;s<f.length;s++)o[s]=m(f[s],c-1);return o}}}),Dl="mean",BC=["typed","add","divide"],Tl=R(Dl,BC,e=>{var{typed:n,add:a,divide:t}=e;return n(Dl,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":r,"...":function(m){if(mn(m))throw new TypeError("Scalar values expected in function mean");return i(m)}});function r(l,m){try{var f=xa(l,m,a),c=Array.isArray(l)?Pe(l):l.size();return t(f,c[m])}catch(s){throw Tr(s,"mean")}}function i(l){var m,f=0;if(bt(l,function(c){try{m=m===void 0?c:a(m,c),f++}catch(s){throw Tr(s,"mean",c)}}),f===0)throw new Error("Cannot calculate the mean of an empty array");return t(m,f)}}),Bl="median",_C=["typed","add","divide","compare","partitionSelect"],$C=R(Bl,_C,e=>{var{typed:n,add:a,divide:t,compare:r,partitionSelect:i}=e;function l(c){try{c=Le(c.valueOf());var s=c.length;if(s===0)throw new Error("Cannot calculate median of an empty array");if(s%2===0){for(var o=s/2-1,u=i(c,o+1),p=c[o],v=0;v<o;++v)r(c[v],p)>0&&(p=c[v]);return f(p,u)}else{var h=i(c,(s-1)/2);return m(h)}}catch(b){throw Tr(b,"median")}}var m=n({"number | BigNumber | Complex | Unit":function(s){return s}}),f=n({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(s,o){return t(a(s,o),2)}});return n(Bl,{"Array | Matrix":l,"Array | Matrix, number | BigNumber":function(s,o){throw new Error("median(A, dim) is not yet supported")},"...":function(s){if(mn(s))throw new TypeError("Scalar values expected in function median");return l(s)}})}),_l="mad",IC=["typed","abs","map","median","subtract"],qC=R(_l,IC,e=>{var{typed:n,abs:a,map:t,median:r,subtract:i}=e;return n(_l,{"Array | Matrix":l,"...":function(f){return l(f)}});function l(m){if(m=Le(m.valueOf()),m.length===0)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var f=r(m);return r(t(m,function(c){return a(i(c,f))}))}catch(c){throw c instanceof TypeError&&c.message.indexOf("median")!==-1?new TypeError(c.message.replace("median","mad")):Tr(c,"mad")}}}),qi="unbiased",$l="variance",RC=["typed","add","subtract","multiply","divide","apply","isNaN"],Il=R($l,RC,e=>{var{typed:n,add:a,subtract:t,multiply:r,divide:i,apply:l,isNaN:m}=e;return n($l,{"Array | Matrix":function(o){return f(o,qi)},"Array | Matrix, string":f,"Array | Matrix, number | BigNumber":function(o,u){return c(o,u,qi)},"Array | Matrix, number | BigNumber, string":c,"...":function(o){return f(o,qi)}});function f(s,o){var u,p=0;if(s.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(bt(s,function(b){try{u=u===void 0?b:a(u,b),p++}catch(w){throw Tr(w,"variance",b)}}),p===0)throw new Error("Cannot calculate variance of an empty array");var v=i(u,p);if(u=void 0,bt(s,function(b){var w=t(b,v);u=u===void 0?r(w,w):a(u,r(w,w))}),m(u))return u;switch(o){case"uncorrected":return i(u,p);case"biased":return i(u,p+1);case"unbiased":{var h=_e(u)?u.mul(0):0;return p===1?h:i(u,p-1)}default:throw new Error('Unknown normalization "'+o+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function c(s,o,u){try{if(s.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return l(s,o,p=>f(p,u))}catch(p){throw Tr(p,"variance")}}}),FC="quantileSeq",zC=["typed","add","multiply","partitionSelect","compare"],PC=R(FC,zC,e=>{var{typed:n,add:a,multiply:t,partitionSelect:r,compare:i}=e;function l(c,s,o){var u,p,v;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(rn(c)){if(o=o||!1,typeof o=="boolean"){if(p=c.valueOf(),Be(s)){if(s<0)throw new Error("N/prob must be non-negative");if(s<=1)return m(p,s,o);if(s>1){if(!Ae(s))throw new Error("N must be a positive integer");var h=s+1;u=new Array(s);for(var b=0;b<s;)u[b]=m(p,++b/h,o);return u}}if(_e(s)){var w=s.constructor;if(s.isNegative())throw new Error("N/prob must be non-negative");if(v=new w(1),s.lte(v))return new w(m(p,s,o));if(s.gt(v)){if(!s.isInteger())throw new Error("N must be a positive integer");var N=s.toNumber();if(N>4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var g=new w(N+1);u=new Array(N);for(var y=0;y<N;)u[y]=new w(m(p,new w(++y).div(g),o));return u}}if(Array.isArray(s)){u=new Array(s.length);for(var x=0;x<u.length;++x){var d=s[x];if(Be(d)){if(d<0||d>1)throw new Error("Probability must be between 0 and 1, inclusive")}else if(_e(d)){if(v=new d.constructor(1),d.isNegative()||d.gt(v))throw new Error("Probability must be between 0 and 1, inclusive")}else throw new TypeError("Unexpected type of argument in function quantileSeq");u[x]=m(p,d,o)}return u}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}function m(c,s,o){var u=Le(c),p=u.length;if(p===0)throw new Error("Cannot calculate quantile of an empty sequence");if(Be(s)){var v=s*(p-1),h=v%1;if(h===0){var b=o?u[v]:r(u,v);return f(b),b}var w=Math.floor(v),N,g;if(o)N=u[w],g=u[w+1];else{g=r(u,w+1),N=u[w];for(var y=0;y<w;++y)i(u[y],N)>0&&(N=u[y])}return f(N),f(g),a(t(N,1-h),t(g,h))}var x=s.times(p-1);if(x.isInteger()){x=x.toNumber();var d=o?u[x]:r(u,x);return f(d),d}var A=x.floor(),S=x.minus(A),O=A.toNumber(),M,_;if(o)M=u[O],_=u[O+1];else{_=r(u,O+1),M=u[O];for(var E=0;E<O;++E)i(u[E],M)>0&&(M=u[E])}f(M),f(_);var $=new S.constructor(1);return a(t(M,$.minus(S)),t(_,S))}var f=n({"number | BigNumber | Unit":function(s){return s}});return l}),ql="std",UC=["typed","sqrt","variance"],Rl=R(ql,UC,e=>{var{typed:n,sqrt:a,variance:t}=e;return n(ql,{"Array | Matrix":r,"Array | Matrix, string":r,"Array | Matrix, number | BigNumber":r,"Array | Matrix, number | BigNumber, string":r,"...":function(l){return r(l)}});function r(i,l){if(i.length===0)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{return a(t.apply(null,arguments))}catch(m){throw m instanceof TypeError&&m.message.indexOf(" variance")!==-1?new TypeError(m.message.replace(" variance"," std")):m}}}),Fl="combinations",LC=["typed"],kC=R(Fl,LC,e=>{var{typed:n}=e;return n(Fl,{"number, number":gs,"BigNumber, BigNumber":function(t,r){var i=t.constructor,l,m,f=t.minus(r),c=new i(1);if(!zl(t)||!zl(r))throw new TypeError("Positive integer value expected in function combinations");if(r.gt(t))throw new TypeError("k must be less than n in function combinations");if(l=c,r.lt(f))for(m=c;m.lte(f);m=m.plus(c))l=l.times(r.plus(m)).dividedBy(m);else for(m=c;m.lte(r);m=m.plus(c))l=l.times(f.plus(m)).dividedBy(m);return l}})});function zl(e){return e.isInteger()&&e.gte(0)}var Pl="combinationsWithRep",HC=["typed"],GC=R(Pl,HC,e=>{var{typed:n}=e;return n(Pl,{"number, number":function(t,r){if(!Ae(t)||t<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!Ae(r)||r<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(t<1)throw new TypeError("k must be less than or equal to n + k - 1");if(r<t-1){var i=wt(t,t+r-1);return i/wt(1,r)}var l=wt(r+1,t+r-1);return l/wt(1,t-1)},"BigNumber, BigNumber":function(t,r){var i=t.constructor,l,m,f=new i(1),c=t.minus(f);if(!Ul(t)||!Ul(r))throw new TypeError("Positive integer value expected in function combinationsWithRep");if(t.lt(f))throw new TypeError("k must be less than or equal to n + k - 1 in function combinationsWithRep");if(l=f,r.lt(c))for(m=f;m.lte(c);m=m.plus(f))l=l.times(r.plus(m)).dividedBy(m);else for(m=f;m.lte(r);m=m.plus(f))l=l.times(c.plus(m)).dividedBy(m);return l}})});function Ul(e){return e.isInteger()&&e.gte(0)}var Ll="gamma",VC=["typed","config","multiplyScalar","pow","BigNumber","Complex"],ZC=R(Ll,VC,e=>{var{typed:n,config:a,multiplyScalar:t,pow:r,BigNumber:i,Complex:l}=e;return n(Ll,{number:yi,Complex:function(c){if(c.im===0)return this(c.re);if(c.re<.5){var s=new l(1-c.re,-c.im),o=new l(Math.PI*c.re,Math.PI*c.im);return new l(Math.PI).div(o.sin()).div(this(s))}c=new l(c.re-1,c.im);for(var u=new l(vn[0],0),p=1;p<vn.length;++p){var v=new l(vn[p],0);u=u.add(v.div(c.add(p)))}var h=new l(c.re+Ns+.5,c.im),b=Math.sqrt(2*Math.PI),w=h.pow(c.add(.5)),N=h.neg().exp();return u.mul(b).mul(w).mul(N)},BigNumber:function(c){if(c.isInteger())return c.isNegative()||c.isZero()?new i(1/0):m(c.minus(1));if(!c.isFinite())return new i(c.isNegative()?NaN:1/0);throw new Error("Integer BigNumber expected")},"Array | Matrix":function(c){return be(c,this)}});function m(f){if(f<8)return new i([1,1,2,6,24,120,720,5040][f]);var c=a.precision+(Math.log(f.toNumber())|0),s=i.clone({precision:c});if(f%2===1)return f.times(m(new i(f-1)));for(var o=f,u=new s(f),p=f.toNumber();o>2;)o-=2,p+=o,u=u.times(p);return new i(u.toPrecision(i.precision))}}),kl="lgamma",XC=["Complex","typed"],YC=R(kl,XC,e=>{var{Complex:n,typed:a}=e,t=7,r=7,i=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return a(kl,{number:wa,Complex:function(c){var s=6.283185307179586,o=1.1447298858494002,u=.1;if(c.isNaN())return new n(NaN,NaN);if(c.im===0)return new n(wa(c.re),0);if(c.re>=t||Math.abs(c.im)>=r)return l(c);if(c.re<=u){var p=nv(s,c.im)*Math.floor(.5*c.re+.25),v=c.mul(Math.PI).sin().log(),h=this(new n(1-c.re,-c.im));return new n(o,p).sub(v).sub(h)}else return c.im>=0?m(c):m(c.conjugate()).conjugate()},BigNumber:function(){throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function l(f){for(var c=f.sub(.5).mul(f.log()).sub(f).add(Ms),s=new n(1,0).div(f),o=s.div(f),u=i[0],p=i[1],v=2*o.re,h=o.re*o.re+o.im*o.im,b=2;b<8;b++){var w=p;p=-h*u+i[b],u=v*u+w}var N=s.mul(o.mul(u).add(p));return c.add(N)}function m(f){var c=0,s=0,o=f;for(f=f.add(1);f.re<=t;){o=o.mul(f);var u=o.im<0?1:0;u!==0&&s===0&&c++,s=u,f=f.add(1)}return l(f).sub(o.log()).sub(new n(0,c*2*Math.PI*1))}}),Hl="factorial",WC=["typed","gamma"],JC=R(Hl,WC,e=>{var{typed:n,gamma:a}=e;return n(Hl,{number:function(r){if(r<0)throw new Error("Value must be non-negative");return a(r+1)},BigNumber:function(r){if(r.isNegative())throw new Error("Value must be non-negative");return a(r.plus(1))},"Array | Matrix":function(r){return be(r,this)}})}),Gl="kldivergence",QC=["typed","matrix","divide","sum","multiply","dotDivide","log","isNumeric"],KC=R(Gl,QC,e=>{var{typed:n,matrix:a,divide:t,sum:r,multiply:i,dotDivide:l,log:m,isNumeric:f}=e;return n(Gl,{"Array, Array":function(o,u){return c(a(o),a(u))},"Matrix, Array":function(o,u){return c(o,a(u))},"Array, Matrix":function(o,u){return c(a(o),u)},"Matrix, Matrix":function(o,u){return c(o,u)}});function c(s,o){var u=o.size().length,p=s.size().length;if(u>1)throw new Error("first object must be one dimensional");if(p>1)throw new Error("second object must be one dimensional");if(u!==p)throw new Error("Length of two vectors must be equal");var v=r(s);if(v===0)throw new Error("Sum of elements in first object must be non zero");var h=r(o);if(h===0)throw new Error("Sum of elements in second object must be non zero");var b=t(s,r(s)),w=t(o,r(o)),N=r(i(b,m(l(b,w))));return f(N)?N:Number.NaN}}),Vl="multinomial",jC=["typed","add","divide","multiply","factorial","isInteger","isPositive"],e3=R(Vl,jC,e=>{var{typed:n,add:a,divide:t,multiply:r,factorial:i,isInteger:l,isPositive:m}=e;return n(Vl,{"Array | Matrix":function(c){var s=0,o=1;return bt(c,function(u){if(!l(u)||!m(u))throw new TypeError("Positive integer value expected in function multinomial");s=a(s,u),o=r(o,i(u))}),t(i(s),o)}})}),Zl="permutations",r3=["typed","factorial"],t3=R(Zl,r3,e=>{var{typed:n,factorial:a}=e;return n(Zl,{"number | BigNumber":a,"number, number":function(r,i){if(!Ae(r)||r<0)throw new TypeError("Positive integer value expected in function permutations");if(!Ae(i)||i<0)throw new TypeError("Positive integer value expected in function permutations");if(i>r)throw new TypeError("second argument k must be less than or equal to first argument n");return wt(r-i+1,r)},"BigNumber, BigNumber":function(r,i){var l,m;if(!Xl(r)||!Xl(i))throw new TypeError("Positive integer value expected in function permutations");if(i.gt(r))throw new TypeError("second argument k must be less than or equal to first argument n");var f=r.mul(0).add(1);for(l=f,m=r.minus(i).plus(1);m.lte(r);m=m.plus(1))l=l.times(m);return l}})});function Xl(e){return e.isInteger()&&e.gte(0)}var _a={exports:{}},n3=_a.exports,Yl;function a3(){return Yl||(Yl=1,function(e){(function(n,a,t){function r(f){var c=this,s=m();c.next=function(){var o=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=o-(c.c=o|0)},c.c=1,c.s0=s(" "),c.s1=s(" "),c.s2=s(" "),c.s0-=s(f),c.s0<0&&(c.s0+=1),c.s1-=s(f),c.s1<0&&(c.s1+=1),c.s2-=s(f),c.s2<0&&(c.s2+=1),s=null}function i(f,c){return c.c=f.c,c.s0=f.s0,c.s1=f.s1,c.s2=f.s2,c}function l(f,c){var s=new r(f),o=c&&c.state,u=s.next;return u.int32=function(){return s.next()*4294967296|0},u.double=function(){return u()+(u()*2097152|0)*11102230246251565e-32},u.quick=u,o&&(typeof o=="object"&&i(o,s),u.state=function(){return i(s,{})}),u}function m(){var f=4022871197,c=function(s){s=String(s);for(var o=0;o<s.length;o++){f+=s.charCodeAt(o);var u=.02519603282416938*f;f=u>>>0,u-=f,u*=f,f=u>>>0,u-=f,f+=u*4294967296}return(f>>>0)*23283064365386963e-26};return c}a&&a.exports?a.exports=l:this.alea=l})(n3,e)}(_a)),_a.exports}var $a={exports:{}},i3=$a.exports,Wl;function o3(){return Wl||(Wl=1,function(e){(function(n,a,t){function r(m){var f=this,c="";f.x=0,f.y=0,f.z=0,f.w=0,f.next=function(){var o=f.x^f.x<<11;return f.x=f.y,f.y=f.z,f.z=f.w,f.w^=f.w>>>19^o^o>>>8},m===(m|0)?f.x=m:c+=m;for(var s=0;s<c.length+64;s++)f.x^=c.charCodeAt(s)|0,f.next()}function i(m,f){return f.x=m.x,f.y=m.y,f.z=m.z,f.w=m.w,f}function l(m,f){var c=new r(m),s=f&&f.state,o=function(){return(c.next()>>>0)/4294967296};return o.double=function(){do var u=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=c.next,o.quick=o,s&&(typeof s=="object"&&i(s,c),o.state=function(){return i(c,{})}),o}a&&a.exports?a.exports=l:this.xor128=l})(i3,e)}($a)),$a.exports}var Ia={exports:{}},s3=Ia.exports,Jl;function u3(){return Jl||(Jl=1,function(e){(function(n,a,t){function r(m){var f=this,c="";f.next=function(){var o=f.x^f.x>>>2;return f.x=f.y,f.y=f.z,f.z=f.w,f.w=f.v,(f.d=f.d+362437|0)+(f.v=f.v^f.v<<4^(o^o<<1))|0},f.x=0,f.y=0,f.z=0,f.w=0,f.v=0,m===(m|0)?f.x=m:c+=m;for(var s=0;s<c.length+64;s++)f.x^=c.charCodeAt(s)|0,s==c.length&&(f.d=f.x<<10^f.x>>>4),f.next()}function i(m,f){return f.x=m.x,f.y=m.y,f.z=m.z,f.w=m.w,f.v=m.v,f.d=m.d,f}function l(m,f){var c=new r(m),s=f&&f.state,o=function(){return(c.next()>>>0)/4294967296};return o.double=function(){do var u=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=c.next,o.quick=o,s&&(typeof s=="object"&&i(s,c),o.state=function(){return i(c,{})}),o}a&&a.exports?a.exports=l:this.xorwow=l})(s3,e)}(Ia)),Ia.exports}var qa={exports:{}},c3=qa.exports,Ql;function f3(){return Ql||(Ql=1,function(e){(function(n,a,t){function r(m){var f=this;f.next=function(){var s=f.x,o=f.i,u,p;return u=s[o],u^=u>>>7,p=u^u<<24,u=s[o+1&7],p^=u^u>>>10,u=s[o+3&7],p^=u^u>>>3,u=s[o+4&7],p^=u^u<<7,u=s[o+7&7],u=u^u<<13,p^=u^u<<9,s[o]=p,f.i=o+1&7,p};function c(s,o){var u,p=[];if(o===(o|0))p[0]=o;else for(o=""+o,u=0;u<o.length;++u)p[u&7]=p[u&7]<<15^o.charCodeAt(u)+p[u+1&7]<<13;for(;p.length<8;)p.push(0);for(u=0;u<8&&p[u]===0;++u);for(u==8?p[7]=-1:p[u],s.x=p,s.i=0,u=256;u>0;--u)s.next()}c(f,m)}function i(m,f){return f.x=m.x.slice(),f.i=m.i,f}function l(m,f){m==null&&(m=+new Date);var c=new r(m),s=f&&f.state,o=function(){return(c.next()>>>0)/4294967296};return o.double=function(){do var u=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=c.next,o.quick=o,s&&(s.x&&i(s,c),o.state=function(){return i(c,{})}),o}a&&a.exports?a.exports=l:this.xorshift7=l})(c3,e)}(qa)),qa.exports}var Ra={exports:{}},l3=Ra.exports,Kl;function m3(){return Kl||(Kl=1,function(e){(function(n,a,t){function r(m){var f=this;f.next=function(){var s=f.w,o=f.X,u=f.i,p,v;return f.w=s=s+1640531527|0,v=o[u+34&127],p=o[u=u+1&127],v^=v<<13,p^=p<<17,v^=v>>>15,p^=p>>>12,v=o[u]=v^p,f.i=u,v+(s^s>>>16)|0};function c(s,o){var u,p,v,h,b,w=[],N=128;for(o===(o|0)?(p=o,o=null):(o=o+"\0",p=0,N=Math.max(N,o.length)),v=0,h=-32;h<N;++h)o&&(p^=o.charCodeAt((h+32)%o.length)),h===0&&(b=p),p^=p<<10,p^=p>>>15,p^=p<<4,p^=p>>>13,h>=0&&(b=b+1640531527|0,u=w[h&127]^=p+b,v=u==0?v+1:0);for(v>=128&&(w[(o&&o.length||0)&127]=-1),v=127,h=4*128;h>0;--h)p=w[v+34&127],u=w[v=v+1&127],p^=p<<13,u^=u<<17,p^=p>>>15,u^=u>>>12,w[v]=p^u;s.w=b,s.X=w,s.i=v}c(f,m)}function i(m,f){return f.i=m.i,f.w=m.w,f.X=m.X.slice(),f}function l(m,f){m==null&&(m=+new Date);var c=new r(m),s=f&&f.state,o=function(){return(c.next()>>>0)/4294967296};return o.double=function(){do var u=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=c.next,o.quick=o,s&&(s.X&&i(s,c),o.state=function(){return i(c,{})}),o}a&&a.exports?a.exports=l:this.xor4096=l})(l3,e)}(Ra)),Ra.exports}var Fa={exports:{}},p3=Fa.exports,jl;function v3(){return jl||(jl=1,function(e){(function(n,a,t){function r(m){var f=this,c="";f.next=function(){var o=f.b,u=f.c,p=f.d,v=f.a;return o=o<<25^o>>>7^u,u=u-p|0,p=p<<24^p>>>8^v,v=v-o|0,f.b=o=o<<20^o>>>12^u,f.c=u=u-p|0,f.d=p<<16^u>>>16^v,f.a=v-o|0},f.a=0,f.b=0,f.c=-1640531527,f.d=1367130551,m===Math.floor(m)?(f.a=m/4294967296|0,f.b=m|0):c+=m;for(var s=0;s<c.length+20;s++)f.b^=c.charCodeAt(s)|0,f.next()}function i(m,f){return f.a=m.a,f.b=m.b,f.c=m.c,f.d=m.d,f}function l(m,f){var c=new r(m),s=f&&f.state,o=function(){return(c.next()>>>0)/4294967296};return o.double=function(){do var u=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(u+p)/(1<<21);while(v===0);return v},o.int32=c.next,o.quick=o,s&&(typeof s=="object"&&i(s,c),o.state=function(){return i(c,{})}),o}a&&a.exports?a.exports=l:this.tychei=l})(p3,e)}(Fa)),Fa.exports}var za={exports:{}};const h3=zp(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var d3=za.exports,em;function g3(){return em||(em=1,function(e){(function(n,a,t){var r=256,i=6,l=52,m="random",f=t.pow(r,i),c=t.pow(2,l),s=c*2,o=r-1,u;function p(y,x,d){var A=[];x=x==!0?{entropy:!0}:x||{};var S=w(b(x.entropy?[y,g(a)]:y==null?N():y,3),A),O=new v(A),M=function(){for(var _=O.g(i),E=f,$=0;_<c;)_=(_+$)*r,E*=r,$=O.g(1);for(;_>=s;)_/=2,E/=2,$>>>=1;return(_+$)/E};return M.int32=function(){return O.g(4)|0},M.quick=function(){return O.g(4)/4294967296},M.double=M,w(g(O.S),a),(x.pass||d||function(_,E,$,z){return z&&(z.S&&h(z,O),_.state=function(){return h(O,{})}),$?(t[m]=_,E):_})(M,S,"global"in x?x.global:this==t,x.state)}function v(y){var x,d=y.length,A=this,S=0,O=A.i=A.j=0,M=A.S=[];for(d||(y=[d++]);S<r;)M[S]=S++;for(S=0;S<r;S++)M[S]=M[O=o&O+y[S%d]+(x=M[S])],M[O]=x;(A.g=function(_){for(var E,$=0,z=A.i,I=A.j,T=A.S;_--;)E=T[z=o&z+1],$=$*r+T[o&(T[z]=T[I=o&I+E])+(T[I]=E)];return A.i=z,A.j=I,$})(r)}function h(y,x){return x.i=y.i,x.j=y.j,x.S=y.S.slice(),x}function b(y,x){var d=[],A=typeof y,S;if(x&&A=="object")for(S in y)try{d.push(b(y[S],x-1))}catch(O){}return d.length?d:A=="string"?y:y+"\0"}function w(y,x){for(var d=y+"",A,S=0;S<d.length;)x[o&S]=o&(A^=x[o&S]*19)+d.charCodeAt(S++);return g(x)}function N(){try{var y;return u&&(y=u.randomBytes)?y=y(r):(y=new Uint8Array(r),(n.crypto||n.msCrypto).getRandomValues(y)),g(y)}catch(A){var x=n.navigator,d=x&&x.plugins;return[+new Date,n,d,n.screen,g(a)]}}function g(y){return String.fromCharCode.apply(0,y)}if(w(t.random(),a),e.exports){e.exports=p;try{u=h3}catch(y){}}else t["seed"+m]=p})(typeof self!="undefined"?self:d3,[],Math)}(za)),za.exports}var Ri,rm;function y3(){if(rm)return Ri;rm=1;var e=a3(),n=o3(),a=u3(),t=f3(),r=m3(),i=v3(),l=g3();return l.alea=e,l.xor128=n,l.xorwow=a,l.xorshift7=t,l.xor4096=r,l.tychei=i,Ri=l,Ri}var x3=y3();const tm=Tn(x3);var b3=tm(Date.now());function bn(e){var n;function a(r){n=r===null?b3:tm(String(r))}a(e);function t(){return n()}return t}var nm="pickRandom",w3=["typed","config","?on"],N3=R(nm,w3,e=>{var{typed:n,config:a,on:t}=e,r=bn(a.randomSeed);return t&&t("config",function(l,m){l.randomSeed!==m.randomSeed&&(r=bn(l.randomSeed))}),n(nm,{"Array | Matrix":function(m){return i(m,{})},"Array | Matrix, Object":function(m,f){return i(m,f)},"Array | Matrix, number":function(m,f){return i(m,{number:f})},"Array | Matrix, Array | Matrix":function(m,f){return i(m,{weights:f})},"Array | Matrix, Array | Matrix, number":function(m,f,c){return i(m,{number:c,weights:f})},"Array | Matrix, number, Array | Matrix":function(m,f,c){return i(m,{number:f,weights:c})}});function i(l,m){var{number:f,weights:c,elementWise:s=!0}=m,o=typeof f=="undefined";o&&(f=1);var u=Oe(l)?l.create:Oe(c)?c.create:null;l=l.valueOf(),c&&(c=c.valueOf()),s===!0&&(l=Le(l),c=Le(c));var p=0;if(typeof c!="undefined"){if(c.length!==l.length)throw new Error("Weights must have the same length as possibles");for(var v=0,h=c.length;v<h;v++){if(!Be(c[v])||c[v]<0)throw new Error("Weights must be an array of positive numbers");p+=c[v]}}for(var b=l.length,w=[],N;w.length<f;){if(typeof c=="undefined")N=l[Math.floor(r()*b)];else for(var g=r()*p,y=0,x=l.length;y<x;y++)if(g-=c[y],g<0){N=l[y];break}w.push(N)}return o?w[0]:u?u(w):w}});function Fi(e,n){var a=[];if(e=e.slice(0),e.length>1)for(var t=0,r=e.shift();t<r;t++)a.push(Fi(e,n));else for(var i=0,l=e.shift();i<l;i++)a.push(n());return a}var am="random",M3=["typed","config","?on"],A3=R(am,M3,e=>{var{typed:n,config:a,on:t}=e,r=bn(a.randomSeed);return t&&t("config",function(m,f){m.randomSeed!==f.randomSeed&&(r=bn(m.randomSeed))}),n(am,{"":()=>l(0,1),number:m=>l(0,m),"number, number":(m,f)=>l(m,f),"Array | Matrix":m=>i(m,0,1),"Array | Matrix, number":(m,f)=>i(m,0,f),"Array | Matrix, number, number":(m,f,c)=>i(m,f,c)});function i(m,f,c){var s=Fi(m.valueOf(),()=>l(f,c));return Oe(m)?m.create(s):s}function l(m,f){return m+r()*(f-m)}}),im="randomInt",S3=["typed","config","?on"],E3=R(im,S3,e=>{var{typed:n,config:a,on:t}=e,r=bn(a.randomSeed);return t&&t("config",function(m,f){m.randomSeed!==f.randomSeed&&(r=bn(m.randomSeed))}),n(im,{"":()=>l(0,1),number:m=>l(0,m),"number, number":(m,f)=>l(m,f),"Array | Matrix":m=>i(m,0,1),"Array | Matrix, number":(m,f)=>i(m,0,f),"Array | Matrix, number, number":(m,f,c)=>i(m,f,c)});function i(m,f,c){var s=Fi(m.valueOf(),()=>l(f,c));return Oe(m)?m.create(s):s}function l(m,f){return Math.floor(m+r()*(f-m))}}),om="stirlingS2",C3=["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],O3=R(om,C3,e=>{var{typed:n,addScalar:a,subtract:t,multiplyScalar:r,divideScalar:i,pow:l,factorial:m,combinations:f,isNegative:c,isInteger:s,number:o,bignumber:u,larger:p}=e,v=[],h=[];return n(om,{"number | BigNumber, number | BigNumber":function(w,N){if(!s(w)||c(w)||!s(N)||c(N))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(p(N,w))throw new TypeError("k must be less than or equal to n in function stirlingS2");var g=!(Be(w)&&Be(N)),y=g?h:v,x=g?u:o,d=o(w),A=o(N);if(y[d]&&y[d].length>A)return y[d][A];for(var S=0;S<=d;++S)if(y[S]||(y[S]=[x(S===0?1:0)]),S!==0)for(var O=y[S],M=y[S-1],_=O.length;_<=S&&_<=A;++_)_===S?O[_]=1:O[_]=a(r(x(_),M[_]),M[_-1]);return y[d][A]}})}),sm="bellNumbers",D3=["typed","addScalar","isNegative","isInteger","stirlingS2"],T3=R(sm,D3,e=>{var{typed:n,addScalar:a,isNegative:t,isInteger:r,stirlingS2:i}=e;return n(sm,{"number | BigNumber":function(m){if(!r(m)||t(m))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var f=0,c=0;c<=m;c++)f=a(f,i(m,c));return f}})}),um="catalan",B3=["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],_3=R(um,B3,e=>{var{typed:n,addScalar:a,divideScalar:t,multiplyScalar:r,combinations:i,isNegative:l,isInteger:m}=e;return n(um,{"number | BigNumber":function(c){if(!m(c)||l(c))throw new TypeError("Non-negative integer value expected in function catalan");return t(i(r(c,2),c),a(c,1))}})}),cm="composition",$3=["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],I3=R(cm,$3,e=>{var{typed:n,addScalar:a,combinations:t,isPositive:r,isNegative:i,isInteger:l,larger:m}=e;return n(cm,{"number | BigNumber, number | BigNumber":function(c,s){if(!l(c)||!r(c)||!l(s)||!r(s))throw new TypeError("Positive integer value expected in function composition");if(m(s,c))throw new TypeError("k must be less than or equal to n in function composition");return t(a(c,-1),a(s,-1))}})}),fm="leafCount",q3=["parse","typed"],R3=R(fm,q3,e=>{var{parse:n,typed:a}=e;function t(r){var i=0;return r.forEach(l=>{i+=t(l)}),i||1}return a(fm,{string:function(i){return this(n(i))},Node:function(i){return t(i)}})});function lm(e,n){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),a.push.apply(a,t)}return a}function zi(e){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?lm(Object(a),!0).forEach(function(t){ff(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):lm(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var F3="simplifyUtil",z3=["FunctionNode","OperatorNode","SymbolNode"],Pi=R(F3,z3,e=>{var{FunctionNode:n,OperatorNode:a,SymbolNode:t}=e,r=!0,i=!1,l="defaultF",m={add:{trivial:r,total:r,commutative:r,associative:r},unaryPlus:{trivial:r,total:r,commutative:r,associative:r},subtract:{trivial:i,total:r,commutative:i,associative:i},multiply:{trivial:r,total:r,commutative:r,associative:r},divide:{trivial:i,total:r,commutative:i,associative:i},paren:{trivial:r,total:r,commutative:r,associative:i},defaultF:{trivial:i,total:r,commutative:i,associative:i}},f={divide:{total:i},log:{total:i}},c={subtract:{total:i},abs:{trivial:r},log:{total:r}};function s(g,y){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:m,d=l;if(typeof g=="string"?d=g:$r(g)?d=g.fn.toString():kt(g)?d=g.name:On(g)&&(d="paren"),Me(x,d)){var A=x[d];if(Me(A,y))return A[y];if(Me(m,d))return m[d][y]}if(Me(x,l)){var S=x[l];return Me(S,y)?S[y]:m[l][y]}if(Me(m,d)){var O=m[d];if(Me(O,y))return O[y]}return m[l][y]}function o(g){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:m;return s(g,"commutative",y)}function u(g){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:m;return s(g,"associative",y)}function p(g,y){var x=zi({},g);for(var d in y)Me(g,d)?x[d]=zi(zi({},y[d]),g[d]):x[d]=y[d];return x}function v(g,y){if(!g.args||g.args.length===0)return g;g.args=h(g,y);for(var x=0;x<g.args.length;x++)v(g.args[x],y)}function h(g,y){var x,d=[],A=function S(O){for(var M=0;M<O.args.length;M++){var _=O.args[M];$r(_)&&x===_.op?S(_):d.push(_)}};return u(g,y)?(x=g.op,A(g),d):g.args}function b(g,y){if(!(!g.args||g.args.length===0)){for(var x=N(g),d=g.args.length,A=0;A<d;A++)b(g.args[A],y);if(d>2&&u(g,y)){for(var S=g.args.pop();g.args.length>0;)S=x([g.args.pop(),S]);g.args=S.args}}}function w(g,y){if(!(!g.args||g.args.length===0)){for(var x=N(g),d=g.args.length,A=0;A<d;A++)w(g.args[A],y);if(d>2&&u(g,y)){for(var S=g.args.shift();g.args.length>0;)S=x([S,g.args.shift()]);g.args=S.args}}}function N(g){return $r(g)?function(y){try{return new a(g.op,g.fn,y,g.implicit)}catch(x){return console.error(x),[]}}:function(y){return new n(new t(g.name),y)}}return{createMakeNodeFunction:N,hasProperty:s,isCommutative:o,isAssociative:u,mergeContext:p,flatten:v,allChildren:h,unflattenr:b,unflattenl:w,defaultContext:m,realContext:f,positiveContext:c}}),P3="simplifyConstant",U3=["typed","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],mm=R(P3,U3,e=>{var{typed:n,config:a,mathWithTransform:t,matrix:r,fraction:i,bignumber:l,AccessorNode:m,ArrayNode:f,ConstantNode:c,FunctionNode:s,IndexNode:o,ObjectNode:u,OperatorNode:p,SymbolNode:v}=e,{isCommutative:h,isAssociative:b,allChildren:w,createMakeNodeFunction:N}=Pi({FunctionNode:s,OperatorNode:p,SymbolNode:v});function g(I,T){return A(z(I,T))}function y(I){return yr(I)?I.valueOf():I instanceof Array?I.map(y):Oe(I)?r(y(I.valueOf())):I}function x(I,T,B){try{return t[I].apply(null,T)}catch(G){return T=T.map(y),O(t[I].apply(null,T),B)}}var d=n({Fraction:_,number:function(T){return T<0?M(new c(-T)):new c(T)},BigNumber:function(T){return T<0?M(new c(-T)):new c(T)},Complex:function(T){throw new Error("Cannot convert Complex number to Node")},string:function(T){return new c(T)},Matrix:function(T){return new f(T.valueOf().map(B=>d(B)))}});function A(I){return Ve(I)?I:d(I)}function S(I,T){var B=T&&T.exactFractions!==!1;if(B&&isFinite(I)&&i){var G=i(I),D=T&&typeof T.fractionsLimit=="number"?T.fractionsLimit:1/0;if(G.valueOf()===I&&G.n<D&&G.d<D)return G}return I}var O=n({"string, Object":function(T,B){if(a.number==="BigNumber")return l===void 0&&Ai(),l(T);if(a.number==="Fraction")return i===void 0&&nc(),i(T);var G=parseFloat(T);return S(G,B)},"Fraction, Object":function(T,B){return T},"BigNumber, Object":function(T,B){return T},"number, Object":function(T,B){return S(T,B)},"Complex, Object":function(T,B){return T.im!==0?T:S(T.re,B)},"Matrix, Object":function(T,B){return r(S(T.valueOf()))},"Array, Object":function(T,B){return T.map(S)}});function M(I){return new p("-","unaryMinus",[I])}function _(I){var T,B=I.s*I.n;return B<0?T=new p("-","unaryMinus",[new c(-B)]):T=new c(B),I.d===1?T:new p("/","divide",[T,new c(I.d)])}function E(I,T,B){if(!tn(T))return new m(A(I),A(T));if(Hr(I)||Oe(I)){for(var G=Array.from(T.dimensions);G.length>0;)if(Ye(G[0])&&typeof G[0].value!="string"){var D=O(G.shift().value,B);Hr(I)?I=I.items[D-1]:(I=I.valueOf()[D-1],I instanceof Array&&(I=r(I)))}else if(G.length>1&&Ye(G[1])&&typeof G[1].value!="string"){var H=O(G[1].value,B),W=[],j=Hr(I)?I.items:I.valueOf();for(var V of j)if(Hr(V))W.push(V.items[H-1]);else if(Oe(I))W.push(V[H-1]);else break;if(W.length===j.length)Hr(I)?I=new f(W):I=r(W),G.splice(1,1);else break}else break;return G.length===T.dimensions.length?new m(A(I),T):G.length>0?(T=new o(G),new m(A(I),T)):I}if(jn(I)&&T.dimensions.length===1&&Ye(T.dimensions[0])){var K=T.dimensions[0].value;return K in I.properties?I.properties[K]:new c}return new m(A(I),T)}function $(I,T,B,G){return T.reduce(function(D,H){if(!Ve(D)&&!Ve(H)){try{return x(I,[D,H],G)}catch(W){}D=d(D),H=d(H)}else Ve(D)?Ve(H)||(H=d(H)):D=d(D);return B([D,H])})}function z(I,T){switch(I.type){case"SymbolNode":return I;case"ConstantNode":switch(typeof I.value){case"number":return O(I.value,T);case"string":return I.value;default:if(!isNaN(I.value))return O(I.value,T)}return I;case"FunctionNode":if(t[I.name]&&t[I.name].rawArgs)return I;{var B=["add","multiply"];if(B.indexOf(I.name)===-1){var G=I.args.map(ye=>z(ye,T));if(!G.some(Ve))try{return x(I.name,G,T)}catch(ye){}if(I.name==="size"&&G.length===1&&Hr(G[0])){for(var D=[],H=G[0];Hr(H);)D.push(H.items.length),H=H.items[0];return r(D)}return new s(I.name,G.map(A))}}case"OperatorNode":{var W=I.fn.toString(),j,V,K=N(I);if($r(I)&&I.isUnary())j=[z(I.args[0],T)],Ve(j[0])?V=K(j):V=x(W,j,T);else if(b(I,T.context))if(j=w(I,T.context),j=j.map(ye=>z(ye,T)),h(W,T.context)){for(var te=[],re=[],ie=0;ie<j.length;ie++)Ve(j[ie])?re.push(j[ie]):te.push(j[ie]);te.length>1?(V=$(W,te,K,T),re.unshift(V),V=$(W,re,K,T)):V=$(W,j,K,T)}else V=$(W,j,K,T);else j=I.args.map(ye=>z(ye,T)),V=$(W,j,K,T);return V}case"ParenthesisNode":return z(I.content,T);case"AccessorNode":return E(z(I.object,T),z(I.index,T),T);case"ArrayNode":{var ne=I.items.map(ye=>z(ye,T));return ne.some(Ve)?new f(ne.map(A)):r(ne)}case"IndexNode":return new o(I.dimensions.map(ye=>g(ye,T)));case"ObjectNode":{var ue={};for(var ee in I.properties)ue[ee]=g(I.properties[ee],T);return new u(ue)}case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"RangeNode":case"ConditionalNode":default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(I.type))}}return g}),L3="simplify",k3=["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","resolve","simplifyCore","?fraction","?bignumber","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],H3=R(L3,k3,e=>{var{config:n,typed:a,parse:t,add:r,subtract:i,multiply:l,divide:m,pow:f,isZero:c,equal:s,resolve:o,simplifyCore:u,fraction:p,bignumber:v,mathWithTransform:h,matrix:b,AccessorNode:w,ArrayNode:N,ConstantNode:g,FunctionNode:y,IndexNode:x,ObjectNode:d,OperatorNode:A,ParenthesisNode:S,SymbolNode:O}=e,M=mm({typed:a,config:n,mathWithTransform:h,matrix:b,fraction:p,bignumber:v,AccessorNode:w,ArrayNode:N,ConstantNode:g,FunctionNode:y,IndexNode:x,ObjectNode:d,OperatorNode:A,SymbolNode:O}),{hasProperty:_,isCommutative:E,isAssociative:$,mergeContext:z,flatten:I,unflattenr:T,unflattenl:B,createMakeNodeFunction:G,defaultContext:D,realContext:H,positiveContext:W}=Pi({FunctionNode:y,OperatorNode:A,SymbolNode:O}),j=a("simplify",{string:function(U){return this(t(U),this.rules,gt(),{})},"string, Map | Object":function(U,J){return this(t(U),this.rules,J,{})},"string, Map | Object, Object":function(U,J,q){return this(t(U),this.rules,J,q)},"string, Array":function(U,J){return this(t(U),J,gt(),{})},"string, Array, Map | Object":function(U,J,q){return this(t(U),J,q,{})},"string, Array, Map | Object, Object":function(U,J,q,P){return this(t(U),J,q,P)},"Node, Map | Object":function(U,J){return this(U,this.rules,J,{})},"Node, Map | Object, Object":function(U,J,q){return this(U,this.rules,J,q)},Node:function(U){return this(U,this.rules,gt(),{})},"Node, Array":function(U,J){return this(U,J,gt(),{})},"Node, Array, Map | Object":function(U,J,q){return this(U,J,q,{})},"Node, Array, Object, Object":function(U,J,q,P){return this(U,J,oi(q),P)},"Node, Array, Map, Object":function(U,J,q,P){var Q=P.consoleDebug;J=re(J,P.context);var L=o(U,q);L=V(L);for(var se={},fe=L.toString({parenthesis:"all"});!se[fe];){se[fe]=!0,ie=0;var ge=fe;Q&&console.log("Working on: ",fe);for(var pe=0;pe<J.length;pe++){var ve="";if(typeof J[pe]=="function"?(L=J[pe](L,P),Q&&(ve=J[pe].name)):(I(L,P.context),L=ee(L,J[pe],P.context),Q&&(ve="".concat(J[pe].l.toString()," -> ").concat(J[pe].r.toString()))),Q){var Ne=L.toString({parenthesis:"all"});Ne!==ge&&(console.log("Applying",ve,"produced",Ne),ge=Ne)}B(L,P.context)}fe=L.toString({parenthesis:"all"})}return L}});j.defaultContext=D,j.realContext=H,j.positiveContext=W;function V(k){return k.transform(function(U,J,q){return On(U)?V(U.content):U})}var K={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};j.rules=[u,{l:"log(e)",r:"1"},{s:"n-n1 -> n+-n1",assuming:{subtract:{total:!0}}},{s:"n-n -> 0",assuming:{subtract:{total:!1}}},{s:"-(c*v) -> v * (-c)",assuming:{multiply:{commutative:!0},subtract:{total:!0}}},{s:"-(c*v) -> (-c) * v",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{s:"-(v*c) -> v * (-c)",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{l:"-(n1/n2)",r:"-n1/n2"},{l:"-v",r:"v * (-1)"},{l:"(n1 + n2)*(-1)",r:"n1*(-1) + n2*(-1)",repeat:!0},{l:"n/n1^n2",r:"n*n1^-n2"},{l:"n/n1",r:"n*n1^-1"},{s:"(n1*n2)^n3 -> n1^n3 * n2^n3",assuming:{multiply:{commutative:!0}}},{s:"(n1*n2)^(-1) -> n2^(-1) * n1^(-1)",assuming:{multiply:{commutative:!1}}},{s:"(n ^ n1) ^ n2 -> n ^ (n1 * n2)",assuming:{divide:{total:!0}}},{l:" v * ( v * n1 + n2)",r:"v^2 * n1 + v * n2"},{s:" v * (v^n4 * n1 + n2) -> v^(1+n4) * n1 + v * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * ( v * n1 + n2) -> v^(n3+1) * n1 + v^n3 * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * (v^n4 * n1 + n2) -> v^(n3+n4) * n1 + v^n3 * n2",assuming:{divide:{total:!0}}},{l:"n*n",r:"n^2"},{s:"n * n^n1 -> n^(n1+1)",assuming:{divide:{total:!0}}},{s:"n^n1 * n^n2 -> n^(n1+n2)",assuming:{divide:{total:!0}}},M,{s:"n+n -> 2*n",assuming:{add:{total:!0}}},{l:"n+-n",r:"0"},{l:"v*n + v",r:"v*(n+1)"},{l:"n3*n1 + n3*n2",r:"n3*(n1+n2)"},{l:"n3^(-n4)*n1 + n3 * n2",r:"n3^(-n4)*(n1 + n3^(n4+1) *n2)"},{l:"n3^(-n4)*n1 + n3^n5 * n2",r:"n3^(-n4)*(n1 + n3^(n4+n5)*n2)"},{s:"n*v + v -> (n+1)*v",assuming:{multiply:{commutative:!1}}},{s:"n1*n3 + n2*n3 -> (n1+n2)*n3",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3 -> (n1 + n2*n3^(n4 + 1))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3^n5 -> (n1 + n2*n3^(n4 + n5))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{l:"n*c + c",r:"(n+1)*c"},{s:"c*n + c -> c*(n+1)",assuming:{multiply:{commutative:!1}}},M,{s:"(-n)*n1 -> -(n*n1)",assuming:{subtract:{total:!0}}},{s:"n1*(-n) -> -(n1*n)",assuming:{subtract:{total:!0},multiply:{commutative:!1}}},{s:"c+v -> v+c",assuming:{add:{commutative:!0}},imposeContext:{add:{commutative:!1}}},{s:"v*c -> c*v",assuming:{multiply:{commutative:!0}},imposeContext:{multiply:{commutative:!1}}},{l:"n+-n1",r:"n-n1"},{s:"n*(n1^-1) -> n/n1",assuming:{multiply:{commutative:!0}}},{s:"n*n1^-n2 -> n/n1^n2",assuming:{multiply:{commutative:!0}}},{s:"n^-1 -> 1/n",assuming:{multiply:{commutative:!0}}},{l:"n^1",r:"n"},{s:"n*(n1/n2) -> (n*n1)/n2",assuming:{multiply:{associative:!0}}},{s:"n-(n1+n2) -> n-n1-n2",assuming:{addition:{associative:!0,commutative:!0}}},{l:"1*n",r:"n",imposeContext:{multiply:{commutative:!0}}},{s:"n1/(n2/n3) -> (n1*n3)/n2",assuming:{multiply:{associative:!0}}},{l:"n1/(-n2)",r:"-n1/n2"}];function te(k,U){var J={};if(k.s){var q=k.s.split("->");if(q.length===2)J.l=q[0],J.r=q[1];else throw SyntaxError("Could not parse rule: "+k.s)}else J.l=k.l,J.r=k.r;J.l=V(t(J.l)),J.r=V(t(J.r));for(var P of["imposeContext","repeat","assuming"])P in k&&(J[P]=k[P]);if(k.evaluate&&(J.evaluate=t(k.evaluate)),$(J.l,U)){var Q=G(J.l),L=ne();J.expanded={},J.expanded.l=Q([J.l.clone(),L]),I(J.expanded.l,U),T(J.expanded.l,U),J.expanded.r=Q([J.r,L])}return J}function re(k,U){for(var J=[],q=0;q<k.length;q++){var P=k[q],Q=void 0,L=typeof P;switch(L){case"string":P={s:P};case"object":Q=te(P,U);break;case"function":Q=P;break;default:throw TypeError("Unsupported type of rule: "+L)}J.push(Q)}return J}var ie=0;function ne(){return new O("_p"+ie++)}function ue(k,U,J){var q=k;if(k)for(var P=0;P<k.length;++P){var Q=ee(k[P],U,J);Q!==k[P]&&(q===k&&(q=k.slice()),q[P]=Q)}return q}function ee(k,U,J){if(U.assuming){for(var q in U.assuming)for(var P in U.assuming[q])if(_(q,P,J)!==U.assuming[q][P])return k}var Q=z(U.imposeContext,J),L=k;if(L instanceof A||L instanceof y){var se=ue(L.args,U,J);se!==L.args&&(L=L.clone(),L.args=se)}else if(L instanceof S){if(L.content){var fe=ee(L.content,U,J);fe!==L.content&&(L=new S(fe))}}else if(L instanceof N){var ge=ue(L.items,U,J);ge!==L.items&&(L=new N(ge))}else if(L instanceof w){var pe=L.object;L.object&&(pe=ee(L.object,U,J));var ve=L.index;L.index&&(ve=ee(L.index,U,J)),(pe!==L.object||ve!==L.index)&&(L=new w(pe,ve))}else if(L instanceof x){var Ne=ue(L.dimensions,U,J);Ne!==L.dimensions&&(L=new x(Ne))}else if(L instanceof d){var Qe=!1,cr={};for(var tr in L.properties)cr[tr]=ee(L.properties[tr],U,J),cr[tr]!==L.properties[tr]&&(Qe=!0);Qe&&(L=new d(cr))}var Jr=U.r,Lr=F(U.l,L,Q)[0];if(!Lr&&U.expanded&&(Jr=U.expanded.r,Lr=F(U.expanded.l,L,Q)[0]),Lr){var Ot=L.implicit;L=Jr.clone(),Ot&&"implicit"in Jr&&(L.implicit=!0),L=L.transform(function(Ze){return Ze.isSymbolNode&&Me(Lr.placeholders,Ze.name)?Lr.placeholders[Ze.name].clone():Ze})}return U.repeat&&L!==k&&(L=ee(L,U,J)),L}function ye(k,U){var J=[],q,P,Q=G(k);if(E(k,U))for(var L=0;L<k.args.length;L++)P=k.args.slice(0),P.splice(L,1),q=P.length===1?P[0]:Q(P),J.push(Q([k.args[L],q]));else for(var se=1;se<k.args.length;se++){var fe=k.args[0];se>1&&(fe=Q(k.args.slice(0,se))),P=k.args.slice(se),q=P.length===1?P[0]:Q(P),J.push(Q([fe,q]))}return J}function we(k,U){var J={placeholders:{}};if(!k.placeholders&&!U.placeholders)return J;if(k.placeholders){if(!U.placeholders)return k}else return U;for(var q in k.placeholders)if(Me(k.placeholders,q)&&(J.placeholders[q]=k.placeholders[q],Me(U.placeholders,q)&&!Y(k.placeholders[q],U.placeholders[q])))return null;for(var P in U.placeholders)Me(U.placeholders,P)&&(J.placeholders[P]=U.placeholders[P]);return J}function me(k,U){var J=[];if(k.length===0||U.length===0)return J;for(var q,P=0;P<k.length;P++)for(var Q=0;Q<U.length;Q++)q=we(k[P],U[Q]),q&&J.push(q);return J}function xe(k){if(k.length===0)return k;for(var U=k.reduce(me),J=[],q={},P=0;P<U.length;P++){var Q=JSON.stringify(U[P]);q[Q]||(q[Q]=!0,J.push(U[P]))}return J}function F(k,U,J,q){var P=[{placeholders:{}}];if(k instanceof A&&U instanceof A||k instanceof y&&U instanceof y){if(k instanceof A){if(k.op!==U.op||k.fn!==U.fn)return[]}else if(k instanceof y&&k.name!==U.name)return[];if(U.args.length===1&&k.args.length===1||!$(U,J)&&U.args.length===k.args.length||q){for(var Q=[],L=0;L<k.args.length;L++){var se=F(k.args[L],U.args[L],J);if(se.length===0)break;Q.push(se)}if(Q.length!==k.args.length){if(!E(U,J)||k.args.length===1)return[];if(k.args.length>2)throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");var fe=F(k.args[0],U.args[1],J);if(fe.length===0)return[];var ge=F(k.args[1],U.args[0],J);if(ge.length===0)return[];Q=[fe,ge]}P=xe(Q)}else if(U.args.length>=2&&k.args.length===2){for(var pe=ye(U,J),ve=[],Ne=0;Ne<pe.length;Ne++){var Qe=F(k,pe[Ne],J,!0);ve=ve.concat(Qe)}return ve}else{if(k.args.length>2)throw Error("Unexpected non-binary associative function: "+k.toString());return[]}}else if(k instanceof O){if(k.name.length===0)throw new Error("Symbol in rule has 0 length...!?");if(K[k.name]){if(k.name!==U.name)return[]}else if(k.name[0]==="n"||k.name.substring(0,2)==="_p")P[0].placeholders[k.name]=U;else if(k.name[0]==="v")if(!Ye(U))P[0].placeholders[k.name]=U;else return[];else if(k.name[0]==="c")if(U instanceof g)P[0].placeholders[k.name]=U;else return[];else throw new Error("Invalid symbol in rule: "+k.name)}else if(k instanceof g){if(!s(k.value,U.value))return[]}else return[];return P}function Y(k,U){if(k instanceof g&&U instanceof g){if(!s(k.value,U.value))return!1}else if(k instanceof O&&U instanceof O){if(k.name!==U.name)return!1}else if(k instanceof A&&U instanceof A||k instanceof y&&U instanceof y){if(k instanceof A){if(k.op!==U.op||k.fn!==U.fn)return!1}else if(k instanceof y&&k.name!==U.name)return!1;if(k.args.length!==U.args.length)return!1;for(var J=0;J<k.args.length;J++)if(!Y(k.args[J],U.args[J]))return!1}else return!1;return!0}return j}),G3="simplifyCore",V3=["equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],Z3=R(G3,V3,e=>{var{equal:n,isZero:a,add:t,subtract:r,multiply:i,divide:l,pow:m,AccessorNode:f,ArrayNode:c,ConstantNode:s,FunctionNode:o,IndexNode:u,ObjectNode:p,OperatorNode:v,ParenthesisNode:h,SymbolNode:b}=e,w=new s(0),N=new s(1),{hasProperty:g,isCommutative:y}=Pi({FunctionNode:o,OperatorNode:v,SymbolNode:b});function x(d,A){var S=A?A.context:void 0;if(g(d,"trivial",S)){if(kt(d)&&d.args.length===1)return x(d.args[0],A);var O=!1,M=0;if(d.forEach(D=>{++M,M===1&&(O=x(D,A))}),M===1)return O}if($r(d)&&d.isUnary()){var _=x(d.args[0],A);if(d.op==="-"){if($r(_)){if(_.isUnary()&&_.op==="-")return _.args[0];if(_.isBinary()&&_.fn==="subtract")return new v("-","subtract",[_.args[1],_.args[0]])}return new v(d.op,d.fn,[_])}}else if($r(d)&&d.isBinary()){var E=x(d.args[0],A),$=x(d.args[1],A);if(d.op==="+"){if(Ye(E)){if(a(E.value))return $;if(Ye($))return new s(t(E.value,$.value))}return Ye($)&&a($.value)?E:$r($)&&$.isUnary()&&$.op==="-"?new v("-","subtract",[E,$.args[0]]):new v(d.op,d.fn,$?[E,$]:[E])}else if(d.op==="-"){if(Ye(E)&&$){if(Ye($))return new s(r(E.value,$.value));if(a(E.value))return new v("-","unaryMinus",[$])}if(d.fn==="subtract")return Ye($)&&a($.value)?E:$r($)&&$.isUnary()&&$.op==="-"?x(new v("+","add",[E,$.args[0]]),A):new v(d.op,d.fn,[E,$])}else if(d.op==="*"){if(Ye(E)){if(a(E.value))return w;if(n(E.value,1))return $;if(Ye($))return new s(i(E.value,$.value))}if(Ye($)){if(a($.value))return w;if(n($.value,1))return E;if($r(E)&&E.isBinary()&&E.op===d.op&&y(d,S)){var z=E.args[0];if(Ye(z)){var I=new s(i(z.value,$.value));return new v(d.op,d.fn,[I,E.args[1]],d.implicit)}}return y(d,S)?new v(d.op,d.fn,[$,E],d.implicit):new v(d.op,d.fn,[E,$],d.implicit)}return new v(d.op,d.fn,[E,$],d.implicit)}else if(d.op==="/"){if(Ye(E)){if(a(E.value))return w;if(Ye($)&&(n($.value,1)||n($.value,2)||n($.value,4)))return new s(l(E.value,$.value))}return new v(d.op,d.fn,[E,$])}else if(d.op==="^"&&Ye($)){if(a($.value))return N;if(n($.value,1))return E;if(Ye(E))return new s(m(E.value,$.value));if($r(E)&&E.isBinary()&&E.op==="^"){var T=E.args[1];if(Ye(T))return new v(d.op,d.fn,[E.args[0],new s(i(T.value,$.value))])}}return new v(d.op,d.fn,[E,$])}else{if(kt(d))return new o(x(d.fn),d.args.map(D=>x(D,A)));if(Hr(d))return new c(d.items.map(D=>x(D,A)));if(Lt(d))return new f(x(d.object,A),x(d.index,A));if(tn(d))return new u(d.dimensions.map(D=>x(D,A)));if(jn(d)){var B={};for(var G in d.properties)B[G]=x(d.properties[G],A);return new p(B)}}return d}return x}),X3="resolve",Y3=["parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],W3=R(X3,Y3,e=>{var{parse:n,ConstantNode:a,FunctionNode:t,OperatorNode:r,ParenthesisNode:i}=e;function l(m,f){var c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;if(!f)return m;if(ua(f)||(f=oi(f)),xr(m)){if(c.has(m.name)){var s=Array.from(c).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(s,"}"))}var o=f.get(m.name);if(Ve(o)){var u=new Set(c);return u.add(m.name),l(o,f,u)}else return typeof o=="number"?n(String(o)):o!==void 0?new a(o):m}else if($r(m)){var p=m.args.map(function(h){return l(h,f,c)});return new r(m.op,m.fn,p,m.implicit)}else{if(On(m))return new i(l(m.content,f,c));if(kt(m)){var v=m.args.map(function(h){return l(h,f,c)});return new t(m.name,v)}}return m.map(h=>l(h,f,c))}return l}),pm="symbolicEqual",J3=["parse","simplify","typed","OperatorNode"],Q3=R(pm,J3,e=>{var{parse:n,simplify:a,typed:t,OperatorNode:r}=e;return t(pm,{"string, string":function(l,m){return this(n(l),n(m),{})},"string, string, Object":function(l,m,f){return this(n(l),n(m),f)},"Node, string":function(l,m){return this(l,n(m),{})},"Node, string, Object":function(l,m,f){return this(l,n(m),f)},"string, Node":function(l,m){return this(n(l),m,{})},"string, Node, Object":function(l,m,f){return this(n(l),m,f)},"Node, Node":function(l,m){return this(l,m,{})},"Node, Node, Object":function(l,m,f){var c=new r("-","subtract",[l,m]),s=a(c,{},f);return Ye(s)&&!s.value}})}),K3="derivative",j3=["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],eO=R(K3,j3,e=>{var{typed:n,config:a,parse:t,simplify:r,equal:i,isZero:l,numeric:m,ConstantNode:f,FunctionNode:c,OperatorNode:s,ParenthesisNode:o,SymbolNode:u}=e,p=n("derivative",{"Node, SymbolNode, Object":function(y,x,d){var A={};h(A,y,x.name);var S=b(y,A);return d.simplify?r(S):S},"Node, SymbolNode":function(y,x){return this(y,x,{simplify:!0})},"string, SymbolNode":function(y,x){return this(t(y),x)},"string, SymbolNode, Object":function(y,x,d){return this(t(y),x,d)},"string, string":function(y,x){return this(t(y),t(x))},"string, string, Object":function(y,x,d){return this(t(y),t(x),d)},"Node, string":function(y,x){return this(y,t(x))},"Node, string, Object":function(y,x,d){return this(y,t(x),d)}});p._simplify=!0,p.toTex=function(g){return v.apply(null,g.args)};var v=n("_derivTex",{"Node, SymbolNode":function(y,x){return Ye(y)&&Ke(y.value)==="string"?v(t(y.value).toString(),x.toString(),1):v(y.toTex(),x.toString(),1)},"Node, ConstantNode":function(y,x){if(Ke(x.value)==="string")return v(y,t(x.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(y,x,d){return v(y.toString(),x.name,d.value)},"string, string, number":function(y,x,d){var A;return d===1?A="{d\\over d"+x+"}":A="{d^{"+d+"}\\over d"+x+"^{"+d+"}}",A+"\\left[".concat(y,"\\right]")}}),h=n("constTag",{"Object, ConstantNode, string":function(y,x){return y[x]=!0,!0},"Object, SymbolNode, string":function(y,x,d){return x.name!==d?(y[x]=!0,!0):!1},"Object, ParenthesisNode, string":function(y,x,d){return h(y,x.content,d)},"Object, FunctionAssignmentNode, string":function(y,x,d){return x.params.indexOf(d)===-1?(y[x]=!0,!0):h(y,x.expr,d)},"Object, FunctionNode | OperatorNode, string":function(y,x,d){if(x.args.length>0){for(var A=h(y,x.args[0],d),S=1;S<x.args.length;++S)A=h(y,x.args[S],d)&&A;if(A)return y[x]=!0,!0}return!1}}),b=n("_derivative",{"ConstantNode, Object":function(y){return N(0)},"SymbolNode, Object":function(y,x){return x[y]!==void 0?N(0):N(1)},"ParenthesisNode, Object":function(y,x){return new o(b(y.content,x))},"FunctionAssignmentNode, Object":function(y,x){return x[y]!==void 0?N(0):b(y.expr,x)},"FunctionNode, Object":function(y,x){if(y.args.length!==1&&w(y),x[y]!==void 0)return N(0);var d=y.args[0],A,S=!1,O=!1,M;switch(y.name){case"cbrt":S=!0,M=new s("*","multiply",[N(3),new s("^","pow",[d,new s("/","divide",[N(2),N(3)])])]);break;case"sqrt":case"nthRoot":if(y.args.length===1)S=!0,M=new s("*","multiply",[N(2),new c("sqrt",[d])]);else if(y.args.length===2)return A=new s("/","divide",[N(1),y.args[1]]),x[A]=x[y.args[1]],b(new s("^","pow",[d,A]),x);break;case"log10":A=N(10);case"log":if(!A&&y.args.length===1)M=d.clone(),S=!0;else if(y.args.length===1&&A||y.args.length===2&&x[y.args[1]]!==void 0)M=new s("*","multiply",[d.clone(),new c("log",[A||y.args[1]])]),S=!0;else if(y.args.length===2)return b(new s("/","divide",[new c("log",[d]),new c("log",[y.args[1]])]),x);break;case"pow":return x[A]=x[y.args[1]],b(new s("^","pow",[d,y.args[1]]),x);case"exp":M=new c("exp",[d.clone()]);break;case"sin":M=new c("cos",[d.clone()]);break;case"cos":M=new s("-","unaryMinus",[new c("sin",[d.clone()])]);break;case"tan":M=new s("^","pow",[new c("sec",[d.clone()]),N(2)]);break;case"sec":M=new s("*","multiply",[y,new c("tan",[d.clone()])]);break;case"csc":O=!0,M=new s("*","multiply",[y,new c("cot",[d.clone()])]);break;case"cot":O=!0,M=new s("^","pow",[new c("csc",[d.clone()]),N(2)]);break;case"asin":S=!0,M=new c("sqrt",[new s("-","subtract",[N(1),new s("^","pow",[d.clone(),N(2)])])]);break;case"acos":S=!0,O=!0,M=new c("sqrt",[new s("-","subtract",[N(1),new s("^","pow",[d.clone(),N(2)])])]);break;case"atan":S=!0,M=new s("+","add",[new s("^","pow",[d.clone(),N(2)]),N(1)]);break;case"asec":S=!0,M=new s("*","multiply",[new c("abs",[d.clone()]),new c("sqrt",[new s("-","subtract",[new s("^","pow",[d.clone(),N(2)]),N(1)])])]);break;case"acsc":S=!0,O=!0,M=new s("*","multiply",[new c("abs",[d.clone()]),new c("sqrt",[new s("-","subtract",[new s("^","pow",[d.clone(),N(2)]),N(1)])])]);break;case"acot":S=!0,O=!0,M=new s("+","add",[new s("^","pow",[d.clone(),N(2)]),N(1)]);break;case"sinh":M=new c("cosh",[d.clone()]);break;case"cosh":M=new c("sinh",[d.clone()]);break;case"tanh":M=new s("^","pow",[new c("sech",[d.clone()]),N(2)]);break;case"sech":O=!0,M=new s("*","multiply",[y,new c("tanh",[d.clone()])]);break;case"csch":O=!0,M=new s("*","multiply",[y,new c("coth",[d.clone()])]);break;case"coth":O=!0,M=new s("^","pow",[new c("csch",[d.clone()]),N(2)]);break;case"asinh":S=!0,M=new c("sqrt",[new s("+","add",[new s("^","pow",[d.clone(),N(2)]),N(1)])]);break;case"acosh":S=!0,M=new c("sqrt",[new s("-","subtract",[new s("^","pow",[d.clone(),N(2)]),N(1)])]);break;case"atanh":S=!0,M=new s("-","subtract",[N(1),new s("^","pow",[d.clone(),N(2)])]);break;case"asech":S=!0,O=!0,M=new s("*","multiply",[d.clone(),new c("sqrt",[new s("-","subtract",[N(1),new s("^","pow",[d.clone(),N(2)])])])]);break;case"acsch":S=!0,O=!0,M=new s("*","multiply",[new c("abs",[d.clone()]),new c("sqrt",[new s("+","add",[new s("^","pow",[d.clone(),N(2)]),N(1)])])]);break;case"acoth":S=!0,O=!0,M=new s("-","subtract",[N(1),new s("^","pow",[d.clone(),N(2)])]);break;case"abs":M=new s("/","divide",[new c(new u("abs"),[d.clone()]),d.clone()]);break;case"gamma":default:throw new Error('Function "'+y.name+'" is not supported by derivative, or a wrong number of arguments is passed')}var _,E;S?(_="/",E="divide"):(_="*",E="multiply");var $=b(d,x);return O&&($=new s("-","unaryMinus",[$])),new s(_,E,[$,M])},"OperatorNode, Object":function(y,x){if(x[y]!==void 0)return N(0);if(y.op==="+")return new s(y.op,y.fn,y.args.map(function(I){return b(I,x)}));if(y.op==="-"){if(y.isUnary())return new s(y.op,y.fn,[b(y.args[0],x)]);if(y.isBinary())return new s(y.op,y.fn,[b(y.args[0],x),b(y.args[1],x)])}if(y.op==="*"){var d=y.args.filter(function(I){return x[I]!==void 0});if(d.length>0){var A=y.args.filter(function(I){return x[I]===void 0}),S=A.length===1?A[0]:new s("*","multiply",A),O=d.concat(b(S,x));return new s("*","multiply",O)}return new s("+","add",y.args.map(function(I){return new s("*","multiply",y.args.map(function(T){return T===I?b(T,x):T.clone()}))}))}if(y.op==="/"&&y.isBinary()){var M=y.args[0],_=y.args[1];return x[_]!==void 0?new s("/","divide",[b(M,x),_]):x[M]!==void 0?new s("*","multiply",[new s("-","unaryMinus",[M]),new s("/","divide",[b(_,x),new s("^","pow",[_.clone(),N(2)])])]):new s("/","divide",[new s("-","subtract",[new s("*","multiply",[b(M,x),_.clone()]),new s("*","multiply",[M.clone(),b(_,x)])]),new s("^","pow",[_.clone(),N(2)])])}if(y.op==="^"&&y.isBinary()){var E=y.args[0],$=y.args[1];if(x[E]!==void 0)return Ye(E)&&(l(E.value)||i(E.value,1))?N(0):new s("*","multiply",[y,new s("*","multiply",[new c("log",[E.clone()]),b($.clone(),x)])]);if(x[$]!==void 0){if(Ye($)){if(l($.value))return N(0);if(i($.value,1))return b(E,x)}var z=new s("^","pow",[E.clone(),new s("-","subtract",[$,N(1)])]);return new s("*","multiply",[$.clone(),new s("*","multiply",[b(E,x),z])])}return new s("*","multiply",[new s("^","pow",[E.clone(),$.clone()]),new s("+","add",[new s("*","multiply",[b(E,x),new s("/","divide",[$.clone(),E.clone()])]),new s("*","multiply",[b($,x),new c("log",[E.clone()])])])])}throw new Error('Operator "'+y.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function w(g){if(!((g.name==="log"||g.name==="nthRoot"||g.name==="pow")&&g.args.length===2)){for(var y=0;y<g.args.length;++y)g.args[y]=N(0);throw g.compile().evaluate(),new Error("Expected TypeError, but none found")}}function N(g,y){return new f(m(g,a.number))}return p}),vm="rationalize",rO=["config","typed","equal","isZero","add","subtract","multiply","divide","pow","parse","simplifyCore","simplify","?bignumber","?fraction","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode","ParenthesisNode"],tO=R(vm,rO,e=>{var{config:n,typed:a,equal:t,isZero:r,add:i,subtract:l,multiply:m,divide:f,pow:c,parse:s,simplifyCore:o,simplify:u,fraction:p,bignumber:v,mathWithTransform:h,matrix:b,AccessorNode:w,ArrayNode:N,ConstantNode:g,FunctionNode:y,IndexNode:x,ObjectNode:d,OperatorNode:A,SymbolNode:S,ParenthesisNode:O}=e,M=mm({typed:a,config:n,mathWithTransform:h,matrix:b,fraction:p,bignumber:v,AccessorNode:w,ArrayNode:N,ConstantNode:g,FunctionNode:y,IndexNode:x,ObjectNode:d,OperatorNode:A,SymbolNode:S});return a(vm,{string:function(T){return this(s(T),{},!1)},"string, boolean":function(T,B){return this(s(T),{},B)},"string, Object":function(T,B){return this(s(T),B,!1)},"string, Object, boolean":function(T,B,G){return this(s(T),B,G)},Node:function(T){return this(T,{},!1)},"Node, boolean":function(T,B){return this(T,{},B)},"Node, Object":function(T,B){return this(T,B,!1)},"Node, Object, boolean":function(T,B,G){var D=E(),H=_(T,B,!0,D.firstRules),W=H.variables.length,j={exactFractions:!1},V={exactFractions:!0};if(T=H.expression,W>=1){T=$(T);var K,te,re=!0,ie=!1;T=u(T,D.firstRules,{},j);for(var ne;te=re?D.distrDivRules:D.sucDivRules,T=u(T,te,{},V),re=!re,ne=T.toString(),ne!==K;)ie=!0,K=ne;ie&&(T=u(T,D.firstRulesAgain,{},j)),T=u(T,D.finalRules,{},j)}var ue=[],ee={};return T.type==="OperatorNode"&&T.isBinary()&&T.op==="/"?(W===1&&(T.args[0]=z(T.args[0],ue),T.args[1]=z(T.args[1])),G&&(ee.numerator=T.args[0],ee.denominator=T.args[1])):(W===1&&(T=z(T,ue)),G&&(ee.numerator=T,ee.denominator=null)),G?(ee.coefficients=ue,ee.variables=H.variables,ee.expression=T,ee):T}});function _(I,T,B,G){var D=[],H=u(I,G,T,{exactFractions:!1});B=!!B;var W="+-*"+(B?"/":"");V(H);var j={};return j.expression=H,j.variables=D,j;function V(K){var te=K.type;if(te==="FunctionNode")throw new Error("There is an unsolved function call");if(te==="OperatorNode")if(K.op==="^"){if(K.args[1].type!=="ConstantNode"||!Ae(parseFloat(K.args[1].value)))throw new Error("There is a non-integer exponent");V(K.args[0])}else{if(W.indexOf(K.op)===-1)throw new Error("Operator "+K.op+" invalid in polynomial expression");for(var re=0;re<K.args.length;re++)V(K.args[re])}else if(te==="SymbolNode"){var ie=K.name,ne=D.indexOf(ie);ne===-1&&D.push(ie)}else if(te==="ParenthesisNode")V(K.content);else if(te!=="ConstantNode")throw new Error("type "+te+" is not allowed in polynomial expression")}}function E(){var I=[o,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},M,{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)"}],B=[{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)"}],G=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],D={};return D.firstRules=I.concat(T,G),D.distrDivRules=B,D.sucDivRules=G,D.firstRulesAgain=I.concat(T),D.finalRules=[o,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},M,{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))"}],D}function $(I,T,B){var G=I.type,D=arguments.length>1;if(G==="OperatorNode"&&I.isBinary()){var H=!1,W;if(I.op==="^"&&(I.args[0].type==="ParenthesisNode"||I.args[0].type==="OperatorNode")&&I.args[1].type==="ConstantNode"&&(W=parseFloat(I.args[1].value),H=W>=2&&Ae(W)),H){if(W>2){var j=I.args[0],V=new A("^","pow",[I.args[0].cloneDeep(),new g(W-1)]);I=new A("*","multiply",[j,V])}else I=new A("*","multiply",[I.args[0],I.args[0].cloneDeep()]);D&&(B==="content"?T.content=I:T.args[B]=I)}}if(G==="ParenthesisNode")$(I.content,I,"content");else if(G!=="ConstantNode"&&G!=="SymbolNode")for(var K=0;K<I.args.length;K++)$(I.args[K],I,K);if(!D)return I}function z(I,T){T===void 0&&(T=[]),T[0]=0;var B={};B.cte=1,B.oper="+",B.fire="";var G=0,D="";ie(I,null,B),G=T.length-1;for(var H=!0,W,j=G;j>=0;j--)if(T[j]!==0){var V=new g(H?T[j]:Math.abs(T[j])),K=T[j]<0?"-":"+";if(j>0){var te=new S(D);if(j>1){var re=new g(j);te=new A("^","pow",[te,re])}T[j]===-1&&H?V=new A("-","unaryMinus",[te]):Math.abs(T[j])===1?V=te:V=new A("*","multiply",[V,te])}H?W=V:K==="+"?W=new A("+","add",[W,V]):W=new A("-","subtract",[W,V]),H=!1}if(H)return new g(0);return W;function ie(ne,ue,ee){var ye=ne.type;if(ye==="FunctionNode")throw new Error("There is an unsolved function call");if(ye==="OperatorNode"){if("+-*^".indexOf(ne.op)===-1)throw new Error("Operator "+ne.op+" invalid");if(ue!==null){if((ne.fn==="unaryMinus"||ne.fn==="pow")&&ue.fn!=="add"&&ue.fn!=="subtract"&&ue.fn!=="multiply")throw new Error("Invalid "+ne.op+" placing");if((ne.fn==="subtract"||ne.fn==="add"||ne.fn==="multiply")&&ue.fn!=="add"&&ue.fn!=="subtract")throw new Error("Invalid "+ne.op+" placing");if((ne.fn==="subtract"||ne.fn==="add"||ne.fn==="unaryMinus")&&ee.noFil!==0)throw new Error("Invalid "+ne.op+" placing")}(ne.op==="^"||ne.op==="*")&&(ee.fire=ne.op);for(var we=0;we<ne.args.length;we++)ne.fn==="unaryMinus"&&(ee.oper="-"),(ne.op==="+"||ne.fn==="subtract")&&(ee.fire="",ee.cte=1,ee.oper=we===0?"+":ne.op),ee.noFil=we,ie(ne.args[we],ne,ee)}else if(ye==="SymbolNode"){if(ne.name!==D&&D!=="")throw new Error("There is more than one variable");if(D=ne.name,ue===null){T[1]=1;return}if(ue.op==="^"&&ee.noFil!==0)throw new Error("In power the variable should be the first parameter");if(ue.op==="*"&&ee.noFil!==1)throw new Error("In multiply the variable should be the second parameter");(ee.fire===""||ee.fire==="*")&&(G<1&&(T[1]=0),T[1]+=ee.cte*(ee.oper==="+"?1:-1),G=Math.max(1,G))}else if(ye==="ConstantNode"){var me=parseFloat(ne.value);if(ue===null){T[0]=me;return}if(ue.op==="^"){if(ee.noFil!==1)throw new Error("Constant cannot be powered");if(!Ae(me)||me<=0)throw new Error("Non-integer exponent is not allowed");for(var xe=G+1;xe<me;xe++)T[xe]=0;me>G&&(T[me]=0),T[me]+=ee.cte*(ee.oper==="+"?1:-1),G=Math.max(me,G);return}ee.cte=me,ee.fire===""&&(T[0]+=ee.cte*(ee.oper==="+"?1:-1))}else throw new Error("Type "+ye+" is not allowed")}}}),nO="reviver",aO=["classes"],iO=R(nO,aO,e=>{var{classes:n}=e;return function(t,r){var i=n[r&&r.mathjs];return i&&typeof i.fromJSON=="function"?i.fromJSON(r):r}}),oO="replacer",sO=[],uO=R(oO,sO,()=>function(n,a){return typeof a=="number"&&(!isFinite(a)||isNaN(a))?{mathjs:"number",value:String(a)}:a}),cO="10.6.4",fO=R("true",[],()=>!0),lO=R("false",[],()=>!1),mO=R("null",[],()=>null),pO=Pr("Infinity",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(1/0):1/0}),vO=Pr("NaN",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(NaN):NaN}),hO=Pr("pi",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?Oi(a):Wh}),dO=Pr("tau",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?ob(a):Jh}),gO=Pr("e",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?ab(a):Qh}),yO=Pr("phi",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?ib(a):Kh}),xO=Pr("LN2",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(2).ln():Math.LN2}),bO=Pr("LN10",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(10).ln():Math.LN10}),wO=Pr("LOG2E",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(1).div(new a(2).ln()):Math.LOG2E}),NO=Pr("LOG10E",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(1).div(new a(10).ln()):Math.LOG10E}),MO=Pr("SQRT1_2",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a("0.5").sqrt():Math.SQRT1_2}),AO=Pr("SQRT2",["config","?BigNumber"],e=>{var{config:n,BigNumber:a}=e;return n.number==="BigNumber"?new a(2).sqrt():Math.SQRT2}),SO=Pr("i",["Complex"],e=>{var{Complex:n}=e;return n.I}),EO=R("version",[],()=>cO);function Pr(e,n,a){return R(e,n,a,{recreateOnConfigChange:!0})}var CO=Ie("speedOfLight","299792458","m s^-1"),OO=Ie("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),DO=Ie("planckConstant","6.62607015e-34","J s"),TO=Ie("reducedPlanckConstant","1.0545718176461565e-34","J s"),BO=Ie("magneticConstant","1.25663706212e-6","N A^-2"),_O=Ie("electricConstant","8.8541878128e-12","F m^-1"),$O=Ie("vacuumImpedance","376.730313667","ohm"),IO=Ie("coulomb","8.987551792261171e9","N m^2 C^-2"),qO=Ie("elementaryCharge","1.602176634e-19","C"),RO=Ie("bohrMagneton","9.2740100783e-24","J T^-1"),FO=Ie("conductanceQuantum","7.748091729863649e-5","S"),zO=Ie("inverseConductanceQuantum","12906.403729652257","ohm"),PO=Ie("magneticFluxQuantum","2.0678338484619295e-15","Wb"),UO=Ie("nuclearMagneton","5.0507837461e-27","J T^-1"),LO=Ie("klitzing","25812.807459304513","ohm"),kO=Ie("bohrRadius","5.29177210903e-11","m"),HO=Ie("classicalElectronRadius","2.8179403262e-15","m"),GO=Ie("electronMass","9.1093837015e-31","kg"),VO=Ie("fermiCoupling","1.1663787e-5","GeV^-2"),ZO=Pa("fineStructure",.0072973525693),XO=Ie("hartreeEnergy","4.3597447222071e-18","J"),YO=Ie("protonMass","1.67262192369e-27","kg"),WO=Ie("deuteronMass","3.3435830926e-27","kg"),JO=Ie("neutronMass","1.6749271613e-27","kg"),QO=Ie("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),KO=Ie("rydberg","10973731.568160","m^-1"),jO=Ie("thomsonCrossSection","6.6524587321e-29","m^2"),eD=Pa("weakMixingAngle",.2229),rD=Pa("efimovFactor",22.7),tD=Ie("atomicMass","1.66053906660e-27","kg"),nD=Ie("avogadro","6.02214076e23","mol^-1"),aD=Ie("boltzmann","1.380649e-23","J K^-1"),iD=Ie("faraday","96485.33212331001","C mol^-1"),oD=Ie("firstRadiation","3.7417718521927573e-16","W m^2"),sD=Ie("loschmidt","2.686780111798444e25","m^-3"),uD=Ie("gasConstant","8.31446261815324","J K^-1 mol^-1"),cD=Ie("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),fD=Ie("molarVolume","0.022413969545014137","m^3 mol^-1"),lD=Pa("sackurTetrode",-1.16487052358),mD=Ie("secondRadiation","0.014387768775039337","m K"),pD=Ie("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),vD=Ie("wienDisplacement","2.897771955e-3","m K"),hD=Ie("molarMass","0.99999999965e-3","kg mol^-1"),dD=Ie("molarMassC12","11.9999999958e-3","kg mol^-1"),gD=Ie("gravity","9.80665","m s^-2"),yD=Ie("planckLength","1.616255e-35","m"),xD=Ie("planckMass","2.176435e-8","kg"),bD=Ie("planckTime","5.391245e-44","s"),wD=Ie("planckCharge","1.87554603778e-18","C"),ND=Ie("planckTemperature","1.416785e+32","K");function Ie(e,n,a){var t=["config","Unit","BigNumber"];return R(e,t,r=>{var{config:i,Unit:l,BigNumber:m}=r,f=i.number==="BigNumber"?new m(n):parseFloat(n),c=new l(f,a);return c.fixPrefix=!0,c})}function Pa(e,n){var a=["config","BigNumber"];return R(e,a,t=>{var{config:r,BigNumber:i}=t;return r.number==="BigNumber"?new i(n):n})}var MD="apply",AD=["typed","isInteger"],SD=R(MD,AD,e=>{var{typed:n,isInteger:a}=e,t=cu({typed:n,isInteger:a});return n("apply",{"...any":function(i){var l=i[1];Be(l)?i[1]=l-1:_e(l)&&(i[1]=l.minus(1));try{return t.apply(null,i)}catch(m){throw Br(m)}}})},{isTransformFunction:!0}),ED="column",CD=["typed","Index","matrix","range"],OD=R(ED,CD,e=>{var{typed:n,Index:a,matrix:t,range:r}=e,i=Gu({typed:n,Index:a,matrix:t,range:r});return n("column",{"...any":function(m){var f=m.length-1,c=m[f];Be(c)&&(m[f]=c-1);try{return i.apply(null,m)}catch(s){throw Br(s)}}})},{isTransformFunction:!0});function Ui(e,n,a){var t=e.filter(function(m){return xr(m)&&!(m.name in n)&&!a.has(m.name)})[0];if(!t)throw new Error('No undefined variable found in inline expression "'+e+'"');var r=t.name,i=Pn(a),l=e.compile();return function(f){return i.set(r,f),l.evaluate(i)}}var DD="filter",TD=["typed"],BD=R(DD,TD,e=>{var{typed:n}=e;function a(r,i,l){var m,f;return r[0]&&(m=r[0].compile().evaluate(l)),r[1]&&(xr(r[1])||Cn(r[1])?f=r[1].compile().evaluate(l):f=Ui(r[1],i,l)),t(m,f)}a.rawArgs=!0;var t=n("filter",{"Array, function":hm,"Matrix, function":function(i,l){return i.create(hm(i.toArray(),l))},"Array, RegExp":oa,"Matrix, RegExp":function(i,l){return i.create(oa(i.toArray(),l))}});return a},{isTransformFunction:!0});function hm(e,n){var a=hn(n);return wo(e,function(t,r,i){return a===1?n(t):a===2?n(t,[r+1]):n(t,[r+1],i)})}var _D="forEach",$D=["typed"],ID=R(_D,$D,e=>{var{typed:n}=e;function a(r,i,l){var m,f;return r[0]&&(m=r[0].compile().evaluate(l)),r[1]&&(xr(r[1])||Cn(r[1])?f=r[1].compile().evaluate(l):f=Ui(r[1],i,l)),t(m,f)}a.rawArgs=!0;var t=n("forEach",{"Array | Matrix, function":function(i,l){var m=hn(l),f=function c(s,o){Array.isArray(s)?ia(s,function(u,p){c(u,o.concat(p+1))}):m===1?l(s):m===2?l(s,o):l(s,o,i)};f(i.valueOf(),[])}});return a},{isTransformFunction:!0}),qD="index",RD=["Index"],FD=R(qD,RD,e=>{var{Index:n}=e;return function(){for(var t=[],r=0,i=arguments.length;r<i;r++){var l=arguments[r];if(Kn(l))l.start--,l.end-=l.step>0?0:2;else if(l&&l.isSet===!0)l=l.map(function(f){return f-1});else if(Xe(l)||Oe(l))l=l.map(function(f){return f-1});else if(Be(l))l--;else if(_e(l))l=l.toNumber()-1;else if(typeof l!="string")throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");t[r]=l}var m=new n;return n.apply(m,t),m}},{isTransformFunction:!0}),zD="map",PD=["typed"],UD=R(zD,PD,e=>{var{typed:n}=e;function a(r,i,l){var m,f;return r[0]&&(m=r[0].compile().evaluate(l)),r[1]&&(xr(r[1])||Cn(r[1])?f=r[1].compile().evaluate(l):f=Ui(r[1],i,l)),t(m,f)}a.rawArgs=!0;var t=n("map",{"Array, function":function(i,l){return dm(i,l,i)},"Matrix, function":function(i,l){return i.create(dm(i.valueOf(),l,i))}});return a},{isTransformFunction:!0});function dm(e,n,a){var t=hn(n);function r(i,l){return Array.isArray(i)?dt(i,function(m,f){return r(m,l.concat(f+1))}):t===1?n(i):t===2?n(i,l):n(i,l,a)}return r(e,[])}function Zt(e){if(e.length===2&&rn(e[0])){e=e.slice();var n=e[1];Be(n)?e[1]=n-1:_e(n)&&(e[1]=n.minus(1))}return e}var LD="max",kD=["typed","config","numeric","larger"],HD=R(LD,kD,e=>{var{typed:n,config:a,numeric:t,larger:r}=e,i=sf({typed:n,config:a,numeric:t,larger:r});return n("max",{"...any":function(m){m=Zt(m);try{return i.apply(null,m)}catch(f){throw Br(f)}}})},{isTransformFunction:!0}),GD="mean",VD=["typed","add","divide"],ZD=R(GD,VD,e=>{var{typed:n,add:a,divide:t}=e,r=Tl({typed:n,add:a,divide:t});return n("mean",{"...any":function(l){l=Zt(l);try{return r.apply(null,l)}catch(m){throw Br(m)}}})},{isTransformFunction:!0}),XD="min",YD=["typed","config","numeric","smaller"],WD=R(XD,YD,e=>{var{typed:n,config:a,numeric:t,smaller:r}=e,i=cf({typed:n,config:a,numeric:t,smaller:r});return n("min",{"...any":function(m){m=Zt(m);try{return i.apply(null,m)}catch(f){throw Br(f)}}})},{isTransformFunction:!0}),JD="range",QD=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],KD=R(JD,QD,e=>{var{typed:n,config:a,matrix:t,bignumber:r,smaller:i,smallerEq:l,larger:m,largerEq:f}=e,c=oc({typed:n,config:a,matrix:t,bignumber:r,smaller:i,smallerEq:l,larger:m,largerEq:f});return n("range",{"...any":function(o){var u=o.length-1,p=o[u];return typeof p!="boolean"&&o.push(!0),c.apply(null,o)}})},{isTransformFunction:!0}),jD="row",eT=["typed","Index","matrix","range"],rT=R(jD,eT,e=>{var{typed:n,Index:a,matrix:t,range:r}=e,i=lc({typed:n,Index:a,matrix:t,range:r});return n("row",{"...any":function(m){var f=m.length-1,c=m[f];Be(c)&&(m[f]=c-1);try{return i.apply(null,m)}catch(s){throw Br(s)}}})},{isTransformFunction:!0}),tT="subset",nT=["typed","matrix"],aT=R(tT,nT,e=>{var{typed:n,matrix:a}=e,t=hc({typed:n,matrix:a});return n("subset",{"...any":function(i){try{return t.apply(null,i)}catch(l){throw Br(l)}}})},{isTransformFunction:!0}),iT="concat",oT=["typed","matrix","isInteger"],sT=R(iT,oT,e=>{var{typed:n,matrix:a,isInteger:t}=e,r=Lu({typed:n,matrix:a,isInteger:t});return n("concat",{"...any":function(l){var m=l.length-1,f=l[m];Be(f)?l[m]=f-1:_e(f)&&(l[m]=f.minus(1));try{return r.apply(null,l)}catch(c){throw Br(c)}}})},{isTransformFunction:!0}),gm="diff",uT=["typed","matrix","subtract","number","bignumber"],cT=R(gm,uT,e=>{var{typed:n,matrix:a,subtract:t,number:r,bignumber:i}=e,l=tc({typed:n,matrix:a,subtract:t,number:r,bignumber:i});return n(gm,{"...any":function(f){f=Zt(f);try{return l.apply(null,f)}catch(c){throw Br(c)}}})},{isTransformFunction:!0}),fT="std",lT=["typed","sqrt","variance"],mT=R(fT,lT,e=>{var{typed:n,sqrt:a,variance:t}=e,r=Rl({typed:n,sqrt:a,variance:t});return n("std",{"...any":function(l){l=Zt(l);try{return r.apply(null,l)}catch(m){throw Br(m)}}})},{isTransformFunction:!0}),ym="sum",pT=["typed","config","add","numeric"],vT=R(ym,pT,e=>{var{typed:n,config:a,add:t,numeric:r}=e,i=Cl({typed:n,config:a,add:t,numeric:r});return n(ym,{"...any":function(m){m=Zt(m);try{return i.apply(null,m)}catch(f){throw Br(f)}}})},{isTransformFunction:!0}),xm="cumsum",hT=["typed","add","unaryPlus"],dT=R(xm,hT,e=>{var{typed:n,add:a,unaryPlus:t}=e,r=Ol({typed:n,add:a,unaryPlus:t});return n(xm,{"...any":function(l){if(l.length===2&&rn(l[0])){var m=l[1];Be(m)?l[1]=m-1:_e(m)&&(l[1]=m.minus(1))}try{return r.apply(null,l)}catch(f){throw Br(f)}}})},{isTransformFunction:!0}),bm="variance",gT=["typed","add","subtract","multiply","divide","apply","isNaN"],yT=R(bm,gT,e=>{var{typed:n,add:a,subtract:t,multiply:r,divide:i,apply:l,isNaN:m}=e,f=Il({typed:n,add:a,subtract:t,multiply:r,divide:i,apply:l,isNaN:m});return n(bm,{"...any":function(s){s=Zt(s);try{return f.apply(null,s)}catch(o){throw Br(o)}}})},{isTransformFunction:!0}),le=bh({config:oe}),rr=Sh({}),wm=gO({BigNumber:le,config:oe}),xT=lO({}),bT=ZO({BigNumber:le,config:oe}),Xt=$h({}),Nm=SO({Complex:rr}),wT=pO({BigNumber:le,config:oe}),NT=bO({BigNumber:le,config:oe}),MT=NO({BigNumber:le,config:oe}),Ua=Ph({}),AT=vO({BigNumber:le,config:oe}),ST=mO({}),ET=yO({BigNumber:le,config:oe}),CT=Rh({}),Mm=Av({}),OT=MO({BigNumber:le,config:oe}),DT=lD({BigNumber:le,config:oe}),Am=dO({BigNumber:le,config:oe}),TT=fO({}),BT=EO({}),ze=kh({Matrix:Ua}),_T=rD({BigNumber:le,config:oe}),$T=xO({BigNumber:le,config:oe}),Sm=hO({BigNumber:le,config:oe}),IT=uO({}),qT=AO({BigNumber:le,config:oe}),Z=bv({BigNumber:le,Complex:rr,DenseMatrix:ze,Fraction:Xt}),Li=jd({BigNumber:le,config:oe,typed:Z}),RT=eD({BigNumber:le,config:oe}),Ur=rg({typed:Z}),FT=gb({Complex:rr,config:oe,typed:Z}),zT=wb({BigNumber:le,typed:Z}),PT=Sb({BigNumber:le,Complex:rr,config:oe,typed:Z}),vr=ig({typed:Z}),UT=Ly({typed:Z}),LT=Bb({BigNumber:le,Complex:rr,config:oe,typed:Z}),kT=Rb({typed:Z}),Em=Pb({typed:Z}),HT=Hb({Complex:rr,config:oe,typed:Z}),Mt=$d({BigNumber:le,typed:Z}),GT=$y({typed:Z}),VT=Td({typed:Z}),ZT=Gh({typed:Z}),La=kC({typed:Z}),ka=Rd({Complex:rr,typed:Z}),wn=Hy({typed:Z}),XT=Xb({typed:Z}),YT=Qb({BigNumber:le,typed:Z}),WT=jb({BigNumber:le,typed:Z}),JT=yg({typed:Z}),ke=yd({config:oe,typed:Z}),QT=u1({typed:Z}),Cm=bg({typed:Z}),KT=Ng({Complex:rr,typed:Z}),jT=l0({typed:Z}),eB=h0({typed:Z}),Un=g1({typed:Z}),rB=y0({typed:Z}),tB=M1({format:Un,typed:Z}),Om=Vy({typed:Z}),Zr=Zh({typed:Z}),Nn=nd({typed:Z}),Ha=cd({typed:Z}),ft=ld({typed:Z}),nB=wO({BigNumber:le,config:oe}),aB=YC({Complex:rr,typed:Z}),iB=Zg({Complex:rr,config:oe,typed:Z}),oB=Yg({Complex:rr,config:oe,typed:Z}),Dm=A0({typed:Z}),lr=ny({typed:Z}),Tm=Wy({typed:Z}),Ft=Ed({typed:Z}),sB=w1({format:Un,typed:Z}),uB=N3({config:oe,typed:Z}),cB=S1({typed:Z}),fB=A3({config:oe,typed:Z}),Bm=Xy({typed:Z}),lB=nw({BigNumber:le,typed:Z}),_m=cy({BigNumber:le,Fraction:Xt,complex:ka,typed:Z}),ki=sw({typed:Z}),At=wd({Matrix:Ua,equalScalar:ke,typed:Z}),mB=Wd({typed:Z}),pB=vy({typed:Z}),vB=Od({typed:Z}),hB=lw({typed:Z}),dB=hd({typed:Z}),gB=xb({Complex:rr,config:oe,typed:Z}),yB=Cb({BigNumber:le,typed:Z}),Hi=cu({isInteger:Zr,typed:Z}),xB=Db({BigNumber:le,Complex:rr,config:oe,typed:Z}),bB=x1({format:Un,typed:Z}),wB=GC({typed:Z}),Gi=Vb({typed:Z}),NB=rw({BigNumber:le,typed:Z}),Ln=pd({typed:Z}),MB=D1({typed:Z}),AB=E3({config:oe,typed:Z}),SB=iw({BigNumber:le,typed:Z}),EB=cw({typed:Z}),CB=pb({SparseMatrix:At,typed:Z}),St=my({Complex:rr,config:oe,typed:Z}),OB=vw({typed:Z}),Et=Qd({typed:Z}),DB=Mb({BigNumber:le,Complex:rr,config:oe,typed:Z}),TB=Wb({BigNumber:le,typed:Z}),kn=Pd({Fraction:Xt,typed:Z}),Yt=id({typed:Z}),de=Ld({DenseMatrix:ze,Matrix:Ua,SparseMatrix:At,typed:Z}),BB=Hd({isZero:ft,matrix:de,typed:Z}),$m=ey({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z}),_B=sy({BigNumber:le,equalScalar:ke,matrix:de,typed:Z}),tt=_1({bignumber:Mt,fraction:kn,number:Ft}),$B=Qy({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z}),Im=h1({config:oe,multiplyScalar:lr,numeric:tt,typed:Z}),IB=_0({isInteger:Zr,matrix:de,typed:Z}),Ar=k0({matrix:de,config:oe,typed:Z}),Xr=Cx({DenseMatrix:ze,config:oe,matrix:de,typed:Z}),qB=G0({matrix:de,typed:Z}),Yr=hc({matrix:de,typed:Z}),ir=dy({DenseMatrix:ze,addScalar:vr,equalScalar:ke,matrix:de,typed:Z,unaryMinus:Et}),RB=C1({matrix:de,typed:Z}),Vi=Q0({matrix:de,typed:Z}),qm=yy({BigNumber:le,config:oe,matrix:de,typed:Z}),lt=r1({BigNumber:le,config:oe,matrix:de,typed:Z}),FB=mx({equalScalar:ke,matrix:de,not:Tm,typed:Z,zeros:lt}),zB=By({equalScalar:ke,matrix:de,typed:Z}),PB=Py({DenseMatrix:ze,matrix:de,typed:Z}),UB=sg({BigNumber:le,Complex:rr,Fraction:Xt,config:oe,isNegative:Nn,matrix:de,typed:Z,unaryMinus:Et}),Mn=vx({BigNumber:le,DenseMatrix:ze,Fraction:Xt,config:oe,equalScalar:ke,matrix:de,typed:Z}),Rm=wx({matrix:de,typed:Z}),Zi=Lu({isInteger:Zr,matrix:de,typed:Z}),LB=n0({prod:Im,size:Ar,typed:Z}),Xi=j0({conj:wn,transpose:Vi,typed:Z}),Fm=s0({DenseMatrix:ze,SparseMatrix:At,matrix:de,typed:Z}),or=I1({numeric:tt,typed:Z}),Ga=Y1({DenseMatrix:ze,divideScalar:or,equalScalar:ke,matrix:de,typed:Z}),nt=Mx({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z}),zm=n1({addScalar:vr,divideScalar:or,exp:Cm,i:Nm,matrix:de,multiplyScalar:lr,tau:Am,typed:Z}),Hn=p0({matrix:de,typed:Z}),kB=zg({BigNumber:le,DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z}),HB=sd({isNumeric:Yt,typed:Z}),GB=zw({abs:Ur,addScalar:vr,divideScalar:or,isPositive:Ha,multiplyScalar:lr,smaller:Xr,sqrt:St,typed:Z}),VB=i1({conj:wn,dotDivide:Ga,fft:zm,typed:Z}),ZB=N0({matrix:de,multiplyScalar:lr,typed:Z}),Va=$x({DenseMatrix:ze,config:oe,matrix:de,typed:Z}),XB=ox({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z,zeros:lt}),Pm=J1({DenseMatrix:ze,divideScalar:or,equalScalar:ke,matrix:de,multiplyScalar:lr,subtract:ir,typed:Z}),Um=Xd({flatten:Hn,matrix:de,size:Ar,typed:Z}),YB=cf({config:oe,numeric:tt,smaller:Xr,typed:Z}),WB=p1({isNaN:Ln,isNumeric:Yt,typed:Z}),JB=G1({Complex:rr,config:oe,divideScalar:or,typed:Z}),QB=D0({BigNumber:le,config:oe,matrix:de,typed:Z}),Yi=Px({compare:Mn,isNaN:Ln,isNumeric:Yt,typed:Z}),KB=q0({config:oe,matrix:de}),jB=ux({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z,zeros:lt}),Gn=z1({BigNumber:le,DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z,zeros:lt}),Wi=Dx({DenseMatrix:ze,config:oe,matrix:de,typed:Z}),e4=Fx({DenseMatrix:ze,config:oe,equalScalar:ke,matrix:de,typed:Z}),Ji=K1({DenseMatrix:ze,divideScalar:or,equalScalar:ke,matrix:de,multiplyScalar:lr,subtract:ir,typed:Z}),r4=jy({DenseMatrix:ze,matrix:de,typed:Z}),sr=Rw({DenseMatrix:ze,SparseMatrix:At,addScalar:vr,equalScalar:ke,matrix:de,typed:Z}),t4=Lb({BigNumber:le,DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z}),n4=qy({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z}),a4=_3({addScalar:vr,combinations:La,divideScalar:or,isInteger:Zr,isNegative:Nn,multiplyScalar:lr,typed:Z}),mt=yx({compare:Mn,typed:Z}),i4=Ol({add:sr,typed:Z,unaryPlus:Li}),Lm=qx({equal:nt,typed:Z}),o4=tc({matrix:de,number:Ft,subtract:ir,typed:Z}),Za=kw({addScalar:vr,conj:wn,multiplyScalar:lr,size:Ar,typed:Z}),s4=Sx({compareText:Rm,isZero:ft,typed:Z}),km=Og({DenseMatrix:ze,config:oe,equalScalar:ke,matrix:de,round:Gn,typed:Z,zeros:lt}),An=b0({BigNumber:le,DenseMatrix:ze,SparseMatrix:At,config:oe,matrix:de,typed:Z}),u4=by({BigNumber:le,add:sr,config:oe,equal:nt,isInteger:Zr,mod:$m,smaller:Xr,typed:Z,xgcd:qm}),Wr=Bx({DenseMatrix:ze,config:oe,matrix:de,typed:Z}),Qi=U1({Complex:rr,config:oe,divideScalar:or,typed:Z}),c4=ex({DenseMatrix:ze,divideScalar:or,equalScalar:ke,matrix:de,multiplyScalar:lr,subtract:ir,typed:Z}),f4=Vd({flatten:Hn,matrix:de,size:Ar,typed:Z}),mr=iy({addScalar:vr,dot:Za,equalScalar:ke,matrix:de,multiplyScalar:lr,typed:Z}),Hm=sM({addScalar:vr,complex:ka,conj:wn,divideScalar:or,equal:nt,identity:An,isZero:ft,matrix:de,multiplyScalar:lr,sign:_m,sqrt:St,subtract:ir,typed:Z,unaryMinus:Et,zeros:lt}),Vn=oc({bignumber:Mt,matrix:de,config:oe,larger:Wr,largerEq:Va,smaller:Xr,smallerEq:Wi,typed:Z}),l4=fx({DenseMatrix:ze,equalScalar:ke,matrix:de,typed:Z,zeros:lt}),m4=Tw({compareNatural:mt,typed:Z}),Gm=BM({SparseMatrix:At,abs:Ur,add:sr,divideScalar:or,larger:Wr,largerEq:Va,multiply:mr,subtract:ir,transpose:Vi,typed:Z}),Vm=Cl({add:sr,config:oe,numeric:tt,typed:Z}),p4=Vw({add:sr,matrix:de,typed:Z}),Zm=tx({DenseMatrix:ze,divideScalar:or,equalScalar:ke,matrix:de,multiplyScalar:lr,subtract:ir,typed:Z}),v4=$b({Complex:rr,config:oe,typed:Z}),Xm=dg({DenseMatrix:ze,config:oe,equalScalar:ke,matrix:de,round:Gn,typed:Z,zeros:lt}),h4=I3({addScalar:vr,combinations:La,isInteger:Zr,isNegative:Nn,isPositive:Ha,larger:Wr,typed:Z}),d4=i0({matrix:de,multiply:mr,subtract:ir,typed:Z}),Ym=sC({divideScalar:or,isZero:ft,matrix:de,multiply:mr,subtract:ir,typed:Z,unaryMinus:Et}),g4=SC({abs:Ur,addScalar:vr,divideScalar:or,multiplyScalar:lr,sqrt:St,subtract:ir,typed:Z,unaryMinus:Et}),y4=Ay({equalScalar:ke,matrix:de,multiplyScalar:lr,typed:Z}),Wm=Kx({larger:Wr,smaller:Xr}),Jm=Sg({Complex:rr,DenseMatrix:ze,ceil:Xm,equalScalar:ke,floor:km,matrix:de,typed:Z,zeros:lt}),Qm=Zx({DenseMatrix:ze,smaller:Xr}),Sr=Wx({ImmutableDenseMatrix:Qm}),x4=OC({abs:Ur,add:sr,addScalar:vr,config:oe,divideScalar:or,equalScalar:ke,flatten:Hn,isNumeric:Yt,isZero:ft,matrix:de,multiply:mr,multiplyScalar:lr,smaller:Xr,subtract:ir,typed:Z}),b4=Gg({equalScalar:ke,matrix:de,typed:Z}),w4=k1({Complex:rr,config:oe,divideScalar:or,log:Qi,typed:Z}),Km=sf({config:oe,larger:Wr,numeric:tt,typed:Z}),N4=PC({add:sr,compare:Mn,multiply:mr,partitionSelect:Yi,typed:Z}),M4=lc({Index:Sr,matrix:de,range:Vn,typed:Z}),A4=dw({DenseMatrix:ze,Index:Sr,compareNatural:mt,size:Ar,subset:Yr,typed:Z}),S4=bw({DenseMatrix:ze,Index:Sr,compareNatural:mt,size:Ar,subset:Yr,typed:Z}),E4=Aw({Index:Sr,compareNatural:mt,size:Ar,subset:Yr,typed:Z}),C4=Ow({Index:Sr,compareNatural:mt,size:Ar,subset:Yr,typed:Z}),O4=Lx({compare:Mn,compareNatural:mt,matrix:de,typed:Z}),jm=Gu({Index:Sr,matrix:de,range:Vn,typed:Z}),D4=Xw({Index:Sr,typed:Z}),Wt=cC({abs:Ur,addScalar:vr,det:Ym,divideScalar:or,identity:An,matrix:de,multiply:mr,typed:Z,unaryMinus:Et}),T4=lC({Complex:rr,add:sr,ctranspose:Xi,deepEqual:Lm,divideScalar:or,dot:Za,dotDivide:Ga,equal:nt,inv:Wt,matrix:de,multiply:mr,typed:Z}),Ct=R1({Complex:rr,config:oe,fraction:kn,identity:An,inv:Wt,matrix:de,multiply:mr,number:Ft,typed:Z}),ep=yw({DenseMatrix:ze,Index:Sr,compareNatural:mt,size:Ar,subset:Yr,typed:Z}),B4=Ew({Index:Sr,compareNatural:mt,size:Ar,subset:Yr,typed:Z}),rp=rb({FibonacciHeap:Wm,addScalar:vr,equalScalar:ke}),_4=bC({abs:Ur,add:sr,identity:An,inv:Wt,max:Km,multiply:mr,size:Ar,sqrt:St,subtract:ir,typed:Z}),Te=cb({BigNumber:le,Complex:rr,Fraction:Xt,abs:Ur,addScalar:vr,config:oe,divideScalar:or,equal:nt,fix:Jm,format:Un,isNumeric:Yt,multiplyScalar:lr,number:Ft,pow:Ct,round:Gn,subtract:ir}),$4=$O({BigNumber:le,Unit:Te,config:oe}),I4=vD({BigNumber:le,Unit:Te,config:oe}),q4=tD({BigNumber:le,Unit:Te,config:oe}),R4=RO({BigNumber:le,Unit:Te,config:oe}),F4=aD({BigNumber:le,Unit:Te,config:oe}),z4=FO({BigNumber:le,Unit:Te,config:oe}),P4=hb({Unit:Te,typed:Z}),U4=WO({BigNumber:le,Unit:Te,config:oe}),L4=Z1({DenseMatrix:ze,equalScalar:ke,matrix:de,pow:Ct,typed:Z}),k4=_O({BigNumber:le,Unit:Te,config:oe}),H4=qO({BigNumber:le,Unit:Te,config:oe}),G4=yC({abs:Ur,add:sr,identity:An,inv:Wt,multiply:mr,typed:Z}),V4=iD({BigNumber:le,Unit:Te,config:oe}),Z4=oD({BigNumber:le,Unit:Te,config:oe}),tp=ZC({BigNumber:le,Complex:rr,config:oe,multiplyScalar:lr,pow:Ct,typed:Z}),X4=OO({BigNumber:le,Unit:Te,config:oe}),Y4=XO({BigNumber:le,Unit:Te,config:oe}),W4=LO({BigNumber:le,Unit:Te,config:oe}),J4=sD({BigNumber:le,Unit:Te,config:oe}),Q4=BO({BigNumber:le,Unit:Te,config:oe}),K4=hD({BigNumber:le,Unit:Te,config:oe}),j4=cD({BigNumber:le,Unit:Te,config:oe}),e_=JO({BigNumber:le,Unit:Te,config:oe}),r_=UO({BigNumber:le,Unit:Te,config:oe}),t_=wD({BigNumber:le,Unit:Te,config:oe}),n_=yD({BigNumber:le,Unit:Te,config:oe}),a_=ND({BigNumber:le,Unit:Te,config:oe}),i_=YO({BigNumber:le,Unit:Te,config:oe}),o_=TO({BigNumber:le,Unit:Te,config:oe}),s_=KO({BigNumber:le,Unit:Te,config:oe}),np=Nw({DenseMatrix:ze,Index:Sr,compareNatural:mt,size:Ar,subset:Yr,typed:Z}),u_=CO({BigNumber:le,Unit:Te,config:oe}),c_=pD({BigNumber:le,Unit:Te,config:oe}),f_=jO({BigNumber:le,Unit:Te,config:oe}),l_=nD({BigNumber:le,Unit:Te,config:oe}),m_=kO({BigNumber:le,Unit:Te,config:oe}),p_=IO({BigNumber:le,Unit:Te,config:oe}),at=MC({divideScalar:or,equalScalar:ke,inv:Wt,matrix:de,multiply:mr,typed:Z}),v_=GO({BigNumber:le,Unit:Te,config:oe}),Xa=JC({gamma:tp,typed:Z}),h_=gD({BigNumber:le,Unit:Te,config:oe}),d_=zO({BigNumber:le,Unit:Te,config:oe}),ap=iM({DenseMatrix:ze,Spa:rp,SparseMatrix:At,abs:Ur,addScalar:vr,divideScalar:or,equalScalar:ke,larger:Wr,matrix:de,multiplyScalar:lr,subtract:ir,typed:Z,unaryMinus:Et}),g_=PO({BigNumber:le,Unit:Te,config:oe}),y_=dD({BigNumber:le,Unit:Te,config:oe}),x_=e3({add:sr,divide:at,factorial:Xa,isInteger:Zr,isPositive:Ha,multiply:mr,typed:Z}),b_=t3({factorial:Xa,typed:Z}),w_=xD({BigNumber:le,Unit:Te,config:oe}),N_=QO({BigNumber:le,Unit:Te,config:oe}),M_=mD({BigNumber:le,Unit:Te,config:oe}),ip=O3({bignumber:Mt,addScalar:vr,combinations:La,divideScalar:or,factorial:Xa,isInteger:Zr,isNegative:Nn,larger:Wr,multiplyScalar:lr,number:Ft,pow:Ct,subtract:ir,typed:Z}),A_=lb({Unit:Te,typed:Z}),S_=T3({addScalar:vr,isInteger:Zr,isNegative:Nn,stirlingS2:ip,typed:Z}),op=dC({abs:Ur,add:sr,addScalar:vr,atan:Em,bignumber:Mt,column:jm,complex:ka,config:oe,cos:Gi,diag:Fm,divideScalar:or,dot:Za,equal:nt,flatten:Hn,im:Om,inv:Wt,larger:Wr,matrix:de,matrixFromColumns:Um,multiply:mr,multiplyScalar:lr,number:Ft,qr:Hm,re:Bm,sin:ki,smaller:Xr,sqrt:St,subtract:ir,typed:Z,usolve:Ji,usolveAll:Zm}),E_=VO({BigNumber:le,Unit:Te,config:oe}),C_=Tl({add:sr,divide:at,typed:Z}),O_=fD({BigNumber:le,Unit:Te,config:oe}),D_=DO({BigNumber:le,Unit:Te,config:oe}),sp=_w({Index:Sr,concat:Zi,setDifference:ep,size:Ar,subset:Yr,typed:Z}),T_=HO({BigNumber:le,Unit:Te,config:oe}),B_=$M({DenseMatrix:ze,lsolve:Pm,lup:ap,matrix:de,slu:Gm,typed:Z,usolve:Ji}),up=$C({add:sr,compare:Mn,divide:at,partitionSelect:Yi,typed:Z}),__=Iw({Index:Sr,concat:Zi,setIntersect:np,setSymDifference:sp,size:Ar,subset:Yr,typed:Z}),Ki=Il({add:sr,apply:Hi,divide:at,isNaN:Ln,multiply:mr,subtract:ir,typed:Z}),$_=KC({divide:at,dotDivide:Ga,isNumeric:Yt,log:Qi,matrix:de,multiply:mr,sum:Vm,typed:Z}),cp=Uw({abs:Ur,add:sr,conj:wn,ctranspose:Xi,eigs:op,equalScalar:ke,larger:Wr,matrix:de,multiply:mr,pow:Ct,smaller:Xr,sqrt:St,typed:Z}),I_=bD({BigNumber:le,Unit:Te,config:oe}),fp=P0({BigNumber:le,DenseMatrix:ze,SparseMatrix:At,addScalar:vr,config:oe,cos:Gi,matrix:de,multiplyScalar:lr,norm:cp,sin:ki,typed:Z,unaryMinus:Et}),q_=uD({BigNumber:le,Unit:Te,config:oe}),R_=Rl({sqrt:St,typed:Z,variance:Ki}),F_=qC({abs:Ur,map:Dm,median:up,subtract:ir,typed:Z}),z_=F0({multiply:mr,rotationMatrix:fp,typed:Z}),Sn={},Zn={},lp={},ji=PM({math:Sn}),Er=Jw({mathWithTransform:Zn}),Xn=ON({Node:Er}),zt=BN({Node:Er}),Jt=IN({Node:Er}),mp=UN({Node:Er}),Yn=tN({Node:Er}),pp=cN({Node:Er,ResultSet:Mm}),vp=mN({Node:Er}),Qt=xN({Node:Er}),hp=FN({Node:Er}),P_=iO({classes:lp}),U_=iC({Chain:ji,typed:Z}),dp=NN({Node:Er,typed:Z}),Wn=jw({Node:Er,subset:Yr}),gp=oN({matrix:de,Node:Er,subset:Yr}),Jn=SN({Node:Er,size:Ar}),Kt=HN({Unit:Te,Node:Er,math:Sn}),jt=ZN({Node:Er,SymbolNode:Kt,math:Sn}),pt=YN({AccessorNode:Wn,ArrayNode:Yn,AssignmentNode:gp,BlockNode:pp,ConditionalNode:vp,ConstantNode:Qt,FunctionAssignmentNode:dp,FunctionNode:jt,IndexNode:Jn,ObjectNode:Xn,OperatorNode:zt,ParenthesisNode:Jt,RangeNode:hp,RelationalNode:mp,SymbolNode:Kt,config:oe,numeric:tt,typed:Z}),yp=W3({ConstantNode:Qt,FunctionNode:jt,OperatorNode:zt,ParenthesisNode:Jt,parse:pt}),eo=Z3({AccessorNode:Wn,ArrayNode:Yn,ConstantNode:Qt,FunctionNode:jt,IndexNode:Jn,ObjectNode:Xn,OperatorNode:zt,ParenthesisNode:Jt,SymbolNode:Kt,add:sr,divide:at,equal:nt,isZero:ft,multiply:mr,pow:Ct,subtract:ir}),L_=JN({parse:pt,typed:Z}),xp=RM({parse:pt}),k_=R3({parse:pt,typed:Z}),Ya=H3({bignumber:Mt,fraction:kn,AccessorNode:Wn,ArrayNode:Yn,ConstantNode:Qt,FunctionNode:jt,IndexNode:Jn,ObjectNode:Xn,OperatorNode:zt,ParenthesisNode:Jt,SymbolNode:Kt,add:sr,config:oe,divide:at,equal:nt,isZero:ft,mathWithTransform:Zn,matrix:de,multiply:mr,parse:pt,pow:Ct,resolve:yp,simplifyCore:eo,subtract:ir,typed:Z}),H_=Q3({OperatorNode:zt,parse:pt,simplify:Ya,typed:Z}),ro=KN({parse:pt,typed:Z}),G_=nC({Help:xp,mathWithTransform:Zn,typed:Z}),bp=rM({evaluate:ro}),V_=tO({bignumber:Mt,fraction:kn,AccessorNode:Wn,ArrayNode:Yn,ConstantNode:Qt,FunctionNode:jt,IndexNode:Jn,ObjectNode:Xn,OperatorNode:zt,ParenthesisNode:Jt,SymbolNode:Kt,add:sr,config:oe,divide:at,equal:nt,isZero:ft,mathWithTransform:Zn,matrix:de,multiply:mr,parse:pt,pow:Ct,simplify:Ya,simplifyCore:eo,subtract:ir,typed:Z}),Z_=eO({ConstantNode:Qt,FunctionNode:jt,OperatorNode:zt,ParenthesisNode:Jt,SymbolNode:Kt,config:oe,equal:nt,isZero:ft,numeric:tt,parse:pt,simplify:Ya,typed:Z}),X_=nM({Parser:bp,typed:Z});ar(Sn,{e:wm,false:xT,fineStructure:bT,i:Nm,Infinity:wT,LN10:NT,LOG10E:MT,NaN:AT,null:ST,phi:ET,SQRT1_2:OT,sackurTetrode:DT,tau:Am,true:TT,E:wm,version:BT,efimovFactor:_T,LN2:$T,pi:Sm,replacer:IT,reviver:P_,SQRT2:qT,typed:Z,unaryPlus:Li,PI:Sm,weakMixingAngle:RT,abs:Ur,acos:FT,acot:zT,acsc:PT,addScalar:vr,arg:UT,asech:LT,asinh:kT,atan:Em,atanh:HT,bignumber:Mt,bitNot:GT,boolean:VT,chain:U_,clone:ZT,combinations:La,complex:ka,conj:wn,cosh:XT,coth:YT,csc:WT,cube:JT,equalScalar:ke,erf:QT,exp:Cm,expm1:KT,filter:jT,forEach:eB,format:Un,getMatrixDataType:rB,hex:tB,im:Om,isInteger:Zr,isNegative:Nn,isPositive:Ha,isZero:ft,LOG2E:nB,lgamma:aB,log10:iB,log2:oB,map:Dm,multiplyScalar:lr,not:Tm,number:Ft,oct:sB,pickRandom:uB,print:cB,random:fB,re:Bm,sec:lB,sign:_m,sin:ki,splitUnit:mB,square:pB,string:vB,tan:hB,typeOf:dB,acosh:gB,acsch:yB,apply:Hi,asec:xB,bin:bB,combinationsWithRep:wB,cos:Gi,csch:NB,isNaN:Ln,isPrime:MB,randomInt:AB,sech:SB,sinh:EB,sparse:CB,sqrt:St,tanh:OB,unaryMinus:Et,acoth:DB,cot:TB,fraction:kn,isNumeric:Yt,matrix:de,matrixFromFunction:BB,mod:$m,nthRoot:_B,numeric:tt,or:$B,prod:Im,reshape:IB,size:Ar,smaller:Xr,squeeze:qB,subset:Yr,subtract:ir,to:RB,transpose:Vi,xgcd:qm,zeros:lt,and:FB,bitAnd:zB,bitXor:PB,cbrt:UB,compare:Mn,compareText:Rm,concat:Zi,count:LB,ctranspose:Xi,diag:Fm,divideScalar:or,dotDivide:Ga,equal:nt,fft:zm,flatten:Hn,gcd:kB,hasNumericValue:HB,hypot:GB,ifft:VB,kron:ZB,largerEq:Va,leftShift:XB,lsolve:Pm,matrixFromColumns:Um,min:YB,mode:WB,nthRoots:JB,ones:QB,partitionSelect:Yi,resize:KB,rightArithShift:jB,round:Gn,smallerEq:Wi,unequal:e4,usolve:Ji,xor:r4,add:sr,atan2:t4,bitOr:n4,catalan:a4,compareNatural:mt,cumsum:i4,deepEqual:Lm,diff:o4,dot:Za,equalText:s4,floor:km,identity:An,invmod:u4,larger:Wr,log:Qi,lsolveAll:c4,matrixFromRows:f4,multiply:mr,qr:Hm,range:Vn,rightLogShift:l4,setSize:m4,slu:Gm,sum:Vm,trace:p4,usolveAll:Zm,asin:v4,ceil:Xm,composition:h4,cross:d4,det:Ym,distance:g4,dotMultiply:y4,fix:Jm,intersect:x4,lcm:b4,log1p:w4,max:Km,quantileSeq:N4,row:M4,setCartesian:A4,setDistinct:S4,setIsSubset:E4,setPowerset:C4,sort:O4,column:jm,index:D4,inv:Wt,pinv:T4,pow:Ct,setDifference:ep,setMultiplicity:B4,sqrtm:_4,vacuumImpedance:$4,wienDisplacement:I4,atomicMass:q4,bohrMagneton:R4,boltzmann:F4,conductanceQuantum:z4,createUnit:P4,deuteronMass:U4,dotPow:L4,electricConstant:k4,elementaryCharge:H4,expm:G4,faraday:V4,firstRadiation:Z4,gamma:tp,gravitationConstant:X4,hartreeEnergy:Y4,klitzing:W4,loschmidt:J4,magneticConstant:Q4,molarMass:K4,molarPlanckConstant:j4,neutronMass:e_,nuclearMagneton:r_,planckCharge:t_,planckLength:n_,planckTemperature:a_,protonMass:i_,reducedPlanckConstant:o_,rydberg:s_,setIntersect:np,speedOfLight:u_,stefanBoltzmann:c_,thomsonCrossSection:f_,avogadro:l_,bohrRadius:m_,coulomb:p_,divide:at,electronMass:v_,factorial:Xa,gravity:h_,inverseConductanceQuantum:d_,lup:ap,magneticFluxQuantum:g_,molarMassC12:y_,multinomial:x_,parse:pt,permutations:b_,planckMass:w_,quantumOfCirculation:N_,resolve:yp,secondRadiation:M_,simplifyCore:eo,stirlingS2:ip,unit:A_,bellNumbers:S_,compile:L_,eigs:op,fermiCoupling:E_,leafCount:k_,mean:C_,molarVolume:O_,planckConstant:D_,setSymDifference:sp,simplify:Ya,symbolicEqual:H_,classicalElectronRadius:T_,evaluate:ro,help:G_,lusolve:B_,median:up,rationalize:V_,setUnion:__,variance:Ki,derivative:Z_,kldivergence:$_,norm:cp,planckTime:I_,rotationMatrix:fp,gasConstant:q_,parser:X_,std:R_,mad:F_,rotate:z_,config:oe}),ar(Zn,Sn,{filter:BD({typed:Z}),forEach:ID({typed:Z}),map:UD({typed:Z}),apply:SD({isInteger:Zr,typed:Z}),diff:cT({bignumber:Mt,matrix:de,number:Ft,subtract:ir,typed:Z}),subset:aT({matrix:de,typed:Z}),concat:sT({isInteger:Zr,matrix:de,typed:Z}),max:HD({config:oe,larger:Wr,numeric:tt,typed:Z}),min:WD({config:oe,numeric:tt,smaller:Xr,typed:Z}),range:KD({bignumber:Mt,matrix:de,config:oe,larger:Wr,largerEq:Va,smaller:Xr,smallerEq:Wi,typed:Z}),sum:vT({add:sr,config:oe,numeric:tt,typed:Z}),cumsum:dT({add:sr,typed:Z,unaryPlus:Li}),row:rT({Index:Sr,matrix:de,range:Vn,typed:Z}),column:OD({Index:Sr,matrix:de,range:Vn,typed:Z}),index:FD({Index:Sr}),mean:ZD({add:sr,divide:at,typed:Z}),variance:yT({add:sr,apply:Hi,divide:at,isNaN:Ln,multiply:mr,subtract:ir,typed:Z}),std:mT({sqrt:St,typed:Z,variance:Ki})}),ar(lp,{BigNumber:le,Chain:ji,Complex:rr,Fraction:Xt,Matrix:Ua,Node:Er,ObjectNode:Xn,OperatorNode:zt,ParenthesisNode:Jt,Range:CT,RelationalNode:mp,ResultSet:Mm,ArrayNode:Yn,BlockNode:pp,ConditionalNode:vp,ConstantNode:Qt,DenseMatrix:ze,RangeNode:hp,FunctionAssignmentNode:dp,SparseMatrix:At,AccessorNode:Wn,AssignmentNode:gp,IndexNode:Jn,FibonacciHeap:Wm,ImmutableDenseMatrix:Qm,Index:Sr,Spa:rp,Unit:Te,SymbolNode:Kt,FunctionNode:jt,Help:xp,Parser:bp}),ji.createProxy(Sn);const Y_={label:"Math.js",tooltip:"{{t('Math.js comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types.')}}",link:"https://mathjs.org/",evaluate:Qr.evaluate.bind(function(e,n={}){const a=ro(e,n);return typeof a=="number"?Number.isNaN(a)||!Number.isFinite(a)?null:Gn(a,9):a},{replaceKey:!0})};class wp extends pr.Plugin{load(){return Np(this,null,function*(){Qr.evaluators.register("math.js",Y_)})}}fr.PluginMathjsEvaluatorClient=wp,fr.default=wp,Object.defineProperties(fr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
53
+ In 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"]},pE={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"]},vE={name:"cumsum",category:"Statistics",syntax:["cumsum(a, b, c, ...)","cumsum(A)"],description:"Compute the cumulative sum of all values.",examples:["cumsum(2, 3, 4, 1)","cumsum([2, 3, 4, 1])","cumsum([1, 2; 3, 4])","cumsum([1, 2; 3, 4], 1)","cumsum([1, 2; 3, 4], 2)"],seealso:["max","mean","median","min","prod","std","sum","variance"]},hE={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"]},dE={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"]},gE={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"]},yE={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"]},xE={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"]},bE={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"]},wE={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"]},NE={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"]},ME={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"]},AE={name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},SE={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"]},EE={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"]},CE={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"]},OE={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"]},DE={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"]},TE={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"]},BE={name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},$E={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"]},_E={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"]},IE={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"]},qE={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"]},RE={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"]},FE={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"]},zE={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"]},PE={name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},UE={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"]},LE={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"]},kE={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:[]},HE={name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},GE={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:[]},VE={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"]},ZE={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"]},XE={name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},YE={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"]},WE={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"]},JE={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"]},QE={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"]},KE={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"]},jE={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"]},eC={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"]},rC={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"]},tC={name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},nC={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"]},aC={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"]},iC={bignumber:i2,boolean:o2,complex:s2,createUnit:u2,fraction:c2,index:f2,matrix:l2,number:m2,sparse:p2,splitUnit:v2,string:h2,unit:d2,e:bl,E:bl,false:GM,i:VM,Infinity:ZM,LN2:YM,LN10:XM,LOG2E:JM,LOG10E:WM,NaN:QM,null:KM,pi:wl,PI:wl,phi:jM,SQRT1_2:e2,SQRT2:r2,tau:t2,true:n2,version:a2,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:b2,lsolve:N2,lsolveAll:M2,lup:A2,lusolve:S2,leafCount:w2,resolve:O2,simplify:D2,simplifyCore:T2,symbolicEqual:$2,rationalize:C2,slu:B2,usolve:_2,usolveAll:I2,qr:E2,abs:q2,add:R2,cbrt:F2,ceil:z2,cube:P2,divide:U2,dotDivide:L2,dotMultiply:k2,dotPow:H2,exp:G2,expm:V2,expm1:Z2,fix:X2,floor:Y2,gcd:W2,hypot:J2,lcm:K2,log:j2,log2:tA,log1p:rA,log10:eA,mod:nA,multiply:aA,norm:iA,nthRoot:oA,nthRoots:sA,pow:uA,round:cA,sign:fA,sqrt:lA,sqrtm:mA,square:pA,subtract:vA,unaryMinus:hA,unaryPlus:dA,xgcd:gA,invmod:Q2,bitAnd:yA,bitNot:xA,bitOr:bA,bitXor:wA,leftShift:NA,rightArithShift:MA,rightLogShift:AA,bellNumbers:SA,catalan:EA,composition:CA,stirlingS2:OA,config:g2,import:y2,typed:x2,arg:DA,conj:TA,re:$A,im:BA,evaluate:_A,help:IA,distance:qA,intersect:RA,and:FA,not:zA,or:PA,xor:UA,concat:kA,count:HA,cross:GA,column:LA,ctranspose:VA,det:ZA,diag:XA,diff:YA,dot:WA,getMatrixDataType:eS,identity:rS,filter:QA,flatten:KA,forEach:jA,inv:tS,pinv:nS,eigs:JA,kron:aS,matrixFromFunction:sS,matrixFromRows:uS,matrixFromColumns:oS,map:iS,ones:cS,partitionSelect:fS,range:lS,resize:pS,reshape:mS,rotate:vS,rotationMatrix:hS,row:dS,size:gS,sort:yS,squeeze:xS,subset:bS,trace:wS,transpose:NS,zeros:MS,fft:AS,ifft:SS,combinations:ES,combinationsWithRep:CS,factorial:OS,gamma:DS,kldivergence:BS,lgamma:TS,multinomial:$S,permutations:_S,pickRandom:IS,random:qS,randomInt:RS,compare:FS,compareNatural:zS,compareText:PS,deepEqual:US,equal:LS,equalText:kS,larger:HS,largerEq:GS,smaller:VS,smallerEq:ZS,unequal:XS,setCartesian:YS,setDifference:WS,setDistinct:JS,setIntersect:QS,setIsSubset:KS,setMultiplicity:jS,setPowerset:eE,setSize:rE,setSymDifference:tE,setUnion:nE,erf:aE,cumsum:vE,mad:iE,max:oE,mean:sE,median:uE,min:cE,mode:fE,prod:lE,quantileSeq:mE,std:pE,sum:hE,variance:dE,acos:gE,acosh:yE,acot:xE,acoth:bE,acsc:wE,acsch:NE,asec:ME,asech:AE,asin:SE,asinh:EE,atan:CE,atanh:DE,atan2:OE,cos:TE,cosh:BE,cot:$E,coth:_E,csc:IE,csch:qE,sec:RE,sech:FE,sin:zE,sinh:PE,tan:UE,tanh:LE,to:kE,clone:GE,format:VE,bin:HE,oct:tC,hex:XE,isNaN:WE,isInteger:YE,isNegative:JE,isNumeric:QE,hasNumericValue:ZE,isPositive:KE,isPrime:jE,isZero:eC,print:nC,typeOf:aC,numeric:rC},Nl="help",oC=["typed","mathWithTransform","Help"],sC=R(Nl,oC,e=>{var{typed:t,mathWithTransform:n,Help:a}=e;return t(Nl,{any:function(i){var u,l=i;if(typeof i!="string"){for(u in n)if(Ae(n,u)&&i===n[u]){l=u;break}}var f=Xr(iC,l);if(!f){var c=typeof l=="function"?l.name:l;throw new Error('No documentation found on "'+c+'"')}return new a(f)}})}),Ml="chain",uC=["typed","Chain"],cC=R(Ml,uC,e=>{var{typed:t,Chain:n}=e;return t(Ml,{"":function(){return new n},any:function(r){return new n(r)}})}),Al="det",fC=["typed","matrix","subtract","multiply","divideScalar","isZero","unaryMinus"],lC=R(Al,fC,e=>{var{typed:t,matrix:n,subtract:a,multiply:r,divideScalar:i,isZero:u,unaryMinus:l}=e;return t(Al,{any:function(o){return Oe(o)},"Array | Matrix":function(o){var s;switch(De(o)?s=o.size():Array.isArray(o)?(o=n(o),s=o.size()):s=[],s.length){case 0:return Oe(o);case 1:if(s[0]===1)return Oe(o.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+Fe(s)+")");case 2:{var m=s[0],p=s[1];if(m===p)return f(o.clone().valueOf(),m);throw new RangeError("Matrix must be square (size: "+Fe(s)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Fe(s)+")")}}});function f(c,o,s){if(o===1)return Oe(c[0][0]);if(o===2)return a(r(c[0][0],c[1][1]),r(c[1][0],c[0][1]));for(var m=!1,p=new Array(o).fill(0).map((A,S)=>S),v=0;v<o;v++){var h=p[v];if(u(c[h][v])){var b=void 0;for(b=v+1;b<o;b++)if(!u(c[p[b]][v])){h=p[b],p[b]=p[v],p[v]=h,m=!m;break}if(b===o)return c[h][v]}for(var w=c[h][v],N=v===0?1:c[p[v-1]][v-1],g=v+1;g<o;g++)for(var y=p[g],x=v+1;x<o;x++)c[y][x]=i(a(r(c[y][x],w),r(c[y][v],c[h][x])),N)}var d=c[p[o-1]][o-1];return m?l(d):d}}),Sl="inv",mC=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],pC=R(Sl,mC,e=>{var{typed:t,matrix:n,divideScalar:a,addScalar:r,multiply:i,unaryMinus:u,det:l,identity:f,abs:c}=e;return t(Sl,{"Array | Matrix":function(m){var p=De(m)?m.size():Ue(m);switch(p.length){case 1:if(p[0]===1)return De(m)?n([a(1,m.valueOf()[0])]):[a(1,m[0])];throw new RangeError("Matrix must be square (size: "+Fe(p)+")");case 2:{var v=p[0],h=p[1];if(v===h)return De(m)?n(o(m.valueOf(),v,h),m.storage()):o(m,v,h);throw new RangeError("Matrix must be square (size: "+Fe(p)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Fe(p)+")")}},any:function(m){return a(1,m)}});function o(s,m,p){var v,h,b,w,N;if(m===1){if(w=s[0][0],w===0)throw Error("Cannot calculate inverse, determinant is zero");return[[a(1,w)]]}else if(m===2){var g=l(s);if(g===0)throw Error("Cannot calculate inverse, determinant is zero");return[[a(s[1][1],g),a(u(s[0][1]),g)],[a(u(s[1][0]),g),a(s[0][0],g)]]}else{var y=s.concat();for(v=0;v<m;v++)y[v]=y[v].concat();for(var x=f(m).valueOf(),d=0;d<p;d++){var A=c(y[d][d]),S=d;for(v=d+1;v<m;)c(y[v][d])>A&&(A=c(y[v][d]),S=v),v++;if(A===0)throw Error("Cannot calculate inverse, determinant is zero");v=S,v!==d&&(N=y[d],y[d]=y[v],y[v]=N,N=x[d],x[d]=x[v],x[v]=N);var O=y[d],M=x[d];for(v=0;v<m;v++){var $=y[v],E=x[v];if(v!==d){if($[d]!==0){for(b=a(u($[d]),O[d]),h=d;h<p;h++)$[h]=r($[h],i(b,O[h]));for(h=0;h<p;h++)E[h]=r(E[h],i(b,M[h]))}}else{for(b=O[d],h=d;h<p;h++)$[h]=a($[h],b);for(h=0;h<p;h++)E[h]=a(E[h],b)}}}return x}}}),El="pinv",vC=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],hC=R(El,vC,e=>{var{typed:t,matrix:n,inv:a,deepEqual:r,equal:i,dotDivide:u,dot:l,ctranspose:f,divideScalar:c,multiply:o,add:s,Complex:m}=e;return t(El,{"Array | Matrix":function(g){var y=De(g)?g.size():Ue(g);switch(y.length){case 1:return w(g)?f(g):y[0]===1?a(g):u(f(g),l(g,g));case 2:{if(w(g))return f(g);var x=y[0],d=y[1];if(x===d)try{return a(g)}catch(A){if(!(A instanceof Error&&A.message.match(/Cannot calculate inverse, determinant is zero/)))throw A}return De(g)?n(p(g.valueOf(),x,d),g.storage()):p(g,x,d)}default:throw new RangeError("Matrix must be two dimensional (size: "+Fe(y)+")")}},any:function(g){return i(g,0)?Oe(g):c(1,g)}});function p(N,g,y){var{C:x,F:d}=h(N,g,y),A=o(a(o(f(x),x)),f(x)),S=o(f(d),a(o(d,f(d))));return o(S,A)}function v(N,g,y){for(var x=Oe(N),d=0,A=0;A<g;A++){if(y<=d)return x;for(var S=A;b(x[S][d]);)if(S++,g===S&&(S=A,d++,y===d))return x;[x[S],x[A]]=[x[A],x[S]];for(var O=x[A][d],M=0;M<y;M++)x[A][M]=u(x[A][M],O);for(var $=0;$<g;$++)if($!==A){O=x[$][d];for(var E=0;E<y;E++)x[$][E]=s(x[$][E],o(-1,o(O,x[A][E])))}d++}return x}function h(N,g,y){var x=v(N,g,y),d=N.map((S,O)=>S.filter((M,$)=>$<g&&!b(l(x[$],x[$])))),A=x.filter((S,O)=>!b(l(x[O],x[O])));return{C:d,F:A}}function b(N){return i(s(N,m(1,1)),s(0,m(1,1)))}function w(N){return r(s(N,m(1,1)),s(o(N,0),m(1,1)))}});function dC(e){var{addScalar:t,subtract:n,flatten:a,multiply:r,multiplyScalar:i,divideScalar:u,sqrt:l,abs:f,bignumber:c,diag:o,inv:s,qr:m,usolve:p,usolveAll:v,equal:h,complex:b,larger:w,smaller:N,matrixFromColumns:g,dot:y}=e;function x(H,W,j,V,K){K===void 0&&(K=!0);var te=d(H,W,j,V,K);A(H,W,j,V,K,te);var{values:re,C:oe}=S(H,W,j,V,K),ae;return K&&(ae=O(H,W,oe,te,re,j,V),ae=g(...ae)),{values:re,vectors:ae}}function d(H,W,j,V,K){var te=V==="BigNumber",re=V==="Complex",oe=te?c(0):0,ae=te?c(1):re?b(1):1,ce=te?c(1):1,ee=te?c(10):2,xe=i(ee,ee),Ne;K&&(Ne=Array(W).fill(ae));for(var pe=!1;!pe;){pe=!0;for(var be=0;be<W;be++){for(var F=oe,Y=oe,k=0;k<W;k++)if(be!==k){var U=f(H[be][k]);F=t(F,U),Y=t(Y,U)}if(!h(F,0)&&!h(Y,0)){for(var J=ce,q=F,P=u(Y,ee),Q=i(Y,ee);N(q,P);)q=i(q,xe),J=i(J,ee);for(;w(q,Q);)q=u(q,xe),J=u(J,ee);var L=N(u(t(q,Y),J),i(t(F,Y),.95));if(L){pe=!1;for(var ue=u(1,J),le=0;le<W;le++)be!==le&&(H[be][le]=i(H[be][le],J),H[le][be]=i(H[le][be],ue));K&&(Ne[be]=i(Ne[be],J))}}}}return o(Ne)}function A(H,W,j,V,K,te){var re=V==="BigNumber",oe=V==="Complex",ae=re?c(0):oe?b(0):0;re&&(j=c(j));for(var ce=0;ce<W-2;ce++){for(var ee=0,xe=ae,Ne=ce+1;Ne<W;Ne++){var pe=H[Ne][ce];N(f(xe),f(pe))&&(xe=pe,ee=Ne)}if(!N(f(xe),j)){if(ee!==ce+1){var be=H[ee];H[ee]=H[ce+1],H[ce+1]=be;for(var F=0;F<W;F++){var Y=H[F][ee];H[F][ee]=H[F][ce+1],H[F][ce+1]=Y}if(K){var k=te[ee];te[ee]=te[ce+1],te[ce+1]=k}}for(var U=ce+2;U<W;U++){var J=u(H[U][ce],xe);if(J!==0){for(var q=0;q<W;q++)H[U][q]=n(H[U][q],i(J,H[ce+1][q]));for(var P=0;P<W;P++)H[P][ce+1]=t(H[P][ce+1],i(J,H[P][U]));if(K)for(var Q=0;Q<W;Q++)te[U][Q]=n(te[U][Q],i(J,te[ce+1][Q]))}}}}return te}function S(H,W,j,V,K){var te=V==="BigNumber",re=V==="Complex",oe=te?c(1):re?b(1):1;te&&(j=c(j));for(var ae=Oe(H),ce=[],ee=W,xe=[],Ne=K?o(Array(W).fill(oe)):void 0,pe=K?o(Array(ee).fill(oe)):void 0,be=0;be<=100;){be+=1;for(var F=0,Y=0;Y<ee;Y++)ae[Y][Y]=n(ae[Y][Y],F);var{Q:k,R:U}=m(ae);ae=r(U,k);for(var J=0;J<ee;J++)ae[J][J]=t(ae[J][J],F);if(K&&(pe=r(pe,k)),ee===1||N(f(ae[ee-1][ee-2]),j)){be=0,ce.push(ae[ee-1][ee-1]),K&&(xe.unshift([[1]]),E(pe,W),Ne=r(Ne,pe),ee>1&&(pe=o(Array(ee-1).fill(oe)))),ee-=1,ae.pop();for(var q=0;q<ee;q++)ae[q].pop()}else if(ee===2||N(f(ae[ee-2][ee-3]),j)){be=0;var P=M(ae[ee-2][ee-2],ae[ee-2][ee-1],ae[ee-1][ee-2],ae[ee-1][ee-1]);ce.push(...P),K&&(xe.unshift($(ae[ee-2][ee-2],ae[ee-2][ee-1],ae[ee-1][ee-2],ae[ee-1][ee-1],P[0],P[1],j,V)),E(pe,W),Ne=r(Ne,pe),ee>2&&(pe=o(Array(ee-2).fill(oe)))),ee-=2,ae.pop(),ae.pop();for(var Q=0;Q<ee;Q++)ae[Q].pop(),ae[Q].pop()}if(ee===0)break}if(ce.sort((le,ye)=>+n(f(le),f(ye))),be>100){var L=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+ce.join(", "));throw L.values=ce,L.vectors=[],L}var ue=K?r(Ne,_(xe,W)):void 0;return{values:ce,C:ue}}function O(H,W,j,V,K,te,re){var oe=s(j),ae=r(oe,H,j),ce=re==="BigNumber",ee=re==="Complex",xe=ce?c(0):ee?b(0):0,Ne=ce?c(1):ee?b(1):1,pe=[],be=[];for(var F of K){var Y=z(pe,F,h);Y===-1?(pe.push(F),be.push(1)):be[Y]+=1}for(var k=[],U=pe.length,J=Array(W).fill(xe),q=o(Array(W).fill(Ne)),P=[],Q=function(ye){var ve=pe[ye],he=n(ae,r(ve,q)),Me=v(he,J);for(Me.shift();Me.length<be[ye];){var Ke=I(he,W,Me,te,re);if(Ke==null){P.push(ve);break}Me.push(Ke)}var fr=r(s(V),j);Me=Me.map(nr=>r(fr,nr)),k.push(...Me.map(nr=>a(nr)))},L=0;L<U;L++)Q(L);if(P.length!==0){var ue=new Error("Failed to find eigenvectors for the following eigenvalues: "+P.join(", "));throw ue.values=K,ue.vectors=k,ue}return k}function M(H,W,j,V){var K=t(H,V),te=n(i(H,V),i(W,j)),re=i(K,.5),oe=i(l(n(i(K,K),i(4,te))),.5);return[t(re,oe),n(re,oe)]}function $(H,W,j,V,K,te,re,oe){var ae=oe==="BigNumber",ce=oe==="Complex",ee=ae?c(0):ce?b(0):0,xe=ae?c(1):ce?b(1):1;if(N(f(j),re))return[[xe,ee],[ee,xe]];if(w(f(n(K,te)),re))return[[n(K,V),n(te,V)],[j,j]];var Ne=n(H,K),pe=n(W,K),be=n(j,K),F=n(V,K);return N(f(pe),re)?[[Ne,xe],[be,ee]]:[[pe,ee],[F,xe]]}function E(H,W){for(var j=0;j<H.length;j++)H[j].push(...Array(W-H[j].length).fill(0));for(var V=H.length;V<W;V++)H.push(Array(W).fill(0)),H[V][V]=1;return H}function _(H,W){for(var j=[],V=0;V<W;V++)j[V]=Array(W).fill(0);var K=0;for(var te of H){for(var re=te.length,oe=0;oe<re;oe++)for(var ae=0;ae<re;ae++)j[K+oe][K+ae]=te[oe][ae];K+=re}return j}function z(H,W,j){for(var V=0;V<H.length;V++)if(j(H[V],W))return V;return-1}function I(H,W,j,V,K){for(var te=K==="BigNumber"?c(1e3):1e3,re,oe=0;re=T(W,j,K),re=p(H,re),!w(G(re),te);)if(++oe>=5)return null;for(oe=0;;){var ae=p(H,re);if(N(G(B(re,[ae])),V))break;if(++oe>=10)return null;re=D(ae)}return re}function T(H,W,j){var V=j==="BigNumber",K=j==="Complex",te=Array(H).fill(0).map(re=>2*Math.random()-1);return V&&(te=te.map(re=>c(re))),K&&(te=te.map(re=>b(re))),te=B(te,W),D(te,j)}function B(H,W){for(var j of W)H=n(H,r(u(y(j,H),y(j,j)),j));return H}function G(H){return f(l(y(H,H)))}function D(H,W){var j=W==="BigNumber",V=W==="Complex",K=j?c(1):V?b(1):1;return r(u(K,G(H)),H)}return x}function gC(e){var{config:t,addScalar:n,subtract:a,abs:r,atan:i,cos:u,sin:l,multiplyScalar:f,inv:c,bignumber:o,multiply:s,add:m}=e;function p(M,$){var E=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t.epsilon,_=arguments.length>3?arguments[3]:void 0;if(_==="number")return v(M,E);if(_==="BigNumber")return h(M,E);throw TypeError("Unsupported data type: "+_)}function v(M,$){for(var E=M.length,_=Math.abs($/E),z,I=new Array(E),T=0;T<E;T++)I[T]=O(E,0),I[T][T]=1;for(var B=d(M);Math.abs(B[1])>=Math.abs(_);){var G=B[0][0],D=B[0][1];z=b(M[G][G],M[D][D],M[G][D]),M=x(M,z,G,D),I=N(I,z,G,D),B=d(M)}for(var H=O(E,0),W=0;W<E;W++)H[W]=M[W][W];return S(Oe(H),Oe(I))}function h(M,$){for(var E=M.length,_=r($/E),z,I=new Array(E),T=0;T<E;T++)I[T]=O(E,0),I[T][T]=1;for(var B=A(M);r(B[1])>=r(_);){var G=B[0][0],D=B[0][1];z=w(M[G][G],M[D][D],M[G][D]),M=y(M,z,G,D),I=g(I,z,G,D),B=A(M)}for(var H=O(E,0),W=0;W<E;W++)H[W]=M[W][W];return S(Oe(H),Oe(I))}function b(M,$,E){var _=$-M;return Math.abs(_)<=t.epsilon?Math.PI/4:.5*Math.atan(2*E/($-M))}function w(M,$,E){var _=a($,M);return r(_)<=t.epsilon?o(-1).acos().div(4):f(.5,i(s(2,E,c(_))))}function N(M,$,E,_){for(var z=M.length,I=Math.cos($),T=Math.sin($),B=O(z,0),G=O(z,0),D=0;D<z;D++)B[D]=I*M[D][E]-T*M[D][_],G[D]=T*M[D][E]+I*M[D][_];for(var H=0;H<z;H++)M[H][E]=B[H],M[H][_]=G[H];return M}function g(M,$,E,_){for(var z=M.length,I=u($),T=l($),B=O(z,o(0)),G=O(z,o(0)),D=0;D<z;D++)B[D]=a(f(I,M[D][E]),f(T,M[D][_])),G[D]=n(f(T,M[D][E]),f(I,M[D][_]));for(var H=0;H<z;H++)M[H][E]=B[H],M[H][_]=G[H];return M}function y(M,$,E,_){for(var z=M.length,I=o(u($)),T=o(l($)),B=f(I,I),G=f(T,T),D=O(z,o(0)),H=O(z,o(0)),W=s(o(2),I,T,M[E][_]),j=n(a(f(B,M[E][E]),W),f(G,M[_][_])),V=m(f(G,M[E][E]),W,f(B,M[_][_])),K=0;K<z;K++)D[K]=a(f(I,M[E][K]),f(T,M[_][K])),H[K]=n(f(T,M[E][K]),f(I,M[_][K]));M[E][E]=j,M[_][_]=V,M[E][_]=o(0),M[_][E]=o(0);for(var te=0;te<z;te++)te!==E&&te!==_&&(M[E][te]=D[te],M[te][E]=D[te],M[_][te]=H[te],M[te][_]=H[te]);return M}function x(M,$,E,_){for(var z=M.length,I=Math.cos($),T=Math.sin($),B=I*I,G=T*T,D=O(z,0),H=O(z,0),W=B*M[E][E]-2*I*T*M[E][_]+G*M[_][_],j=G*M[E][E]+2*I*T*M[E][_]+B*M[_][_],V=0;V<z;V++)D[V]=I*M[E][V]-T*M[_][V],H[V]=T*M[E][V]+I*M[_][V];M[E][E]=W,M[_][_]=j,M[E][_]=0,M[_][E]=0;for(var K=0;K<z;K++)K!==E&&K!==_&&(M[E][K]=D[K],M[K][E]=D[K],M[_][K]=H[K],M[K][_]=H[K]);return M}function d(M){for(var $=M.length,E=0,_=[0,1],z=0;z<$;z++)for(var I=z+1;I<$;I++)Math.abs(E)<Math.abs(M[z][I])&&(E=Math.abs(M[z][I]),_=[z,I]);return[_,E]}function A(M){for(var $=M.length,E=0,_=[0,1],z=0;z<$;z++)for(var I=z+1;I<$;I++)r(E)<r(M[z][I])&&(E=r(M[z][I]),_=[z,I]);return[_,E]}function S(M,$){for(var E=M.length,_=Array(E),z=Array(E),I=0;I<E;I++)z[I]=Array(E);for(var T=0;T<E;T++){for(var B=0,G=M[0],D=0;D<M.length;D++)r(M[D])<r(G)&&(B=D,G=M[B]);_[T]=M.splice(B,1)[0];for(var H=0;H<E;H++)z[H][T]=$[H][B],$[H].splice(B,1)}return{values:_,vectors:z}}function O(M,$){for(var E=new Array(M),_=0;_<M;_++)E[_]=$;return E}return p}var yC="eigs",xC=["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"],bC=R(yC,xC,e=>{var{config:t,typed:n,matrix:a,addScalar:r,subtract:i,equal:u,abs:l,atan:f,cos:c,sin:o,multiplyScalar:s,divideScalar:m,inv:p,bignumber:v,multiply:h,add:b,larger:w,column:N,flatten:g,number:y,complex:x,sqrt:d,diag:A,qr:S,usolve:O,usolveAll:M,im:$,re:E,smaller:_,matrixFromColumns:z,dot:I}=e,T=gC({config:t,addScalar:r,subtract:i,abs:l,atan:f,cos:c,sin:o,multiplyScalar:s,inv:p,bignumber:v,multiply:h,add:b}),B=dC({addScalar:r,subtract:i,multiply:h,multiplyScalar:s,flatten:g,divideScalar:m,sqrt:d,abs:l,bignumber:v,diag:A,qr:S,inv:p,usolve:O,usolveAll:M,equal:u,complex:x,larger:w,smaller:_,matrixFromColumns:z,dot:I});return n("eigs",{Array:function(K){var te=a(K);return G(te)},"Array, number|BigNumber":function(K,te){var re=a(K);return G(re,te)},Matrix:function(K){var{values:te,vectors:re}=G(K);return{values:a(te),vectors:a(re)}},"Matrix, number|BigNumber":function(K,te){var{values:re,vectors:oe}=G(K,te);return{values:a(re),vectors:a(oe)}}});function G(V,K){K===void 0&&(K=t.epsilon);var te=V.size();if(te.length!==2||te[0]!==te[1])throw new RangeError("Matrix must be square (size: "+Fe(te)+")");var re=V.toArray(),oe=te[0];if(H(re,oe,K)&&(W(re,oe),D(re,oe,K))){var ae=j(V,re,oe);return T(re,oe,K,ae)}var ce=j(V,re,oe);return B(re,oe,K,ce)}function D(V,K,te){for(var re=0;re<K;re++)for(var oe=re;oe<K;oe++)if(w(v(l(i(V[re][oe],V[oe][re]))),te))return!1;return!0}function H(V,K,te){for(var re=0;re<K;re++)for(var oe=0;oe<K;oe++)if(w(v(l($(V[re][oe]))),te))return!1;return!0}function W(V,K){for(var te=0;te<K;te++)for(var re=0;re<K;re++)V[te][re]=E(V[te][re])}function j(V,K,te){var re=V.datatype();if(re==="number"||re==="BigNumber"||re==="Complex")return re;for(var oe=!1,ae=!1,ce=!1,ee=0;ee<te;ee++)for(var xe=0;xe<te;xe++){var Ne=K[ee][xe];if($e(Ne)||xr(Ne))oe=!0;else if(_e(Ne))ae=!0;else if(Tr(Ne))ce=!0;else throw TypeError("Unsupported type in Matrix: "+je(Ne))}if(ae&&ce&&console.warn("Complex BigNumbers not supported, this operation will lose precission."),ce){for(var pe=0;pe<te;pe++)for(var be=0;be<te;be++)K[pe][be]=x(K[pe][be]);return"Complex"}if(ae){for(var F=0;F<te;F++)for(var Y=0;Y<te;Y++)K[F][Y]=v(K[F][Y]);return"BigNumber"}if(oe){for(var k=0;k<te;k++)for(var U=0;U<te;U++)K[k][U]=y(K[k][U]);return"number"}else throw TypeError("Matrix contains unsupported types only.")}}),Cl="expm",wC=["typed","abs","add","identity","inv","multiply"],NC=R(Cl,wC,e=>{var{typed:t,abs:n,add:a,identity:r,inv:i,multiply:u}=e;return t(Cl,{Matrix:function(s){var m=s.size();if(m.length!==2||m[0]!==m[1])throw new RangeError("Matrix must be square (size: "+Fe(m)+")");for(var p=m[0],v=1e-15,h=l(s),b=f(h,v),w=b.q,N=b.j,g=u(s,Math.pow(2,-N)),y=r(p),x=r(p),d=1,A=g,S=-1,O=1;O<=w;O++)O>1&&(A=u(A,g),S=-S),d=d*(w-O+1)/((2*w-O+1)*O),y=a(y,u(d,A)),x=a(x,u(d*S,A));for(var M=u(i(x),y),$=0;$<N;$++)M=u(M,M);return kt(s)?s.createSparseMatrix(M):M}});function l(o){for(var s=o.size()[0],m=0,p=0;p<s;p++){for(var v=0,h=0;h<s;h++)v+=n(o.get([p,h]));m=Math.max(v,m)}return m}function f(o,s){for(var m=30,p=0;p<m;p++)for(var v=0;v<=p;v++){var h=p-v;if(c(o,v,h)<s)return{q:v,j:h}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}function c(o,s,m){for(var p=1,v=2;v<=s;v++)p*=v;for(var h=p,b=s+1;b<=2*s;b++)h*=b;var w=h*(2*s+1);return 8*Math.pow(o/Math.pow(2,m),2*s)*p*p/(h*w)}}),Ol="sqrtm",MC=["typed","abs","add","multiply","sqrt","subtract","inv","size","max","identity"],AC=R(Ol,MC,e=>{var{typed:t,abs:n,add:a,multiply:r,sqrt:i,subtract:u,inv:l,size:f,max:c,identity:o}=e,s=1e3,m=1e-6;function p(v){var h,b=0,w=v,N=o(f(v));do{var g=w;if(w=r(.5,a(g,l(N))),N=r(.5,a(N,l(g))),h=c(n(u(w,g))),h>m&&++b>s)throw new Error("computing square root of matrix: iterative method could not converge")}while(h>m);return w}return t(Ol,{"Array | Matrix":function(h){var b=De(h)?h.size():Ue(h);switch(b.length){case 1:if(b[0]===1)return i(h);throw new RangeError("Matrix must be square (size: "+Fe(b)+")");case 2:{var w=b[0],N=b[1];if(w===N)return p(h);throw new RangeError("Matrix must be square (size: "+Fe(b)+")")}default:throw new RangeError("Matrix must be at most two dimensional (size: "+Fe(b)+")")}}})}),SC="divide",EC=["typed","matrix","multiply","equalScalar","divideScalar","inv"],CC=R(SC,EC,e=>{var{typed:t,matrix:n,multiply:a,equalScalar:r,divideScalar:i,inv:u}=e,l=Nr({typed:t,equalScalar:r}),f=Ve({typed:t});return t("divide",ti({"Array | Matrix, Array | Matrix":function(o,s){return a(o,u(s))},"DenseMatrix, any":function(o,s){return f(o,s,i,!1)},"SparseMatrix, any":function(o,s){return l(o,s,i,!1)},"Array, any":function(o,s){return f(n(o),s,i,!1).valueOf()},"any, Array | Matrix":function(o,s){return a(o,u(s))}},i.signatures))}),Dl="distance",OC=["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],DC=R(Dl,OC,e=>{var{typed:t,addScalar:n,subtract:a,multiplyScalar:r,divideScalar:i,unaryMinus:u,sqrt:l,abs:f}=e;return t(Dl,{"Array, Array, Array":function(x,d,A){if(x.length===2&&d.length===2&&A.length===2){if(!o(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!o(d))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!o(A))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var S=i(a(A[1],A[0]),a(d[1],d[0])),O=r(r(S,S),d[0]),M=u(r(S,d[0])),$=x[1];return b(x[0],x[1],O,M,$)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(x,d,A){if(Object.keys(x).length===2&&Object.keys(d).length===2&&Object.keys(A).length===2){if(!o(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!o(d))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!o(A))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"lineOnePtX"in d&&"lineOnePtY"in d&&"lineTwoPtX"in A&&"lineTwoPtY"in A){var S=i(a(A.lineTwoPtY,A.lineTwoPtX),a(d.lineOnePtY,d.lineOnePtX)),O=r(r(S,S),d.lineOnePtX),M=u(r(S,d.lineOnePtX)),$=x.pointX;return b(x.pointX,x.pointY,O,M,$)}else throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(x,d){if(x.length===2&&d.length===3){if(!o(x))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!s(d))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return b(x[0],x[1],d[0],d[1],d[2])}else if(x.length===3&&d.length===6){if(!s(x))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!p(d))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return w(x[0],x[1],x[2],d[0],d[1],d[2],d[3],d[4],d[5])}else if(x.length===d.length&&x.length>0){if(!m(x))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!m(d))throw new TypeError("All values of an array should be numbers or BigNumbers");return N(x,d)}else throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(x,d){if(Object.keys(x).length===2&&Object.keys(d).length===3){if(!o(x))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!s(d))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"xCoeffLine"in d&&"yCoeffLine"in d&&"constant"in d)return b(x.pointX,x.pointY,d.xCoeffLine,d.yCoeffLine,d.constant);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===3&&Object.keys(d).length===6){if(!s(x))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!p(d))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in x&&"pointY"in x&&"x0"in d&&"y0"in d&&"z0"in d&&"a"in d&&"b"in d&&"c"in d)return w(x.pointX,x.pointY,x.pointZ,d.x0,d.y0,d.z0,d.a,d.b,d.c);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===2&&Object.keys(d).length===2){if(!o(x))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!o(d))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in x&&"pointOneY"in x&&"pointTwoX"in d&&"pointTwoY"in d)return N([x.pointOneX,x.pointOneY],[d.pointTwoX,d.pointTwoY]);throw new TypeError("Key names do not match")}else if(Object.keys(x).length===3&&Object.keys(d).length===3){if(!s(x))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!s(d))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in x&&"pointOneY"in x&&"pointOneZ"in x&&"pointTwoX"in d&&"pointTwoY"in d&&"pointTwoZ"in d)return N([x.pointOneX,x.pointOneY,x.pointOneZ],[d.pointTwoX,d.pointTwoY,d.pointTwoZ]);throw new TypeError("Key names do not match")}else throw new TypeError("Invalid Arguments: Try again")},Array:function(x){if(!h(x))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return g(x)}});function c(y){return typeof y=="number"||_e(y)}function o(y){return y.constructor!==Array&&(y=v(y)),c(y[0])&&c(y[1])}function s(y){return y.constructor!==Array&&(y=v(y)),c(y[0])&&c(y[1])&&c(y[2])}function m(y){return Array.isArray(y)||(y=v(y)),y.every(c)}function p(y){return y.constructor!==Array&&(y=v(y)),c(y[0])&&c(y[1])&&c(y[2])&&c(y[3])&&c(y[4])&&c(y[5])}function v(y){for(var x=Object.keys(y),d=[],A=0;A<x.length;A++)d.push(y[x[A]]);return d}function h(y){if(y[0].length===2&&c(y[0][0])&&c(y[0][1])){if(y.some(x=>x.length!==2||!c(x[0])||!c(x[1])))return!1}else if(y[0].length===3&&c(y[0][0])&&c(y[0][1])&&c(y[0][2])){if(y.some(x=>x.length!==3||!c(x[0])||!c(x[1])||!c(x[2])))return!1}else return!1;return!0}function b(y,x,d,A,S){var O=f(n(n(r(d,y),r(A,x)),S)),M=l(n(r(d,d),r(A,A)));return i(O,M)}function w(y,x,d,A,S,O,M,$,E){var _=[a(r(a(S,x),E),r(a(O,d),$)),a(r(a(O,d),M),r(a(A,y),E)),a(r(a(A,y),$),r(a(S,x),M))];_=l(n(n(r(_[0],_[0]),r(_[1],_[1])),r(_[2],_[2])));var z=l(n(n(r(M,M),r($,$)),r(E,E)));return i(_,z)}function N(y,x){for(var d=y.length,A=0,S=0,O=0;O<d;O++)S=a(y[O],x[O]),A=n(r(S,S),A);return l(A)}function g(y){for(var x=[],d=[],A=[],S=0;S<y.length-1;S++)for(var O=S+1;O<y.length;O++)y[0].length===2?(d=[y[S][0],y[S][1]],A=[y[O][0],y[O][1]]):y[0].length===3&&(d=[y[S][0],y[S][1],y[S][2]],A=[y[O][0],y[O][1],y[O][2]]),x.push(N(d,A));return x}}),TC="intersect",BC=["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten","isZero","isNumeric"],$C=R(TC,BC,e=>{var{typed:t,config:n,abs:a,add:r,addScalar:i,matrix:u,multiply:l,multiplyScalar:f,divideScalar:c,subtract:o,smaller:s,equalScalar:m,flatten:p,isZero:v,isNumeric:h}=e;return t("intersect",{"Array, Array, Array":b,"Array, Array, Array, Array":w,"Matrix, Matrix, Matrix":function($,E,_){var z=b($.valueOf(),E.valueOf(),_.valueOf());return z===null?null:u(z)},"Matrix, Matrix, Matrix, Matrix":function($,E,_,z){var I=w($.valueOf(),E.valueOf(),_.valueOf(),z.valueOf());return I===null?null:u(I)}});function b(M,$,E){if(M=N(M),$=N($),E=N(E),!y(M))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!y($))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!x(E))throw new TypeError("Array with 4 numbers expected as third argument");return O(M[0],M[1],M[2],$[0],$[1],$[2],E[0],E[1],E[2],E[3])}function w(M,$,E,_){if(M=N(M),$=N($),E=N(E),_=N(_),M.length===2){if(!g(M))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!g($))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!g(E))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!g(_))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return d(M,$,E,_)}else if(M.length===3){if(!y(M))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!y($))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!y(E))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!y(_))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return S(M[0],M[1],M[2],$[0],$[1],$[2],E[0],E[1],E[2],_[0],_[1],_[2])}else throw new TypeError("Arrays with two or thee dimensional points expected")}function N(M){return M.length===1?M[0]:M.length>1&&Array.isArray(M[0])&&M.every($=>Array.isArray($)&&$.length===1)?p(M):M}function g(M){return M.length===2&&h(M[0])&&h(M[1])}function y(M){return M.length===3&&h(M[0])&&h(M[1])&&h(M[2])}function x(M){return M.length===4&&h(M[0])&&h(M[1])&&h(M[2])&&h(M[3])}function d(M,$,E,_){var z=M,I=E,T=o(z,$),B=o(I,_),G=o(f(T[0],B[1]),f(B[0],T[1]));if(v(G)||s(a(G),n.epsilon))return null;var D=f(B[0],z[1]),H=f(B[1],z[0]),W=f(B[0],I[1]),j=f(B[1],I[0]),V=c(i(o(o(D,H),W),j),G);return r(l(T,V),z)}function A(M,$,E,_,z,I,T,B,G,D,H,W){var j=f(o(M,$),o(E,_)),V=f(o(z,I),o(T,B)),K=f(o(G,D),o(H,W));return i(i(j,V),K)}function S(M,$,E,_,z,I,T,B,G,D,H,W){var j=A(M,T,D,T,$,B,H,B,E,G,W,G),V=A(D,T,_,M,H,B,z,$,W,G,I,E),K=A(M,T,_,M,$,B,z,$,E,G,I,E),te=A(D,T,D,T,H,B,H,B,W,G,W,G),re=A(_,M,_,M,z,$,z,$,I,E,I,E),oe=o(f(j,V),f(K,te)),ae=o(f(re,te),f(V,V));if(v(ae))return null;var ce=c(oe,ae),ee=c(i(j,f(ce,V)),te),xe=i(M,f(ce,o(_,M))),Ne=i($,f(ce,o(z,$))),pe=i(E,f(ce,o(I,E))),be=i(T,f(ee,o(D,T))),F=i(B,f(ee,o(H,B))),Y=i(G,f(ee,o(W,G)));return m(xe,be)&&m(Ne,F)&&m(pe,Y)?[xe,Ne,pe]:null}function O(M,$,E,_,z,I,T,B,G,D){var H=f(M,T),W=f(_,T),j=f($,B),V=f(z,B),K=f(E,G),te=f(I,G),re=o(o(o(D,H),j),K),oe=o(o(o(i(i(W,V),te),H),j),K),ae=c(re,oe),ce=i(M,f(ae,o(_,M))),ee=i($,f(ae,o(z,$))),xe=i(E,f(ae,o(I,E)));return[ce,ee,xe]}}),Tl="sum",_C=["typed","config","add","numeric"],Bl=R(Tl,_C,e=>{var{typed:t,config:n,add:a,numeric:r}=e;return t(Tl,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":u,"...":function(f){if(dn(f))throw new TypeError("Scalar values expected in function sum");return i(f)}});function i(l){var f;return Nt(l,function(c){try{f=f===void 0?c:a(f,c)}catch(o){throw $r(o,"sum",c)}}),f===void 0&&(f=r(0,n.number)),typeof f=="string"&&(f=r(f,n.number)),f}function u(l,f){try{var c=Ma(l,f,a);return c}catch(o){throw $r(o,"sum")}}}),qa="cumsum",IC=["typed","add","unaryPlus"],$l=R(qa,IC,e=>{var{typed:t,add:n,unaryPlus:a}=e;return t(qa,{Array:r,Matrix:function(c){return c.create(r(c.valueOf()))},"Array, number | BigNumber":u,"Matrix, number | BigNumber":function(c,o){return c.create(u(c.valueOf(),o))},"...":function(c){if(dn(c))throw new TypeError("All values expected to be scalar in function cumsum");return r(c)}});function r(f){try{return i(f)}catch(c){throw $r(c,qa)}}function i(f){if(f.length===0)return[];for(var c=[a(f[0])],o=1;o<f.length;++o)c.push(n(c[o-1],f[o]));return c}function u(f,c){var o=Ue(f);if(c<0||c>=o.length)throw new et(c,o.length);try{return l(f,c)}catch(s){throw $r(s,qa)}}function l(f,c){var o,s,m;if(c<=0){var p=f[0][0];if(Array.isArray(p)){for(m=Xo(f),s=[],o=0;o<m.length;o++)s[o]=l(m[o],c-1);return s}else return i(f)}else{for(s=[],o=0;o<f.length;o++)s[o]=l(f[o],c-1);return s}}}),_l="mean",qC=["typed","add","divide"],Il=R(_l,qC,e=>{var{typed:t,add:n,divide:a}=e;return t(_l,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":r,"...":function(l){if(dn(l))throw new TypeError("Scalar values expected in function mean");return i(l)}});function r(u,l){try{var f=Ma(u,l,n),c=Array.isArray(u)?Ue(u):u.size();return a(f,c[l])}catch(o){throw $r(o,"mean")}}function i(u){var l,f=0;if(Nt(u,function(c){try{l=l===void 0?c:n(l,c),f++}catch(o){throw $r(o,"mean",c)}}),f===0)throw new Error("Cannot calculate the mean of an empty array");return a(l,f)}}),ql="median",RC=["typed","add","divide","compare","partitionSelect"],FC=R(ql,RC,e=>{var{typed:t,add:n,divide:a,compare:r,partitionSelect:i}=e;function u(c){try{c=ke(c.valueOf());var o=c.length;if(o===0)throw new Error("Cannot calculate median of an empty array");if(o%2===0){for(var s=o/2-1,m=i(c,s+1),p=c[s],v=0;v<s;++v)r(c[v],p)>0&&(p=c[v]);return f(p,m)}else{var h=i(c,(o-1)/2);return l(h)}}catch(b){throw $r(b,"median")}}var l=t({"number | BigNumber | Complex | Unit":function(o){return o}}),f=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(o,s){return a(n(o,s),2)}});return t(ql,{"Array | Matrix":u,"Array | Matrix, number | BigNumber":function(o,s){throw new Error("median(A, dim) is not yet supported")},"...":function(o){if(dn(o))throw new TypeError("Scalar values expected in function median");return u(o)}})}),Rl="mad",zC=["typed","abs","map","median","subtract"],PC=R(Rl,zC,e=>{var{typed:t,abs:n,map:a,median:r,subtract:i}=e;return t(Rl,{"Array | Matrix":u,"...":function(f){return u(f)}});function u(l){if(l=ke(l.valueOf()),l.length===0)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var f=r(l);return r(a(l,function(c){return n(i(c,f))}))}catch(c){throw c instanceof TypeError&&c.message.indexOf("median")!==-1?new TypeError(c.message.replace("median","mad")):$r(c,"mad")}}}),Ui="unbiased",Fl="variance",UC=["typed","add","subtract","multiply","divide","apply","isNaN"],zl=R(Fl,UC,e=>{var{typed:t,add:n,subtract:a,multiply:r,divide:i,apply:u,isNaN:l}=e;return t(Fl,{"Array | Matrix":function(s){return f(s,Ui)},"Array | Matrix, string":f,"Array | Matrix, number | BigNumber":function(s,m){return c(s,m,Ui)},"Array | Matrix, number | BigNumber, string":c,"...":function(s){return f(s,Ui)}});function f(o,s){var m,p=0;if(o.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Nt(o,function(b){try{m=m===void 0?b:n(m,b),p++}catch(w){throw $r(w,"variance",b)}}),p===0)throw new Error("Cannot calculate variance of an empty array");var v=i(m,p);if(m=void 0,Nt(o,function(b){var w=a(b,v);m=m===void 0?r(w,w):n(m,r(w,w))}),l(m))return m;switch(s){case"uncorrected":return i(m,p);case"biased":return i(m,p+1);case"unbiased":{var h=_e(m)?m.mul(0):0;return p===1?h:i(m,p-1)}default:throw new Error('Unknown normalization "'+s+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function c(o,s,m){try{if(o.length===0)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return u(o,s,p=>f(p,m))}catch(p){throw $r(p,"variance")}}}),LC="quantileSeq",kC=["typed","add","multiply","partitionSelect","compare"],HC=R(LC,kC,e=>{var{typed:t,add:n,multiply:a,partitionSelect:r,compare:i}=e;function u(c,o,s){var m,p,v;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(an(c)){if(s=s||!1,typeof s=="boolean"){if(p=c.valueOf(),$e(o)){if(o<0)throw new Error("N/prob must be non-negative");if(o<=1)return l(p,o,s);if(o>1){if(!Se(o))throw new Error("N must be a positive integer");var h=o+1;m=new Array(o);for(var b=0;b<o;)m[b]=l(p,++b/h,s);return m}}if(_e(o)){var w=o.constructor;if(o.isNegative())throw new Error("N/prob must be non-negative");if(v=new w(1),o.lte(v))return new w(l(p,o,s));if(o.gt(v)){if(!o.isInteger())throw new Error("N must be a positive integer");var N=o.toNumber();if(N>4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var g=new w(N+1);m=new Array(N);for(var y=0;y<N;)m[y]=new w(l(p,new w(++y).div(g),s));return m}}if(Array.isArray(o)){m=new Array(o.length);for(var x=0;x<m.length;++x){var d=o[x];if($e(d)){if(d<0||d>1)throw new Error("Probability must be between 0 and 1, inclusive")}else if(_e(d)){if(v=new d.constructor(1),d.isNegative()||d.gt(v))throw new Error("Probability must be between 0 and 1, inclusive")}else throw new TypeError("Unexpected type of argument in function quantileSeq");m[x]=l(p,d,s)}return m}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}function l(c,o,s){var m=ke(c),p=m.length;if(p===0)throw new Error("Cannot calculate quantile of an empty sequence");if($e(o)){var v=o*(p-1),h=v%1;if(h===0){var b=s?m[v]:r(m,v);return f(b),b}var w=Math.floor(v),N,g;if(s)N=m[w],g=m[w+1];else{g=r(m,w+1),N=m[w];for(var y=0;y<w;++y)i(m[y],N)>0&&(N=m[y])}return f(N),f(g),n(a(N,1-h),a(g,h))}var x=o.times(p-1);if(x.isInteger()){x=x.toNumber();var d=s?m[x]:r(m,x);return f(d),d}var A=x.floor(),S=x.minus(A),O=A.toNumber(),M,$;if(s)M=m[O],$=m[O+1];else{$=r(m,O+1),M=m[O];for(var E=0;E<O;++E)i(m[E],M)>0&&(M=m[E])}f(M),f($);var _=new S.constructor(1);return n(a(M,_.minus(S)),a($,S))}var f=t({"number | BigNumber | Unit":function(o){return o}});return u}),Pl="std",GC=["typed","sqrt","variance"],Ul=R(Pl,GC,e=>{var{typed:t,sqrt:n,variance:a}=e;return t(Pl,{"Array | Matrix":r,"Array | Matrix, string":r,"Array | Matrix, number | BigNumber":r,"Array | Matrix, number | BigNumber, string":r,"...":function(u){return r(u)}});function r(i,u){if(i.length===0)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{return n(a.apply(null,arguments))}catch(l){throw l instanceof TypeError&&l.message.indexOf(" variance")!==-1?new TypeError(l.message.replace(" variance"," std")):l}}}),Ll="combinations",VC=["typed"],ZC=R(Ll,VC,e=>{var{typed:t}=e;return t(Ll,{"number, number":ws,"BigNumber, BigNumber":function(a,r){var i=a.constructor,u,l,f=a.minus(r),c=new i(1);if(!kl(a)||!kl(r))throw new TypeError("Positive integer value expected in function combinations");if(r.gt(a))throw new TypeError("k must be less than n in function combinations");if(u=c,r.lt(f))for(l=c;l.lte(f);l=l.plus(c))u=u.times(r.plus(l)).dividedBy(l);else for(l=c;l.lte(r);l=l.plus(c))u=u.times(f.plus(l)).dividedBy(l);return u}})});function kl(e){return e.isInteger()&&e.gte(0)}var Hl="combinationsWithRep",XC=["typed"],YC=R(Hl,XC,e=>{var{typed:t}=e;return t(Hl,{"number, number":function(a,r){if(!Se(a)||a<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!Se(r)||r<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(a<1)throw new TypeError("k must be less than or equal to n + k - 1");if(r<a-1){var i=Mt(a,a+r-1);return i/Mt(1,r)}var u=Mt(r+1,a+r-1);return u/Mt(1,a-1)},"BigNumber, BigNumber":function(a,r){var i=a.constructor,u,l,f=new i(1),c=a.minus(f);if(!Gl(a)||!Gl(r))throw new TypeError("Positive integer value expected in function combinationsWithRep");if(a.lt(f))throw new TypeError("k must be less than or equal to n + k - 1 in function combinationsWithRep");if(u=f,r.lt(c))for(l=f;l.lte(c);l=l.plus(f))u=u.times(r.plus(l)).dividedBy(l);else for(l=f;l.lte(r);l=l.plus(f))u=u.times(c.plus(l)).dividedBy(l);return u}})});function Gl(e){return e.isInteger()&&e.gte(0)}var Vl="gamma",WC=["typed","config","multiplyScalar","pow","BigNumber","Complex"],JC=R(Vl,WC,e=>{var{typed:t,config:n,multiplyScalar:a,pow:r,BigNumber:i,Complex:u}=e;return t(Vl,{number:Mi,Complex:function(c){if(c.im===0)return this(c.re);if(c.re<.5){var o=new u(1-c.re,-c.im),s=new u(Math.PI*c.re,Math.PI*c.im);return new u(Math.PI).div(s.sin()).div(this(o))}c=new u(c.re-1,c.im);for(var m=new u(yn[0],0),p=1;p<yn.length;++p){var v=new u(yn[p],0);m=m.add(v.div(c.add(p)))}var h=new u(c.re+Es+.5,c.im),b=Math.sqrt(2*Math.PI),w=h.pow(c.add(.5)),N=h.neg().exp();return m.mul(b).mul(w).mul(N)},BigNumber:function(c){if(c.isInteger())return c.isNegative()||c.isZero()?new i(1/0):l(c.minus(1));if(!c.isFinite())return new i(c.isNegative()?NaN:1/0);throw new Error("Integer BigNumber expected")},"Array | Matrix":function(c){return we(c,this)}});function l(f){if(f<8)return new i([1,1,2,6,24,120,720,5040][f]);var c=n.precision+(Math.log(f.toNumber())|0),o=i.clone({precision:c});if(f%2===1)return f.times(l(new i(f-1)));for(var s=f,m=new o(f),p=f.toNumber();s>2;)s-=2,p+=s,m=m.times(p);return new i(m.toPrecision(i.precision))}}),Zl="lgamma",QC=["Complex","typed"],KC=R(Zl,QC,e=>{var{Complex:t,typed:n}=e,a=7,r=7,i=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return n(Zl,{number:Sa,Complex:function(c){var o=6.283185307179586,s=1.1447298858494002,m=.1;if(c.isNaN())return new t(NaN,NaN);if(c.im===0)return new t(Sa(c.re),0);if(c.re>=a||Math.abs(c.im)>=r)return u(c);if(c.re<=m){var p=sv(o,c.im)*Math.floor(.5*c.re+.25),v=c.mul(Math.PI).sin().log(),h=this(new t(1-c.re,-c.im));return new t(s,p).sub(v).sub(h)}else return c.im>=0?l(c):l(c.conjugate()).conjugate()},BigNumber:function(){throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function u(f){for(var c=f.sub(.5).mul(f.log()).sub(f).add(Cs),o=new t(1,0).div(f),s=o.div(f),m=i[0],p=i[1],v=2*s.re,h=s.re*s.re+s.im*s.im,b=2;b<8;b++){var w=p;p=-h*m+i[b],m=v*m+w}var N=o.mul(s.mul(m).add(p));return c.add(N)}function l(f){var c=0,o=0,s=f;for(f=f.add(1);f.re<=a;){s=s.mul(f);var m=s.im<0?1:0;m!==0&&o===0&&c++,o=m,f=f.add(1)}return u(f).sub(s.log()).sub(new t(0,c*2*Math.PI*1))}}),Xl="factorial",jC=["typed","gamma"],e3=R(Xl,jC,e=>{var{typed:t,gamma:n}=e;return t(Xl,{number:function(r){if(r<0)throw new Error("Value must be non-negative");return n(r+1)},BigNumber:function(r){if(r.isNegative())throw new Error("Value must be non-negative");return n(r.plus(1))},"Array | Matrix":function(r){return we(r,this)}})}),Yl="kldivergence",r3=["typed","matrix","divide","sum","multiply","dotDivide","log","isNumeric"],t3=R(Yl,r3,e=>{var{typed:t,matrix:n,divide:a,sum:r,multiply:i,dotDivide:u,log:l,isNumeric:f}=e;return t(Yl,{"Array, Array":function(s,m){return c(n(s),n(m))},"Matrix, Array":function(s,m){return c(s,n(m))},"Array, Matrix":function(s,m){return c(n(s),m)},"Matrix, Matrix":function(s,m){return c(s,m)}});function c(o,s){var m=s.size().length,p=o.size().length;if(m>1)throw new Error("first object must be one dimensional");if(p>1)throw new Error("second object must be one dimensional");if(m!==p)throw new Error("Length of two vectors must be equal");var v=r(o);if(v===0)throw new Error("Sum of elements in first object must be non zero");var h=r(s);if(h===0)throw new Error("Sum of elements in second object must be non zero");var b=a(o,r(o)),w=a(s,r(s)),N=r(i(b,l(u(b,w))));return f(N)?N:Number.NaN}}),Wl="multinomial",n3=["typed","add","divide","multiply","factorial","isInteger","isPositive"],a3=R(Wl,n3,e=>{var{typed:t,add:n,divide:a,multiply:r,factorial:i,isInteger:u,isPositive:l}=e;return t(Wl,{"Array | Matrix":function(c){var o=0,s=1;return Nt(c,function(m){if(!u(m)||!l(m))throw new TypeError("Positive integer value expected in function multinomial");o=n(o,m),s=r(s,i(m))}),a(i(o),s)}})}),Jl="permutations",i3=["typed","factorial"],o3=R(Jl,i3,e=>{var{typed:t,factorial:n}=e;return t(Jl,{"number | BigNumber":n,"number, number":function(r,i){if(!Se(r)||r<0)throw new TypeError("Positive integer value expected in function permutations");if(!Se(i)||i<0)throw new TypeError("Positive integer value expected in function permutations");if(i>r)throw new TypeError("second argument k must be less than or equal to first argument n");return Mt(r-i+1,r)},"BigNumber, BigNumber":function(r,i){var u,l;if(!Ql(r)||!Ql(i))throw new TypeError("Positive integer value expected in function permutations");if(i.gt(r))throw new TypeError("second argument k must be less than or equal to first argument n");var f=r.mul(0).add(1);for(u=f,l=r.minus(i).plus(1);l.lte(r);l=l.plus(1))u=u.times(l);return u}})});function Ql(e){return e.isInteger()&&e.gte(0)}var Ra={exports:{}},s3=Ra.exports,Kl;function u3(){return Kl||(Kl=1,function(e){(function(t,n,a){function r(f){var c=this,o=l();c.next=function(){var s=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=s-(c.c=s|0)},c.c=1,c.s0=o(" "),c.s1=o(" "),c.s2=o(" "),c.s0-=o(f),c.s0<0&&(c.s0+=1),c.s1-=o(f),c.s1<0&&(c.s1+=1),c.s2-=o(f),c.s2<0&&(c.s2+=1),o=null}function i(f,c){return c.c=f.c,c.s0=f.s0,c.s1=f.s1,c.s2=f.s2,c}function u(f,c){var o=new r(f),s=c&&c.state,m=o.next;return m.int32=function(){return o.next()*4294967296|0},m.double=function(){return m()+(m()*2097152|0)*11102230246251565e-32},m.quick=m,s&&(typeof s=="object"&&i(s,o),m.state=function(){return i(o,{})}),m}function l(){var f=4022871197,c=function(o){o=String(o);for(var s=0;s<o.length;s++){f+=o.charCodeAt(s);var m=.02519603282416938*f;f=m>>>0,m-=f,m*=f,f=m>>>0,m-=f,f+=m*4294967296}return(f>>>0)*23283064365386963e-26};return c}n&&n.exports?n.exports=u:this.alea=u})(s3,e)}(Ra)),Ra.exports}var Fa={exports:{}},c3=Fa.exports,jl;function f3(){return jl||(jl=1,function(e){(function(t,n,a){function r(l){var f=this,c="";f.x=0,f.y=0,f.z=0,f.w=0,f.next=function(){var s=f.x^f.x<<11;return f.x=f.y,f.y=f.z,f.z=f.w,f.w^=f.w>>>19^s^s>>>8},l===(l|0)?f.x=l:c+=l;for(var o=0;o<c.length+64;o++)f.x^=c.charCodeAt(o)|0,f.next()}function i(l,f){return f.x=l.x,f.y=l.y,f.z=l.z,f.w=l.w,f}function u(l,f){var c=new r(l),o=f&&f.state,s=function(){return(c.next()>>>0)/4294967296};return s.double=function(){do var m=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(m+p)/(1<<21);while(v===0);return v},s.int32=c.next,s.quick=s,o&&(typeof o=="object"&&i(o,c),s.state=function(){return i(c,{})}),s}n&&n.exports?n.exports=u:this.xor128=u})(c3,e)}(Fa)),Fa.exports}var za={exports:{}},l3=za.exports,em;function m3(){return em||(em=1,function(e){(function(t,n,a){function r(l){var f=this,c="";f.next=function(){var s=f.x^f.x>>>2;return f.x=f.y,f.y=f.z,f.z=f.w,f.w=f.v,(f.d=f.d+362437|0)+(f.v=f.v^f.v<<4^(s^s<<1))|0},f.x=0,f.y=0,f.z=0,f.w=0,f.v=0,l===(l|0)?f.x=l:c+=l;for(var o=0;o<c.length+64;o++)f.x^=c.charCodeAt(o)|0,o==c.length&&(f.d=f.x<<10^f.x>>>4),f.next()}function i(l,f){return f.x=l.x,f.y=l.y,f.z=l.z,f.w=l.w,f.v=l.v,f.d=l.d,f}function u(l,f){var c=new r(l),o=f&&f.state,s=function(){return(c.next()>>>0)/4294967296};return s.double=function(){do var m=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(m+p)/(1<<21);while(v===0);return v},s.int32=c.next,s.quick=s,o&&(typeof o=="object"&&i(o,c),s.state=function(){return i(c,{})}),s}n&&n.exports?n.exports=u:this.xorwow=u})(l3,e)}(za)),za.exports}var Pa={exports:{}},p3=Pa.exports,rm;function v3(){return rm||(rm=1,function(e){(function(t,n,a){function r(l){var f=this;f.next=function(){var o=f.x,s=f.i,m,p;return m=o[s],m^=m>>>7,p=m^m<<24,m=o[s+1&7],p^=m^m>>>10,m=o[s+3&7],p^=m^m>>>3,m=o[s+4&7],p^=m^m<<7,m=o[s+7&7],m=m^m<<13,p^=m^m<<9,o[s]=p,f.i=s+1&7,p};function c(o,s){var m,p=[];if(s===(s|0))p[0]=s;else for(s=""+s,m=0;m<s.length;++m)p[m&7]=p[m&7]<<15^s.charCodeAt(m)+p[m+1&7]<<13;for(;p.length<8;)p.push(0);for(m=0;m<8&&p[m]===0;++m);for(m==8?p[7]=-1:p[m],o.x=p,o.i=0,m=256;m>0;--m)o.next()}c(f,l)}function i(l,f){return f.x=l.x.slice(),f.i=l.i,f}function u(l,f){l==null&&(l=+new Date);var c=new r(l),o=f&&f.state,s=function(){return(c.next()>>>0)/4294967296};return s.double=function(){do var m=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(m+p)/(1<<21);while(v===0);return v},s.int32=c.next,s.quick=s,o&&(o.x&&i(o,c),s.state=function(){return i(c,{})}),s}n&&n.exports?n.exports=u:this.xorshift7=u})(p3,e)}(Pa)),Pa.exports}var Ua={exports:{}},h3=Ua.exports,tm;function d3(){return tm||(tm=1,function(e){(function(t,n,a){function r(l){var f=this;f.next=function(){var o=f.w,s=f.X,m=f.i,p,v;return f.w=o=o+1640531527|0,v=s[m+34&127],p=s[m=m+1&127],v^=v<<13,p^=p<<17,v^=v>>>15,p^=p>>>12,v=s[m]=v^p,f.i=m,v+(o^o>>>16)|0};function c(o,s){var m,p,v,h,b,w=[],N=128;for(s===(s|0)?(p=s,s=null):(s=s+"\0",p=0,N=Math.max(N,s.length)),v=0,h=-32;h<N;++h)s&&(p^=s.charCodeAt((h+32)%s.length)),h===0&&(b=p),p^=p<<10,p^=p>>>15,p^=p<<4,p^=p>>>13,h>=0&&(b=b+1640531527|0,m=w[h&127]^=p+b,v=m==0?v+1:0);for(v>=128&&(w[(s&&s.length||0)&127]=-1),v=127,h=4*128;h>0;--h)p=w[v+34&127],m=w[v=v+1&127],p^=p<<13,m^=m<<17,p^=p>>>15,m^=m>>>12,w[v]=p^m;o.w=b,o.X=w,o.i=v}c(f,l)}function i(l,f){return f.i=l.i,f.w=l.w,f.X=l.X.slice(),f}function u(l,f){l==null&&(l=+new Date);var c=new r(l),o=f&&f.state,s=function(){return(c.next()>>>0)/4294967296};return s.double=function(){do var m=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(m+p)/(1<<21);while(v===0);return v},s.int32=c.next,s.quick=s,o&&(o.X&&i(o,c),s.state=function(){return i(c,{})}),s}n&&n.exports?n.exports=u:this.xor4096=u})(h3,e)}(Ua)),Ua.exports}var La={exports:{}},g3=La.exports,nm;function y3(){return nm||(nm=1,function(e){(function(t,n,a){function r(l){var f=this,c="";f.next=function(){var s=f.b,m=f.c,p=f.d,v=f.a;return s=s<<25^s>>>7^m,m=m-p|0,p=p<<24^p>>>8^v,v=v-s|0,f.b=s=s<<20^s>>>12^m,f.c=m=m-p|0,f.d=p<<16^m>>>16^v,f.a=v-s|0},f.a=0,f.b=0,f.c=-1640531527,f.d=1367130551,l===Math.floor(l)?(f.a=l/4294967296|0,f.b=l|0):c+=l;for(var o=0;o<c.length+20;o++)f.b^=c.charCodeAt(o)|0,f.next()}function i(l,f){return f.a=l.a,f.b=l.b,f.c=l.c,f.d=l.d,f}function u(l,f){var c=new r(l),o=f&&f.state,s=function(){return(c.next()>>>0)/4294967296};return s.double=function(){do var m=c.next()>>>11,p=(c.next()>>>0)/4294967296,v=(m+p)/(1<<21);while(v===0);return v},s.int32=c.next,s.quick=s,o&&(typeof o=="object"&&i(o,c),s.state=function(){return i(c,{})}),s}n&&n.exports?n.exports=u:this.tychei=u})(g3,e)}(La)),La.exports}var ka={exports:{}};const x3=kp(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var b3=ka.exports,am;function w3(){return am||(am=1,function(e){(function(t,n,a){var r=256,i=6,u=52,l="random",f=a.pow(r,i),c=a.pow(2,u),o=c*2,s=r-1,m;function p(y,x,d){var A=[];x=x==!0?{entropy:!0}:x||{};var S=w(b(x.entropy?[y,g(n)]:y==null?N():y,3),A),O=new v(A),M=function(){for(var $=O.g(i),E=f,_=0;$<c;)$=($+_)*r,E*=r,_=O.g(1);for(;$>=o;)$/=2,E/=2,_>>>=1;return($+_)/E};return M.int32=function(){return O.g(4)|0},M.quick=function(){return O.g(4)/4294967296},M.double=M,w(g(O.S),n),(x.pass||d||function($,E,_,z){return z&&(z.S&&h(z,O),$.state=function(){return h(O,{})}),_?(a[l]=$,E):$})(M,S,"global"in x?x.global:this==a,x.state)}function v(y){var x,d=y.length,A=this,S=0,O=A.i=A.j=0,M=A.S=[];for(d||(y=[d++]);S<r;)M[S]=S++;for(S=0;S<r;S++)M[S]=M[O=s&O+y[S%d]+(x=M[S])],M[O]=x;(A.g=function($){for(var E,_=0,z=A.i,I=A.j,T=A.S;$--;)E=T[z=s&z+1],_=_*r+T[s&(T[z]=T[I=s&I+E])+(T[I]=E)];return A.i=z,A.j=I,_})(r)}function h(y,x){return x.i=y.i,x.j=y.j,x.S=y.S.slice(),x}function b(y,x){var d=[],A=typeof y,S;if(x&&A=="object")for(S in y)try{d.push(b(y[S],x-1))}catch(O){}return d.length?d:A=="string"?y:y+"\0"}function w(y,x){for(var d=y+"",A,S=0;S<d.length;)x[s&S]=s&(A^=x[s&S]*19)+d.charCodeAt(S++);return g(x)}function N(){try{var y;return m&&(y=m.randomBytes)?y=y(r):(y=new Uint8Array(r),(t.crypto||t.msCrypto).getRandomValues(y)),g(y)}catch(A){var x=t.navigator,d=x&&x.plugins;return[+new Date,t,d,t.screen,g(n)]}}function g(y){return String.fromCharCode.apply(0,y)}if(w(a.random(),n),e.exports){e.exports=p;try{m=x3}catch(y){}}else a["seed"+l]=p})(typeof self!="undefined"?self:b3,[],Math)}(ka)),ka.exports}var Li,im;function N3(){if(im)return Li;im=1;var e=u3(),t=f3(),n=m3(),a=v3(),r=d3(),i=y3(),u=w3();return u.alea=e,u.xor128=t,u.xorwow=n,u.xorshift7=a,u.xor4096=r,u.tychei=i,Li=u,Li}var M3=N3();const om=na(M3);var A3=om(Date.now());function An(e){var t;function n(r){t=r===null?A3:om(String(r))}n(e);function a(){return t()}return a}var sm="pickRandom",S3=["typed","config","?on"],E3=R(sm,S3,e=>{var{typed:t,config:n,on:a}=e,r=An(n.randomSeed);return a&&a("config",function(u,l){u.randomSeed!==l.randomSeed&&(r=An(u.randomSeed))}),t(sm,{"Array | Matrix":function(l){return i(l,{})},"Array | Matrix, Object":function(l,f){return i(l,f)},"Array | Matrix, number":function(l,f){return i(l,{number:f})},"Array | Matrix, Array | Matrix":function(l,f){return i(l,{weights:f})},"Array | Matrix, Array | Matrix, number":function(l,f,c){return i(l,{number:c,weights:f})},"Array | Matrix, number, Array | Matrix":function(l,f,c){return i(l,{number:f,weights:c})}});function i(u,l){var{number:f,weights:c,elementWise:o=!0}=l,s=typeof f=="undefined";s&&(f=1);var m=De(u)?u.create:De(c)?c.create:null;u=u.valueOf(),c&&(c=c.valueOf()),o===!0&&(u=ke(u),c=ke(c));var p=0;if(typeof c!="undefined"){if(c.length!==u.length)throw new Error("Weights must have the same length as possibles");for(var v=0,h=c.length;v<h;v++){if(!$e(c[v])||c[v]<0)throw new Error("Weights must be an array of positive numbers");p+=c[v]}}for(var b=u.length,w=[],N;w.length<f;){if(typeof c=="undefined")N=u[Math.floor(r()*b)];else for(var g=r()*p,y=0,x=u.length;y<x;y++)if(g-=c[y],g<0){N=u[y];break}w.push(N)}return s?w[0]:m?m(w):w}});function ki(e,t){var n=[];if(e=e.slice(0),e.length>1)for(var a=0,r=e.shift();a<r;a++)n.push(ki(e,t));else for(var i=0,u=e.shift();i<u;i++)n.push(t());return n}var um="random",C3=["typed","config","?on"],O3=R(um,C3,e=>{var{typed:t,config:n,on:a}=e,r=An(n.randomSeed);return a&&a("config",function(l,f){l.randomSeed!==f.randomSeed&&(r=An(l.randomSeed))}),t(um,{"":()=>u(0,1),number:l=>u(0,l),"number, number":(l,f)=>u(l,f),"Array | Matrix":l=>i(l,0,1),"Array | Matrix, number":(l,f)=>i(l,0,f),"Array | Matrix, number, number":(l,f,c)=>i(l,f,c)});function i(l,f,c){var o=ki(l.valueOf(),()=>u(f,c));return De(l)?l.create(o):o}function u(l,f){return l+r()*(f-l)}}),cm="randomInt",D3=["typed","config","?on"],T3=R(cm,D3,e=>{var{typed:t,config:n,on:a}=e,r=An(n.randomSeed);return a&&a("config",function(l,f){l.randomSeed!==f.randomSeed&&(r=An(l.randomSeed))}),t(cm,{"":()=>u(0,1),number:l=>u(0,l),"number, number":(l,f)=>u(l,f),"Array | Matrix":l=>i(l,0,1),"Array | Matrix, number":(l,f)=>i(l,0,f),"Array | Matrix, number, number":(l,f,c)=>i(l,f,c)});function i(l,f,c){var o=ki(l.valueOf(),()=>u(f,c));return De(l)?l.create(o):o}function u(l,f){return Math.floor(l+r()*(f-l))}}),fm="stirlingS2",B3=["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],$3=R(fm,B3,e=>{var{typed:t,addScalar:n,subtract:a,multiplyScalar:r,divideScalar:i,pow:u,factorial:l,combinations:f,isNegative:c,isInteger:o,number:s,bignumber:m,larger:p}=e,v=[],h=[];return t(fm,{"number | BigNumber, number | BigNumber":function(w,N){if(!o(w)||c(w)||!o(N)||c(N))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(p(N,w))throw new TypeError("k must be less than or equal to n in function stirlingS2");var g=!($e(w)&&$e(N)),y=g?h:v,x=g?m:s,d=s(w),A=s(N);if(y[d]&&y[d].length>A)return y[d][A];for(var S=0;S<=d;++S)if(y[S]||(y[S]=[x(S===0?1:0)]),S!==0)for(var O=y[S],M=y[S-1],$=O.length;$<=S&&$<=A;++$)$===S?O[$]=1:O[$]=n(r(x($),M[$]),M[$-1]);return y[d][A]}})}),lm="bellNumbers",_3=["typed","addScalar","isNegative","isInteger","stirlingS2"],I3=R(lm,_3,e=>{var{typed:t,addScalar:n,isNegative:a,isInteger:r,stirlingS2:i}=e;return t(lm,{"number | BigNumber":function(l){if(!r(l)||a(l))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var f=0,c=0;c<=l;c++)f=n(f,i(l,c));return f}})}),mm="catalan",q3=["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],R3=R(mm,q3,e=>{var{typed:t,addScalar:n,divideScalar:a,multiplyScalar:r,combinations:i,isNegative:u,isInteger:l}=e;return t(mm,{"number | BigNumber":function(c){if(!l(c)||u(c))throw new TypeError("Non-negative integer value expected in function catalan");return a(i(r(c,2),c),n(c,1))}})}),pm="composition",F3=["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],z3=R(pm,F3,e=>{var{typed:t,addScalar:n,combinations:a,isPositive:r,isNegative:i,isInteger:u,larger:l}=e;return t(pm,{"number | BigNumber, number | BigNumber":function(c,o){if(!u(c)||!r(c)||!u(o)||!r(o))throw new TypeError("Positive integer value expected in function composition");if(l(o,c))throw new TypeError("k must be less than or equal to n in function composition");return a(n(c,-1),n(o,-1))}})}),vm="leafCount",P3=["parse","typed"],U3=R(vm,P3,e=>{var{parse:t,typed:n}=e;function a(r){var i=0;return r.forEach(u=>{i+=a(u)}),i||1}return n(vm,{string:function(i){return this(t(i))},Node:function(i){return a(i)}})});function hm(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,a)}return n}function Hi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?hm(Object(n),!0).forEach(function(a){vf(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hm(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}var L3="simplifyUtil",k3=["FunctionNode","OperatorNode","SymbolNode"],Gi=R(L3,k3,e=>{var{FunctionNode:t,OperatorNode:n,SymbolNode:a}=e,r=!0,i=!1,u="defaultF",l={add:{trivial:r,total:r,commutative:r,associative:r},unaryPlus:{trivial:r,total:r,commutative:r,associative:r},subtract:{trivial:i,total:r,commutative:i,associative:i},multiply:{trivial:r,total:r,commutative:r,associative:r},divide:{trivial:i,total:r,commutative:i,associative:i},paren:{trivial:r,total:r,commutative:r,associative:i},defaultF:{trivial:i,total:r,commutative:i,associative:i}},f={divide:{total:i},log:{total:i}},c={subtract:{total:i},abs:{trivial:r},log:{total:r}};function o(g,y){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:l,d=u;if(typeof g=="string"?d=g:qr(g)?d=g.fn.toString():Gt(g)?d=g.name:$n(g)&&(d="paren"),Ae(x,d)){var A=x[d];if(Ae(A,y))return A[y];if(Ae(l,d))return l[d][y]}if(Ae(x,u)){var S=x[u];return Ae(S,y)?S[y]:l[u][y]}if(Ae(l,d)){var O=l[d];if(Ae(O,y))return O[y]}return l[u][y]}function s(g){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:l;return o(g,"commutative",y)}function m(g){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:l;return o(g,"associative",y)}function p(g,y){var x=Hi({},g);for(var d in y)Ae(g,d)?x[d]=Hi(Hi({},y[d]),g[d]):x[d]=y[d];return x}function v(g,y){if(!g.args||g.args.length===0)return g;g.args=h(g,y);for(var x=0;x<g.args.length;x++)v(g.args[x],y)}function h(g,y){var x,d=[],A=function S(O){for(var M=0;M<O.args.length;M++){var $=O.args[M];qr($)&&x===$.op?S($):d.push($)}};return m(g,y)?(x=g.op,A(g),d):g.args}function b(g,y){if(!(!g.args||g.args.length===0)){for(var x=N(g),d=g.args.length,A=0;A<d;A++)b(g.args[A],y);if(d>2&&m(g,y)){for(var S=g.args.pop();g.args.length>0;)S=x([g.args.pop(),S]);g.args=S.args}}}function w(g,y){if(!(!g.args||g.args.length===0)){for(var x=N(g),d=g.args.length,A=0;A<d;A++)w(g.args[A],y);if(d>2&&m(g,y)){for(var S=g.args.shift();g.args.length>0;)S=x([S,g.args.shift()]);g.args=S.args}}}function N(g){return qr(g)?function(y){try{return new n(g.op,g.fn,y,g.implicit)}catch(x){return console.error(x),[]}}:function(y){return new t(new a(g.name),y)}}return{createMakeNodeFunction:N,hasProperty:o,isCommutative:s,isAssociative:m,mergeContext:p,flatten:v,allChildren:h,unflattenr:b,unflattenl:w,defaultContext:l,realContext:f,positiveContext:c}}),H3="simplifyConstant",G3=["typed","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],dm=R(H3,G3,e=>{var{typed:t,config:n,mathWithTransform:a,matrix:r,fraction:i,bignumber:u,AccessorNode:l,ArrayNode:f,ConstantNode:c,FunctionNode:o,IndexNode:s,ObjectNode:m,OperatorNode:p,SymbolNode:v}=e,{isCommutative:h,isAssociative:b,allChildren:w,createMakeNodeFunction:N}=Gi({FunctionNode:o,OperatorNode:p,SymbolNode:v});function g(I,T){return A(z(I,T))}function y(I){return xr(I)?I.valueOf():I instanceof Array?I.map(y):De(I)?r(y(I.valueOf())):I}function x(I,T,B){try{return a[I].apply(null,T)}catch(G){return T=T.map(y),O(a[I].apply(null,T),B)}}var d=t({Fraction:$,number:function(T){return T<0?M(new c(-T)):new c(T)},BigNumber:function(T){return T<0?M(new c(-T)):new c(T)},Complex:function(T){throw new Error("Cannot convert Complex number to Node")},string:function(T){return new c(T)},Matrix:function(T){return new f(T.valueOf().map(B=>d(B)))}});function A(I){return Ze(I)?I:d(I)}function S(I,T){var B=T&&T.exactFractions!==!1;if(B&&isFinite(I)&&i){var G=i(I),D=T&&typeof T.fractionsLimit=="number"?T.fractionsLimit:1/0;if(G.valueOf()===I&&G.n<D&&G.d<D)return G}return I}var O=t({"string, Object":function(T,B){if(n.number==="BigNumber")return u===void 0&&Di(),u(T);if(n.number==="Fraction")return i===void 0&&sc(),i(T);var G=parseFloat(T);return S(G,B)},"Fraction, Object":function(T,B){return T},"BigNumber, Object":function(T,B){return T},"number, Object":function(T,B){return S(T,B)},"Complex, Object":function(T,B){return T.im!==0?T:S(T.re,B)},"Matrix, Object":function(T,B){return r(S(T.valueOf()))},"Array, Object":function(T,B){return T.map(S)}});function M(I){return new p("-","unaryMinus",[I])}function $(I){var T,B=I.s*I.n;return B<0?T=new p("-","unaryMinus",[new c(-B)]):T=new c(B),I.d===1?T:new p("/","divide",[T,new c(I.d)])}function E(I,T,B){if(!on(T))return new l(A(I),A(T));if(Vr(I)||De(I)){for(var G=Array.from(T.dimensions);G.length>0;)if(We(G[0])&&typeof G[0].value!="string"){var D=O(G.shift().value,B);Vr(I)?I=I.items[D-1]:(I=I.valueOf()[D-1],I instanceof Array&&(I=r(I)))}else if(G.length>1&&We(G[1])&&typeof G[1].value!="string"){var H=O(G[1].value,B),W=[],j=Vr(I)?I.items:I.valueOf();for(var V of j)if(Vr(V))W.push(V.items[H-1]);else if(De(I))W.push(V[H-1]);else break;if(W.length===j.length)Vr(I)?I=new f(W):I=r(W),G.splice(1,1);else break}else break;return G.length===T.dimensions.length?new l(A(I),T):G.length>0?(T=new s(G),new l(A(I),T)):I}if(ta(I)&&T.dimensions.length===1&&We(T.dimensions[0])){var K=T.dimensions[0].value;return K in I.properties?I.properties[K]:new c}return new l(A(I),T)}function _(I,T,B,G){return T.reduce(function(D,H){if(!Ze(D)&&!Ze(H)){try{return x(I,[D,H],G)}catch(W){}D=d(D),H=d(H)}else Ze(D)?Ze(H)||(H=d(H)):D=d(D);return B([D,H])})}function z(I,T){switch(I.type){case"SymbolNode":return I;case"ConstantNode":switch(typeof I.value){case"number":return O(I.value,T);case"string":return I.value;default:if(!isNaN(I.value))return O(I.value,T)}return I;case"FunctionNode":if(a[I.name]&&a[I.name].rawArgs)return I;{var B=["add","multiply"];if(B.indexOf(I.name)===-1){var G=I.args.map(xe=>z(xe,T));if(!G.some(Ze))try{return x(I.name,G,T)}catch(xe){}if(I.name==="size"&&G.length===1&&Vr(G[0])){for(var D=[],H=G[0];Vr(H);)D.push(H.items.length),H=H.items[0];return r(D)}return new o(I.name,G.map(A))}}case"OperatorNode":{var W=I.fn.toString(),j,V,K=N(I);if(qr(I)&&I.isUnary())j=[z(I.args[0],T)],Ze(j[0])?V=K(j):V=x(W,j,T);else if(b(I,T.context))if(j=w(I,T.context),j=j.map(xe=>z(xe,T)),h(W,T.context)){for(var te=[],re=[],oe=0;oe<j.length;oe++)Ze(j[oe])?re.push(j[oe]):te.push(j[oe]);te.length>1?(V=_(W,te,K,T),re.unshift(V),V=_(W,re,K,T)):V=_(W,j,K,T)}else V=_(W,j,K,T);else j=I.args.map(xe=>z(xe,T)),V=_(W,j,K,T);return V}case"ParenthesisNode":return z(I.content,T);case"AccessorNode":return E(z(I.object,T),z(I.index,T),T);case"ArrayNode":{var ae=I.items.map(xe=>z(xe,T));return ae.some(Ze)?new f(ae.map(A)):r(ae)}case"IndexNode":return new s(I.dimensions.map(xe=>g(xe,T)));case"ObjectNode":{var ce={};for(var ee in I.properties)ce[ee]=g(I.properties[ee],T);return new m(ce)}case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"RangeNode":case"ConditionalNode":default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(I.type))}}return g}),V3="simplify",Z3=["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","resolve","simplifyCore","?fraction","?bignumber","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],X3=R(V3,Z3,e=>{var{config:t,typed:n,parse:a,add:r,subtract:i,multiply:u,divide:l,pow:f,isZero:c,equal:o,resolve:s,simplifyCore:m,fraction:p,bignumber:v,mathWithTransform:h,matrix:b,AccessorNode:w,ArrayNode:N,ConstantNode:g,FunctionNode:y,IndexNode:x,ObjectNode:d,OperatorNode:A,ParenthesisNode:S,SymbolNode:O}=e,M=dm({typed:n,config:t,mathWithTransform:h,matrix:b,fraction:p,bignumber:v,AccessorNode:w,ArrayNode:N,ConstantNode:g,FunctionNode:y,IndexNode:x,ObjectNode:d,OperatorNode:A,SymbolNode:O}),{hasProperty:$,isCommutative:E,isAssociative:_,mergeContext:z,flatten:I,unflattenr:T,unflattenl:B,createMakeNodeFunction:G,defaultContext:D,realContext:H,positiveContext:W}=Gi({FunctionNode:y,OperatorNode:A,SymbolNode:O}),j=n("simplify",{string:function(U){return this(a(U),this.rules,xt(),{})},"string, Map | Object":function(U,J){return this(a(U),this.rules,J,{})},"string, Map | Object, Object":function(U,J,q){return this(a(U),this.rules,J,q)},"string, Array":function(U,J){return this(a(U),J,xt(),{})},"string, Array, Map | Object":function(U,J,q){return this(a(U),J,q,{})},"string, Array, Map | Object, Object":function(U,J,q,P){return this(a(U),J,q,P)},"Node, Map | Object":function(U,J){return this(U,this.rules,J,{})},"Node, Map | Object, Object":function(U,J,q){return this(U,this.rules,J,q)},Node:function(U){return this(U,this.rules,xt(),{})},"Node, Array":function(U,J){return this(U,J,xt(),{})},"Node, Array, Map | Object":function(U,J,q){return this(U,J,q,{})},"Node, Array, Object, Object":function(U,J,q,P){return this(U,J,fi(q),P)},"Node, Array, Map, Object":function(U,J,q,P){var Q=P.consoleDebug;J=re(J,P.context);var L=s(U,q);L=V(L);for(var ue={},le=L.toString({parenthesis:"all"});!ue[le];){ue[le]=!0,oe=0;var ye=le;Q&&console.log("Working on: ",le);for(var ve=0;ve<J.length;ve++){var he="";if(typeof J[ve]=="function"?(L=J[ve](L,P),Q&&(he=J[ve].name)):(I(L,P.context),L=ee(L,J[ve],P.context),Q&&(he="".concat(J[ve].l.toString()," -> ").concat(J[ve].r.toString()))),Q){var Me=L.toString({parenthesis:"all"});Me!==ye&&(console.log("Applying",he,"produced",Me),ye=Me)}B(L,P.context)}le=L.toString({parenthesis:"all"})}return L}});j.defaultContext=D,j.realContext=H,j.positiveContext=W;function V(k){return k.transform(function(U,J,q){return $n(U)?V(U.content):U})}var K={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};j.rules=[m,{l:"log(e)",r:"1"},{s:"n-n1 -> n+-n1",assuming:{subtract:{total:!0}}},{s:"n-n -> 0",assuming:{subtract:{total:!1}}},{s:"-(c*v) -> v * (-c)",assuming:{multiply:{commutative:!0},subtract:{total:!0}}},{s:"-(c*v) -> (-c) * v",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{s:"-(v*c) -> v * (-c)",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{l:"-(n1/n2)",r:"-n1/n2"},{l:"-v",r:"v * (-1)"},{l:"(n1 + n2)*(-1)",r:"n1*(-1) + n2*(-1)",repeat:!0},{l:"n/n1^n2",r:"n*n1^-n2"},{l:"n/n1",r:"n*n1^-1"},{s:"(n1*n2)^n3 -> n1^n3 * n2^n3",assuming:{multiply:{commutative:!0}}},{s:"(n1*n2)^(-1) -> n2^(-1) * n1^(-1)",assuming:{multiply:{commutative:!1}}},{s:"(n ^ n1) ^ n2 -> n ^ (n1 * n2)",assuming:{divide:{total:!0}}},{l:" v * ( v * n1 + n2)",r:"v^2 * n1 + v * n2"},{s:" v * (v^n4 * n1 + n2) -> v^(1+n4) * n1 + v * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * ( v * n1 + n2) -> v^(n3+1) * n1 + v^n3 * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * (v^n4 * n1 + n2) -> v^(n3+n4) * n1 + v^n3 * n2",assuming:{divide:{total:!0}}},{l:"n*n",r:"n^2"},{s:"n * n^n1 -> n^(n1+1)",assuming:{divide:{total:!0}}},{s:"n^n1 * n^n2 -> n^(n1+n2)",assuming:{divide:{total:!0}}},M,{s:"n+n -> 2*n",assuming:{add:{total:!0}}},{l:"n+-n",r:"0"},{l:"v*n + v",r:"v*(n+1)"},{l:"n3*n1 + n3*n2",r:"n3*(n1+n2)"},{l:"n3^(-n4)*n1 + n3 * n2",r:"n3^(-n4)*(n1 + n3^(n4+1) *n2)"},{l:"n3^(-n4)*n1 + n3^n5 * n2",r:"n3^(-n4)*(n1 + n3^(n4+n5)*n2)"},{s:"n*v + v -> (n+1)*v",assuming:{multiply:{commutative:!1}}},{s:"n1*n3 + n2*n3 -> (n1+n2)*n3",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3 -> (n1 + n2*n3^(n4 + 1))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3^n5 -> (n1 + n2*n3^(n4 + n5))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{l:"n*c + c",r:"(n+1)*c"},{s:"c*n + c -> c*(n+1)",assuming:{multiply:{commutative:!1}}},M,{s:"(-n)*n1 -> -(n*n1)",assuming:{subtract:{total:!0}}},{s:"n1*(-n) -> -(n1*n)",assuming:{subtract:{total:!0},multiply:{commutative:!1}}},{s:"c+v -> v+c",assuming:{add:{commutative:!0}},imposeContext:{add:{commutative:!1}}},{s:"v*c -> c*v",assuming:{multiply:{commutative:!0}},imposeContext:{multiply:{commutative:!1}}},{l:"n+-n1",r:"n-n1"},{s:"n*(n1^-1) -> n/n1",assuming:{multiply:{commutative:!0}}},{s:"n*n1^-n2 -> n/n1^n2",assuming:{multiply:{commutative:!0}}},{s:"n^-1 -> 1/n",assuming:{multiply:{commutative:!0}}},{l:"n^1",r:"n"},{s:"n*(n1/n2) -> (n*n1)/n2",assuming:{multiply:{associative:!0}}},{s:"n-(n1+n2) -> n-n1-n2",assuming:{addition:{associative:!0,commutative:!0}}},{l:"1*n",r:"n",imposeContext:{multiply:{commutative:!0}}},{s:"n1/(n2/n3) -> (n1*n3)/n2",assuming:{multiply:{associative:!0}}},{l:"n1/(-n2)",r:"-n1/n2"}];function te(k,U){var J={};if(k.s){var q=k.s.split("->");if(q.length===2)J.l=q[0],J.r=q[1];else throw SyntaxError("Could not parse rule: "+k.s)}else J.l=k.l,J.r=k.r;J.l=V(a(J.l)),J.r=V(a(J.r));for(var P of["imposeContext","repeat","assuming"])P in k&&(J[P]=k[P]);if(k.evaluate&&(J.evaluate=a(k.evaluate)),_(J.l,U)){var Q=G(J.l),L=ae();J.expanded={},J.expanded.l=Q([J.l.clone(),L]),I(J.expanded.l,U),T(J.expanded.l,U),J.expanded.r=Q([J.r,L])}return J}function re(k,U){for(var J=[],q=0;q<k.length;q++){var P=k[q],Q=void 0,L=typeof P;switch(L){case"string":P={s:P};case"object":Q=te(P,U);break;case"function":Q=P;break;default:throw TypeError("Unsupported type of rule: "+L)}J.push(Q)}return J}var oe=0;function ae(){return new O("_p"+oe++)}function ce(k,U,J){var q=k;if(k)for(var P=0;P<k.length;++P){var Q=ee(k[P],U,J);Q!==k[P]&&(q===k&&(q=k.slice()),q[P]=Q)}return q}function ee(k,U,J){if(U.assuming){for(var q in U.assuming)for(var P in U.assuming[q])if($(q,P,J)!==U.assuming[q][P])return k}var Q=z(U.imposeContext,J),L=k;if(L instanceof A||L instanceof y){var ue=ce(L.args,U,J);ue!==L.args&&(L=L.clone(),L.args=ue)}else if(L instanceof S){if(L.content){var le=ee(L.content,U,J);le!==L.content&&(L=new S(le))}}else if(L instanceof N){var ye=ce(L.items,U,J);ye!==L.items&&(L=new N(ye))}else if(L instanceof w){var ve=L.object;L.object&&(ve=ee(L.object,U,J));var he=L.index;L.index&&(he=ee(L.index,U,J)),(ve!==L.object||he!==L.index)&&(L=new w(ve,he))}else if(L instanceof x){var Me=ce(L.dimensions,U,J);Me!==L.dimensions&&(L=new x(Me))}else if(L instanceof d){var Ke=!1,fr={};for(var nr in L.properties)fr[nr]=ee(L.properties[nr],U,J),fr[nr]!==L.properties[nr]&&(Ke=!0);Ke&&(L=new d(fr))}var jr=U.r,kr=F(U.l,L,Q)[0];if(!kr&&U.expanded&&(jr=U.expanded.r,kr=F(U.expanded.l,L,Q)[0]),kr){var Tt=L.implicit;L=jr.clone(),Tt&&"implicit"in jr&&(L.implicit=!0),L=L.transform(function(Xe){return Xe.isSymbolNode&&Ae(kr.placeholders,Xe.name)?kr.placeholders[Xe.name].clone():Xe})}return U.repeat&&L!==k&&(L=ee(L,U,J)),L}function xe(k,U){var J=[],q,P,Q=G(k);if(E(k,U))for(var L=0;L<k.args.length;L++)P=k.args.slice(0),P.splice(L,1),q=P.length===1?P[0]:Q(P),J.push(Q([k.args[L],q]));else for(var ue=1;ue<k.args.length;ue++){var le=k.args[0];ue>1&&(le=Q(k.args.slice(0,ue))),P=k.args.slice(ue),q=P.length===1?P[0]:Q(P),J.push(Q([le,q]))}return J}function Ne(k,U){var J={placeholders:{}};if(!k.placeholders&&!U.placeholders)return J;if(k.placeholders){if(!U.placeholders)return k}else return U;for(var q in k.placeholders)if(Ae(k.placeholders,q)&&(J.placeholders[q]=k.placeholders[q],Ae(U.placeholders,q)&&!Y(k.placeholders[q],U.placeholders[q])))return null;for(var P in U.placeholders)Ae(U.placeholders,P)&&(J.placeholders[P]=U.placeholders[P]);return J}function pe(k,U){var J=[];if(k.length===0||U.length===0)return J;for(var q,P=0;P<k.length;P++)for(var Q=0;Q<U.length;Q++)q=Ne(k[P],U[Q]),q&&J.push(q);return J}function be(k){if(k.length===0)return k;for(var U=k.reduce(pe),J=[],q={},P=0;P<U.length;P++){var Q=JSON.stringify(U[P]);q[Q]||(q[Q]=!0,J.push(U[P]))}return J}function F(k,U,J,q){var P=[{placeholders:{}}];if(k instanceof A&&U instanceof A||k instanceof y&&U instanceof y){if(k instanceof A){if(k.op!==U.op||k.fn!==U.fn)return[]}else if(k instanceof y&&k.name!==U.name)return[];if(U.args.length===1&&k.args.length===1||!_(U,J)&&U.args.length===k.args.length||q){for(var Q=[],L=0;L<k.args.length;L++){var ue=F(k.args[L],U.args[L],J);if(ue.length===0)break;Q.push(ue)}if(Q.length!==k.args.length){if(!E(U,J)||k.args.length===1)return[];if(k.args.length>2)throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");var le=F(k.args[0],U.args[1],J);if(le.length===0)return[];var ye=F(k.args[1],U.args[0],J);if(ye.length===0)return[];Q=[le,ye]}P=be(Q)}else if(U.args.length>=2&&k.args.length===2){for(var ve=xe(U,J),he=[],Me=0;Me<ve.length;Me++){var Ke=F(k,ve[Me],J,!0);he=he.concat(Ke)}return he}else{if(k.args.length>2)throw Error("Unexpected non-binary associative function: "+k.toString());return[]}}else if(k instanceof O){if(k.name.length===0)throw new Error("Symbol in rule has 0 length...!?");if(K[k.name]){if(k.name!==U.name)return[]}else if(k.name[0]==="n"||k.name.substring(0,2)==="_p")P[0].placeholders[k.name]=U;else if(k.name[0]==="v")if(!We(U))P[0].placeholders[k.name]=U;else return[];else if(k.name[0]==="c")if(U instanceof g)P[0].placeholders[k.name]=U;else return[];else throw new Error("Invalid symbol in rule: "+k.name)}else if(k instanceof g){if(!o(k.value,U.value))return[]}else return[];return P}function Y(k,U){if(k instanceof g&&U instanceof g){if(!o(k.value,U.value))return!1}else if(k instanceof O&&U instanceof O){if(k.name!==U.name)return!1}else if(k instanceof A&&U instanceof A||k instanceof y&&U instanceof y){if(k instanceof A){if(k.op!==U.op||k.fn!==U.fn)return!1}else if(k instanceof y&&k.name!==U.name)return!1;if(k.args.length!==U.args.length)return!1;for(var J=0;J<k.args.length;J++)if(!Y(k.args[J],U.args[J]))return!1}else return!1;return!0}return j}),Y3="simplifyCore",W3=["equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],J3=R(Y3,W3,e=>{var{equal:t,isZero:n,add:a,subtract:r,multiply:i,divide:u,pow:l,AccessorNode:f,ArrayNode:c,ConstantNode:o,FunctionNode:s,IndexNode:m,ObjectNode:p,OperatorNode:v,ParenthesisNode:h,SymbolNode:b}=e,w=new o(0),N=new o(1),{hasProperty:g,isCommutative:y}=Gi({FunctionNode:s,OperatorNode:v,SymbolNode:b});function x(d,A){var S=A?A.context:void 0;if(g(d,"trivial",S)){if(Gt(d)&&d.args.length===1)return x(d.args[0],A);var O=!1,M=0;if(d.forEach(D=>{++M,M===1&&(O=x(D,A))}),M===1)return O}if(qr(d)&&d.isUnary()){var $=x(d.args[0],A);if(d.op==="-"){if(qr($)){if($.isUnary()&&$.op==="-")return $.args[0];if($.isBinary()&&$.fn==="subtract")return new v("-","subtract",[$.args[1],$.args[0]])}return new v(d.op,d.fn,[$])}}else if(qr(d)&&d.isBinary()){var E=x(d.args[0],A),_=x(d.args[1],A);if(d.op==="+"){if(We(E)){if(n(E.value))return _;if(We(_))return new o(a(E.value,_.value))}return We(_)&&n(_.value)?E:qr(_)&&_.isUnary()&&_.op==="-"?new v("-","subtract",[E,_.args[0]]):new v(d.op,d.fn,_?[E,_]:[E])}else if(d.op==="-"){if(We(E)&&_){if(We(_))return new o(r(E.value,_.value));if(n(E.value))return new v("-","unaryMinus",[_])}if(d.fn==="subtract")return We(_)&&n(_.value)?E:qr(_)&&_.isUnary()&&_.op==="-"?x(new v("+","add",[E,_.args[0]]),A):new v(d.op,d.fn,[E,_])}else if(d.op==="*"){if(We(E)){if(n(E.value))return w;if(t(E.value,1))return _;if(We(_))return new o(i(E.value,_.value))}if(We(_)){if(n(_.value))return w;if(t(_.value,1))return E;if(qr(E)&&E.isBinary()&&E.op===d.op&&y(d,S)){var z=E.args[0];if(We(z)){var I=new o(i(z.value,_.value));return new v(d.op,d.fn,[I,E.args[1]],d.implicit)}}return y(d,S)?new v(d.op,d.fn,[_,E],d.implicit):new v(d.op,d.fn,[E,_],d.implicit)}return new v(d.op,d.fn,[E,_],d.implicit)}else if(d.op==="/"){if(We(E)){if(n(E.value))return w;if(We(_)&&(t(_.value,1)||t(_.value,2)||t(_.value,4)))return new o(u(E.value,_.value))}return new v(d.op,d.fn,[E,_])}else if(d.op==="^"&&We(_)){if(n(_.value))return N;if(t(_.value,1))return E;if(We(E))return new o(l(E.value,_.value));if(qr(E)&&E.isBinary()&&E.op==="^"){var T=E.args[1];if(We(T))return new v(d.op,d.fn,[E.args[0],new o(i(T.value,_.value))])}}return new v(d.op,d.fn,[E,_])}else{if(Gt(d))return new s(x(d.fn),d.args.map(D=>x(D,A)));if(Vr(d))return new c(d.items.map(D=>x(D,A)));if(Ht(d))return new f(x(d.object,A),x(d.index,A));if(on(d))return new m(d.dimensions.map(D=>x(D,A)));if(ta(d)){var B={};for(var G in d.properties)B[G]=x(d.properties[G],A);return new p(B)}}return d}return x}),Q3="resolve",K3=["parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],j3=R(Q3,K3,e=>{var{parse:t,ConstantNode:n,FunctionNode:a,OperatorNode:r,ParenthesisNode:i}=e;function u(l,f){var c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;if(!f)return l;if(ma(f)||(f=fi(f)),br(l)){if(c.has(l.name)){var o=Array.from(c).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(o,"}"))}var s=f.get(l.name);if(Ze(s)){var m=new Set(c);return m.add(l.name),u(s,f,m)}else return typeof s=="number"?t(String(s)):s!==void 0?new n(s):l}else if(qr(l)){var p=l.args.map(function(h){return u(h,f,c)});return new r(l.op,l.fn,p,l.implicit)}else{if($n(l))return new i(u(l.content,f,c));if(Gt(l)){var v=l.args.map(function(h){return u(h,f,c)});return new a(l.name,v)}}return l.map(h=>u(h,f,c))}return u}),gm="symbolicEqual",eO=["parse","simplify","typed","OperatorNode"],rO=R(gm,eO,e=>{var{parse:t,simplify:n,typed:a,OperatorNode:r}=e;return a(gm,{"string, string":function(u,l){return this(t(u),t(l),{})},"string, string, Object":function(u,l,f){return this(t(u),t(l),f)},"Node, string":function(u,l){return this(u,t(l),{})},"Node, string, Object":function(u,l,f){return this(u,t(l),f)},"string, Node":function(u,l){return this(t(u),l,{})},"string, Node, Object":function(u,l,f){return this(t(u),l,f)},"Node, Node":function(u,l){return this(u,l,{})},"Node, Node, Object":function(u,l,f){var c=new r("-","subtract",[u,l]),o=n(c,{},f);return We(o)&&!o.value}})}),tO="derivative",nO=["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],aO=R(tO,nO,e=>{var{typed:t,config:n,parse:a,simplify:r,equal:i,isZero:u,numeric:l,ConstantNode:f,FunctionNode:c,OperatorNode:o,ParenthesisNode:s,SymbolNode:m}=e,p=t("derivative",{"Node, SymbolNode, Object":function(y,x,d){var A={};h(A,y,x.name);var S=b(y,A);return d.simplify?r(S):S},"Node, SymbolNode":function(y,x){return this(y,x,{simplify:!0})},"string, SymbolNode":function(y,x){return this(a(y),x)},"string, SymbolNode, Object":function(y,x,d){return this(a(y),x,d)},"string, string":function(y,x){return this(a(y),a(x))},"string, string, Object":function(y,x,d){return this(a(y),a(x),d)},"Node, string":function(y,x){return this(y,a(x))},"Node, string, Object":function(y,x,d){return this(y,a(x),d)}});p._simplify=!0,p.toTex=function(g){return v.apply(null,g.args)};var v=t("_derivTex",{"Node, SymbolNode":function(y,x){return We(y)&&je(y.value)==="string"?v(a(y.value).toString(),x.toString(),1):v(y.toTex(),x.toString(),1)},"Node, ConstantNode":function(y,x){if(je(x.value)==="string")return v(y,a(x.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(y,x,d){return v(y.toString(),x.name,d.value)},"string, string, number":function(y,x,d){var A;return d===1?A="{d\\over d"+x+"}":A="{d^{"+d+"}\\over d"+x+"^{"+d+"}}",A+"\\left[".concat(y,"\\right]")}}),h=t("constTag",{"Object, ConstantNode, string":function(y,x){return y[x]=!0,!0},"Object, SymbolNode, string":function(y,x,d){return x.name!==d?(y[x]=!0,!0):!1},"Object, ParenthesisNode, string":function(y,x,d){return h(y,x.content,d)},"Object, FunctionAssignmentNode, string":function(y,x,d){return x.params.indexOf(d)===-1?(y[x]=!0,!0):h(y,x.expr,d)},"Object, FunctionNode | OperatorNode, string":function(y,x,d){if(x.args.length>0){for(var A=h(y,x.args[0],d),S=1;S<x.args.length;++S)A=h(y,x.args[S],d)&&A;if(A)return y[x]=!0,!0}return!1}}),b=t("_derivative",{"ConstantNode, Object":function(y){return N(0)},"SymbolNode, Object":function(y,x){return x[y]!==void 0?N(0):N(1)},"ParenthesisNode, Object":function(y,x){return new s(b(y.content,x))},"FunctionAssignmentNode, Object":function(y,x){return x[y]!==void 0?N(0):b(y.expr,x)},"FunctionNode, Object":function(y,x){if(y.args.length!==1&&w(y),x[y]!==void 0)return N(0);var d=y.args[0],A,S=!1,O=!1,M;switch(y.name){case"cbrt":S=!0,M=new o("*","multiply",[N(3),new o("^","pow",[d,new o("/","divide",[N(2),N(3)])])]);break;case"sqrt":case"nthRoot":if(y.args.length===1)S=!0,M=new o("*","multiply",[N(2),new c("sqrt",[d])]);else if(y.args.length===2)return A=new o("/","divide",[N(1),y.args[1]]),x[A]=x[y.args[1]],b(new o("^","pow",[d,A]),x);break;case"log10":A=N(10);case"log":if(!A&&y.args.length===1)M=d.clone(),S=!0;else if(y.args.length===1&&A||y.args.length===2&&x[y.args[1]]!==void 0)M=new o("*","multiply",[d.clone(),new c("log",[A||y.args[1]])]),S=!0;else if(y.args.length===2)return b(new o("/","divide",[new c("log",[d]),new c("log",[y.args[1]])]),x);break;case"pow":return x[A]=x[y.args[1]],b(new o("^","pow",[d,y.args[1]]),x);case"exp":M=new c("exp",[d.clone()]);break;case"sin":M=new c("cos",[d.clone()]);break;case"cos":M=new o("-","unaryMinus",[new c("sin",[d.clone()])]);break;case"tan":M=new o("^","pow",[new c("sec",[d.clone()]),N(2)]);break;case"sec":M=new o("*","multiply",[y,new c("tan",[d.clone()])]);break;case"csc":O=!0,M=new o("*","multiply",[y,new c("cot",[d.clone()])]);break;case"cot":O=!0,M=new o("^","pow",[new c("csc",[d.clone()]),N(2)]);break;case"asin":S=!0,M=new c("sqrt",[new o("-","subtract",[N(1),new o("^","pow",[d.clone(),N(2)])])]);break;case"acos":S=!0,O=!0,M=new c("sqrt",[new o("-","subtract",[N(1),new o("^","pow",[d.clone(),N(2)])])]);break;case"atan":S=!0,M=new o("+","add",[new o("^","pow",[d.clone(),N(2)]),N(1)]);break;case"asec":S=!0,M=new o("*","multiply",[new c("abs",[d.clone()]),new c("sqrt",[new o("-","subtract",[new o("^","pow",[d.clone(),N(2)]),N(1)])])]);break;case"acsc":S=!0,O=!0,M=new o("*","multiply",[new c("abs",[d.clone()]),new c("sqrt",[new o("-","subtract",[new o("^","pow",[d.clone(),N(2)]),N(1)])])]);break;case"acot":S=!0,O=!0,M=new o("+","add",[new o("^","pow",[d.clone(),N(2)]),N(1)]);break;case"sinh":M=new c("cosh",[d.clone()]);break;case"cosh":M=new c("sinh",[d.clone()]);break;case"tanh":M=new o("^","pow",[new c("sech",[d.clone()]),N(2)]);break;case"sech":O=!0,M=new o("*","multiply",[y,new c("tanh",[d.clone()])]);break;case"csch":O=!0,M=new o("*","multiply",[y,new c("coth",[d.clone()])]);break;case"coth":O=!0,M=new o("^","pow",[new c("csch",[d.clone()]),N(2)]);break;case"asinh":S=!0,M=new c("sqrt",[new o("+","add",[new o("^","pow",[d.clone(),N(2)]),N(1)])]);break;case"acosh":S=!0,M=new c("sqrt",[new o("-","subtract",[new o("^","pow",[d.clone(),N(2)]),N(1)])]);break;case"atanh":S=!0,M=new o("-","subtract",[N(1),new o("^","pow",[d.clone(),N(2)])]);break;case"asech":S=!0,O=!0,M=new o("*","multiply",[d.clone(),new c("sqrt",[new o("-","subtract",[N(1),new o("^","pow",[d.clone(),N(2)])])])]);break;case"acsch":S=!0,O=!0,M=new o("*","multiply",[new c("abs",[d.clone()]),new c("sqrt",[new o("+","add",[new o("^","pow",[d.clone(),N(2)]),N(1)])])]);break;case"acoth":S=!0,O=!0,M=new o("-","subtract",[N(1),new o("^","pow",[d.clone(),N(2)])]);break;case"abs":M=new o("/","divide",[new c(new m("abs"),[d.clone()]),d.clone()]);break;case"gamma":default:throw new Error('Function "'+y.name+'" is not supported by derivative, or a wrong number of arguments is passed')}var $,E;S?($="/",E="divide"):($="*",E="multiply");var _=b(d,x);return O&&(_=new o("-","unaryMinus",[_])),new o($,E,[_,M])},"OperatorNode, Object":function(y,x){if(x[y]!==void 0)return N(0);if(y.op==="+")return new o(y.op,y.fn,y.args.map(function(I){return b(I,x)}));if(y.op==="-"){if(y.isUnary())return new o(y.op,y.fn,[b(y.args[0],x)]);if(y.isBinary())return new o(y.op,y.fn,[b(y.args[0],x),b(y.args[1],x)])}if(y.op==="*"){var d=y.args.filter(function(I){return x[I]!==void 0});if(d.length>0){var A=y.args.filter(function(I){return x[I]===void 0}),S=A.length===1?A[0]:new o("*","multiply",A),O=d.concat(b(S,x));return new o("*","multiply",O)}return new o("+","add",y.args.map(function(I){return new o("*","multiply",y.args.map(function(T){return T===I?b(T,x):T.clone()}))}))}if(y.op==="/"&&y.isBinary()){var M=y.args[0],$=y.args[1];return x[$]!==void 0?new o("/","divide",[b(M,x),$]):x[M]!==void 0?new o("*","multiply",[new o("-","unaryMinus",[M]),new o("/","divide",[b($,x),new o("^","pow",[$.clone(),N(2)])])]):new o("/","divide",[new o("-","subtract",[new o("*","multiply",[b(M,x),$.clone()]),new o("*","multiply",[M.clone(),b($,x)])]),new o("^","pow",[$.clone(),N(2)])])}if(y.op==="^"&&y.isBinary()){var E=y.args[0],_=y.args[1];if(x[E]!==void 0)return We(E)&&(u(E.value)||i(E.value,1))?N(0):new o("*","multiply",[y,new o("*","multiply",[new c("log",[E.clone()]),b(_.clone(),x)])]);if(x[_]!==void 0){if(We(_)){if(u(_.value))return N(0);if(i(_.value,1))return b(E,x)}var z=new o("^","pow",[E.clone(),new o("-","subtract",[_,N(1)])]);return new o("*","multiply",[_.clone(),new o("*","multiply",[b(E,x),z])])}return new o("*","multiply",[new o("^","pow",[E.clone(),_.clone()]),new o("+","add",[new o("*","multiply",[b(E,x),new o("/","divide",[_.clone(),E.clone()])]),new o("*","multiply",[b(_,x),new c("log",[E.clone()])])])])}throw new Error('Operator "'+y.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function w(g){if(!((g.name==="log"||g.name==="nthRoot"||g.name==="pow")&&g.args.length===2)){for(var y=0;y<g.args.length;++y)g.args[y]=N(0);throw g.compile().evaluate(),new Error("Expected TypeError, but none found")}}function N(g,y){return new f(l(g,n.number))}return p}),ym="rationalize",iO=["config","typed","equal","isZero","add","subtract","multiply","divide","pow","parse","simplifyCore","simplify","?bignumber","?fraction","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode","ParenthesisNode"],oO=R(ym,iO,e=>{var{config:t,typed:n,equal:a,isZero:r,add:i,subtract:u,multiply:l,divide:f,pow:c,parse:o,simplifyCore:s,simplify:m,fraction:p,bignumber:v,mathWithTransform:h,matrix:b,AccessorNode:w,ArrayNode:N,ConstantNode:g,FunctionNode:y,IndexNode:x,ObjectNode:d,OperatorNode:A,SymbolNode:S,ParenthesisNode:O}=e,M=dm({typed:n,config:t,mathWithTransform:h,matrix:b,fraction:p,bignumber:v,AccessorNode:w,ArrayNode:N,ConstantNode:g,FunctionNode:y,IndexNode:x,ObjectNode:d,OperatorNode:A,SymbolNode:S});return n(ym,{string:function(T){return this(o(T),{},!1)},"string, boolean":function(T,B){return this(o(T),{},B)},"string, Object":function(T,B){return this(o(T),B,!1)},"string, Object, boolean":function(T,B,G){return this(o(T),B,G)},Node:function(T){return this(T,{},!1)},"Node, boolean":function(T,B){return this(T,{},B)},"Node, Object":function(T,B){return this(T,B,!1)},"Node, Object, boolean":function(T,B,G){var D=E(),H=$(T,B,!0,D.firstRules),W=H.variables.length,j={exactFractions:!1},V={exactFractions:!0};if(T=H.expression,W>=1){T=_(T);var K,te,re=!0,oe=!1;T=m(T,D.firstRules,{},j);for(var ae;te=re?D.distrDivRules:D.sucDivRules,T=m(T,te,{},V),re=!re,ae=T.toString(),ae!==K;)oe=!0,K=ae;oe&&(T=m(T,D.firstRulesAgain,{},j)),T=m(T,D.finalRules,{},j)}var ce=[],ee={};return T.type==="OperatorNode"&&T.isBinary()&&T.op==="/"?(W===1&&(T.args[0]=z(T.args[0],ce),T.args[1]=z(T.args[1])),G&&(ee.numerator=T.args[0],ee.denominator=T.args[1])):(W===1&&(T=z(T,ce)),G&&(ee.numerator=T,ee.denominator=null)),G?(ee.coefficients=ce,ee.variables=H.variables,ee.expression=T,ee):T}});function $(I,T,B,G){var D=[],H=m(I,G,T,{exactFractions:!1});B=!!B;var W="+-*"+(B?"/":"");V(H);var j={};return j.expression=H,j.variables=D,j;function V(K){var te=K.type;if(te==="FunctionNode")throw new Error("There is an unsolved function call");if(te==="OperatorNode")if(K.op==="^"){if(K.args[1].type!=="ConstantNode"||!Se(parseFloat(K.args[1].value)))throw new Error("There is a non-integer exponent");V(K.args[0])}else{if(W.indexOf(K.op)===-1)throw new Error("Operator "+K.op+" invalid in polynomial expression");for(var re=0;re<K.args.length;re++)V(K.args[re])}else if(te==="SymbolNode"){var oe=K.name,ae=D.indexOf(oe);ae===-1&&D.push(oe)}else if(te==="ParenthesisNode")V(K.content);else if(te!=="ConstantNode")throw new Error("type "+te+" is not allowed in polynomial expression")}}function E(){var I=[s,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},M,{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)"}],B=[{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)"}],G=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],D={};return D.firstRules=I.concat(T,G),D.distrDivRules=B,D.sucDivRules=G,D.firstRulesAgain=I.concat(T),D.finalRules=[s,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},M,{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))"}],D}function _(I,T,B){var G=I.type,D=arguments.length>1;if(G==="OperatorNode"&&I.isBinary()){var H=!1,W;if(I.op==="^"&&(I.args[0].type==="ParenthesisNode"||I.args[0].type==="OperatorNode")&&I.args[1].type==="ConstantNode"&&(W=parseFloat(I.args[1].value),H=W>=2&&Se(W)),H){if(W>2){var j=I.args[0],V=new A("^","pow",[I.args[0].cloneDeep(),new g(W-1)]);I=new A("*","multiply",[j,V])}else I=new A("*","multiply",[I.args[0],I.args[0].cloneDeep()]);D&&(B==="content"?T.content=I:T.args[B]=I)}}if(G==="ParenthesisNode")_(I.content,I,"content");else if(G!=="ConstantNode"&&G!=="SymbolNode")for(var K=0;K<I.args.length;K++)_(I.args[K],I,K);if(!D)return I}function z(I,T){T===void 0&&(T=[]),T[0]=0;var B={};B.cte=1,B.oper="+",B.fire="";var G=0,D="";oe(I,null,B),G=T.length-1;for(var H=!0,W,j=G;j>=0;j--)if(T[j]!==0){var V=new g(H?T[j]:Math.abs(T[j])),K=T[j]<0?"-":"+";if(j>0){var te=new S(D);if(j>1){var re=new g(j);te=new A("^","pow",[te,re])}T[j]===-1&&H?V=new A("-","unaryMinus",[te]):Math.abs(T[j])===1?V=te:V=new A("*","multiply",[V,te])}H?W=V:K==="+"?W=new A("+","add",[W,V]):W=new A("-","subtract",[W,V]),H=!1}if(H)return new g(0);return W;function oe(ae,ce,ee){var xe=ae.type;if(xe==="FunctionNode")throw new Error("There is an unsolved function call");if(xe==="OperatorNode"){if("+-*^".indexOf(ae.op)===-1)throw new Error("Operator "+ae.op+" invalid");if(ce!==null){if((ae.fn==="unaryMinus"||ae.fn==="pow")&&ce.fn!=="add"&&ce.fn!=="subtract"&&ce.fn!=="multiply")throw new Error("Invalid "+ae.op+" placing");if((ae.fn==="subtract"||ae.fn==="add"||ae.fn==="multiply")&&ce.fn!=="add"&&ce.fn!=="subtract")throw new Error("Invalid "+ae.op+" placing");if((ae.fn==="subtract"||ae.fn==="add"||ae.fn==="unaryMinus")&&ee.noFil!==0)throw new Error("Invalid "+ae.op+" placing")}(ae.op==="^"||ae.op==="*")&&(ee.fire=ae.op);for(var Ne=0;Ne<ae.args.length;Ne++)ae.fn==="unaryMinus"&&(ee.oper="-"),(ae.op==="+"||ae.fn==="subtract")&&(ee.fire="",ee.cte=1,ee.oper=Ne===0?"+":ae.op),ee.noFil=Ne,oe(ae.args[Ne],ae,ee)}else if(xe==="SymbolNode"){if(ae.name!==D&&D!=="")throw new Error("There is more than one variable");if(D=ae.name,ce===null){T[1]=1;return}if(ce.op==="^"&&ee.noFil!==0)throw new Error("In power the variable should be the first parameter");if(ce.op==="*"&&ee.noFil!==1)throw new Error("In multiply the variable should be the second parameter");(ee.fire===""||ee.fire==="*")&&(G<1&&(T[1]=0),T[1]+=ee.cte*(ee.oper==="+"?1:-1),G=Math.max(1,G))}else if(xe==="ConstantNode"){var pe=parseFloat(ae.value);if(ce===null){T[0]=pe;return}if(ce.op==="^"){if(ee.noFil!==1)throw new Error("Constant cannot be powered");if(!Se(pe)||pe<=0)throw new Error("Non-integer exponent is not allowed");for(var be=G+1;be<pe;be++)T[be]=0;pe>G&&(T[pe]=0),T[pe]+=ee.cte*(ee.oper==="+"?1:-1),G=Math.max(pe,G);return}ee.cte=pe,ee.fire===""&&(T[0]+=ee.cte*(ee.oper==="+"?1:-1))}else throw new Error("Type "+xe+" is not allowed")}}}),sO="reviver",uO=["classes"],cO=R(sO,uO,e=>{var{classes:t}=e;return function(a,r){var i=t[r&&r.mathjs];return i&&typeof i.fromJSON=="function"?i.fromJSON(r):r}}),fO="replacer",lO=[],mO=R(fO,lO,()=>function(t,n){return typeof n=="number"&&(!isFinite(n)||isNaN(n))?{mathjs:"number",value:String(n)}:n}),pO="10.6.4",vO=R("true",[],()=>!0),hO=R("false",[],()=>!1),dO=R("null",[],()=>null),gO=Ur("Infinity",["config","?BigNumber"],e=>{var{config:t,BigNumber:n}=e;return t.number==="BigNumber"?new n(1/0):1/0}),yO=Ur("NaN",["config","?BigNumber"],e=>{var{config:t,BigNumber:n}=e;return t.number==="BigNumber"?new n(NaN):NaN}),xO=Ur("pi",["config","?BigNumber"],e=>{var{config:t,BigNumber:n}=e;return t.number==="BigNumber"?_i(n):jh}),bO=Ur("tau",["config","?BigNumber"],e=>{var{config:t,BigNumber:n}=e;return t.number==="BigNumber"?fb(n):ed}),wO=Ur("e",["config","?BigNumber"],e=>{var{config:t,BigNumber:n}=e;return t.number==="BigNumber"?ub(n):rd}),NO=Ur("phi",["config","?BigNumber"],e=>{var{config:t,BigNumber:n}=e;return t.number==="BigNumber"?cb(n):td}),MO=Ur("LN2",["config","?BigNumber"],e=>{var{config:t,BigNumber:n}=e;return t.number==="BigNumber"?new n(2).ln():Math.LN2}),AO=Ur("LN10",["config","?BigNumber"],e=>{var{config:t,BigNumber:n}=e;return t.number==="BigNumber"?new n(10).ln():Math.LN10}),SO=Ur("LOG2E",["config","?BigNumber"],e=>{var{config:t,BigNumber:n}=e;return t.number==="BigNumber"?new n(1).div(new n(2).ln()):Math.LOG2E}),EO=Ur("LOG10E",["config","?BigNumber"],e=>{var{config:t,BigNumber:n}=e;return t.number==="BigNumber"?new n(1).div(new n(10).ln()):Math.LOG10E}),CO=Ur("SQRT1_2",["config","?BigNumber"],e=>{var{config:t,BigNumber:n}=e;return t.number==="BigNumber"?new n("0.5").sqrt():Math.SQRT1_2}),OO=Ur("SQRT2",["config","?BigNumber"],e=>{var{config:t,BigNumber:n}=e;return t.number==="BigNumber"?new n(2).sqrt():Math.SQRT2}),DO=Ur("i",["Complex"],e=>{var{Complex:t}=e;return t.I}),TO=R("version",[],()=>pO);function Ur(e,t,n){return R(e,t,n,{recreateOnConfigChange:!0})}var BO=qe("speedOfLight","299792458","m s^-1"),$O=qe("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),_O=qe("planckConstant","6.62607015e-34","J s"),IO=qe("reducedPlanckConstant","1.0545718176461565e-34","J s"),qO=qe("magneticConstant","1.25663706212e-6","N A^-2"),RO=qe("electricConstant","8.8541878128e-12","F m^-1"),FO=qe("vacuumImpedance","376.730313667","ohm"),zO=qe("coulomb","8.987551792261171e9","N m^2 C^-2"),PO=qe("elementaryCharge","1.602176634e-19","C"),UO=qe("bohrMagneton","9.2740100783e-24","J T^-1"),LO=qe("conductanceQuantum","7.748091729863649e-5","S"),kO=qe("inverseConductanceQuantum","12906.403729652257","ohm"),HO=qe("magneticFluxQuantum","2.0678338484619295e-15","Wb"),GO=qe("nuclearMagneton","5.0507837461e-27","J T^-1"),VO=qe("klitzing","25812.807459304513","ohm"),ZO=qe("bohrRadius","5.29177210903e-11","m"),XO=qe("classicalElectronRadius","2.8179403262e-15","m"),YO=qe("electronMass","9.1093837015e-31","kg"),WO=qe("fermiCoupling","1.1663787e-5","GeV^-2"),JO=Ha("fineStructure",.0072973525693),QO=qe("hartreeEnergy","4.3597447222071e-18","J"),KO=qe("protonMass","1.67262192369e-27","kg"),jO=qe("deuteronMass","3.3435830926e-27","kg"),eD=qe("neutronMass","1.6749271613e-27","kg"),rD=qe("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),tD=qe("rydberg","10973731.568160","m^-1"),nD=qe("thomsonCrossSection","6.6524587321e-29","m^2"),aD=Ha("weakMixingAngle",.2229),iD=Ha("efimovFactor",22.7),oD=qe("atomicMass","1.66053906660e-27","kg"),sD=qe("avogadro","6.02214076e23","mol^-1"),uD=qe("boltzmann","1.380649e-23","J K^-1"),cD=qe("faraday","96485.33212331001","C mol^-1"),fD=qe("firstRadiation","3.7417718521927573e-16","W m^2"),lD=qe("loschmidt","2.686780111798444e25","m^-3"),mD=qe("gasConstant","8.31446261815324","J K^-1 mol^-1"),pD=qe("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),vD=qe("molarVolume","0.022413969545014137","m^3 mol^-1"),hD=Ha("sackurTetrode",-1.16487052358),dD=qe("secondRadiation","0.014387768775039337","m K"),gD=qe("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),yD=qe("wienDisplacement","2.897771955e-3","m K"),xD=qe("molarMass","0.99999999965e-3","kg mol^-1"),bD=qe("molarMassC12","11.9999999958e-3","kg mol^-1"),wD=qe("gravity","9.80665","m s^-2"),ND=qe("planckLength","1.616255e-35","m"),MD=qe("planckMass","2.176435e-8","kg"),AD=qe("planckTime","5.391245e-44","s"),SD=qe("planckCharge","1.87554603778e-18","C"),ED=qe("planckTemperature","1.416785e+32","K");function qe(e,t,n){var a=["config","Unit","BigNumber"];return R(e,a,r=>{var{config:i,Unit:u,BigNumber:l}=r,f=i.number==="BigNumber"?new l(t):parseFloat(t),c=new u(f,n);return c.fixPrefix=!0,c})}function Ha(e,t){var n=["config","BigNumber"];return R(e,n,a=>{var{config:r,BigNumber:i}=a;return r.number==="BigNumber"?new i(t):t})}var CD="apply",OD=["typed","isInteger"],DD=R(CD,OD,e=>{var{typed:t,isInteger:n}=e,a=pu({typed:t,isInteger:n});return t("apply",{"...any":function(i){var u=i[1];$e(u)?i[1]=u-1:_e(u)&&(i[1]=u.minus(1));try{return a.apply(null,i)}catch(l){throw _r(l)}}})},{isTransformFunction:!0}),TD="column",BD=["typed","Index","matrix","range"],$D=R(TD,BD,e=>{var{typed:t,Index:n,matrix:a,range:r}=e,i=Yu({typed:t,Index:n,matrix:a,range:r});return t("column",{"...any":function(l){var f=l.length-1,c=l[f];$e(c)&&(l[f]=c-1);try{return i.apply(null,l)}catch(o){throw _r(o)}}})},{isTransformFunction:!0});function Vi(e,t,n){var a=e.filter(function(l){return br(l)&&!(l.name in t)&&!n.has(l.name)})[0];if(!a)throw new Error('No undefined variable found in inline expression "'+e+'"');var r=a.name,i=kn(n),u=e.compile();return function(f){return i.set(r,f),u.evaluate(i)}}var _D="filter",ID=["typed"],qD=R(_D,ID,e=>{var{typed:t}=e;function n(r,i,u){var l,f;return r[0]&&(l=r[0].compile().evaluate(u)),r[1]&&(br(r[1])||Bn(r[1])?f=r[1].compile().evaluate(u):f=Vi(r[1],i,u)),a(l,f)}n.rawArgs=!0;var a=t("filter",{"Array, function":xm,"Matrix, function":function(i,u){return i.create(xm(i.toArray(),u))},"Array, RegExp":fa,"Matrix, RegExp":function(i,u){return i.create(fa(i.toArray(),u))}});return n},{isTransformFunction:!0});function xm(e,t){var n=xn(t);return Eo(e,function(a,r,i){return n===1?t(a):n===2?t(a,[r+1]):t(a,[r+1],i)})}var RD="forEach",FD=["typed"],zD=R(RD,FD,e=>{var{typed:t}=e;function n(r,i,u){var l,f;return r[0]&&(l=r[0].compile().evaluate(u)),r[1]&&(br(r[1])||Bn(r[1])?f=r[1].compile().evaluate(u):f=Vi(r[1],i,u)),a(l,f)}n.rawArgs=!0;var a=t("forEach",{"Array | Matrix, function":function(i,u){var l=xn(u),f=function c(o,s){Array.isArray(o)?ca(o,function(m,p){c(m,s.concat(p+1))}):l===1?u(o):l===2?u(o,s):u(o,s,i)};f(i.valueOf(),[])}});return n},{isTransformFunction:!0}),PD="index",UD=["Index"],LD=R(PD,UD,e=>{var{Index:t}=e;return function(){for(var a=[],r=0,i=arguments.length;r<i;r++){var u=arguments[r];if(ra(u))u.start--,u.end-=u.step>0?0:2;else if(u&&u.isSet===!0)u=u.map(function(f){return f-1});else if(Ye(u)||De(u))u=u.map(function(f){return f-1});else if($e(u))u--;else if(_e(u))u=u.toNumber()-1;else if(typeof u!="string")throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");a[r]=u}var l=new t;return t.apply(l,a),l}},{isTransformFunction:!0}),kD="map",HD=["typed"],GD=R(kD,HD,e=>{var{typed:t}=e;function n(r,i,u){var l,f;return r[0]&&(l=r[0].compile().evaluate(u)),r[1]&&(br(r[1])||Bn(r[1])?f=r[1].compile().evaluate(u):f=Vi(r[1],i,u)),a(l,f)}n.rawArgs=!0;var a=t("map",{"Array, function":function(i,u){return bm(i,u,i)},"Matrix, function":function(i,u){return i.create(bm(i.valueOf(),u,i))}});return n},{isTransformFunction:!0});function bm(e,t,n){var a=xn(t);function r(i,u){return Array.isArray(i)?yt(i,function(l,f){return r(l,u.concat(f+1))}):a===1?t(i):a===2?t(i,u):t(i,u,n)}return r(e,[])}function Wt(e){if(e.length===2&&an(e[0])){e=e.slice();var t=e[1];$e(t)?e[1]=t-1:_e(t)&&(e[1]=t.minus(1))}return e}var VD="max",ZD=["typed","config","numeric","larger"],XD=R(VD,ZD,e=>{var{typed:t,config:n,numeric:a,larger:r}=e,i=lf({typed:t,config:n,numeric:a,larger:r});return t("max",{"...any":function(l){l=Wt(l);try{return i.apply(null,l)}catch(f){throw _r(f)}}})},{isTransformFunction:!0}),YD="mean",WD=["typed","add","divide"],JD=R(YD,WD,e=>{var{typed:t,add:n,divide:a}=e,r=Il({typed:t,add:n,divide:a});return t("mean",{"...any":function(u){u=Wt(u);try{return r.apply(null,u)}catch(l){throw _r(l)}}})},{isTransformFunction:!0}),QD="min",KD=["typed","config","numeric","smaller"],jD=R(QD,KD,e=>{var{typed:t,config:n,numeric:a,smaller:r}=e,i=pf({typed:t,config:n,numeric:a,smaller:r});return t("min",{"...any":function(l){l=Wt(l);try{return i.apply(null,l)}catch(f){throw _r(f)}}})},{isTransformFunction:!0}),eT="range",rT=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],tT=R(eT,rT,e=>{var{typed:t,config:n,matrix:a,bignumber:r,smaller:i,smallerEq:u,larger:l,largerEq:f}=e,c=fc({typed:t,config:n,matrix:a,bignumber:r,smaller:i,smallerEq:u,larger:l,largerEq:f});return t("range",{"...any":function(s){var m=s.length-1,p=s[m];return typeof p!="boolean"&&s.push(!0),c.apply(null,s)}})},{isTransformFunction:!0}),nT="row",aT=["typed","Index","matrix","range"],iT=R(nT,aT,e=>{var{typed:t,Index:n,matrix:a,range:r}=e,i=hc({typed:t,Index:n,matrix:a,range:r});return t("row",{"...any":function(l){var f=l.length-1,c=l[f];$e(c)&&(l[f]=c-1);try{return i.apply(null,l)}catch(o){throw _r(o)}}})},{isTransformFunction:!0}),oT="subset",sT=["typed","matrix"],uT=R(oT,sT,e=>{var{typed:t,matrix:n}=e,a=xc({typed:t,matrix:n});return t("subset",{"...any":function(i){try{return a.apply(null,i)}catch(u){throw _r(u)}}})},{isTransformFunction:!0}),cT="concat",fT=["typed","matrix","isInteger"],lT=R(cT,fT,e=>{var{typed:t,matrix:n,isInteger:a}=e,r=Vu({typed:t,matrix:n,isInteger:a});return t("concat",{"...any":function(u){var l=u.length-1,f=u[l];$e(f)?u[l]=f-1:_e(f)&&(u[l]=f.minus(1));try{return r.apply(null,u)}catch(c){throw _r(c)}}})},{isTransformFunction:!0}),wm="diff",mT=["typed","matrix","subtract","number","bignumber"],pT=R(wm,mT,e=>{var{typed:t,matrix:n,subtract:a,number:r,bignumber:i}=e,u=oc({typed:t,matrix:n,subtract:a,number:r,bignumber:i});return t(wm,{"...any":function(f){f=Wt(f);try{return u.apply(null,f)}catch(c){throw _r(c)}}})},{isTransformFunction:!0}),vT="std",hT=["typed","sqrt","variance"],dT=R(vT,hT,e=>{var{typed:t,sqrt:n,variance:a}=e,r=Ul({typed:t,sqrt:n,variance:a});return t("std",{"...any":function(u){u=Wt(u);try{return r.apply(null,u)}catch(l){throw _r(l)}}})},{isTransformFunction:!0}),Nm="sum",gT=["typed","config","add","numeric"],yT=R(Nm,gT,e=>{var{typed:t,config:n,add:a,numeric:r}=e,i=Bl({typed:t,config:n,add:a,numeric:r});return t(Nm,{"...any":function(l){l=Wt(l);try{return i.apply(null,l)}catch(f){throw _r(f)}}})},{isTransformFunction:!0}),Mm="cumsum",xT=["typed","add","unaryPlus"],bT=R(Mm,xT,e=>{var{typed:t,add:n,unaryPlus:a}=e,r=$l({typed:t,add:n,unaryPlus:a});return t(Mm,{"...any":function(u){if(u.length===2&&an(u[0])){var l=u[1];$e(l)?u[1]=l-1:_e(l)&&(u[1]=l.minus(1))}try{return r.apply(null,u)}catch(f){throw _r(f)}}})},{isTransformFunction:!0}),Am="variance",wT=["typed","add","subtract","multiply","divide","apply","isNaN"],NT=R(Am,wT,e=>{var{typed:t,add:n,subtract:a,multiply:r,divide:i,apply:u,isNaN:l}=e,f=zl({typed:t,add:n,subtract:a,multiply:r,divide:i,apply:u,isNaN:l});return t(Am,{"...any":function(o){o=Wt(o);try{return f.apply(null,o)}catch(s){throw _r(s)}}})},{isTransformFunction:!0}),me=Ah({config:se}),tr=Dh({}),Sm=wO({BigNumber:me,config:se}),MT=hO({}),AT=JO({BigNumber:me,config:se}),Jt=Fh({}),Em=DO({Complex:tr}),ST=gO({BigNumber:me,config:se}),ET=AO({BigNumber:me,config:se}),CT=EO({BigNumber:me,config:se}),Ga=Hh({}),OT=yO({BigNumber:me,config:se}),DT=dO({}),TT=NO({BigNumber:me,config:se}),BT=Uh({}),Cm=Ov({}),$T=CO({BigNumber:me,config:se}),_T=hD({BigNumber:me,config:se}),Om=bO({BigNumber:me,config:se}),IT=vO({}),qT=TO({}),Pe=Zh({Matrix:Ga}),RT=iD({BigNumber:me,config:se}),FT=MO({BigNumber:me,config:se}),Dm=xO({BigNumber:me,config:se}),zT=mO({}),PT=OO({BigNumber:me,config:se}),Z=Av({BigNumber:me,Complex:tr,DenseMatrix:Pe,Fraction:Jt}),Zi=ng({BigNumber:me,config:se,typed:Z}),UT=aD({BigNumber:me,config:se}),Lr=ig({typed:Z}),LT=wb({Complex:tr,config:se,typed:Z}),kT=Sb({BigNumber:me,typed:Z}),HT=Db({BigNumber:me,Complex:tr,config:se,typed:Z}),hr=cg({typed:Z}),GT=Vy({typed:Z}),VT=qb({BigNumber:me,Complex:tr,config:se,typed:Z}),ZT=Ub({typed:Z}),Tm=Hb({typed:Z}),XT=Xb({Complex:tr,config:se,typed:Z}),St=Fd({BigNumber:me,typed:Z}),YT=Fy({typed:Z}),WT=Id({typed:Z}),JT=Yh({typed:Z}),Va=ZC({typed:Z}),Za=Ud({Complex:tr,typed:Z}),Sn=Xy({typed:Z}),QT=Qb({typed:Z}),KT=rw({BigNumber:me,typed:Z}),jT=nw({BigNumber:me,typed:Z}),eB=Ng({typed:Z}),He=Nd({config:se,typed:Z}),rB=m1({typed:Z}),Bm=Ag({typed:Z}),tB=Eg({Complex:tr,typed:Z}),nB=h0({typed:Z}),aB=x0({typed:Z}),Hn=w1({typed:Z}),iB=N0({typed:Z}),oB=C1({format:Hn,typed:Z}),$m=Wy({typed:Z}),Wr=Jh({typed:Z}),En=sd({typed:Z}),Xa=pd({typed:Z}),mt=hd({typed:Z}),sB=SO({BigNumber:me,config:se}),uB=KC({Complex:tr,typed:Z}),cB=Jg({Complex:tr,config:se,typed:Z}),fB=Kg({Complex:tr,config:se,typed:Z}),_m=O0({typed:Z}),mr=sy({typed:Z}),Im=jy({typed:Z}),Pt=Td({typed:Z}),lB=S1({format:Hn,typed:Z}),mB=E3({config:se,typed:Z}),pB=D1({typed:Z}),vB=O3({config:se,typed:Z}),qm=Qy({typed:Z}),hB=sw({BigNumber:me,typed:Z}),Rm=py({BigNumber:me,Fraction:Jt,complex:Za,typed:Z}),Xi=lw({typed:Z}),Et=Sd({Matrix:Ga,equalScalar:He,typed:Z}),dB=jd({typed:Z}),gB=yy({typed:Z}),yB=$d({typed:Z}),xB=hw({typed:Z}),bB=xd({typed:Z}),wB=Mb({Complex:tr,config:se,typed:Z}),NB=Bb({BigNumber:me,typed:Z}),Yi=pu({isInteger:Wr,typed:Z}),MB=_b({BigNumber:me,Complex:tr,config:se,typed:Z}),AB=M1({format:Hn,typed:Z}),SB=YC({typed:Z}),Wi=Wb({typed:Z}),EB=iw({BigNumber:me,typed:Z}),Gn=gd({typed:Z}),CB=_1({typed:Z}),OB=T3({config:se,typed:Z}),DB=cw({BigNumber:me,typed:Z}),TB=pw({typed:Z}),BB=gb({SparseMatrix:Et,typed:Z}),Ct=dy({Complex:tr,config:se,typed:Z}),$B=yw({typed:Z}),Ot=rg({typed:Z}),_B=Cb({BigNumber:me,Complex:tr,config:se,typed:Z}),IB=jb({BigNumber:me,typed:Z}),Vn=Hd({Fraction:Jt,typed:Z}),Qt=cd({typed:Z}),ge=Vd({DenseMatrix:Pe,Matrix:Ga,SparseMatrix:Et,typed:Z}),qB=Xd({isZero:mt,matrix:ge,typed:Z}),Fm=ay({DenseMatrix:Pe,equalScalar:He,matrix:ge,typed:Z}),RB=ly({BigNumber:me,equalScalar:He,matrix:ge,typed:Z}),at=R1({bignumber:St,fraction:Vn,number:Pt}),FB=r0({DenseMatrix:Pe,equalScalar:He,matrix:ge,typed:Z}),zm=x1({config:se,multiplyScalar:mr,numeric:at,typed:Z}),zB=R0({isInteger:Wr,matrix:ge,typed:Z}),Er=Z0({matrix:ge,config:se,typed:Z}),Jr=Bx({DenseMatrix:Pe,config:se,matrix:ge,typed:Z}),PB=Y0({matrix:ge,typed:Z}),Qr=xc({matrix:ge,typed:Z}),or=by({DenseMatrix:Pe,addScalar:hr,equalScalar:He,matrix:ge,typed:Z,unaryMinus:Ot}),UB=B1({matrix:ge,typed:Z}),Ji=r1({matrix:ge,typed:Z}),Pm=Ny({BigNumber:me,config:se,matrix:ge,typed:Z}),pt=i1({BigNumber:me,config:se,matrix:ge,typed:Z}),LB=dx({equalScalar:He,matrix:ge,not:Im,typed:Z,zeros:pt}),kB=qy({equalScalar:He,matrix:ge,typed:Z}),HB=Hy({DenseMatrix:Pe,matrix:ge,typed:Z}),GB=lg({BigNumber:me,Complex:tr,Fraction:Jt,config:se,isNegative:En,matrix:ge,typed:Z,unaryMinus:Ot}),Cn=yx({BigNumber:me,DenseMatrix:Pe,Fraction:Jt,config:se,equalScalar:He,matrix:ge,typed:Z}),Um=Sx({matrix:ge,typed:Z}),Qi=Vu({isInteger:Wr,matrix:ge,typed:Z}),VB=s0({prod:zm,size:Er,typed:Z}),Ki=n1({conj:Sn,transpose:Ji,typed:Z}),Lm=l0({DenseMatrix:Pe,SparseMatrix:Et,matrix:ge,typed:Z}),sr=z1({numeric:at,typed:Z}),Ya=K1({DenseMatrix:Pe,divideScalar:sr,equalScalar:He,matrix:ge,typed:Z}),it=Cx({DenseMatrix:Pe,equalScalar:He,matrix:ge,typed:Z}),km=s1({addScalar:hr,divideScalar:sr,exp:Bm,i:Em,matrix:ge,multiplyScalar:mr,tau:Om,typed:Z}),Zn=g0({matrix:ge,typed:Z}),ZB=kg({BigNumber:me,DenseMatrix:Pe,equalScalar:He,matrix:ge,typed:Z}),XB=ld({isNumeric:Qt,typed:Z}),YB=kw({abs:Lr,addScalar:hr,divideScalar:sr,isPositive:Xa,multiplyScalar:mr,smaller:Jr,sqrt:Ct,typed:Z}),WB=c1({conj:Sn,dotDivide:Ya,fft:km,typed:Z}),JB=E0({matrix:ge,multiplyScalar:mr,typed:Z}),Wa=Fx({DenseMatrix:Pe,config:se,matrix:ge,typed:Z}),QB=fx({DenseMatrix:Pe,equalScalar:He,matrix:ge,typed:Z,zeros:pt}),Hm=ex({DenseMatrix:Pe,divideScalar:sr,equalScalar:He,matrix:ge,multiplyScalar:mr,subtract:or,typed:Z}),Gm=Qd({flatten:Zn,matrix:ge,size:Er,typed:Z}),KB=pf({config:se,numeric:at,smaller:Jr,typed:Z}),jB=g1({isNaN:Gn,isNumeric:Qt,typed:Z}),e4=Y1({Complex:tr,config:se,divideScalar:sr,typed:Z}),r4=_0({BigNumber:me,config:se,matrix:ge,typed:Z}),ji=Hx({compare:Cn,isNaN:Gn,isNumeric:Qt,typed:Z}),t4=P0({config:se,matrix:ge}),n4=mx({DenseMatrix:Pe,equalScalar:He,matrix:ge,typed:Z,zeros:pt}),Xn=k1({BigNumber:me,DenseMatrix:Pe,equalScalar:He,matrix:ge,typed:Z,zeros:pt}),eo=_x({DenseMatrix:Pe,config:se,matrix:ge,typed:Z}),a4=Lx({DenseMatrix:Pe,config:se,equalScalar:He,matrix:ge,typed:Z}),ro=tx({DenseMatrix:Pe,divideScalar:sr,equalScalar:He,matrix:ge,multiplyScalar:mr,subtract:or,typed:Z}),i4=n0({DenseMatrix:Pe,matrix:ge,typed:Z}),ur=Uw({DenseMatrix:Pe,SparseMatrix:Et,addScalar:hr,equalScalar:He,matrix:ge,typed:Z}),o4=Vb({BigNumber:me,DenseMatrix:Pe,equalScalar:He,matrix:ge,typed:Z}),s4=Py({DenseMatrix:Pe,equalScalar:He,matrix:ge,typed:Z}),u4=R3({addScalar:hr,combinations:Va,divideScalar:sr,isInteger:Wr,isNegative:En,multiplyScalar:mr,typed:Z}),vt=Nx({compare:Cn,typed:Z}),c4=$l({add:ur,typed:Z,unaryPlus:Zi}),Vm=Px({equal:it,typed:Z}),f4=oc({matrix:ge,number:Pt,subtract:or,typed:Z}),Ja=Zw({addScalar:hr,conj:Sn,multiplyScalar:mr,size:Er,typed:Z}),l4=Dx({compareText:Um,isZero:mt,typed:Z}),Zm=$g({DenseMatrix:Pe,config:se,equalScalar:He,matrix:ge,round:Xn,typed:Z,zeros:pt}),On=A0({BigNumber:me,DenseMatrix:Pe,SparseMatrix:Et,config:se,matrix:ge,typed:Z}),m4=Ay({BigNumber:me,add:ur,config:se,equal:it,isInteger:Wr,mod:Fm,smaller:Jr,typed:Z,xgcd:Pm}),Kr=qx({DenseMatrix:Pe,config:se,matrix:ge,typed:Z}),to=G1({Complex:tr,config:se,divideScalar:sr,typed:Z}),p4=ax({DenseMatrix:Pe,divideScalar:sr,equalScalar:He,matrix:ge,multiplyScalar:mr,subtract:or,typed:Z}),v4=Wd({flatten:Zn,matrix:ge,size:Er,typed:Z}),pr=cy({addScalar:hr,dot:Ja,equalScalar:He,matrix:ge,multiplyScalar:mr,typed:Z}),Xm=lM({addScalar:hr,complex:Za,conj:Sn,divideScalar:sr,equal:it,identity:On,isZero:mt,matrix:ge,multiplyScalar:mr,sign:Rm,sqrt:Ct,subtract:or,typed:Z,unaryMinus:Ot,zeros:pt}),Yn=fc({bignumber:St,matrix:ge,config:se,larger:Kr,largerEq:Wa,smaller:Jr,smallerEq:eo,typed:Z}),h4=vx({DenseMatrix:Pe,equalScalar:He,matrix:ge,typed:Z,zeros:pt}),d4=Iw({compareNatural:vt,typed:Z}),Ym=qM({SparseMatrix:Et,abs:Lr,add:ur,divideScalar:sr,larger:Kr,largerEq:Wa,multiply:pr,subtract:or,transpose:Ji,typed:Z}),Wm=Bl({add:ur,config:se,numeric:at,typed:Z}),g4=Ww({add:ur,matrix:ge,typed:Z}),Jm=ox({DenseMatrix:Pe,divideScalar:sr,equalScalar:He,matrix:ge,multiplyScalar:mr,subtract:or,typed:Z}),y4=Fb({Complex:tr,config:se,typed:Z}),Qm=bg({DenseMatrix:Pe,config:se,equalScalar:He,matrix:ge,round:Xn,typed:Z,zeros:pt}),x4=z3({addScalar:hr,combinations:Va,isInteger:Wr,isNegative:En,isPositive:Xa,larger:Kr,typed:Z}),b4=c0({matrix:ge,multiply:pr,subtract:or,typed:Z}),Km=lC({divideScalar:sr,isZero:mt,matrix:ge,multiply:pr,subtract:or,typed:Z,unaryMinus:Ot}),w4=DC({abs:Lr,addScalar:hr,divideScalar:sr,multiplyScalar:mr,sqrt:Ct,subtract:or,typed:Z,unaryMinus:Ot}),N4=Oy({equalScalar:He,matrix:ge,multiplyScalar:mr,typed:Z}),jm=tb({larger:Kr,smaller:Jr}),ep=Dg({Complex:tr,DenseMatrix:Pe,ceil:Qm,equalScalar:He,floor:Zm,matrix:ge,typed:Z,zeros:pt}),rp=Jx({DenseMatrix:Pe,smaller:Jr}),Cr=jx({ImmutableDenseMatrix:rp}),M4=$C({abs:Lr,add:ur,addScalar:hr,config:se,divideScalar:sr,equalScalar:He,flatten:Zn,isNumeric:Qt,isZero:mt,matrix:ge,multiply:pr,multiplyScalar:mr,smaller:Jr,subtract:or,typed:Z}),A4=Yg({equalScalar:He,matrix:ge,typed:Z}),S4=Z1({Complex:tr,config:se,divideScalar:sr,log:to,typed:Z}),tp=lf({config:se,larger:Kr,numeric:at,typed:Z}),E4=HC({add:ur,compare:Cn,multiply:pr,partitionSelect:ji,typed:Z}),C4=hc({Index:Cr,matrix:ge,range:Yn,typed:Z}),O4=bw({DenseMatrix:Pe,Index:Cr,compareNatural:vt,size:Er,subset:Qr,typed:Z}),D4=Aw({DenseMatrix:Pe,Index:Cr,compareNatural:vt,size:Er,subset:Qr,typed:Z}),T4=Ow({Index:Cr,compareNatural:vt,size:Er,subset:Qr,typed:Z}),B4=$w({Index:Cr,compareNatural:vt,size:Er,subset:Qr,typed:Z}),$4=Vx({compare:Cn,compareNatural:vt,matrix:ge,typed:Z}),np=Yu({Index:Cr,matrix:ge,range:Yn,typed:Z}),_4=Qw({Index:Cr,typed:Z}),Kt=pC({abs:Lr,addScalar:hr,det:Km,divideScalar:sr,identity:On,matrix:ge,multiply:pr,typed:Z,unaryMinus:Ot}),I4=hC({Complex:tr,add:ur,ctranspose:Ki,deepEqual:Vm,divideScalar:sr,dot:Ja,dotDivide:Ya,equal:it,inv:Kt,matrix:ge,multiply:pr,typed:Z}),Dt=U1({Complex:tr,config:se,fraction:Vn,identity:On,inv:Kt,matrix:ge,multiply:pr,number:Pt,typed:Z}),ap=Nw({DenseMatrix:Pe,Index:Cr,compareNatural:vt,size:Er,subset:Qr,typed:Z}),q4=Tw({Index:Cr,compareNatural:vt,size:Er,subset:Qr,typed:Z}),ip=ib({FibonacciHeap:jm,addScalar:hr,equalScalar:He}),R4=AC({abs:Lr,add:ur,identity:On,inv:Kt,max:tp,multiply:pr,size:Er,sqrt:Ct,subtract:or,typed:Z}),Be=pb({BigNumber:me,Complex:tr,Fraction:Jt,abs:Lr,addScalar:hr,config:se,divideScalar:sr,equal:it,fix:ep,format:Hn,isNumeric:Qt,multiplyScalar:mr,number:Pt,pow:Dt,round:Xn,subtract:or}),F4=FO({BigNumber:me,Unit:Be,config:se}),z4=yD({BigNumber:me,Unit:Be,config:se}),P4=oD({BigNumber:me,Unit:Be,config:se}),U4=UO({BigNumber:me,Unit:Be,config:se}),L4=uD({BigNumber:me,Unit:Be,config:se}),k4=LO({BigNumber:me,Unit:Be,config:se}),H4=xb({Unit:Be,typed:Z}),G4=jO({BigNumber:me,Unit:Be,config:se}),V4=J1({DenseMatrix:Pe,equalScalar:He,matrix:ge,pow:Dt,typed:Z}),Z4=RO({BigNumber:me,Unit:Be,config:se}),X4=PO({BigNumber:me,Unit:Be,config:se}),Y4=NC({abs:Lr,add:ur,identity:On,inv:Kt,multiply:pr,typed:Z}),W4=cD({BigNumber:me,Unit:Be,config:se}),J4=fD({BigNumber:me,Unit:Be,config:se}),op=JC({BigNumber:me,Complex:tr,config:se,multiplyScalar:mr,pow:Dt,typed:Z}),Q4=$O({BigNumber:me,Unit:Be,config:se}),K4=QO({BigNumber:me,Unit:Be,config:se}),j4=VO({BigNumber:me,Unit:Be,config:se}),e$=lD({BigNumber:me,Unit:Be,config:se}),r$=qO({BigNumber:me,Unit:Be,config:se}),t$=xD({BigNumber:me,Unit:Be,config:se}),n$=pD({BigNumber:me,Unit:Be,config:se}),a$=eD({BigNumber:me,Unit:Be,config:se}),i$=GO({BigNumber:me,Unit:Be,config:se}),o$=SD({BigNumber:me,Unit:Be,config:se}),s$=ND({BigNumber:me,Unit:Be,config:se}),u$=ED({BigNumber:me,Unit:Be,config:se}),c$=KO({BigNumber:me,Unit:Be,config:se}),f$=IO({BigNumber:me,Unit:Be,config:se}),l$=tD({BigNumber:me,Unit:Be,config:se}),sp=Ew({DenseMatrix:Pe,Index:Cr,compareNatural:vt,size:Er,subset:Qr,typed:Z}),m$=BO({BigNumber:me,Unit:Be,config:se}),p$=gD({BigNumber:me,Unit:Be,config:se}),v$=nD({BigNumber:me,Unit:Be,config:se}),h$=sD({BigNumber:me,Unit:Be,config:se}),d$=ZO({BigNumber:me,Unit:Be,config:se}),g$=zO({BigNumber:me,Unit:Be,config:se}),ot=CC({divideScalar:sr,equalScalar:He,inv:Kt,matrix:ge,multiply:pr,typed:Z}),y$=YO({BigNumber:me,Unit:Be,config:se}),Qa=e3({gamma:op,typed:Z}),x$=wD({BigNumber:me,Unit:Be,config:se}),b$=kO({BigNumber:me,Unit:Be,config:se}),up=cM({DenseMatrix:Pe,Spa:ip,SparseMatrix:Et,abs:Lr,addScalar:hr,divideScalar:sr,equalScalar:He,larger:Kr,matrix:ge,multiplyScalar:mr,subtract:or,typed:Z,unaryMinus:Ot}),w$=HO({BigNumber:me,Unit:Be,config:se}),N$=bD({BigNumber:me,Unit:Be,config:se}),M$=a3({add:ur,divide:ot,factorial:Qa,isInteger:Wr,isPositive:Xa,multiply:pr,typed:Z}),A$=o3({factorial:Qa,typed:Z}),S$=MD({BigNumber:me,Unit:Be,config:se}),E$=rD({BigNumber:me,Unit:Be,config:se}),C$=dD({BigNumber:me,Unit:Be,config:se}),cp=$3({bignumber:St,addScalar:hr,combinations:Va,divideScalar:sr,factorial:Qa,isInteger:Wr,isNegative:En,larger:Kr,multiplyScalar:mr,number:Pt,pow:Dt,subtract:or,typed:Z}),O$=hb({Unit:Be,typed:Z}),D$=I3({addScalar:hr,isInteger:Wr,isNegative:En,stirlingS2:cp,typed:Z}),fp=bC({abs:Lr,add:ur,addScalar:hr,atan:Tm,bignumber:St,column:np,complex:Za,config:se,cos:Wi,diag:Lm,divideScalar:sr,dot:Ja,equal:it,flatten:Zn,im:$m,inv:Kt,larger:Kr,matrix:ge,matrixFromColumns:Gm,multiply:pr,multiplyScalar:mr,number:Pt,qr:Xm,re:qm,sin:Xi,smaller:Jr,sqrt:Ct,subtract:or,typed:Z,usolve:ro,usolveAll:Jm}),T$=WO({BigNumber:me,Unit:Be,config:se}),B$=Il({add:ur,divide:ot,typed:Z}),$$=vD({BigNumber:me,Unit:Be,config:se}),_$=_O({BigNumber:me,Unit:Be,config:se}),lp=Rw({Index:Cr,concat:Qi,setDifference:ap,size:Er,subset:Qr,typed:Z}),I$=XO({BigNumber:me,Unit:Be,config:se}),q$=FM({DenseMatrix:Pe,lsolve:Hm,lup:up,matrix:ge,slu:Ym,typed:Z,usolve:ro}),mp=FC({add:ur,compare:Cn,divide:ot,partitionSelect:ji,typed:Z}),R$=zw({Index:Cr,concat:Qi,setIntersect:sp,setSymDifference:lp,size:Er,subset:Qr,typed:Z}),no=zl({add:ur,apply:Yi,divide:ot,isNaN:Gn,multiply:pr,subtract:or,typed:Z}),F$=t3({divide:ot,dotDivide:Ya,isNumeric:Qt,log:to,matrix:ge,multiply:pr,sum:Wm,typed:Z}),pp=Gw({abs:Lr,add:ur,conj:Sn,ctranspose:Ki,eigs:fp,equalScalar:He,larger:Kr,matrix:ge,multiply:pr,pow:Dt,smaller:Jr,sqrt:Ct,typed:Z}),z$=AD({BigNumber:me,Unit:Be,config:se}),vp=H0({BigNumber:me,DenseMatrix:Pe,SparseMatrix:Et,addScalar:hr,config:se,cos:Wi,matrix:ge,multiplyScalar:mr,norm:pp,sin:Xi,typed:Z,unaryMinus:Ot}),P$=mD({BigNumber:me,Unit:Be,config:se}),U$=Ul({sqrt:Ct,typed:Z,variance:no}),L$=PC({abs:Lr,map:_m,median:mp,subtract:or,typed:Z}),k$=L0({multiply:pr,rotationMatrix:vp,typed:Z}),Dn={},Wn={},hp={},ao=HM({math:Dn}),Or=eN({mathWithTransform:Wn}),Jn=$N({Node:Or}),Ut=qN({Node:Or}),jt=zN({Node:Or}),dp=GN({Node:Or}),Qn=oN({Node:Or}),gp=pN({Node:Or,ResultSet:Cm}),yp=dN({Node:Or}),en=MN({Node:Or}),xp=LN({Node:Or}),H$=cO({classes:hp}),G$=cC({Chain:ao,typed:Z}),bp=EN({Node:Or,typed:Z}),Kn=nN({Node:Or,subset:Qr}),wp=fN({matrix:ge,Node:Or,subset:Qr}),jn=DN({Node:Or,size:Er}),rn=XN({Unit:Be,Node:Or,math:Dn}),tn=JN({Node:Or,SymbolNode:rn,math:Dn}),ht=KN({AccessorNode:Kn,ArrayNode:Qn,AssignmentNode:wp,BlockNode:gp,ConditionalNode:yp,ConstantNode:en,FunctionAssignmentNode:bp,FunctionNode:tn,IndexNode:jn,ObjectNode:Jn,OperatorNode:Ut,ParenthesisNode:jt,RangeNode:xp,RelationalNode:dp,SymbolNode:rn,config:se,numeric:at,typed:Z}),Np=j3({ConstantNode:en,FunctionNode:tn,OperatorNode:Ut,ParenthesisNode:jt,parse:ht}),io=J3({AccessorNode:Kn,ArrayNode:Qn,ConstantNode:en,FunctionNode:tn,IndexNode:jn,ObjectNode:Jn,OperatorNode:Ut,ParenthesisNode:jt,SymbolNode:rn,add:ur,divide:ot,equal:it,isZero:mt,multiply:pr,pow:Dt,subtract:or}),V$=eM({parse:ht,typed:Z}),Mp=UM({parse:ht}),Z$=U3({parse:ht,typed:Z}),Ka=X3({bignumber:St,fraction:Vn,AccessorNode:Kn,ArrayNode:Qn,ConstantNode:en,FunctionNode:tn,IndexNode:jn,ObjectNode:Jn,OperatorNode:Ut,ParenthesisNode:jt,SymbolNode:rn,add:ur,config:se,divide:ot,equal:it,isZero:mt,mathWithTransform:Wn,matrix:ge,multiply:pr,parse:ht,pow:Dt,resolve:Np,simplifyCore:io,subtract:or,typed:Z}),X$=rO({OperatorNode:Ut,parse:ht,simplify:Ka,typed:Z}),oo=tM({parse:ht,typed:Z}),Y$=sC({Help:Mp,mathWithTransform:Wn,typed:Z}),Ap=iM({evaluate:oo}),W$=oO({bignumber:St,fraction:Vn,AccessorNode:Kn,ArrayNode:Qn,ConstantNode:en,FunctionNode:tn,IndexNode:jn,ObjectNode:Jn,OperatorNode:Ut,ParenthesisNode:jt,SymbolNode:rn,add:ur,config:se,divide:ot,equal:it,isZero:mt,mathWithTransform:Wn,matrix:ge,multiply:pr,parse:ht,pow:Dt,simplify:Ka,simplifyCore:io,subtract:or,typed:Z}),J$=aO({ConstantNode:en,FunctionNode:tn,OperatorNode:Ut,ParenthesisNode:jt,SymbolNode:rn,config:se,equal:it,isZero:mt,numeric:at,parse:ht,simplify:Ka,typed:Z}),Q$=sM({Parser:Ap,typed:Z});ir(Dn,{e:Sm,false:MT,fineStructure:AT,i:Em,Infinity:ST,LN10:ET,LOG10E:CT,NaN:OT,null:DT,phi:TT,SQRT1_2:$T,sackurTetrode:_T,tau:Om,true:IT,E:Sm,version:qT,efimovFactor:RT,LN2:FT,pi:Dm,replacer:zT,reviver:H$,SQRT2:PT,typed:Z,unaryPlus:Zi,PI:Dm,weakMixingAngle:UT,abs:Lr,acos:LT,acot:kT,acsc:HT,addScalar:hr,arg:GT,asech:VT,asinh:ZT,atan:Tm,atanh:XT,bignumber:St,bitNot:YT,boolean:WT,chain:G$,clone:JT,combinations:Va,complex:Za,conj:Sn,cosh:QT,coth:KT,csc:jT,cube:eB,equalScalar:He,erf:rB,exp:Bm,expm1:tB,filter:nB,forEach:aB,format:Hn,getMatrixDataType:iB,hex:oB,im:$m,isInteger:Wr,isNegative:En,isPositive:Xa,isZero:mt,LOG2E:sB,lgamma:uB,log10:cB,log2:fB,map:_m,multiplyScalar:mr,not:Im,number:Pt,oct:lB,pickRandom:mB,print:pB,random:vB,re:qm,sec:hB,sign:Rm,sin:Xi,splitUnit:dB,square:gB,string:yB,tan:xB,typeOf:bB,acosh:wB,acsch:NB,apply:Yi,asec:MB,bin:AB,combinationsWithRep:SB,cos:Wi,csch:EB,isNaN:Gn,isPrime:CB,randomInt:OB,sech:DB,sinh:TB,sparse:BB,sqrt:Ct,tanh:$B,unaryMinus:Ot,acoth:_B,cot:IB,fraction:Vn,isNumeric:Qt,matrix:ge,matrixFromFunction:qB,mod:Fm,nthRoot:RB,numeric:at,or:FB,prod:zm,reshape:zB,size:Er,smaller:Jr,squeeze:PB,subset:Qr,subtract:or,to:UB,transpose:Ji,xgcd:Pm,zeros:pt,and:LB,bitAnd:kB,bitXor:HB,cbrt:GB,compare:Cn,compareText:Um,concat:Qi,count:VB,ctranspose:Ki,diag:Lm,divideScalar:sr,dotDivide:Ya,equal:it,fft:km,flatten:Zn,gcd:ZB,hasNumericValue:XB,hypot:YB,ifft:WB,kron:JB,largerEq:Wa,leftShift:QB,lsolve:Hm,matrixFromColumns:Gm,min:KB,mode:jB,nthRoots:e4,ones:r4,partitionSelect:ji,resize:t4,rightArithShift:n4,round:Xn,smallerEq:eo,unequal:a4,usolve:ro,xor:i4,add:ur,atan2:o4,bitOr:s4,catalan:u4,compareNatural:vt,cumsum:c4,deepEqual:Vm,diff:f4,dot:Ja,equalText:l4,floor:Zm,identity:On,invmod:m4,larger:Kr,log:to,lsolveAll:p4,matrixFromRows:v4,multiply:pr,qr:Xm,range:Yn,rightLogShift:h4,setSize:d4,slu:Ym,sum:Wm,trace:g4,usolveAll:Jm,asin:y4,ceil:Qm,composition:x4,cross:b4,det:Km,distance:w4,dotMultiply:N4,fix:ep,intersect:M4,lcm:A4,log1p:S4,max:tp,quantileSeq:E4,row:C4,setCartesian:O4,setDistinct:D4,setIsSubset:T4,setPowerset:B4,sort:$4,column:np,index:_4,inv:Kt,pinv:I4,pow:Dt,setDifference:ap,setMultiplicity:q4,sqrtm:R4,vacuumImpedance:F4,wienDisplacement:z4,atomicMass:P4,bohrMagneton:U4,boltzmann:L4,conductanceQuantum:k4,createUnit:H4,deuteronMass:G4,dotPow:V4,electricConstant:Z4,elementaryCharge:X4,expm:Y4,faraday:W4,firstRadiation:J4,gamma:op,gravitationConstant:Q4,hartreeEnergy:K4,klitzing:j4,loschmidt:e$,magneticConstant:r$,molarMass:t$,molarPlanckConstant:n$,neutronMass:a$,nuclearMagneton:i$,planckCharge:o$,planckLength:s$,planckTemperature:u$,protonMass:c$,reducedPlanckConstant:f$,rydberg:l$,setIntersect:sp,speedOfLight:m$,stefanBoltzmann:p$,thomsonCrossSection:v$,avogadro:h$,bohrRadius:d$,coulomb:g$,divide:ot,electronMass:y$,factorial:Qa,gravity:x$,inverseConductanceQuantum:b$,lup:up,magneticFluxQuantum:w$,molarMassC12:N$,multinomial:M$,parse:ht,permutations:A$,planckMass:S$,quantumOfCirculation:E$,resolve:Np,secondRadiation:C$,simplifyCore:io,stirlingS2:cp,unit:O$,bellNumbers:D$,compile:V$,eigs:fp,fermiCoupling:T$,leafCount:Z$,mean:B$,molarVolume:$$,planckConstant:_$,setSymDifference:lp,simplify:Ka,symbolicEqual:X$,classicalElectronRadius:I$,evaluate:oo,help:Y$,lusolve:q$,median:mp,rationalize:W$,setUnion:R$,variance:no,derivative:J$,kldivergence:F$,norm:pp,planckTime:z$,rotationMatrix:vp,gasConstant:P$,parser:Q$,std:U$,mad:L$,rotate:k$,config:se}),ir(Wn,Dn,{filter:qD({typed:Z}),forEach:zD({typed:Z}),map:GD({typed:Z}),apply:DD({isInteger:Wr,typed:Z}),diff:pT({bignumber:St,matrix:ge,number:Pt,subtract:or,typed:Z}),subset:uT({matrix:ge,typed:Z}),concat:lT({isInteger:Wr,matrix:ge,typed:Z}),max:XD({config:se,larger:Kr,numeric:at,typed:Z}),min:jD({config:se,numeric:at,smaller:Jr,typed:Z}),range:tT({bignumber:St,matrix:ge,config:se,larger:Kr,largerEq:Wa,smaller:Jr,smallerEq:eo,typed:Z}),sum:yT({add:ur,config:se,numeric:at,typed:Z}),cumsum:bT({add:ur,typed:Z,unaryPlus:Zi}),row:iT({Index:Cr,matrix:ge,range:Yn,typed:Z}),column:$D({Index:Cr,matrix:ge,range:Yn,typed:Z}),index:LD({Index:Cr}),mean:JD({add:ur,divide:ot,typed:Z}),variance:NT({add:ur,apply:Yi,divide:ot,isNaN:Gn,multiply:pr,subtract:or,typed:Z}),std:dT({sqrt:Ct,typed:Z,variance:no})}),ir(hp,{BigNumber:me,Chain:ao,Complex:tr,Fraction:Jt,Matrix:Ga,Node:Or,ObjectNode:Jn,OperatorNode:Ut,ParenthesisNode:jt,Range:BT,RelationalNode:dp,ResultSet:Cm,ArrayNode:Qn,BlockNode:gp,ConditionalNode:yp,ConstantNode:en,DenseMatrix:Pe,RangeNode:xp,FunctionAssignmentNode:bp,SparseMatrix:Et,AccessorNode:Kn,AssignmentNode:wp,IndexNode:jn,FibonacciHeap:jm,ImmutableDenseMatrix:rp,Index:Cr,Spa:ip,Unit:Be,SymbolNode:rn,FunctionNode:tn,Help:Mp,Parser:Ap}),ao.createProxy(Dn);const K$={label:"Math.js",tooltip:"{{t('Math.js comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types.')}}",link:"https://mathjs.org/",evaluate:Hr.evaluate.bind(function(e,t={}){const n=oo(e,t);return typeof n=="number"?Number.isNaN(n)||!Number.isFinite(n)?null:Xn(n,9):n},{replaceKey:!0})};class Sp extends vr.Plugin{load(){return Ep(this,null,function*(){Hr.evaluators.get("math.js")||Hr.evaluators.register("math.js",K$)})}}lr.PluginMathjsEvaluatorClient=Sp,lr.default=Sp,Object.defineProperties(lr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});