rf-touchstone 0.0.1 → 0.0.2
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.
- package/coverage/coverage-badge.svg +4 -4
- package/dist/Touchstone.cjs.js +7 -13
- package/dist/Touchstone.es.js +3502 -3440
- package/dist/Touchstone.umd.js +7 -13
- package/dist/frequency.d.ts +394 -0
- package/dist/index.d.ts +24 -0
- package/dist/touchstone.d.ts +367 -803
- package/package.json +33 -30
- package/readme.md +3 -1
- package/src/frequency.ts +693 -0
- package/src/index.ts +33 -0
- package/src/touchstone.ts +774 -0
- package/development.md +0 -205
- /package/{LICENSE → LICENSE.md} +0 -0
package/dist/Touchstone.cjs.js
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function ct(){return ct=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},ct.apply(null,arguments)}var ti={relTol:1e-12,absTol:1e-15,matrix:"Matrix",number:"number",numberFallback:"number",precision:64,predictable:!1,randomSeed:null,legacySubset:!1};function ni(e,r){if(lt(e,r))return e[r];throw typeof e[r]=="function"&&Pu(e,r)?new Error('Cannot access method "'+r+'" as a property'):new Error('No access to property "'+r+'"')}function ii(e,r,t){if(lt(e,r))return e[r]=t,t;throw new Error('No access to property "'+r+'"')}function lt(e,r){return!qu(e)&&!Array.isArray(e)?!1:Wr(Uu,r)?!0:!(r in Object.prototype||r in Function.prototype)}function Pu(e,r){return e==null||typeof e[r]!="function"||Wr(e,r)&&Object.getPrototypeOf&&r in Object.getPrototypeOf(e)?!1:Wr(Ru,r)?!0:!(r in Object.prototype||r in Function.prototype)}function qu(e){return typeof e=="object"&&e&&e.constructor===Object}var Uu={length:!0,name:!0},Ru={toString:!0,valueOf:!0,toLocaleString:!0};class Lu{constructor(r){this.wrappedObject=r,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).filter(r=>this.has(r)).values()}get(r){return ni(this.wrappedObject,r)}set(r,t){return ii(this.wrappedObject,r,t),this}has(r){return lt(this.wrappedObject,r)&&r in this.wrappedObject}entries(){return Hu(this.keys(),r=>[r,this.get(r)])}forEach(r){for(var t of this.keys())r(this.get(t),t,this)}delete(r){lt(this.wrappedObject,r)&&delete this.wrappedObject[r]}clear(){for(var r of this.keys())this.delete(r)}get size(){return Object.keys(this.wrappedObject).length}}function Hu(e,r){return{next:()=>{var t=e.next();return t.done?t:{value:r(t.value),done:!1}}}}function ne(e){return typeof e=="number"}function Ee(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 Zu(e){return typeof e=="bigint"}function ui(e){return e&&typeof e=="object"&&Object.getPrototypeOf(e).isComplex===!0||!1}function oi(e){return e&&typeof e=="object"&&Object.getPrototypeOf(e).isFraction===!0||!1}function ai(e){return e&&e.constructor.prototype.isUnit===!0||!1}function Te(e){return typeof e=="string"}var ve=Array.isArray;function ye(e){return e&&e.constructor.prototype.isMatrix===!0||!1}function ht(e){return Array.isArray(e)||ye(e)}function Wu(e){return e&&e.isDenseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function Vu(e){return e&&e.isSparseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function si(e){return e&&e.constructor.prototype.isRange===!0||!1}function Nt(e){return e&&e.constructor.prototype.isIndex===!0||!1}function Gu(e){return typeof e=="boolean"}function Ju(e){return e&&e.constructor.prototype.isResultSet===!0||!1}function ku(e){return e&&e.constructor.prototype.isHelp===!0||!1}function Yu(e){return typeof e=="function"}function Xu(e){return e instanceof Date}function Qu(e){return e instanceof RegExp}function nn(e){return!!(e&&typeof e=="object"&&e.constructor===Object&&!ui(e)&&!oi(e))}function Ku(e){return e?e instanceof Map||e instanceof Lu||typeof e.set=="function"&&typeof e.get=="function"&&typeof e.keys=="function"&&typeof e.has=="function":!1}function ju(e){return e===null}function eo(e){return e===void 0}function ro(e){return e&&e.isAccessorNode===!0&&e.constructor.prototype.isNode===!0||!1}function to(e){return e&&e.isArrayNode===!0&&e.constructor.prototype.isNode===!0||!1}function no(e){return e&&e.isAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function io(e){return e&&e.isBlockNode===!0&&e.constructor.prototype.isNode===!0||!1}function uo(e){return e&&e.isConditionalNode===!0&&e.constructor.prototype.isNode===!0||!1}function oo(e){return e&&e.isConstantNode===!0&&e.constructor.prototype.isNode===!0||!1}function ao(e){return e&&e.isFunctionAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function so(e){return e&&e.isFunctionNode===!0&&e.constructor.prototype.isNode===!0||!1}function fo(e){return e&&e.isIndexNode===!0&&e.constructor.prototype.isNode===!0||!1}function co(e){return e&&e.isNode===!0&&e.constructor.prototype.isNode===!0||!1}function lo(e){return e&&e.isObjectNode===!0&&e.constructor.prototype.isNode===!0||!1}function ho(e){return e&&e.isOperatorNode===!0&&e.constructor.prototype.isNode===!0||!1}function po(e){return e&&e.isParenthesisNode===!0&&e.constructor.prototype.isNode===!0||!1}function Do(e){return e&&e.isRangeNode===!0&&e.constructor.prototype.isNode===!0||!1}function mo(e){return e&&e.isRelationalNode===!0&&e.constructor.prototype.isNode===!0||!1}function go(e){return e&&e.isSymbolNode===!0&&e.constructor.prototype.isNode===!0||!1}function vo(e){return e&&e.constructor.prototype.isChain===!0||!1}function ur(e){var r=typeof e;return r==="object"?e===null?"null":Ee(e)?"BigNumber":e.constructor&&e.constructor.name?e.constructor.name:"Object":r}function de(e){var r=typeof e;if(r==="number"||r==="bigint"||r==="string"||r==="boolean"||e===null||e===void 0)return e;if(typeof e.clone=="function")return e.clone();if(Array.isArray(e))return e.map(function(t){return de(t)});if(e instanceof Date)return new Date(e.valueOf());if(Ee(e))return e;if(nn(e))return wo(e,de);if(r==="function")return e;throw new TypeError("Cannot clone: unknown type of value (value: ".concat(e,")"))}function wo(e,r){var t={};for(var n in e)Wr(e,n)&&(t[n]=r(e[n]));return t}function yo(e,r){for(var t in r)Wr(r,t)&&(e[t]=r[t]);return e}function mr(e,r){var t,n,i;if(Array.isArray(e)){if(!Array.isArray(r)||e.length!==r.length)return!1;for(n=0,i=e.length;n<i;n++)if(!mr(e[n],r[n]))return!1;return!0}else{if(typeof e=="function")return e===r;if(e instanceof Object){if(Array.isArray(r)||!(r instanceof Object))return!1;for(t in e)if(!(t in r)||!mr(e[t],r[t]))return!1;for(t in r)if(!(t in e))return!1;return!0}else return e===r}}function Wr(e,r){return e&&Object.hasOwnProperty.call(e,r)}function Fo(e,r){for(var t={},n=0;n<r.length;n++){var i=r[n],u=e[i];u!==void 0&&(t[i]=u)}return t}var Eo=["Matrix","Array"],Ao=["number","BigNumber","bigint","Fraction"],qe=function(r){if(r)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(ri)};st(Pe,ri,{MATRIX_OPTIONS:yo,NUMBER_OPTIONS:Fo});function cn(){return!0}function Ye(){return!1}function Br(){}const ln="Argument is not a typed-function.";function si(){function e(F){return typeof F=="object"&&F!==null&&F.constructor===Object}const r=[{name:"number",test:function(F){return typeof F=="number"}},{name:"string",test:function(F){return typeof F=="string"}},{name:"boolean",test:function(F){return typeof F=="boolean"}},{name:"Function",test:function(F){return typeof F=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(F){return F instanceof Date}},{name:"RegExp",test:function(F){return F instanceof RegExp}},{name:"Object",test:e},{name:"null",test:function(F){return F===null}},{name:"undefined",test:function(F){return F===void 0}}],t={name:"any",test:cn,isAny:!0};let n,i,u=0,o={createCount:0};function a(F){const _=n.get(F);if(_)return _;let N='Unknown type "'+F+'"';const T=F.toLowerCase();let $;for($ of i)if($.toLowerCase()===T){N+='. Did you mean "'+$+'" ?';break}throw new TypeError(N)}function c(F){let _=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const N=_?a(_).index:i.length,T=[];for(let I=0;I<F.length;++I){if(!F[I]||typeof F[I].name!="string"||typeof F[I].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const H=F[I].name;if(n.has(H))throw new TypeError('Duplicate type name "'+H+'"');T.push(H),n.set(H,{name:H,test:F[I].test,isAny:F[I].isAny,index:N+I,conversionsTo:[]})}const $=i.slice(N);i=i.slice(0,N).concat(T).concat($);for(let I=N+T.length;I<i.length;++I)n.get(i[I]).index=I}function l(){n=new Map,i=[],u=0,c([t],!1)}l(),c(r);function f(){let F;for(F of i)n.get(F).conversionsTo=[];u=0}function h(F){const _=i.filter(N=>{const T=n.get(N);return!T.isAny&&T.test(F)});return _.length?_:["any"]}function D(F){return F&&typeof F=="function"&&"_typedFunctionData"in F}function p(F,_,N){if(!D(F))throw new TypeError(ln);const T=N&&N.exact,$=Array.isArray(_)?_.join(","):_,I=A($),H=d(I);if(!T||H in F.signatures){const se=F._typedFunctionData.signatureMap.get(H);if(se)return se}const U=I.length;let Z;if(T){Z=[];let se;for(se in F.signatures)Z.push(F._typedFunctionData.signatureMap.get(se))}else Z=F._typedFunctionData.signatures;for(let se=0;se<U;++se){const pe=I[se],_e=[];let Le;for(Le of Z){const Re=b(Le.params,se);if(!(!Re||pe.restParam&&!Re.restParam)){if(!Re.hasAny){const Ke=v(Re);if(pe.types.some(je=>!Ke.has(je.name)))continue}_e.push(Le)}}if(Z=_e,Z.length===0)break}let P;for(P of Z)if(P.params.length<=U)return P;throw new TypeError("Signature not found (signature: "+(F.name||"unnamed")+"("+d(I,", ")+"))")}function m(F,_,N){return p(F,_,N).implementation}function s(F,_){const N=a(_);if(N.test(F))return F;const T=N.conversionsTo;if(T.length===0)throw new Error("There are no conversions to "+_+" defined.");for(let $=0;$<T.length;$++)if(a(T[$].from).test(F))return T[$].convert(F);throw new Error("Cannot convert "+F+" to "+_)}function d(F){let _=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return F.map(N=>N.name).join(_)}function g(F){const _=F.indexOf("...")===0,T=(_?F.length>3?F.slice(3):"any":F).split("|").map(U=>a(U.trim()));let $=!1,I=_?"...":"";return{types:T.map(function(U){return $=U.isAny||$,I+=U.name+"|",{name:U.name,typeIndex:U.index,test:U.test,isAny:U.isAny,conversion:null,conversionIndex:-1}}),name:I.slice(0,-1),hasAny:$,hasConversion:!1,restParam:_}}function E(F){const _=F.types.map(H=>H.name),N=Q(_);let T=F.hasAny,$=F.name;const I=N.map(function(H){const U=a(H.from);return T=U.isAny||T,$+="|"+H.from,{name:H.from,typeIndex:U.index,test:U.test,isAny:U.isAny,conversion:H,conversionIndex:H.index}});return{types:F.types.concat(I),name:$,hasAny:T,hasConversion:I.length>0,restParam:F.restParam}}function v(F){return F.typeSet||(F.typeSet=new Set,F.types.forEach(_=>F.typeSet.add(_.name))),F.typeSet}function A(F){const _=[];if(typeof F!="string")throw new TypeError("Signatures must be strings");const N=F.trim();if(N==="")return _;const T=N.split(",");for(let $=0;$<T.length;++$){const I=g(T[$].trim());if(I.restParam&&$!==T.length-1)throw new SyntaxError('Unexpected rest parameter "'+T[$]+'": only allowed for the last parameter');if(I.types.length===0)return null;_.push(I)}return _}function y(F){const _=ce(F);return _?_.restParam:!1}function w(F){if(!F||F.types.length===0)return cn;if(F.types.length===1)return a(F.types[0].name).test;if(F.types.length===2){const _=a(F.types[0].name).test,N=a(F.types[1].name).test;return function($){return _($)||N($)}}else{const _=F.types.map(function(N){return a(N.name).test});return function(T){for(let $=0;$<_.length;$++)if(_[$](T))return!0;return!1}}}function C(F){let _,N,T;if(y(F)){_=qe(F).map(w);const $=_.length,I=w(ce(F)),H=function(U){for(let Z=$;Z<U.length;Z++)if(!I(U[Z]))return!1;return!0};return function(Z){for(let P=0;P<_.length;P++)if(!_[P](Z[P]))return!1;return H(Z)&&Z.length>=$+1}}else return F.length===0?function(I){return I.length===0}:F.length===1?(N=w(F[0]),function(I){return N(I[0])&&I.length===1}):F.length===2?(N=w(F[0]),T=w(F[1]),function(I){return N(I[0])&&T(I[1])&&I.length===2}):(_=F.map(w),function(I){for(let H=0;H<_.length;H++)if(!_[H](I[H]))return!1;return I.length===_.length})}function b(F,_){return _<F.length?F[_]:y(F)?ce(F):null}function B(F,_){const N=b(F,_);return N?v(N):new Set}function M(F){return F.conversion===null||F.conversion===void 0}function S(F,_){const N=new Set;return F.forEach(T=>{const $=B(T.params,_);let I;for(I of $)N.add(I)}),N.has("any")?["any"]:Array.from(N)}function R(F,_,N){let T,$;const I=F||"unnamed";let H=N,U;for(U=0;U<_.length;U++){const pe=[];if(H.forEach(_e=>{const Le=b(_e.params,U),Re=w(Le);(U<_e.params.length||y(_e.params))&&Re(_[U])&&pe.push(_e)}),pe.length===0){if($=S(H,U),$.length>0){const _e=h(_[U]);return T=new TypeError("Unexpected type of argument in function "+I+" (expected: "+$.join(" or ")+", actual: "+_e.join(" | ")+", index: "+U+")"),T.data={category:"wrongType",fn:I,index:U,actual:_e,expected:$},T}}else H=pe}const Z=H.map(function(pe){return y(pe.params)?1/0:pe.params.length});if(_.length<Math.min.apply(null,Z))return $=S(H,U),T=new TypeError("Too few arguments in function "+I+" (expected: "+$.join(" or ")+", index: "+_.length+")"),T.data={category:"tooFewArgs",fn:I,index:_.length,expected:$},T;const P=Math.max.apply(null,Z);if(_.length>P)return T=new TypeError("Too many arguments in function "+I+" (expected: "+P+", actual: "+_.length+")"),T.data={category:"tooManyArgs",fn:I,index:_.length,expectedLength:P},T;const se=[];for(let pe=0;pe<_.length;++pe)se.push(h(_[pe]).join("|"));return T=new TypeError('Arguments of type "'+se.join(", ")+'" do not match any of the defined signatures of function '+I+"."),T.data={category:"mismatch",actual:se},T}function V(F){let _=i.length+1;for(let N=0;N<F.types.length;N++)M(F.types[N])&&(_=Math.min(_,F.types[N].typeIndex));return _}function q(F){let _=u+1;for(let N=0;N<F.types.length;N++)M(F.types[N])||(_=Math.min(_,F.types[N].conversionIndex));return _}function W(F,_){if(F.hasAny){if(!_.hasAny)return 1}else if(_.hasAny)return-1;if(F.restParam){if(!_.restParam)return 1}else if(_.restParam)return-1;if(F.hasConversion){if(!_.hasConversion)return 1}else if(_.hasConversion)return-1;const N=V(F)-V(_);if(N<0)return-1;if(N>0)return 1;const T=q(F)-q(_);return T<0?-1:T>0?1:0}function O(F,_){const N=F.params,T=_.params,$=ce(N),I=ce(T),H=y(N),U=y(T);if(H&&$.hasAny){if(!U||!I.hasAny)return 1}else if(U&&I.hasAny)return-1;let Z=0,P=0,se;for(se of N)se.hasAny&&++Z,se.hasConversion&&++P;let pe=0,_e=0;for(se of T)se.hasAny&&++pe,se.hasConversion&&++_e;if(Z!==pe)return Z-pe;if(H&&$.hasConversion){if(!U||!I.hasConversion)return 1}else if(U&&I.hasConversion)return-1;if(P!==_e)return P-_e;if(H){if(!U)return 1}else if(U)return-1;const Le=(N.length-T.length)*(H?-1:1);if(Le!==0)return Le;const Re=[];let Ke=0;for(let _r=0;_r<N.length;++_r){const Qr=W(N[_r],T[_r]);Re.push(Qr),Ke+=Qr}if(Ke!==0)return Ke;let je;for(je of Re)if(je!==0)return je;return 0}function Q(F){if(F.length===0)return[];const _=F.map(a);F.length>1&&_.sort(($,I)=>$.index-I.index);let N=_[0].conversionsTo;if(F.length===1)return N;N=N.concat([]);const T=new Set(F);for(let $=1;$<_.length;++$){let I;for(I of _[$].conversionsTo)T.has(I.from)||(N.push(I),T.add(I.from))}return N}function Y(F,_){let N=_;if(F.some($=>$.hasConversion)){const $=y(F),I=F.map(J);N=function(){const U=[],Z=$?arguments.length-1:arguments.length;for(let P=0;P<Z;P++)U[P]=I[P](arguments[P]);return $&&(U[Z]=arguments[Z].map(I[Z])),_.apply(this,U)}}let T=N;if(y(F)){const $=F.length-1;T=function(){return N.apply(this,ae(arguments,0,$).concat([ae(arguments,$)]))}}return T}function J(F){let _,N,T,$;const I=[],H=[];switch(F.types.forEach(function(U){U.conversion&&(I.push(a(U.conversion.from).test),H.push(U.conversion.convert))}),H.length){case 0:return function(Z){return Z};case 1:return _=I[0],T=H[0],function(Z){return _(Z)?T(Z):Z};case 2:return _=I[0],N=I[1],T=H[0],$=H[1],function(Z){return _(Z)?T(Z):N(Z)?$(Z):Z};default:return function(Z){for(let P=0;P<H.length;P++)if(I[P](Z))return H[P](Z);return Z}}}function ee(F){function _(N,T,$){if(T<N.length){const I=N[T];let H=[];if(I.restParam){const U=I.types.filter(M);U.length<I.types.length&&H.push({types:U,name:"..."+U.map(Z=>Z.name).join("|"),hasAny:U.some(Z=>Z.isAny),hasConversion:!1,restParam:!0}),H.push(I)}else H=I.types.map(function(U){return{types:[U],name:U.name,hasAny:U.isAny,hasConversion:U.conversion,restParam:!1}});return Te(H,function(U){return _(N,T+1,$.concat([U]))})}else return[$]}return _(F,0,[])}function oe(F,_){const N=Math.max(F.length,_.length);for(let U=0;U<N;U++){const Z=B(F,U),P=B(_,U);let se=!1,pe;for(pe of P)if(Z.has(pe)){se=!0;break}if(!se)return!1}const T=F.length,$=_.length,I=y(F),H=y(_);return I?H?T===$:$>=T:H?T>=$:T===$}function ie(F){return F.map(_=>sr(_)?Je(_.referToSelf.callback):ar(_)?Me(_.referTo.references,_.referTo.callback):_)}function fe(F,_,N){const T=[];let $;for($ of F){let I=N[$];if(typeof I!="number")throw new TypeError('No definition for referenced signature "'+$+'"');if(I=_[I],typeof I!="function")return!1;T.push(I)}return T}function Ce(F,_,N){const T=ie(F),$=new Array(T.length).fill(!1);let I=!0;for(;I;){I=!1;let H=!0;for(let U=0;U<T.length;++U){if($[U])continue;const Z=T[U];if(sr(Z))T[U]=Z.referToSelf.callback(N),T[U].referToSelf=Z.referToSelf,$[U]=!0,H=!1;else if(ar(Z)){const P=fe(Z.referTo.references,T,_);P?(T[U]=Z.referTo.callback.apply(this,P),T[U].referTo=Z.referTo,$[U]=!0,H=!1):I=!0}}if(H&&I)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return T}function be(F){const _=/\bthis(\(|\.signatures\b)/;Object.keys(F).forEach(N=>{const T=F[N];if(_.test(T.toString()))throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function Ae(F,_){if(o.createCount++,Object.keys(_).length===0)throw new SyntaxError("No signatures provided");o.warnAgainstDeprecatedThis&&be(_);const N=[],T=[],$={},I=[];let H;for(H in _){if(!Object.prototype.hasOwnProperty.call(_,H))continue;const ue=A(H);if(!ue)continue;N.forEach(function(Ur){if(oe(Ur,ue))throw new TypeError('Conflicting signatures "'+d(Ur)+'" and "'+d(ue)+'".')}),N.push(ue);const He=T.length;T.push(_[H]);const Iu=ue.map(E);let Kr;for(Kr of ee(Iu)){const Ur=d(Kr);I.push({params:Kr,name:Ur,fn:He}),Kr.every(zu=>!zu.hasConversion)&&($[Ur]=He)}}I.sort(O);const U=Ce(T,$,Pr);let Z;for(Z in $)Object.prototype.hasOwnProperty.call($,Z)&&($[Z]=U[$[Z]]);const P=[],se=new Map;for(Z of I)se.has(Z.name)||(Z.fn=U[Z.fn],P.push(Z),se.set(Z.name,Z));const pe=P[0]&&P[0].params.length<=2&&!y(P[0].params),_e=P[1]&&P[1].params.length<=2&&!y(P[1].params),Le=P[2]&&P[2].params.length<=2&&!y(P[2].params),Re=P[3]&&P[3].params.length<=2&&!y(P[3].params),Ke=P[4]&&P[4].params.length<=2&&!y(P[4].params),je=P[5]&&P[5].params.length<=2&&!y(P[5].params),_r=pe&&_e&&Le&&Re&&Ke&&je;for(let ue=0;ue<P.length;++ue)P[ue].test=C(P[ue].params);const Qr=pe?w(P[0].params[0]):Ye,uu=_e?w(P[1].params[0]):Ye,ou=Le?w(P[2].params[0]):Ye,au=Re?w(P[3].params[0]):Ye,su=Ke?w(P[4].params[0]):Ye,fu=je?w(P[5].params[0]):Ye,cu=pe?w(P[0].params[1]):Ye,lu=_e?w(P[1].params[1]):Ye,hu=Le?w(P[2].params[1]):Ye,pu=Re?w(P[3].params[1]):Ye,Du=Ke?w(P[4].params[1]):Ye,mu=je?w(P[5].params[1]):Ye;for(let ue=0;ue<P.length;++ue)P[ue].implementation=Y(P[ue].params,P[ue].fn);const du=pe?P[0].implementation:Br,gu=_e?P[1].implementation:Br,vu=Le?P[2].implementation:Br,wu=Re?P[3].implementation:Br,yu=Ke?P[4].implementation:Br,Fu=je?P[5].implementation:Br,Eu=pe?P[0].params.length:-1,Au=_e?P[1].params.length:-1,bu=Le?P[2].params.length:-1,Cu=Re?P[3].params.length:-1,_u=Ke?P[4].params.length:-1,Bu=je?P[5].params.length:-1,Nu=_r?6:0,Mu=P.length,Su=P.map(ue=>ue.test),xu=P.map(ue=>ue.implementation),Tu=function(){for(let He=Nu;He<Mu;He++)if(Su[He](arguments))return xu[He].apply(this,arguments);return o.onMismatch(F,arguments,P)};function Pr(ue,He){return arguments.length===Eu&&Qr(ue)&&cu(He)?du.apply(this,arguments):arguments.length===Au&&uu(ue)&&lu(He)?gu.apply(this,arguments):arguments.length===bu&&ou(ue)&&hu(He)?vu.apply(this,arguments):arguments.length===Cu&&au(ue)&&pu(He)?wu.apply(this,arguments):arguments.length===_u&&su(ue)&&Du(He)?yu.apply(this,arguments):arguments.length===Bu&&fu(ue)&&mu(He)?Fu.apply(this,arguments):Tu.apply(this,arguments)}try{Object.defineProperty(Pr,"name",{value:F})}catch{}return Pr.signatures=$,Pr._typedFunctionData={signatures:P,signatureMap:se},Pr}function we(F,_,N){throw R(F,_,N)}function qe(F){return ae(F,0,F.length-1)}function ce(F){return F[F.length-1]}function ae(F,_,N){return Array.prototype.slice.call(F,_,N)}function Ge(F,_){for(let N=0;N<F.length;N++)if(_(F[N]))return F[N]}function Te(F,_){return Array.prototype.concat.apply([],F.map(_))}function le(){const F=qe(arguments).map(N=>d(A(N))),_=ce(arguments);if(typeof _!="function")throw new TypeError("Callback function expected as last argument");return Me(F,_)}function Me(F,_){return{referTo:{references:F,callback:_}}}function Je(F){if(typeof F!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:F}}}function ar(F){return F&&typeof F.referTo=="object"&&Array.isArray(F.referTo.references)&&typeof F.referTo.callback=="function"}function sr(F){return F&&typeof F.referToSelf=="object"&&typeof F.referToSelf.callback=="function"}function br(F,_){if(!F)return _;if(_&&_!==F){const N=new Error("Function names do not match (expected: "+F+", actual: "+_+")");throw N.data={actual:_,expected:F},N}return F}function Cr(F){let _;for(const N in F)Object.prototype.hasOwnProperty.call(F,N)&&(D(F[N])||typeof F[N].signature=="string")&&(_=br(_,F[N].name));return _}function qt(F,_){let N;for(N in _)if(Object.prototype.hasOwnProperty.call(_,N)){if(N in F&&_[N]!==F[N]){const T=new Error('Signature "'+N+'" is defined twice');throw T.data={signature:N,sourceFunction:_[N],destFunction:F[N]},T}F[N]=_[N]}}const iu=o;o=function(F){const _=typeof F=="string",N=_?1:0;let T=_?F:"";const $={};for(let I=N;I<arguments.length;++I){const H=arguments[I];let U={},Z;if(typeof H=="function"?(Z=H.name,typeof H.signature=="string"?U[H.signature]=H:D(H)&&(U=H.signatures)):e(H)&&(U=H,_||(Z=Cr(H))),Object.keys(U).length===0){const P=new TypeError("Argument to 'typed' at index "+I+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw P.data={index:I,argument:H},P}_||(T=br(T,Z)),qt($,U)}return Ae(T||"",$)},o.create=si,o.createCount=iu.createCount,o.onMismatch=we,o.throwMismatchError=we,o.createError=R,o.clear=l,o.clearConversions=f,o.addTypes=c,o._findType=a,o.referTo=le,o.referToSelf=Je,o.convert=s,o.findSignature=p,o.find=m,o.isTypedFunction=D,o.warnAgainstDeprecatedThis=!0,o.addType=function(F,_){let N="any";_!==!1&&n.has("Object")&&(N="Object"),o.addTypes([F],N)};function fn(F){if(!F||typeof F.from!="string"||typeof F.to!="string"||typeof F.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(F.to===F.from)throw new SyntaxError('Illegal to define conversion from "'+F.from+'" to itself.')}return o.addConversion=function(F){let _=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{override:!1};fn(F);const N=a(F.to),T=N.conversionsTo.find($=>$.from===F.from);if(T)if(_&&_.override)o.removeConversion({from:T.from,to:F.to,convert:T.convert});else throw new Error('There is already a conversion from "'+F.from+'" to "'+N.name+'"');N.conversionsTo.push({from:F.from,convert:F.convert,index:u++})},o.addConversions=function(F,_){F.forEach(N=>o.addConversion(N,_))},o.removeConversion=function(F){fn(F);const _=a(F.to),N=Ge(_.conversionsTo,$=>$.from===F.from);if(!N)throw new Error("Attempt to remove nonexistent conversion from "+F.from+" to "+F.to);if(N.convert!==F.convert)throw new Error("Conversion to remove does not match existing conversion");const T=_.conversionsTo.indexOf(N);_.conversionsTo.splice(T,1)},o.resolve=function(F,_){if(!D(F))throw new TypeError(ln);const N=F._typedFunctionData.signatures;for(let T=0;T<N.length;++T)if(N[T].test(_))return N[T];return null},o}const lt=si();function G(e,r,t,n){function i(u){var o=wo(u,r.map(bo));return Eo(e,r,u),t(o)}return i.isFactory=!0,i.fn=e,i.dependencies=r.slice().sort(),n&&(i.meta=n),i}function Eo(e,r,t){var n=r.filter(u=>!Ao(u)).every(u=>t[u]!==void 0);if(!n){var i=r.filter(u=>t[u]===void 0);throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(i.map(u=>'"'.concat(u,'"')).join(", "),"."))}}function Ao(e){return e&&e[0]==="?"}function bo(e){return e&&e[0]==="?"?e.slice(1):e}function ge(e){return typeof e=="boolean"?!0:isFinite(e)?e===Math.round(e):!1}var Co=Math.log10||function(r){return Math.log(r)/Math.LN10};function Rt(e,r,t){var n={2:"0b",8:"0o",16:"0x"},i=n[r],u="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!ge(t))throw new Error("size must be an integer");if(e>2**(t-1)-1||e<-(2**(t-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!ge(e))throw new Error("Value must be an integer");e<0&&(e=e+2**t),u="i".concat(t)}var o="";return e<0&&(e=-e,o="-"),"".concat(o).concat(i).concat(e.toString(r)).concat(u)}function Wt(e,r){if(typeof r=="function")return r(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var{notation:t,precision:n,wordSize:i}=fi(r);switch(t){case"fixed":return ci(e,n);case"exponential":return li(e,n);case"engineering":return _o(e,n);case"bin":return Rt(e,2,i);case"oct":return Rt(e,8,i);case"hex":return Rt(e,16,i);case"auto":return Bo(e,n,r).replace(/((\.\d*?)(0+))($|e)/,function(){var u=arguments[2],o=arguments[4];return u!=="."?u+o:o});default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function fi(e){var r="auto",t,n;if(e!==void 0)if(de(e))t=e;else if(Ee(e))t=e.toNumber();else if(rn(e))e.precision!==void 0&&(t=hn(e.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),e.wordSize!==void 0&&(n=hn(e.wordSize,()=>{throw new Error('Option "wordSize" must be a number or BigNumber')})),e.notation&&(r=e.notation);else throw new Error("Unsupported type of options, number, BigNumber, or object expected");return{notation:r,precision:t,wordSize:n}}function Vr(e){var r=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!r)throw new SyntaxError("Invalid number "+e);var t=r[1],n=r[2],i=parseFloat(r[4]||"0"),u=n.indexOf(".");i+=u!==-1?u-1:n.length-1;var o=n.replace(".","").replace(/^0*/,function(a){return i-=a.length,""}).replace(/0*$/,"").split("").map(function(a){return parseInt(a)});return o.length===0&&(o.push(0),i++),{sign:t,coefficients:o,exponent:i}}function _o(e,r){if(isNaN(e)||!isFinite(e))return String(e);var t=Vr(e),n=_t(t,r),i=n.exponent,u=n.coefficients,o=i%3===0?i:i<0?i-3-i%3:i-i%3;if(de(r))for(;r>u.length||i-o+1>u.length;)u.push(0);else for(var a=Math.abs(i-o)-(u.length-1),c=0;c<a;c++)u.push(0);for(var l=Math.abs(i-o),f=1;l>0;)f++,l--;var h=u.slice(f).join(""),D=de(r)&&h.length||h.match(/[1-9]/)?"."+h:"",p=u.slice(0,f).join("")+D+"e"+(i>=0?"+":"")+o.toString();return n.sign+p}function ci(e,r){if(isNaN(e)||!isFinite(e))return String(e);var t=Vr(e),n=typeof r=="number"?_t(t,t.exponent+1+r):t,i=n.coefficients,u=n.exponent+1,o=u+(r||0);return i.length<o&&(i=i.concat(Tr(o-i.length))),u<0&&(i=Tr(-u+1).concat(i),u=1),u<i.length&&i.splice(u,0,u===0?"0.":"."),n.sign+i.join("")}function li(e,r){if(isNaN(e)||!isFinite(e))return String(e);var t=Vr(e),n=r?_t(t,r):t,i=n.coefficients,u=n.exponent;i.length<r&&(i=i.concat(Tr(r-i.length)));var o=i.shift();return n.sign+o+(i.length>0?"."+i.join(""):"")+"e"+(u>=0?"+":"")+u}function Bo(e,r,t){if(isNaN(e)||!isFinite(e))return String(e);var n=pn(t?.lowerExp,-3),i=pn(t?.upperExp,5),u=Vr(e),o=r?_t(u,r):u;if(o.exponent<n||o.exponent>=i)return li(e,r);var a=o.coefficients,c=o.exponent;a.length<r&&(a=a.concat(Tr(r-a.length))),a=a.concat(Tr(c-a.length+1+(a.length<r?r-a.length:0))),a=Tr(-c).concat(a);var l=c>0?c:0;return l<a.length-1&&a.splice(l+1,0,"."),o.sign+a.join("")}function _t(e,r){for(var t={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},n=t.coefficients;r<=0;)n.unshift(0),t.exponent++,r++;if(n.length>r){var i=n.splice(r,n.length-r);if(i[0]>=5){var u=r-1;for(n[u]++;n[u]===10;)n.pop(),u===0&&(n.unshift(0),t.exponent++,u++),u--,n[u]++}}return t}function Tr(e){for(var r=[],t=0;t<e;t++)r.push(0);return r}function No(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}function tr(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e-8,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(t<=0)throw new Error("Relative tolerance must be greater than 0");if(n<0)throw new Error("Absolute tolerance must be at least 0");return isNaN(e)||isNaN(r)?!1:!isFinite(e)||!isFinite(r)?e===r:e===r?!0:Math.abs(e-r)<=Math.max(t*Math.max(Math.abs(e),Math.abs(r)),n)}function hn(e,r){if(de(e))return e;if(Ee(e))return e.toNumber();r()}function pn(e,r){return de(e)?e:Ee(e)?e.toNumber():r}var hi=function(){return hi=lt.create,lt},Mo=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],So=G("typed",Mo,function(r){var{BigNumber:t,Complex:n,DenseMatrix:i,Fraction:u}=r,o=hi();return o.clear(),o.addTypes([{name:"number",test:de},{name:"Complex",test:ii},{name:"BigNumber",test:Ee},{name:"bigint",test:Lu},{name:"Fraction",test:ui},{name:"Unit",test:oi},{name:"identifier",test:a=>Qe&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC4\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC4\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])*$/.test(a)},{name:"string",test:Qe},{name:"Chain",test:mo},{name:"Array",test:ye},{name:"Matrix",test:ve},{name:"DenseMatrix",test:Hu},{name:"SparseMatrix",test:Zu},{name:"Range",test:ai},{name:"Index",test:Ct},{name:"boolean",test:Wu},{name:"ResultSet",test:Vu},{name:"Help",test:Gu},{name:"function",test:Ju},{name:"Date",test:Yu},{name:"RegExp",test:ku},{name:"null",test:Qu},{name:"undefined",test:Ku},{name:"AccessorNode",test:ju},{name:"ArrayNode",test:eo},{name:"AssignmentNode",test:ro},{name:"BlockNode",test:to},{name:"ConditionalNode",test:no},{name:"ConstantNode",test:io},{name:"FunctionNode",test:oo},{name:"FunctionAssignmentNode",test:uo},{name:"IndexNode",test:ao},{name:"Node",test:so},{name:"ObjectNode",test:fo},{name:"OperatorNode",test:co},{name:"ParenthesisNode",test:lo},{name:"RangeNode",test:ho},{name:"RelationalNode",test:po},{name:"SymbolNode",test:Do},{name:"Map",test:Xu},{name:"Object",test:rn}]),o.addConversions([{from:"number",to:"BigNumber",convert:function(c){if(t||jr(c),No(c)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+c+"). Use function bignumber(x) to convert to BigNumber.");return new t(c)}},{from:"number",to:"Complex",convert:function(c){return n||et(c),new n(c,0)}},{from:"BigNumber",to:"Complex",convert:function(c){return n||et(c),new n(c.toNumber(),0)}},{from:"bigint",to:"number",convert:function(c){if(c>Number.MAX_SAFE_INTEGER)throw new TypeError("Cannot implicitly convert bigint to number: value exceeds the max safe integer value (value: "+c+")");return Number(c)}},{from:"bigint",to:"BigNumber",convert:function(c){return t||jr(c),new t(c.toString())}},{from:"bigint",to:"Fraction",convert:function(c){return u||rt(c),new u(c)}},{from:"Fraction",to:"BigNumber",convert:function(c){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(c){return n||et(c),new n(c.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(c){u||rt(c);var l=new u(c);if(l.valueOf()!==c)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+c+"). Use function fraction(x) to convert to Fraction.");return l}},{from:"string",to:"number",convert:function(c){var l=Number(c);if(isNaN(l))throw new Error('Cannot convert "'+c+'" to a number');return l}},{from:"string",to:"BigNumber",convert:function(c){t||jr(c);try{return new t(c)}catch{throw new Error('Cannot convert "'+c+'" to BigNumber')}}},{from:"string",to:"bigint",convert:function(c){try{return BigInt(c)}catch{throw new Error('Cannot convert "'+c+'" to BigInt')}}},{from:"string",to:"Fraction",convert:function(c){u||rt(c);try{return new u(c)}catch{throw new Error('Cannot convert "'+c+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(c){n||et(c);try{return new n(c)}catch{throw new Error('Cannot convert "'+c+'" to Complex')}}},{from:"boolean",to:"number",convert:function(c){return+c}},{from:"boolean",to:"BigNumber",convert:function(c){return t||jr(c),new t(+c)}},{from:"boolean",to:"bigint",convert:function(c){return BigInt(+c)}},{from:"boolean",to:"Fraction",convert:function(c){return u||rt(c),new u(+c)}},{from:"boolean",to:"string",convert:function(c){return String(c)}},{from:"Array",to:"Matrix",convert:function(c){return i||xo(),new i(c)}},{from:"Matrix",to:"Array",convert:function(c){return c.valueOf()}}]),o.onMismatch=(a,c,l)=>{var f=o.createError(a,c,l);if(["wrongType","mismatch"].includes(f.data.category)&&c.length===1&&ct(c[0])&&l.some(D=>!D.params.includes(","))){var h=new TypeError("Function '".concat(a,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(a,")'."));throw h.data=f.data,h}throw f},o.onMismatch=(a,c,l)=>{var f=o.createError(a,c,l);if(["wrongType","mismatch"].includes(f.data.category)&&c.length===1&&ct(c[0])&&l.some(D=>!D.params.includes(","))){var h=new TypeError("Function '".concat(a,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(a,")'."));throw h.data=f.data,h}throw f},o});function jr(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function et(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function xo(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function rt(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}/*!
|
|
9
|
-
* decimal.js v10.5.0
|
|
10
|
-
|
|
11
|
-
* https://github.com/MikeMcl/decimal.js
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
*/var xr=9e15,vr=1e9,Vt="0123456789abcdef",ht="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",pt="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Gt={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-xr,maxE:xr,crypto:!1},pi,cr,j=!0,Bt="[DecimalError] ",dr=Bt+"Invalid argument: ",Di=Bt+"Precision limit exceeded",mi=Bt+"crypto unavailable",di="[object Decimal]",$e=Math.floor,Ne=Math.pow,To=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Io=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,zo=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,gi=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,rr=1e7,K=7,Oo=9007199254740991,$o=ht.length-1,Jt=pt.length-1,z={toStringTag:di};z.absoluteValue=z.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),X(e)};z.ceil=function(){return X(new this.constructor(this),this.e+1,2)};z.clampedTo=z.clamp=function(e,r){var t,n=this,i=n.constructor;if(e=new i(e),r=new i(r),!e.s||!r.s)return new i(NaN);if(e.gt(r))throw Error(dr+r);return t=n.cmp(e),t<0?e:n.cmp(r)>0?r:new i(n)};z.comparedTo=z.cmp=function(e){var r,t,n,i,u=this,o=u.d,a=(e=new u.constructor(e)).d,c=u.s,l=e.s;if(!o||!a)return!c||!l?NaN:c!==l?c:o===a?0:!o^c<0?1:-1;if(!o[0]||!a[0])return o[0]?c:a[0]?-l:0;if(c!==l)return c;if(u.e!==e.e)return u.e>e.e^c<0?1:-1;for(n=o.length,i=a.length,r=0,t=n<i?n:i;r<t;++r)if(o[r]!==a[r])return o[r]>a[r]^c<0?1:-1;return n===i?0:n>i^c<0?1:-1};z.cosine=z.cos=function(){var e,r,t=this,n=t.constructor;return t.d?t.d[0]?(e=n.precision,r=n.rounding,n.precision=e+Math.max(t.e,t.sd())+K,n.rounding=1,t=Po(n,Ei(n,t)),n.precision=e,n.rounding=r,X(cr==2||cr==3?t.neg():t,e,r,!0)):new n(1):new n(NaN)};z.cubeRoot=z.cbrt=function(){var e,r,t,n,i,u,o,a,c,l,f=this,h=f.constructor;if(!f.isFinite()||f.isZero())return new h(f);for(j=!1,u=f.s*Ne(f.s*f,1/3),!u||Math.abs(u)==1/0?(t=Ie(f.d),e=f.e,(u=(e-t.length+1)%3)&&(t+=u==1||u==-2?"0":"00"),u=Ne(t,1/3),e=$e((e+1)/3)-(e%3==(e<0?-1:2)),u==1/0?t="5e"+e:(t=u.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),n=new h(t),n.s=f.s):n=new h(u.toString()),o=(e=h.precision)+3;;)if(a=n,c=a.times(a).times(a),l=c.plus(f),n=he(l.plus(f).times(a),l.plus(c),o+2,1),Ie(a.d).slice(0,o)===(t=Ie(n.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!i&&t=="4999"){if(!i&&(X(a,e+1,0),a.times(a).times(a).eq(f))){n=a;break}o+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(X(n,e+1,1),r=!n.times(n).times(n).eq(f));break}return j=!0,X(n,e,h.rounding,r)};z.decimalPlaces=z.dp=function(){var e,r=this.d,t=NaN;if(r){if(e=r.length-1,t=(e-$e(this.e/K))*K,e=r[e],e)for(;e%10==0;e/=10)t--;t<0&&(t=0)}return t};z.dividedBy=z.div=function(e){return he(this,new this.constructor(e))};z.dividedToIntegerBy=z.divToInt=function(e){var r=this,t=r.constructor;return X(he(r,new t(e),0,1,1),t.precision,t.rounding)};z.equals=z.eq=function(e){return this.cmp(e)===0};z.floor=function(){return X(new this.constructor(this),this.e+1,3)};z.greaterThan=z.gt=function(e){return this.cmp(e)>0};z.greaterThanOrEqualTo=z.gte=function(e){var r=this.cmp(e);return r==1||r===0};z.hyperbolicCosine=z.cosh=function(){var e,r,t,n,i,u=this,o=u.constructor,a=new o(1);if(!u.isFinite())return new o(u.s?1/0:NaN);if(u.isZero())return a;t=o.precision,n=o.rounding,o.precision=t+Math.max(u.e,u.sd())+4,o.rounding=1,i=u.d.length,i<32?(e=Math.ceil(i/3),r=(1/Mt(4,e)).toString()):(e=16,r="2.3283064365386962890625e-10"),u=Ir(o,1,u.times(r),new o(1),!0);for(var c,l=e,f=new o(8);l--;)c=u.times(u),u=a.minus(c.times(f.minus(c.times(f))));return X(u,o.precision=t,o.rounding=n,!0)};z.hyperbolicSine=z.sinh=function(){var e,r,t,n,i=this,u=i.constructor;if(!i.isFinite()||i.isZero())return new u(i);if(r=u.precision,t=u.rounding,u.precision=r+Math.max(i.e,i.sd())+4,u.rounding=1,n=i.d.length,n<3)i=Ir(u,2,i,i,!0);else{e=1.4*Math.sqrt(n),e=e>16?16:e|0,i=i.times(1/Mt(5,e)),i=Ir(u,2,i,i,!0);for(var o,a=new u(5),c=new u(16),l=new u(20);e--;)o=i.times(i),i=i.times(a.plus(o.times(c.times(o).plus(l))))}return u.precision=r,u.rounding=t,X(i,r,t,!0)};z.hyperbolicTangent=z.tanh=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+7,n.rounding=1,he(t.sinh(),t.cosh(),n.precision=e,n.rounding=r)):new n(t.s)};z.inverseCosine=z.acos=function(){var e=this,r=e.constructor,t=e.abs().cmp(1),n=r.precision,i=r.rounding;return t!==-1?t===0?e.isNeg()?nr(r,n,i):new r(0):new r(NaN):e.isZero()?nr(r,n+4,i).times(.5):(r.precision=n+6,r.rounding=1,e=new r(1).minus(e).div(e.plus(1)).sqrt().atan(),r.precision=n,r.rounding=i,e.times(2))};z.inverseHyperbolicCosine=z.acosh=function(){var e,r,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(e=n.precision,r=n.rounding,n.precision=e+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,j=!1,t=t.times(t).minus(1).sqrt().plus(t),j=!0,n.precision=e,n.rounding=r,t.ln()):new n(t)};z.inverseHyperbolicSine=z.asinh=function(){var e,r,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,j=!1,t=t.times(t).plus(1).sqrt().plus(t),j=!0,n.precision=e,n.rounding=r,t.ln())};z.inverseHyperbolicTangent=z.atanh=function(){var e,r,t,n,i=this,u=i.constructor;return i.isFinite()?i.e>=0?new u(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=u.precision,r=u.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?X(new u(i),e,r,!0):(u.precision=t=n-i.e,i=he(i.plus(1),new u(1).minus(i),t+e,1),u.precision=e+4,u.rounding=1,i=i.ln(),u.precision=e,u.rounding=r,i.times(.5))):new u(NaN)};z.inverseSine=z.asin=function(){var e,r,t,n,i=this,u=i.constructor;return i.isZero()?new u(i):(r=i.abs().cmp(1),t=u.precision,n=u.rounding,r!==-1?r===0?(e=nr(u,t+4,n).times(.5),e.s=i.s,e):new u(NaN):(u.precision=t+6,u.rounding=1,i=i.div(new u(1).minus(i.times(i)).sqrt().plus(1)).atan(),u.precision=t,u.rounding=n,i.times(2)))};z.inverseTangent=z.atan=function(){var e,r,t,n,i,u,o,a,c,l=this,f=l.constructor,h=f.precision,D=f.rounding;if(l.isFinite()){if(l.isZero())return new f(l);if(l.abs().eq(1)&&h+4<=Jt)return o=nr(f,h+4,D).times(.25),o.s=l.s,o}else{if(!l.s)return new f(NaN);if(h+4<=Jt)return o=nr(f,h+4,D).times(.5),o.s=l.s,o}for(f.precision=a=h+10,f.rounding=1,t=Math.min(28,a/K+2|0),e=t;e;--e)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(j=!1,r=Math.ceil(a/K),n=1,c=l.times(l),o=new f(l),i=l;e!==-1;)if(i=i.times(c),u=o.minus(i.div(n+=2)),i=i.times(c),o=u.plus(i.div(n+=2)),o.d[r]!==void 0)for(e=r;o.d[e]===u.d[e]&&e--;);return t&&(o=o.times(2<<t-1)),j=!0,X(o,f.precision=h,f.rounding=D,!0)};z.isFinite=function(){return!!this.d};z.isInteger=z.isInt=function(){return!!this.d&&$e(this.e/K)>this.d.length-2};z.isNaN=function(){return!this.s};z.isNegative=z.isNeg=function(){return this.s<0};z.isPositive=z.isPos=function(){return this.s>0};z.isZero=function(){return!!this.d&&this.d[0]===0};z.lessThan=z.lt=function(e){return this.cmp(e)<0};z.lessThanOrEqualTo=z.lte=function(e){return this.cmp(e)<1};z.logarithm=z.log=function(e){var r,t,n,i,u,o,a,c,l=this,f=l.constructor,h=f.precision,D=f.rounding,p=5;if(e==null)e=new f(10),r=!0;else{if(e=new f(e),t=e.d,e.s<0||!t||!t[0]||e.eq(1))return new f(NaN);r=e.eq(10)}if(t=l.d,l.s<0||!t||!t[0]||l.eq(1))return new f(t&&!t[0]?-1/0:l.s!=1?NaN:t?0:1/0);if(r)if(t.length>1)u=!0;else{for(i=t[0];i%10===0;)i/=10;u=i!==1}if(j=!1,a=h+p,o=Dr(l,a),n=r?Dt(f,a+10):Dr(e,a),c=he(o,n,a,1),Hr(c.d,i=h,D))do if(a+=10,o=Dr(l,a),n=r?Dt(f,a+10):Dr(e,a),c=he(o,n,a,1),!u){+Ie(c.d).slice(i+1,i+15)+1==1e14&&(c=X(c,h+1,0));break}while(Hr(c.d,i+=10,D));return j=!0,X(c,h,D)};z.minus=z.sub=function(e){var r,t,n,i,u,o,a,c,l,f,h,D,p=this,m=p.constructor;if(e=new m(e),!p.d||!e.d)return!p.s||!e.s?e=new m(NaN):p.d?e.s=-e.s:e=new m(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(l=p.d,D=e.d,a=m.precision,c=m.rounding,!l[0]||!D[0]){if(D[0])e.s=-e.s;else if(l[0])e=new m(p);else return new m(c===3?-0:0);return j?X(e,a,c):e}if(t=$e(e.e/K),f=$e(p.e/K),l=l.slice(),u=f-t,u){for(h=u<0,h?(r=l,u=-u,o=D.length):(r=D,t=f,o=l.length),n=Math.max(Math.ceil(a/K),o)+2,u>n&&(u=n,r.length=1),r.reverse(),n=u;n--;)r.push(0);r.reverse()}else{for(n=l.length,o=D.length,h=n<o,h&&(o=n),n=0;n<o;n++)if(l[n]!=D[n]){h=l[n]<D[n];break}u=0}for(h&&(r=l,l=D,D=r,e.s=-e.s),o=l.length,n=D.length-o;n>0;--n)l[o++]=0;for(n=D.length;n>u;){if(l[--n]<D[n]){for(i=n;i&&l[--i]===0;)l[i]=rr-1;--l[i],l[n]+=rr}l[n]-=D[n]}for(;l[--o]===0;)l.pop();for(;l[0]===0;l.shift())--t;return l[0]?(e.d=l,e.e=Nt(l,t),j?X(e,a,c):e):new m(c===3?-0:0)};z.modulo=z.mod=function(e){var r,t=this,n=t.constructor;return e=new n(e),!t.d||!e.s||e.d&&!e.d[0]?new n(NaN):!e.d||t.d&&!t.d[0]?X(new n(t),n.precision,n.rounding):(j=!1,n.modulo==9?(r=he(t,e.abs(),0,3,1),r.s*=e.s):r=he(t,e,0,n.modulo,1),r=r.times(e),j=!0,t.minus(r))};z.naturalExponential=z.exp=function(){return Yt(this)};z.naturalLogarithm=z.ln=function(){return Dr(this)};z.negated=z.neg=function(){var e=new this.constructor(this);return e.s=-e.s,X(e)};z.plus=z.add=function(e){var r,t,n,i,u,o,a,c,l,f,h=this,D=h.constructor;if(e=new D(e),!h.d||!e.d)return!h.s||!e.s?e=new D(NaN):h.d||(e=new D(e.d||h.s===e.s?h:NaN)),e;if(h.s!=e.s)return e.s=-e.s,h.minus(e);if(l=h.d,f=e.d,a=D.precision,c=D.rounding,!l[0]||!f[0])return f[0]||(e=new D(h)),j?X(e,a,c):e;if(u=$e(h.e/K),n=$e(e.e/K),l=l.slice(),i=u-n,i){for(i<0?(t=l,i=-i,o=f.length):(t=f,n=u,o=l.length),u=Math.ceil(a/K),o=u>o?u+1:o+1,i>o&&(i=o,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for(o=l.length,i=f.length,o-i<0&&(i=o,t=f,f=l,l=t),r=0;i;)r=(l[--i]=l[i]+f[i]+r)/rr|0,l[i]%=rr;for(r&&(l.unshift(r),++n),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=Nt(l,n),j?X(e,a,c):e};z.precision=z.sd=function(e){var r,t=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(dr+e);return t.d?(r=vi(t.d),e&&t.e+1>r&&(r=t.e+1)):r=NaN,r};z.round=function(){var e=this,r=e.constructor;return X(new r(e),e.e+1,r.rounding)};z.sine=z.sin=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+Math.max(t.e,t.sd())+K,n.rounding=1,t=qo(n,Ei(n,t)),n.precision=e,n.rounding=r,X(cr>2?t.neg():t,e,r,!0)):new n(NaN)};z.squareRoot=z.sqrt=function(){var e,r,t,n,i,u,o=this,a=o.d,c=o.e,l=o.s,f=o.constructor;if(l!==1||!a||!a[0])return new f(!l||l<0&&(!a||a[0])?NaN:a?o:1/0);for(j=!1,l=Math.sqrt(+o),l==0||l==1/0?(r=Ie(a),(r.length+c)%2==0&&(r+="0"),l=Math.sqrt(r),c=$e((c+1)/2)-(c<0||c%2),l==1/0?r="5e"+c:(r=l.toExponential(),r=r.slice(0,r.indexOf("e")+1)+c),n=new f(r)):n=new f(l.toString()),t=(c=f.precision)+3;;)if(u=n,n=u.plus(he(o,u,t+2,1)).times(.5),Ie(u.d).slice(0,t)===(r=Ie(n.d)).slice(0,t))if(r=r.slice(t-3,t+1),r=="9999"||!i&&r=="4999"){if(!i&&(X(u,c+1,0),u.times(u).eq(o))){n=u;break}t+=4,i=1}else{(!+r||!+r.slice(1)&&r.charAt(0)=="5")&&(X(n,c+1,1),e=!n.times(n).eq(o));break}return j=!0,X(n,c,f.rounding,e)};z.tangent=z.tan=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+10,n.rounding=1,t=t.sin(),t.s=1,t=he(t,new n(1).minus(t.times(t)).sqrt(),e+10,0),n.precision=e,n.rounding=r,X(cr==2||cr==4?t.neg():t,e,r,!0)):new n(NaN)};z.times=z.mul=function(e){var r,t,n,i,u,o,a,c,l,f=this,h=f.constructor,D=f.d,p=(e=new h(e)).d;if(e.s*=f.s,!D||!D[0]||!p||!p[0])return new h(!e.s||D&&!D[0]&&!p||p&&!p[0]&&!D?NaN:!D||!p?e.s/0:e.s*0);for(t=$e(f.e/K)+$e(e.e/K),c=D.length,l=p.length,c<l&&(u=D,D=p,p=u,o=c,c=l,l=o),u=[],o=c+l,n=o;n--;)u.push(0);for(n=l;--n>=0;){for(r=0,i=c+n;i>n;)a=u[i]+p[n]*D[i-n-1]+r,u[i--]=a%rr|0,r=a/rr|0;u[i]=(u[i]+r)%rr|0}for(;!u[--o];)u.pop();return r?++t:u.shift(),e.d=u,e.e=Nt(u,t),j?X(e,h.precision,h.rounding):e};z.toBinary=function(e,r){return tn(this,2,e,r)};z.toDecimalPlaces=z.toDP=function(e,r){var t=this,n=t.constructor;return t=new n(t),e===void 0?t:(We(e,0,vr),r===void 0?r=n.rounding:We(r,0,8),X(t,e+t.e+1,r))};z.toExponential=function(e,r){var t,n=this,i=n.constructor;return e===void 0?t=ur(n,!0):(We(e,0,vr),r===void 0?r=i.rounding:We(r,0,8),n=X(new i(n),e+1,r),t=ur(n,!0,e+1)),n.isNeg()&&!n.isZero()?"-"+t:t};z.toFixed=function(e,r){var t,n,i=this,u=i.constructor;return e===void 0?t=ur(i):(We(e,0,vr),r===void 0?r=u.rounding:We(r,0,8),n=X(new u(i),e+i.e+1,r),t=ur(n,!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t};z.toFraction=function(e){var r,t,n,i,u,o,a,c,l,f,h,D,p=this,m=p.d,s=p.constructor;if(!m)return new s(p);if(l=t=new s(1),n=c=new s(0),r=new s(n),u=r.e=vi(m)-p.e-1,o=u%K,r.d[0]=Ne(10,o<0?K+o:o),e==null)e=u>0?r:l;else{if(a=new s(e),!a.isInt()||a.lt(l))throw Error(dr+a);e=a.gt(r)?u>0?r:l:a}for(j=!1,a=new s(Ie(m)),f=s.precision,s.precision=u=m.length*K*2;h=he(a,r,0,1,1),i=t.plus(h.times(n)),i.cmp(e)!=1;)t=n,n=i,i=l,l=c.plus(h.times(i)),c=i,i=r,r=a.minus(h.times(i)),a=i;return i=he(e.minus(t),n,0,1,1),c=c.plus(i.times(l)),t=t.plus(i.times(n)),c.s=l.s=p.s,D=he(l,n,u,1).minus(p).abs().cmp(he(c,t,u,1).minus(p).abs())<1?[l,n]:[c,t],s.precision=f,j=!0,D};z.toHexadecimal=z.toHex=function(e,r){return tn(this,16,e,r)};z.toNearest=function(e,r){var t=this,n=t.constructor;if(t=new n(t),e==null){if(!t.d)return t;e=new n(1),r=n.rounding}else{if(e=new n(e),r===void 0?r=n.rounding:We(r,0,8),!t.d)return e.s?t:e;if(!e.d)return e.s&&(e.s=t.s),e}return e.d[0]?(j=!1,t=he(t,e,0,r,1).times(e),j=!0,X(t)):(e.s=t.s,t=e),t};z.toNumber=function(){return+this};z.toOctal=function(e,r){return tn(this,8,e,r)};z.toPower=z.pow=function(e){var r,t,n,i,u,o,a=this,c=a.constructor,l=+(e=new c(e));if(!a.d||!e.d||!a.d[0]||!e.d[0])return new c(Ne(+a,l));if(a=new c(a),a.eq(1))return a;if(n=c.precision,u=c.rounding,e.eq(1))return X(a,n,u);if(r=$e(e.e/K),r>=e.d.length-1&&(t=l<0?-l:l)<=Oo)return i=wi(c,a,t,n),e.s<0?new c(1).div(i):X(i,n,u);if(o=a.s,o<0){if(r<e.d.length-1)return new c(NaN);if((e.d[r]&1)==0&&(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return t=Ne(+a,l),r=t==0||!isFinite(t)?$e(l*(Math.log("0."+Ie(a.d))/Math.LN10+a.e+1)):new c(t+"").e,r>c.maxE+1||r<c.minE-1?new c(r>0?o/0:0):(j=!1,c.rounding=a.s=1,t=Math.min(12,(r+"").length),i=Yt(e.times(Dr(a,n+t)),n),i.d&&(i=X(i,n+5,1),Hr(i.d,n,u)&&(r=n+10,i=X(Yt(e.times(Dr(a,r+t)),r),r+5,1),+Ie(i.d).slice(n+1,n+15)+1==1e14&&(i=X(i,n+1,0)))),i.s=o,j=!0,c.rounding=u,X(i,n,u))};z.toPrecision=function(e,r){var t,n=this,i=n.constructor;return e===void 0?t=ur(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(We(e,1,vr),r===void 0?r=i.rounding:We(r,0,8),n=X(new i(n),e,r),t=ur(n,e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+t:t};z.toSignificantDigits=z.toSD=function(e,r){var t=this,n=t.constructor;return e===void 0?(e=n.precision,r=n.rounding):(We(e,1,vr),r===void 0?r=n.rounding:We(r,0,8)),X(new n(t),e,r)};z.toString=function(){var e=this,r=e.constructor,t=ur(e,e.e<=r.toExpNeg||e.e>=r.toExpPos);return e.isNeg()&&!e.isZero()?"-"+t:t};z.truncated=z.trunc=function(){return X(new this.constructor(this),this.e+1,1)};z.valueOf=z.toJSON=function(){var e=this,r=e.constructor,t=ur(e,e.e<=r.toExpNeg||e.e>=r.toExpPos);return e.isNeg()?"-"+t:t};function Ie(e){var r,t,n,i=e.length-1,u="",o=e[0];if(i>0){for(u+=o,r=1;r<i;r++)n=e[r]+"",t=K-n.length,t&&(u+=pr(t)),u+=n;o=e[r],n=o+"",t=K-n.length,t&&(u+=pr(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return u+o}function We(e,r,t){if(e!==~~e||e<r||e>t)throw Error(dr+e)}function Hr(e,r,t,n){var i,u,o,a;for(u=e[0];u>=10;u/=10)--r;return--r<0?(r+=K,i=0):(i=Math.ceil((r+1)/K),r%=K),u=Ne(10,K-r),a=e[i]%u|0,n==null?r<3?(r==0?a=a/100|0:r==1&&(a=a/10|0),o=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):o=(t<4&&a+1==u||t>3&&a+1==u/2)&&(e[i+1]/u/100|0)==Ne(10,r-2)-1||(a==u/2||a==0)&&(e[i+1]/u/100|0)==0:r<4?(r==0?a=a/1e3|0:r==1?a=a/100|0:r==2&&(a=a/10|0),o=(n||t<4)&&a==9999||!n&&t>3&&a==4999):o=((n||t<4)&&a+1==u||!n&&t>3&&a+1==u/2)&&(e[i+1]/u/1e3|0)==Ne(10,r-3)-1,o}function tt(e,r,t){for(var n,i=[0],u,o=0,a=e.length;o<a;){for(u=i.length;u--;)i[u]*=r;for(i[0]+=Vt.indexOf(e.charAt(o++)),n=0;n<i.length;n++)i[n]>t-1&&(i[n+1]===void 0&&(i[n+1]=0),i[n+1]+=i[n]/t|0,i[n]%=t)}return i.reverse()}function Po(e,r){var t,n,i;if(r.isZero())return r;n=r.d.length,n<32?(t=Math.ceil(n/3),i=(1/Mt(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),e.precision+=t,r=Ir(e,1,r.times(i),new e(1));for(var u=t;u--;){var o=r.times(r);r=o.times(o).minus(o).times(8).plus(1)}return e.precision-=t,r}var he=function(){function e(n,i,u){var o,a=0,c=n.length;for(n=n.slice();c--;)o=n[c]*i+a,n[c]=o%u|0,a=o/u|0;return a&&n.unshift(a),n}function r(n,i,u,o){var a,c;if(u!=o)c=u>o?1:-1;else for(a=c=0;a<u;a++)if(n[a]!=i[a]){c=n[a]>i[a]?1:-1;break}return c}function t(n,i,u,o){for(var a=0;u--;)n[u]-=a,a=n[u]<i[u]?1:0,n[u]=a*o+n[u]-i[u];for(;!n[0]&&n.length>1;)n.shift()}return function(n,i,u,o,a,c){var l,f,h,D,p,m,s,d,g,E,v,A,y,w,C,b,B,M,S,R,V=n.constructor,q=n.s==i.s?1:-1,W=n.d,O=i.d;if(!W||!W[0]||!O||!O[0])return new V(!n.s||!i.s||(W?O&&W[0]==O[0]:!O)?NaN:W&&W[0]==0||!O?q*0:q/0);for(c?(p=1,f=n.e-i.e):(c=rr,p=K,f=$e(n.e/p)-$e(i.e/p)),S=O.length,B=W.length,g=new V(q),E=g.d=[],h=0;O[h]==(W[h]||0);h++);if(O[h]>(W[h]||0)&&f--,u==null?(w=u=V.precision,o=V.rounding):a?w=u+(n.e-i.e)+1:w=u,w<0)E.push(1),m=!0;else{if(w=w/p+2|0,h=0,S==1){for(D=0,O=O[0],w++;(h<B||D)&&w--;h++)C=D*c+(W[h]||0),E[h]=C/O|0,D=C%O|0;m=D||h<B}else{for(D=c/(O[0]+1)|0,D>1&&(O=e(O,D,c),W=e(W,D,c),S=O.length,B=W.length),b=S,v=W.slice(0,S),A=v.length;A<S;)v[A++]=0;R=O.slice(),R.unshift(0),M=O[0],O[1]>=c/2&&++M;do D=0,l=r(O,v,S,A),l<0?(y=v[0],S!=A&&(y=y*c+(v[1]||0)),D=y/M|0,D>1?(D>=c&&(D=c-1),s=e(O,D,c),d=s.length,A=v.length,l=r(s,v,d,A),l==1&&(D--,t(s,S<d?R:O,d,c))):(D==0&&(l=D=1),s=O.slice()),d=s.length,d<A&&s.unshift(0),t(v,s,A,c),l==-1&&(A=v.length,l=r(O,v,S,A),l<1&&(D++,t(v,S<A?R:O,A,c))),A=v.length):l===0&&(D++,v=[0]),E[h++]=D,l&&v[0]?v[A++]=W[b]||0:(v=[W[b]],A=1);while((b++<B||v[0]!==void 0)&&w--);m=v[0]!==void 0}E[0]||E.shift()}if(p==1)g.e=f,pi=m;else{for(h=1,D=E[0];D>=10;D/=10)h++;g.e=h+f*p-1,X(g,a?u+g.e+1:u,o,m)}return g}}();function X(e,r,t,n){var i,u,o,a,c,l,f,h,D,p=e.constructor;e:if(r!=null){if(h=e.d,!h)return e;for(i=1,a=h[0];a>=10;a/=10)i++;if(u=r-i,u<0)u+=K,o=r,f=h[D=0],c=f/Ne(10,i-o-1)%10|0;else if(D=Math.ceil((u+1)/K),a=h.length,D>=a)if(n){for(;a++<=D;)h.push(0);f=c=0,i=1,u%=K,o=u-K+1}else break e;else{for(f=a=h[D],i=1;a>=10;a/=10)i++;u%=K,o=u-K+i,c=o<0?0:f/Ne(10,i-o-1)%10|0}if(n=n||r<0||h[D+1]!==void 0||(o<0?f:f%Ne(10,i-o-1)),l=t<4?(c||n)&&(t==0||t==(e.s<0?3:2)):c>5||c==5&&(t==4||n||t==6&&(u>0?o>0?f/Ne(10,i-o):0:h[D-1])%10&1||t==(e.s<0?8:7)),r<1||!h[0])return h.length=0,l?(r-=e.e+1,h[0]=Ne(10,(K-r%K)%K),e.e=-r||0):h[0]=e.e=0,e;if(u==0?(h.length=D,a=1,D--):(h.length=D+1,a=Ne(10,K-u),h[D]=o>0?(f/Ne(10,i-o)%Ne(10,o)|0)*a:0),l)for(;;)if(D==0){for(u=1,o=h[0];o>=10;o/=10)u++;for(o=h[0]+=a,a=1;o>=10;o/=10)a++;u!=a&&(e.e++,h[0]==rr&&(h[0]=1));break}else{if(h[D]+=a,h[D]!=rr)break;h[D--]=0,a=1}for(u=h.length;h[--u]===0;)h.pop()}return j&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function ur(e,r,t){if(!e.isFinite())return Fi(e);var n,i=e.e,u=Ie(e.d),o=u.length;return r?(t&&(n=t-o)>0?u=u.charAt(0)+"."+u.slice(1)+pr(n):o>1&&(u=u.charAt(0)+"."+u.slice(1)),u=u+(e.e<0?"e":"e+")+e.e):i<0?(u="0."+pr(-i-1)+u,t&&(n=t-o)>0&&(u+=pr(n))):i>=o?(u+=pr(i+1-o),t&&(n=t-i-1)>0&&(u=u+"."+pr(n))):((n=i+1)<o&&(u=u.slice(0,n)+"."+u.slice(n)),t&&(n=t-o)>0&&(i+1===o&&(u+="."),u+=pr(n))),u}function Nt(e,r){var t=e[0];for(r*=K;t>=10;t/=10)r++;return r}function Dt(e,r,t){if(r>$o)throw j=!0,t&&(e.precision=t),Error(Di);return X(new e(ht),r,1,!0)}function nr(e,r,t){if(r>Jt)throw Error(Di);return X(new e(pt),r,t,!0)}function vi(e){var r=e.length-1,t=r*K+1;if(r=e[r],r){for(;r%10==0;r/=10)t--;for(r=e[0];r>=10;r/=10)t++}return t}function pr(e){for(var r="";e--;)r+="0";return r}function wi(e,r,t,n){var i,u=new e(1),o=Math.ceil(n/K+4);for(j=!1;;){if(t%2&&(u=u.times(r),mn(u.d,o)&&(i=!0)),t=$e(t/2),t===0){t=u.d.length-1,i&&u.d[t]===0&&++u.d[t];break}r=r.times(r),mn(r.d,o)}return j=!0,u}function Dn(e){return e.d[e.d.length-1]&1}function yi(e,r,t){for(var n,i,u=new e(r[0]),o=0;++o<r.length;){if(i=new e(r[o]),!i.s){u=i;break}n=u.cmp(i),(n===t||n===0&&u.s===t)&&(u=i)}return u}function Yt(e,r){var t,n,i,u,o,a,c,l=0,f=0,h=0,D=e.constructor,p=D.rounding,m=D.precision;if(!e.d||!e.d[0]||e.e>17)return new D(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(r==null?(j=!1,c=m):c=r,a=new D(.03125);e.e>-2;)e=e.times(a),h+=5;for(n=Math.log(Ne(2,h))/Math.LN10*2+5|0,c+=n,t=u=o=new D(1),D.precision=c;;){if(u=X(u.times(e),c,1),t=t.times(++f),a=o.plus(he(u,t,c,1)),Ie(a.d).slice(0,c)===Ie(o.d).slice(0,c)){for(i=h;i--;)o=X(o.times(o),c,1);if(r==null)if(l<3&&Hr(o.d,c-n,p,l))D.precision=c+=10,t=u=a=new D(1),f=0,l++;else return X(o,D.precision=m,p,j=!0);else return D.precision=m,o}o=a}}function Dr(e,r){var t,n,i,u,o,a,c,l,f,h,D,p=1,m=10,s=e,d=s.d,g=s.constructor,E=g.rounding,v=g.precision;if(s.s<0||!d||!d[0]||!s.e&&d[0]==1&&d.length==1)return new g(d&&!d[0]?-1/0:s.s!=1?NaN:d?0:s);if(r==null?(j=!1,f=v):f=r,g.precision=f+=m,t=Ie(d),n=t.charAt(0),Math.abs(u=s.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)s=s.times(e),t=Ie(s.d),n=t.charAt(0),p++;u=s.e,n>1?(s=new g("0."+t),u++):s=new g(n+"."+t.slice(1))}else return l=Dt(g,f+2,v).times(u+""),s=Dr(new g(n+"."+t.slice(1)),f-m).plus(l),g.precision=v,r==null?X(s,v,E,j=!0):s;for(h=s,c=o=s=he(s.minus(1),s.plus(1),f,1),D=X(s.times(s),f,1),i=3;;){if(o=X(o.times(D),f,1),l=c.plus(he(o,new g(i),f,1)),Ie(l.d).slice(0,f)===Ie(c.d).slice(0,f))if(c=c.times(2),u!==0&&(c=c.plus(Dt(g,f+2,v).times(u+""))),c=he(c,new g(p),f,1),r==null)if(Hr(c.d,f-m,E,a))g.precision=f+=m,l=o=s=he(h.minus(1),h.plus(1),f,1),D=X(s.times(s),f,1),i=a=1;else return X(c,g.precision=v,E,j=!0);else return g.precision=v,c;c=l,i+=2}}function Fi(e){return String(e.s*e.s/0)}function nt(e,r){var t,n,i;for((t=r.indexOf("."))>-1&&(r=r.replace(".","")),(n=r.search(/e/i))>0?(t<0&&(t=n),t+=+r.slice(n+1),r=r.substring(0,n)):t<0&&(t=r.length),n=0;r.charCodeAt(n)===48;n++);for(i=r.length;r.charCodeAt(i-1)===48;--i);if(r=r.slice(n,i),r){if(i-=n,e.e=t=t-n-1,e.d=[],n=(t+1)%K,t<0&&(n+=K),n<i){for(n&&e.d.push(+r.slice(0,n)),i-=K;n<i;)e.d.push(+r.slice(n,n+=K));r=r.slice(n),n=K-r.length}else n-=i;for(;n--;)r+="0";e.d.push(+r),j&&(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 Uo(e,r){var t,n,i,u,o,a,c,l,f;if(r.indexOf("_")>-1){if(r=r.replace(/(\d)_(?=\d)/g,"$1"),gi.test(r))return nt(e,r)}else if(r==="Infinity"||r==="NaN")return+r||(e.s=NaN),e.e=NaN,e.d=null,e;if(Io.test(r))t=16,r=r.toLowerCase();else if(To.test(r))t=2;else if(zo.test(r))t=8;else throw Error(dr+r);for(u=r.search(/p/i),u>0?(c=+r.slice(u+1),r=r.substring(2,u)):r=r.slice(2),u=r.indexOf("."),o=u>=0,n=e.constructor,o&&(r=r.replace(".",""),a=r.length,u=a-u,i=wi(n,new n(t),u,u*2)),l=tt(r,t,rr),f=l.length-1,u=f;l[u]===0;--u)l.pop();return u<0?new n(e.s*0):(e.e=Nt(l,f),e.d=l,j=!1,o&&(e=he(e,i,a*4)),c&&(e=e.times(Math.abs(c)<54?Ne(2,c):zr.pow(2,c))),j=!0,e)}function qo(e,r){var t,n=r.d.length;if(n<3)return r.isZero()?r:Ir(e,2,r,r);t=1.4*Math.sqrt(n),t=t>16?16:t|0,r=r.times(1/Mt(5,t)),r=Ir(e,2,r,r);for(var i,u=new e(5),o=new e(16),a=new e(20);t--;)i=r.times(r),r=r.times(u.plus(i.times(o.times(i).minus(a))));return r}function Ir(e,r,t,n,i){var u,o,a,c,l=e.precision,f=Math.ceil(l/K);for(j=!1,c=t.times(t),a=new e(n);;){if(o=he(a.times(c),new e(r++*r++),l,1),a=i?n.plus(o):n.minus(o),n=he(o.times(c),new e(r++*r++),l,1),o=a.plus(n),o.d[f]!==void 0){for(u=f;o.d[u]===a.d[u]&&u--;);if(u==-1)break}u=a,a=n,n=o,o=u}return j=!0,o.d.length=f+1,o}function Mt(e,r){for(var t=e;--r;)t*=e;return t}function Ei(e,r){var t,n=r.s<0,i=nr(e,e.precision,1),u=i.times(.5);if(r=r.abs(),r.lte(u))return cr=n?4:1,r;if(t=r.divToInt(i),t.isZero())cr=n?3:2;else{if(r=r.minus(t.times(i)),r.lte(u))return cr=Dn(t)?n?2:3:n?4:1,r;cr=Dn(t)?n?1:4:n?3:2}return r.minus(i).abs()}function tn(e,r,t,n){var i,u,o,a,c,l,f,h,D,p=e.constructor,m=t!==void 0;if(m?(We(t,1,vr),n===void 0?n=p.rounding:We(n,0,8)):(t=p.precision,n=p.rounding),!e.isFinite())f=Fi(e);else{for(f=ur(e),o=f.indexOf("."),m?(i=2,r==16?t=t*4-3:r==8&&(t=t*3-2)):i=r,o>=0&&(f=f.replace(".",""),D=new p(1),D.e=f.length-o,D.d=tt(ur(D),10,i),D.e=D.d.length),h=tt(f,10,i),u=c=h.length;h[--c]==0;)h.pop();if(!h[0])f=m?"0p+0":"0";else{if(o<0?u--:(e=new p(e),e.d=h,e.e=u,e=he(e,D,t,n,0,i),h=e.d,u=e.e,l=pi),o=h[t],a=i/2,l=l||h[t+1]!==void 0,l=n<4?(o!==void 0||l)&&(n===0||n===(e.s<0?3:2)):o>a||o===a&&(n===4||l||n===6&&h[t-1]&1||n===(e.s<0?8:7)),h.length=t,l)for(;++h[--t]>i-1;)h[t]=0,t||(++u,h.unshift(1));for(c=h.length;!h[c-1];--c);for(o=0,f="";o<c;o++)f+=Vt.charAt(h[o]);if(m){if(c>1)if(r==16||r==8){for(o=r==16?4:3,--c;c%o;c++)f+="0";for(h=tt(f,i,r),c=h.length;!h[c-1];--c);for(o=1,f="1.";o<c;o++)f+=Vt.charAt(h[o])}else f=f.charAt(0)+"."+f.slice(1);f=f+(u<0?"p":"p+")+u}else if(u<0){for(;++u;)f="0"+f;f="0."+f}else if(++u>c)for(u-=c;u--;)f+="0";else u<c&&(f=f.slice(0,u)+"."+f.slice(u))}f=(r==16?"0x":r==2?"0b":r==8?"0o":"")+f}return e.s<0?"-"+f:f}function mn(e,r){if(e.length>r)return e.length=r,!0}function Ro(e){return new this(e).abs()}function Lo(e){return new this(e).acos()}function Ho(e){return new this(e).acosh()}function Zo(e,r){return new this(e).plus(r)}function Wo(e){return new this(e).asin()}function Vo(e){return new this(e).asinh()}function Go(e){return new this(e).atan()}function Jo(e){return new this(e).atanh()}function Yo(e,r){e=new this(e),r=new this(r);var t,n=this.precision,i=this.rounding,u=n+4;return!e.s||!r.s?t=new this(NaN):!e.d&&!r.d?(t=nr(this,u,1).times(r.s>0?.25:.75),t.s=e.s):!r.d||e.isZero()?(t=r.s<0?nr(this,n,i):new this(0),t.s=e.s):!e.d||r.isZero()?(t=nr(this,u,1).times(.5),t.s=e.s):r.s<0?(this.precision=u,this.rounding=1,t=this.atan(he(e,r,u,1)),r=nr(this,u,1),this.precision=n,this.rounding=i,t=e.s<0?t.minus(r):t.plus(r)):t=this.atan(he(e,r,u,1)),t}function ko(e){return new this(e).cbrt()}function Xo(e){return X(e=new this(e),e.e+1,2)}function Qo(e,r,t){return new this(e).clamp(r,t)}function Ko(e){if(!e||typeof e!="object")throw Error(Bt+"Object expected");var r,t,n,i=e.defaults===!0,u=["precision",1,vr,"rounding",0,8,"toExpNeg",-xr,0,"toExpPos",0,xr,"maxE",0,xr,"minE",-xr,0,"modulo",0,9];for(r=0;r<u.length;r+=3)if(t=u[r],i&&(this[t]=Gt[t]),(n=e[t])!==void 0)if($e(n)===n&&n>=u[r+1]&&n<=u[r+2])this[t]=n;else throw Error(dr+t+": "+n);if(t="crypto",i&&(this[t]=Gt[t]),(n=e[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(mi);else this[t]=!1;else throw Error(dr+t+": "+n);return this}function jo(e){return new this(e).cos()}function ea(e){return new this(e).cosh()}function Ai(e){var r,t,n;function i(u){var o,a,c,l=this;if(!(l instanceof i))return new i(u);if(l.constructor=i,dn(u)){l.s=u.s,j?!u.d||u.e>i.maxE?(l.e=NaN,l.d=null):u.e<i.minE?(l.e=0,l.d=[0]):(l.e=u.e,l.d=u.d.slice()):(l.e=u.e,l.d=u.d?u.d.slice():u.d);return}if(c=typeof u,c==="number"){if(u===0){l.s=1/u<0?-1:1,l.e=0,l.d=[0];return}if(u<0?(u=-u,l.s=-1):l.s=1,u===~~u&&u<1e7){for(o=0,a=u;a>=10;a/=10)o++;j?o>i.maxE?(l.e=NaN,l.d=null):o<i.minE?(l.e=0,l.d=[0]):(l.e=o,l.d=[u]):(l.e=o,l.d=[u]);return}if(u*0!==0){u||(l.s=NaN),l.e=NaN,l.d=null;return}return nt(l,u.toString())}if(c==="string")return(a=u.charCodeAt(0))===45?(u=u.slice(1),l.s=-1):(a===43&&(u=u.slice(1)),l.s=1),gi.test(u)?nt(l,u):Uo(l,u);if(c==="bigint")return u<0?(u=-u,l.s=-1):l.s=1,nt(l,u.toString());throw Error(dr+u)}if(i.prototype=z,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=Ko,i.clone=Ai,i.isDecimal=dn,i.abs=Ro,i.acos=Lo,i.acosh=Ho,i.add=Zo,i.asin=Wo,i.asinh=Vo,i.atan=Go,i.atanh=Jo,i.atan2=Yo,i.cbrt=ko,i.ceil=Xo,i.clamp=Qo,i.cos=jo,i.cosh=ea,i.div=ra,i.exp=ta,i.floor=na,i.hypot=ia,i.ln=ua,i.log=oa,i.log10=sa,i.log2=aa,i.max=fa,i.min=ca,i.mod=la,i.mul=ha,i.pow=pa,i.random=Da,i.round=ma,i.sign=da,i.sin=ga,i.sinh=va,i.sqrt=wa,i.sub=ya,i.sum=Fa,i.tan=Ea,i.tanh=Aa,i.trunc=ba,e===void 0&&(e={}),e&&e.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],r=0;r<n.length;)e.hasOwnProperty(t=n[r++])||(e[t]=this[t]);return i.config(e),i}function ra(e,r){return new this(e).div(r)}function ta(e){return new this(e).exp()}function na(e){return X(e=new this(e),e.e+1,3)}function ia(){var e,r,t=new this(0);for(j=!1,e=0;e<arguments.length;)if(r=new this(arguments[e++]),r.d)t.d&&(t=t.plus(r.times(r)));else{if(r.s)return j=!0,new this(1/0);t=r}return j=!0,t.sqrt()}function dn(e){return e instanceof zr||e&&e.toStringTag===di||!1}function ua(e){return new this(e).ln()}function oa(e,r){return new this(e).log(r)}function aa(e){return new this(e).log(2)}function sa(e){return new this(e).log(10)}function fa(){return yi(this,arguments,-1)}function ca(){return yi(this,arguments,1)}function la(e,r){return new this(e).mod(r)}function ha(e,r){return new this(e).mul(r)}function pa(e,r){return new this(e).pow(r)}function Da(e){var r,t,n,i,u=0,o=new this(1),a=[];if(e===void 0?e=this.precision:We(e,1,vr),n=Math.ceil(e/K),this.crypto)if(crypto.getRandomValues)for(r=crypto.getRandomValues(new Uint32Array(n));u<n;)i=r[u],i>=429e7?r[u]=crypto.getRandomValues(new Uint32Array(1))[0]:a[u++]=i%1e7;else if(crypto.randomBytes){for(r=crypto.randomBytes(n*=4);u<n;)i=r[u]+(r[u+1]<<8)+(r[u+2]<<16)+((r[u+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(r,u):(a.push(i%1e7),u+=4);u=n/4}else throw Error(mi);else for(;u<n;)a[u++]=Math.random()*1e7|0;for(n=a[--u],e%=K,n&&e&&(i=Ne(10,K-e),a[u]=(n/i|0)*i);a[u]===0;u--)a.pop();if(u<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=K)a.shift();for(n=1,i=a[0];i>=10;i/=10)n++;n<K&&(t-=K-n)}return o.e=t,o.d=a,o}function ma(e){return X(e=new this(e),e.e+1,this.rounding)}function da(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function ga(e){return new this(e).sin()}function va(e){return new this(e).sinh()}function wa(e){return new this(e).sqrt()}function ya(e,r){return new this(e).sub(r)}function Fa(){var e=0,r=arguments,t=new this(r[e]);for(j=!1;t.s&&++e<r.length;)t=t.plus(r[e]);return j=!0,X(t,this.precision,this.rounding)}function Ea(e){return new this(e).tan()}function Aa(e){return new this(e).tanh()}function ba(e){return X(e=new this(e),e.e+1,1)}z[Symbol.for("nodejs.util.inspect.custom")]=z.toString;z[Symbol.toStringTag]="Decimal";var zr=z.constructor=Ai(Gt);ht=new zr(ht);pt=new zr(pt);var Ca="BigNumber",_a=["?on","config"],Ba=G(Ca,_a,e=>{var{on:r,config:t}=e,n=zr.clone({precision:t.precision,modulo:zr.EUCLID});return n.prototype=Object.create(n.prototype),n.prototype.type="BigNumber",n.prototype.isBigNumber=!0,n.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},n.fromJSON=function(i){return new n(i.value)},r&&r("config",function(i,u){i.precision!==u.precision&&n.config({precision:i.precision})}),n},{isClass:!0});const Oe=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:(Math.exp(e)+Math.exp(-e))*.5},ke=Math.sinh||function(e){return Math.abs(e)<1e-9?e:(Math.exp(e)-Math.exp(-e))*.5},Na=function(e){const r=Math.PI/4;if(-r>e||e>r)return Math.cos(e)-1;const t=e*e;return t*(t*(t*(t*(t*(t*(t*(t/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},Lt=function(e,r){return e=Math.abs(e),r=Math.abs(r),e<r&&([e,r]=[r,e]),e<1e8?Math.sqrt(e*e+r*r):(r/=e,e*Math.sqrt(1+r*r))},Nr=function(){throw SyntaxError("Invalid Param")};function Ht(e,r){const t=Math.abs(e),n=Math.abs(r);return e===0?Math.log(n):r===0?Math.log(t):t<3e3&&n<3e3?Math.log(e*e+r*r)*.5:(e=e*.5,r=r*.5,.5*Math.log(e*e+r*r)+Math.LN2)}const Ma={re:0,im:0},wr=function(e,r){const t=Ma;if(e==null)t.re=t.im=0;else if(r!==void 0)t.re=e,t.im=r;else switch(typeof e){case"object":if("im"in e&&"re"in e)t.re=e.re,t.im=e.im;else if("abs"in e&&"arg"in e){if(!isFinite(e.abs)&&isFinite(e.arg))return x.INFINITY;t.re=e.abs*Math.cos(e.arg),t.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!isFinite(e.r)&&isFinite(e.phi))return x.INFINITY;t.re=e.r*Math.cos(e.phi),t.im=e.r*Math.sin(e.phi)}else e.length===2?(t.re=e[0],t.im=e[1]):Nr();break;case"string":t.im=t.re=0;const n=e.replace(/_/g,"").match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g);let i=1,u=0;n===null&&Nr();for(let o=0;o<n.length;o++){const a=n[o];a===" "||a===" "||a===`
|
|
15
|
-
`||(a==="+"?i++:a==="-"?u++:a==="i"||a==="I"?(i+u===0&&Nr(),n[o+1]!==" "&&!isNaN(n[o+1])?(t.im+=parseFloat((u%2?"-":"")+n[o+1]),o++):t.im+=parseFloat((u%2?"-":"")+"1"),i=u=0):((i+u===0||isNaN(a))&&Nr(),n[o+1]==="i"||n[o+1]==="I"?(t.im+=parseFloat((u%2?"-":"")+a),o++):t.re+=parseFloat((u%2?"-":"")+a),i=u=0))}i+u>0&&Nr();break;case"number":t.im=0,t.re=e;break;default:Nr()}return isNaN(t.re)||isNaN(t.im),t};function x(e,r){if(!(this instanceof x))return new x(e,r);const t=wr(e,r);this.re=t.re,this.im=t.im}x.prototype={re:0,im:0,sign:function(){const e=Lt(this.re,this.im);return new x(this.re/e,this.im/e)},add:function(e,r){const t=wr(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n||i?n&&i?x.NAN:x.INFINITY:new x(this.re+t.re,this.im+t.im)},sub:function(e,r){const t=wr(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n||i?n&&i?x.NAN:x.INFINITY:new x(this.re-t.re,this.im-t.im)},mul:function(e,r){const t=wr(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im)),u=this.re===0&&this.im===0,o=t.re===0&&t.im===0;return n&&o||i&&u?x.NAN:n||i?x.INFINITY:t.im===0&&this.im===0?new x(this.re*t.re,0):new x(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)},div:function(e,r){const t=wr(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im)),u=this.re===0&&this.im===0,o=t.re===0&&t.im===0;if(u&&o||n&&i)return x.NAN;if(o||n)return x.INFINITY;if(u||i)return x.ZERO;if(t.im===0)return new x(this.re/t.re,this.im/t.re);if(Math.abs(t.re)<Math.abs(t.im)){const a=t.re/t.im,c=t.re*a+t.im;return new x((this.re*a+this.im)/c,(this.im*a-this.re)/c)}else{const a=t.im/t.re,c=t.im*a+t.re;return new x((this.re+this.im*a)/c,(this.im-this.re*a)/c)}},pow:function(e,r){const t=wr(e,r),n=this.re===0&&this.im===0;if(t.re===0&&t.im===0)return x.ONE;if(t.im===0){if(this.im===0&&this.re>0)return new x(Math.pow(this.re,t.re),0);if(this.re===0)switch((t.re%4+4)%4){case 0:return new x(Math.pow(this.im,t.re),0);case 1:return new x(0,Math.pow(this.im,t.re));case 2:return new x(-Math.pow(this.im,t.re),0);case 3:return new x(0,-Math.pow(this.im,t.re))}}if(n&&t.re>0)return x.ZERO;const u=Math.atan2(this.im,this.re),o=Ht(this.re,this.im);let a=Math.exp(t.re*o-t.im*u),c=t.im*o+t.re*u;return new x(a*Math.cos(c),a*Math.sin(c))},sqrt:function(){const e=this.re,r=this.im;if(r===0)return e>=0?new x(Math.sqrt(e),0):new x(0,Math.sqrt(-e));const t=Lt(e,r);let n=Math.sqrt(.5*(t+Math.abs(e))),i=Math.abs(r)/(2*n);return e>=0?new x(n,r<0?-i:i):new x(i,r<0?-n:n)},exp:function(){const e=Math.exp(this.re);return this.im===0?new x(e,0):new x(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){const e=this.re,r=this.im;return new x(Math.expm1(e)*Math.cos(r)+Na(r),Math.exp(e)*Math.sin(r))},log:function(){const e=this.re,r=this.im;return r===0&&e>0?new x(Math.log(e),0):new x(Ht(e,r),Math.atan2(r,e))},abs:function(){return Lt(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){const e=this.re,r=this.im;return new x(Math.sin(e)*Oe(r),Math.cos(e)*ke(r))},cos:function(){const e=this.re,r=this.im;return new x(Math.cos(e)*Oe(r),-Math.sin(e)*ke(r))},tan:function(){const e=2*this.re,r=2*this.im,t=Math.cos(e)+Oe(r);return new x(Math.sin(e)/t,ke(r)/t)},cot:function(){const e=2*this.re,r=2*this.im,t=Math.cos(e)-Oe(r);return new x(-Math.sin(e)/t,ke(r)/t)},sec:function(){const e=this.re,r=this.im,t=.5*Oe(2*r)+.5*Math.cos(2*e);return new x(Math.cos(e)*Oe(r)/t,Math.sin(e)*ke(r)/t)},csc:function(){const e=this.re,r=this.im,t=.5*Oe(2*r)-.5*Math.cos(2*e);return new x(Math.sin(e)*Oe(r)/t,-Math.cos(e)*ke(r)/t)},asin:function(){const e=this.re,r=this.im,t=new x(r*r-e*e+1,-2*e*r).sqrt(),n=new x(t.re-r,t.im+e).log();return new x(n.im,-n.re)},acos:function(){const e=this.re,r=this.im,t=new x(r*r-e*e+1,-2*e*r).sqrt(),n=new x(t.re-r,t.im+e).log();return new x(Math.PI/2-n.im,n.re)},atan:function(){const e=this.re,r=this.im;if(e===0){if(r===1)return new x(0,1/0);if(r===-1)return new x(0,-1/0)}const t=e*e+(1-r)*(1-r),n=new x((1-r*r-e*e)/t,-2*e/t).log();return new x(-.5*n.im,.5*n.re)},acot:function(){const e=this.re,r=this.im;if(r===0)return new x(Math.atan2(1,e),0);const t=e*e+r*r;return t!==0?new x(e/t,-r/t).atan():new x(e!==0?e/0:0,r!==0?-r/0:0).atan()},asec:function(){const e=this.re,r=this.im;if(e===0&&r===0)return new x(0,1/0);const t=e*e+r*r;return t!==0?new x(e/t,-r/t).acos():new x(e!==0?e/0:0,r!==0?-r/0:0).acos()},acsc:function(){const e=this.re,r=this.im;if(e===0&&r===0)return new x(Math.PI/2,1/0);const t=e*e+r*r;return t!==0?new x(e/t,-r/t).asin():new x(e!==0?e/0:0,r!==0?-r/0:0).asin()},sinh:function(){const e=this.re,r=this.im;return new x(ke(e)*Math.cos(r),Oe(e)*Math.sin(r))},cosh:function(){const e=this.re,r=this.im;return new x(Oe(e)*Math.cos(r),ke(e)*Math.sin(r))},tanh:function(){const e=2*this.re,r=2*this.im,t=Oe(e)+Math.cos(r);return new x(ke(e)/t,Math.sin(r)/t)},coth:function(){const e=2*this.re,r=2*this.im,t=Oe(e)-Math.cos(r);return new x(ke(e)/t,-Math.sin(r)/t)},csch:function(){const e=this.re,r=this.im,t=Math.cos(2*r)-Oe(2*e);return new x(-2*ke(e)*Math.cos(r)/t,2*Oe(e)*Math.sin(r)/t)},sech:function(){const e=this.re,r=this.im,t=Math.cos(2*r)+Oe(2*e);return new x(2*Oe(e)*Math.cos(r)/t,-2*ke(e)*Math.sin(r)/t)},asinh:function(){let e=this.im;this.im=-this.re,this.re=e;const r=this.asin();return this.re=-this.im,this.im=e,e=r.re,r.re=-r.im,r.im=e,r},acosh:function(){const e=this.acos();if(e.im<=0){const r=e.re;e.re=-e.im,e.im=r}else{const r=e.im;e.im=-e.re,e.re=r}return e},atanh:function(){const e=this.re,r=this.im,t=e>1&&r===0,n=1-e,i=1+e,u=n*n+r*r,o=u!==0?new x((i*n-r*r)/u,(r*n+i*r)/u):new x(e!==-1?e/0:0,r!==0?r/0:0),a=o.re;return o.re=Ht(o.re,o.im)/2,o.im=Math.atan2(o.im,a)/2,t&&(o.im=-o.im),o},acoth:function(){const e=this.re,r=this.im;if(e===0&&r===0)return new x(0,Math.PI/2);const t=e*e+r*r;return t!==0?new x(e/t,-r/t).atanh():new x(e!==0?e/0:0,r!==0?-r/0:0).atanh()},acsch:function(){const e=this.re,r=this.im;if(r===0)return new x(e!==0?Math.log(e+Math.sqrt(e*e+1)):1/0,0);const t=e*e+r*r;return t!==0?new x(e/t,-r/t).asinh():new x(e!==0?e/0:0,r!==0?-r/0:0).asinh()},asech:function(){const e=this.re,r=this.im;if(this.isZero())return x.INFINITY;const t=e*e+r*r;return t!==0?new x(e/t,-r/t).acosh():new x(e!==0?e/0:0,r!==0?-r/0:0).acosh()},inverse:function(){if(this.isZero())return x.INFINITY;if(this.isInfinite())return x.ZERO;const e=this.re,r=this.im,t=e*e+r*r;return new x(e/t,-r/t)},conjugate:function(){return new x(this.re,-this.im)},neg:function(){return new x(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new x(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new x(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new x(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,r){const t=wr(e,r);return Math.abs(t.re-this.re)<=x.EPSILON&&Math.abs(t.im-this.im)<=x.EPSILON},clone:function(){return new x(this.re,this.im)},toString:function(){let e=this.re,r=this.im,t="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<x.EPSILON&&(e=0),Math.abs(r)<x.EPSILON&&(r=0),r===0?t+e:(e!==0?(t+=e,t+=" ",r<0?(r=-r,t+="-"):t+="+",t+=" "):r<0&&(r=-r,t+="-"),r!==1&&(t+=r),t+"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()}};x.ZERO=new x(0,0);x.ONE=new x(1,0);x.I=new x(0,1);x.PI=new x(Math.PI,0);x.E=new x(Math.E,0);x.INFINITY=new x(1/0,1/0);x.NAN=new x(NaN,NaN);x.EPSILON=1e-15;var Sa="Complex",xa=[],Ta=G(Sa,xa,()=>(Object.defineProperty(x,"name",{value:"Complex"}),x.prototype.constructor=x,x.prototype.type="Complex",x.prototype.isComplex=!0,x.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},x.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},x.prototype.format=function(e){var r="",t=this.im,n=this.re,i=Wt(this.re,e),u=Wt(this.im,e),o=de(e)?e:e?e.precision:null;if(o!==null){var a=Math.pow(10,-o);Math.abs(n/t)<a&&(n=0),Math.abs(t/n)<a&&(t=0)}return t===0?r=i:n===0?t===1?r="i":t===-1?r="-i":r=u+"i":t<0?t===-1?r=i+" - i":r=i+" - "+u.substring(1)+"i":t===1?r=i+" + i":r=i+" + "+u+"i",r},x.fromPolar=function(e){switch(arguments.length){case 1:{var r=arguments[0];if(typeof r=="object")return x(r);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var t=arguments[0],n=arguments[1];if(de(t)){if(oi(n)&&n.hasBase("ANGLE")&&(n=n.toNumber("rad")),de(n))return new x({r:t,phi:n});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")}},x.prototype.valueOf=x.prototype.toString,x.fromJSON=function(e){return new x(e)},x.compare=function(e,r){return e.re>r.re?1:e.re<r.re?-1:e.im>r.im?1:e.im<r.im?-1:0},x),{isClass:!0});typeof BigInt>"u"&&(BigInt=function(e){if(isNaN(e))throw new Error("");return e});const k=BigInt(0),re=BigInt(1),Zr=BigInt(2),kt=BigInt(5),Ze=BigInt(10),Ia=2e3,L={s:re,n:k,d:re};function fr(e,r){try{e=BigInt(e)}catch{throw hr()}return e*r}function er(e){return typeof e=="bigint"?e:Math.floor(e)}function Fe(e,r){if(r===k)throw nn();const t=Object.create(Xe.prototype);t.s=e<k?-re:re,e=e<k?-e:e;const n=yr(e,r);return t.n=e/n,t.d=r/n,t}function Mr(e){const r={};let t=e,n=Zr,i=kt-re;for(;i<=t;){for(;t%n===k;)t/=n,r[n]=(r[n]||k)+re;i+=re+Zr*n++}return t!==e?t>1&&(r[t]=(r[t]||k)+re):r[e]=(r[e]||k)+re,r}const xe=function(e,r){let t=k,n=re,i=re;if(e!=null)if(r!==void 0){if(typeof e=="bigint")t=e;else{if(isNaN(e))throw hr();if(e%1!==0)throw gn();t=BigInt(e)}if(typeof r=="bigint")n=r;else{if(isNaN(r))throw hr();if(r%1!==0)throw gn();n=BigInt(r)}i=t*n}else if(typeof e=="object"){if("d"in e&&"n"in e)t=BigInt(e.n),n=BigInt(e.d),"s"in e&&(t*=BigInt(e.s));else if(0 in e)t=BigInt(e[0]),1 in e&&(n=BigInt(e[1]));else if(typeof e=="bigint")t=e;else throw hr();i=t*n}else if(typeof e=="number"){if(isNaN(e))throw hr();if(e<0&&(i=-re,e=-e),e%1===0)t=BigInt(e);else{let u=1,o=0,a=1,c=1,l=1,f=1e7;for(e>=1&&(u=10**Math.floor(1+Math.log10(e)),e/=u);a<=f&&l<=f;){let h=(o+c)/(a+l);if(e===h){a+l<=f?(t=o+c,n=a+l):l>a?(t=c,n=l):(t=o,n=a);break}else e>h?(o+=c,a+=l):(c+=o,l+=a),a>f?(t=c,n=l):(t=o,n=a)}t=BigInt(t)*BigInt(u),n=BigInt(n)}}else if(typeof e=="string"){let u=0,o=k,a=k,c=k,l=re,f=re,h=e.replace(/_/g,"").match(/\d+|./g);if(h===null)throw hr();if(h[u]==="-"?(i=-re,u++):h[u]==="+"&&u++,h.length===u+1?a=fr(h[u++],i):h[u+1]==="."||h[u]==="."?(h[u]!=="."&&(o=fr(h[u++],i)),u++,(u+1===h.length||h[u+1]==="("&&h[u+3]===")"||h[u+1]==="'"&&h[u+3]==="'")&&(a=fr(h[u],i),l=Ze**BigInt(h[u].length),u++),(h[u]==="("&&h[u+2]===")"||h[u]==="'"&&h[u+2]==="'")&&(c=fr(h[u+1],i),f=Ze**BigInt(h[u+1].length)-re,u+=3)):h[u+1]==="/"||h[u+1]===":"?(a=fr(h[u],i),l=fr(h[u+2],re),u+=3):h[u+3]==="/"&&h[u+1]===" "&&(o=fr(h[u],i),a=fr(h[u+2],i),l=fr(h[u+4],re),u+=5),h.length<=u)n=l*f,i=t=c+n*o+f*a;else throw hr()}else if(typeof e=="bigint")t=e,i=e,n=re;else throw hr();if(n===k)throw nn();L.s=i<k?-re:re,L.n=t<k?-t:t,L.d=n<k?-n:n};function za(e,r,t){let n=re;for(;r>k;e=e*e%t,r>>=re)r&re&&(n=n*e%t);return n}function Oa(e,r){for(;r%Zr===k;r/=Zr);for(;r%kt===k;r/=kt);if(r===re)return k;let t=Ze%r,n=1;for(;t!==re;n++)if(t=t*Ze%r,n>Ia)return k;return BigInt(n)}function $a(e,r,t){let n=re,i=za(Ze,t,r);for(let u=0;u<300;u++){if(n===i)return BigInt(u);n=n*Ze%r,i=i*Ze%r}return 0}function yr(e,r){if(!e)return r;if(!r)return e;for(;;){if(e%=r,!e)return r;if(r%=e,!r)return e}}function Xe(e,r){if(xe(e,r),this instanceof Xe)e=yr(L.d,L.n),this.s=L.s,this.n=L.n/e,this.d=L.d/e;else return Fe(L.s*L.n,L.d)}var nn=function(){return new Error("Division by Zero")},hr=function(){return new Error("Invalid argument")},gn=function(){return new Error("Parameters must be integer")};Xe.prototype={s:re,n:k,d:re,abs:function(){return Fe(this.n,this.d)},neg:function(){return Fe(-this.s*this.n,this.d)},add:function(e,r){return xe(e,r),Fe(this.s*this.n*L.d+L.s*this.d*L.n,this.d*L.d)},sub:function(e,r){return xe(e,r),Fe(this.s*this.n*L.d-L.s*this.d*L.n,this.d*L.d)},mul:function(e,r){return xe(e,r),Fe(this.s*L.s*this.n*L.n,this.d*L.d)},div:function(e,r){return xe(e,r),Fe(this.s*L.s*this.n*L.d,this.d*L.n)},clone:function(){return Fe(this.s*this.n,this.d)},mod:function(e,r){if(e===void 0)return Fe(this.s*this.n%this.d,re);if(xe(e,r),k===L.n*this.d)throw nn();return Fe(this.s*(L.d*this.n)%(L.n*this.d),L.d*this.d)},gcd:function(e,r){return xe(e,r),Fe(yr(L.n,this.n)*yr(L.d,this.d),L.d*this.d)},lcm:function(e,r){return xe(e,r),L.n===k&&this.n===k?Fe(k,re):Fe(L.n*this.n,yr(L.n,this.n)*yr(L.d,this.d))},inverse:function(){return Fe(this.s*this.d,this.n)},pow:function(e,r){if(xe(e,r),L.d===re)return L.s<k?Fe((this.s*this.d)**L.n,this.n**L.n):Fe((this.s*this.n)**L.n,this.d**L.n);if(this.s<k)return null;let t=Mr(this.n),n=Mr(this.d),i=re,u=re;for(let o in t)if(o!=="1"){if(o==="0"){i=k;break}if(t[o]*=L.n,t[o]%L.d===k)t[o]/=L.d;else return null;i*=BigInt(o)**t[o]}for(let o in n)if(o!=="1"){if(n[o]*=L.n,n[o]%L.d===k)n[o]/=L.d;else return null;u*=BigInt(o)**n[o]}return L.s<k?Fe(u,i):Fe(i,u)},log:function(e,r){if(xe(e,r),this.s<=k||L.s<=k)return null;const t={},n=Mr(L.n),i=Mr(L.d),u=Mr(this.n),o=Mr(this.d);for(const l in i)n[l]=(n[l]||k)-i[l];for(const l in o)u[l]=(u[l]||k)-o[l];for(const l in n)l!=="1"&&(t[l]=!0);for(const l in u)l!=="1"&&(t[l]=!0);let a=null,c=null;for(const l in t){const f=n[l]||k,h=u[l]||k;if(f===k){if(h!==k)return null;continue}let D=h,p=f;const m=yr(D,p);if(D/=m,p/=m,a===null&&c===null)a=D,c=p;else if(D*c!==a*p)return null}return a!==null&&c!==null?Fe(a,c):null},equals:function(e,r){return xe(e,r),this.s*this.n*L.d===L.s*L.n*this.d},lt:function(e,r){return xe(e,r),this.s*this.n*L.d<L.s*L.n*this.d},lte:function(e,r){return xe(e,r),this.s*this.n*L.d<=L.s*L.n*this.d},gt:function(e,r){return xe(e,r),this.s*this.n*L.d>L.s*L.n*this.d},gte:function(e,r){return xe(e,r),this.s*this.n*L.d>=L.s*L.n*this.d},compare:function(e,r){xe(e,r);let t=this.s*this.n*L.d-L.s*L.n*this.d;return(k<t)-(t<k)},ceil:function(e){return e=Ze**BigInt(e||0),Fe(er(this.s*e*this.n/this.d)+(e*this.n%this.d>k&&this.s>=k?re:k),e)},floor:function(e){return e=Ze**BigInt(e||0),Fe(er(this.s*e*this.n/this.d)-(e*this.n%this.d>k&&this.s<k?re:k),e)},round:function(e){return e=Ze**BigInt(e||0),Fe(er(this.s*e*this.n/this.d)+this.s*((this.s>=k?re:k)+Zr*(e*this.n%this.d)>this.d?re:k),e)},roundTo:function(e,r){xe(e,r);const t=this.n*L.d,n=this.d*L.n,i=t%n;let u=er(t/n);return i+i>=n&&u++,Fe(this.s*u*L.n,L.d)},divisible:function(e,r){return xe(e,r),!(!(L.n*this.d)||this.n*L.d%(L.n*this.d))},valueOf:function(){return Number(this.s*this.n)/Number(this.d)},toString:function(e){let r=this.n,t=this.d;e=e||15;let n=Oa(r,t),i=$a(r,t,n),u=this.s<k?"-":"";if(u+=er(r/t),r%=t,r*=Ze,r&&(u+="."),n){for(let o=i;o--;)u+=er(r/t),r%=t,r*=Ze;u+="(";for(let o=n;o--;)u+=er(r/t),r%=t,r*=Ze;u+=")"}else for(let o=e;r&&o--;)u+=er(r/t),r%=t,r*=Ze;return u},toFraction:function(e){let r=this.n,t=this.d,n=this.s<k?"-":"";if(t===re)n+=r;else{let i=er(r/t);e&&i>k&&(n+=i,n+=" ",r%=t),n+=r,n+="/",n+=t}return n},toLatex:function(e){let r=this.n,t=this.d,n=this.s<k?"-":"";if(t===re)n+=r;else{let i=er(r/t);e&&i>k&&(n+=i,r%=t),n+="\\frac{",n+=r,n+="}{",n+=t,n+="}"}return n},toContinued:function(){let e=this.n,r=this.d,t=[];do{t.push(er(e/r));let n=e%r;e=r,r=n}while(e!==re);return t},simplify:function(e){const r=BigInt(1/(e||.001)|0),t=this.abs(),n=t.toContinued();for(let i=1;i<n.length;i++){let u=Fe(n[i-1],re);for(let a=i-2;a>=0;a--)u=u.inverse().add(n[a]);let o=u.sub(t);if(o.n*r<o.d)return u.mul(this.s)}return this}};var Pa="Fraction",Ua=[],qa=G(Pa,Ua,()=>(Object.defineProperty(Xe,"name",{value:"Fraction"}),Xe.prototype.constructor=Xe,Xe.prototype.type="Fraction",Xe.prototype.isFraction=!0,Xe.prototype.toJSON=function(){return{mathjs:"Fraction",n:String(this.s*this.n),d:String(this.d)}},Xe.fromJSON=function(e){return new Xe(e)},Xe),{isClass:!0}),Ra="Matrix",La=[],Ha=G(Ra,La,()=>{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(r,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(r,t,n){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(r){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(r,t,n){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(r,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(r,t){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(r,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(r){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(r){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});function Zt(e,r,t){var n=e.constructor,i=new n(2),u="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!ge(t))throw new Error("size must be an integer");if(e.greaterThan(i.pow(t-1).sub(1))||e.lessThan(i.pow(t-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!e.isInteger())throw new Error("Value must be an integer");e.lessThan(0)&&(e=e.add(i.pow(t))),u="i".concat(t)}switch(r){case 2:return"".concat(e.toBinary()).concat(u);case 8:return"".concat(e.toOctal()).concat(u);case 16:return"".concat(e.toHexadecimal()).concat(u);default:throw new Error("Base ".concat(r," not supported "))}}function Za(e,r){if(typeof r=="function")return r(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var{notation:t,precision:n,wordSize:i}=fi(r);switch(t){case"fixed":return Va(e,n);case"exponential":return vn(e,n);case"engineering":return Wa(e,n);case"bin":return Zt(e,2,i);case"oct":return Zt(e,8,i);case"hex":return Zt(e,16,i);case"auto":{var u=wn(r?.lowerExp,-3),o=wn(r?.upperExp,5);if(e.isZero())return"0";var a,c=e.toSignificantDigits(n),l=c.e;return l>=u&&l<o?a=c.toFixed():a=vn(e,n),a.replace(/((\.\d*?)(0+))($|e)/,function(){var f=arguments[2],h=arguments[4];return f!=="."?f+h:h})}default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function Wa(e,r){var t=e.e,n=t%3===0?t:t<0?t-3-t%3:t-t%3,i=e.mul(Math.pow(10,-n)),u=i.toPrecision(r);if(u.includes("e")){var o=e.constructor;u=new o(u).toFixed()}return u+"e"+(t>=0?"+":"")+n.toString()}function vn(e,r){return r!==void 0?e.toExponential(r-1):e.toExponential()}function Va(e,r){return e.toFixed(r)}function wn(e,r){return de(e)?e:Ee(e)?e.toNumber():r}function Be(e,r){var t=Ga(e,r);return r&&typeof r=="object"&&"truncate"in r&&t.length>r.truncate?t.substring(0,r.truncate-3)+"...":t}function Ga(e,r){if(typeof e=="number")return Wt(e,r);if(Ee(e))return Za(e,r);if(Ja(e))return!r||r.fraction!=="decimal"?"".concat(e.s*e.n,"/").concat(e.d):e.toString();if(Array.isArray(e))return bi(e,r);if(Qe(e))return yn(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(r);if(e&&e.toString(r)!=={}.toString())return e.toString(r);var t=Object.keys(e).map(n=>yn(n)+": "+Be(e[n],r));return"{"+t.join(", ")+"}"}return String(e)}function yn(e){for(var r=String(e),t="",n=0;n<r.length;){var i=r.charAt(n);t+=i in Fn?Fn[i]:i,n++}return'"'+t+'"'}var Fn={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function bi(e,r){if(Array.isArray(e)){for(var t="[",n=e.length,i=0;i<n;i++)i!==0&&(t+=", "),t+=bi(e[i],r);return t+="]",t}else return Be(e,r)}function Ja(e){return e&&typeof e=="object"&&typeof e.s=="bigint"&&typeof e.n=="bigint"&&typeof e.d=="bigint"||!1}function ne(e,r,t){if(!(this instanceof ne))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=r,this.relation=t,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(r)?"["+r.join(", ")+"]":r)+")",this.stack=new Error().stack}ne.prototype=new RangeError;ne.prototype.constructor=RangeError;ne.prototype.name="DimensionError";ne.prototype.isDimensionError=!0;function Er(e,r,t){if(!(this instanceof Er))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=r):(this.min=r,this.max=t),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}Er.prototype=new RangeError;Er.prototype.constructor=RangeError;Er.prototype.name="IndexError";Er.prototype.isIndexError=!0;function ze(e){for(var r=[];Array.isArray(e);)r.push(e.length),e=e[0];return r}function Ci(e,r,t){var n,i=e.length;if(i!==r[t])throw new ne(i,r[t]);if(t<r.length-1){var u=t+1;for(n=0;n<i;n++){var o=e[n];if(!Array.isArray(o))throw new ne(r.length-1,r.length,"<");Ci(e[n],r,u)}}else for(n=0;n<i;n++)if(Array.isArray(e[n]))throw new ne(r.length+1,r.length,">")}function En(e,r){var t=r.length===0;if(t){if(Array.isArray(e))throw new ne(e.length,0)}else Ci(e,r,0)}function mt(e,r){var t=e.isMatrix?e._size:ze(e),n=r._sourceSize;n.forEach((i,u)=>{if(i!==null&&i!==t[u])throw new ne(i,t[u])})}function De(e,r){if(e!==void 0){if(!de(e)||!ge(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||typeof r=="number"&&e>=r)throw new Er(e,r)}}function Or(e){for(var r=0;r<e._dimensions.length;++r){var t=e._dimensions[r];if(t._data&&ye(t._data)){if(t._size[0]===0)return!0}else if(t.isRange){if(t.start===t.end)return!0}else if(Qe(t)&&t.length===0)return!0}return!1}function dt(e,r,t){if(!Array.isArray(r))throw new TypeError("Array expected");if(r.length===0)throw new Error("Resizing to scalar is not supported");r.forEach(function(i){if(!de(i)||!ge(i)||i<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Be(r)+")")}),(de(e)||Ee(e))&&(e=[e]);var n=t!==void 0?t:0;return Xt(e,r,0,n),e}function Xt(e,r,t,n){var i,u,o=e.length,a=r[t],c=Math.min(o,a);if(e.length=a,t<r.length-1){var l=t+1;for(i=0;i<c;i++)u=e[i],Array.isArray(u)||(u=[u],e[i]=u),Xt(u,r,l,n);for(i=c;i<a;i++)u=[],e[i]=u,Xt(u,r,l,n)}else{for(i=0;i<c;i++)for(;Array.isArray(e[i]);)e[i]=e[i][0];for(i=c;i<a;i++)e[i]=n}}function _i(e,r){var t=ka(e,!0),n=t.length;if(!Array.isArray(e)||!Array.isArray(r))throw new TypeError("Array expected");if(r.length===0)throw new ne(0,n,"!=");r=un(r,n);var i=Bi(r);if(n!==i)throw new ne(i,n,"!=");try{return Ya(t,r)}catch(u){throw u instanceof ne?new ne(i,n,"!="):u}}function un(e,r){var t=Bi(e),n=e.slice(),i=-1,u=e.indexOf(i),o=e.indexOf(i,u+1)>=0;if(o)throw new Error("More than one wildcard in sizes");var a=u>=0,c=r%t===0;if(a)if(c)n[u]=-r/t;else throw new Error("Could not replace wildcard, since "+r+" is no multiple of "+-t);return n}function Bi(e){return e.reduce((r,t)=>r*t,1)}function Ya(e,r){for(var t=e,n,i=r.length-1;i>0;i--){var u=r[i];n=[];for(var o=t.length/u,a=0;a<o;a++)n.push(t.slice(a*u,(a+1)*u));t=n}return t}function Ni(e,r,t,n){var i=n||ze(e);if(t)for(var u=0;u<t;u++)e=[e],i.unshift(1);for(e=Mi(e,r,0);i.length<r;)i.push(1);return e}function Mi(e,r,t){var n,i;if(Array.isArray(e)){var u=t+1;for(n=0,i=e.length;n<i;n++)e[n]=Mi(e[n],r,u)}else for(var o=t;o<r;o++)e=[e];return e}function ka(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!Array.isArray(e))return e;if(typeof r!="boolean")throw new TypeError("Boolean expected for second argument of flatten");var t=[];return r?i(e):n(e),t;function n(u){for(var o=0;o<u.length;o++){var a=u[o];Array.isArray(a)?n(a):t.push(a)}}function i(u){if(Array.isArray(u[0]))for(var o=0;o<u.length;o++)i(u[o]);else for(var a=0;a<u.length;a++)t.push(u[a])}}function St(e,r){for(var t,n=0,i=0;i<e.length;i++){var u=e[i],o=Array.isArray(u);if(i===0&&o&&(n=u.length),o&&u.length!==n)return;var a=o?St(u,r):r(u);if(t===void 0)t=a;else if(t!==a)return"mixed"}return t}function Si(e,r,t,n){if(n<t){if(e.length!==r.length)throw new ne(e.length,r.length);for(var i=[],u=0;u<e.length;u++)i[u]=Si(e[u],r[u],t,n+1);return i}else return e.concat(r)}function xi(){var e=Array.prototype.slice.call(arguments,0,-1),r=Array.prototype.slice.call(arguments,-1);if(e.length===1)return e[0];if(e.length>1)return e.slice(1).reduce(function(t,n){return Si(t,n,r,0)},e[0]);throw new Error("Wrong number of arguments in function concat")}function Ti(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];for(var n=r.map(D=>D.length),i=Math.max(...n),u=new Array(i).fill(null),o=0;o<r.length;o++)for(var a=r[o],c=n[o],l=0;l<c;l++){var f=i-c+l;a[l]>u[f]&&(u[f]=a[l])}for(var h=0;h<r.length;h++)Ii(r[h],u);return u}function Ii(e,r){for(var t=r.length,n=e.length,i=0;i<n;i++){var u=t-n+i;if(e[i]<r[u]&&e[i]>1||e[i]>r[u])throw new Error("shape mismatch: mismatch is found in arg with shape (".concat(e,") not possible to broadcast dimension ").concat(n," with size ").concat(e[i]," to size ").concat(r[u]))}}function Qt(e,r){var t=ze(e);if(mr(t,r))return e;Ii(t,r);var n=Ti(t,r),i=n.length,u=[...Array(i-t.length).fill(1),...t],o=Qa(e);t.length<i&&(o=_i(o,u),t=ze(o));for(var a=0;a<i;a++)t[a]<n[a]&&(o=Xa(o,n[a],a),t=ze(o));return o}function Xa(e,r,t){return xi(...Array(r).fill(e),t)}function zi(e,r){if(!Array.isArray(e))throw new Error("Array expected");var t=ze(e);if(r.length!==t.length)throw new ne(r.length,t.length);for(var n=0;n<r.length;n++)De(r[n],t[n]);return r.reduce((i,u)=>i[u],e)}function An(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(e.length===0)return[];if(t)return u(e);var n=[];return i(e,0);function i(o,a){if(Array.isArray(o)){for(var c=o.length,l=Array(c),f=0;f<c;f++)n[a]=f,l[f]=i(o[f],a+1);return l}else return r(o,n.slice(0,a),e)}function u(o){if(Array.isArray(o)){for(var a=o.length,c=Array(a),l=0;l<a;l++)c[l]=u(o[l]);return c}else return r(o)}}function Qa(e){return st([],e)}function gt(e,r,t){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(lt.isTypedFunction(e)){var i;if(n)i=1;else{var u=(r.isMatrix?r.size():ze(r)).map(()=>0),o=r.isMatrix?r.get(u):zi(r,u);i=es(e,o,u,r)}var a;if(r.isMatrix&&r.dataType!=="mixed"&&r.dataType!==void 0){var c=Ka(e,i);a=c!==void 0?c:e}else a=e;return i>=1&&i<=3?{isUnary:i===1,fn:function(){for(var f=arguments.length,h=new Array(f),D=0;D<f;D++)h[D]=arguments[D];return bn(a,h.slice(0,i),t,e.name)}}:{isUnary:!1,fn:function(){for(var f=arguments.length,h=new Array(f),D=0;D<f;D++)h[D]=arguments[D];return bn(a,h,t,e.name)}}}return n===void 0?{isUnary:ja(e),fn:e}:{isUnary:n,fn:e}}function Ka(e,r){var t=[];if(Object.entries(e.signatures).forEach(n=>{var[i,u]=n;i.split(",").length===r&&t.push(u)}),t.length===1)return t[0]}function ja(e){if(e.length!==1)return!1;var r=e.toString();if(/arguments/.test(r))return!1;var t=r.match(/\(.*?\)/);return!/\.\.\./.test(t)}function es(e,r,t,n){for(var i=[r,t,n],u=3;u>0;u--){var o=i.slice(0,u);if(lt.resolve(e,o)!==null)return u}}function bn(e,r,t,n){try{return e(...r)}catch(i){rs(i,r,t,n)}}function rs(e,r,t,n){var i;if(e instanceof TypeError&&((i=e.data)===null||i===void 0?void 0:i.category)==="wrongType"){var u=[];throw u.push("value: ".concat(ir(r[0]))),r.length>=2&&u.push("index: ".concat(ir(r[1]))),r.length>=3&&u.push("array: ".concat(ir(r[2]))),new TypeError("Function ".concat(t," cannot apply callback arguments ")+"".concat(n,"(").concat(u.join(", "),") at index ").concat(JSON.stringify(r[1])))}else throw new TypeError("Function ".concat(t," cannot apply callback arguments ")+"to function ".concat(n,": ").concat(e.message))}var ts="DenseMatrix",ns=["Matrix"],is=G(ts,ns,e=>{var{Matrix:r}=e;function t(f,h){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(h&&!Qe(h))throw new Error("Invalid datatype: "+h);if(ve(f))f.type==="DenseMatrix"?(this._data=me(f._data),this._size=me(f._size),this._datatype=h||f._datatype):(this._data=f.toArray(),this._size=f.size(),this._datatype=h||f._datatype);else if(f&&ye(f.data)&&ye(f.size))this._data=f.data,this._size=f.size,En(this._data,this._size),this._datatype=h||f.datatype;else if(ye(f))this._data=l(f),this._size=ze(this._data),En(this._data,this._size),this._datatype=h;else{if(f)throw new TypeError("Unsupported type of data ("+ir(f)+")");this._data=[],this._size=[0],this._datatype=h}}t.prototype=new r,t.prototype.createDenseMatrix=function(f,h){return new t(f,h)},Object.defineProperty(t,"name",{value:"DenseMatrix"}),t.prototype.constructor=t,t.prototype.type="DenseMatrix",t.prototype.isDenseMatrix=!0,t.prototype.getDataType=function(){return St(this._data,ir)},t.prototype.storage=function(){return"dense"},t.prototype.datatype=function(){return this._datatype},t.prototype.create=function(f,h){return new t(f,h)},t.prototype.subset=function(f,h,D){switch(arguments.length){case 1:return n(this,f);case 2:case 3:return u(this,f,h,D);default:throw new SyntaxError("Wrong number of arguments")}},t.prototype.get=function(f){return zi(this._data,f)},t.prototype.set=function(f,h,D){if(!ye(f))throw new TypeError("Array expected");if(f.length<this._size.length)throw new ne(f.length,this._size.length,"<");var p,m,s,d=f.map(function(E){return E+1});c(this,d,D);var g=this._data;for(p=0,m=f.length-1;p<m;p++)s=f[p],De(s,g.length),g=g[s];return s=f[f.length-1],De(s,g.length),g[s]=h,this};function n(f,h){if(!Ct(h))throw new TypeError("Invalid index");var D=h.isScalar();if(D)return f.get(h.min());var p=h.size();if(p.length!==f._size.length)throw new ne(p.length,f._size.length);for(var m=h.min(),s=h.max(),d=0,g=f._size.length;d<g;d++)De(m[d],f._size[d]),De(s[d],f._size[d]);var E=new t([]),v=i(f._data,h);return E._size=v.size,E._datatype=f._datatype,E._data=v.data,E}function i(f,h){var D=h.size().length-1,p=Array(D);return{data:m(f),size:p};function m(s){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,g=h.dimension(d);return p[d]=g.size()[0],d<D?g.map(E=>(De(E,s.length),m(s[E],d+1))).valueOf():g.map(E=>(De(E,s.length),s[E])).valueOf()}}function u(f,h,D,p){if(!h||h.isIndex!==!0)throw new TypeError("Invalid index");var m=h.size(),s=h.isScalar(),d;if(ve(D)?(d=D.size(),D=D.valueOf()):d=ze(D),s){if(d.length!==0)throw new TypeError("Scalar expected");f.set(h.min(),D,p)}else{if(!mr(d,m))try{d.length===0?D=Qt([D],m):D=Qt(D,m),d=ze(D)}catch{}if(m.length<f._size.length)throw new ne(m.length,f._size.length,"<");if(d.length<m.length){for(var g=0,E=0;m[g]===1&&d[g]===1;)g++;for(;m[g]===1;)E++,g++;D=Ni(D,m.length,E,d)}if(!mr(m,d))throw new ne(m,d,">");var v=h.max().map(function(A){return A+1});c(f,v,p),o(f._data,h,D)}return f}function o(f,h,D){var p=h.size().length-1;m(f,D);function m(s,d){var g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,E=h.dimension(g);g<p?E.forEach((v,A)=>{De(v,s.length),m(s[v],d[A[0]],g+1)}):E.forEach((v,A)=>{De(v,s.length),s[v]=d[A[0]]})}}t.prototype.resize=function(f,h,D){if(!ct(f))throw new TypeError("Array or Matrix expected");var p=f.valueOf().map(s=>Array.isArray(s)&&s.length===1?s[0]:s),m=D?this.clone():this;return a(m,p,h)};function a(f,h,D){if(h.length===0){for(var p=f._data;ye(p);)p=p[0];return p}return f._size=h.slice(0),f._data=dt(f._data,f._size,D),f}t.prototype.reshape=function(f,h){var D=h?this.clone():this;D._data=_i(D._data,f);var p=D._size.reduce((m,s)=>m*s);return D._size=un(f,p),D};function c(f,h,D){for(var p=f._size.slice(0),m=!1;p.length<h.length;)p.push(0),m=!0;for(var s=0,d=h.length;s<d;s++)h[s]>p[s]&&(p[s]=h[s],m=!0);m&&a(f,p,D)}t.prototype.clone=function(){var f=new t({data:me(this._data),size:me(this._size),datatype:this._datatype});return f},t.prototype.size=function(){return this._size.slice(0)},t.prototype.map=function(f){var h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,D=this,p=D._size.length-1;if(p<0)return D.clone();var m=gt(f,D,"map",h),s=m.fn,d=D.create(void 0,D._datatype);if(d._size=D._size,h||m.isUnary)return d._data=w(D._data),d;if(p===0){for(var g=D.valueOf(),E=Array(g.length),v=0;v<g.length;v++)E[v]=s(g[v],[v],D);return d._data=E,d}var A=[];return d._data=y(D._data),d;function y(C){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,B=Array(C.length);if(b<p)for(var M=0;M<C.length;M++)A[b]=M,B[M]=y(C[M],b+1);else for(var S=0;S<C.length;S++)A[b]=S,B[S]=s(C[S],A.slice(),D);return B}function w(C){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,B=Array(C.length);if(b<p)for(var M=0;M<C.length;M++)B[M]=w(C[M],b+1);else for(var S=0;S<C.length;S++)B[S]=s(C[S]);return B}},t.prototype.forEach=function(f){var h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,D=this,p=D._size.length-1;if(p<0)return;var m=gt(f,D,"map",h),s=m.fn;if(h||m.isUnary){v(D._data);return}if(p===0){for(var d=0;d<D._data.length;d++)s(D._data[d],[d],D);return}var g=[];E(D._data);function E(A){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(y<p)for(var w=0;w<A.length;w++)g[y]=w,E(A[w],y+1);else for(var C=0;C<A.length;C++)g[y]=C,s(A[C],g.slice(),D)}function v(A){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(y<p)for(var w=0;w<A.length;w++)v(A[w],y+1);else for(var C=0;C<A.length;C++)s(A[C])}},t.prototype[Symbol.iterator]=function*(){var f=this._size.length-1;if(!(f<0)){if(f===0){for(var h=0;h<this._data.length;h++)yield{value:this._data[h],index:[h]};return}var D=[],p=function*(s,d){if(d<f)for(var g=0;g<s.length;g++)D[d]=g,yield*p(s[g],d+1);else for(var E=0;E<s.length;E++)D[d]=E,yield{value:s[E],index:D.slice()}};yield*p(this._data,0)}},t.prototype.rows=function(){var f=[],h=this.size();if(h.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var D=this._data;for(var p of D)f.push(new t([p],this._datatype));return f},t.prototype.columns=function(){var f=this,h=[],D=this.size();if(D.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var p=this._data,m=function(g){var E=p.map(v=>[v[g]]);h.push(new t(E,f._datatype))},s=0;s<D[1];s++)m(s);return h},t.prototype.toArray=function(){return me(this._data)},t.prototype.valueOf=function(){return this._data},t.prototype.format=function(f){return Be(this._data,f)},t.prototype.toString=function(){return Be(this._data)},t.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},t.prototype.diagonal=function(f){if(f){if(Ee(f)&&(f=f.toNumber()),!de(f)||!ge(f))throw new TypeError("The parameter k must be an integer number")}else f=0;for(var h=f>0?f:0,D=f<0?-f:0,p=this._size[0],m=this._size[1],s=Math.min(p-D,m-h),d=[],g=0;g<s;g++)d[g]=this._data[g+D][g+h];return new t({data:d,size:[s],datatype:this._datatype})},t.diagonal=function(f,h,D,p){if(!ye(f))throw new TypeError("Array expected, size parameter");if(f.length!==2)throw new Error("Only two dimensions matrix are supported");if(f=f.map(function(C){if(Ee(C)&&(C=C.toNumber()),!de(C)||!ge(C)||C<1)throw new Error("Size values must be positive integers");return C}),D){if(Ee(D)&&(D=D.toNumber()),!de(D)||!ge(D))throw new TypeError("The parameter k must be an integer number")}else D=0;var m=D>0?D:0,s=D<0?-D:0,d=f[0],g=f[1],E=Math.min(d-s,g-m),v;if(ye(h)){if(h.length!==E)throw new Error("Invalid value array length");v=function(b){return h[b]}}else if(ve(h)){var A=h.size();if(A.length!==1||A[0]!==E)throw new Error("Invalid matrix length");v=function(b){return h.get([b])}}else v=function(){return h};p||(p=Ee(v(0))?v(0).mul(0):0);var y=[];if(f.length>0){y=dt(y,f,p);for(var w=0;w<E;w++)y[w+s][w+m]=v(w)}return new t({data:y,size:[d,g]})},t.fromJSON=function(f){return new t(f)},t.prototype.swapRows=function(f,h){if(!de(f)||!ge(f)||!de(h)||!ge(h))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return De(f,this._size[0]),De(h,this._size[0]),t._swapRows(f,h,this._data),this},t._swapRows=function(f,h,D){var p=D[f];D[f]=D[h],D[h]=p};function l(f){return ve(f)?l(f.valueOf()):ye(f)?f.map(l):f}return t},{isClass:!0});function Ve(e,r,t){if(!t)return ve(e)?e.map(i=>r(i),!1,!0):An(e,r,!0);var n=i=>i===0?i:r(i);return ve(e)?e.map(i=>n(i),!1,!0):An(e,n,!0)}var Cn="isInteger",us=["typed"],os=G(Cn,us,e=>{var{typed:r}=e;return r(Cn,{number:ge,BigNumber:function(n){return n.isInt()},bigint:function(n){return!0},Fraction:function(n){return n.d===1n},"Array | Matrix":r.referToSelf(t=>n=>Ve(n,t))})}),on="number",xt="number, number";function Oi(e){return Math.abs(e)}Oi.signature=on;function $i(e,r){return e+r}$i.signature=xt;function Pi(e,r){return e-r}Pi.signature=xt;function Ui(e,r){return e*r}Ui.signature=xt;function qi(e){return-e}qi.signature=on;function vt(e){return Co(e)}vt.signature=on;function Ri(e,r){return e*e<1&&r===1/0||e*e>1&&r===-1/0?0:Math.pow(e,r)}Ri.signature=xt;function qr(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!ge(r)||r<0||r>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(ci(e,r))}var as=Math.PI,ss="number";function Li(e){return e>0}Li.signature=ss;function gr(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e-9,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(t<=0)throw new Error("Relative tolerance must be greater than 0");if(n<0)throw new Error("Absolute tolerance must be at least 0");return e.isNaN()||r.isNaN()?!1:!e.isFinite()||!r.isFinite()?e.eq(r):e.eq(r)?!0:e.minus(r).abs().lte(e.constructor.max(e.constructor.max(e.abs(),r.abs()).mul(t),n))}var _n="isPositive",fs=["typed","config"],cs=G(_n,fs,e=>{var{typed:r,config:t}=e;return r(_n,{number:n=>tr(n,0,t.relTol,t.absTol)?!1:Li(n),BigNumber:n=>gr(n,new n.constructor(0),t.relTol,t.absTol)?!1:!n.isNeg()&&!n.isZero()&&!n.isNaN(),bigint:n=>n>0n,Fraction:n=>n.s>0n&&n.n>0n,Unit:r.referToSelf(n=>i=>r.find(n,i.valueType())(i.value)),"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})}),Bn="isZero",ls=["typed","equalScalar"],hs=G(Bn,ls,e=>{var{typed:r,equalScalar:t}=e;return r(Bn,{"number | BigNumber | Complex | Fraction":n=>t(n,0),bigint:n=>n===0n,Unit:r.referToSelf(n=>i=>r.find(n,i.valueType())(i.value)),"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})});function ps(e,r,t,n){return tr(e.re,r.re,t,n)&&tr(e.im,r.im,t,n)}var Gr=G("compareUnits",["typed"],e=>{var{typed:r}=e;return{"Unit, Unit":r.referToSelf(t=>(n,i)=>{if(!n.equalBase(i))throw new Error("Cannot compare units with different base");return r.find(t,[n.valueType(),i.valueType()])(n.value,i.value)})}}),wt="equalScalar",Ds=["typed","config"],ms=G(wt,Ds,e=>{var{typed:r,config:t}=e,n=Gr({typed:r});return r(wt,{"boolean, boolean":function(u,o){return u===o},"number, number":function(u,o){return tr(u,o,t.relTol,t.absTol)},"BigNumber, BigNumber":function(u,o){return u.eq(o)||gr(u,o,t.relTol,t.absTol)},"bigint, bigint":function(u,o){return u===o},"Fraction, Fraction":function(u,o){return u.equals(o)},"Complex, Complex":function(u,o){return ps(u,o,t.relTol,t.absTol)}},n)});G(wt,["typed","config"],e=>{var{typed:r,config:t}=e;return r(wt,{"number, number":function(i,u){return tr(i,u,t.relTol,t.absTol)}})});var ds="SparseMatrix",gs=["typed","equalScalar","Matrix"],vs=G(ds,gs,e=>{var{typed:r,equalScalar:t,Matrix:n}=e;function i(s,d){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(d&&!Qe(d))throw new Error("Invalid datatype: "+d);if(ve(s))u(this,s,d);else if(s&&ye(s.index)&&ye(s.ptr)&&ye(s.size))this._values=s.values,this._index=s.index,this._ptr=s.ptr,this._size=s.size,this._datatype=d||s.datatype;else if(ye(s))o(this,s,d);else{if(s)throw new TypeError("Unsupported type of data ("+ir(s)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=d}}function u(s,d,g){d.type==="SparseMatrix"?(s._values=d._values?me(d._values):void 0,s._index=me(d._index),s._ptr=me(d._ptr),s._size=me(d._size),s._datatype=g||d._datatype):o(s,d.valueOf(),g||d._datatype)}function o(s,d,g){s._values=[],s._index=[],s._ptr=[],s._datatype=g;var E=d.length,v=0,A=t,y=0;if(Qe(g)&&(A=r.find(t,[g,g])||t,y=r.convert(0,g)),E>0){var w=0;do{s._ptr.push(s._index.length);for(var C=0;C<E;C++){var b=d[C];if(ye(b)){if(w===0&&v<b.length&&(v=b.length),w<b.length){var B=b[w];A(B,y)||(s._values.push(B),s._index.push(C))}}else w===0&&v<1&&(v=1),A(b,y)||(s._values.push(b),s._index.push(C))}w++}while(w<v)}s._ptr.push(s._index.length),s._size=[E,v]}i.prototype=new n,i.prototype.createSparseMatrix=function(s,d){return new i(s,d)},Object.defineProperty(i,"name",{value:"SparseMatrix"}),i.prototype.constructor=i,i.prototype.type="SparseMatrix",i.prototype.isSparseMatrix=!0,i.prototype.getDataType=function(){return St(this._values,ir)},i.prototype.storage=function(){return"sparse"},i.prototype.datatype=function(){return this._datatype},i.prototype.create=function(s,d){return new i(s,d)},i.prototype.density=function(){var s=this._size[0],d=this._size[1];return s!==0&&d!==0?this._index.length/(s*d):0},i.prototype.subset=function(s,d,g){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return a(this,s);case 2:case 3:return c(this,s,d,g);default:throw new SyntaxError("Wrong number of arguments")}};function a(s,d){if(!Ct(d))throw new TypeError("Invalid index");var g=d.isScalar();if(g)return s.get(d.min());var E=d.size();if(E.length!==s._size.length)throw new ne(E.length,s._size.length);var v,A,y,w,C=d.min(),b=d.max();for(v=0,A=s._size.length;v<A;v++)De(C[v],s._size[v]),De(b[v],s._size[v]);var B=s._values,M=s._index,S=s._ptr,R=d.dimension(0),V=d.dimension(1),q=[],W=[];R.forEach(function(J,ee){W[J]=ee[0],q[J]=!0});var O=B?[]:void 0,Q=[],Y=[];return V.forEach(function(J){for(Y.push(Q.length),y=S[J],w=S[J+1];y<w;y++)v=M[y],q[v]===!0&&(Q.push(W[v]),O&&O.push(B[y]))}),Y.push(Q.length),new i({values:O,index:Q,ptr:Y,size:E,datatype:s._datatype})}function c(s,d,g,E){if(!d||d.isIndex!==!0)throw new TypeError("Invalid index");var v=d.size(),A=d.isScalar(),y;if(ve(g)?(y=g.size(),g=g.toArray()):y=ze(g),A){if(y.length!==0)throw new TypeError("Scalar expected");s.set(d.min(),g,E)}else{if(v.length!==1&&v.length!==2)throw new ne(v.length,s._size.length,"<");if(y.length<v.length){for(var w=0,C=0;v[w]===1&&y[w]===1;)w++;for(;v[w]===1;)C++,w++;g=Ni(g,v.length,C,y)}if(!mr(v,y))throw new ne(v,y,">");if(v.length===1){var b=d.dimension(0);b.forEach(function(S,R){De(S),s.set([S,0],g[R[0]],E)})}else{var B=d.dimension(0),M=d.dimension(1);B.forEach(function(S,R){De(S),M.forEach(function(V,q){De(V),s.set([S,V],g[R[0]][q[0]],E)})})}}return s}i.prototype.get=function(s){if(!ye(s))throw new TypeError("Array expected");if(s.length!==this._size.length)throw new ne(s.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var d=s[0],g=s[1];De(d,this._size[0]),De(g,this._size[1]);var E=l(d,this._ptr[g],this._ptr[g+1],this._index);return E<this._ptr[g+1]&&this._index[E]===d?this._values[E]:0},i.prototype.set=function(s,d,g){if(!ye(s))throw new TypeError("Array expected");if(s.length!==this._size.length)throw new ne(s.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var E=s[0],v=s[1],A=this._size[0],y=this._size[1],w=t,C=0;Qe(this._datatype)&&(w=r.find(t,[this._datatype,this._datatype])||t,C=r.convert(0,this._datatype)),(E>A-1||v>y-1)&&(D(this,Math.max(E+1,A),Math.max(v+1,y),g),A=this._size[0],y=this._size[1]),De(E,A),De(v,y);var b=l(E,this._ptr[v],this._ptr[v+1],this._index);return b<this._ptr[v+1]&&this._index[b]===E?w(d,C)?f(b,v,this._values,this._index,this._ptr):this._values[b]=d:w(d,C)||h(b,E,v,d,this._values,this._index,this._ptr),this};function l(s,d,g,E){if(g-d===0)return g;for(var v=d;v<g;v++)if(E[v]===s)return v;return d}function f(s,d,g,E,v){g.splice(s,1),E.splice(s,1);for(var A=d+1;A<v.length;A++)v[A]--}function h(s,d,g,E,v,A,y){v.splice(s,0,E),A.splice(s,0,d);for(var w=g+1;w<y.length;w++)y[w]++}i.prototype.resize=function(s,d,g){if(!ct(s))throw new TypeError("Array or Matrix expected");var E=s.valueOf().map(A=>Array.isArray(A)&&A.length===1?A[0]:A);if(E.length!==2)throw new Error("Only two dimensions matrix are supported");E.forEach(function(A){if(!de(A)||!ge(A)||A<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Be(E)+")")});var v=g?this.clone():this;return D(v,E[0],E[1],d)};function D(s,d,g,E){var v=E||0,A=t,y=0;Qe(s._datatype)&&(A=r.find(t,[s._datatype,s._datatype])||t,y=r.convert(0,s._datatype),v=r.convert(v,s._datatype));var w=!A(v,y),C=s._size[0],b=s._size[1],B,M,S;if(g>b){for(M=b;M<g;M++)if(s._ptr[M]=s._values.length,w)for(B=0;B<C;B++)s._values.push(v),s._index.push(B);s._ptr[g]=s._values.length}else g<b&&(s._ptr.splice(g+1,b-g),s._values.splice(s._ptr[g],s._values.length),s._index.splice(s._ptr[g],s._index.length));if(b=g,d>C){if(w){var R=0;for(M=0;M<b;M++){s._ptr[M]=s._ptr[M]+R,S=s._ptr[M+1]+R;var V=0;for(B=C;B<d;B++,V++)s._values.splice(S+V,0,v),s._index.splice(S+V,0,B),R++}s._ptr[b]=s._values.length}}else if(d<C){var q=0;for(M=0;M<b;M++){s._ptr[M]=s._ptr[M]-q;var W=s._ptr[M],O=s._ptr[M+1]-q;for(S=W;S<O;S++)B=s._index[S],B>d-1&&(s._values.splice(S,1),s._index.splice(S,1),q++)}s._ptr[M]=s._values.length}return s._size[0]=d,s._size[1]=g,s}i.prototype.reshape=function(s,d){if(!ye(s))throw new TypeError("Array expected");if(s.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");s.forEach(function(J){if(!de(J)||!ge(J)||J<=-2||J===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Be(s)+")")});var g=this._size[0]*this._size[1];s=un(s,g);var E=s[0]*s[1];if(g!==E)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var v=d?this.clone():this;if(this._size[0]===s[0]&&this._size[1]===s[1])return v;for(var A=[],y=0;y<v._ptr.length;y++)for(var w=0;w<v._ptr[y+1]-v._ptr[y];w++)A.push(y);for(var C=v._values.slice(),b=v._index.slice(),B=0;B<v._index.length;B++){var M=b[B],S=A[B],R=M*v._size[1]+S;A[B]=R%s[1],b[B]=Math.floor(R/s[1])}v._values.length=0,v._index.length=0,v._ptr.length=s[1]+1,v._size=s.slice();for(var V=0;V<v._ptr.length;V++)v._ptr[V]=0;for(var q=0;q<C.length;q++){var W=b[q],O=A[q],Q=C[q],Y=l(W,v._ptr[O],v._ptr[O+1],v._index);h(Y,W,O,Q,v._values,v._index,v._ptr)}return v},i.prototype.clone=function(){var s=new i({values:this._values?me(this._values):void 0,index:me(this._index),ptr:me(this._ptr),size:me(this._size),datatype:this._datatype});return s},i.prototype.size=function(){return this._size.slice(0)},i.prototype.map=function(s,d){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var g=this,E=this._size[0],v=this._size[1],A=gt(s,g,"map"),y=function(C,b,B){return A.fn(C,[b,B],g)};return p(this,0,E-1,0,v-1,y,d)};function p(s,d,g,E,v,A,y){var w=[],C=[],b=[],B=t,M=0;Qe(s._datatype)&&(B=r.find(t,[s._datatype,s._datatype])||t,M=r.convert(0,s._datatype));for(var S=function(fe,Ce,be){var Ae=A(fe,Ce,be);B(Ae,M)||(w.push(Ae),C.push(Ce))},R=E;R<=v;R++){b.push(w.length);var V=s._ptr[R],q=s._ptr[R+1];if(y)for(var W=V;W<q;W++){var O=s._index[W];O>=d&&O<=g&&S(s._values[W],O-d,R-E)}else{for(var Q={},Y=V;Y<q;Y++){var J=s._index[Y];Q[J]=s._values[Y]}for(var ee=d;ee<=g;ee++){var oe=ee in Q?Q[ee]:0;S(oe,ee-d,R-E)}}}return b.push(w.length),new i({values:w,index:C,ptr:b,size:[g-d+1,v-E+1]})}i.prototype.forEach=function(s,d){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var g=this,E=this._size[0],v=this._size[1],A=gt(s,g,"forEach"),y=0;y<v;y++){var w=this._ptr[y],C=this._ptr[y+1];if(d)for(var b=w;b<C;b++){var B=this._index[b];A.fn(this._values[b],[B,y],g)}else{for(var M={},S=w;S<C;S++){var R=this._index[S];M[R]=this._values[S]}for(var V=0;V<E;V++){var q=V in M?M[V]:0;A.fn(q,[V,y],g)}}}},i.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var s=this._size[1],d=0;d<s;d++)for(var g=this._ptr[d],E=this._ptr[d+1],v=g;v<E;v++){var A=this._index[v];yield{value:this._values[v],index:[A,d]}}},i.prototype.toArray=function(){return m(this._values,this._index,this._ptr,this._size,!0)},i.prototype.valueOf=function(){return m(this._values,this._index,this._ptr,this._size,!1)};function m(s,d,g,E,v){var A=E[0],y=E[1],w=[],C,b;for(C=0;C<A;C++)for(w[C]=[],b=0;b<y;b++)w[C][b]=0;for(b=0;b<y;b++)for(var B=g[b],M=g[b+1],S=B;S<M;S++)C=d[S],w[C][b]=s?v?me(s[S]):s[S]:1;return w}return i.prototype.format=function(s){for(var d=this._size[0],g=this._size[1],E=this.density(),v="Sparse Matrix ["+Be(d,s)+" x "+Be(g,s)+"] density: "+Be(E,s)+`
|
|
16
|
-
`,A=0;A<g;A++)for(var y=this._ptr[A],w=this._ptr[A+1],C=y;C<w;C++){var b=this._index[C];v+=`
|
|
17
|
-
(`+Be(b,s)+", "+Be(A,s)+") ==> "+(this._values?Be(this._values[C],s):"X")}return v},i.prototype.toString=function(){return Be(this.toArray())},i.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},i.prototype.diagonal=function(s){if(s){if(Ee(s)&&(s=s.toNumber()),!de(s)||!ge(s))throw new TypeError("The parameter k must be an integer number")}else s=0;var d=s>0?s:0,g=s<0?-s:0,E=this._size[0],v=this._size[1],A=Math.min(E-g,v-d),y=[],w=[],C=[];C[0]=0;for(var b=d;b<v&&y.length<A;b++)for(var B=this._ptr[b],M=this._ptr[b+1],S=B;S<M;S++){var R=this._index[S];if(R===b-d+g){y.push(this._values[S]),w[y.length-1]=R-g;break}}return C.push(y.length),new i({values:y,index:w,ptr:C,size:[A,1]})},i.fromJSON=function(s){return new i(s)},i.diagonal=function(s,d,g,E,v){if(!ye(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(J){if(Ee(J)&&(J=J.toNumber()),!de(J)||!ge(J)||J<1)throw new Error("Size values must be positive integers");return J}),g){if(Ee(g)&&(g=g.toNumber()),!de(g)||!ge(g))throw new TypeError("The parameter k must be an integer number")}else g=0;var A=t,y=0;Qe(v)&&(A=r.find(t,[v,v])||t,y=r.convert(0,v));var w=g>0?g:0,C=g<0?-g:0,b=s[0],B=s[1],M=Math.min(b-C,B-w),S;if(ye(d)){if(d.length!==M)throw new Error("Invalid value array length");S=function(ee){return d[ee]}}else if(ve(d)){var R=d.size();if(R.length!==1||R[0]!==M)throw new Error("Invalid matrix length");S=function(ee){return d.get([ee])}}else S=function(){return d};for(var V=[],q=[],W=[],O=0;O<B;O++){W.push(V.length);var Q=O-w;if(Q>=0&&Q<M){var Y=S(Q);A(Y,y)||(q.push(Q+C),V.push(Y))}}return W.push(V.length),new i({values:V,index:q,ptr:W,size:[b,B]})},i.prototype.swapRows=function(s,d){if(!de(s)||!ge(s)||!de(d)||!ge(d))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return De(s,this._size[0]),De(d,this._size[0]),i._swapRows(s,d,this._size[1],this._values,this._index,this._ptr),this},i._forEachRow=function(s,d,g,E,v){for(var A=E[s],y=E[s+1],w=A;w<y;w++)v(g[w],d[w])},i._swapRows=function(s,d,g,E,v,A){for(var y=0;y<g;y++){var w=A[y],C=A[y+1],b=l(s,w,C,v),B=l(d,w,C,v);if(b<C&&B<C&&v[b]===s&&v[B]===d){if(E){var M=E[b];E[b]=E[B],E[B]=M}continue}if(b<C&&v[b]===s&&(B>=C||v[B]!==d)){var S=E?E[b]:void 0;v.splice(B,0,d),E&&E.splice(B,0,S),v.splice(B<=b?b+1:b,1),E&&E.splice(B<=b?b+1:b,1);continue}if(B<C&&v[B]===d&&(b>=C||v[b]!==s)){var R=E?E[B]:void 0;v.splice(b,0,s),E&&E.splice(b,0,R),v.splice(b<=B?B+1:B,1),E&&E.splice(b<=B?B+1:B,1)}}},i},{isClass:!0}),ws="number",ys=["typed"];function Fs(e){var r=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(r){var t={"0b":2,"0o":8,"0x":16}[r[1]],n=r[2],i=r[3];return{input:e,radix:t,integerPart:n,fractionalPart:i}}else return null}function Es(e){for(var r=parseInt(e.integerPart,e.radix),t=0,n=0;n<e.fractionalPart.length;n++){var i=parseInt(e.fractionalPart[n],e.radix);t+=i/Math.pow(e.radix,n+1)}var u=r+t;if(isNaN(u))throw new SyntaxError('String "'+e.input+'" is not a valid number');return u}var As=G(ws,ys,e=>{var{typed:r}=e,t=r("number",{"":function(){return 0},number:function(i){return i},string:function(i){if(i==="NaN")return NaN;var u=Fs(i);if(u)return Es(u);var o=0,a=i.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);a&&(o=Number(a[2]),i=a[1]);var c=Number(i);if(isNaN(c))throw new SyntaxError('String "'+i+'" is not a valid number');if(a){if(c>2**o-1)throw new SyntaxError('String "'.concat(i,'" is out of range'));c>=2**(o-1)&&(c=c-2**o)}return c},BigNumber:function(i){return i.toNumber()},bigint:function(i){return Number(i)},Fraction:function(i){return i.valueOf()},Unit:r.referToSelf(n=>i=>{var u=i.clone();return u.value=n(i.value),u}),null:function(i){return 0},"Unit, string | Unit":function(i,u){return i.toNumber(u)},"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))});return t.fromJSON=function(n){return parseFloat(n.value)},t}),bs="bignumber",Cs=["typed","BigNumber"],_s=G(bs,Cs,e=>{var{typed:r,BigNumber:t}=e;return r("bignumber",{"":function(){return new t(0)},number:function(i){return new t(i+"")},string:function(i){var u=i.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(u){var o=u[2],a=t(u[1]),c=new t(2).pow(Number(o));if(a.gt(c.sub(1)))throw new SyntaxError('String "'.concat(i,'" is out of range'));var l=new t(2).pow(Number(o)-1);return a.gte(l)?a.sub(c):a}return new t(i)},BigNumber:function(i){return i},bigint:function(i){return new t(i.toString())},Unit:r.referToSelf(n=>i=>{var u=i.clone();return u.value=n(i.value),u}),Fraction:function(i){return new t(String(i.n)).div(String(i.d)).times(String(i.s))},null:function(i){return new t(0)},"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})}),Bs="complex",Ns=["typed","Complex"],Ms=G(Bs,Ns,e=>{var{typed:r,Complex:t}=e;return r("complex",{"":function(){return t.ZERO},number:function(i){return new t(i,0)},"number, number":function(i,u){return new t(i,u)},"BigNumber, BigNumber":function(i,u){return new t(i.toNumber(),u.toNumber())},Fraction:function(i){return new t(i.valueOf(),0)},Complex:function(i){return i.clone()},string:function(i){return t(i)},null:function(i){return t(0)},Object:function(i){if("re"in i&&"im"in i)return new t(i.re,i.im);if("r"in i&&"phi"in i||"abs"in i&&"arg"in i)return new t(i);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})}),Ss="fraction",xs=["typed","Fraction"],Ts=G(Ss,xs,e=>{var{typed:r,Fraction:t}=e;return r("fraction",{number:function(i){if(!isFinite(i)||isNaN(i))throw new Error(i+" cannot be represented as a fraction");return new t(i)},string:function(i){return new t(i)},"number, number":function(i,u){return new t(i,u)},"bigint, bigint":function(i,u){return new t(i,u)},null:function(i){return new t(0)},BigNumber:function(i){return new t(i.toString())},bigint:function(i){return new t(i.toString())},Fraction:function(i){return i},Unit:r.referToSelf(n=>i=>{var u=i.clone();return u.value=n(i.value),u}),Object:function(i){return new t(i)},"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})}),Nn="matrix",Is=["typed","Matrix","DenseMatrix","SparseMatrix"],zs=G(Nn,Is,e=>{var{typed:r,Matrix:t,DenseMatrix:n,SparseMatrix:i}=e;return r(Nn,{"":function(){return u([])},string:function(a){return u([],a)},"string, string":function(a,c){return u([],a,c)},Array:function(a){return u(a)},Matrix:function(a){return u(a,a.storage())},"Array | Matrix, string":u,"Array | Matrix, string, string":u});function u(o,a,c){if(a==="dense"||a==="default"||a===void 0)return new n(o,c);if(a==="sparse")return new i(o,c);throw new TypeError("Unknown matrix type "+JSON.stringify(a)+".")}}),Mn="unaryMinus",Os=["typed"],$s=G(Mn,Os,e=>{var{typed:r}=e;return r(Mn,{number:qi,"Complex | BigNumber | Fraction":t=>t.neg(),bigint:t=>-t,Unit:r.referToSelf(t=>n=>{var i=n.clone();return i.value=r.find(t,i.valueType())(n.value),i}),"Array | Matrix":r.referToSelf(t=>n=>Ve(n,t,!0))})}),Sn="abs",Ps=["typed"],Us=G(Sn,Ps,e=>{var{typed:r}=e;return r(Sn,{number:Oi,"Complex | BigNumber | Fraction | Unit":t=>t.abs(),bigint:t=>t<0n?-t:t,"Array | Matrix":r.referToSelf(t=>n=>Ve(n,t,!0))})}),xn="addScalar",qs=["typed"],Rs=G(xn,qs,e=>{var{typed:r}=e;return r(xn,{"number, number":$i,"Complex, Complex":function(n,i){return n.add(i)},"BigNumber, BigNumber":function(n,i){return n.plus(i)},"bigint, bigint":function(n,i){return n+i},"Fraction, Fraction":function(n,i){return n.add(i)},"Unit, Unit":r.referToSelf(t=>(n,i)=>{if(n.value===null||n.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(i.value===null||i.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!n.equalBase(i))throw new Error("Units do not match");var u=n.clone();return u.value=r.find(t,[u.valueType(),i.valueType()])(u.value,i.value),u.fixPrefix=!1,u})})}),Tn="subtractScalar",Ls=["typed"],Hs=G(Tn,Ls,e=>{var{typed:r}=e;return r(Tn,{"number, number":Pi,"Complex, Complex":function(n,i){return n.sub(i)},"BigNumber, BigNumber":function(n,i){return n.minus(i)},"bigint, bigint":function(n,i){return n-i},"Fraction, Fraction":function(n,i){return n.sub(i)},"Unit, Unit":r.referToSelf(t=>(n,i)=>{if(n.value===null||n.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(i.value===null||i.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!n.equalBase(i))throw new Error("Units do not match");var u=n.clone();return u.value=r.find(t,[u.valueType(),i.valueType()])(u.value,i.value),u.fixPrefix=!1,u})})}),Zs="matAlgo11xS0s",Ws=["typed","equalScalar"],Hi=G(Zs,Ws,e=>{var{typed:r,equalScalar:t}=e;return function(i,u,o,a){var c=i._values,l=i._index,f=i._ptr,h=i._size,D=i._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=h[0],m=h[1],s,d=t,g=0,E=o;typeof D=="string"&&(s=D,d=r.find(t,[s,s]),g=r.convert(0,s),u=r.convert(u,s),E=r.find(o,[s,s]));for(var v=[],A=[],y=[],w=0;w<m;w++){y[w]=A.length;for(var C=f[w],b=f[w+1],B=C;B<b;B++){var M=l[B],S=a?E(u,c[B]):E(c[B],u);d(S,g)||(A.push(M),v.push(S))}}return y[m]=A.length,i.createSparseMatrix({values:v,index:A,ptr:y,size:[p,m],datatype:s})}}),Vs="matAlgo12xSfs",Gs=["typed","DenseMatrix"],Jr=G(Vs,Gs,e=>{var{typed:r,DenseMatrix:t}=e;return function(i,u,o,a){var c=i._values,l=i._index,f=i._ptr,h=i._size,D=i._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=h[0],m=h[1],s,d=o;typeof D=="string"&&(s=D,u=r.convert(u,s),d=r.find(o,[s,s]));for(var g=[],E=[],v=[],A=0;A<m;A++){for(var y=A+1,w=f[A],C=f[A+1],b=w;b<C;b++){var B=l[b];E[B]=c[b],v[B]=y}for(var M=0;M<p;M++)A===0&&(g[M]=[]),v[M]===y?g[M][A]=a?d(u,E[M]):d(E[M],u):g[M][A]=a?d(u,0):d(0,u)}return new t({data:g,size:[p,m],datatype:s})}}),Js="matAlgo14xDs",Ys=["typed"],an=G(Js,Ys,e=>{var{typed:r}=e;return function(i,u,o,a){var c=i._data,l=i._size,f=i._datatype,h,D=o;typeof f=="string"&&(h=f,u=r.convert(u,h),D=r.find(o,[h,h]));var p=l.length>0?t(D,0,l,l[0],c,u,a):[];return i.createDenseMatrix({data:p,size:me(l),datatype:h})};function t(n,i,u,o,a,c,l){var f=[];if(i===u.length-1)for(var h=0;h<o;h++)f[h]=l?n(c,a[h]):n(a[h],c);else for(var D=0;D<o;D++)f[D]=t(n,i+1,u,u[i+1],a[D],c,l);return f}}),ks="matAlgo03xDSf",Xs=["typed"],Tt=G(ks,Xs,e=>{var{typed:r}=e;return function(n,i,u,o){var a=n._data,c=n._size,l=n._datatype||n.getDataType(),f=i._values,h=i._index,D=i._ptr,p=i._size,m=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(c.length!==p.length)throw new ne(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+p+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var s=c[0],d=c[1],g,E=0,v=u;typeof l=="string"&&l===m&&l!=="mixed"&&(g=l,E=r.convert(0,g),v=r.find(u,[g,g]));for(var A=[],y=0;y<s;y++)A[y]=[];for(var w=[],C=[],b=0;b<d;b++){for(var B=b+1,M=D[b],S=D[b+1],R=M;R<S;R++){var V=h[R];w[V]=o?v(f[R],a[V][b]):v(a[V][b],f[R]),C[V]=B}for(var q=0;q<s;q++)C[q]===B?A[q][b]=w[q]:A[q][b]=o?v(E,a[q][b]):v(a[q][b],E)}return n.createDenseMatrix({data:A,size:[s,d],datatype:l===n._datatype&&m===i._datatype?g:void 0})}}),Qs="matAlgo13xDD",Ks=["typed"],js=G(Qs,Ks,e=>{var{typed:r}=e;return function(i,u,o){var a=i._data,c=i._size,l=i._datatype,f=u._data,h=u._size,D=u._datatype,p=[];if(c.length!==h.length)throw new ne(c.length,h.length);for(var m=0;m<c.length;m++){if(c[m]!==h[m])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+h+")");p[m]=c[m]}var s,d=o;typeof l=="string"&&l===D&&(s=l,d=r.find(o,[s,s]));var g=p.length>0?t(d,0,p,p[0],a,f):[];return i.createDenseMatrix({data:g,size:p,datatype:s})};function t(n,i,u,o,a,c){var l=[];if(i===u.length-1)for(var f=0;f<o;f++)l[f]=n(a[f],c[f]);else for(var h=0;h<o;h++)l[h]=t(n,i+1,u,u[i+1],a[h],c[h]);return l}});function Se(e,r){if(mr(e.size(),r.size()))return[e,r];var t=Ti(e.size(),r.size());return[e,r].map(n=>ef(n,t))}function ef(e,r){return mr(e.size(),r)?e:e.create(Qt(e.valueOf(),r),e.datatype())}var rf="matrixAlgorithmSuite",tf=["typed","matrix"],Yr=G(rf,tf,e=>{var{typed:r,matrix:t}=e,n=js({typed:r}),i=an({typed:r});return function(o){var a=o.elop,c=o.SD||o.DS,l;a?(l={"DenseMatrix, DenseMatrix":(p,m)=>n(...Se(p,m),a),"Array, Array":(p,m)=>n(...Se(t(p),t(m)),a).valueOf(),"Array, DenseMatrix":(p,m)=>n(...Se(t(p),m),a),"DenseMatrix, Array":(p,m)=>n(...Se(p,t(m)),a)},o.SS&&(l["SparseMatrix, SparseMatrix"]=(p,m)=>o.SS(...Se(p,m),a,!1)),o.DS&&(l["DenseMatrix, SparseMatrix"]=(p,m)=>o.DS(...Se(p,m),a,!1),l["Array, SparseMatrix"]=(p,m)=>o.DS(...Se(t(p),m),a,!1)),c&&(l["SparseMatrix, DenseMatrix"]=(p,m)=>c(...Se(m,p),a,!0),l["SparseMatrix, Array"]=(p,m)=>c(...Se(t(m),p),a,!0))):(l={"DenseMatrix, DenseMatrix":r.referToSelf(p=>(m,s)=>n(...Se(m,s),p)),"Array, Array":r.referToSelf(p=>(m,s)=>n(...Se(t(m),t(s)),p).valueOf()),"Array, DenseMatrix":r.referToSelf(p=>(m,s)=>n(...Se(t(m),s),p)),"DenseMatrix, Array":r.referToSelf(p=>(m,s)=>n(...Se(m,t(s)),p))},o.SS&&(l["SparseMatrix, SparseMatrix"]=r.referToSelf(p=>(m,s)=>o.SS(...Se(m,s),p,!1))),o.DS&&(l["DenseMatrix, SparseMatrix"]=r.referToSelf(p=>(m,s)=>o.DS(...Se(m,s),p,!1)),l["Array, SparseMatrix"]=r.referToSelf(p=>(m,s)=>o.DS(...Se(t(m),s),p,!1))),c&&(l["SparseMatrix, DenseMatrix"]=r.referToSelf(p=>(m,s)=>c(...Se(s,m),p,!0)),l["SparseMatrix, Array"]=r.referToSelf(p=>(m,s)=>c(...Se(t(s),m),p,!0))));var f=o.scalar||"any",h=o.Ds||o.Ss;h&&(a?(l["DenseMatrix,"+f]=(p,m)=>i(p,m,a,!1),l[f+", DenseMatrix"]=(p,m)=>i(m,p,a,!0),l["Array,"+f]=(p,m)=>i(t(p),m,a,!1).valueOf(),l[f+", Array"]=(p,m)=>i(t(m),p,a,!0).valueOf()):(l["DenseMatrix,"+f]=r.referToSelf(p=>(m,s)=>i(m,s,p,!1)),l[f+", DenseMatrix"]=r.referToSelf(p=>(m,s)=>i(s,m,p,!0)),l["Array,"+f]=r.referToSelf(p=>(m,s)=>i(t(m),s,p,!1).valueOf()),l[f+", Array"]=r.referToSelf(p=>(m,s)=>i(t(s),m,p,!0).valueOf())));var D=o.sS!==void 0?o.sS:o.Ss;return a?(o.Ss&&(l["SparseMatrix,"+f]=(p,m)=>o.Ss(p,m,a,!1)),D&&(l[f+", SparseMatrix"]=(p,m)=>D(m,p,a,!0))):(o.Ss&&(l["SparseMatrix,"+f]=r.referToSelf(p=>(m,s)=>o.Ss(m,s,p,!1))),D&&(l[f+", SparseMatrix"]=r.referToSelf(p=>(m,s)=>D(s,m,p,!0)))),a&&a.signatures&&vo(l,a.signatures),l}}),nf="matAlgo01xDSid",uf=["typed"],of=G(nf,uf,e=>{var{typed:r}=e;return function(n,i,u,o){var a=n._data,c=n._size,l=n._datatype||n.getDataType(),f=i._values,h=i._index,D=i._ptr,p=i._size,m=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(c.length!==p.length)throw new ne(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+p+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var s=c[0],d=c[1],g=typeof l=="string"&&l!=="mixed"&&l===m?l:void 0,E=g?r.find(u,[g,g]):u,v,A,y=[];for(v=0;v<s;v++)y[v]=[];var w=[],C=[];for(A=0;A<d;A++){for(var b=A+1,B=D[A],M=D[A+1],S=B;S<M;S++)v=h[S],w[v]=o?E(f[S],a[v][A]):E(a[v][A],f[S]),C[v]=b;for(v=0;v<s;v++)C[v]===b?y[v][A]=w[v]:y[v][A]=a[v][A]}return n.createDenseMatrix({data:y,size:[s,d],datatype:l===n._datatype&&m===i._datatype?g:void 0})}}),af="matAlgo04xSidSid",sf=["typed","equalScalar"],ff=G(af,sf,e=>{var{typed:r,equalScalar:t}=e;return function(i,u,o){var a=i._values,c=i._index,l=i._ptr,f=i._size,h=i._datatype||i._data===void 0?i._datatype:i.getDataType(),D=u._values,p=u._index,m=u._ptr,s=u._size,d=u._datatype||u._data===void 0?u._datatype:u.getDataType();if(f.length!==s.length)throw new ne(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 g=f[0],E=f[1],v,A=t,y=0,w=o;typeof h=="string"&&h===d&&h!=="mixed"&&(v=h,A=r.find(t,[v,v]),y=r.convert(0,v),w=r.find(o,[v,v]));var C=a&&D?[]:void 0,b=[],B=[],M=a&&D?[]:void 0,S=a&&D?[]:void 0,R=[],V=[],q,W,O,Q,Y;for(W=0;W<E;W++){B[W]=b.length;var J=W+1;for(Q=l[W],Y=l[W+1],O=Q;O<Y;O++)q=c[O],b.push(q),R[q]=J,M&&(M[q]=a[O]);for(Q=m[W],Y=m[W+1],O=Q;O<Y;O++)if(q=p[O],R[q]===J){if(M){var ee=w(M[q],D[O]);A(ee,y)?R[q]=null:M[q]=ee}}else b.push(q),V[q]=J,S&&(S[q]=D[O]);if(M&&S)for(O=B[W];O<b.length;)q=b[O],R[q]===J?(C[O]=M[q],O++):V[q]===J?(C[O]=S[q],O++):b.splice(O,1)}return B[E]=b.length,i.createSparseMatrix({values:C,index:b,ptr:B,size:[g,E],datatype:h===i._datatype&&d===u._datatype?v:void 0})}}),cf="matAlgo10xSids",lf=["typed","DenseMatrix"],hf=G(cf,lf,e=>{var{typed:r,DenseMatrix:t}=e;return function(i,u,o,a){var c=i._values,l=i._index,f=i._ptr,h=i._size,D=i._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=h[0],m=h[1],s,d=o;typeof D=="string"&&(s=D,u=r.convert(u,s),d=r.find(o,[s,s]));for(var g=[],E=[],v=[],A=0;A<m;A++){for(var y=A+1,w=f[A],C=f[A+1],b=w;b<C;b++){var B=l[b];E[B]=c[b],v[B]=y}for(var M=0;M<p;M++)A===0&&(g[M]=[]),v[M]===y?g[M][A]=a?d(u,E[M]):d(E[M],u):g[M][A]=u}return new t({data:g,size:[p,m],datatype:s})}});function pf(e,r,t,n){return function(i){if(i>0||t.predictable){if(i<=0)return NaN;var u=i.toString(16),o=u.substring(0,15);return e*(u.length-o.length)+r(+("0x"+o))}return n(i.toNumber())}}var In="log10",Df=["typed","config","Complex"],mf=vt(16),df=G(In,Df,e=>{var{typed:r,config:t,Complex:n}=e;function i(o){return o.log().div(Math.LN10)}function u(o){return i(new n(o,0))}return r(In,{number:function(a){return a>=0||t.predictable?vt(a):u(a)},bigint:pf(mf,vt,t,u),Complex:i,BigNumber:function(a){return!a.isNegative()||t.predictable?a.log():u(a.toNumber())},"Array | Matrix":r.referToSelf(o=>a=>Ve(a,o))})}),gf="multiplyScalar",vf=["typed"],wf=G(gf,vf,e=>{var{typed:r}=e;return r("multiplyScalar",{"number, number":Ui,"Complex, Complex":function(n,i){return n.mul(i)},"BigNumber, BigNumber":function(n,i){return n.times(i)},"bigint, bigint":function(n,i){return n*i},"Fraction, Fraction":function(n,i){return n.mul(i)},"number | Fraction | BigNumber | Complex, Unit":(t,n)=>n.multiply(t),"Unit, number | Fraction | BigNumber | Complex | Unit":(t,n)=>t.multiply(n)})}),zn="multiply",yf=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],Ff=G(zn,yf,e=>{var{typed:r,matrix:t,addScalar:n,multiplyScalar:i,equalScalar:u,dot:o}=e,a=Hi({typed:r,equalScalar:u}),c=an({typed:r});function l(y,w){switch(y.length){case 1:switch(w.length){case 1:if(y[0]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(y[0]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+y[0]+") must match Matrix rows ("+w[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+w.length+" dimensions)")}break;case 2:switch(w.length){case 1:if(y[1]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+y[1]+") must match Vector length ("+w[0]+")");break;case 2:if(y[1]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+y[1]+") must match Matrix B rows ("+w[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+w.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+y.length+" dimensions)")}}function f(y,w,C){if(C===0)throw new Error("Cannot multiply two empty vectors");return o(y,w)}function h(y,w){if(w.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return D(y,w)}function D(y,w){var C=y._data,b=y._size,B=y._datatype||y.getDataType(),M=w._data,S=w._size,R=w._datatype||w.getDataType(),V=b[0],q=S[1],W,O=n,Q=i;B&&R&&B===R&&typeof B=="string"&&B!=="mixed"&&(W=B,O=r.find(n,[W,W]),Q=r.find(i,[W,W]));for(var Y=[],J=0;J<q;J++){for(var ee=Q(C[0],M[0][J]),oe=1;oe<V;oe++)ee=O(ee,Q(C[oe],M[oe][J]));Y[J]=ee}return y.createDenseMatrix({data:Y,size:[q],datatype:B===y._datatype&&R===w._datatype?W:void 0})}var p=r("_multiplyMatrixVector",{"DenseMatrix, any":s,"SparseMatrix, any":E}),m=r("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":d,"DenseMatrix, SparseMatrix":g,"SparseMatrix, DenseMatrix":v,"SparseMatrix, SparseMatrix":A});function s(y,w){var C=y._data,b=y._size,B=y._datatype||y.getDataType(),M=w._data,S=w._datatype||w.getDataType(),R=b[0],V=b[1],q,W=n,O=i;B&&S&&B===S&&typeof B=="string"&&B!=="mixed"&&(q=B,W=r.find(n,[q,q]),O=r.find(i,[q,q]));for(var Q=[],Y=0;Y<R;Y++){for(var J=C[Y],ee=O(J[0],M[0]),oe=1;oe<V;oe++)ee=W(ee,O(J[oe],M[oe]));Q[Y]=ee}return y.createDenseMatrix({data:Q,size:[R],datatype:B===y._datatype&&S===w._datatype?q:void 0})}function d(y,w){var C=y._data,b=y._size,B=y._datatype||y.getDataType(),M=w._data,S=w._size,R=w._datatype||w.getDataType(),V=b[0],q=b[1],W=S[1],O,Q=n,Y=i;B&&R&&B===R&&typeof B=="string"&&B!=="mixed"&&B!=="mixed"&&(O=B,Q=r.find(n,[O,O]),Y=r.find(i,[O,O]));for(var J=[],ee=0;ee<V;ee++){var oe=C[ee];J[ee]=[];for(var ie=0;ie<W;ie++){for(var fe=Y(oe[0],M[0][ie]),Ce=1;Ce<q;Ce++)fe=Q(fe,Y(oe[Ce],M[Ce][ie]));J[ee][ie]=fe}}return y.createDenseMatrix({data:J,size:[V,W],datatype:B===y._datatype&&R===w._datatype?O:void 0})}function g(y,w){var C=y._data,b=y._size,B=y._datatype||y.getDataType(),M=w._values,S=w._index,R=w._ptr,V=w._size,q=w._datatype||w._data===void 0?w._datatype:w.getDataType();if(!M)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var W=b[0],O=V[1],Q,Y=n,J=i,ee=u,oe=0;B&&q&&B===q&&typeof B=="string"&&B!=="mixed"&&(Q=B,Y=r.find(n,[Q,Q]),J=r.find(i,[Q,Q]),ee=r.find(u,[Q,Q]),oe=r.convert(0,Q));for(var ie=[],fe=[],Ce=[],be=w.createSparseMatrix({values:ie,index:fe,ptr:Ce,size:[W,O],datatype:B===y._datatype&&q===w._datatype?Q:void 0}),Ae=0;Ae<O;Ae++){Ce[Ae]=fe.length;var we=R[Ae],qe=R[Ae+1];if(qe>we)for(var ce=0,ae=0;ae<W;ae++){for(var Ge=ae+1,Te=void 0,le=we;le<qe;le++){var Me=S[le];ce!==Ge?(Te=J(C[ae][Me],M[le]),ce=Ge):Te=Y(Te,J(C[ae][Me],M[le]))}ce===Ge&&!ee(Te,oe)&&(fe.push(ae),ie.push(Te))}}return Ce[O]=fe.length,be}function E(y,w){var C=y._values,b=y._index,B=y._ptr,M=y._datatype||y._data===void 0?y._datatype:y.getDataType();if(!C)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var S=w._data,R=w._datatype||w.getDataType(),V=y._size[0],q=w._size[0],W=[],O=[],Q=[],Y,J=n,ee=i,oe=u,ie=0;M&&R&&M===R&&typeof M=="string"&&M!=="mixed"&&(Y=M,J=r.find(n,[Y,Y]),ee=r.find(i,[Y,Y]),oe=r.find(u,[Y,Y]),ie=r.convert(0,Y));var fe=[],Ce=[];Q[0]=0;for(var be=0;be<q;be++){var Ae=S[be];if(!oe(Ae,ie))for(var we=B[be],qe=B[be+1],ce=we;ce<qe;ce++){var ae=b[ce];Ce[ae]?fe[ae]=J(fe[ae],ee(Ae,C[ce])):(Ce[ae]=!0,O.push(ae),fe[ae]=ee(Ae,C[ce]))}}for(var Ge=O.length,Te=0;Te<Ge;Te++){var le=O[Te];W[Te]=fe[le]}return Q[1]=O.length,y.createSparseMatrix({values:W,index:O,ptr:Q,size:[V,1],datatype:M===y._datatype&&R===w._datatype?Y:void 0})}function v(y,w){var C=y._values,b=y._index,B=y._ptr,M=y._datatype||y._data===void 0?y._datatype:y.getDataType();if(!C)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var S=w._data,R=w._datatype||w.getDataType(),V=y._size[0],q=w._size[0],W=w._size[1],O,Q=n,Y=i,J=u,ee=0;M&&R&&M===R&&typeof M=="string"&&M!=="mixed"&&(O=M,Q=r.find(n,[O,O]),Y=r.find(i,[O,O]),J=r.find(u,[O,O]),ee=r.convert(0,O));for(var oe=[],ie=[],fe=[],Ce=y.createSparseMatrix({values:oe,index:ie,ptr:fe,size:[V,W],datatype:M===y._datatype&&R===w._datatype?O:void 0}),be=[],Ae=[],we=0;we<W;we++){fe[we]=ie.length;for(var qe=we+1,ce=0;ce<q;ce++){var ae=S[ce][we];if(!J(ae,ee))for(var Ge=B[ce],Te=B[ce+1],le=Ge;le<Te;le++){var Me=b[le];Ae[Me]!==qe?(Ae[Me]=qe,ie.push(Me),be[Me]=Y(ae,C[le])):be[Me]=Q(be[Me],Y(ae,C[le]))}}for(var Je=fe[we],ar=ie.length,sr=Je;sr<ar;sr++){var br=ie[sr];oe[sr]=be[br]}}return fe[W]=ie.length,Ce}function A(y,w){var C=y._values,b=y._index,B=y._ptr,M=y._datatype||y._data===void 0?y._datatype:y.getDataType(),S=w._values,R=w._index,V=w._ptr,q=w._datatype||w._data===void 0?w._datatype:w.getDataType(),W=y._size[0],O=w._size[1],Q=C&&S,Y,J=n,ee=i;M&&q&&M===q&&typeof M=="string"&&M!=="mixed"&&(Y=M,J=r.find(n,[Y,Y]),ee=r.find(i,[Y,Y]));for(var oe=Q?[]:void 0,ie=[],fe=[],Ce=y.createSparseMatrix({values:oe,index:ie,ptr:fe,size:[W,O],datatype:M===y._datatype&&q===w._datatype?Y:void 0}),be=Q?[]:void 0,Ae=[],we,qe,ce,ae,Ge,Te,le,Me,Je=0;Je<O;Je++){fe[Je]=ie.length;var ar=Je+1;for(Ge=V[Je],Te=V[Je+1],ae=Ge;ae<Te;ae++)if(Me=R[ae],Q)for(qe=B[Me],ce=B[Me+1],we=qe;we<ce;we++)le=b[we],Ae[le]!==ar?(Ae[le]=ar,ie.push(le),be[le]=ee(S[ae],C[we])):be[le]=J(be[le],ee(S[ae],C[we]));else for(qe=B[Me],ce=B[Me+1],we=qe;we<ce;we++)le=b[we],Ae[le]!==ar&&(Ae[le]=ar,ie.push(le));if(Q)for(var sr=fe[Je],br=ie.length,Cr=sr;Cr<br;Cr++){var qt=ie[Cr];oe[Cr]=be[qt]}}return fe[O]=ie.length,Ce}return r(zn,i,{"Array, Array":r.referTo("Matrix, Matrix",y=>(w,C)=>{l(ze(w),ze(C));var b=y(t(w),t(C));return ve(b)?b.valueOf():b}),"Matrix, Matrix":function(w,C){var b=w.size(),B=C.size();return l(b,B),b.length===1?B.length===1?f(w,C,b[0]):h(w,C):B.length===1?p(w,C):m(w,C)},"Matrix, Array":r.referTo("Matrix,Matrix",y=>(w,C)=>y(w,t(C))),"Array, Matrix":r.referToSelf(y=>(w,C)=>y(t(w,C.storage()),C)),"SparseMatrix, any":function(w,C){return a(w,C,i,!1)},"DenseMatrix, any":function(w,C){return c(w,C,i,!1)},"any, SparseMatrix":function(w,C){return a(C,w,i,!0)},"any, DenseMatrix":function(w,C){return c(C,w,i,!0)},"Array, any":function(w,C){return c(t(w),C,i,!1).valueOf()},"any, Array":function(w,C){return c(t(C),w,i,!0).valueOf()},"any, any":i,"any, any, ...any":r.referToSelf(y=>(w,C,b)=>{for(var B=y(w,C),M=0;M<b.length;M++)B=y(B,b[M]);return B})})}),Ef="matAlgo07xSSf",Af=["typed","SparseMatrix"],It=G(Ef,Af,e=>{var{typed:r,SparseMatrix:t}=e;return function(u,o,a){var c=u._size,l=u._datatype||u._data===void 0?u._datatype:u.getDataType(),f=o._size,h=o._datatype||o._data===void 0?o._datatype:o.getDataType();if(c.length!==f.length)throw new ne(c.length,f.length);if(c[0]!==f[0]||c[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+f+")");var D=c[0],p=c[1],m,s=0,d=a;typeof l=="string"&&l===h&&l!=="mixed"&&(m=l,s=r.convert(0,m),d=r.find(a,[m,m]));for(var g=[],E=[],v=new Array(p+1).fill(0),A=[],y=[],w=[],C=[],b=0;b<p;b++){var B=b+1,M=0;n(u,b,w,A,B),n(o,b,C,y,B);for(var S=0;S<D;S++){var R=w[S]===B?A[S]:s,V=C[S]===B?y[S]:s,q=d(R,V);q!==0&&q!==!1&&(E.push(S),g.push(q),M++)}v[b+1]=v[b]+M}return new t({values:g,index:E,ptr:v,size:[D,p],datatype:l===u._datatype&&h===o._datatype?m:void 0})};function n(i,u,o,a,c){for(var l=i._values,f=i._index,h=i._ptr,D=h[u],p=h[u+1];D<p;D++){var m=f[D];o[m]=c,a[m]=l[D]}}}),On="arg",bf=["typed"],Cf=G(On,bf,e=>{var{typed:r}=e;return r(On,{number:function(n){return Math.atan2(0,n)},BigNumber:function(n){return n.constructor.atan2(0,n)},Complex:function(n){return n.arg()},"Array | Matrix":r.referToSelf(t=>n=>Ve(n,t))})}),$n="conj",_f=["typed"],Bf=G($n,_f,e=>{var{typed:r}=e;return r($n,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.conjugate(),Unit:r.referToSelf(t=>n=>new n.constructor(t(n.toNumeric()),n.formatUnits())),"Array | Matrix":r.referToSelf(t=>n=>Ve(n,t))})}),Pn="concat",Nf=["typed","matrix","isInteger"],Mf=G(Pn,Nf,e=>{var{typed:r,matrix:t,isInteger:n}=e;return r(Pn,{"...Array | Matrix | number | BigNumber":function(u){var o,a=u.length,c=-1,l,f=!1,h=[];for(o=0;o<a;o++){var D=u[o];if(ve(D)&&(f=!0),de(D)||Ee(D)){if(o!==a-1)throw new Error("Dimension must be specified as last argument");if(l=c,c=D.valueOf(),!n(c))throw new TypeError("Integer number expected for dimension");if(c<0||o>0&&c>l)throw new Er(c,l+1)}else{var p=me(D).valueOf(),m=ze(p);if(h[o]=p,l=c,c=m.length-1,o>0&&c!==l)throw new ne(l+1,c+1)}}if(h.length===0)throw new SyntaxError("At least one matrix expected");for(var s=h.shift();h.length;)s=xi(s,h.shift(),c);return f?t(s):s},"...string":function(u){return u.join("")}})}),Un="getMatrixDataType",Sf=["typed"],xf=G(Un,Sf,e=>{var{typed:r}=e;return r(Un,{Array:function(n){return St(n,ir)},Matrix:function(n){return n.getDataType()}})}),qn="identity",Tf=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],If=G(qn,Tf,e=>{var{typed:r,config:t,matrix:n,BigNumber:i,DenseMatrix:u,SparseMatrix:o}=e;return r(qn,{"":function(){return t.matrix==="Matrix"?n([]):[]},string:function(f){return n(f)},"number | BigNumber":function(f){return c(f,f,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(f,h){return c(f,f,h)},"number | BigNumber, number | BigNumber":function(f,h){return c(f,h,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(f,h,D){return c(f,h,D)},Array:function(f){return a(f)},"Array, string":function(f,h){return a(f,h)},Matrix:function(f){return a(f.valueOf(),f.storage())},"Matrix, string":function(f,h){return a(f.valueOf(),h)}});function a(l,f){switch(l.length){case 0:return f?n(f):[];case 1:return c(l[0],l[0],f);case 2:return c(l[0],l[1],f);default:throw new Error("Vector containing two values expected")}}function c(l,f,h){var D=Ee(l)||Ee(f)?i:null;if(Ee(l)&&(l=l.toNumber()),Ee(f)&&(f=f.toNumber()),!ge(l)||l<1)throw new Error("Parameters in function identity must be positive integers");if(!ge(f)||f<1)throw new Error("Parameters in function identity must be positive integers");var p=D?new i(1):1,m=D?new D(0):0,s=[l,f];if(h){if(h==="sparse")return o.diagonal(s,p,0,m);if(h==="dense")return u.diagonal(s,p,0,m);throw new TypeError('Unknown matrix type "'.concat(h,'"'))}for(var d=dt([],s,m),g=l<f?l:f,E=0;E<g;E++)d[E][E]=p;return d}});function Zi(){throw new Error('No "bignumber" implementation available')}function zf(){throw new Error('No "fraction" implementation available')}function Wi(){throw new Error('No "matrix" implementation available')}var Rn="range",Of=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq","add","isPositive"],$f=G(Rn,Of,e=>{var{typed:r,config:t,matrix:n,bignumber:i,smaller:u,smallerEq:o,larger:a,largerEq:c,add:l,isPositive:f}=e;return r(Rn,{string:D,"string, boolean":D,number:function(d){throw new TypeError("Too few arguments to function range(): ".concat(d))},boolean:function(d){throw new TypeError("Unexpected type of argument 1 to function range(): ".concat(d,", number|bigint|BigNumber|Fraction"))},"number, number":function(d,g){return h(p(d,g,1,!1))},"number, number, number":function(d,g,E){return h(p(d,g,E,!1))},"number, number, boolean":function(d,g,E){return h(p(d,g,1,E))},"number, number, number, boolean":function(d,g,E,v){return h(p(d,g,E,v))},"bigint, bigint|number":function(d,g){return h(p(d,g,1n,!1))},"number, bigint":function(d,g){return h(p(BigInt(d),g,1n,!1))},"bigint, bigint|number, bigint|number":function(d,g,E){return h(p(d,g,BigInt(E),!1))},"number, bigint, bigint|number":function(d,g,E){return h(p(BigInt(d),g,BigInt(E),!1))},"bigint, bigint|number, boolean":function(d,g,E){return h(p(d,g,1n,E))},"number, bigint, boolean":function(d,g,E){return h(p(BigInt(d),g,1n,E))},"bigint, bigint|number, bigint|number, boolean":function(d,g,E,v){return h(p(d,g,BigInt(E),v))},"number, bigint, bigint|number, boolean":function(d,g,E,v){return h(p(BigInt(d),g,BigInt(E),v))},"BigNumber, BigNumber":function(d,g){var E=d.constructor;return h(p(d,g,new E(1),!1))},"BigNumber, BigNumber, BigNumber":function(d,g,E){return h(p(d,g,E,!1))},"BigNumber, BigNumber, boolean":function(d,g,E){var v=d.constructor;return h(p(d,g,new v(1),E))},"BigNumber, BigNumber, BigNumber, boolean":function(d,g,E,v){return h(p(d,g,E,v))},"Fraction, Fraction":function(d,g){return h(p(d,g,1,!1))},"Fraction, Fraction, Fraction":function(d,g,E){return h(p(d,g,E,!1))},"Fraction, Fraction, boolean":function(d,g,E){return h(p(d,g,1,E))},"Fraction, Fraction, Fraction, boolean":function(d,g,E,v){return h(p(d,g,E,v))},"Unit, Unit, Unit":function(d,g,E){return h(p(d,g,E,!1))},"Unit, Unit, Unit, boolean":function(d,g,E,v){return h(p(d,g,E,v))}});function h(s){return t.matrix==="Matrix"?n?n(s):Wi():s}function D(s,d){var g=m(s);if(!g)throw new SyntaxError('String "'+s+'" is no valid range');return t.number==="BigNumber"?(i===void 0&&Zi(),h(p(i(g.start),i(g.end),i(g.step)))):h(p(g.start,g.end,g.step,d))}function p(s,d,g,E){for(var v=[],A=f(g)?E?o:u:E?c:a,y=s;A(y,d);)v.push(y),y=l(y,g);return v}function m(s){var d=s.split(":"),g=d.map(function(v){return Number(v)}),E=g.some(function(v){return isNaN(v)});if(E)return null;switch(g.length){case 2:return{start:g[0],end:g[1],step:1};case 3:return{start:g[0],end:g[2],step:g[1]};default:return null}}}),Ln="size",Pf=["typed","config","?matrix"],Uf=G(Ln,Pf,e=>{var{typed:r,config:t,matrix:n}=e;return r(Ln,{Matrix:function(u){return u.create(u.size(),"number")},Array:ze,string:function(u){return t.matrix==="Array"?[u.length]:n([u.length],"dense","number")},"number | Complex | BigNumber | Unit | boolean | null":function(u){return t.matrix==="Array"?[]:n?n([],"dense","number"):Wi()}})}),Hn="subset",qf=["typed","matrix","zeros","add"],Rf=G(Hn,qf,e=>{var{typed:r,matrix:t,zeros:n,add:i}=e;return r(Hn,{"Matrix, Index":function(a,c){return Or(c)?t():(mt(a,c),a.subset(c))},"Array, Index":r.referTo("Matrix, Index",function(o){return function(a,c){var l=o(t(a),c);return c.isScalar()?l:l.valueOf()}}),"Object, Index":Hf,"string, Index":Lf,"Matrix, Index, any, any":function(a,c,l,f){return Or(c)?a:(mt(a,c),a.clone().subset(c,u(l,c),f))},"Array, Index, any, any":r.referTo("Matrix, Index, any, any",function(o){return function(a,c,l,f){var h=o(t(a),c,l,f);return h.isMatrix?h.valueOf():h}}),"Array, Index, any":r.referTo("Matrix, Index, any, any",function(o){return function(a,c,l){return o(t(a),c,l,void 0).valueOf()}}),"Matrix, Index, any":r.referTo("Matrix, Index, any, any",function(o){return function(a,c,l){return o(a,c,l,void 0)}}),"string, Index, string":Zn,"string, Index, string, string":Zn,"Object, Index, any":Zf});function u(o,a){if(typeof o=="string")throw new Error("can't boradcast a string");if(a._isScalar)return o;var c=a.size();if(c.every(l=>l>0))try{return i(o,n(c))}catch{return o}else return o}});function Lf(e,r){if(!Ct(r))throw new TypeError("Index expected");if(Or(r))return"";if(mt(Array.from(e),r),r.size().length!==1)throw new ne(r.size().length,1);var t=e.length;De(r.min()[0],t),De(r.max()[0],t);var n=r.dimension(0),i="";return n.forEach(function(u){i+=e.charAt(u)}),i}function Zn(e,r,t,n){if(!r||r.isIndex!==!0)throw new TypeError("Index expected");if(Or(r))return e;if(mt(Array.from(e),r),r.size().length!==1)throw new ne(r.size().length,1);if(n!==void 0){if(typeof n!="string"||n.length!==1)throw new TypeError("Single character expected as defaultValue")}else n=" ";var i=r.dimension(0),u=i.size()[0];if(u!==t.length)throw new ne(i.size()[0],t.length);var o=e.length;De(r.min()[0]),De(r.max()[0]);for(var a=[],c=0;c<o;c++)a[c]=e.charAt(c);if(i.forEach(function(h,D){a[h]=t.charAt(D[0])}),a.length>o)for(var l=o-1,f=a.length;l<f;l++)a[l]||(a[l]=n);return a.join("")}function Hf(e,r){if(!Or(r)){if(r.size().length!==1)throw new ne(r.size(),1);var t=r.dimension(0);if(typeof t!="string")throw new TypeError("String expected as index to retrieve an object property");return ti(e,t)}}function Zf(e,r,t){if(Or(r))return e;if(r.size().length!==1)throw new ne(r.size(),1);var n=r.dimension(0);if(typeof n!="string")throw new TypeError("String expected as index to retrieve an object property");var i=me(e);return ni(i,n,t),i}var Wn="zeros",Wf=["typed","config","matrix","BigNumber"],Vf=G(Wn,Wf,e=>{var{typed:r,config:t,matrix:n,BigNumber:i}=e;return r(Wn,{"":function(){return t.matrix==="Array"?u([]):u([],"default")},"...number | BigNumber | string":function(l){var f=l[l.length-1];if(typeof f=="string"){var h=l.pop();return u(l,h)}else return t.matrix==="Array"?u(l):u(l,"default")},Array:u,Matrix:function(l){var f=l.storage();return u(l.valueOf(),f)},"Array | Matrix, string":function(l,f){return u(l.valueOf(),f)}});function u(c,l){var f=o(c),h=f?new i(0):0;if(a(c),l){var D=n(l);return c.length>0?D.resize(c,h):D}else{var p=[];return c.length>0?dt(p,c,h):p}}function o(c){var l=!1;return c.forEach(function(f,h,D){Ee(f)&&(l=!0,D[h]=f.toNumber())}),l}function a(c){c.forEach(function(l){if(typeof l!="number"||!ge(l)||l<0)throw new Error("Parameters in function zeros must be positive integers")})}}),Gf="numeric",Jf=["number","?bignumber","?fraction"],Yf=G(Gf,Jf,e=>{var{number:r,bignumber:t,fraction:n}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},u={number:o=>r(o),BigNumber:t?o=>t(o):Zi,bigint:o=>BigInt(o),Fraction:n?o=>n(o):zf};return function(a){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",l=arguments.length>2?arguments[2]:void 0;if(l!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var f=ir(a);if(!(f in i))throw new TypeError("Cannot convert "+a+' of type "'+f+'"; valid input types are '+Object.keys(i).join(", "));if(!(c in u))throw new TypeError("Cannot convert "+a+' to type "'+c+'"; valid output types are '+Object.keys(u).join(", "));return c===f?a:u[c](a)}}),Vn="divideScalar",kf=["typed","numeric"],Xf=G(Vn,kf,e=>{var{typed:r,numeric:t}=e;return r(Vn,{"number, number":function(i,u){return i/u},"Complex, Complex":function(i,u){return i.div(u)},"BigNumber, BigNumber":function(i,u){return i.div(u)},"bigint, bigint":function(i,u){return i/u},"Fraction, Fraction":function(i,u){return i.div(u)},"Unit, number | Complex | Fraction | BigNumber | Unit":(n,i)=>n.divide(i),"number | Fraction | Complex | BigNumber, Unit":(n,i)=>i.divideInto(n)})}),Gn="pow",Qf=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],Kf=G(Gn,Qf,e=>{var{typed:r,config:t,identity:n,multiply:i,matrix:u,inv:o,number:a,fraction:c,Complex:l}=e;return r(Gn,{"number, number":f,"Complex, Complex":function(m,s){return m.pow(s)},"BigNumber, BigNumber":function(m,s){return s.isInteger()||m>=0||t.predictable?m.pow(s):new l(m.toNumber(),0).pow(s.toNumber(),0)},"bigint, bigint":(p,m)=>p**m,"Fraction, Fraction":function(m,s){var d=m.pow(s);if(d!=null)return d;if(t.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return f(m.valueOf(),s.valueOf())},"Array, number":h,"Array, BigNumber":function(m,s){return h(m,s.toNumber())},"Matrix, number":D,"Matrix, BigNumber":function(m,s){return D(m,s.toNumber())},"Unit, number | BigNumber":function(m,s){return m.pow(s)}});function f(p,m){if(t.predictable&&!ge(m)&&p<0)try{var s=c(m),d=a(s);if((m===d||Math.abs((m-d)/m)<1e-14)&&s.d%2n===1n)return(s.n%2n===0n?1:-1)*Math.pow(-p,m)}catch{}return t.predictable&&(p<-1&&m===1/0||p>-1&&p<0&&m===-1/0)?NaN:ge(m)||p>=0||t.predictable?Ri(p,m):p*p<1&&m===1/0||p*p>1&&m===-1/0?0:new l(p,0).pow(m,0)}function h(p,m){if(!ge(m))throw new TypeError("For A^b, b must be an integer (value is "+m+")");var s=ze(p);if(s.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+s.length+" dimensions)");if(s[0]!==s[1])throw new Error("For A^b, A must be square (size is "+s[0]+"x"+s[1]+")");if(m<0)try{return h(o(p),-m)}catch(E){throw E.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 "+m+")"):E}for(var d=n(s[0]).valueOf(),g=p;m>=1;)(m&1)===1&&(d=i(g,d)),m>>=1,g=i(g,g);return d}function D(p,m){return u(h(p.valueOf(),m))}}),Sr="Number of decimals in function round must be an integer",Jn="round",jf=["typed","config","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],ec=G(Jn,jf,e=>{var{typed:r,config:t,matrix:n,equalScalar:i,zeros:u,BigNumber:o,DenseMatrix:a}=e,c=Hi({typed:r,equalScalar:i}),l=Jr({typed:r,DenseMatrix:a}),f=an({typed:r});function h(D){return Math.abs(Vr(D).exponent)}return r(Jn,{number:function(p){var m=qr(p,h(t.relTol)),s=tr(p,m,t.relTol,t.absTol)?m:p;return qr(s)},"number, number":function(p,m){var s=h(t.relTol);if(m>=s)return qr(p,m);var d=qr(p,s),g=tr(p,d,t.relTol,t.absTol)?d:p;return qr(g,m)},"number, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError(Sr);return new o(p).toDecimalPlaces(m.toNumber())},Complex:function(p){return p.round()},"Complex, number":function(p,m){if(m%1)throw new TypeError(Sr);return p.round(m)},"Complex, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError(Sr);var s=m.toNumber();return p.round(s)},BigNumber:function(p){var m=new o(p).toDecimalPlaces(h(t.relTol)),s=gr(p,m,t.relTol,t.absTol)?m:p;return s.toDecimalPlaces(0)},"BigNumber, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError(Sr);var s=h(t.relTol);if(m>=s)return p.toDecimalPlaces(m.toNumber());var d=p.toDecimalPlaces(s),g=gr(p,d,t.relTol,t.absTol)?d:p;return g.toDecimalPlaces(m.toNumber())},bigint:D=>D,"bigint, number":(D,p)=>D,"bigint, BigNumber":(D,p)=>D,Fraction:function(p){return p.round()},"Fraction, number":function(p,m){if(m%1)throw new TypeError(Sr);return p.round(m)},"Fraction, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError(Sr);return p.round(m.toNumber())},"Unit, number, Unit":r.referToSelf(D=>function(p,m,s){var d=p.toNumeric(s);return s.multiply(D(d,m))}),"Unit, BigNumber, Unit":r.referToSelf(D=>(p,m,s)=>D(p,m.toNumber(),s)),"Array | Matrix, number | BigNumber, Unit":r.referToSelf(D=>(p,m,s)=>Ve(p,d=>D(d,m,s),!0)),"Array | Matrix | Unit, Unit":r.referToSelf(D=>(p,m)=>D(p,0,m)),"Array | Matrix":r.referToSelf(D=>p=>Ve(p,D,!0)),"SparseMatrix, number | BigNumber":r.referToSelf(D=>(p,m)=>c(p,m,D,!1)),"DenseMatrix, number | BigNumber":r.referToSelf(D=>(p,m)=>f(p,m,D,!1)),"Array, number | BigNumber":r.referToSelf(D=>(p,m)=>f(n(p),m,D,!1).valueOf()),"number | Complex | BigNumber | Fraction, SparseMatrix":r.referToSelf(D=>(p,m)=>i(p,0)?u(m.size(),m.storage()):l(m,p,D,!0)),"number | Complex | BigNumber | Fraction, DenseMatrix":r.referToSelf(D=>(p,m)=>i(p,0)?u(m.size(),m.storage()):f(m,p,D,!0)),"number | Complex | BigNumber | Fraction, Array":r.referToSelf(D=>(p,m)=>f(n(m),p,D,!0).valueOf())})}),yt="smaller",rc=["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],tc=G(yt,rc,e=>{var{typed:r,config:t,bignumber:n,matrix:i,DenseMatrix:u,concat:o,SparseMatrix:a}=e,c=Tt({typed:r}),l=It({typed:r,SparseMatrix:a}),f=Jr({typed:r,DenseMatrix:u}),h=Yr({typed:r,matrix:i,concat:o}),D=Gr({typed:r});function p(m,s){return m.lt(s)&&!gr(m,s,t.relTol,t.absTol)}return r(yt,nc({typed:r,config:t}),{"boolean, boolean":(m,s)=>m<s,"BigNumber, BigNumber":p,"bigint, bigint":(m,s)=>m<s,"Fraction, Fraction":(m,s)=>m.compare(s)===-1,"Fraction, BigNumber":function(s,d){return p(n(s),d)},"BigNumber, Fraction":function(s,d){return p(s,n(d))},"Complex, Complex":function(s,d){throw new TypeError("No ordering relation is defined for complex numbers")}},D,h({SS:l,DS:c,Ss:f}))}),nc=G(yt,["typed","config"],e=>{var{typed:r,config:t}=e;return r(yt,{"number, number":function(i,u){return i<u&&!tr(i,u,t.relTol,t.absTol)}})}),Ft="smallerEq",ic=["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],uc=G(Ft,ic,e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i,concat:u,SparseMatrix:o}=e,a=Tt({typed:r}),c=It({typed:r,SparseMatrix:o}),l=Jr({typed:r,DenseMatrix:i}),f=Yr({typed:r,matrix:n,concat:u}),h=Gr({typed:r});return r(Ft,oc({typed:r,config:t}),{"boolean, boolean":(D,p)=>D<=p,"BigNumber, BigNumber":function(p,m){return p.lte(m)||gr(p,m,t.relTol,t.absTol)},"bigint, bigint":(D,p)=>D<=p,"Fraction, Fraction":(D,p)=>D.compare(p)!==1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},h,f({SS:c,DS:a,Ss:l}))}),oc=G(Ft,["typed","config"],e=>{var{typed:r,config:t}=e;return r(Ft,{"number, number":function(i,u){return i<=u||tr(i,u,t.relTol,t.absTol)}})}),Et="larger",ac=["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],sc=G(Et,ac,e=>{var{typed:r,config:t,bignumber:n,matrix:i,DenseMatrix:u,concat:o,SparseMatrix:a}=e,c=Tt({typed:r}),l=It({typed:r,SparseMatrix:a}),f=Jr({typed:r,DenseMatrix:u}),h=Yr({typed:r,matrix:i,concat:o}),D=Gr({typed:r});function p(m,s){return m.gt(s)&&!gr(m,s,t.relTol,t.absTol)}return r(Et,fc({typed:r,config:t}),{"boolean, boolean":(m,s)=>m>s,"BigNumber, BigNumber":p,"bigint, bigint":(m,s)=>m>s,"Fraction, Fraction":(m,s)=>m.compare(s)===1,"Fraction, BigNumber":function(s,d){return p(n(s),d)},"BigNumber, Fraction":function(s,d){return p(s,n(d))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},D,h({SS:l,DS:c,Ss:f}))}),fc=G(Et,["typed","config"],e=>{var{typed:r,config:t}=e;return r(Et,{"number, number":function(i,u){return i>u&&!tr(i,u,t.relTol,t.absTol)}})}),At="largerEq",cc=["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],lc=G(At,cc,e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i,concat:u,SparseMatrix:o}=e,a=Tt({typed:r}),c=It({typed:r,SparseMatrix:o}),l=Jr({typed:r,DenseMatrix:i}),f=Yr({typed:r,matrix:n,concat:u}),h=Gr({typed:r});return r(At,hc({typed:r,config:t}),{"boolean, boolean":(D,p)=>D>=p,"BigNumber, BigNumber":function(p,m){return p.gte(m)||gr(p,m,t.relTol,t.absTol)},"bigint, bigint":function(p,m){return p>=m},"Fraction, Fraction":(D,p)=>D.compare(p)!==-1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},h,f({SS:c,DS:a,Ss:l}))}),hc=G(At,["typed","config"],e=>{var{typed:r,config:t}=e;return r(At,{"number, number":function(i,u){return i>=u||tr(i,u,t.relTol,t.absTol)}})}),pc="ImmutableDenseMatrix",Dc=["smaller","DenseMatrix"],mc=G(pc,Dc,e=>{var{smaller:r,DenseMatrix:t}=e;function n(i,u){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(u&&!Qe(u))throw new Error("Invalid datatype: "+u);if(ve(i)||ye(i)){var o=new t(i,u);this._data=o._data,this._size=o._size,this._datatype=o._datatype,this._min=null,this._max=null}else if(i&&ye(i.data)&&ye(i.size))this._data=i.data,this._size=i.size,this._datatype=i.datatype,this._min=typeof i.min<"u"?i.min:null,this._max=typeof i.max<"u"?i.max:null;else{if(i)throw new TypeError("Unsupported type of data ("+ir(i)+")");this._data=[],this._size=[0],this._datatype=u,this._min=null,this._max=null}}return n.prototype=new t,n.prototype.type="ImmutableDenseMatrix",n.prototype.isImmutableDenseMatrix=!0,n.prototype.subset=function(i){switch(arguments.length){case 1:{var u=t.prototype.subset.call(this,i);return ve(u)?new n({data:u._data,size:u._size,datatype:u._datatype}):u}case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},n.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},n.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},n.prototype.clone=function(){return new n({data:me(this._data),size:me(this._size),datatype:this._datatype})},n.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.fromJSON=function(i){return new n(i)},n.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},n.prototype.min=function(){if(this._min===null){var i=null;this.forEach(function(u){(i===null||r(u,i))&&(i=u)}),this._min=i!==null?i:void 0}return this._min},n.prototype.max=function(){if(this._max===null){var i=null;this.forEach(function(u){(i===null||r(i,u))&&(i=u)}),this._max=i!==null?i:void 0}return this._max},n},{isClass:!0}),dc="Index",gc=["ImmutableDenseMatrix","getMatrixDataType"],vc=G(dc,gc,e=>{var{ImmutableDenseMatrix:r,getMatrixDataType:t}=e;function n(u){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._sourceSize=[],this._isScalar=!0;for(var o=0,a=arguments.length;o<a;o++){var c=arguments[o],l=ye(c),f=ve(c),h=typeof c,D=null;if(ai(c))this._dimensions.push(c),this._isScalar=!1;else if(l||f){var p=void 0;t(c)==="boolean"?(l&&(p=i(Yn(c).valueOf())),f&&(p=i(Yn(c._data).valueOf())),D=c.valueOf().length):p=i(c.valueOf()),this._dimensions.push(p);var m=p.size();(m.length!==1||m[0]!==1||D!==null)&&(this._isScalar=!1)}else if(h==="number")this._dimensions.push(i([c]));else if(h==="bigint")this._dimensions.push(i([Number(c)]));else if(h==="string")this._dimensions.push(c);else throw new TypeError("Dimension must be an Array, Matrix, number, bigint, string, or Range");this._sourceSize.push(D)}}n.prototype.type="Index",n.prototype.isIndex=!0;function i(u){for(var o=0,a=u.length;o<a;o++)if(typeof u[o]!="number"||!ge(u[o]))throw new TypeError("Index parameters must be positive integer numbers");return new r(u)}return n.prototype.clone=function(){var u=new n;return u._dimensions=me(this._dimensions),u._isScalar=this._isScalar,u._sourceSize=this._sourceSize,u},n.create=function(u){var o=new n;return n.apply(o,u),o},n.prototype.size=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var c=this._dimensions[o];u[o]=typeof c=="string"?1:c.size()[0]}return u},n.prototype.max=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var c=this._dimensions[o];u[o]=typeof c=="string"?c:c.max()}return u},n.prototype.min=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var c=this._dimensions[o];u[o]=typeof c=="string"?c:c.min()}return u},n.prototype.forEach=function(u){for(var o=0,a=this._dimensions.length;o<a;o++)u(this._dimensions[o],o,this)},n.prototype.dimension=function(u){return typeof u!="number"?null:this._dimensions[u]||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 u=[],o=0,a=this._dimensions.length;o<a;o++){var c=this._dimensions[o];u.push(typeof c=="string"?c:c.toArray())}return u},n.prototype.valueOf=n.prototype.toArray,n.prototype.toString=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var c=this._dimensions[o];typeof c=="string"?u.push(JSON.stringify(c)):u.push(c.toString())}return"["+u.join(", ")+"]"},n.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},n.fromJSON=function(u){return n.create(u.dimensions)},n},{isClass:!0});function Yn(e){var r=[];return e.forEach((t,n)=>{t&&r.push(n)}),r}function wc(e){var r=0,t=1,n=Object.create(null),i=Object.create(null),u=0,o=function(c){var l=i[c];if(l&&(delete n[l],delete i[c],--r,t===l)){if(!r){u=0,t=1;return}for(;!Object.prototype.hasOwnProperty.call(n,++t););}};return e=Math.abs(e),{hit:function(c){var l=i[c],f=++u;if(n[f]=c,i[c]=f,!l)return++r,r<=e?void 0:(c=n[t],o(c),c);if(delete n[l],t===l)for(;!Object.prototype.hasOwnProperty.call(n,++t););},delete:o,clear:function(){r=u=0,t=1,n=Object.create(null),i=Object.create(null)}}}function zt(e){var{hasher:r,limit:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return t=t??Number.POSITIVE_INFINITY,r=r??JSON.stringify,function n(){typeof n.cache!="object"&&(n.cache={values:new Map,lru:wc(t||Number.POSITIVE_INFINITY)});for(var i=[],u=0;u<arguments.length;u++)i[u]=arguments[u];var o=r(i);if(n.cache.values.has(o))return n.cache.lru.hit(o),n.cache.values.get(o);var a=e.apply(e,i);return n.cache.values.set(o,a),n.cache.values.delete(n.cache.lru.hit(o)),a}}zt(function(e){return new e(1).exp()},{hasher:Ot});zt(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},{hasher:Ot});var Vi=zt(function(e){return e.acos(-1)},{hasher:Ot});zt(function(e){return Vi(e).times(2)},{hasher:Ot});function Ot(e){return e[0].precision}var kn="add",yc=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],Fc=G(kn,yc,e=>{var{typed:r,matrix:t,addScalar:n,equalScalar:i,DenseMatrix:u,SparseMatrix:o,concat:a}=e,c=of({typed:r}),l=ff({typed:r,equalScalar:i}),f=hf({typed:r,DenseMatrix:u}),h=Yr({typed:r,matrix:t,concat:a});return r(kn,{"any, any":n,"any, any, ...any":r.referToSelf(D=>(p,m,s)=>{for(var d=D(p,m),g=0;g<s.length;g++)d=D(d,s[g]);return d})},h({elop:n,DS:c,SS:l,Ss:f}))}),Xn="dot",Ec=["typed","addScalar","multiplyScalar","conj","size"],Ac=G(Xn,Ec,e=>{var{typed:r,addScalar:t,multiplyScalar:n,conj:i,size:u}=e;return r(Xn,{"Array | DenseMatrix, Array | DenseMatrix":a,"SparseMatrix, SparseMatrix":c});function o(f,h){var D=l(f),p=l(h),m,s;if(D.length===1)m=D[0];else if(D.length===2&&D[1]===1)m=D[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+D.join(", ")+")");if(p.length===1)s=p[0];else if(p.length===2&&p[1]===1)s=p[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+p.join(", ")+")");if(m!==s)throw new RangeError("Vectors must have equal length ("+m+" != "+s+")");if(m===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return m}function a(f,h){var D=o(f,h),p=ve(f)?f._data:f,m=ve(f)?f._datatype||f.getDataType():void 0,s=ve(h)?h._data:h,d=ve(h)?h._datatype||h.getDataType():void 0,g=l(f).length===2,E=l(h).length===2,v=t,A=n;if(m&&d&&m===d&&typeof m=="string"&&m!=="mixed"){var y=m;v=r.find(t,[y,y]),A=r.find(n,[y,y])}if(!g&&!E){for(var w=A(i(p[0]),s[0]),C=1;C<D;C++)w=v(w,A(i(p[C]),s[C]));return w}if(!g&&E){for(var b=A(i(p[0]),s[0][0]),B=1;B<D;B++)b=v(b,A(i(p[B]),s[B][0]));return b}if(g&&!E){for(var M=A(i(p[0][0]),s[0]),S=1;S<D;S++)M=v(M,A(i(p[S][0]),s[S]));return M}if(g&&E){for(var R=A(i(p[0][0]),s[0][0]),V=1;V<D;V++)R=v(R,A(i(p[V][0]),s[V][0]));return R}}function c(f,h){o(f,h);for(var D=f._index,p=f._values,m=h._index,s=h._values,d=0,g=t,E=n,v=0,A=0;v<D.length&&A<m.length;){var y=D[v],w=m[A];if(y<w){v++;continue}if(y>w){A++;continue}y===w&&(d=g(d,E(p[v],s[A])),v++,A++)}return d}function l(f){return ve(f)?f.size():u(f)}}),Qn="index",bc=["typed","Index"],Cc=G(Qn,bc,e=>{var{typed:r,Index:t}=e;return r(Qn,{"...number | string | BigNumber | Range | Array | Matrix":function(i){var u=i.map(function(a){return Ee(a)?a.toNumber():ye(a)||ve(a)?a.map(function(c){return Ee(c)?c.toNumber():c}):a}),o=new t;return t.apply(o,u),o}})}),Kn="det",_c=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],Bc=G(Kn,_c,e=>{var{typed:r,matrix:t,subtractScalar:n,multiply:i,divideScalar:u,isZero:o,unaryMinus:a}=e;return r(Kn,{any:function(f){return me(f)},"Array | Matrix":function(f){var h;switch(ve(f)?h=f.size():Array.isArray(f)?(f=t(f),h=f.size()):h=[],h.length){case 0:return me(f);case 1:if(h[0]===1)return me(f.valueOf()[0]);if(h[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+Be(h)+")");case 2:{var D=h[0],p=h[1];if(D===p)return c(f.clone().valueOf(),D);if(p===0)return 1;throw new RangeError("Matrix must be square (size: "+Be(h)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Be(h)+")")}}});function c(l,f,h){if(f===1)return me(l[0][0]);if(f===2)return n(i(l[0][0],l[1][1]),i(l[1][0],l[0][1]));for(var D=!1,p=new Array(f).fill(0).map((C,b)=>b),m=0;m<f;m++){var s=p[m];if(o(l[s][m])){var d=void 0;for(d=m+1;d<f;d++)if(!o(l[p[d]][m])){s=p[d],p[d]=p[m],p[m]=s,D=!D;break}if(d===f)return l[s][m]}for(var g=l[s][m],E=m===0?1:l[p[m-1]][m-1],v=m+1;v<f;v++)for(var A=p[v],y=m+1;y<f;y++)l[A][y]=u(n(i(l[A][y],g),i(l[A][m],l[s][y])),E)}var w=l[p[f-1]][f-1];return D?a(w):w}}),jn="inv",Nc=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],Mc=G(jn,Nc,e=>{var{typed:r,matrix:t,divideScalar:n,addScalar:i,multiply:u,unaryMinus:o,det:a,identity:c,abs:l}=e;return r(jn,{"Array | Matrix":function(D){var p=ve(D)?D.size():ze(D);switch(p.length){case 1:if(p[0]===1)return ve(D)?t([n(1,D.valueOf()[0])]):[n(1,D[0])];throw new RangeError("Matrix must be square (size: "+Be(p)+")");case 2:{var m=p[0],s=p[1];if(m===s)return ve(D)?t(f(D.valueOf(),m,s),D.storage()):f(D,m,s);throw new RangeError("Matrix must be square (size: "+Be(p)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Be(p)+")")}},any:function(D){return n(1,D)}});function f(h,D,p){var m,s,d,g,E;if(D===1){if(g=h[0][0],g===0)throw Error("Cannot calculate inverse, determinant is zero");return[[n(1,g)]]}else if(D===2){var v=a(h);if(v===0)throw Error("Cannot calculate inverse, determinant is zero");return[[n(h[1][1],v),n(o(h[0][1]),v)],[n(o(h[1][0]),v),n(h[0][0],v)]]}else{var A=h.concat();for(m=0;m<D;m++)A[m]=A[m].concat();for(var y=c(D).valueOf(),w=0;w<p;w++){var C=l(A[w][w]),b=w;for(m=w+1;m<D;)l(A[m][w])>C&&(C=l(A[m][w]),b=m),m++;if(C===0)throw Error("Cannot calculate inverse, determinant is zero");m=b,m!==w&&(E=A[w],A[w]=A[m],A[m]=E,E=y[w],y[w]=y[m],y[m]=E);var B=A[w],M=y[w];for(m=0;m<D;m++){var S=A[m],R=y[m];if(m!==w){if(S[w]!==0){for(d=n(o(S[w]),B[w]),s=w;s<p;s++)S[s]=i(S[s],u(d,B[s]));for(s=0;s<p;s++)R[s]=i(R[s],u(d,M[s]))}}else{for(d=B[w],s=w;s<p;s++)S[s]=n(S[s],d);for(s=0;s<p;s++)R[s]=n(R[s],d)}}}return y}}}),Sc=xc("pi",["config","?BigNumber"],e=>{var{config:r,BigNumber:t}=e;return r.number==="BigNumber"?Vi(t):as});function xc(e,r,t){return G(e,r,t,{recreateOnConfigChange:!0})}var $r=Ba({config:Pe}),$t=Ta({}),Gi=qa({}),sn=Ha({}),or=is({Matrix:sn}),Rr=Sc({BigNumber:$r,config:Pe}),te=So({BigNumber:$r,Complex:$t,DenseMatrix:or,Fraction:Gi}),bt=Us({typed:te}),Pt=Rs({typed:te}),Kt=Cf({typed:te}),it=Ms({Complex:$t,typed:te}),Tc=Bf({typed:te}),kr=ms({config:Pe,typed:te}),Ic=xf({typed:te}),zc=os({typed:te}),Oc=cs({config:Pe,typed:te}),$c=hs({equalScalar:kr,typed:te}),Ji=df({Complex:$t,config:Pe,typed:te}),Yi=wf({typed:te}),ki=As({typed:te}),Ar=vs({Matrix:sn,equalScalar:kr,typed:te}),Pc=Hs({typed:te}),Ut=_s({BigNumber:$r,typed:te}),Ue=zs({DenseMatrix:or,Matrix:sn,SparseMatrix:Ar,typed:te}),Xi=Vf({BigNumber:$r,config:Pe,matrix:Ue,typed:te}),Xr=Mf({isInteger:zc,matrix:Ue,typed:te}),Qi=Ts({Fraction:Gi,typed:te}),Ki=If({BigNumber:$r,DenseMatrix:or,SparseMatrix:Ar,config:Pe,matrix:Ue,typed:te}),Uc=lc({DenseMatrix:or,SparseMatrix:Ar,concat:Xr,config:Pe,matrix:Ue,typed:te}),qc=Yf({bignumber:Ut,fraction:Qi,number:ki}),jt=ec({BigNumber:$r,DenseMatrix:or,config:Pe,equalScalar:kr,matrix:Ue,typed:te,zeros:Xi}),Rc=Uf({matrix:Ue,config:Pe,typed:te}),ji=tc({DenseMatrix:or,SparseMatrix:Ar,bignumber:Ut,concat:Xr,config:Pe,matrix:Ue,typed:te}),eu=$s({typed:te}),Wr=Fc({DenseMatrix:or,SparseMatrix:Ar,addScalar:Pt,concat:Xr,equalScalar:kr,matrix:Ue,typed:te}),ru=Xf({numeric:qc,typed:te}),Lc=mc({DenseMatrix:or,smaller:ji}),Hc=vc({ImmutableDenseMatrix:Lc,getMatrixDataType:Ic}),Zc=sc({DenseMatrix:or,SparseMatrix:Ar,bignumber:Ut,concat:Xr,config:Pe,matrix:Ue,typed:te}),Wc=uc({DenseMatrix:or,SparseMatrix:Ar,concat:Xr,config:Pe,matrix:Ue,typed:te}),ut=Rf({add:Wr,matrix:Ue,typed:te,zeros:Xi}),Vc=Ac({addScalar:Pt,conj:Tc,multiplyScalar:Yi,size:Rc,typed:te}),ot=Cc({Index:Hc,typed:te}),Fr=Ff({addScalar:Pt,dot:Vc,equalScalar:kr,matrix:Ue,multiplyScalar:Yi,typed:te}),at=$f({bignumber:Ut,matrix:Ue,add:Wr,config:Pe,isPositive:Oc,larger:Zc,largerEq:Uc,smaller:ji,smallerEq:Wc,typed:te}),Gc=Bc({divideScalar:ru,isZero:$c,matrix:Ue,multiply:Fr,subtractScalar:Pc,typed:te,unaryMinus:eu}),Jc=Mc({abs:bt,addScalar:Pt,det:Gc,divideScalar:ru,identity:Ki,matrix:Ue,multiply:Fr,typed:te,unaryMinus:eu}),tu=Kf({Complex:$t,config:Pe,fraction:Qi,identity:Ki,inv:Jc,matrix:Ue,multiply:Fr,number:ki,typed:te});const Yc=["Hz","kHz","MHz","GHz"],en=299792458,lr={Hz:1,kHz:1e3,MHz:1e6,GHz:1e9,THz:1e12},ei={m:1,cm:.01,mm:.001,um:1e-6,nm:1e-9};class nu{_unit="Hz";set unit(r){if(typeof r!="string")throw new Error(`Unknown frequency unit: ${r}`);const t=this._unit;let n;switch(r.toLowerCase()){case"hz":n="Hz";break;case"khz":n="kHz";break;case"mhz":n="MHz";break;case"ghz":n="GHz";break;default:throw new Error(`Unknown frequency unit: ${r}`)}if(n!==t&&this.f_scaled&&this.f_scaled.length>0){const i=lr[t],u=lr[n];if(i&&u)this.f_scaled=this.f_scaled.map(o=>o*i/u);else throw new Error(`Could not find frequency multipliers (old: ${i}, new: ${u}) for unit conversion`)}this._unit=n}get unit(){return this._unit}_f_scaled=[];set f_scaled(r){if(!Array.isArray(r))throw new Error("Frequency value must be an array");for(const t of r){if(typeof t!="number")throw new Error(`Frequency value must be an array of numbers, but received: ${t}`);if(t<0)throw new Error(`Frequency values cannot be negative, but received: ${t}`)}this._f_scaled=r}get f_scaled(){return this._f_scaled}_getFrequencyInTargetUnit(r){if(!this.f_scaled||this.f_scaled.length===0)return[];const t=lr[this.unit];if(!t)throw new Error(`Multiplier for current unit ${this.unit} not found.`);const n=lr[r];if(!n)throw new Error(`Multiplier for target unit ${r} not found.`);return this.f_scaled.map(i=>i*t/n)}_setFrequencyFromTargetUnit(r,t){if(!r){this.f_scaled=[];return}if(r.length===0){this.f_scaled=[];return}const n=lr[t];if(!n)throw new Error(`Multiplier for source unit ${t} not found.`);const i=lr[this.unit];if(!i)throw new Error(`Multiplier for current internal unit ${this.unit} not found.`);const u=r.map(o=>o*n/i);this.f_scaled=u}get f_Hz(){return this._getFrequencyInTargetUnit("Hz")}set f_Hz(r){this._setFrequencyFromTargetUnit(r,"Hz")}get f_kHz(){return this._getFrequencyInTargetUnit("kHz")}set f_kHz(r){this._setFrequencyFromTargetUnit(r,"kHz")}get f_MHz(){return this._getFrequencyInTargetUnit("MHz")}set f_MHz(r){this._setFrequencyFromTargetUnit(r,"MHz")}get f_GHz(){return this._getFrequencyInTargetUnit("GHz")}set f_GHz(r){this._setFrequencyFromTargetUnit(r,"GHz")}get f_THz(){return this._getFrequencyInTargetUnit("THz")}set f_THz(r){this._setFrequencyFromTargetUnit(r,"THz")}_getWavelengthInTargetUnit(r){if(!this.f_scaled||this.f_scaled.length===0)return[];const t=lr[this.unit];if(!t)throw new Error(`Frequency multiplier for current unit ${this.unit} not found.`);const n=ei[r];if(!n)throw new Error(`Wavelength multiplier to meters for target wavelength unit ${r} not found.`);return this.f_scaled.map(i=>{const u=i*t;return u===0?1/0:en/u/n})}_setWavelengthFromTargetUnit(r,t){if(!r){this.f_scaled=[];return}if(r.length===0){this.f_scaled=[];return}const n=ei[t];if(!n)throw new Error(`Wavelength multiplier to meters for source unit ${t} not found.`);const i=lr[this.unit];if(!i)throw new Error(`Frequency multiplier for current unit ${this.unit} not found.`);const u=r.map(o=>{const a=o*n;if(a===0)throw new Error("Cannot convert zero wavelength to frequency.");return en/a/i});this.f_scaled=u}get wavelength_m(){return this._getWavelengthInTargetUnit("m")}set wavelength_m(r){this._setWavelengthFromTargetUnit(r,"m")}get wavelength_cm(){return this._getWavelengthInTargetUnit("cm")}set wavelength_cm(r){this._setWavelengthFromTargetUnit(r,"cm")}get wavelength_mm(){return this._getWavelengthInTargetUnit("mm")}set wavelength_mm(r){this._setWavelengthFromTargetUnit(r,"mm")}get wavelength_um(){return this._getWavelengthInTargetUnit("um")}set wavelength_um(r){this._setWavelengthFromTargetUnit(r,"um")}get wavelength_nm(){return this._getWavelengthInTargetUnit("nm")}set wavelength_nm(r){this._setWavelengthFromTargetUnit(r,"nm")}}const kc=["RI","MA","DB"],Xc=["S","Y","Z","G","H"];class Qc{comments=[];_format;set format(r){if(r==null){this._format=void 0;return}if(typeof r!="string")throw new Error(`Unknown Touchstone format: ${r}`);switch(r.toLowerCase()){case"ma":this._format="MA";break;case"db":this._format="DB";break;case"ri":this._format="RI";break;default:throw new Error(`Unknown Touchstone format: ${r}`)}}get format(){return this._format}_parameter;set parameter(r){if(r==null){this._parameter=void 0;return}if(typeof r!="string")throw new Error(`Unknown Touchstone parameter: ${r}`);switch(r.toLowerCase()){case"s":this._parameter="S";break;case"y":this._parameter="Y";break;case"z":this._parameter="Z";break;case"g":this._parameter="G";break;case"h":this._parameter="H";break;default:throw new Error(`Unknown Touchstone parameter: ${r}`)}}get parameter(){return this._parameter}_impedance=50;set impedance(r){if(typeof r=="number"){this._impedance=r;return}if(!Array.isArray(r)||r.length===0)throw new Error(`Unknown Touchstone impedance: ${r}`);for(const t of r)if(typeof t!="number")throw new Error(`Unknown Touchstone impedance: ${r}`);this._impedance=r}get impedance(){return this._impedance}_nports;set nports(r){if(r==null){this._nports=void 0;return}if(typeof r!="number")throw new Error(`Unknown ports number: ${r}`);if(!Number.isInteger(r))throw new Error(`Unknown ports number: ${r}`);if(r<1)throw new Error(`Unknown ports number: ${r}`);this._nports=r}get nports(){return this._nports}frequency;_matrix;set matrix(r){if(r==null){this._matrix=void 0;return}this._matrix=r}get matrix(){return this._matrix}readContent(r,t){this.nports=t;const n=r.split(`
|
|
18
|
-
`).map(f=>f.trim()).filter(f=>f!=="");this.comments=n.filter(f=>f.startsWith("!")).map(f=>f.slice(1).trim()),this.frequency=new nu;const i=n.filter(f=>f.startsWith("#"));if(i.length===0)throw new Error('Unable to find the option line starting with "#"');if(i.length>1)throw new Error(`Only one option line starting with "#" is supported, but found ${i.length} lines`);const u=i[0].slice(1).trim().split(/\s+/);if(this.frequency.unit=u[0],this.parameter=u[1],this.format=u[2],u.length>=4){if(u[3].toLowerCase()!=="r")throw new Error(`Unknown Touchstone impedance: ${u.slice(3).join(" ")}`);const f=u.slice(4).map(h=>parseFloat(h));if(f.length===0||f.some(Number.isNaN))throw new Error(`Unknown Touchstone impedance: ${u.slice(3).join(" ")}`);if(f.length===1)this.impedance=f[0];else if(f.length===this.nports)this.impedance=f;else throw new Error(`${this.nports}-ports network, but find ${f.length} impedances: [${f}]`)}const a=n.filter(f=>!f.startsWith("!")&&!f.startsWith("#")).map(f=>{const h=f.indexOf("!");return h!==-1?f.substring(0,h).trim():f.trim()}).join(" ").split(/\s+/).map(f=>parseFloat(f)),c=2*Math.pow(this.nports,2)+1;if(a.length%c!==0)throw new Error(`Touchstone invalid data number: ${a.length}, which should be multiple of ${c}`);const l=a.length/c;this.frequency.f_scaled=ut(a,ot(Fr(at(0,l),c))),this.matrix=new Array(t);for(let f=0;f<t;f++){this.matrix[f]=new Array(t);for(let h=0;h<t;h++)this.matrix[f][h]=new Array(l)}for(let f=0;f<t;f++)for(let h=0;h<t;h++){const D=ut(a,ot(Wr(Fr(at(0,l),c),(f*t+h)*2+1))),p=ut(a,ot(Wr(Fr(at(0,l),c),(f*t+h)*2+2)));for(let m=0;m<l;m++){let s;switch(this.format){case"RI":s=it(D[m],p[m]);break;case"MA":s=it({r:D[m],phi:p[m]/180*Rr});break;case"DB":s=it({r:tu(10,D[m]/20),phi:p[m]/180*Rr});break;default:throw new Error(`Unknown Touchstone format: ${this.format}`)}t===2?this.matrix[h][f][m]=s:this.matrix[f][h][m]=s}}}validate(){if(!this.nports)throw new Error("Number of ports (nports) is not defined");if(!this.frequency)throw new Error("Frequency object is not defined");if(this.frequency.f_scaled.length===0)throw new Error("Frequency points array is empty");if(!this.parameter)throw new Error("Network parameter type is not defined");if(!this.format)throw new Error("Data format (RI/MA/DB) is not defined");if(!this.matrix)throw new Error("Network parameter matrix is not defined");const r=this.frequency.f_scaled.length;if(this.matrix.length!==this.nports)throw new Error(`Touchstone matrix has ${this.matrix.length} rows, but expected ${this.nports}`);for(let t=0;t<this.nports;t++){if(this.matrix[t].length!==this.nports)throw new Error(`Touchstone matrix at row #${t} has ${this.matrix[t].length} columns, but expected ${this.nports}`);for(let n=0;n<this.nports;n++)if(this.matrix[t][n].length!==r)throw new Error(`Touchstone matrix at row #${t} column #${n} has ${this.matrix[t][n].length} points, but expected ${r}`)}}writeContent(){this.validate();const r=this.frequency.f_scaled.length,t=[];this.comments.length>0&&t.push(...this.comments.map(i=>`! ${i}`));let n=`# ${this.frequency.unit} ${this.parameter} ${this.format}`;Array.isArray(this.impedance)?n+=` R ${this.impedance.join(" ")}`:n+=` R ${this.impedance}`,t.push(n);for(let i=0;i<r;i++){const u=[this.frequency.f_scaled[i].toString()];for(let o=0;o<this.nports;o++)for(let a=0;a<this.nports;a++){const c=this.nports===2?this.matrix[a][o][i]:this.matrix[o][a][i];let l,f;switch(this.format){case"RI":l=c.re,f=c.im;break;case"MA":l=bt(c),f=Kt(c)/Rr*180;break;case"DB":l=20*Ji(bt(c)),f=Kt(c)/Rr*180;break;default:throw new Error(`Unknown Touchstone format: ${this.format}`)}u.push(jt(l,12).toString(),jt(f,12).toString())}t.push(u.join(" "))}return t.push(""),t.join(`
|
|
19
|
-
`)}}exports.Frequency=nu;exports.FrequencyUnits=Yc;exports.SPEED_OF_LIGHT=en;exports.Touchstone=Qc;exports.TouchstoneFormats=kc;exports.TouchstoneParameters=Xc;exports.abs=bt;exports.add=Wr;exports.arg=Kt;exports.complex=it;exports.index=ot;exports.log10=Ji;exports.multiply=Fr;exports.pi=Rr;exports.pow=tu;exports.range=at;exports.round=jt;exports.subset=ut;
|
|
8
|
+
`);return Object.freeze(ti)};ct(qe,ti,{MATRIX_OPTIONS:Eo,NUMBER_OPTIONS:Ao});function hn(){return!0}function Ye(){return!1}function Br(){}const pn="Argument is not a typed-function.";function fi(){function e(E){return typeof E=="object"&&E!==null&&E.constructor===Object}const r=[{name:"number",test:function(E){return typeof E=="number"}},{name:"string",test:function(E){return typeof E=="string"}},{name:"boolean",test:function(E){return typeof E=="boolean"}},{name:"Function",test:function(E){return typeof E=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(E){return E instanceof Date}},{name:"RegExp",test:function(E){return E instanceof RegExp}},{name:"Object",test:e},{name:"null",test:function(E){return E===null}},{name:"undefined",test:function(E){return E===void 0}}],t={name:"any",test:hn,isAny:!0};let n,i,u=0,o={createCount:0};function a(E){const C=n.get(E);if(C)return C;let N='Unknown type "'+E+'"';const T=E.toLowerCase();let P;for(P of i)if(P.toLowerCase()===T){N+='. Did you mean "'+P+'" ?';break}throw new TypeError(N)}function s(E){let C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const N=C?a(C).index:i.length,T=[];for(let I=0;I<E.length;++I){if(!E[I]||typeof E[I].name!="string"||typeof E[I].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const Z=E[I].name;if(n.has(Z))throw new TypeError('Duplicate type name "'+Z+'"');T.push(Z),n.set(Z,{name:Z,test:E[I].test,isAny:E[I].isAny,index:N+I,conversionsTo:[]})}const P=i.slice(N);i=i.slice(0,N).concat(T).concat(P);for(let I=N+T.length;I<i.length;++I)n.get(i[I]).index=I}function f(){n=new Map,i=[],u=0,s([t],!1)}f(),s(r);function m(){let E;for(E of i)n.get(E).conversionsTo=[];u=0}function l(E){const C=i.filter(N=>{const T=n.get(N);return!T.isAny&&T.test(E)});return C.length?C:["any"]}function h(E){return E&&typeof E=="function"&&"_typedFunctionData"in E}function p(E,C,N){if(!h(E))throw new TypeError(pn);const T=N&&N.exact,P=Array.isArray(C)?C.join(","):C,I=A(P),Z=d(I);if(!T||Z in E.signatures){const fe=E._typedFunctionData.signatureMap.get(Z);if(fe)return fe}const U=I.length;let W;if(T){W=[];let fe;for(fe in E.signatures)W.push(E._typedFunctionData.signatureMap.get(fe))}else W=E._typedFunctionData.signatures;for(let fe=0;fe<U;++fe){const De=I[fe],_e=[];let He;for(He of W){const Le=b(He.params,fe);if(!(!Le||De.restParam&&!Le.restParam)){if(!Le.hasAny){const Ke=g(Le);if(De.types.some(je=>!Ke.has(je.name)))continue}_e.push(He)}}if(W=_e,W.length===0)break}let q;for(q of W)if(q.params.length<=U)return q;throw new TypeError("Signature not found (signature: "+(E.name||"unnamed")+"("+d(I,", ")+"))")}function D(E,C,N){return p(E,C,N).implementation}function c(E,C){const N=a(C);if(N.test(E))return E;const T=N.conversionsTo;if(T.length===0)throw new Error("There are no conversions to "+C+" defined.");for(let P=0;P<T.length;P++)if(a(T[P].from).test(E))return T[P].convert(E);throw new Error("Cannot convert "+E+" to "+C)}function d(E){let C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return E.map(N=>N.name).join(C)}function v(E){const C=E.indexOf("...")===0,T=(C?E.length>3?E.slice(3):"any":E).split("|").map(U=>a(U.trim()));let P=!1,I=C?"...":"";return{types:T.map(function(U){return P=U.isAny||P,I+=U.name+"|",{name:U.name,typeIndex:U.index,test:U.test,isAny:U.isAny,conversion:null,conversionIndex:-1}}),name:I.slice(0,-1),hasAny:P,hasConversion:!1,restParam:C}}function y(E){const C=E.types.map(Z=>Z.name),N=Q(C);let T=E.hasAny,P=E.name;const I=N.map(function(Z){const U=a(Z.from);return T=U.isAny||T,P+="|"+Z.from,{name:Z.from,typeIndex:U.index,test:U.test,isAny:U.isAny,conversion:Z,conversionIndex:Z.index}});return{types:E.types.concat(I),name:P,hasAny:T,hasConversion:I.length>0,restParam:E.restParam}}function g(E){return E.typeSet||(E.typeSet=new Set,E.types.forEach(C=>E.typeSet.add(C.name))),E.typeSet}function A(E){const C=[];if(typeof E!="string")throw new TypeError("Signatures must be strings");const N=E.trim();if(N==="")return C;const T=N.split(",");for(let P=0;P<T.length;++P){const I=v(T[P].trim());if(I.restParam&&P!==T.length-1)throw new SyntaxError('Unexpected rest parameter "'+T[P]+'": only allowed for the last parameter');if(I.types.length===0)return null;C.push(I)}return C}function F(E){const C=le(E);return C?C.restParam:!1}function w(E){if(!E||E.types.length===0)return hn;if(E.types.length===1)return a(E.types[0].name).test;if(E.types.length===2){const C=a(E.types[0].name).test,N=a(E.types[1].name).test;return function(P){return C(P)||N(P)}}else{const C=E.types.map(function(N){return a(N.name).test});return function(T){for(let P=0;P<C.length;P++)if(C[P](T))return!0;return!1}}}function _(E){let C,N,T;if(F(E)){C=Re(E).map(w);const P=C.length,I=w(le(E)),Z=function(U){for(let W=P;W<U.length;W++)if(!I(U[W]))return!1;return!0};return function(W){for(let q=0;q<C.length;q++)if(!C[q](W[q]))return!1;return Z(W)&&W.length>=P+1}}else return E.length===0?function(I){return I.length===0}:E.length===1?(N=w(E[0]),function(I){return N(I[0])&&I.length===1}):E.length===2?(N=w(E[0]),T=w(E[1]),function(I){return N(I[0])&&T(I[1])&&I.length===2}):(C=E.map(w),function(I){for(let Z=0;Z<C.length;Z++)if(!C[Z](I[Z]))return!1;return I.length===C.length})}function b(E,C){return C<E.length?E[C]:F(E)?le(E):null}function B(E,C){const N=b(E,C);return N?g(N):new Set}function S(E){return E.conversion===null||E.conversion===void 0}function x(E,C){const N=new Set;return E.forEach(T=>{const P=B(T.params,C);let I;for(I of P)N.add(I)}),N.has("any")?["any"]:Array.from(N)}function O(E,C,N){let T,P;const I=E||"unnamed";let Z=N,U;for(U=0;U<C.length;U++){const De=[];if(Z.forEach(_e=>{const He=b(_e.params,U),Le=w(He);(U<_e.params.length||F(_e.params))&&Le(C[U])&&De.push(_e)}),De.length===0){if(P=x(Z,U),P.length>0){const _e=l(C[U]);return T=new TypeError("Unexpected type of argument in function "+I+" (expected: "+P.join(" or ")+", actual: "+_e.join(" | ")+", index: "+U+")"),T.data={category:"wrongType",fn:I,index:U,actual:_e,expected:P},T}}else Z=De}const W=Z.map(function(De){return F(De.params)?1/0:De.params.length});if(C.length<Math.min.apply(null,W))return P=x(Z,U),T=new TypeError("Too few arguments in function "+I+" (expected: "+P.join(" or ")+", index: "+C.length+")"),T.data={category:"tooFewArgs",fn:I,index:C.length,expected:P},T;const q=Math.max.apply(null,W);if(C.length>q)return T=new TypeError("Too many arguments in function "+I+" (expected: "+q+", actual: "+C.length+")"),T.data={category:"tooManyArgs",fn:I,index:C.length,expectedLength:q},T;const fe=[];for(let De=0;De<C.length;++De)fe.push(l(C[De]).join("|"));return T=new TypeError('Arguments of type "'+fe.join(", ")+'" do not match any of the defined signatures of function '+I+"."),T.data={category:"mismatch",actual:fe},T}function V(E){let C=i.length+1;for(let N=0;N<E.types.length;N++)S(E.types[N])&&(C=Math.min(C,E.types[N].typeIndex));return C}function R(E){let C=u+1;for(let N=0;N<E.types.length;N++)S(E.types[N])||(C=Math.min(C,E.types[N].conversionIndex));return C}function H(E,C){if(E.hasAny){if(!C.hasAny)return 1}else if(C.hasAny)return-1;if(E.restParam){if(!C.restParam)return 1}else if(C.restParam)return-1;if(E.hasConversion){if(!C.hasConversion)return 1}else if(C.hasConversion)return-1;const N=V(E)-V(C);if(N<0)return-1;if(N>0)return 1;const T=R(E)-R(C);return T<0?-1:T>0?1:0}function $(E,C){const N=E.params,T=C.params,P=le(N),I=le(T),Z=F(N),U=F(T);if(Z&&P.hasAny){if(!U||!I.hasAny)return 1}else if(U&&I.hasAny)return-1;let W=0,q=0,fe;for(fe of N)fe.hasAny&&++W,fe.hasConversion&&++q;let De=0,_e=0;for(fe of T)fe.hasAny&&++De,fe.hasConversion&&++_e;if(W!==De)return W-De;if(Z&&P.hasConversion){if(!U||!I.hasConversion)return 1}else if(U&&I.hasConversion)return-1;if(q!==_e)return q-_e;if(Z){if(!U)return 1}else if(U)return-1;const He=(N.length-T.length)*(Z?-1:1);if(He!==0)return He;const Le=[];let Ke=0;for(let _r=0;_r<N.length;++_r){const jr=H(N[_r],T[_r]);Le.push(jr),Ke+=jr}if(Ke!==0)return Ke;let je;for(je of Le)if(je!==0)return je;return 0}function Q(E){if(E.length===0)return[];const C=E.map(a);E.length>1&&C.sort((P,I)=>P.index-I.index);let N=C[0].conversionsTo;if(E.length===1)return N;N=N.concat([]);const T=new Set(E);for(let P=1;P<C.length;++P){let I;for(I of C[P].conversionsTo)T.has(I.from)||(N.push(I),T.add(I.from))}return N}function J(E,C){let N=C;if(E.some(P=>P.hasConversion)){const P=F(E),I=E.map(X);N=function(){const U=[],W=P?arguments.length-1:arguments.length;for(let q=0;q<W;q++)U[q]=I[q](arguments[q]);return P&&(U[W]=arguments[W].map(I[W])),C.apply(this,U)}}let T=N;if(F(E)){const P=E.length-1;T=function(){return N.apply(this,se(arguments,0,P).concat([se(arguments,P)]))}}return T}function X(E){let C,N,T,P;const I=[],Z=[];switch(E.types.forEach(function(U){U.conversion&&(I.push(a(U.conversion.from).test),Z.push(U.conversion.convert))}),Z.length){case 0:return function(W){return W};case 1:return C=I[0],T=Z[0],function(W){return C(W)?T(W):W};case 2:return C=I[0],N=I[1],T=Z[0],P=Z[1],function(W){return C(W)?T(W):N(W)?P(W):W};default:return function(W){for(let q=0;q<Z.length;q++)if(I[q](W))return Z[q](W);return W}}}function ee(E){function C(N,T,P){if(T<N.length){const I=N[T];let Z=[];if(I.restParam){const U=I.types.filter(S);U.length<I.types.length&&Z.push({types:U,name:"..."+U.map(W=>W.name).join("|"),hasAny:U.some(W=>W.isAny),hasConversion:!1,restParam:!0}),Z.push(I)}else Z=I.types.map(function(U){return{types:[U],name:U.name,hasAny:U.isAny,hasConversion:U.conversion,restParam:!1}});return Ie(Z,function(U){return C(N,T+1,P.concat([U]))})}else return[P]}return C(E,0,[])}function ue(E,C){const N=Math.max(E.length,C.length);for(let U=0;U<N;U++){const W=B(E,U),q=B(C,U);let fe=!1,De;for(De of q)if(W.has(De)){fe=!0;break}if(!fe)return!1}const T=E.length,P=C.length,I=F(E),Z=F(C);return I?Z?T===P:P>=T:Z?T>=P:T===P}function oe(E){return E.map(C=>sr(C)?ke(C.referToSelf.callback):ar(C)?Se(C.referTo.references,C.referTo.callback):C)}function ce(E,C,N){const T=[];let P;for(P of E){let I=N[P];if(typeof I!="number")throw new TypeError('No definition for referenced signature "'+P+'"');if(I=C[I],typeof I!="function")return!1;T.push(I)}return T}function Ce(E,C,N){const T=oe(E),P=new Array(T.length).fill(!1);let I=!0;for(;I;){I=!1;let Z=!0;for(let U=0;U<T.length;++U){if(P[U])continue;const W=T[U];if(sr(W))T[U]=W.referToSelf.callback(N),T[U].referToSelf=W.referToSelf,P[U]=!0,Z=!1;else if(ar(W)){const q=ce(W.referTo.references,T,C);q?(T[U]=W.referTo.callback.apply(this,q),T[U].referTo=W.referTo,P[U]=!0,Z=!1):I=!0}}if(Z&&I)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return T}function be(E){const C=/\bthis(\(|\.signatures\b)/;Object.keys(E).forEach(N=>{const T=E[N];if(C.test(T.toString()))throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function Ae(E,C){if(o.createCount++,Object.keys(C).length===0)throw new SyntaxError("No signatures provided");o.warnAgainstDeprecatedThis&&be(C);const N=[],T=[],P={},I=[];let Z;for(Z in C){if(!Object.prototype.hasOwnProperty.call(C,Z))continue;const ae=A(Z);if(!ae)continue;N.forEach(function(Lr){if(ue(Lr,ae))throw new TypeError('Conflicting signatures "'+d(Lr)+'" and "'+d(ae)+'".')}),N.push(ae);const Ze=T.length;T.push(C[Z]);const Ou=ae.map(y);let et;for(et of ee(Ou)){const Lr=d(et);I.push({params:et,name:Lr,fn:Ze}),et.every($u=>!$u.hasConversion)&&(P[Lr]=Ze)}}I.sort($);const U=Ce(T,P,Rr);let W;for(W in P)Object.prototype.hasOwnProperty.call(P,W)&&(P[W]=U[P[W]]);const q=[],fe=new Map;for(W of I)fe.has(W.name)||(W.fn=U[W.fn],q.push(W),fe.set(W.name,W));const De=q[0]&&q[0].params.length<=2&&!F(q[0].params),_e=q[1]&&q[1].params.length<=2&&!F(q[1].params),He=q[2]&&q[2].params.length<=2&&!F(q[2].params),Le=q[3]&&q[3].params.length<=2&&!F(q[3].params),Ke=q[4]&&q[4].params.length<=2&&!F(q[4].params),je=q[5]&&q[5].params.length<=2&&!F(q[5].params),_r=De&&_e&&He&&Le&&Ke&&je;for(let ae=0;ae<q.length;++ae)q[ae].test=_(q[ae].params);const jr=De?w(q[0].params[0]):Ye,au=_e?w(q[1].params[0]):Ye,su=He?w(q[2].params[0]):Ye,fu=Le?w(q[3].params[0]):Ye,cu=Ke?w(q[4].params[0]):Ye,lu=je?w(q[5].params[0]):Ye,hu=De?w(q[0].params[1]):Ye,pu=_e?w(q[1].params[1]):Ye,Du=He?w(q[2].params[1]):Ye,mu=Le?w(q[3].params[1]):Ye,du=Ke?w(q[4].params[1]):Ye,gu=je?w(q[5].params[1]):Ye;for(let ae=0;ae<q.length;++ae)q[ae].implementation=J(q[ae].params,q[ae].fn);const vu=De?q[0].implementation:Br,wu=_e?q[1].implementation:Br,yu=He?q[2].implementation:Br,Fu=Le?q[3].implementation:Br,Eu=Ke?q[4].implementation:Br,Au=je?q[5].implementation:Br,bu=De?q[0].params.length:-1,Cu=_e?q[1].params.length:-1,_u=He?q[2].params.length:-1,Bu=Le?q[3].params.length:-1,Nu=Ke?q[4].params.length:-1,Su=je?q[5].params.length:-1,Mu=_r?6:0,xu=q.length,Tu=q.map(ae=>ae.test),Iu=q.map(ae=>ae.implementation),zu=function(){for(let Ze=Mu;Ze<xu;Ze++)if(Tu[Ze](arguments))return Iu[Ze].apply(this,arguments);return o.onMismatch(E,arguments,q)};function Rr(ae,Ze){return arguments.length===bu&&jr(ae)&&hu(Ze)?vu.apply(this,arguments):arguments.length===Cu&&au(ae)&&pu(Ze)?wu.apply(this,arguments):arguments.length===_u&&su(ae)&&Du(Ze)?yu.apply(this,arguments):arguments.length===Bu&&fu(ae)&&mu(Ze)?Fu.apply(this,arguments):arguments.length===Nu&&cu(ae)&&du(Ze)?Eu.apply(this,arguments):arguments.length===Su&&lu(ae)&&gu(Ze)?Au.apply(this,arguments):zu.apply(this,arguments)}try{Object.defineProperty(Rr,"name",{value:E})}catch{}return Rr.signatures=P,Rr._typedFunctionData={signatures:q,signatureMap:fe},Rr}function ge(E,C,N){throw O(E,C,N)}function Re(E){return se(E,0,E.length-1)}function le(E){return E[E.length-1]}function se(E,C,N){return Array.prototype.slice.call(E,C,N)}function Je(E,C){for(let N=0;N<E.length;N++)if(C(E[N]))return E[N]}function Ie(E,C){return Array.prototype.concat.apply([],E.map(C))}function he(){const E=Re(arguments).map(N=>d(A(N))),C=le(arguments);if(typeof C!="function")throw new TypeError("Callback function expected as last argument");return Se(E,C)}function Se(E,C){return{referTo:{references:E,callback:C}}}function ke(E){if(typeof E!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:E}}}function ar(E){return E&&typeof E.referTo=="object"&&Array.isArray(E.referTo.references)&&typeof E.referTo.callback=="function"}function sr(E){return E&&typeof E.referToSelf=="object"&&typeof E.referToSelf.callback=="function"}function br(E,C){if(!E)return C;if(C&&C!==E){const N=new Error("Function names do not match (expected: "+E+", actual: "+C+")");throw N.data={actual:C,expected:E},N}return E}function Cr(E){let C;for(const N in E)Object.prototype.hasOwnProperty.call(E,N)&&(h(E[N])||typeof E[N].signature=="string")&&(C=br(C,E[N].name));return C}function Rt(E,C){let N;for(N in C)if(Object.prototype.hasOwnProperty.call(C,N)){if(N in E&&C[N]!==E[N]){const T=new Error('Signature "'+N+'" is defined twice');throw T.data={signature:N,sourceFunction:C[N],destFunction:E[N]},T}E[N]=C[N]}}const ou=o;o=function(E){const C=typeof E=="string",N=C?1:0;let T=C?E:"";const P={};for(let I=N;I<arguments.length;++I){const Z=arguments[I];let U={},W;if(typeof Z=="function"?(W=Z.name,typeof Z.signature=="string"?U[Z.signature]=Z:h(Z)&&(U=Z.signatures)):e(Z)&&(U=Z,C||(W=Cr(Z))),Object.keys(U).length===0){const q=new TypeError("Argument to 'typed' at index "+I+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw q.data={index:I,argument:Z},q}C||(T=br(T,W)),Rt(P,U)}return Ae(T||"",P)},o.create=fi,o.createCount=ou.createCount,o.onMismatch=ge,o.throwMismatchError=ge,o.createError=O,o.clear=f,o.clearConversions=m,o.addTypes=s,o._findType=a,o.referTo=he,o.referToSelf=ke,o.convert=c,o.findSignature=p,o.find=D,o.isTypedFunction=h,o.warnAgainstDeprecatedThis=!0,o.addType=function(E,C){let N="any";C!==!1&&n.has("Object")&&(N="Object"),o.addTypes([E],N)};function ln(E){if(!E||typeof E.from!="string"||typeof E.to!="string"||typeof E.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(E.to===E.from)throw new SyntaxError('Illegal to define conversion from "'+E.from+'" to itself.')}return o.addConversion=function(E){let C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{override:!1};ln(E);const N=a(E.to),T=N.conversionsTo.find(P=>P.from===E.from);if(T)if(C&&C.override)o.removeConversion({from:T.from,to:E.to,convert:T.convert});else throw new Error('There is already a conversion from "'+E.from+'" to "'+N.name+'"');N.conversionsTo.push({from:E.from,convert:E.convert,index:u++})},o.addConversions=function(E,C){E.forEach(N=>o.addConversion(N,C))},o.removeConversion=function(E){ln(E);const C=a(E.to),N=Je(C.conversionsTo,P=>P.from===E.from);if(!N)throw new Error("Attempt to remove nonexistent conversion from "+E.from+" to "+E.to);if(N.convert!==E.convert)throw new Error("Conversion to remove does not match existing conversion");const T=C.conversionsTo.indexOf(N);C.conversionsTo.splice(T,1)},o.resolve=function(E,C){if(!h(E))throw new TypeError(pn);const N=E._typedFunctionData.signatures;for(let T=0;T<N.length;++T)if(N[T].test(C))return N[T];return null},o}const pt=fi();function G(e,r,t,n){function i(u){var o=Fo(u,r.map(_o));return bo(e,r,u),t(o)}return i.isFactory=!0,i.fn=e,i.dependencies=r.slice().sort(),n&&(i.meta=n),i}function bo(e,r,t){var n=r.filter(u=>!Co(u)).every(u=>t[u]!==void 0);if(!n){var i=r.filter(u=>t[u]===void 0);throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(i.map(u=>'"'.concat(u,'"')).join(", "),"."))}}function Co(e){return e&&e[0]==="?"}function _o(e){return e&&e[0]==="?"?e.slice(1):e}function we(e){return typeof e=="boolean"?!0:Number.isFinite(e)?e===Math.round(e):!1}var Bo=Math.log10||function(r){return Math.log(r)/Math.LN10};function Lt(e,r,t){var n={2:"0b",8:"0o",16:"0x"},i=n[r],u="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!we(t))throw new Error("size must be an integer");if(e>2**(t-1)-1||e<-(2**(t-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!we(e))throw new Error("Value must be an integer");e<0&&(e=e+2**t),u="i".concat(t)}var o="";return e<0&&(e=-e,o="-"),"".concat(o).concat(i).concat(e.toString(r)).concat(u)}function Vt(e,r){if(typeof r=="function")return r(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var{notation:t,precision:n,wordSize:i}=ci(r);switch(t){case"fixed":return li(e,n);case"exponential":return hi(e,n);case"engineering":return No(e,n);case"bin":return Lt(e,2,i);case"oct":return Lt(e,8,i);case"hex":return Lt(e,16,i);case"auto":return So(e,n,r).replace(/((\.\d*?)(0+))($|e)/,function(){var u=arguments[2],o=arguments[4];return u!=="."?u+o:o});default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function ci(e){var r="auto",t,n;if(e!==void 0)if(ne(e))t=e;else if(Ee(e))t=e.toNumber();else if(nn(e))e.precision!==void 0&&(t=Dn(e.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),e.wordSize!==void 0&&(n=Dn(e.wordSize,()=>{throw new Error('Option "wordSize" must be a number or BigNumber')})),e.notation&&(r=e.notation);else throw new Error("Unsupported type of options, number, BigNumber, or object expected");return{notation:r,precision:t,wordSize:n}}function kr(e){var r=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!r)throw new SyntaxError("Invalid number "+e);var t=r[1],n=r[2],i=parseFloat(r[4]||"0"),u=n.indexOf(".");i+=u!==-1?u-1:n.length-1;var o=n.replace(".","").replace(/^0*/,function(a){return i-=a.length,""}).replace(/0*$/,"").split("").map(function(a){return parseInt(a)});return o.length===0&&(o.push(0),i++),{sign:t,coefficients:o,exponent:i}}function No(e,r){if(isNaN(e)||!Number.isFinite(e))return String(e);var t=kr(e),n=St(t,r),i=n.exponent,u=n.coefficients,o=i%3===0?i:i<0?i-3-i%3:i-i%3;if(ne(r))for(;r>u.length||i-o+1>u.length;)u.push(0);else for(var a=Math.abs(i-o)-(u.length-1),s=0;s<a;s++)u.push(0);for(var f=Math.abs(i-o),m=1;f>0;)m++,f--;var l=u.slice(m).join(""),h=ne(r)&&l.length||l.match(/[1-9]/)?"."+l:"",p=u.slice(0,m).join("")+h+"e"+(i>=0?"+":"")+o.toString();return n.sign+p}function li(e,r){if(isNaN(e)||!Number.isFinite(e))return String(e);var t=kr(e),n=typeof r=="number"?St(t,t.exponent+1+r):t,i=n.coefficients,u=n.exponent+1,o=u+(r||0);return i.length<o&&(i=i.concat(Tr(o-i.length))),u<0&&(i=Tr(-u+1).concat(i),u=1),u<i.length&&i.splice(u,0,u===0?"0.":"."),n.sign+i.join("")}function hi(e,r){if(isNaN(e)||!Number.isFinite(Number(e)))return String(e);var t=kr(e),n=r?St(t,r):t,i=n.coefficients,u=n.exponent;i.length<r&&(i=i.concat(Tr(r-i.length)));var o=i.shift();return n.sign+o+(i.length>0?"."+i.join(""):"")+"e"+(u>=0?"+":"")+u}function So(e,r,t){if(isNaN(e)||!Number.isFinite(e))return String(e);var n=mn(t?.lowerExp,-3),i=mn(t?.upperExp,5),u=kr(e),o=r?St(u,r):u;if(o.exponent<n||o.exponent>=i)return hi(e,r);var a=o.coefficients,s=o.exponent;a.length<r&&(a=a.concat(Tr(r-a.length))),a=a.concat(Tr(s-a.length+1+(a.length<r?r-a.length:0))),a=Tr(-s).concat(a);var f=s>0?s:0;return f<a.length-1&&a.splice(f+1,0,"."),o.sign+a.join("")}function St(e,r){for(var t={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},n=t.coefficients;r<=0;)n.unshift(0),t.exponent++,r++;if(n.length>r){var i=n.splice(r,n.length-r);if(i[0]>=5){var u=r-1;for(n[u]++;n[u]===10;)n.pop(),u===0&&(n.unshift(0),t.exponent++,u++),u--,n[u]++}}return t}function Tr(e){for(var r=[],t=0;t<e;t++)r.push(0);return r}function Mo(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}function tr(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e-8,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(t<=0)throw new Error("Relative tolerance must be greater than 0");if(n<0)throw new Error("Absolute tolerance must be at least 0");return isNaN(e)||isNaN(r)?!1:!Number.isFinite(e)||!Number.isFinite(r)?e===r:e===r?!0:Math.abs(e-r)<=Math.max(t*Math.max(Math.abs(e),Math.abs(r)),n)}function Dn(e,r){if(ne(e))return e;if(Ee(e))return e.toNumber();r()}function mn(e,r){return ne(e)?e:Ee(e)?e.toNumber():r}var pi=function(){return pi=pt.create,pt},xo=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],To=G("typed",xo,function(r){var{BigNumber:t,Complex:n,DenseMatrix:i,Fraction:u}=r,o=pi();return o.clear(),o.addTypes([{name:"number",test:ne},{name:"Complex",test:ui},{name:"BigNumber",test:Ee},{name:"bigint",test:Zu},{name:"Fraction",test:oi},{name:"Unit",test:ai},{name:"identifier",test:a=>Te&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC4\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC4\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])*$/.test(a)},{name:"string",test:Te},{name:"Chain",test:vo},{name:"Array",test:ve},{name:"Matrix",test:ye},{name:"DenseMatrix",test:Wu},{name:"SparseMatrix",test:Vu},{name:"Range",test:si},{name:"Index",test:Nt},{name:"boolean",test:Gu},{name:"ResultSet",test:Ju},{name:"Help",test:ku},{name:"function",test:Yu},{name:"Date",test:Xu},{name:"RegExp",test:Qu},{name:"null",test:ju},{name:"undefined",test:eo},{name:"AccessorNode",test:ro},{name:"ArrayNode",test:to},{name:"AssignmentNode",test:no},{name:"BlockNode",test:io},{name:"ConditionalNode",test:uo},{name:"ConstantNode",test:oo},{name:"FunctionNode",test:so},{name:"FunctionAssignmentNode",test:ao},{name:"IndexNode",test:fo},{name:"Node",test:co},{name:"ObjectNode",test:lo},{name:"OperatorNode",test:ho},{name:"ParenthesisNode",test:po},{name:"RangeNode",test:Do},{name:"RelationalNode",test:mo},{name:"SymbolNode",test:go},{name:"Map",test:Ku},{name:"Object",test:nn}]),o.addConversions([{from:"number",to:"BigNumber",convert:function(s){if(t||rt(s),Mo(s)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+s+"). Use function bignumber(x) to convert to BigNumber.");return new t(s)}},{from:"number",to:"Complex",convert:function(s){return n||tt(s),new n(s,0)}},{from:"BigNumber",to:"Complex",convert:function(s){return n||tt(s),new n(s.toNumber(),0)}},{from:"bigint",to:"number",convert:function(s){if(s>Number.MAX_SAFE_INTEGER)throw new TypeError("Cannot implicitly convert bigint to number: value exceeds the max safe integer value (value: "+s+")");return Number(s)}},{from:"bigint",to:"BigNumber",convert:function(s){return t||rt(s),new t(s.toString())}},{from:"bigint",to:"Fraction",convert:function(s){return u||nt(s),new u(s)}},{from:"Fraction",to:"BigNumber",convert:function(s){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(s){return n||tt(s),new n(s.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(s){u||nt(s);var f=new u(s);if(f.valueOf()!==s)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+s+"). Use function fraction(x) to convert to Fraction.");return f}},{from:"string",to:"number",convert:function(s){var f=Number(s);if(isNaN(f))throw new Error('Cannot convert "'+s+'" to a number');return f}},{from:"string",to:"BigNumber",convert:function(s){t||rt(s);try{return new t(s)}catch{throw new Error('Cannot convert "'+s+'" to BigNumber')}}},{from:"string",to:"bigint",convert:function(s){try{return BigInt(s)}catch{throw new Error('Cannot convert "'+s+'" to BigInt')}}},{from:"string",to:"Fraction",convert:function(s){u||nt(s);try{return new u(s)}catch{throw new Error('Cannot convert "'+s+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(s){n||tt(s);try{return new n(s)}catch{throw new Error('Cannot convert "'+s+'" to Complex')}}},{from:"boolean",to:"number",convert:function(s){return+s}},{from:"boolean",to:"BigNumber",convert:function(s){return t||rt(s),new t(+s)}},{from:"boolean",to:"bigint",convert:function(s){return BigInt(+s)}},{from:"boolean",to:"Fraction",convert:function(s){return u||nt(s),new u(+s)}},{from:"boolean",to:"string",convert:function(s){return String(s)}},{from:"Array",to:"Matrix",convert:function(s){return i||Io(),new i(s)}},{from:"Matrix",to:"Array",convert:function(s){return s.valueOf()}}]),o.onMismatch=(a,s,f)=>{var m=o.createError(a,s,f);if(["wrongType","mismatch"].includes(m.data.category)&&s.length===1&&ht(s[0])&&f.some(h=>!h.params.includes(","))){var l=new TypeError("Function '".concat(a,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(a,")'."));throw l.data=m.data,l}throw m},o.onMismatch=(a,s,f)=>{var m=o.createError(a,s,f);if(["wrongType","mismatch"].includes(m.data.category)&&s.length===1&&ht(s[0])&&f.some(h=>!h.params.includes(","))){var l=new TypeError("Function '".concat(a,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(a,")'."));throw l.data=m.data,l}throw m},o});function rt(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function tt(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function Io(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function nt(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var xr=9e15,vr=1e9,Gt="0123456789abcdef",Dt="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",mt="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Jt={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-xr,maxE:xr,crypto:!1},Di,lr,j=!0,Mt="[DecimalError] ",dr=Mt+"Invalid argument: ",mi=Mt+"Precision limit exceeded",di=Mt+"crypto unavailable",gi="[object Decimal]",Pe=Math.floor,Ne=Math.pow,zo=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Oo=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,$o=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,vi=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,rr=1e7,K=7,Po=9007199254740991,qo=Dt.length-1,kt=mt.length-1,z={toStringTag:gi};z.absoluteValue=z.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),Y(e)};z.ceil=function(){return Y(new this.constructor(this),this.e+1,2)};z.clampedTo=z.clamp=function(e,r){var t,n=this,i=n.constructor;if(e=new i(e),r=new i(r),!e.s||!r.s)return new i(NaN);if(e.gt(r))throw Error(dr+r);return t=n.cmp(e),t<0?e:n.cmp(r)>0?r:new i(n)};z.comparedTo=z.cmp=function(e){var r,t,n,i,u=this,o=u.d,a=(e=new u.constructor(e)).d,s=u.s,f=e.s;if(!o||!a)return!s||!f?NaN:s!==f?s:o===a?0:!o^s<0?1:-1;if(!o[0]||!a[0])return o[0]?s:a[0]?-f:0;if(s!==f)return s;if(u.e!==e.e)return u.e>e.e^s<0?1:-1;for(n=o.length,i=a.length,r=0,t=n<i?n:i;r<t;++r)if(o[r]!==a[r])return o[r]>a[r]^s<0?1:-1;return n===i?0:n>i^s<0?1:-1};z.cosine=z.cos=function(){var e,r,t=this,n=t.constructor;return t.d?t.d[0]?(e=n.precision,r=n.rounding,n.precision=e+Math.max(t.e,t.sd())+K,n.rounding=1,t=Uo(n,Ai(n,t)),n.precision=e,n.rounding=r,Y(lr==2||lr==3?t.neg():t,e,r,!0)):new n(1):new n(NaN)};z.cubeRoot=z.cbrt=function(){var e,r,t,n,i,u,o,a,s,f,m=this,l=m.constructor;if(!m.isFinite()||m.isZero())return new l(m);for(j=!1,u=m.s*Ne(m.s*m,1/3),!u||Math.abs(u)==1/0?(t=ze(m.d),e=m.e,(u=(e-t.length+1)%3)&&(t+=u==1||u==-2?"0":"00"),u=Ne(t,1/3),e=Pe((e+1)/3)-(e%3==(e<0?-1:2)),u==1/0?t="5e"+e:(t=u.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),n=new l(t),n.s=m.s):n=new l(u.toString()),o=(e=l.precision)+3;;)if(a=n,s=a.times(a).times(a),f=s.plus(m),n=pe(f.plus(m).times(a),f.plus(s),o+2,1),ze(a.d).slice(0,o)===(t=ze(n.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!i&&t=="4999"){if(!i&&(Y(a,e+1,0),a.times(a).times(a).eq(m))){n=a;break}o+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Y(n,e+1,1),r=!n.times(n).times(n).eq(m));break}return j=!0,Y(n,e,l.rounding,r)};z.decimalPlaces=z.dp=function(){var e,r=this.d,t=NaN;if(r){if(e=r.length-1,t=(e-Pe(this.e/K))*K,e=r[e],e)for(;e%10==0;e/=10)t--;t<0&&(t=0)}return t};z.dividedBy=z.div=function(e){return pe(this,new this.constructor(e))};z.dividedToIntegerBy=z.divToInt=function(e){var r=this,t=r.constructor;return Y(pe(r,new t(e),0,1,1),t.precision,t.rounding)};z.equals=z.eq=function(e){return this.cmp(e)===0};z.floor=function(){return Y(new this.constructor(this),this.e+1,3)};z.greaterThan=z.gt=function(e){return this.cmp(e)>0};z.greaterThanOrEqualTo=z.gte=function(e){var r=this.cmp(e);return r==1||r===0};z.hyperbolicCosine=z.cosh=function(){var e,r,t,n,i,u=this,o=u.constructor,a=new o(1);if(!u.isFinite())return new o(u.s?1/0:NaN);if(u.isZero())return a;t=o.precision,n=o.rounding,o.precision=t+Math.max(u.e,u.sd())+4,o.rounding=1,i=u.d.length,i<32?(e=Math.ceil(i/3),r=(1/Tt(4,e)).toString()):(e=16,r="2.3283064365386962890625e-10"),u=Ir(o,1,u.times(r),new o(1),!0);for(var s,f=e,m=new o(8);f--;)s=u.times(u),u=a.minus(s.times(m.minus(s.times(m))));return Y(u,o.precision=t,o.rounding=n,!0)};z.hyperbolicSine=z.sinh=function(){var e,r,t,n,i=this,u=i.constructor;if(!i.isFinite()||i.isZero())return new u(i);if(r=u.precision,t=u.rounding,u.precision=r+Math.max(i.e,i.sd())+4,u.rounding=1,n=i.d.length,n<3)i=Ir(u,2,i,i,!0);else{e=1.4*Math.sqrt(n),e=e>16?16:e|0,i=i.times(1/Tt(5,e)),i=Ir(u,2,i,i,!0);for(var o,a=new u(5),s=new u(16),f=new u(20);e--;)o=i.times(i),i=i.times(a.plus(o.times(s.times(o).plus(f))))}return u.precision=r,u.rounding=t,Y(i,r,t,!0)};z.hyperbolicTangent=z.tanh=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+7,n.rounding=1,pe(t.sinh(),t.cosh(),n.precision=e,n.rounding=r)):new n(t.s)};z.inverseCosine=z.acos=function(){var e=this,r=e.constructor,t=e.abs().cmp(1),n=r.precision,i=r.rounding;return t!==-1?t===0?e.isNeg()?ir(r,n,i):new r(0):new r(NaN):e.isZero()?ir(r,n+4,i).times(.5):(r.precision=n+6,r.rounding=1,e=new r(1).minus(e).div(e.plus(1)).sqrt().atan(),r.precision=n,r.rounding=i,e.times(2))};z.inverseHyperbolicCosine=z.acosh=function(){var e,r,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(e=n.precision,r=n.rounding,n.precision=e+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,j=!1,t=t.times(t).minus(1).sqrt().plus(t),j=!0,n.precision=e,n.rounding=r,t.ln()):new n(t)};z.inverseHyperbolicSine=z.asinh=function(){var e,r,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,j=!1,t=t.times(t).plus(1).sqrt().plus(t),j=!0,n.precision=e,n.rounding=r,t.ln())};z.inverseHyperbolicTangent=z.atanh=function(){var e,r,t,n,i=this,u=i.constructor;return i.isFinite()?i.e>=0?new u(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=u.precision,r=u.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?Y(new u(i),e,r,!0):(u.precision=t=n-i.e,i=pe(i.plus(1),new u(1).minus(i),t+e,1),u.precision=e+4,u.rounding=1,i=i.ln(),u.precision=e,u.rounding=r,i.times(.5))):new u(NaN)};z.inverseSine=z.asin=function(){var e,r,t,n,i=this,u=i.constructor;return i.isZero()?new u(i):(r=i.abs().cmp(1),t=u.precision,n=u.rounding,r!==-1?r===0?(e=ir(u,t+4,n).times(.5),e.s=i.s,e):new u(NaN):(u.precision=t+6,u.rounding=1,i=i.div(new u(1).minus(i.times(i)).sqrt().plus(1)).atan(),u.precision=t,u.rounding=n,i.times(2)))};z.inverseTangent=z.atan=function(){var e,r,t,n,i,u,o,a,s,f=this,m=f.constructor,l=m.precision,h=m.rounding;if(f.isFinite()){if(f.isZero())return new m(f);if(f.abs().eq(1)&&l+4<=kt)return o=ir(m,l+4,h).times(.25),o.s=f.s,o}else{if(!f.s)return new m(NaN);if(l+4<=kt)return o=ir(m,l+4,h).times(.5),o.s=f.s,o}for(m.precision=a=l+10,m.rounding=1,t=Math.min(28,a/K+2|0),e=t;e;--e)f=f.div(f.times(f).plus(1).sqrt().plus(1));for(j=!1,r=Math.ceil(a/K),n=1,s=f.times(f),o=new m(f),i=f;e!==-1;)if(i=i.times(s),u=o.minus(i.div(n+=2)),i=i.times(s),o=u.plus(i.div(n+=2)),o.d[r]!==void 0)for(e=r;o.d[e]===u.d[e]&&e--;);return t&&(o=o.times(2<<t-1)),j=!0,Y(o,m.precision=l,m.rounding=h,!0)};z.isFinite=function(){return!!this.d};z.isInteger=z.isInt=function(){return!!this.d&&Pe(this.e/K)>this.d.length-2};z.isNaN=function(){return!this.s};z.isNegative=z.isNeg=function(){return this.s<0};z.isPositive=z.isPos=function(){return this.s>0};z.isZero=function(){return!!this.d&&this.d[0]===0};z.lessThan=z.lt=function(e){return this.cmp(e)<0};z.lessThanOrEqualTo=z.lte=function(e){return this.cmp(e)<1};z.logarithm=z.log=function(e){var r,t,n,i,u,o,a,s,f=this,m=f.constructor,l=m.precision,h=m.rounding,p=5;if(e==null)e=new m(10),r=!0;else{if(e=new m(e),t=e.d,e.s<0||!t||!t[0]||e.eq(1))return new m(NaN);r=e.eq(10)}if(t=f.d,f.s<0||!t||!t[0]||f.eq(1))return new m(t&&!t[0]?-1/0:f.s!=1?NaN:t?0:1/0);if(r)if(t.length>1)u=!0;else{for(i=t[0];i%10===0;)i/=10;u=i!==1}if(j=!1,a=l+p,o=Dr(f,a),n=r?dt(m,a+10):Dr(e,a),s=pe(o,n,a,1),Vr(s.d,i=l,h))do if(a+=10,o=Dr(f,a),n=r?dt(m,a+10):Dr(e,a),s=pe(o,n,a,1),!u){+ze(s.d).slice(i+1,i+15)+1==1e14&&(s=Y(s,l+1,0));break}while(Vr(s.d,i+=10,h));return j=!0,Y(s,l,h)};z.minus=z.sub=function(e){var r,t,n,i,u,o,a,s,f,m,l,h,p=this,D=p.constructor;if(e=new D(e),!p.d||!e.d)return!p.s||!e.s?e=new D(NaN):p.d?e.s=-e.s:e=new D(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(f=p.d,h=e.d,a=D.precision,s=D.rounding,!f[0]||!h[0]){if(h[0])e.s=-e.s;else if(f[0])e=new D(p);else return new D(s===3?-0:0);return j?Y(e,a,s):e}if(t=Pe(e.e/K),m=Pe(p.e/K),f=f.slice(),u=m-t,u){for(l=u<0,l?(r=f,u=-u,o=h.length):(r=h,t=m,o=f.length),n=Math.max(Math.ceil(a/K),o)+2,u>n&&(u=n,r.length=1),r.reverse(),n=u;n--;)r.push(0);r.reverse()}else{for(n=f.length,o=h.length,l=n<o,l&&(o=n),n=0;n<o;n++)if(f[n]!=h[n]){l=f[n]<h[n];break}u=0}for(l&&(r=f,f=h,h=r,e.s=-e.s),o=f.length,n=h.length-o;n>0;--n)f[o++]=0;for(n=h.length;n>u;){if(f[--n]<h[n]){for(i=n;i&&f[--i]===0;)f[i]=rr-1;--f[i],f[n]+=rr}f[n]-=h[n]}for(;f[--o]===0;)f.pop();for(;f[0]===0;f.shift())--t;return f[0]?(e.d=f,e.e=xt(f,t),j?Y(e,a,s):e):new D(s===3?-0:0)};z.modulo=z.mod=function(e){var r,t=this,n=t.constructor;return e=new n(e),!t.d||!e.s||e.d&&!e.d[0]?new n(NaN):!e.d||t.d&&!t.d[0]?Y(new n(t),n.precision,n.rounding):(j=!1,n.modulo==9?(r=pe(t,e.abs(),0,3,1),r.s*=e.s):r=pe(t,e,0,n.modulo,1),r=r.times(e),j=!0,t.minus(r))};z.naturalExponential=z.exp=function(){return Yt(this)};z.naturalLogarithm=z.ln=function(){return Dr(this)};z.negated=z.neg=function(){var e=new this.constructor(this);return e.s=-e.s,Y(e)};z.plus=z.add=function(e){var r,t,n,i,u,o,a,s,f,m,l=this,h=l.constructor;if(e=new h(e),!l.d||!e.d)return!l.s||!e.s?e=new h(NaN):l.d||(e=new h(e.d||l.s===e.s?l:NaN)),e;if(l.s!=e.s)return e.s=-e.s,l.minus(e);if(f=l.d,m=e.d,a=h.precision,s=h.rounding,!f[0]||!m[0])return m[0]||(e=new h(l)),j?Y(e,a,s):e;if(u=Pe(l.e/K),n=Pe(e.e/K),f=f.slice(),i=u-n,i){for(i<0?(t=f,i=-i,o=m.length):(t=m,n=u,o=f.length),u=Math.ceil(a/K),o=u>o?u+1:o+1,i>o&&(i=o,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for(o=f.length,i=m.length,o-i<0&&(i=o,t=m,m=f,f=t),r=0;i;)r=(f[--i]=f[i]+m[i]+r)/rr|0,f[i]%=rr;for(r&&(f.unshift(r),++n),o=f.length;f[--o]==0;)f.pop();return e.d=f,e.e=xt(f,n),j?Y(e,a,s):e};z.precision=z.sd=function(e){var r,t=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(dr+e);return t.d?(r=wi(t.d),e&&t.e+1>r&&(r=t.e+1)):r=NaN,r};z.round=function(){var e=this,r=e.constructor;return Y(new r(e),e.e+1,r.rounding)};z.sine=z.sin=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+Math.max(t.e,t.sd())+K,n.rounding=1,t=Lo(n,Ai(n,t)),n.precision=e,n.rounding=r,Y(lr>2?t.neg():t,e,r,!0)):new n(NaN)};z.squareRoot=z.sqrt=function(){var e,r,t,n,i,u,o=this,a=o.d,s=o.e,f=o.s,m=o.constructor;if(f!==1||!a||!a[0])return new m(!f||f<0&&(!a||a[0])?NaN:a?o:1/0);for(j=!1,f=Math.sqrt(+o),f==0||f==1/0?(r=ze(a),(r.length+s)%2==0&&(r+="0"),f=Math.sqrt(r),s=Pe((s+1)/2)-(s<0||s%2),f==1/0?r="5e"+s:(r=f.toExponential(),r=r.slice(0,r.indexOf("e")+1)+s),n=new m(r)):n=new m(f.toString()),t=(s=m.precision)+3;;)if(u=n,n=u.plus(pe(o,u,t+2,1)).times(.5),ze(u.d).slice(0,t)===(r=ze(n.d)).slice(0,t))if(r=r.slice(t-3,t+1),r=="9999"||!i&&r=="4999"){if(!i&&(Y(u,s+1,0),u.times(u).eq(o))){n=u;break}t+=4,i=1}else{(!+r||!+r.slice(1)&&r.charAt(0)=="5")&&(Y(n,s+1,1),e=!n.times(n).eq(o));break}return j=!0,Y(n,s,m.rounding,e)};z.tangent=z.tan=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+10,n.rounding=1,t=t.sin(),t.s=1,t=pe(t,new n(1).minus(t.times(t)).sqrt(),e+10,0),n.precision=e,n.rounding=r,Y(lr==2||lr==4?t.neg():t,e,r,!0)):new n(NaN)};z.times=z.mul=function(e){var r,t,n,i,u,o,a,s,f,m=this,l=m.constructor,h=m.d,p=(e=new l(e)).d;if(e.s*=m.s,!h||!h[0]||!p||!p[0])return new l(!e.s||h&&!h[0]&&!p||p&&!p[0]&&!h?NaN:!h||!p?e.s/0:e.s*0);for(t=Pe(m.e/K)+Pe(e.e/K),s=h.length,f=p.length,s<f&&(u=h,h=p,p=u,o=s,s=f,f=o),u=[],o=s+f,n=o;n--;)u.push(0);for(n=f;--n>=0;){for(r=0,i=s+n;i>n;)a=u[i]+p[n]*h[i-n-1]+r,u[i--]=a%rr|0,r=a/rr|0;u[i]=(u[i]+r)%rr|0}for(;!u[--o];)u.pop();return r?++t:u.shift(),e.d=u,e.e=xt(u,t),j?Y(e,l.precision,l.rounding):e};z.toBinary=function(e,r){return un(this,2,e,r)};z.toDecimalPlaces=z.toDP=function(e,r){var t=this,n=t.constructor;return t=new n(t),e===void 0?t:(Ve(e,0,vr),r===void 0?r=n.rounding:Ve(r,0,8),Y(t,e+t.e+1,r))};z.toExponential=function(e,r){var t,n=this,i=n.constructor;return e===void 0?t=or(n,!0):(Ve(e,0,vr),r===void 0?r=i.rounding:Ve(r,0,8),n=Y(new i(n),e+1,r),t=or(n,!0,e+1)),n.isNeg()&&!n.isZero()?"-"+t:t};z.toFixed=function(e,r){var t,n,i=this,u=i.constructor;return e===void 0?t=or(i):(Ve(e,0,vr),r===void 0?r=u.rounding:Ve(r,0,8),n=Y(new u(i),e+i.e+1,r),t=or(n,!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t};z.toFraction=function(e){var r,t,n,i,u,o,a,s,f,m,l,h,p=this,D=p.d,c=p.constructor;if(!D)return new c(p);if(f=t=new c(1),n=s=new c(0),r=new c(n),u=r.e=wi(D)-p.e-1,o=u%K,r.d[0]=Ne(10,o<0?K+o:o),e==null)e=u>0?r:f;else{if(a=new c(e),!a.isInt()||a.lt(f))throw Error(dr+a);e=a.gt(r)?u>0?r:f:a}for(j=!1,a=new c(ze(D)),m=c.precision,c.precision=u=D.length*K*2;l=pe(a,r,0,1,1),i=t.plus(l.times(n)),i.cmp(e)!=1;)t=n,n=i,i=f,f=s.plus(l.times(i)),s=i,i=r,r=a.minus(l.times(i)),a=i;return i=pe(e.minus(t),n,0,1,1),s=s.plus(i.times(f)),t=t.plus(i.times(n)),s.s=f.s=p.s,h=pe(f,n,u,1).minus(p).abs().cmp(pe(s,t,u,1).minus(p).abs())<1?[f,n]:[s,t],c.precision=m,j=!0,h};z.toHexadecimal=z.toHex=function(e,r){return un(this,16,e,r)};z.toNearest=function(e,r){var t=this,n=t.constructor;if(t=new n(t),e==null){if(!t.d)return t;e=new n(1),r=n.rounding}else{if(e=new n(e),r===void 0?r=n.rounding:Ve(r,0,8),!t.d)return e.s?t:e;if(!e.d)return e.s&&(e.s=t.s),e}return e.d[0]?(j=!1,t=pe(t,e,0,r,1).times(e),j=!0,Y(t)):(e.s=t.s,t=e),t};z.toNumber=function(){return+this};z.toOctal=function(e,r){return un(this,8,e,r)};z.toPower=z.pow=function(e){var r,t,n,i,u,o,a=this,s=a.constructor,f=+(e=new s(e));if(!a.d||!e.d||!a.d[0]||!e.d[0])return new s(Ne(+a,f));if(a=new s(a),a.eq(1))return a;if(n=s.precision,u=s.rounding,e.eq(1))return Y(a,n,u);if(r=Pe(e.e/K),r>=e.d.length-1&&(t=f<0?-f:f)<=Po)return i=yi(s,a,t,n),e.s<0?new s(1).div(i):Y(i,n,u);if(o=a.s,o<0){if(r<e.d.length-1)return new s(NaN);if((e.d[r]&1)==0&&(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return t=Ne(+a,f),r=t==0||!isFinite(t)?Pe(f*(Math.log("0."+ze(a.d))/Math.LN10+a.e+1)):new s(t+"").e,r>s.maxE+1||r<s.minE-1?new s(r>0?o/0:0):(j=!1,s.rounding=a.s=1,t=Math.min(12,(r+"").length),i=Yt(e.times(Dr(a,n+t)),n),i.d&&(i=Y(i,n+5,1),Vr(i.d,n,u)&&(r=n+10,i=Y(Yt(e.times(Dr(a,r+t)),r),r+5,1),+ze(i.d).slice(n+1,n+15)+1==1e14&&(i=Y(i,n+1,0)))),i.s=o,j=!0,s.rounding=u,Y(i,n,u))};z.toPrecision=function(e,r){var t,n=this,i=n.constructor;return e===void 0?t=or(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(Ve(e,1,vr),r===void 0?r=i.rounding:Ve(r,0,8),n=Y(new i(n),e,r),t=or(n,e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+t:t};z.toSignificantDigits=z.toSD=function(e,r){var t=this,n=t.constructor;return e===void 0?(e=n.precision,r=n.rounding):(Ve(e,1,vr),r===void 0?r=n.rounding:Ve(r,0,8)),Y(new n(t),e,r)};z.toString=function(){var e=this,r=e.constructor,t=or(e,e.e<=r.toExpNeg||e.e>=r.toExpPos);return e.isNeg()&&!e.isZero()?"-"+t:t};z.truncated=z.trunc=function(){return Y(new this.constructor(this),this.e+1,1)};z.valueOf=z.toJSON=function(){var e=this,r=e.constructor,t=or(e,e.e<=r.toExpNeg||e.e>=r.toExpPos);return e.isNeg()?"-"+t:t};function ze(e){var r,t,n,i=e.length-1,u="",o=e[0];if(i>0){for(u+=o,r=1;r<i;r++)n=e[r]+"",t=K-n.length,t&&(u+=pr(t)),u+=n;o=e[r],n=o+"",t=K-n.length,t&&(u+=pr(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return u+o}function Ve(e,r,t){if(e!==~~e||e<r||e>t)throw Error(dr+e)}function Vr(e,r,t,n){var i,u,o,a;for(u=e[0];u>=10;u/=10)--r;return--r<0?(r+=K,i=0):(i=Math.ceil((r+1)/K),r%=K),u=Ne(10,K-r),a=e[i]%u|0,n==null?r<3?(r==0?a=a/100|0:r==1&&(a=a/10|0),o=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):o=(t<4&&a+1==u||t>3&&a+1==u/2)&&(e[i+1]/u/100|0)==Ne(10,r-2)-1||(a==u/2||a==0)&&(e[i+1]/u/100|0)==0:r<4?(r==0?a=a/1e3|0:r==1?a=a/100|0:r==2&&(a=a/10|0),o=(n||t<4)&&a==9999||!n&&t>3&&a==4999):o=((n||t<4)&&a+1==u||!n&&t>3&&a+1==u/2)&&(e[i+1]/u/1e3|0)==Ne(10,r-3)-1,o}function it(e,r,t){for(var n,i=[0],u,o=0,a=e.length;o<a;){for(u=i.length;u--;)i[u]*=r;for(i[0]+=Gt.indexOf(e.charAt(o++)),n=0;n<i.length;n++)i[n]>t-1&&(i[n+1]===void 0&&(i[n+1]=0),i[n+1]+=i[n]/t|0,i[n]%=t)}return i.reverse()}function Uo(e,r){var t,n,i;if(r.isZero())return r;n=r.d.length,n<32?(t=Math.ceil(n/3),i=(1/Tt(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),e.precision+=t,r=Ir(e,1,r.times(i),new e(1));for(var u=t;u--;){var o=r.times(r);r=o.times(o).minus(o).times(8).plus(1)}return e.precision-=t,r}var pe=(function(){function e(n,i,u){var o,a=0,s=n.length;for(n=n.slice();s--;)o=n[s]*i+a,n[s]=o%u|0,a=o/u|0;return a&&n.unshift(a),n}function r(n,i,u,o){var a,s;if(u!=o)s=u>o?1:-1;else for(a=s=0;a<u;a++)if(n[a]!=i[a]){s=n[a]>i[a]?1:-1;break}return s}function t(n,i,u,o){for(var a=0;u--;)n[u]-=a,a=n[u]<i[u]?1:0,n[u]=a*o+n[u]-i[u];for(;!n[0]&&n.length>1;)n.shift()}return function(n,i,u,o,a,s){var f,m,l,h,p,D,c,d,v,y,g,A,F,w,_,b,B,S,x,O,V=n.constructor,R=n.s==i.s?1:-1,H=n.d,$=i.d;if(!H||!H[0]||!$||!$[0])return new V(!n.s||!i.s||(H?$&&H[0]==$[0]:!$)?NaN:H&&H[0]==0||!$?R*0:R/0);for(s?(p=1,m=n.e-i.e):(s=rr,p=K,m=Pe(n.e/p)-Pe(i.e/p)),x=$.length,B=H.length,v=new V(R),y=v.d=[],l=0;$[l]==(H[l]||0);l++);if($[l]>(H[l]||0)&&m--,u==null?(w=u=V.precision,o=V.rounding):a?w=u+(n.e-i.e)+1:w=u,w<0)y.push(1),D=!0;else{if(w=w/p+2|0,l=0,x==1){for(h=0,$=$[0],w++;(l<B||h)&&w--;l++)_=h*s+(H[l]||0),y[l]=_/$|0,h=_%$|0;D=h||l<B}else{for(h=s/($[0]+1)|0,h>1&&($=e($,h,s),H=e(H,h,s),x=$.length,B=H.length),b=x,g=H.slice(0,x),A=g.length;A<x;)g[A++]=0;O=$.slice(),O.unshift(0),S=$[0],$[1]>=s/2&&++S;do h=0,f=r($,g,x,A),f<0?(F=g[0],x!=A&&(F=F*s+(g[1]||0)),h=F/S|0,h>1?(h>=s&&(h=s-1),c=e($,h,s),d=c.length,A=g.length,f=r(c,g,d,A),f==1&&(h--,t(c,x<d?O:$,d,s))):(h==0&&(f=h=1),c=$.slice()),d=c.length,d<A&&c.unshift(0),t(g,c,A,s),f==-1&&(A=g.length,f=r($,g,x,A),f<1&&(h++,t(g,x<A?O:$,A,s))),A=g.length):f===0&&(h++,g=[0]),y[l++]=h,f&&g[0]?g[A++]=H[b]||0:(g=[H[b]],A=1);while((b++<B||g[0]!==void 0)&&w--);D=g[0]!==void 0}y[0]||y.shift()}if(p==1)v.e=m,Di=D;else{for(l=1,h=y[0];h>=10;h/=10)l++;v.e=l+m*p-1,Y(v,a?u+v.e+1:u,o,D)}return v}})();function Y(e,r,t,n){var i,u,o,a,s,f,m,l,h,p=e.constructor;e:if(r!=null){if(l=e.d,!l)return e;for(i=1,a=l[0];a>=10;a/=10)i++;if(u=r-i,u<0)u+=K,o=r,m=l[h=0],s=m/Ne(10,i-o-1)%10|0;else if(h=Math.ceil((u+1)/K),a=l.length,h>=a)if(n){for(;a++<=h;)l.push(0);m=s=0,i=1,u%=K,o=u-K+1}else break e;else{for(m=a=l[h],i=1;a>=10;a/=10)i++;u%=K,o=u-K+i,s=o<0?0:m/Ne(10,i-o-1)%10|0}if(n=n||r<0||l[h+1]!==void 0||(o<0?m:m%Ne(10,i-o-1)),f=t<4?(s||n)&&(t==0||t==(e.s<0?3:2)):s>5||s==5&&(t==4||n||t==6&&(u>0?o>0?m/Ne(10,i-o):0:l[h-1])%10&1||t==(e.s<0?8:7)),r<1||!l[0])return l.length=0,f?(r-=e.e+1,l[0]=Ne(10,(K-r%K)%K),e.e=-r||0):l[0]=e.e=0,e;if(u==0?(l.length=h,a=1,h--):(l.length=h+1,a=Ne(10,K-u),l[h]=o>0?(m/Ne(10,i-o)%Ne(10,o)|0)*a:0),f)for(;;)if(h==0){for(u=1,o=l[0];o>=10;o/=10)u++;for(o=l[0]+=a,a=1;o>=10;o/=10)a++;u!=a&&(e.e++,l[0]==rr&&(l[0]=1));break}else{if(l[h]+=a,l[h]!=rr)break;l[h--]=0,a=1}for(u=l.length;l[--u]===0;)l.pop()}return j&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function or(e,r,t){if(!e.isFinite())return Ei(e);var n,i=e.e,u=ze(e.d),o=u.length;return r?(t&&(n=t-o)>0?u=u.charAt(0)+"."+u.slice(1)+pr(n):o>1&&(u=u.charAt(0)+"."+u.slice(1)),u=u+(e.e<0?"e":"e+")+e.e):i<0?(u="0."+pr(-i-1)+u,t&&(n=t-o)>0&&(u+=pr(n))):i>=o?(u+=pr(i+1-o),t&&(n=t-i-1)>0&&(u=u+"."+pr(n))):((n=i+1)<o&&(u=u.slice(0,n)+"."+u.slice(n)),t&&(n=t-o)>0&&(i+1===o&&(u+="."),u+=pr(n))),u}function xt(e,r){var t=e[0];for(r*=K;t>=10;t/=10)r++;return r}function dt(e,r,t){if(r>qo)throw j=!0,t&&(e.precision=t),Error(mi);return Y(new e(Dt),r,1,!0)}function ir(e,r,t){if(r>kt)throw Error(mi);return Y(new e(mt),r,t,!0)}function wi(e){var r=e.length-1,t=r*K+1;if(r=e[r],r){for(;r%10==0;r/=10)t--;for(r=e[0];r>=10;r/=10)t++}return t}function pr(e){for(var r="";e--;)r+="0";return r}function yi(e,r,t,n){var i,u=new e(1),o=Math.ceil(n/K+4);for(j=!1;;){if(t%2&&(u=u.times(r),gn(u.d,o)&&(i=!0)),t=Pe(t/2),t===0){t=u.d.length-1,i&&u.d[t]===0&&++u.d[t];break}r=r.times(r),gn(r.d,o)}return j=!0,u}function dn(e){return e.d[e.d.length-1]&1}function Fi(e,r,t){for(var n,i,u=new e(r[0]),o=0;++o<r.length;){if(i=new e(r[o]),!i.s){u=i;break}n=u.cmp(i),(n===t||n===0&&u.s===t)&&(u=i)}return u}function Yt(e,r){var t,n,i,u,o,a,s,f=0,m=0,l=0,h=e.constructor,p=h.rounding,D=h.precision;if(!e.d||!e.d[0]||e.e>17)return new h(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(r==null?(j=!1,s=D):s=r,a=new h(.03125);e.e>-2;)e=e.times(a),l+=5;for(n=Math.log(Ne(2,l))/Math.LN10*2+5|0,s+=n,t=u=o=new h(1),h.precision=s;;){if(u=Y(u.times(e),s,1),t=t.times(++m),a=o.plus(pe(u,t,s,1)),ze(a.d).slice(0,s)===ze(o.d).slice(0,s)){for(i=l;i--;)o=Y(o.times(o),s,1);if(r==null)if(f<3&&Vr(o.d,s-n,p,f))h.precision=s+=10,t=u=a=new h(1),m=0,f++;else return Y(o,h.precision=D,p,j=!0);else return h.precision=D,o}o=a}}function Dr(e,r){var t,n,i,u,o,a,s,f,m,l,h,p=1,D=10,c=e,d=c.d,v=c.constructor,y=v.rounding,g=v.precision;if(c.s<0||!d||!d[0]||!c.e&&d[0]==1&&d.length==1)return new v(d&&!d[0]?-1/0:c.s!=1?NaN:d?0:c);if(r==null?(j=!1,m=g):m=r,v.precision=m+=D,t=ze(d),n=t.charAt(0),Math.abs(u=c.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)c=c.times(e),t=ze(c.d),n=t.charAt(0),p++;u=c.e,n>1?(c=new v("0."+t),u++):c=new v(n+"."+t.slice(1))}else return f=dt(v,m+2,g).times(u+""),c=Dr(new v(n+"."+t.slice(1)),m-D).plus(f),v.precision=g,r==null?Y(c,g,y,j=!0):c;for(l=c,s=o=c=pe(c.minus(1),c.plus(1),m,1),h=Y(c.times(c),m,1),i=3;;){if(o=Y(o.times(h),m,1),f=s.plus(pe(o,new v(i),m,1)),ze(f.d).slice(0,m)===ze(s.d).slice(0,m))if(s=s.times(2),u!==0&&(s=s.plus(dt(v,m+2,g).times(u+""))),s=pe(s,new v(p),m,1),r==null)if(Vr(s.d,m-D,y,a))v.precision=m+=D,f=o=c=pe(l.minus(1),l.plus(1),m,1),h=Y(c.times(c),m,1),i=a=1;else return Y(s,v.precision=g,y,j=!0);else return v.precision=g,s;s=f,i+=2}}function Ei(e){return String(e.s*e.s/0)}function ut(e,r){var t,n,i;for((t=r.indexOf("."))>-1&&(r=r.replace(".","")),(n=r.search(/e/i))>0?(t<0&&(t=n),t+=+r.slice(n+1),r=r.substring(0,n)):t<0&&(t=r.length),n=0;r.charCodeAt(n)===48;n++);for(i=r.length;r.charCodeAt(i-1)===48;--i);if(r=r.slice(n,i),r){if(i-=n,e.e=t=t-n-1,e.d=[],n=(t+1)%K,t<0&&(n+=K),n<i){for(n&&e.d.push(+r.slice(0,n)),i-=K;n<i;)e.d.push(+r.slice(n,n+=K));r=r.slice(n),n=K-r.length}else n-=i;for(;n--;)r+="0";e.d.push(+r),j&&(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 Ro(e,r){var t,n,i,u,o,a,s,f,m;if(r.indexOf("_")>-1){if(r=r.replace(/(\d)_(?=\d)/g,"$1"),vi.test(r))return ut(e,r)}else if(r==="Infinity"||r==="NaN")return+r||(e.s=NaN),e.e=NaN,e.d=null,e;if(Oo.test(r))t=16,r=r.toLowerCase();else if(zo.test(r))t=2;else if($o.test(r))t=8;else throw Error(dr+r);for(u=r.search(/p/i),u>0?(s=+r.slice(u+1),r=r.substring(2,u)):r=r.slice(2),u=r.indexOf("."),o=u>=0,n=e.constructor,o&&(r=r.replace(".",""),a=r.length,u=a-u,i=yi(n,new n(t),u,u*2)),f=it(r,t,rr),m=f.length-1,u=m;f[u]===0;--u)f.pop();return u<0?new n(e.s*0):(e.e=xt(f,m),e.d=f,j=!1,o&&(e=pe(e,i,a*4)),s&&(e=e.times(Math.abs(s)<54?Ne(2,s):zr.pow(2,s))),j=!0,e)}function Lo(e,r){var t,n=r.d.length;if(n<3)return r.isZero()?r:Ir(e,2,r,r);t=1.4*Math.sqrt(n),t=t>16?16:t|0,r=r.times(1/Tt(5,t)),r=Ir(e,2,r,r);for(var i,u=new e(5),o=new e(16),a=new e(20);t--;)i=r.times(r),r=r.times(u.plus(i.times(o.times(i).minus(a))));return r}function Ir(e,r,t,n,i){var u,o,a,s,f=e.precision,m=Math.ceil(f/K);for(j=!1,s=t.times(t),a=new e(n);;){if(o=pe(a.times(s),new e(r++*r++),f,1),a=i?n.plus(o):n.minus(o),n=pe(o.times(s),new e(r++*r++),f,1),o=a.plus(n),o.d[m]!==void 0){for(u=m;o.d[u]===a.d[u]&&u--;);if(u==-1)break}u=a,a=n,n=o,o=u}return j=!0,o.d.length=m+1,o}function Tt(e,r){for(var t=e;--r;)t*=e;return t}function Ai(e,r){var t,n=r.s<0,i=ir(e,e.precision,1),u=i.times(.5);if(r=r.abs(),r.lte(u))return lr=n?4:1,r;if(t=r.divToInt(i),t.isZero())lr=n?3:2;else{if(r=r.minus(t.times(i)),r.lte(u))return lr=dn(t)?n?2:3:n?4:1,r;lr=dn(t)?n?1:4:n?3:2}return r.minus(i).abs()}function un(e,r,t,n){var i,u,o,a,s,f,m,l,h,p=e.constructor,D=t!==void 0;if(D?(Ve(t,1,vr),n===void 0?n=p.rounding:Ve(n,0,8)):(t=p.precision,n=p.rounding),!e.isFinite())m=Ei(e);else{for(m=or(e),o=m.indexOf("."),D?(i=2,r==16?t=t*4-3:r==8&&(t=t*3-2)):i=r,o>=0&&(m=m.replace(".",""),h=new p(1),h.e=m.length-o,h.d=it(or(h),10,i),h.e=h.d.length),l=it(m,10,i),u=s=l.length;l[--s]==0;)l.pop();if(!l[0])m=D?"0p+0":"0";else{if(o<0?u--:(e=new p(e),e.d=l,e.e=u,e=pe(e,h,t,n,0,i),l=e.d,u=e.e,f=Di),o=l[t],a=i/2,f=f||l[t+1]!==void 0,f=n<4?(o!==void 0||f)&&(n===0||n===(e.s<0?3:2)):o>a||o===a&&(n===4||f||n===6&&l[t-1]&1||n===(e.s<0?8:7)),l.length=t,f)for(;++l[--t]>i-1;)l[t]=0,t||(++u,l.unshift(1));for(s=l.length;!l[s-1];--s);for(o=0,m="";o<s;o++)m+=Gt.charAt(l[o]);if(D){if(s>1)if(r==16||r==8){for(o=r==16?4:3,--s;s%o;s++)m+="0";for(l=it(m,i,r),s=l.length;!l[s-1];--s);for(o=1,m="1.";o<s;o++)m+=Gt.charAt(l[o])}else m=m.charAt(0)+"."+m.slice(1);m=m+(u<0?"p":"p+")+u}else if(u<0){for(;++u;)m="0"+m;m="0."+m}else if(++u>s)for(u-=s;u--;)m+="0";else u<s&&(m=m.slice(0,u)+"."+m.slice(u))}m=(r==16?"0x":r==2?"0b":r==8?"0o":"")+m}return e.s<0?"-"+m:m}function gn(e,r){if(e.length>r)return e.length=r,!0}function Ho(e){return new this(e).abs()}function Zo(e){return new this(e).acos()}function Wo(e){return new this(e).acosh()}function Vo(e,r){return new this(e).plus(r)}function Go(e){return new this(e).asin()}function Jo(e){return new this(e).asinh()}function ko(e){return new this(e).atan()}function Yo(e){return new this(e).atanh()}function Xo(e,r){e=new this(e),r=new this(r);var t,n=this.precision,i=this.rounding,u=n+4;return!e.s||!r.s?t=new this(NaN):!e.d&&!r.d?(t=ir(this,u,1).times(r.s>0?.25:.75),t.s=e.s):!r.d||e.isZero()?(t=r.s<0?ir(this,n,i):new this(0),t.s=e.s):!e.d||r.isZero()?(t=ir(this,u,1).times(.5),t.s=e.s):r.s<0?(this.precision=u,this.rounding=1,t=this.atan(pe(e,r,u,1)),r=ir(this,u,1),this.precision=n,this.rounding=i,t=e.s<0?t.minus(r):t.plus(r)):t=this.atan(pe(e,r,u,1)),t}function Qo(e){return new this(e).cbrt()}function Ko(e){return Y(e=new this(e),e.e+1,2)}function jo(e,r,t){return new this(e).clamp(r,t)}function ea(e){if(!e||typeof e!="object")throw Error(Mt+"Object expected");var r,t,n,i=e.defaults===!0,u=["precision",1,vr,"rounding",0,8,"toExpNeg",-xr,0,"toExpPos",0,xr,"maxE",0,xr,"minE",-xr,0,"modulo",0,9];for(r=0;r<u.length;r+=3)if(t=u[r],i&&(this[t]=Jt[t]),(n=e[t])!==void 0)if(Pe(n)===n&&n>=u[r+1]&&n<=u[r+2])this[t]=n;else throw Error(dr+t+": "+n);if(t="crypto",i&&(this[t]=Jt[t]),(n=e[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(di);else this[t]=!1;else throw Error(dr+t+": "+n);return this}function ra(e){return new this(e).cos()}function ta(e){return new this(e).cosh()}function bi(e){var r,t,n;function i(u){var o,a,s,f=this;if(!(f instanceof i))return new i(u);if(f.constructor=i,vn(u)){f.s=u.s,j?!u.d||u.e>i.maxE?(f.e=NaN,f.d=null):u.e<i.minE?(f.e=0,f.d=[0]):(f.e=u.e,f.d=u.d.slice()):(f.e=u.e,f.d=u.d?u.d.slice():u.d);return}if(s=typeof u,s==="number"){if(u===0){f.s=1/u<0?-1:1,f.e=0,f.d=[0];return}if(u<0?(u=-u,f.s=-1):f.s=1,u===~~u&&u<1e7){for(o=0,a=u;a>=10;a/=10)o++;j?o>i.maxE?(f.e=NaN,f.d=null):o<i.minE?(f.e=0,f.d=[0]):(f.e=o,f.d=[u]):(f.e=o,f.d=[u]);return}if(u*0!==0){u||(f.s=NaN),f.e=NaN,f.d=null;return}return ut(f,u.toString())}if(s==="string")return(a=u.charCodeAt(0))===45?(u=u.slice(1),f.s=-1):(a===43&&(u=u.slice(1)),f.s=1),vi.test(u)?ut(f,u):Ro(f,u);if(s==="bigint")return u<0?(u=-u,f.s=-1):f.s=1,ut(f,u.toString());throw Error(dr+u)}if(i.prototype=z,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=ea,i.clone=bi,i.isDecimal=vn,i.abs=Ho,i.acos=Zo,i.acosh=Wo,i.add=Vo,i.asin=Go,i.asinh=Jo,i.atan=ko,i.atanh=Yo,i.atan2=Xo,i.cbrt=Qo,i.ceil=Ko,i.clamp=jo,i.cos=ra,i.cosh=ta,i.div=na,i.exp=ia,i.floor=ua,i.hypot=oa,i.ln=aa,i.log=sa,i.log10=ca,i.log2=fa,i.max=la,i.min=ha,i.mod=pa,i.mul=Da,i.pow=ma,i.random=da,i.round=ga,i.sign=va,i.sin=wa,i.sinh=ya,i.sqrt=Fa,i.sub=Ea,i.sum=Aa,i.tan=ba,i.tanh=Ca,i.trunc=_a,e===void 0&&(e={}),e&&e.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],r=0;r<n.length;)e.hasOwnProperty(t=n[r++])||(e[t]=this[t]);return i.config(e),i}function na(e,r){return new this(e).div(r)}function ia(e){return new this(e).exp()}function ua(e){return Y(e=new this(e),e.e+1,3)}function oa(){var e,r,t=new this(0);for(j=!1,e=0;e<arguments.length;)if(r=new this(arguments[e++]),r.d)t.d&&(t=t.plus(r.times(r)));else{if(r.s)return j=!0,new this(1/0);t=r}return j=!0,t.sqrt()}function vn(e){return e instanceof zr||e&&e.toStringTag===gi||!1}function aa(e){return new this(e).ln()}function sa(e,r){return new this(e).log(r)}function fa(e){return new this(e).log(2)}function ca(e){return new this(e).log(10)}function la(){return Fi(this,arguments,-1)}function ha(){return Fi(this,arguments,1)}function pa(e,r){return new this(e).mod(r)}function Da(e,r){return new this(e).mul(r)}function ma(e,r){return new this(e).pow(r)}function da(e){var r,t,n,i,u=0,o=new this(1),a=[];if(e===void 0?e=this.precision:Ve(e,1,vr),n=Math.ceil(e/K),this.crypto)if(crypto.getRandomValues)for(r=crypto.getRandomValues(new Uint32Array(n));u<n;)i=r[u],i>=429e7?r[u]=crypto.getRandomValues(new Uint32Array(1))[0]:a[u++]=i%1e7;else if(crypto.randomBytes){for(r=crypto.randomBytes(n*=4);u<n;)i=r[u]+(r[u+1]<<8)+(r[u+2]<<16)+((r[u+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(r,u):(a.push(i%1e7),u+=4);u=n/4}else throw Error(di);else for(;u<n;)a[u++]=Math.random()*1e7|0;for(n=a[--u],e%=K,n&&e&&(i=Ne(10,K-e),a[u]=(n/i|0)*i);a[u]===0;u--)a.pop();if(u<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=K)a.shift();for(n=1,i=a[0];i>=10;i/=10)n++;n<K&&(t-=K-n)}return o.e=t,o.d=a,o}function ga(e){return Y(e=new this(e),e.e+1,this.rounding)}function va(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function wa(e){return new this(e).sin()}function ya(e){return new this(e).sinh()}function Fa(e){return new this(e).sqrt()}function Ea(e,r){return new this(e).sub(r)}function Aa(){var e=0,r=arguments,t=new this(r[e]);for(j=!1;t.s&&++e<r.length;)t=t.plus(r[e]);return j=!0,Y(t,this.precision,this.rounding)}function ba(e){return new this(e).tan()}function Ca(e){return new this(e).tanh()}function _a(e){return Y(e=new this(e),e.e+1,1)}z[Symbol.for("nodejs.util.inspect.custom")]=z.toString;z[Symbol.toStringTag]="Decimal";var zr=z.constructor=bi(Jt);Dt=new zr(Dt);mt=new zr(mt);var Ba="BigNumber",Na=["?on","config"],Sa=G(Ba,Na,e=>{var{on:r,config:t}=e,n=zr.clone({precision:t.precision,modulo:zr.EUCLID});return n.prototype=Object.create(n.prototype),n.prototype.type="BigNumber",n.prototype.isBigNumber=!0,n.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},n.fromJSON=function(i){return new n(i.value)},r&&r("config",function(i,u){i.precision!==u.precision&&n.config({precision:i.precision})}),n},{isClass:!0});const $e=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:(Math.exp(e)+Math.exp(-e))*.5},Xe=Math.sinh||function(e){return Math.abs(e)<1e-9?e:(Math.exp(e)-Math.exp(-e))*.5},Ma=function(e){const r=Math.PI/4;if(-r>e||e>r)return Math.cos(e)-1;const t=e*e;return t*(t*(t*(t*(t*(t*(t*(t/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},Ht=function(e,r){return e=Math.abs(e),r=Math.abs(r),e<r&&([e,r]=[r,e]),e<1e8?Math.sqrt(e*e+r*r):(r/=e,e*Math.sqrt(1+r*r))},Nr=function(){throw SyntaxError("Invalid Param")};function Zt(e,r){const t=Math.abs(e),n=Math.abs(r);return e===0?Math.log(n):r===0?Math.log(t):t<3e3&&n<3e3?Math.log(e*e+r*r)*.5:(e=e*.5,r=r*.5,.5*Math.log(e*e+r*r)+Math.LN2)}const xa={re:0,im:0},yr=function(e,r){const t=xa;if(e==null)t.re=t.im=0;else if(r!==void 0)t.re=e,t.im=r;else switch(typeof e){case"object":if("im"in e&&"re"in e)t.re=e.re,t.im=e.im;else if("abs"in e&&"arg"in e){if(!isFinite(e.abs)&&isFinite(e.arg))return M.INFINITY;t.re=e.abs*Math.cos(e.arg),t.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!isFinite(e.r)&&isFinite(e.phi))return M.INFINITY;t.re=e.r*Math.cos(e.phi),t.im=e.r*Math.sin(e.phi)}else e.length===2?(t.re=e[0],t.im=e[1]):Nr();break;case"string":t.im=t.re=0;const n=e.replace(/_/g,"").match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g);let i=1,u=0;n===null&&Nr();for(let o=0;o<n.length;o++){const a=n[o];a===" "||a===" "||a===`
|
|
9
|
+
`||(a==="+"?i++:a==="-"?u++:a==="i"||a==="I"?(i+u===0&&Nr(),n[o+1]!==" "&&!isNaN(n[o+1])?(t.im+=parseFloat((u%2?"-":"")+n[o+1]),o++):t.im+=parseFloat((u%2?"-":"")+"1"),i=u=0):((i+u===0||isNaN(a))&&Nr(),n[o+1]==="i"||n[o+1]==="I"?(t.im+=parseFloat((u%2?"-":"")+a),o++):t.re+=parseFloat((u%2?"-":"")+a),i=u=0))}i+u>0&&Nr();break;case"number":t.im=0,t.re=e;break;default:Nr()}return isNaN(t.re)||isNaN(t.im),t};function M(e,r){if(!(this instanceof M))return new M(e,r);const t=yr(e,r);this.re=t.re,this.im=t.im}M.prototype={re:0,im:0,sign:function(){const e=Ht(this.re,this.im);return new M(this.re/e,this.im/e)},add:function(e,r){const t=yr(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n||i?n&&i?M.NAN:M.INFINITY:new M(this.re+t.re,this.im+t.im)},sub:function(e,r){const t=yr(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n||i?n&&i?M.NAN:M.INFINITY:new M(this.re-t.re,this.im-t.im)},mul:function(e,r){const t=yr(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im)),u=this.re===0&&this.im===0,o=t.re===0&&t.im===0;return n&&o||i&&u?M.NAN:n||i?M.INFINITY:t.im===0&&this.im===0?new M(this.re*t.re,0):new M(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)},div:function(e,r){const t=yr(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im)),u=this.re===0&&this.im===0,o=t.re===0&&t.im===0;if(u&&o||n&&i)return M.NAN;if(o||n)return M.INFINITY;if(u||i)return M.ZERO;if(t.im===0)return new M(this.re/t.re,this.im/t.re);if(Math.abs(t.re)<Math.abs(t.im)){const a=t.re/t.im,s=t.re*a+t.im;return new M((this.re*a+this.im)/s,(this.im*a-this.re)/s)}else{const a=t.im/t.re,s=t.im*a+t.re;return new M((this.re+this.im*a)/s,(this.im-this.re*a)/s)}},pow:function(e,r){const t=yr(e,r),n=this.re===0&&this.im===0;if(t.re===0&&t.im===0)return M.ONE;if(t.im===0){if(this.im===0&&this.re>0)return new M(Math.pow(this.re,t.re),0);if(this.re===0)switch((t.re%4+4)%4){case 0:return new M(Math.pow(this.im,t.re),0);case 1:return new M(0,Math.pow(this.im,t.re));case 2:return new M(-Math.pow(this.im,t.re),0);case 3:return new M(0,-Math.pow(this.im,t.re))}}if(n&&t.re>0)return M.ZERO;const u=Math.atan2(this.im,this.re),o=Zt(this.re,this.im);let a=Math.exp(t.re*o-t.im*u),s=t.im*o+t.re*u;return new M(a*Math.cos(s),a*Math.sin(s))},sqrt:function(){const e=this.re,r=this.im;if(r===0)return e>=0?new M(Math.sqrt(e),0):new M(0,Math.sqrt(-e));const t=Ht(e,r);let n=Math.sqrt(.5*(t+Math.abs(e))),i=Math.abs(r)/(2*n);return e>=0?new M(n,r<0?-i:i):new M(i,r<0?-n:n)},exp:function(){const e=Math.exp(this.re);return this.im===0?new M(e,0):new M(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){const e=this.re,r=this.im;return new M(Math.expm1(e)*Math.cos(r)+Ma(r),Math.exp(e)*Math.sin(r))},log:function(){const e=this.re,r=this.im;return r===0&&e>0?new M(Math.log(e),0):new M(Zt(e,r),Math.atan2(r,e))},abs:function(){return Ht(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){const e=this.re,r=this.im;return new M(Math.sin(e)*$e(r),Math.cos(e)*Xe(r))},cos:function(){const e=this.re,r=this.im;return new M(Math.cos(e)*$e(r),-Math.sin(e)*Xe(r))},tan:function(){const e=2*this.re,r=2*this.im,t=Math.cos(e)+$e(r);return new M(Math.sin(e)/t,Xe(r)/t)},cot:function(){const e=2*this.re,r=2*this.im,t=Math.cos(e)-$e(r);return new M(-Math.sin(e)/t,Xe(r)/t)},sec:function(){const e=this.re,r=this.im,t=.5*$e(2*r)+.5*Math.cos(2*e);return new M(Math.cos(e)*$e(r)/t,Math.sin(e)*Xe(r)/t)},csc:function(){const e=this.re,r=this.im,t=.5*$e(2*r)-.5*Math.cos(2*e);return new M(Math.sin(e)*$e(r)/t,-Math.cos(e)*Xe(r)/t)},asin:function(){const e=this.re,r=this.im,t=new M(r*r-e*e+1,-2*e*r).sqrt(),n=new M(t.re-r,t.im+e).log();return new M(n.im,-n.re)},acos:function(){const e=this.re,r=this.im,t=new M(r*r-e*e+1,-2*e*r).sqrt(),n=new M(t.re-r,t.im+e).log();return new M(Math.PI/2-n.im,n.re)},atan:function(){const e=this.re,r=this.im;if(e===0){if(r===1)return new M(0,1/0);if(r===-1)return new M(0,-1/0)}const t=e*e+(1-r)*(1-r),n=new M((1-r*r-e*e)/t,-2*e/t).log();return new M(-.5*n.im,.5*n.re)},acot:function(){const e=this.re,r=this.im;if(r===0)return new M(Math.atan2(1,e),0);const t=e*e+r*r;return t!==0?new M(e/t,-r/t).atan():new M(e!==0?e/0:0,r!==0?-r/0:0).atan()},asec:function(){const e=this.re,r=this.im;if(e===0&&r===0)return new M(0,1/0);const t=e*e+r*r;return t!==0?new M(e/t,-r/t).acos():new M(e!==0?e/0:0,r!==0?-r/0:0).acos()},acsc:function(){const e=this.re,r=this.im;if(e===0&&r===0)return new M(Math.PI/2,1/0);const t=e*e+r*r;return t!==0?new M(e/t,-r/t).asin():new M(e!==0?e/0:0,r!==0?-r/0:0).asin()},sinh:function(){const e=this.re,r=this.im;return new M(Xe(e)*Math.cos(r),$e(e)*Math.sin(r))},cosh:function(){const e=this.re,r=this.im;return new M($e(e)*Math.cos(r),Xe(e)*Math.sin(r))},tanh:function(){const e=2*this.re,r=2*this.im,t=$e(e)+Math.cos(r);return new M(Xe(e)/t,Math.sin(r)/t)},coth:function(){const e=2*this.re,r=2*this.im,t=$e(e)-Math.cos(r);return new M(Xe(e)/t,-Math.sin(r)/t)},csch:function(){const e=this.re,r=this.im,t=Math.cos(2*r)-$e(2*e);return new M(-2*Xe(e)*Math.cos(r)/t,2*$e(e)*Math.sin(r)/t)},sech:function(){const e=this.re,r=this.im,t=Math.cos(2*r)+$e(2*e);return new M(2*$e(e)*Math.cos(r)/t,-2*Xe(e)*Math.sin(r)/t)},asinh:function(){let e=this.im;this.im=-this.re,this.re=e;const r=this.asin();return this.re=-this.im,this.im=e,e=r.re,r.re=-r.im,r.im=e,r},acosh:function(){const e=this.acos();if(e.im<=0){const r=e.re;e.re=-e.im,e.im=r}else{const r=e.im;e.im=-e.re,e.re=r}return e},atanh:function(){const e=this.re,r=this.im,t=e>1&&r===0,n=1-e,i=1+e,u=n*n+r*r,o=u!==0?new M((i*n-r*r)/u,(r*n+i*r)/u):new M(e!==-1?e/0:0,r!==0?r/0:0),a=o.re;return o.re=Zt(o.re,o.im)/2,o.im=Math.atan2(o.im,a)/2,t&&(o.im=-o.im),o},acoth:function(){const e=this.re,r=this.im;if(e===0&&r===0)return new M(0,Math.PI/2);const t=e*e+r*r;return t!==0?new M(e/t,-r/t).atanh():new M(e!==0?e/0:0,r!==0?-r/0:0).atanh()},acsch:function(){const e=this.re,r=this.im;if(r===0)return new M(e!==0?Math.log(e+Math.sqrt(e*e+1)):1/0,0);const t=e*e+r*r;return t!==0?new M(e/t,-r/t).asinh():new M(e!==0?e/0:0,r!==0?-r/0:0).asinh()},asech:function(){const e=this.re,r=this.im;if(this.isZero())return M.INFINITY;const t=e*e+r*r;return t!==0?new M(e/t,-r/t).acosh():new M(e!==0?e/0:0,r!==0?-r/0:0).acosh()},inverse:function(){if(this.isZero())return M.INFINITY;if(this.isInfinite())return M.ZERO;const e=this.re,r=this.im,t=e*e+r*r;return new M(e/t,-r/t)},conjugate:function(){return new M(this.re,-this.im)},neg:function(){return new M(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new M(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new M(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new M(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,r){const t=yr(e,r);return Math.abs(t.re-this.re)<=M.EPSILON&&Math.abs(t.im-this.im)<=M.EPSILON},clone:function(){return new M(this.re,this.im)},toString:function(){let e=this.re,r=this.im,t="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<M.EPSILON&&(e=0),Math.abs(r)<M.EPSILON&&(r=0),r===0?t+e:(e!==0?(t+=e,t+=" ",r<0?(r=-r,t+="-"):t+="+",t+=" "):r<0&&(r=-r,t+="-"),r!==1&&(t+=r),t+"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()}};M.ZERO=new M(0,0);M.ONE=new M(1,0);M.I=new M(0,1);M.PI=new M(Math.PI,0);M.E=new M(Math.E,0);M.INFINITY=new M(1/0,1/0);M.NAN=new M(NaN,NaN);M.EPSILON=1e-15;var Ta="Complex",Ia=[],za=G(Ta,Ia,()=>(Object.defineProperty(M,"name",{value:"Complex"}),M.prototype.constructor=M,M.prototype.type="Complex",M.prototype.isComplex=!0,M.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},M.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},M.prototype.format=function(e){var r="",t=this.im,n=this.re,i=Vt(this.re,e),u=Vt(this.im,e),o=ne(e)?e:e?e.precision:null;if(o!==null){var a=Math.pow(10,-o);Math.abs(n/t)<a&&(n=0),Math.abs(t/n)<a&&(t=0)}return t===0?r=i:n===0?t===1?r="i":t===-1?r="-i":r=u+"i":t<0?t===-1?r=i+" - i":r=i+" - "+u.substring(1)+"i":t===1?r=i+" + i":r=i+" + "+u+"i",r},M.fromPolar=function(e){switch(arguments.length){case 1:{var r=arguments[0];if(typeof r=="object")return M(r);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var t=arguments[0],n=arguments[1];if(ne(t)){if(ai(n)&&n.hasBase("ANGLE")&&(n=n.toNumber("rad")),ne(n))return new M({r:t,phi:n});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")}},M.prototype.valueOf=M.prototype.toString,M.fromJSON=function(e){return new M(e)},M.compare=function(e,r){return e.re>r.re?1:e.re<r.re?-1:e.im>r.im?1:e.im<r.im?-1:0},M),{isClass:!0});typeof BigInt>"u"&&(BigInt=function(e){if(isNaN(e))throw new Error("");return e});const k=BigInt(0),re=BigInt(1),Gr=BigInt(2),Xt=BigInt(5),We=BigInt(10),Oa=2e3,L={s:re,n:k,d:re};function fr(e,r){try{e=BigInt(e)}catch{throw hr()}return e*r}function er(e){return typeof e=="bigint"?e:Math.floor(e)}function Fe(e,r){if(r===k)throw on();const t=Object.create(Qe.prototype);t.s=e<k?-re:re,e=e<k?-e:e;const n=Fr(e,r);return t.n=e/n,t.d=r/n,t}function Sr(e){const r={};let t=e,n=Gr,i=Xt-re;for(;i<=t;){for(;t%n===k;)t/=n,r[n]=(r[n]||k)+re;i+=re+Gr*n++}return t!==e?t>1&&(r[t]=(r[t]||k)+re):r[e]=(r[e]||k)+re,r}const xe=function(e,r){let t=k,n=re,i=re;if(e!=null)if(r!==void 0){if(typeof e=="bigint")t=e;else{if(isNaN(e))throw hr();if(e%1!==0)throw wn();t=BigInt(e)}if(typeof r=="bigint")n=r;else{if(isNaN(r))throw hr();if(r%1!==0)throw wn();n=BigInt(r)}i=t*n}else if(typeof e=="object"){if("d"in e&&"n"in e)t=BigInt(e.n),n=BigInt(e.d),"s"in e&&(t*=BigInt(e.s));else if(0 in e)t=BigInt(e[0]),1 in e&&(n=BigInt(e[1]));else if(typeof e=="bigint")t=e;else throw hr();i=t*n}else if(typeof e=="number"){if(isNaN(e))throw hr();if(e<0&&(i=-re,e=-e),e%1===0)t=BigInt(e);else{let u=1,o=0,a=1,s=1,f=1,m=1e7;for(e>=1&&(u=10**Math.floor(1+Math.log10(e)),e/=u);a<=m&&f<=m;){let l=(o+s)/(a+f);if(e===l){a+f<=m?(t=o+s,n=a+f):f>a?(t=s,n=f):(t=o,n=a);break}else e>l?(o+=s,a+=f):(s+=o,f+=a),a>m?(t=s,n=f):(t=o,n=a)}t=BigInt(t)*BigInt(u),n=BigInt(n)}}else if(typeof e=="string"){let u=0,o=k,a=k,s=k,f=re,m=re,l=e.replace(/_/g,"").match(/\d+|./g);if(l===null)throw hr();if(l[u]==="-"?(i=-re,u++):l[u]==="+"&&u++,l.length===u+1?a=fr(l[u++],i):l[u+1]==="."||l[u]==="."?(l[u]!=="."&&(o=fr(l[u++],i)),u++,(u+1===l.length||l[u+1]==="("&&l[u+3]===")"||l[u+1]==="'"&&l[u+3]==="'")&&(a=fr(l[u],i),f=We**BigInt(l[u].length),u++),(l[u]==="("&&l[u+2]===")"||l[u]==="'"&&l[u+2]==="'")&&(s=fr(l[u+1],i),m=We**BigInt(l[u+1].length)-re,u+=3)):l[u+1]==="/"||l[u+1]===":"?(a=fr(l[u],i),f=fr(l[u+2],re),u+=3):l[u+3]==="/"&&l[u+1]===" "&&(o=fr(l[u],i),a=fr(l[u+2],i),f=fr(l[u+4],re),u+=5),l.length<=u)n=f*m,i=t=s+n*o+m*a;else throw hr()}else if(typeof e=="bigint")t=e,i=e,n=re;else throw hr();if(n===k)throw on();L.s=i<k?-re:re,L.n=t<k?-t:t,L.d=n<k?-n:n};function $a(e,r,t){let n=re;for(;r>k;e=e*e%t,r>>=re)r&re&&(n=n*e%t);return n}function Pa(e,r){for(;r%Gr===k;r/=Gr);for(;r%Xt===k;r/=Xt);if(r===re)return k;let t=We%r,n=1;for(;t!==re;n++)if(t=t*We%r,n>Oa)return k;return BigInt(n)}function qa(e,r,t){let n=re,i=$a(We,t,r);for(let u=0;u<300;u++){if(n===i)return BigInt(u);n=n*We%r,i=i*We%r}return 0}function Fr(e,r){if(!e)return r;if(!r)return e;for(;;){if(e%=r,!e)return r;if(r%=e,!r)return e}}function Qe(e,r){if(xe(e,r),this instanceof Qe)e=Fr(L.d,L.n),this.s=L.s,this.n=L.n/e,this.d=L.d/e;else return Fe(L.s*L.n,L.d)}var on=function(){return new Error("Division by Zero")},hr=function(){return new Error("Invalid argument")},wn=function(){return new Error("Parameters must be integer")};Qe.prototype={s:re,n:k,d:re,abs:function(){return Fe(this.n,this.d)},neg:function(){return Fe(-this.s*this.n,this.d)},add:function(e,r){return xe(e,r),Fe(this.s*this.n*L.d+L.s*this.d*L.n,this.d*L.d)},sub:function(e,r){return xe(e,r),Fe(this.s*this.n*L.d-L.s*this.d*L.n,this.d*L.d)},mul:function(e,r){return xe(e,r),Fe(this.s*L.s*this.n*L.n,this.d*L.d)},div:function(e,r){return xe(e,r),Fe(this.s*L.s*this.n*L.d,this.d*L.n)},clone:function(){return Fe(this.s*this.n,this.d)},mod:function(e,r){if(e===void 0)return Fe(this.s*this.n%this.d,re);if(xe(e,r),k===L.n*this.d)throw on();return Fe(this.s*(L.d*this.n)%(L.n*this.d),L.d*this.d)},gcd:function(e,r){return xe(e,r),Fe(Fr(L.n,this.n)*Fr(L.d,this.d),L.d*this.d)},lcm:function(e,r){return xe(e,r),L.n===k&&this.n===k?Fe(k,re):Fe(L.n*this.n,Fr(L.n,this.n)*Fr(L.d,this.d))},inverse:function(){return Fe(this.s*this.d,this.n)},pow:function(e,r){if(xe(e,r),L.d===re)return L.s<k?Fe((this.s*this.d)**L.n,this.n**L.n):Fe((this.s*this.n)**L.n,this.d**L.n);if(this.s<k)return null;let t=Sr(this.n),n=Sr(this.d),i=re,u=re;for(let o in t)if(o!=="1"){if(o==="0"){i=k;break}if(t[o]*=L.n,t[o]%L.d===k)t[o]/=L.d;else return null;i*=BigInt(o)**t[o]}for(let o in n)if(o!=="1"){if(n[o]*=L.n,n[o]%L.d===k)n[o]/=L.d;else return null;u*=BigInt(o)**n[o]}return L.s<k?Fe(u,i):Fe(i,u)},log:function(e,r){if(xe(e,r),this.s<=k||L.s<=k)return null;const t={},n=Sr(L.n),i=Sr(L.d),u=Sr(this.n),o=Sr(this.d);for(const f in i)n[f]=(n[f]||k)-i[f];for(const f in o)u[f]=(u[f]||k)-o[f];for(const f in n)f!=="1"&&(t[f]=!0);for(const f in u)f!=="1"&&(t[f]=!0);let a=null,s=null;for(const f in t){const m=n[f]||k,l=u[f]||k;if(m===k){if(l!==k)return null;continue}let h=l,p=m;const D=Fr(h,p);if(h/=D,p/=D,a===null&&s===null)a=h,s=p;else if(h*s!==a*p)return null}return a!==null&&s!==null?Fe(a,s):null},equals:function(e,r){return xe(e,r),this.s*this.n*L.d===L.s*L.n*this.d},lt:function(e,r){return xe(e,r),this.s*this.n*L.d<L.s*L.n*this.d},lte:function(e,r){return xe(e,r),this.s*this.n*L.d<=L.s*L.n*this.d},gt:function(e,r){return xe(e,r),this.s*this.n*L.d>L.s*L.n*this.d},gte:function(e,r){return xe(e,r),this.s*this.n*L.d>=L.s*L.n*this.d},compare:function(e,r){xe(e,r);let t=this.s*this.n*L.d-L.s*L.n*this.d;return(k<t)-(t<k)},ceil:function(e){return e=We**BigInt(e||0),Fe(er(this.s*e*this.n/this.d)+(e*this.n%this.d>k&&this.s>=k?re:k),e)},floor:function(e){return e=We**BigInt(e||0),Fe(er(this.s*e*this.n/this.d)-(e*this.n%this.d>k&&this.s<k?re:k),e)},round:function(e){return e=We**BigInt(e||0),Fe(er(this.s*e*this.n/this.d)+this.s*((this.s>=k?re:k)+Gr*(e*this.n%this.d)>this.d?re:k),e)},roundTo:function(e,r){xe(e,r);const t=this.n*L.d,n=this.d*L.n,i=t%n;let u=er(t/n);return i+i>=n&&u++,Fe(this.s*u*L.n,L.d)},divisible:function(e,r){return xe(e,r),!(!(L.n*this.d)||this.n*L.d%(L.n*this.d))},valueOf:function(){return Number(this.s*this.n)/Number(this.d)},toString:function(e){let r=this.n,t=this.d;e=e||15;let n=Pa(r,t),i=qa(r,t,n),u=this.s<k?"-":"";if(u+=er(r/t),r%=t,r*=We,r&&(u+="."),n){for(let o=i;o--;)u+=er(r/t),r%=t,r*=We;u+="(";for(let o=n;o--;)u+=er(r/t),r%=t,r*=We;u+=")"}else for(let o=e;r&&o--;)u+=er(r/t),r%=t,r*=We;return u},toFraction:function(e){let r=this.n,t=this.d,n=this.s<k?"-":"";if(t===re)n+=r;else{let i=er(r/t);e&&i>k&&(n+=i,n+=" ",r%=t),n+=r,n+="/",n+=t}return n},toLatex:function(e){let r=this.n,t=this.d,n=this.s<k?"-":"";if(t===re)n+=r;else{let i=er(r/t);e&&i>k&&(n+=i,r%=t),n+="\\frac{",n+=r,n+="}{",n+=t,n+="}"}return n},toContinued:function(){let e=this.n,r=this.d,t=[];do{t.push(er(e/r));let n=e%r;e=r,r=n}while(e!==re);return t},simplify:function(e){const r=BigInt(1/(e||.001)|0),t=this.abs(),n=t.toContinued();for(let i=1;i<n.length;i++){let u=Fe(n[i-1],re);for(let a=i-2;a>=0;a--)u=u.inverse().add(n[a]);let o=u.sub(t);if(o.n*r<o.d)return u.mul(this.s)}return this}};var Ua="Fraction",Ra=[],La=G(Ua,Ra,()=>(Object.defineProperty(Qe,"name",{value:"Fraction"}),Qe.prototype.constructor=Qe,Qe.prototype.type="Fraction",Qe.prototype.isFraction=!0,Qe.prototype.toJSON=function(){return{mathjs:"Fraction",n:String(this.s*this.n),d:String(this.d)}},Qe.fromJSON=function(e){return new Qe(e)},Qe),{isClass:!0}),Ha="Matrix",Za=[],Wa=G(Ha,Za,()=>{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(r,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(r,t,n){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(r){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(r,t,n){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(r,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(r,t){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(r,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(r){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(r){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});function Wt(e,r,t){var n=e.constructor,i=new n(2),u="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!we(t))throw new Error("size must be an integer");if(e.greaterThan(i.pow(t-1).sub(1))||e.lessThan(i.pow(t-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!e.isInteger())throw new Error("Value must be an integer");e.lessThan(0)&&(e=e.add(i.pow(t))),u="i".concat(t)}switch(r){case 2:return"".concat(e.toBinary()).concat(u);case 8:return"".concat(e.toOctal()).concat(u);case 16:return"".concat(e.toHexadecimal()).concat(u);default:throw new Error("Base ".concat(r," not supported "))}}function Va(e,r){if(typeof r=="function")return r(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var{notation:t,precision:n,wordSize:i}=ci(r);switch(t){case"fixed":return Ja(e,n);case"exponential":return yn(e,n);case"engineering":return Ga(e,n);case"bin":return Wt(e,2,i);case"oct":return Wt(e,8,i);case"hex":return Wt(e,16,i);case"auto":{var u=Fn(r?.lowerExp,-3),o=Fn(r?.upperExp,5);if(e.isZero())return"0";var a,s=e.toSignificantDigits(n),f=s.e;return f>=u&&f<o?a=s.toFixed():a=yn(e,n),a.replace(/((\.\d*?)(0+))($|e)/,function(){var m=arguments[2],l=arguments[4];return m!=="."?m+l:l})}default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function Ga(e,r){var t=e.e,n=t%3===0?t:t<0?t-3-t%3:t-t%3,i=e.mul(Math.pow(10,-n)),u=i.toPrecision(r);if(u.includes("e")){var o=e.constructor;u=new o(u).toFixed()}return u+"e"+(t>=0?"+":"")+n.toString()}function yn(e,r){return r!==void 0?e.toExponential(r-1):e.toExponential()}function Ja(e,r){return e.toFixed(r)}function Fn(e,r){return ne(e)?e:Ee(e)?e.toNumber():r}function Be(e,r){var t=ka(e,r);return r&&typeof r=="object"&&"truncate"in r&&t.length>r.truncate?t.substring(0,r.truncate-3)+"...":t}function ka(e,r){if(typeof e=="number")return Vt(e,r);if(Ee(e))return Va(e,r);if(Ya(e))return!r||r.fraction!=="decimal"?"".concat(e.s*e.n,"/").concat(e.d):e.toString();if(Array.isArray(e))return Ci(e,r);if(Te(e))return En(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(r);if(e&&e.toString(r)!=={}.toString())return e.toString(r);var t=Object.keys(e).map(n=>En(n)+": "+Be(e[n],r));return"{"+t.join(", ")+"}"}return String(e)}function En(e){for(var r=String(e),t="",n=0;n<r.length;){var i=r.charAt(n);t+=i in An?An[i]:i,n++}return'"'+t+'"'}var An={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function Ci(e,r){if(Array.isArray(e)){for(var t="[",n=e.length,i=0;i<n;i++)i!==0&&(t+=", "),t+=Ci(e[i],r);return t+="]",t}else return Be(e,r)}function Ya(e){return e&&typeof e=="object"&&typeof e.s=="bigint"&&typeof e.n=="bigint"&&typeof e.d=="bigint"||!1}function ie(e,r,t){if(!(this instanceof ie))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=r,this.relation=t,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(r)?"["+r.join(", ")+"]":r)+")",this.stack=new Error().stack}ie.prototype=new RangeError;ie.prototype.constructor=RangeError;ie.prototype.name="DimensionError";ie.prototype.isDimensionError=!0;function Ar(e,r,t){if(!(this instanceof Ar))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=r):(this.min=r,this.max=t),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}Ar.prototype=new RangeError;Ar.prototype.constructor=RangeError;Ar.prototype.name="IndexError";Ar.prototype.isIndexError=!0;function Oe(e){for(var r=[];Array.isArray(e);)r.push(e.length),e=e[0];return r}function _i(e,r,t){var n,i=e.length;if(i!==r[t])throw new ie(i,r[t]);if(t<r.length-1){var u=t+1;for(n=0;n<i;n++){var o=e[n];if(!Array.isArray(o))throw new ie(r.length-1,r.length,"<");_i(e[n],r,u)}}else for(n=0;n<i;n++)if(Array.isArray(e[n]))throw new ie(r.length+1,r.length,">")}function bn(e,r){var t=r.length===0;if(t){if(Array.isArray(e))throw new ie(e.length,0)}else _i(e,r,0)}function gt(e,r){var t=e.isMatrix?e._size:Oe(e),n=r._sourceSize;n.forEach((i,u)=>{if(i!==null&&i!==t[u])throw new ie(i,t[u])})}function me(e,r){if(e!==void 0){if(!ne(e)||!we(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||typeof r=="number"&&e>=r)throw new Ar(e,r)}}function Or(e){for(var r=0;r<e._dimensions.length;++r){var t=e._dimensions[r];if(t._data&&ve(t._data)){if(t._size[0]===0)return!0}else if(t.isRange){if(t.start===t.end)return!0}else if(Te(t)&&t.length===0)return!0}return!1}function vt(e,r,t){if(!Array.isArray(r))throw new TypeError("Array expected");if(r.length===0)throw new Error("Resizing to scalar is not supported");r.forEach(function(i){if(!ne(i)||!we(i)||i<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Be(r)+")")}),(ne(e)||Ee(e))&&(e=[e]);var n=t!==void 0?t:0;return Qt(e,r,0,n),e}function Qt(e,r,t,n){var i,u,o=e.length,a=r[t],s=Math.min(o,a);if(e.length=a,t<r.length-1){var f=t+1;for(i=0;i<s;i++)u=e[i],Array.isArray(u)||(u=[u],e[i]=u),Qt(u,r,f,n);for(i=s;i<a;i++)u=[],e[i]=u,Qt(u,r,f,n)}else{for(i=0;i<s;i++)for(;Array.isArray(e[i]);)e[i]=e[i][0];for(i=s;i<a;i++)e[i]=n}}function Bi(e,r){var t=Qa(e,!0),n=t.length;if(!Array.isArray(e)||!Array.isArray(r))throw new TypeError("Array expected");if(r.length===0)throw new ie(0,n,"!=");r=an(r,n);var i=Ni(r);if(n!==i)throw new ie(i,n,"!=");try{return Xa(t,r)}catch(u){throw u instanceof ie?new ie(i,n,"!="):u}}function an(e,r){var t=Ni(e),n=e.slice(),i=-1,u=e.indexOf(i),o=e.indexOf(i,u+1)>=0;if(o)throw new Error("More than one wildcard in sizes");var a=u>=0,s=r%t===0;if(a)if(s)n[u]=-r/t;else throw new Error("Could not replace wildcard, since "+r+" is no multiple of "+-t);return n}function Ni(e){return e.reduce((r,t)=>r*t,1)}function Xa(e,r){for(var t=e,n,i=r.length-1;i>0;i--){var u=r[i];n=[];for(var o=t.length/u,a=0;a<o;a++)n.push(t.slice(a*u,(a+1)*u));t=n}return t}function Si(e,r,t,n){var i=n||Oe(e);if(t)for(var u=0;u<t;u++)e=[e],i.unshift(1);for(e=Mi(e,r,0);i.length<r;)i.push(1);return e}function Mi(e,r,t){var n,i;if(Array.isArray(e)){var u=t+1;for(n=0,i=e.length;n<i;n++)e[n]=Mi(e[n],r,u)}else for(var o=t;o<r;o++)e=[e];return e}function Qa(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!Array.isArray(e))return e;if(typeof r!="boolean")throw new TypeError("Boolean expected for second argument of flatten");var t=[];return r?i(e):n(e),t;function n(u){for(var o=0;o<u.length;o++){var a=u[o];Array.isArray(a)?n(a):t.push(a)}}function i(u){if(Array.isArray(u[0]))for(var o=0;o<u.length;o++)i(u[o]);else for(var a=0;a<u.length;a++)t.push(u[a])}}function It(e,r){for(var t,n=0,i=0;i<e.length;i++){var u=e[i],o=Array.isArray(u);if(i===0&&o&&(n=u.length),o&&u.length!==n)return;var a=o?It(u,r):r(u);if(t===void 0)t=a;else if(t!==a)return"mixed"}return t}function xi(e,r,t,n){if(n<t){if(e.length!==r.length)throw new ie(e.length,r.length);for(var i=[],u=0;u<e.length;u++)i[u]=xi(e[u],r[u],t,n+1);return i}else return e.concat(r)}function Ti(){var e=Array.prototype.slice.call(arguments,0,-1),r=Array.prototype.slice.call(arguments,-1);if(e.length===1)return e[0];if(e.length>1)return e.slice(1).reduce(function(t,n){return xi(t,n,r,0)},e[0]);throw new Error("Wrong number of arguments in function concat")}function Ii(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];for(var n=r.map(h=>h.length),i=Math.max(...n),u=new Array(i).fill(null),o=0;o<r.length;o++)for(var a=r[o],s=n[o],f=0;f<s;f++){var m=i-s+f;a[f]>u[m]&&(u[m]=a[f])}for(var l=0;l<r.length;l++)zi(r[l],u);return u}function zi(e,r){for(var t=r.length,n=e.length,i=0;i<n;i++){var u=t-n+i;if(e[i]<r[u]&&e[i]>1||e[i]>r[u])throw new Error("shape mismatch: mismatch is found in arg with shape (".concat(e,") not possible to broadcast dimension ").concat(n," with size ").concat(e[i]," to size ").concat(r[u]))}}function Kt(e,r){var t=Oe(e);if(mr(t,r))return e;zi(t,r);var n=Ii(t,r),i=n.length,u=[...Array(i-t.length).fill(1),...t],o=ja(e);t.length<i&&(o=Bi(o,u),t=Oe(o));for(var a=0;a<i;a++)t[a]<n[a]&&(o=Ka(o,n[a],a),t=Oe(o));return o}function Ka(e,r,t){return Ti(...Array(r).fill(e),t)}function Oi(e,r){if(!Array.isArray(e))throw new Error("Array expected");var t=Oe(e);if(r.length!==t.length)throw new ie(r.length,t.length);for(var n=0;n<r.length;n++)me(r[n],t[n]);return r.reduce((i,u)=>i[u],e)}function Cn(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(e.length===0)return[];if(t)return u(e);var n=[];return i(e,0);function i(o,a){if(Array.isArray(o)){for(var s=o.length,f=Array(s),m=0;m<s;m++)n[a]=m,f[m]=i(o[m],a+1);return f}else return r(o,n.slice(0,a),e)}function u(o){if(Array.isArray(o)){for(var a=o.length,s=Array(a),f=0;f<a;f++)s[f]=u(o[f]);return s}else return r(o)}}function ja(e){return ct([],e)}function wt(e,r,t,n){if(pt.isTypedFunction(e)){var i;if(n)i=1;else{var u=r.isMatrix?r.size():Oe(r),o=u.length?u[u.length-1]===0:!0;if(o)return{isUnary:n,fn:e};var a=u.map(()=>0),s=r.isMatrix?r.get(a):Oi(r,a);i=ts(e,s,a,r)}var f;if(r.isMatrix&&r.dataType!=="mixed"&&r.dataType!==void 0){var m=es(e,i);f=m!==void 0?m:e}else f=e;return i>=1&&i<=3?{isUnary:i===1,fn:function(){for(var h=arguments.length,p=new Array(h),D=0;D<h;D++)p[D]=arguments[D];return _n(f,p.slice(0,i),t,e.name)}}:{isUnary:!1,fn:function(){for(var h=arguments.length,p=new Array(h),D=0;D<h;D++)p[D]=arguments[D];return _n(f,p,t,e.name)}}}return n===void 0?{isUnary:rs(e),fn:e}:{isUnary:n,fn:e}}function es(e,r){var t=[];if(Object.entries(e.signatures).forEach(n=>{var[i,u]=n;i.split(",").length===r&&t.push(u)}),t.length===1)return t[0]}function rs(e){if(e.length!==1)return!1;var r=e.toString();if(/arguments/.test(r))return!1;var t=r.match(/\(.*?\)/);return!/\.\.\./.test(t)}function ts(e,r,t,n){for(var i=[r,t,n],u=3;u>0;u--){var o=i.slice(0,u);if(pt.resolve(e,o)!==null)return u}}function _n(e,r,t,n){try{return e(...r)}catch(i){ns(i,r,t,n)}}function ns(e,r,t,n){var i;if(e instanceof TypeError&&((i=e.data)===null||i===void 0?void 0:i.category)==="wrongType"){var u=[];throw u.push("value: ".concat(ur(r[0]))),r.length>=2&&u.push("index: ".concat(ur(r[1]))),r.length>=3&&u.push("array: ".concat(ur(r[2]))),new TypeError("Function ".concat(t," cannot apply callback arguments ")+"".concat(n,"(").concat(u.join(", "),") at index ").concat(JSON.stringify(r[1])))}else throw new TypeError("Function ".concat(t," cannot apply callback arguments ")+"to function ".concat(n,": ").concat(e.message))}var is="DenseMatrix",us=["Matrix","config"],os=G(is,us,e=>{var{Matrix:r,config:t}=e;function n(l,h){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(h&&!Te(h))throw new Error("Invalid datatype: "+h);if(ye(l))l.type==="DenseMatrix"?(this._data=de(l._data),this._size=de(l._size),this._datatype=h||l._datatype):(this._data=l.toArray(),this._size=l.size(),this._datatype=h||l._datatype);else if(l&&ve(l.data)&&ve(l.size))this._data=l.data,this._size=l.size,bn(this._data,this._size),this._datatype=h||l.datatype;else if(ve(l))this._data=m(l),this._size=Oe(this._data),bn(this._data,this._size),this._datatype=h;else{if(l)throw new TypeError("Unsupported type of data ("+ur(l)+")");this._data=[],this._size=[0],this._datatype=h}}n.prototype=new r,n.prototype.createDenseMatrix=function(l,h){return new n(l,h)},Object.defineProperty(n,"name",{value:"DenseMatrix"}),n.prototype.constructor=n,n.prototype.type="DenseMatrix",n.prototype.isDenseMatrix=!0,n.prototype.getDataType=function(){return It(this._data,ur)},n.prototype.storage=function(){return"dense"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(l,h){return new n(l,h)},n.prototype.subset=function(l,h,p){switch(arguments.length){case 1:return i(this,l);case 2:case 3:return o(this,l,h,p);default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.get=function(l){return Oi(this._data,l)},n.prototype.set=function(l,h,p){if(!ve(l))throw new TypeError("Array expected");if(l.length<this._size.length)throw new ie(l.length,this._size.length,"<");var D,c,d,v=l.map(function(g){return g+1});f(this,v,p);var y=this._data;for(D=0,c=l.length-1;D<c;D++)d=l[D],me(d,y.length),y=y[d];return d=l[l.length-1],me(d,y.length),y[d]=h,this};function i(l,h){if(!Nt(h))throw new TypeError("Invalid index");var p=t.legacySubset?h.size().every(F=>F===1):h.isScalar();if(p)return l.get(h.min());var D=h.size();if(D.length!==l._size.length)throw new ie(D.length,l._size.length);for(var c=h.min(),d=h.max(),v=0,y=l._size.length;v<y;v++)me(c[v],l._size[v]),me(d[v],l._size[v]);var g=new n,A=u(l._data,h);return g._size=A.size,g._datatype=l._datatype,g._data=A.data,t.legacySubset?g.reshape(h.size()):g}function u(l,h){var p=h.size().length-1,D=Array(p);return{data:c(l),size:D.filter(d=>d!==null)};function c(d){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,y=h.dimension(v);function g(A,F){return ne(A)?F(A):A.map(F).valueOf()}return ne(y)?D[v]=null:D[v]=y.size()[0],v<p?g(y,A=>(me(A,d.length),c(d[A],v+1))):g(y,A=>(me(A,d.length),d[A]))}}function o(l,h,p,D){if(!h||h.isIndex!==!0)throw new TypeError("Invalid index");var c=h.size(),d=h.isScalar(),v;if(ye(p)?(v=p.size(),p=p.valueOf()):v=Oe(p),d){if(v.length!==0)throw new TypeError("Scalar expected");l.set(h.min(),p,D)}else{if(!mr(v,c)){if(v.length===0)p=Kt([p],c);else try{p=Kt(p,c)}catch{}v=Oe(p)}if(c.length<l._size.length)throw new ie(c.length,l._size.length,"<");if(v.length<c.length){for(var y=0,g=0;c[y]===1&&v[y]===1;)y++;for(;c[y]===1;)g++,y++;p=Si(p,c.length,g,v)}if(!mr(c,v))throw new ie(c,v,">");var A=h.max().map(function(F){return F+1});f(l,A,D),a(l._data,h,p)}return l}function a(l,h,p){var D=h.size().length-1;c(l,p);function c(d,v){var y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,g=h.dimension(y),A=(w,_)=>{me(w,d.length),c(d[w],v[_[0]],y+1)},F=(w,_)=>{me(w,d.length),d[w]=v[_[0]]};y<D?ne(g)?A(g,[0]):g.forEach(A):ne(g)?F(g,[0]):g.forEach(F)}}n.prototype.resize=function(l,h,p){if(!ht(l))throw new TypeError("Array or Matrix expected");var D=l.valueOf().map(d=>Array.isArray(d)&&d.length===1?d[0]:d),c=p?this.clone():this;return s(c,D,h)};function s(l,h,p){if(h.length===0){for(var D=l._data;ve(D);)D=D[0];return D}return l._size=h.slice(0),l._data=vt(l._data,l._size,p),l}n.prototype.reshape=function(l,h){var p=h?this.clone():this;p._data=Bi(p._data,l);var D=p._size.reduce((c,d)=>c*d);return p._size=an(l,D),p};function f(l,h,p){for(var D=l._size.slice(0),c=!1;D.length<h.length;)D.push(0),c=!0;for(var d=0,v=h.length;d<v;d++)h[d]>D[d]&&(D[d]=h[d],c=!0);c&&s(l,D,p)}n.prototype.clone=function(){var l=new n({data:de(this._data),size:de(this._size),datatype:this._datatype});return l},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(l){var h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,p=this,D=p._size.length-1;if(D<0)return p.clone();var c=wt(l,p,"map",h),d=c.fn,v=p.create(void 0,p._datatype);if(v._size=p._size,h||c.isUnary)return v._data=_(p._data),v;if(D===0){for(var y=p.valueOf(),g=Array(y.length),A=0;A<y.length;A++)g[A]=d(y[A],[A],p);return v._data=g,v}var F=[];return v._data=w(p._data),v;function w(b){var B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,S=Array(b.length);if(B<D)for(var x=0;x<b.length;x++)F[B]=x,S[x]=w(b[x],B+1);else for(var O=0;O<b.length;O++)F[B]=O,S[O]=d(b[O],F.slice(),p);return S}function _(b){var B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,S=Array(b.length);if(B<D)for(var x=0;x<b.length;x++)S[x]=_(b[x],B+1);else for(var O=0;O<b.length;O++)S[O]=d(b[O]);return S}},n.prototype.forEach=function(l){var h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,p=this,D=p._size.length-1;if(D<0)return;var c=wt(l,p,"map",h),d=c.fn;if(h||c.isUnary){A(p._data);return}if(D===0){for(var v=0;v<p._data.length;v++)d(p._data[v],[v],p);return}var y=[];g(p._data);function g(F){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(w<D)for(var _=0;_<F.length;_++)y[w]=_,g(F[_],w+1);else for(var b=0;b<F.length;b++)y[w]=b,d(F[b],y.slice(),p)}function A(F){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(w<D)for(var _=0;_<F.length;_++)A(F[_],w+1);else for(var b=0;b<F.length;b++)d(F[b])}},n.prototype[Symbol.iterator]=function*(){var l=this._size.length-1;if(!(l<0)){if(l===0){for(var h=0;h<this._data.length;h++)yield{value:this._data[h],index:[h]};return}for(var p=Array(l+1).fill(0),D=this._size.reduce((g,A)=>g*A,1),c=0;c<D;c++){for(var d=this._data,v=0;v<l;v++)d=d[p[v]];yield{value:d[p[l]],index:p.slice()};for(var y=l;y>=0&&(p[y]++,!(p[y]<this._size[y]));y--)p[y]=0}}},n.prototype.rows=function(){var l=[],h=this.size();if(h.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var p=this._data;for(var D of p)l.push(new n([D],this._datatype));return l},n.prototype.columns=function(){var l=this,h=[],p=this.size();if(p.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var D=this._data,c=function(y){var g=D.map(A=>[A[y]]);h.push(new n(g,l._datatype))},d=0;d<p[1];d++)c(d);return h},n.prototype.toArray=function(){return de(this._data)},n.prototype.valueOf=function(){return this._data},n.prototype.format=function(l){return Be(this._data,l)},n.prototype.toString=function(){return Be(this._data)},n.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(l){if(l){if(Ee(l)&&(l=l.toNumber()),!ne(l)||!we(l))throw new TypeError("The parameter k must be an integer number")}else l=0;for(var h=l>0?l:0,p=l<0?-l:0,D=this._size[0],c=this._size[1],d=Math.min(D-p,c-h),v=[],y=0;y<d;y++)v[y]=this._data[y+p][y+h];return new n({data:v,size:[d],datatype:this._datatype})},n.diagonal=function(l,h,p,D){if(!ve(l))throw new TypeError("Array expected, size parameter");if(l.length!==2)throw new Error("Only two dimensions matrix are supported");if(l=l.map(function(b){if(Ee(b)&&(b=b.toNumber()),!ne(b)||!we(b)||b<1)throw new Error("Size values must be positive integers");return b}),p){if(Ee(p)&&(p=p.toNumber()),!ne(p)||!we(p))throw new TypeError("The parameter k must be an integer number")}else p=0;var c=p>0?p:0,d=p<0?-p:0,v=l[0],y=l[1],g=Math.min(v-d,y-c),A;if(ve(h)){if(h.length!==g)throw new Error("Invalid value array length");A=function(B){return h[B]}}else if(ye(h)){var F=h.size();if(F.length!==1||F[0]!==g)throw new Error("Invalid matrix length");A=function(B){return h.get([B])}}else A=function(){return h};D||(D=Ee(A(0))?A(0).mul(0):0);var w=[];if(l.length>0){w=vt(w,l,D);for(var _=0;_<g;_++)w[_+d][_+c]=A(_)}return new n({data:w,size:[v,y]})},n.fromJSON=function(l){return new n(l)},n.prototype.swapRows=function(l,h){if(!ne(l)||!we(l)||!ne(h)||!we(h))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return me(l,this._size[0]),me(h,this._size[0]),n._swapRows(l,h,this._data),this},n._swapRows=function(l,h,p){var D=p[l];p[l]=p[h],p[h]=D};function m(l){return ye(l)?m(l.valueOf()):ve(l)?l.map(m):l}return n},{isClass:!0});function Ge(e,r,t){if(!t)return ye(e)?e.map(i=>r(i),!1,!0):Cn(e,r,!0);var n=i=>i===0?i:r(i);return ye(e)?e.map(i=>n(i),!1,!0):Cn(e,n,!0)}var Bn="isInteger",as=["typed","equal"],ss=G(Bn,as,e=>{var{typed:r,equal:t}=e;return r(Bn,{number:n=>Number.isFinite(n)?t(n,Math.round(n)):!1,BigNumber:n=>n.isFinite()?t(n.round(),n):!1,bigint:n=>!0,Fraction:n=>n.d===1n,"Array | Matrix":r.referToSelf(n=>i=>Ge(i,n))})}),sn="number",zt="number, number";function $i(e){return Math.abs(e)}$i.signature=sn;function Pi(e,r){return e+r}Pi.signature=zt;function qi(e,r){return e-r}qi.signature=zt;function Ui(e,r){return e*r}Ui.signature=zt;function Ri(e){return-e}Ri.signature=sn;function yt(e){return Bo(e)}yt.signature=sn;function Li(e,r){return e*e<1&&r===1/0||e*e>1&&r===-1/0?0:Math.pow(e,r)}Li.signature=zt;function Hr(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!we(r)||r<0||r>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(li(e,r))}var fs=Math.PI,cs="number";function Hi(e){return e>0}Hi.signature=cs;function gr(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e-9,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(t<=0)throw new Error("Relative tolerance must be greater than 0");if(n<0)throw new Error("Absolute tolerance must be at least 0");return e.isNaN()||r.isNaN()?!1:!e.isFinite()||!r.isFinite()?e.eq(r):e.eq(r)?!0:e.minus(r).abs().lte(e.constructor.max(e.constructor.max(e.abs(),r.abs()).mul(t),n))}var Nn="isPositive",ls=["typed","config"],hs=G(Nn,ls,e=>{var{typed:r,config:t}=e;return r(Nn,{number:n=>tr(n,0,t.relTol,t.absTol)?!1:Hi(n),BigNumber:n=>gr(n,new n.constructor(0),t.relTol,t.absTol)?!1:!n.isNeg()&&!n.isZero()&&!n.isNaN(),bigint:n=>n>0n,Fraction:n=>n.s>0n&&n.n>0n,Unit:r.referToSelf(n=>i=>r.find(n,i.valueType())(i.value)),"Array | Matrix":r.referToSelf(n=>i=>Ge(i,n))})}),Sn="isZero",ps=["typed","equalScalar"],Ds=G(Sn,ps,e=>{var{typed:r,equalScalar:t}=e;return r(Sn,{"number | BigNumber | Complex | Fraction":n=>t(n,0),bigint:n=>n===0n,Unit:r.referToSelf(n=>i=>r.find(n,i.valueType())(i.value)),"Array | Matrix":r.referToSelf(n=>i=>Ge(i,n))})});function ms(e,r,t,n){return tr(e.re,r.re,t,n)&&tr(e.im,r.im,t,n)}var Yr=G("compareUnits",["typed"],e=>{var{typed:r}=e;return{"Unit, Unit":r.referToSelf(t=>(n,i)=>{if(!n.equalBase(i))throw new Error("Cannot compare units with different base");return r.find(t,[n.valueType(),i.valueType()])(n.value,i.value)})}}),Ft="equalScalar",ds=["typed","config"],gs=G(Ft,ds,e=>{var{typed:r,config:t}=e,n=Yr({typed:r});return r(Ft,{"boolean, boolean":function(u,o){return u===o},"number, number":function(u,o){return tr(u,o,t.relTol,t.absTol)},"BigNumber, BigNumber":function(u,o){return u.eq(o)||gr(u,o,t.relTol,t.absTol)},"bigint, bigint":function(u,o){return u===o},"Fraction, Fraction":function(u,o){return u.equals(o)},"Complex, Complex":function(u,o){return ms(u,o,t.relTol,t.absTol)}},n)});G(Ft,["typed","config"],e=>{var{typed:r,config:t}=e;return r(Ft,{"number, number":function(i,u){return tr(i,u,t.relTol,t.absTol)}})});var vs="SparseMatrix",ws=["typed","equalScalar","Matrix"],ys=G(vs,ws,e=>{var{typed:r,equalScalar:t,Matrix:n}=e;function i(c,d){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(d&&!Te(d))throw new Error("Invalid datatype: "+d);if(ye(c))u(this,c,d);else if(c&&ve(c.index)&&ve(c.ptr)&&ve(c.size))this._values=c.values,this._index=c.index,this._ptr=c.ptr,this._size=c.size,this._datatype=d||c.datatype;else if(ve(c))o(this,c,d);else{if(c)throw new TypeError("Unsupported type of data ("+ur(c)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=d}}function u(c,d,v){d.type==="SparseMatrix"?(c._values=d._values?de(d._values):void 0,c._index=de(d._index),c._ptr=de(d._ptr),c._size=de(d._size),c._datatype=v||d._datatype):o(c,d.valueOf(),v||d._datatype)}function o(c,d,v){c._values=[],c._index=[],c._ptr=[],c._datatype=v;var y=d.length,g=0,A=t,F=0;if(Te(v)&&(A=r.find(t,[v,v])||t,F=r.convert(0,v)),y>0){var w=0;do{c._ptr.push(c._index.length);for(var _=0;_<y;_++){var b=d[_];if(ve(b)){if(w===0&&g<b.length&&(g=b.length),w<b.length){var B=b[w];A(B,F)||(c._values.push(B),c._index.push(_))}}else w===0&&g<1&&(g=1),A(b,F)||(c._values.push(b),c._index.push(_))}w++}while(w<g)}for(;c._ptr.length<=g;)c._ptr.push(c._index.length);c._size=[y,g]}i.prototype=new n,i.prototype.createSparseMatrix=function(c,d){return new i(c,d)},Object.defineProperty(i,"name",{value:"SparseMatrix"}),i.prototype.constructor=i,i.prototype.type="SparseMatrix",i.prototype.isSparseMatrix=!0,i.prototype.getDataType=function(){return It(this._values,ur)},i.prototype.storage=function(){return"sparse"},i.prototype.datatype=function(){return this._datatype},i.prototype.create=function(c,d){return new i(c,d)},i.prototype.density=function(){var c=this._size[0],d=this._size[1];return c!==0&&d!==0?this._index.length/(c*d):0},i.prototype.subset=function(c,d,v){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return a(this,c);case 2:case 3:return s(this,c,d,v);default:throw new SyntaxError("Wrong number of arguments")}};function a(c,d){if(!Nt(d))throw new TypeError("Invalid index");var v=d.isScalar();if(v)return c.get(d.min());var y=d.size();if(y.length!==c._size.length)throw new ie(y.length,c._size.length);var g,A,F,w,_=d.min(),b=d.max();for(g=0,A=c._size.length;g<A;g++)me(_[g],c._size[g]),me(b[g],c._size[g]);var B=c._values,S=c._index,x=c._ptr,O=d.dimension(0),V=d.dimension(1),R=[],H=[];function $(ue,oe){H[ue]=oe[0],R[ue]=!0}Number.isInteger(O)?$(O,[0]):O.forEach($);var Q=B?[]:void 0,J=[],X=[];function ee(ue){for(X.push(J.length),F=x[ue],w=x[ue+1];F<w;F++)g=S[F],R[g]===!0&&(J.push(H[g]),Q&&Q.push(B[F]))}return Number.isInteger(V)?ee(V):V.forEach(ee),X.push(J.length),new i({values:Q,index:J,ptr:X,size:y,datatype:c._datatype})}function s(c,d,v,y){if(!d||d.isIndex!==!0)throw new TypeError("Invalid index");var g=d.size(),A=d.isScalar(),F;if(ye(v)?(F=v.size(),v=v.toArray()):F=Oe(v),A){if(F.length!==0)throw new TypeError("Scalar expected");c.set(d.min(),v,y)}else{if(g.length!==1&&g.length!==2)throw new ie(g.length,c._size.length,"<");if(F.length<g.length){for(var w=0,_=0;g[w]===1&&F[w]===1;)w++;for(;g[w]===1;)_++,w++;v=Si(v,g.length,_,F)}if(!mr(g,F))throw new ie(g,F,">");if(g.length===1){var b=d.dimension(0);x(b,(O,V)=>{me(O),c.set([O,0],v[V[0]],y)})}else{var B=d.dimension(0),S=d.dimension(1);x(B,(O,V)=>{me(O),x(S,(R,H)=>{me(R),c.set([O,R],v[V[0]][H[0]],y)})})}}return c;function x(O,V){ne(O)?V(O,[0]):O.forEach(V)}}i.prototype.get=function(c){if(!ve(c))throw new TypeError("Array expected");if(c.length!==this._size.length)throw new ie(c.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var d=c[0],v=c[1];me(d,this._size[0]),me(v,this._size[1]);var y=f(d,this._ptr[v],this._ptr[v+1],this._index);return y<this._ptr[v+1]&&this._index[y]===d?this._values[y]:0},i.prototype.set=function(c,d,v){if(!ve(c))throw new TypeError("Array expected");if(c.length!==this._size.length)throw new ie(c.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var y=c[0],g=c[1],A=this._size[0],F=this._size[1],w=t,_=0;Te(this._datatype)&&(w=r.find(t,[this._datatype,this._datatype])||t,_=r.convert(0,this._datatype)),(y>A-1||g>F-1)&&(h(this,Math.max(y+1,A),Math.max(g+1,F),v),A=this._size[0],F=this._size[1]),me(y,A),me(g,F);var b=f(y,this._ptr[g],this._ptr[g+1],this._index);return b<this._ptr[g+1]&&this._index[b]===y?w(d,_)?m(b,g,this._values,this._index,this._ptr):this._values[b]=d:w(d,_)||l(b,y,g,d,this._values,this._index,this._ptr),this};function f(c,d,v,y){if(v-d===0)return v;for(var g=d;g<v;g++)if(y[g]===c)return g;return d}function m(c,d,v,y,g){v.splice(c,1),y.splice(c,1);for(var A=d+1;A<g.length;A++)g[A]--}function l(c,d,v,y,g,A,F){g.splice(c,0,y),A.splice(c,0,d);for(var w=v+1;w<F.length;w++)F[w]++}i.prototype.resize=function(c,d,v){if(!ht(c))throw new TypeError("Array or Matrix expected");var y=c.valueOf().map(A=>Array.isArray(A)&&A.length===1?A[0]:A);if(y.length!==2)throw new Error("Only two dimensions matrix are supported");y.forEach(function(A){if(!ne(A)||!we(A)||A<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Be(y)+")")});var g=v?this.clone():this;return h(g,y[0],y[1],d)};function h(c,d,v,y){var g=y||0,A=t,F=0;Te(c._datatype)&&(A=r.find(t,[c._datatype,c._datatype])||t,F=r.convert(0,c._datatype),g=r.convert(g,c._datatype));var w=!A(g,F),_=c._size[0],b=c._size[1],B,S,x;if(v>b){for(S=b;S<v;S++)if(c._ptr[S]=c._values.length,w)for(B=0;B<_;B++)c._values.push(g),c._index.push(B);c._ptr[v]=c._values.length}else v<b&&(c._ptr.splice(v+1,b-v),c._values.splice(c._ptr[v],c._values.length),c._index.splice(c._ptr[v],c._index.length));if(b=v,d>_){if(w){var O=0;for(S=0;S<b;S++){c._ptr[S]=c._ptr[S]+O,x=c._ptr[S+1]+O;var V=0;for(B=_;B<d;B++,V++)c._values.splice(x+V,0,g),c._index.splice(x+V,0,B),O++}c._ptr[b]=c._values.length}}else if(d<_){var R=0;for(S=0;S<b;S++){c._ptr[S]=c._ptr[S]-R;var H=c._ptr[S],$=c._ptr[S+1]-R;for(x=H;x<$;x++)B=c._index[x],B>d-1&&(c._values.splice(x,1),c._index.splice(x,1),R++)}c._ptr[S]=c._values.length}return c._size[0]=d,c._size[1]=v,c}i.prototype.reshape=function(c,d){if(!ve(c))throw new TypeError("Array expected");if(c.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");c.forEach(function(X){if(!ne(X)||!we(X)||X<=-2||X===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Be(c)+")")});var v=this._size[0]*this._size[1];c=an(c,v);var y=c[0]*c[1];if(v!==y)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var g=d?this.clone():this;if(this._size[0]===c[0]&&this._size[1]===c[1])return g;for(var A=[],F=0;F<g._ptr.length;F++)for(var w=0;w<g._ptr[F+1]-g._ptr[F];w++)A.push(F);for(var _=g._values.slice(),b=g._index.slice(),B=0;B<g._index.length;B++){var S=b[B],x=A[B],O=S*g._size[1]+x;A[B]=O%c[1],b[B]=Math.floor(O/c[1])}g._values.length=0,g._index.length=0,g._ptr.length=c[1]+1,g._size=c.slice();for(var V=0;V<g._ptr.length;V++)g._ptr[V]=0;for(var R=0;R<_.length;R++){var H=b[R],$=A[R],Q=_[R],J=f(H,g._ptr[$],g._ptr[$+1],g._index);l(J,H,$,Q,g._values,g._index,g._ptr)}return g},i.prototype.clone=function(){var c=new i({values:this._values?de(this._values):void 0,index:de(this._index),ptr:de(this._ptr),size:de(this._size),datatype:this._datatype});return c},i.prototype.size=function(){return this._size.slice(0)},i.prototype.map=function(c,d){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var v=this,y=this._size[0],g=this._size[1],A=wt(c,v,"map"),F=function(_,b,B){return A.fn(_,[b,B],v)};return p(this,0,y-1,0,g-1,F,d)};function p(c,d,v,y,g,A,F){var w=[],_=[],b=[],B=t,S=0;Te(c._datatype)&&(B=r.find(t,[c._datatype,c._datatype])||t,S=r.convert(0,c._datatype));for(var x=function(ce,Ce,be){var Ae=A(ce,Ce,be);B(Ae,S)||(w.push(Ae),_.push(Ce))},O=y;O<=g;O++){b.push(w.length);var V=c._ptr[O],R=c._ptr[O+1];if(F)for(var H=V;H<R;H++){var $=c._index[H];$>=d&&$<=v&&x(c._values[H],$-d,O-y)}else{for(var Q={},J=V;J<R;J++){var X=c._index[J];Q[X]=c._values[J]}for(var ee=d;ee<=v;ee++){var ue=ee in Q?Q[ee]:0;x(ue,ee-d,O-y)}}}return b.push(w.length),new i({values:w,index:_,ptr:b,size:[v-d+1,g-y+1]})}i.prototype.forEach=function(c,d){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var v=this,y=this._size[0],g=this._size[1],A=wt(c,v,"forEach"),F=0;F<g;F++){var w=this._ptr[F],_=this._ptr[F+1];if(d)for(var b=w;b<_;b++){var B=this._index[b];A.fn(this._values[b],[B,F],v)}else{for(var S={},x=w;x<_;x++){var O=this._index[x];S[O]=this._values[x]}for(var V=0;V<y;V++){var R=V in S?S[V]:0;A.fn(R,[V,F],v)}}}},i.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var c=this._size[1],d=0;d<c;d++)for(var v=this._ptr[d],y=this._ptr[d+1],g=v;g<y;g++){var A=this._index[g];yield{value:this._values[g],index:[A,d]}}},i.prototype.toArray=function(){return D(this._values,this._index,this._ptr,this._size,!0)},i.prototype.valueOf=function(){return D(this._values,this._index,this._ptr,this._size,!1)};function D(c,d,v,y,g){var A=y[0],F=y[1],w=[],_,b;for(_=0;_<A;_++)for(w[_]=[],b=0;b<F;b++)w[_][b]=0;for(b=0;b<F;b++)for(var B=v[b],S=v[b+1],x=B;x<S;x++)_=d[x],w[_][b]=c?g?de(c[x]):c[x]:1;return w}return i.prototype.format=function(c){for(var d=this._size[0],v=this._size[1],y=this.density(),g="Sparse Matrix ["+Be(d,c)+" x "+Be(v,c)+"] density: "+Be(y,c)+`
|
|
10
|
+
`,A=0;A<v;A++)for(var F=this._ptr[A],w=this._ptr[A+1],_=F;_<w;_++){var b=this._index[_];g+=`
|
|
11
|
+
(`+Be(b,c)+", "+Be(A,c)+") ==> "+(this._values?Be(this._values[_],c):"X")}return g},i.prototype.toString=function(){return Be(this.toArray())},i.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},i.prototype.diagonal=function(c){if(c){if(Ee(c)&&(c=c.toNumber()),!ne(c)||!we(c))throw new TypeError("The parameter k must be an integer number")}else c=0;var d=c>0?c:0,v=c<0?-c:0,y=this._size[0],g=this._size[1],A=Math.min(y-v,g-d),F=[],w=[],_=[];_[0]=0;for(var b=d;b<g&&F.length<A;b++)for(var B=this._ptr[b],S=this._ptr[b+1],x=B;x<S;x++){var O=this._index[x];if(O===b-d+v){F.push(this._values[x]),w[F.length-1]=O-v;break}}return _.push(F.length),new i({values:F,index:w,ptr:_,size:[A,1]})},i.fromJSON=function(c){return new i(c)},i.diagonal=function(c,d,v,y,g){if(!ve(c))throw new TypeError("Array expected, size parameter");if(c.length!==2)throw new Error("Only two dimensions matrix are supported");if(c=c.map(function(X){if(Ee(X)&&(X=X.toNumber()),!ne(X)||!we(X)||X<1)throw new Error("Size values must be positive integers");return X}),v){if(Ee(v)&&(v=v.toNumber()),!ne(v)||!we(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var A=t,F=0;Te(g)&&(A=r.find(t,[g,g])||t,F=r.convert(0,g));var w=v>0?v:0,_=v<0?-v:0,b=c[0],B=c[1],S=Math.min(b-_,B-w),x;if(ve(d)){if(d.length!==S)throw new Error("Invalid value array length");x=function(ee){return d[ee]}}else if(ye(d)){var O=d.size();if(O.length!==1||O[0]!==S)throw new Error("Invalid matrix length");x=function(ee){return d.get([ee])}}else x=function(){return d};for(var V=[],R=[],H=[],$=0;$<B;$++){H.push(V.length);var Q=$-w;if(Q>=0&&Q<S){var J=x(Q);A(J,F)||(R.push(Q+_),V.push(J))}}return H.push(V.length),new i({values:V,index:R,ptr:H,size:[b,B]})},i.prototype.swapRows=function(c,d){if(!ne(c)||!we(c)||!ne(d)||!we(d))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return me(c,this._size[0]),me(d,this._size[0]),i._swapRows(c,d,this._size[1],this._values,this._index,this._ptr),this},i._forEachRow=function(c,d,v,y,g){for(var A=y[c],F=y[c+1],w=A;w<F;w++)g(v[w],d[w])},i._swapRows=function(c,d,v,y,g,A){for(var F=0;F<v;F++){var w=A[F],_=A[F+1],b=f(c,w,_,g),B=f(d,w,_,g);if(b<_&&B<_&&g[b]===c&&g[B]===d){if(y){var S=y[b];y[b]=y[B],y[B]=S}continue}if(b<_&&g[b]===c&&(B>=_||g[B]!==d)){var x=y?y[b]:void 0;g.splice(B,0,d),y&&y.splice(B,0,x),g.splice(B<=b?b+1:b,1),y&&y.splice(B<=b?b+1:b,1);continue}if(B<_&&g[B]===d&&(b>=_||g[b]!==c)){var O=y?y[B]:void 0;g.splice(b,0,c),y&&y.splice(b,0,O),g.splice(b<=B?B+1:B,1),y&&y.splice(b<=B?B+1:B,1)}}},i},{isClass:!0}),Fs="number",Es=["typed"];function As(e){var r=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(r){var t={"0b":2,"0o":8,"0x":16}[r[1]],n=r[2],i=r[3];return{input:e,radix:t,integerPart:n,fractionalPart:i}}else return null}function bs(e){for(var r=parseInt(e.integerPart,e.radix),t=0,n=0;n<e.fractionalPart.length;n++){var i=parseInt(e.fractionalPart[n],e.radix);t+=i/Math.pow(e.radix,n+1)}var u=r+t;if(isNaN(u))throw new SyntaxError('String "'+e.input+'" is not a valid number');return u}var Cs=G(Fs,Es,e=>{var{typed:r}=e,t=r("number",{"":function(){return 0},number:function(i){return i},string:function(i){if(i==="NaN")return NaN;var u=As(i);if(u)return bs(u);var o=0,a=i.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);a&&(o=Number(a[2]),i=a[1]);var s=Number(i);if(isNaN(s))throw new SyntaxError('String "'+i+'" is not a valid number');if(a){if(s>2**o-1)throw new SyntaxError('String "'.concat(i,'" is out of range'));s>=2**(o-1)&&(s=s-2**o)}return s},BigNumber:function(i){return i.toNumber()},bigint:function(i){return Number(i)},Fraction:function(i){return i.valueOf()},Unit:r.referToSelf(n=>i=>{var u=i.clone();return u.value=n(i.value),u}),null:function(i){return 0},"Unit, string | Unit":function(i,u){return i.toNumber(u)},"Array | Matrix":r.referToSelf(n=>i=>Ge(i,n))});return t.fromJSON=function(n){return parseFloat(n.value)},t}),_s="bignumber",Bs=["typed","BigNumber"],Ns=G(_s,Bs,e=>{var{typed:r,BigNumber:t}=e;return r("bignumber",{"":function(){return new t(0)},number:function(i){return new t(i+"")},string:function(i){var u=i.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(u){var o=u[2],a=t(u[1]),s=new t(2).pow(Number(o));if(a.gt(s.sub(1)))throw new SyntaxError('String "'.concat(i,'" is out of range'));var f=new t(2).pow(Number(o)-1);return a.gte(f)?a.sub(s):a}return new t(i)},BigNumber:function(i){return i},bigint:function(i){return new t(i.toString())},Unit:r.referToSelf(n=>i=>{var u=i.clone();return u.value=n(i.value),u}),Fraction:function(i){return new t(String(i.n)).div(String(i.d)).times(String(i.s))},null:function(i){return new t(0)},"Array | Matrix":r.referToSelf(n=>i=>Ge(i,n))})}),Ss="complex",Ms=["typed","Complex"],xs=G(Ss,Ms,e=>{var{typed:r,Complex:t}=e;return r("complex",{"":function(){return t.ZERO},number:function(i){return new t(i,0)},"number, number":function(i,u){return new t(i,u)},"BigNumber, BigNumber":function(i,u){return new t(i.toNumber(),u.toNumber())},Fraction:function(i){return new t(i.valueOf(),0)},Complex:function(i){return i.clone()},string:function(i){return t(i)},null:function(i){return t(0)},Object:function(i){if("re"in i&&"im"in i)return new t(i.re,i.im);if("r"in i&&"phi"in i||"abs"in i&&"arg"in i)return new t(i);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":r.referToSelf(n=>i=>Ge(i,n))})}),Ts="fraction",Is=["typed","Fraction"],zs=G(Ts,Is,e=>{var{typed:r,Fraction:t}=e;return r("fraction",{number:function(i){if(!Number.isFinite(i)||isNaN(i))throw new Error(i+" cannot be represented as a fraction");return new t(i)},string:function(i){return new t(i)},"number, number":function(i,u){return new t(i,u)},"bigint, bigint":function(i,u){return new t(i,u)},null:function(i){return new t(0)},BigNumber:function(i){return new t(i.toString())},bigint:function(i){return new t(i.toString())},Fraction:function(i){return i},Unit:r.referToSelf(n=>i=>{var u=i.clone();return u.value=n(i.value),u}),Object:function(i){return new t(i)},"Array | Matrix":r.referToSelf(n=>i=>Ge(i,n))})}),Mn="matrix",Os=["typed","Matrix","DenseMatrix","SparseMatrix"],$s=G(Mn,Os,e=>{var{typed:r,Matrix:t,DenseMatrix:n,SparseMatrix:i}=e;return r(Mn,{"":function(){return u([])},string:function(a){return u([],a)},"string, string":function(a,s){return u([],a,s)},Array:function(a){return u(a)},Matrix:function(a){return u(a,a.storage())},"Array | Matrix, string":u,"Array | Matrix, string, string":u});function u(o,a,s){if(a==="dense"||a==="default"||a===void 0)return new n(o,s);if(a==="sparse")return new i(o,s);throw new TypeError("Unknown matrix type "+JSON.stringify(a)+".")}}),xn="unaryMinus",Ps=["typed"],qs=G(xn,Ps,e=>{var{typed:r}=e;return r(xn,{number:Ri,"Complex | BigNumber | Fraction":t=>t.neg(),bigint:t=>-t,Unit:r.referToSelf(t=>n=>{var i=n.clone();return i.value=r.find(t,i.valueType())(n.value),i}),"Array | Matrix":r.referToSelf(t=>n=>Ge(n,t,!0))})}),Tn="abs",Us=["typed"],Rs=G(Tn,Us,e=>{var{typed:r}=e;return r(Tn,{number:$i,"Complex | BigNumber | Fraction | Unit":t=>t.abs(),bigint:t=>t<0n?-t:t,"Array | Matrix":r.referToSelf(t=>n=>Ge(n,t,!0))})}),In="addScalar",Ls=["typed"],Hs=G(In,Ls,e=>{var{typed:r}=e;return r(In,{"number, number":Pi,"Complex, Complex":function(n,i){return n.add(i)},"BigNumber, BigNumber":function(n,i){return n.plus(i)},"bigint, bigint":function(n,i){return n+i},"Fraction, Fraction":function(n,i){return n.add(i)},"Unit, Unit":r.referToSelf(t=>(n,i)=>{if(n.value===null||n.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(i.value===null||i.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!n.equalBase(i))throw new Error("Units do not match");var u=n.clone();return u.value=r.find(t,[u.valueType(),i.valueType()])(u.value,i.value),u.fixPrefix=!1,u})})}),zn="subtractScalar",Zs=["typed"],Ws=G(zn,Zs,e=>{var{typed:r}=e;return r(zn,{"number, number":qi,"Complex, Complex":function(n,i){return n.sub(i)},"BigNumber, BigNumber":function(n,i){return n.minus(i)},"bigint, bigint":function(n,i){return n-i},"Fraction, Fraction":function(n,i){return n.sub(i)},"Unit, Unit":r.referToSelf(t=>(n,i)=>{if(n.value===null||n.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(i.value===null||i.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!n.equalBase(i))throw new Error("Units do not match");var u=n.clone();return u.value=r.find(t,[u.valueType(),i.valueType()])(u.value,i.value),u.fixPrefix=!1,u})})}),Vs="matAlgo11xS0s",Gs=["typed","equalScalar"],Zi=G(Vs,Gs,e=>{var{typed:r,equalScalar:t}=e;return function(i,u,o,a){var s=i._values,f=i._index,m=i._ptr,l=i._size,h=i._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=l[0],D=l[1],c,d=t,v=0,y=o;typeof h=="string"&&(c=h,d=r.find(t,[c,c]),v=r.convert(0,c),u=r.convert(u,c),y=r.find(o,[c,c]));for(var g=[],A=[],F=[],w=0;w<D;w++){F[w]=A.length;for(var _=m[w],b=m[w+1],B=_;B<b;B++){var S=f[B],x=a?y(u,s[B]):y(s[B],u);d(x,v)||(A.push(S),g.push(x))}}return F[D]=A.length,i.createSparseMatrix({values:g,index:A,ptr:F,size:[p,D],datatype:c})}}),Js="matAlgo12xSfs",ks=["typed","DenseMatrix"],$r=G(Js,ks,e=>{var{typed:r,DenseMatrix:t}=e;return function(i,u,o,a){var s=i._values,f=i._index,m=i._ptr,l=i._size,h=i._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=l[0],D=l[1],c,d=o;typeof h=="string"&&(c=h,u=r.convert(u,c),d=r.find(o,[c,c]));for(var v=[],y=[],g=[],A=0;A<D;A++){for(var F=A+1,w=m[A],_=m[A+1],b=w;b<_;b++){var B=f[b];y[B]=s[b],g[B]=F}for(var S=0;S<p;S++)A===0&&(v[S]=[]),g[S]===F?v[S][A]=a?d(u,y[S]):d(y[S],u):v[S][A]=a?d(u,0):d(0,u)}return new t({data:v,size:[p,D],datatype:c})}}),Ys="matAlgo14xDs",Xs=["typed"],fn=G(Ys,Xs,e=>{var{typed:r}=e;return function(i,u,o,a){var s=i._data,f=i._size,m=i._datatype,l,h=o;typeof m=="string"&&(l=m,u=r.convert(u,l),h=r.find(o,[l,l]));var p=f.length>0?t(h,0,f,f[0],s,u,a):[];return i.createDenseMatrix({data:p,size:de(f),datatype:l})};function t(n,i,u,o,a,s,f){var m=[];if(i===u.length-1)for(var l=0;l<o;l++)m[l]=f?n(s,a[l]):n(a[l],s);else for(var h=0;h<o;h++)m[h]=t(n,i+1,u,u[i+1],a[h],s,f);return m}}),Qs="matAlgo03xDSf",Ks=["typed"],Xr=G(Qs,Ks,e=>{var{typed:r}=e;return function(n,i,u,o){var a=n._data,s=n._size,f=n._datatype||n.getDataType(),m=i._values,l=i._index,h=i._ptr,p=i._size,D=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(s.length!==p.length)throw new ie(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!m)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var c=s[0],d=s[1],v,y=0,g=u;typeof f=="string"&&f===D&&f!=="mixed"&&(v=f,y=r.convert(0,v),g=r.find(u,[v,v]));for(var A=[],F=0;F<c;F++)A[F]=[];for(var w=[],_=[],b=0;b<d;b++){for(var B=b+1,S=h[b],x=h[b+1],O=S;O<x;O++){var V=l[O];w[V]=o?g(m[O],a[V][b]):g(a[V][b],m[O]),_[V]=B}for(var R=0;R<c;R++)_[R]===B?A[R][b]=w[R]:A[R][b]=o?g(y,a[R][b]):g(a[R][b],y)}return n.createDenseMatrix({data:A,size:[c,d],datatype:f===n._datatype&&D===i._datatype?v:void 0})}}),js="matAlgo13xDD",ef=["typed"],rf=G(js,ef,e=>{var{typed:r}=e;return function(i,u,o){var a=i._data,s=i._size,f=i._datatype,m=u._data,l=u._size,h=u._datatype,p=[];if(s.length!==l.length)throw new ie(s.length,l.length);for(var D=0;D<s.length;D++){if(s[D]!==l[D])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+l+")");p[D]=s[D]}var c,d=o;typeof f=="string"&&f===h&&(c=f,d=r.find(o,[c,c]));var v=p.length>0?t(d,0,p,p[0],a,m):[];return i.createDenseMatrix({data:v,size:p,datatype:c})};function t(n,i,u,o,a,s){var f=[];if(i===u.length-1)for(var m=0;m<o;m++)f[m]=n(a[m],s[m]);else for(var l=0;l<o;l++)f[l]=t(n,i+1,u,u[i+1],a[l],s[l]);return f}});function Me(e,r){if(mr(e.size(),r.size()))return[e,r];var t=Ii(e.size(),r.size());return[e,r].map(n=>tf(n,t))}function tf(e,r){return mr(e.size(),r)?e:e.create(Kt(e.valueOf(),r),e.datatype())}var nf="matrixAlgorithmSuite",uf=["typed","matrix"],Pr=G(nf,uf,e=>{var{typed:r,matrix:t}=e,n=rf({typed:r}),i=fn({typed:r});return function(o){var a=o.elop,s=o.SD||o.DS,f;a?(f={"DenseMatrix, DenseMatrix":(p,D)=>n(...Me(p,D),a),"Array, Array":(p,D)=>n(...Me(t(p),t(D)),a).valueOf(),"Array, DenseMatrix":(p,D)=>n(...Me(t(p),D),a),"DenseMatrix, Array":(p,D)=>n(...Me(p,t(D)),a)},o.SS&&(f["SparseMatrix, SparseMatrix"]=(p,D)=>o.SS(...Me(p,D),a,!1)),o.DS&&(f["DenseMatrix, SparseMatrix"]=(p,D)=>o.DS(...Me(p,D),a,!1),f["Array, SparseMatrix"]=(p,D)=>o.DS(...Me(t(p),D),a,!1)),s&&(f["SparseMatrix, DenseMatrix"]=(p,D)=>s(...Me(D,p),a,!0),f["SparseMatrix, Array"]=(p,D)=>s(...Me(t(D),p),a,!0))):(f={"DenseMatrix, DenseMatrix":r.referToSelf(p=>(D,c)=>n(...Me(D,c),p)),"Array, Array":r.referToSelf(p=>(D,c)=>n(...Me(t(D),t(c)),p).valueOf()),"Array, DenseMatrix":r.referToSelf(p=>(D,c)=>n(...Me(t(D),c),p)),"DenseMatrix, Array":r.referToSelf(p=>(D,c)=>n(...Me(D,t(c)),p))},o.SS&&(f["SparseMatrix, SparseMatrix"]=r.referToSelf(p=>(D,c)=>o.SS(...Me(D,c),p,!1))),o.DS&&(f["DenseMatrix, SparseMatrix"]=r.referToSelf(p=>(D,c)=>o.DS(...Me(D,c),p,!1)),f["Array, SparseMatrix"]=r.referToSelf(p=>(D,c)=>o.DS(...Me(t(D),c),p,!1))),s&&(f["SparseMatrix, DenseMatrix"]=r.referToSelf(p=>(D,c)=>s(...Me(c,D),p,!0)),f["SparseMatrix, Array"]=r.referToSelf(p=>(D,c)=>s(...Me(t(c),D),p,!0))));var m=o.scalar||"any",l=o.Ds||o.Ss;l&&(a?(f["DenseMatrix,"+m]=(p,D)=>i(p,D,a,!1),f[m+", DenseMatrix"]=(p,D)=>i(D,p,a,!0),f["Array,"+m]=(p,D)=>i(t(p),D,a,!1).valueOf(),f[m+", Array"]=(p,D)=>i(t(D),p,a,!0).valueOf()):(f["DenseMatrix,"+m]=r.referToSelf(p=>(D,c)=>i(D,c,p,!1)),f[m+", DenseMatrix"]=r.referToSelf(p=>(D,c)=>i(c,D,p,!0)),f["Array,"+m]=r.referToSelf(p=>(D,c)=>i(t(D),c,p,!1).valueOf()),f[m+", Array"]=r.referToSelf(p=>(D,c)=>i(t(c),D,p,!0).valueOf())));var h=o.sS!==void 0?o.sS:o.Ss;return a?(o.Ss&&(f["SparseMatrix,"+m]=(p,D)=>o.Ss(p,D,a,!1)),h&&(f[m+", SparseMatrix"]=(p,D)=>h(D,p,a,!0))):(o.Ss&&(f["SparseMatrix,"+m]=r.referToSelf(p=>(D,c)=>o.Ss(D,c,p,!1))),h&&(f[m+", SparseMatrix"]=r.referToSelf(p=>(D,c)=>h(c,D,p,!0)))),a&&a.signatures&&yo(f,a.signatures),f}}),of="matAlgo01xDSid",af=["typed"],sf=G(of,af,e=>{var{typed:r}=e;return function(n,i,u,o){var a=n._data,s=n._size,f=n._datatype||n.getDataType(),m=i._values,l=i._index,h=i._ptr,p=i._size,D=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(s.length!==p.length)throw new ie(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!m)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var c=s[0],d=s[1],v=typeof f=="string"&&f!=="mixed"&&f===D?f:void 0,y=v?r.find(u,[v,v]):u,g,A,F=[];for(g=0;g<c;g++)F[g]=[];var w=[],_=[];for(A=0;A<d;A++){for(var b=A+1,B=h[A],S=h[A+1],x=B;x<S;x++)g=l[x],w[g]=o?y(m[x],a[g][A]):y(a[g][A],m[x]),_[g]=b;for(g=0;g<c;g++)_[g]===b?F[g][A]=w[g]:F[g][A]=a[g][A]}return n.createDenseMatrix({data:F,size:[c,d],datatype:f===n._datatype&&D===i._datatype?v:void 0})}}),ff="matAlgo04xSidSid",cf=["typed","equalScalar"],lf=G(ff,cf,e=>{var{typed:r,equalScalar:t}=e;return function(i,u,o){var a=i._values,s=i._index,f=i._ptr,m=i._size,l=i._datatype||i._data===void 0?i._datatype:i.getDataType(),h=u._values,p=u._index,D=u._ptr,c=u._size,d=u._datatype||u._data===void 0?u._datatype:u.getDataType();if(m.length!==c.length)throw new ie(m.length,c.length);if(m[0]!==c[0]||m[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+m+") must match Matrix B ("+c+")");var v=m[0],y=m[1],g,A=t,F=0,w=o;typeof l=="string"&&l===d&&l!=="mixed"&&(g=l,A=r.find(t,[g,g]),F=r.convert(0,g),w=r.find(o,[g,g]));var _=a&&h?[]:void 0,b=[],B=[],S=a&&h?[]:void 0,x=a&&h?[]:void 0,O=[],V=[],R,H,$,Q,J;for(H=0;H<y;H++){B[H]=b.length;var X=H+1;for(Q=f[H],J=f[H+1],$=Q;$<J;$++)R=s[$],b.push(R),O[R]=X,S&&(S[R]=a[$]);for(Q=D[H],J=D[H+1],$=Q;$<J;$++)if(R=p[$],O[R]===X){if(S){var ee=w(S[R],h[$]);A(ee,F)?O[R]=null:S[R]=ee}}else b.push(R),V[R]=X,x&&(x[R]=h[$]);if(S&&x)for($=B[H];$<b.length;)R=b[$],O[R]===X?(_[$]=S[R],$++):V[R]===X?(_[$]=x[R],$++):b.splice($,1)}return B[y]=b.length,i.createSparseMatrix({values:_,index:b,ptr:B,size:[v,y],datatype:l===i._datatype&&d===u._datatype?g:void 0})}}),hf="matAlgo10xSids",pf=["typed","DenseMatrix"],Df=G(hf,pf,e=>{var{typed:r,DenseMatrix:t}=e;return function(i,u,o,a){var s=i._values,f=i._index,m=i._ptr,l=i._size,h=i._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=l[0],D=l[1],c,d=o;typeof h=="string"&&(c=h,u=r.convert(u,c),d=r.find(o,[c,c]));for(var v=[],y=[],g=[],A=0;A<D;A++){for(var F=A+1,w=m[A],_=m[A+1],b=w;b<_;b++){var B=f[b];y[B]=s[b],g[B]=F}for(var S=0;S<p;S++)A===0&&(v[S]=[]),g[S]===F?v[S][A]=a?d(u,y[S]):d(y[S],u):v[S][A]=u}return new t({data:v,size:[p,D],datatype:c})}});function mf(e,r,t,n){return function(i){if(i>0||t.predictable){if(i<=0)return NaN;var u=i.toString(16),o=u.substring(0,15);return e*(u.length-o.length)+r(+("0x"+o))}return n(i.toNumber())}}var On="log10",df=["typed","config","Complex"],gf=yt(16),vf=G(On,df,e=>{var{typed:r,config:t,Complex:n}=e;function i(o){return o.log().div(Math.LN10)}function u(o){return i(new n(o,0))}return r(On,{number:function(a){return a>=0||t.predictable?yt(a):u(a)},bigint:mf(gf,yt,t,u),Complex:i,BigNumber:function(a){return!a.isNegative()||t.predictable?a.log():u(a.toNumber())},"Array | Matrix":r.referToSelf(o=>a=>Ge(a,o))})}),wf="multiplyScalar",yf=["typed"],Ff=G(wf,yf,e=>{var{typed:r}=e;return r("multiplyScalar",{"number, number":Ui,"Complex, Complex":function(n,i){return n.mul(i)},"BigNumber, BigNumber":function(n,i){return n.times(i)},"bigint, bigint":function(n,i){return n*i},"Fraction, Fraction":function(n,i){return n.mul(i)},"number | Fraction | BigNumber | Complex, Unit":(t,n)=>n.multiply(t),"Unit, number | Fraction | BigNumber | Complex | Unit":(t,n)=>t.multiply(n)})}),$n="multiply",Ef=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],Af=G($n,Ef,e=>{var{typed:r,matrix:t,addScalar:n,multiplyScalar:i,equalScalar:u,dot:o}=e,a=Zi({typed:r,equalScalar:u}),s=fn({typed:r});function f(F,w){switch(F.length){case 1:switch(w.length){case 1:if(F[0]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(F[0]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+F[0]+") must match Matrix rows ("+w[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+w.length+" dimensions)")}break;case 2:switch(w.length){case 1:if(F[1]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+F[1]+") must match Vector length ("+w[0]+")");break;case 2:if(F[1]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+F[1]+") must match Matrix B rows ("+w[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+w.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+F.length+" dimensions)")}}function m(F,w,_){if(_===0)throw new Error("Cannot multiply two empty vectors");return o(F,w)}function l(F,w){if(w.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return h(F,w)}function h(F,w){var _=F._data,b=F._size,B=F._datatype||F.getDataType(),S=w._data,x=w._size,O=w._datatype||w.getDataType(),V=b[0],R=x[1],H,$=n,Q=i;B&&O&&B===O&&typeof B=="string"&&B!=="mixed"&&(H=B,$=r.find(n,[H,H]),Q=r.find(i,[H,H]));for(var J=[],X=0;X<R;X++){for(var ee=Q(_[0],S[0][X]),ue=1;ue<V;ue++)ee=$(ee,Q(_[ue],S[ue][X]));J[X]=ee}return F.createDenseMatrix({data:J,size:[R],datatype:B===F._datatype&&O===w._datatype?H:void 0})}var p=r("_multiplyMatrixVector",{"DenseMatrix, any":c,"SparseMatrix, any":y}),D=r("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":d,"DenseMatrix, SparseMatrix":v,"SparseMatrix, DenseMatrix":g,"SparseMatrix, SparseMatrix":A});function c(F,w){var _=F._data,b=F._size,B=F._datatype||F.getDataType(),S=w._data,x=w._datatype||w.getDataType(),O=b[0],V=b[1],R,H=n,$=i;B&&x&&B===x&&typeof B=="string"&&B!=="mixed"&&(R=B,H=r.find(n,[R,R]),$=r.find(i,[R,R]));for(var Q=[],J=0;J<O;J++){for(var X=_[J],ee=$(X[0],S[0]),ue=1;ue<V;ue++)ee=H(ee,$(X[ue],S[ue]));Q[J]=ee}return F.createDenseMatrix({data:Q,size:[O],datatype:B===F._datatype&&x===w._datatype?R:void 0})}function d(F,w){var _=F._data,b=F._size,B=F._datatype||F.getDataType(),S=w._data,x=w._size,O=w._datatype||w.getDataType(),V=b[0],R=b[1],H=x[1],$,Q=n,J=i;B&&O&&B===O&&typeof B=="string"&&B!=="mixed"&&B!=="mixed"&&($=B,Q=r.find(n,[$,$]),J=r.find(i,[$,$]));for(var X=[],ee=0;ee<V;ee++){var ue=_[ee];X[ee]=[];for(var oe=0;oe<H;oe++){for(var ce=J(ue[0],S[0][oe]),Ce=1;Ce<R;Ce++)ce=Q(ce,J(ue[Ce],S[Ce][oe]));X[ee][oe]=ce}}return F.createDenseMatrix({data:X,size:[V,H],datatype:B===F._datatype&&O===w._datatype?$:void 0})}function v(F,w){var _=F._data,b=F._size,B=F._datatype||F.getDataType(),S=w._values,x=w._index,O=w._ptr,V=w._size,R=w._datatype||w._data===void 0?w._datatype:w.getDataType();if(!S)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var H=b[0],$=V[1],Q,J=n,X=i,ee=u,ue=0;B&&R&&B===R&&typeof B=="string"&&B!=="mixed"&&(Q=B,J=r.find(n,[Q,Q]),X=r.find(i,[Q,Q]),ee=r.find(u,[Q,Q]),ue=r.convert(0,Q));for(var oe=[],ce=[],Ce=[],be=w.createSparseMatrix({values:oe,index:ce,ptr:Ce,size:[H,$],datatype:B===F._datatype&&R===w._datatype?Q:void 0}),Ae=0;Ae<$;Ae++){Ce[Ae]=ce.length;var ge=O[Ae],Re=O[Ae+1];if(Re>ge)for(var le=0,se=0;se<H;se++){for(var Je=se+1,Ie=void 0,he=ge;he<Re;he++){var Se=x[he];le!==Je?(Ie=X(_[se][Se],S[he]),le=Je):Ie=J(Ie,X(_[se][Se],S[he]))}le===Je&&!ee(Ie,ue)&&(ce.push(se),oe.push(Ie))}}return Ce[$]=ce.length,be}function y(F,w){var _=F._values,b=F._index,B=F._ptr,S=F._datatype||F._data===void 0?F._datatype:F.getDataType();if(!_)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var x=w._data,O=w._datatype||w.getDataType(),V=F._size[0],R=w._size[0],H=[],$=[],Q=[],J,X=n,ee=i,ue=u,oe=0;S&&O&&S===O&&typeof S=="string"&&S!=="mixed"&&(J=S,X=r.find(n,[J,J]),ee=r.find(i,[J,J]),ue=r.find(u,[J,J]),oe=r.convert(0,J));var ce=[],Ce=[];Q[0]=0;for(var be=0;be<R;be++){var Ae=x[be];if(!ue(Ae,oe))for(var ge=B[be],Re=B[be+1],le=ge;le<Re;le++){var se=b[le];Ce[se]?ce[se]=X(ce[se],ee(Ae,_[le])):(Ce[se]=!0,$.push(se),ce[se]=ee(Ae,_[le]))}}for(var Je=$.length,Ie=0;Ie<Je;Ie++){var he=$[Ie];H[Ie]=ce[he]}return Q[1]=$.length,F.createSparseMatrix({values:H,index:$,ptr:Q,size:[V,1],datatype:S===F._datatype&&O===w._datatype?J:void 0})}function g(F,w){var _=F._values,b=F._index,B=F._ptr,S=F._datatype||F._data===void 0?F._datatype:F.getDataType();if(!_)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var x=w._data,O=w._datatype||w.getDataType(),V=F._size[0],R=w._size[0],H=w._size[1],$,Q=n,J=i,X=u,ee=0;S&&O&&S===O&&typeof S=="string"&&S!=="mixed"&&($=S,Q=r.find(n,[$,$]),J=r.find(i,[$,$]),X=r.find(u,[$,$]),ee=r.convert(0,$));for(var ue=[],oe=[],ce=[],Ce=F.createSparseMatrix({values:ue,index:oe,ptr:ce,size:[V,H],datatype:S===F._datatype&&O===w._datatype?$:void 0}),be=[],Ae=[],ge=0;ge<H;ge++){ce[ge]=oe.length;for(var Re=ge+1,le=0;le<R;le++){var se=x[le][ge];if(!X(se,ee))for(var Je=B[le],Ie=B[le+1],he=Je;he<Ie;he++){var Se=b[he];Ae[Se]!==Re?(Ae[Se]=Re,oe.push(Se),be[Se]=J(se,_[he])):be[Se]=Q(be[Se],J(se,_[he]))}}for(var ke=ce[ge],ar=oe.length,sr=ke;sr<ar;sr++){var br=oe[sr];ue[sr]=be[br]}}return ce[H]=oe.length,Ce}function A(F,w){var _=F._values,b=F._index,B=F._ptr,S=F._datatype||F._data===void 0?F._datatype:F.getDataType(),x=w._values,O=w._index,V=w._ptr,R=w._datatype||w._data===void 0?w._datatype:w.getDataType(),H=F._size[0],$=w._size[1],Q=_&&x,J,X=n,ee=i;S&&R&&S===R&&typeof S=="string"&&S!=="mixed"&&(J=S,X=r.find(n,[J,J]),ee=r.find(i,[J,J]));for(var ue=Q?[]:void 0,oe=[],ce=[],Ce=F.createSparseMatrix({values:ue,index:oe,ptr:ce,size:[H,$],datatype:S===F._datatype&&R===w._datatype?J:void 0}),be=Q?[]:void 0,Ae=[],ge,Re,le,se,Je,Ie,he,Se,ke=0;ke<$;ke++){ce[ke]=oe.length;var ar=ke+1;for(Je=V[ke],Ie=V[ke+1],se=Je;se<Ie;se++)if(Se=O[se],Q)for(Re=B[Se],le=B[Se+1],ge=Re;ge<le;ge++)he=b[ge],Ae[he]!==ar?(Ae[he]=ar,oe.push(he),be[he]=ee(x[se],_[ge])):be[he]=X(be[he],ee(x[se],_[ge]));else for(Re=B[Se],le=B[Se+1],ge=Re;ge<le;ge++)he=b[ge],Ae[he]!==ar&&(Ae[he]=ar,oe.push(he));if(Q)for(var sr=ce[ke],br=oe.length,Cr=sr;Cr<br;Cr++){var Rt=oe[Cr];ue[Cr]=be[Rt]}}return ce[$]=oe.length,Ce}return r($n,i,{"Array, Array":r.referTo("Matrix, Matrix",F=>(w,_)=>{f(Oe(w),Oe(_));var b=F(t(w),t(_));return ye(b)?b.valueOf():b}),"Matrix, Matrix":function(w,_){var b=w.size(),B=_.size();return f(b,B),b.length===1?B.length===1?m(w,_,b[0]):l(w,_):B.length===1?p(w,_):D(w,_)},"Matrix, Array":r.referTo("Matrix,Matrix",F=>(w,_)=>F(w,t(_))),"Array, Matrix":r.referToSelf(F=>(w,_)=>F(t(w,_.storage()),_)),"SparseMatrix, any":function(w,_){return a(w,_,i,!1)},"DenseMatrix, any":function(w,_){return s(w,_,i,!1)},"any, SparseMatrix":function(w,_){return a(_,w,i,!0)},"any, DenseMatrix":function(w,_){return s(_,w,i,!0)},"Array, any":function(w,_){return s(t(w),_,i,!1).valueOf()},"any, Array":function(w,_){return s(t(_),w,i,!0).valueOf()},"any, any":i,"any, any, ...any":r.referToSelf(F=>(w,_,b)=>{for(var B=F(w,_),S=0;S<b.length;S++)B=F(B,b[S]);return B})})}),bf="matAlgo07xSSf",Cf=["typed","SparseMatrix"],Qr=G(bf,Cf,e=>{var{typed:r,SparseMatrix:t}=e;return function(u,o,a){var s=u._size,f=u._datatype||u._data===void 0?u._datatype:u.getDataType(),m=o._size,l=o._datatype||o._data===void 0?o._datatype:o.getDataType();if(s.length!==m.length)throw new ie(s.length,m.length);if(s[0]!==m[0]||s[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+m+")");var h=s[0],p=s[1],D,c=0,d=a;typeof f=="string"&&f===l&&f!=="mixed"&&(D=f,c=r.convert(0,D),d=r.find(a,[D,D]));for(var v=[],y=[],g=new Array(p+1).fill(0),A=[],F=[],w=[],_=[],b=0;b<p;b++){var B=b+1,S=0;n(u,b,w,A,B),n(o,b,_,F,B);for(var x=0;x<h;x++){var O=w[x]===B?A[x]:c,V=_[x]===B?F[x]:c,R=d(O,V);R!==0&&R!==!1&&(y.push(x),v.push(R),S++)}g[b+1]=g[b]+S}return new t({values:v,index:y,ptr:g,size:[h,p],datatype:f===u._datatype&&l===o._datatype?D:void 0})};function n(i,u,o,a,s){for(var f=i._values,m=i._index,l=i._ptr,h=l[u],p=l[u+1];h<p;h++){var D=m[h];o[D]=s,a[D]=f[h]}}}),Pn="arg",_f=["typed"],Bf=G(Pn,_f,e=>{var{typed:r}=e;return r(Pn,{number:function(n){return Math.atan2(0,n)},BigNumber:function(n){return n.constructor.atan2(0,n)},Complex:function(n){return n.arg()},"Array | Matrix":r.referToSelf(t=>n=>Ge(n,t))})}),qn="conj",Nf=["typed"],Sf=G(qn,Nf,e=>{var{typed:r}=e;return r(qn,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.conjugate(),Unit:r.referToSelf(t=>n=>new n.constructor(t(n.toNumeric()),n.formatUnits())),"Array | Matrix":r.referToSelf(t=>n=>Ge(n,t))})}),Un="concat",Mf=["typed","matrix","isInteger"],xf=G(Un,Mf,e=>{var{typed:r,matrix:t,isInteger:n}=e;return r(Un,{"...Array | Matrix | number | BigNumber":function(u){var o,a=u.length,s=-1,f,m=!1,l=[];for(o=0;o<a;o++){var h=u[o];if(ye(h)&&(m=!0),ne(h)||Ee(h)){if(o!==a-1)throw new Error("Dimension must be specified as last argument");if(f=s,s=h.valueOf(),!n(s))throw new TypeError("Integer number expected for dimension");if(s<0||o>0&&s>f)throw new Ar(s,f+1)}else{var p=de(h).valueOf(),D=Oe(p);if(l[o]=p,f=s,s=D.length-1,o>0&&s!==f)throw new ie(f+1,s+1)}}if(l.length===0)throw new SyntaxError("At least one matrix expected");for(var c=l.shift();l.length;)c=Ti(c,l.shift(),s);return m?t(c):c},"...string":function(u){return u.join("")}})}),Rn="getMatrixDataType",Tf=["typed"],If=G(Rn,Tf,e=>{var{typed:r}=e;return r(Rn,{Array:function(n){return It(n,ur)},Matrix:function(n){return n.getDataType()}})}),Ln="identity",zf=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],Of=G(Ln,zf,e=>{var{typed:r,config:t,matrix:n,BigNumber:i,DenseMatrix:u,SparseMatrix:o}=e;return r(Ln,{"":function(){return t.matrix==="Matrix"?n([]):[]},string:function(m){return n(m)},"number | BigNumber":function(m){return s(m,m,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(m,l){return s(m,m,l)},"number | BigNumber, number | BigNumber":function(m,l){return s(m,l,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(m,l,h){return s(m,l,h)},Array:function(m){return a(m)},"Array, string":function(m,l){return a(m,l)},Matrix:function(m){return a(m.valueOf(),m.storage())},"Matrix, string":function(m,l){return a(m.valueOf(),l)}});function a(f,m){switch(f.length){case 0:return m?n(m):[];case 1:return s(f[0],f[0],m);case 2:return s(f[0],f[1],m);default:throw new Error("Vector containing two values expected")}}function s(f,m,l){var h=Ee(f)||Ee(m)?i:null;if(Ee(f)&&(f=f.toNumber()),Ee(m)&&(m=m.toNumber()),!we(f)||f<1)throw new Error("Parameters in function identity must be positive integers");if(!we(m)||m<1)throw new Error("Parameters in function identity must be positive integers");var p=h?new i(1):1,D=h?new h(0):0,c=[f,m];if(l){if(l==="sparse")return o.diagonal(c,p,0,D);if(l==="dense")return u.diagonal(c,p,0,D);throw new TypeError('Unknown matrix type "'.concat(l,'"'))}for(var d=vt([],c,D),v=f<m?f:m,y=0;y<v;y++)d[y][y]=p;return d}});function Wi(){throw new Error('No "bignumber" implementation available')}function $f(){throw new Error('No "fraction" implementation available')}function Pf(){throw new Error('No "matrix" implementation available')}var Hn="range",qf=["typed","config","?matrix","?bignumber","equal","smaller","smallerEq","larger","largerEq","add","isZero","isPositive"],Uf=G(Hn,qf,e=>{var{typed:r,config:t,matrix:n,bignumber:i,smaller:u,smallerEq:o,larger:a,largerEq:s,add:f,isZero:m,isPositive:l}=e;return r(Hn,{string:p,"string, boolean":p,number:function(v){throw new TypeError("Too few arguments to function range(): ".concat(v))},boolean:function(v){throw new TypeError("Unexpected type of argument 1 to function range(): ".concat(v,", number|bigint|BigNumber|Fraction"))},"number, number":function(v,y){return h(D(v,y,1,!1))},"number, number, number":function(v,y,g){return h(D(v,y,g,!1))},"number, number, boolean":function(v,y,g){return h(D(v,y,1,g))},"number, number, number, boolean":function(v,y,g,A){return h(D(v,y,g,A))},"bigint, bigint|number":function(v,y){return h(D(v,y,1n,!1))},"number, bigint":function(v,y){return h(D(BigInt(v),y,1n,!1))},"bigint, bigint|number, bigint|number":function(v,y,g){return h(D(v,y,BigInt(g),!1))},"number, bigint, bigint|number":function(v,y,g){return h(D(BigInt(v),y,BigInt(g),!1))},"bigint, bigint|number, boolean":function(v,y,g){return h(D(v,y,1n,g))},"number, bigint, boolean":function(v,y,g){return h(D(BigInt(v),y,1n,g))},"bigint, bigint|number, bigint|number, boolean":function(v,y,g,A){return h(D(v,y,BigInt(g),A))},"number, bigint, bigint|number, boolean":function(v,y,g,A){return h(D(BigInt(v),y,BigInt(g),A))},"BigNumber, BigNumber":function(v,y){var g=v.constructor;return h(D(v,y,new g(1),!1))},"BigNumber, BigNumber, BigNumber":function(v,y,g){return h(D(v,y,g,!1))},"BigNumber, BigNumber, boolean":function(v,y,g){var A=v.constructor;return h(D(v,y,new A(1),g))},"BigNumber, BigNumber, BigNumber, boolean":function(v,y,g,A){return h(D(v,y,g,A))},"Fraction, Fraction":function(v,y){return h(D(v,y,1,!1))},"Fraction, Fraction, Fraction":function(v,y,g){return h(D(v,y,g,!1))},"Fraction, Fraction, boolean":function(v,y,g){return h(D(v,y,1,g))},"Fraction, Fraction, Fraction, boolean":function(v,y,g,A){return h(D(v,y,g,A))},"Unit, Unit, Unit":function(v,y,g){return h(D(v,y,g,!1))},"Unit, Unit, Unit, boolean":function(v,y,g,A){return h(D(v,y,g,A))}});function h(d){return t.matrix==="Matrix"?n?n(d):Pf():d}function p(d,v){var y=c(d);if(!y)throw new SyntaxError('String "'+d+'" is no valid range');return t.number==="BigNumber"?(i===void 0&&Wi(),h(D(i(y.start),i(y.end),i(y.step)))):h(D(y.start,y.end,y.step,v))}function D(d,v,y,g){var A=[];if(m(y))throw new Error("Step must be non-zero");for(var F=l(y)?g?o:u:g?s:a,w=d;F(w,v);)A.push(w),w=f(w,y);return A}function c(d){var v=d.split(":"),y=v.map(function(A){return Number(A)}),g=y.some(function(A){return isNaN(A)});if(g)return null;switch(y.length){case 2:return{start:y[0],end:y[1],step:1};case 3:return{start:y[0],end:y[2],step:y[1]};default:return null}}}),Zn="size",Rf=["typed"],Lf=G(Zn,Rf,e=>{var{typed:r}=e;return r(Zn,{Matrix:t=>t.size(),Array:Oe,string:t=>[t.length],"number | Complex | BigNumber | Unit | boolean | null":t=>[]})}),Wn="subset",Hf=["typed","matrix","zeros","add"],Zf=G(Wn,Hf,e=>{var{typed:r,matrix:t,zeros:n,add:i}=e;return r(Wn,{"Matrix, Index":function(a,s){return Or(s)?t():(gt(a,s),a.subset(s))},"Array, Index":r.referTo("Matrix, Index",function(o){return function(a,s){var f=o(t(a),s);return s.isScalar()?f:f.valueOf()}}),"Object, Index":Vf,"string, Index":Wf,"Matrix, Index, any, any":function(a,s,f,m){return Or(s)?a:(gt(a,s),a.clone().subset(s,u(f,s),m))},"Array, Index, any, any":r.referTo("Matrix, Index, any, any",function(o){return function(a,s,f,m){var l=o(t(a),s,f,m);return l.isMatrix?l.valueOf():l}}),"Array, Index, any":r.referTo("Matrix, Index, any, any",function(o){return function(a,s,f){return o(t(a),s,f,void 0).valueOf()}}),"Matrix, Index, any":r.referTo("Matrix, Index, any, any",function(o){return function(a,s,f){return o(a,s,f,void 0)}}),"string, Index, string":Vn,"string, Index, string, string":Vn,"Object, Index, any":Gf});function u(o,a){if(typeof o=="string")throw new Error("can't boradcast a string");if(a.isScalar())return o;var s=a.size();if(s.every(f=>f>0))try{return i(o,n(s))}catch{return o}else return o}});function Wf(e,r){if(!Nt(r))throw new TypeError("Index expected");if(Or(r))return"";if(gt(Array.from(e),r),r.size().length!==1)throw new ie(r.size().length,1);var t=e.length;me(r.min()[0],t),me(r.max()[0],t);var n=r.dimension(0),i="";function u(o){i+=e.charAt(o)}return Number.isInteger(n)?u(n):n.forEach(u),i}function Vn(e,r,t,n){if(!r||r.isIndex!==!0)throw new TypeError("Index expected");if(Or(r))return e;if(gt(Array.from(e),r),r.size().length!==1)throw new ie(r.size().length,1);if(n!==void 0){if(typeof n!="string"||n.length!==1)throw new TypeError("Single character expected as defaultValue")}else n=" ";var i=r.dimension(0),u=Number.isInteger(i)?1:i.size()[0];if(u!==t.length)throw new ie(i.size()[0],t.length);var o=e.length;me(r.min()[0]),me(r.max()[0]);for(var a=[],s=0;s<o;s++)a[s]=e.charAt(s);function f(h,p){a[h]=t.charAt(p[0])}if(Number.isInteger(i)?f(i,[0]):i.forEach(f),a.length>o)for(var m=o-1,l=a.length;m<l;m++)a[m]||(a[m]=n);return a.join("")}function Vf(e,r){if(!Or(r)){if(r.size().length!==1)throw new ie(r.size(),1);var t=r.dimension(0);if(typeof t!="string")throw new TypeError("String expected as index to retrieve an object property");return ni(e,t)}}function Gf(e,r,t){if(Or(r))return e;if(r.size().length!==1)throw new ie(r.size(),1);var n=r.dimension(0);if(typeof n!="string")throw new TypeError("String expected as index to retrieve an object property");var i=de(e);return ii(i,n,t),i}var Gn="zeros",Jf=["typed","config","matrix","BigNumber"],kf=G(Gn,Jf,e=>{var{typed:r,config:t,matrix:n,BigNumber:i}=e;return r(Gn,{"":function(){return t.matrix==="Array"?u([]):u([],"default")},"...number | BigNumber | string":function(f){var m=f[f.length-1];if(typeof m=="string"){var l=f.pop();return u(f,l)}else return t.matrix==="Array"?u(f):u(f,"default")},Array:u,Matrix:function(f){var m=f.storage();return u(f.valueOf(),m)},"Array | Matrix, string":function(f,m){return u(f.valueOf(),m)}});function u(s,f){var m=o(s),l=m?new i(0):0;if(a(s),f){var h=n(f);return s.length>0?h.resize(s,l):h}else{var p=[];return s.length>0?vt(p,s,l):p}}function o(s){var f=!1;return s.forEach(function(m,l,h){Ee(m)&&(f=!0,h[l]=m.toNumber())}),f}function a(s){s.forEach(function(f){if(typeof f!="number"||!we(f)||f<0)throw new Error("Parameters in function zeros must be positive integers")})}}),Yf="numeric",Xf=["number","?bignumber","?fraction"],Qf=G(Yf,Xf,e=>{var{number:r,bignumber:t,fraction:n}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},u={number:o=>r(o),BigNumber:t?o=>t(o):Wi,bigint:o=>BigInt(o),Fraction:n?o=>n(o):$f};return function(a){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",f=arguments.length>2?arguments[2]:void 0;if(f!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var m=ur(a);if(!(m in i))throw new TypeError("Cannot convert "+a+' of type "'+m+'"; valid input types are '+Object.keys(i).join(", "));if(!(s in u))throw new TypeError("Cannot convert "+a+' to type "'+s+'"; valid output types are '+Object.keys(u).join(", "));return s===m?a:u[s](a)}}),Jn="divideScalar",Kf=["typed","numeric"],jf=G(Jn,Kf,e=>{var{typed:r,numeric:t}=e;return r(Jn,{"number, number":function(i,u){return i/u},"Complex, Complex":function(i,u){return i.div(u)},"BigNumber, BigNumber":function(i,u){return i.div(u)},"bigint, bigint":function(i,u){return i/u},"Fraction, Fraction":function(i,u){return i.div(u)},"Unit, number | Complex | Fraction | BigNumber | Unit":(n,i)=>n.divide(i),"number | Fraction | Complex | BigNumber, Unit":(n,i)=>i.divideInto(n)})}),kn="pow",ec=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],rc=G(kn,ec,e=>{var{typed:r,config:t,identity:n,multiply:i,matrix:u,inv:o,number:a,fraction:s,Complex:f}=e;return r(kn,{"number, number":m,"Complex, Complex":function(D,c){return D.pow(c)},"BigNumber, BigNumber":function(D,c){return c.isInteger()||D>=0||t.predictable?D.pow(c):new f(D.toNumber(),0).pow(c.toNumber(),0)},"bigint, bigint":(p,D)=>p**D,"Fraction, Fraction":function(D,c){var d=D.pow(c);if(d!=null)return d;if(t.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return m(D.valueOf(),c.valueOf())},"Array, number":l,"Array, BigNumber":function(D,c){return l(D,c.toNumber())},"Matrix, number":h,"Matrix, BigNumber":function(D,c){return h(D,c.toNumber())},"Unit, number | BigNumber":function(D,c){return D.pow(c)}});function m(p,D){if(t.predictable&&!we(D)&&p<0)try{var c=s(D),d=a(c);if((D===d||Math.abs((D-d)/D)<1e-14)&&c.d%2n===1n)return(c.n%2n===0n?1:-1)*Math.pow(-p,D)}catch{}return t.predictable&&(p<-1&&D===1/0||p>-1&&p<0&&D===-1/0)?NaN:we(D)||p>=0||t.predictable?Li(p,D):p*p<1&&D===1/0||p*p>1&&D===-1/0?0:new f(p,0).pow(D,0)}function l(p,D){if(!we(D))throw new TypeError("For A^b, b must be an integer (value is "+D+")");var c=Oe(p);if(c.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+c.length+" dimensions)");if(c[0]!==c[1])throw new Error("For A^b, A must be square (size is "+c[0]+"x"+c[1]+")");if(D<0)try{return l(o(p),-D)}catch(y){throw y.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 "+D+")"):y}for(var d=n(c[0]).valueOf(),v=p;D>=1;)(D&1)===1&&(d=i(v,d)),D>>=1,v=i(v,v);return d}function h(p,D){return u(l(p.valueOf(),D))}}),Mr="Number of decimals in function round must be an integer",Yn="round",tc=["typed","config","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],nc=G(Yn,tc,e=>{var{typed:r,config:t,matrix:n,equalScalar:i,zeros:u,BigNumber:o,DenseMatrix:a}=e,s=Zi({typed:r,equalScalar:i}),f=$r({typed:r,DenseMatrix:a}),m=fn({typed:r});function l(h){return Math.abs(kr(h).exponent)}return r(Yn,{number:function(p){var D=Hr(p,l(t.relTol)),c=tr(p,D,t.relTol,t.absTol)?D:p;return Hr(c)},"number, number":function(p,D){var c=l(t.relTol);if(D>=c)return Hr(p,D);var d=Hr(p,c),v=tr(p,d,t.relTol,t.absTol)?d:p;return Hr(v,D)},"number, BigNumber":function(p,D){if(!D.isInteger())throw new TypeError(Mr);return new o(p).toDecimalPlaces(D.toNumber())},Complex:function(p){return p.round()},"Complex, number":function(p,D){if(D%1)throw new TypeError(Mr);return p.round(D)},"Complex, BigNumber":function(p,D){if(!D.isInteger())throw new TypeError(Mr);var c=D.toNumber();return p.round(c)},BigNumber:function(p){var D=new o(p).toDecimalPlaces(l(t.relTol)),c=gr(p,D,t.relTol,t.absTol)?D:p;return c.toDecimalPlaces(0)},"BigNumber, BigNumber":function(p,D){if(!D.isInteger())throw new TypeError(Mr);var c=l(t.relTol);if(D>=c)return p.toDecimalPlaces(D.toNumber());var d=p.toDecimalPlaces(c),v=gr(p,d,t.relTol,t.absTol)?d:p;return v.toDecimalPlaces(D.toNumber())},bigint:h=>h,"bigint, number":(h,p)=>h,"bigint, BigNumber":(h,p)=>h,Fraction:function(p){return p.round()},"Fraction, number":function(p,D){if(D%1)throw new TypeError(Mr);return p.round(D)},"Fraction, BigNumber":function(p,D){if(!D.isInteger())throw new TypeError(Mr);return p.round(D.toNumber())},"Unit, number, Unit":r.referToSelf(h=>function(p,D,c){var d=p.toNumeric(c);return c.multiply(h(d,D))}),"Unit, BigNumber, Unit":r.referToSelf(h=>(p,D,c)=>h(p,D.toNumber(),c)),"Array | Matrix, number | BigNumber, Unit":r.referToSelf(h=>(p,D,c)=>Ge(p,d=>h(d,D,c),!0)),"Array | Matrix | Unit, Unit":r.referToSelf(h=>(p,D)=>h(p,0,D)),"Array | Matrix":r.referToSelf(h=>p=>Ge(p,h,!0)),"SparseMatrix, number | BigNumber":r.referToSelf(h=>(p,D)=>s(p,D,h,!1)),"DenseMatrix, number | BigNumber":r.referToSelf(h=>(p,D)=>m(p,D,h,!1)),"Array, number | BigNumber":r.referToSelf(h=>(p,D)=>m(n(p),D,h,!1).valueOf()),"number | Complex | BigNumber | Fraction, SparseMatrix":r.referToSelf(h=>(p,D)=>i(p,0)?u(D.size(),D.storage()):f(D,p,h,!0)),"number | Complex | BigNumber | Fraction, DenseMatrix":r.referToSelf(h=>(p,D)=>i(p,0)?u(D.size(),D.storage()):m(D,p,h,!0)),"number | Complex | BigNumber | Fraction, Array":r.referToSelf(h=>(p,D)=>m(n(D),p,h,!0).valueOf())})}),Et="equal",ic=["typed","matrix","equalScalar","DenseMatrix","SparseMatrix"],uc=G(Et,ic,e=>{var{typed:r,matrix:t,equalScalar:n,DenseMatrix:i,concat:u,SparseMatrix:o}=e,a=Xr({typed:r}),s=Qr({typed:r,SparseMatrix:o}),f=$r({typed:r,DenseMatrix:i}),m=Pr({typed:r,matrix:t});return r(Et,oc({typed:r,equalScalar:n}),m({elop:n,SS:s,DS:a,Ss:f}))}),oc=G(Et,["typed","equalScalar"],e=>{var{typed:r,equalScalar:t}=e;return r(Et,{"any, any":function(i,u){return i===null?u===null:u===null?i===null:i===void 0?u===void 0:u===void 0?i===void 0:t(i,u)}})}),At="smaller",ac=["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],sc=G(At,ac,e=>{var{typed:r,config:t,bignumber:n,matrix:i,DenseMatrix:u,concat:o,SparseMatrix:a}=e,s=Xr({typed:r}),f=Qr({typed:r,SparseMatrix:a}),m=$r({typed:r,DenseMatrix:u}),l=Pr({typed:r,matrix:i,concat:o}),h=Yr({typed:r});function p(D,c){return D.lt(c)&&!gr(D,c,t.relTol,t.absTol)}return r(At,fc({typed:r,config:t}),{"boolean, boolean":(D,c)=>D<c,"BigNumber, BigNumber":p,"bigint, bigint":(D,c)=>D<c,"Fraction, Fraction":(D,c)=>D.compare(c)===-1,"Fraction, BigNumber":function(c,d){return p(n(c),d)},"BigNumber, Fraction":function(c,d){return p(c,n(d))},"Complex, Complex":function(c,d){throw new TypeError("No ordering relation is defined for complex numbers")}},h,l({SS:f,DS:s,Ss:m}))}),fc=G(At,["typed","config"],e=>{var{typed:r,config:t}=e;return r(At,{"number, number":function(i,u){return i<u&&!tr(i,u,t.relTol,t.absTol)}})}),bt="smallerEq",cc=["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],lc=G(bt,cc,e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i,concat:u,SparseMatrix:o}=e,a=Xr({typed:r}),s=Qr({typed:r,SparseMatrix:o}),f=$r({typed:r,DenseMatrix:i}),m=Pr({typed:r,matrix:n,concat:u}),l=Yr({typed:r});return r(bt,hc({typed:r,config:t}),{"boolean, boolean":(h,p)=>h<=p,"BigNumber, BigNumber":function(p,D){return p.lte(D)||gr(p,D,t.relTol,t.absTol)},"bigint, bigint":(h,p)=>h<=p,"Fraction, Fraction":(h,p)=>h.compare(p)!==1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},l,m({SS:s,DS:a,Ss:f}))}),hc=G(bt,["typed","config"],e=>{var{typed:r,config:t}=e;return r(bt,{"number, number":function(i,u){return i<=u||tr(i,u,t.relTol,t.absTol)}})}),Ct="larger",pc=["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],Dc=G(Ct,pc,e=>{var{typed:r,config:t,bignumber:n,matrix:i,DenseMatrix:u,concat:o,SparseMatrix:a}=e,s=Xr({typed:r}),f=Qr({typed:r,SparseMatrix:a}),m=$r({typed:r,DenseMatrix:u}),l=Pr({typed:r,matrix:i,concat:o}),h=Yr({typed:r});function p(D,c){return D.gt(c)&&!gr(D,c,t.relTol,t.absTol)}return r(Ct,mc({typed:r,config:t}),{"boolean, boolean":(D,c)=>D>c,"BigNumber, BigNumber":p,"bigint, bigint":(D,c)=>D>c,"Fraction, Fraction":(D,c)=>D.compare(c)===1,"Fraction, BigNumber":function(c,d){return p(n(c),d)},"BigNumber, Fraction":function(c,d){return p(c,n(d))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},h,l({SS:f,DS:s,Ss:m}))}),mc=G(Ct,["typed","config"],e=>{var{typed:r,config:t}=e;return r(Ct,{"number, number":function(i,u){return i>u&&!tr(i,u,t.relTol,t.absTol)}})}),_t="largerEq",dc=["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],gc=G(_t,dc,e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i,concat:u,SparseMatrix:o}=e,a=Xr({typed:r}),s=Qr({typed:r,SparseMatrix:o}),f=$r({typed:r,DenseMatrix:i}),m=Pr({typed:r,matrix:n,concat:u}),l=Yr({typed:r});return r(_t,vc({typed:r,config:t}),{"boolean, boolean":(h,p)=>h>=p,"BigNumber, BigNumber":function(p,D){return p.gte(D)||gr(p,D,t.relTol,t.absTol)},"bigint, bigint":function(p,D){return p>=D},"Fraction, Fraction":(h,p)=>h.compare(p)!==-1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},l,m({SS:s,DS:a,Ss:f}))}),vc=G(_t,["typed","config"],e=>{var{typed:r,config:t}=e;return r(_t,{"number, number":function(i,u){return i>=u||tr(i,u,t.relTol,t.absTol)}})}),wc="ImmutableDenseMatrix",yc=["smaller","DenseMatrix"],Fc=G(wc,yc,e=>{var{smaller:r,DenseMatrix:t}=e;function n(i,u){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(u&&!Te(u))throw new Error("Invalid datatype: "+u);if(ye(i)||ve(i)){var o=new t(i,u);this._data=o._data,this._size=o._size,this._datatype=o._datatype,this._min=null,this._max=null}else if(i&&ve(i.data)&&ve(i.size))this._data=i.data,this._size=i.size,this._datatype=i.datatype,this._min=typeof i.min<"u"?i.min:null,this._max=typeof i.max<"u"?i.max:null;else{if(i)throw new TypeError("Unsupported type of data ("+ur(i)+")");this._data=[],this._size=[0],this._datatype=u,this._min=null,this._max=null}}return n.prototype=new t,n.prototype.type="ImmutableDenseMatrix",n.prototype.isImmutableDenseMatrix=!0,n.prototype.subset=function(i){switch(arguments.length){case 1:{var u=t.prototype.subset.call(this,i);return ye(u)?new n({data:u._data,size:u._size,datatype:u._datatype}):u}case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},n.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},n.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},n.prototype.clone=function(){return new n({data:de(this._data),size:de(this._size),datatype:this._datatype})},n.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.fromJSON=function(i){return new n(i)},n.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},n.prototype.min=function(){if(this._min===null){var i=null;this.forEach(function(u){(i===null||r(u,i))&&(i=u)}),this._min=i!==null?i:void 0}return this._min},n.prototype.max=function(){if(this._max===null){var i=null;this.forEach(function(u){(i===null||r(i,u))&&(i=u)}),this._max=i!==null?i:void 0}return this._max},n},{isClass:!0}),Ec="Index",Ac=["ImmutableDenseMatrix","getMatrixDataType"],bc=G(Ec,Ac,e=>{var{ImmutableDenseMatrix:r,getMatrixDataType:t}=e;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._sourceSize=[],this._isScalar=!0;for(var u=0,o=arguments.length;u<o;u++){var a=u<0||arguments.length<=u?void 0:arguments[u],s=ve(a),f=ye(a),m=typeof a,l=null;if(si(a))this._dimensions.push(a),this._isScalar=!1;else if(s||f){var h=void 0;this._isScalar=!1,t(a)==="boolean"?(s&&(h=i(Xn(a).valueOf())),f&&(h=i(Xn(a._data).valueOf())),l=a.valueOf().length):h=i(a.valueOf()),this._dimensions.push(h)}else if(m==="number")this._dimensions.push(a);else if(m==="bigint")this._dimensions.push(Number(a));else if(m==="string")this._dimensions.push(a);else throw new TypeError("Dimension must be an Array, Matrix, number, bigint, string, or Range");this._sourceSize.push(l)}}n.prototype.type="Index",n.prototype.isIndex=!0;function i(u){for(var o=0,a=u.length;o<a;o++)if(!ne(u[o])||!we(u[o]))throw new TypeError("Index parameters must be positive integer numbers");var s=new r;return s._data=u,s._size=[u.length],s}return n.prototype.clone=function(){var u=new n;return u._dimensions=de(this._dimensions),u._isScalar=this._isScalar,u._sourceSize=this._sourceSize,u},n.create=function(u){var o=new n;return n.apply(o,u),o},n.prototype.size=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var s=this._dimensions[o];u[o]=Te(s)||ne(s)?1:s.size()[0]}return u},n.prototype.max=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var s=this._dimensions[o];u[o]=Te(s)||ne(s)?s:s.max()}return u},n.prototype.min=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var s=this._dimensions[o];u[o]=Te(s)||ne(s)?s:s.min()}return u},n.prototype.forEach=function(u){for(var o=0,a=this._dimensions.length;o<a;o++)u(this._dimensions[o],o,this)},n.prototype.dimension=function(u){var o;return ne(u)&&(o=this._dimensions[u])!==null&&o!==void 0?o:null},n.prototype.isObjectProperty=function(){return this._dimensions.length===1&&Te(this._dimensions[0])},n.prototype.getObjectProperty=function(){return this.isObjectProperty()?this._dimensions[0]:null},n.prototype.isScalar=function(){return this._isScalar},n.prototype.toArray=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var s=this._dimensions[o];u.push(Te(s)||ne(s)?s:s.toArray())}return u},n.prototype.valueOf=n.prototype.toArray,n.prototype.toString=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var s=this._dimensions[o];Te(s)?u.push(JSON.stringify(s)):u.push(s.toString())}return"["+u.join(", ")+"]"},n.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},n.fromJSON=function(u){return n.create(u.dimensions)},n},{isClass:!0});function Xn(e){var r=[];return e.forEach((t,n)=>{t&&r.push(n)}),r}function Cc(e){var r=0,t=1,n=Object.create(null),i=Object.create(null),u=0,o=function(s){var f=i[s];if(f&&(delete n[f],delete i[s],--r,t===f)){if(!r){u=0,t=1;return}for(;!Object.prototype.hasOwnProperty.call(n,++t););}};return e=Math.abs(e),{hit:function(s){var f=i[s],m=++u;if(n[m]=s,i[s]=m,!f)return++r,r<=e?void 0:(s=n[t],o(s),s);if(delete n[f],t===f)for(;!Object.prototype.hasOwnProperty.call(n,++t););},delete:o,clear:function(){r=u=0,t=1,n=Object.create(null),i=Object.create(null)}}}function Ot(e){var{hasher:r,limit:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return t=t??Number.POSITIVE_INFINITY,r=r??JSON.stringify,function n(){typeof n.cache!="object"&&(n.cache={values:new Map,lru:Cc(t||Number.POSITIVE_INFINITY)});for(var i=[],u=0;u<arguments.length;u++)i[u]=arguments[u];var o=r(i);if(n.cache.values.has(o))return n.cache.lru.hit(o),n.cache.values.get(o);var a=e.apply(e,i);return n.cache.values.set(o,a),n.cache.values.delete(n.cache.lru.hit(o)),a}}Ot(function(e){return new e(1).exp()},{hasher:$t});Ot(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},{hasher:$t});var Vi=Ot(function(e){return e.acos(-1)},{hasher:$t});Ot(function(e){return Vi(e).times(2)},{hasher:$t});function $t(e){return e[0].precision}var Qn="add",_c=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],Bc=G(Qn,_c,e=>{var{typed:r,matrix:t,addScalar:n,equalScalar:i,DenseMatrix:u,SparseMatrix:o,concat:a}=e,s=sf({typed:r}),f=lf({typed:r,equalScalar:i}),m=Df({typed:r,DenseMatrix:u}),l=Pr({typed:r,matrix:t,concat:a});return r(Qn,{"any, any":n,"any, any, ...any":r.referToSelf(h=>(p,D,c)=>{for(var d=h(p,D),v=0;v<c.length;v++)d=h(d,c[v]);return d})},l({elop:n,DS:s,SS:f,Ss:m}))}),Kn="dot",Nc=["typed","addScalar","multiplyScalar","conj","size"],Sc=G(Kn,Nc,e=>{var{typed:r,addScalar:t,multiplyScalar:n,conj:i,size:u}=e;return r(Kn,{"Array | DenseMatrix, Array | DenseMatrix":a,"SparseMatrix, SparseMatrix":s});function o(f,m){var l=u(f),h=u(m),p,D;if(l.length===1)p=l[0];else if(l.length===2&&l[1]===1)p=l[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+l.join(", ")+")");if(h.length===1)D=h[0];else if(h.length===2&&h[1]===1)D=h[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+h.join(", ")+")");if(p!==D)throw new RangeError("Vectors must have equal length ("+p+" != "+D+")");if(p===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return p}function a(f,m){var l=o(f,m),h=ye(f)?f._data:f,p=ye(f)?f._datatype||f.getDataType():void 0,D=ye(m)?m._data:m,c=ye(m)?m._datatype||m.getDataType():void 0,d=u(f).length===2,v=u(m).length===2,y=t,g=n;if(p&&c&&p===c&&typeof p=="string"&&p!=="mixed"){var A=p;y=r.find(t,[A,A]),g=r.find(n,[A,A])}if(!d&&!v){for(var F=g(i(h[0]),D[0]),w=1;w<l;w++)F=y(F,g(i(h[w]),D[w]));return F}if(!d&&v){for(var _=g(i(h[0]),D[0][0]),b=1;b<l;b++)_=y(_,g(i(h[b]),D[b][0]));return _}if(d&&!v){for(var B=g(i(h[0][0]),D[0]),S=1;S<l;S++)B=y(B,g(i(h[S][0]),D[S]));return B}if(d&&v){for(var x=g(i(h[0][0]),D[0][0]),O=1;O<l;O++)x=y(x,g(i(h[O][0]),D[O][0]));return x}}function s(f,m){o(f,m);for(var l=f._index,h=f._values,p=m._index,D=m._values,c=0,d=t,v=n,y=0,g=0;y<l.length&&g<p.length;){var A=l[y],F=p[g];if(A<F){y++;continue}if(A>F){g++;continue}A===F&&(c=d(c,v(h[y],D[g])),y++,g++)}return c}}),jn="index",Mc=["typed","Index"],xc=G(jn,Mc,e=>{var{typed:r,Index:t}=e;return r(jn,{"...number | string | BigNumber | Range | Array | Matrix":function(i){var u=i.map(function(a){return Ee(a)?a.toNumber():ve(a)||ye(a)?a.map(function(s){return Ee(s)?s.toNumber():s}):a}),o=new t;return t.apply(o,u),o}})}),ei="det",Tc=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],Ic=G(ei,Tc,e=>{var{typed:r,matrix:t,subtractScalar:n,multiply:i,divideScalar:u,isZero:o,unaryMinus:a}=e;return r(ei,{any:function(m){return de(m)},"Array | Matrix":function(m){var l;switch(ye(m)?l=m.size():Array.isArray(m)?(m=t(m),l=m.size()):l=[],l.length){case 0:return de(m);case 1:if(l[0]===1)return de(m.valueOf()[0]);if(l[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+Be(l)+")");case 2:{var h=l[0],p=l[1];if(h===p)return s(m.clone().valueOf(),h);if(p===0)return 1;throw new RangeError("Matrix must be square (size: "+Be(l)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Be(l)+")")}}});function s(f,m,l){if(m===1)return de(f[0][0]);if(m===2)return n(i(f[0][0],f[1][1]),i(f[1][0],f[0][1]));for(var h=!1,p=new Array(m).fill(0).map((_,b)=>b),D=0;D<m;D++){var c=p[D];if(o(f[c][D])){var d=void 0;for(d=D+1;d<m;d++)if(!o(f[p[d]][D])){c=p[d],p[d]=p[D],p[D]=c,h=!h;break}if(d===m)return f[c][D]}for(var v=f[c][D],y=D===0?1:f[p[D-1]][D-1],g=D+1;g<m;g++)for(var A=p[g],F=D+1;F<m;F++)f[A][F]=u(n(i(f[A][F],v),i(f[A][D],f[c][F])),y)}var w=f[p[m-1]][m-1];return h?a(w):w}}),ri="inv",zc=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],Oc=G(ri,zc,e=>{var{typed:r,matrix:t,divideScalar:n,addScalar:i,multiply:u,unaryMinus:o,det:a,identity:s,abs:f}=e;return r(ri,{"Array | Matrix":function(h){var p=ye(h)?h.size():Oe(h);switch(p.length){case 1:if(p[0]===1)return ye(h)?t([n(1,h.valueOf()[0])]):[n(1,h[0])];throw new RangeError("Matrix must be square (size: "+Be(p)+")");case 2:{var D=p[0],c=p[1];if(D===c)return ye(h)?t(m(h.valueOf(),D,c),h.storage()):m(h,D,c);throw new RangeError("Matrix must be square (size: "+Be(p)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Be(p)+")")}},any:function(h){return n(1,h)}});function m(l,h,p){var D,c,d,v,y;if(h===1){if(v=l[0][0],v===0)throw Error("Cannot calculate inverse, determinant is zero");return[[n(1,v)]]}else if(h===2){var g=a(l);if(g===0)throw Error("Cannot calculate inverse, determinant is zero");return[[n(l[1][1],g),n(o(l[0][1]),g)],[n(o(l[1][0]),g),n(l[0][0],g)]]}else{var A=l.concat();for(D=0;D<h;D++)A[D]=A[D].concat();for(var F=s(h).valueOf(),w=0;w<p;w++){var _=f(A[w][w]),b=w;for(D=w+1;D<h;)f(A[D][w])>_&&(_=f(A[D][w]),b=D),D++;if(_===0)throw Error("Cannot calculate inverse, determinant is zero");D=b,D!==w&&(y=A[w],A[w]=A[D],A[D]=y,y=F[w],F[w]=F[D],F[D]=y);var B=A[w],S=F[w];for(D=0;D<h;D++){var x=A[D],O=F[D];if(D!==w){if(x[w]!==0){for(d=n(o(x[w]),B[w]),c=w;c<p;c++)x[c]=i(x[c],u(d,B[c]));for(c=0;c<p;c++)O[c]=i(O[c],u(d,S[c]))}}else{for(d=B[w],c=w;c<p;c++)x[c]=n(x[c],d);for(c=0;c<p;c++)O[c]=n(O[c],d)}}}return F}}}),$c=Pc("pi",["config","?BigNumber"],e=>{var{config:r,BigNumber:t}=e;return r.number==="BigNumber"?Vi(t):fs});function Pc(e,r,t){return G(e,r,t,{recreateOnConfigChange:!0})}var qr=Sa({config:qe}),Pt=za({}),Gi=La({}),cn=Wa({}),nr=os({Matrix:cn,config:qe}),Zr=$c({BigNumber:qr,config:qe}),te=To({BigNumber:qr,Complex:Pt,DenseMatrix:nr,Fraction:Gi}),Bt=Rs({typed:te}),qt=Hs({typed:te}),jt=Bf({typed:te}),ot=xs({Complex:Pt,typed:te}),qc=Sf({typed:te}),Ur=gs({config:qe,typed:te}),Uc=If({typed:te}),Ji=vf({Complex:Pt,config:qe,typed:te}),ki=Ff({typed:te}),Yi=Cs({typed:te}),Rc=Lf({typed:te}),wr=ys({Matrix:cn,equalScalar:Ur,typed:te}),Lc=Ws({typed:te}),Ut=Ns({BigNumber:qr,typed:te}),Hc=Sc({addScalar:qt,conj:qc,multiplyScalar:ki,size:Rc,typed:te}),Xi=Ds({equalScalar:Ur,typed:te}),Ue=$s({DenseMatrix:nr,Matrix:cn,SparseMatrix:wr,typed:te}),Er=Af({addScalar:qt,dot:Hc,equalScalar:Ur,matrix:Ue,multiplyScalar:ki,typed:te}),Qi=kf({BigNumber:qr,config:qe,matrix:Ue,typed:te}),Ki=uc({DenseMatrix:nr,SparseMatrix:wr,equalScalar:Ur,matrix:Ue,typed:te}),ji=zs({Fraction:Gi,typed:te}),eu=Of({BigNumber:qr,DenseMatrix:nr,SparseMatrix:wr,config:qe,matrix:Ue,typed:te}),Zc=ss({equal:Ki,typed:te}),Wc=Qf({bignumber:Ut,fraction:ji,number:Yi}),en=nc({BigNumber:qr,DenseMatrix:nr,config:qe,equalScalar:Ur,matrix:Ue,typed:te,zeros:Qi}),ru=qs({typed:te}),Kr=xf({isInteger:Zc,matrix:Ue,typed:te}),tu=jf({numeric:Wc,typed:te}),Vc=hs({config:qe,typed:te}),Gc=Dc({DenseMatrix:nr,SparseMatrix:wr,bignumber:Ut,concat:Kr,config:qe,matrix:Ue,typed:te}),nu=sc({DenseMatrix:nr,SparseMatrix:wr,bignumber:Ut,concat:Kr,config:qe,matrix:Ue,typed:te}),Jr=Bc({DenseMatrix:nr,SparseMatrix:wr,addScalar:qt,concat:Kr,equalScalar:Ur,matrix:Ue,typed:te}),Jc=Ic({divideScalar:tu,isZero:Xi,matrix:Ue,multiply:Er,subtractScalar:Lc,typed:te,unaryMinus:ru}),kc=Fc({DenseMatrix:nr,smaller:nu}),Yc=bc({ImmutableDenseMatrix:kc,getMatrixDataType:Uc}),Xc=gc({DenseMatrix:nr,SparseMatrix:wr,concat:Kr,config:qe,matrix:Ue,typed:te}),at=Zf({add:Jr,matrix:Ue,typed:te,zeros:Qi}),st=xc({Index:Yc,typed:te}),Qc=Oc({abs:Bt,addScalar:qt,det:Jc,divideScalar:tu,identity:eu,matrix:Ue,multiply:Er,typed:te,unaryMinus:ru}),iu=rc({Complex:Pt,config:qe,fraction:ji,identity:eu,inv:Qc,matrix:Ue,multiply:Er,number:Yi,typed:te}),Kc=lc({DenseMatrix:nr,SparseMatrix:wr,concat:Kr,config:qe,matrix:Ue,typed:te}),ft=Uf({bignumber:Ut,matrix:Ue,add:Jr,config:qe,equal:Ki,isPositive:Vc,isZero:Xi,larger:Gc,largerEq:Xc,smaller:nu,smallerEq:Kc,typed:te});const jc=["Hz","kHz","MHz","GHz"],rn=299792458,cr={Hz:1,kHz:1e3,MHz:1e6,GHz:1e9,THz:1e12},tn={m:1,cm:.01,mm:.001,um:1e-6,nm:1e-9};class uu{_unit="Hz";set unit(r){if(typeof r!="string")throw new Error(`Unknown frequency unit: ${r}`);const t=this._unit;let n;switch(r.toLowerCase()){case"hz":n="Hz";break;case"khz":n="kHz";break;case"mhz":n="MHz";break;case"ghz":n="GHz";break;default:throw new Error(`Unknown frequency unit: ${r}`)}if(n!==t&&this.f_scaled&&this.f_scaled.length>0){const i=cr[t],u=cr[n];if(i&&u)this.f_scaled=this.f_scaled.map(o=>o*i/u);else throw new Error(`Could not find frequency multipliers (old: ${i}, new: ${u}) for unit conversion`)}this._unit=n}get unit(){return this._unit}_f_scaled=[];set f_scaled(r){if(!Array.isArray(r))throw new Error("Frequency value must be an array");for(const t of r){if(typeof t!="number")throw new Error(`Frequency value must be an array of numbers, but received: ${t}`);if(t<0)throw new Error(`Frequency values cannot be negative, but received: ${t}`)}this._f_scaled=r}get f_scaled(){return this._f_scaled}_getFrequencyInTargetUnit(r){if(!this.f_scaled||this.f_scaled.length===0)return[];const t=cr[this.unit];if(!t)throw new Error(`Multiplier for current unit ${this.unit} not found.`);const n=cr[r];if(!n)throw new Error(`Multiplier for target unit ${r} not found.`);return this.f_scaled.map(i=>i*t/n)}_setFrequencyFromTargetUnit(r,t){if(!r){this.f_scaled=[];return}if(r.length===0){this.f_scaled=[];return}const n=cr[t];if(!n)throw new Error(`Multiplier for source unit ${t} not found.`);const i=cr[this.unit];if(!i)throw new Error(`Multiplier for current internal unit ${this.unit} not found.`);const u=r.map(o=>o*n/i);this.f_scaled=u}get f_Hz(){return this._getFrequencyInTargetUnit("Hz")}set f_Hz(r){this._setFrequencyFromTargetUnit(r,"Hz")}get f_kHz(){return this._getFrequencyInTargetUnit("kHz")}set f_kHz(r){this._setFrequencyFromTargetUnit(r,"kHz")}get f_MHz(){return this._getFrequencyInTargetUnit("MHz")}set f_MHz(r){this._setFrequencyFromTargetUnit(r,"MHz")}get f_GHz(){return this._getFrequencyInTargetUnit("GHz")}set f_GHz(r){this._setFrequencyFromTargetUnit(r,"GHz")}get f_THz(){return this._getFrequencyInTargetUnit("THz")}set f_THz(r){this._setFrequencyFromTargetUnit(r,"THz")}_getWavelengthInTargetUnit(r){if(!this.f_scaled||this.f_scaled.length===0)return[];const t=cr[this.unit];if(!t)throw new Error(`Frequency multiplier for current unit ${this.unit} not found.`);const n=tn[r];if(!n)throw new Error(`Wavelength multiplier to meters for target wavelength unit ${r} not found.`);return this.f_scaled.map(i=>{const u=i*t;return u===0?1/0:rn/u/n})}_setWavelengthFromTargetUnit(r,t){if(!r){this.f_scaled=[];return}if(r.length===0){this.f_scaled=[];return}const n=tn[t];if(!n)throw new Error(`Wavelength multiplier to meters for source unit ${t} not found.`);const i=cr[this.unit];if(!i)throw new Error(`Frequency multiplier for current unit ${this.unit} not found.`);const u=r.map(o=>{const a=o*n;if(a===0)throw new Error("Cannot convert zero wavelength to frequency.");return rn/a/i});this.f_scaled=u}get wavelength_m(){return this._getWavelengthInTargetUnit("m")}set wavelength_m(r){this._setWavelengthFromTargetUnit(r,"m")}get wavelength_cm(){return this._getWavelengthInTargetUnit("cm")}set wavelength_cm(r){this._setWavelengthFromTargetUnit(r,"cm")}get wavelength_mm(){return this._getWavelengthInTargetUnit("mm")}set wavelength_mm(r){this._setWavelengthFromTargetUnit(r,"mm")}get wavelength_um(){return this._getWavelengthInTargetUnit("um")}set wavelength_um(r){this._setWavelengthFromTargetUnit(r,"um")}get wavelength_nm(){return this._getWavelengthInTargetUnit("nm")}set wavelength_nm(r){this._setWavelengthFromTargetUnit(r,"nm")}}const el=["RI","MA","DB"],rl=["S","Y","Z","G","H"];class tl{comments=[];_format;set format(r){if(r==null){this._format=void 0;return}if(typeof r!="string")throw new Error(`Unknown Touchstone format: ${r}`);switch(r.toLowerCase()){case"ma":this._format="MA";break;case"db":this._format="DB";break;case"ri":this._format="RI";break;default:throw new Error(`Unknown Touchstone format: ${r}`)}}get format(){return this._format}_parameter;set parameter(r){if(r==null){this._parameter=void 0;return}if(typeof r!="string")throw new Error(`Unknown Touchstone parameter: ${r}`);switch(r.toLowerCase()){case"s":this._parameter="S";break;case"y":this._parameter="Y";break;case"z":this._parameter="Z";break;case"g":this._parameter="G";break;case"h":this._parameter="H";break;default:throw new Error(`Unknown Touchstone parameter: ${r}`)}}get parameter(){return this._parameter}_impedance=50;set impedance(r){if(typeof r=="number"){this._impedance=r;return}if(!Array.isArray(r)||r.length===0)throw new Error(`Unknown Touchstone impedance: ${r}`);for(const t of r)if(typeof t!="number")throw new Error(`Unknown Touchstone impedance: ${r}`);this._impedance=r}get impedance(){return this._impedance}_nports;set nports(r){if(r==null){this._nports=void 0;return}if(typeof r!="number")throw new Error(`Unknown ports number: ${r}`);if(!Number.isInteger(r))throw new Error(`Unknown ports number: ${r}`);if(r<1)throw new Error(`Unknown ports number: ${r}`);this._nports=r}get nports(){return this._nports}frequency;_matrix;set matrix(r){if(r==null){this._matrix=void 0;return}this._matrix=r}get matrix(){return this._matrix}readContent(r,t){this.nports=t;const n=r.split(`
|
|
12
|
+
`).map(l=>l.trim()).filter(l=>l!=="");this.comments=n.filter(l=>l.startsWith("!")).map(l=>l.slice(1).trim()),this.frequency=new uu;const i=n.filter(l=>l.startsWith("#"));if(i.length===0)throw new Error('Unable to find the option line starting with "#"');if(i.length>1)throw new Error(`Only one option line starting with "#" is supported, but found ${i.length} lines`);const u=i[0].slice(1).trim().split(/\s+/);if(this.frequency.unit=u[0],this.parameter=u[1],this.format=u[2],u.length>=4){if(u[3].toLowerCase()!=="r")throw new Error(`Unknown Touchstone impedance: ${u.slice(3).join(" ")}`);const l=u.slice(4).map(h=>parseFloat(h));if(l.length===0||l.some(Number.isNaN))throw new Error(`Unknown Touchstone impedance: ${u.slice(3).join(" ")}`);if(l.length===1)this.impedance=l[0];else if(l.length===this.nports)this.impedance=l;else throw new Error(`${this.nports}-ports network, but find ${l.length} impedances: [${l}]`)}const a=n.filter(l=>!l.startsWith("!")&&!l.startsWith("#")).map(l=>{const h=l.indexOf("!");return h!==-1?l.substring(0,h).trim():l.trim()}).join(" ").split(/\s+/).map(l=>parseFloat(l)),s=2*Math.pow(this.nports,2)+1;if(a.length%s!==0)throw new Error(`Touchstone invalid data number: ${a.length}, which should be multiple of ${s}`);const f=a.length/s,m=at(a,st(Er(ft(0,f),s)));if(Array.isArray(m))this.frequency.f_scaled=m;else if(typeof m=="number")this.frequency.f_scaled=[m];else throw new Error(`Unknown frequency.f_scaled type: ${typeof m}, and its value: ${m}`);this.matrix=new Array(t);for(let l=0;l<t;l++){this.matrix[l]=new Array(t);for(let h=0;h<t;h++)this.matrix[l][h]=new Array(f)}for(let l=0;l<t;l++)for(let h=0;h<t;h++){const p=at(a,st(Jr(Er(ft(0,f),s),(l*t+h)*2+1))),D=at(a,st(Jr(Er(ft(0,f),s),(l*t+h)*2+2)));for(let c=0;c<f;c++){let d;switch(this.format){case"RI":d=ot(p[c],D[c]);break;case"MA":d=ot({r:p[c],phi:D[c]/180*Zr});break;case"DB":d=ot({r:iu(10,p[c]/20),phi:D[c]/180*Zr});break;default:throw new Error(`Unknown Touchstone format: ${this.format}`)}t===2?this.matrix[h][l][c]=d:this.matrix[l][h][c]=d}}}validate(){if(!this.nports)throw new Error("Number of ports (nports) is not defined");if(!this.frequency)throw new Error("Frequency object is not defined");if(this.frequency.f_scaled.length===0)throw new Error("Frequency points array is empty");if(!this.parameter)throw new Error("Network parameter type is not defined");if(!this.format)throw new Error("Data format (RI/MA/DB) is not defined");if(!this.matrix)throw new Error("Network parameter matrix is not defined");const r=this.frequency.f_scaled.length;if(this.matrix.length!==this.nports)throw new Error(`Touchstone matrix has ${this.matrix.length} rows, but expected ${this.nports}`);for(let t=0;t<this.nports;t++){if(this.matrix[t].length!==this.nports)throw new Error(`Touchstone matrix at row #${t} has ${this.matrix[t].length} columns, but expected ${this.nports}`);for(let n=0;n<this.nports;n++)if(this.matrix[t][n].length!==r)throw new Error(`Touchstone matrix at row #${t} column #${n} has ${this.matrix[t][n].length} points, but expected ${r}`)}}writeContent(){this.validate();const r=this.frequency.f_scaled.length,t=[];this.comments.length>0&&t.push(...this.comments.map(i=>`! ${i}`));let n=`# ${this.frequency.unit} ${this.parameter} ${this.format}`;Array.isArray(this.impedance)?n+=` R ${this.impedance.join(" ")}`:n+=` R ${this.impedance}`,t.push(n);for(let i=0;i<r;i++){const u=[this.frequency.f_scaled[i].toString()];for(let o=0;o<this.nports;o++)for(let a=0;a<this.nports;a++){const s=this.nports===2?this.matrix[a][o][i]:this.matrix[o][a][i];let f,m;switch(this.format){case"RI":f=s.re,m=s.im;break;case"MA":f=Bt(s),m=jt(s)/Zr*180;break;case"DB":f=20*Ji(Bt(s)),m=jt(s)/Zr*180;break;default:throw new Error(`Unknown Touchstone format: ${this.format}`)}u.push(en(f,12).toString(),en(m,12).toString())}t.push(u.join(" "))}return t.push(""),t.join(`
|
|
13
|
+
`)}}const nl=ot,il=ft;exports.FREQUENCY_MULTIPLIERS=cr;exports.Frequency=uu;exports.FrequencyUnits=jc;exports.SPEED_OF_LIGHT=rn;exports.Touchstone=tl;exports.TouchstoneFormats=el;exports.TouchstoneParameters=rl;exports.WAVELENGTH_MULTIPLIERS_TO_M=tn;exports.abs=Bt;exports.add=Jr;exports.arg=jt;exports.complex=nl;exports.index=st;exports.log10=Ji;exports.multiply=Er;exports.pi=Zr;exports.pow=iu;exports.range=il;exports.round=en;exports.subset=at;
|