0)if(++s>u)for(s-=u;s--;)l+="0";else s1&&((c[p+1]===null||c[p+1]===void 0)&&(c[p+1]=0),c[p+1]+=c[p]>>1,c[p]&=1)}return c.reverse()}function JP(t,e){if(t.isFinite()&&!t.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function bitXor");var r=t.constructor;if(t.isNaN()||e.isNaN())return new r(NaN);if(t.isZero())return e;if(e.isZero())return t;if(t.eq(e))return new r(0);var i=new r(-1);return t.eq(i)?Qc(e):e.eq(i)?Qc(t):!t.isFinite()||!e.isFinite()?!t.isFinite()&&!e.isFinite()?i:new r(t.isNegative()===e.isNegative()?1/0:-1/0):UE(t,e,function(n,o){return n^o})}function XP(t,e){if(t.isFinite()&&!t.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function leftShift");var r=t.constructor;return t.isNaN()||e.isNaN()||e.isNegative()&&!e.isZero()?new r(NaN):t.isZero()||e.isZero()?t:!t.isFinite()&&!e.isFinite()?new r(NaN):e.lt(55)?t.times(Math.pow(2,e.toNumber())+""):t.times(new r(2).pow(e))}function KP(t,e){if(t.isFinite()&&!t.isInteger()||e.isFinite()&&!e.isInteger())throw new Error("Integers expected in function rightArithShift");var r=t.constructor;return t.isNaN()||e.isNaN()||e.isNegative()&&!e.isZero()?new r(NaN):t.isZero()||e.isZero()?t:e.isFinite()?e.lt(55)?t.div(Math.pow(2,e.toNumber())+"").floor():t.div(new r(2).pow(e)).floor():t.isNegative()?new r(-1):t.isFinite()?new r(0):new r(NaN)}var QP="bitAnd",ene=["typed","matrix","equalScalar","concat"],yy=N(QP,ene,t=>{var{typed:e,matrix:r,equalScalar:i,concat:n}=t,o=Tn({typed:e,equalScalar:i}),a=Iu({typed:e,equalScalar:i}),s=Er({typed:e,equalScalar:i}),l=Bt({typed:e,matrix:r,concat:n});return e(QP,{"number, number":oE,"BigNumber, BigNumber":HP,"bigint, bigint":(u,c)=>u&c},l({SS:a,DS:o,Ss:s}))});var e2="bitNot",tne=["typed"],t2=N(e2,tne,t=>{var{typed:e}=t;return e(e2,{number:aE,BigNumber:Qc,bigint:r=>~r,"Array | Matrix":e.referToSelf(r=>i=>it(i,r))})});var r2="bitOr",rne=["typed","matrix","equalScalar","DenseMatrix","concat"],by=N(r2,rne,t=>{var{typed:e,matrix:r,equalScalar:i,DenseMatrix:n,concat:o}=t,a=Ii({typed:e}),s=Xc({typed:e,equalScalar:i}),l=mo({typed:e,DenseMatrix:n}),u=Bt({typed:e,matrix:r,concat:o});return e(r2,{"number, number":sE,"BigNumber, BigNumber":YP,"bigint, bigint":(c,f)=>c|f},u({SS:s,DS:a,Ss:l}))});var nne="matAlgo07xSSf",ine=["typed","SparseMatrix"],Ln=N(nne,ine,t=>{var{typed:e,SparseMatrix:r}=t;return function(o,a,s){var l=o._size,u=o._datatype||o._data===void 0?o._datatype:o.getDataType(),c=a._size,f=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(l.length!==c.length)throw new $t(l.length,c.length);if(l[0]!==c[0]||l[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+l+") must match Matrix B ("+c+")");var m=l[0],p=l[1],d,h=0,v=s;typeof u=="string"&&u===f&&u!=="mixed"&&(d=u,h=e.convert(0,d),v=e.find(s,[d,d]));for(var y=[],S=[],b=new Array(p+1).fill(0),_=[],w=[],x=[],E=[],T=0;T{var{typed:e,matrix:r,DenseMatrix:i,concat:n,SparseMatrix:o}=t,a=Vr({typed:e}),s=Ln({typed:e,SparseMatrix:o}),l=mr({typed:e,DenseMatrix:i}),u=Bt({typed:e,matrix:r,concat:n});return e(n2,{"number, number":uE,"BigNumber, BigNumber":JP,"bigint, bigint":(c,f)=>c^f},u({SS:s,DS:a,Ss:l}))});var o2="arg",ane=["typed"],a2=N(o2,ane,t=>{var{typed:e}=t;return e(o2,{number:function(i){return Math.atan2(0,i)},BigNumber:function(i){return i.constructor.atan2(0,i)},Complex:function(i){return i.arg()},"Array | Matrix":e.referToSelf(r=>i=>it(i,r))})});var s2="conj",sne=["typed"],u2=N(s2,sne,t=>{var{typed:e}=t;return e(s2,{"number | BigNumber | Fraction":r=>r,Complex:r=>r.conjugate(),Unit:e.referToSelf(r=>i=>new i.constructor(r(i.toNumeric()),i.formatUnits())),"Array | Matrix":e.referToSelf(r=>i=>it(i,r))})});var l2="im",une=["typed"],c2=N(l2,une,t=>{var{typed:e}=t;return e(l2,{number:()=>0,"BigNumber | Fraction":r=>r.mul(0),Complex:r=>r.im,"Array | Matrix":e.referToSelf(r=>i=>it(i,r))})});var f2="re",lne=["typed"],p2=N(f2,lne,t=>{var{typed:e}=t;return e(f2,{"number | BigNumber | Fraction":r=>r,Complex:r=>r.re,"Array | Matrix":e.referToSelf(r=>i=>it(i,r))})});var m2="not",cne=["typed"],d2=N(m2,cne,t=>{var{typed:e}=t;return e(m2,{"null | undefined":()=>!0,number:dE,Complex:function(i){return i.re===0&&i.im===0},BigNumber:function(i){return i.isZero()||i.isNaN()},bigint:r=>!r,Unit:e.referToSelf(r=>i=>e.find(r,i.valueType())(i.value)),"Array | Matrix":e.referToSelf(r=>i=>it(i,r))})});var h2="or",fne=["typed","matrix","equalScalar","DenseMatrix","concat"],xy=N(h2,fne,t=>{var{typed:e,matrix:r,equalScalar:i,DenseMatrix:n,concat:o}=t,a=Vr({typed:e}),s=$u({typed:e,equalScalar:i}),l=mr({typed:e,DenseMatrix:n}),u=Bt({typed:e,matrix:r,concat:o});return e(h2,{"number, number":ly,"Complex, Complex":function(f,m){return f.re!==0||f.im!==0||m.re!==0||m.im!==0},"BigNumber, BigNumber":function(f,m){return!f.isZero()&&!f.isNaN()||!m.isZero()&&!m.isNaN()},"bigint, bigint":ly,"Unit, Unit":e.referToSelf(c=>(f,m)=>c(f.value||0,m.value||0))},u({SS:s,DS:a,Ss:l}))});var g2="xor",pne=["typed","matrix","DenseMatrix","concat","SparseMatrix"],v2=N(g2,pne,t=>{var{typed:e,matrix:r,DenseMatrix:i,concat:n,SparseMatrix:o}=t,a=Vr({typed:e}),s=Ln({typed:e,SparseMatrix:o}),l=mr({typed:e,DenseMatrix:i}),u=Bt({typed:e,matrix:r,concat:n});return e(g2,{"number, number":cy,"Complex, Complex":function(f,m){return(f.re!==0||f.im!==0)!=(m.re!==0||m.im!==0)},"bigint, bigint":cy,"BigNumber, BigNumber":function(f,m){return(!f.isZero()&&!f.isNaN())!=(!m.isZero()&&!m.isNaN())},"Unit, Unit":e.referToSelf(c=>(f,m)=>c(f.value||0,m.value||0))},u({SS:s,DS:a,Ss:l}))});var y2="concat",mne=["typed","matrix","isInteger"],_y=N(y2,mne,t=>{var{typed:e,matrix:r,isInteger:i}=t;return e(y2,{"...Array | Matrix | number | BigNumber":function(o){var a,s=o.length,l=-1,u,c=!1,f=[];for(a=0;a0&&l>u)throw new ii(l,u+1)}else{var p=dt(m).valueOf(),d=vt(p);if(f[a]=p,u=l,l=d.length-1,a>0&&l!==u)throw new $t(u+1,l+1)}}if(f.length===0)throw new SyntaxError("At least one matrix expected");for(var h=f.shift();f.length;)h=zD(h,f.shift(),l);return c?r(h):h},"...string":function(o){return o.join("")}})});var b2="column",dne=["typed","Index","matrix","range"],wy=N(b2,dne,t=>{var{typed:e,Index:r,matrix:i,range:n}=t;return e(b2,{"Matrix, number":o,"Array, number":function(s,l){return o(i(dt(s)),l).valueOf()}});function o(a,s){if(a.size().length!==2)throw new Error("Only two dimensional matrix is supported");Mr(s,a.size()[1]);var l=n(0,a.size()[0]),u=new r(l,s),c=a.subset(u);return Je(c)?c:i([[c]])}});var x2="count",hne=["typed","size","prod"],_2=N(x2,hne,t=>{var{typed:e,size:r,prod:i}=t;return e(x2,{string:function(o){return o.length},"Matrix | Array":function(o){return i(r(o))}})});var w2="cross",gne=["typed","matrix","subtract","multiply"],S2=N(w2,gne,t=>{var{typed:e,matrix:r,subtract:i,multiply:n}=t;return e(w2,{"Matrix, Matrix":function(s,l){return r(o(s.toArray(),l.toArray()))},"Matrix, Array":function(s,l){return r(o(s.toArray(),l))},"Array, Matrix":function(s,l){return r(o(s,l.toArray()))},"Array, Array":o});function o(a,s){var l=Math.max(vt(a).length,vt(s).length);a=Zc(a),s=Zc(s);var u=vt(a),c=vt(s);if(u.length!==1||c.length!==1||u[0]!==3||c[0]!==3)throw new RangeError("Vectors with length 3 expected (Size A = ["+u.join(", ")+"], B = ["+c.join(", ")+"])");var f=[i(n(a[1],s[2]),n(a[2],s[1])),i(n(a[2],s[0]),n(a[0],s[2])),i(n(a[0],s[1]),n(a[1],s[0]))];return l>1?[f]:f}});var D2="diag",vne=["typed","matrix","DenseMatrix","SparseMatrix"],E2=N(D2,vne,t=>{var{typed:e,matrix:r,DenseMatrix:i,SparseMatrix:n}=t;return e(D2,{Array:function(u){return o(u,0,vt(u),null)},"Array, number":function(u,c){return o(u,c,vt(u),null)},"Array, BigNumber":function(u,c){return o(u,c.toNumber(),vt(u),null)},"Array, string":function(u,c){return o(u,0,vt(u),c)},"Array, number, string":function(u,c,f){return o(u,c,vt(u),f)},"Array, BigNumber, string":function(u,c,f){return o(u,c.toNumber(),vt(u),f)},Matrix:function(u){return o(u,0,u.size(),u.storage())},"Matrix, number":function(u,c){return o(u,c,u.size(),u.storage())},"Matrix, BigNumber":function(u,c){return o(u,c.toNumber(),u.size(),u.storage())},"Matrix, string":function(u,c){return o(u,0,u.size(),c)},"Matrix, number, string":function(u,c,f){return o(u,c,u.size(),f)},"Matrix, BigNumber, string":function(u,c,f){return o(u,c.toNumber(),u.size(),f)}});function o(l,u,c,f){if(!Ge(u))throw new TypeError("Second parameter in function diag must be an integer");var m=u>0?u:0,p=u<0?-u:0;switch(c.length){case 1:return a(l,u,f,c[0],p,m);case 2:return s(l,u,f,c,p,m)}throw new RangeError("Matrix for function diag must be 2 dimensional")}function a(l,u,c,f,m,p){var d=[f+m,f+p];if(c&&c!=="sparse"&&c!=="dense")throw new TypeError("Unknown matrix type ".concat(c,'"'));var h=c==="sparse"?n.diagonal(d,l,u):i.diagonal(d,l,u);return c!==null?h:h.valueOf()}function s(l,u,c,f,m,p){if(Je(l)){var d=l.diagonal(u);return c!==null?c!==d.storage()?r(d,c):d:d.valueOf()}for(var h=Math.min(f[0]-m,f[1]-p),v=[],y=0;y{var{typed:e}=t;return e("filter",{"Array, function":A2,"Matrix, function":function(i,n){return i.create(A2(i.valueOf(),n),i.datatype())},"Array, RegExp":LD,"Matrix, RegExp":function(i,n){return i.create(LD(i.valueOf(),n),i.datatype())}})});function A2(t,e){var r=oa(e,t,"filter");return r.isUnary?RD(t,r.fn):RD(t,function(i,n,o){return r.fn(i,[n],o)})}var T2="flatten",xne=["typed"],N2=N(T2,xne,t=>{var{typed:e}=t;return e(T2,{Array:function(i){return Ut(i)},Matrix:function(i){return i.create(Ut(i.valueOf(),!0),i.datatype())}})});var zE="forEach",_ne=["typed"],Dy=N(zE,_ne,t=>{var{typed:e}=t;return e(zE,{"Array, function":wne,"Matrix, function":function(i,n){i.forEach(n)}})});function wne(t,e){var r=oa(e,t,zE);iy(t,r.fn,r.isUnary)}var M2="getMatrixDataType",Sne=["typed"],C2=N(M2,Sne,t=>{var{typed:e}=t;return e(M2,{Array:function(i){return wl(i,ir)},Matrix:function(i){return i.getDataType()}})});var $2="identity",Dne=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],I2=N($2,Dne,t=>{var{typed:e,config:r,matrix:i,BigNumber:n,DenseMatrix:o,SparseMatrix:a}=t;return e($2,{"":function(){return r.matrix==="Matrix"?i([]):[]},string:function(c){return i(c)},"number | BigNumber":function(c){return l(c,c,r.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(c,f){return l(c,c,f)},"number | BigNumber, number | BigNumber":function(c,f){return l(c,f,r.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(c,f,m){return l(c,f,m)},Array:function(c){return s(c)},"Array, string":function(c,f){return s(c,f)},Matrix:function(c){return s(c.valueOf(),c.storage())},"Matrix, string":function(c,f){return s(c.valueOf(),f)}});function s(u,c){switch(u.length){case 0:return c?i(c):[];case 1:return l(u[0],u[0],c);case 2:return l(u[0],u[1],c);default:throw new Error("Vector containing two values expected")}}function l(u,c,f){var m=mt(u)||mt(c)?n:null;if(mt(u)&&(u=u.toNumber()),mt(c)&&(c=c.toNumber()),!Ge(u)||u<1)throw new Error("Parameters in function identity must be positive integers");if(!Ge(c)||c<1)throw new Error("Parameters in function identity must be positive integers");var p=m?new n(1):1,d=m?new m(0):0,h=[u,c];if(f){if(f==="sparse")return a.diagonal(h,p,0,d);if(f==="dense")return o.diagonal(h,p,0,d);throw new TypeError('Unknown matrix type "'.concat(f,'"'))}for(var v=Ta([],h,d),y=u{var{typed:e,matrix:r,multiplyScalar:i}=t;return e(F2,{"Matrix, Matrix":function(a,s){return r(n(a.toArray(),s.toArray()))},"Matrix, Array":function(a,s){return r(n(a.toArray(),s))},"Array, Matrix":function(a,s){return r(n(a,s.toArray()))},"Array, Array":n});function n(o,a){if(vt(o).length===1&&(o=[o]),vt(a).length===1&&(a=[a]),vt(o).length>2||vt(a).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(o.length)+", y = "+JSON.stringify(a.length)+")");var s=[],l=[];return o.map(function(u){return a.map(function(c){return l=[],s.push(l),u.map(function(f){return c.map(function(m){return l.push(i(f,m))})})})})&&s}});var VE="map",Ane=["typed"],Ey=N(VE,Ane,t=>{var{typed:e}=t;return e(VE,{"Array, function":i,"Matrix, function":function(o,a){return o.map(a)},"Array|Matrix, Array|Matrix, ...Array|Matrix|function":(n,o,a)=>r([n,o,...a.slice(0,a.length-1)],a[a.length-1])});function r(n,o){if(typeof o!="function")throw new Error("Last argument must be a callback function");var a=n[0].isMatrix,s=tm(...n.map(_=>_.isMatrix?_.size():vt(_))),l=a?(_,w)=>_.get(w):Wc,u=a?n.map(_=>_.isMatrix?_.create(ts(_.toArray(),s),_.datatype()):n[0].create(ts(_.valueOf(),s))):n.map(_=>_.isMatrix?ts(_.toArray(),s):ts(_,s)),c;if(e.isTypedFunction(o)){var f=s.map(()=>0),m=u.map(_=>l(_,f)),p=b(o,m,f,u);c=y(p)}else{var d=n.length,h=S(o,d);c=y(h)}var v=(_,w)=>c([_,...u.slice(1).map(x=>l(x,w))],w);if(a)return u[0].map(v);return i(u[0],v);function y(_){switch(_){case 0:return w=>o(...w);case 1:return(w,x)=>o(...w,x);case 2:return(w,x)=>o(...w,x,...u)}}function S(_,w){return _.length>w+1?2:_.length===w+1?1:0}function b(_,w,x,E){return e.resolve(_,[...w,x,...E])!==null?2:e.resolve(_,[...w,x])!==null?1:(e.resolve(_,w)!==null,0)}}function i(n,o){var a=oa(o,n,VE);return rm(n,a.fn,a.isUnary)}});var P2="diff",Tne=["typed","matrix","subtract","number"],Ay=N(P2,Tne,t=>{var{typed:e,matrix:r,subtract:i,number:n}=t;return e(P2,{"Array | Matrix":function(c){return Je(c)?r(a(c.toArray())):a(c)},"Array | Matrix, number":function(c,f){if(!Ge(f))throw new RangeError("Dimension must be a whole number");return Je(c)?r(o(c.toArray(),f)):o(c,f)},"Array, BigNumber":e.referTo("Array,number",u=>(c,f)=>u(c,n(f))),"Matrix, BigNumber":e.referTo("Matrix,number",u=>(c,f)=>u(c,n(f)))});function o(u,c){if(Je(u)&&(u=u.toArray()),!Array.isArray(u))throw RangeError("Array/Matrix does not have that many dimensions");if(c>0){var f=[];return u.forEach(m=>{f.push(o(m,c-1))}),f}else{if(c===0)return a(u);throw RangeError("Cannot have negative dimension")}}function a(u){for(var c=[],f=u.length,m=1;m{var{typed:e,config:r,matrix:i,BigNumber:n}=t;return e("ones",{"":function(){return r.matrix==="Array"?o([]):o([],"default")},"...number | BigNumber | string":function(u){var c=u[u.length-1];if(typeof c=="string"){var f=u.pop();return o(u,f)}else return r.matrix==="Array"?o(u):o(u,"default")},Array:o,Matrix:function(u){var c=u.storage();return o(u.valueOf(),c)},"Array | Matrix, string":function(u,c){return o(u.valueOf(),c)}});function o(l,u){var c=a(l),f=c?new n(1):1;if(s(l),u){var m=i(u);return l.length>0?m.resize(l,f):m}else{var p=[];return l.length>0?Ta(p,l,f):p}}function a(l){var u=!1;return l.forEach(function(c,f,m){mt(c)&&(u=!0,m[f]=c.toNumber())}),u}function s(l){l.forEach(function(u){if(typeof u!="number"||!Ge(u)||u<0)throw new Error("Parameters in function ones must be positive integers")})}});function ef(){throw new Error('No "bignumber" implementation available')}function Ty(){throw new Error('No "fraction" implementation available')}function Ny(){throw new Error('No "matrix" implementation available')}var O2="range",Cne=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq","add","isPositive"],My=N(O2,Cne,t=>{var{typed:e,config:r,matrix:i,bignumber:n,smaller:o,smallerEq:a,larger:s,largerEq:l,add:u,isPositive:c}=t;return e(O2,{string:m,"string, boolean":m,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 f(p(v,y,1,!1))},"number, number, number":function(v,y,S){return f(p(v,y,S,!1))},"number, number, boolean":function(v,y,S){return f(p(v,y,1,S))},"number, number, number, boolean":function(v,y,S,b){return f(p(v,y,S,b))},"bigint, bigint|number":function(v,y){return f(p(v,y,1n,!1))},"number, bigint":function(v,y){return f(p(BigInt(v),y,1n,!1))},"bigint, bigint|number, bigint|number":function(v,y,S){return f(p(v,y,BigInt(S),!1))},"number, bigint, bigint|number":function(v,y,S){return f(p(BigInt(v),y,BigInt(S),!1))},"bigint, bigint|number, boolean":function(v,y,S){return f(p(v,y,1n,S))},"number, bigint, boolean":function(v,y,S){return f(p(BigInt(v),y,1n,S))},"bigint, bigint|number, bigint|number, boolean":function(v,y,S,b){return f(p(v,y,BigInt(S),b))},"number, bigint, bigint|number, boolean":function(v,y,S,b){return f(p(BigInt(v),y,BigInt(S),b))},"BigNumber, BigNumber":function(v,y){var S=v.constructor;return f(p(v,y,new S(1),!1))},"BigNumber, BigNumber, BigNumber":function(v,y,S){return f(p(v,y,S,!1))},"BigNumber, BigNumber, boolean":function(v,y,S){var b=v.constructor;return f(p(v,y,new b(1),S))},"BigNumber, BigNumber, BigNumber, boolean":function(v,y,S,b){return f(p(v,y,S,b))},"Fraction, Fraction":function(v,y){return f(p(v,y,1,!1))},"Fraction, Fraction, Fraction":function(v,y,S){return f(p(v,y,S,!1))},"Fraction, Fraction, boolean":function(v,y,S){return f(p(v,y,1,S))},"Fraction, Fraction, Fraction, boolean":function(v,y,S,b){return f(p(v,y,S,b))},"Unit, Unit, Unit":function(v,y,S){return f(p(v,y,S,!1))},"Unit, Unit, Unit, boolean":function(v,y,S,b){return f(p(v,y,S,b))}});function f(h){return r.matrix==="Matrix"?i?i(h):Ny():h}function m(h,v){var y=d(h);if(!y)throw new SyntaxError('String "'+h+'" is no valid range');return r.number==="BigNumber"?(n===void 0&&ef(),f(p(n(y.start),n(y.end),n(y.step)),v)):f(p(y.start,y.end,y.step,v))}function p(h,v,y,S){for(var b=[],_=c(y)?S?a:o:S?l:s,w=h;_(w,v);)b.push(w),w=u(w,y);return b}function d(h){var v=h.split(":"),y=v.map(function(b){return Number(b)}),S=y.some(function(b){return isNaN(b)});if(S)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}}});var R2="reshape",$ne=["typed","isInteger","matrix"],L2=N(R2,$ne,t=>{var{typed:e,isInteger:r}=t;return e(R2,{"Matrix, Array":function(n,o){return n.reshape(o,!0)},"Array, Array":function(n,o){return o.forEach(function(a){if(!r(a))throw new TypeError("Invalid size for dimension: "+a)}),Qp(n,o)}})});var Ine="resize",Fne=["config","matrix"],U2=N(Ine,Fne,t=>{var{config:e,matrix:r}=t;return function(o,a,s){if(arguments.length!==2&&arguments.length!==3)throw new Bo("resize",arguments.length,2,3);if(Je(a)&&(a=a.valueOf()),mt(a[0])&&(a=a.map(function(c){return mt(c)?c.toNumber():c})),Je(o))return o.resize(a,s,!0);if(typeof o=="string")return i(o,a,s);var l=Array.isArray(o)?!1:e.matrix!=="Array";if(a.length===0){for(;Array.isArray(o);)o=o[0];return dt(o)}else{Array.isArray(o)||(o=[o]),o=dt(o);var u=Ta(o,a,s);return l?r(u):u}};function i(n,o,a){if(a!==void 0){if(typeof a!="string"||a.length!==1)throw new TypeError("Single character expected as defaultValue")}else a=" ";if(o.length!==1)throw new $t(o.length,1);var s=o[0];if(typeof s!="number"||!Ge(s))throw new TypeError("Invalid size, must contain positive integers (size: "+Ct(o)+")");if(n.length>s)return n.substring(0,s);if(n.length{var{typed:e,multiply:r,rotationMatrix:i}=t;return e(z2,{"Array , number | BigNumber | Complex | Unit":function(a,s){n(a,2);var l=r(i(s),a);return l.toArray()},"Matrix , number | BigNumber | Complex | Unit":function(a,s){return n(a,2),r(i(s),a)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(a,s,l){n(a,3);var u=r(i(s,l),a);return u},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(a,s,l){return n(a,3),r(i(s,l),a)}});function n(o,a){var s=Array.isArray(o)?vt(o):o.size();if(s.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(a));if(s.length===2&&s[1]!==1)throw new RangeError("Vector must be of dimensions 1x".concat(a));if(s[0]!==a)throw new RangeError("Vector must be of dimensions 1x".concat(a))}});var q2="rotationMatrix",Pne=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],j2=N(q2,Pne,t=>{var{typed:e,config:r,multiplyScalar:i,addScalar:n,unaryMinus:o,norm:a,BigNumber:s,matrix:l,DenseMatrix:u,SparseMatrix:c,cos:f,sin:m}=t;return e(q2,{"":function(){return r.matrix==="Matrix"?l([]):[]},string:function(b){return l(b)},"number | BigNumber | Complex | Unit":function(b){return p(b,r.matrix==="Matrix"?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(b,_){return p(b,_)},"number | BigNumber | Complex | Unit, Array":function(b,_){var w=l(_);return d(w),y(b,w,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(b,_){d(_);var w=_.storage()||(r.matrix==="Matrix"?"dense":void 0);return y(b,_,w)},"number | BigNumber | Complex | Unit, Array, string":function(b,_,w){var x=l(_);return d(x),y(b,x,w)},"number | BigNumber | Complex | Unit, Matrix, string":function(b,_,w){return d(_),y(b,_,w)}});function p(S,b){var _=mt(S),w=_?new s(-1):-1,x=f(S),E=m(S),T=[[x,i(w,E)],[E,x]];return v(T,b)}function d(S){var b=S.size();if(b.length<1||b[0]!==3)throw new RangeError("Vector must be of dimensions 1x3")}function h(S){return S.reduce((b,_)=>i(b,_))}function v(S,b){if(b){if(b==="sparse")return new c(S);if(b==="dense")return new u(S);throw new TypeError('Unknown matrix type "'.concat(b,'"'))}return S}function y(S,b,_){var w=a(b);if(w===0)throw new RangeError("Rotation around zero vector");var x=mt(S)?s:null,E=x?new x(1):1,T=x?new x(-1):-1,D=x?new x(b.get([0])/w):b.get([0])/w,M=x?new x(b.get([1])/w):b.get([1])/w,C=x?new x(b.get([2])/w):b.get([2])/w,$=f(S),O=n(E,o($)),R=m(S),L=n($,h([D,D,O])),k=n(h([D,M,O]),h([T,C,R])),V=n(h([D,C,O]),h([M,R])),J=n(h([D,M,O]),h([C,R])),W=n($,h([M,M,O])),Q=n(h([M,C,O]),h([T,D,R])),ie=n(h([D,C,O]),h([T,M,R])),B=n(h([M,C,O]),h([D,R])),Z=n($,h([C,C,O])),q=[[L,k,V],[J,W,Q],[ie,B,Z]];return v(q,_)}});var Z2="row",Bne=["typed","Index","matrix","range"],Cy=N(Z2,Bne,t=>{var{typed:e,Index:r,matrix:i,range:n}=t;return e(Z2,{"Matrix, number":o,"Array, number":function(s,l){return o(i(dt(s)),l).valueOf()}});function o(a,s){if(a.size().length!==2)throw new Error("Only two dimensional matrix is supported");Mr(s,a.size()[0]);var l=n(0,a.size()[1]),u=new r(s,l),c=a.subset(u);return Je(c)?c:i([[c]])}});var G2="size",One=["typed","config","?matrix"],W2=N(G2,One,t=>{var{typed:e,config:r,matrix:i}=t;return e(G2,{Matrix:function(o){return o.create(o.size(),"number")},Array:vt,string:function(o){return r.matrix==="Array"?[o.length]:i([o.length],"dense","number")},"number | Complex | BigNumber | Unit | boolean | null":function(o){return r.matrix==="Array"?[]:i?i([],"dense","number"):Ny()}})});var H2="squeeze",Rne=["typed"],Y2=N(H2,Rne,t=>{var{typed:e}=t;return e(H2,{Array:function(i){return Zc(dt(i))},Matrix:function(i){var n=Zc(i.toArray());return Array.isArray(n)?i.create(n,i.datatype()):n},any:function(i){return dt(i)}})});var J2="subset",Lne=["typed","matrix","zeros","add"],$y=N(J2,Lne,t=>{var{typed:e,matrix:r,zeros:i,add:n}=t;return e(J2,{"Matrix, Index":function(s,l){return _l(l)?r():(Kp(s,l),s.subset(l))},"Array, Index":e.referTo("Matrix, Index",function(a){return function(s,l){var u=a(r(s),l);return l.isScalar()?u:u.valueOf()}}),"Object, Index":zne,"string, Index":Une,"Matrix, Index, any, any":function(s,l,u,c){return _l(l)?s:(Kp(s,l),s.clone().subset(l,o(u,l),c))},"Array, Index, any, any":e.referTo("Matrix, Index, any, any",function(a){return function(s,l,u,c){var f=a(r(s),l,u,c);return f.isMatrix?f.valueOf():f}}),"Array, Index, any":e.referTo("Matrix, Index, any, any",function(a){return function(s,l,u){return a(r(s),l,u,void 0).valueOf()}}),"Matrix, Index, any":e.referTo("Matrix, Index, any, any",function(a){return function(s,l,u){return a(s,l,u,void 0)}}),"string, Index, string":X2,"string, Index, string, string":X2,"Object, Index, any":Vne});function o(a,s){if(typeof a=="string")throw new Error("can't boradcast a string");if(s._isScalar)return a;var l=s.size();if(l.every(u=>u>0))try{return n(a,i(l))}catch{return a}else return a}});function Une(t,e){if(!Xa(e))throw new TypeError("Index expected");if(_l(e))return"";if(Kp(Array.from(t),e),e.size().length!==1)throw new $t(e.size().length,1);var r=t.length;Mr(e.min()[0],r),Mr(e.max()[0],r);var i=e.dimension(0),n="";return i.forEach(function(o){n+=t.charAt(o)}),n}function X2(t,e,r,i){if(!e||e.isIndex!==!0)throw new TypeError("Index expected");if(_l(e))return t;if(Kp(Array.from(t),e),e.size().length!==1)throw new $t(e.size().length,1);if(i!==void 0){if(typeof i!="string"||i.length!==1)throw new TypeError("Single character expected as defaultValue")}else i=" ";var n=e.dimension(0),o=n.size()[0];if(o!==r.length)throw new $t(n.size()[0],r.length);var a=t.length;Mr(e.min()[0]),Mr(e.max()[0]);for(var s=[],l=0;la)for(var u=a-1,c=s.length;u{var{typed:e,matrix:r}=t;return e(K2,{Array:a=>i(r(a)).valueOf(),Matrix:i,any:dt});function i(a){var s=a.size(),l;switch(s.length){case 1:l=a.clone();break;case 2:{var u=s[0],c=s[1];if(c===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+Ct(s)+")");switch(a.storage()){case"dense":l=n(a,u,c);break;case"sparse":l=o(a,u,c);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+Ct(s)+")")}return l}function n(a,s,l){for(var u=a._data,c=[],f,m=0;m{var{typed:e,transpose:r,conj:i}=t;return e(eB,{any:function(o){return i(r(o))}})});var rB="zeros",Zne=["typed","config","matrix","BigNumber"],nB=N(rB,Zne,t=>{var{typed:e,config:r,matrix:i,BigNumber:n}=t;return e(rB,{"":function(){return r.matrix==="Array"?o([]):o([],"default")},"...number | BigNumber | string":function(u){var c=u[u.length-1];if(typeof c=="string"){var f=u.pop();return o(u,f)}else return r.matrix==="Array"?o(u):o(u,"default")},Array:o,Matrix:function(u){var c=u.storage();return o(u.valueOf(),c)},"Array | Matrix, string":function(u,c){return o(u.valueOf(),c)}});function o(l,u){var c=a(l),f=c?new n(0):0;if(s(l),u){var m=i(u);return l.length>0?m.resize(l,f):m}else{var p=[];return l.length>0?Ta(p,l,f):p}}function a(l){var u=!1;return l.forEach(function(c,f,m){mt(c)&&(u=!0,m[f]=c.toNumber())}),u}function s(l){l.forEach(function(u){if(typeof u!="number"||!Ge(u)||u<0)throw new Error("Parameters in function zeros must be positive integers")})}});var iB="fft",Gne=["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i","dotDivide","conj","pow","ceil","log2"],oB=N(iB,Gne,t=>{var{typed:e,matrix:r,addScalar:i,multiplyScalar:n,divideScalar:o,exp:a,tau:s,i:l,dotDivide:u,conj:c,pow:f,ceil:m,log2:p}=t;return e(iB,{Array:d,Matrix:function(b){return b.create(d(b.valueOf()),b.datatype())}});function d(S){var b=vt(S);return b.length===1?y(S,b[0]):h(S.map(_=>d(_,b.slice(1))),0)}function h(S,b){var _=vt(S);if(b!==0)return new Array(_[0]).fill(0).map((x,E)=>h(S[E],b-1));if(_.length===1)return y(S);function w(x){var E=vt(x);return new Array(E[1]).fill(0).map((T,D)=>new Array(E[0]).fill(0).map((M,C)=>x[C][D]))}return w(h(w(S),1))}function v(S){for(var b=S.length,_=a(o(n(-1,n(l,s)),b)),w=[],x=1-b;xn(S[V],w[b-1+V])),...new Array(E-b).fill(0)],D=[...new Array(b+b-1).fill(0).map((k,V)=>o(1,w[V])),...new Array(E-(b+b-1)).fill(0)],M=y(T),C=y(D),$=new Array(E).fill(0).map((k,V)=>n(M[V],C[V])),O=u(c(d(c($))),E),R=[],L=b-1;LD%2===0),b/2),...y(S.filter((T,D)=>D%2===1),b/2)],w=0;w{var{typed:e,fft:r,dotDivide:i,conj:n}=t;return e(aB,{"Array | Matrix":function(a){var s=Je(a)?a.size():vt(a);return i(n(r(n(a))),s.reduce((l,u)=>l*u,1))}})});function Dl(t){"@babel/helpers - typeof";return Dl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Dl(t)}function uB(t,e){if(Dl(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var i=r.call(t,e||"default");if(Dl(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function lB(t){var e=uB(t,"string");return Dl(e)=="symbol"?e:e+""}function dr(t,e,r){return(e=lB(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function cB(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,i)}return r}function Hne(t){for(var e=1;e{var{typed:e,add:r,subtract:i,multiply:n,divide:o,max:a,map:s,abs:l,isPositive:u,isNegative:c,larger:f,smaller:m,matrix:p,bignumber:d,unaryMinus:h}=t;function v(T){return function(D,M,C,$){var O=!(M.length===2&&(M.every(x)||M.every(En)));if(O)throw new Error('"tspan" must be an Array of two numeric values or two units [tStart, tEnd]');var R=M[0],L=M[1],k=f(L,R),V=$.firstStep;if(V!==void 0&&!u(V))throw new Error('"firstStep" must be positive');var J=$.maxStep;if(J!==void 0&&!u(J))throw new Error('"maxStep" must be positive');var W=$.minStep;if(W&&c(W))throw new Error('"minStep" must be positive or zero');var Q=[R,L,V,W,J].filter(De=>De!==void 0);if(!(Q.every(x)||Q.every(En)))throw new Error('Inconsistent type of "t" dependant variables');for(var ie=1,B=$.tol?$.tol:1e-4,Z=$.minDelta?$.minDelta:.2,q=$.maxDelta?$.maxDelta:5,xe=$.maxIter?$.maxIter:1e4,de=[R,L,...C,J,W].some(mt),[be,G,K,re]=de?[d(T.a),d(T.c),d(T.b),d(T.bp)]:[T.a,T.c,T.b,T.bp],ae=V?k?V:h(V):o(i(L,R),ie),le=[R],Se=[C],_e=i(K,re),Oe=0,st=0,yt=_(k),Qe=w(k);yt(le[Oe],L);){var ut=[];ae=Qe(le[Oe],L,ae),ut.push(D(le[Oe],Se[Oe]));for(var H=1;HEn(De)?De.value:De)));oe1/4&&(le.push(r(le[Oe],ae)),Se.push(r(Se[Oe],n(ae,K,ut))),Oe++);var ve=.84*(B/oe)**(1/5);if(m(ve,Z)?ve=Z:f(ve,q)&&(ve=q),ve=de?d(ve):ve,ae=n(ae,ve),J&&f(l(ae),J)?ae=k?J:h(J):W&&m(l(ae),W)&&(ae=k?W:h(W)),st++,st>xe)throw new Error("Maximum number of iterations reached, try changing options")}return{t:le,y:Se}}}function y(T,D,M,C){var $=[[],[.5],[0,.75],[.2222222222222222,.3333333333333333,.4444444444444444]],O=[null,1/2,3/4,1],R=[2/9,1/3,4/9,0],L=[7/24,1/4,1/3,1/8],k={a:$,c:O,b:R,bp:L};return v(k)(T,D,M,C)}function S(T,D,M,C){var $=[[],[.2],[.075,.225],[.9777777777777777,-3.7333333333333334,3.5555555555555554],[2.9525986892242035,-11.595793324188385,9.822892851699436,-.2908093278463649],[2.8462752525252526,-10.757575757575758,8.906422717743473,.2784090909090909,-.2735313036020583],[.09114583333333333,0,.44923629829290207,.6510416666666666,-.322376179245283,.13095238095238096]],O=[null,1/5,3/10,4/5,8/9,1,1],R=[35/384,0,500/1113,125/192,-2187/6784,11/84,0],L=[5179/57600,0,7571/16695,393/640,-92097/339200,187/2100,1/40],k={a:$,c:O,b:R,bp:L};return v(k)(T,D,M,C)}function b(T,D,M,C){var $=C.method?C.method:"RK45",O={RK23:y,RK45:S};if($.toUpperCase()in O){var R=Hne({},C);return delete R.method,O[$.toUpperCase()](T,D,M,R)}else{var L=Object.keys(O).map(V=>'"'.concat(V,'"')),k="".concat(L.slice(0,-1).join(", ")," and ").concat(L.slice(-1));throw new Error('Unavailable method "'.concat($,'". Available methods are ').concat(k))}}function _(T){return T?m:f}function w(T){var D=T?f:m;return function(M,C,$){var O=r(M,$);return D(O,C)?i(C,M):$}}function x(T){return mt(T)||Et(T)}function E(T,D,M,C){var $=b(T,D.toArray(),M.toArray(),C);return{t:p($.t),y:p($.y)}}return e("solveODE",{"function, Array, Array, Object":b,"function, Matrix, Matrix, Object":E,"function, Array, Array":(T,D,M)=>b(T,D,M,{}),"function, Matrix, Matrix":(T,D,M)=>E(T,D,M,{}),"function, Array, number | BigNumber | Unit":(T,D,M)=>{var C=b(T,D,[M],{});return{t:C.t,y:C.y.map($=>$[0])}},"function, Matrix, number | BigNumber | Unit":(T,D,M)=>{var C=b(T,D.toArray(),[M],{});return{t:p(C.t),y:p(C.y.map($=>$[0]))}},"function, Array, number | BigNumber | Unit, Object":(T,D,M,C)=>{var $=b(T,D,[M],C);return{t:$.t,y:$.y.map(O=>O[0])}},"function, Matrix, number | BigNumber | Unit, Object":(T,D,M,C)=>{var $=b(T,D.toArray(),[M],C);return{t:p($.t),y:p($.y.map(O=>O[0]))}}})});var Xne="erf",Kne=["typed"],pB=N(Xne,Kne,t=>{var{typed:e}=t;return e("name",{number:function(a){var s=Math.abs(a);return s>=tie?ra(a):s<=Qne?ra(a)*r(s):s<=4?ra(a)*(1-i(s)):ra(a)*(1-n(s))},"Array | Matrix":e.referToSelf(o=>a=>it(a,o))});function r(o){var a=o*o,s=Xs[0][4]*a,l=a,u;for(u=0;u<3;u+=1)s=(s+Xs[0][u])*a,l=(l+tf[0][u])*a;return o*(s+Xs[0][3])/(l+tf[0][3])}function i(o){var a=Xs[1][8]*o,s=o,l;for(l=0;l<7;l+=1)a=(a+Xs[1][l])*o,s=(s+tf[1][l])*o;var u=(a+Xs[1][7])/(s+tf[1][7]),c=parseInt(o*16)/16,f=(o-c)*(o+c);return Math.exp(-c*c)*Math.exp(-f)*u}function n(o){var a=1/(o*o),s=Xs[2][5]*a,l=a,u;for(u=0;u<4;u+=1)s=(s+Xs[2][u])*a,l=(l+tf[2][u])*a;var c=a*(s+Xs[2][4])/(l+tf[2][4]);c=(eie-c)/o,a=parseInt(o*16)/16;var f=(o-a)*(o+a);return Math.exp(-a*a)*Math.exp(-f)*c}}),Qne=.46875,eie=.5641895835477563,Xs=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,21531153547440383e-24],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],tf=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],tie=Math.pow(2,53);var mB="zeta",rie=["typed","config","multiply","pow","divide","factorial","equal","smallerEq","isNegative","gamma","sin","subtract","add","?Complex","?BigNumber","pi"],dB=N(mB,rie,t=>{var{typed:e,config:r,multiply:i,pow:n,divide:o,factorial:a,equal:s,smallerEq:l,isNegative:u,gamma:c,sin:f,subtract:m,add:p,Complex:d,BigNumber:h,pi:v}=t;return e(mB,{number:x=>y(x,E=>E,()=>20),BigNumber:x=>y(x,E=>new h(E),()=>Math.abs(Math.log10(r.relTol))),Complex:S});function y(x,E,T){return s(x,0)?E(-.5):s(x,1)?E(NaN):isFinite(x)?b(x,E,T,D=>D):u(x)?E(NaN):E(1)}function S(x){return x.re===0&&x.im===0?new d(-.5):x.re===1?new d(NaN,NaN):x.re===1/0&&x.im===0?new d(1):x.im===1/0||x.re===-1/0?new d(NaN,NaN):b(x,E=>E,E=>Math.round(1.3*15+.9*Math.abs(E.im)),E=>E.re)}function b(x,E,T,D){var M=T(x);if(D(x)>-(M-1)/2)return w(x,E(M),E);var C=i(n(2,x),n(E(v),m(x,1)));return C=i(C,f(i(o(E(v),2),x))),C=i(C,c(m(1,x))),i(C,b(m(1,x),E,T,D))}function _(x,E){for(var T=x,D=x;l(D,E);D=p(D,1)){var M=o(i(a(p(E,m(D,1))),n(4,D)),i(a(m(E,D)),a(i(2,D))));T=p(T,M)}return i(E,T)}function w(x,E,T){for(var D=o(1,i(_(T(0),E),m(1,n(2,m(1,x))))),M=T(0),C=T(1);l(C,E);C=p(C,1))M=p(M,o(i((-1)**(C-1),_(C,E)),n(C,x)));return i(D,M)}});var hB="mode",nie=["typed","isNaN","isNumeric"],gB=N(hB,nie,t=>{var{typed:e,isNaN:r,isNumeric:i}=t;return e(hB,{"Array | Matrix":n,"...":function(a){return n(a)}});function n(o){o=Ut(o.valueOf());var a=o.length;if(a===0)throw new Error("Cannot calculate mode of an empty array");for(var s={},l=[],u=0,c=0;cu&&(u=s[f],l=[f])}return l}});function gn(t,e,r){var i;return String(t).includes("Unexpected type")?(i=arguments.length>2?" (type: "+ir(r)+", value: "+JSON.stringify(r)+")":" (type: "+t.data.actual+")",new TypeError("Cannot calculate "+e+", unexpected type of argument"+i)):String(t).includes("complex numbers")?(i=arguments.length>2?" (type: "+ir(r)+", value: "+JSON.stringify(r)+")":"",new TypeError("Cannot calculate "+e+", no ordering relation is defined for complex numbers"+i)):t}var vB="prod",iie=["typed","config","multiplyScalar","numeric"],yB=N(vB,iie,t=>{var{typed:e,config:r,multiplyScalar:i,numeric:n}=t;return e(vB,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(s,l){throw new Error("prod(A, dim) is not yet supported")},"...":function(s){return o(s)}});function o(a){var s;if(Zi(a,function(l){try{s=s===void 0?l:i(s,l)}catch(u){throw gn(u,"prod",l)}}),typeof s=="string"&&(s=n(s,Mi(s,r))),s===void 0)throw new Error("Cannot calculate prod of an empty array");return s}});var bB="format",oie=["typed"],xB=N(bB,oie,t=>{var{typed:e}=t;return e(bB,{any:Ct,"any, Object | function | number | BigNumber":Ct})});var _B="bin",aie=["typed","format"],wB=N(_B,aie,t=>{var{typed:e,format:r}=t;return e(_B,{"number | BigNumber":function(n){return r(n,{notation:"bin"})},"number | BigNumber, number | BigNumber":function(n,o){return r(n,{notation:"bin",wordSize:o})}})});var SB="oct",sie=["typed","format"],DB=N(SB,sie,t=>{var{typed:e,format:r}=t;return e(SB,{"number | BigNumber":function(n){return r(n,{notation:"oct"})},"number | BigNumber, number | BigNumber":function(n,o){return r(n,{notation:"oct",wordSize:o})}})});var EB="hex",uie=["typed","format"],AB=N(EB,uie,t=>{var{typed:e,format:r}=t;return e(EB,{"number | BigNumber":function(n){return r(n,{notation:"hex"})},"number | BigNumber, number | BigNumber":function(n,o){return r(n,{notation:"hex",wordSize:o})}})});var Iy=/\$([\w.]+)/g;var TB="print",lie=["typed"],Fy=N(TB,lie,t=>{var{typed:e}=t;return e(TB,{"string, Object | Array":NB,"string, Object | Array, number | Object":NB})});function NB(t,e,r){return t.replace(Iy,function(i,n){var o=n.split("."),a=e[o.shift()];for(a!==void 0&&a.isMatrix&&(a=a.toArray());o.length&&a!==void 0;){var s=o.shift();a=s?a[s]:a+"."}return a!==void 0?Qr(a)?a:Ct(a,r):i})}var MB="to",cie=["typed","matrix","concat"],CB=N(MB,cie,t=>{var{typed:e,matrix:r,concat:i}=t,n=Bt({typed:e,matrix:r,concat:i});return e(MB,{"Unit, Unit | string":(o,a)=>o.to(a)},n({Ds:!0}))});var $B="toBest",fie=["typed"],IB=N($B,fie,t=>{var{typed:e}=t;return e($B,{Unit:r=>r.toBest(),"Unit, string":(r,i)=>r.toBest(i.split(",")),"Unit, string, Object":(r,i,n)=>r.toBest(i.split(","),n),"Unit, Array":(r,i)=>r.toBest(i),"Unit, Array, Object":(r,i,n)=>r.toBest(i,n)})});var FB="isPrime",pie=["typed"],kB=N(FB,pie,t=>{var{typed:e}=t;return e(FB,{number:function(i){if(i<=3)return i>1;if(i%2===0||i%3===0)return!1;for(var n=5;n*n<=i;n+=6)if(i%n===0||i%(n+2)===0)return!1;return!0},bigint:function(i){if(i<=3n)return i>1n;if(i%2n===0n||i%3n===0n)return!1;for(var n=5n;n*n<=i;n+=6n)if(i%n===0n||i%(n+2n)===0n)return!1;return!0},BigNumber:function(i){if(i.lte(3))return i.gt(1);if(i.mod(2).eq(0)||i.mod(3).eq(0))return!1;if(i.lt(Math.pow(2,32))){for(var n=i.toNumber(),o=5;o*o<=n;o+=6)if(n%o===0||n%(o+2)===0)return!1;return!0}function a(S,b,_){for(var w=1;!b.eq(0);)b.mod(2).eq(0)?(b=b.div(2),S=S.mul(S).mod(_)):(b=b.sub(1),w=S.mul(w).mod(_));return w}var s=i.constructor.clone({precision:i.toFixed(0).length*2});i=new s(i);for(var l=0,u=i.sub(1);u.mod(2).eq(0);)u=u.div(2),l+=1;var c=null;if(i.lt("3317044064679887385961981"))c=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter(S=>Si=>it(i,r))})});var mie="numeric",die=["number","?bignumber","?fraction"],PB=N(mie,die,t=>{var{number:e,bignumber:r,fraction:i}=t,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},o={number:a=>e(a),BigNumber:r?a=>r(a):ef,bigint:a=>BigInt(a),Fraction:i?a=>i(a):Ty};return function(s){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",u=arguments.length>2?arguments[2]:void 0;if(u!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var c=ir(s);if(!(c in n))throw new TypeError("Cannot convert "+s+' of type "'+c+'"; valid input types are '+Object.keys(n).join(", "));if(!(l in o))throw new TypeError("Cannot convert "+s+' to type "'+l+'"; valid output types are '+Object.keys(o).join(", "));return l===c?s:o[l](s)}});var BB="divideScalar",hie=["typed","numeric"],OB=N(BB,hie,t=>{var{typed:e,numeric:r}=t;return e(BB,{"number, number":function(n,o){return n/o},"Complex, Complex":function(n,o){return n.div(o)},"BigNumber, BigNumber":function(n,o){return n.div(o)},"bigint, bigint":function(n,o){return n/o},"Fraction, Fraction":function(n,o){return n.div(o)},"Unit, number | Complex | Fraction | BigNumber | Unit":(i,n)=>i.divide(n),"number | Fraction | Complex | BigNumber, Unit":(i,n)=>n.divideInto(i)})});var RB="pow",gie=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],LB=N(RB,gie,t=>{var{typed:e,config:r,identity:i,multiply:n,matrix:o,inv:a,number:s,fraction:l,Complex:u}=t;return e(RB,{"number, number":c,"Complex, Complex":function(d,h){return d.pow(h)},"BigNumber, BigNumber":function(d,h){return h.isInteger()||d>=0||r.predictable?d.pow(h):new u(d.toNumber(),0).pow(h.toNumber(),0)},"bigint, bigint":(p,d)=>p**d,"Fraction, Fraction":function(d,h){var v=d.pow(h);if(v!=null)return v;if(r.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return c(d.valueOf(),h.valueOf())},"Array, number":f,"Array, BigNumber":function(d,h){return f(d,h.toNumber())},"Matrix, number":m,"Matrix, BigNumber":function(d,h){return m(d,h.toNumber())},"Unit, number | BigNumber":function(d,h){return d.pow(h)}});function c(p,d){if(r.predictable&&!Ge(d)&&p<0)try{var h=l(d),v=s(h);if((d===v||Math.abs((d-v)/d)<1e-14)&&h.d%2n===1n)return(h.n%2n===0n?1:-1)*Math.pow(-p,d)}catch{}return r.predictable&&(p<-1&&d===1/0||p>-1&&p<0&&d===-1/0)?NaN:Ge(d)||p>=0||r.predictable?iE(p,d):p*p<1&&d===1/0||p*p>1&&d===-1/0?0:new u(p,0).pow(d,0)}function f(p,d){if(!Ge(d))throw new TypeError("For A^b, b must be an integer (value is "+d+")");var h=vt(p);if(h.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+h.length+" dimensions)");if(h[0]!==h[1])throw new Error("For A^b, A must be square (size is "+h[0]+"x"+h[1]+")");if(d<0)try{return f(a(p),-d)}catch(S){throw S.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+")"):S}for(var v=i(h[0]).valueOf(),y=p;d>=1;)(d&1)===1&&(v=n(y,v)),d>>=1,y=n(y,y);return v}function m(p,d){return o(f(p.valueOf(),d))}});var rf="Number of decimals in function round must be an integer",UB="round",vie=["typed","config","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],zB=N(UB,vie,t=>{var{typed:e,config:r,matrix:i,equalScalar:n,zeros:o,BigNumber:a,DenseMatrix:s}=t,l=Er({typed:e,equalScalar:n}),u=mr({typed:e,DenseMatrix:s}),c=An({typed:e});function f(m){return Math.abs(Uc(m).exponent)}return e(UB,{number:function(p){var d=Yc(p,f(r.relTol)),h=jr(p,d,r.relTol,r.absTol)?d:p;return Yc(h)},"number, number":function(p,d){var h=f(r.relTol);if(d>=h)return Yc(p,d);var v=Yc(p,h),y=jr(p,v,r.relTol,r.absTol)?v:p;return Yc(y,d)},"number, BigNumber":function(p,d){if(!d.isInteger())throw new TypeError(rf);return new a(p).toDecimalPlaces(d.toNumber())},Complex:function(p){return p.round()},"Complex, number":function(p,d){if(d%1)throw new TypeError(rf);return p.round(d)},"Complex, BigNumber":function(p,d){if(!d.isInteger())throw new TypeError(rf);var h=d.toNumber();return p.round(h)},BigNumber:function(p){var d=new a(p).toDecimalPlaces(f(r.relTol)),h=xn(p,d,r.relTol,r.absTol)?d:p;return h.toDecimalPlaces(0)},"BigNumber, BigNumber":function(p,d){if(!d.isInteger())throw new TypeError(rf);var h=f(r.relTol);if(d>=h)return p.toDecimalPlaces(d.toNumber());var v=p.toDecimalPlaces(h),y=xn(p,v,r.relTol,r.absTol)?v:p;return y.toDecimalPlaces(d.toNumber())},bigint:m=>m,"bigint, number":(m,p)=>m,"bigint, BigNumber":(m,p)=>m,Fraction:function(p){return p.round()},"Fraction, number":function(p,d){if(d%1)throw new TypeError(rf);return p.round(d)},"Fraction, BigNumber":function(p,d){if(!d.isInteger())throw new TypeError(rf);return p.round(d.toNumber())},"Unit, number, Unit":e.referToSelf(m=>function(p,d,h){var v=p.toNumeric(h);return h.multiply(m(v,d))}),"Unit, BigNumber, Unit":e.referToSelf(m=>(p,d,h)=>m(p,d.toNumber(),h)),"Array | Matrix, number | BigNumber, Unit":e.referToSelf(m=>(p,d,h)=>it(p,v=>m(v,d,h),!0)),"Array | Matrix | Unit, Unit":e.referToSelf(m=>(p,d)=>m(p,0,d)),"Array | Matrix":e.referToSelf(m=>p=>it(p,m,!0)),"SparseMatrix, number | BigNumber":e.referToSelf(m=>(p,d)=>l(p,d,m,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(m=>(p,d)=>c(p,d,m,!1)),"Array, number | BigNumber":e.referToSelf(m=>(p,d)=>c(i(p),d,m,!1).valueOf()),"number | Complex | BigNumber | Fraction, SparseMatrix":e.referToSelf(m=>(p,d)=>n(p,0)?o(d.size(),d.storage()):u(d,p,m,!0)),"number | Complex | BigNumber | Fraction, DenseMatrix":e.referToSelf(m=>(p,d)=>n(p,0)?o(d.size(),d.storage()):c(d,p,m,!0)),"number | Complex | BigNumber | Fraction, Array":e.referToSelf(m=>(p,d)=>c(i(d),p,m,!0).valueOf())})});var VB="log",yie=["config","typed","typeOf","divideScalar","Complex"],bie=Math.log(16),qB=N(VB,yie,t=>{var{typed:e,typeOf:r,config:i,divideScalar:n,Complex:o}=t;function a(l){return l.log()}function s(l){return a(new o(l,0))}return e(VB,{number:function(u){return u>=0||i.predictable?eE(u):s(u)},bigint:Kc(bie,eE,i,s),Complex:a,BigNumber:function(u){return!u.isNegative()||i.predictable?u.ln():s(u.toNumber())},"any, any":e.referToSelf(l=>(u,c)=>{if(r(u)==="Fraction"&&r(c)==="Fraction"){var f=u.log(c);if(f!==null)return f}return n(l(u),l(c))})})});var jB="log1p",xie=["typed","config","divideScalar","log","Complex"],ZB=N(jB,xie,t=>{var{typed:e,config:r,divideScalar:i,log:n,Complex:o}=t;return e(jB,{number:function(l){return l>=-1||r.predictable?Uv(l):a(new o(l,0))},Complex:a,BigNumber:function(l){var u=l.plus(1);return!u.isNegative()||r.predictable?u.ln():a(new o(l.toNumber(),0))},"Array | Matrix":e.referToSelf(s=>l=>it(l,s)),"any, any":e.referToSelf(s=>(l,u)=>i(s(l),n(u)))});function a(s){var l=s.re+1;return new o(Math.log(Math.sqrt(l*l+s.im*s.im)),Math.atan2(s.im,l))}});var GB="nthRoots",_ie=["config","typed","divideScalar","Complex"],WB=N(GB,_ie,t=>{var{typed:e,config:r,divideScalar:i,Complex:n}=t,o=[function(l){return new n(l,0)},function(l){return new n(0,l)},function(l){return new n(-l,0)},function(l){return new n(0,-l)}];function a(s,l){if(l<0)throw new Error("Root must be greater than zero");if(l===0)throw new Error("Root must be non-zero");if(l%1!==0)throw new Error("Root must be an integer");if(s===0||s.abs()===0)return[new n(0,0)];var u=typeof s=="number",c;(u||s.re===0||s.im===0)&&(u?c=2*+(s<0):s.im===0?c=2*+(s.re<0):c=2*+(s.im<0)+1);for(var f=s.arg(),m=s.abs(),p=[],d=Math.pow(m,1/l),h=0;h{var{typed:e,equalScalar:r,matrix:i,pow:n,DenseMatrix:o,concat:a,SparseMatrix:s}=t,l=Vr({typed:e}),u=Ln({typed:e,SparseMatrix:s}),c=Er({typed:e,equalScalar:r}),f=mr({typed:e,DenseMatrix:o}),m=Bt({typed:e,matrix:i,concat:a}),p={};for(var d in n.signatures)Object.prototype.hasOwnProperty.call(n.signatures,d)&&!d.includes("Matrix")&&!d.includes("Array")&&(p[d]=n.signatures[d]);var h=e(p);return e(HB,m({elop:h,SS:u,DS:l,Ss:c,sS:f}))});var JB="dotDivide",Sie=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat","SparseMatrix"],XB=N(JB,Sie,t=>{var{typed:e,matrix:r,equalScalar:i,divideScalar:n,DenseMatrix:o,concat:a,SparseMatrix:s}=t,l=Tn({typed:e,equalScalar:i}),u=Vr({typed:e}),c=Ln({typed:e,SparseMatrix:s}),f=Er({typed:e,equalScalar:i}),m=mr({typed:e,DenseMatrix:o}),p=Bt({typed:e,matrix:r,concat:a});return e(JB,p({elop:n,SS:c,DS:u,SD:l,Ss:f,sS:m}))});function rs(t){var{DenseMatrix:e}=t;return function(i,n,o){var a=i.size();if(a.length!==2)throw new RangeError("Matrix must be two dimensional (size: "+Ct(a)+")");var s=a[0],l=a[1];if(s!==l)throw new RangeError("Matrix must be square (size: "+Ct(a)+")");var u=[];if(Je(n)){var c=n.size(),f=n._data;if(c.length===1){if(c[0]!==s)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var m=0;m{var{typed:e,matrix:r,divideScalar:i,multiplyScalar:n,subtractScalar:o,equalScalar:a,DenseMatrix:s}=t,l=rs({DenseMatrix:s});return e(KB,{"SparseMatrix, Array | Matrix":function(m,p){return c(m,p)},"DenseMatrix, Array | Matrix":function(m,p){return u(m,p)},"Array, Array | Matrix":function(m,p){var d=r(m),h=u(d,p);return h.valueOf()}});function u(f,m){m=l(f,m,!0);for(var p=m._data,d=f._size[0],h=f._size[1],v=[],y=f._data,S=0;S_&&(E.push(v[C]),T.push($))}if(a(x,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var O=i(w,x),R=0,L=T.length;R{var{typed:e,matrix:r,divideScalar:i,multiplyScalar:n,subtractScalar:o,equalScalar:a,DenseMatrix:s}=t,l=rs({DenseMatrix:s});return e(eO,{"SparseMatrix, Array | Matrix":function(m,p){return c(m,p)},"DenseMatrix, Array | Matrix":function(m,p){return u(m,p)},"Array, Array | Matrix":function(m,p){var d=r(m),h=u(d,p);return h.valueOf()}});function u(f,m){m=l(f,m,!0);for(var p=m._data,d=f._size[0],h=f._size[1],v=[],y=f._data,S=h-1;S>=0;S--){var b=p[S][0]||0,_=void 0;if(a(b,0))_=0;else{var w=y[S][S];if(a(w,0))throw new Error("Linear system cannot be solved since matrix is singular");_=i(b,w);for(var x=S-1;x>=0;x--)p[x]=[o(p[x][0]||0,n(_,y[x][S]))]}v[S]=[_]}return new s({data:v,size:[d,1]})}function c(f,m){m=l(f,m,!0);for(var p=m._data,d=f._size[0],h=f._size[1],v=f._values,y=f._index,S=f._ptr,b=[],_=h-1;_>=0;_--){var w=p[_][0]||0;if(a(w,0))b[_]=[0];else{for(var x=0,E=[],T=[],D=S[_],M=S[_+1],C=M-1;C>=D;C--){var $=y[C];$===_?x=v[C]:$<_&&(E.push(v[C]),T.push($))}if(a(x,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var O=i(w,x),R=0,L=T.length;R{var{typed:e,matrix:r,divideScalar:i,multiplyScalar:n,subtractScalar:o,equalScalar:a,DenseMatrix:s}=t,l=rs({DenseMatrix:s});return e(rO,{"SparseMatrix, Array | Matrix":function(m,p){return c(m,p)},"DenseMatrix, Array | Matrix":function(m,p){return u(m,p)},"Array, Array | Matrix":function(m,p){var d=r(m),h=u(d,p);return h.map(v=>v.valueOf())}});function u(f,m){for(var p=[l(f,m,!0)._data.map(T=>T[0])],d=f._data,h=f._size[0],v=f._size[1],y=0;ynew s({data:T.map(D=>[D]),size:[h,1]}))}function c(f,m){for(var p=[l(f,m,!0)._data.map(ie=>ie[0])],d=f._size[0],h=f._size[1],v=f._values,y=f._index,S=f._ptr,b=0;bb&&(E.push(v[$]),T.push(O))}if(a(C,0))if(a(x[b],0)){if(w===0){var V=[...x];V[b]=1;for(var J=0,W=T.length;Jnew s({data:ie.map(B=>[B]),size:[d,1]}))}});var iO="usolveAll",Tie=["typed","matrix","divideScalar","multiplyScalar","subtractScalar","equalScalar","DenseMatrix"],oO=N(iO,Tie,t=>{var{typed:e,matrix:r,divideScalar:i,multiplyScalar:n,subtractScalar:o,equalScalar:a,DenseMatrix:s}=t,l=rs({DenseMatrix:s});return e(iO,{"SparseMatrix, Array | Matrix":function(m,p){return c(m,p)},"DenseMatrix, Array | Matrix":function(m,p){return u(m,p)},"Array, Array | Matrix":function(m,p){var d=r(m),h=u(d,p);return h.map(v=>v.valueOf())}});function u(f,m){for(var p=[l(f,m,!0)._data.map(T=>T[0])],d=f._data,h=f._size[0],v=f._size[1],y=v-1;y>=0;y--)for(var S=p.length,b=0;b=0;E--)x[E]=o(x[E],d[E][y]);p.push(x)}}else{if(b===0)return[];p.splice(b,1),b-=1,S-=1}else{_[y]=i(_[y],d[y][y]);for(var w=y-1;w>=0;w--)_[w]=o(_[w],n(_[y],d[w][y]))}}return p.map(T=>new s({data:T.map(D=>[D]),size:[h,1]}))}function c(f,m){for(var p=[l(f,m,!0)._data.map(ie=>ie[0])],d=f._size[0],h=f._size[1],v=f._values,y=f._index,S=f._ptr,b=h-1;b>=0;b--)for(var _=p.length,w=0;w<_;w++){for(var x=p[w],E=[],T=[],D=S[b],M=S[b+1],C=0,$=M-1;$>=D;$--){var O=y[$];O===b?C=v[$]:Onew s({data:ie.map(B=>[B]),size:[d,1]}))}});var Nie="matAlgo08xS0Sid",Mie=["typed","equalScalar"],nf=N(Nie,Mie,t=>{var{typed:e,equalScalar:r}=t;return function(n,o,a){var s=n._values,l=n._index,u=n._ptr,c=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType(),m=o._values,p=o._index,d=o._ptr,h=o._size,v=o._datatype||o._data===void 0?o._datatype:o.getDataType();if(c.length!==h.length)throw new $t(c.length,h.length);if(c[0]!==h[0]||c[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+h+")");if(!s||!m)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var y=c[0],S=c[1],b,_=r,w=0,x=a;typeof f=="string"&&f===v&&f!=="mixed"&&(b=f,_=e.find(r,[b,b]),w=e.convert(0,b),x=e.find(a,[b,b]));for(var E=[],T=[],D=[],M=[],C=[],$,O,R,L,k=0;k{var{typed:e,matrix:r}=t;return{"Array, number":e.referTo("DenseMatrix, number",i=>(n,o)=>i(r(n),o).valueOf()),"Array, BigNumber":e.referTo("DenseMatrix, BigNumber",i=>(n,o)=>i(r(n),o).valueOf()),"number, Array":e.referTo("number, DenseMatrix",i=>(n,o)=>i(n,r(o)).valueOf()),"BigNumber, Array":e.referTo("BigNumber, DenseMatrix",i=>(n,o)=>i(n,r(o)).valueOf())}});var aO="leftShift",Cie=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],sO=N(aO,Cie,t=>{var{typed:e,matrix:r,equalScalar:i,zeros:n,DenseMatrix:o,concat:a}=t,s=Ii({typed:e}),l=Tn({typed:e,equalScalar:i}),u=nf({typed:e,equalScalar:i}),c=mo({typed:e,DenseMatrix:o}),f=Er({typed:e,equalScalar:i}),m=An({typed:e}),p=Bt({typed:e,matrix:r,concat:a}),d=of({typed:e,matrix:r});return e(aO,{"number, number":lE,"BigNumber, BigNumber":XP,"bigint, bigint":(h,v)=>h<(v,y)=>i(y,0)?v.clone():f(v,y,h,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(h=>(v,y)=>i(y,0)?v.clone():m(v,y,h,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(h=>(v,y)=>i(v,0)?n(y.size(),y.storage()):c(y,v,h,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(h=>(v,y)=>i(v,0)?n(y.size(),y.storage()):m(y,v,h,!0))},d,p({SS:u,DS:s,SD:l}))});var uO="rightArithShift",$ie=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],lO=N(uO,$ie,t=>{var{typed:e,matrix:r,equalScalar:i,zeros:n,DenseMatrix:o,concat:a}=t,s=Ii({typed:e}),l=Tn({typed:e,equalScalar:i}),u=nf({typed:e,equalScalar:i}),c=mo({typed:e,DenseMatrix:o}),f=Er({typed:e,equalScalar:i}),m=An({typed:e}),p=Bt({typed:e,matrix:r,concat:a}),d=of({typed:e,matrix:r});return e(uO,{"number, number":cE,"BigNumber, BigNumber":KP,"bigint, bigint":(h,v)=>h>>v,"SparseMatrix, number | BigNumber":e.referToSelf(h=>(v,y)=>i(y,0)?v.clone():f(v,y,h,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(h=>(v,y)=>i(y,0)?v.clone():m(v,y,h,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(h=>(v,y)=>i(v,0)?n(y.size(),y.storage()):c(y,v,h,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(h=>(v,y)=>i(v,0)?n(y.size(),y.storage()):m(y,v,h,!0))},d,p({SS:u,DS:s,SD:l}))});var cO="rightLogShift",Iie=["typed","matrix","equalScalar","zeros","DenseMatrix","concat"],fO=N(cO,Iie,t=>{var{typed:e,matrix:r,equalScalar:i,zeros:n,DenseMatrix:o,concat:a}=t,s=Ii({typed:e}),l=Tn({typed:e,equalScalar:i}),u=nf({typed:e,equalScalar:i}),c=mo({typed:e,DenseMatrix:o}),f=Er({typed:e,equalScalar:i}),m=An({typed:e}),p=Bt({typed:e,matrix:r,concat:a}),d=of({typed:e,matrix:r});return e(cO,{"number, number":fE,"SparseMatrix, number | BigNumber":e.referToSelf(h=>(v,y)=>i(y,0)?v.clone():f(v,y,h,!1)),"DenseMatrix, number | BigNumber":e.referToSelf(h=>(v,y)=>i(y,0)?v.clone():m(v,y,h,!1)),"number | BigNumber, SparseMatrix":e.referToSelf(h=>(v,y)=>i(v,0)?n(y.size(),y.storage()):c(y,v,h,!0)),"number | BigNumber, DenseMatrix":e.referToSelf(h=>(v,y)=>i(v,0)?n(y.size(),y.storage()):m(y,v,h,!0))},d,p({SS:u,DS:s,SD:l}))});var pO="and",Fie=["typed","matrix","equalScalar","zeros","not","concat"],ky=N(pO,Fie,t=>{var{typed:e,matrix:r,equalScalar:i,zeros:n,not:o,concat:a}=t,s=Tn({typed:e,equalScalar:i}),l=Iu({typed:e,equalScalar:i}),u=Er({typed:e,equalScalar:i}),c=An({typed:e}),f=Bt({typed:e,matrix:r,concat:a});return e(pO,{"number, number":fy,"Complex, Complex":function(p,d){return(p.re!==0||p.im!==0)&&(d.re!==0||d.im!==0)},"BigNumber, BigNumber":function(p,d){return!p.isZero()&&!d.isZero()&&!p.isNaN()&&!d.isNaN()},"bigint, bigint":fy,"Unit, Unit":e.referToSelf(m=>(p,d)=>m(p.value||0,d.value||0)),"SparseMatrix, any":e.referToSelf(m=>(p,d)=>o(d)?n(p.size(),p.storage()):u(p,d,m,!1)),"DenseMatrix, any":e.referToSelf(m=>(p,d)=>o(d)?n(p.size(),p.storage()):c(p,d,m,!1)),"any, SparseMatrix":e.referToSelf(m=>(p,d)=>o(p)?n(p.size(),p.storage()):u(d,p,m,!0)),"any, DenseMatrix":e.referToSelf(m=>(p,d)=>o(p)?n(p.size(),p.storage()):c(d,p,m,!0)),"Array, any":e.referToSelf(m=>(p,d)=>m(r(p),d).valueOf()),"any, Array":e.referToSelf(m=>(p,d)=>m(p,r(d)).valueOf())},f({SS:l,DS:s}))});var Py="compare",kie=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],mO=N(Py,kie,t=>{var{typed:e,config:r,equalScalar:i,matrix:n,BigNumber:o,Fraction:a,DenseMatrix:s,concat:l}=t,u=Vr({typed:e}),c=$u({typed:e,equalScalar:i}),f=mr({typed:e,DenseMatrix:s}),m=Bt({typed:e,matrix:n,concat:l}),p=sa({typed:e});return e(Py,Pie({typed:e,config:r}),{"boolean, boolean":function(h,v){return h===v?0:h>v?1:-1},"BigNumber, BigNumber":function(h,v){return xn(h,v,r.relTol,r.absTol)?new o(0):new o(h.cmp(v))},"bigint, bigint":function(h,v){return h===v?0n:h>v?1n:-1n},"Fraction, Fraction":function(h,v){return new a(h.compare(v))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},p,m({SS:c,DS:u,Ss:f}))}),Pie=N(Py,["typed","config"],t=>{var{typed:e,config:r}=t;return e(Py,{"number, number":function(n,o){return jr(n,o,r.relTol,r.absTol)?0:n>o?1:-1}})});var El=Ar(hO(),1);var gO="compareNatural",Bie=["typed","compare"],vO=N(gO,Bie,t=>{var{typed:e,compare:r}=t,i=r.signatures["boolean,boolean"];return e(gO,{"any, any":n});function n(l,u){var c=ir(l),f=ir(u),m;if((c==="number"||c==="BigNumber"||c==="Fraction")&&(f==="number"||f==="BigNumber"||f==="Fraction"))return m=r(l,u),m.toString()!=="0"?m>0?1:-1:(0,El.default)(c,f);var p=["Array","DenseMatrix","SparseMatrix"];if(p.includes(c)||p.includes(f))return m=o(n,l,u),m!==0?m:(0,El.default)(c,f);if(c!==f)return(0,El.default)(c,f);if(c==="Complex")return Oie(l,u);if(c==="Unit")return l.equalBase(u)?n(l.value,u.value):a(n,l.formatUnits(),u.formatUnits());if(c==="boolean")return i(l,u);if(c==="string")return(0,El.default)(l,u);if(c==="Object")return s(n,l,u);if(c==="null"||c==="undefined")return 0;throw new TypeError('Unsupported type of value "'+c+'"')}function o(l,u,c){return Fo(u)&&Fo(c)?a(l,u.toJSON().values,c.toJSON().values):Fo(u)?o(l,u.toArray(),c):Fo(c)?o(l,u,c.toArray()):Zs(u)?o(l,u.toJSON().data,c):Zs(c)?o(l,u,c.toJSON().data):Array.isArray(u)?Array.isArray(c)?a(l,u,c):o(l,u,[c]):o(l,[u],c)}function a(l,u,c){for(var f=0,m=Math.min(u.length,c.length);fc.length?1:u.length