diff --git a/addon/index.js b/addon/index.js index f742dee..763da61 100644 --- a/addon/index.js +++ b/addon/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -(()=>{var e={977:function(e,t){var r;!function(n){"use strict";var i=function(e){return.5*(Math.exp(e)+Math.exp(-e))},a=function(e){return.5*(Math.exp(e)-Math.exp(-e))},o=function(){throw SyntaxError("Invalid Param")};function s(e,t){var r=Math.abs(e),n=Math.abs(t);return 0===e?Math.log(n):0===t?Math.log(r):r<3e3&&n<3e3?.5*Math.log(e*e+t*t):Math.log(e/Math.cos(Math.atan2(t,e)))}function u(e,t){if(!(this instanceof u))return new u(e,t);var r=function(e,t){var r={re:0,im:0};if(null==e)r.re=r.im=0;else if(void 0!==t)r.re=e,r.im=t;else switch(typeof e){case"object":if("im"in e&&"re"in e)r.re=e.re,r.im=e.im;else if("abs"in e&&"arg"in e){if(!Number.isFinite(e.abs)&&Number.isFinite(e.arg))return u.INFINITY;r.re=e.abs*Math.cos(e.arg),r.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!Number.isFinite(e.r)&&Number.isFinite(e.phi))return u.INFINITY;r.re=e.r*Math.cos(e.phi),r.im=e.r*Math.sin(e.phi)}else 2===e.length?(r.re=e[0],r.im=e[1]):o();break;case"string":r.im=r.re=0;var n=e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),i=1,a=0;null===n&&o();for(var s=0;s0&&o();break;case"number":r.im=0,r.re=e;break;default:o()}return isNaN(r.re)||isNaN(r.im),r}(e,t);this.re=r.re,this.im=r.im}u.prototype={re:0,im:0,sign:function(){var e=this.abs();return new u(this.re/e,this.im/e)},add:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:new u(this.re+r.re,this.im+r.im)},sub:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:new u(this.re-r.re,this.im-r.im)},mul:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isZero()||this.isZero()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:0===r.im&&0===this.im?new u(this.re*r.re,0):new u(this.re*r.re-this.im*r.im,this.re*r.im+this.im*r.re)},div:function(e,t){var r=new u(e,t);if(this.isZero()&&r.isZero()||this.isInfinite()&&r.isInfinite())return u.NAN;if(this.isInfinite()||r.isZero())return u.INFINITY;if(this.isZero()||r.isInfinite())return u.ZERO;e=this.re,t=this.im;var n,i,a=r.re,o=r.im;return 0===o?new u(e/a,t/a):Math.abs(a)0)return new u(Math.pow(e,r.re),0);if(0===e)switch((r.re%4+4)%4){case 0:return new u(Math.pow(t,r.re),0);case 1:return new u(0,Math.pow(t,r.re));case 2:return new u(-Math.pow(t,r.re),0);case 3:return new u(0,-Math.pow(t,r.re))}}if(0===e&&0===t&&r.re>0&&r.im>=0)return u.ZERO;var n=Math.atan2(t,e),i=s(e,t);return e=Math.exp(r.re*i-r.im*n),t=r.im*i+r.re*n,new u(e*Math.cos(t),e*Math.sin(t))},sqrt:function(){var e,t,r=this.re,n=this.im,i=this.abs();if(r>=0){if(0===n)return new u(Math.sqrt(r),0);e=.5*Math.sqrt(2*(i+r))}else e=Math.abs(n)/Math.sqrt(2*(i-r));return t=r<=0?.5*Math.sqrt(2*(i-r)):Math.abs(n)/Math.sqrt(2*(i+r)),new u(e,n<0?-t:t)},exp:function(){var e=Math.exp(this.re);return this.im,new u(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){var e=this.re,t=this.im;return new u(Math.expm1(e)*Math.cos(t)+function(e){var t=Math.PI/4;if(e<-t||e>t)return Math.cos(e)-1;var r=e*e;return r*(r*(1/24+r*(-1/720+r*(1/40320+r*(-1/3628800+r*(1/4790014600+r*(-1/87178291200+r*(1/20922789888e3)))))))-.5)}(t),Math.exp(e)*Math.sin(t))},log:function(){var e=this.re,t=this.im;return new u(s(e,t),Math.atan2(t,e))},abs:function(){return e=this.re,t=this.im,r=Math.abs(e),n=Math.abs(t),r<3e3&&n<3e3?Math.sqrt(r*r+n*n):(r1&&0===t,n=1-e,i=1+e,a=n*n+t*t,o=0!==a?new u((i*n-t*t)/a,(t*n+i*t)/a):new u(-1!==e?e/0:0,0!==t?t/0:0),c=o.re;return o.re=s(o.re,o.im)/2,o.im=Math.atan2(o.im,c)/2,r&&(o.im=-o.im),o},acoth:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new u(0,Math.PI/2);var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).atanh():new u(0!==e?e/0:0,0!==t?-t/0:0).atanh()},acsch:function(){var e=this.re,t=this.im;if(0===t)return new u(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).asinh():new u(0!==e?e/0:0,0!==t?-t/0:0).asinh()},asech:function(){var e=this.re,t=this.im;if(this.isZero())return u.INFINITY;var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).acosh():new u(0!==e?e/0:0,0!==t?-t/0:0).acosh()},inverse:function(){if(this.isZero())return u.INFINITY;if(this.isInfinite())return u.ZERO;var e=this.re,t=this.im,r=e*e+t*t;return new u(e/r,-t/r)},conjugate:function(){return new u(this.re,-this.im)},neg:function(){return new u(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new u(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new u(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new u(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){var r=new u(e,t);return Math.abs(r.re-this.re)<=u.EPSILON&&Math.abs(r.im-this.im)<=u.EPSILON},clone:function(){return new u(this.re,this.im)},toString:function(){var e=this.re,t=this.im,r="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)0){for(a+=o,t=1;tr)throw Error(y+e)}function B(e,t,r,n){var i,a,o,s;for(a=e[0];a>=10;a/=10)--t;return--t<0?(t+=7,i=0):(i=Math.ceil((t+1)/7),t%=7),a=b(10,7-t),s=e[i]%a|0,null==n?t<3?(0==t?s=s/100|0:1==t&&(s=s/10|0),o=r<4&&99999==s||r>3&&49999==s||5e4==s||0==s):o=(r<4&&s+1==a||r>3&&s+1==a/2)&&(e[i+1]/a/100|0)==b(10,t-2)-1||(s==a/2||0==s)&&0==(e[i+1]/a/100|0):t<4?(0==t?s=s/1e3|0:1==t?s=s/100|0:2==t&&(s=s/10|0),o=(n||r<4)&&9999==s||!n&&r>3&&4999==s):o=((n||r<4)&&s+1==a||!n&&r>3&&s+1==a/2)&&(e[i+1]/a/1e3|0)==b(10,t-3)-1,o}function q(e,t,r){for(var n,i,a=[0],o=0,s=e.length;or-1&&(void 0===a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/r|0,a[n]%=r)}return a.reverse()}C.absoluteValue=C.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),D(e)},C.ceil=function(){return D(new this.constructor(this),this.e+1,2)},C.comparedTo=C.cmp=function(e){var t,r,n,i,a=this,o=a.d,s=(e=new a.constructor(e)).d,u=a.s,c=e.s;if(!o||!s)return u&&c?u!==c?u:o===s?0:!o^u<0?1:-1:NaN;if(!o[0]||!s[0])return o[0]?u:s[0]?-c:0;if(u!==c)return u;if(a.e!==e.e)return a.e>e.e^u<0?1:-1;for(t=0,r=(n=o.length)<(i=s.length)?n:i;ts[t]^u<0?1:-1;return n===i?0:n>i^u<0?1:-1},C.cosine=C.cos=function(){var e,t,r=this,n=r.constructor;return r.d?r.d[0]?(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(e,t){var r,n,i=t.d.length;i<32?n=(1/Y(4,r=Math.ceil(i/3))).toString():(r=16,n="2.3283064365386962890625e-10"),e.precision+=r,t=J(e,1,t.times(n),new e(1));for(var a=r;a--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=r,t}(n,X(n,r)),n.precision=e,n.rounding=t,D(2==s||3==s?r.neg():r,e,t,!0)):new n(1):new n(NaN)},C.cubeRoot=C.cbrt=function(){var e,t,r,n,i,a,o,s,u,c,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(h=!1,(a=l.s*b(l.s*l,1/3))&&Math.abs(a)!=1/0?n=new f(a.toString()):(r=_(l.d),(a=((e=l.e)-r.length+1)%3)&&(r+=1==a||-2==a?"0":"00"),a=b(r,1/3),e=x((e+1)/3)-(e%3==(e<0?-1:2)),(n=new f(r=a==1/0?"5e"+e:(r=a.toExponential()).slice(0,r.indexOf("e")+1)+e)).s=l.s),o=(e=f.precision)+3;;)if(c=(u=(s=n).times(s).times(s)).plus(l),n=z(c.plus(l).times(s),c.plus(u),o+2,1),_(s.d).slice(0,o)===(r=_(n.d)).slice(0,o)){if("9999"!=(r=r.slice(o-3,o+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(D(n,e+1,1),t=!n.times(n).times(n).eq(l));break}if(!i&&(D(s,e+1,0),s.times(s).times(s).eq(l))){n=s;break}o+=4,i=1}return h=!0,D(n,e,f.rounding,t)},C.decimalPlaces=C.dp=function(){var e,t=this.d,r=NaN;if(t){if(r=7*((e=t.length-1)-x(this.e/7)),e=t[e])for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r},C.dividedBy=C.div=function(e){return z(this,new this.constructor(e))},C.dividedToIntegerBy=C.divToInt=function(e){var t=this.constructor;return D(z(this,new t(e),0,1,1),t.precision,t.rounding)},C.equals=C.eq=function(e){return 0===this.cmp(e)},C.floor=function(){return D(new this.constructor(this),this.e+1,3)},C.greaterThan=C.gt=function(e){return this.cmp(e)>0},C.greaterThanOrEqualTo=C.gte=function(e){var t=this.cmp(e);return 1==t||0===t},C.hyperbolicCosine=C.cosh=function(){var e,t,r,n,i,a=this,o=a.constructor,s=new o(1);if(!a.isFinite())return new o(a.s?1/0:NaN);if(a.isZero())return s;r=o.precision,n=o.rounding,o.precision=r+Math.max(a.e,a.sd())+4,o.rounding=1,(i=a.d.length)<32?t=(1/Y(4,e=Math.ceil(i/3))).toString():(e=16,t="2.3283064365386962890625e-10"),a=J(o,1,a.times(t),new o(1),!0);for(var u,c=e,l=new o(8);c--;)u=a.times(a),a=s.minus(u.times(l.minus(u.times(l))));return D(a,o.precision=r,o.rounding=n,!0)},C.hyperbolicSine=C.sinh=function(){var e,t,r,n,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.precision,r=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,(n=i.d.length)<3)i=J(a,2,i,i,!0);else{e=(e=1.4*Math.sqrt(n))>16?16:0|e,i=J(a,2,i=i.times(1/Y(5,e)),i,!0);for(var o,s=new a(5),u=new a(16),c=new a(20);e--;)o=i.times(i),i=i.times(s.plus(o.times(u.times(o).plus(c))))}return a.precision=t,a.rounding=r,D(i,t,r,!0)},C.hyperbolicTangent=C.tanh=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+7,n.rounding=1,z(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)},C.inverseCosine=C.acos=function(){var e,t=this,r=t.constructor,n=t.abs().cmp(1),i=r.precision,a=r.rounding;return-1!==n?0===n?t.isNeg()?F(r,i,a):new r(0):new r(NaN):t.isZero()?F(r,i+4,a).times(.5):(r.precision=i+6,r.rounding=1,t=t.asin(),e=F(r,i+4,a).times(.5),r.precision=i,r.rounding=a,e.minus(t))},C.inverseHyperbolicCosine=C.acosh=function(){var e,t,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(e=n.precision,t=n.rounding,n.precision=e+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,h=!1,r=r.times(r).minus(1).sqrt().plus(r),h=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)},C.inverseHyperbolicSine=C.asinh=function(){var e,t,r=this,n=r.constructor;return!r.isFinite()||r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,h=!1,r=r.times(r).plus(1).sqrt().plus(r),h=!0,n.precision=e,n.rounding=t,r.ln())},C.inverseHyperbolicTangent=C.atanh=function(){var e,t,r,n,i=this,a=i.constructor;return i.isFinite()?i.e>=0?new a(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=a.precision,t=a.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?D(new a(i),e,t,!0):(a.precision=r=n-i.e,i=z(i.plus(1),new a(1).minus(i),r+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=t,i.times(.5))):new a(NaN)},C.inverseSine=C.asin=function(){var e,t,r,n,i=this,a=i.constructor;return i.isZero()?new a(i):(t=i.abs().cmp(1),r=a.precision,n=a.rounding,-1!==t?0===t?((e=F(a,r+4,n).times(.5)).s=i.s,e):new a(NaN):(a.precision=r+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=r,a.rounding=n,i.times(2)))},C.inverseTangent=C.atan=function(){var e,t,r,n,i,a,o,s,u,c=this,l=c.constructor,f=l.precision,p=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&f+4<=O)return(o=F(l,f+4,p).times(.25)).s=c.s,o}else{if(!c.s)return new l(NaN);if(f+4<=O)return(o=F(l,f+4,p).times(.5)).s=c.s,o}for(l.precision=s=f+10,l.rounding=1,e=r=Math.min(28,s/7+2|0);e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(h=!1,t=Math.ceil(s/7),n=1,u=c.times(c),o=new l(c),i=c;-1!==e;)if(i=i.times(u),a=o.minus(i.div(n+=2)),i=i.times(u),void 0!==(o=a.plus(i.div(n+=2))).d[t])for(e=t;o.d[e]===a.d[e]&&e--;);return r&&(o=o.times(2<this.d.length-2},C.isNaN=function(){return!this.s},C.isNegative=C.isNeg=function(){return this.s<0},C.isPositive=C.isPos=function(){return this.s>0},C.isZero=function(){return!!this.d&&0===this.d[0]},C.lessThan=C.lt=function(e){return this.cmp(e)<0},C.lessThanOrEqualTo=C.lte=function(e){return this.cmp(e)<1},C.logarithm=C.log=function(e){var t,r,n,i,a,o,s,u,c=this,l=c.constructor,f=l.precision,p=l.rounding;if(null==e)e=new l(10),t=!0;else{if(r=(e=new l(e)).d,e.s<0||!r||!r[0]||e.eq(1))return new l(NaN);t=e.eq(10)}if(r=c.d,c.s<0||!r||!r[0]||c.eq(1))return new l(r&&!r[0]?-1/0:1!=c.s?NaN:r?0:1/0);if(t)if(r.length>1)a=!0;else{for(i=r[0];i%10==0;)i/=10;a=1!==i}if(h=!1,o=G(c,s=f+5),n=t?R(l,s+10):G(e,s),B((u=z(o,n,s,1)).d,i=f,p))do{if(o=G(c,s+=10),n=t?R(l,s+10):G(e,s),u=z(o,n,s,1),!a){+_(u.d).slice(i+1,i+15)+1==1e14&&(u=D(u,f+1,0));break}}while(B(u.d,i+=10,p));return h=!0,D(u,f,p)},C.minus=C.sub=function(e){var t,r,n,i,a,o,s,u,c,l,f,p,m=this,d=m.constructor;if(e=new d(e),!m.d||!e.d)return m.s&&e.s?m.d?e.s=-e.s:e=new d(e.d||m.s!==e.s?m:NaN):e=new d(NaN),e;if(m.s!=e.s)return e.s=-e.s,m.plus(e);if(c=m.d,p=e.d,s=d.precision,u=d.rounding,!c[0]||!p[0]){if(p[0])e.s=-e.s;else{if(!c[0])return new d(3===u?-0:0);e=new d(m)}return h?D(e,s,u):e}if(r=x(e.e/7),l=x(m.e/7),c=c.slice(),a=l-r){for((f=a<0)?(t=c,a=-a,o=p.length):(t=p,r=l,o=c.length),a>(n=Math.max(Math.ceil(s/7),o)+2)&&(a=n,t.length=1),t.reverse(),n=a;n--;)t.push(0);t.reverse()}else{for((f=(n=c.length)<(o=p.length))&&(o=n),n=0;n0;--n)c[o++]=0;for(n=p.length;n>a;){if(c[--n](o=(a=Math.ceil(s/7))>o?a+1:o+1)&&(i=o,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for((o=c.length)-(i=l.length)<0&&(i=o,r=l,l=c,c=r),t=0;i;)t=(c[--i]=c[i]+l[i]+t)/E|0,c[i]%=E;for(t&&(c.unshift(t),++n),o=c.length;0==c[--o];)c.pop();return e.d=c,e.e=k(c,n),h?D(e,s,u):e},C.precision=C.sd=function(e){var t,r=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(y+e);return r.d?(t=U(r.d),e&&r.e+1>t&&(t=r.e+1)):t=NaN,t},C.round=function(){var e=this,t=e.constructor;return D(new t(e),e.e+1,t.rounding)},C.sine=C.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(e,t){var r,n=t.d.length;if(n<3)return J(e,2,t,t);r=(r=1.4*Math.sqrt(n))>16?16:0|r,t=J(e,2,t=t.times(1/Y(5,r)),t);for(var i,a=new e(5),o=new e(16),s=new e(20);r--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}(n,X(n,r)),n.precision=e,n.rounding=t,D(s>2?r.neg():r,e,t,!0)):new n(NaN)},C.squareRoot=C.sqrt=function(){var e,t,r,n,i,a,o=this,s=o.d,u=o.e,c=o.s,l=o.constructor;if(1!==c||!s||!s[0])return new l(!c||c<0&&(!s||s[0])?NaN:s?o:1/0);for(h=!1,0==(c=Math.sqrt(+o))||c==1/0?(((t=_(s)).length+u)%2==0&&(t+="0"),c=Math.sqrt(t),u=x((u+1)/2)-(u<0||u%2),n=new l(t=c==1/0?"5e"+u:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+u)):n=new l(c.toString()),r=(u=l.precision)+3;;)if(n=(a=n).plus(z(o,a,r+2,1)).times(.5),_(a.d).slice(0,r)===(t=_(n.d)).slice(0,r)){if("9999"!=(t=t.slice(r-3,r+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(D(n,u+1,1),e=!n.times(n).eq(o));break}if(!i&&(D(a,u+1,0),a.times(a).eq(o))){n=a;break}r+=4,i=1}return h=!0,D(n,u,l.rounding,e)},C.tangent=C.tan=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+10,n.rounding=1,(r=r.sin()).s=1,r=z(r,new n(1).minus(r.times(r)).sqrt(),e+10,0),n.precision=e,n.rounding=t,D(2==s||4==s?r.neg():r,e,t,!0)):new n(NaN)},C.times=C.mul=function(e){var t,r,n,i,a,o,s,u,c,l=this,f=l.constructor,p=l.d,m=(e=new f(e)).d;if(e.s*=l.s,!(p&&p[0]&&m&&m[0]))return new f(!e.s||p&&!p[0]&&!m||m&&!m[0]&&!p?NaN:p&&m?0*e.s:e.s/0);for(r=x(l.e/7)+x(e.e/7),(u=p.length)<(c=m.length)&&(a=p,p=m,m=a,o=u,u=c,c=o),a=[],n=o=u+c;n--;)a.push(0);for(n=c;--n>=0;){for(t=0,i=u+n;i>n;)s=a[i]+m[n]*p[i-n-1]+t,a[i--]=s%E|0,t=s/E|0;a[i]=(a[i]+t)%E|0}for(;!a[--o];)a.pop();return t?++r:a.shift(),e.d=a,e.e=k(a,r),h?D(e,f.precision,f.rounding):e},C.toBinary=function(e,t){return Q(this,2,e,t)},C.toDecimalPlaces=C.toDP=function(e,t){var r=this,n=r.constructor;return r=new n(r),void 0===e?r:(T(e,0,c),void 0===t?t=n.rounding:T(t,0,8),D(r,e+r.e+1,t))},C.toExponential=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=I(n,!0):(T(e,0,c),void 0===t?t=i.rounding:T(t,0,8),r=I(n=D(new i(n),e+1,t),!0,e+1)),n.isNeg()&&!n.isZero()?"-"+r:r},C.toFixed=function(e,t){var r,n,i=this,a=i.constructor;return void 0===e?r=I(i):(T(e,0,c),void 0===t?t=a.rounding:T(t,0,8),r=I(n=D(new a(i),e+i.e+1,t),!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r},C.toFraction=function(e){var t,r,n,i,a,o,s,u,c,l,f,p,m=this,d=m.d,g=m.constructor;if(!d)return new g(m);if(c=r=new g(1),n=u=new g(0),o=(a=(t=new g(n)).e=U(d)-m.e-1)%7,t.d[0]=b(10,o<0?7+o:o),null==e)e=a>0?t:c;else{if(!(s=new g(e)).isInt()||s.lt(c))throw Error(y+s);e=s.gt(t)?a>0?t:c:s}for(h=!1,s=new g(_(d)),l=g.precision,g.precision=a=7*d.length*2;f=z(s,t,0,1,1),1!=(i=r.plus(f.times(n))).cmp(e);)r=n,n=i,i=c,c=u.plus(f.times(i)),u=i,i=t,t=s.minus(f.times(i)),s=i;return i=z(e.minus(r),n,0,1,1),u=u.plus(i.times(c)),r=r.plus(i.times(n)),u.s=c.s=m.s,p=z(c,n,a,1).minus(m).abs().cmp(z(u,r,a,1).minus(m).abs())<1?[c,n]:[u,r],g.precision=l,h=!0,p},C.toHexadecimal=C.toHex=function(e,t){return Q(this,16,e,t)},C.toNearest=function(e,t){var r=this,n=r.constructor;if(r=new n(r),null==e){if(!r.d)return r;e=new n(1),t=n.rounding}else{if(e=new n(e),void 0===t?t=n.rounding:T(t,0,8),!r.d)return e.s?r:e;if(!e.d)return e.s&&(e.s=r.s),e}return e.d[0]?(h=!1,r=z(r,e,0,t,1).times(e),h=!0,D(r)):(e.s=r.s,r=e),r},C.toNumber=function(){return+this},C.toOctal=function(e,t){return Q(this,8,e,t)},C.toPower=C.pow=function(e){var t,r,n,i,a,o,s=this,u=s.constructor,c=+(e=new u(e));if(!(s.d&&e.d&&s.d[0]&&e.d[0]))return new u(b(+s,c));if((s=new u(s)).eq(1))return s;if(n=u.precision,a=u.rounding,e.eq(1))return D(s,n,a);if((t=x(e.e/7))>=e.d.length-1&&(r=c<0?-c:c)<=9007199254740991)return i=j(u,s,r,n),e.s<0?new u(1).div(i):D(i,n,a);if((o=s.s)<0){if(tu.maxE+1||t0?o/0:0):(h=!1,u.rounding=s.s=1,r=Math.min(12,(t+"").length),(i=$(e.times(G(s,n+r)),n)).d&&B((i=D(i,n+5,1)).d,n,a)&&(t=n+10,+_((i=D($(e.times(G(s,t+r)),t),t+5,1)).d).slice(n+1,n+15)+1==1e14&&(i=D(i,n+1,0))),i.s=o,h=!0,u.rounding=a,D(i,n,a))},C.toPrecision=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=I(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(T(e,1,c),void 0===t?t=i.rounding:T(t,0,8),r=I(n=D(new i(n),e,t),e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+r:r},C.toSignificantDigits=C.toSD=function(e,t){var r=this.constructor;return void 0===e?(e=r.precision,t=r.rounding):(T(e,1,c),void 0===t?t=r.rounding:T(t,0,8)),D(new r(this),e,t)},C.toString=function(){var e=this,t=e.constructor,r=I(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r},C.truncated=C.trunc=function(){return D(new this.constructor(this),this.e+1,1)},C.valueOf=C.toJSON=function(){var e=this,t=e.constructor,r=I(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};var z=function(){function e(e,t,r){var n,i=0,a=e.length;for(e=e.slice();a--;)n=e[a]*t+i,e[a]=n%r|0,i=n/r|0;return i&&e.unshift(i),e}function t(e,t,r,n){var i,a;if(r!=n)a=r>n?1:-1;else for(i=a=0;it[i]?1:-1;break}return a}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]1;)e.shift()}return function(n,i,a,s,u,c){var l,f,p,m,h,d,y,g,v,b,w,N,M,S,A,O,C,_,T,B,q=n.constructor,z=n.s==i.s?1:-1,I=n.d,k=i.d;if(!(I&&I[0]&&k&&k[0]))return new q(n.s&&i.s&&(I?!k||I[0]!=k[0]:k)?I&&0==I[0]||!k?0*z:z/0:NaN);for(c?(h=1,f=n.e-i.e):(c=E,h=7,f=x(n.e/h)-x(i.e/h)),T=k.length,C=I.length,b=(v=new q(z)).d=[],p=0;k[p]==(I[p]||0);p++);if(k[p]>(I[p]||0)&&f--,null==a?(S=a=q.precision,s=q.rounding):S=u?a+(n.e-i.e)+1:a,S<0)b.push(1),d=!0;else{if(S=S/h+2|0,p=0,1==T){for(m=0,k=k[0],S++;(p1&&(k=e(k,m,c),I=e(I,m,c),T=k.length,C=I.length),O=T,N=(w=I.slice(0,T)).length;N=c/2&&++_;do{m=0,(l=t(k,w,T,N))<0?(M=w[0],T!=N&&(M=M*c+(w[1]||0)),(m=M/_|0)>1?(m>=c&&(m=c-1),1==(l=t(y=e(k,m,c),w,g=y.length,N=w.length))&&(m--,r(y,T=10;m/=10)p++;v.e=p+f*h-1,D(v,u?a+v.e+1:a,s,d)}return v}}();function D(e,t,r,n){var i,a,o,s,u,c,l,f,p,m=e.constructor;e:if(null!=t){if(!(f=e.d))return e;for(i=1,s=f[0];s>=10;s/=10)i++;if((a=t-i)<0)a+=7,o=t,u=(l=f[p=0])/b(10,i-o-1)%10|0;else if((p=Math.ceil((a+1)/7))>=(s=f.length)){if(!n)break e;for(;s++<=p;)f.push(0);l=u=0,i=1,o=(a%=7)-7+1}else{for(l=s=f[p],i=1;s>=10;s/=10)i++;u=(o=(a%=7)-7+i)<0?0:l/b(10,i-o-1)%10|0}if(n=n||t<0||void 0!==f[p+1]||(o<0?l:l%b(10,i-o-1)),c=r<4?(u||n)&&(0==r||r==(e.s<0?3:2)):u>5||5==u&&(4==r||n||6==r&&(a>0?o>0?l/b(10,i-o):0:f[p-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,c?(t-=e.e+1,f[0]=b(10,(7-t%7)%7),e.e=-t||0):f[0]=e.e=0,e;if(0==a?(f.length=p,s=1,p--):(f.length=p+1,s=b(10,7-a),f[p]=o>0?(l/b(10,i-o)%b(10,o)|0)*s:0),c)for(;;){if(0==p){for(a=1,o=f[0];o>=10;o/=10)a++;for(o=f[0]+=s,s=1;o>=10;o/=10)s++;a!=s&&(e.e++,f[0]==E&&(f[0]=1));break}if(f[p]+=s,f[p]!=E)break;f[p--]=0,s=1}for(a=f.length;0===f[--a];)f.pop()}return h&&(e.e>m.maxE?(e.d=null,e.e=NaN):e.e0?a=a.charAt(0)+"."+a.slice(1)+P(n):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(e.e<0?"e":"e+")+e.e):i<0?(a="0."+P(-i-1)+a,r&&(n=r-o)>0&&(a+=P(n))):i>=o?(a+=P(i+1-o),r&&(n=r-i-1)>0&&(a=a+"."+P(n))):((n=i+1)0&&(i+1===o&&(a+="."),a+=P(n))),a}function k(e,t){var r=e[0];for(t*=7;r>=10;r/=10)t++;return t}function R(e,t,r){if(t>A)throw h=!0,r&&(e.precision=r),Error(g);return D(new e(f),t,1,!0)}function F(e,t,r){if(t>O)throw Error(g);return D(new e(p),t,r,!0)}function U(e){var t=e.length-1,r=7*t+1;if(t=e[t]){for(;t%10==0;t/=10)r--;for(t=e[0];t>=10;t/=10)r++}return r}function P(e){for(var t="";e--;)t+="0";return t}function j(e,t,r,n){var i,a=new e(1),o=Math.ceil(n/7+4);for(h=!1;;){if(r%2&&K((a=a.times(t)).d,o)&&(i=!0),0===(r=x(r/2))){r=a.d.length-1,i&&0===a.d[r]&&++a.d[r];break}K((t=t.times(t)).d,o)}return h=!0,a}function L(e){return 1&e.d[e.d.length-1]}function H(e,t,r){for(var n,i=new e(t[0]),a=0;++a17)return new p(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(h=!1,u=d):u=t,s=new p(.03125);e.e>-2;)e=e.times(s),f+=5;for(u+=n=Math.log(b(2,f))/Math.LN10*2+5|0,r=a=o=new p(1),p.precision=u;;){if(a=D(a.times(e),u,1),r=r.times(++l),_((s=o.plus(z(a,r,u,1))).d).slice(0,u)===_(o.d).slice(0,u)){for(i=f;i--;)o=D(o.times(o),u,1);if(null!=t)return p.precision=d,o;if(!(c<3&&B(o.d,u-n,m,c)))return D(o,p.precision=d,m,h=!0);p.precision=u+=10,r=a=s=new p(1),l=0,c++}o=s}}function G(e,t){var r,n,i,a,o,s,u,c,l,f,p,m=1,d=e,y=d.d,g=d.constructor,v=g.rounding,x=g.precision;if(d.s<0||!y||!y[0]||!d.e&&1==y[0]&&1==y.length)return new g(y&&!y[0]?-1/0:1!=d.s?NaN:y?0:d);if(null==t?(h=!1,l=x):l=t,g.precision=l+=10,n=(r=_(y)).charAt(0),!(Math.abs(a=d.e)<15e14))return c=R(g,l+2,x).times(a+""),d=G(new g(n+"."+r.slice(1)),l-10).plus(c),g.precision=x,null==t?D(d,x,v,h=!0):d;for(;n<7&&1!=n||1==n&&r.charAt(1)>3;)n=(r=_((d=d.times(e)).d)).charAt(0),m++;for(a=d.e,n>1?(d=new g("0."+r),a++):d=new g(n+"."+r.slice(1)),f=d,u=o=d=z(d.minus(1),d.plus(1),l,1),p=D(d.times(d),l,1),i=3;;){if(o=D(o.times(p),l,1),_((c=u.plus(z(o,new g(i),l,1))).d).slice(0,l)===_(u.d).slice(0,l)){if(u=u.times(2),0!==a&&(u=u.plus(R(g,l+2,x).times(a+""))),u=z(u,new g(m),l,1),null!=t)return g.precision=x,u;if(!B(u.d,l-10,v,s))return D(u,g.precision=x,v,h=!0);g.precision=l+=10,c=o=d=z(f.minus(1),f.plus(1),l,1),p=D(d.times(d),l,1),i=s=1}u=c,i+=2}}function V(e){return String(e.s*e.s/0)}function Z(e,t){var r,n,i;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;48===t.charCodeAt(n);n++);for(i=t.length;48===t.charCodeAt(i-1);--i);if(t=t.slice(n,i)){if(i-=n,e.e=r=r-n-1,e.d=[],n=(r+1)%7,r<0&&(n+=7),ne.constructor.maxE?(e.d=null,e.e=NaN):e.e0?(c=+t.slice(o+1),t=t.substring(2,o)):t=t.slice(2),s=(o=t.indexOf("."))>=0,n=e.constructor,s&&(o=(u=(t=t.replace(".","")).length)-o,i=j(n,new n(r),o,2*o)),o=f=(l=q(t,r,E)).length-1;0===l[o];--o)l.pop();return o<0?new n(0*e.s):(e.e=k(l,f),e.d=l,h=!1,s&&(e=z(e,i,4*u)),c&&(e=e.times(Math.abs(c)<54?b(2,c):a.pow(2,c))),h=!0,e)}function J(e,t,r,n,i){var a,o,s,u,c=e.precision,l=Math.ceil(c/7);for(h=!1,u=r.times(r),s=new e(n);;){if(o=z(s.times(u),new e(t++*t++),c,1),s=i?n.plus(o):n.minus(o),n=z(o.times(u),new e(t++*t++),c,1),void 0!==(o=s.plus(n)).d[l]){for(a=l;o.d[a]===s.d[a]&&a--;);if(-1==a)break}a=s,s=n,n=o,o=a}return h=!0,o.d.length=l+1,o}function Y(e,t){for(var r=e;--t;)r*=e;return r}function X(e,t){var r,n=t.s<0,i=F(e,e.precision,1),a=i.times(.5);if((t=t.abs()).lte(a))return s=n?4:1,t;if((r=t.divToInt(i)).isZero())s=n?3:2;else{if((t=t.minus(r.times(i))).lte(a))return s=L(r)?n?2:3:n?4:1,t;s=L(r)?n?1:4:n?3:2}return t.minus(i).abs()}function Q(e,t,r,n){var i,a,s,u,f,p,m,h,d,y=e.constructor,g=void 0!==r;if(g?(T(r,1,c),void 0===n?n=y.rounding:T(n,0,8)):(r=y.precision,n=y.rounding),e.isFinite()){for(g?(i=2,16==t?r=4*r-3:8==t&&(r=3*r-2)):i=t,(s=(m=I(e)).indexOf("."))>=0&&(m=m.replace(".",""),(d=new y(1)).e=m.length-s,d.d=q(I(d),10,i),d.e=d.d.length),a=f=(h=q(m,10,i)).length;0==h[--f];)h.pop();if(h[0]){if(s<0?a--:((e=new y(e)).d=h,e.e=a,h=(e=z(e,d,r,n,0,i)).d,a=e.e,p=o),s=h[r],u=i/2,p=p||void 0!==h[r+1],p=n<4?(void 0!==s||p)&&(0===n||n===(e.s<0?3:2)):s>u||s===u&&(4===n||p||6===n&&1&h[r-1]||n===(e.s<0?8:7)),h.length=r,p)for(;++h[--r]>i-1;)h[r]=0,r||(++a,h.unshift(1));for(f=h.length;!h[f-1];--f);for(s=0,m="";s1)if(16==t||8==t){for(s=16==t?4:3,--f;f%s;f++)m+="0";for(f=(h=q(m,i,t)).length;!h[f-1];--f);for(s=1,m="1.";sf)for(a-=f;a--;)m+="0";else at)return e.length=t,!0}function ee(e){return new this(e).abs()}function te(e){return new this(e).acos()}function re(e){return new this(e).acosh()}function ne(e,t){return new this(e).plus(t)}function ie(e){return new this(e).asin()}function ae(e){return new this(e).asinh()}function oe(e){return new this(e).atan()}function se(e){return new this(e).atanh()}function ue(e,t){e=new this(e),t=new this(t);var r,n=this.precision,i=this.rounding,a=n+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(r=t.s<0?F(this,n,i):new this(0)).s=e.s:!e.d||t.isZero()?(r=F(this,a,1).times(.5)).s=e.s:t.s<0?(this.precision=a,this.rounding=1,r=this.atan(z(e,t,a,1)),t=F(this,a,1),this.precision=n,this.rounding=i,r=e.s<0?r.minus(t):r.plus(t)):r=this.atan(z(e,t,a,1)):(r=F(this,a,1).times(t.s>0?.25:.75)).s=e.s:r=new this(NaN),r}function ce(e){return new this(e).cbrt()}function le(e){return D(e=new this(e),e.e+1,2)}function fe(e){if(!e||"object"!=typeof e)throw Error(d+"Object expected");var t,r,n,i=!0===e.defaults,a=["precision",1,c,"rounding",0,8,"toExpNeg",-u,0,"toExpPos",0,u,"maxE",0,u,"minE",-u,0,"modulo",0,9];for(t=0;t=a[t+1]&&n<=a[t+2]))throw Error(y+r+": "+n);this[r]=n}if(r="crypto",i&&(this[r]=m[r]),void 0!==(n=e[r])){if(!0!==n&&!1!==n&&0!==n&&1!==n)throw Error(y+r+": "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(v);this[r]=!0}else this[r]=!1}return this}function pe(e){return new this(e).cos()}function me(e){return new this(e).cosh()}function he(e,t){return new this(e).div(t)}function de(e){return new this(e).exp()}function ye(e){return D(e=new this(e),e.e+1,3)}function ge(){var e,t,r=new this(0);for(h=!1,e=0;e=429e7?t[a]=crypto.getRandomValues(new Uint32Array(1))[0]:s[a++]=i%1e7;else{if(!crypto.randomBytes)throw Error(v);for(t=crypto.randomBytes(n*=4);a=214e7?crypto.randomBytes(4).copy(t,a):(s.push(i%1e7),a+=4);a=n/4}else for(;a=10;i/=10)n++;n<7&&(r-=7-n)}return o.e=r,o.d=s,o}function _e(e){return D(e=new this(e),e.e+1,this.rounding)}function Te(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function Be(e){return new this(e).sin()}function qe(e){return new this(e).sinh()}function ze(e){return new this(e).sqrt()}function De(e,t){return new this(e).sub(t)}function Ie(e){return new this(e).tan()}function ke(e){return new this(e).tanh()}function Re(e){return D(e=new this(e),e.e+1,1)}(a=function e(t){var r,n,i;function a(e){var t,r,n,i=this;if(!(i instanceof a))return new a(e);if(i.constructor=a,e instanceof a)return i.s=e.s,void(h?!e.d||e.e>a.maxE?(i.e=NaN,i.d=null):e.e=10;r/=10)t++;return void(h?t>a.maxE?(i.e=NaN,i.d=null):t{"use strict";var t=Object.assign||function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{},o=a.preserveFormatting,s=void 0!==o&&o,u=a.escapeMapFn,c=void 0===u?i:u,l=String(e),f="",p=c(t({},r),s?t({},n):{}),m=Object.keys(p),h=function(){var e=!1;m.forEach((function(t,r){e||l.length>=t.length&&l.slice(0,t.length)===t&&(f+=p[m[r]],l=l.slice(t.length,l.length),e=!0)})),e||(f+=l.slice(0,1),l=l.slice(1,l.length))};l;)h();return f}},628:function(e,t){var r;!function(n){"use strict";var i={s:1,n:0,d:1};function a(e){function t(){var t=Error.apply(this,arguments);t.name=this.name=e,this.stack=t.stack,this.message=t.message}function r(){}return r.prototype=Error.prototype,t.prototype=new r,t}var o=m.DivisionByZero=a("DivisionByZero"),s=m.InvalidParameter=a("InvalidParameter");function u(e,t){return isNaN(e=parseInt(e,10))&&c(),e*t}function c(){throw new s}function l(e){for(var t={},r=e,n=2,i=4;i<=r;){for(;r%n==0;)r/=n,t[n]=(t[n]||0)+1;i+=1+2*n++}return r!==e?r>1&&(t[r]=(t[r]||0)+1):t[e]=(t[e]||0)+1,t}var f=function(e,t){var r,n=0,a=1,s=1,l=0,f=0,p=0,m=1,h=1,d=0,y=1,g=1,v=1,x=1e7;if(null==e);else if(void 0!==t)s=(n=e)*(a=t);else switch(typeof e){case"object":"d"in e&&"n"in e?(n=e.n,a=e.d,"s"in e&&(n*=e.s)):0 in e?(n=e[0],1 in e&&(a=e[1])):c(),s=n*a;break;case"number":if(e<0&&(s=e,e=-e),e%1==0)n=e;else if(e>0){for(e>=1&&(e/=h=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)));y<=x&&v<=x;){if(e===(r=(d+g)/(y+v))){y+v<=x?(n=d+g,a=y+v):v>y?(n=g,a=v):(n=d,a=y);break}e>r?(d+=g,y+=v):(g+=d,v+=y),y>x?(n=g,a=v):(n=d,a=y)}n*=h}else(isNaN(e)||isNaN(t))&&(a=n=NaN);break;case"string":if(null===(y=e.match(/\d+|./g))&&c(),"-"===y[d]?(s=-1,d++):"+"===y[d]&&d++,y.length===d+1?f=u(y[d++],s):"."===y[d+1]||"."===y[d]?("."!==y[d]&&(l=u(y[d++],s)),(1+ ++d===y.length||"("===y[d+1]&&")"===y[d+3]||"'"===y[d+1]&&"'"===y[d+3])&&(f=u(y[d],s),m=Math.pow(10,y[d].length),d++),("("===y[d]&&")"===y[d+2]||"'"===y[d]&&"'"===y[d+2])&&(p=u(y[d+1],s),h=Math.pow(10,y[d+1].length)-1,d+=3)):"/"===y[d+1]||":"===y[d+1]?(f=u(y[d],s),m=u(y[d+2],1),d+=3):"/"===y[d+3]&&" "===y[d+1]&&(l=u(y[d],s),f=u(y[d+2],s),m=u(y[d+4],1),d+=5),y.length<=d){s=n=p+(a=m*h)*l+h*f;break}default:c()}if(0===a)throw new o;i.s=s<0?-1:1,i.n=Math.abs(n),i.d=Math.abs(a)};function p(e,t){if(!e)return t;if(!t)return e;for(;;){if(!(e%=t))return t;if(!(t%=e))return e}}function m(e,t){if(!(this instanceof m))return new m(e,t);f(e,t),e=m.REDUCE?p(i.d,i.n):1,this.s=i.s,this.n=i.n/e,this.d=i.d/e}m.REDUCE=1,m.prototype={s:1,n:0,d:1,abs:function(){return new m(this.n,this.d)},neg:function(){return new m(-this.s*this.n,this.d)},add:function(e,t){return f(e,t),new m(this.s*this.n*i.d+i.s*this.d*i.n,this.d*i.d)},sub:function(e,t){return f(e,t),new m(this.s*this.n*i.d-i.s*this.d*i.n,this.d*i.d)},mul:function(e,t){return f(e,t),new m(this.s*i.s*this.n*i.n,this.d*i.d)},div:function(e,t){return f(e,t),new m(this.s*i.s*this.n*i.d,this.d*i.n)},clone:function(){return new m(this)},mod:function(e,t){return isNaN(this.n)||isNaN(this.d)?new m(NaN):void 0===e?new m(this.s*this.n%this.d,1):(f(e,t),0===i.n&&0===this.d&&m(0,0),new m(this.s*(i.d*this.n)%(i.n*this.d),i.d*this.d))},gcd:function(e,t){return f(e,t),new m(p(i.n,this.n)*p(i.d,this.d),i.d*this.d)},lcm:function(e,t){return f(e,t),0===i.n&&0===this.n?new m:new m(i.n*this.n,p(i.n,this.n)*p(i.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.round(e*this.s*this.n/this.d),e)},inverse:function(){return new m(this.s*this.d,this.n)},pow:function(e,t){if(f(e,t),1===i.d)return i.s<0?new m(Math.pow(this.s*this.d,i.n),Math.pow(this.n,i.n)):new m(Math.pow(this.s*this.n,i.n),Math.pow(this.d,i.n));if(this.s<0)return null;var r=l(this.n),n=l(this.d),a=1,o=1;for(var s in r)if("1"!==s){if("0"===s){a=0;break}if(r[s]*=i.n,r[s]%i.d!=0)return null;r[s]/=i.d,a*=Math.pow(s,r[s])}for(var s in n)if("1"!==s){if(n[s]*=i.n,n[s]%i.d!=0)return null;n[s]/=i.d,o*=Math.pow(s,n[s])}return i.s<0?new m(o,a):new m(a,o)},equals:function(e,t){return f(e,t),this.s*this.n*i.d==i.s*i.n*this.d},compare:function(e,t){f(e,t);var r=this.s*this.n*i.d-i.s*i.n*this.d;return(00&&(r+=t,r+=" ",n%=i),r+=n,r+="/",r+=i),r},toLatex:function(e){var t,r="",n=this.n,i=this.d;return this.s<0&&(r+="-"),1===i?r+=n:(e&&(t=Math.floor(n/i))>0&&(r+=t,n%=i),r+="\\frac{",r+=n,r+="}{",r+=i,r+="}"),r},toContinued:function(){var e,t=this.n,r=this.d,n=[];if(isNaN(t)||isNaN(r))return n;do{n.push(Math.floor(t/r)),e=t%r,t=r,r=e}while(1!==t);return n},toString:function(e){var t,r=this.n,n=this.d;if(isNaN(r)||isNaN(n))return"NaN";m.REDUCE||(r/=t=p(r,n),n/=t),e=e||15;var i=function(e,t){for(;t%2==0;t/=2);for(;t%5==0;t/=5);if(1===t)return 0;for(var r=10%t,n=1;1!==r;n++)if(r=10*r%t,n>2e3)return 0;return n}(0,n),a=function(e,t,r){for(var n=1,i=function(e,t,r){for(var n=1;t>0;e=e*e%r,t>>=1)1&t&&(n=n*e%r);return n}(10,r,t),a=0;a<300;a++){if(n===i)return a;n=10*n%t,i=10*i%t}return 0}(0,n,i),o=-1===this.s?"-":"";if(o+=r/n|0,r%=n,(r*=10)&&(o+="."),i){for(var s=a;s--;)o+=r/n|0,r%=n,r*=10;for(o+="(",s=i;s--;)o+=r/n|0,r%=n,r*=10;o+=")"}else for(s=e;r&&s--;)o+=r/n|0,r%=n,r*=10;return o}},void 0===(r=function(){return m}.apply(t,[]))||(e.exports=r)}()},228:e=>{e.exports=function e(t,r){"use strict";var n,i,a=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,o=/(^[ ]*|[ ]*$)/g,s=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,u=/^0x[0-9a-f]+$/i,c=/^0/,l=function(t){return e.insensitive&&(""+t).toLowerCase()||""+t},f=l(t).replace(o,"")||"",p=l(r).replace(o,"")||"",m=f.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),h=p.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),d=parseInt(f.match(u),16)||1!==m.length&&f.match(s)&&Date.parse(f),y=parseInt(p.match(u),16)||d&&p.match(s)&&Date.parse(p)||null;if(y){if(dy)return 1}for(var g=0,v=Math.max(m.length,h.length);gi)return 1}return 0}},377:(e,t,r)=>{var n=r(832),i=r(652),a=r(801),o=r(30),s=r(618),u=r(49),c=r(971);c.alea=n,c.xor128=i,c.xorwow=a,c.xorshift7=o,c.xor4096=s,c.tychei=u,e.exports=c},832:function(e,t,r){var n;!function(e,i,a){function o(e){var t,r=this,n=(t=4022871197,function(e){e=String(e);for(var r=0;r>>0,t=(n*=t)>>>0,t+=4294967296*(n-=t)}return 2.3283064365386963e-10*(t>>>0)});r.next=function(){var e=2091639*r.s0+2.3283064365386963e-10*r.c;return r.s0=r.s1,r.s1=r.s2,r.s2=e-(r.c=0|e)},r.c=1,r.s0=n(" "),r.s1=n(" "),r.s2=n(" "),r.s0-=n(e),r.s0<0&&(r.s0+=1),r.s1-=n(e),r.s1<0&&(r.s1+=1),r.s2-=n(e),r.s2<0&&(r.s2+=1),n=null}function s(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function u(e,t){var r=new o(e),n=t&&t.state,i=r.next;return i.int32=function(){return 4294967296*r.next()|0},i.double=function(){return i()+11102230246251565e-32*(2097152*i()|0)},i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.alea=u}(0,e=r.nmd(e),r.amdD)},49:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.next=function(){var e=t.b,r=t.c,n=t.d,i=t.a;return e=e<<25^e>>>7^r,r=r-n|0,n=n<<24^n>>>8^i,i=i-e|0,t.b=e=e<<20^e>>>12^r,t.c=r=r-n|0,t.d=n<<16^r>>>16^i,t.a=i-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):r+=e;for(var n=0;n>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.tychei=u}(0,e=r.nmd(e),r.amdD)},652:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:r+=e;for(var n=0;n>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xor128=u}(0,e=r.nmd(e),r.amdD)},618:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this;t.next=function(){var e,r,n=t.w,i=t.X,a=t.i;return t.w=n=n+1640531527|0,r=i[a+34&127],e=i[a=a+1&127],r^=r<<13,e^=e<<17,r^=r>>>15,e^=e>>>12,r=i[a]=r^e,t.i=a,r+(n^n>>>16)|0},function(e,t){var r,n,i,a,o,s=[],u=128;for(t===(0|t)?(n=t,t=null):(t+="\0",n=0,u=Math.max(u,t.length)),i=0,a=-32;a>>15,n^=n<<4,n^=n>>>13,a>=0&&(o=o+1640531527|0,i=0==(r=s[127&a]^=n+o)?i+1:0);for(i>=128&&(s[127&(t&&t.length||0)]=-1),i=127,a=512;a>0;--a)n=s[i+34&127],r=s[i=i+1&127],n^=n<<13,r^=r<<17,n^=n>>>15,r^=r>>>12,s[i]=n^r;e.w=o,e.X=s,e.i=i}(t,e)}function s(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function u(e,t){null==e&&(e=+new Date);var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&(n.X&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xor4096=u}(0,e=r.nmd(e),r.amdD)},30:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this;t.next=function(){var e,r,n=t.x,i=t.i;return e=n[i],r=(e^=e>>>7)^e<<24,r^=(e=n[i+1&7])^e>>>10,r^=(e=n[i+3&7])^e>>>3,r^=(e=n[i+4&7])^e<<7,e=n[i+7&7],r^=(e^=e<<13)^e<<9,n[i]=r,t.i=i+1&7,r},function(e,t){var r,n=[];if(t===(0|t))n[0]=t;else for(t=""+t,r=0;r0;--r)e.next()}(t,e)}function s(e,t){return t.x=e.x.slice(),t.i=e.i,t}function u(e,t){null==e&&(e=+new Date);var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&(n.x&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xorshift7=u}(0,e=r.nmd(e),r.amdD)},801:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:r+=e;for(var n=0;n>>4),t.next()}function s(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function u(e,t){var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xorwow=u}(0,e=r.nmd(e),r.amdD)},971:function(e,t,r){var n;!function(i,a,o){var s,u=256,c=o.pow(u,6),l=o.pow(2,52),f=2*l,p=255;function m(e,t,r){var n=[],p=g(y((t=1==t?{entropy:!0}:t||{}).entropy?[e,v(a)]:null==e?function(){try{var e;return s&&(e=s.randomBytes)?e=e(u):(e=new Uint8Array(u),(i.crypto||i.msCrypto).getRandomValues(e)),v(e)}catch(e){var t=i.navigator,r=t&&t.plugins;return[+new Date,i,r,i.screen,v(a)]}}():e,3),n),m=new h(n),x=function(){for(var e=m.g(6),t=c,r=0;e=f;)e/=2,t/=2,r>>>=1;return(e+r)/t};return x.int32=function(){return 0|m.g(4)},x.quick=function(){return m.g(4)/4294967296},x.double=x,g(v(m.S),a),(t.pass||r||function(e,t,r,n){return n&&(n.S&&d(n,m),e.state=function(){return d(m,{})}),r?(o.random=e,t):e})(x,p,"global"in t?t.global:this==o,t.state)}function h(e){var t,r=e.length,n=this,i=0,a=n.i=n.j=0,o=n.S=[];for(r||(e=[r++]);i3?e.slice(3):"any":e).split("|").map(q).filter(z).filter(B),i=function(e,t){var r={};return e.forEach((function(e){-1!==t.indexOf(e.from)||-1===t.indexOf(e.to)||r[e.from]||(r[e.from]=e)})),Object.keys(r).map((function(e){return r[e]}))}(t,n),a=n.map((function(e){var t=c(e);return{name:e,typeIndex:l(t),test:t.test,conversion:null,conversionIndex:-1}})),o=i.map((function(e){var r=c(e.from);return{name:e.from,typeIndex:l(r),test:r.test,conversion:e,conversionIndex:t.indexOf(e)}}));return{types:a.concat(o),restParam:r}}function h(e){var t=k(e);return!!t&&t.restParam}function d(e){return e.types.some((function(e){return null!=e.conversion}))}function y(t){if(t&&0!==t.types.length){if(1===t.types.length)return c(t.types[0].name).test;if(2===t.types.length){var r=c(t.types[0].name).test,n=c(t.types[1].name).test;return function(e){return r(e)||n(e)}}var i=t.types.map((function(e){return c(e.name).test}));return function(e){for(var t=0;t=a+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(r=y(e[0]),function(e){return r(e[0])&&1===e.length}):2===e.length?(r=y(e[0]),n=y(e[1]),function(e){return r(e[0])&&n(e[1])&&2===e.length}):(t=e.map(y),function(e){for(var r=0;r0){var c=f(t[a]);return(n=new TypeError("Unexpected type of argument in function "+o+" (expected: "+i.join(" or ")+", actual: "+c+", index: "+a+")")).data={category:"wrongType",fn:o,index:a,actual:c,expected:i},n}}else s=u}var l=s.map((function(e){return h(e.params)?1/0:e.params.length}));if(t.lengthp?((n=new TypeError("Too many arguments in function "+o+" (expected: "+p+", actual: "+t.length+")")).data={category:"tooManyArgs",fn:o,index:t.length,expectedLength:p},n):((n=new TypeError('Arguments of type "'+t.join(", ")+'" do not match any of the defined signatures of function '+o+".")).data={category:"mismatch",actual:t.map(f)},n)}function S(e){for(var t=999,r=0;r=i:s?i>=a:i===a}(t,e)}));if(t)throw new TypeError('Conflicting signatures "'+p(t.params)+'" and "'+p(e.params)+'".');i.push(e)}));var a=P(i,(function(e){return(e?_(e.params,!1):[]).map((function(t){return{params:t,fn:e.fn}}))})).filter(D);a.sort(O);var o=a[0]&&a[0].params.length<=2&&!h(a[0].params),s=a[1]&&a[1].params.length<=2&&!h(a[1].params),c=a[2]&&a[2].params.length<=2&&!h(a[2].params),l=a[3]&&a[3].params.length<=2&&!h(a[3].params),f=a[4]&&a[4].params.length<=2&&!h(a[4].params),v=a[5]&&a[5].params.length<=2&&!h(a[5].params),b=o&&s&&c&&l&&f&&v,w=a.map((function(e){return g(e.params)})),N=o?y(a[0].params[0]):t,S=s?y(a[1].params[0]):t,E=c?y(a[2].params[0]):t,A=l?y(a[3].params[0]):t,T=f?y(a[4].params[0]):t,B=v?y(a[5].params[0]):t,z=o?y(a[0].params[1]):t,k=s?y(a[1].params[1]):t,j=c?y(a[2].params[1]):t,L=l?y(a[3].params[1]):t,H=f?y(a[4].params[1]):t,$=v?y(a[5].params[1]):t,G=a.map((function(e){return function(e,t){var r=t;if(e.some(d)){var n=h(e),i=e.map(C);r=function(){for(var e=[],r=n?arguments.length-1:arguments.length,a=0;a{}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var a=t[n]={id:n,loaded:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.loaded=!0,a.exports}r.amdD=function(){throw new Error("define cannot be used indirect")},r.amdO={},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";function e(){return(e=Object.assign||function(e){for(var t=1;t!function(e){return e&&"?"===e[0]}(e))).every((e=>void 0!==r[e]))){var n=t.filter((e=>void 0===r[e]));throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(n.map((e=>'"'.concat(e,'"'))).join(", "),"."))}}(e,t,n),r(i)}return i.isFactory=!0,i.fn=e,i.dependencies=t.slice().sort(),n&&(i.meta=n),i}function J(e){return e&&"?"===e[0]?e.slice(1):e}function Y(e,t){if(ee(e)&&Q(e,t))return e[t];if("function"==typeof e[t]&&K(e,t))throw new Error('Cannot access method "'+t+'" as a property');throw new Error('No access to property "'+t+'"')}function X(e,t,r){if(ee(e)&&Q(e,t))return e[t]=r,r;throw new Error('No access to property "'+t+'"')}function Q(e,t){return!(!e||"object"!=typeof e||!Z(te,t)&&(t in Object.prototype||t in Function.prototype))}function K(e,t){return!(null==e||"function"!=typeof e[t]||Z(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e)||!Z(re,t)&&(t in Object.prototype||t in Function.prototype))}function ee(e){return"object"==typeof e&&e&&e.constructor===Object}var te={length:!0,name:!0},re={toString:!0,valueOf:!0,toLocaleString:!0};class ne{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return Y(this.wrappedObject,e)}set(e,t){return X(this.wrappedObject,e,t),this}has(e){return e in this.wrappedObject}}function ie(){return new Map}function ae(e){if(!e)return ie();if(oe(e))return e;if(M(e))return new ne(e);throw new Error("createMap can create maps from objects or Maps")}function oe(e){return!!e&&(e instanceof Map||e instanceof ne||"function"==typeof e.set&&"function"==typeof e.get&&"function"==typeof e.keys&&"function"==typeof e.has)}function se(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{var{mathWithTransform:t}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator")}return r.prototype.evaluate=function(e){return this.compile().evaluate(e)},r.prototype.type="Node",r.prototype.isNode=!0,r.prototype.comment="",r.prototype.compile=function(){var e=this._compile(t,{}),r={};return{evaluate:function(t){var n=ae(t);return function(e){for(var t of[...H])if(e.has(t))throw new Error('Scope contains an illegal symbol, "'+t+'" is a reserved keyword')}(n),e(n,r,null)}}},r.prototype._compile=function(e,t){throw new Error("Method _compile should be implemented by type "+this.type)},r.prototype.forEach=function(e){throw new Error("Cannot run forEach on a Node interface")},r.prototype.map=function(e){throw new Error("Cannot run map on a Node interface")},r.prototype._ifNode=function(e){if(!I(e))throw new TypeError("Callback function must return a Node");return e},r.prototype.traverse=function(e){e(this,null,null),function e(t,r){t.forEach((function(t,n,i){r(t,n,i),e(t,r)}))}(this,e)},r.prototype.transform=function(e){return function t(r,n,i){var a=e(r,n,i);return a!==r?a:r.map(t)}(this,null,null)},r.prototype.filter=function(e){var t=[];return this.traverse((function(r,n,i){e(r,n,i)&&t.push(r)})),t},r.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},r.prototype.cloneDeep=function(){return this.map((function(e){return e.cloneDeep()}))},r.prototype.equals=function(e){return!!e&&V(this,e)},r.prototype.toString=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toString(e)},r.prototype.toJSON=function(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)},r.prototype.toHTML=function(e){var t=this._getCustomString(e);return void 0!==t?t:this.toHTML(e)},r.prototype._toString=function(){throw new Error("_toString not implemented for "+this.type)},r.prototype.toTex=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toTex(e)},r.prototype._toTex=function(e){throw new Error("_toTex not implemented for "+this.type)},r.prototype._getCustomString=function(e){if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":return;case"function":return e.handler(this,e);default:throw new TypeError("Object or function expected as callback")}},r.prototype.getIdentifier=function(){return this.type},r.prototype.getContent=function(){return this},r}),{isClass:!0,isNode:!0});function ce(e){return"boolean"==typeof e||!!isFinite(e)&&e===Math.round(e)}var le=Math.sign||function(e){return e>0?1:e<0?-1:0},fe=Math.log2||function(e){return Math.log(e)/Math.LN2},pe=Math.log10||function(e){return Math.log(e)/Math.LN10},me=Math.log1p||function(e){return Math.log(e+1)},he=Math.cbrt||function(e){if(0===e)return e;var t,r=e<0;return r&&(e=-e),t=isFinite(e)?(e/((t=Math.exp(Math.log(e)/3))*t)+2*t)/3:e,r?-t:t},de=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function ye(e,t,r){var n={2:"0b",8:"0o",16:"0x"}[t],i="";if(r){if(r<1)throw new Error("size must be in greater than 0");if(!ce(r))throw new Error("size must be an integer");if(e>2**(r-1)-1||e<-(2**(r-1)))throw new Error("Value must be in range [-2^".concat(r-1,", 2^").concat(r-1,"-1]"));if(!ce(e))throw new Error("Value must be an integer");e<0&&(e+=2**r),i="i".concat(r)}var a="";return e<0&&(e=-e,a="-"),"".concat(a).concat(n).concat(e.toString(t)).concat(i)}function ge(e,t){if("function"==typeof t)return t(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var r,n,a="auto";if(t&&(t.notation&&(a=t.notation),i(t)?r=t:i(t.precision)&&(r=t.precision),t.wordSize&&"number"!=typeof(n=t.wordSize)))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return xe(e,r);case"exponential":return be(e,r);case"engineering":return function(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=we(ve(e),t),n=r.exponent,a=r.coefficients,o=n%3==0?n:n<0?n-3-n%3:n-n%3;if(i(t))for(;t>a.length||n-o+1>a.length;)a.push(0);else for(var s=Math.abs(n-o)-(a.length-1),u=0;u0;)l++,c--;var f=a.slice(l).join(""),p=i(t)&&f.length||f.match(/[1-9]/)?"."+f:"",m=a.slice(0,l).join("")+p+"e"+(n>=0?"+":"")+o.toString();return r.sign+m}(e,r);case"bin":return ye(e,2,n);case"oct":return ye(e,8,n);case"hex":return ye(e,16,n);case"auto":return function(e,t,r){if(isNaN(e)||!isFinite(e))return String(e);var n=r&&void 0!==r.lowerExp?r.lowerExp:-3,i=r&&void 0!==r.upperExp?r.upperExp:5,a=ve(e),o=t?we(a,t):a;if(o.exponent=i)return be(e,t);var s=o.coefficients,u=o.exponent;s.length0?u:0;return c<(s=Ne(-u).concat(s)).length-1&&s.splice(c+1,0,"."),o.sign+s.join("")}(e,r,t&&t).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t}));default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function ve(e){var t=String(e).toLowerCase().match(/^0*?(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+e);var r=t[1],n=t[2],i=parseFloat(t[4]||"0"),a=n.indexOf(".");i+=-1!==a?a-1:n.length-1;var o=n.replace(".","").replace(/^0*/,(function(e){return i-=e.length,""})).replace(/0*$/,"").split("").map((function(e){return parseInt(e)}));return 0===o.length&&(o.push(0),i++),{sign:r,coefficients:o,exponent:i}}function xe(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=ve(e),n="number"==typeof t?we(r,r.exponent+1+t):r,i=n.coefficients,a=n.exponent+1,o=a+(t||0);return i.length0?"."+i.join(""):"")+"e"+(a>=0?"+":"")+a}function we(e,t){for(var r={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},n=r.coefficients;t<=0;)n.unshift(0),r.exponent++,t++;if(n.length>t&&n.splice(t,n.length-t)[0]>=5){var i=t-1;for(n[i]++;10===n[i];)n.pop(),0===i&&(n.unshift(0),r.exponent++,i++),n[--i]++}return r}function Ne(e){for(var t=[],r=0;r=0?"+":"")+n.toString()}(e,r);case"bin":return Be(e,2,n);case"oct":return Be(e,8,n);case"hex":return Be(e,16,n);case"auto":var a=t&&void 0!==t.lowerExp?t.lowerExp:-3,o=t&&void 0!==t.upperExp?t.upperExp:5;if(e.isZero())return"0";var s=e.toSignificantDigits(r),u=s.e;return(u>=a&&u'"'+r+'": '+De(e[r],t))).join(", ")+"}":String(e)}function Ie(e){for(var t=String(e),r="",n=0;n/g,">")}function Re(e,t){if(Array.isArray(e)){for(var r="[",n=e.length,i=0;it?1:-1}function Ue(e,t,r){if(!(this instanceof Ue))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=t,this.relation=r,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=(new Error).stack}function Pe(e,t,r){if(!(this instanceof Pe))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=r),void 0!==this.min&&this.index=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}function je(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function Le(e,t,r){var n,i=e.length;if(i!==t[r])throw new Ue(i,t[r]);if(r")}function He(e,t){if(0===t.length){if(Array.isArray(e))throw new Ue(e.length,0)}else Le(e,t,0)}function $e(e,t){if(!i(e)||!ce(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&e>=t)throw new Pe(e,t)}function Ge(e,t,r){if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");return t.forEach((function(e){if(!i(e)||!ce(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+De(t)+")")})),Ve(e,t,0,void 0!==r?r:0),e}function Ve(e,t,r,n){var i,a,o=e.length,s=t[r],u=Math.min(o,s);if(e.length=s,r=0){if(t%r!=0)throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-r);n[i]=-t/r}return n}function Je(e){return e.reduce(((e,t)=>e*t),1)}function Ye(e,t){for(var r=t||je(e);Array.isArray(e)&&1===e.length;)e=e[0],r.shift();for(var n=r.length;1===r[n-1];)n--;return nt.test(e)))}function at(e,t){return Array.prototype.join.call(e,t)}function ot(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;var t=[],r=0;t[0]={value:e[0],identifier:0};for(var n=1;n{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=e||[],!Array.isArray(this.items)||!this.items.every(I))throw new TypeError("Array containing Nodes expected")}return r.prototype=new t,r.prototype.type="ArrayNode",r.prototype.isArrayNode=!0,r.prototype._compile=function(e,t){var r=tt(this.items,(function(r){return r._compile(e,t)}));if("Array"!==e.config.matrix){var n=e.matrix;return function(e,t,i){return n(tt(r,(function(r){return r(e,t,i)})))}}return function(e,t,n){return tt(r,(function(r){return r(e,t,n)}))}},r.prototype.forEach=function(e){for(var t=0;t['+this.items.map((function(t){return t.toHTML(e)})).join(',')+']'},r.prototype._toTex=function(e){var t="\\begin{bmatrix}";return this.items.forEach((function(r){r.items?t+=r.items.map((function(t){return t.toTex(e)})).join("&"):t+=r.toTex(e),t+="\\\\"})),t+="\\end{bmatrix}"},r}),{isClass:!0,isNode:!0}),lt=W("BlockNode",["ResultSet","Node"],(e=>{var{ResultSet:t,Node:r}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map((function(e){var t=e&&e.node,r=!e||void 0===e.visible||e.visible;if(!I(t))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof r)throw new TypeError('Property "visible" must be a boolean');return{node:t,visible:r}}))}return n.prototype=new r,n.prototype.type="BlockNode",n.prototype.isBlockNode=!0,n.prototype._compile=function(e,r){var n=tt(this.blocks,(function(t){return{evaluate:t.node._compile(e,r),visible:t.visible}}));return function(e,r,i){var a=[];return rt(n,(function(t){var n=t.evaluate(e,r,i);t.visible&&a.push(n)})),new t(a)}},n.prototype.forEach=function(e){for(var t=0;t;')})).join('
')},n.prototype._toTex=function(e){return this.blocks.map((function(t){return t.node.toTex(e)+(t.visible?"":";")})).join("\\;\\;\n")},n}),{isClass:!0,isNode:!0}),ft=r(928),pt={Alpha:"A",alpha:"\\alpha",Beta:"B",beta:"\\beta",Gamma:"\\Gamma",gamma:"\\gamma",Delta:"\\Delta",delta:"\\delta",Epsilon:"E",epsilon:"\\epsilon",varepsilon:"\\varepsilon",Zeta:"Z",zeta:"\\zeta",Eta:"H",eta:"\\eta",Theta:"\\Theta",theta:"\\theta",vartheta:"\\vartheta",Iota:"I",iota:"\\iota",Kappa:"K",kappa:"\\kappa",varkappa:"\\varkappa",Lambda:"\\Lambda",lambda:"\\lambda",Mu:"M",mu:"\\mu",Nu:"N",nu:"\\nu",Xi:"\\Xi",xi:"\\xi",Omicron:"O",omicron:"o",Pi:"\\Pi",pi:"\\pi",varpi:"\\varpi",Rho:"P",rho:"\\rho",varrho:"\\varrho",Sigma:"\\Sigma",sigma:"\\sigma",varsigma:"\\varsigma",Tau:"T",tau:"\\tau",Upsilon:"\\Upsilon",upsilon:"\\upsilon",Phi:"\\Phi",phi:"\\phi",varphi:"\\varphi",Chi:"X",chi:"\\chi",Psi:"\\Psi",psi:"\\psi",Omega:"\\Omega",omega:"\\omega",true:"\\mathrm{True}",false:"\\mathrm{False}",i:"i",inf:"\\infty",Inf:"\\infty",infinity:"\\infty",Infinity:"\\infty",oo:"\\infty",lim:"\\lim",undefined:"\\mathbf{?}"},mt={transpose:"^\\top",ctranspose:"^H",factorial:"!",pow:"^",dotPow:".^\\wedge",unaryPlus:"+",unaryMinus:"-",bitNot:"\\~",not:"\\neg",multiply:"\\cdot",divide:"\\frac",dotMultiply:".\\cdot",dotDivide:".:",mod:"\\mod",add:"+",subtract:"-",to:"\\rightarrow",leftShift:"<<",rightArithShift:">>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},ht={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(mt.add,"${args[1]}\\right)")},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:"\\left(${args[0]}".concat(mt.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(mt.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(mt.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(mt.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:"\\left(${args[0]}".concat(mt.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(mt.multiply,"${args[1]}\\right)")},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : $y^{args[1]} = {${args[0]}}\\}"},pow:{2:"\\left(${args[0]}\\right)".concat(mt.pow,"{${args[1]}}")},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:"\\left(${args[0]}".concat(mt.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(mt.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(mt.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(mt.bitAnd,"${args[1]}\\right)")},bitNot:{1:mt.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(mt.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(mt.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(mt.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(mt.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(mt.rightLogShift,"${args[1]}\\right)")},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:"\\left(${args[0]}".concat(mt.and,"${args[1]}\\right)")},not:{1:mt.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(mt.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(mt.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(mt.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},sqrtm:{1:"{${args[0]}}".concat(mt.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(mt.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(mt.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(mt.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(mt.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(mt.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(mt.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(mt.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(mt.unequal,"${args[1]}\\right)")},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:"\\left(${args[0]}".concat(mt.to,"${args[1]}\\right)")},numeric:function(e,t){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(pt.i,"\\cdot\\left(${args[1]}\\right)\\right)")},matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},dt={deg:"^\\circ"};function yt(e){return ft(e,{preserveFormatting:!0})}function gt(e,t){return(t=void 0!==t&&t)?Z(dt,e)?dt[e]:"\\mathrm{"+yt(e)+"}":Z(pt,e)?pt[e]:yt(e)}var vt=W("ConstantNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this.value=e}return r.prototype=new t,r.prototype.type="ConstantNode",r.prototype.isConstantNode=!0,r.prototype._compile=function(e,t){var r=this.value;return function(){return r}},r.prototype.forEach=function(e){},r.prototype.map=function(e){return this.clone()},r.prototype.clone=function(){return new r(this.value)},r.prototype._toString=function(e){return De(this.value,e)},r.prototype.toHTML=function(e){var t=this._toString(e);switch(L(this.value)){case"number":case"BigNumber":case"Fraction":return''+t+"";case"string":return''+t+"";case"boolean":return''+t+"";case"null":return''+t+"";case"undefined":return''+t+"";default:return''+t+""}},r.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},r.fromJSON=function(e){return new r(e.value)},r.prototype._toTex=function(e){var t=this._toString(e);switch(L(this.value)){case"string":return"\\mathtt{"+yt(t)+"}";case"number":case"BigNumber":if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var r=t.toLowerCase().indexOf("e");return-1!==r?t.substring(0,r)+"\\cdot10^{"+t.substring(r+1)+"}":t;case"Fraction":return this.value.toLatex();default:return t}},r}),{isClass:!0,isNode:!0}),xt=W("ObjectNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=e||{},e&&("object"!=typeof e||!Object.keys(e).every((function(t){return I(e[t])}))))throw new TypeError("Object containing Nodes expected")}return r.prototype=new t,r.prototype.type="ObjectNode",r.prototype.isObjectNode=!0,r.prototype._compile=function(e,t){var r={};for(var n in this.properties)if(Z(this.properties,n)){var i=Ie(n),a=JSON.parse(i);if(!Q(this.properties,a))throw new Error('No access to property "'+a+'"');r[a]=this.properties[n]._compile(e,t)}return function(e,t,n){var i={};for(var a in r)Z(r,a)&&(i[a]=r[a](e,t,n));return i}},r.prototype.forEach=function(e){for(var t in this.properties)Z(this.properties,t)&&e(this.properties[t],"properties["+Ie(t)+"]",this)},r.prototype.map=function(e){var t={};for(var n in this.properties)Z(this.properties,n)&&(t[n]=this._ifNode(e(this.properties[n],"properties["+Ie(n)+"]",this)));return new r(t)},r.prototype.clone=function(){var e={};for(var t in this.properties)Z(this.properties,t)&&(e[t]=this.properties[t]);return new r(e)},r.prototype._toString=function(e){var t=[];for(var r in this.properties)Z(this.properties,r)&&t.push(Ie(r)+": "+this.properties[r].toString(e));return"{"+t.join(", ")+"}"},r.prototype.toJSON=function(){return{mathjs:"ObjectNode",properties:this.properties}},r.fromJSON=function(e){return new r(e.properties)},r.prototype.toHTML=function(e){var t=[];for(var r in this.properties)Z(this.properties,r)&&t.push(''+ke(r)+':'+this.properties[r].toHTML(e));return'{'+t.join(',')+'}'},r.prototype._toTex=function(e){var t=[];for(var r in this.properties)Z(this.properties,r)&&t.push("\\mathbf{"+r+":} & "+this.properties[r].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(t.join("\n"),"\\end{array}\\right\\}")},r}),{isClass:!0,isNode:!0}),bt=W("ParenthesisNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError('Node expected for parameter "content"');this.content=e}return r.prototype=new t,r.prototype.type="ParenthesisNode",r.prototype.isParenthesisNode=!0,r.prototype._compile=function(e,t){return this.content._compile(e,t)},r.prototype.getContent=function(){return this.content.getContent()},r.prototype.forEach=function(e){e(this.content,"content",this)},r.prototype.map=function(e){return new r(e(this.content,"content",this))},r.prototype.clone=function(){return new r(this.content)},r.prototype._toString=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)},r.prototype.toJSON=function(){return{mathjs:"ParenthesisNode",content:this.content}},r.fromJSON=function(e){return new r(e.content)},r.prototype.toHTML=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?'('+this.content.toHTML(e)+')':this.content.toHTML(e)},r.prototype._toTex=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)},r}),{isClass:!0,isNode:!0}),wt=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{associativity:"left",associativeWith:[]}},{"OperatorNode:and":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{associativity:"left",associativeWith:[]},"OperatorNode:unequal":{associativity:"left",associativeWith:[]},"OperatorNode:smaller":{associativity:"left",associativeWith:[]},"OperatorNode:larger":{associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{associativity:"left",associativeWith:[]}},{"OperatorNode:to":{associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{associativity:"left",associativeWith:[]},"OperatorNode:mod":{associativity:"left",associativeWith:[]}},{"OperatorNode:unaryPlus":{associativity:"right"},"OperatorNode:unaryMinus":{associativity:"right"},"OperatorNode:bitNot":{associativity:"right"},"OperatorNode:not":{associativity:"right"}},{"OperatorNode:pow":{associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{associativity:"left"}},{"OperatorNode:transpose":{associativity:"left"}}];function Nt(e,t){var r=e;"keep"!==t&&(r=e.getContent());for(var n=r.getIdentifier(),i=0;i{var{Node:t}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(t))throw new TypeError("Parameter params must be an array");if(e.length!==t.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=t}return r.prototype=new t,r.prototype.type="RelationalNode",r.prototype.isRelationalNode=!0,r.prototype._compile=function(e,t){var r=this,n=this.params.map((r=>r._compile(e,t)));return function(t,i,a){for(var o,s=n[0](t,i,a),u=0;ue(t,"params["+r+"]",this)),this)},r.prototype.map=function(e){return new r(this.conditionals.slice(),this.params.map(((t,r)=>this._ifNode(e(t,"params["+r+"]",this))),this))},r.prototype.clone=function(){return new r(this.conditionals,this.params)},r.prototype._toString=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.params.map((function(n,i){var a=Nt(n,t);return"all"===t||null!==a&&a<=r?"("+n.toString(e)+")":n.toString(e)})),i={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},a=n[0],o=0;o('+n.toHTML(e)+')':n.toHTML(e)})),i={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},a=n[0],o=0;o'+ke(i[this.conditionals[o]])+""+n[o+1];return a},r.prototype._toTex=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.params.map((function(n,i){var a=Nt(n,t);return"all"===t||null!==a&&a<=r?"\\left("+n.toTex(e)+"\right)":n.toTex(e)})),i=n[0],a=0;a{var{on:t,math:r}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");j(e)?this.value=e.value:this.value=e}function i(e,t){var r,i,o,s,u;r=n.prototype,i=e,o=function(){var e=t();if("function"==typeof e)return a(e)},u=!0,Object.defineProperty(r,i,{get:function(){return u&&(s=o(),u=!1),s},set:function(e){s=e,u=!1},configurable:!0,enumerable:!0})}function a(e){return function(){for(var t=[this.value],r=0;re[t]))};for(var s in e)r(s)}var u,c};var o={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return n.createProxy(r),t&&t("import",(function(e,t,r){r||i(e,t)})),n}),{isClass:!0}),Ot=W("reviver",["classes"],(e=>{var{classes:t}=e;return function(e,r){var n=t[r&&r.mathjs];return n&&"function"==typeof n.fromJSON?n.fromJSON(r):r}})),Ct=W("ConditionalNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError("Parameter condition must be a Node");if(!I(t))throw new TypeError("Parameter trueExpr must be a Node");if(!I(n))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=t,this.falseExpr=n}return r.prototype=new t,r.prototype.type="ConditionalNode",r.prototype.isConditionalNode=!0,r.prototype._compile=function(e,t){var r=this.condition._compile(e,t),n=this.trueExpr._compile(e,t),i=this.falseExpr._compile(e,t);return function(e,t,s){return function(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return!!e;if(e){if(a(e))return!e.isZero();if(o(e))return!(!e.re&&!e.im);if(u(e))return!!e.value}if(null==e)return!1;throw new TypeError('Unsupported type of condition "'+L(e)+'"')}(r(e,t,s))?n(e,t,s):i(e,t,s)}},r.prototype.forEach=function(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)},r.prototype.map=function(e){return new r(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))},r.prototype.clone=function(){return new r(this.condition,this.trueExpr,this.falseExpr)},r.prototype._toString=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.condition.toString(e),i=Nt(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n="("+n+")");var a=this.trueExpr.toString(e),o=Nt(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a="("+a+")");var s=this.falseExpr.toString(e),u=Nt(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s="("+s+")"),n+" ? "+a+" : "+s},r.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},r.fromJSON=function(e){return new r(e.condition,e.trueExpr,e.falseExpr)},r.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.condition.toHTML(e),i=Nt(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n='('+n+')');var a=this.trueExpr.toHTML(e),o=Nt(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a='('+a+')');var s=this.falseExpr.toHTML(e),u=Nt(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s='('+s+')'),n+'?'+a+':'+s},r.prototype._toTex=function(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"},r}),{isClass:!0,isNode:!0}),_t=W("OperatorNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n,i){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('string expected for parameter "op"');if("string"!=typeof t)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(n)||!n.every(I))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=!0===i,this.op=e,this.fn=t,this.args=n||[]}function n(e,t,r,n,i){var a,o=Nt(e,t),s=Mt(e,t);if("all"===t||n.length>2&&"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier())return n.map((function(e){switch(e.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}}));switch(n.length){case 0:a=[];break;case 1:var u=Nt(n[0],t);if(i&&null!==u){var c,l;if("keep"===t?(c=n[0].getIdentifier(),l=e.getIdentifier()):(c=n[0].getContent().getIdentifier(),l=e.getContent().getIdentifier()),!1===wt[o][l].latexLeftParens){a=[!1];break}if(!1===wt[u][c].latexParens){a=[!1];break}}if(null===u){a=[!1];break}if(u<=o){a=[!0];break}a=[!1];break;case 2:var f,p,m=Nt(n[0],t),h=St(e,n[0],t);f=null!==m&&(m===o&&"right"===s&&!h||m=2&&"OperatorNode:multiply"===e.getIdentifier()&&e.implicit&&"auto"===t&&"hide"===r&&(a=n.map((function(e,t){var r="ParenthesisNode"===e.getIdentifier();return!(!a[t]&&!r)}))),a}return r.prototype=new t,r.prototype.type="OperatorNode",r.prototype.isOperatorNode=!0,r.prototype._compile=function(e,t){if("string"!=typeof this.fn||!K(e,this.fn))throw e[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var r=Y(e,this.fn),n=tt(this.args,(function(r){return r._compile(e,t)}));if(1===n.length){var i=n[0];return function(e,t,n){return r(i(e,t,n))}}if(2===n.length){var a=n[0],o=n[1];return function(e,t,n){return r(a(e,t,n),o(e,t,n))}}return function(e,t,i){return r.apply(null,tt(n,(function(r){return r(e,t,i)})))}},r.prototype.forEach=function(e){for(var t=0;t2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var f=i.map((function(t,r){return t=t.toString(e),a[r]&&(t="("+t+")"),t}));return this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?f.join(" "):f.join(" "+this.op+" ")}return this.fn+"("+this.args.join(", ")+")"},r.prototype.toJSON=function(){return{mathjs:"OperatorNode",op:this.op,fn:this.fn,args:this.args,implicit:this.implicit}},r.fromJSON=function(e){return new r(e.op,e.fn,e.args,e.implicit)},r.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,t,r,i,!1);if(1===i.length){var o=Mt(this,t),s=i[0].toHTML(e);return a[0]&&(s='('+s+')'),"right"===o?''+ke(this.op)+""+s:s+''+ke(this.op)+""}if(2===i.length){var u=i[0].toHTML(e),c=i[1].toHTML(e);return a[0]&&(u='('+u+')'),a[1]&&(c='('+c+')'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?u+''+c:u+''+ke(this.op)+""+c}var l=i.map((function(t,r){return t=t.toHTML(e),a[r]&&(t='('+t+')'),t}));return i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())?this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?l.join(''):l.join(''+ke(this.op)+""):''+ke(this.fn)+'('+l.join(',')+')'},r.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,t,r,i,!0),o=mt[this.fn];if(o=void 0===o?this.op:o,1===i.length){var s=Mt(this,t),u=i[0].toTex(e);return a[0]&&(u="\\left(".concat(u,"\\right)")),"right"===s?o+u:u+o}if(2===i.length){var c=i[0],l=c.toTex(e);a[0]&&(l="\\left(".concat(l,"\\right)"));var f,p=i[1].toTex(e);switch(a[1]&&(p="\\left(".concat(p,"\\right)")),f="keep"===t?c.getIdentifier():c.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return o+"{"+l+"}{"+p+"}";case"OperatorNode:pow":switch(l="{"+l+"}",p="{"+p+"}",f){case"ConditionalNode":case"OperatorNode:divide":l="\\left(".concat(l,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&"hide"===r)return l+"~"+p}return l+o+p}if(i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var m=i.map((function(t,r){return t=t.toTex(e),a[r]&&(t="\\left(".concat(t,"\\right)")),t}));return"OperatorNode:multiply"===this.getIdentifier()&&this.implicit?m.join("~"):m.join(o)}return"\\mathrm{"+this.fn+"}\\left("+i.map((function(t){return t.toTex(e)})).join(",")+"\\right)"},r.prototype.getIdentifier=function(){return this.type+":"+this.fn},r}),{isClass:!0,isNode:!0}),Tt=W("RangeNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError("Node expected");if(!I(t))throw new TypeError("Node expected");if(n&&!I(n))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=e,this.end=t,this.step=n||null}function n(e,t){var r=Nt(e,t),n={},i=Nt(e.start,t);if(n.start=null!==i&&i<=r||"all"===t,e.step){var a=Nt(e.step,t);n.step=null!==a&&a<=r||"all"===t}var o=Nt(e.end,t);return n.end=null!==o&&o<=r||"all"===t,n}return r.prototype=new t,r.prototype.type="RangeNode",r.prototype.isRangeNode=!0,r.prototype.needsEnd=function(){return this.filter((function(e){return P(e)&&"end"===e.name})).length>0},r.prototype._compile=function(e,t){var r=e.range,n=this.start._compile(e,t),i=this.end._compile(e,t);if(this.step){var a=this.step._compile(e,t);return function(e,t,o){return r(n(e,t,o),i(e,t,o),a(e,t,o))}}return function(e,t,a){return r(n(e,t,a),i(e,t,a))}},r.prototype.forEach=function(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)},r.prototype.map=function(e){return new r(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))},r.prototype.clone=function(){return new r(this.start,this.end,this.step&&this.step)},r.prototype._toString=function(e){var t,r=n(this,e&&e.parenthesis?e.parenthesis:"keep"),i=this.start.toString(e);if(r.start&&(i="("+i+")"),t=i,this.step){var a=this.step.toString(e);r.step&&(a="("+a+")"),t+=":"+a}var o=this.end.toString(e);return r.end&&(o="("+o+")"),t+":"+o},r.prototype.toJSON=function(){return{mathjs:"RangeNode",start:this.start,end:this.end,step:this.step}},r.fromJSON=function(e){return new r(e.start,e.end,e.step)},r.prototype.toHTML=function(e){var t,r=n(this,e&&e.parenthesis?e.parenthesis:"keep"),i=this.start.toHTML(e);if(r.start&&(i='('+i+')'),t=i,this.step){var a=this.step.toHTML(e);r.step&&(a='('+a+')'),t+=':'+a}var o=this.end.toHTML(e);return r.end&&(o='('+o+')'),t+':'+o},r.prototype._toTex=function(e){var t=n(this,e&&e.parenthesis?e.parenthesis:"keep"),r=this.start.toTex(e);if(t.start&&(r="\\left(".concat(r,"\\right)")),this.step){var i=this.step.toTex(e);t.step&&(i="\\left(".concat(i,"\\right)")),r+=":"+i}var a=this.end.toTex(e);return t.end&&(a="\\left(".concat(a,"\\right)")),r+":"+a},r}),{isClass:!0,isNode:!0}),Bt=W("FunctionAssignmentNode",["typed","Node"],(e=>{var{typed:t,Node:r}=e;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(t))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!I(r))throw new TypeError('Node expected for parameter "expr"');if(H.has(e))throw new Error('Illegal function name, "'+e+'" is a reserved keyword');this.name=e,this.params=t.map((function(e){return e&&e.name||e})),this.types=t.map((function(e){return e&&e.type||"any"})),this.expr=r}function i(e,t){var r=Nt(e,t),n=Nt(e.expr,t);return"all"===t||null!==n&&n<=r}return n.prototype=new r,n.prototype.type="FunctionAssignmentNode",n.prototype.isFunctionAssignmentNode=!0,n.prototype._compile=function(e,r){var n=Object.create(r);rt(this.params,(function(e){n[e]=!0}));var i=this.expr._compile(e,n),a=this.name,o=this.params,s=at(this.types,","),u=a+"("+at(this.params,", ")+")";return function(e,r,n){var c={};c[s]=function(){for(var t=Object.create(r),a=0;a'+ke(this.params[n])+"");var a=this.expr.toHTML(e);return i(this,t)&&(a='('+a+')'),''+ke(this.name)+'('+r.join(',')+')='+a},n.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=this.expr.toTex(e);return i(this,t)&&(r="\\left(".concat(r,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(gt).join(",")+"\\right):="+r},n}),{isClass:!0,isNode:!0}),qt="chain",zt=W(qt,["typed","Chain"],(e=>{var{typed:t,Chain:r}=e;return t(qt,{"":function(){return new r},any:function(e){return new r(e)}})}));function Dt(e){return e&&e.isIndexError?new Pe(e.index+1,e.min+1,void 0!==e.max?e.max+1:void 0):e}function It(e){var{subset:t}=e;return function(e,r){try{if(Array.isArray(e))return t(e,r);if(e&&"function"==typeof e.subset)return e.subset(r);if("string"==typeof e)return t(e,r);if("object"==typeof e){if(!r.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return Y(e,r.getObjectProperty())}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Dt(e)}}}var kt=W("AccessorNode",["subset","Node"],(e=>{var{subset:t,Node:r}=e,n=It({subset:t});function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError('Node expected for parameter "object"');if(!D(t))throw new TypeError('IndexNode expected for parameter "index"');this.object=e||null,this.index=t,Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function a(e){return!(A(e)||O(e)||B(e)||z(e)||k(e)||F(e)||P(e))}return i.prototype=new r,i.prototype.type="AccessorNode",i.prototype.isAccessorNode=!0,i.prototype._compile=function(e,t){var r=this.object._compile(e,t),i=this.index._compile(e,t);if(this.index.isObjectProperty()){var a=this.index.getObjectProperty();return function(e,t,n){return Y(r(e,t,n),a)}}return function(e,t,a){var o=r(e,t,a),s=i(e,t,o);return n(o,s)}},i.prototype.forEach=function(e){e(this.object,"object",this),e(this.index,"index",this)},i.prototype.map=function(e){return new i(this._ifNode(e(this.object,"object",this)),this._ifNode(e(this.index,"index",this)))},i.prototype.clone=function(){return new i(this.object,this.index)},i.prototype._toString=function(e){var t=this.object.toString(e);return a(this.object)&&(t="("+t+")"),t+this.index.toString(e)},i.prototype.toHTML=function(e){var t=this.object.toHTML(e);return a(this.object)&&(t='('+t+')'),t+this.index.toHTML(e)},i.prototype._toTex=function(e){var t=this.object.toTex(e);return a(this.object)&&(t="\\left(' + object + '\\right)"),t+this.index.toTex(e)},i.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},i.fromJSON=function(e){return new i(e.object,e.index)},i}),{isClass:!0,isNode:!0}),Rt=W("IndexNode",["Range","Node","size"],(e=>{var{Range:t,Node:r,size:n}=e;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(this.dimensions=e,this.dotNotation=t||!1,!Array.isArray(e)||!e.every(I))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}function o(e,r,n){return new t(a(e)?e.toNumber():e,a(r)?r.toNumber():r,a(n)?n.toNumber():n)}return i.prototype=new r,i.prototype.type="IndexNode",i.prototype.isIndexNode=!0,i.prototype._compile=function(e,t){var r=tt(this.dimensions,(function(r,i){if(U(r)){if(r.needsEnd()){var a=Object.create(t);a.end=!0;var s=r.start._compile(e,a),u=r.end._compile(e,a),c=r.step?r.step._compile(e,a):function(){return 1};return function(e,t,r){var a=n(r).valueOf(),l=Object.create(t);return l.end=a[i],o(s(e,l,r),u(e,l,r),c(e,l,r))}}var l=r.start._compile(e,t),f=r.end._compile(e,t),p=r.step?r.step._compile(e,t):function(){return 1};return function(e,t,r){return o(l(e,t,r),f(e,t,r),p(e,t,r))}}if(P(r)&&"end"===r.name){var m=Object.create(t);m.end=!0;var h=r._compile(e,m);return function(e,t,r){var a=n(r).valueOf(),o=Object.create(t);return o.end=a[i],h(e,o,r)}}var d=r._compile(e,t);return function(e,t,r){return d(e,t,r)}})),i=Y(e,"index");return function(e,t,n){var a=tt(r,(function(r){return r(e,t,n)}));return i(...a)}},i.prototype.forEach=function(e){for(var t=0;t.'+ke(this.getObjectProperty())+"":'['+t.join(',')+']'},i.prototype._toTex=function(e){var t=this.dimensions.map((function(t){return t.toTex(e)}));return this.dotNotation?"."+this.getObjectProperty():"_{"+t.join(",")+"}"},i}),{isClass:!0,isNode:!0}),Ft=W("AssignmentNode",["subset","?matrix","Node"],(e=>{var{subset:t,matrix:r,Node:n}=e,i=It({subset:t}),a=function(e){var{subset:t,matrix:r}=e;return function(e,n,i){try{if(Array.isArray(e))return r(e).subset(n,i).valueOf();if(e&&"function"==typeof e.subset)return e.subset(n,i);if("string"==typeof e)return t(e,n,i);if("object"==typeof e){if(!n.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return X(e,n.getObjectProperty(),i),e}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Dt(e)}}}({subset:t,matrix:r});function o(e,t,r){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=e,this.index=r?t:null,this.value=r||t,!P(e)&&!A(e))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(P(e)&&"end"===e.name)throw new Error('Cannot assign to symbol "end"');if(this.index&&!D(this.index))throw new TypeError('IndexNode expected as "index"');if(!I(this.value))throw new TypeError('Node expected as "value"');Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function s(e,t){t||(t="keep");var r=Nt(e,t),n=Nt(e.value,t);return"all"===t||null!==n&&n<=r}return o.prototype=new n,o.prototype.type="AssignmentNode",o.prototype.isAssignmentNode=!0,o.prototype._compile=function(e,t){var r=this.object._compile(e,t),n=this.index?this.index._compile(e,t):null,o=this.value._compile(e,t),s=this.object.name;if(this.index){if(this.index.isObjectProperty()){var u=this.index.getObjectProperty();return function(e,t,n){var i=r(e,t,n),a=o(e,t,n);return X(i,u,a),a}}if(P(this.object))return function(e,t,i){var u=r(e,t,i),c=o(e,t,i),l=n(e,t,u);return e.set(s,a(u,l,c)),c};var c=this.object.object._compile(e,t);if(this.object.index.isObjectProperty()){var l=this.object.index.getObjectProperty();return function(e,t,r){var i=c(e,t,r),s=Y(i,l),u=n(e,t,s),f=o(e,t,r);return X(i,l,a(s,u,f)),f}}var f=this.object.index._compile(e,t);return function(e,t,r){var s=c(e,t,r),u=f(e,t,s),l=i(s,u),p=n(e,t,l),m=o(e,t,r);return a(s,u,a(l,p,m)),m}}if(!P(this.object))throw new TypeError("SymbolNode expected as object");return function(e,t,r){var n=o(e,t,r);return e.set(s,n),n}},o.prototype.forEach=function(e){e(this.object,"object",this),this.index&&e(this.index,"index",this),e(this.value,"value",this)},o.prototype.map=function(e){return new o(this._ifNode(e(this.object,"object",this)),this.index?this._ifNode(e(this.index,"index",this)):null,this._ifNode(e(this.value,"value",this)))},o.prototype.clone=function(){return new o(this.object,this.index,this.value)},o.prototype._toString=function(e){var t=this.object.toString(e),r=this.index?this.index.toString(e):"",n=this.value.toString(e);return s(this,e&&e.parenthesis)&&(n="("+n+")"),t+r+" = "+n},o.prototype.toJSON=function(){return{mathjs:"AssignmentNode",object:this.object,index:this.index,value:this.value}},o.fromJSON=function(e){return new o(e.object,e.index,e.value)},o.prototype.toHTML=function(e){var t=this.object.toHTML(e),r=this.index?this.index.toHTML(e):"",n=this.value.toHTML(e);return s(this,e&&e.parenthesis)&&(n='('+n+')'),t+r+'='+n},o.prototype._toTex=function(e){var t=this.object.toTex(e),r=this.index?this.index.toTex(e):"",n=this.value.toTex(e);return s(this,e&&e.parenthesis)&&(n="\\left(".concat(n,"\\right)")),t+r+":="+n},o}),{isClass:!0,isNode:!0}),Ut=W("SymbolNode",["math","?Unit","Node"],(e=>{var{math:t,Unit:r,Node:n}=e;function i(e){return!!r&&r.isValuelessUnit(e)}function a(e){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');this.name=e}return a.prototype=new n,a.prototype.type="SymbolNode",a.prototype.isSymbolNode=!0,a.prototype._compile=function(e,t){var n=this.name;if(!0===t[n])return function(e,t,r){return t[n]};if(n in e)return function(t,r,i){return t.has(n)?t.get(n):Y(e,n)};var o=i(n);return function(e,t,i){return e.has(n)?e.get(n):o?new r(null,n):a.onUndefinedSymbol(n)}},a.prototype.forEach=function(e){},a.prototype.map=function(e){return this.clone()},a.onUndefinedSymbol=function(e){throw new Error("Undefined symbol "+e)},a.prototype.clone=function(){return new a(this.name)},a.prototype._toString=function(e){return this.name},a.prototype.toHTML=function(e){var t=ke(this.name);return"true"===t||"false"===t?''+t+"":"i"===t?''+t+"":"Infinity"===t?''+t+"":"NaN"===t?''+t+"":"null"===t?''+t+"":"undefined"===t?''+t+"":''+t+""},a.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},a.fromJSON=function(e){return new a(e.name)},a.prototype._toTex=function(e){var r=!1;void 0===t[this.name]&&i(this.name)&&(r=!0);var n=gt(this.name,r);return"\\"===n[0]?n:" "+n},a}),{isClass:!0,isNode:!0});function Pt(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{var{math:t,Node:r,SymbolNode:n}=e;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if("string"==typeof e&&(e=new n(e)),!I(e))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(t)||!t.every(I))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=e,this.args=t||[],Object.defineProperty(this,"name",{get:function(){return this.fn.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}i.prototype=new r,i.prototype.type="FunctionNode",i.prototype.isFunctionNode=!0,i.prototype._compile=function(e,t){if(!(this instanceof i))throw new TypeError("No valid FunctionNode");var r=this.args.map((r=>r._compile(e,t)));if(!P(this.fn)){if(A(this.fn)&&D(this.fn.index)&&this.fn.index.isObjectProperty()){var n=this.fn.object._compile(e,t),a=this.fn.index.getObjectProperty(),o=this.args;return function(t,i,s){var u=n(t,i,s);if(function(e,t){if(!K(e,t))throw new Error('No access to method "'+t+'"')}(u,a),u[a]&&u[a].rawArgs)return u[a](o,e,Pt(t,i),t);var c=r.map((e=>e(t,i,s)));return u[a].apply(u,c)}}var s=this.fn._compile(e,t),u=this.args;return function(t,n,i){var a=s(t,n,i);if(a&&a.rawArgs)return a(u,e,Pt(t,n),t);var o=r.map((e=>e(t,n,i)));return a.apply(a,o)}}var c=this.fn.name,l=c in e?Y(e,c):void 0,f="function"==typeof l&&!0===l.rawArgs,p=t=>t.has(c)?t.get(c):c in e?Y(e,c):i.onUndefinedFunction(c);if(f){var m=this.args;return function(t,r,n){return p(t)(m,e,Pt(t,r),t)}}switch(r.length){case 0:return function(e,t,r){return p(e)()};case 1:return function(e,t,n){return p(e)((0,r[0])(e,t,n))};case 2:return function(e,t,n){var i=p(e),a=r[0],o=r[1];return i(a(e,t,n),o(e,t,n))};default:return function(e,t,n){return p(e)(...r.map((r=>r(e,t,n))))}}},i.prototype.forEach=function(e){e(this.fn,"fn",this);for(var t=0;t'+ke(this.fn)+'('+t.join(',')+')'};var s=i.prototype.toTex;return i.prototype.toTex=function(e){var t;return e&&"object"==typeof e.handler&&Z(e.handler,this.name)&&(t=e.handler[this.name](this,e)),void 0!==t?t:s.call(this,e)},i.prototype._toTex=function(e){var r,n,i=this.args.map((function(t){return t.toTex(e)}));switch(ht[this.name]&&(r=ht[this.name]),!t[this.name]||"function"!=typeof t[this.name].toTex&&"object"!=typeof t[this.name].toTex&&"string"!=typeof t[this.name].toTex||(r=t[this.name].toTex),typeof r){case"function":n=r(this,e);break;case"string":n=o(r,this,e);break;case"object":switch(typeof r[i.length]){case"function":n=r[i.length](this,e);break;case"string":n=o(r[i.length],this,e)}}return void 0!==n?n:o("\\mathrm{${name}}\\left(${args}\\right)",this,e)},i.prototype.getIdentifier=function(){return this.type+":"+this.name},i}),{isClass:!0,isNode:!0});function Lt(e){for(var t=0;t=n.length)throw new Pe(t,n.length);return f(e)?e.create(Vt(e.valueOf(),t,r)):Vt(e,t,r)}function Vt(e,t,r){var n,i,a,o;if(t<=0){if(Array.isArray(e[0])){for(o=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r{var{typed:r,numeric:n,config:i,AccessorNode:a,ArrayNode:o,AssignmentNode:s,BlockNode:u,ConditionalNode:c,ConstantNode:l,FunctionAssignmentNode:f,FunctionNode:p,IndexNode:m,ObjectNode:h,OperatorNode:d,ParenthesisNode:y,RangeNode:g,RelationalNode:v,SymbolNode:x}=t,b=r(Wt,{string:function(e){return U(e,{})},"Array | Matrix":function(e){return w(e,{})},"string, Object":function(e,t){return U(e,void 0!==t.nodes?t.nodes:{})},"Array | Matrix, Object":w});function w(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=void 0!==t.nodes?t.nodes:{};return $t(e,(function(e){if("string"!=typeof e)throw new TypeError("String expected");return U(e,r)}))}var N={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},M={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},S={true:!0,false:!1,null:null,undefined:void 0},E=["NaN","Infinity"];function O(e,t){return e.expression.substr(e.index,t)}function C(e){return O(e,1)}function _(e){e.index++}function T(e){return e.expression.charAt(e.index-1)}function q(e){return e.expression.charAt(e.index+1)}function D(e){for(e.tokenType=0,e.token="",e.comment="";b.isWhitespace(C(e),e.nestingLevel);)_(e);if("#"===C(e))for(;"\n"!==C(e)&&""!==C(e);)e.comment+=C(e),_(e);if(""!==C(e)){if("\n"===C(e)&&!e.nestingLevel)return e.tokenType=1,e.token=C(e),void _(e);var t=C(e),r=O(e,2),n=O(e,3);if(3===n.length&&N[n])return e.tokenType=1,e.token=n,_(e),_(e),void _(e);if(2===r.length&&N[r])return e.tokenType=1,e.token=r,_(e),void _(e);if(N[t])return e.tokenType=1,e.token=t,void _(e);if(b.isDigitDot(t)){e.tokenType=2;var i=O(e,2);if("0b"===i||"0o"===i||"0x"===i){for(e.token+=C(e),_(e),e.token+=C(e),_(e);b.isHexDigit(C(e));)e.token+=C(e),_(e);if("."===C(e))for(e.token+=".",_(e);b.isHexDigit(C(e));)e.token+=C(e),_(e);else if("i"===C(e))for(e.token+="i",_(e);b.isDigit(C(e));)e.token+=C(e),_(e);return}if("."===C(e))e.token+=C(e),_(e),b.isDigit(C(e))||(e.tokenType=1);else{for(;b.isDigit(C(e));)e.token+=C(e),_(e);b.isDecimalMark(C(e),q(e))&&(e.token+=C(e),_(e))}for(;b.isDigit(C(e));)e.token+=C(e),_(e);if("E"===C(e)||"e"===C(e))if(b.isDigit(q(e))||"-"===q(e)||"+"===q(e)){if(e.token+=C(e),_(e),"+"!==C(e)&&"-"!==C(e)||(e.token+=C(e),_(e)),!b.isDigit(C(e)))throw ue(e,'Digit expected, got "'+C(e)+'"');for(;b.isDigit(C(e));)e.token+=C(e),_(e);if(b.isDecimalMark(C(e),q(e)))throw ue(e,'Digit expected, got "'+C(e)+'"')}else if("."===q(e))throw _(e),ue(e,'Digit expected, got "'+C(e)+'"')}else{if(!b.isAlpha(C(e),T(e),q(e))){for(e.tokenType=4;""!==C(e);)e.token+=C(e),_(e);throw ue(e,'Syntax error in part "'+e.token+'"')}for(;b.isAlpha(C(e),T(e),q(e))||b.isDigit(C(e));)e.token+=C(e),_(e);Z(M,e.token)?e.tokenType=1:e.tokenType=3}}else e.tokenType=1}function I(e){do{D(e)}while("\n"===e.token)}function k(e){e.nestingLevel++}function F(e){e.nestingLevel--}function U(t,r){var n={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:0,nestingLevel:0,conditionalLevel:null};e(n,{expression:t,extraNodes:r}),D(n);var i=function(e){var t,r,n=[];for(""!==e.token&&"\n"!==e.token&&";"!==e.token&&((t=j(e)).comment=e.comment);"\n"===e.token||";"===e.token;)0===n.length&&t&&(r=";"!==e.token,n.push({node:t,visible:r})),D(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&((t=j(e)).comment=e.comment,r=";"!==e.token,n.push({node:t,visible:r}));return n.length>0?new u(n):(t||((t=new l(void 0)).comment=e.comment),t)}(n);if(""!==n.token)throw 1===n.tokenType?ce(n,"Unexpected operator "+n.token):ue(n,'Unexpected part "'+n.token+'"');return i}function j(e){var t,r,n,i,a=function(e){for(var t=function(e){for(var t=L(e);"or"===e.token;)I(e),t=new d("or","or",[t,L(e)]);return t}(e);"?"===e.token;){var r=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,I(e);var n=t,i=j(e);if(":"!==e.token)throw ue(e,"False part of conditional expression expected");e.conditionalLevel=null,I(e);var a=j(e);t=new c(n,i,a),e.conditionalLevel=r}return t}(e);if("="===e.token){if(P(a))return t=a.name,I(e),n=j(e),new s(new x(t),n);if(A(a))return I(e),n=j(e),new s(a.object,a.index,n);if(z(a)&&P(a.fn)&&(i=!0,r=[],t=a.name,a.args.forEach((function(e,t){P(e)?r[t]=e.name:i=!1})),i))return I(e),n=j(e),new f(t,r,n);throw ue(e,"Invalid left hand side of assignment operator =")}return a}function L(e){for(var t=H(e);"xor"===e.token;)I(e),t=new d("xor","xor",[t,H(e)]);return t}function H(e){for(var t=$(e);"and"===e.token;)I(e),t=new d("and","and",[t,$(e)]);return t}function $(e){for(var t=G(e);"|"===e.token;)I(e),t=new d("|","bitOr",[t,G(e)]);return t}function G(e){for(var t=V(e);"^|"===e.token;)I(e),t=new d("^|","bitXor",[t,V(e)]);return t}function V(e){for(var t=W(e);"&"===e.token;)I(e),t=new d("&","bitAnd",[t,W(e)]);return t}function W(e){for(var t=[J(e)],r=[],n={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};Z(n,e.token);){var i={name:e.token,fn:n[e.token]};r.push(i),I(e),t.push(J(e))}return 1===t.length?t[0]:2===t.length?new d(r[0].name,r[0].fn,t):new v(r.map((e=>e.fn)),t)}function J(e){var t,r,n,i;t=Y(e);for(var a={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Z(a,e.token);)n=a[r=e.token],I(e),i=[t,Y(e)],t=new d(r,n,i);return t}function Y(e){var t,r,n,i;t=X(e);for(var a={to:"to",in:"to"};Z(a,e.token);)n=a[r=e.token],I(e),"in"===r&&""===e.token?t=new d("*","multiply",[t,new x("in")],!0):(i=[t,X(e)],t=new d(r,n,i));return t}function X(e){var t,r=[];if(t=":"===e.token?new l(1):Q(e),":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(r.push(t);":"===e.token&&r.length<3;)I(e),")"===e.token||"]"===e.token||","===e.token||""===e.token?r.push(new x("end")):r.push(Q(e));t=3===r.length?new g(r[0],r[2],r[1]):new g(r[0],r[1])}return t}function Q(e){var t,r,n,i;t=K(e);for(var a={"+":"add","-":"subtract"};Z(a,e.token);)n=a[r=e.token],I(e),i=[t,K(e)],t=new d(r,n,i);return t}function K(e){var t,r,n,i;r=t=ee(e);for(var a={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"};Z(a,e.token);)i=a[n=e.token],I(e),r=ee(e),t=new d(n,i,[t,r]);return t}function ee(e){var t,r;for(r=t=te(e);3===e.tokenType||"in"===e.token&&B(t)||!(2!==e.tokenType||B(r)||R(r)&&"!"!==r.op)||"("===e.token;)r=te(e),t=new d("*","multiply",[t,r],!0);return t}function te(t){for(var r=re(t),n=r,i=[];"/"===t.token&&B(n);){if(i.push(e({},t)),I(t),2!==t.tokenType){e(t,i.pop());break}if(i.push(e({},t)),I(t),3!==t.tokenType&&"("!==t.token){i.pop(),e(t,i.pop());break}e(t,i.pop()),i.pop(),n=re(t),r=new d("/","divide",[r,n])}return r}function re(e){var t,r,a,s={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Z(s,e.token)?(a=s[e.token],t=e.token,I(e),r=[re(e)],new d(t,a,r)):function(e){var t,r,a,s;return t=function(e){var t,r,a;t=function(e){var t=[];if(3===e.tokenType&&Z(e.extraNodes,e.token)){var r=e.extraNodes[e.token];if(D(e),"("===e.token){if(t=[],k(e),D(e),")"!==e.token)for(t.push(j(e));","===e.token;)D(e),t.push(j(e));if(")"!==e.token)throw ue(e,"Parenthesis ) expected");F(e),D(e)}return new r(t)}return function(e){var t;return 3===e.tokenType||1===e.tokenType&&e.token in M?(t=e.token,D(e),ne(e,Z(S,t)?new l(S[t]):-1!==E.indexOf(t)?new l(n(t,"number")):new x(t))):function(e){var t;return'"'===e.token?(t=ie(e),ne(e,new l(t))):function(e){var t;return"'"===e.token?(t=ae(e),ne(e,new l(t))):function(e){var t,r,a,s;if("["===e.token){if(k(e),D(e),"]"!==e.token){var u=oe(e);if(";"===e.token){for(a=1,r=[u];";"===e.token;)D(e),r[a]=oe(e),a++;if("]"!==e.token)throw ue(e,"End of matrix ] expected");F(e),D(e),s=r[0].items.length;for(var c=1;c0},b.isDecimalMark=function(e,t){return"."===e&&"/"!==t&&"*"!==t&&"^"!==t},b.isDigitDot=function(e){return e>="0"&&e<="9"||"."===e},b.isDigit=function(e){return e>="0"&&e<="9"},b.isHexDigit=function(e){return e>="0"&&e<="9"||e>="a"&&e<="f"||e>="A"&&e<="F"},b})),Yt="evaluate",Xt=W(Yt,["typed","parse"],(e=>{var{typed:t,parse:r}=e;return t(Yt,{string:function(e){var t=ie();return r(e).compile().evaluate(t)},"string, Map | Object":function(e,t){return r(e).compile().evaluate(t)},"Array | Matrix":function(e){var t=ie();return $t(e,(function(e){return r(e).compile().evaluate(t)}))},"Array | Matrix, Map | Object":function(e,t){return $t(e,(function(e){return r(e).compile().evaluate(t)}))}})})),Qt=W("Help",["parse"],(e=>{var{parse:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw new Error('Argument "doc" missing');this.doc=e}return r.prototype.type="Help",r.prototype.isHelp=!0,r.prototype.toString=function(){var e=this.doc||{},r="\n";if(e.name&&(r+="Name: "+e.name+"\n\n"),e.category&&(r+="Category: "+e.category+"\n\n"),e.description&&(r+="Description:\n "+e.description+"\n\n"),e.syntax&&(r+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){r+="Examples:\n";for(var n={},i=0;i"mathjs"!==e)).forEach((r=>{t[r]=e[r]})),new r(t)},r.prototype.valueOf=r.prototype.toString,r}),{isClass:!0}),Kt=W("Parser",["parse"],(e=>{var{parse:t}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:ie(),writable:!1})}return r.prototype.type="Parser",r.prototype.isParser=!0,r.prototype.evaluate=function(e){return t(e).compile().evaluate(this.scope)},r.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},r.prototype.getAll=function(){return function(e){if(e instanceof ne)return e.wrappedObject;var t={};for(var r of e.keys())X(t,r,e.get(r));return t}(this.scope)},r.prototype.getAllAsMap=function(){return this.scope},r.prototype.set=function(e,t){return this.scope.set(e,t),t},r.prototype.remove=function(e){this.scope.delete(e)},r.prototype.clear=function(){this.scope.clear()},r}),{isClass:!0}),er={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]},tr={name:"e",category:"Constants",syntax:["e"],description:"Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",examples:["e","e ^ 2","exp(2)","log(e)"],seealso:["exp"]},rr={bignumber:{name:"bignumber",category:"Construction",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","complex","fraction","index","matrix","string","unit"]},boolean:{name:"boolean",category:"Construction",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]},complex:{name:"complex",category:"Construction",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]},createUnit:{name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.",examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]},fraction:{name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(num,den)"],description:"Create a fraction from a number or from a numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},index:{name:"index",category:"Construction",syntax:["[start]","[start:end]","[start:step:end]","[start1, start 2, ...]","[start1:end1, start2:end2, ...]","[start1:step1:end1, start2:step2:end2, ...]"],description:"Create an index to get or replace a subset of a matrix",examples:["[]","[1, 2, 3]","A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[0:2, 0:2] = ones(2, 2)"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]},matrix:{name:"matrix",category:"Construction",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()",'matrix("dense")',"matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])",'matrix([3, 4; 5, 6], "sparse")','matrix([3, 4; 5, 6], "sparse", "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","sparse"]},number:{name:"number",category:"Construction",syntax:["x","number(x)","number(unit, valuelessUnit)"],description:"Create a number or convert a string or boolean into a number.",examples:["2","2e3","4.05","number(2)",'number("7.2")',"number(true)","number([true, false, true, true])",'number(unit("52cm"), "m")'],seealso:["bignumber","boolean","complex","fraction","index","matrix","string","unit"]},sparse:{name:"sparse",category:"Construction",syntax:["sparse()","sparse([a1, b1, ...; a1, b2, ...])",'sparse([a1, b1, ...; a1, b2, ...], "number")'],description:"Create a sparse matrix.",examples:["sparse()","sparse([3, 4; 5, 6])",'sparse([3, 0; 5, 0], "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","matrix"]},splitUnit:{name:"splitUnit",category:"Construction",syntax:["splitUnit(unit: Unit, parts: Unit[])"],description:"Split a unit in an array of units whose sum is equal to the original unit.",examples:['splitUnit(1 m, ["feet", "inch"])'],seealso:["unit","createUnit"]},string:{name:"string",category:"Construction",syntax:['"text"',"string(x)"],description:"Create a string or convert a value to a string",examples:['"Hello World!"',"string(4.2)","string(3 + 2i)"],seealso:["bignumber","boolean","complex","index","matrix","number","unit"]},unit:{name:"unit",category:"Construction",syntax:["value unit","unit(value, unit)","unit(string)"],description:"Create a unit.",examples:["5.5 mm","3 inch",'unit(7.1, "kilogram")','unit("23 deg")'],seealso:["bignumber","boolean","complex","index","matrix","number","string"]},e:tr,E:tr,false:{name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},i:{name:"i",category:"Constants",syntax:["i"],description:"Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",examples:["i","i * i","sqrt(-1)"],seealso:[]},Infinity:{name:"Infinity",category:"Constants",syntax:["Infinity"],description:"Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",examples:["Infinity","1 / 0"],seealso:[]},LN2:{name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},LN10:{name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},LOG2E:{name:"LOG2E",category:"Constants",syntax:["LOG2E"],description:"Returns the base-2 logarithm of E, approximately equal to 1.442",examples:["LOG2E","log(e, 2)"],seealso:[]},LOG10E:{name:"LOG10E",category:"Constants",syntax:["LOG10E"],description:"Returns the base-10 logarithm of E, approximately equal to 0.434",examples:["LOG10E","log(e, 10)"],seealso:[]},NaN:{name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},null:{name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},pi:er,PI:er,phi:{name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["phi"],seealso:[]},SQRT1_2:{name:"SQRT1_2",category:"Constants",syntax:["SQRT1_2"],description:"Returns the square root of 1/2, approximately equal to 0.707",examples:["SQRT1_2","sqrt(1/2)"],seealso:[]},SQRT2:{name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},tau:{name:"tau",category:"Constants",syntax:["tau"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]},true:{name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},version:{name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},speedOfLight:{description:"Speed of light in vacuum",examples:["speedOfLight"]},gravitationConstant:{description:"Newtonian constant of gravitation",examples:["gravitationConstant"]},planckConstant:{description:"Planck constant",examples:["planckConstant"]},reducedPlanckConstant:{description:"Reduced Planck constant",examples:["reducedPlanckConstant"]},magneticConstant:{description:"Magnetic constant (vacuum permeability)",examples:["magneticConstant"]},electricConstant:{description:"Electric constant (vacuum permeability)",examples:["electricConstant"]},vacuumImpedance:{description:"Characteristic impedance of vacuum",examples:["vacuumImpedance"]},coulomb:{description:"Coulomb's constant",examples:["coulomb"]},elementaryCharge:{description:"Elementary charge",examples:["elementaryCharge"]},bohrMagneton:{description:"Borh magneton",examples:["bohrMagneton"]},conductanceQuantum:{description:"Conductance quantum",examples:["conductanceQuantum"]},inverseConductanceQuantum:{description:"Inverse conductance quantum",examples:["inverseConductanceQuantum"]},magneticFluxQuantum:{description:"Magnetic flux quantum",examples:["magneticFluxQuantum"]},nuclearMagneton:{description:"Nuclear magneton",examples:["nuclearMagneton"]},klitzing:{description:"Von Klitzing constant",examples:["klitzing"]},bohrRadius:{description:"Borh radius",examples:["bohrRadius"]},classicalElectronRadius:{description:"Classical electron radius",examples:["classicalElectronRadius"]},electronMass:{description:"Electron mass",examples:["electronMass"]},fermiCoupling:{description:"Fermi coupling constant",examples:["fermiCoupling"]},fineStructure:{description:"Fine-structure constant",examples:["fineStructure"]},hartreeEnergy:{description:"Hartree energy",examples:["hartreeEnergy"]},protonMass:{description:"Proton mass",examples:["protonMass"]},deuteronMass:{description:"Deuteron Mass",examples:["deuteronMass"]},neutronMass:{description:"Neutron mass",examples:["neutronMass"]},quantumOfCirculation:{description:"Quantum of circulation",examples:["quantumOfCirculation"]},rydberg:{description:"Rydberg constant",examples:["rydberg"]},thomsonCrossSection:{description:"Thomson cross section",examples:["thomsonCrossSection"]},weakMixingAngle:{description:"Weak mixing angle",examples:["weakMixingAngle"]},efimovFactor:{description:"Efimov factor",examples:["efimovFactor"]},atomicMass:{description:"Atomic mass constant",examples:["atomicMass"]},avogadro:{description:"Avogadro's number",examples:["avogadro"]},boltzmann:{description:"Boltzmann constant",examples:["boltzmann"]},faraday:{description:"Faraday constant",examples:["faraday"]},firstRadiation:{description:"First radiation constant",examples:["firstRadiation"]},loschmidt:{description:"Loschmidt constant at T=273.15 K and p=101.325 kPa",examples:["loschmidt"]},gasConstant:{description:"Gas constant",examples:["gasConstant"]},molarPlanckConstant:{description:"Molar Planck constant",examples:["molarPlanckConstant"]},molarVolume:{description:"Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",examples:["molarVolume"]},sackurTetrode:{description:"Sackur-Tetrode constant at T=1 K and p=101.325 kPa",examples:["sackurTetrode"]},secondRadiation:{description:"Second radiation constant",examples:["secondRadiation"]},stefanBoltzmann:{description:"Stefan-Boltzmann constant",examples:["stefanBoltzmann"]},wienDisplacement:{description:"Wien displacement law constant",examples:["wienDisplacement"]},molarMass:{description:"Molar mass constant",examples:["molarMass"]},molarMassC12:{description:"Molar mass constant of carbon-12",examples:["molarMassC12"]},gravity:{description:"Standard acceleration of gravity (standard acceleration of free-fall on Earth)",examples:["gravity"]},planckLength:{description:"Planck length",examples:["planckLength"]},planckMass:{description:"Planck mass",examples:["planckMass"]},planckTime:{description:"Planck time",examples:["planckTime"]},planckCharge:{description:"Planck charge",examples:["planckCharge"]},planckTemperature:{description:"Planck temperature",examples:["planckTemperature"]},derivative:{name:"derivative",category:"Algebra",syntax:["derivative(expr, variable)","derivative(expr, variable, {simplify: boolean})"],description:"Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",examples:['derivative("2x^3", "x")','derivative("2x^3", "x", {simplify: false})','derivative("2x^2 + 3x + 4", "x")','derivative("sin(2x)", "x")','f = parse("x^2 + x")','x = parse("x")',"df = derivative(f, x)","df.evaluate({x: 3})"],seealso:["simplify","parse","evaluate"]},lsolve:{name:"lsolve",category:"Algebra",syntax:["x=lsolve(L, b)"],description:"Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolveAll","lup","lusolve","usolve","matrix","sparse"]},lsolveAll:{name:"lsolveAll",category:"Algebra",syntax:["x=lsolveAll(L, b)"],description:"Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolve","lup","lusolve","usolve","matrix","sparse"]},lup:{name:"lup",category:"Algebra",syntax:["lup(m)"],description:"Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",examples:["lup([[2, 1], [1, 4]])","lup(matrix([[2, 1], [1, 4]]))","lup(sparse([[2, 1], [1, 4]]))"],seealso:["lusolve","lsolve","usolve","matrix","sparse","slu","qr"]},lusolve:{name:"lusolve",category:"Algebra",syntax:["x=lusolve(A, b)","x=lusolve(lu, b)"],description:"Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lusolve(a, b)"],seealso:["lup","slu","lsolve","usolve","matrix","sparse"]},simplify:{name:"simplify",category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["derivative","parse","evaluate"]},rationalize:{name:"rationalize",category:"Algebra",syntax:["rationalize(expr)","rationalize(expr, scope)","rationalize(expr, scope, detailed)"],description:"Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",examples:['rationalize("2x/y - y/(x+1)")','rationalize("2x/y - y/(x+1)", true)'],seealso:["simplify"]},slu:{name:"slu",category:"Algebra",syntax:["slu(A, order, threshold)"],description:"Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",examples:["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],seealso:["lusolve","lsolve","usolve","matrix","sparse","lup","qr"]},usolve:{name:"usolve",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolveAll","lup","lusolve","lsolve","matrix","sparse"]},usolveAll:{name:"usolveAll",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolve","lup","lusolve","lsolve","matrix","sparse"]},qr:{name:"qr",category:"Algebra",syntax:["qr(A)"],description:"Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",examples:["qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])"],seealso:["lup","slu","matrix"]},abs:{name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},add:{name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i","3 cm + 2 inch",'"2.3" + "4"'],seealso:["subtract"]},cbrt:{name:"cbrt",category:"Arithmetic",syntax:["cbrt(x)","cbrt(x, allRoots)"],description:"Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",examples:["cbrt(64)","cube(4)","cbrt(-8)","cbrt(2 + 3i)","cbrt(8i)","cbrt(8i, true)","cbrt(27 m^3)"],seealso:["square","sqrt","cube","multiply"]},ceil:{name:"ceil",category:"Arithmetic",syntax:["ceil(x)"],description:"Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)"],seealso:["floor","fix","round"]},cube:{name:"cube",category:"Arithmetic",syntax:["cube(x)"],description:"Compute the cube of a value. The cube of x is x * x * x.",examples:["cube(2)","2^3","2 * 2 * 2"],seealso:["multiply","square","pow"]},divide:{name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["a = 2 / 3","a * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]},dotDivide:{name:"dotDivide",category:"Operators",syntax:["x ./ y","dotDivide(x, y)"],description:"Divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","dotMultiply","divide"]},dotMultiply:{name:"dotMultiply",category:"Operators",syntax:["x .* y","dotMultiply(x, y)"],description:"Multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","dotDivide"]},dotPow:{name:"dotPow",category:"Operators",syntax:["x .^ y","dotPow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]},exp:{name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["expm","expm1","pow","log"]},expm:{name:"expm",category:"Arithmetic",syntax:["exp(x)"],description:"Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",examples:["expm([[0,2],[0,0]])"],seealso:["exp"]},expm1:{name:"expm1",category:"Arithmetic",syntax:["expm1(x)"],description:"Calculate the value of subtracting 1 from the exponential value.",examples:["expm1(2)","pow(e, 2) - 1","log(expm1(2) + 1)"],seealso:["exp","pow","log"]},fix:{name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]},floor:{name:"floor",category:"Arithmetic",syntax:["floor(x)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)"],seealso:["ceil","fix","round"]},gcd:{name:"gcd",category:"Arithmetic",syntax:["gcd(a, b)","gcd(a, b, c, ...)"],description:"Compute the greatest common divisor.",examples:["gcd(8, 12)","gcd(-4, 6)","gcd(25, 15, -10)"],seealso:["lcm","xgcd"]},hypot:{name:"hypot",category:"Arithmetic",syntax:["hypot(a, b, c, ...)","hypot([a, b, c, ...])"],description:"Calculate the hypotenusa of a list with values. ",examples:["hypot(3, 4)","sqrt(3^2 + 4^2)","hypot(-2)","hypot([3, 4, 5])"],seealso:["abs","norm"]},lcm:{name:"lcm",category:"Arithmetic",syntax:["lcm(x, y)"],description:"Compute the least common multiple.",examples:["lcm(4, 6)","lcm(6, 21)","lcm(6, 21, 5)"],seealso:["gcd"]},log:{name:"log",category:"Arithmetic",syntax:["log(x)","log(x, base)"],description:"Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",examples:["log(3.5)","a = log(2.4)","exp(a)","10 ^ 4","log(10000, 10)","log(10000) / log(10)","b = log(1024, 2)","2 ^ b"],seealso:["exp","log1p","log2","log10"]},log2:{name:"log2",category:"Arithmetic",syntax:["log2(x)"],description:"Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",examples:["log2(0.03125)","log2(16)","log2(16) / log2(2)","pow(2, 4)"],seealso:["exp","log1p","log","log10"]},log1p:{name:"log1p",category:"Arithmetic",syntax:["log1p(x)","log1p(x, base)"],description:"Calculate the logarithm of a `value+1`",examples:["log1p(2.5)","exp(log1p(1.4))","pow(10, 4)","log1p(9999, 10)","log1p(9999) / log(10)"],seealso:["exp","log","log2","log10"]},log10:{name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(0.00001)","log10(10000)","10 ^ 4","log(10000) / log(10)","log(10000, 10)"],seealso:["exp","log"]},mod:{name:"mod",category:"Operators",syntax:["x % y","x mod y","mod(x, y)"],description:"Calculates the modulus, the remainder of an integer division.",examples:["7 % 3","11 % 2","10 mod 4","isOdd(x) = x % 2","isOdd(2)","isOdd(3)"],seealso:["divide"]},multiply:{name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["a = 2.1 * 3.4","a / 3.4","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]},norm:{name:"norm",category:"Arithmetic",syntax:["norm(x)","norm(x, p)"],description:"Calculate the norm of a number, vector or matrix.",examples:["abs(-3.5)","norm(-3.5)","norm(3 - 4i)","norm([1, 2, -3], Infinity)","norm([1, 2, -3], -Infinity)","norm([3, 4], 2)","norm([[1, 2], [3, 4]], 1)",'norm([[1, 2], [3, 4]], "inf")','norm([[1, 2], [3, 4]], "fro")']},nthRoot:{name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["nthRoots","pow","sqrt"]},nthRoots:{name:"nthRoots",category:"Arithmetic",syntax:["nthRoots(A)","nthRoots(A, root)"],description:'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',examples:["nthRoots(1)","nthRoots(1, 3)"],seealso:["sqrt","pow","nthRoot"]},pow:{name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3","2*2*2","1 + e ^ (pi * i)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},round:{name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)"],seealso:["ceil","floor","fix"]},sign:{name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},sqrt:{name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},sqrtm:{name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},square:{name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},subtract:{name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},unaryMinus:{name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},bitAnd:{name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitNot:{name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitOr:{name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},bitXor:{name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},leftShift:{name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},rightArithShift:{name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},rightLogShift:{name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},bellNumbers:{name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},catalan:{name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},composition:{name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},stirlingS2:{name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},config:{name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},import:{name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number, number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},arg:{name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},conj:{name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},re:{name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},im:{name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},evaluate:{name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(" + 4 + ")")'],seealso:[]},help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},distance:{name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])","distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},intersect:{name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},and:{name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},not:{name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},or:{name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},xor:{name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},concat:{name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},count:{name:"count",category:"Matrix",syntax:["count(x)"],description:"Count the number of elements of a matrix, array or string.",examples:["a = [1, 2; 3, 4; 5, 6]","count(a)","size(a)",'count("hello world")'],seealso:["size"]},cross:{name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},column:{name:"column",category:"Matrix",syntax:["column(x, index)"],description:"Return a column from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","column(A, 1)","column(A, 2)"],seealso:["row","matrixFromColumns"]},ctranspose:{name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},det:{name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diag:{name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diff:{name:"diff",category:"Matrix",syntax:["diff(arr)","diff(arr, dim)"],description:["Create a new matrix or array with the difference of the passed matrix or array.","Dim parameter is optional and used to indicant the dimension of the array/matrix to apply the difference","If no dimension parameter is passed it is assumed as dimension 0","Dimension is zero-based in javascript and one-based in the parser","Arrays must be 'rectangular' meaning arrays like [1, 2]","If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],examples:["diff([1, 2, 4, 7, 0])","diff([1, 2, 4, 7, 0], 0)","diff(matrix([1, 2, 4, 7, 0]))","diff([[1, 2], [3, 4]])","diff([[1, 2], [3, 4]], 0)","diff([[1, 2], [3, 4]], 1)","diff([[1, 2], [3, 4]], bignumber(1))","diff(matrix([[1, 2], [3, 4]]), 1)","diff([[1, 2], matrix([3, 4])], 1)"],seealso:["subtract","partitionSelect"]},dot:{name:"dot",category:"Matrix",syntax:["dot(A, B)","A * B"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]},getMatrixDataType:{name:"getMatrixDataType",category:"Matrix",syntax:["getMatrixDataType(x)"],description:'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',examples:["getMatrixDataType([1, 2, 3])","getMatrixDataType([[5 cm], [2 inch]])",'getMatrixDataType([1, "text"])',"getMatrixDataType([1, bignumber(4)])"],seealso:["matrix","sparse","typeOf"]},identity:{name:"identity",category:"Matrix",syntax:["identity(n)","identity(m, n)","identity([m, n])"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["identity(3)","identity(3, 5)","a = [1, 2, 3; 4, 5, 6]","identity(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},filter:{name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},flatten:{name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]},forEach:{name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["forEach([1, 2, 3], function(val) { console.log(val) })"],seealso:["map","sort","filter"]},inv:{name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","identity","ones","range","size","squeeze","subset","trace","transpose","zeros"]},eigs:{name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and eigenvectors of a real symmetric matrix",examples:["eigs([[5, 2.3], [2.3, 1]])"],seealso:["inv"]},kron:{name:"kron",category:"Matrix",syntax:["kron(x, y)"],description:"Calculates the kronecker product of 2 matrices or vectors.",examples:["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])","kron([1,1], [2,3,4])"],seealso:["multiply","dot","cross"]},matrixFromFunction:{name:"matrixFromFunction",category:"Matrix",syntax:["math.matrixFromFunction(size, fn)","math.matrixFromFunction(size, fn, format)","math.matrixFromFunction(size, fn, format, datatype)","math.matrixFromFunction(size, format, fn)","math.matrixFromFunction(size, format, datatype, fn)"],description:"Create a matrix by evaluating a generating function at each index.",examples:["f(I) = I[1] - I[2]","matrixFromFunction([3,3], f)","g(I) = I[1] - I[2] == 1 ? 4 : 0",'matrixFromFunction([100, 100], "sparse", g)',"matrixFromFunction([5], random)"],seealso:["matrix","matrixFromRows","matrixFromColumns","zeros"]},matrixFromRows:{name:"matrixFromRows",category:"Matrix",syntax:["math.matrixFromRows(...arr)","math.matrixFromRows(row1, row2)","math.matrixFromRows(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual rows.",examples:["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromColumns","matrixFromFunction","zeros"]},matrixFromColumns:{name:"matrixFromColumns",category:"Matrix",syntax:["math.matrixFromColumns(...arr)","math.matrixFromColumns(row1, row2)","math.matrixFromColumns(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual columns.",examples:["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromRows","matrixFromFunction","zeros"]},map:{name:"map",category:"Matrix",syntax:["map(x, callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",examples:["map([1, 2, 3], square)"],seealso:["filter","forEach"]},ones:{name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","identity","inv","range","size","squeeze","subset","trace","transpose","zeros"]},partitionSelect:{name:"partitionSelect",category:"Matrix",syntax:["partitionSelect(x, k)","partitionSelect(x, k, compare)"],description:"Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",examples:["partitionSelect([5, 10, 1], 2)",'partitionSelect(["C", "B", "A", "D"], 1)'],seealso:["sort"]},range:{name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","identity","inv","ones","size","squeeze","subset","trace","transpose","zeros"]},resize:{name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze","reshape"]},reshape:{name:"reshape",category:"Matrix",syntax:["reshape(x, sizes)"],description:"Reshape a multi dimensional array to fit the specified dimensions.",examples:["reshape([1, 2, 3, 4, 5, 6], [2, 3])","reshape([[1, 2], [3, 4]], [1, 4])","reshape([[1, 2], [3, 4]], [4])"],seealso:["size","squeeze","resize"]},rotate:{name:"rotate",category:"Matrix",syntax:["rotate(w, theta)","rotate(w, theta, v)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotate([1, 0], math.pi / 2)",'rotate(matrix([1, 0]), unit("35deg"))','rotate([1, 0, 0], unit("90deg"), [0, 0, 1])','rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],seealso:["matrix","rotationMatrix"]},rotationMatrix:{name:"rotationMatrix",category:"Matrix",syntax:["rotationMatrix(theta)","rotationMatrix(theta, v)","rotationMatrix(theta, v, format)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotationMatrix(pi / 2)",'rotationMatrix(unit("45deg"), [0, 0, 1])','rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],seealso:["cos","sin"]},row:{name:"row",category:"Matrix",syntax:["row(x, index)"],description:"Return a row from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","row(A, 1)","row(A, 2)"],seealso:["column","matrixFromRows"]},size:{name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","count","det","diag","identity","inv","ones","range","squeeze","subset","trace","transpose","zeros"]},sort:{name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"])',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},squeeze:{name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","identity","inv","ones","range","size","subset","trace","transpose","zeros"]},subset:{name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of a matrix or string. Indexes are one-based. Both the ranges lower-bound and upper-bound are included.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},trace:{name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","transpose","zeros"]},transpose:{name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},zeros:{name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose"]},combinations:{name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},combinationsWithRep:{name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"],seealso:["combinations","permutations","factorial"]},factorial:{name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},gamma:{name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},kldivergence:{name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},multinomial:{name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},permutations:{name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},pickRandom:{name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)","pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])","pickRandom([1, 3, 1, 6], 2)","pickRandom([1, 3, 1, 6], [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],seealso:["random","randomInt"]},random:{name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]},randomInt:{name:"randomInt",category:"Probability",syntax:["randomInt(max)","randomInt(min, max)","randomInt(size)","randomInt(size, max)","randomInt(size, min, max)"],description:"Return a random integer number",examples:["randomInt(10, 20)","randomInt([2, 3], 10)"],seealso:["pickRandom","random"]},compare:{name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compareNatural","compareText"]},compareNatural:{name:"compareNatural",category:"Relational",syntax:["compareNatural(x, y)"],description:"Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compareNatural(2, 3)","compareNatural(3, 2)","compareNatural(2, 2)","compareNatural(5cm, 40mm)",'compareNatural("2", "10")',"compareNatural(2 + 3i, 2 + 4i)","compareNatural([1, 2, 4], [1, 2, 3])","compareNatural([1, 5], [1, 2, 3])","compareNatural([1, 2], [1, 2])","compareNatural({a: 2}, {a: 4})"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare","compareText"]},compareText:{name:"compareText",category:"Relational",syntax:["compareText(x, y)"],description:"Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:['compareText("B", "A")','compareText("A", "B")','compareText("A", "A")','compareText("2", "10")','compare("2", "10")',"compare(2, 10)",'compareNatural("2", "10")','compareText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural"]},deepEqual:{name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["deepEqual([1,3,4], [1,3,4])","deepEqual([1,3,4], [1,3])"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]},equal:{name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual","equalText"]},equalText:{name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},larger:{name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},largerEq:{name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},smaller:{name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},smallerEq:{name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 <= 1+1","2 < 1+1","a = 3.2","b = 6-2.8","(a <= b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]},unequal:{name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]},setCartesian:{name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},setDifference:{name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},setDistinct:{name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},setIntersect:{name:"setIntersect",category:"Set",syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},setIsSubset:{name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},setMultiplicity:{name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]},setPowerset:{name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},setSize:{name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},setSymDifference:{name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setDifference"]},setUnion:{name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},erf:{name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},mad:{name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},mean:{name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},median:{name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},min:{name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},mode:{name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},prod:{name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},quantileSeq:{name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:"Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.",examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},std:{name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},sum:{name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},variance:{name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},acos:{name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},acosh:{name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},acot:{name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},acoth:{name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},acsc:{name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},acsch:{name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},asec:{name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},asech:{name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},asin:{name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},asinh:{name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},atan:{name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},atanh:{name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},atan2:{name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},cos:{name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},cosh:{name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},cot:{name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},coth:{name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},csc:{name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},csch:{name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},sec:{name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},sech:{name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},sin:{name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},sinh:{name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},tan:{name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},tanh:{name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},to:{name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},clone:{name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},format:{name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},bin:{name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},oct:{name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},hex:{name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},isNaN:{name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isInteger:{name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isNegative:{name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},isNumeric:{name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},hasNumericValue:{name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},isPositive:{name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isPrime:{name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isZero:{name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},typeOf:{name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},numeric:{name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "BigNumber")','numeric("4", "Fraction)','numeric(4, "Fraction")','numeric(fraction(2, 5), "number)'],seealso:["number","fraction","bignumber","string","format"]}},nr="help",ir=W(nr,["typed","mathWithTransform","Help"],(e=>{var{typed:t,mathWithTransform:r,Help:n}=e;return t(nr,{any:function(e){var t,i=e;if("string"!=typeof e)for(t in r)if(Z(r,t)&&e===r[t]){i=t;break}var a=Y(rr,i);if(!a){var o="function"==typeof i?i.name:i;throw new Error('No documentation found on "'+o+'"')}return new n(a)}})})),ar="compile",or=W(ar,["typed","parse"],(e=>{var{typed:t,parse:r}=e;return t(ar,{string:function(e){return r(e).compile()},"Array | Matrix":function(e){return $t(e,(function(e){return r(e).compile()}))}})})),sr=W("simplifyUtil",["FunctionNode","OperatorNode","SymbolNode"],(e=>{var{FunctionNode:t,OperatorNode:r,SymbolNode:n}=e,i={add:!0,multiply:!0},a={add:!0,multiply:!0};function o(e,t){if(!R(e))return!1;var r=e.fn.toString();return t&&Z(t,r)&&Z(t[r],"associative")?t[r].associative:a[r]||!1}function s(e){var t,r=[];return o(e)?(t=e.op,function e(n){for(var i=0;i2&&o(t)){for(var a=t.args.pop();t.args.length>0;)a=r([t.args.pop(),a]);t.args=a.args}}},unflattenl:function e(t){if(t.args&&0!==t.args.length){for(var r=u(t),n=t.args.length,i=0;i2&&o(t)){for(var a=t.args.shift();t.args.length>0;)a=r([a,t.args.shift()]);t.args=a.args}}}}})),ur=W("simplifyCore",["equal","isZero","add","subtract","multiply","divide","pow","ConstantNode","OperatorNode","FunctionNode","ParenthesisNode"],(e=>{var{equal:t,isZero:r,add:n,subtract:i,multiply:a,divide:o,pow:s,ConstantNode:u,OperatorNode:c,FunctionNode:l,ParenthesisNode:f}=e,p=new u(0),m=new u(1);return function e(h){if(R(h)&&h.isUnary()){var d=e(h.args[0]);if("+"===h.op)return d;if("-"===h.op){if(R(d)){if(d.isUnary()&&"-"===d.op)return d.args[0];if(d.isBinary()&&"subtract"===d.fn)return new c("-","subtract",[d.args[1],d.args[0]])}return new c(h.op,h.fn,[d])}}else if(R(h)&&h.isBinary()){var y=e(h.args[0]),g=e(h.args[1]);if("+"===h.op){if(B(y)){if(r(y.value))return g;if(B(g))return new u(n(y.value,g.value))}return B(g)&&r(g.value)?y:R(g)&&g.isUnary()&&"-"===g.op?new c("-","subtract",[y,g.args[0]]):new c(h.op,h.fn,g?[y,g]:[y])}if("-"===h.op){if(B(y)&&g){if(B(g))return new u(i(y.value,g.value));if(r(y.value))return new c("-","unaryMinus",[g])}if("subtract"===h.fn)return B(g)&&r(g.value)?y:R(g)&&g.isUnary()&&"-"===g.op?e(new c("+","add",[y,g.args[0]])):new c(h.op,h.fn,[y,g])}else{if("*"===h.op){if(B(y)){if(r(y.value))return p;if(t(y.value,1))return g;if(B(g))return new u(a(y.value,g.value))}if(B(g)){if(r(g.value))return p;if(t(g.value,1))return y;if(R(y)&&y.isBinary()&&y.op===h.op){var v=y.args[0];if(B(v)){var x=new u(a(v.value,g.value));return new c(h.op,h.fn,[x,y.args[1]],h.implicit)}}return new c(h.op,h.fn,[g,y],h.implicit)}return new c(h.op,h.fn,[y,g],h.implicit)}if("/"===h.op){if(B(y)){if(r(y.value))return p;if(B(g)&&(t(g.value,1)||t(g.value,2)||t(g.value,4)))return new u(o(y.value,g.value))}return new c(h.op,h.fn,[y,g])}if("^"===h.op){if(B(g)){if(r(g.value))return m;if(t(g.value,1))return y;if(B(y))return new u(s(y.value,g.value));if(R(y)&&y.isBinary()&&"^"===y.op){var b=y.args[1];if(B(b))return new c(h.op,h.fn,[y.args[0],new u(a(b.value,g.value))])}}return new c(h.op,h.fn,[y,g])}}}else{if(F(h)){var w=e(h.content);return F(w)||P(w)||B(w)?w:new f(w)}if(z(h)){var N=h.args.map(e).map((function(e){return F(e)?e.content:e}));return new l(e(h.fn),N)}}return h}}));function cr(){throw new Error('No "bignumber" implementation available')}function lr(){throw new Error('No "fraction" implementation available')}function fr(){throw new Error('No "matrix" implementation available')}var pr=W("simplifyConstant",["typed","config","mathWithTransform","?fraction","?bignumber","ConstantNode","OperatorNode","FunctionNode","SymbolNode"],(e=>{var{typed:t,config:r,mathWithTransform:n,fraction:i,bignumber:a,ConstantNode:o,OperatorNode:u,FunctionNode:c,SymbolNode:l}=e,{isCommutative:f,isAssociative:p,allChildren:m,createMakeNodeFunction:h}=sr({FunctionNode:c,OperatorNode:u,SymbolNode:l});function d(e,t,r){try{return v(n[e].apply(null,t),r)}catch(i){return t=t.map((function(e){return s(e)?e.valueOf():e})),v(n[e].apply(null,t),r)}}var y=t({Fraction:function(e){var t,r=e.s*e.n;return t=r<0?new u("-","unaryMinus",[new o(-r)]):new o(r),1===e.d?t:new u("/","divide",[t,new o(e.d)])},number:function(e){return e<0?x(new o(-e)):new o(e)},BigNumber:function(e){return e<0?x(new o(-e)):new o(e)},Complex:function(e){throw new Error("Cannot convert Complex number to Node")}});function g(e,t){if(t&&!1!==t.exactFractions&&isFinite(e)&&i){var r=i(e),n=t&&"number"==typeof t.fractionsLimit?t.fractionsLimit:1/0;if(r.valueOf()===e&&r.nw(e,t)));if(!r.some(I))try{return d(e.name,r,t)}catch(e){}return r=r.map((function(e){return I(e)?e:y(e)})),new c(e.name,r)}case"OperatorNode":var i,a,o=e.fn.toString(),s=h(e);if(R(e)&&e.isUnary())a=I((i=[w(e.args[0],t)])[0])?s(i):d(o,i,t);else if(p(e))if(i=(i=m(e)).map((e=>w(e,t))),f(o)){for(var u=[],l=[],g=0;g1?(a=b(o,u,s,t),l.unshift(a),a=b(o,l,s,t)):a=b(o,i,s,t)}else a=b(o,i,s,t);else a=b(o,i=e.args.map((e=>w(e,t))),s,t);return a;case"ParenthesisNode":return w(e.content,t);case"AccessorNode":case"ArrayNode":case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"IndexNode":case"ObjectNode":case"RangeNode":case"ConditionalNode":default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(e.type))}}return function(e,t){var r=w(e,t);return I(r)?r:y(r)}})),mr=W("resolve",["parse","FunctionNode","OperatorNode","ParenthesisNode"],(e=>{var{parse:t,FunctionNode:r,OperatorNode:n,ParenthesisNode:i}=e;return function e(a,o){if(!o)return a;if(oe(o)||(o=ae(o)),P(a)){var s=o.get(a.name);if(I(s))return e(s,o);if("number"==typeof s)return t(String(s))}else{if(R(a)){var u=a.args.map((function(t){return e(t,o)}));return new n(a.op,a.fn,u,a.implicit)}if(F(a))return new i(e(a.content,o));if(z(a)){var c=a.args.map((function(t){return e(t,o)}));return new r(a.name,c)}}return a}})),hr=W("simplify",["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","?fraction","?bignumber","mathWithTransform","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{config:t,typed:r,parse:n,add:i,subtract:a,multiply:o,divide:s,pow:u,isZero:c,equal:l,fraction:f,bignumber:p,mathWithTransform:m,ConstantNode:h,FunctionNode:d,OperatorNode:y,ParenthesisNode:g,SymbolNode:v}=e,x=pr({typed:r,config:t,mathWithTransform:m,fraction:f,bignumber:p,ConstantNode:h,OperatorNode:y,FunctionNode:d,SymbolNode:v}),b=ur({equal:l,isZero:c,add:i,subtract:a,multiply:o,divide:s,pow:u,ConstantNode:h,OperatorNode:y,FunctionNode:d,ParenthesisNode:g}),w=mr({parse:n,FunctionNode:d,OperatorNode:y,ParenthesisNode:g}),{isCommutative:N,isAssociative:M,flatten:S,unflattenr:E,unflattenl:A,createMakeNodeFunction:O}=sr({FunctionNode:d,OperatorNode:y,SymbolNode:v}),C=r("simplify",{string:function(e){return this(n(e),this.rules,ie(),{})},"string, Map | Object":function(e,t){return this(n(e),this.rules,t,{})},"string, Map | Object, Object":function(e,t,r){return this(n(e),this.rules,t,r)},"string, Array":function(e,t){return this(n(e),t,ie(),{})},"string, Array, Map | Object":function(e,t,r){return this(n(e),t,r,{})},"string, Array, Map | Object, Object":function(e,t,r,i){return this(n(e),t,r,i)},"Node, Map | Object":function(e,t){return this(e,this.rules,t,{})},"Node, Map | Object, Object":function(e,t,r){return this(e,this.rules,t,r)},Node:function(e){return this(e,this.rules,ie(),{})},"Node, Array":function(e,t){return this(e,t,ie(),{})},"Node, Array, Map | Object":function(e,t,r){return this(e,t,r,{})},"Node, Array, Object, Object":function(e,t,r,n){return this(e,t,ae(r),n)},"Node, Array, Map, Object":function(e,t,r,i){t=function(e){for(var t=[],r=0;r");if(2!==s.length)throw SyntaxError("Could not parse rule: "+i);i={l:s[0],r:s[1]};case"object":if(a={l:_(n(i.l)),r:_(n(i.r))},i.context&&(a.evaluate=i.context),i.evaluate&&(a.evaluate=n(i.evaluate)),M(a.l)){var u=O(a.l),c=new v("_p"+q++);a.expanded={},a.expanded.l=u([a.l.clone(),c]),S(a.expanded.l),E(a.expanded.l),a.expanded.r=u([a.r,c])}break;case"function":a=i;break;default:throw TypeError("Unsupported type of rule: "+o)}t.push(a)}return t}(t);for(var a=w(e,r),o={},s=(a=_(a)).toString({parenthesis:"all"});!o[s];){o[s]=!0,q=0;for(var u=0;u=2&&2===e.args.length){for(var i=function(e,t){var r,n,i=[],a=O(e);if(N(e,t))for(var o=0;o2)throw Error("Unexpected non-binary associative function: "+e.toString());return[]}for(var u=[],c=0;c{var{config:t,typed:r,equal:n,isZero:i,add:a,subtract:o,multiply:s,divide:u,pow:c,parse:l,simplify:f,fraction:p,bignumber:m,mathWithTransform:h,ConstantNode:d,OperatorNode:y,FunctionNode:g,SymbolNode:v,ParenthesisNode:x}=e,b=pr({typed:r,config:t,mathWithTransform:h,fraction:p,bignumber:m,ConstantNode:d,OperatorNode:y,FunctionNode:g,SymbolNode:v}),w=ur({equal:n,isZero:i,add:a,subtract:o,multiply:s,divide:u,pow:c,ConstantNode:d,OperatorNode:y,FunctionNode:g,ParenthesisNode:x});return r(dr,{string:function(e){return this(l(e),{},!1)},"string, boolean":function(e,t){return this(l(e),{},t)},"string, Object":function(e,t){return this(l(e),t,!1)},"string, Object, boolean":function(e,t,r){return this(l(e),t,r)},Node:function(e){return this(e,{},!1)},"Node, boolean":function(e,t){return this(e,{},t)},"Node, Object":function(e,t){return this(e,t,!1)},"Node, Object, boolean":function(e,t,r){var n=function(){var e=[w,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},b,{l:"n*(n1^-1)",r:"n/n1"},{l:"n*n1^-n2",r:"n/n1^n2"},{l:"n1^-1",r:"1/n1"},{l:"n*(n1/n2)",r:"(n*n1)/n2"},{l:"1*n",r:"n"}],t=[{l:"(-n1)/(-n2)",r:"n1/n2"},{l:"(-n1)*(-n2)",r:"n1*n2"},{l:"n1--n2",r:"n1+n2"},{l:"n1-n2",r:"n1+(-n2)"},{l:"(n1+n2)*n3",r:"(n1*n3 + n2*n3)"},{l:"n1*(n2+n3)",r:"(n1*n2+n1*n3)"},{l:"c1*n + c2*n",r:"(c1+c2)*n"},{l:"c1*n + n",r:"(c1+1)*n"},{l:"c1*n - c2*n",r:"(c1-c2)*n"},{l:"c1*n - n",r:"(c1-1)*n"},{l:"v/c",r:"(1/c)*v"},{l:"v/-c",r:"-(1/c)*v"},{l:"-v*-c",r:"c*v"},{l:"-v*c",r:"-c*v"},{l:"v*-c",r:"-c*v"},{l:"v*c",r:"c*v"},{l:"-(-n1*n2)",r:"(n1*n2)"},{l:"-(n1*n2)",r:"(-n1*n2)"},{l:"-(-n1+n2)",r:"(n1-n2)"},{l:"-(n1+n2)",r:"(-n1-n2)"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"},{l:"-(-n1/n2)",r:"(n1/n2)"},{l:"-(n1/n2)",r:"(-n1/n2)"}],r=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],n={};return n.firstRules=e.concat(t,r),n.distrDivRules=[{l:"(n1/n2 + n3/n4)",r:"((n1*n4 + n3*n2)/(n2*n4))"},{l:"(n1/n2 + n3)",r:"((n1 + n3*n2)/n2)"},{l:"(n1 + n2/n3)",r:"((n1*n3 + n2)/n3)"}],n.sucDivRules=r,n.firstRulesAgain=e.concat(t),n.finalRules=[w,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},b,{l:"n*-n^n1",r:"-n^(n1+1)"},{l:"n*n^n1",r:"n^(n1+1)"},{l:"n^n1*-n^n2",r:"-n^(n1+n2)"},{l:"n^n1*n^n2",r:"n^(n1+n2)"},{l:"n^n1*-n",r:"-n^(n1+1)"},{l:"n^n1*n",r:"n^(n1+1)"},{l:"n^n1/-n",r:"-n^(n1-1)"},{l:"n^n1/n",r:"n^(n1-1)"},{l:"n/-n^n1",r:"-n^(1-n1)"},{l:"n/n^n1",r:"n^(1-n1)"},{l:"n^n1/-n^n2",r:"n^(n1-n2)"},{l:"n^n1/n^n2",r:"n^(n1-n2)"},{l:"n1+(-n2*n3)",r:"n1-n2*n3"},{l:"v*(-c)",r:"-c*v"},{l:"n1+-n2",r:"n1-n2"},{l:"v*c",r:"c*v"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"}],n}(),i=function(e,t,r,n){var i=[],a=f(e,n,t,{exactFractions:!1}),o="+-*"+((r=!!r)?"/":"");!function e(t){var r=t.type;if("FunctionNode"===r)throw new Error("There is an unsolved function call");if("OperatorNode"===r)if("^"===t.op){if("ConstantNode"!==t.args[1].type||!ce(parseFloat(t.args[1].value)))throw new Error("There is a non-integer exponent");e(t.args[0])}else{if(-1===o.indexOf(t.op))throw new Error("Operator "+t.op+" invalid in polynomial expression");for(var n=0;n=1){var o,s;e=N(e);var u,c=!0,l=!1;for(e=f(e,n.firstRules,{},{exactFractions:!1});s=c?n.distrDivRules:n.sucDivRules,c=!c,(u=(e=f(e,s)).toString())!==o;)l=!0,o=u;l&&(e=f(e,n.firstRulesAgain,{},{exactFractions:!1})),e=f(e,n.finalRules,{},{exactFractions:!1})}var p=[],m={};return"OperatorNode"===e.type&&e.isBinary()&&"/"===e.op?(1===a&&(e.args[0]=M(e.args[0],p),e.args[1]=M(e.args[1])),r&&(m.numerator=e.args[0],m.denominator=e.args[1])):(1===a&&(e=M(e,p)),r&&(m.numerator=e,m.denominator=null)),r?(m.coefficients=p,m.variables=i.variables,m.expression=e,m):e}});function N(e,t,r){var n=e.type,i=arguments.length>1;if("OperatorNode"===n&&e.isBinary()){var a,o=!1;if("^"===e.op&&("ParenthesisNode"!==e.args[0].type&&"OperatorNode"!==e.args[0].type||"ConstantNode"!==e.args[1].type||(o=(a=parseFloat(e.args[1].value))>=2&&ce(a))),o){if(a>2){var s=e.args[0],u=new y("^","pow",[e.args[0].cloneDeep(),new d(a-1)]);e=new y("*","multiply",[s,u])}else e=new y("*","multiply",[e.args[0],e.args[0].cloneDeep()]);i&&("content"===r?t.content=e:t.args[r]=e)}}if("ParenthesisNode"===n)N(e.content,e,"content");else if("ConstantNode"!==n&&"SymbolNode"!==n)for(var c=0;cr&&(t[c]=0),t[c]+=o.cte*("+"===o.oper?1:-1),void(r=Math.max(c,r))}o.cte=c,""===o.fire&&(t[0]+=o.cte*("+"===o.oper?1:-1))}}(e,null,{cte:1,oper:"+",fire:""});for(var i,a=!0,o=r=t.length-1;o>=0;o--)if(0!==t[o]){var s=new d(a?t[o]:Math.abs(t[o])),u=t[o]<0?"-":"+";if(o>0){var c=new v(n);if(o>1){var l=new d(o);c=new y("^","pow",[c,l])}s=-1===t[o]&&a?new y("-","unaryMinus",[c]):1===Math.abs(t[o])?c:new y("*","multiply",[s,c])}i=a?s:"+"===u?new y("+","add",[i,s]):new y("-","subtract",[i,s]),a=!1}return a?new d(0):i}})),gr="parser",vr=W(gr,["typed","Parser"],(e=>{var{typed:t,Parser:r}=e;return t(gr,{"":function(){return new r}})})),xr=W("derivative",["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:t,config:r,parse:n,simplify:i,equal:a,isZero:o,numeric:s,ConstantNode:u,FunctionNode:c,OperatorNode:l,ParenthesisNode:f,SymbolNode:p}=e,m=t("derivative",{"Node, SymbolNode, Object":function(e,t,r){var n={};d(n,e,t.name);var a=y(e,n);return r.simplify?i(a):a},"Node, SymbolNode":function(e,t){return this(e,t,{simplify:!0})},"string, SymbolNode":function(e,t){return this(n(e),t)},"string, SymbolNode, Object":function(e,t,r){return this(n(e),t,r)},"string, string":function(e,t){return this(n(e),n(t))},"string, string, Object":function(e,t,r){return this(n(e),n(t),r)},"Node, string":function(e,t){return this(e,n(t))},"Node, string, Object":function(e,t,r){return this(e,n(t),r)}});m._simplify=!0,m.toTex=function(e){return h.apply(null,e.args)};var h=t("_derivTex",{"Node, SymbolNode":function(e,t){return B(e)&&"string"===L(e.value)?h(n(e.value).toString(),t.toString(),1):h(e.toString(),t.toString(),1)},"Node, ConstantNode":function(e,t){if("string"===L(t.value))return h(e,n(t.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(e,t,r){return h(e.toString(),t.name,r.value)},"string, string, number":function(e,t,r){return(1===r?"{d\\over d"+t+"}":"{d^{"+r+"}\\over d"+t+"^{"+r+"}}")+"\\left[".concat(e,"\\right]")}}),d=t("constTag",{"Object, ConstantNode, string":function(e,t){return e[t]=!0,!0},"Object, SymbolNode, string":function(e,t,r){return t.name!==r&&(e[t]=!0,!0)},"Object, ParenthesisNode, string":function(e,t,r){return d(e,t.content,r)},"Object, FunctionAssignmentNode, string":function(e,t,r){return-1===t.params.indexOf(r)?(e[t]=!0,!0):d(e,t.expr,r)},"Object, FunctionNode | OperatorNode, string":function(e,t,r){if(t.args.length>0){for(var n=d(e,t.args[0],r),i=1;i0){var n=e.args.filter((function(e){return void 0===t[e]})),i=1===n.length?n[0]:new l("*","multiply",n),s=r.concat(y(i,t));return new l("*","multiply",s)}return new l("+","add",e.args.map((function(r){return new l("*","multiply",e.args.map((function(e){return e===r?y(e,t):e.clone()})))})))}if("/"===e.op&&e.isBinary()){var u=e.args[0],f=e.args[1];return void 0!==t[f]?new l("/","divide",[y(u,t),f]):void 0!==t[u]?new l("*","multiply",[new l("-","unaryMinus",[u]),new l("/","divide",[y(f,t),new l("^","pow",[f.clone(),g(2)])])]):new l("/","divide",[new l("-","subtract",[new l("*","multiply",[y(u,t),f.clone()]),new l("*","multiply",[u.clone(),y(f,t)])]),new l("^","pow",[f.clone(),g(2)])])}if("^"===e.op&&e.isBinary()){var p=e.args[0],m=e.args[1];if(void 0!==t[p])return B(p)&&(o(p.value)||a(p.value,1))?g(0):new l("*","multiply",[e,new l("*","multiply",[new c("log",[p.clone()]),y(m.clone(),t)])]);if(void 0!==t[m]){if(B(m)){if(o(m.value))return g(0);if(a(m.value,1))return y(p,t)}var h=new l("^","pow",[p.clone(),new l("-","subtract",[m,g(1)])]);return new l("*","multiply",[m.clone(),new l("*","multiply",[y(p,t),h])])}return new l("*","multiply",[new l("^","pow",[p.clone(),m.clone()]),new l("+","add",[new l("*","multiply",[y(p,t),new l("/","divide",[m.clone(),p.clone()])]),new l("*","multiply",[y(m,t),new c("log",[p.clone()])])])])}throw new Error('Operator "'+e.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function g(e,t){return new u(s(e,t||r.number))}return m})),br="apply",wr=W(br,["typed","isInteger"],(e=>{var{typed:t,isInteger:r}=e;return t(br,{"Array | Matrix, number | BigNumber, function":function(e,t,n){if(!r(t))throw new TypeError("Integer number expected for dimension");var i=Array.isArray(e)?je(e):e.size();if(t<0||t>=i.length)throw new Pe(t,i.length);return f(e)?e.create(Nr(e.valueOf(),t,n)):Nr(e,t,n)}})}));function Nr(e,t,r){var n,i,a;if(t<=0){if(Array.isArray(e[0])){for(a=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r{var{typed:t,isInteger:r}=e,n=wr({typed:t,isInteger:r});return t("apply",{"...any":function(e){var t=e[1];i(t)?e[1]=t-1:a(t)&&(e[1]=t.minus(1));try{return n.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0});function Sr(e){var t=0,r=1,n=Object.create(null),i=Object.create(null),a=0,o=function(e){var o=i[e];if(o&&(delete n[o],delete i[e],--t,r===o)){if(!t)return a=0,void(r=1);for(;!hasOwnProperty.call(n,++r););}};return e=Math.abs(e),{hit:function(s){var u=i[s],c=++a;if(n[c]=s,i[s]=c,!u){if(++t<=e)return;return s=n[r],o(s),s}if(delete n[u],r===u)for(;!hasOwnProperty.call(n,++r););},delete:o,clear:function(){t=a=0,r=1,n=Object.create(null),i=Object.create(null)}}}function Er(e){var{hasher:t,limit:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r=null==r?Number.POSITIVE_INFINITY:r,t=null==t?JSON.stringify:t,function n(){"object"!=typeof n.cache&&(n.cache={values:new Map,lru:Sr(r||Number.POSITIVE_INFINITY)});for(var i=[],a=0;a{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=P(e[1])||q(e[1])?e[1].compile().evaluate(r):Or(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("filter",{"Array, function":_r,"Matrix, function":function(e,t){return e.create(_r(e.toArray(),t))},"Array, RegExp":it,"Matrix, RegExp":function(e,t){return e.create(it(e.toArray(),t))}});return r}),{isTransformFunction:!0});function _r(e,t){var r=Ar(t);return nt(e,(function(e,n,i){return 1===r?t(e):2===r?t(e,[n+1]):t(e,[n+1],i)}))}var Tr=W("map",["typed"],(e=>{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=P(e[1])||q(e[1])?e[1].compile().evaluate(r):Or(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("map",{"Array, function":function(e,t){return Br(e,t,e)},"Matrix, function":function(e,t){return e.create(Br(e.valueOf(),t,e))}});return r}),{isTransformFunction:!0});function Br(e,t,r){var n=Ar(t);return function e(i,a){return Array.isArray(i)?tt(i,(function(t,r){return e(t,a.concat(r+1))})):1===n?t(i):2===n?t(i,a):t(i,a,r)}(e,[])}var qr=W("forEach",["typed"],(e=>{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=P(e[1])||q(e[1])?e[1].compile().evaluate(r):Or(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("forEach",{"Array | Matrix, function":function(e,t){var r=Ar(t);!function n(i,a){Array.isArray(i)?rt(i,(function(e,t){n(e,a.concat(t+1))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e.valueOf(),[])}});return r}),{isTransformFunction:!0}),zr="subset",Dr=W(zr,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t(zr,{"Array, Index":function(e,t){var n=r(e).subset(t);return t.isScalar()?n:n.valueOf()},"Matrix, Index":function(e,t){return e.subset(t)},"Object, Index":Rr,"string, Index":Ir,"Array, Index, any":function(e,t,n){return r($(e)).subset(t,n,void 0).valueOf()},"Array, Index, any, any":function(e,t,n,i){return r($(e)).subset(t,n,i).valueOf()},"Matrix, Index, any":function(e,t,r){return e.clone().subset(t,r)},"Matrix, Index, any, any":function(e,t,r,n){return e.clone().subset(t,r,n)},"string, Index, string":kr,"string, Index, string, string":kr,"Object, Index, any":Fr})}));function Ir(e,t){if(!y(t))throw new TypeError("Index expected");if(1!==t.size().length)throw new Ue(t.size().length,1);var r=e.length;$e(t.min()[0],r),$e(t.max()[0],r);var n=t.dimension(0),i="";return n.forEach((function(t){i+=e.charAt(t)})),i}function kr(e,t,r,n){if(!t||!0!==t.isIndex)throw new TypeError("Index expected");if(1!==t.size().length)throw new Ue(t.size().length,1);if(void 0!==n){if("string"!=typeof n||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";var i=t.dimension(0);if(i.size()[0]!==r.length)throw new Ue(i.size()[0],r.length);var a=e.length;$e(t.min()[0]),$e(t.max()[0]);for(var o=[],s=0;sa)for(var u=a-1,c=o.length;u{var{typed:t,matrix:r}=e,n=Dr({typed:t,matrix:r});return t("subset",{"...any":function(e){try{return n.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Pr=W("index",["Index"],(e=>{var{Index:t}=e;return function(){for(var e=[],r=0,n=arguments.length;r0?0:2;else if(o&&!0===o.isSet)o=o.map((function(e){return e-1}));else if(l(o)||f(o))o=o.map((function(e){return e-1}));else if(i(o))o--;else if(a(o))o=o.toNumber()-1;else if("string"!=typeof o)throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");e[r]=o}var s=new t;return t.apply(s,e),s}}),{isTransformFunction:!0}),jr="concat",Lr=W(jr,["typed","matrix","isInteger"],(e=>{var{typed:t,matrix:r,isInteger:n}=e;return t(jr,{"...Array | Matrix | number | BigNumber":function(e){var t,o,s=e.length,u=-1,c=!1,l=[];for(t=0;t0&&u>o)throw new Pe(u,o+1)}else{var m=$(p).valueOf(),h=je(m);if(l[t]=m,o=u,u=h.length-1,t>0&&u!==o)throw new Ue(o+1,u+1)}}if(0===l.length)throw new SyntaxError("At least one matrix expected");for(var d=l.shift();l.length;)d=Hr(d,l.shift(),u,0);return c?r(d):d},"...string":function(e){return e.join("")}})}));function Hr(e,t,r,n){if(n{var{typed:t,matrix:r,isInteger:n}=e,o=Lr({typed:t,matrix:r,isInteger:n});return t("concat",{"...any":function(e){var t=e.length-1,r=e[t];i(r)?e[t]=r-1:a(r)&&(e[t]=r.minus(1));try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0});function Gr(e,t,r){var n;return-1!==String(e).indexOf("Unexpected type")?(n=arguments.length>2?" (type: "+L(r)+", value: "+JSON.stringify(r)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+n)):-1!==String(e).indexOf("complex numbers")?(n=arguments.length>2?" (type: "+L(r)+", value: "+JSON.stringify(r)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+n)):e}var Vr=W("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:r,numeric:n,larger:i}=e;return t("max",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){return Gt(e,t.valueOf(),a)},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function max");return o(e)}});function a(e,t){try{return i(e,t)?e:t}catch(e){throw Gr(e,"max",t)}}function o(e){var t;if(Ht(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw Gr(t,"max",e)}})),void 0===t)throw new Error("Cannot calculate max of an empty array");return"string"==typeof t&&(t=n(t,r.number)),t}}));function Zr(e){if(2===e.length&&p(e[0])){var t=(e=e.slice())[1];i(t)?e[1]=t-1:a(t)&&(e[1]=t.minus(1))}return e}var Wr=W("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:r,numeric:n,larger:i}=e,a=Vr({typed:t,config:r,numeric:n,larger:i});return t("max",{"...any":function(e){e=Zr(e);try{return a.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Jr=W("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:r,numeric:n,smaller:i}=e;return t("min",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){return Gt(e,t.valueOf(),a)},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function min");return o(e)}});function a(e,t){try{return i(e,t)?e:t}catch(e){throw Gr(e,"min",t)}}function o(e){var t;if(Ht(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw Gr(t,"min",e)}})),void 0===t)throw new Error("Cannot calculate min of an empty array");return"string"==typeof t&&(t=n(t,r.number)),t}})),Yr=W("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:r,numeric:n,smaller:i}=e,a=Jr({typed:t,config:r,numeric:n,smaller:i});return t("min",{"...any":function(e){e=Zr(e);try{return a.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Xr=W("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:r,add:n,numeric:i}=e;return t("sum",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){try{return Gt(e,t,n)}catch(e){throw Gr(e,"sum")}},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function sum");return a(e)}});function a(e){var t;return Ht(e,(function(e){try{t=void 0===t?e:n(t,e)}catch(t){throw Gr(t,"sum",e)}})),void 0===t&&(t=i(0,r.number)),"string"==typeof t&&(t=i(t,r.number)),t}})),Qr=W("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:r,add:n,numeric:i}=e,a=Xr({typed:t,config:r,add:n,numeric:i});return t("sum",{"...any":function(e){e=Zr(e);try{return a.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Kr="column",en=W(Kr,["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e;return t(Kr,{"Matrix, number":a,"Array, number":function(e,t){return a(n($(e)),t).valueOf()}});function a(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");$e(t,e.size()[1]);var n=i(0,e.size()[0]),a=new r(n,t);return e.subset(a)}})),tn=W("column",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:a}=e,o=en({typed:t,Index:r,matrix:n,range:a});return t("column",{"...any":function(e){var t=e.length-1,r=e[t];i(r)&&(e[t]=r-1);try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),rn="range",nn=W(rn,["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u}=e;return t(rn,{string:l,"string, boolean":l,"number, number":function(e,t){return c(f(e,t,1))},"number, number, number":function(e,t,r){return c(f(e,t,r))},"number, number, boolean":function(e,t,r){return c(r?p(e,t,1):f(e,t,1))},"number, number, number, boolean":function(e,t,r,n){return c(n?p(e,t,r):f(e,t,r))},"BigNumber, BigNumber":function(e,t){return c(m(e,t,new(0,e.constructor)(1)))},"BigNumber, BigNumber, BigNumber":function(e,t,r){return c(m(e,t,r))},"BigNumber, BigNumber, boolean":function(e,t,r){var n=e.constructor;return c(r?h(e,t,new n(1)):m(e,t,new n(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,r,n){return c(n?h(e,t,r):m(e,t,r))}});function c(e){return"Matrix"===r.matrix?n?n(e):fr():e}function l(e,t){var n=function(e){var t=e.split(":").map((function(e){return Number(e)}));if(t.some((function(e){return isNaN(e)})))return null;switch(t.length){case 2:return{start:t[0],end:t[1],step:1};case 3:return{start:t[0],end:t[2],step:t[1]};default:return null}}(e);if(!n)throw new SyntaxError('String "'+e+'" is no valid range');return"BigNumber"===r.number?(void 0===i&&cr(),c((t?h:m)(i(n.start),i(n.end),i(n.step)))):c((t?p:f)(n.start,n.end,n.step))}function f(e,t,r){var n=[],i=e;if(r>0)for(;a(i,t);)n.push(i),i+=r;else if(r<0)for(;s(i,t);)n.push(i),i+=r;return n}function p(e,t,r){var n=[],i=e;if(r>0)for(;o(i,t);)n.push(i),i+=r;else if(r<0)for(;u(i,t);)n.push(i),i+=r;return n}function m(e,t,r){var n=i(0),o=[],u=e;if(r.gt(n))for(;a(u,t);)o.push(u),u=u.plus(r);else if(r.lt(n))for(;s(u,t);)o.push(u),u=u.plus(r);return o}function h(e,t,r){var n=i(0),a=[],s=e;if(r.gt(n))for(;o(s,t);)a.push(s),s=s.plus(r);else if(r.lt(n))for(;u(s,t);)a.push(s),s=s.plus(r);return a}})),an=W("range",["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u}=e,c=nn({typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u});return t("range",{"...any":function(e){return"boolean"!=typeof e[e.length-1]&&e.push(!0),c.apply(null,e)}})}),{isTransformFunction:!0}),on="diff",sn=W(on,["typed","matrix","subtract","number"],(e=>{var{typed:t,matrix:r,subtract:n,number:i}=e;return t(on,{"Array | Matrix":function(e){return f(e)?r(o(e.toArray())):o(e)},"Array | Matrix, number":function(e,t){if(!ce(t))throw new RangeError("Dimension must be a whole number");return f(e)?r(a(e.toArray(),t)):a(e,t)},"Array | Matrix, BigNumber":function(e,t){return this(e,i(t))}});function a(e,t){if(f(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError("Array/Matrix does not have that many dimensions");if(t>0){var r=[];return e.forEach((e=>{r.push(a(e,t-1))})),r}if(0===t)return o(e);throw RangeError("Cannot have negative dimension")}function o(e){var t=[],r=e.length;if(r<2)return e;for(var n=1;n{var{typed:t,matrix:r,subtract:n,number:i,bignumber:a}=e,o=sn({typed:t,matrix:r,subtract:n,number:i,bignumber:a});return t(un,{"...any":function(e){e=Zr(e);try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),ln=W("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e;return t("row",{"Matrix, number":a,"Array, number":function(e,t){return a(n($(e)),t).valueOf()}});function a(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");$e(t,e.size()[0]);var n=i(0,e.size()[1]),a=new r(t,n);return e.subset(a)}})),fn=W("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:a}=e,o=ln({typed:t,Index:r,matrix:n,range:a});return t("row",{"...any":function(e){var t=e.length-1,r=e[t];i(r)&&(e[t]=r-1);try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),pn="mean",mn=W(pn,["typed","add","divide"],(e=>{var{typed:t,add:r,divide:n}=e;return t(pn,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,t){try{var i=Gt(e,t,r),a=Array.isArray(e)?je(e):e.size();return n(i,a[t])}catch(e){throw Gr(e,"mean")}},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function mean");return i(e)}});function i(e){var t,i=0;if(Ht(e,(function(e){try{t=void 0===t?e:r(t,e),i++}catch(t){throw Gr(t,"mean",e)}})),0===i)throw new Error("Cannot calculate the mean of an empty array");return n(t,i)}})),hn=W("mean",["typed","add","divide"],(e=>{var{typed:t,add:r,divide:n}=e,i=mn({typed:t,add:r,divide:n});return t("mean",{"...any":function(e){e=Zr(e);try{return i.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),dn="unbiased",yn="variance",gn=W(yn,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:r,subtract:n,multiply:i,divide:o,apply:s,isNaN:u}=e;return t(yn,{"Array | Matrix":function(e){return c(e,dn)},"Array | Matrix, string":c,"Array | Matrix, number | BigNumber":function(e,t){return l(e,t,dn)},"Array | Matrix, number | BigNumber, string":l,"...":function(e){return c(e,dn)}});function c(e,t){var s,c=0;if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Ht(e,(function(e){try{s=void 0===s?e:r(s,e),c++}catch(t){throw Gr(t,"variance",e)}})),0===c)throw new Error("Cannot calculate variance of an empty array");var l=o(s,c);if(s=void 0,Ht(e,(function(e){var t=n(e,l);s=void 0===s?i(t,t):r(s,i(t,t))})),u(s))return s;switch(t){case"uncorrected":return o(s,c);case"biased":return o(s,c+1);case"unbiased":var f=a(s)?s.mul(0):0;return 1===c?f:o(s,c-1);default:throw new Error('Unknown normalization "'+t+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function l(e,t,r){try{if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return s(e,t,(e=>c(e,r)))}catch(e){throw Gr(e,"variance")}}})),vn="variance",xn=W(vn,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:r,subtract:n,multiply:i,divide:a,apply:o,isNaN:s}=e,u=gn({typed:t,add:r,subtract:n,multiply:i,divide:a,apply:o,isNaN:s});return t(vn,{"...any":function(e){e=Zr(e);try{return u.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),bn=W("std",["typed","sqrt","variance"],(e=>{var{typed:t,sqrt:r,variance:n}=e;return t("std",{"Array | Matrix":i,"Array | Matrix, string":i,"Array | Matrix, number | BigNumber":i,"Array | Matrix, number | BigNumber, string":i,"...":function(e){return i(e)}});function i(e,t){if(0===e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{return r(n.apply(null,arguments))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf(" variance")?new TypeError(e.message.replace(" variance"," std")):e}}})),wn=W("std",["typed","sqrt","variance"],(e=>{var{typed:t,sqrt:r,variance:n}=e,i=bn({typed:t,sqrt:r,variance:n});return t("std",{"...any":function(e){e=Zr(e);try{return i.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Nn=W("ResultSet",[],(()=>{function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=t||[]}return e.prototype.type="ResultSet",e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},e.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},e.fromJSON=function(t){return new e(t.entries)},e}),{isClass:!0}),Mn=r(977),Sn=W("Complex",[],(()=>(Mn.prototype.type="Complex",Mn.prototype.isComplex=!0,Mn.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Mn.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Mn.prototype.format=function(e){var t=this.im,r=this.re,n=ge(this.re,e),a=ge(this.im,e),o=i(e)?e:e?e.precision:null;if(null!==o){var s=Math.pow(10,-o);Math.abs(r/t)t.re?1:e.ret.im?1:e.im{function e(t,r,n){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var i=null!=t,o=null!=r,s=null!=n;if(i)if(a(t))t=t.toNumber();else if("number"!=typeof t)throw new TypeError("Parameter start must be a number");if(o)if(a(r))r=r.toNumber();else if("number"!=typeof r)throw new TypeError("Parameter end must be a number");if(s)if(a(n))n=n.toNumber();else if("number"!=typeof n)throw new TypeError("Parameter step must be a number");this.start=i?parseFloat(t):0,this.end=o?parseFloat(r):0,this.step=s?parseFloat(n):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(t){if("string"!=typeof t)return null;var r=t.split(":").map((function(e){return parseFloat(e)}));if(r.some((function(e){return isNaN(e)})))return null;switch(r.length){case 2:return new e(r[0],r[1]);case 3:return new e(r[0],r[2],r[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var e=0,t=this.start,r=this.step,n=this.end-t;return le(r)===le(n)?e=Math.ceil(n/r):0===n&&(e=0),isNaN(e)&&(e=0),[e]},e.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},e.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},e.prototype.forEach=function(e){var t=this.start,r=this.step,n=this.end,i=0;if(r>0)for(;tn;)e(t,[i],this),t+=r,i++},e.prototype.map=function(e){var t=[];return this.forEach((function(r,n,i){t[n[0]]=e(r,n,i)})),t},e.prototype.toArray=function(){var e=[];return this.forEach((function(t,r){e[r[0]]=t})),e},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(e){var t=ge(this.start,e);return 1!==this.step&&(t+=":"+ge(this.step,e)),t+":"+ge(this.end,e)},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},e.fromJSON=function(t){return new e(t.start,t.end,t.step)},e}),{isClass:!0}),An=Er((function(e){return new e(1).exp()}),{hasher:Tn}),On=Er((function(e){return new e(1).plus(new e(5).sqrt()).div(2)}),{hasher:Tn}),Cn=Er((function(e){return e.acos(-1)}),{hasher:Tn}),_n=Er((function(e){return Cn(e).times(2)}),{hasher:Tn});function Tn(e){return e[0].precision}var Bn=Math.PI,qn=2*Math.PI,zn=Math.E,Dn=W("true",[],(()=>!0)),In=W("false",[],(()=>!1)),kn=W("null",[],(()=>null)),Rn=Xn("Infinity",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1/0):1/0})),Fn=Xn("NaN",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(NaN):NaN})),Un=Xn("pi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?Cn(r):Bn})),Pn=Xn("tau",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?_n(r):qn})),jn=Xn("e",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?An(r):zn})),Ln=Xn("phi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?On(r):1.618033988749895})),Hn=Xn("LN2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(2).ln():Math.LN2})),$n=Xn("LN10",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(10).ln():Math.LN10})),Gn=Xn("LOG2E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1).div(new r(2).ln()):Math.LOG2E})),Vn=Xn("LOG10E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1).div(new r(10).ln()):Math.LOG10E})),Zn=Xn("SQRT1_2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r("0.5").sqrt():Math.SQRT1_2})),Wn=Xn("SQRT2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(2).sqrt():Math.SQRT2})),Jn=Xn("i",["Complex"],(e=>{var{Complex:t}=e;return t.I})),Yn=W("version",[],(()=>"9.4.1"));function Xn(e,t,r){return W(e,t,r,{recreateOnConfigChange:!0})}var Qn=r(776),Kn=W("BigNumber",["?on","config"],(e=>{var{on:t,config:r}=e,n=Qn.clone({precision:r.precision,modulo:9});return n.prototype.type="BigNumber",n.prototype.isBigNumber=!0,n.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},n.fromJSON=function(e){return new n(e.value)},t&&t("config",(function(e,t){e.precision!==t.precision&&n.config({precision:e.precision})})),n}),{isClass:!0}),ei=W("Matrix",[],(()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(e,t,r){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(e,t,r){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e}),{isClass:!0}),ti=W("replacer",[],(()=>function(e,t){return"number"!=typeof t||isFinite(t)&&!isNaN(t)?t:{mathjs:"number",value:String(t)}})),ri=Qi("speedOfLight","299792458","m s^-1"),ni=Qi("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),ii=Qi("planckConstant","6.62607015e-34","J s"),ai=Qi("reducedPlanckConstant","1.0545718176461565e-34","J s"),oi=Qi("magneticConstant","1.25663706212e-6","N A^-2"),si=Qi("electricConstant","8.8541878128e-12","F m^-1"),ui=Qi("vacuumImpedance","376.730313667","ohm"),ci=Qi("coulomb","8.987551792261171e9","N m^2 C^-2"),li=Qi("elementaryCharge","1.602176634e-19","C"),fi=Qi("bohrMagneton","9.2740100783e-24","J T^-1"),pi=Qi("conductanceQuantum","7.748091729863649e-5","S"),mi=Qi("inverseConductanceQuantum","12906.403729652257","ohm"),hi=Qi("magneticFluxQuantum","2.0678338484619295e-15","Wb"),di=Qi("nuclearMagneton","5.0507837461e-27","J T^-1"),yi=Qi("klitzing","25812.807459304513","ohm"),gi=Qi("bohrRadius","5.29177210903e-11","m"),vi=Qi("classicalElectronRadius","2.8179403262e-15","m"),xi=Qi("electronMass","9.1093837015e-31","kg"),bi=Qi("fermiCoupling","1.1663787e-5","GeV^-2"),wi=Ki("fineStructure",.0072973525693),Ni=Qi("hartreeEnergy","4.3597447222071e-18","J"),Mi=Qi("protonMass","1.67262192369e-27","kg"),Si=Qi("deuteronMass","3.3435830926e-27","kg"),Ei=Qi("neutronMass","1.6749271613e-27","kg"),Ai=Qi("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),Oi=Qi("rydberg","10973731.568160","m^-1"),Ci=Qi("thomsonCrossSection","6.6524587321e-29","m^2"),_i=Ki("weakMixingAngle",.2229),Ti=Ki("efimovFactor",22.7),Bi=Qi("atomicMass","1.66053906660e-27","kg"),qi=Qi("avogadro","6.02214076e23","mol^-1"),zi=Qi("boltzmann","1.380649e-23","J K^-1"),Di=Qi("faraday","96485.33212331001","C mol^-1"),Ii=Qi("firstRadiation","3.7417718521927573e-16","W m^2"),ki=Qi("loschmidt","2.686780111798444e25","m^-3"),Ri=Qi("gasConstant","8.31446261815324","J K^-1 mol^-1"),Fi=Qi("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),Ui=Qi("molarVolume","0.022413969545014137","m^3 mol^-1"),Pi=Ki("sackurTetrode",-1.16487052358),ji=Qi("secondRadiation","0.014387768775039337","m K"),Li=Qi("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),Hi=Qi("wienDisplacement","2.897771955e-3","m K"),$i=Qi("molarMass","0.99999999965e-3","kg mol^-1"),Gi=Qi("molarMassC12","11.9999999958e-3","kg mol^-1"),Vi=Qi("gravity","9.80665","m s^-2"),Zi=Qi("planckLength","1.616255e-35","m"),Wi=Qi("planckMass","2.176435e-8","kg"),Ji=Qi("planckTime","5.391245e-44","s"),Yi=Qi("planckCharge","1.87554603778e-18","C"),Xi=Qi("planckTemperature","1.416785e+32","K");function Qi(e,t,r){return W(e,["config","Unit","BigNumber"],(e=>{var{config:n,Unit:i,BigNumber:a}=e,o=new i("BigNumber"===n.number?new a(t):parseFloat(t),r);return o.fixPrefix=!0,o}))}function Ki(e,t){return W(e,["config","BigNumber"],(e=>{var{config:r,BigNumber:n}=e;return"BigNumber"===r.number?new n(t):t}))}var ea=r(628),ta=W("Fraction",[],(()=>(ea.prototype.type="Fraction",ea.prototype.isFraction=!0,ea.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},ea.fromJSON=function(e){return new ea(e)},ea)),{isClass:!0}),ra=W("DenseMatrix",["Matrix"],(e=>{var{Matrix:t}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!c(t))throw new Error("Invalid datatype: "+t);if(f(e))"DenseMatrix"===e.type?(this._data=$(e._data),this._size=$(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&l(e.data)&&l(e.size))this._data=e.data,this._size=e.size,He(this._data,this._size),this._datatype=t||e.datatype;else if(l(e))this._data=d(e),this._size=je(this._data),He(this._data,this._size),this._datatype=t;else{if(e)throw new TypeError("Unsupported type of data ("+L(e)+")");this._data=[],this._size=[0],this._datatype=t}}function n(e,t){if(!y(t))throw new TypeError("Invalid index");if(t.isScalar())return e.get(t.min());var n=t.size();if(n.length!==e._size.length)throw new Ue(n.length,e._size.length);for(var i=t.min(),a=t.max(),s=0,u=e._size.length;s");h(e,t.max().map((function(e){return e+1})),n);var l=a.length;u(e._data,t,r,l,0)}return e}function u(e,t,r,n,i){var a=i===n-1,o=t.dimension(i);a?o.forEach((function(t,n){$e(t),e[t]=r[n[0]]})):o.forEach((function(a,o){$e(a),u(e[a],t,r[o[0]],n,i+1)}))}function m(e,t,r){if(0===t.length){for(var n=e._data;l(n);)n=n[0];return n}return e._size=t.slice(0),e._data=Ge(e._data,e._size,r),e}function h(e,t,r){for(var n=e._size.slice(0),i=!1;n.lengthn[a]&&(n[a]=t[a],i=!0);i&&m(e,n,r)}function d(e){for(var t=0,r=e.length;tArray.isArray(e)&&1===e.length?e[0]:e));return m(r?this.clone():this,n,t)},r.prototype.reshape=function(e,t){var r=t?this.clone():this;r._data=Ze(r._data,e);var n=r._size.reduce(((e,t)=>e*t));return r._size=We(e,n),r},r.prototype.clone=function(){return new r({data:$(this._data),size:$(this._size),datatype:this._datatype})},r.prototype.size=function(){return this._size.slice(0)},r.prototype.map=function(e){var t=this,n=function r(n,i){return l(n)?n.map((function(e,t){return r(e,i.concat(t))})):e(n,i,t)}(this._data,[]);return new r(n,void 0!==this._datatype?ut(n,L):void 0)},r.prototype.forEach=function(e){var t=this;!function r(n,i){l(n)?n.forEach((function(e,t){r(e,i.concat(t))})):e(n,i,t)}(this._data,[])},r.prototype[Symbol.iterator]=function*(){yield*function*e(t,r){if(l(t))for(var n=0;n[e[n]]));t.push(new r(a,e._datatype))},o=0;o0?e:0,n=e<0?-e:0,o=this._size[0],s=this._size[1],u=Math.min(o-n,s-t),c=[],l=0;l0?n:0,c=n<0?-n:0,p=e[0],m=e[1],h=Math.min(p-c,m-u);if(l(t)){if(t.length!==h)throw new Error("Invalid value array length");s=function(e){return t[e]}}else if(f(t)){var d=t.size();if(1!==d.length||d[0]!==h)throw new Error("Invalid matrix length");s=function(e){return t.get([e])}}else s=function(){return t};o||(o=a(s(0))?s(0).mul(0):0);var y=[];if(e.length>0){y=Ge(y,e,o);for(var g=0;g15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new t(e)}},{from:"number",to:"Complex",convert:function(e){return r||sa(e),new r(e,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(e){return r||sa(e),new r(e.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(e){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(e){return r||sa(e),new r(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){p||ua(e);var t=new p(e);if(t.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return t}},{from:"string",to:"number",convert:function(e){var t=Number(e);if(isNaN(t))throw new Error('Cannot convert "'+e+'" to a number');return t}},{from:"string",to:"BigNumber",convert:function(e){t||oa(e);try{return new t(e)}catch(t){throw new Error('Cannot convert "'+e+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(e){p||ua(e);try{return new p(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(e){r||sa(e);try{return new r(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return t||oa(e),new t(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return p||ua(e),new p(+e)}},{from:"boolean",to:"string",convert:function(e){return String(e)}},{from:"Array",to:"Matrix",convert:function(e){return n||function(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}(),new n(e)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}],L}));function oa(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function sa(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function ua(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var ca="isInteger",la=W(ca,["typed"],(e=>{var{typed:t}=e;return t(ca,{number:ce,BigNumber:function(e){return e.isInt()},Fraction:function(e){return 1===e.d&&isFinite(e.n)},"Array | Matrix":function(e){return $t(e,this)}})})),fa="isNumeric",pa=W(fa,["typed"],(e=>{var{typed:t}=e;return t(fa,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(e){return $t(e,this)}})})),ma="number";function ha(e){return e<0}function da(e){return e>0}function ya(e){return 0===e}function ga(e){return Number.isNaN(e)}ha.signature=ma,da.signature=ma,ya.signature=ma,ga.signature=ma;var va="isPositive",xa=W(va,["typed"],(e=>{var{typed:t}=e;return t(va,{number:da,BigNumber:function(e){return!e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s>0&&e.n>0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),ba="isNaN",wa=W(ba,["typed"],(e=>{var{typed:t}=e;return t(ba,{number:ga,BigNumber:function(e){return e.isNaN()},Fraction:function(e){return!1},Complex:function(e){return e.isNaN()},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":function(e){return $t(e,Number.isNaN)}})}));function Na(e,t,r){if(null==r)return e.eq(t);if(e.eq(t))return!0;if(e.isNaN()||t.isNaN())return!1;if(e.isFinite()&&t.isFinite()){var n=e.minus(t).abs();if(n.isZero())return!0;var i=e.constructor.max(e.abs(),t.abs());return n.lte(i.times(r))}return!1}var Ma="equalScalar",Sa=W(Ma,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(Ma,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return e.equals(t)},"Complex, Complex":function(e,t){return function(e,t,r){return Se(e.re,t.re,r)&&Se(e.im,t.im,r)}(e,t,r.epsilon)},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)}})}));W(Ma,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(Ma,{"number, number":function(e,t){return Se(e,t,r.epsilon)}})}));var Ea=W("number",["typed"],(e=>{var{typed:t}=e,r=t("number",{"":function(){return 0},number:function(e){return e},string:function(e){if("NaN"===e)return NaN;var t,r,n=(r=(t=e).match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/))?{input:t,radix:{"0b":2,"0o":8,"0x":16}[r[1]],integerPart:r[2],fractionalPart:r[3]}:null;if(n)return function(e){for(var t=parseInt(e.integerPart,e.radix),r=0,n=0;n2**i-1)throw new SyntaxError('String "'.concat(e,'" is out of range'));o>=2**(i-1)&&(o-=2**i)}return o},BigNumber:function(e){return e.toNumber()},Fraction:function(e){return e.valueOf()},Unit:function(e){throw new Error("Second argument with valueless unit expected")},null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":function(e){return $t(e,this)}});return r.fromJSON=function(e){return parseFloat(e.value)},r})),Aa="boolean",Oa=W(Aa,["typed"],(e=>{var{typed:t}=e;return t(Aa,{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(e){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;var r=Number(e);if(""!==e&&!isNaN(r))return!!r;throw new Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":function(e){return $t(e,this)}})})),Ca=W("complex",["typed","Complex"],(e=>{var{typed:t,Complex:r}=e;return t("complex",{"":function(){return r.ZERO},number:function(e){return new r(e,0)},"number, number":function(e,t){return new r(e,t)},"BigNumber, BigNumber":function(e,t){return new r(e.toNumber(),t.toNumber())},Fraction:function(e){return new r(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return r(e)},null:function(e){return r(0)},Object:function(e){if("re"in e&&"im"in e)return new r(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new r(e);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(e){return $t(e,this)}})})),_a="splitUnit",Ta=W(_a,["typed"],(e=>{var{typed:t}=e;return t(_a,{"Unit, Array":function(e,t){return e.splitUnit(t)}})})),Ba="number",qa="number, number";function za(e){return Math.abs(e)}function Da(e,t){return e+t}function Ia(e,t){return e*t}function ka(e){return-e}function Ra(e){return e}function Fa(e){return he(e)}function Ua(e){return Math.ceil(e)}function Pa(e){return e*e*e}function ja(e){return Math.exp(e)}function La(e){return de(e)}function Ha(e,t){if(!ce(e)||!ce(t))throw new Error("Parameters in function gcd must be integer numbers");for(var r;0!==t;)r=e%t,e=t,t=r;return e<0?-e:e}function $a(e,t){if(!ce(e)||!ce(t))throw new Error("Parameters in function lcm must be integer numbers");if(0===e||0===t)return 0;for(var r,n=e*t;0!==t;)t=e%(r=t),e=r;return Math.abs(n/e)}function Ga(e){return Math.log(e)}function Va(e){return pe(e)}function Za(e){return fe(e)}function Wa(e,t){if(t>0)return e-t*Math.floor(e/t);if(0===t)return e;throw new Error("Cannot calculate mod for a negative divisor")}function Ja(e,t){var r=t<0;if(r&&(t=-t),0===t)throw new Error("Root must be non-zero");if(e<0&&Math.abs(t)%2!=1)throw new Error("Root must be odd when a is negative.");if(0===e)return r?1/0:0;if(!isFinite(e))return r?0:e;var n=Math.pow(Math.abs(e),1/t);return n=e<0?-n:n,r?1/n:n}function Ya(e){return le(e)}function Xa(e){return e*e}function Qa(e,t){var r,n,i,a=0,o=1,s=1,u=0;if(!ce(e)||!ce(t))throw new Error("Parameters in function xgcd must be integer numbers");for(;t;)i=e-(n=Math.floor(e/t))*t,r=a,a=o-n*a,o=r,r=s,s=u-n*s,u=r,e=t,t=i;return e<0?[-e,-o,-u]:[e,e?o:0,u]}function Ka(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:Math.pow(e,t)}function eo(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return parseFloat(xe(e,t))}za.signature=Ba,Da.signature=qa,Ia.signature=qa,ka.signature=Ba,Ra.signature=Ba,Fa.signature=Ba,Ua.signature=Ba,Pa.signature=Ba,ja.signature=Ba,La.signature=Ba,Ha.signature=qa,$a.signature=qa,Ga.signature=Ba,Va.signature=Ba,Za.signature=Ba,Wa.signature=qa,Ja.signature=qa,Ya.signature=Ba,Xa.signature=Ba,Qa.signature=qa,Ka.signature=qa,eo.signature=qa;var to="unaryPlus",ro=W(to,["typed","config","BigNumber"],(e=>{var{typed:t,config:r,BigNumber:n}=e;return t(to,{number:Ra,Complex:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":function(e){return $t(e,this,!0)},"boolean | string":function(e){return"BigNumber"===r.number?new n(+e):+e}})})),no="cube",io=W(no,["typed"],(e=>{var{typed:t}=e;return t(no,{number:Pa,Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},Fraction:function(e){return e.pow(3)},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.pow(3)}})})),ao="expm1",oo=W(ao,["typed","Complex"],(e=>{var{typed:t,Complex:r}=e;return t(ao,{number:La,Complex:function(e){var t=Math.exp(e.re);return new r(t*Math.cos(e.im)-1,t*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)},"Array | Matrix":function(e){return $t(e,this)}})})),so="log10",uo=W(so,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(so,{number:function(e){return e>=0||r.predictable?Va(e):new n(e,0).log().div(Math.LN10)},Complex:function(e){return new n(e).log().div(Math.LN10)},BigNumber:function(e){return!e.isNegative()||r.predictable?e.log():new n(e.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(e){return $t(e,this)}})})),co=W("multiplyScalar",["typed"],(e=>{var{typed:t}=e;return t("multiplyScalar",{"number, number":Ia,"Complex, Complex":function(e,t){return e.mul(t)},"BigNumber, BigNumber":function(e,t){return e.times(t)},"Fraction, Fraction":function(e,t){return e.mul(t)},"number | Fraction | BigNumber | Complex, Unit":function(e,t){var r=t.clone();return r.value=null===r.value?r._normalize(e):this(r.value,e),r},"Unit, number | Fraction | BigNumber | Complex":function(e,t){var r=e.clone();return r.value=null===r.value?r._normalize(t):this(r.value,t),r},"Unit, Unit":function(e,t){return e.multiply(t)}})})),lo="sign",fo=W(lo,["typed","BigNumber","Fraction","complex"],(e=>{var{typed:t,BigNumber:r,complex:n,Fraction:i}=e;return t(lo,{number:Ya,Complex:function(e){return 0===e.im?n(Ya(e.re)):e.sign()},BigNumber:function(e){return new r(e.cmp(0))},Fraction:function(e){return new i(e.s,1)},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return this(e.value)}})})),po="square",mo=W(po,["typed"],(e=>{var{typed:t}=e;return t(po,{number:Xa,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},Fraction:function(e){return e.mul(e)},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.pow(2)}})}));function ho(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitAnd");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero()||t.eq(-1)||e.eq(t))return e;if(t.isZero()||e.eq(-1))return t;if(!e.isFinite()||!t.isFinite()){if(!e.isFinite()&&!t.isFinite())return e.isNegative()===t.isNegative()?e:new r(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new r(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new r(0):e}return vo(e,t,(function(e,t){return e&t}))}function yo(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var t=e.constructor,r=t.precision;t.config({precision:1e9});var n=e.plus(new t(1));return n.s=-n.s||null,t.config({precision:r}),n}function go(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitOr");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);var n=new r(-1);return e.isZero()||t.eq(n)||e.eq(t)?t:t.isZero()||e.eq(n)?e:e.isFinite()&&t.isFinite()?vo(e,t,(function(e,t){return e|t})):!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?n:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e}function vo(e,t,r){var n,i,a,o,s,u=e.constructor,c=+(e.s<0),l=+(t.s<0);if(c){n=xo(yo(e));for(var f=0;f0;)r(a[--m],o[--h])===d&&(y=y.plus(g)),g=g.times(v);for(;h>0;)r(s,o[--h])===d&&(y=y.plus(g)),g=g.times(v);return u.config({precision:x}),0===d&&(y.s=-y.s),y}function xo(e){for(var t=e.d,r=t[0]+"",n=1;n0)if(++s>c)for(s-=c;s--;)u+="0";else s1&&(null!==l[m+1]&&void 0!==l[m+1]||(l[m+1]=0),l[m+1]+=l[m]>>1,l[m]&=1)}return l.reverse()}function bo(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new r(0);var n=new r(-1);return e.eq(n)?yo(t):t.eq(n)?yo(e):e.isFinite()&&t.isFinite()?vo(e,t,(function(e,t){return e^t})):e.isFinite()||t.isFinite()?new r(e.isNegative()===t.isNegative()?1/0:-1/0):n}function wo(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:e.isFinite()||t.isFinite()?t.lt(55)?e.times(Math.pow(2,t.toNumber())+""):e.times(new r(2).pow(t)):new r(NaN)}function No(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(Math.pow(2,t.toNumber())+"").floor():e.div(new r(2).pow(t)).floor():e.isNegative()?new r(-1):e.isFinite()?new r(0):new r(NaN)}var Mo="number, number";function So(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function bitAnd");return e&t}function Eo(e){if(!ce(e))throw new Error("Integer expected in function bitNot");return~e}function Ao(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function bitOr");return e|t}function Oo(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function bitXor");return e^t}function Co(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function leftShift");return e<>t}function To(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}So.signature=Mo,Eo.signature="number",Ao.signature=Mo,Oo.signature=Mo,Co.signature=Mo,_o.signature=Mo,To.signature=Mo;var Bo="bitNot",qo=W(Bo,["typed"],(e=>{var{typed:t}=e;return t(Bo,{number:Eo,BigNumber:yo,"Array | Matrix":function(e){return $t(e,this)}})})),zo=W("arg",["typed"],(e=>{var{typed:t}=e;return t("arg",{number:function(e){return Math.atan2(0,e)},BigNumber:function(e){return e.constructor.atan2(0,e)},Complex:function(e){return e.arg()},"Array | Matrix":function(e){return $t(e,this)}})})),Do=W("im",["typed"],(e=>{var{typed:t}=e;return t("im",{number:function(e){return 0},BigNumber:function(e){return e.mul(0)},Fraction:function(e){return e.mul(0)},Complex:function(e){return e.im},"Array | Matrix":function(e){return $t(e,this)}})})),Io="number, number";function ko(e){return!e}function Ro(e,t){return!(!e&&!t)}function Fo(e,t){return!!e!=!!t}function Uo(e,t){return!(!e||!t)}ko.signature="number",Ro.signature=Io,Fo.signature=Io,Uo.signature=Io;var Po=W("not",["typed"],(e=>{var{typed:t}=e;return t("not",{number:ko,Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},Unit:function(e){return null===e.value||this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),jo=W("filter",["typed"],(e=>{var{typed:t}=e;return t("filter",{"Array, function":Lo,"Matrix, function":function(e,t){return e.create(Lo(e.toArray(),t))},"Array, RegExp":it,"Matrix, RegExp":function(e,t){return e.create(it(e.toArray(),t))}})}));function Lo(e,t){var r=Ar(t);return nt(e,(function(e,n,i){return 1===r?t(e):2===r?t(e,[n]):t(e,[n],i)}))}var Ho="forEach",$o=W(Ho,["typed"],(e=>{var{typed:t}=e;return t(Ho,{"Array, function":Go,"Matrix, function":function(e,t){return e.forEach(t)}})}));function Go(e,t){var r=Ar(t);!function n(i,a){Array.isArray(i)?rt(i,(function(e,t){n(e,a.concat(t))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e,[])}var Vo=W("map",["typed"],(e=>{var{typed:t}=e;return t("map",{"Array, function":Zo,"Matrix, function":function(e,t){return e.map(t)}})}));function Zo(e,t){var r=Ar(t);return function n(i,a){return Array.isArray(i)?i.map((function(e,t){return n(e,a.concat(t))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e,[])}var Wo=W("erf",["typed"],(e=>{var{typed:t}=e;return t("name",{number:function(e){var t=Math.abs(e);return t>=Ko?le(e):t<=Jo?le(e)*function(e){var t,r=e*e,n=Xo[0][4]*r,i=r;for(t=0;t<3;t+=1)n=(n+Xo[0][t])*r,i=(i+Qo[0][t])*r;return e*(n+Xo[0][3])/(i+Qo[0][3])}(t):t<=4?le(e)*(1-function(e){var t,r=Xo[1][8]*e,n=e;for(t=0;t<7;t+=1)r=(r+Xo[1][t])*e,n=(n+Qo[1][t])*e;var i=(r+Xo[1][7])/(n+Qo[1][7]),a=parseInt(16*e)/16,o=(e-a)*(e+a);return Math.exp(-a*a)*Math.exp(-o)*i}(t)):le(e)*(1-function(e){var t,r=1/(e*e),n=Xo[2][5]*r,i=r;for(t=0;t<4;t+=1)n=(n+Xo[2][t])*r,i=(i+Qo[2][t])*r;var a=r*(n+Xo[2][4])/(i+Qo[2][4]);a=(Yo-a)/e;var o=(e-(r=parseInt(16*e)/16))*(e+r);return Math.exp(-r*r)*Math.exp(-o)*a}(t))},"Array | Matrix":function(e){return $t(e,this)}})})),Jo=.46875,Yo=.5641895835477563,Xo=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],Qo=[[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]],Ko=Math.pow(2,53),es="format",ts=W(es,["typed"],(e=>{var{typed:t}=e;return t(es,{any:De,"any, Object | function | number":De})})),rs=W("oct",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("oct",{"number | BigNumber":function(e){return r(e,{notation:"oct"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"oct",wordSize:t})}})})),ns="print",is=W(ns,["typed"],(e=>{var{typed:t}=e;return t(ns,{"string, Object | Array":as,"string, Object | Array, number | Object":as})}));function as(e,t,r){return e.replace(/\$([\w.]+)/g,(function(e,n){for(var i=n.split("."),a=t[i.shift()];i.length&&void 0!==a;){var o=i.shift();a=o?a[o]:a+"."}return void 0!==a?c(a)?a:De(a,r):e}))}var os="isPrime",ss=W(os,["typed"],(e=>{var{typed:t}=e;return t(os,{number:function(e){if(0*e!=0)return!1;if(e<=3)return e>1;if(e%2==0||e%3==0)return!1;for(var t=5;t*t<=e;t+=6)if(e%t==0||e%(t+2)==0)return!1;return!0},BigNumber:function(e){if(0*e.toNumber()!=0)return!1;if(e.lte(3))return e.gt(1);if(e.mod(2).eq(0)||e.mod(3).eq(0))return!1;if(e.lt(Math.pow(2,32))){for(var t=e.toNumber(),r=5;r*r<=t;r+=6)if(t%r==0||t%(r+2)==0)return!1;return!0}function n(e,t,r){for(var n=1;!t.eq(0);)t.mod(2).eq(0)?(t=t.div(2),e=e.mul(e).mod(r)):(t=t.sub(1),n=e.mul(n).mod(r));return n}for(var i=e.constructor.clone({precision:2*e.toFixed(0).length}),a=0,o=(e=new i(e)).sub(1);o.mod(2).eq(0);)o=o.div(2),a+=1;var s=null;if(e.lt("3317044064679887385961981"))s=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter((t=>t{var{typed:t,config:r,Complex:n}=e;return t(us,{number:function(e){return e>=-1&&e<=1||r.predictable?Math.acos(e):new n(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()},"Array | Matrix":function(e){return $t(e,this)}})})),ls="number";function fs(e){return Ee(e)}function ps(e){return Math.atan(1/e)}function ms(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}function hs(e){return Math.asin(1/e)}function ds(e){var t=1/e;return Math.log(t+Math.sqrt(t*t+1))}function ys(e){return Math.acos(1/e)}function gs(e){var t=1/e,r=Math.sqrt(t*t-1);return Math.log(r+t)}function vs(e){return Ae(e)}function xs(e){return Oe(e)}function bs(e){return 1/Math.tan(e)}function ws(e){var t=Math.exp(2*e);return(t+1)/(t-1)}function Ns(e){return 1/Math.sin(e)}function Ms(e){return 0===e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*le(e)}function Ss(e){return 1/Math.cos(e)}function Es(e){return 2/(Math.exp(e)+Math.exp(-e))}function As(e){return _e(e)}fs.signature=ls,ps.signature=ls,ms.signature=ls,hs.signature=ls,ds.signature=ls,ys.signature=ls,gs.signature=ls,vs.signature=ls,xs.signature=ls,bs.signature=ls,ws.signature=ls,Ns.signature=ls,Ms.signature=ls,Ss.signature=ls,Es.signature=ls,As.signature=ls;var Os="acot",Cs=W(Os,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Os,{number:ps,Complex:function(e){return e.acot()},BigNumber:function(e){return new r(1).div(e).atan()},"Array | Matrix":function(e){return $t(e,this)}})})),_s="acsc",Ts=W(_s,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(_s,{number:function(e){return e<=-1||e>=1||r.predictable?hs(e):new n(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new i(1).div(e).asin()},"Array | Matrix":function(e){return $t(e,this)}})})),Bs="asec",qs=W(Bs,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(Bs,{number:function(e){return e<=-1||e>=1||r.predictable?ys(e):new n(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new i(1).div(e).acos()},"Array | Matrix":function(e){return $t(e,this)}})})),zs="asin",Ds=W(zs,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(zs,{number:function(e){return e>=-1&&e<=1||r.predictable?Math.asin(e):new n(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Is=W("atan",["typed"],(e=>{var{typed:t}=e;return t("atan",{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),ks="atanh",Rs=W(ks,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(ks,{number:function(e){return e<=1&&e>=-1||r.predictable?xs(e):new n(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Fs="cosh",Us=W(Fs,["typed"],(e=>{var{typed:t}=e;return t(Fs,{number:Ce,Complex:function(e){return e.cosh()},BigNumber:function(e){return e.cosh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Ps="coth",js=W(Ps,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Ps,{number:ws,Complex:function(e){return e.coth()},BigNumber:function(e){return new r(1).div(e.tanh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Ls="csch",Hs=W(Ls,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Ls,{number:Ms,Complex:function(e){return e.csch()},BigNumber:function(e){return new r(1).div(e.sinh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),$s="sech",Gs=W($s,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t($s,{number:Es,Complex:function(e){return e.sech()},BigNumber:function(e){return new r(1).div(e.cosh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Vs="sinh",Zs=W(Vs,["typed"],(e=>{var{typed:t}=e;return t(Vs,{number:As,Complex:function(e){return e.sinh()},BigNumber:function(e){return e.sinh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Ws=W("tanh",["typed"],(e=>{var{typed:t}=e;return t("tanh",{number:Te,Complex:function(e){return e.tanh()},BigNumber:function(e){return e.tanh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})}));function Js(e,t){if(t>1;return Js(e,r)*Js(r+1,t)}function Ys(e,t){if(!ce(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!ce(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(t>e)throw new TypeError("k must be less than or equal to n");var r=e-t;return t{var{typed:t}=e;return t(Xs,{"number, number":Ys,"BigNumber, BigNumber":function(e,t){var r,n,i=e.constructor,a=e.minus(t),o=new i(1);if(!Ks(e)||!Ks(t))throw new TypeError("Positive integer value expected in function combinations");if(t.gt(e))throw new TypeError("k must be less than n in function combinations");if(r=o,t.lt(a))for(n=o;n.lte(a);n=n.plus(o))r=r.times(t.plus(n)).dividedBy(n);else for(n=o;n.lte(t);n=n.plus(o))r=r.times(a.plus(n)).dividedBy(n);return r}})}));function Ks(e){return e.isInteger()&&e.gte(0)}var eu=r(377),tu=eu(Date.now());function ru(e){var t,r;return t=null===(r=e)?tu:eu(String(r)),function(){return t()}}var nu="pickRandom",iu=W(nu,["typed","config","?on"],(e=>{var{typed:t,config:r,on:n}=e,a=ru(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(a=ru(e.randomSeed))})),t(nu,{"Array | Matrix":function(e){return o(e,{})},"Array | Matrix, Object":function(e,t){return o(e,t)},"Array | Matrix, number":function(e,t){return o(e,{number:t})},"Array | Matrix, Array | Matrix":function(e,t){return o(e,{weights:t})},"Array | Matrix, Array | Matrix, number":function(e,t,r){return o(e,{number:r,weights:t})},"Array | Matrix, number, Array | Matrix":function(e,t,r){return o(e,{number:t,weights:r})}});function o(e,t){var{number:r,weights:n,elementWise:o=!0}=t,s=void 0===r;s&&(r=1);var u=f(e)?e.create:f(n)?n.create:null;e=e.valueOf(),n&&(n=n.valueOf()),!0===o&&(e=et(e),n=et(n));var c=0;if(void 0!==n){if(n.length!==e.length)throw new Error("Weights must have the same length as possibles");for(var l=0,p=n.length;l1)for(var n=0,i=e.shift();n{var{typed:t,config:r,on:n}=e,i=ru(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(i=ru(e.randomSeed))})),t(ou,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,t)=>o(e,t),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,t)=>a(e,0,t),"Array | Matrix, number, number":(e,t,r)=>a(e,t,r)});function a(e,t,r){var n=au(e.valueOf(),(()=>o(t,r)));return f(e)?e.create(n):n}function o(e,t){return Math.floor(e+i()*(t-e))}})),uu="clone",cu=W(uu,["typed"],(e=>{var{typed:t}=e;return t(uu,{any:$})})),lu="hasNumericValue",fu=W(lu,["typed","isNumeric"],(e=>{var{typed:t,isNumeric:r}=e;return t(lu,{string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return r(e)}})})),pu="typeOf",mu=W(pu,["typed"],(e=>{var{typed:t}=e;return t(pu,{any:L})})),hu="string",du=W(hu,["typed"],(e=>{var{typed:t}=e;return t(hu,{"":function(){return""},number:ge,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":function(e){return $t(e,this)},any:function(e){return String(e)}})})),yu=W("fraction",["typed","Fraction"],(e=>{var{typed:t,Fraction:r}=e;return t("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw new Error(e+" cannot be represented as a fraction");return new r(e)},string:function(e){return new r(e)},"number, number":function(e,t){return new r(e,t)},null:function(e){return new r(0)},BigNumber:function(e){return new r(e.toString())},Fraction:function(e){return e},Object:function(e){return new r(e)},"Array | Matrix":function(e){return $t(e,this)}})})),gu="unaryMinus",vu=W(gu,["typed"],(e=>{var{typed:t}=e;return t(gu,{number:ka,Complex:function(e){return e.neg()},BigNumber:function(e){return e.neg()},Fraction:function(e){return e.neg()},Unit:function(e){var t=e.clone();return t.value=this(e.value),t},"Array | Matrix":function(e){return $t(e,this,!0)}})})),xu="addScalar",bu=W(xu,["typed"],(e=>{var{typed:t}=e;return t(xu,{"number, number":Da,"Complex, Complex":function(e,t){return e.add(t)},"BigNumber, BigNumber":function(e,t){return e.plus(t)},"Fraction, Fraction":function(e,t){return e.add(t)},"Unit, Unit":function(e,t){if(null===e.value||void 0===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value||void 0===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var r=e.clone();return r.value=this(r.value,t.value),r.fixPrefix=!1,r}})})),wu=W("exp",["typed"],(e=>{var{typed:t}=e;return t("exp",{number:ja,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()},"Array | Matrix":function(e){return $t(e,this)}})})),Nu="log2",Mu=W(Nu,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(Nu,{number:function(e){return e>=0||r.predictable?Za(e):i(new n(e,0))},Complex:i,BigNumber:function(e){return!e.isNegative()||r.predictable?e.log(2):i(new n(e.toNumber(),0))},"Array | Matrix":function(e){return $t(e,this)}});function i(e){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new n(Math.log2?Math.log2(t):Math.log(t)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}})),Su=W("sqrt",["config","typed","Complex"],(e=>{var{config:t,typed:r,Complex:n}=e;return r("sqrt",{number:i,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.sqrt():i(e.toNumber())},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.pow(.5)}});function i(e){return isNaN(e)?NaN:e>=0||t.predictable?Math.sqrt(e):new n(e,0).sqrt()}})),Eu="conj",Au=W(Eu,["typed"],(e=>{var{typed:t}=e;return t(Eu,{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.conjugate()},"Array | Matrix":function(e){return $t(e,this)}})})),Ou="getMatrixDataType",Cu=W(Ou,["typed"],(e=>{var{typed:t}=e;return t(Ou,{Array:function(e){return ut(e,L)},Matrix:function(e){return e.getDataType()}})})),_u="mode",Tu=W(_u,["typed","isNaN","isNumeric"],(e=>{var{typed:t,isNaN:r,isNumeric:n}=e;return t(_u,{"Array | Matrix":i,"...":function(e){return i(e)}});function i(e){if(0===(e=et(e.valueOf())).length)throw new Error("Cannot calculate mode of an empty array");for(var t={},i=[],a=0,o=0;oa&&(a=t[s],i=[s])}return i}})),Bu=W("bin",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("bin",{"number | BigNumber":function(e){return r(e,{notation:"bin"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"bin",wordSize:t})}})})),qu="acosh",zu=W(qu,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(qu,{number:function(e){return e>=1||r.predictable?fs(e):e<=-1?new n(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new n(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()},"Array | Matrix":function(e){return $t(e,this)}})})),Du="acsch",Iu=W(Du,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Du,{number:ds,Complex:function(e){return e.acsch()},BigNumber:function(e){return new r(1).div(e).asinh()},"Array | Matrix":function(e){return $t(e,this)}})})),ku=W("asinh",["typed"],(e=>{var{typed:t}=e;return t("asinh",{number:vs,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Ru=W("cos",["typed"],(e=>{var{typed:t}=e;return t("cos",{number:Math.cos,Complex:function(e){return e.cos()},BigNumber:function(e){return e.cos()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Fu=W("csc",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("csc",{number:Ns,Complex:function(e){return e.csc()},BigNumber:function(e){return new r(1).div(e.sin())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Uu=W("sin",["typed"],(e=>{var{typed:t}=e;return t("sin",{number:Math.sin,Complex:function(e){return e.sin()},BigNumber:function(e){return e.sin()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Pu="combinationsWithRep",ju=W(Pu,["typed"],(e=>{var{typed:t}=e;return t(Pu,{"number, number":function(e,t){if(!ce(e)||e<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!ce(t)||t<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e<1)throw new TypeError("k must be less than or equal to n + k - 1");return t{var{typed:t,config:r,on:n}=e,i=ru(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(i=ru(e.randomSeed))})),t(Hu,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,t)=>o(e,t),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,t)=>a(e,0,t),"Array | Matrix, number, number":(e,t,r)=>a(e,t,r)});function a(e,t,r){var n=au(e.valueOf(),(()=>o(t,r)));return f(e)?e.create(n):n}function o(e,t){return e+i()*(t-e)}})),Gu="isNegative",Vu=W(Gu,["typed"],(e=>{var{typed:t}=e;return t(Gu,{number:ha,BigNumber:function(e){return e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s<0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Zu=W("SparseMatrix",["typed","equalScalar","Matrix"],(e=>{var{typed:t,equalScalar:r,Matrix:n}=e;function o(e,t){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!c(t))throw new Error("Invalid datatype: "+t);if(f(e))!function(e,t,r){"SparseMatrix"===t.type?(e._values=t._values?$(t._values):void 0,e._index=$(t._index),e._ptr=$(t._ptr),e._size=$(t._size),e._datatype=r||t._datatype):s(e,t.valueOf(),r||t._datatype)}(this,e,t);else if(e&&l(e.index)&&l(e.ptr)&&l(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=t||e.datatype;else if(l(e))s(this,e,t);else{if(e)throw new TypeError("Unsupported type of data ("+L(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=t}}function s(e,n,i){e._values=[],e._index=[],e._ptr=[],e._datatype=i;var a=n.length,o=0,s=r,u=0;if(c(i)&&(s=t.find(r,[i,i])||r,u=t.convert(0,i)),a>0){var f=0;do{e._ptr.push(e._index.length);for(var p=0;p");for(var c=t.min()[0],l=t.min()[1],p=i[0],m=i[1],h=0;hd){for(f=d;fh){if(m){var y=0;for(f=0;fn-1&&(e._values.splice(p,1),e._index.splice(p,1),v++)}e._ptr[f]=e._values.length}return e._size[0]=n,e._size[1]=i,e}function v(e,t,r,n,i){var a,o,s=n[0],u=n[1],c=[];for(a=0;as-1||o>u-1)&&(g(this,Math.max(a+1,s),Math.max(o+1,u),i),s=this._size[0],u=this._size[1]),$e(a,s),$e(o,u);var m=h(a,this._ptr[o],this._ptr[o+1],this._index);return mArray.isArray(e)&&1===e.length?e[0]:e));if(2!==n.length)throw new Error("Only two dimensions matrix are supported");return n.forEach((function(e){if(!i(e)||!ce(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+De(n)+")")})),g(r?this.clone():this,n[0],n[1],t)},o.prototype.reshape=function(e,t){if(!l(e))throw new TypeError("Array expected");if(2!==e.length)throw new Error("Sparse matrices can only be reshaped in two dimensions");e.forEach((function(t){if(!i(t)||!ce(t)||t<=-2||0===t)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+De(e)+")")}));var r=this._size[0]*this._size[1];if(r!==(e=We(e,r))[0]*e[1])throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var n=t?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return n;for(var a=[],o=0;o=0&&w<=i&&y(e._values[b],w-0,g-0)}else{for(var N={},M=v;M "+(this._values?De(this._values[u],e):"X");return i},o.prototype.toString=function(){return De(this.toArray())},o.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},o.prototype.diagonal=function(e){if(e){if(a(e)&&(e=e.toNumber()),!i(e)||!ce(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var t=e>0?e:0,r=e<0?-e:0,n=this._size[0],s=this._size[1],u=Math.min(n-r,s-t),c=[],l=[],f=[];f[0]=0;for(var p=t;p0?s:0,g=s<0?-s:0,v=e[0],x=e[1],b=Math.min(v-g,x-y);if(l(n)){if(n.length!==b)throw new Error("Invalid value array length");d=function(e){return n[e]}}else if(f(n)){var w=n.size();if(1!==w.length||w[0]!==b)throw new Error("Invalid matrix length");d=function(e){return n.get([e])}}else d=function(){return n};for(var N=[],M=[],S=[],E=0;E=0&&A=u||i[l]!==t)){var p=n?n[c]:void 0;i.splice(l,0,t),n&&n.splice(l,0,p),i.splice(l<=c?c+1:c,1),n&&n.splice(l<=c?c+1:c,1)}else if(l=u||i[c]!==e)){var m=n?n[l]:void 0;i.splice(c,0,e),n&&n.splice(c,0,m),i.splice(c<=l?l+1:l,1),n&&n.splice(c<=l?l+1:l,1)}}},o}),{isClass:!0}),Wu="matrix",Ju=W(Wu,["typed","Matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,Matrix:r,DenseMatrix:n,SparseMatrix:i}=e;return t(Wu,{"":function(){return a([])},string:function(e){return a([],e)},"string, string":function(e,t){return a([],e,t)},Array:function(e){return a(e)},Matrix:function(e){return a(e,e.storage())},"Array | Matrix, string":a,"Array | Matrix, string, string":a});function a(e,t,r){if("dense"===t||"default"===t||void 0===t)return new n(e,r);if("sparse"===t)return new i(e,r);throw new TypeError("Unknown matrix type "+JSON.stringify(t)+".")}})),Yu=W("abs",["typed"],(e=>{var{typed:t}=e;return t("abs",{number:za,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},Fraction:function(e){return e.abs()},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.abs()}})})),Xu=W("algorithm01",["typed"],(e=>{var{typed:t}=e;return function(e,r,n,i){var a=e._data,o=e._size,s=e._datatype,u=r._values,c=r._index,l=r._ptr,f=r._size,p=r._datatype;if(o.length!==f.length)throw new Ue(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m,h,d=o[0],y=o[1],g="string"==typeof s&&s===p?s:void 0,v=g?t.find(n,[g,g]):n,x=[];for(m=0;m{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E,A=a&&l?[]:void 0,O=[],C=[],_=a&&l?[]:void 0,T=a&&l?[]:void 0,B=[],q=[];for(N=0;N{var{typed:t,DenseMatrix:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=i;"string"==typeof l&&(f=l,n=t.convert(n,f),h=t.find(i,[f,f]));for(var d=[],y=[],g=[],v=0;v{var{typed:t}=e;return function(e,n,i){var a,o=e._data,s=e._size,u=e._datatype,c=n._data,l=n._size,f=n._datatype,p=[];if(s.length!==l.length)throw new Ue(s.length,l.length);for(var m=0;m0?r(h,0,p,p[0],o,c):[];return e.createDenseMatrix({data:d,size:p,datatype:a})};function r(e,t,n,i,a,o){var s=[];if(t===n.length-1)for(var u=0;u{var{typed:t}=e;return function(e,n,i,a){var o,s=e._data,u=e._size,c=e._datatype,l=i;"string"==typeof c&&(o=c,n=t.convert(n,o),l=t.find(i,[o,o]));var f=u.length>0?r(l,0,u,u[0],s,n,a):[];return e.createDenseMatrix({data:f,size:$(u),datatype:o})};function r(e,t,n,i,a,o,s){var u=[];if(t===n.length-1)for(var c=0;c{var{typed:t,matrix:r,equalScalar:n,BigNumber:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=Qu({typed:t,equalScalar:n}),u=Ku({typed:t,DenseMatrix:a}),c=ec({typed:t}),l=tc({typed:t});return t("gcd",{"number, number":Ha,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var r=new i(0);!t.isZero();){var n=e.mod(t);e=t,t=n}return e.lt(r)?e.neg():e},"Fraction, Fraction":function(e,t){return e.gcd(t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return u(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return l(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return l(r(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,equalScalar:r}=e;return function(e,n,i,a){var o=e._data,s=e._size,u=e._datatype,c=n._values,l=n._index,f=n._ptr,p=n._size,m=n._datatype;if(s.length!==p.length)throw new Ue(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h,d=s[0],y=s[1],g=r,v=0,x=i;"string"==typeof u&&u===m&&(h=u,g=t.find(r,[h,h]),v=t.convert(0,h),x=t.find(i,[h,h]));for(var b=[],w=[],N=[],M=0;M{var{typed:t}=e;return function(e,r,n,i){var a=e._data,o=e._size,s=e._datatype,u=r._values,c=r._index,l=r._ptr,f=r._size,p=r._datatype;if(o.length!==f.length)throw new Ue(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m,h=o[0],d=o[1],y=0,g=n;"string"==typeof s&&s===p&&(m=s,y=t.convert(0,m),g=t.find(n,[m,m]));for(var v=[],x=0;x{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E=a&&l?[]:void 0,A=[],O=[],C=E?[]:void 0,_=E?[]:void 0,T=[],B=[];for(N=0;N{var{typed:t,equalScalar:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=r,d=0,y=i;"string"==typeof l&&(f=l,h=t.find(r,[f,f]),d=t.convert(0,f),n=t.convert(n,f),y=t.find(i,[f,f]));for(var g=[],v=[],x=[],b=0;b{var{typed:t,DenseMatrix:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=i;"string"==typeof l&&(f=l,n=t.convert(n,f),h=t.find(i,[f,f]));for(var d=[],y=[],g=[],v=0;v{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=nc({typed:t,equalScalar:n}),o=ic({typed:t}),s=ac({typed:t,equalScalar:n}),u=oc({typed:t,equalScalar:n}),c=sc({typed:t,DenseMatrix:i}),l=ec({typed:t}),f=tc({typed:t});return t("mod",{"number, number":Wa,"BigNumber, BigNumber":function(e,t){if(t.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return t.isZero()?e:e.mod(t)},"Fraction, Fraction":function(e,t){if(t.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return e.compare(0)>=0?e.mod(t):e.mod(t).add(t).mod(t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return f(e,t,this,!1)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return f(t,e,this,!0)},"Array, any":function(e,t){return f(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return f(r(t),e,this,!0).valueOf()}})})),cc=W("algorithm06",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._size,s=e._datatype,u=n._values,c=n._size,l=n._datatype;if(o.length!==c.length)throw new Ue(o.length,c.length);if(o[0]!==c[0]||o[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+c+")");var f,p=o[0],m=o[1],h=r,d=0,y=i;"string"==typeof s&&s===l&&(f=s,h=t.find(r,[f,f]),d=t.convert(0,f),y=t.find(i,[f,f]));for(var g=a&&u?[]:void 0,v=[],x=[],b=g?[]:void 0,w=[],N=[],M=0;M{var{typed:t,matrix:r,equalScalar:n,BigNumber:i}=e,a=Xu({typed:t}),o=nc({typed:t,equalScalar:n}),s=cc({typed:t,equalScalar:n}),u=oc({typed:t,equalScalar:n}),c=ec({typed:t}),l=tc({typed:t}),f="Complex number not supported in function nthRoot. Use nthRoots instead.";return t(lc,{number:function(e){return Ja(e,2)},"number, number":Ja,BigNumber:function(e){return p(e,new i(2))},Complex:function(e){throw new Error(f)},"Complex, number":function(e,t){throw new Error(f)},"BigNumber, BigNumber":p,"Array | Matrix":function(e){return this(e,2)},"SparseMatrix, SparseMatrix":function(e,t){if(1===t.density())return s(e,t,this);throw new Error("Root must be non-zero")},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){if(1===t.density())return a(e,t,this,!1);throw new Error("Root must be non-zero")},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){if(1===t.density())return u(t,e,this,!0);throw new Error("Root must be non-zero")},"number | BigNumber, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}});function p(e,t){var r=i.precision,n=i.clone({precision:r+2}),a=new i(0),o=new n(1),s=t.isNegative();if(s&&(t=t.neg()),t.isZero())throw new Error("Root must be non-zero");if(e.isNegative()&&!t.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(e.isZero())return s?new n(1/0):0;if(!e.isFinite())return s?a:e;var u=e.abs().pow(o.div(t));return u=e.isNeg()?u.neg():u,new i((s?o.div(u):u).toPrecision(r))}})),pc="xgcd",mc=W(pc,["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t(pc,{"number, number":function(e,t){var i=Qa(e,t);return"Array"===r.matrix?i:n(i)},"BigNumber, BigNumber":function(e,t){var a,o,s,u,c=new i(0),l=new i(1),f=c,p=l,m=l,h=c;if(!e.isInt()||!t.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!t.isZero();)o=e.div(t).floor(),s=e.mod(t),a=f,f=p.minus(o.times(f)),p=a,a=m,m=h.minus(o.times(m)),h=a,e=t,t=s;return u=e.lt(c)?[e.neg(),p.neg(),h.neg()]:[e,e.isZero()?0:p,h],"Array"===r.matrix?u:n(u)}})})),hc="bitAnd",dc=W(hc,["typed","matrix","equalScalar"],(e=>{var{typed:t,matrix:r,equalScalar:n}=e,i=nc({typed:t,equalScalar:n}),a=cc({typed:t,equalScalar:n}),o=oc({typed:t,equalScalar:n}),s=ec({typed:t}),u=tc({typed:t});return t(hc,{"number, number":So,"BigNumber, BigNumber":ho,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),yc=W("algorithm07",["typed","DenseMatrix"],(e=>{var{typed:t,DenseMatrix:r}=e;return function(e,i,a){var o=e._size,s=e._datatype,u=i._size,c=i._datatype;if(o.length!==u.length)throw new Ue(o.length,u.length);if(o[0]!==u[0]||o[1]!==u[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+u+")");var l,f,p,m=o[0],h=o[1],d=0,y=a;"string"==typeof s&&s===c&&(l=s,d=t.convert(0,l),y=t.find(a,[l,l]));var g=[];for(f=0;f{var{typed:t,matrix:r,DenseMatrix:n}=e,i=ic({typed:t}),a=yc({typed:t,DenseMatrix:n}),o=sc({typed:t,DenseMatrix:n}),s=ec({typed:t}),u=tc({typed:t});return t(gc,{"number, number":Oo,"BigNumber, BigNumber":bo,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),xc=W("or",["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=ic({typed:t}),o=ac({typed:t,equalScalar:n}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t("or",{"number, number":Ro,"Complex, Complex":function(e,t){return 0!==e.re||0!==e.im||0!==t.re||0!==t.im},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!e.isNaN()||!t.isZero()&&!t.isNaN()},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})})),bc="diag",wc=W(bc,["typed","matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:r,DenseMatrix:n,SparseMatrix:i}=e;return t(bc,{Array:function(e){return a(e,0,je(e),null)},"Array, number":function(e,t){return a(e,t,je(e),null)},"Array, BigNumber":function(e,t){return a(e,t.toNumber(),je(e),null)},"Array, string":function(e,t){return a(e,0,je(e),t)},"Array, number, string":function(e,t,r){return a(e,t,je(e),r)},"Array, BigNumber, string":function(e,t,r){return a(e,t.toNumber(),je(e),r)},Matrix:function(e){return a(e,0,e.size(),e.storage())},"Matrix, number":function(e,t){return a(e,t,e.size(),e.storage())},"Matrix, BigNumber":function(e,t){return a(e,t.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,t){return a(e,0,e.size(),t)},"Matrix, number, string":function(e,t,r){return a(e,t,e.size(),r)},"Matrix, BigNumber, string":function(e,t,r){return a(e,t.toNumber(),e.size(),r)}});function a(e,t,a,o){if(!ce(t))throw new TypeError("Second parameter in function diag must be an integer");var s=t>0?t:0,u=t<0?-t:0;switch(a.length){case 1:return function(e,t,r,a,o,s){var u=[a+o,a+s];if(r&&"sparse"!==r&&"dense"!==r)throw new TypeError("Unknown matrix type ".concat(r,'"'));var c="sparse"===r?i.diagonal(u,e,t):n.diagonal(u,e,t);return null!==r?c:c.valueOf()}(e,t,o,a[0],u,s);case 2:return function(e,t,n,i,a,o){if(f(e)){var s=e.diagonal(t);return null!==n?n!==s.storage()?r(s,n):s:s.valueOf()}for(var u=Math.min(i[0]-a,i[1]-o),c=[],l=0;l{var{typed:t,config:r,matrix:n,BigNumber:i,DenseMatrix:o,SparseMatrix:s}=e;return t(Nc,{"":function(){return"Matrix"===r.matrix?n([]):[]},string:function(e){return n(e)},"number | BigNumber":function(e){return c(e,e,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, string":function(e,t){return c(e,e,t)},"number | BigNumber, number | BigNumber":function(e,t){return c(e,t,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(e,t,r){return c(e,t,r)},Array:function(e){return u(e)},"Array, string":function(e,t){return u(e,t)},Matrix:function(e){return u(e.valueOf(),e.storage())},"Matrix, string":function(e,t){return u(e.valueOf(),t)}});function u(e,t){switch(e.length){case 0:return t?n(t):[];case 1:return c(e[0],e[0],t);case 2:return c(e[0],e[1],t);default:throw new Error("Vector containing two values expected")}}function c(e,t,r){var n=a(e)||a(t)?i:null;if(a(e)&&(e=e.toNumber()),a(t)&&(t=t.toNumber()),!ce(e)||e<1)throw new Error("Parameters in function identity must be positive integers");if(!ce(t)||t<1)throw new Error("Parameters in function identity must be positive integers");var u=n?new i(1):1,c=n?new n(0):0,l=[e,t];if(r){if("sparse"===r)return s.diagonal(l,u,0,c);if("dense"===r)return o.diagonal(l,u,0,c);throw new TypeError('Unknown matrix type "'.concat(r,'"'))}for(var f=Ge([],l,c),p=e{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t("ones",{"":function(){return"Array"===r.matrix?o([]):o([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return o(e,t)}return"Array"===r.matrix?o(e):o(e,"default")},Array:o,Matrix:function(e){var t=e.storage();return o(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return o(e.valueOf(),t)}});function o(e,t){var r=function(e){var t=!1;return e.forEach((function(e,r,n){a(e)&&(t=!0,n[r]=e.toNumber())})),t}(e)?new i(1):1;if(function(e){e.forEach((function(e){if("number"!=typeof e||!ce(e)||e<0)throw new Error("Parameters in function ones must be positive integers")}))}(e),t){var o=n(t);return e.length>0?o.resize(e,r):o}var s=[];return e.length>0?Ge(s,e,r):s}})),Ec="reshape",Ac=W(Ec,["typed","isInteger","matrix"],(e=>{var{typed:t,isInteger:r}=e;return t(Ec,{"Matrix, Array":function(e,t){return e.reshape(t)},"Array, Array":function(e,t){return t.forEach((function(e){if(!r(e))throw new TypeError("Invalid size for dimension: "+e)})),Ze(e,t)}})})),Oc="size",Cc=W(Oc,["typed","config","?matrix"],(e=>{var{typed:t,config:r,matrix:n}=e;return t(Oc,{Matrix:function(e){return e.create(e.size())},Array:je,string:function(e){return"Array"===r.matrix?[e.length]:n([e.length])},"number | Complex | BigNumber | Unit | boolean | null":function(e){return"Array"===r.matrix?[]:n?n([]):fr()}})})),_c="zeros",Tc=W(_c,["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t(_c,{"":function(){return"Array"===r.matrix?o([]):o([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return o(e,t)}return"Array"===r.matrix?o(e):o(e,"default")},Array:o,Matrix:function(e){var t=e.storage();return o(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return o(e.valueOf(),t)}});function o(e,t){var r=function(e){var t=!1;return e.forEach((function(e,r,n){a(e)&&(t=!0,n[r]=e.toNumber())})),t}(e)?new i(0):0;if(function(e){e.forEach((function(e){if("number"!=typeof e||!ce(e)||e<0)throw new Error("Parameters in function zeros must be positive integers")}))}(e),t){var o=n(t);return e.length>0?o.resize(e,r):o}var s=[];return e.length>0?Ge(s,e,r):s}})),Bc=W("hex",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("hex",{"number | BigNumber":function(e){return r(e,{notation:"hex"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"hex",wordSize:t})}})}));function qc(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function zc(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Dc(e){for(var t=1;t{var{typed:t,matrix:r,equalScalar:n,zeros:i,BigNumber:a,DenseMatrix:o}=e,s=oc({typed:t,equalScalar:n}),u=sc({typed:t,DenseMatrix:o}),c=tc({typed:t});return t(kc,Dc(Dc({},Fc),{},{Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw new TypeError(Ic);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(Ic);var r=t.toNumber();return e.round(r)},"number, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(Ic);return new a(e).toDecimalPlaces(t.toNumber())},BigNumber:function(e){return e.toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(Ic);return e.toDecimalPlaces(t.toNumber())},Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw new TypeError(Ic);return e.round(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"SparseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | Complex | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):u(t,e,this,!0)},"number | Complex | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return c(r(e),t,this,!1).valueOf()},"number | Complex | BigNumber, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}}))})),Fc={number:eo,"number, number":function(e,t){if(!ce(t))throw new TypeError(Ic);if(t<0||t>15)throw new Error("Number of decimals in function round must be in the range of 0-15");return eo(e,t)}},Uc=W("algorithm08",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");if(!a||!l)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));for(var w,N,M,S,E=[],A=[],O=[],C=[],_=[],T=0;T{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=nc({typed:t,equalScalar:n}),u=Uc({typed:t,equalScalar:n}),c=Ku({typed:t,DenseMatrix:a}),l=oc({typed:t,equalScalar:n}),f=ec({typed:t}),p=tc({typed:t});return t(Pc,{"number, number":Co,"BigNumber, BigNumber":wo,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Lc="rightLogShift",Hc=W(Lc,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=nc({typed:t,equalScalar:n}),u=Uc({typed:t,equalScalar:n}),c=Ku({typed:t,DenseMatrix:a}),l=oc({typed:t,equalScalar:n}),f=ec({typed:t}),p=tc({typed:t});return t(Lc,{"number, number":To,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})})),$c="compare",Gc=W($c,["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],(e=>{var{typed:t,config:r,equalScalar:n,matrix:i,BigNumber:a,Fraction:o,DenseMatrix:s}=e,u=ic({typed:t}),c=ac({typed:t,equalScalar:n}),l=sc({typed:t,DenseMatrix:s}),f=ec({typed:t}),p=tc({typed:t});return t($c,{"boolean, boolean":function(e,t){return e===t?0:e>t?1:-1},"number, number":function(e,t){return Se(e,t,r.epsilon)?0:e>t?1:-1},"BigNumber, BigNumber":function(e,t){return Na(e,t,r.epsilon)?new a(0):new a(e.cmp(t))},"Fraction, Fraction":function(e,t){return new o(e.compare(t))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return c(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(i(e),i(t)).valueOf()},"Array, Matrix":function(e,t){return this(i(e),t)},"Matrix, Array":function(e,t){return this(e,i(t))},"SparseMatrix, any":function(e,t){return l(e,t,this,!1)},"DenseMatrix, any":function(e,t){return p(e,t,this,!1)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(i(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(i(t),e,this,!0).valueOf()}})})),Vc="compareText",Zc=W(Vc,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e,n=ec({typed:t}),i=tc({typed:t});return t(Vc,{"any, any":Fe,"DenseMatrix, DenseMatrix":function(e,t){return n(e,t,Fe)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"DenseMatrix, any":function(e,t){return i(e,t,Fe,!1)},"any, DenseMatrix":function(e,t){return i(t,e,Fe,!0)},"Array, any":function(e,t){return i(r(e),t,Fe,!1).valueOf()},"any, Array":function(e,t){return i(r(t),e,Fe,!0).valueOf()}})})),Wc="smaller",Jc=W(Wc,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Wc,{"boolean, boolean":function(e,t){return e{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Yc,{"boolean, boolean":function(e,t){return e>t},"number, number":function(e,t){return e>t&&!Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gt(t)&&!Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return 1===e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),Qc="unequal",Kc=W(Qc,["typed","config","equalScalar","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,equalScalar:n,matrix:i,DenseMatrix:a}=e,o=ic({typed:t}),s=yc({typed:t,DenseMatrix:a}),u=sc({typed:t,DenseMatrix:a}),c=ec({typed:t}),l=tc({typed:t});return t("unequal",{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:f(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,f)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,f,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,f,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,f)},"Array, Array":function(e,t){return this(i(e),i(t)).valueOf()},"Array, Matrix":function(e,t){return this(i(e),t)},"Matrix, Array":function(e,t){return this(e,i(t))},"SparseMatrix, any":function(e,t){return u(e,t,f,!1)},"DenseMatrix, any":function(e,t){return l(e,t,f,!1)},"any, SparseMatrix":function(e,t){return u(t,e,f,!0)},"any, DenseMatrix":function(e,t){return l(t,e,f,!0)},"Array, any":function(e,t){return l(i(e),t,f,!1).valueOf()},"any, Array":function(e,t){return l(i(t),e,f,!0).valueOf()}});function f(e,t){return!n(e,t)}})),el=(W(Qc,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return t(Qc,{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:!r(e,t)}})})),W("ImmutableDenseMatrix",["smaller","DenseMatrix"],(e=>{var{smaller:t,DenseMatrix:r}=e;function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!c(t))throw new Error("Invalid datatype: "+t);if(f(e)||l(e)){var i=new r(e,t);this._data=i._data,this._size=i._size,this._datatype=i._datatype,this._min=null,this._max=null}else if(e&&l(e.data)&&l(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=void 0!==e.min?e.min:null,this._max=void 0!==e.max?e.max:null;else{if(e)throw new TypeError("Unsupported type of data ("+L(e)+")");this._data=[],this._size=[0],this._datatype=t,this._min=null,this._max=null}}return n.prototype=new r,n.prototype.type="ImmutableDenseMatrix",n.prototype.isImmutableDenseMatrix=!0,n.prototype.subset=function(e){switch(arguments.length){case 1:var t=r.prototype.subset.call(this,e);return f(t)?new n({data:t._data,size:t._size,datatype:t._datatype}):t;case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},n.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},n.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},n.prototype.clone=function(){return new n({data:$(this._data),size:$(this._size),datatype:this._datatype})},n.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.fromJSON=function(e){return new n(e)},n.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},n.prototype.min=function(){if(null===this._min){var e=null;this.forEach((function(r){(null===e||t(r,e))&&(e=r)})),this._min=null!==e?e:void 0}return this._min},n.prototype.max=function(){if(null===this._max){var e=null;this.forEach((function(r){(null===e||t(e,r))&&(e=r)})),this._max=null!==e?e:void 0}return this._max},n}),{isClass:!0})),tl=W("FibonacciHeap",["smaller","larger"],(e=>{var{smaller:t,larger:r}=e,n=1/Math.log((1+Math.sqrt(5))/2);function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}function a(e,t,r){t.left.right=t.right,t.right.left=t.left,r.degree--,r.child===t&&(r.child=t.right),0===r.degree&&(r.child=null),t.left=e,t.right=e.right,e.right=t,t.right.left=t,t.parent=null,t.mark=!1}function o(e,t){var r=t.parent;r&&(t.mark?(a(e,t,r),o(r)):t.mark=!0)}i.prototype.type="FibonacciHeap",i.prototype.isFibonacciHeap=!0,i.prototype.insert=function(e,r){var n={key:e,value:r,degree:0};if(this._minimum){var i=this._minimum;n.left=i,n.right=i.right,i.right=n,n.right.left=n,t(e,i.key)&&(this._minimum=n)}else n.left=n,n.right=n,this._minimum=n;return this._size++,n},i.prototype.size=function(){return this._size},i.prototype.clear=function(){this._minimum=null,this._size=0},i.prototype.isEmpty=function(){return 0===this._size},i.prototype.extractMinimum=function(){var e=this._minimum;if(null===e)return e;for(var i=this._minimum,a=e.degree,o=e.child;a>0;){var u=o.right;o.left.right=o.right,o.right.left=o.left,o.left=i,o.right=i.right,i.right=o,o.right.left=o,o.parent=null,o=u,a--}return e.left.right=e.right,e.right.left=e.left,i=e===e.right?null:function(e,i){var a,o=Math.floor(Math.log(i)*n)+1,u=new Array(o),c=0,l=e;if(l)for(c++,l=l.right;l!==e;)c++,l=l.right;for(;c>0;){for(var f=l.degree,p=l.right;a=u[f];){if(r(l.key,a.key)){var m=a;a=l,l=m}s(a,l),u[f]=null,f++}u[f]=l,l=p,c--}e=null;for(var h=0;h{var{typed:t,SparseMatrix:r}=e;return t(rl,{"":function(){return new r([])},string:function(e){return new r([],e)},"Array | Matrix":function(e){return new r(e)},"Array | Matrix, string":function(e,t){return new r(e,t)}})})),il="acoth",al=W(il,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(il,{number:function(e){return e>=1||e<=-1||r.predictable?ms(e):new n(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new i(1).div(e).atanh()},"Array | Matrix":function(e){return $t(e,this)}})})),ol=W("algorithm09",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E,A=a&&l?[]:void 0,O=[],C=[],_=A?[]:void 0,T=[];for(N=0;N{var{typed:t,matrix:r,equalScalar:n,BigNumber:i,DenseMatrix:a}=e,o=nc({typed:t,equalScalar:n}),s=ic({typed:t}),u=ol({typed:t,equalScalar:n}),c=oc({typed:t,equalScalar:n}),l=sc({typed:t,DenseMatrix:a}),f=ec({typed:t}),p=tc({typed:t});return t(sl,{"number, number":Math.atan2,"BigNumber, BigNumber":function(e,t){return i.atan2(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return l(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return p(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return p(r(t),e,this,!0).valueOf()}})})),cl=W("sec",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("sec",{number:Ss,Complex:function(e){return e.sec()},BigNumber:function(e){return new r(1).div(e.cos())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),ll=W("add",["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:r,addScalar:n,equalScalar:i,DenseMatrix:a,SparseMatrix:o}=e,s=Xu({typed:t}),u=Qu({typed:t,equalScalar:i}),c=Ku({typed:t,DenseMatrix:a}),l=ec({typed:t}),f=tc({typed:t});return t("add",G({"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,n)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,n,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,n,!0)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,n)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"DenseMatrix, any":function(e,t){return f(e,t,n,!1)},"SparseMatrix, any":function(e,t){return c(e,t,n,!1)},"any, DenseMatrix":function(e,t){return f(t,e,n,!0)},"any, SparseMatrix":function(e,t){return c(t,e,n,!0)},"Array, any":function(e,t){return f(r(e),t,n,!1).valueOf()},"any, Array":function(e,t){return f(r(t),e,n,!0).valueOf()},"any, any":n,"any, any, ...any":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,addScalar:r,multiplyScalar:n,conj:i,size:a}=e;return t("dot",{"Array | DenseMatrix, Array | DenseMatrix":function(e,a){var u=o(e,a),c=f(e)?e._data:e,l=f(e)?e._datatype:void 0,p=f(a)?a._data:a,m=f(a)?a._datatype:void 0,h=2===s(e).length,d=2===s(a).length,y=r,g=n;if(l&&m&&l===m&&"string"==typeof l){var v=l;y=t.find(r,[v,v]),g=t.find(n,[v,v])}if(!h&&!d){for(var x=g(i(c[0]),p[0]),b=1;bd?m++:h===d&&(c=l(c,f(a[p],u[m])),p++,m++)}return c}});function o(e,t){var r,n,i=s(e),a=s(t);if(1===i.length)r=i[0];else{if(2!==i.length||1!==i[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+i.join(", ")+")");r=i[0]}if(1===a.length)n=a[0];else{if(2!==a.length||1!==a[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+a.join(", ")+")");n=a[0]}if(r!==n)throw new RangeError("Vectors must have equal length ("+r+" != "+n+")");if(0===r)throw new RangeError("Cannot calculate the dot product of empty vectors");return r}function s(e){return f(e)?e.size():a(e)}})),pl="composition",ml=W(pl,["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],(e=>{var{typed:t,addScalar:r,combinations:n,isPositive:i,isNegative:a,isInteger:o,larger:s}=e;return t(pl,{"number | BigNumber, number | BigNumber":function(e,t){if(!(o(e)&&i(e)&&o(t)&&i(t)))throw new TypeError("Positive integer value expected in function composition");if(s(t,e))throw new TypeError("k must be less than or equal to n in function composition");return n(r(e,-1),r(t,-1))}})})),hl="isZero",dl=W(hl,["typed"],(e=>{var{typed:t}=e;return t(hl,{number:ya,BigNumber:function(e){return e.isZero()},Complex:function(e){return 0===e.re&&0===e.im},Fraction:function(e){return 1===e.d&&0===e.n},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),yl="matrixFromFunction",gl=W(yl,["typed","matrix","isZero"],(e=>{var{typed:t,matrix:r,isZero:n}=e;return t(yl,{"Array | Matrix, function, string, string":function(e,t,r,n){return i(e,t,r,n)},"Array | Matrix, function, string":function(e,t,r){return i(e,t,r)},"Matrix, function":function(e,t){return i(e,t,"dense")},"Array, function":function(e,t){return i(e,t,"dense").toArray()},"Array | Matrix, string, function":function(e,t,r){return i(e,r,t)},"Array | Matrix, string, string, function":function(e,t,r,n){return i(e,n,t,r)}});function i(e,t,i,a){var o;return(o=void 0!==a?r(i,a):r(i)).resize(e),o.forEach((function(e,r){var i=t(r);n(i)||o.set(r,i)})),o}})),vl="cbrt",xl=W(vl,["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],(e=>{var{config:t,typed:r,isNegative:n,unaryMinus:i,matrix:u,Complex:c,BigNumber:l,Fraction:f}=e;return r(vl,{number:Fa,Complex:p,"Complex, boolean":p,BigNumber:function(e){return e.cbrt()},Unit:function(e){if(e.value&&o(e.value)){var t=e.clone();return t.value=1,(t=t.pow(1/3)).value=p(e.value),t}var r,u=n(e.value);u&&(e.value=i(e.value)),r=a(e.value)?new l(1).div(3):s(e.value)?new f(1,3):1/3;var c=e.pow(r);return u&&(c.value=i(c.value)),c},"Array | Matrix":function(e){return $t(e,this,!0)}});function p(e,r){var n=e.arg()/3,i=e.abs(),a=new c(Fa(i),0).mul(new c(0,n).exp());if(r){var o=[a,new c(Fa(i),0).mul(new c(0,n+2*Math.PI/3).exp()),new c(Fa(i),0).mul(new c(0,n-2*Math.PI/3).exp())];return"Array"===t.matrix?o:u(o)}return a}})),bl=W("floor",["typed","config","round","matrix","equalScalar"],(e=>{var{typed:t,config:r,round:n,matrix:i,equalScalar:a}=e,o=oc({typed:t,equalScalar:a}),s=tc({typed:t});return t("floor",{number:function(e){return Se(e,n(e),r.epsilon)?n(e):Math.floor(e)},"number, number":function(e,t){if(Se(e,n(e,t),r.epsilon))return n(e,t);var[i,a]="".concat(e,"e").split("e"),o=Math.floor(Number("".concat(i,"e").concat(Number(a)+t)));return[i,a]="".concat(o,"e").split("e"),Number("".concat(i,"e").concat(Number(a)-t))},Complex:function(e){return e.floor()},"Complex, number":function(e,t){return e.floor(t)},BigNumber:function(e){return Na(e,n(e),r.epsilon)?n(e):e.floor()},"BigNumber, BigNumber":function(e,t){return Na(e,n(e,t),r.epsilon)?n(e,t):e.toDecimalPlaces(t.toNumber(),Qn.ROUND_FLOOR)},Fraction:function(e){return e.floor()},"Fraction, number":function(e,t){return e.floor(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"Array | Matrix, number":function(e,t){return $t(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"number | Complex | BigNumber, Array":function(e,t){return s(i(t),e,this,!0).valueOf()}})})),wl="multiply",Nl=W(wl,["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],(e=>{var{typed:t,matrix:r,addScalar:n,multiplyScalar:i,equalScalar:a,dot:o}=e,s=oc({typed:t,equalScalar:a}),u=tc({typed:t});function c(e,t){switch(e.length){case 1:switch(t.length){case 1:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;case 2:switch(t.length){case 1:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+t[0]+")");break;case 2:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}}var l=t("_multiplyMatrixVector",{"DenseMatrix, any":function(e,r){var a,o=e._data,s=e._size,u=e._datatype,c=r._data,l=r._datatype,f=s[0],p=s[1],m=n,h=i;u&&l&&u===l&&"string"==typeof u&&(a=u,m=t.find(n,[a,a]),h=t.find(i,[a,a]));for(var d=[],y=0;yA)for(var C=0,_=0;_{var{typed:t,matrix:r,equalScalar:n,multiplyScalar:i}=e,a=nc({typed:t,equalScalar:n}),o=ol({typed:t,equalScalar:n}),s=oc({typed:t,equalScalar:n}),u=ec({typed:t}),c=tc({typed:t});return t(Ml,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,i)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,i,!1)},"DenseMatrix, any":function(e,t){return c(e,t,i,!1)},"any, SparseMatrix":function(e,t){return s(t,e,i,!0)},"any, DenseMatrix":function(e,t){return c(t,e,i,!0)},"Array, any":function(e,t){return c(r(e),t,i,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,i,!0).valueOf()}})})),El=W("re",["typed"],(e=>{var{typed:t}=e;return t("re",{number:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Complex:function(e){return e.re},"Array | Matrix":function(e){return $t(e,this)}})})),Al="flatten",Ol=W(Al,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t(Al,{Array:function(e){return et($(e))},Matrix:function(e){var t=et($(e.toArray()));return r(t)}})}));function Cl(e,t,r,n){if(!(this instanceof Cl))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=t,this.min=r,this.max=n,this.message="Wrong number of arguments in function "+e+" ("+t+" provided, "+r+(null!=n?"-"+n:"")+" expected)",this.stack=(new Error).stack}Cl.prototype=new Error,Cl.prototype.constructor=Error,Cl.prototype.name="ArgumentsError",Cl.prototype.isArgumentsError=!0;var _l=W("resize",["config","matrix"],(e=>{var{config:t,matrix:r}=e;return function(e,i,o){if(2!==arguments.length&&3!==arguments.length)throw new Cl("resize",arguments.length,2,3);if(f(i)&&(i=i.valueOf()),a(i[0])&&(i=i.map((function(e){return a(e)?e.toNumber():e}))),f(e))return e.resize(i,o,!0);if("string"==typeof e)return n(e,i,o);var s=!Array.isArray(e)&&"Array"!==t.matrix;if(0===i.length){for(;Array.isArray(e);)e=e[0];return $(e)}Array.isArray(e)||(e=[e]);var u=Ge(e=$(e),i,o);return s?r(u):u};function n(e,t,r){if(void 0!==r){if("string"!=typeof r||1!==r.length)throw new TypeError("Single character expected as defaultValue")}else r=" ";if(1!==t.length)throw new Ue(t.length,1);var n=t[0];if("number"!=typeof n||!ce(n))throw new TypeError("Invalid size, must contain positive integers (size: "+De(t)+")");if(e.length>n)return e.substring(0,n);if(e.length{var{typed:t,matrix:r}=e;return t(Tl,{Array:function(e){return Ye($(e))},Matrix:function(e){var t=Ye(e.toArray());return Array.isArray(t)?r(t):t},any:function(e){return $(e)}})})),ql=W("to",["typed","matrix"],(e=>{var{typed:t,matrix:r}=e,n=ec({typed:t}),i=tc({typed:t});return t("to",{"Unit, Unit | string":function(e,t){return e.to(t)},"Matrix, Matrix":function(e,t){return n(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"Matrix, any":function(e,t){return i(e,t,this,!1)},"any, Matrix":function(e,t){return i(t,e,this,!0)},"Array, any":function(e,t){return i(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return i(r(t),e,this,!0).valueOf()}})})),zl=W("pow",["typed","config","identity","multiply","matrix","fraction","number","Complex"],(e=>{var{typed:t,config:r,identity:n,multiply:i,matrix:a,number:o,fraction:s,Complex:u}=e;return t("pow",{"number, number":c,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(e,t){return t.isInteger()||e>=0||r.predictable?e.pow(t):new u(e.toNumber(),0).pow(t.toNumber(),0)},"Fraction, Fraction":function(e,t){var n=e.pow(t);if(null!=n)return n;if(r.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return c(e.valueOf(),t.valueOf())},"Array, number":l,"Array, BigNumber":function(e,t){return l(e,t.toNumber())},"Matrix, number":f,"Matrix, BigNumber":function(e,t){return f(e,t.toNumber())},"Unit, number | BigNumber":function(e,t){return e.pow(t)}});function c(e,t){if(r.predictable&&!ce(t)&&e<0)try{var n=s(t),i=o(n);if((t===i||Math.abs((t-i)/t)<1e-14)&&n.d%2==1)return(n.n%2==0?1:-1)*Math.pow(-e,t)}catch(e){}return r.predictable&&(e<-1&&t===1/0||e>-1&&e<0&&t===-1/0)?NaN:ce(t)||e>=0||r.predictable?Ka(e,t):e*e<1&&t===1/0||e*e>1&&t===-1/0?0:new u(e,0).pow(t,0)}function l(e,t){if(!ce(t)||t<0)throw new TypeError("For A^b, b must be a positive integer (value is "+t+")");var r=je(e);if(2!==r.length)throw new Error("For A^b, A must be 2 dimensional (A has "+r.length+" dimensions)");if(r[0]!==r[1])throw new Error("For A^b, A must be square (size is "+r[0]+"x"+r[1]+")");for(var a=n(r[0]).valueOf(),o=e;t>=1;)1==(1&t)&&(a=i(o,a)),t>>=1,o=i(o,o);return a}function f(e,t){return a(l(e.valueOf(),t))}})),Dl="dotPow",Il=W(Dl,["typed","equalScalar","matrix","pow","DenseMatrix"],(e=>{var{typed:t,equalScalar:r,matrix:n,pow:i,DenseMatrix:a}=e,o=ic({typed:t}),s=yc({typed:t,DenseMatrix:a}),u=oc({typed:t,equalScalar:r}),c=sc({typed:t,DenseMatrix:a}),l=ec({typed:t}),f=tc({typed:t});return t(Dl,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,i)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return f(e,t,this,!1)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return f(t,e,this,!0)},"Array, any":function(e,t){return f(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return f(n(t),e,this,!0).valueOf()}})})),kl="rightArithShift",Rl=W(kl,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=nc({typed:t,equalScalar:n}),u=Uc({typed:t,equalScalar:n}),c=Ku({typed:t,DenseMatrix:a}),l=oc({typed:t,equalScalar:n}),f=ec({typed:t}),p=tc({typed:t});return t(kl,{"number, number":_o,"BigNumber, BigNumber":No,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Fl=r(228),Ul="compareNatural",Pl=W(Ul,["typed","compare"],(e=>{var{typed:t,compare:r}=e,n=r.signatures["boolean,boolean"];return t(Ul,{"any, any":function(e,t){var o,s=L(e),u=L(t);if(!("number"!==s&&"BigNumber"!==s&&"Fraction"!==s||"number"!==u&&"BigNumber"!==u&&"Fraction"!==u))return"0"!==(o=r(e,t)).toString()?o>0?1:-1:Fl(s,u);if("Array"===s||"Matrix"===s||"Array"===u||"Matrix"===u)return 0!==(o=i(this,e,t))?o:Fl(s,u);if(s!==u)return Fl(s,u);if("Complex"===s)return function(e,t){return e.re>t.re?1:e.ret.im?1:e.imr.length?1:t.length{var{typed:t,compareText:r,isZero:n}=e;return t(jl,{"any, any":function(e,t){return n(r(e,t))}})})),Hl="largerEq",$l=W(Hl,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Hl,{"boolean, boolean":function(e,t){return e>=t},"number, number":function(e,t){return e>=t||Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gte(t)||Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return-1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),Gl="partitionSelect",Vl=W(Gl,["typed","isNumeric","isNaN","compare"],(e=>{var{typed:t,isNumeric:r,isNaN:n,compare:i}=e,a=i,o=(e,t)=>-i(e,t);return t(Gl,{"Array | Matrix, number":function(e,t){return s(e,t,a)},"Array | Matrix, number, string":function(e,t,r){if("asc"===r)return s(e,t,a);if("desc"===r)return s(e,t,o);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":s});function s(e,t,r){if(!ce(t)||t<0)throw new Error("k must be a non-negative integer");if(f(e)){if(e.size().length>1)throw new Error("Only one dimensional matrices supported");return u(e.valueOf(),t,r)}if(Array.isArray(e))return u(e,t,r)}function u(e,t,i){if(t>=e.length)throw new Error("k out of bounds");for(var a=0;a=0){var f=e[c];e[c]=e[u],e[u]=f,--c}else++u;i(e[u],l)>0&&--u,t<=u?s=u:o=u+1}return e[t]}})),Zl=W("Index",["ImmutableDenseMatrix"],(e=>{var{ImmutableDenseMatrix:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var t=0,i=arguments.length;t{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(Wl,{number:function(e){if(e<=1&&e>=-1||r.predictable){var t=1/e;if(t>0||r.predictable)return gs(e);var i=Math.sqrt(t*t-1);return new n(Math.log(i-t),Math.PI)}return new n(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new i(1).div(e).acosh()},"Array | Matrix":function(e){return $t(e,this)}})})),Yl=W("tan",["typed"],(e=>{var{typed:t}=e;return t("tan",{number:Math.tan,Complex:function(e){return e.tan()},BigNumber:function(e){return e.tan()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Xl="setDifference",Ql=W(Xl,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Xl,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(0===n(r(e),new a(0)))s=[];else{if(0===n(r(t),new a(0)))return et(e.toArray());var u,c=ot(et(Array.isArray(e)?e:e.toArray()).sort(i)),l=ot(et(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var f=0;f{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Kl,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(0===n(r(e),new a(0))||0===n(r(t),new a(0)))s=[];else{var u=ot(et(Array.isArray(e)?e:e.toArray()).sort(i)),c=ot(et(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var l=0;l{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(tf,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,t){if(0===n(r(t),new a(0)))return 0;for(var o=et(Array.isArray(t)?t:t.toArray()),s=0,u=0;u{var{typed:t,compareNatural:r}=e;return t(nf,{"Array | Matrix":function(e){return Array.isArray(e)?et(e).length:et(e.toArray()).length},"Array | Matrix, boolean":function(e,t){if(!1===t||0===e.length)return Array.isArray(e)?et(e).length:et(e.toArray()).length;for(var n=et(Array.isArray(e)?e:e.toArray()).sort(r),i=1,a=1;a{var{typed:t,matrix:r,add:n}=e;return t("trace",{Array:function(e){return i(r(e))},SparseMatrix:function(e){var t=e._values,r=e._index,i=e._ptr,a=e._size,o=a[0],s=a[1];if(o===s){var u=0;if(t.length>0)for(var c=0;cc)break}return u}throw new RangeError("Matrix must be square (size: "+De(a)+")")},DenseMatrix:i,any:$});function i(e){var t=e._size,r=e._data;switch(t.length){case 1:if(1===t[0])return $(r[0]);throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:var i=t[0];if(i===t[1]){for(var a=0,o=0;o{var{typed:t,add:r,multiply:n,partitionSelect:o,compare:s}=e;function u(e,t,a){var u=et(e),l=u.length;if(0===l)throw new Error("Cannot calculate quantile of an empty sequence");if(i(t)){var f=t*(l-1),p=f%1;if(0===p){var m=a?u[f]:o(u,f);return c(m),m}var h,d,y=Math.floor(f);if(a)h=u[y],d=u[y+1];else{d=o(u,y+1),h=u[y];for(var g=0;g0&&(h=u[g])}return c(h),c(d),r(n(h,1-p),n(d,p))}var v=t.times(l-1);if(v.isInteger()){v=v.toNumber();var x=a?u[v]:o(u,v);return c(x),x}var b,w,N=v.floor(),M=v.minus(N),S=N.toNumber();if(a)b=u[S],w=u[S+1];else{w=o(u,S+1),b=u[S];for(var E=0;E0&&(b=u[E])}c(b),c(w);var A=new M.constructor(1);return r(n(b,A.minus(M)),n(w,M))}var c=t({"number | BigNumber | Unit":function(e){return e}});return function(e,t,r){var n,o,s;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(p(e)){if("boolean"==typeof(r=r||!1)){if(o=e.valueOf(),i(t)){if(t<0)throw new Error("N/prob must be non-negative");if(t<=1)return u(o,t,r);if(t>1){if(!ce(t))throw new Error("N must be a positive integer");var c=t+1;n=new Array(t);for(var l=0;l4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var h=new f(m+1);n=new Array(m);for(var d=0;d1)throw new Error("Probability must be between 0 and 1, inclusive")}else{if(!a(g))throw new TypeError("Unexpected type of argument in function quantileSeq");if(s=new g.constructor(1),g.isNegative()||g.gt(s))throw new Error("Probability must be between 0 and 1, inclusive")}n[y]=u(o,g,r)}return n}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}}));function uf(e){var t;if(ce(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:Js(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*uf(1-e));if(e>=171.35)return 1/0;if(e>85){var r=e*e,n=r*e,i=n*e,a=i*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*r)-139/(51840*n)-571/(2488320*i)+163879/(209018880*a)+5246819/(75246796800*a*e))}--e,t=lf[0];for(var o=1;o{var{typed:t,config:r,multiplyScalar:n,pow:i,BigNumber:a,Complex:o}=e;return t(ff,{number:uf,Complex:function(e){if(0===e.im)return this(e.re);e=new o(e.re-1,e.im);for(var t=new o(lf[0],0),r=1;r2;)u+=i-=2,o=o.times(u);return new a(o.toPrecision(a.precision))}})),mf=W("bignumber",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("bignumber",{"":function(){return new r(0)},number:function(e){return new r(e+"")},string:function(e){var t=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(t){var n=t[2],i=r(t[1]),a=new r(2).pow(Number(n));if(i.gt(a.sub(1)))throw new SyntaxError('String "'.concat(e,'" is out of range'));var o=new r(2).pow(Number(n)-1);return i.gte(o)?i.sub(a):i}return new r(e)},BigNumber:function(e){return e},Fraction:function(e){return new r(e.n).div(e.d).times(e.s)},null:function(e){return new r(0)},"Array | Matrix":function(e){return $t(e,this)}})})),hf="matrixFromColumns",df=W(hf,["typed","matrix","flatten","size"],(e=>{var{typed:t,matrix:r,flatten:n,size:i}=e;return t(hf,{"...Array":function(e){return a(e)},"...Matrix":function(e){return r(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one column is needed to construct a matrix.");for(var t=o(e[0]),r=[],i=0;i{var{typed:t,matrix:r,equalScalar:n}=e,i=nc({typed:t,equalScalar:n}),a=cc({typed:t,equalScalar:n}),o=oc({typed:t,equalScalar:n}),s=ec({typed:t}),u=tc({typed:t});return t("lcm",{"number, number":$a,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(e.isZero())return e;if(t.isZero())return t;for(var r=e.times(t);!t.isZero();){var n=t;t=e.mod(n),e=n}return r.div(e).abs()},"Fraction, Fraction":function(e,t){return e.lcm(t)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return o(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return u(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return u(r(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=Xu({typed:t}),o=Qu({typed:t,equalScalar:n}),s=Ku({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(gf,{"number, number":Ao,"BigNumber, BigNumber":go,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})})),xf="kron",bf=W(xf,["typed","matrix","multiplyScalar"],(e=>{var{typed:t,matrix:r,multiplyScalar:n}=e;return t(xf,{"Matrix, Matrix":function(e,t){return r(i(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(i(e.toArray(),t))},"Array, Matrix":function(e,t){return r(i(e,t.toArray()))},"Array, Array":i});function i(e,t){if(1===je(e).length&&(e=[e]),1===je(t).length&&(t=[t]),je(e).length>2||je(t).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(e.length)+", y = "+JSON.stringify(t.length)+")");var r=[],i=[];return e.map((function(e){return t.map((function(t){return i=[],r.push(i),e.map((function(e){return t.map((function(t){return i.push(n(e,t))}))}))}))}))&&r}})),wf=W("transpose",["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t("transpose",{Array:function(e){return this(r(e)).valueOf()},Matrix:function(e){var t,r=e.size();switch(r.length){case 1:t=e.clone();break;case 2:var n=r[0],i=r[1];if(0===i)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+De(r)+")");switch(e.storage()){case"dense":t=function(e,t,r){for(var n,i=e._data,a=[],o=0;o{var{number:t,bignumber:r,fraction:n}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},a={number:e=>t(e),BigNumber:r?e=>r(e):cr,Fraction:n?e=>n(e):lr};return function(e,t){var r=L(e);if(!(r in i))throw new TypeError("Cannot convert "+e+' of type "'+r+'"; valid input types are '+Object.keys(i).join(", "));if(!(t in a))throw new TypeError("Cannot convert "+e+' to type "'+t+'"; valid output types are '+Object.keys(a).join(", "));return t===r?e:a[t](e)}})),Mf=W("and",["typed","matrix","equalScalar","zeros","not"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,not:a}=e,o=nc({typed:t,equalScalar:n}),s=cc({typed:t,equalScalar:n}),u=oc({typed:t,equalScalar:n}),c=ec({typed:t}),l=tc({typed:t});return t("and",{"number, number":Uo,"Complex, Complex":function(e,t){return!(0===e.re&&0===e.im||0===t.re&&0===t.im)},"BigNumber, BigNumber":function(e,t){return!(e.isZero()||t.isZero()||e.isNaN()||t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return a(t)?i(e.size(),e.storage()):u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return a(t)?i(e.size(),e.storage()):l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return a(e)?i(e.size(),e.storage()):u(t,e,this,!0)},"any, DenseMatrix":function(e,t){return a(e)?i(e.size(),e.storage()):l(t,e,this,!0)},"Array, any":function(e,t){return this(r(e),t).valueOf()},"any, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Sf="smallerEq",Ef=W(Sf,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Sf,{"boolean, boolean":function(e,t){return e<=t},"number, number":function(e,t){return e<=t||Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.lte(t)||Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return 1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),Af="sort",Of=W(Af,["typed","matrix","compare","compareNatural"],(e=>{var{typed:t,matrix:r,compare:n,compareNatural:i}=e,a=n,o=(e,t)=>-n(e,t);return t(Af,{Array:function(e){return u(e),e.sort(a)},Matrix:function(e){return c(e),r(e.toArray().sort(a),e.storage())},"Array, function":function(e,t){return u(e),e.sort(t)},"Matrix, function":function(e,t){return c(e),r(e.toArray().sort(t),e.storage())},"Array, string":function(e,t){return u(e),e.sort(s(t))},"Matrix, string":function(e,t){return c(e),r(e.toArray().sort(s(t)),e.storage())}});function s(e){if("asc"===e)return a;if("desc"===e)return o;if("natural"===e)return i;throw new Error('String "asc", "desc", or "natural" expected')}function u(e){if(1!==je(e).length)throw new Error("One dimensional array expected")}function c(e){if(1!==e.size().length)throw new Error("One dimensional matrix expected")}})),Cf=W("cot",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("cot",{number:bs,Complex:function(e){return e.cot()},BigNumber:function(e){return new r(1).div(e.tan())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),_f="setDistinct",Tf=W(_f,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(_f,{"Array | Matrix":function(e){var t;if(0===n(r(e),new a(0)))t=[];else{var s=et(Array.isArray(e)?e:e.toArray()).sort(i);(t=[]).push(s[0]);for(var u=1;u{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(Bf,{"Array | Matrix":function(e){if(0===n(r(e),new a(0)))return[];for(var t=et(Array.isArray(e)?e:e.toArray()).sort(i),s=[],u=0;u.toString(2).length<=t.length;)s.push(o(t,u.toString(2).split("").reverse())),u++;return function(e){for(var t=[],r=e.length-1;r>0;r--)for(var n=0;ne[n+1].length&&(t=e[n],e[n]=e[n+1],e[n+1]=t);return e}(s)}});function o(e,t){for(var r=[],n=0;n{var{typed:t,Index:r}=e;return t(zf,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var t=e.map((function(e){return a(e)?e.toNumber():Array.isArray(e)||f(e)?e.map((function(e){return a(e)?e.toNumber():e})):e})),n=new r;return r.apply(n,t),n}})})),If="factorial",kf=W(If,["typed","gamma"],(e=>{var{typed:t,gamma:r}=e;return t(If,{number:function(e){if(e<0)throw new Error("Value must be non-negative");return r(e+1)},BigNumber:function(e){if(e.isNegative())throw new Error("Value must be non-negative");return r(e.plus(1))},"Array | Matrix":function(e){return $t(e,this)}})})),Rf="permutations",Ff=W(Rf,["typed","factorial"],(e=>{var{typed:t,factorial:r}=e;return t(Rf,{"number | BigNumber":r,"number, number":function(e,t){if(!ce(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!ce(t)||t<0)throw new TypeError("Positive integer value expected in function permutations");if(t>e)throw new TypeError("second argument k must be less than or equal to first argument n");return Js(e-t+1,e)},"BigNumber, BigNumber":function(e,t){var r,n;if(!Uf(e)||!Uf(t))throw new TypeError("Positive integer value expected in function permutations");if(t.gt(e))throw new TypeError("second argument k must be less than or equal to first argument n");for(r=e.mul(0).add(1),n=e.minus(t).plus(1);n.lte(e);n=n.plus(1))r=r.times(n);return r}})}));function Uf(e){return e.isInteger()&&e.gte(0)}var Pf="matrixFromRows",jf=W(Pf,["typed","matrix","flatten","size"],(e=>{var{typed:t,matrix:r,flatten:n,size:i}=e;return t(Pf,{"...Array":function(e){return a(e)},"...Matrix":function(e){return r(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one row is needed to construct a matrix.");var t=o(e[0]),r=[];for(var i of e){var a=o(i);if(a!==t)throw new TypeError("The vectors had different length: "+(0|t)+" ≠ "+(0|a));r.push(n(i))}return r}function o(e){var t=i(e);if(1===t.length)return t[0];if(2===t.length){if(1===t[0])return t[1];if(1===t[1])return t[0];throw new TypeError("At least one of the arguments is not a vector.")}throw new TypeError("Only one- or two-dimensional vectors are supported.")}})),Lf="subtract",Hf=W(Lf,["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,addScalar:i,unaryMinus:a,DenseMatrix:o}=e,s=Xu({typed:t}),u=ic({typed:t}),c=ac({typed:t,equalScalar:n}),l=Ku({typed:t,DenseMatrix:o}),f=ec({typed:t}),p=tc({typed:t});return t(Lf,{"number, number":function(e,t){return e-t},"Complex, Complex":function(e,t){return e.sub(t)},"BigNumber, BigNumber":function(e,t){return e.minus(t)},"Fraction, Fraction":function(e,t){return e.sub(t)},"Unit, Unit":function(e,t){if(null===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var r=e.clone();return r.value=this(r.value,t.value),r.fixPrefix=!1,r},"SparseMatrix, SparseMatrix":function(e,t){return $f(e,t),c(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return $f(e,t),u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return $f(e,t),s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return $f(e,t),f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return l(e,a(t),i)},"DenseMatrix, any":function(e,t){return p(e,t,this)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(r(t),e,this,!0).valueOf()}})}));function $f(e,t){var r=e.size(),n=t.size();if(r.length!==n.length)throw new Ue(r.length,n.length)}var Gf="cross",Vf=W(Gf,["typed","matrix","subtract","multiply"],(e=>{var{typed:t,matrix:r,subtract:n,multiply:i}=e;return t(Gf,{"Matrix, Matrix":function(e,t){return r(a(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(a(e.toArray(),t))},"Array, Matrix":function(e,t){return r(a(e,t.toArray()))},"Array, Array":a});function a(e,t){var r=Math.max(je(e).length,je(t).length);e=Ye(e),t=Ye(t);var a=je(e),o=je(t);if(1!==a.length||1!==o.length||3!==a[0]||3!==o[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+a.join(", ")+"], B = ["+o.join(", ")+"])");var s=[n(i(e[1],t[2]),i(e[2],t[1])),n(i(e[2],t[0]),i(e[0],t[2])),n(i(e[0],t[1]),i(e[1],t[0]))];return r>1?[s]:s}})),Zf="prod",Wf=W(Zf,["typed","config","multiplyScalar","numeric"],(e=>{var{typed:t,config:r,multiplyScalar:n,numeric:i}=e;return t(Zf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("prod(A, dim) is not yet supported")},"...":function(e){return a(e)}});function a(e){var t;if(Ht(e,(function(e){try{t=void 0===t?e:n(t,e)}catch(t){throw Gr(t,"prod",e)}})),"string"==typeof t&&(t=i(t,r.number)),void 0===t)throw new Error("Cannot calculate prod of an empty array");return t}})),Jf="equal",Yf=W(Jf,["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Jf,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:n(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,n)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,n,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,n,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,n)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,n,!1)},"DenseMatrix, any":function(e,t){return c(e,t,n,!1)},"any, SparseMatrix":function(e,t){return s(t,e,n,!0)},"any, DenseMatrix":function(e,t){return c(t,e,n,!0)},"Array, any":function(e,t){return c(r(e),t,n,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,n,!0).valueOf()}})})),Xf=(W(Jf,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return t(Jf,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:r(e,t)}})})),"setCartesian"),Qf=W(Xf,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Xf,{"Array | Matrix, Array | Matrix":function(e,t){var s=[];if(0!==n(r(e),new a(0))&&0!==n(r(t),new a(0))){var u=et(Array.isArray(e)?e:e.toArray()).sort(i),c=et(Array.isArray(t)?t:t.toArray()).sort(i);s=[];for(var l=0;l{var{typed:t,size:r,concat:n,subset:i,setDifference:a,Index:o}=e;return t(Kf,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new o(0)))return et(t);if(0===i(r(t),new o(0)))return et(e);var s=et(e),u=et(t);return n(a(s,u),a(u,s))}})})),tp=W("ceil",["typed","config","round","matrix","equalScalar"],(e=>{var{typed:t,config:r,round:n,matrix:i,equalScalar:a}=e,o=oc({typed:t,equalScalar:a}),s=tc({typed:t});return t("ceil",{number:function(e){return Se(e,n(e),r.epsilon)?n(e):Ua(e)},"number, number":function(e,t){if(Se(e,n(e,t),r.epsilon))return n(e,t);var[i,a]="".concat(e,"e").split("e"),o=Math.ceil(Number("".concat(i,"e").concat(Number(a)+t)));return[i,a]="".concat(o,"e").split("e"),Number("".concat(i,"e").concat(Number(a)-t))},Complex:function(e){return e.ceil()},"Complex, number":function(e,t){return e.ceil(t)},BigNumber:function(e){return Na(e,n(e),r.epsilon)?n(e):e.ceil()},"BigNumber, BigNumber":function(e,t){return Na(e,n(e,t),r.epsilon)?n(e,t):e.toDecimalPlaces(t.toNumber(),Qn.ROUND_CEIL)},Fraction:function(e){return e.ceil()},"Fraction, number":function(e,t){return e.ceil(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"Array | Matrix, number":function(e,t){return $t(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"number | Complex | BigNumber, Array":function(e,t){return s(i(t),e,this,!0).valueOf()}})})),rp=W("xor",["typed","matrix","DenseMatrix"],(e=>{var{typed:t,matrix:r,DenseMatrix:n}=e,i=ic({typed:t}),a=yc({typed:t,DenseMatrix:n}),o=sc({typed:t,DenseMatrix:n}),s=ec({typed:t}),u=tc({typed:t});return t("xor",{"number, number":Fo,"Complex, Complex":function(e,t){return(0!==e.re||0!==e.im)!=(0!==t.re||0!==t.im)},"BigNumber, BigNumber":function(e,t){return(!e.isZero()&&!e.isNaN())!=(!t.isZero()&&!t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),np="count",ip=W(np,["typed","size","prod"],(e=>{var{typed:t,size:r,prod:n}=e;return t(np,{string:function(e){return e.length},"Matrix | Array":function(e){return n(r(e))}})})),ap="ctranspose",op=W(ap,["typed","transpose","conj"],(e=>{var{typed:t,transpose:r,conj:n}=e;return t(ap,{any:function(e){return n(r(e))}})})),sp="deepEqual",up=W(sp,["typed","equal"],(e=>{var{typed:t,equal:r}=e;return t(sp,{"any, any":function(e,t){return n(e.valueOf(),t.valueOf())}});function n(e,t){if(Array.isArray(e)){if(Array.isArray(t)){var i=e.length;if(i!==t.length)return!1;for(var a=0;a{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(cp,{"Array | Matrix, Array | Matrix":function(e,t){if(0===n(r(e),new a(0)))return!0;if(0===n(r(t),new a(0)))return!1;for(var o,s=ot(et(Array.isArray(e)?e:e.toArray()).sort(i)),u=ot(et(Array.isArray(t)?t:t.toArray()).sort(i)),c=0;c{var{typed:t,Complex:r,matrix:n,ceil:i,floor:a}=e,o=tc({typed:t});return t("fix",{number:function(e){return e>0?a(e):i(e)},"number, number | BigNumber":function(e,t){return e>0?a(e,t):i(e,t)},Complex:function(e){return new r(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},"Complex, number | BigNumber":function(e,t){return new r(e.re>0?a(e.re,t):i(e.re,t),e.im>0?a(e.im,t):i(e.im,t))},BigNumber:function(e){return e.isNegative()?i(e):a(e)},"BigNumber, number | BigNumber":function(e,t){return e.isNegative()?i(e,t):a(e,t)},Fraction:function(e){return e.s<0?e.ceil():e.floor()},"Fraction, number | BigNumber":function(e,t){return e.s<0?e.ceil(t):e.floor(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"Array | Matrix, number | BigNumber":function(e,t){return $t(e,(e=>this(e,t)),!0)},"number | Complex | BigNumber, Array":function(e,t){return o(n(t),e,this,!0).valueOf()}})})),pp="divideScalar",mp=W(pp,["typed","numeric"],(e=>{var{typed:t,numeric:r}=e;return t(pp,{"number, number":function(e,t){return e/t},"Complex, Complex":function(e,t){return e.div(t)},"BigNumber, BigNumber":function(e,t){return e.div(t)},"Fraction, Fraction":function(e,t){return e.div(t)},"Unit, number | Fraction | BigNumber":function(e,t){var n=e.clone(),i=r(1,L(t));return n.value=this(null===n.value?n._normalize(i):n.value,t),n},"number | Fraction | BigNumber, Unit":function(e,t){var n=t.clone();n=n.pow(-1);var i=r(1,L(e));return n.value=this(e,null===t.value?t._normalize(i):t.value),n},"Unit, Unit":function(e,t){return e.divide(t)}})})),hp="nthRoots",dp=W(hp,["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,Complex:i}=e,a=[function(e){return new i(e,0)},function(e){return new i(0,e)},function(e){return new i(-e,0)},function(e){return new i(0,-e)}];function o(e,t){if(t<0)throw new Error("Root must be greater than zero");if(0===t)throw new Error("Root must be non-zero");if(t%1!=0)throw new Error("Root must be an integer");if(0===e||0===e.abs())return[new i(0,0)];var r,n="number"==typeof e;(n||0===e.re||0===e.im)&&(r=n?2*+(e<0):0===e.im?2*+(e.re<0):2*+(e.im<0)+1);for(var o=e.arg(),s=e.abs(),u=[],c=Math.pow(s,1/t),l=0;l{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(gp,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=(t=u(e,t,!0))._data,c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=[],d=0;dd&&(v.push(f[N]),x.push(M))}if(o(g,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var S=n(y,g),E=0,A=x.length;E{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(xp,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=0;hh&&(v.push(f[M]),x.push(S))}if(o(N,0))if(o(g[h],0)){if(0===y){var E=[...g];E[h]=1;for(var A=0,O=x.length;Anew s({data:e.map((e=>[e])),size:[c,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(r(e),t).map((e=>e.valueOf()))}});function c(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1],p=0;pnew s({data:e.map((e=>[e])),size:[l,1]})))}})),wp=W("Spa",["addScalar","equalScalar","FibonacciHeap"],(e=>{var{addScalar:t,equalScalar:r,FibonacciHeap:n}=e;function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new n}return i.prototype.type="Spa",i.prototype.isSpa=!0,i.prototype.set=function(e,t){if(this._values[e])this._values[e].value=t;else{var r=this._heap.insert(e,t);this._values[e]=r}},i.prototype.get=function(e){var t=this._values[e];return t?t.value:0},i.prototype.accumulate=function(e,r){var n=this._values[e];n?n.value=t(n.value,r):(n=this._heap.insert(e,r),this._values[e]=n)},i.prototype.forEach=function(e,t,n){var i=this._heap,a=this._values,o=[],s=i.extractMinimum();for(s&&o.push(s);s&&s.key<=t;)s.key>=e&&(r(s.value,0)||n(s.key,s.value,this)),(s=i.extractMinimum())&&o.push(s);for(var u=0;u{var{typed:t,size:r,concat:n,subset:i,setIntersect:a,setSymDifference:o,Index:s}=e;return t(Np,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new s(0)))return et(t);if(0===i(r(t),new s(0)))return et(e);var u=et(e),c=et(t);return n(o(u,c),a(u,c))}})})),Sp=W("lup",["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],(e=>{var{typed:t,matrix:r,abs:n,addScalar:i,divideScalar:a,multiplyScalar:o,subtract:s,larger:u,equalScalar:c,unaryMinus:l,DenseMatrix:f,SparseMatrix:p,Spa:m}=e;return t("lup",{DenseMatrix:function(e){return h(e)},SparseMatrix:function(e){return function(e){var t,r,i,s=e._size[0],f=e._size[1],h=Math.min(s,f),d=e._values,y=e._index,g=e._ptr,v=[],x=[],b=[],w=[s,h],N=[],M=[],S=[],E=[h,f],A=[],O=[];for(t=0;t0&&e.forEach(0,r-1,(function(t,r){p._forEachRow(t,v,x,b,(function(n,i){n>t&&e.accumulate(n,l(o(i,r)))}))}));var C,_,T,B,q=r,z=e.get(r),D=n(z);e.forEach(r+1,s-1,(function(e,t){var r=n(t);u(r,D)&&(q=e,D=r,z=t)})),r!==q&&(p._swapRows(r,q,w[1],v,x,b),p._swapRows(r,q,E[1],N,M,S),e.swap(r,q),_=q,T=O[C=r],B=O[_],A[T]=_,A[B]=C,O[C]=B,O[_]=T),e.forEach(0,s-1,(function(e,t){e<=r?(N.push(t),M.push(e)):(t=a(t,z),c(t,0)||(v.push(t),x.push(e)))}))};for(r=0;r0)for(t=0;t=0;){var u=r[o+s],c=r[n+u];-1===c?(s--,a[t++]=u):(r[n+u]=r[i+c],r[o+ ++s]=c)}return t}function Ap(e){return-e-2}var Op=W("csAmd",["add","multiply","transpose"],(e=>{var{add:t,multiply:r,transpose:n}=e;return function(e,o){if(!o||e<=0||e>3)return null;var s=o._size,u=s[0],c=s[1],l=0,f=Math.max(16,10*Math.sqrt(c)),p=function(e,i,a,o,s){var u=n(i);if(1===e&&o===a)return t(i,u);if(2===e){for(var c=u._index,l=u._ptr,f=0,p=0;ps))for(var h=l[p+1];mo)r[s+p]=0,r[i+p]=-1,f++,t[p]=Ap(e),r[s+e]++;else{var h=r[u+m];-1!==h&&(c[h]=p),r[l+p]=r[u+m],r[u+m]=p}}return f}(c,T,z,F,R,U,f,D,k,j,I),$=0;HG?(v=d,x=W,b=z[0+d]-G):(x=T[v=_[W++]],b=z[0+v]),g=1;g<=b;g++)(w=z[D+(m=_[x++])])<=0||(Z+=w,z[D+m]=-w,_[Y++]=m,-1!==z[I+m]&&(j[z[I+m]]=j[m]),-1!==j[m]?z[I+j[m]]=z[I+m]:z[k+z[F+m]]=z[I+m]);v!==d&&(T[v]=Ap(d),z[U+v]=0)}for(0!==G&&(B=Y),z[F+d]=Z,T[d]=J,z[0+d]=Y-J,z[R+d]=-2,L=i(L,l,z,U,c),N=J;N=L?z[U+v]-=w:0!==z[U+v]&&(z[U+v]=z[F+v]+X)}for(N=J;N0?(C+=Q,_[A++]=v,O+=v):(T[v]=Ap(d),z[U+v]=0)}z[R+m]=A-S+1;var K=A,ee=S+z[0+m];for(W=E+1;W=0))for(m=z[P+(O=j[m])],z[P+O]=-1;-1!==m&&-1!==z[I+m];m=z[I+m],L++){for(b=z[0+m],M=z[R+m],W=T[m]+1;W<=T[m]+b-1;W++)z[U+_[W]]=L;var re=m;for(h=z[I+m];-1!==h;){var ne=z[0+h]===b&&z[R+h]===M;for(W=T[h]+1;ne&&W<=T[h]+b-1;W++)z[U+_[W]]!==L&&(ne=0);ne?(T[h]=Ap(m),z[D+m]+=z[D+h],z[D+h]=0,z[R+h]=-1,h=z[I+h],z[I+re]=h):(re=h,h=z[I+h])}}for(W=J,N=J;N=0;h--)z[D+h]>0||(z[I+h]=z[k+T[h]],z[k+T[h]]=h);for(v=c;v>=0;v--)z[D+v]<=0||-1!==T[v]&&(z[I+v]=z[k+T[v]],z[k+T[v]]=v);for(d=0,m=0;m<=c;m++)-1===T[m]&&(d=Ep(m,d,z,k,I,q,U));return q.splice(q.length-1,1),q};function i(e,t,r,n,i){if(e<2||e+t<0){for(var a=0;a{var{transpose:t}=e;return function(e,r,n,i){if(!e||!r||!n)return null;var a,o,s,u,c,l,f,p=e._size,m=p[0],h=p[1],d=4*h+(i?h+m+1:0),y=[],g=h,v=2*h,x=3*h,b=4*h,w=5*h+1;for(s=0;s=1&&N[o]++,2===A.jleaf&&N[A.q]--}-1!==r[o]&&(y[0+o]=r[o])}for(o=0;o{var{add:t,multiply:r,transpose:n}=e,i=Op({add:t,multiply:r,transpose:n}),a=_p({transpose:n});return function(e,t,r){var n,o=t._ptr,s=t._size[1],u={};if(u.q=i(e,t),e&&!u.q)return null;if(r){var c=e?function(e,t,r,n){for(var i=e._values,a=e._index,o=e._ptr,s=e._size,u=e._datatype,c=s[0],l=s[1],f=null,p=[],m=[],h=0,d=0;d=0;r--)-1!==e[r]&&(a[o+r]=a[0+e[r]],a[0+e[r]]=r);for(r=0;r=0;u--)for(l=r[u],f=r[u+1],c=l;c=0;s--)m[s]=-1,-1!==(u=h[s])&&(0==d[v+u]++&&(d[g+u]=s),d[0+s]=d[y+u],d[y+u]=s);for(t.lnz=0,t.m2=a,u=0;u=0;){e=n[f];var p=i?i[e]:e;Bp(c,e)||(qp(c,e),n[l+f]=p<0?0:zp(c[p]));var m=1;for(o=n[l+f],s=p<0?0:zp(c[p+1]);o{var{divideScalar:t,multiply:r,subtract:n}=e;return function(e,i,a,o,s,u,c){var l,f,p,m,h=e._values,d=e._index,y=e._ptr,g=e._size[1],v=i._values,x=i._index,b=i._ptr,w=function(e,t,r,n,i){var a,o,s,u=e._ptr,c=e._size,l=t._index,f=t._ptr,p=c[1],m=p;for(o=f[r],s=f[r+1],a=o;a{var{abs:t,divideScalar:r,multiply:n,subtract:i,larger:a,largerEq:o,SparseMatrix:s}=e,u=Ip({divideScalar:r,multiply:n,subtract:i});return function(e,i,c){if(!e)return null;var l,f=e._size[1],p=100,m=100;i&&(l=i.q,p=i.lnz||p,m=i.unz||m);var h,d,y=[],g=[],v=[],x=new s({values:y,index:g,ptr:v,size:[f,f]}),b=[],w=[],N=[],M=new s({values:b,index:w,ptr:N,size:[f,f]}),S=[],E=[],A=[];for(h=0;h{var{typed:t,abs:r,add:n,multiply:i,transpose:a,divideScalar:o,subtract:s,larger:u,largerEq:c,SparseMatrix:l}=e,f=Tp({add:n,multiply:i,transpose:a}),p=kp({abs:r,divideScalar:o,multiply:i,subtract:s,larger:u,largerEq:c,SparseMatrix:l});return t("slu",{"SparseMatrix, number, number":function(e,t,r){if(!ce(t)||t<0||t>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(r<0||r>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var n=f(t,e,!1),i=p(e,n,r);return{L:i.L,U:i.U,p:i.pinv,q:n.q,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\np: "+this.p.toString()+(this.q?"\nq: "+this.q.toString():"")+"\n"}}}})})),Fp=W("det",["typed","matrix","subtract","multiply","unaryMinus","lup"],(e=>{var{typed:t,matrix:r,subtract:n,multiply:i,unaryMinus:a,lup:o}=e;return t("det",{any:function(e){return $(e)},"Array | Matrix":function(e){var t;switch((t=f(e)?e.size():Array.isArray(e)?(e=r(e)).size():[]).length){case 0:return $(e);case 1:if(1===t[0])return $(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:var s=t[0];if(s===t[1])return function(e,t,r){if(1===t)return $(e[0][0]);if(2===t)return n(i(e[0][0],e[1][1]),i(e[1][0],e[0][1]));for(var s=o(e),u=s.U[0][0],c=1;c=t)break;for(var m=f,h=0;!p[s.p[m]];)p[s.p[m]]=!0,m=s.p[m],h++;h%2==0&&l++}return l%2==0?u:a(u)}(e.clone().valueOf(),s);throw new RangeError("Matrix must be square (size: "+De(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+De(t)+")")}}})})),Up="distance",Pp=W(Up,["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],(e=>{var{typed:t,addScalar:r,subtract:n,multiplyScalar:i,divideScalar:o,unaryMinus:s,sqrt:u,abs:c}=e;return t(Up,{"Array, Array, Array":function(e,t,r){if(2===e.length&&2===t.length&&2===r.length){if(!f(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!f(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!f(r))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var a=o(n(r[1],r[0]),n(t[1],t[0])),u=i(i(a,a),t[0]),c=s(i(a,t[0])),l=e[1];return y(e[0],e[1],u,c,l)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(e,t,r){if(2===Object.keys(e).length&&2===Object.keys(t).length&&2===Object.keys(r).length){if(!f(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!f(t))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!f(r))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"lineOnePtX"in t&&"lineOnePtY"in t&&"lineTwoPtX"in r&&"lineTwoPtY"in r){var a=o(n(r.lineTwoPtY,r.lineTwoPtX),n(t.lineOnePtY,t.lineOnePtX)),u=i(i(a,a),t.lineOnePtX),c=s(i(a,t.lineOnePtX)),l=e.pointX;return y(e.pointX,e.pointY,u,c,l)}throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(e,t){if(2===e.length&&3===t.length){if(!f(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!p(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return y(e[0],e[1],t[0],t[1],t[2])}if(3===e.length&&6===t.length){if(!p(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!h(t))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return g(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}if(e.length===t.length&&e.length>0){if(!m(e))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!m(t))throw new TypeError("All values of an array should be numbers or BigNumbers");return v(e,t)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,t){if(2===Object.keys(e).length&&3===Object.keys(t).length){if(!f(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"xCoeffLine"in t&&"yCoeffLine"in t&&"constant"in t)return y(e.pointX,e.pointY,t.xCoeffLine,t.yCoeffLine,t.constant);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&6===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!h(t))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"x0"in t&&"y0"in t&&"z0"in t&&"a"in t&&"b"in t&&"c"in t)return g(e.pointX,e.pointY,e.pointZ,t.x0,t.y0,t.z0,t.a,t.b,t.c);throw new TypeError("Key names do not match")}if(2===Object.keys(e).length&&2===Object.keys(t).length){if(!f(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!f(t))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointTwoX"in t&&"pointTwoY"in t)return v([e.pointOneX,e.pointOneY],[t.pointTwoX,t.pointTwoY]);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&3===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointOneZ"in e&&"pointTwoX"in t&&"pointTwoY"in t&&"pointTwoZ"in t)return v([e.pointOneX,e.pointOneY,e.pointOneZ],[t.pointTwoX,t.pointTwoY,t.pointTwoZ]);throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},Array:function(e){if(!function(e){if(2===e[0].length&&l(e[0][0])&&l(e[0][1])){if(e.some((e=>2!==e.length||!l(e[0])||!l(e[1]))))return!1}else{if(!(3===e[0].length&&l(e[0][0])&&l(e[0][1])&&l(e[0][2])))return!1;if(e.some((e=>3!==e.length||!l(e[0])||!l(e[1])||!l(e[2]))))return!1}return!0}(e))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return function(e){for(var t=[],r=[],n=[],i=0;i{var{typed:t,addScalar:r,subtract:n,multiplyScalar:i,divideScalar:a,pow:o,factorial:s,combinations:u,isNegative:c,isInteger:l,larger:f}=e;return t(jp,{"number | BigNumber, number | BigNumber":function(e,t){if(!l(e)||c(e)||!l(t)||c(t))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(f(t,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");for(var p=s(t),m=0,h=0;h<=t;h++){var d=o(-1,n(t,h)),y=u(t,h),g=o(h,e);m=r(m,i(i(y,g),d))}return a(m,p)}})})),Hp="catalan",$p=W(Hp,["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],(e=>{var{typed:t,addScalar:r,divideScalar:n,multiplyScalar:i,combinations:a,isNegative:o,isInteger:s}=e;return t(Hp,{"number | BigNumber":function(e){if(!s(e)||o(e))throw new TypeError("Non-negative integer value expected in function catalan");return n(a(i(e,2),e),r(e,1))}})})),Gp=W("log",["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,Complex:i}=e;return t("log",{number:function(e){return e>=0||r.predictable?Ga(e):new i(e,0).log()},Complex:function(e){return e.log()},BigNumber:function(e){return!e.isNegative()||r.predictable?e.ln():new i(e.toNumber(),0).log()},"Array | Matrix":function(e){return $t(e,this)},"any, any":function(e,t){return n(this(e),this(t))}})})),Vp="dotDivide",Zp=W(Vp,["typed","matrix","equalScalar","divideScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,divideScalar:i,DenseMatrix:a}=e,o=nc({typed:t,equalScalar:n}),s=ic({typed:t}),u=yc({typed:t,DenseMatrix:a}),c=oc({typed:t,equalScalar:n}),l=sc({typed:t,DenseMatrix:a}),f=ec({typed:t}),p=tc({typed:t});return t(Vp,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,i)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return c(e,t,i,!1)},"DenseMatrix, any":function(e,t){return p(e,t,i,!1)},"any, SparseMatrix":function(e,t){return l(t,e,i,!0)},"any, DenseMatrix":function(e,t){return p(t,e,i,!0)},"Array, any":function(e,t){return p(r(e),t,i,!1).valueOf()},"any, Array":function(e,t){return p(r(t),e,i,!0).valueOf()}})})),Wp="usolveAll",Jp=W(Wp,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(Wp,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=l-1;h>=0;h--)for(var d=r.length,y=0;y=b;N--){var M=p[N];M===h?w=f[N]:Mnew s({data:e.map((e=>[e])),size:[c,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(r(e),t).map((e=>e.valueOf()))}});function c(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1]-1;f>=0;f--)for(var p=r.length,m=0;m=0;y--)d[y]=a(d[y],c[y][f]);r.push(d)}}else{if(0===m)return[];r.splice(m,1),m-=1,p-=1}else{h[f]=n(h[f],c[f][f]);for(var g=f-1;g>=0;g--)h[g]=a(h[g],i(h[f],c[g][f]))}}return r.map((e=>new s({data:e.map((e=>[e])),size:[l,1]})))}})),Yp="hypot",Xp=W(Yp,["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],(e=>{var{typed:t,abs:r,addScalar:n,divideScalar:i,multiplyScalar:a,sqrt:o,smaller:s,isPositive:u}=e;return t(Yp,{"... number | BigNumber":function(e){for(var t=0,c=0,l=0;l{var{typed:r,matrix:n,zeros:i,identity:a,isZero:o,equal:s,sign:u,sqrt:c,conj:l,unaryMinus:f,addScalar:p,divideScalar:m,multiplyScalar:h,subtract:d,complex:y}=t;return e(r("qr",{DenseMatrix:function(e){return v(e)},SparseMatrix:function(e){return function(e){throw new Error("qr not implemented for sparse matrices yet")}()},Array:function(e){var t=v(n(e));return{Q:t.Q.valueOf(),R:t.R.valueOf()}}}),{_denseQRimpl:g});function g(e){var t,r,n,y=e._size[0],g=e._size[1],v=a([y],"dense"),x=v._data,b=e.clone(),w=b._data,N=i([y],"");for(n=0;n0)for(var n="Complex"===r[0][0].type?y(0):0,i=0;i{var{typed:t,matrix:r,divideScalar:n,addScalar:i,multiply:a,unaryMinus:o,det:s,identity:u,abs:c}=e;return t("inv",{"Array | Matrix":function(e){var t=f(e)?e.size():je(e);switch(t.length){case 1:if(1===t[0])return f(e)?r([n(1,e.valueOf()[0])]):[n(1,e[0])];throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:var i=t[0],a=t[1];if(i===a)return f(e)?r(l(e.valueOf(),i,a),e.storage()):l(e,i,a);throw new RangeError("Matrix must be square (size: "+De(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+De(t)+")")}},any:function(e){return n(1,e)}});function l(e,t,r){var l,f,p,m,h;if(1===t){if(0===(m=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero");return[[n(1,m)]]}if(2===t){var d=s(e);if(0===d)throw Error("Cannot calculate inverse, determinant is zero");return[[n(e[1][1],d),n(o(e[0][1]),d)],[n(o(e[1][0]),d),n(e[0][0],d)]]}var y=e.concat();for(l=0;lx&&(x=c(y[l][v]),b=l),l++;if(0===x)throw Error("Cannot calculate inverse, determinant is zero");(l=b)!==v&&(h=y[v],y[v]=y[l],y[l]=h,h=g[v],g[v]=g[l],g[l]=h);var w=y[v],N=g[v];for(l=0;l{var{typed:t,abs:r,add:n,identity:i,inv:a,multiply:o}=e;return t(em,{Matrix:function(e){var t=e.size();if(2!==t.length||t[0]!==t[1])throw new RangeError("Matrix must be square (size: "+De(t)+")");for(var u=t[0],c=function(e,t){for(var r=0;r<30;r++)for(var n=0;n<=r;n++){var i=r-n;if(s(e,n,i)<1e-15)return{q:n,j:i}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}(function(e){for(var t=e.size()[0],n=0,i=0;i1&&(g=o(g,p),v=-v),m=n(m,o(y=y*(l-x+1)/((2*l-x+1)*x),g)),d=n(d,o(y*v,g));for(var b=o(a(d),m),w=0;w{var{typed:t,matrix:r,multiply:n,equalScalar:i,divideScalar:a,inv:o}=e,s=oc({typed:t,equalScalar:i}),u=tc({typed:t});return t("divide",G({"Array | Matrix, Array | Matrix":function(e,t){return n(e,o(t))},"DenseMatrix, any":function(e,t){return u(e,t,a,!1)},"SparseMatrix, any":function(e,t){return s(e,t,a,!1)},"Array, any":function(e,t){return u(r(e),t,a,!1).valueOf()},"any, Array | Matrix":function(e,t){return n(e,o(t))}},a.signatures))})),nm="kldivergence",im=W(nm,["typed","matrix","divide","sum","multiply","dotDivide","log","isNumeric"],(e=>{var{typed:t,matrix:r,divide:n,sum:i,multiply:a,dotDivide:o,log:s,isNumeric:u}=e;return t(nm,{"Array, Array":function(e,t){return c(r(e),r(t))},"Matrix, Array":function(e,t){return c(e,r(t))},"Array, Matrix":function(e,t){return c(r(e),t)},"Matrix, Matrix":function(e,t){return c(e,t)}});function c(e,t){var r=t.size().length,c=e.size().length;if(r>1)throw new Error("first object must be one dimensional");if(c>1)throw new Error("second object must be one dimensional");if(r!==c)throw new Error("Length of two vectors must be equal");if(0===i(e))throw new Error("Sum of elements in first object must be non zero");if(0===i(t))throw new Error("Sum of elements in second object must be non zero");var l=n(e,i(e)),f=n(t,i(t)),p=i(a(l,s(o(l,f))));return u(p)?p:Number.NaN}})),am="bellNumbers",om=W(am,["typed","addScalar","isNegative","isInteger","stirlingS2"],(e=>{var{typed:t,addScalar:r,isNegative:n,isInteger:i,stirlingS2:a}=e;return t(am,{"number | BigNumber":function(e){if(!i(e)||n(e))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var t=0,o=0;o<=e;o++)t=r(t,a(e,o));return t}})})),sm="log1p",um=W(sm,["typed","config","divideScalar","log","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,log:i,Complex:a}=e;return t(sm,{number:function(e){return e>=-1||r.predictable?me(e):o(new a(e,0))},Complex:o,BigNumber:function(e){var t=e.plus(1);return!t.isNegative()||r.predictable?t.ln():o(new a(e.toNumber(),0))},"Array | Matrix":function(e){return $t(e,this)},"any, any":function(e,t){return n(this(e),i(t))}});function o(e){var t=e.re+1;return new a(Math.log(Math.sqrt(t*t+e.im*e.im)),Math.atan2(e.im,t))}}));function cm(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function lm(e){for(var t=1;t{var r,n,i,{on:a,config:s,addScalar:c,subtract:l,multiplyScalar:f,divideScalar:p,pow:m,abs:h,fix:d,round:y,equal:g,isNumeric:v,format:x,number:b,Complex:w,BigNumber:N,Fraction:M}=t,S=b;function E(e,t){if(!(this instanceof E))throw new Error("Constructor must be called with the new operator");if(null!=e&&!v(e)&&!o(e))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(void 0!==t&&("string"!=typeof t||""===t))throw new TypeError("Second parameter in Unit constructor must be a string");if(void 0!==t){var r=E.parse(t);this.units=r.units,this.dimensions=r.dimensions}else{this.units=[{unit:U,prefix:I.NONE,power:0}],this.dimensions=[];for(var n=0;n="0"&&e<="9"}function C(){n++,i=r.charAt(n)}function _(e){n=e,i=r.charAt(n)}function T(){var e="",t=n;if("+"===i?C():"-"===i&&(e+=i,C()),!function(e){return e>="0"&&e<="9"||"."===e}(i))return _(t),null;if("."===i){if(e+=i,C(),!O(i))return _(t),null}else{for(;O(i);)e+=i,C();"."===i&&(e+=i,C())}for(;O(i);)e+=i,C();if("E"===i||"e"===i){var r="",a=n;if(r+=i,C(),"+"!==i&&"-"!==i||(r+=i,C()),!O(i))return _(a),e;for(e+=r;O(i);)e+=i,C()}return e}function B(){for(var e="";O(i)||E.isValidAlpha(i);)e+=i,C();var t=e.charAt(0);return E.isValidAlpha(t)?e:null}function q(e){return i===e?(C(),e):null}E.prototype.type="Unit",E.prototype.isUnit=!0,E.parse=function(e,t){if(t=t||{},n=-1,i="","string"!=typeof(r=e))throw new TypeError("Invalid argument in Unit.parse, string expected");var a=new E;a.units=[];var o=1,u=!1;C(),A();var c=T(),l=null;if(c){if("BigNumber"===s.number)l=new N(c);else if("Fraction"===s.number)try{l=new M(c)}catch(e){l=parseFloat(c)}else l=parseFloat(c);A(),q("*")?(o=1,u=!0):q("/")&&(o=-1,u=!0)}for(var f=[],p=1;;){for(A();"("===i;)f.push(o),p*=o,o=1,C(),A();var m;if(!i)break;var h=i;if(null===(m=B()))throw new SyntaxError('Unexpected "'+h+'" in "'+r+'" at index '+n.toString());var d=z(m);if(null===d)throw new SyntaxError('Unit "'+m+'" not found.');var y=o*p;if(A(),q("^")){A();var g=T();if(null===g)throw new SyntaxError('In "'+e+'", "^" must be followed by a floating-point number');y*=g}a.units.push({unit:d.unit,prefix:d.prefix,power:y});for(var v=0;v1||Math.abs(this.units[0].power-1)>1e-15)},E.prototype._normalize=function(e){var t,r,n,i,a;if(null==e||0===this.units.length)return e;if(this._isDerived()){var o=e;a=E._getNumberConverter(L(e));for(var s=0;s{if(Z(P,e)){var t=P[e];return{unit:t,prefix:t.prefixes[""]}}for(var r in P)if(Z(P,r)&&ze(e,r)){var n=P[r],i=e.length-r.length,a=e.substring(0,i),o=Z(n.prefixes,a)?n.prefixes[a]:void 0;if(void 0!==o)return{unit:n,prefix:o}}return null}),{hasher:e=>e[0],limit:100});function D(e){return e.equalBase(R.NONE)&&null!==e.value&&!s.predictable?e.value:e}E.isValuelessUnit=function(e){return null!==z(e)},E.prototype.hasBase=function(e){if("string"==typeof e&&(e=R[e]),!e)return!1;for(var t=0;t1e-12)return!1;return!0},E.prototype.equalBase=function(e){for(var t=0;t1e-12)return!1;return!0},E.prototype.equals=function(e){return this.equalBase(e)&&g(this.value,e.value)},E.prototype.multiply=function(e){for(var t=this.clone(),r=0;r1e-12&&(Z(V,s)?n.push({unit:V[s].unit,prefix:V[s].prefix,power:r.dimensions[o]||0}):a=!0)}n.length1e-12){if(!Z(G.si,n))throw new Error("Cannot express custom unit "+n+" in SI units");t.push({unit:G.si[n].unit,prefix:G.si[n].prefix,power:e.dimensions[r]||0})}}return e.units=t,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,e},E.prototype.formatUnits=function(){for(var e="",t="",r=0,n=0,i=0;i0?(r++,e+=" "+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power-1)>1e-15&&(e+="^"+this.units[i].power)):this.units[i].power<0&&n++;if(n>0)for(var a=0;a0?(t+=" "+this.units[a].prefix.name+this.units[a].unit.name,Math.abs(this.units[a].power+1)>1e-15&&(t+="^"+-this.units[a].power)):(t+=" "+this.units[a].prefix.name+this.units[a].unit.name,t+="^"+this.units[a].power));e=e.substr(1),t=t.substr(1),r>1&&n>0&&(e="("+e+")"),n>1&&r>0&&(t="("+t+")");var o=e;return r>0&&n>0&&(o+=" / "),o+t},E.prototype.format=function(e){var t=this.skipAutomaticSimplification||null===this.value?this.clone():this.simplify(),r=!1;for(var n in void 0!==t.value&&null!==t.value&&o(t.value)&&(r=Math.abs(t.value.re)<1e-14),t.units)Z(t.units,n)&&t.units[n].unit&&("VA"===t.units[n].unit.name&&r?t.units[n].unit=P.VAR:"VAR"!==t.units[n].unit.name||r||(t.units[n].unit=P.VA));1!==t.units.length||t.fixPrefix||Math.abs(t.units[0].power-Math.round(t.units[0].power))<1e-14&&(t.units[0].prefix=t._bestPrefix());var i=t._denormalize(t.value),a=null!==t.value?x(i,e||{}):"",s=t.formatUnits();return t.value&&o(t.value)&&(a="("+a+")"),s.length>0&&a.length>0&&(a+=" "),a+s},E.prototype._bestPrefix=function(){if(1!==this.units.length)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var e=null!==this.value?h(this.value):0,t=h(this.units[0].unit.value),r=this.units[0].prefix;if(0===e)return r;var n=this.units[0].power,i=Math.log(e/Math.pow(r.value*t,n))/Math.LN10-1.2;if(i>-2.200001&&i<1.800001)return r;i=Math.abs(i);var a=this.units[0].unit.prefixes;for(var o in a)if(Z(a,o)){var s=a[o];if(s.scientific){var u=Math.abs(Math.log(e/Math.pow(s.value*t,n))/Math.LN10-1.2);(u0))},P={meter:{name:"meter",base:R.LENGTH,prefixes:I.LONG,value:1,offset:0},inch:{name:"inch",base:R.LENGTH,prefixes:I.NONE,value:.0254,offset:0},foot:{name:"foot",base:R.LENGTH,prefixes:I.NONE,value:.3048,offset:0},yard:{name:"yard",base:R.LENGTH,prefixes:I.NONE,value:.9144,offset:0},mile:{name:"mile",base:R.LENGTH,prefixes:I.NONE,value:1609.344,offset:0},link:{name:"link",base:R.LENGTH,prefixes:I.NONE,value:.201168,offset:0},rod:{name:"rod",base:R.LENGTH,prefixes:I.NONE,value:5.0292,offset:0},chain:{name:"chain",base:R.LENGTH,prefixes:I.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:R.LENGTH,prefixes:I.NONE,value:1e-10,offset:0},m:{name:"m",base:R.LENGTH,prefixes:I.SHORT,value:1,offset:0},in:{name:"in",base:R.LENGTH,prefixes:I.NONE,value:.0254,offset:0},ft:{name:"ft",base:R.LENGTH,prefixes:I.NONE,value:.3048,offset:0},yd:{name:"yd",base:R.LENGTH,prefixes:I.NONE,value:.9144,offset:0},mi:{name:"mi",base:R.LENGTH,prefixes:I.NONE,value:1609.344,offset:0},li:{name:"li",base:R.LENGTH,prefixes:I.NONE,value:.201168,offset:0},rd:{name:"rd",base:R.LENGTH,prefixes:I.NONE,value:5.02921,offset:0},ch:{name:"ch",base:R.LENGTH,prefixes:I.NONE,value:20.1168,offset:0},mil:{name:"mil",base:R.LENGTH,prefixes:I.NONE,value:254e-7,offset:0},m2:{name:"m2",base:R.SURFACE,prefixes:I.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:R.SURFACE,prefixes:I.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:R.SURFACE,prefixes:I.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:R.SURFACE,prefixes:I.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:R.SURFACE,prefixes:I.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:R.SURFACE,prefixes:I.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:R.SURFACE,prefixes:I.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:R.SURFACE,prefixes:I.NONE,value:6.4516e-10,offset:0},acre:{name:"acre",base:R.SURFACE,prefixes:I.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:R.SURFACE,prefixes:I.NONE,value:1e4,offset:0},m3:{name:"m3",base:R.VOLUME,prefixes:I.CUBIC,value:1,offset:0},L:{name:"L",base:R.VOLUME,prefixes:I.SHORT,value:.001,offset:0},l:{name:"l",base:R.VOLUME,prefixes:I.SHORT,value:.001,offset:0},litre:{name:"litre",base:R.VOLUME,prefixes:I.LONG,value:.001,offset:0},cuin:{name:"cuin",base:R.VOLUME,prefixes:I.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:R.VOLUME,prefixes:I.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:R.VOLUME,prefixes:I.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:R.VOLUME,prefixes:I.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:R.VOLUME,prefixes:I.NONE,value:15e-6,offset:0},drop:{name:"drop",base:R.VOLUME,prefixes:I.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:R.VOLUME,prefixes:I.NONE,value:5e-8,offset:0},minim:{name:"minim",base:R.VOLUME,prefixes:I.NONE,value:6.161152e-8,offset:0},fluiddram:{name:"fluiddram",base:R.VOLUME,prefixes:I.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:R.VOLUME,prefixes:I.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:R.VOLUME,prefixes:I.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:R.VOLUME,prefixes:I.NONE,value:1e-6,offset:0},cup:{name:"cup",base:R.VOLUME,prefixes:I.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:R.VOLUME,prefixes:I.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:R.VOLUME,prefixes:I.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:R.VOLUME,prefixes:I.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:R.VOLUME,prefixes:I.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:R.VOLUME,prefixes:I.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:R.VOLUME,prefixes:I.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:R.VOLUME,prefixes:I.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:R.VOLUME,prefixes:I.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:R.VOLUME,prefixes:I.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:R.VOLUME,prefixes:I.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:R.VOLUME,prefixes:I.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:R.VOLUME,prefixes:I.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:R.VOLUME,prefixes:I.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:R.VOLUME,prefixes:I.NONE,value:.1173478,offset:0},obl:{name:"obl",base:R.VOLUME,prefixes:I.NONE,value:.1589873,offset:0},g:{name:"g",base:R.MASS,prefixes:I.SHORT,value:.001,offset:0},gram:{name:"gram",base:R.MASS,prefixes:I.LONG,value:.001,offset:0},ton:{name:"ton",base:R.MASS,prefixes:I.SHORT,value:907.18474,offset:0},t:{name:"t",base:R.MASS,prefixes:I.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:R.MASS,prefixes:I.LONG,value:1e3,offset:0},grain:{name:"grain",base:R.MASS,prefixes:I.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:R.MASS,prefixes:I.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:R.MASS,prefixes:I.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:R.MASS,prefixes:I.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:R.MASS,prefixes:I.NONE,value:45.359237,offset:0},stick:{name:"stick",base:R.MASS,prefixes:I.NONE,value:.115,offset:0},stone:{name:"stone",base:R.MASS,prefixes:I.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:R.MASS,prefixes:I.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:R.MASS,prefixes:I.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:R.MASS,prefixes:I.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:R.MASS,prefixes:I.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:R.MASS,prefixes:I.NONE,value:45.359237,offset:0},s:{name:"s",base:R.TIME,prefixes:I.SHORT,value:1,offset:0},min:{name:"min",base:R.TIME,prefixes:I.NONE,value:60,offset:0},h:{name:"h",base:R.TIME,prefixes:I.NONE,value:3600,offset:0},second:{name:"second",base:R.TIME,prefixes:I.LONG,value:1,offset:0},sec:{name:"sec",base:R.TIME,prefixes:I.LONG,value:1,offset:0},minute:{name:"minute",base:R.TIME,prefixes:I.NONE,value:60,offset:0},hour:{name:"hour",base:R.TIME,prefixes:I.NONE,value:3600,offset:0},day:{name:"day",base:R.TIME,prefixes:I.NONE,value:86400,offset:0},week:{name:"week",base:R.TIME,prefixes:I.NONE,value:604800,offset:0},month:{name:"month",base:R.TIME,prefixes:I.NONE,value:2629800,offset:0},year:{name:"year",base:R.TIME,prefixes:I.NONE,value:31557600,offset:0},decade:{name:"decade",base:R.TIME,prefixes:I.NONE,value:315576e3,offset:0},century:{name:"century",base:R.TIME,prefixes:I.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:R.TIME,prefixes:I.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:R.FREQUENCY,prefixes:I.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:R.FREQUENCY,prefixes:I.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:R.ANGLE,prefixes:I.SHORT,value:1,offset:0},radian:{name:"radian",base:R.ANGLE,prefixes:I.LONG,value:1,offset:0},deg:{name:"deg",base:R.ANGLE,prefixes:I.SHORT,value:null,offset:0},degree:{name:"degree",base:R.ANGLE,prefixes:I.LONG,value:null,offset:0},grad:{name:"grad",base:R.ANGLE,prefixes:I.SHORT,value:null,offset:0},gradian:{name:"gradian",base:R.ANGLE,prefixes:I.LONG,value:null,offset:0},cycle:{name:"cycle",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},A:{name:"A",base:R.CURRENT,prefixes:I.SHORT,value:1,offset:0},ampere:{name:"ampere",base:R.CURRENT,prefixes:I.LONG,value:1,offset:0},K:{name:"K",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:0},degC:{name:"degC",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:273.15},degF:{name:"degF",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:0},celsius:{name:"celsius",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:R.AMOUNT_OF_SUBSTANCE,prefixes:I.SHORT,value:1,offset:0},mole:{name:"mole",base:R.AMOUNT_OF_SUBSTANCE,prefixes:I.LONG,value:1,offset:0},cd:{name:"cd",base:R.LUMINOUS_INTENSITY,prefixes:I.SHORT,value:1,offset:0},candela:{name:"candela",base:R.LUMINOUS_INTENSITY,prefixes:I.LONG,value:1,offset:0},N:{name:"N",base:R.FORCE,prefixes:I.SHORT,value:1,offset:0},newton:{name:"newton",base:R.FORCE,prefixes:I.LONG,value:1,offset:0},dyn:{name:"dyn",base:R.FORCE,prefixes:I.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:R.FORCE,prefixes:I.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:R.FORCE,prefixes:I.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:R.FORCE,prefixes:I.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:R.FORCE,prefixes:I.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:R.FORCE,prefixes:I.NONE,value:9.80665,offset:0},J:{name:"J",base:R.ENERGY,prefixes:I.SHORT,value:1,offset:0},joule:{name:"joule",base:R.ENERGY,prefixes:I.SHORT,value:1,offset:0},erg:{name:"erg",base:R.ENERGY,prefixes:I.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:R.ENERGY,prefixes:I.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:R.ENERGY,prefixes:I.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:R.ENERGY,prefixes:I.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:R.ENERGY,prefixes:I.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:R.POWER,prefixes:I.SHORT,value:1,offset:0},watt:{name:"watt",base:R.POWER,prefixes:I.LONG,value:1,offset:0},hp:{name:"hp",base:R.POWER,prefixes:I.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:R.POWER,prefixes:I.SHORT,value:w.I,offset:0},VA:{name:"VA",base:R.POWER,prefixes:I.SHORT,value:1,offset:0},Pa:{name:"Pa",base:R.PRESSURE,prefixes:I.SHORT,value:1,offset:0},psi:{name:"psi",base:R.PRESSURE,prefixes:I.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:R.PRESSURE,prefixes:I.NONE,value:101325,offset:0},bar:{name:"bar",base:R.PRESSURE,prefixes:I.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:R.PRESSURE,prefixes:I.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:R.PRESSURE,prefixes:I.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:R.PRESSURE,prefixes:I.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:R.PRESSURE,prefixes:I.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:R.ELECTRIC_CHARGE,prefixes:I.LONG,value:1,offset:0},C:{name:"C",base:R.ELECTRIC_CHARGE,prefixes:I.SHORT,value:1,offset:0},farad:{name:"farad",base:R.ELECTRIC_CAPACITANCE,prefixes:I.LONG,value:1,offset:0},F:{name:"F",base:R.ELECTRIC_CAPACITANCE,prefixes:I.SHORT,value:1,offset:0},volt:{name:"volt",base:R.ELECTRIC_POTENTIAL,prefixes:I.LONG,value:1,offset:0},V:{name:"V",base:R.ELECTRIC_POTENTIAL,prefixes:I.SHORT,value:1,offset:0},ohm:{name:"ohm",base:R.ELECTRIC_RESISTANCE,prefixes:I.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:R.ELECTRIC_INDUCTANCE,prefixes:I.LONG,value:1,offset:0},H:{name:"H",base:R.ELECTRIC_INDUCTANCE,prefixes:I.SHORT,value:1,offset:0},siemens:{name:"siemens",base:R.ELECTRIC_CONDUCTANCE,prefixes:I.LONG,value:1,offset:0},S:{name:"S",base:R.ELECTRIC_CONDUCTANCE,prefixes:I.SHORT,value:1,offset:0},weber:{name:"weber",base:R.MAGNETIC_FLUX,prefixes:I.LONG,value:1,offset:0},Wb:{name:"Wb",base:R.MAGNETIC_FLUX,prefixes:I.SHORT,value:1,offset:0},tesla:{name:"tesla",base:R.MAGNETIC_FLUX_DENSITY,prefixes:I.LONG,value:1,offset:0},T:{name:"T",base:R.MAGNETIC_FLUX_DENSITY,prefixes:I.SHORT,value:1,offset:0},b:{name:"b",base:R.BIT,prefixes:I.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:R.BIT,prefixes:I.BINARY_LONG,value:1,offset:0},B:{name:"B",base:R.BIT,prefixes:I.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:R.BIT,prefixes:I.BINARY_LONG,value:8,offset:0}},j={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function H(e){if("BigNumber"===e.number){var t=Cn(N);P.rad.value=new N(1),P.deg.value=t.div(180),P.grad.value=t.div(200),P.cycle.value=t.times(2),P.arcsec.value=t.div(648e3),P.arcmin.value=t.div(10800)}else P.rad.value=1,P.deg.value=Math.PI/180,P.grad.value=Math.PI/200,P.cycle.value=2*Math.PI,P.arcsec.value=Math.PI/648e3,P.arcmin.value=Math.PI/10800;P.radian.value=P.rad.value,P.degree.value=P.deg.value,P.gradian.value=P.grad.value}H(s),a&&a("config",(function(e,t){e.number!==t.number&&H(e)}));var G={si:{NONE:{unit:U,prefix:I.NONE[""]},LENGTH:{unit:P.m,prefix:I.SHORT[""]},MASS:{unit:P.g,prefix:I.SHORT.k},TIME:{unit:P.s,prefix:I.SHORT[""]},CURRENT:{unit:P.A,prefix:I.SHORT[""]},TEMPERATURE:{unit:P.K,prefix:I.SHORT[""]},LUMINOUS_INTENSITY:{unit:P.cd,prefix:I.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:P.mol,prefix:I.SHORT[""]},ANGLE:{unit:P.rad,prefix:I.SHORT[""]},BIT:{unit:P.bits,prefix:I.SHORT[""]},FORCE:{unit:P.N,prefix:I.SHORT[""]},ENERGY:{unit:P.J,prefix:I.SHORT[""]},POWER:{unit:P.W,prefix:I.SHORT[""]},PRESSURE:{unit:P.Pa,prefix:I.SHORT[""]},ELECTRIC_CHARGE:{unit:P.C,prefix:I.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:P.F,prefix:I.SHORT[""]},ELECTRIC_POTENTIAL:{unit:P.V,prefix:I.SHORT[""]},ELECTRIC_RESISTANCE:{unit:P.ohm,prefix:I.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:P.H,prefix:I.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:P.S,prefix:I.SHORT[""]},MAGNETIC_FLUX:{unit:P.Wb,prefix:I.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:P.T,prefix:I.SHORT[""]},FREQUENCY:{unit:P.Hz,prefix:I.SHORT[""]}}};G.cgs=JSON.parse(JSON.stringify(G.si)),G.cgs.LENGTH={unit:P.m,prefix:I.SHORT.c},G.cgs.MASS={unit:P.g,prefix:I.SHORT[""]},G.cgs.FORCE={unit:P.dyn,prefix:I.SHORT[""]},G.cgs.ENERGY={unit:P.erg,prefix:I.NONE[""]},G.us=JSON.parse(JSON.stringify(G.si)),G.us.LENGTH={unit:P.ft,prefix:I.NONE[""]},G.us.MASS={unit:P.lbm,prefix:I.NONE[""]},G.us.TEMPERATURE={unit:P.degF,prefix:I.NONE[""]},G.us.FORCE={unit:P.lbf,prefix:I.NONE[""]},G.us.ENERGY={unit:P.BTU,prefix:I.BTU[""]},G.us.POWER={unit:P.hp,prefix:I.NONE[""]},G.us.PRESSURE={unit:P.psi,prefix:I.NONE[""]},G.auto=JSON.parse(JSON.stringify(G.si));var V=G.auto;for(var W in E.setUnitSystem=function(e){if(!Z(G,e))throw new Error("Unit system "+e+" does not exist. Choices are: "+Object.keys(G).join(", "));V=G[e]},E.getUnitSystem=function(){for(var e in G)if(Z(G,e)&&G[e]===V)return e},E.typeConverters={BigNumber:function(e){return new N(e+"")},Fraction:function(e){return new M(e)},Complex:function(e){return e},number:function(e){return e}},E._getNumberConverter=function(e){if(!E.typeConverters[e])throw new TypeError('Unsupported type "'+e+'"');return E.typeConverters[e]},P)if(Z(P,W)){var J=P[W];J.dimensions=J.base.dimensions}for(var Y in j)if(Z(j,Y)){var X=P[j[Y]],Q={};for(var K in X)Z(X,K)&&(Q[K]=X[K]);Q.name=Y,P[Y]=Q}return E.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)},E.createUnit=function(e,t){if("object"!=typeof e)throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(t&&t.override)for(var r in e)if(Z(e,r)&&E.deleteUnit(r),e[r].aliases)for(var n=0;n0&&!E.isValidAlpha(i)&&!O(i))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+e+'"')}}(e);var n,a,o,s=null,u=[],c=0;if(t&&"Unit"===t.type)s=t.clone();else if("string"==typeof t)""!==t&&(n=t);else{if("object"!=typeof t)throw new TypeError('Cannot create unit "'+e+'" from "'+t.toString()+'": expecting "string" or "Unit" or "Object"');n=t.definition,a=t.prefixes,c=t.offset,o=t.baseName,t.aliases&&(u=t.aliases.valueOf())}if(u)for(var l=0;l1e-12){h=!1;break}if(h){p=!0,f.base=R[m];break}}if(!p){o=o||e+"_STUFF";var y={dimensions:s.dimensions.slice(0)};y.key=o,R[o]=y,V[o]={unit:f,prefix:I.NONE[""]},f.base=R[o]}}else{if(o=o||e+"_STUFF",k.indexOf(o)>=0)throw new Error('Cannot create new base unit "'+e+'": a base unit with that name already exists (and cannot be overridden)');for(var g in k.push(o),R)Z(R,g)&&(R[g].dimensions[k.length-1]=0);for(var v={dimensions:[]},x=0;x{var{typed:t,Unit:r}=e;return t(pm,{"Object, Object":function(e,t){return r.createUnit(e,t)},Object:function(e){return r.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,t,n){var i={};return i[e]=t,r.createUnit(i,n)},"string, Unit | string | Object":function(e,t){var n={};return n[e]=t,r.createUnit(n,{})},string:function(e){var t={};return t[e]={},r.createUnit(t,{})}})}));var hm=W("eigs",["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","divideScalar","inv","bignumber","multiply","add","larger","column","flatten","number","complex","sqrt","diag","qr","usolveAll","im","re","smaller","round","log10","transpose","matrixFromColumns"],(e=>{var{config:t,typed:r,matrix:n,addScalar:u,subtract:c,equal:l,abs:f,atan:p,cos:m,sin:h,multiplyScalar:d,divideScalar:y,inv:g,bignumber:v,multiply:x,add:b,larger:w,column:N,flatten:M,number:S,complex:E,sqrt:A,diag:O,qr:C,usolveAll:_,im:T,re:B,smaller:q,round:z,log10:D,transpose:I,matrixFromColumns:k}=e,R=function(e){var{config:t,addScalar:r,subtract:n,abs:i,atan:a,cos:o,sin:s,multiplyScalar:u,inv:c,bignumber:l,multiply:f,add:p}=e;function m(e,r){for(var n,i=e.length,a=Math.abs(r/i),o=new Array(i),s=0;s=Math.abs(a);){var c=u[0][0],l=u[0][1];e=v(e,(f=e[c][c],p=e[l][l],m=e[c][l],h=void 0,h=p-f,n=Math.abs(h)<=t.epsilon?Math.PI/4:.5*Math.atan(2*m/(p-f))),c,l),o=d(o,n,c,l),u=x(e)}for(var f,p,m,h,y=N(i,0),g=0;g=i(p);){var v=d[0][0],x=d[0][1];e=g(e,(M=e[v][v],S=e[x][x],E=e[v][x],A=void 0,A=n(S,M),o=i(A)<=t.epsilon?l(-1).acos().div(4):u(.5,a(f(2,E,c(A))))),v,x),m=y(m,o,v,x),d=b(e)}for(var M,S,E,A,O=N(s,0),C=0;C2&&void 0!==arguments[2]?arguments[2]:t.epsilon,i=arguments.length>3?arguments[3]:void 0;if("number"===i)return m(e,n);if("BigNumber"===i)return h(e,n);throw TypeError("Unsupported data type: "+i)}}({config:t,addScalar:u,subtract:c,column:N,flatten:M,equal:l,abs:f,atan:p,cos:m,sin:h,multiplyScalar:d,inv:g,bignumber:v,complex:E,multiply:x,add:b}),F=function(e){var{addScalar:t,subtract:r,flatten:n,multiply:i,multiplyScalar:a,divideScalar:o,sqrt:s,abs:u,bignumber:c,diag:l,inv:f,qr:p,usolveAll:m,equal:h,complex:d,larger:y,smaller:g,round:v,log10:x,transpose:b,matrixFromColumns:w}=e;function N(e,t,n,i,a,o,s,l){var f="BigNumber"===l,p="Complex"===l,m=f?c(0):p?d(0):0,h=f?c(1):p?d(1):1;if(g(u(n),s))return[[h,m],[m,h]];if(y(u(r(a,o)),s))return[[r(a,i),r(o,i)],[n,n]];var v=r(e,a),x=r(t,a),b=r(n,a),w=r(i,a);return g(u(x),s)?[[v,h],[b,m]]:[[x,m],[w,h]]}function M(e,t){for(var r=0;r1&&(D=l(Array(B-1).fill(v)))),B-=1,_.pop();for(var P=0;P2&&(D=l(Array(B-2).fill(v)))),B-=2,_.pop(),_.pop();for(var L=0;L+r(u(e),u(t)))),I>100){var H=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+T.join(", "));throw H.values=T,H.vectors=[],H}return{values:T,C:m?i(z,function(e,t){for(var r=[],n=0;ni(a,e)))).shift(),_.lengthn(e))))}if(0!==A.length){var T=new Error("Failed to find eigenvectors for the following eigenvalues: "+A.join(", "));throw T.values=o,T.vectors=w,T}return w}(e,b,B,T,E),_=w(..._)),{values:T,vectors:_}}}({config:t,addScalar:u,subtract:c,multiply:x,multiplyScalar:d,flatten:M,divideScalar:y,sqrt:A,abs:f,bignumber:v,diag:O,qr:C,inv:g,usolveAll:_,equal:l,complex:E,larger:w,smaller:q,round:z,log10:D,transpose:I,matrixFromColumns:k});return r("eigs",{Array:function(e){return U(n(e))},"Array, number|BigNumber":function(e,t){return U(n(e),t)},Matrix:function(e){var{values:t,vectors:r}=U(e);return{values:n(t),vectors:n(r)}},"Matrix, number|BigNumber":function(e,t){var{values:r,vectors:i}=U(e,t);return{values:n(r),vectors:n(i)}}});function U(e,r){void 0===r&&(r=t.epsilon);var n=e.size();if(2!==n.length||n[0]!==n[1])throw new RangeError("Matrix must be square (size: "+De(n)+")");var i=e.toArray(),a=n[0];if(function(e,t,r){for(var n=0;n{var{typed:t,config:r,abs:n,add:i,addScalar:o,matrix:s,multiply:u,multiplyScalar:c,divideScalar:l,subtract:f,smaller:p,equalScalar:m}=e;return t("intersect",{"Array, Array, Array":function(e,t,r){if(!y(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!y(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!function(e){return 4===e.length&&h(e[0])&&h(e[1])&&h(e[2])&&h(e[3])}(r))throw new TypeError("Array with 4 numbers expected as third argument");return function(e,t,r,n,i,a,s,u,p,m){var h=c(e,s),d=c(n,s),y=c(t,u),g=c(i,u),v=c(r,p),x=c(a,p),b=l(f(f(f(m,h),y),v),f(f(f(o(o(d,g),x),h),y),v));return[o(e,c(b,f(n,e))),o(t,c(b,f(i,t))),o(r,c(b,f(a,r)))]}(e[0],e[1],e[2],t[0],t[1],t[2],r[0],r[1],r[2],r[3])},"Array, Array, Array, Array":function(e,t,a,s){if(2===e.length){if(!d(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!d(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!d(a))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!d(s))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return function(e,t,a,s){var m=e,h=a,d=f(m,t),y=f(h,s),g=f(c(d[0],y[1]),c(y[0],d[1]));if(p(n(g),r.epsilon))return null;var v=c(y[0],m[1]),x=c(y[1],m[0]),b=c(y[0],h[1]),w=c(y[1],h[0]),N=l(o(f(f(v,x),b),w),g);return i(u(d,N),m)}(e,t,a,s)}if(3===e.length){if(!y(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!y(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!y(a))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!y(s))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return h=e[0],v=e[1],x=e[2],b=t[0],w=t[1],N=t[2],M=a[0],S=a[1],E=a[2],_=g(h,M,A=s[0],M,v,S,O=s[1],S,x,E,C=s[2],E),T=g(A,M,b,h,O,S,w,v,C,E,N,x),B=g(h,M,b,h,v,S,w,v,x,E,N,x),q=g(A,M,A,M,O,S,O,S,C,E,C,E),z=g(b,h,b,h,w,v,w,v,N,x,N,x),D=l(f(c(_,T),c(B,q)),f(c(z,q),c(T,T))),I=l(o(_,c(D,T)),q),k=o(h,c(D,f(b,h))),R=o(v,c(D,f(w,v))),F=o(x,c(D,f(N,x))),U=o(M,c(I,f(A,M))),P=o(S,c(I,f(O,S))),j=o(E,c(I,f(C,E))),m(k,U)&&m(R,P)&&m(F,j)?[k,R,F]:null}throw new TypeError("Arrays with two or thee dimensional points expected");var h,v,x,b,w,N,M,S,E,A,O,C,_,T,B,q,z,D,I,k,R,F,U,P,j},"Matrix, Matrix, Matrix":function(e,t,r){return s(this(e.valueOf(),t.valueOf(),r.valueOf()))},"Matrix, Matrix, Matrix, Matrix":function(e,t,r,n){return s(this(e.valueOf(),t.valueOf(),r.valueOf(),n.valueOf()))}});function h(e){return"number"==typeof e||a(e)}function d(e){return 2===e.length&&h(e[0])&&h(e[1])}function y(e){return 3===e.length&&h(e[0])&&h(e[1])&&h(e[2])}function g(e,t,r,n,i,a,s,u,l,p,m,h){var d=c(f(e,t),f(r,n)),y=c(f(i,a),f(s,u)),g=c(f(l,p),f(m,h));return o(o(d,y),g)}})),ym="usolve",gm=W(ym,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(ym,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=(t=u(e,t,!0))._data,c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=[],d=l-1;d>=0;d--){var y=r[d][0]||0;if(o(y,0))h[d]=[0];else{for(var g=0,v=[],x=[],b=m[d],w=m[d+1]-1;w>=b;w--){var N=p[w];N===d?g=f[w]:N=0;m--){var h=r[m][0]||0,d=void 0;if(o(h,0))d=0;else{var y=p[m][m];if(o(y,0))throw new Error("Linear system cannot be solved since matrix is singular");d=n(h,y);for(var g=m-1;g>=0;g--)r[g]=[a(r[g][0]||0,i(d,p[g][m]))]}f[m]=[d]}return new s({data:f,size:[c,1]})}})),vm="norm",xm=W(vm,["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],(e=>{var{typed:t,abs:r,add:n,pow:i,conj:a,sqrt:o,multiply:s,equalScalar:u,larger:c,smaller:l,matrix:f,ctranspose:p,eigs:m}=e;return t(vm,{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},boolean:function(e){return Math.abs(e)},Array:function(e){return h(f(e),2)},Matrix:function(e){return h(e,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(e){return this(e)},"Array, number | BigNumber | string":function(e,t){return h(f(e),t)},"Matrix, number | BigNumber | string":function(e,t){return h(e,t)}});function h(e,t){var f=e.size();if(1===f.length)return function(e,t){if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=0;return e.forEach((function(e){var n=r(e);c(n,t)&&(t=n)}),!0),t}(e);if(t===Number.NEGATIVE_INFINITY||"-inf"===t)return function(e){var t;return e.forEach((function(e){var n=r(e);t&&!l(n,t)||(t=n)}),!0),t||0}(e);if("fro"===t)return h(e,2);if("number"==typeof t&&!isNaN(t)){if(!u(t,0)){var a=0;return e.forEach((function(e){a=n(i(r(e),t),a)}),!0),i(a,1/t)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}(e,t);if(2===f.length){if(f[0]&&f[1])return function(e,t){if(1===t)return function(e){var t=[],i=0;return e.forEach((function(e,a){var o=a[1],s=n(t[o]||0,r(e));c(s,i)&&(i=s),t[o]=s}),!0),i}(e);if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=[],i=0;return e.forEach((function(e,a){var o=a[0],s=n(t[o]||0,r(e));c(s,i)&&(i=s),t[o]=s}),!0),i}(e);if("fro"===t)return function(e){var t=0;return e.forEach((function(e,r){t=n(t,s(e,a(e)))})),r(o(t))}(e);if(2===t)return function(e){var t=e.size();if(t[0]!==t[1])throw new RangeError("Invalid matrix dimensions");var n=p(e),i=s(n,e),a=m(i).values.toArray(),u=a[a.length-1];return r(o(u))}(e);throw new Error("Unsupported parameter value "+t)}(e,t);throw new RangeError("Invalid matrix dimensions")}}}));function bm(e,t){var r,n=t.length,i=[];if(e)for(r=0;r{var{typed:t,matrix:r,lup:n,slu:i,usolve:a,lsolve:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(wm,{"Array, Array | Matrix":function(e,t){e=r(e);var i=n(e);return p(i.L,i.U,i.p,null,t).valueOf()},"DenseMatrix, Array | Matrix":function(e,t){var r=n(e);return p(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){var r=n(e);return p(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,r,n){var a=i(e,r,n);return p(a.L,a.U,a.p,a.q,t)},"Object, Array | Matrix":function(e,t){return p(e.L,e.U,e.p,e.q,t)}});function c(e){if(f(e))return e;if(l(e))return r(e);throw new TypeError("Invalid Matrix LU decomposition")}function p(e,t,r,n,i){e=c(e),t=c(t),r&&((i=u(e,i,!0))._data=bm(r,i._data));var s=o(e,i),l=a(t,s);return n&&(l._data=bm(n,l._data)),l}})),Sm="sqrtm",Em=["typed","abs","add","multiply","sqrt","subtract","inv","size","max","identity"],Am=W(Sm,Em,(e=>{var{typed:t,abs:r,add:n,multiply:i,sqrt:a,subtract:o,inv:s,size:u,max:c,identity:l}=e,p=1e-6;function m(e){var t,a=0,f=e,m=l(u(e));do{var h=f;if(f=i(.5,n(h,s(m))),m=i(.5,n(m,s(h))),(t=c(r(o(f,h))))>p&&++a>1e3)throw new Error("computing square root of matrix: iterative method could not converge")}while(t>p);return f}return t(Sm,{"Array | Matrix":function(e){var t=f(e)?e.size():je(e);switch(t.length){case 1:if(1===t[0])return a(e);throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:if(t[0]===t[1])return m(e);throw new RangeError("Matrix must be square (size: "+De(t)+")");default:throw new RangeError("Matrix must be at most two dimensional (size: "+De(t)+")")}}})})),Om="multinomial",Cm=["typed","add","divide","multiply","factorial","isInteger","isPositive"],_m=W(Om,Cm,(e=>{var{typed:t,add:r,divide:n,multiply:i,factorial:a,isInteger:o,isPositive:s}=e;return t(Om,{"Array | Matrix":function(e){var t=0,u=1;return Ht(e,(function(e){if(!o(e)||!s(e))throw new TypeError("Positive integer value expected in function multinomial");t=r(t,e),u=i(u,a(e))})),n(a(t),u)}})})),Tm="rotationMatrix",Bm=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],qm=W(Tm,Bm,(e=>{var{typed:t,config:r,multiplyScalar:n,addScalar:i,unaryMinus:o,norm:s,BigNumber:u,matrix:c,DenseMatrix:l,SparseMatrix:f,cos:p,sin:m}=e;return t(Tm,{"":function(){return"Matrix"===r.matrix?c([]):[]},string:function(e){return c(e)},"number | BigNumber | Complex | Unit":function(e){return h(e,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(e,t){return h(e,t)},"number | BigNumber | Complex | Unit, Array":function(e,t){var r=c(t);return d(r),v(e,r,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,t){d(t);var n=t.storage()||("Matrix"===r.matrix?"dense":void 0);return v(e,t,n)},"number | BigNumber | Complex | Unit, Array, string":function(e,t,r){var n=c(t);return d(n),v(e,n,r)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,t,r){return d(t),v(e,t,r)}});function h(e,t){var r=a(e)?new u(-1):-1,i=p(e),o=m(e);return g([[i,n(r,o)],[o,i]],t)}function d(e){var t=e.size();if(t.length<1||3!==t[0])throw new RangeError("Vector must be of dimensions 1x3")}function y(e){return e.reduce(((e,t)=>n(e,t)))}function g(e,t){if(t){if("sparse"===t)return new f(e);if("dense"===t)return new l(e);throw new TypeError('Unknown matrix type "'.concat(t,'"'))}return e}function v(e,t,r){var n=s(t);if(0===n)throw new RangeError("Rotation around zero vector");var c=a(e)?u:null,l=c?new c(1):1,f=c?new c(-1):-1,h=c?new c(t.get([0])/n):t.get([0])/n,d=c?new c(t.get([1])/n):t.get([1])/n,v=c?new c(t.get([2])/n):t.get([2])/n,x=p(e),b=i(l,o(x)),w=m(e);return g([[i(x,y([h,h,b])),i(y([h,d,b]),y([f,v,w])),i(y([h,v,b]),y([d,w]))],[i(y([h,d,b]),y([v,w])),i(x,y([d,d,b])),i(y([d,v,b]),y([f,h,w]))],[i(y([h,v,b]),y([f,d,w])),i(y([d,v,b]),y([h,w])),i(x,y([v,v,b]))]],r)}})),zm="median",Dm=["typed","add","divide","compare","partitionSelect"],Im=W(zm,Dm,(e=>{var{typed:t,add:r,divide:n,compare:i,partitionSelect:a}=e;function o(e){try{var t=(e=et(e.valueOf())).length;if(0===t)throw new Error("Cannot calculate median of an empty array");if(t%2==0){for(var r=t/2-1,n=a(e,r+1),o=e[r],c=0;c0&&(o=e[c]);return u(o,n)}var l=a(e,(t-1)/2);return s(l)}catch(e){throw Gr(e,"median")}}var s=t({"number | BigNumber | Complex | Unit":function(e){return e}}),u=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,t){return n(r(e,t),2)}});return t(zm,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("median(A, dim) is not yet supported")},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function median");return o(e)}})})),km="rotate",Rm=["typed","multiply","rotationMatrix"],Fm=W(km,Rm,(e=>{var{typed:t,multiply:r,rotationMatrix:n}=e;return t(km,{"Array , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),r(n(t),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),r(n(t),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),r(n(t,a),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),r(n(t,a),e)}});function i(e,t){var r=Array.isArray(e)?je(e):e.size();if(r.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(t));if(2===r.length&&1!==r[1])throw new RangeError("Vector must be of dimensions 1x".concat(t));if(r[0]!==t)throw new RangeError("Vector must be of dimensions 1x".concat(t))}})),Um=["typed","abs","map","median","subtract"],Pm=W("mad",Um,(e=>{var{typed:t,abs:r,map:n,median:i,subtract:a}=e;return t("mad",{"Array | Matrix":o,"...":function(e){return o(e)}});function o(e){if(0===(e=et(e.valueOf())).length)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var t=i(e);return i(n(e,(function(e){return r(a(e,t))})))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf("median")?new TypeError(e.message.replace("median","mad")):Gr(e,"mad")}}})),jm="unit",Lm=["typed","Unit"],Hm=W(jm,Lm,(e=>{var{typed:t,Unit:r}=e;return t(jm,{Unit:function(e){return e.clone()},string:function(e){return r.isValuelessUnit(e)?new r(null,e):r.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string":function(e,t){return new r(e,t)},"Array | Matrix":function(e){return $t(e,this)}})})),$m=Nn({}),Gm=Sn({}),Vm=En({}),Zm=In({}),Wm=kn({}),Jm=Dn({}),Ym=Kn({config:n}),Xm=ei({}),Qm=ti({}),Km=Jn({Complex:Gm}),eh=$n({BigNumber:Ym,config:n}),th=Vn({BigNumber:Ym,config:n}),rh=Fn({BigNumber:Ym,config:n}),nh=Un({BigNumber:Ym,config:n}),ih=Zn({BigNumber:Ym,config:n}),ah=Pn({BigNumber:Ym,config:n}),oh=Ti({BigNumber:Ym,config:n}),sh=wi({BigNumber:Ym,config:n}),uh=Pi({BigNumber:Ym,config:n}),ch=_i({BigNumber:Ym,config:n}),lh=ta({}),fh=jn({BigNumber:Ym,config:n}),ph=Rn({BigNumber:Ym,config:n}),mh=Gn({BigNumber:Ym,config:n}),hh=Yn({}),dh=ra({Matrix:Xm}),yh=Ln({BigNumber:Ym,config:n}),gh=aa({BigNumber:Ym,Complex:Gm,DenseMatrix:dh,Fraction:lh}),vh=la({typed:gh}),xh=pa({typed:gh}),bh=xa({typed:gh}),wh=wa({typed:gh}),Nh=Sa({config:n,typed:gh}),Mh=Ea({typed:gh}),Sh=Oa({typed:gh}),Eh=Ca({Complex:Gm,typed:gh}),Ah=Ta({typed:gh}),Oh=ro({BigNumber:Ym,config:n,typed:gh}),Ch=wr({isInteger:vh,typed:gh}),_h=io({typed:gh}),Th=oo({Complex:Gm,typed:gh}),Bh=uo({Complex:Gm,config:n,typed:gh}),qh=co({typed:gh}),zh=fo({BigNumber:Ym,Fraction:lh,complex:Eh,typed:gh}),Dh=mo({typed:gh}),Ih=qo({typed:gh}),kh=zo({typed:gh}),Rh=Do({typed:gh}),Fh=Po({typed:gh}),Uh=jo({typed:gh}),Ph=$o({typed:gh}),jh=Vo({typed:gh}),Lh=Wo({typed:gh}),Hh=ts({typed:gh}),$h=rs({format:Hh,typed:gh}),Gh=is({typed:gh}),Vh=ss({typed:gh}),Zh=cs({Complex:Gm,config:n,typed:gh}),Wh=Cs({BigNumber:Ym,typed:gh}),Jh=Ts({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),Yh=qs({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),Xh=Ds({Complex:Gm,config:n,typed:gh}),Qh=Is({typed:gh}),Kh=Rs({Complex:Gm,config:n,typed:gh}),ed=Us({typed:gh}),td=js({BigNumber:Ym,typed:gh}),rd=Hs({BigNumber:Ym,typed:gh}),nd=Gs({BigNumber:Ym,typed:gh}),id=Zs({typed:gh}),ad=Ws({typed:gh}),od=Qs({typed:gh}),sd=iu({config:n,typed:gh}),ud=su({config:n,typed:gh}),cd=Hn({BigNumber:Ym,config:n}),ld=cu({typed:gh}),fd=fu({isNumeric:xh,typed:gh}),pd=mu({typed:gh}),md=du({typed:gh}),hd=yu({Fraction:lh,typed:gh}),dd=vu({typed:gh}),yd=bu({typed:gh}),gd=wu({typed:gh}),vd=Mu({Complex:Gm,config:n,typed:gh}),xd=Su({Complex:Gm,config:n,typed:gh}),bd=Au({typed:gh}),wd=Cu({typed:gh}),Nd=Tu({isNaN:wh,isNumeric:xh,typed:gh}),Md=Bu({format:Hh,typed:gh}),Sd=zu({Complex:Gm,config:n,typed:gh}),Ed=Iu({BigNumber:Ym,typed:gh}),Ad=ku({typed:gh}),Od=Ru({typed:gh}),Cd=Fu({BigNumber:Ym,typed:gh}),_d=Uu({typed:gh}),Td=ju({typed:gh}),Bd=$u({config:n,typed:gh}),qd=Wn({BigNumber:Ym,config:n}),zd=Vu({typed:gh}),Dd=Zu({Matrix:Xm,equalScalar:Nh,typed:gh}),Id=Ju({DenseMatrix:dh,Matrix:Xm,SparseMatrix:Dd,typed:gh}),kd=Yu({typed:gh}),Rd=rc({BigNumber:Ym,DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),Fd=uc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),Ud=fc({BigNumber:Ym,equalScalar:Nh,matrix:Id,typed:gh}),Pd=mc({BigNumber:Ym,config:n,matrix:Id,typed:gh}),jd=dc({equalScalar:Nh,matrix:Id,typed:gh}),Ld=vc({DenseMatrix:dh,matrix:Id,typed:gh}),Hd=xc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),$d=Lr({isInteger:vh,matrix:Id,typed:gh}),Gd=wc({DenseMatrix:dh,SparseMatrix:Dd,matrix:Id,typed:gh}),Vd=Mc({BigNumber:Ym,DenseMatrix:dh,SparseMatrix:Dd,config:n,matrix:Id,typed:gh}),Zd=Sc({BigNumber:Ym,config:n,matrix:Id,typed:gh}),Wd=Ac({isInteger:vh,matrix:Id,typed:gh}),Jd=Cc({matrix:Id,config:n,typed:gh}),Yd=Dr({matrix:Id,typed:gh}),Xd=Tc({BigNumber:Ym,config:n,matrix:Id,typed:gh}),Qd=Bc({format:Hh,typed:gh}),Kd=Rc({BigNumber:Ym,DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),ey=jc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),ty=Hc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),ry=Gc({BigNumber:Ym,DenseMatrix:dh,Fraction:lh,config:n,equalScalar:Nh,matrix:Id,typed:gh}),ny=Zc({matrix:Id,typed:gh}),iy=Jc({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),ay=Xc({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),oy=Kc({DenseMatrix:dh,config:n,equalScalar:Nh,matrix:Id,typed:gh}),sy=el({DenseMatrix:dh,smaller:iy}),uy=tl({larger:ay,smaller:iy}),cy=nl({SparseMatrix:Dd,typed:gh}),ly=al({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),fy=ul({BigNumber:Ym,DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),py=cl({BigNumber:Ym,typed:gh}),my=ll({DenseMatrix:dh,SparseMatrix:Dd,addScalar:yd,equalScalar:Nh,matrix:Id,typed:gh}),hy=fl({addScalar:yd,conj:bd,multiplyScalar:qh,size:Jd,typed:gh}),dy=ml({addScalar:yd,combinations:od,isInteger:vh,isNegative:zd,isPositive:bh,larger:ay,typed:gh}),yy=dl({typed:gh}),gy=gl({isZero:yy,matrix:Id,typed:gh}),vy=xl({BigNumber:Ym,Complex:Gm,Fraction:lh,config:n,isNegative:zd,matrix:Id,typed:gh,unaryMinus:dd}),xy=bl({config:n,equalScalar:Nh,matrix:Id,round:Kd,typed:gh}),by=Nl({addScalar:yd,dot:hy,equalScalar:Nh,matrix:Id,multiplyScalar:qh,typed:gh}),wy=Sl({equalScalar:Nh,matrix:Id,multiplyScalar:qh,typed:gh}),Ny=El({typed:gh}),My=Ol({matrix:Id,typed:gh}),Sy=_l({config:n,matrix:Id}),Ey=Bl({matrix:Id,typed:gh}),Ay=ql({matrix:Id,typed:gh}),Oy=zl({Complex:Gm,config:n,fraction:hd,identity:Vd,matrix:Id,multiply:by,number:Mh,typed:gh}),Cy=Il({DenseMatrix:dh,equalScalar:Nh,matrix:Id,pow:Oy,typed:gh}),_y=Rl({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),Ty=Pl({compare:ry,typed:gh}),By=Ll({compareText:ny,isZero:yy,typed:gh}),qy=$l({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),zy=Vl({compare:ry,isNaN:wh,isNumeric:xh,typed:gh}),Dy=Zl({ImmutableDenseMatrix:sy}),Iy=Jl({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),ky=Yl({typed:gh}),Ry=Ql({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Fy=ef({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Uy=rf({Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Py=af({compareNatural:Ty,typed:gh}),jy=of({add:my,matrix:Id,typed:gh}),Ly=sf({add:my,compare:ry,multiply:by,partitionSelect:zy,typed:gh}),Hy=pf({BigNumber:Ym,Complex:Gm,config:n,multiplyScalar:qh,pow:Oy,typed:gh}),$y=mf({BigNumber:Ym,typed:gh}),Gy=df({flatten:My,matrix:Id,size:Jd,typed:gh}),Vy=yf({equalScalar:Nh,matrix:Id,typed:gh}),Zy=vf({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),Wy=bf({matrix:Id,multiplyScalar:qh,typed:gh}),Jy=wf({matrix:Id,typed:gh}),Yy=Nf({bignumber:$y,fraction:hd,number:Mh}),Xy=Mf({equalScalar:Nh,matrix:Id,not:Fh,typed:gh,zeros:Xd}),Qy=Ef({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),Ky=Of({compare:ry,compareNatural:Ty,matrix:Id,typed:gh}),eg=Jr({config:n,numeric:Yy,smaller:iy,typed:gh}),tg=Cf({BigNumber:Ym,typed:gh}),rg=Tf({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),ng=qf({Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),ig=Df({Index:Dy,typed:gh}),ag=Xr({add:my,config:n,numeric:Yy,typed:gh}),og=kf({gamma:Hy,typed:gh}),sg=Ff({factorial:og,typed:gh}),ug=jf({flatten:My,matrix:Id,size:Jd,typed:gh}),cg=Hf({DenseMatrix:dh,addScalar:yd,equalScalar:Nh,matrix:Id,typed:gh,unaryMinus:dd}),lg=Vf({matrix:Id,multiply:by,subtract:cg,typed:gh}),fg=nn({bignumber:$y,matrix:Id,config:n,larger:ay,largerEq:qy,smaller:iy,smallerEq:Qy,typed:gh}),pg=ln({Index:Dy,matrix:Id,range:fg,typed:gh}),mg=Wf({config:n,multiplyScalar:qh,numeric:Yy,typed:gh}),hg=Yf({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),dg=Vr({config:n,larger:ay,numeric:Yy,typed:gh}),yg=Qf({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),gg=ep({Index:Dy,concat:$d,setDifference:Ry,size:Jd,subset:Yd,typed:gh}),vg=tp({config:n,equalScalar:Nh,matrix:Id,round:Kd,typed:gh}),xg=rp({DenseMatrix:dh,matrix:Id,typed:gh}),bg=ip({prod:mg,size:Jd,typed:gh}),wg=op({conj:bd,transpose:Jy,typed:gh}),Ng=up({equal:hg,typed:gh}),Mg=lp({Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Sg=fp({Complex:Gm,ceil:vg,floor:xy,matrix:Id,typed:gh}),Eg=sn({matrix:Id,number:Mh,subtract:cg,typed:gh}),Ag=mp({numeric:Yy,typed:gh}),Og=dp({Complex:Gm,config:n,divideScalar:Ag,typed:gh}),Cg=vp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),_g=bp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),Tg=wp({FibonacciHeap:uy,addScalar:yd,equalScalar:Nh}),Bg=Mp({Index:Dy,concat:$d,setIntersect:Fy,setSymDifference:gg,size:Jd,subset:Yd,typed:gh}),qg=Sp({DenseMatrix:dh,Spa:Tg,SparseMatrix:Dd,abs:kd,addScalar:yd,divideScalar:Ag,equalScalar:Nh,larger:ay,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh,unaryMinus:dd}),zg=Rp({SparseMatrix:Dd,abs:kd,add:my,divideScalar:Ag,larger:ay,largerEq:qy,multiply:by,subtract:cg,transpose:Jy,typed:gh}),Dg=Fp({lup:qg,matrix:Id,multiply:by,subtract:cg,typed:gh,unaryMinus:dd}),Ig=Pp({abs:kd,addScalar:yd,divideScalar:Ag,multiplyScalar:qh,sqrt:xd,subtract:cg,typed:gh,unaryMinus:dd}),kg=Lp({addScalar:yd,combinations:od,divideScalar:Ag,factorial:og,isInteger:vh,isNegative:zd,larger:ay,multiplyScalar:qh,pow:Oy,subtract:cg,typed:gh}),Rg=$p({addScalar:yd,combinations:od,divideScalar:Ag,isInteger:vh,isNegative:zd,multiplyScalar:qh,typed:gh}),Fg=en({Index:Dy,matrix:Id,range:fg,typed:gh}),Ug=Gp({Complex:Gm,config:n,divideScalar:Ag,typed:gh}),Pg=Zp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,typed:gh}),jg=Jp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),Lg=Xp({abs:kd,addScalar:yd,divideScalar:Ag,isPositive:bh,multiplyScalar:qh,smaller:iy,sqrt:xd,typed:gh}),Hg=Qp({addScalar:yd,complex:Eh,conj:bd,divideScalar:Ag,equal:hg,identity:Vd,isZero:yy,matrix:Id,multiplyScalar:qh,sign:zh,sqrt:xd,subtract:cg,typed:gh,unaryMinus:dd,zeros:Xd}),$g=Kp({abs:kd,addScalar:yd,det:Dg,divideScalar:Ag,identity:Vd,matrix:Id,multiply:by,typed:gh,unaryMinus:dd}),Gg=tm({abs:kd,add:my,identity:Vd,inv:$g,multiply:by,typed:gh}),Vg=rm({divideScalar:Ag,equalScalar:Nh,inv:$g,matrix:Id,multiply:by,typed:gh}),Zg=mn({add:my,divide:Vg,typed:gh}),Wg=gn({add:my,apply:Ch,divide:Vg,isNaN:wh,multiply:by,subtract:cg,typed:gh}),Jg=im({divide:Vg,dotDivide:Pg,isNumeric:xh,log:Ug,matrix:Id,multiply:by,sum:ag,typed:gh}),Yg=om({addScalar:yd,isInteger:vh,isNegative:zd,stirlingS2:kg,typed:gh}),Xg=um({Complex:Gm,config:n,divideScalar:Ag,log:Ug,typed:gh}),Qg=fm({BigNumber:Ym,Complex:Gm,Fraction:lh,abs:kd,addScalar:yd,config:n,divideScalar:Ag,equal:hg,fix:Sg,format:Hh,isNumeric:xh,multiplyScalar:qh,number:Mh,pow:Oy,round:Kd,subtract:cg}),Kg=mm({Unit:Qg,typed:gh}),ev=hm({abs:kd,add:my,addScalar:yd,atan:Qh,bignumber:$y,column:Fg,complex:Eh,config:n,cos:Od,diag:Gd,divideScalar:Ag,equal:hg,flatten:My,im:Rh,inv:$g,larger:ay,log10:Bh,matrix:Id,matrixFromColumns:Gy,multiply:by,multiplyScalar:qh,number:Mh,qr:Hg,re:Ny,round:Kd,sin:_d,smaller:iy,sqrt:xd,subtract:cg,transpose:Jy,typed:gh,usolveAll:jg}),tv=dm({abs:kd,add:my,addScalar:yd,config:n,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiply:by,multiplyScalar:qh,smaller:iy,subtract:cg,typed:gh}),rv=bn({sqrt:xd,typed:gh,variance:Wg}),nv=Bi({BigNumber:Ym,Unit:Qg,config:n}),iv=fi({BigNumber:Ym,Unit:Qg,config:n}),av=zi({BigNumber:Ym,Unit:Qg,config:n}),ov=pi({BigNumber:Ym,Unit:Qg,config:n}),sv=Si({BigNumber:Ym,Unit:Qg,config:n}),uv=xi({BigNumber:Ym,Unit:Qg,config:n}),cv=Di({BigNumber:Ym,Unit:Qg,config:n}),lv=Ii({BigNumber:Ym,Unit:Qg,config:n}),fv=ni({BigNumber:Ym,Unit:Qg,config:n}),pv=Ni({BigNumber:Ym,Unit:Qg,config:n}),mv=yi({BigNumber:Ym,Unit:Qg,config:n}),hv=oi({BigNumber:Ym,Unit:Qg,config:n}),dv=$i({BigNumber:Ym,Unit:Qg,config:n}),yv=Fi({BigNumber:Ym,Unit:Qg,config:n}),gv=Ei({BigNumber:Ym,Unit:Qg,config:n}),vv=Yi({BigNumber:Ym,Unit:Qg,config:n}),xv=Zi({BigNumber:Ym,Unit:Qg,config:n}),bv=Xi({BigNumber:Ym,Unit:Qg,config:n}),wv=Mi({BigNumber:Ym,Unit:Qg,config:n}),Nv=ai({BigNumber:Ym,Unit:Qg,config:n}),Mv=ji({BigNumber:Ym,Unit:Qg,config:n}),Sv=Li({BigNumber:Ym,Unit:Qg,config:n}),Ev=ui({BigNumber:Ym,Unit:Qg,config:n}),Av=gm({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),Ov=xm({abs:kd,add:my,conj:bd,ctranspose:wg,eigs:ev,equalScalar:Nh,larger:ay,matrix:Id,multiply:by,pow:Oy,smaller:iy,sqrt:xd,typed:gh}),Cv=Mm({DenseMatrix:dh,lsolve:Cg,lup:qg,matrix:Id,slu:zg,typed:gh,usolve:Av}),_v=Am({abs:kd,add:my,identity:Vd,inv:$g,max:dg,multiply:by,size:Jd,sqrt:xd,subtract:cg,typed:gh}),Tv=_m({add:my,divide:Vg,factorial:og,isInteger:vh,isPositive:bh,multiply:by,typed:gh}),Bv=qi({BigNumber:Ym,Unit:Qg,config:n}),qv=vi({BigNumber:Ym,Unit:Qg,config:n}),zv=si({BigNumber:Ym,Unit:Qg,config:n}),Dv=bi({BigNumber:Ym,Unit:Qg,config:n}),Iv=Vi({BigNumber:Ym,Unit:Qg,config:n}),kv=ki({BigNumber:Ym,Unit:Qg,config:n}),Rv=Gi({BigNumber:Ym,Unit:Qg,config:n}),Fv=di({BigNumber:Ym,Unit:Qg,config:n}),Uv=Wi({BigNumber:Ym,Unit:Qg,config:n}),Pv=Ai({BigNumber:Ym,Unit:Qg,config:n}),jv=ri({BigNumber:Ym,Unit:Qg,config:n}),Lv=Hi({BigNumber:Ym,Unit:Qg,config:n}),Hv=qm({BigNumber:Ym,DenseMatrix:dh,SparseMatrix:Dd,addScalar:yd,config:n,cos:Od,matrix:Id,multiplyScalar:qh,norm:Ov,sin:_d,typed:gh,unaryMinus:dd}),$v=Im({add:my,compare:ry,divide:Vg,partitionSelect:zy,typed:gh}),Gv=gi({BigNumber:Ym,Unit:Qg,config:n}),Vv=li({BigNumber:Ym,Unit:Qg,config:n}),Zv=mi({BigNumber:Ym,Unit:Qg,config:n}),Wv=Ui({BigNumber:Ym,Unit:Qg,config:n}),Jv=Ji({BigNumber:Ym,Unit:Qg,config:n}),Yv=Ci({BigNumber:Ym,Unit:Qg,config:n}),Xv=Fm({multiply:by,rotationMatrix:Hv,typed:gh}),Qv=Pm({abs:kd,map:jh,median:$v,subtract:cg,typed:gh}),Kv=ci({BigNumber:Ym,Unit:Qg,config:n}),ex=hi({BigNumber:Ym,Unit:Qg,config:n}),tx=Oi({BigNumber:Ym,Unit:Qg,config:n}),rx=Hm({Unit:Qg,typed:gh}),nx=Ri({BigNumber:Ym,Unit:Qg,config:n}),ix=ii({BigNumber:Ym,Unit:Qg,config:n}),ax={},ox={},sx={},ux=ue({mathWithTransform:ox}),cx=ct({Node:ux}),lx=lt({Node:ux,ResultSet:$m}),fx=vt({Node:ux}),px=xt({Node:ux}),mx=bt({Node:ux}),hx=Et({Node:ux}),dx=At({math:ax}),yx=Ot({classes:sx}),gx=Ct({Node:ux}),vx=_t({Node:ux}),xx=Tt({Node:ux}),bx=Bt({Node:ux,typed:gh}),wx=zt({Chain:dx,typed:gh}),Nx=kt({Node:ux,subset:Yd}),Mx=Rt({Node:ux,Range:Vm,size:Jd}),Sx=Ft({matrix:Id,Node:ux,subset:Yd}),Ex=Ut({Unit:Qg,Node:ux,math:ax}),Ax=jt({Node:ux,SymbolNode:Ex,math:ax}),Ox=Jt({AccessorNode:Nx,ArrayNode:cx,AssignmentNode:Sx,BlockNode:lx,ConditionalNode:gx,ConstantNode:fx,FunctionAssignmentNode:bx,FunctionNode:Ax,IndexNode:Mx,ObjectNode:px,OperatorNode:vx,ParenthesisNode:mx,RangeNode:xx,RelationalNode:hx,SymbolNode:Ex,config:n,numeric:Yy,typed:gh}),Cx=Xt({parse:Ox,typed:gh}),_x=Qt({parse:Ox}),Tx=Kt({parse:Ox}),Bx=ir({Help:_x,mathWithTransform:ox,typed:gh}),qx=or({parse:Ox,typed:gh}),zx=hr({bignumber:$y,fraction:hd,ConstantNode:fx,FunctionNode:Ax,OperatorNode:vx,ParenthesisNode:mx,SymbolNode:Ex,add:my,config:n,divide:Vg,equal:hg,isZero:yy,mathWithTransform:ox,multiply:by,parse:Ox,pow:Oy,subtract:cg,typed:gh}),Dx=yr({bignumber:$y,fraction:hd,ConstantNode:fx,FunctionNode:Ax,OperatorNode:vx,ParenthesisNode:mx,SymbolNode:Ex,add:my,config:n,divide:Vg,equal:hg,isZero:yy,mathWithTransform:ox,multiply:by,parse:Ox,pow:Oy,simplify:zx,subtract:cg,typed:gh}),Ix=vr({Parser:Tx,typed:gh}),kx=xr({ConstantNode:fx,FunctionNode:Ax,OperatorNode:vx,ParenthesisNode:mx,SymbolNode:Ex,config:n,equal:hg,isZero:yy,numeric:Yy,parse:Ox,simplify:zx,typed:gh});e(ax,{reviver:yx,false:Zm,null:Wm,true:Jm,replacer:Qm,i:Km,LN10:eh,LOG10E:th,NaN:rh,pi:nh,SQRT1_2:ih,tau:ah,efimovFactor:oh,fineStructure:sh,sackurTetrode:uh,weakMixingAngle:ch,e:fh,Infinity:ph,LOG2E:mh,PI:nh,version:hh,E:fh,phi:yh,typed:gh,isInteger:vh,isNumeric:xh,isPositive:bh,isNaN:wh,equalScalar:Nh,number:Mh,boolean:Sh,complex:Eh,splitUnit:Ah,unaryPlus:Oh,apply:Ch,cube:_h,expm1:Th,log10:Bh,multiplyScalar:qh,sign:zh,square:Dh,bitNot:Ih,arg:kh,im:Rh,not:Fh,filter:Uh,forEach:Ph,map:jh,erf:Lh,format:Hh,oct:$h,print:Gh,isPrime:Vh,acos:Zh,acot:Wh,acsc:Jh,asec:Yh,asin:Xh,atan:Qh,atanh:Kh,cosh:ed,coth:td,csch:rd,sech:nd,sinh:id,tanh:ad,chain:wx,combinations:od,pickRandom:sd,randomInt:ud,LN2:cd,clone:ld,hasNumericValue:fd,typeOf:pd,string:md,fraction:hd,unaryMinus:dd,addScalar:yd,exp:gd,log2:vd,sqrt:xd,conj:bd,getMatrixDataType:wd,mode:Nd,bin:Md,acosh:Sd,acsch:Ed,asinh:Ad,cos:Od,csc:Cd,sin:_d,combinationsWithRep:Td,random:Bd,SQRT2:qd,isNegative:zd,matrix:Id,abs:kd,gcd:Rd,mod:Fd,nthRoot:Ud,xgcd:Pd,bitAnd:jd,bitXor:Ld,or:Hd,concat:$d,diag:Gd,identity:Vd,ones:Zd,reshape:Wd,size:Jd,subset:Yd,zeros:Xd,hex:Qd,round:Kd,leftShift:ey,rightLogShift:ty,compare:ry,compareText:ny,smaller:iy,larger:ay,unequal:oy,sparse:cy,acoth:ly,atan2:fy,sec:py,add:my,dot:hy,composition:dy,isZero:yy,matrixFromFunction:gy,cbrt:vy,floor:xy,multiply:by,dotMultiply:wy,re:Ny,flatten:My,resize:Sy,squeeze:Ey,to:Ay,pow:Oy,dotPow:Cy,rightArithShift:_y,compareNatural:Ty,equalText:By,largerEq:qy,partitionSelect:zy,asech:Iy,tan:ky,setDifference:Ry,setIntersect:Fy,setMultiplicity:Uy,setSize:Py,trace:jy,quantileSeq:Ly,gamma:Hy,bignumber:$y,matrixFromColumns:Gy,lcm:Vy,bitOr:Zy,kron:Wy,transpose:Jy,numeric:Yy,and:Xy,smallerEq:Qy,sort:Ky,min:eg,cot:tg,setDistinct:rg,setPowerset:ng,index:ig,sum:ag,factorial:og,permutations:sg,matrixFromRows:ug,subtract:cg,cross:lg,range:fg,row:pg,prod:mg,equal:hg,max:dg,setCartesian:yg,setSymDifference:gg,ceil:vg,xor:xg,count:bg,ctranspose:wg,deepEqual:Ng,setIsSubset:Mg,fix:Sg,diff:Eg,divideScalar:Ag,nthRoots:Og,lsolve:Cg,lsolveAll:_g,setUnion:Bg,lup:qg,slu:zg,det:Dg,distance:Ig,stirlingS2:kg,catalan:Rg,column:Fg,log:Ug,dotDivide:Pg,usolveAll:jg,hypot:Lg,qr:Hg,inv:$g,expm:Gg,divide:Vg,mean:Zg,variance:Wg,kldivergence:Jg,bellNumbers:Yg,log1p:Xg,createUnit:Kg,eigs:ev,intersect:tv,std:rv,atomicMass:nv,bohrMagneton:iv,boltzmann:av,conductanceQuantum:ov,deuteronMass:sv,electronMass:uv,faraday:cv,firstRadiation:lv,gravitationConstant:fv,hartreeEnergy:pv,klitzing:mv,magneticConstant:hv,molarMass:dv,molarPlanckConstant:yv,neutronMass:gv,planckCharge:vv,planckLength:xv,planckTemperature:bv,protonMass:wv,reducedPlanckConstant:Nv,secondRadiation:Mv,stefanBoltzmann:Sv,vacuumImpedance:Ev,usolve:Av,norm:Ov,lusolve:Cv,sqrtm:_v,multinomial:Tv,avogadro:Bv,classicalElectronRadius:qv,electricConstant:zv,fermiCoupling:Dv,gravity:Iv,loschmidt:kv,molarMassC12:Rv,nuclearMagneton:Fv,planckMass:Uv,quantumOfCirculation:Pv,speedOfLight:jv,wienDisplacement:Lv,rotationMatrix:Hv,median:$v,bohrRadius:Gv,elementaryCharge:Vv,inverseConductanceQuantum:Zv,molarVolume:Wv,planckTime:Jv,thomsonCrossSection:Yv,rotate:Xv,parse:Ox,evaluate:Cx,mad:Qv,coulomb:Kv,magneticFluxQuantum:ex,rydberg:tx,unit:rx,help:Bx,gasConstant:nx,compile:qx,simplify:zx,rationalize:Dx,parser:Ix,planckConstant:ix,derivative:kx,config:n}),e(ox,ax,{apply:Mr({isInteger:vh,typed:gh}),filter:Cr({typed:gh}),map:Tr({typed:gh}),forEach:qr({typed:gh}),subset:Ur({matrix:Id,typed:gh}),index:Pr({Index:Dy}),concat:$r({isInteger:vh,matrix:Id,typed:gh}),max:Wr({config:n,larger:ay,numeric:Yy,typed:gh}),min:Yr({config:n,numeric:Yy,smaller:iy,typed:gh}),sum:Qr({add:my,config:n,numeric:Yy,typed:gh}),column:tn({Index:Dy,matrix:Id,range:fg,typed:gh}),range:an({bignumber:$y,matrix:Id,config:n,larger:ay,largerEq:qy,smaller:iy,smallerEq:Qy,typed:gh}),diff:cn({bignumber:$y,matrix:Id,number:Mh,subtract:cg,typed:gh}),row:fn({Index:Dy,matrix:Id,range:fg,typed:gh}),mean:hn({add:my,divide:Vg,typed:gh}),variance:xn({add:my,apply:Ch,divide:Vg,isNaN:wh,multiply:by,subtract:cg,typed:gh}),std:wn({sqrt:xd,typed:gh,variance:Wg})}),e(sx,{ResultSet:$m,Complex:Gm,Range:Vm,Node:ux,ArrayNode:cx,BlockNode:lx,ConstantNode:fx,ObjectNode:px,ParenthesisNode:mx,RelationalNode:hx,Chain:dx,BigNumber:Ym,Matrix:Xm,ConditionalNode:gx,OperatorNode:vx,Fraction:lh,RangeNode:xx,DenseMatrix:dh,FunctionAssignmentNode:bx,SparseMatrix:Dd,ImmutableDenseMatrix:sy,FibonacciHeap:uy,AccessorNode:Nx,IndexNode:Mx,Index:Dy,AssignmentNode:Sx,Spa:Tg,Unit:Qg,SymbolNode:Ex,FunctionNode:Ax,Help:_x,Parser:Tx}),dx.createProxy(ax),browser.omnibox.setDefaultSuggestion({description:"Do most mathematical computations."});const Rx=(e,t)=>{console.log(e);const r=Cx(e);console.log(e,r),t([{description:String(r),content:String(r)}])};browser.omnibox.onInputStarted.addListener(Rx),browser.omnibox.onInputChanged.addListener(Rx)})()})(); \ No newline at end of file +(()=>{var e={977:function(e,t){var r;!function(n){"use strict";var i=function(e){return.5*(Math.exp(e)+Math.exp(-e))},a=function(e){return.5*(Math.exp(e)-Math.exp(-e))},o=function(){throw SyntaxError("Invalid Param")};function s(e,t){var r=Math.abs(e),n=Math.abs(t);return 0===e?Math.log(n):0===t?Math.log(r):r<3e3&&n<3e3?.5*Math.log(e*e+t*t):Math.log(e/Math.cos(Math.atan2(t,e)))}function u(e,t){if(!(this instanceof u))return new u(e,t);var r=function(e,t){var r={re:0,im:0};if(null==e)r.re=r.im=0;else if(void 0!==t)r.re=e,r.im=t;else switch(typeof e){case"object":if("im"in e&&"re"in e)r.re=e.re,r.im=e.im;else if("abs"in e&&"arg"in e){if(!Number.isFinite(e.abs)&&Number.isFinite(e.arg))return u.INFINITY;r.re=e.abs*Math.cos(e.arg),r.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!Number.isFinite(e.r)&&Number.isFinite(e.phi))return u.INFINITY;r.re=e.r*Math.cos(e.phi),r.im=e.r*Math.sin(e.phi)}else 2===e.length?(r.re=e[0],r.im=e[1]):o();break;case"string":r.im=r.re=0;var n=e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),i=1,a=0;null===n&&o();for(var s=0;s0&&o();break;case"number":r.im=0,r.re=e;break;default:o()}return isNaN(r.re)||isNaN(r.im),r}(e,t);this.re=r.re,this.im=r.im}u.prototype={re:0,im:0,sign:function(){var e=this.abs();return new u(this.re/e,this.im/e)},add:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:new u(this.re+r.re,this.im+r.im)},sub:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:new u(this.re-r.re,this.im-r.im)},mul:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isZero()||this.isZero()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:0===r.im&&0===this.im?new u(this.re*r.re,0):new u(this.re*r.re-this.im*r.im,this.re*r.im+this.im*r.re)},div:function(e,t){var r=new u(e,t);if(this.isZero()&&r.isZero()||this.isInfinite()&&r.isInfinite())return u.NAN;if(this.isInfinite()||r.isZero())return u.INFINITY;if(this.isZero()||r.isInfinite())return u.ZERO;e=this.re,t=this.im;var n,i,a=r.re,o=r.im;return 0===o?new u(e/a,t/a):Math.abs(a)0)return new u(Math.pow(e,r.re),0);if(0===e)switch((r.re%4+4)%4){case 0:return new u(Math.pow(t,r.re),0);case 1:return new u(0,Math.pow(t,r.re));case 2:return new u(-Math.pow(t,r.re),0);case 3:return new u(0,-Math.pow(t,r.re))}}if(0===e&&0===t&&r.re>0&&r.im>=0)return u.ZERO;var n=Math.atan2(t,e),i=s(e,t);return e=Math.exp(r.re*i-r.im*n),t=r.im*i+r.re*n,new u(e*Math.cos(t),e*Math.sin(t))},sqrt:function(){var e,t,r=this.re,n=this.im,i=this.abs();if(r>=0){if(0===n)return new u(Math.sqrt(r),0);e=.5*Math.sqrt(2*(i+r))}else e=Math.abs(n)/Math.sqrt(2*(i-r));return t=r<=0?.5*Math.sqrt(2*(i-r)):Math.abs(n)/Math.sqrt(2*(i+r)),new u(e,n<0?-t:t)},exp:function(){var e=Math.exp(this.re);return this.im,new u(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){var e=this.re,t=this.im;return new u(Math.expm1(e)*Math.cos(t)+function(e){var t=Math.PI/4;if(-t>e||e>t)return Math.cos(e)-1;var r=e*e;return r*(r*(r*(r*(r*(r*(r*(r/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-.5)}(t),Math.exp(e)*Math.sin(t))},log:function(){var e=this.re,t=this.im;return new u(s(e,t),Math.atan2(t,e))},abs:function(){return e=this.re,t=this.im,r=Math.abs(e),n=Math.abs(t),r<3e3&&n<3e3?Math.sqrt(r*r+n*n):(r1&&0===t,n=1-e,i=1+e,a=n*n+t*t,o=0!==a?new u((i*n-t*t)/a,(t*n+i*t)/a):new u(-1!==e?e/0:0,0!==t?t/0:0),c=o.re;return o.re=s(o.re,o.im)/2,o.im=Math.atan2(o.im,c)/2,r&&(o.im=-o.im),o},acoth:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new u(0,Math.PI/2);var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).atanh():new u(0!==e?e/0:0,0!==t?-t/0:0).atanh()},acsch:function(){var e=this.re,t=this.im;if(0===t)return new u(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).asinh():new u(0!==e?e/0:0,0!==t?-t/0:0).asinh()},asech:function(){var e=this.re,t=this.im;if(this.isZero())return u.INFINITY;var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).acosh():new u(0!==e?e/0:0,0!==t?-t/0:0).acosh()},inverse:function(){if(this.isZero())return u.INFINITY;if(this.isInfinite())return u.ZERO;var e=this.re,t=this.im,r=e*e+t*t;return new u(e/r,-t/r)},conjugate:function(){return new u(this.re,-this.im)},neg:function(){return new u(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new u(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new u(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new u(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){var r=new u(e,t);return Math.abs(r.re-this.re)<=u.EPSILON&&Math.abs(r.im-this.im)<=u.EPSILON},clone:function(){return new u(this.re,this.im)},toString:function(){var e=this.re,t=this.im,r="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)0){for(a+=o,t=1;tr)throw Error(y+e)}function q(e,t,r,n){var i,a,o,s;for(a=e[0];a>=10;a/=10)--t;return--t<0?(t+=7,i=0):(i=Math.ceil((t+1)/7),t%=7),a=w(10,7-t),s=e[i]%a|0,null==n?t<3?(0==t?s=s/100|0:1==t&&(s=s/10|0),o=r<4&&99999==s||r>3&&49999==s||5e4==s||0==s):o=(r<4&&s+1==a||r>3&&s+1==a/2)&&(e[i+1]/a/100|0)==w(10,t-2)-1||(s==a/2||0==s)&&0==(e[i+1]/a/100|0):t<4?(0==t?s=s/1e3|0:1==t?s=s/100|0:2==t&&(s=s/10|0),o=(n||r<4)&&9999==s||!n&&r>3&&4999==s):o=((n||r<4)&&s+1==a||!n&&r>3&&s+1==a/2)&&(e[i+1]/a/1e3|0)==w(10,t-3)-1,o}function z(e,t,r){for(var n,i,a=[0],o=0,s=e.length;or-1&&(void 0===a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/r|0,a[n]%=r)}return a.reverse()}_.absoluteValue=_.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),I(e)},_.ceil=function(){return I(new this.constructor(this),this.e+1,2)},_.clampedTo=_.clamp=function(e,t){var r=this,n=r.constructor;if(e=new n(e),t=new n(t),!e.s||!t.s)return new n(NaN);if(e.gt(t))throw Error(y+t);return r.cmp(e)<0?e:r.cmp(t)>0?t:new n(r)},_.comparedTo=_.cmp=function(e){var t,r,n,i,a=this,o=a.d,s=(e=new a.constructor(e)).d,u=a.s,c=e.s;if(!o||!s)return u&&c?u!==c?u:o===s?0:!o^u<0?1:-1:NaN;if(!o[0]||!s[0])return o[0]?u:s[0]?-c:0;if(u!==c)return u;if(a.e!==e.e)return a.e>e.e^u<0?1:-1;for(t=0,r=(n=o.length)<(i=s.length)?n:i;ts[t]^u<0?1:-1;return n===i?0:n>i^u<0?1:-1},_.cosine=_.cos=function(){var e,t,r=this,n=r.constructor;return r.d?r.d[0]?(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(e,t){var r,n,i;if(t.isZero())return t;(n=t.d.length)<32?i=(1/X(4,r=Math.ceil(n/3))).toString():(r=16,i="2.3283064365386962890625e-10"),e.precision+=r,t=Y(e,1,t.times(i),new e(1));for(var a=r;a--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=r,t}(n,Q(n,r)),n.precision=e,n.rounding=t,I(2==s||3==s?r.neg():r,e,t,!0)):new n(1):new n(NaN)},_.cubeRoot=_.cbrt=function(){var e,t,r,n,i,a,o,s,u,c,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(h=!1,(a=l.s*w(l.s*l,1/3))&&Math.abs(a)!=1/0?n=new f(a.toString()):(r=T(l.d),(a=((e=l.e)-r.length+1)%3)&&(r+=1==a||-2==a?"0":"00"),a=w(r,1/3),e=b((e+1)/3)-(e%3==(e<0?-1:2)),(n=new f(r=a==1/0?"5e"+e:(r=a.toExponential()).slice(0,r.indexOf("e")+1)+e)).s=l.s),o=(e=f.precision)+3;;)if(c=(u=(s=n).times(s).times(s)).plus(l),n=D(c.plus(l).times(s),c.plus(u),o+2,1),T(s.d).slice(0,o)===(r=T(n.d)).slice(0,o)){if("9999"!=(r=r.slice(o-3,o+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(I(n,e+1,1),t=!n.times(n).times(n).eq(l));break}if(!i&&(I(s,e+1,0),s.times(s).times(s).eq(l))){n=s;break}o+=4,i=1}return h=!0,I(n,e,f.rounding,t)},_.decimalPlaces=_.dp=function(){var e,t=this.d,r=NaN;if(t){if(r=7*((e=t.length-1)-b(this.e/7)),e=t[e])for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r},_.dividedBy=_.div=function(e){return D(this,new this.constructor(e))},_.dividedToIntegerBy=_.divToInt=function(e){var t=this.constructor;return I(D(this,new t(e),0,1,1),t.precision,t.rounding)},_.equals=_.eq=function(e){return 0===this.cmp(e)},_.floor=function(){return I(new this.constructor(this),this.e+1,3)},_.greaterThan=_.gt=function(e){return this.cmp(e)>0},_.greaterThanOrEqualTo=_.gte=function(e){var t=this.cmp(e);return 1==t||0===t},_.hyperbolicCosine=_.cosh=function(){var e,t,r,n,i,a=this,o=a.constructor,s=new o(1);if(!a.isFinite())return new o(a.s?1/0:NaN);if(a.isZero())return s;r=o.precision,n=o.rounding,o.precision=r+Math.max(a.e,a.sd())+4,o.rounding=1,(i=a.d.length)<32?t=(1/X(4,e=Math.ceil(i/3))).toString():(e=16,t="2.3283064365386962890625e-10"),a=Y(o,1,a.times(t),new o(1),!0);for(var u,c=e,l=new o(8);c--;)u=a.times(a),a=s.minus(u.times(l.minus(u.times(l))));return I(a,o.precision=r,o.rounding=n,!0)},_.hyperbolicSine=_.sinh=function(){var e,t,r,n,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.precision,r=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,(n=i.d.length)<3)i=Y(a,2,i,i,!0);else{e=(e=1.4*Math.sqrt(n))>16?16:0|e,i=Y(a,2,i=i.times(1/X(5,e)),i,!0);for(var o,s=new a(5),u=new a(16),c=new a(20);e--;)o=i.times(i),i=i.times(s.plus(o.times(u.times(o).plus(c))))}return a.precision=t,a.rounding=r,I(i,t,r,!0)},_.hyperbolicTangent=_.tanh=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+7,n.rounding=1,D(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)},_.inverseCosine=_.acos=function(){var e,t=this,r=t.constructor,n=t.abs().cmp(1),i=r.precision,a=r.rounding;return-1!==n?0===n?t.isNeg()?U(r,i,a):new r(0):new r(NaN):t.isZero()?U(r,i+4,a).times(.5):(r.precision=i+6,r.rounding=1,t=t.asin(),e=U(r,i+4,a).times(.5),r.precision=i,r.rounding=a,e.minus(t))},_.inverseHyperbolicCosine=_.acosh=function(){var e,t,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(e=n.precision,t=n.rounding,n.precision=e+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,h=!1,r=r.times(r).minus(1).sqrt().plus(r),h=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)},_.inverseHyperbolicSine=_.asinh=function(){var e,t,r=this,n=r.constructor;return!r.isFinite()||r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,h=!1,r=r.times(r).plus(1).sqrt().plus(r),h=!0,n.precision=e,n.rounding=t,r.ln())},_.inverseHyperbolicTangent=_.atanh=function(){var e,t,r,n,i=this,a=i.constructor;return i.isFinite()?i.e>=0?new a(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=a.precision,t=a.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?I(new a(i),e,t,!0):(a.precision=r=n-i.e,i=D(i.plus(1),new a(1).minus(i),r+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=t,i.times(.5))):new a(NaN)},_.inverseSine=_.asin=function(){var e,t,r,n,i=this,a=i.constructor;return i.isZero()?new a(i):(t=i.abs().cmp(1),r=a.precision,n=a.rounding,-1!==t?0===t?((e=U(a,r+4,n).times(.5)).s=i.s,e):new a(NaN):(a.precision=r+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=r,a.rounding=n,i.times(2)))},_.inverseTangent=_.atan=function(){var e,t,r,n,i,a,o,s,u,c=this,l=c.constructor,f=l.precision,p=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&f+4<=C)return(o=U(l,f+4,p).times(.25)).s=c.s,o}else{if(!c.s)return new l(NaN);if(f+4<=C)return(o=U(l,f+4,p).times(.5)).s=c.s,o}for(l.precision=s=f+10,l.rounding=1,e=r=Math.min(28,s/7+2|0);e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(h=!1,t=Math.ceil(s/7),n=1,u=c.times(c),o=new l(c),i=c;-1!==e;)if(i=i.times(u),a=o.minus(i.div(n+=2)),i=i.times(u),void 0!==(o=a.plus(i.div(n+=2))).d[t])for(e=t;o.d[e]===a.d[e]&&e--;);return r&&(o=o.times(2<this.d.length-2},_.isNaN=function(){return!this.s},_.isNegative=_.isNeg=function(){return this.s<0},_.isPositive=_.isPos=function(){return this.s>0},_.isZero=function(){return!!this.d&&0===this.d[0]},_.lessThan=_.lt=function(e){return this.cmp(e)<0},_.lessThanOrEqualTo=_.lte=function(e){return this.cmp(e)<1},_.logarithm=_.log=function(e){var t,r,n,i,a,o,s,u,c=this,l=c.constructor,f=l.precision,p=l.rounding;if(null==e)e=new l(10),t=!0;else{if(r=(e=new l(e)).d,e.s<0||!r||!r[0]||e.eq(1))return new l(NaN);t=e.eq(10)}if(r=c.d,c.s<0||!r||!r[0]||c.eq(1))return new l(r&&!r[0]?-1/0:1!=c.s?NaN:r?0:1/0);if(t)if(r.length>1)a=!0;else{for(i=r[0];i%10==0;)i/=10;a=1!==i}if(h=!1,o=Z(c,s=f+5),n=t?F(l,s+10):Z(e,s),q((u=D(o,n,s,1)).d,i=f,p))do{if(o=Z(c,s+=10),n=t?F(l,s+10):Z(e,s),u=D(o,n,s,1),!a){+T(u.d).slice(i+1,i+15)+1==1e14&&(u=I(u,f+1,0));break}}while(q(u.d,i+=10,p));return h=!0,I(u,f,p)},_.minus=_.sub=function(e){var t,r,n,i,a,o,s,u,c,l,f,p,m=this,d=m.constructor;if(e=new d(e),!m.d||!e.d)return m.s&&e.s?m.d?e.s=-e.s:e=new d(e.d||m.s!==e.s?m:NaN):e=new d(NaN),e;if(m.s!=e.s)return e.s=-e.s,m.plus(e);if(c=m.d,p=e.d,s=d.precision,u=d.rounding,!c[0]||!p[0]){if(p[0])e.s=-e.s;else{if(!c[0])return new d(3===u?-0:0);e=new d(m)}return h?I(e,s,u):e}if(r=b(e.e/7),l=b(m.e/7),c=c.slice(),a=l-r){for((f=a<0)?(t=c,a=-a,o=p.length):(t=p,r=l,o=c.length),a>(n=Math.max(Math.ceil(s/7),o)+2)&&(a=n,t.length=1),t.reverse(),n=a;n--;)t.push(0);t.reverse()}else{for((f=(n=c.length)<(o=p.length))&&(o=n),n=0;n0;--n)c[o++]=0;for(n=p.length;n>a;){if(c[--n](o=(a=Math.ceil(s/7))>o?a+1:o+1)&&(i=o,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for((o=c.length)-(i=l.length)<0&&(i=o,r=l,l=c,c=r),t=0;i;)t=(c[--i]=c[i]+l[i]+t)/A|0,c[i]%=A;for(t&&(c.unshift(t),++n),o=c.length;0==c[--o];)c.pop();return e.d=c,e.e=R(c,n),h?I(e,s,u):e},_.precision=_.sd=function(e){var t,r=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(y+e);return r.d?(t=P(r.d),e&&r.e+1>t&&(t=r.e+1)):t=NaN,t},_.round=function(){var e=this,t=e.constructor;return I(new t(e),e.e+1,t.rounding)},_.sine=_.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(e,t){var r,n=t.d.length;if(n<3)return t.isZero()?t:Y(e,2,t,t);r=(r=1.4*Math.sqrt(n))>16?16:0|r,t=Y(e,2,t=t.times(1/X(5,r)),t);for(var i,a=new e(5),o=new e(16),s=new e(20);r--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}(n,Q(n,r)),n.precision=e,n.rounding=t,I(s>2?r.neg():r,e,t,!0)):new n(NaN)},_.squareRoot=_.sqrt=function(){var e,t,r,n,i,a,o=this,s=o.d,u=o.e,c=o.s,l=o.constructor;if(1!==c||!s||!s[0])return new l(!c||c<0&&(!s||s[0])?NaN:s?o:1/0);for(h=!1,0==(c=Math.sqrt(+o))||c==1/0?(((t=T(s)).length+u)%2==0&&(t+="0"),c=Math.sqrt(t),u=b((u+1)/2)-(u<0||u%2),n=new l(t=c==1/0?"5e"+u:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+u)):n=new l(c.toString()),r=(u=l.precision)+3;;)if(n=(a=n).plus(D(o,a,r+2,1)).times(.5),T(a.d).slice(0,r)===(t=T(n.d)).slice(0,r)){if("9999"!=(t=t.slice(r-3,r+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(I(n,u+1,1),e=!n.times(n).eq(o));break}if(!i&&(I(a,u+1,0),a.times(a).eq(o))){n=a;break}r+=4,i=1}return h=!0,I(n,u,l.rounding,e)},_.tangent=_.tan=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+10,n.rounding=1,(r=r.sin()).s=1,r=D(r,new n(1).minus(r.times(r)).sqrt(),e+10,0),n.precision=e,n.rounding=t,I(2==s||4==s?r.neg():r,e,t,!0)):new n(NaN)},_.times=_.mul=function(e){var t,r,n,i,a,o,s,u,c,l=this,f=l.constructor,p=l.d,m=(e=new f(e)).d;if(e.s*=l.s,!(p&&p[0]&&m&&m[0]))return new f(!e.s||p&&!p[0]&&!m||m&&!m[0]&&!p?NaN:p&&m?0*e.s:e.s/0);for(r=b(l.e/7)+b(e.e/7),(u=p.length)<(c=m.length)&&(a=p,p=m,m=a,o=u,u=c,c=o),a=[],n=o=u+c;n--;)a.push(0);for(n=c;--n>=0;){for(t=0,i=u+n;i>n;)s=a[i]+m[n]*p[i-n-1]+t,a[i--]=s%A|0,t=s/A|0;a[i]=(a[i]+t)%A|0}for(;!a[--o];)a.pop();return t?++r:a.shift(),e.d=a,e.e=R(a,r),h?I(e,f.precision,f.rounding):e},_.toBinary=function(e,t){return K(this,2,e,t)},_.toDecimalPlaces=_.toDP=function(e,t){var r=this,n=r.constructor;return r=new n(r),void 0===e?r:(B(e,0,c),void 0===t?t=n.rounding:B(t,0,8),I(r,e+r.e+1,t))},_.toExponential=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=k(n,!0):(B(e,0,c),void 0===t?t=i.rounding:B(t,0,8),r=k(n=I(new i(n),e+1,t),!0,e+1)),n.isNeg()&&!n.isZero()?"-"+r:r},_.toFixed=function(e,t){var r,n,i=this,a=i.constructor;return void 0===e?r=k(i):(B(e,0,c),void 0===t?t=a.rounding:B(t,0,8),r=k(n=I(new a(i),e+i.e+1,t),!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r},_.toFraction=function(e){var t,r,n,i,a,o,s,u,c,l,f,p,m=this,d=m.d,g=m.constructor;if(!d)return new g(m);if(c=r=new g(1),n=u=new g(0),o=(a=(t=new g(n)).e=P(d)-m.e-1)%7,t.d[0]=w(10,o<0?7+o:o),null==e)e=a>0?t:c;else{if(!(s=new g(e)).isInt()||s.lt(c))throw Error(y+s);e=s.gt(t)?a>0?t:c:s}for(h=!1,s=new g(T(d)),l=g.precision,g.precision=a=7*d.length*2;f=D(s,t,0,1,1),1!=(i=r.plus(f.times(n))).cmp(e);)r=n,n=i,i=c,c=u.plus(f.times(i)),u=i,i=t,t=s.minus(f.times(i)),s=i;return i=D(e.minus(r),n,0,1,1),u=u.plus(i.times(c)),r=r.plus(i.times(n)),u.s=c.s=m.s,p=D(c,n,a,1).minus(m).abs().cmp(D(u,r,a,1).minus(m).abs())<1?[c,n]:[u,r],g.precision=l,h=!0,p},_.toHexadecimal=_.toHex=function(e,t){return K(this,16,e,t)},_.toNearest=function(e,t){var r=this,n=r.constructor;if(r=new n(r),null==e){if(!r.d)return r;e=new n(1),t=n.rounding}else{if(e=new n(e),void 0===t?t=n.rounding:B(t,0,8),!r.d)return e.s?r:e;if(!e.d)return e.s&&(e.s=r.s),e}return e.d[0]?(h=!1,r=D(r,e,0,t,1).times(e),h=!0,I(r)):(e.s=r.s,r=e),r},_.toNumber=function(){return+this},_.toOctal=function(e,t){return K(this,8,e,t)},_.toPower=_.pow=function(e){var t,r,n,i,a,o,s=this,u=s.constructor,c=+(e=new u(e));if(!(s.d&&e.d&&s.d[0]&&e.d[0]))return new u(w(+s,c));if((s=new u(s)).eq(1))return s;if(n=u.precision,a=u.rounding,e.eq(1))return I(s,n,a);if((t=b(e.e/7))>=e.d.length-1&&(r=c<0?-c:c)<=9007199254740991)return i=L(u,s,r,n),e.s<0?new u(1).div(i):I(i,n,a);if((o=s.s)<0){if(tu.maxE+1||t0?o/0:0):(h=!1,u.rounding=s.s=1,r=Math.min(12,(t+"").length),(i=G(e.times(Z(s,n+r)),n)).d&&q((i=I(i,n+5,1)).d,n,a)&&(t=n+10,+T((i=I(G(e.times(Z(s,t+r)),t),t+5,1)).d).slice(n+1,n+15)+1==1e14&&(i=I(i,n+1,0))),i.s=o,h=!0,u.rounding=a,I(i,n,a))},_.toPrecision=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=k(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(B(e,1,c),void 0===t?t=i.rounding:B(t,0,8),r=k(n=I(new i(n),e,t),e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+r:r},_.toSignificantDigits=_.toSD=function(e,t){var r=this.constructor;return void 0===e?(e=r.precision,t=r.rounding):(B(e,1,c),void 0===t?t=r.rounding:B(t,0,8)),I(new r(this),e,t)},_.toString=function(){var e=this,t=e.constructor,r=k(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r},_.truncated=_.trunc=function(){return I(new this.constructor(this),this.e+1,1)},_.valueOf=_.toJSON=function(){var e=this,t=e.constructor,r=k(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};var D=function(){function e(e,t,r){var n,i=0,a=e.length;for(e=e.slice();a--;)n=e[a]*t+i,e[a]=n%r|0,i=n/r|0;return i&&e.unshift(i),e}function t(e,t,r,n){var i,a;if(r!=n)a=r>n?1:-1;else for(i=a=0;it[i]?1:-1;break}return a}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]1;)e.shift()}return function(n,i,a,s,u,c){var l,f,p,m,h,d,y,g,v,x,w,N,M,S,E,O,C,_,T,B,q=n.constructor,z=n.s==i.s?1:-1,D=n.d,k=i.d;if(!(D&&D[0]&&k&&k[0]))return new q(n.s&&i.s&&(D?!k||D[0]!=k[0]:k)?D&&0==D[0]||!k?0*z:z/0:NaN);for(c?(h=1,f=n.e-i.e):(c=A,h=7,f=b(n.e/h)-b(i.e/h)),T=k.length,C=D.length,x=(v=new q(z)).d=[],p=0;k[p]==(D[p]||0);p++);if(k[p]>(D[p]||0)&&f--,null==a?(S=a=q.precision,s=q.rounding):S=u?a+(n.e-i.e)+1:a,S<0)x.push(1),d=!0;else{if(S=S/h+2|0,p=0,1==T){for(m=0,k=k[0],S++;(p1&&(k=e(k,m,c),D=e(D,m,c),T=k.length,C=D.length),O=T,N=(w=D.slice(0,T)).length;N=c/2&&++_;do{m=0,(l=t(k,w,T,N))<0?(M=w[0],T!=N&&(M=M*c+(w[1]||0)),(m=M/_|0)>1?(m>=c&&(m=c-1),1==(l=t(y=e(k,m,c),w,g=y.length,N=w.length))&&(m--,r(y,T=10;m/=10)p++;v.e=p+f*h-1,I(v,u?a+v.e+1:a,s,d)}return v}}();function I(e,t,r,n){var i,a,o,s,u,c,l,f,p,m=e.constructor;e:if(null!=t){if(!(f=e.d))return e;for(i=1,s=f[0];s>=10;s/=10)i++;if((a=t-i)<0)a+=7,o=t,u=(l=f[p=0])/w(10,i-o-1)%10|0;else if((p=Math.ceil((a+1)/7))>=(s=f.length)){if(!n)break e;for(;s++<=p;)f.push(0);l=u=0,i=1,o=(a%=7)-7+1}else{for(l=s=f[p],i=1;s>=10;s/=10)i++;u=(o=(a%=7)-7+i)<0?0:l/w(10,i-o-1)%10|0}if(n=n||t<0||void 0!==f[p+1]||(o<0?l:l%w(10,i-o-1)),c=r<4?(u||n)&&(0==r||r==(e.s<0?3:2)):u>5||5==u&&(4==r||n||6==r&&(a>0?o>0?l/w(10,i-o):0:f[p-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,c?(t-=e.e+1,f[0]=w(10,(7-t%7)%7),e.e=-t||0):f[0]=e.e=0,e;if(0==a?(f.length=p,s=1,p--):(f.length=p+1,s=w(10,7-a),f[p]=o>0?(l/w(10,i-o)%w(10,o)|0)*s:0),c)for(;;){if(0==p){for(a=1,o=f[0];o>=10;o/=10)a++;for(o=f[0]+=s,s=1;o>=10;o/=10)s++;a!=s&&(e.e++,f[0]==A&&(f[0]=1));break}if(f[p]+=s,f[p]!=A)break;f[p--]=0,s=1}for(a=f.length;0===f[--a];)f.pop()}return h&&(e.e>m.maxE?(e.d=null,e.e=NaN):e.e0?a=a.charAt(0)+"."+a.slice(1)+j(n):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(e.e<0?"e":"e+")+e.e):i<0?(a="0."+j(-i-1)+a,r&&(n=r-o)>0&&(a+=j(n))):i>=o?(a+=j(i+1-o),r&&(n=r-i-1)>0&&(a=a+"."+j(n))):((n=i+1)0&&(i+1===o&&(a+="."),a+=j(n))),a}function R(e,t){var r=e[0];for(t*=7;r>=10;r/=10)t++;return t}function F(e,t,r){if(t>O)throw h=!0,r&&(e.precision=r),Error(g);return I(new e(f),t,1,!0)}function U(e,t,r){if(t>C)throw Error(g);return I(new e(p),t,r,!0)}function P(e){var t=e.length-1,r=7*t+1;if(t=e[t]){for(;t%10==0;t/=10)r--;for(t=e[0];t>=10;t/=10)r++}return r}function j(e){for(var t="";e--;)t+="0";return t}function L(e,t,r,n){var i,a=new e(1),o=Math.ceil(n/7+4);for(h=!1;;){if(r%2&&ee((a=a.times(t)).d,o)&&(i=!0),0===(r=b(r/2))){r=a.d.length-1,i&&0===a.d[r]&&++a.d[r];break}ee((t=t.times(t)).d,o)}return h=!0,a}function H(e){return 1&e.d[e.d.length-1]}function $(e,t,r){for(var n,i=new e(t[0]),a=0;++a17)return new p(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(h=!1,u=d):u=t,s=new p(.03125);e.e>-2;)e=e.times(s),f+=5;for(u+=n=Math.log(w(2,f))/Math.LN10*2+5|0,r=a=o=new p(1),p.precision=u;;){if(a=I(a.times(e),u,1),r=r.times(++l),T((s=o.plus(D(a,r,u,1))).d).slice(0,u)===T(o.d).slice(0,u)){for(i=f;i--;)o=I(o.times(o),u,1);if(null!=t)return p.precision=d,o;if(!(c<3&&q(o.d,u-n,m,c)))return I(o,p.precision=d,m,h=!0);p.precision=u+=10,r=a=s=new p(1),l=0,c++}o=s}}function Z(e,t){var r,n,i,a,o,s,u,c,l,f,p,m=1,d=e,y=d.d,g=d.constructor,v=g.rounding,x=g.precision;if(d.s<0||!y||!y[0]||!d.e&&1==y[0]&&1==y.length)return new g(y&&!y[0]?-1/0:1!=d.s?NaN:y?0:d);if(null==t?(h=!1,l=x):l=t,g.precision=l+=10,n=(r=T(y)).charAt(0),!(Math.abs(a=d.e)<15e14))return c=F(g,l+2,x).times(a+""),d=Z(new g(n+"."+r.slice(1)),l-10).plus(c),g.precision=x,null==t?I(d,x,v,h=!0):d;for(;n<7&&1!=n||1==n&&r.charAt(1)>3;)n=(r=T((d=d.times(e)).d)).charAt(0),m++;for(a=d.e,n>1?(d=new g("0."+r),a++):d=new g(n+"."+r.slice(1)),f=d,u=o=d=D(d.minus(1),d.plus(1),l,1),p=I(d.times(d),l,1),i=3;;){if(o=I(o.times(p),l,1),T((c=u.plus(D(o,new g(i),l,1))).d).slice(0,l)===T(u.d).slice(0,l)){if(u=u.times(2),0!==a&&(u=u.plus(F(g,l+2,x).times(a+""))),u=D(u,new g(m),l,1),null!=t)return g.precision=x,u;if(!q(u.d,l-10,v,s))return I(u,g.precision=x,v,h=!0);g.precision=l+=10,c=o=d=D(f.minus(1),f.plus(1),l,1),p=I(d.times(d),l,1),i=s=1}u=c,i+=2}}function V(e){return String(e.s*e.s/0)}function W(e,t){var r,n,i;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;48===t.charCodeAt(n);n++);for(i=t.length;48===t.charCodeAt(i-1);--i);if(t=t.slice(n,i)){if(i-=n,e.e=r=r-n-1,e.d=[],n=(r+1)%7,r<0&&(n+=7),ne.constructor.maxE?(e.d=null,e.e=NaN):e.e-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),E.test(t))return W(e,t)}else if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(M.test(t))r=16,t=t.toLowerCase();else if(N.test(t))r=2;else{if(!S.test(t))throw Error(y+t);r=8}for((o=t.search(/p/i))>0?(c=+t.slice(o+1),t=t.substring(2,o)):t=t.slice(2),s=(o=t.indexOf("."))>=0,n=e.constructor,s&&(o=(u=(t=t.replace(".","")).length)-o,i=L(n,new n(r),o,2*o)),o=f=(l=z(t,r,A)).length-1;0===l[o];--o)l.pop();return o<0?new n(0*e.s):(e.e=R(l,f),e.d=l,h=!1,s&&(e=D(e,i,4*u)),c&&(e=e.times(Math.abs(c)<54?w(2,c):a.pow(2,c))),h=!0,e)}function Y(e,t,r,n,i){var a,o,s,u,c=e.precision,l=Math.ceil(c/7);for(h=!1,u=r.times(r),s=new e(n);;){if(o=D(s.times(u),new e(t++*t++),c,1),s=i?n.plus(o):n.minus(o),n=D(o.times(u),new e(t++*t++),c,1),void 0!==(o=s.plus(n)).d[l]){for(a=l;o.d[a]===s.d[a]&&a--;);if(-1==a)break}a=s,s=n,n=o,o=a}return h=!0,o.d.length=l+1,o}function X(e,t){for(var r=e;--t;)r*=e;return r}function Q(e,t){var r,n=t.s<0,i=U(e,e.precision,1),a=i.times(.5);if((t=t.abs()).lte(a))return s=n?4:1,t;if((r=t.divToInt(i)).isZero())s=n?3:2;else{if((t=t.minus(r.times(i))).lte(a))return s=H(r)?n?2:3:n?4:1,t;s=H(r)?n?1:4:n?3:2}return t.minus(i).abs()}function K(e,t,r,n){var i,a,s,u,f,p,m,h,d,y=e.constructor,g=void 0!==r;if(g?(B(r,1,c),void 0===n?n=y.rounding:B(n,0,8)):(r=y.precision,n=y.rounding),e.isFinite()){for(g?(i=2,16==t?r=4*r-3:8==t&&(r=3*r-2)):i=t,(s=(m=k(e)).indexOf("."))>=0&&(m=m.replace(".",""),(d=new y(1)).e=m.length-s,d.d=z(k(d),10,i),d.e=d.d.length),a=f=(h=z(m,10,i)).length;0==h[--f];)h.pop();if(h[0]){if(s<0?a--:((e=new y(e)).d=h,e.e=a,h=(e=D(e,d,r,n,0,i)).d,a=e.e,p=o),s=h[r],u=i/2,p=p||void 0!==h[r+1],p=n<4?(void 0!==s||p)&&(0===n||n===(e.s<0?3:2)):s>u||s===u&&(4===n||p||6===n&&1&h[r-1]||n===(e.s<0?8:7)),h.length=r,p)for(;++h[--r]>i-1;)h[r]=0,r||(++a,h.unshift(1));for(f=h.length;!h[f-1];--f);for(s=0,m="";s1)if(16==t||8==t){for(s=16==t?4:3,--f;f%s;f++)m+="0";for(f=(h=z(m,i,t)).length;!h[f-1];--f);for(s=1,m="1.";sf)for(a-=f;a--;)m+="0";else at)return e.length=t,!0}function te(e){return new this(e).abs()}function re(e){return new this(e).acos()}function ne(e){return new this(e).acosh()}function ie(e,t){return new this(e).plus(t)}function ae(e){return new this(e).asin()}function oe(e){return new this(e).asinh()}function se(e){return new this(e).atan()}function ue(e){return new this(e).atanh()}function ce(e,t){e=new this(e),t=new this(t);var r,n=this.precision,i=this.rounding,a=n+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(r=t.s<0?U(this,n,i):new this(0)).s=e.s:!e.d||t.isZero()?(r=U(this,a,1).times(.5)).s=e.s:t.s<0?(this.precision=a,this.rounding=1,r=this.atan(D(e,t,a,1)),t=U(this,a,1),this.precision=n,this.rounding=i,r=e.s<0?r.minus(t):r.plus(t)):r=this.atan(D(e,t,a,1)):(r=U(this,a,1).times(t.s>0?.25:.75)).s=e.s:r=new this(NaN),r}function le(e){return new this(e).cbrt()}function fe(e){return I(e=new this(e),e.e+1,2)}function pe(e,t,r){return new this(e).clamp(t,r)}function me(e){if(!e||"object"!=typeof e)throw Error(d+"Object expected");var t,r,n,i=!0===e.defaults,a=["precision",1,c,"rounding",0,8,"toExpNeg",-u,0,"toExpPos",0,u,"maxE",0,u,"minE",-u,0,"modulo",0,9];for(t=0;t=a[t+1]&&n<=a[t+2]))throw Error(y+r+": "+n);this[r]=n}if(r="crypto",i&&(this[r]=m[r]),void 0!==(n=e[r])){if(!0!==n&&!1!==n&&0!==n&&1!==n)throw Error(y+r+": "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(v);this[r]=!0}else this[r]=!1}return this}function he(e){return new this(e).cos()}function de(e){return new this(e).cosh()}function ye(e,t){return new this(e).div(t)}function ge(e){return new this(e).exp()}function ve(e){return I(e=new this(e),e.e+1,3)}function xe(){var e,t,r=new this(0);for(h=!1,e=0;e=429e7?t[a]=crypto.getRandomValues(new Uint32Array(1))[0]:s[a++]=i%1e7;else{if(!crypto.randomBytes)throw Error(v);for(t=crypto.randomBytes(n*=4);a=214e7?crypto.randomBytes(4).copy(t,a):(s.push(i%1e7),a+=4);a=n/4}else for(;a=10;i/=10)n++;n<7&&(r-=7-n)}return o.e=r,o.d=s,o}function Be(e){return I(e=new this(e),e.e+1,this.rounding)}function qe(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function ze(e){return new this(e).sin()}function De(e){return new this(e).sinh()}function Ie(e){return new this(e).sqrt()}function ke(e,t){return new this(e).sub(t)}function Re(){var e=0,t=arguments,r=new this(t[e]);for(h=!1;r.s&&++ea.maxE?(i.e=NaN,i.d=null):e.e=10;r/=10)t++;return void(h?t>a.maxE?(i.e=NaN,i.d=null):t{"use strict";var t=Object.assign||function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{},o=a.preserveFormatting,s=void 0!==o&&o,u=a.escapeMapFn,c=void 0===u?i:u,l=String(e),f="",p=c(t({},r),s?t({},n):{}),m=Object.keys(p),h=function(){var e=!1;m.forEach((function(t,r){e||l.length>=t.length&&l.slice(0,t.length)===t&&(f+=p[m[r]],l=l.slice(t.length,l.length),e=!0)})),e||(f+=l.slice(0,1),l=l.slice(1,l.length))};l;)h();return f}},628:function(e,t){var r;!function(n){"use strict";var i={s:1,n:0,d:1};function a(e){function t(){var t=Error.apply(this,arguments);t.name=this.name=e,this.stack=t.stack,this.message=t.message}function r(){}return r.prototype=Error.prototype,t.prototype=new r,t}var o=m.DivisionByZero=a("DivisionByZero"),s=m.InvalidParameter=a("InvalidParameter");function u(e,t){return isNaN(e=parseInt(e,10))&&c(),e*t}function c(){throw new s}function l(e){for(var t={},r=e,n=2,i=4;i<=r;){for(;r%n==0;)r/=n,t[n]=(t[n]||0)+1;i+=1+2*n++}return r!==e?r>1&&(t[r]=(t[r]||0)+1):t[e]=(t[e]||0)+1,t}var f=function(e,t){var r,n=0,a=1,s=1,l=0,f=0,p=0,m=1,h=1,d=0,y=1,g=1,v=1,x=1e7;if(null==e);else if(void 0!==t)s=(n=e)*(a=t);else switch(typeof e){case"object":"d"in e&&"n"in e?(n=e.n,a=e.d,"s"in e&&(n*=e.s)):0 in e?(n=e[0],1 in e&&(a=e[1])):c(),s=n*a;break;case"number":if(e<0&&(s=e,e=-e),e%1==0)n=e;else if(e>0){for(e>=1&&(e/=h=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)));y<=x&&v<=x;){if(e===(r=(d+g)/(y+v))){y+v<=x?(n=d+g,a=y+v):v>y?(n=g,a=v):(n=d,a=y);break}e>r?(d+=g,y+=v):(g+=d,v+=y),y>x?(n=g,a=v):(n=d,a=y)}n*=h}else(isNaN(e)||isNaN(t))&&(a=n=NaN);break;case"string":if(null===(y=e.match(/\d+|./g))&&c(),"-"===y[d]?(s=-1,d++):"+"===y[d]&&d++,y.length===d+1?f=u(y[d++],s):"."===y[d+1]||"."===y[d]?("."!==y[d]&&(l=u(y[d++],s)),(1+ ++d===y.length||"("===y[d+1]&&")"===y[d+3]||"'"===y[d+1]&&"'"===y[d+3])&&(f=u(y[d],s),m=Math.pow(10,y[d].length),d++),("("===y[d]&&")"===y[d+2]||"'"===y[d]&&"'"===y[d+2])&&(p=u(y[d+1],s),h=Math.pow(10,y[d+1].length)-1,d+=3)):"/"===y[d+1]||":"===y[d+1]?(f=u(y[d],s),m=u(y[d+2],1),d+=3):"/"===y[d+3]&&" "===y[d+1]&&(l=u(y[d],s),f=u(y[d+2],s),m=u(y[d+4],1),d+=5),y.length<=d){s=n=p+(a=m*h)*l+h*f;break}default:c()}if(0===a)throw new o;i.s=s<0?-1:1,i.n=Math.abs(n),i.d=Math.abs(a)};function p(e,t){if(!e)return t;if(!t)return e;for(;;){if(!(e%=t))return t;if(!(t%=e))return e}}function m(e,t){if(!(this instanceof m))return new m(e,t);f(e,t),e=m.REDUCE?p(i.d,i.n):1,this.s=i.s,this.n=i.n/e,this.d=i.d/e}m.REDUCE=1,m.prototype={s:1,n:0,d:1,abs:function(){return new m(this.n,this.d)},neg:function(){return new m(-this.s*this.n,this.d)},add:function(e,t){return f(e,t),new m(this.s*this.n*i.d+i.s*this.d*i.n,this.d*i.d)},sub:function(e,t){return f(e,t),new m(this.s*this.n*i.d-i.s*this.d*i.n,this.d*i.d)},mul:function(e,t){return f(e,t),new m(this.s*i.s*this.n*i.n,this.d*i.d)},div:function(e,t){return f(e,t),new m(this.s*i.s*this.n*i.d,this.d*i.n)},clone:function(){return new m(this)},mod:function(e,t){return isNaN(this.n)||isNaN(this.d)?new m(NaN):void 0===e?new m(this.s*this.n%this.d,1):(f(e,t),0===i.n&&0===this.d&&m(0,0),new m(this.s*(i.d*this.n)%(i.n*this.d),i.d*this.d))},gcd:function(e,t){return f(e,t),new m(p(i.n,this.n)*p(i.d,this.d),i.d*this.d)},lcm:function(e,t){return f(e,t),0===i.n&&0===this.n?new m:new m(i.n*this.n,p(i.n,this.n)*p(i.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.round(e*this.s*this.n/this.d),e)},inverse:function(){return new m(this.s*this.d,this.n)},pow:function(e,t){if(f(e,t),1===i.d)return i.s<0?new m(Math.pow(this.s*this.d,i.n),Math.pow(this.n,i.n)):new m(Math.pow(this.s*this.n,i.n),Math.pow(this.d,i.n));if(this.s<0)return null;var r=l(this.n),n=l(this.d),a=1,o=1;for(var s in r)if("1"!==s){if("0"===s){a=0;break}if(r[s]*=i.n,r[s]%i.d!=0)return null;r[s]/=i.d,a*=Math.pow(s,r[s])}for(var s in n)if("1"!==s){if(n[s]*=i.n,n[s]%i.d!=0)return null;n[s]/=i.d,o*=Math.pow(s,n[s])}return i.s<0?new m(o,a):new m(a,o)},equals:function(e,t){return f(e,t),this.s*this.n*i.d==i.s*i.n*this.d},compare:function(e,t){f(e,t);var r=this.s*this.n*i.d-i.s*i.n*this.d;return(00&&(r+=t,r+=" ",n%=i),r+=n,r+="/",r+=i),r},toLatex:function(e){var t,r="",n=this.n,i=this.d;return this.s<0&&(r+="-"),1===i?r+=n:(e&&(t=Math.floor(n/i))>0&&(r+=t,n%=i),r+="\\frac{",r+=n,r+="}{",r+=i,r+="}"),r},toContinued:function(){var e,t=this.n,r=this.d,n=[];if(isNaN(t)||isNaN(r))return n;do{n.push(Math.floor(t/r)),e=t%r,t=r,r=e}while(1!==t);return n},toString:function(e){var t,r=this.n,n=this.d;if(isNaN(r)||isNaN(n))return"NaN";m.REDUCE||(r/=t=p(r,n),n/=t),e=e||15;var i=function(e,t){for(;t%2==0;t/=2);for(;t%5==0;t/=5);if(1===t)return 0;for(var r=10%t,n=1;1!==r;n++)if(r=10*r%t,n>2e3)return 0;return n}(0,n),a=function(e,t,r){for(var n=1,i=function(e,t,r){for(var n=1;t>0;e=e*e%r,t>>=1)1&t&&(n=n*e%r);return n}(10,r,t),a=0;a<300;a++){if(n===i)return a;n=10*n%t,i=10*i%t}return 0}(0,n,i),o=-1===this.s?"-":"";if(o+=r/n|0,r%=n,(r*=10)&&(o+="."),i){for(var s=a;s--;)o+=r/n|0,r%=n,r*=10;for(o+="(",s=i;s--;)o+=r/n|0,r%=n,r*=10;o+=")"}else for(s=e;r&&s--;)o+=r/n|0,r%=n,r*=10;return o}},void 0===(r=function(){return m}.apply(t,[]))||(e.exports=r)}()},228:e=>{e.exports=function e(t,r){"use strict";var n,i,a=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,o=/(^[ ]*|[ ]*$)/g,s=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,u=/^0x[0-9a-f]+$/i,c=/^0/,l=function(t){return e.insensitive&&(""+t).toLowerCase()||""+t},f=l(t).replace(o,"")||"",p=l(r).replace(o,"")||"",m=f.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),h=p.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),d=parseInt(f.match(u),16)||1!==m.length&&f.match(s)&&Date.parse(f),y=parseInt(p.match(u),16)||d&&p.match(s)&&Date.parse(p)||null;if(y){if(dy)return 1}for(var g=0,v=Math.max(m.length,h.length);gi)return 1}return 0}},377:(e,t,r)=>{var n=r(832),i=r(652),a=r(801),o=r(30),s=r(618),u=r(49),c=r(971);c.alea=n,c.xor128=i,c.xorwow=a,c.xorshift7=o,c.xor4096=s,c.tychei=u,e.exports=c},832:function(e,t,r){var n;!function(e,i,a){function o(e){var t,r=this,n=(t=4022871197,function(e){e=String(e);for(var r=0;r>>0,t=(n*=t)>>>0,t+=4294967296*(n-=t)}return 2.3283064365386963e-10*(t>>>0)});r.next=function(){var e=2091639*r.s0+2.3283064365386963e-10*r.c;return r.s0=r.s1,r.s1=r.s2,r.s2=e-(r.c=0|e)},r.c=1,r.s0=n(" "),r.s1=n(" "),r.s2=n(" "),r.s0-=n(e),r.s0<0&&(r.s0+=1),r.s1-=n(e),r.s1<0&&(r.s1+=1),r.s2-=n(e),r.s2<0&&(r.s2+=1),n=null}function s(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function u(e,t){var r=new o(e),n=t&&t.state,i=r.next;return i.int32=function(){return 4294967296*r.next()|0},i.double=function(){return i()+11102230246251565e-32*(2097152*i()|0)},i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.alea=u}(0,e=r.nmd(e),r.amdD)},49:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.next=function(){var e=t.b,r=t.c,n=t.d,i=t.a;return e=e<<25^e>>>7^r,r=r-n|0,n=n<<24^n>>>8^i,i=i-e|0,t.b=e=e<<20^e>>>12^r,t.c=r=r-n|0,t.d=n<<16^r>>>16^i,t.a=i-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):r+=e;for(var n=0;n>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.tychei=u}(0,e=r.nmd(e),r.amdD)},652:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:r+=e;for(var n=0;n>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xor128=u}(0,e=r.nmd(e),r.amdD)},618:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this;t.next=function(){var e,r,n=t.w,i=t.X,a=t.i;return t.w=n=n+1640531527|0,r=i[a+34&127],e=i[a=a+1&127],r^=r<<13,e^=e<<17,r^=r>>>15,e^=e>>>12,r=i[a]=r^e,t.i=a,r+(n^n>>>16)|0},function(e,t){var r,n,i,a,o,s=[],u=128;for(t===(0|t)?(n=t,t=null):(t+="\0",n=0,u=Math.max(u,t.length)),i=0,a=-32;a>>15,n^=n<<4,n^=n>>>13,a>=0&&(o=o+1640531527|0,i=0==(r=s[127&a]^=n+o)?i+1:0);for(i>=128&&(s[127&(t&&t.length||0)]=-1),i=127,a=512;a>0;--a)n=s[i+34&127],r=s[i=i+1&127],n^=n<<13,r^=r<<17,n^=n>>>15,r^=r>>>12,s[i]=n^r;e.w=o,e.X=s,e.i=i}(t,e)}function s(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function u(e,t){null==e&&(e=+new Date);var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&(n.X&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xor4096=u}(0,e=r.nmd(e),r.amdD)},30:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this;t.next=function(){var e,r,n=t.x,i=t.i;return e=n[i],r=(e^=e>>>7)^e<<24,r^=(e=n[i+1&7])^e>>>10,r^=(e=n[i+3&7])^e>>>3,r^=(e=n[i+4&7])^e<<7,e=n[i+7&7],r^=(e^=e<<13)^e<<9,n[i]=r,t.i=i+1&7,r},function(e,t){var r,n=[];if(t===(0|t))n[0]=t;else for(t=""+t,r=0;r0;--r)e.next()}(t,e)}function s(e,t){return t.x=e.x.slice(),t.i=e.i,t}function u(e,t){null==e&&(e=+new Date);var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&(n.x&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xorshift7=u}(0,e=r.nmd(e),r.amdD)},801:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:r+=e;for(var n=0;n>>4),t.next()}function s(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function u(e,t){var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xorwow=u}(0,e=r.nmd(e),r.amdD)},971:function(e,t,r){var n;!function(i,a,o){var s,u=256,c=o.pow(u,6),l=o.pow(2,52),f=2*l,p=255;function m(e,t,r){var n=[],p=g(y((t=1==t?{entropy:!0}:t||{}).entropy?[e,v(a)]:null==e?function(){try{var e;return s&&(e=s.randomBytes)?e=e(u):(e=new Uint8Array(u),(i.crypto||i.msCrypto).getRandomValues(e)),v(e)}catch(e){var t=i.navigator,r=t&&t.plugins;return[+new Date,i,r,i.screen,v(a)]}}():e,3),n),m=new h(n),x=function(){for(var e=m.g(6),t=c,r=0;e=f;)e/=2,t/=2,r>>>=1;return(e+r)/t};return x.int32=function(){return 0|m.g(4)},x.quick=function(){return m.g(4)/4294967296},x.double=x,g(v(m.S),a),(t.pass||r||function(e,t,r,n){return n&&(n.S&&d(n,m),e.state=function(){return d(m,{})}),r?(o.random=e,t):e})(x,p,"global"in t?t.global:this==o,t.state)}function h(e){var t,r=e.length,n=this,i=0,a=n.i=n.j=0,o=n.S=[];for(r||(e=[r++]);i3?e.slice(3):"any":e).split("|").map(q).filter(z).filter(B),i=function(e,t){var r={};return e.forEach((function(e){-1!==t.indexOf(e.from)||-1===t.indexOf(e.to)||r[e.from]||(r[e.from]=e)})),Object.keys(r).map((function(e){return r[e]}))}(t,n),a=n.map((function(e){var t=c(e);return{name:e,typeIndex:l(t),test:t.test,conversion:null,conversionIndex:-1}})),o=i.map((function(e){var r=c(e.from);return{name:e.from,typeIndex:l(r),test:r.test,conversion:e,conversionIndex:t.indexOf(e)}}));return{types:a.concat(o),restParam:r}}function h(e){var t=k(e);return!!t&&t.restParam}function d(e){return e.types.some((function(e){return null!=e.conversion}))}function y(t){if(t&&0!==t.types.length){if(1===t.types.length)return c(t.types[0].name).test;if(2===t.types.length){var r=c(t.types[0].name).test,n=c(t.types[1].name).test;return function(e){return r(e)||n(e)}}var i=t.types.map((function(e){return c(e.name).test}));return function(e){for(var t=0;t=a+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(r=y(e[0]),function(e){return r(e[0])&&1===e.length}):2===e.length?(r=y(e[0]),n=y(e[1]),function(e){return r(e[0])&&n(e[1])&&2===e.length}):(t=e.map(y),function(e){for(var r=0;r0){var c=f(t[a]);return(n=new TypeError("Unexpected type of argument in function "+o+" (expected: "+i.join(" or ")+", actual: "+c+", index: "+a+")")).data={category:"wrongType",fn:o,index:a,actual:c,expected:i},n}}else s=u}var l=s.map((function(e){return h(e.params)?1/0:e.params.length}));if(t.lengthp?((n=new TypeError("Too many arguments in function "+o+" (expected: "+p+", actual: "+t.length+")")).data={category:"tooManyArgs",fn:o,index:t.length,expectedLength:p},n):((n=new TypeError('Arguments of type "'+t.join(", ")+'" do not match any of the defined signatures of function '+o+".")).data={category:"mismatch",actual:t.map(f)},n)}function S(e){for(var t=999,r=0;r=i:s?i>=a:i===a}(t,e)}));if(t)throw new TypeError('Conflicting signatures "'+p(t.params)+'" and "'+p(e.params)+'".');i.push(e)}));var a=P(i,(function(e){return(e?_(e.params,!1):[]).map((function(t){return{params:t,fn:e.fn}}))})).filter(D);a.sort(O);var o=a[0]&&a[0].params.length<=2&&!h(a[0].params),s=a[1]&&a[1].params.length<=2&&!h(a[1].params),c=a[2]&&a[2].params.length<=2&&!h(a[2].params),l=a[3]&&a[3].params.length<=2&&!h(a[3].params),f=a[4]&&a[4].params.length<=2&&!h(a[4].params),v=a[5]&&a[5].params.length<=2&&!h(a[5].params),b=o&&s&&c&&l&&f&&v,w=a.map((function(e){return g(e.params)})),N=o?y(a[0].params[0]):t,S=s?y(a[1].params[0]):t,E=c?y(a[2].params[0]):t,A=l?y(a[3].params[0]):t,T=f?y(a[4].params[0]):t,B=v?y(a[5].params[0]):t,z=o?y(a[0].params[1]):t,k=s?y(a[1].params[1]):t,j=c?y(a[2].params[1]):t,L=l?y(a[3].params[1]):t,H=f?y(a[4].params[1]):t,$=v?y(a[5].params[1]):t,G=a.map((function(e){return function(e,t){var r=t;if(e.some(d)){var n=h(e),i=e.map(C);r=function(){for(var e=[],r=n?arguments.length-1:arguments.length,a=0;a{}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var a=t[n]={id:n,loaded:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.loaded=!0,a.exports}r.amdD=function(){throw new Error("define cannot be used indirect")},r.amdO={},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";function e(){return(e=Object.assign||function(e){for(var t=1;t!function(e){return e&&"?"===e[0]}(e))).every((e=>void 0!==r[e]))){var n=t.filter((e=>void 0===r[e]));throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(n.map((e=>'"'.concat(e,'"'))).join(", "),"."))}}(e,t,n),r(i)}return i.isFactory=!0,i.fn=e,i.dependencies=t.slice().sort(),n&&(i.meta=n),i}function J(e){return e&&"?"===e[0]?e.slice(1):e}function Y(e,t){if(ee(e)&&Q(e,t))return e[t];if("function"==typeof e[t]&&K(e,t))throw new Error('Cannot access method "'+t+'" as a property');throw new Error('No access to property "'+t+'"')}function X(e,t,r){if(ee(e)&&Q(e,t))return e[t]=r,r;throw new Error('No access to property "'+t+'"')}function Q(e,t){return!(!e||"object"!=typeof e||!V(te,t)&&(t in Object.prototype||t in Function.prototype))}function K(e,t){return!(null==e||"function"!=typeof e[t]||V(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e)||!V(re,t)&&(t in Object.prototype||t in Function.prototype))}function ee(e){return"object"==typeof e&&e&&e.constructor===Object}var te={length:!0,name:!0},re={toString:!0,valueOf:!0,toLocaleString:!0};class ne{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return Y(this.wrappedObject,e)}set(e,t){return X(this.wrappedObject,e,t),this}has(e){return e in this.wrappedObject}}function ie(){return new Map}function ae(e){if(!e)return ie();if(oe(e))return e;if(M(e))return new ne(e);throw new Error("createMap can create maps from objects or Maps")}function oe(e){return!!e&&(e instanceof Map||e instanceof ne||"function"==typeof e.set&&"function"==typeof e.get&&"function"==typeof e.keys&&"function"==typeof e.has)}function se(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{var{mathWithTransform:t}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator")}return r.prototype.evaluate=function(e){return this.compile().evaluate(e)},r.prototype.type="Node",r.prototype.isNode=!0,r.prototype.comment="",r.prototype.compile=function(){var e=this._compile(t,{}),r={};return{evaluate:function(t){var n=ae(t);return function(e){for(var t of[...H])if(e.has(t))throw new Error('Scope contains an illegal symbol, "'+t+'" is a reserved keyword')}(n),e(n,r,null)}}},r.prototype._compile=function(e,t){throw new Error("Method _compile should be implemented by type "+this.type)},r.prototype.forEach=function(e){throw new Error("Cannot run forEach on a Node interface")},r.prototype.map=function(e){throw new Error("Cannot run map on a Node interface")},r.prototype._ifNode=function(e){if(!I(e))throw new TypeError("Callback function must return a Node");return e},r.prototype.traverse=function(e){e(this,null,null),function e(t,r){t.forEach((function(t,n,i){r(t,n,i),e(t,r)}))}(this,e)},r.prototype.transform=function(e){return function t(r,n,i){var a=e(r,n,i);return a!==r?a:r.map(t)}(this,null,null)},r.prototype.filter=function(e){var t=[];return this.traverse((function(r,n,i){e(r,n,i)&&t.push(r)})),t},r.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},r.prototype.cloneDeep=function(){return this.map((function(e){return e.cloneDeep()}))},r.prototype.equals=function(e){return!!e&&Z(this,e)},r.prototype.toString=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toString(e)},r.prototype.toJSON=function(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)},r.prototype.toHTML=function(e){var t=this._getCustomString(e);return void 0!==t?t:this.toHTML(e)},r.prototype._toString=function(){throw new Error("_toString not implemented for "+this.type)},r.prototype.toTex=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toTex(e)},r.prototype._toTex=function(e){throw new Error("_toTex not implemented for "+this.type)},r.prototype._getCustomString=function(e){if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":return;case"function":return e.handler(this,e);default:throw new TypeError("Object or function expected as callback")}},r.prototype.getIdentifier=function(){return this.type},r.prototype.getContent=function(){return this},r}),{isClass:!0,isNode:!0});function ce(e){return"boolean"==typeof e||!!isFinite(e)&&e===Math.round(e)}var le=Math.sign||function(e){return e>0?1:e<0?-1:0},fe=Math.log2||function(e){return Math.log(e)/Math.LN2},pe=Math.log10||function(e){return Math.log(e)/Math.LN10},me=Math.log1p||function(e){return Math.log(e+1)},he=Math.cbrt||function(e){if(0===e)return e;var t,r=e<0;return r&&(e=-e),t=isFinite(e)?(e/((t=Math.exp(Math.log(e)/3))*t)+2*t)/3:e,r?-t:t},de=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function ye(e,t,r){var n={2:"0b",8:"0o",16:"0x"}[t],i="";if(r){if(r<1)throw new Error("size must be in greater than 0");if(!ce(r))throw new Error("size must be an integer");if(e>2**(r-1)-1||e<-(2**(r-1)))throw new Error("Value must be in range [-2^".concat(r-1,", 2^").concat(r-1,"-1]"));if(!ce(e))throw new Error("Value must be an integer");e<0&&(e+=2**r),i="i".concat(r)}var a="";return e<0&&(e=-e,a="-"),"".concat(a).concat(n).concat(e.toString(t)).concat(i)}function ge(e,t){if("function"==typeof t)return t(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var r,n,a="auto";if(t&&(t.notation&&(a=t.notation),i(t)?r=t:i(t.precision)&&(r=t.precision),t.wordSize&&"number"!=typeof(n=t.wordSize)))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return xe(e,r);case"exponential":return be(e,r);case"engineering":return function(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=we(ve(e),t),n=r.exponent,a=r.coefficients,o=n%3==0?n:n<0?n-3-n%3:n-n%3;if(i(t))for(;t>a.length||n-o+1>a.length;)a.push(0);else for(var s=Math.abs(n-o)-(a.length-1),u=0;u0;)l++,c--;var f=a.slice(l).join(""),p=i(t)&&f.length||f.match(/[1-9]/)?"."+f:"",m=a.slice(0,l).join("")+p+"e"+(n>=0?"+":"")+o.toString();return r.sign+m}(e,r);case"bin":return ye(e,2,n);case"oct":return ye(e,8,n);case"hex":return ye(e,16,n);case"auto":return function(e,t,r){if(isNaN(e)||!isFinite(e))return String(e);var n=r&&void 0!==r.lowerExp?r.lowerExp:-3,i=r&&void 0!==r.upperExp?r.upperExp:5,a=ve(e),o=t?we(a,t):a;if(o.exponent=i)return be(e,t);var s=o.coefficients,u=o.exponent;s.length0?u:0;return c<(s=Ne(-u).concat(s)).length-1&&s.splice(c+1,0,"."),o.sign+s.join("")}(e,r,t&&t).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t}));default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function ve(e){var t=String(e).toLowerCase().match(/^0*?(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+e);var r=t[1],n=t[2],i=parseFloat(t[4]||"0"),a=n.indexOf(".");i+=-1!==a?a-1:n.length-1;var o=n.replace(".","").replace(/^0*/,(function(e){return i-=e.length,""})).replace(/0*$/,"").split("").map((function(e){return parseInt(e)}));return 0===o.length&&(o.push(0),i++),{sign:r,coefficients:o,exponent:i}}function xe(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=ve(e),n="number"==typeof t?we(r,r.exponent+1+t):r,i=n.coefficients,a=n.exponent+1,o=a+(t||0);return i.length0?"."+i.join(""):"")+"e"+(a>=0?"+":"")+a}function we(e,t){for(var r={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},n=r.coefficients;t<=0;)n.unshift(0),r.exponent++,t++;if(n.length>t&&n.splice(t,n.length-t)[0]>=5){var i=t-1;for(n[i]++;10===n[i];)n.pop(),0===i&&(n.unshift(0),r.exponent++,i++),n[--i]++}return r}function Ne(e){for(var t=[],r=0;r=0?"+":"")+n.toString()}(e,r);case"bin":return Be(e,2,n);case"oct":return Be(e,8,n);case"hex":return Be(e,16,n);case"auto":var a=t&&void 0!==t.lowerExp?t.lowerExp:-3,o=t&&void 0!==t.upperExp?t.upperExp:5;if(e.isZero())return"0";var s=e.toSignificantDigits(r),u=s.e;return(u>=a&&u'"'+r+'": '+De(e[r],t))).join(", ")+"}":String(e)}function Ie(e){for(var t=String(e),r="",n=0;n/g,">")}function Re(e,t){if(Array.isArray(e)){for(var r="[",n=e.length,i=0;it?1:-1}function Ue(e,t,r){if(!(this instanceof Ue))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=t,this.relation=r,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=(new Error).stack}function Pe(e,t,r){if(!(this instanceof Pe))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=r),void 0!==this.min&&this.index=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}function je(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function Le(e,t,r){var n,i=e.length;if(i!==t[r])throw new Ue(i,t[r]);if(r")}function He(e,t){if(0===t.length){if(Array.isArray(e))throw new Ue(e.length,0)}else Le(e,t,0)}function $e(e,t){if(!i(e)||!ce(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&e>=t)throw new Pe(e,t)}function Ge(e,t,r){if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");return t.forEach((function(e){if(!i(e)||!ce(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+De(t)+")")})),Ze(e,t,0,void 0!==r?r:0),e}function Ze(e,t,r,n){var i,a,o=e.length,s=t[r],u=Math.min(o,s);if(e.length=s,r=0){if(t%r!=0)throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-r);n[i]=-t/r}return n}function Je(e){return e.reduce(((e,t)=>e*t),1)}function Ye(e,t){for(var r=t||je(e);Array.isArray(e)&&1===e.length;)e=e[0],r.shift();for(var n=r.length;1===r[n-1];)n--;return nt.test(e)))}function at(e,t){return Array.prototype.join.call(e,t)}function ot(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;var t=[],r=0;t[0]={value:e[0],identifier:0};for(var n=1;n{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=e||[],!Array.isArray(this.items)||!this.items.every(I))throw new TypeError("Array containing Nodes expected")}return r.prototype=new t,r.prototype.type="ArrayNode",r.prototype.isArrayNode=!0,r.prototype._compile=function(e,t){var r=tt(this.items,(function(r){return r._compile(e,t)}));if("Array"!==e.config.matrix){var n=e.matrix;return function(e,t,i){return n(tt(r,(function(r){return r(e,t,i)})))}}return function(e,t,n){return tt(r,(function(r){return r(e,t,n)}))}},r.prototype.forEach=function(e){for(var t=0;t['+this.items.map((function(t){return t.toHTML(e)})).join(',')+']'},r.prototype._toTex=function(e){return function t(r,n){var i=r.some(O)&&!r.every(O),a=n||i,o=a?"&":"\\\\",s=r.map((function(r){return r.items?t(r.items,!n):r.toTex(e)})).join(o);return i||!a||a&&!n?"\\begin{bmatrix}"+s+"\\end{bmatrix}":s}(this.items,!1)},r}),{isClass:!0,isNode:!0}),lt=W("BlockNode",["ResultSet","Node"],(e=>{var{ResultSet:t,Node:r}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map((function(e){var t=e&&e.node,r=!e||void 0===e.visible||e.visible;if(!I(t))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof r)throw new TypeError('Property "visible" must be a boolean');return{node:t,visible:r}}))}return n.prototype=new r,n.prototype.type="BlockNode",n.prototype.isBlockNode=!0,n.prototype._compile=function(e,r){var n=tt(this.blocks,(function(t){return{evaluate:t.node._compile(e,r),visible:t.visible}}));return function(e,r,i){var a=[];return rt(n,(function(t){var n=t.evaluate(e,r,i);t.visible&&a.push(n)})),new t(a)}},n.prototype.forEach=function(e){for(var t=0;t;')})).join('
')},n.prototype._toTex=function(e){return this.blocks.map((function(t){return t.node.toTex(e)+(t.visible?"":";")})).join("\\;\\;\n")},n}),{isClass:!0,isNode:!0}),ft=r(928),pt={Alpha:"A",alpha:"\\alpha",Beta:"B",beta:"\\beta",Gamma:"\\Gamma",gamma:"\\gamma",Delta:"\\Delta",delta:"\\delta",Epsilon:"E",epsilon:"\\epsilon",varepsilon:"\\varepsilon",Zeta:"Z",zeta:"\\zeta",Eta:"H",eta:"\\eta",Theta:"\\Theta",theta:"\\theta",vartheta:"\\vartheta",Iota:"I",iota:"\\iota",Kappa:"K",kappa:"\\kappa",varkappa:"\\varkappa",Lambda:"\\Lambda",lambda:"\\lambda",Mu:"M",mu:"\\mu",Nu:"N",nu:"\\nu",Xi:"\\Xi",xi:"\\xi",Omicron:"O",omicron:"o",Pi:"\\Pi",pi:"\\pi",varpi:"\\varpi",Rho:"P",rho:"\\rho",varrho:"\\varrho",Sigma:"\\Sigma",sigma:"\\sigma",varsigma:"\\varsigma",Tau:"T",tau:"\\tau",Upsilon:"\\Upsilon",upsilon:"\\upsilon",Phi:"\\Phi",phi:"\\phi",varphi:"\\varphi",Chi:"X",chi:"\\chi",Psi:"\\Psi",psi:"\\psi",Omega:"\\Omega",omega:"\\omega",true:"\\mathrm{True}",false:"\\mathrm{False}",i:"i",inf:"\\infty",Inf:"\\infty",infinity:"\\infty",Infinity:"\\infty",oo:"\\infty",lim:"\\lim",undefined:"\\mathbf{?}"},mt={transpose:"^\\top",ctranspose:"^H",factorial:"!",pow:"^",dotPow:".^\\wedge",unaryPlus:"+",unaryMinus:"-",bitNot:"\\~",not:"\\neg",multiply:"\\cdot",divide:"\\frac",dotMultiply:".\\cdot",dotDivide:".:",mod:"\\mod",add:"+",subtract:"-",to:"\\rightarrow",leftShift:"<<",rightArithShift:">>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},ht={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(mt.add,"${args[1]}\\right)")},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:"\\left(${args[0]}".concat(mt.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(mt.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(mt.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(mt.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:"\\left(${args[0]}".concat(mt.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(mt.multiply,"${args[1]}\\right)")},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : $y^{args[1]} = {${args[0]}}\\}"},pow:{2:"\\left(${args[0]}\\right)".concat(mt.pow,"{${args[1]}}")},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:"\\left(${args[0]}".concat(mt.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(mt.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(mt.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(mt.bitAnd,"${args[1]}\\right)")},bitNot:{1:mt.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(mt.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(mt.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(mt.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(mt.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(mt.rightLogShift,"${args[1]}\\right)")},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:"\\left(${args[0]}".concat(mt.and,"${args[1]}\\right)")},not:{1:mt.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(mt.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(mt.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(mt.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},sqrtm:{1:"{${args[0]}}".concat(mt.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(mt.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(mt.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(mt.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(mt.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(mt.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(mt.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(mt.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(mt.unequal,"${args[1]}\\right)")},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:"\\left(${args[0]}".concat(mt.to,"${args[1]}\\right)")},numeric:function(e,t){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(pt.i,"\\cdot\\left(${args[1]}\\right)\\right)")},matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},dt={deg:"^\\circ"};function yt(e){return ft(e,{preserveFormatting:!0})}function gt(e,t){return(t=void 0!==t&&t)?V(dt,e)?dt[e]:"\\mathrm{"+yt(e)+"}":V(pt,e)?pt[e]:yt(e)}var vt=W("ConstantNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this.value=e}return r.prototype=new t,r.prototype.type="ConstantNode",r.prototype.isConstantNode=!0,r.prototype._compile=function(e,t){var r=this.value;return function(){return r}},r.prototype.forEach=function(e){},r.prototype.map=function(e){return this.clone()},r.prototype.clone=function(){return new r(this.value)},r.prototype._toString=function(e){return De(this.value,e)},r.prototype.toHTML=function(e){var t=this._toString(e);switch(L(this.value)){case"number":case"BigNumber":case"Fraction":return''+t+"";case"string":return''+t+"";case"boolean":return''+t+"";case"null":return''+t+"";case"undefined":return''+t+"";default:return''+t+""}},r.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},r.fromJSON=function(e){return new r(e.value)},r.prototype._toTex=function(e){var t=this._toString(e);switch(L(this.value)){case"string":return"\\mathtt{"+yt(t)+"}";case"number":case"BigNumber":if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var r=t.toLowerCase().indexOf("e");return-1!==r?t.substring(0,r)+"\\cdot10^{"+t.substring(r+1)+"}":t;case"Fraction":return this.value.toLatex();default:return t}},r}),{isClass:!0,isNode:!0}),xt=W("ObjectNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=e||{},e&&("object"!=typeof e||!Object.keys(e).every((function(t){return I(e[t])}))))throw new TypeError("Object containing Nodes expected")}return r.prototype=new t,r.prototype.type="ObjectNode",r.prototype.isObjectNode=!0,r.prototype._compile=function(e,t){var r={};for(var n in this.properties)if(V(this.properties,n)){var i=Ie(n),a=JSON.parse(i);if(!Q(this.properties,a))throw new Error('No access to property "'+a+'"');r[a]=this.properties[n]._compile(e,t)}return function(e,t,n){var i={};for(var a in r)V(r,a)&&(i[a]=r[a](e,t,n));return i}},r.prototype.forEach=function(e){for(var t in this.properties)V(this.properties,t)&&e(this.properties[t],"properties["+Ie(t)+"]",this)},r.prototype.map=function(e){var t={};for(var n in this.properties)V(this.properties,n)&&(t[n]=this._ifNode(e(this.properties[n],"properties["+Ie(n)+"]",this)));return new r(t)},r.prototype.clone=function(){var e={};for(var t in this.properties)V(this.properties,t)&&(e[t]=this.properties[t]);return new r(e)},r.prototype._toString=function(e){var t=[];for(var r in this.properties)V(this.properties,r)&&t.push(Ie(r)+": "+this.properties[r].toString(e));return"{"+t.join(", ")+"}"},r.prototype.toJSON=function(){return{mathjs:"ObjectNode",properties:this.properties}},r.fromJSON=function(e){return new r(e.properties)},r.prototype.toHTML=function(e){var t=[];for(var r in this.properties)V(this.properties,r)&&t.push(''+ke(r)+':'+this.properties[r].toHTML(e));return'{'+t.join(',')+'}'},r.prototype._toTex=function(e){var t=[];for(var r in this.properties)V(this.properties,r)&&t.push("\\mathbf{"+r+":} & "+this.properties[r].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(t.join("\n"),"\\end{array}\\right\\}")},r}),{isClass:!0,isNode:!0}),bt=W("ParenthesisNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError('Node expected for parameter "content"');this.content=e}return r.prototype=new t,r.prototype.type="ParenthesisNode",r.prototype.isParenthesisNode=!0,r.prototype._compile=function(e,t){return this.content._compile(e,t)},r.prototype.getContent=function(){return this.content.getContent()},r.prototype.forEach=function(e){e(this.content,"content",this)},r.prototype.map=function(e){return new r(e(this.content,"content",this))},r.prototype.clone=function(){return new r(this.content)},r.prototype._toString=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)},r.prototype.toJSON=function(){return{mathjs:"ParenthesisNode",content:this.content}},r.fromJSON=function(e){return new r(e.content)},r.prototype.toHTML=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?'('+this.content.toHTML(e)+')':this.content.toHTML(e)},r.prototype._toTex=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)},r}),{isClass:!0,isNode:!0}),wt=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{associativity:"left",associativeWith:[]}},{"OperatorNode:and":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{associativity:"left",associativeWith:[]},"OperatorNode:unequal":{associativity:"left",associativeWith:[]},"OperatorNode:smaller":{associativity:"left",associativeWith:[]},"OperatorNode:larger":{associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{associativity:"left",associativeWith:[]}},{"OperatorNode:to":{associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{associativity:"left",associativeWith:[]},"OperatorNode:mod":{associativity:"left",associativeWith:[]}},{"OperatorNode:unaryPlus":{associativity:"right"},"OperatorNode:unaryMinus":{associativity:"right"},"OperatorNode:bitNot":{associativity:"right"},"OperatorNode:not":{associativity:"right"}},{"OperatorNode:pow":{associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{associativity:"left"}},{"OperatorNode:transpose":{associativity:"left"}}];function Nt(e,t){var r=e;"keep"!==t&&(r=e.getContent());for(var n=r.getIdentifier(),i=0;i{var{Node:t}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(t))throw new TypeError("Parameter params must be an array");if(e.length!==t.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=t}return r.prototype=new t,r.prototype.type="RelationalNode",r.prototype.isRelationalNode=!0,r.prototype._compile=function(e,t){var r=this,n=this.params.map((r=>r._compile(e,t)));return function(t,i,a){for(var o,s=n[0](t,i,a),u=0;ue(t,"params["+r+"]",this)),this)},r.prototype.map=function(e){return new r(this.conditionals.slice(),this.params.map(((t,r)=>this._ifNode(e(t,"params["+r+"]",this))),this))},r.prototype.clone=function(){return new r(this.conditionals,this.params)},r.prototype._toString=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.params.map((function(n,i){var a=Nt(n,t);return"all"===t||null!==a&&a<=r?"("+n.toString(e)+")":n.toString(e)})),i={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},a=n[0],o=0;o('+n.toHTML(e)+')':n.toHTML(e)})),i={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},a=n[0],o=0;o'+ke(i[this.conditionals[o]])+""+n[o+1];return a},r.prototype._toTex=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.params.map((function(n,i){var a=Nt(n,t);return"all"===t||null!==a&&a<=r?"\\left("+n.toTex(e)+"\right)":n.toTex(e)})),i=n[0],a=0;a{var{on:t,math:r}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");j(e)?this.value=e.value:this.value=e}function i(e,t){var r,i,o,s,u;r=n.prototype,i=e,o=function(){var e=t();if("function"==typeof e)return a(e)},u=!0,Object.defineProperty(r,i,{get:function(){return u&&(s=o(),u=!1),s},set:function(e){s=e,u=!1},configurable:!0,enumerable:!0})}function a(e){return function(){for(var t=[this.value],r=0;re[t]))};for(var s in e)r(s)}var u,c};var o={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return n.createProxy(r),t&&t("import",(function(e,t,r){r||i(e,t)})),n}),{isClass:!0}),Ot=W("reviver",["classes"],(e=>{var{classes:t}=e;return function(e,r){var n=t[r&&r.mathjs];return n&&"function"==typeof n.fromJSON?n.fromJSON(r):r}})),Ct=W("ConditionalNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError("Parameter condition must be a Node");if(!I(t))throw new TypeError("Parameter trueExpr must be a Node");if(!I(n))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=t,this.falseExpr=n}return r.prototype=new t,r.prototype.type="ConditionalNode",r.prototype.isConditionalNode=!0,r.prototype._compile=function(e,t){var r=this.condition._compile(e,t),n=this.trueExpr._compile(e,t),i=this.falseExpr._compile(e,t);return function(e,t,s){return function(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return!!e;if(e){if(a(e))return!e.isZero();if(o(e))return!(!e.re&&!e.im);if(u(e))return!!e.value}if(null==e)return!1;throw new TypeError('Unsupported type of condition "'+L(e)+'"')}(r(e,t,s))?n(e,t,s):i(e,t,s)}},r.prototype.forEach=function(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)},r.prototype.map=function(e){return new r(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))},r.prototype.clone=function(){return new r(this.condition,this.trueExpr,this.falseExpr)},r.prototype._toString=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.condition.toString(e),i=Nt(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n="("+n+")");var a=this.trueExpr.toString(e),o=Nt(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a="("+a+")");var s=this.falseExpr.toString(e),u=Nt(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s="("+s+")"),n+" ? "+a+" : "+s},r.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},r.fromJSON=function(e){return new r(e.condition,e.trueExpr,e.falseExpr)},r.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.condition.toHTML(e),i=Nt(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n='('+n+')');var a=this.trueExpr.toHTML(e),o=Nt(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a='('+a+')');var s=this.falseExpr.toHTML(e),u=Nt(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s='('+s+')'),n+'?'+a+':'+s},r.prototype._toTex=function(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"},r}),{isClass:!0,isNode:!0}),_t=W("OperatorNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n,i,a){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('string expected for parameter "op"');if("string"!=typeof t)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(n)||!n.every(I))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=!0===i,this.isPercentage=!0===a,this.op=e,this.fn=t,this.args=n||[]}function n(e,t,r,n,i){var a,o=Nt(e,t),s=Mt(e,t);if("all"===t||n.length>2&&"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier())return n.map((function(e){switch(e.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}}));switch(n.length){case 0:a=[];break;case 1:var u=Nt(n[0],t);if(i&&null!==u){var c,l;if("keep"===t?(c=n[0].getIdentifier(),l=e.getIdentifier()):(c=n[0].getContent().getIdentifier(),l=e.getContent().getIdentifier()),!1===wt[o][l].latexLeftParens){a=[!1];break}if(!1===wt[u][c].latexParens){a=[!1];break}}if(null===u){a=[!1];break}if(u<=o){a=[!0];break}a=[!1];break;case 2:var f,p,m=Nt(n[0],t),h=St(e,n[0],t);f=null!==m&&(m===o&&"right"===s&&!h||m=2&&"OperatorNode:multiply"===e.getIdentifier()&&e.implicit&&"auto"===t&&"hide"===r&&(a=n.map((function(e,t){var r="ParenthesisNode"===e.getIdentifier();return!(!a[t]&&!r)}))),a}return r.prototype=new t,r.prototype.type="OperatorNode",r.prototype.isOperatorNode=!0,r.prototype._compile=function(e,t){if("string"!=typeof this.fn||!K(e,this.fn))throw e[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var r=Y(e,this.fn),n=tt(this.args,(function(r){return r._compile(e,t)}));if(1===n.length){var i=n[0];return function(e,t,n){return r(i(e,t,n))}}if(2===n.length){var a=n[0],o=n[1];return function(e,t,n){return r(a(e,t,n),o(e,t,n))}}return function(e,t,i){return r.apply(null,tt(n,(function(r){return r(e,t,i)})))}},r.prototype.forEach=function(e){for(var t=0;t2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var f=i.map((function(t,r){return t=t.toString(e),a[r]&&(t="("+t+")"),t}));return this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?f.join(" "):f.join(" "+this.op+" ")}return this.fn+"("+this.args.join(", ")+")"},r.prototype.toJSON=function(){return{mathjs:"OperatorNode",op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}},r.fromJSON=function(e){return new r(e.op,e.fn,e.args,e.implicit,e.isPercentage)},r.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,t,r,i,!1);if(1===i.length){var o=Mt(this,t),s=i[0].toHTML(e);return a[0]&&(s='('+s+')'),"right"===o?''+ke(this.op)+""+s:s+''+ke(this.op)+""}if(2===i.length){var u=i[0].toHTML(e),c=i[1].toHTML(e);return a[0]&&(u='('+u+')'),a[1]&&(c='('+c+')'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?u+''+c:u+''+ke(this.op)+""+c}var l=i.map((function(t,r){return t=t.toHTML(e),a[r]&&(t='('+t+')'),t}));return i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())?this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?l.join(''):l.join(''+ke(this.op)+""):''+ke(this.fn)+'('+l.join(',')+')'},r.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,t,r,i,!0),o=mt[this.fn];if(o=void 0===o?this.op:o,1===i.length){var s=Mt(this,t),u=i[0].toTex(e);return a[0]&&(u="\\left(".concat(u,"\\right)")),"right"===s?o+u:u+o}if(2===i.length){var c=i[0],l=c.toTex(e);a[0]&&(l="\\left(".concat(l,"\\right)"));var f,p=i[1].toTex(e);switch(a[1]&&(p="\\left(".concat(p,"\\right)")),f="keep"===t?c.getIdentifier():c.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return o+"{"+l+"}{"+p+"}";case"OperatorNode:pow":switch(l="{"+l+"}",p="{"+p+"}",f){case"ConditionalNode":case"OperatorNode:divide":l="\\left(".concat(l,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&"hide"===r)return l+"~"+p}return l+o+p}if(i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var m=i.map((function(t,r){return t=t.toTex(e),a[r]&&(t="\\left(".concat(t,"\\right)")),t}));return"OperatorNode:multiply"===this.getIdentifier()&&this.implicit?m.join("~"):m.join(o)}return"\\mathrm{"+this.fn+"}\\left("+i.map((function(t){return t.toTex(e)})).join(",")+"\\right)"},r.prototype.getIdentifier=function(){return this.type+":"+this.fn},r}),{isClass:!0,isNode:!0}),Tt=W("RangeNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError("Node expected");if(!I(t))throw new TypeError("Node expected");if(n&&!I(n))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=e,this.end=t,this.step=n||null}function n(e,t){var r=Nt(e,t),n={},i=Nt(e.start,t);if(n.start=null!==i&&i<=r||"all"===t,e.step){var a=Nt(e.step,t);n.step=null!==a&&a<=r||"all"===t}var o=Nt(e.end,t);return n.end=null!==o&&o<=r||"all"===t,n}return r.prototype=new t,r.prototype.type="RangeNode",r.prototype.isRangeNode=!0,r.prototype.needsEnd=function(){return this.filter((function(e){return P(e)&&"end"===e.name})).length>0},r.prototype._compile=function(e,t){var r=e.range,n=this.start._compile(e,t),i=this.end._compile(e,t);if(this.step){var a=this.step._compile(e,t);return function(e,t,o){return r(n(e,t,o),i(e,t,o),a(e,t,o))}}return function(e,t,a){return r(n(e,t,a),i(e,t,a))}},r.prototype.forEach=function(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)},r.prototype.map=function(e){return new r(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))},r.prototype.clone=function(){return new r(this.start,this.end,this.step&&this.step)},r.prototype._toString=function(e){var t,r=n(this,e&&e.parenthesis?e.parenthesis:"keep"),i=this.start.toString(e);if(r.start&&(i="("+i+")"),t=i,this.step){var a=this.step.toString(e);r.step&&(a="("+a+")"),t+=":"+a}var o=this.end.toString(e);return r.end&&(o="("+o+")"),t+":"+o},r.prototype.toJSON=function(){return{mathjs:"RangeNode",start:this.start,end:this.end,step:this.step}},r.fromJSON=function(e){return new r(e.start,e.end,e.step)},r.prototype.toHTML=function(e){var t,r=n(this,e&&e.parenthesis?e.parenthesis:"keep"),i=this.start.toHTML(e);if(r.start&&(i='('+i+')'),t=i,this.step){var a=this.step.toHTML(e);r.step&&(a='('+a+')'),t+=':'+a}var o=this.end.toHTML(e);return r.end&&(o='('+o+')'),t+':'+o},r.prototype._toTex=function(e){var t=n(this,e&&e.parenthesis?e.parenthesis:"keep"),r=this.start.toTex(e);if(t.start&&(r="\\left(".concat(r,"\\right)")),this.step){var i=this.step.toTex(e);t.step&&(i="\\left(".concat(i,"\\right)")),r+=":"+i}var a=this.end.toTex(e);return t.end&&(a="\\left(".concat(a,"\\right)")),r+":"+a},r}),{isClass:!0,isNode:!0}),Bt=W("FunctionAssignmentNode",["typed","Node"],(e=>{var{typed:t,Node:r}=e;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(t))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!I(r))throw new TypeError('Node expected for parameter "expr"');if(H.has(e))throw new Error('Illegal function name, "'+e+'" is a reserved keyword');this.name=e,this.params=t.map((function(e){return e&&e.name||e})),this.types=t.map((function(e){return e&&e.type||"any"})),this.expr=r}function i(e,t){var r=Nt(e,t),n=Nt(e.expr,t);return"all"===t||null!==n&&n<=r}return n.prototype=new r,n.prototype.type="FunctionAssignmentNode",n.prototype.isFunctionAssignmentNode=!0,n.prototype._compile=function(e,r){var n=Object.create(r);rt(this.params,(function(e){n[e]=!0}));var i=this.expr._compile(e,n),a=this.name,o=this.params,s=at(this.types,","),u=a+"("+at(this.params,", ")+")";return function(e,r,n){var c={};c[s]=function(){for(var t=Object.create(r),a=0;a'+ke(this.params[n])+"");var a=this.expr.toHTML(e);return i(this,t)&&(a='('+a+')'),''+ke(this.name)+'('+r.join(',')+')='+a},n.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=this.expr.toTex(e);return i(this,t)&&(r="\\left(".concat(r,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(gt).join(",")+"\\right):="+r},n}),{isClass:!0,isNode:!0}),qt="chain",zt=W(qt,["typed","Chain"],(e=>{var{typed:t,Chain:r}=e;return t(qt,{"":function(){return new r},any:function(e){return new r(e)}})}));function Dt(e){return e&&e.isIndexError?new Pe(e.index+1,e.min+1,void 0!==e.max?e.max+1:void 0):e}function It(e){var{subset:t}=e;return function(e,r){try{if(Array.isArray(e))return t(e,r);if(e&&"function"==typeof e.subset)return e.subset(r);if("string"==typeof e)return t(e,r);if("object"==typeof e){if(!r.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return Y(e,r.getObjectProperty())}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Dt(e)}}}var kt=W("AccessorNode",["subset","Node"],(e=>{var{subset:t,Node:r}=e,n=It({subset:t});function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError('Node expected for parameter "object"');if(!D(t))throw new TypeError('IndexNode expected for parameter "index"');this.object=e||null,this.index=t,Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function a(e){return!(A(e)||O(e)||B(e)||z(e)||k(e)||F(e)||P(e))}return i.prototype=new r,i.prototype.type="AccessorNode",i.prototype.isAccessorNode=!0,i.prototype._compile=function(e,t){var r=this.object._compile(e,t),i=this.index._compile(e,t);if(this.index.isObjectProperty()){var a=this.index.getObjectProperty();return function(e,t,n){return Y(r(e,t,n),a)}}return function(e,t,a){var o=r(e,t,a),s=i(e,t,o);return n(o,s)}},i.prototype.forEach=function(e){e(this.object,"object",this),e(this.index,"index",this)},i.prototype.map=function(e){return new i(this._ifNode(e(this.object,"object",this)),this._ifNode(e(this.index,"index",this)))},i.prototype.clone=function(){return new i(this.object,this.index)},i.prototype._toString=function(e){var t=this.object.toString(e);return a(this.object)&&(t="("+t+")"),t+this.index.toString(e)},i.prototype.toHTML=function(e){var t=this.object.toHTML(e);return a(this.object)&&(t='('+t+')'),t+this.index.toHTML(e)},i.prototype._toTex=function(e){var t=this.object.toTex(e);return a(this.object)&&(t="\\left(' + object + '\\right)"),t+this.index.toTex(e)},i.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},i.fromJSON=function(e){return new i(e.object,e.index)},i}),{isClass:!0,isNode:!0}),Rt=W("IndexNode",["Range","Node","size"],(e=>{var{Range:t,Node:r,size:n}=e;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(this.dimensions=e,this.dotNotation=t||!1,!Array.isArray(e)||!e.every(I))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}function o(e,r,n){return new t(a(e)?e.toNumber():e,a(r)?r.toNumber():r,a(n)?n.toNumber():n)}return i.prototype=new r,i.prototype.type="IndexNode",i.prototype.isIndexNode=!0,i.prototype._compile=function(e,t){var r=tt(this.dimensions,(function(r,i){if(U(r)){if(r.needsEnd()){var a=Object.create(t);a.end=!0;var s=r.start._compile(e,a),u=r.end._compile(e,a),c=r.step?r.step._compile(e,a):function(){return 1};return function(e,t,r){var a=n(r).valueOf(),l=Object.create(t);return l.end=a[i],o(s(e,l,r),u(e,l,r),c(e,l,r))}}var l=r.start._compile(e,t),f=r.end._compile(e,t),p=r.step?r.step._compile(e,t):function(){return 1};return function(e,t,r){return o(l(e,t,r),f(e,t,r),p(e,t,r))}}if(P(r)&&"end"===r.name){var m=Object.create(t);m.end=!0;var h=r._compile(e,m);return function(e,t,r){var a=n(r).valueOf(),o=Object.create(t);return o.end=a[i],h(e,o,r)}}var d=r._compile(e,t);return function(e,t,r){return d(e,t,r)}})),i=Y(e,"index");return function(e,t,n){var a=tt(r,(function(r){return r(e,t,n)}));return i(...a)}},i.prototype.forEach=function(e){for(var t=0;t.'+ke(this.getObjectProperty())+"":'['+t.join(',')+']'},i.prototype._toTex=function(e){var t=this.dimensions.map((function(t){return t.toTex(e)}));return this.dotNotation?"."+this.getObjectProperty():"_{"+t.join(",")+"}"},i}),{isClass:!0,isNode:!0}),Ft=W("AssignmentNode",["subset","?matrix","Node"],(e=>{var{subset:t,matrix:r,Node:n}=e,i=It({subset:t}),a=function(e){var{subset:t,matrix:r}=e;return function(e,n,i){try{if(Array.isArray(e))return r(e).subset(n,i).valueOf();if(e&&"function"==typeof e.subset)return e.subset(n,i);if("string"==typeof e)return t(e,n,i);if("object"==typeof e){if(!n.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return X(e,n.getObjectProperty(),i),e}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Dt(e)}}}({subset:t,matrix:r});function o(e,t,r){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=e,this.index=r?t:null,this.value=r||t,!P(e)&&!A(e))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(P(e)&&"end"===e.name)throw new Error('Cannot assign to symbol "end"');if(this.index&&!D(this.index))throw new TypeError('IndexNode expected as "index"');if(!I(this.value))throw new TypeError('Node expected as "value"');Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function s(e,t){t||(t="keep");var r=Nt(e,t),n=Nt(e.value,t);return"all"===t||null!==n&&n<=r}return o.prototype=new n,o.prototype.type="AssignmentNode",o.prototype.isAssignmentNode=!0,o.prototype._compile=function(e,t){var r=this.object._compile(e,t),n=this.index?this.index._compile(e,t):null,o=this.value._compile(e,t),s=this.object.name;if(this.index){if(this.index.isObjectProperty()){var u=this.index.getObjectProperty();return function(e,t,n){var i=r(e,t,n),a=o(e,t,n);return X(i,u,a),a}}if(P(this.object))return function(e,t,i){var u=r(e,t,i),c=o(e,t,i),l=n(e,t,u);return e.set(s,a(u,l,c)),c};var c=this.object.object._compile(e,t);if(this.object.index.isObjectProperty()){var l=this.object.index.getObjectProperty();return function(e,t,r){var i=c(e,t,r),s=Y(i,l),u=n(e,t,s),f=o(e,t,r);return X(i,l,a(s,u,f)),f}}var f=this.object.index._compile(e,t);return function(e,t,r){var s=c(e,t,r),u=f(e,t,s),l=i(s,u),p=n(e,t,l),m=o(e,t,r);return a(s,u,a(l,p,m)),m}}if(!P(this.object))throw new TypeError("SymbolNode expected as object");return function(e,t,r){var n=o(e,t,r);return e.set(s,n),n}},o.prototype.forEach=function(e){e(this.object,"object",this),this.index&&e(this.index,"index",this),e(this.value,"value",this)},o.prototype.map=function(e){return new o(this._ifNode(e(this.object,"object",this)),this.index?this._ifNode(e(this.index,"index",this)):null,this._ifNode(e(this.value,"value",this)))},o.prototype.clone=function(){return new o(this.object,this.index,this.value)},o.prototype._toString=function(e){var t=this.object.toString(e),r=this.index?this.index.toString(e):"",n=this.value.toString(e);return s(this,e&&e.parenthesis)&&(n="("+n+")"),t+r+" = "+n},o.prototype.toJSON=function(){return{mathjs:"AssignmentNode",object:this.object,index:this.index,value:this.value}},o.fromJSON=function(e){return new o(e.object,e.index,e.value)},o.prototype.toHTML=function(e){var t=this.object.toHTML(e),r=this.index?this.index.toHTML(e):"",n=this.value.toHTML(e);return s(this,e&&e.parenthesis)&&(n='('+n+')'),t+r+'='+n},o.prototype._toTex=function(e){var t=this.object.toTex(e),r=this.index?this.index.toTex(e):"",n=this.value.toTex(e);return s(this,e&&e.parenthesis)&&(n="\\left(".concat(n,"\\right)")),t+r+":="+n},o}),{isClass:!0,isNode:!0}),Ut=W("SymbolNode",["math","?Unit","Node"],(e=>{var{math:t,Unit:r,Node:n}=e;function i(e){return!!r&&r.isValuelessUnit(e)}function a(e){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');this.name=e}return a.prototype=new n,a.prototype.type="SymbolNode",a.prototype.isSymbolNode=!0,a.prototype._compile=function(e,t){var n=this.name;if(!0===t[n])return function(e,t,r){return t[n]};if(n in e)return function(t,r,i){return t.has(n)?t.get(n):Y(e,n)};var o=i(n);return function(e,t,i){return e.has(n)?e.get(n):o?new r(null,n):a.onUndefinedSymbol(n)}},a.prototype.forEach=function(e){},a.prototype.map=function(e){return this.clone()},a.onUndefinedSymbol=function(e){throw new Error("Undefined symbol "+e)},a.prototype.clone=function(){return new a(this.name)},a.prototype._toString=function(e){return this.name},a.prototype.toHTML=function(e){var t=ke(this.name);return"true"===t||"false"===t?''+t+"":"i"===t?''+t+"":"Infinity"===t?''+t+"":"NaN"===t?''+t+"":"null"===t?''+t+"":"undefined"===t?''+t+"":''+t+""},a.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},a.fromJSON=function(e){return new a(e.name)},a.prototype._toTex=function(e){var r=!1;void 0===t[this.name]&&i(this.name)&&(r=!0);var n=gt(this.name,r);return"\\"===n[0]?n:" "+n},a}),{isClass:!0,isNode:!0});function Pt(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{var{math:t,Node:r,SymbolNode:n}=e;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if("string"==typeof e&&(e=new n(e)),!I(e))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(t)||!t.every(I))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=e,this.args=t||[],Object.defineProperty(this,"name",{get:function(){return this.fn.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}i.prototype=new r,i.prototype.type="FunctionNode",i.prototype.isFunctionNode=!0,i.prototype._compile=function(e,t){if(!(this instanceof i))throw new TypeError("No valid FunctionNode");var r=this.args.map((r=>r._compile(e,t)));if(!P(this.fn)){if(A(this.fn)&&D(this.fn.index)&&this.fn.index.isObjectProperty()){var n=this.fn.object._compile(e,t),a=this.fn.index.getObjectProperty(),o=this.args;return function(t,i,s){var u=n(t,i,s);if(function(e,t){if(!K(e,t))throw new Error('No access to method "'+t+'"')}(u,a),u[a]&&u[a].rawArgs)return u[a](o,e,Pt(t,i),t);var c=r.map((e=>e(t,i,s)));return u[a].apply(u,c)}}var s=this.fn._compile(e,t),u=this.args;return function(t,n,i){var a=s(t,n,i);if(a&&a.rawArgs)return a(u,e,Pt(t,n),t);var o=r.map((e=>e(t,n,i)));return a.apply(a,o)}}var c=this.fn.name,l=c in e?Y(e,c):void 0,f="function"==typeof l&&!0===l.rawArgs,p=t=>t.has(c)?t.get(c):c in e?Y(e,c):i.onUndefinedFunction(c);if(f){var m=this.args;return function(t,r,n){return p(t)(m,e,Pt(t,r),t)}}switch(r.length){case 0:return function(e,t,r){return p(e)()};case 1:return function(e,t,n){return p(e)((0,r[0])(e,t,n))};case 2:return function(e,t,n){var i=p(e),a=r[0],o=r[1];return i(a(e,t,n),o(e,t,n))};default:return function(e,t,n){return p(e)(...r.map((r=>r(e,t,n))))}}},i.prototype.forEach=function(e){e(this.fn,"fn",this);for(var t=0;t'+ke(this.fn)+'('+t.join(',')+')'};var s=i.prototype.toTex;return i.prototype.toTex=function(e){var t;return e&&"object"==typeof e.handler&&V(e.handler,this.name)&&(t=e.handler[this.name](this,e)),void 0!==t?t:s.call(this,e)},i.prototype._toTex=function(e){var r,n,i=this.args.map((function(t){return t.toTex(e)}));switch(ht[this.name]&&(r=ht[this.name]),!t[this.name]||"function"!=typeof t[this.name].toTex&&"object"!=typeof t[this.name].toTex&&"string"!=typeof t[this.name].toTex||(r=t[this.name].toTex),typeof r){case"function":n=r(this,e);break;case"string":n=o(r,this,e);break;case"object":switch(typeof r[i.length]){case"function":n=r[i.length](this,e);break;case"string":n=o(r[i.length],this,e)}}return void 0!==n?n:o("\\mathrm{${name}}\\left(${args}\\right)",this,e)},i.prototype.getIdentifier=function(){return this.type+":"+this.name},i}),{isClass:!0,isNode:!0});function Lt(e){for(var t=0;t=n.length)throw new Pe(t,n.length);return f(e)?e.create(Zt(e.valueOf(),t,r)):Zt(e,t,r)}function Zt(e,t,r){var n,i,a,o;if(t<=0){if(Array.isArray(e[0])){for(o=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r{var{typed:r,numeric:n,config:i,AccessorNode:a,ArrayNode:o,AssignmentNode:s,BlockNode:u,ConditionalNode:c,ConstantNode:l,FunctionAssignmentNode:f,FunctionNode:p,IndexNode:m,ObjectNode:h,OperatorNode:d,ParenthesisNode:y,RangeNode:g,RelationalNode:v,SymbolNode:x}=t,b=r(Wt,{string:function(e){return U(e,{})},"Array | Matrix":function(e){return w(e,{})},"string, Object":function(e,t){return U(e,void 0!==t.nodes?t.nodes:{})},"Array | Matrix, Object":w});function w(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=void 0!==t.nodes?t.nodes:{};return $t(e,(function(e){if("string"!=typeof e)throw new TypeError("String expected");return U(e,r)}))}var N={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},M={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},S={true:!0,false:!1,null:null,undefined:void 0},E=["NaN","Infinity"];function O(e,t){return e.expression.substr(e.index,t)}function C(e){return O(e,1)}function _(e){e.index++}function T(e){return e.expression.charAt(e.index-1)}function q(e){return e.expression.charAt(e.index+1)}function D(e){for(e.tokenType=0,e.token="",e.comment="";b.isWhitespace(C(e),e.nestingLevel);)_(e);if("#"===C(e))for(;"\n"!==C(e)&&""!==C(e);)e.comment+=C(e),_(e);if(""!==C(e)){if("\n"===C(e)&&!e.nestingLevel)return e.tokenType=1,e.token=C(e),void _(e);var t=C(e),r=O(e,2),n=O(e,3);if(3===n.length&&N[n])return e.tokenType=1,e.token=n,_(e),_(e),void _(e);if(2===r.length&&N[r])return e.tokenType=1,e.token=r,_(e),void _(e);if(N[t])return e.tokenType=1,e.token=t,void _(e);if(b.isDigitDot(t)){e.tokenType=2;var i=O(e,2);if("0b"===i||"0o"===i||"0x"===i){for(e.token+=C(e),_(e),e.token+=C(e),_(e);b.isHexDigit(C(e));)e.token+=C(e),_(e);if("."===C(e))for(e.token+=".",_(e);b.isHexDigit(C(e));)e.token+=C(e),_(e);else if("i"===C(e))for(e.token+="i",_(e);b.isDigit(C(e));)e.token+=C(e),_(e);return}if("."===C(e)){if(e.token+=C(e),_(e),!b.isDigit(C(e)))return void(e.tokenType=1)}else{for(;b.isDigit(C(e));)e.token+=C(e),_(e);b.isDecimalMark(C(e),q(e))&&(e.token+=C(e),_(e))}for(;b.isDigit(C(e));)e.token+=C(e),_(e);if("E"===C(e)||"e"===C(e))if(b.isDigit(q(e))||"-"===q(e)||"+"===q(e)){if(e.token+=C(e),_(e),"+"!==C(e)&&"-"!==C(e)||(e.token+=C(e),_(e)),!b.isDigit(C(e)))throw ce(e,'Digit expected, got "'+C(e)+'"');for(;b.isDigit(C(e));)e.token+=C(e),_(e);if(b.isDecimalMark(C(e),q(e)))throw ce(e,'Digit expected, got "'+C(e)+'"')}else if("."===q(e))throw _(e),ce(e,'Digit expected, got "'+C(e)+'"')}else{if(!b.isAlpha(C(e),T(e),q(e))){for(e.tokenType=4;""!==C(e);)e.token+=C(e),_(e);throw ce(e,'Syntax error in part "'+e.token+'"')}for(;b.isAlpha(C(e),T(e),q(e))||b.isDigit(C(e));)e.token+=C(e),_(e);V(M,e.token)?e.tokenType=1:e.tokenType=3}}else e.tokenType=1}function I(e){do{D(e)}while("\n"===e.token)}function k(e){e.nestingLevel++}function F(e){e.nestingLevel--}function U(t,r){var n={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:0,nestingLevel:0,conditionalLevel:null};e(n,{expression:t,extraNodes:r}),D(n);var i=function(e){var t,r,n=[];for(""!==e.token&&"\n"!==e.token&&";"!==e.token&&((t=j(e)).comment=e.comment);"\n"===e.token||";"===e.token;)0===n.length&&t&&(r=";"!==e.token,n.push({node:t,visible:r})),D(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&((t=j(e)).comment=e.comment,r=";"!==e.token,n.push({node:t,visible:r}));return n.length>0?new u(n):(t||((t=new l(void 0)).comment=e.comment),t)}(n);if(""!==n.token)throw 1===n.tokenType?le(n,"Unexpected operator "+n.token):ce(n,'Unexpected part "'+n.token+'"');return i}function j(e){var t,r,n,i,a=function(e){for(var t=function(e){for(var t=L(e);"or"===e.token;)I(e),t=new d("or","or",[t,L(e)]);return t}(e);"?"===e.token;){var r=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,I(e);var n=t,i=j(e);if(":"!==e.token)throw ce(e,"False part of conditional expression expected");e.conditionalLevel=null,I(e);var a=j(e);t=new c(n,i,a),e.conditionalLevel=r}return t}(e);if("="===e.token){if(P(a))return t=a.name,I(e),n=j(e),new s(new x(t),n);if(A(a))return I(e),n=j(e),new s(a.object,a.index,n);if(z(a)&&P(a.fn)&&(i=!0,r=[],t=a.name,a.args.forEach((function(e,t){P(e)?r[t]=e.name:i=!1})),i))return I(e),n=j(e),new f(t,r,n);throw ce(e,"Invalid left hand side of assignment operator =")}return a}function L(e){for(var t=H(e);"xor"===e.token;)I(e),t=new d("xor","xor",[t,H(e)]);return t}function H(e){for(var t=$(e);"and"===e.token;)I(e),t=new d("and","and",[t,$(e)]);return t}function $(e){for(var t=G(e);"|"===e.token;)I(e),t=new d("|","bitOr",[t,G(e)]);return t}function G(e){for(var t=Z(e);"^|"===e.token;)I(e),t=new d("^|","bitXor",[t,Z(e)]);return t}function Z(e){for(var t=W(e);"&"===e.token;)I(e),t=new d("&","bitAnd",[t,W(e)]);return t}function W(e){for(var t=[J(e)],r=[],n={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};V(n,e.token);){var i={name:e.token,fn:n[e.token]};r.push(i),I(e),t.push(J(e))}return 1===t.length?t[0]:2===t.length?new d(r[0].name,r[0].fn,t):new v(r.map((e=>e.fn)),t)}function J(e){var t,r,n,i;t=Y(e);for(var a={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};V(a,e.token);)n=a[r=e.token],I(e),i=[t,Y(e)],t=new d(r,n,i);return t}function Y(e){var t,r,n,i;t=X(e);for(var a={to:"to",in:"to"};V(a,e.token);)n=a[r=e.token],I(e),"in"===r&&""===e.token?t=new d("*","multiply",[t,new x("in")],!0):(i=[t,X(e)],t=new d(r,n,i));return t}function X(e){var t,r=[];if(t=":"===e.token?new l(1):Q(e),":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(r.push(t);":"===e.token&&r.length<3;)I(e),")"===e.token||"]"===e.token||","===e.token||""===e.token?r.push(new x("end")):r.push(Q(e));t=3===r.length?new g(r[0],r[2],r[1]):new g(r[0],r[1])}return t}function Q(e){var t,r,n,i;t=K(e);for(var a={"+":"add","-":"subtract"};V(a,e.token);){n=a[r=e.token],I(e);var o=K(e);i=o.isPercentage?[t,new d("*","multiply",[t,o])]:[t,o],t=new d(r,n,i)}return t}function K(e){var t,r,n,i;r=t=ee(e);for(var a={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};V(a,e.token);)i=a[n=e.token],I(e),r=ee(e),t=new d(n,i,[t,r]);return t}function ee(e){var t,r;for(r=t=te(e);3===e.tokenType||"in"===e.token&&B(t)||!(2!==e.tokenType||B(r)||R(r)&&"!"!==r.op)||"("===e.token;)r=te(e),t=new d("*","multiply",[t,r],!0);return t}function te(t){for(var r=re(t),n=r,i=[];"/"===t.token&&B(n);){if(i.push(e({},t)),I(t),2!==t.tokenType){e(t,i.pop());break}if(i.push(e({},t)),I(t),3!==t.tokenType&&"("!==t.token){i.pop(),e(t,i.pop());break}e(t,i.pop()),i.pop(),n=re(t),r=new d("/","divide",[r,n])}return r}function re(e){var t,r,n,i;t=ne(e);for(var a={"%":"mod",mod:"mod"};V(a,e.token);)n=a[r=e.token],I(e),"%"===r&&1===e.tokenType&&"("!==e.token?t=new d("/","divide",[t,new l(100)],!1,!0):(i=[t,ne(e)],t=new d(r,n,i));return t}function ne(e){var t,r,a,s={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return V(s,e.token)?(a=s[e.token],t=e.token,I(e),r=[ne(e)],new d(t,a,r)):function(e){var t,r,a,s;return t=function(e){var t,r,a;t=function(e){var t=[];if(3===e.tokenType&&V(e.extraNodes,e.token)){var r=e.extraNodes[e.token];if(D(e),"("===e.token){if(t=[],k(e),D(e),")"!==e.token)for(t.push(j(e));","===e.token;)D(e),t.push(j(e));if(")"!==e.token)throw ce(e,"Parenthesis ) expected");F(e),D(e)}return new r(t)}return function(e){var t;return 3===e.tokenType||1===e.tokenType&&e.token in M?(t=e.token,D(e),ie(e,V(S,t)?new l(S[t]):-1!==E.indexOf(t)?new l(n(t,"number")):new x(t))):function(e){var t;return'"'===e.token?(t=ae(e),ie(e,new l(t))):function(e){var t;return"'"===e.token?(t=oe(e),ie(e,new l(t))):function(e){var t,r,a,s;if("["===e.token){if(k(e),D(e),"]"!==e.token){var u=se(e);if(";"===e.token){for(a=1,r=[u];";"===e.token;)D(e),r[a]=se(e),a++;if("]"!==e.token)throw ce(e,"End of matrix ] expected");F(e),D(e),s=r[0].items.length;for(var c=1;c0},b.isDecimalMark=function(e,t){return"."===e&&"/"!==t&&"*"!==t&&"^"!==t},b.isDigitDot=function(e){return e>="0"&&e<="9"||"."===e},b.isDigit=function(e){return e>="0"&&e<="9"},b.isHexDigit=function(e){return e>="0"&&e<="9"||e>="a"&&e<="f"||e>="A"&&e<="F"},b})),Yt="evaluate",Xt=W(Yt,["typed","parse"],(e=>{var{typed:t,parse:r}=e;return t(Yt,{string:function(e){var t=ie();return r(e).compile().evaluate(t)},"string, Map | Object":function(e,t){return r(e).compile().evaluate(t)},"Array | Matrix":function(e){var t=ie();return $t(e,(function(e){return r(e).compile().evaluate(t)}))},"Array | Matrix, Map | Object":function(e,t){return $t(e,(function(e){return r(e).compile().evaluate(t)}))}})})),Qt=W("Help",["parse"],(e=>{var{parse:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw new Error('Argument "doc" missing');this.doc=e}return r.prototype.type="Help",r.prototype.isHelp=!0,r.prototype.toString=function(){var e=this.doc||{},r="\n";if(e.name&&(r+="Name: "+e.name+"\n\n"),e.category&&(r+="Category: "+e.category+"\n\n"),e.description&&(r+="Description:\n "+e.description+"\n\n"),e.syntax&&(r+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){r+="Examples:\n";for(var n={},i=0;i"mathjs"!==e)).forEach((r=>{t[r]=e[r]})),new r(t)},r.prototype.valueOf=r.prototype.toString,r}),{isClass:!0}),Kt=W("simplifyUtil",["FunctionNode","OperatorNode","SymbolNode"],(e=>{var{FunctionNode:t,OperatorNode:r,SymbolNode:n}=e,i={add:!0,multiply:!0},a={add:!0,multiply:!0};function o(e,t){if(!R(e))return!1;var r=e.fn.toString();return t&&V(t,r)&&V(t[r],"associative")?t[r].associative:a[r]||!1}function s(e){var t,r=[];return o(e)?(t=e.op,function e(n){for(var i=0;i2&&o(t)){for(var a=t.args.pop();t.args.length>0;)a=r([t.args.pop(),a]);t.args=a.args}}},unflattenl:function e(t){if(t.args&&0!==t.args.length){for(var r=u(t),n=t.args.length,i=0;i2&&o(t)){for(var a=t.args.shift();t.args.length>0;)a=r([a,t.args.shift()]);t.args=a.args}}}}})),er=W("simplifyCore",["equal","isZero","add","subtract","multiply","divide","pow","ConstantNode","OperatorNode","FunctionNode","ParenthesisNode"],(e=>{var{equal:t,isZero:r,add:n,subtract:i,multiply:a,divide:o,pow:s,ConstantNode:u,OperatorNode:c,FunctionNode:l,ParenthesisNode:f}=e,p=new u(0),m=new u(1);return function e(h){if(R(h)&&h.isUnary()){var d=e(h.args[0]);if("+"===h.op)return d;if("-"===h.op){if(R(d)){if(d.isUnary()&&"-"===d.op)return d.args[0];if(d.isBinary()&&"subtract"===d.fn)return new c("-","subtract",[d.args[1],d.args[0]])}return new c(h.op,h.fn,[d])}}else if(R(h)&&h.isBinary()){var y=e(h.args[0]),g=e(h.args[1]);if("+"===h.op){if(B(y)){if(r(y.value))return g;if(B(g))return new u(n(y.value,g.value))}return B(g)&&r(g.value)?y:R(g)&&g.isUnary()&&"-"===g.op?new c("-","subtract",[y,g.args[0]]):new c(h.op,h.fn,g?[y,g]:[y])}if("-"===h.op){if(B(y)&&g){if(B(g))return new u(i(y.value,g.value));if(r(y.value))return new c("-","unaryMinus",[g])}if("subtract"===h.fn)return B(g)&&r(g.value)?y:R(g)&&g.isUnary()&&"-"===g.op?e(new c("+","add",[y,g.args[0]])):new c(h.op,h.fn,[y,g])}else{if("*"===h.op){if(B(y)){if(r(y.value))return p;if(t(y.value,1))return g;if(B(g))return new u(a(y.value,g.value))}if(B(g)){if(r(g.value))return p;if(t(g.value,1))return y;if(R(y)&&y.isBinary()&&y.op===h.op){var v=y.args[0];if(B(v)){var x=new u(a(v.value,g.value));return new c(h.op,h.fn,[x,y.args[1]],h.implicit)}}return new c(h.op,h.fn,[g,y],h.implicit)}return new c(h.op,h.fn,[y,g],h.implicit)}if("/"===h.op){if(B(y)){if(r(y.value))return p;if(B(g)&&(t(g.value,1)||t(g.value,2)||t(g.value,4)))return new u(o(y.value,g.value))}return new c(h.op,h.fn,[y,g])}if("^"===h.op){if(B(g)){if(r(g.value))return m;if(t(g.value,1))return y;if(B(y))return new u(s(y.value,g.value));if(R(y)&&y.isBinary()&&"^"===y.op){var b=y.args[1];if(B(b))return new c(h.op,h.fn,[y.args[0],new u(a(b.value,g.value))])}}return new c(h.op,h.fn,[y,g])}}}else{if(F(h)){var w=e(h.content);return F(w)||P(w)||B(w)?w:new f(w)}if(z(h)){var N=h.args.map(e).map((function(e){return F(e)?e.content:e}));return new l(e(h.fn),N)}}return h}}));function tr(){throw new Error('No "bignumber" implementation available')}function rr(){throw new Error('No "fraction" implementation available')}function nr(){throw new Error('No "matrix" implementation available')}var ir=W("simplifyConstant",["typed","config","mathWithTransform","?fraction","?bignumber","ConstantNode","OperatorNode","FunctionNode","SymbolNode"],(e=>{var{typed:t,config:r,mathWithTransform:n,fraction:i,bignumber:a,ConstantNode:o,OperatorNode:u,FunctionNode:c,SymbolNode:l}=e,{isCommutative:f,isAssociative:p,allChildren:m,createMakeNodeFunction:h}=Kt({FunctionNode:c,OperatorNode:u,SymbolNode:l});function d(e,t,r){try{return v(n[e].apply(null,t),r)}catch(i){return t=t.map((function(e){return s(e)?e.valueOf():e})),v(n[e].apply(null,t),r)}}var y=t({Fraction:function(e){var t,r=e.s*e.n;return t=r<0?new u("-","unaryMinus",[new o(-r)]):new o(r),1===e.d?t:new u("/","divide",[t,new o(e.d)])},number:function(e){return e<0?x(new o(-e)):new o(e)},BigNumber:function(e){return e<0?x(new o(-e)):new o(e)},Complex:function(e){throw new Error("Cannot convert Complex number to Node")}});function g(e,t){if(t&&!1!==t.exactFractions&&isFinite(e)&&i){var r=i(e),n=t&&"number"==typeof t.fractionsLimit?t.fractionsLimit:1/0;if(r.valueOf()===e&&r.nw(e,t)));if(!r.some(I))try{return d(e.name,r,t)}catch(e){}return r=r.map((function(e){return I(e)?e:y(e)})),new c(e.name,r)}case"OperatorNode":var i,a,o=e.fn.toString(),s=h(e);if(R(e)&&e.isUnary())a=I((i=[w(e.args[0],t)])[0])?s(i):d(o,i,t);else if(p(e))if(i=(i=m(e)).map((e=>w(e,t))),f(o)){for(var u=[],l=[],g=0;g1?(a=b(o,u,s,t),l.unshift(a),a=b(o,l,s,t)):a=b(o,i,s,t)}else a=b(o,i,s,t);else a=b(o,i=e.args.map((e=>w(e,t))),s,t);return a;case"ParenthesisNode":return w(e.content,t);case"AccessorNode":case"ArrayNode":case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"IndexNode":case"ObjectNode":case"RangeNode":case"ConditionalNode":default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(e.type))}}return function(e,t){var r=w(e,t);return I(r)?r:y(r)}})),ar=W("resolve",["parse","FunctionNode","OperatorNode","ParenthesisNode"],(e=>{var{parse:t,FunctionNode:r,OperatorNode:n,ParenthesisNode:i}=e;return function e(a,o){if(!o)return a;if(oe(o)||(o=ae(o)),P(a)){var s=o.get(a.name);if(I(s))return e(s,o);if("number"==typeof s)return t(String(s))}else{if(R(a)){var u=a.args.map((function(t){return e(t,o)}));return new n(a.op,a.fn,u,a.implicit)}if(F(a))return new i(e(a.content,o));if(z(a)){var c=a.args.map((function(t){return e(t,o)}));return new r(a.name,c)}}return a}})),or=W("simplify",["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","?fraction","?bignumber","mathWithTransform","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{config:t,typed:r,parse:n,add:i,subtract:a,multiply:o,divide:s,pow:u,isZero:c,equal:l,fraction:f,bignumber:p,mathWithTransform:m,ConstantNode:h,FunctionNode:d,OperatorNode:y,ParenthesisNode:g,SymbolNode:v}=e,x=ir({typed:r,config:t,mathWithTransform:m,fraction:f,bignumber:p,ConstantNode:h,OperatorNode:y,FunctionNode:d,SymbolNode:v}),b=er({equal:l,isZero:c,add:i,subtract:a,multiply:o,divide:s,pow:u,ConstantNode:h,OperatorNode:y,FunctionNode:d,ParenthesisNode:g}),w=ar({parse:n,FunctionNode:d,OperatorNode:y,ParenthesisNode:g}),{isCommutative:N,isAssociative:M,flatten:S,unflattenr:E,unflattenl:A,createMakeNodeFunction:O}=Kt({FunctionNode:d,OperatorNode:y,SymbolNode:v}),C=r("simplify",{string:function(e){return this(n(e),this.rules,ie(),{})},"string, Map | Object":function(e,t){return this(n(e),this.rules,t,{})},"string, Map | Object, Object":function(e,t,r){return this(n(e),this.rules,t,r)},"string, Array":function(e,t){return this(n(e),t,ie(),{})},"string, Array, Map | Object":function(e,t,r){return this(n(e),t,r,{})},"string, Array, Map | Object, Object":function(e,t,r,i){return this(n(e),t,r,i)},"Node, Map | Object":function(e,t){return this(e,this.rules,t,{})},"Node, Map | Object, Object":function(e,t,r){return this(e,this.rules,t,r)},Node:function(e){return this(e,this.rules,ie(),{})},"Node, Array":function(e,t){return this(e,t,ie(),{})},"Node, Array, Map | Object":function(e,t,r){return this(e,t,r,{})},"Node, Array, Object, Object":function(e,t,r,n){return this(e,t,ae(r),n)},"Node, Array, Map, Object":function(e,t,r,i){t=function(e){for(var t=[],r=0;r");if(2!==s.length)throw SyntaxError("Could not parse rule: "+i);i={l:s[0],r:s[1]};case"object":if(a={l:_(n(i.l)),r:_(n(i.r))},i.context&&(a.evaluate=i.context),i.evaluate&&(a.evaluate=n(i.evaluate)),M(a.l)){var u=O(a.l),c=new v("_p"+q++);a.expanded={},a.expanded.l=u([a.l.clone(),c]),S(a.expanded.l),E(a.expanded.l),a.expanded.r=u([a.r,c])}break;case"function":a=i;break;default:throw TypeError("Unsupported type of rule: "+o)}t.push(a)}return t}(t);for(var a=w(e,r),o={},s=(a=_(a)).toString({parenthesis:"all"});!o[s];){o[s]=!0,q=0;for(var u=0;u=2&&2===e.args.length){for(var i=function(e,t){var r,n,i=[],a=O(e);if(N(e,t))for(var o=0;o2)throw Error("Unexpected non-binary associative function: "+e.toString());return[]}for(var u=[],c=0;c{var{config:t,typed:r,equal:n,isZero:i,add:a,subtract:o,multiply:s,divide:u,pow:c,parse:l,simplify:f,fraction:p,bignumber:m,mathWithTransform:h,ConstantNode:d,OperatorNode:y,FunctionNode:g,SymbolNode:v,ParenthesisNode:x}=e,b=ir({typed:r,config:t,mathWithTransform:h,fraction:p,bignumber:m,ConstantNode:d,OperatorNode:y,FunctionNode:g,SymbolNode:v}),w=er({equal:n,isZero:i,add:a,subtract:o,multiply:s,divide:u,pow:c,ConstantNode:d,OperatorNode:y,FunctionNode:g,ParenthesisNode:x});return r(sr,{string:function(e){return this(l(e),{},!1)},"string, boolean":function(e,t){return this(l(e),{},t)},"string, Object":function(e,t){return this(l(e),t,!1)},"string, Object, boolean":function(e,t,r){return this(l(e),t,r)},Node:function(e){return this(e,{},!1)},"Node, boolean":function(e,t){return this(e,{},t)},"Node, Object":function(e,t){return this(e,t,!1)},"Node, Object, boolean":function(e,t,r){var n=function(){var e=[w,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},b,{l:"n*(n1^-1)",r:"n/n1"},{l:"n*n1^-n2",r:"n/n1^n2"},{l:"n1^-1",r:"1/n1"},{l:"n*(n1/n2)",r:"(n*n1)/n2"},{l:"1*n",r:"n"}],t=[{l:"(-n1)/(-n2)",r:"n1/n2"},{l:"(-n1)*(-n2)",r:"n1*n2"},{l:"n1--n2",r:"n1+n2"},{l:"n1-n2",r:"n1+(-n2)"},{l:"(n1+n2)*n3",r:"(n1*n3 + n2*n3)"},{l:"n1*(n2+n3)",r:"(n1*n2+n1*n3)"},{l:"c1*n + c2*n",r:"(c1+c2)*n"},{l:"c1*n + n",r:"(c1+1)*n"},{l:"c1*n - c2*n",r:"(c1-c2)*n"},{l:"c1*n - n",r:"(c1-1)*n"},{l:"v/c",r:"(1/c)*v"},{l:"v/-c",r:"-(1/c)*v"},{l:"-v*-c",r:"c*v"},{l:"-v*c",r:"-c*v"},{l:"v*-c",r:"-c*v"},{l:"v*c",r:"c*v"},{l:"-(-n1*n2)",r:"(n1*n2)"},{l:"-(n1*n2)",r:"(-n1*n2)"},{l:"-(-n1+n2)",r:"(n1-n2)"},{l:"-(n1+n2)",r:"(-n1-n2)"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"},{l:"-(-n1/n2)",r:"(n1/n2)"},{l:"-(n1/n2)",r:"(-n1/n2)"}],r=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],n={};return n.firstRules=e.concat(t,r),n.distrDivRules=[{l:"(n1/n2 + n3/n4)",r:"((n1*n4 + n3*n2)/(n2*n4))"},{l:"(n1/n2 + n3)",r:"((n1 + n3*n2)/n2)"},{l:"(n1 + n2/n3)",r:"((n1*n3 + n2)/n3)"}],n.sucDivRules=r,n.firstRulesAgain=e.concat(t),n.finalRules=[w,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},b,{l:"n*-n^n1",r:"-n^(n1+1)"},{l:"n*n^n1",r:"n^(n1+1)"},{l:"n^n1*-n^n2",r:"-n^(n1+n2)"},{l:"n^n1*n^n2",r:"n^(n1+n2)"},{l:"n^n1*-n",r:"-n^(n1+1)"},{l:"n^n1*n",r:"n^(n1+1)"},{l:"n^n1/-n",r:"-n^(n1-1)"},{l:"n^n1/n",r:"n^(n1-1)"},{l:"n/-n^n1",r:"-n^(1-n1)"},{l:"n/n^n1",r:"n^(1-n1)"},{l:"n^n1/-n^n2",r:"n^(n1-n2)"},{l:"n^n1/n^n2",r:"n^(n1-n2)"},{l:"n1+(-n2*n3)",r:"n1-n2*n3"},{l:"v*(-c)",r:"-c*v"},{l:"n1+-n2",r:"n1-n2"},{l:"v*c",r:"c*v"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"}],n}(),i=function(e,t,r,n){var i=[],a=f(e,n,t,{exactFractions:!1}),o="+-*"+((r=!!r)?"/":"");!function e(t){var r=t.type;if("FunctionNode"===r)throw new Error("There is an unsolved function call");if("OperatorNode"===r)if("^"===t.op){if("ConstantNode"!==t.args[1].type||!ce(parseFloat(t.args[1].value)))throw new Error("There is a non-integer exponent");e(t.args[0])}else{if(-1===o.indexOf(t.op))throw new Error("Operator "+t.op+" invalid in polynomial expression");for(var n=0;n=1){var o,s;e=N(e);var u,c=!0,l=!1;for(e=f(e,n.firstRules,{},{exactFractions:!1});s=c?n.distrDivRules:n.sucDivRules,c=!c,(u=(e=f(e,s)).toString())!==o;)l=!0,o=u;l&&(e=f(e,n.firstRulesAgain,{},{exactFractions:!1})),e=f(e,n.finalRules,{},{exactFractions:!1})}var p=[],m={};return"OperatorNode"===e.type&&e.isBinary()&&"/"===e.op?(1===a&&(e.args[0]=M(e.args[0],p),e.args[1]=M(e.args[1])),r&&(m.numerator=e.args[0],m.denominator=e.args[1])):(1===a&&(e=M(e,p)),r&&(m.numerator=e,m.denominator=null)),r?(m.coefficients=p,m.variables=i.variables,m.expression=e,m):e}});function N(e,t,r){var n=e.type,i=arguments.length>1;if("OperatorNode"===n&&e.isBinary()){var a,o=!1;if("^"===e.op&&("ParenthesisNode"!==e.args[0].type&&"OperatorNode"!==e.args[0].type||"ConstantNode"!==e.args[1].type||(o=(a=parseFloat(e.args[1].value))>=2&&ce(a))),o){if(a>2){var s=e.args[0],u=new y("^","pow",[e.args[0].cloneDeep(),new d(a-1)]);e=new y("*","multiply",[s,u])}else e=new y("*","multiply",[e.args[0],e.args[0].cloneDeep()]);i&&("content"===r?t.content=e:t.args[r]=e)}}if("ParenthesisNode"===n)N(e.content,e,"content");else if("ConstantNode"!==n&&"SymbolNode"!==n)for(var c=0;cr&&(t[c]=0),t[c]+=o.cte*("+"===o.oper?1:-1),void(r=Math.max(c,r))}o.cte=c,""===o.fire&&(t[0]+=o.cte*("+"===o.oper?1:-1))}}(e,null,{cte:1,oper:"+",fire:""});for(var i,a=!0,o=r=t.length-1;o>=0;o--)if(0!==t[o]){var s=new d(a?t[o]:Math.abs(t[o])),u=t[o]<0?"-":"+";if(o>0){var c=new v(n);if(o>1){var l=new d(o);c=new y("^","pow",[c,l])}s=-1===t[o]&&a?new y("-","unaryMinus",[c]):1===Math.abs(t[o])?c:new y("*","multiply",[s,c])}i=a?s:"+"===u?new y("+","add",[i,s]):new y("-","subtract",[i,s]),a=!1}return a?new d(0):i}})),cr=W("Parser",["evaluate"],(e=>{var{evaluate:t}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:ie(),writable:!1})}return r.prototype.type="Parser",r.prototype.isParser=!0,r.prototype.evaluate=function(e){return t(e,this.scope)},r.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},r.prototype.getAll=function(){return function(e){if(e instanceof ne)return e.wrappedObject;var t={};for(var r of e.keys())X(t,r,e.get(r));return t}(this.scope)},r.prototype.getAllAsMap=function(){return this.scope},r.prototype.set=function(e,t){return this.scope.set(e,t),t},r.prototype.remove=function(e){this.scope.delete(e)},r.prototype.clear=function(){this.scope.clear()},r}),{isClass:!0}),lr={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]},fr={name:"e",category:"Constants",syntax:["e"],description:"Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",examples:["e","e ^ 2","exp(2)","log(e)"],seealso:["exp"]},pr={bignumber:{name:"bignumber",category:"Construction",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","complex","fraction","index","matrix","string","unit"]},boolean:{name:"boolean",category:"Construction",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]},complex:{name:"complex",category:"Construction",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]},createUnit:{name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.",examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]},fraction:{name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(num,den)"],description:"Create a fraction from a number or from a numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},index:{name:"index",category:"Construction",syntax:["[start]","[start:end]","[start:step:end]","[start1, start 2, ...]","[start1:end1, start2:end2, ...]","[start1:step1:end1, start2:step2:end2, ...]"],description:"Create an index to get or replace a subset of a matrix",examples:["[]","[1, 2, 3]","A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[0:2, 0:2] = ones(2, 2)"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]},matrix:{name:"matrix",category:"Construction",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()",'matrix("dense")',"matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])",'matrix([3, 4; 5, 6], "sparse")','matrix([3, 4; 5, 6], "sparse", "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","sparse"]},number:{name:"number",category:"Construction",syntax:["x","number(x)","number(unit, valuelessUnit)"],description:"Create a number or convert a string or boolean into a number.",examples:["2","2e3","4.05","number(2)",'number("7.2")',"number(true)","number([true, false, true, true])",'number(unit("52cm"), "m")'],seealso:["bignumber","boolean","complex","fraction","index","matrix","string","unit"]},sparse:{name:"sparse",category:"Construction",syntax:["sparse()","sparse([a1, b1, ...; a1, b2, ...])",'sparse([a1, b1, ...; a1, b2, ...], "number")'],description:"Create a sparse matrix.",examples:["sparse()","sparse([3, 4; 5, 6])",'sparse([3, 0; 5, 0], "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","matrix"]},splitUnit:{name:"splitUnit",category:"Construction",syntax:["splitUnit(unit: Unit, parts: Unit[])"],description:"Split a unit in an array of units whose sum is equal to the original unit.",examples:['splitUnit(1 m, ["feet", "inch"])'],seealso:["unit","createUnit"]},string:{name:"string",category:"Construction",syntax:['"text"',"string(x)"],description:"Create a string or convert a value to a string",examples:['"Hello World!"',"string(4.2)","string(3 + 2i)"],seealso:["bignumber","boolean","complex","index","matrix","number","unit"]},unit:{name:"unit",category:"Construction",syntax:["value unit","unit(value, unit)","unit(string)"],description:"Create a unit.",examples:["5.5 mm","3 inch",'unit(7.1, "kilogram")','unit("23 deg")'],seealso:["bignumber","boolean","complex","index","matrix","number","string"]},e:fr,E:fr,false:{name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},i:{name:"i",category:"Constants",syntax:["i"],description:"Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",examples:["i","i * i","sqrt(-1)"],seealso:[]},Infinity:{name:"Infinity",category:"Constants",syntax:["Infinity"],description:"Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",examples:["Infinity","1 / 0"],seealso:[]},LN2:{name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},LN10:{name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},LOG2E:{name:"LOG2E",category:"Constants",syntax:["LOG2E"],description:"Returns the base-2 logarithm of E, approximately equal to 1.442",examples:["LOG2E","log(e, 2)"],seealso:[]},LOG10E:{name:"LOG10E",category:"Constants",syntax:["LOG10E"],description:"Returns the base-10 logarithm of E, approximately equal to 0.434",examples:["LOG10E","log(e, 10)"],seealso:[]},NaN:{name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},null:{name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},pi:lr,PI:lr,phi:{name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["phi"],seealso:[]},SQRT1_2:{name:"SQRT1_2",category:"Constants",syntax:["SQRT1_2"],description:"Returns the square root of 1/2, approximately equal to 0.707",examples:["SQRT1_2","sqrt(1/2)"],seealso:[]},SQRT2:{name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},tau:{name:"tau",category:"Constants",syntax:["tau"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]},true:{name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},version:{name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},speedOfLight:{description:"Speed of light in vacuum",examples:["speedOfLight"]},gravitationConstant:{description:"Newtonian constant of gravitation",examples:["gravitationConstant"]},planckConstant:{description:"Planck constant",examples:["planckConstant"]},reducedPlanckConstant:{description:"Reduced Planck constant",examples:["reducedPlanckConstant"]},magneticConstant:{description:"Magnetic constant (vacuum permeability)",examples:["magneticConstant"]},electricConstant:{description:"Electric constant (vacuum permeability)",examples:["electricConstant"]},vacuumImpedance:{description:"Characteristic impedance of vacuum",examples:["vacuumImpedance"]},coulomb:{description:"Coulomb's constant",examples:["coulomb"]},elementaryCharge:{description:"Elementary charge",examples:["elementaryCharge"]},bohrMagneton:{description:"Borh magneton",examples:["bohrMagneton"]},conductanceQuantum:{description:"Conductance quantum",examples:["conductanceQuantum"]},inverseConductanceQuantum:{description:"Inverse conductance quantum",examples:["inverseConductanceQuantum"]},magneticFluxQuantum:{description:"Magnetic flux quantum",examples:["magneticFluxQuantum"]},nuclearMagneton:{description:"Nuclear magneton",examples:["nuclearMagneton"]},klitzing:{description:"Von Klitzing constant",examples:["klitzing"]},bohrRadius:{description:"Borh radius",examples:["bohrRadius"]},classicalElectronRadius:{description:"Classical electron radius",examples:["classicalElectronRadius"]},electronMass:{description:"Electron mass",examples:["electronMass"]},fermiCoupling:{description:"Fermi coupling constant",examples:["fermiCoupling"]},fineStructure:{description:"Fine-structure constant",examples:["fineStructure"]},hartreeEnergy:{description:"Hartree energy",examples:["hartreeEnergy"]},protonMass:{description:"Proton mass",examples:["protonMass"]},deuteronMass:{description:"Deuteron Mass",examples:["deuteronMass"]},neutronMass:{description:"Neutron mass",examples:["neutronMass"]},quantumOfCirculation:{description:"Quantum of circulation",examples:["quantumOfCirculation"]},rydberg:{description:"Rydberg constant",examples:["rydberg"]},thomsonCrossSection:{description:"Thomson cross section",examples:["thomsonCrossSection"]},weakMixingAngle:{description:"Weak mixing angle",examples:["weakMixingAngle"]},efimovFactor:{description:"Efimov factor",examples:["efimovFactor"]},atomicMass:{description:"Atomic mass constant",examples:["atomicMass"]},avogadro:{description:"Avogadro's number",examples:["avogadro"]},boltzmann:{description:"Boltzmann constant",examples:["boltzmann"]},faraday:{description:"Faraday constant",examples:["faraday"]},firstRadiation:{description:"First radiation constant",examples:["firstRadiation"]},loschmidt:{description:"Loschmidt constant at T=273.15 K and p=101.325 kPa",examples:["loschmidt"]},gasConstant:{description:"Gas constant",examples:["gasConstant"]},molarPlanckConstant:{description:"Molar Planck constant",examples:["molarPlanckConstant"]},molarVolume:{description:"Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",examples:["molarVolume"]},sackurTetrode:{description:"Sackur-Tetrode constant at T=1 K and p=101.325 kPa",examples:["sackurTetrode"]},secondRadiation:{description:"Second radiation constant",examples:["secondRadiation"]},stefanBoltzmann:{description:"Stefan-Boltzmann constant",examples:["stefanBoltzmann"]},wienDisplacement:{description:"Wien displacement law constant",examples:["wienDisplacement"]},molarMass:{description:"Molar mass constant",examples:["molarMass"]},molarMassC12:{description:"Molar mass constant of carbon-12",examples:["molarMassC12"]},gravity:{description:"Standard acceleration of gravity (standard acceleration of free-fall on Earth)",examples:["gravity"]},planckLength:{description:"Planck length",examples:["planckLength"]},planckMass:{description:"Planck mass",examples:["planckMass"]},planckTime:{description:"Planck time",examples:["planckTime"]},planckCharge:{description:"Planck charge",examples:["planckCharge"]},planckTemperature:{description:"Planck temperature",examples:["planckTemperature"]},derivative:{name:"derivative",category:"Algebra",syntax:["derivative(expr, variable)","derivative(expr, variable, {simplify: boolean})"],description:"Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",examples:['derivative("2x^3", "x")','derivative("2x^3", "x", {simplify: false})','derivative("2x^2 + 3x + 4", "x")','derivative("sin(2x)", "x")','f = parse("x^2 + x")','x = parse("x")',"df = derivative(f, x)","df.evaluate({x: 3})"],seealso:["simplify","parse","evaluate"]},lsolve:{name:"lsolve",category:"Algebra",syntax:["x=lsolve(L, b)"],description:"Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolveAll","lup","lusolve","usolve","matrix","sparse"]},lsolveAll:{name:"lsolveAll",category:"Algebra",syntax:["x=lsolveAll(L, b)"],description:"Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolve","lup","lusolve","usolve","matrix","sparse"]},lup:{name:"lup",category:"Algebra",syntax:["lup(m)"],description:"Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",examples:["lup([[2, 1], [1, 4]])","lup(matrix([[2, 1], [1, 4]]))","lup(sparse([[2, 1], [1, 4]]))"],seealso:["lusolve","lsolve","usolve","matrix","sparse","slu","qr"]},lusolve:{name:"lusolve",category:"Algebra",syntax:["x=lusolve(A, b)","x=lusolve(lu, b)"],description:"Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lusolve(a, b)"],seealso:["lup","slu","lsolve","usolve","matrix","sparse"]},simplify:{name:"simplify",category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["derivative","parse","evaluate"]},rationalize:{name:"rationalize",category:"Algebra",syntax:["rationalize(expr)","rationalize(expr, scope)","rationalize(expr, scope, detailed)"],description:"Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",examples:['rationalize("2x/y - y/(x+1)")','rationalize("2x/y - y/(x+1)", true)'],seealso:["simplify"]},slu:{name:"slu",category:"Algebra",syntax:["slu(A, order, threshold)"],description:"Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",examples:["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],seealso:["lusolve","lsolve","usolve","matrix","sparse","lup","qr"]},usolve:{name:"usolve",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolveAll","lup","lusolve","lsolve","matrix","sparse"]},usolveAll:{name:"usolveAll",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolve","lup","lusolve","lsolve","matrix","sparse"]},qr:{name:"qr",category:"Algebra",syntax:["qr(A)"],description:"Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",examples:["qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])"],seealso:["lup","slu","matrix"]},abs:{name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},add:{name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i","3 cm + 2 inch",'"2.3" + "4"'],seealso:["subtract"]},cbrt:{name:"cbrt",category:"Arithmetic",syntax:["cbrt(x)","cbrt(x, allRoots)"],description:"Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",examples:["cbrt(64)","cube(4)","cbrt(-8)","cbrt(2 + 3i)","cbrt(8i)","cbrt(8i, true)","cbrt(27 m^3)"],seealso:["square","sqrt","cube","multiply"]},ceil:{name:"ceil",category:"Arithmetic",syntax:["ceil(x)"],description:"Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)"],seealso:["floor","fix","round"]},cube:{name:"cube",category:"Arithmetic",syntax:["cube(x)"],description:"Compute the cube of a value. The cube of x is x * x * x.",examples:["cube(2)","2^3","2 * 2 * 2"],seealso:["multiply","square","pow"]},divide:{name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["a = 2 / 3","a * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]},dotDivide:{name:"dotDivide",category:"Operators",syntax:["x ./ y","dotDivide(x, y)"],description:"Divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","dotMultiply","divide"]},dotMultiply:{name:"dotMultiply",category:"Operators",syntax:["x .* y","dotMultiply(x, y)"],description:"Multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","dotDivide"]},dotPow:{name:"dotPow",category:"Operators",syntax:["x .^ y","dotPow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]},exp:{name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["expm","expm1","pow","log"]},expm:{name:"expm",category:"Arithmetic",syntax:["exp(x)"],description:"Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",examples:["expm([[0,2],[0,0]])"],seealso:["exp"]},expm1:{name:"expm1",category:"Arithmetic",syntax:["expm1(x)"],description:"Calculate the value of subtracting 1 from the exponential value.",examples:["expm1(2)","pow(e, 2) - 1","log(expm1(2) + 1)"],seealso:["exp","pow","log"]},fix:{name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]},floor:{name:"floor",category:"Arithmetic",syntax:["floor(x)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)"],seealso:["ceil","fix","round"]},gcd:{name:"gcd",category:"Arithmetic",syntax:["gcd(a, b)","gcd(a, b, c, ...)"],description:"Compute the greatest common divisor.",examples:["gcd(8, 12)","gcd(-4, 6)","gcd(25, 15, -10)"],seealso:["lcm","xgcd"]},hypot:{name:"hypot",category:"Arithmetic",syntax:["hypot(a, b, c, ...)","hypot([a, b, c, ...])"],description:"Calculate the hypotenusa of a list with values. ",examples:["hypot(3, 4)","sqrt(3^2 + 4^2)","hypot(-2)","hypot([3, 4, 5])"],seealso:["abs","norm"]},lcm:{name:"lcm",category:"Arithmetic",syntax:["lcm(x, y)"],description:"Compute the least common multiple.",examples:["lcm(4, 6)","lcm(6, 21)","lcm(6, 21, 5)"],seealso:["gcd"]},log:{name:"log",category:"Arithmetic",syntax:["log(x)","log(x, base)"],description:"Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",examples:["log(3.5)","a = log(2.4)","exp(a)","10 ^ 4","log(10000, 10)","log(10000) / log(10)","b = log(1024, 2)","2 ^ b"],seealso:["exp","log1p","log2","log10"]},log2:{name:"log2",category:"Arithmetic",syntax:["log2(x)"],description:"Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",examples:["log2(0.03125)","log2(16)","log2(16) / log2(2)","pow(2, 4)"],seealso:["exp","log1p","log","log10"]},log1p:{name:"log1p",category:"Arithmetic",syntax:["log1p(x)","log1p(x, base)"],description:"Calculate the logarithm of a `value+1`",examples:["log1p(2.5)","exp(log1p(1.4))","pow(10, 4)","log1p(9999, 10)","log1p(9999) / log(10)"],seealso:["exp","log","log2","log10"]},log10:{name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(0.00001)","log10(10000)","10 ^ 4","log(10000) / log(10)","log(10000, 10)"],seealso:["exp","log"]},mod:{name:"mod",category:"Operators",syntax:["x % y","x mod y","mod(x, y)"],description:"Calculates the modulus, the remainder of an integer division.",examples:["7 % 3","11 % 2","10 mod 4","isOdd(x) = x % 2","isOdd(2)","isOdd(3)"],seealso:["divide"]},multiply:{name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["a = 2.1 * 3.4","a / 3.4","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]},norm:{name:"norm",category:"Arithmetic",syntax:["norm(x)","norm(x, p)"],description:"Calculate the norm of a number, vector or matrix.",examples:["abs(-3.5)","norm(-3.5)","norm(3 - 4i)","norm([1, 2, -3], Infinity)","norm([1, 2, -3], -Infinity)","norm([3, 4], 2)","norm([[1, 2], [3, 4]], 1)",'norm([[1, 2], [3, 4]], "inf")','norm([[1, 2], [3, 4]], "fro")']},nthRoot:{name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["nthRoots","pow","sqrt"]},nthRoots:{name:"nthRoots",category:"Arithmetic",syntax:["nthRoots(A)","nthRoots(A, root)"],description:'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',examples:["nthRoots(1)","nthRoots(1, 3)"],seealso:["sqrt","pow","nthRoot"]},pow:{name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3","2*2*2","1 + e ^ (pi * i)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},round:{name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)"],seealso:["ceil","floor","fix"]},sign:{name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},sqrt:{name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},sqrtm:{name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},square:{name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},subtract:{name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},unaryMinus:{name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},bitAnd:{name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitNot:{name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitOr:{name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},bitXor:{name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},leftShift:{name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},rightArithShift:{name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},rightLogShift:{name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},bellNumbers:{name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},catalan:{name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},composition:{name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},stirlingS2:{name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},config:{name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},import:{name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number, number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},arg:{name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},conj:{name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},re:{name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},im:{name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},evaluate:{name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(" + 4 + ")")'],seealso:[]},help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},distance:{name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])","distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},intersect:{name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},and:{name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},not:{name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},or:{name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},xor:{name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},concat:{name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},count:{name:"count",category:"Matrix",syntax:["count(x)"],description:"Count the number of elements of a matrix, array or string.",examples:["a = [1, 2; 3, 4; 5, 6]","count(a)","size(a)",'count("hello world")'],seealso:["size"]},cross:{name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},column:{name:"column",category:"Matrix",syntax:["column(x, index)"],description:"Return a column from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","column(A, 1)","column(A, 2)"],seealso:["row","matrixFromColumns"]},ctranspose:{name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},det:{name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diag:{name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diff:{name:"diff",category:"Matrix",syntax:["diff(arr)","diff(arr, dim)"],description:["Create a new matrix or array with the difference of the passed matrix or array.","Dim parameter is optional and used to indicant the dimension of the array/matrix to apply the difference","If no dimension parameter is passed it is assumed as dimension 0","Dimension is zero-based in javascript and one-based in the parser","Arrays must be 'rectangular' meaning arrays like [1, 2]","If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],examples:["diff([1, 2, 4, 7, 0])","diff([1, 2, 4, 7, 0], 0)","diff(matrix([1, 2, 4, 7, 0]))","diff([[1, 2], [3, 4]])","diff([[1, 2], [3, 4]], 0)","diff([[1, 2], [3, 4]], 1)","diff([[1, 2], [3, 4]], bignumber(1))","diff(matrix([[1, 2], [3, 4]]), 1)","diff([[1, 2], matrix([3, 4])], 1)"],seealso:["subtract","partitionSelect"]},dot:{name:"dot",category:"Matrix",syntax:["dot(A, B)","A * B"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]},getMatrixDataType:{name:"getMatrixDataType",category:"Matrix",syntax:["getMatrixDataType(x)"],description:'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',examples:["getMatrixDataType([1, 2, 3])","getMatrixDataType([[5 cm], [2 inch]])",'getMatrixDataType([1, "text"])',"getMatrixDataType([1, bignumber(4)])"],seealso:["matrix","sparse","typeOf"]},identity:{name:"identity",category:"Matrix",syntax:["identity(n)","identity(m, n)","identity([m, n])"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["identity(3)","identity(3, 5)","a = [1, 2, 3; 4, 5, 6]","identity(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},filter:{name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},flatten:{name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]},forEach:{name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["forEach([1, 2, 3], function(val) { console.log(val) })"],seealso:["map","sort","filter"]},inv:{name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","identity","ones","range","size","squeeze","subset","trace","transpose","zeros"]},eigs:{name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and eigenvectors of a real symmetric matrix",examples:["eigs([[5, 2.3], [2.3, 1]])"],seealso:["inv"]},kron:{name:"kron",category:"Matrix",syntax:["kron(x, y)"],description:"Calculates the kronecker product of 2 matrices or vectors.",examples:["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])","kron([1,1], [2,3,4])"],seealso:["multiply","dot","cross"]},matrixFromFunction:{name:"matrixFromFunction",category:"Matrix",syntax:["math.matrixFromFunction(size, fn)","math.matrixFromFunction(size, fn, format)","math.matrixFromFunction(size, fn, format, datatype)","math.matrixFromFunction(size, format, fn)","math.matrixFromFunction(size, format, datatype, fn)"],description:"Create a matrix by evaluating a generating function at each index.",examples:["f(I) = I[1] - I[2]","matrixFromFunction([3,3], f)","g(I) = I[1] - I[2] == 1 ? 4 : 0",'matrixFromFunction([100, 100], "sparse", g)',"matrixFromFunction([5], random)"],seealso:["matrix","matrixFromRows","matrixFromColumns","zeros"]},matrixFromRows:{name:"matrixFromRows",category:"Matrix",syntax:["math.matrixFromRows(...arr)","math.matrixFromRows(row1, row2)","math.matrixFromRows(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual rows.",examples:["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromColumns","matrixFromFunction","zeros"]},matrixFromColumns:{name:"matrixFromColumns",category:"Matrix",syntax:["math.matrixFromColumns(...arr)","math.matrixFromColumns(row1, row2)","math.matrixFromColumns(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual columns.",examples:["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromRows","matrixFromFunction","zeros"]},map:{name:"map",category:"Matrix",syntax:["map(x, callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",examples:["map([1, 2, 3], square)"],seealso:["filter","forEach"]},ones:{name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","identity","inv","range","size","squeeze","subset","trace","transpose","zeros"]},partitionSelect:{name:"partitionSelect",category:"Matrix",syntax:["partitionSelect(x, k)","partitionSelect(x, k, compare)"],description:"Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",examples:["partitionSelect([5, 10, 1], 2)",'partitionSelect(["C", "B", "A", "D"], 1)'],seealso:["sort"]},range:{name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","identity","inv","ones","size","squeeze","subset","trace","transpose","zeros"]},resize:{name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze","reshape"]},reshape:{name:"reshape",category:"Matrix",syntax:["reshape(x, sizes)"],description:"Reshape a multi dimensional array to fit the specified dimensions.",examples:["reshape([1, 2, 3, 4, 5, 6], [2, 3])","reshape([[1, 2], [3, 4]], [1, 4])","reshape([[1, 2], [3, 4]], [4])"],seealso:["size","squeeze","resize"]},rotate:{name:"rotate",category:"Matrix",syntax:["rotate(w, theta)","rotate(w, theta, v)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotate([1, 0], math.pi / 2)",'rotate(matrix([1, 0]), unit("35deg"))','rotate([1, 0, 0], unit("90deg"), [0, 0, 1])','rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],seealso:["matrix","rotationMatrix"]},rotationMatrix:{name:"rotationMatrix",category:"Matrix",syntax:["rotationMatrix(theta)","rotationMatrix(theta, v)","rotationMatrix(theta, v, format)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotationMatrix(pi / 2)",'rotationMatrix(unit("45deg"), [0, 0, 1])','rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],seealso:["cos","sin"]},row:{name:"row",category:"Matrix",syntax:["row(x, index)"],description:"Return a row from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","row(A, 1)","row(A, 2)"],seealso:["column","matrixFromRows"]},size:{name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","count","det","diag","identity","inv","ones","range","squeeze","subset","trace","transpose","zeros"]},sort:{name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"])',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},squeeze:{name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","identity","inv","ones","range","size","subset","trace","transpose","zeros"]},subset:{name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of a matrix or string. Indexes are one-based. Both the ranges lower-bound and upper-bound are included.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},trace:{name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","transpose","zeros"]},transpose:{name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},zeros:{name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose"]},combinations:{name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},combinationsWithRep:{name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"],seealso:["combinations","permutations","factorial"]},factorial:{name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},gamma:{name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},kldivergence:{name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},multinomial:{name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},permutations:{name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},pickRandom:{name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)","pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])","pickRandom([1, 3, 1, 6], 2)","pickRandom([1, 3, 1, 6], [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],seealso:["random","randomInt"]},random:{name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]},randomInt:{name:"randomInt",category:"Probability",syntax:["randomInt(max)","randomInt(min, max)","randomInt(size)","randomInt(size, max)","randomInt(size, min, max)"],description:"Return a random integer number",examples:["randomInt(10, 20)","randomInt([2, 3], 10)"],seealso:["pickRandom","random"]},compare:{name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compareNatural","compareText"]},compareNatural:{name:"compareNatural",category:"Relational",syntax:["compareNatural(x, y)"],description:"Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compareNatural(2, 3)","compareNatural(3, 2)","compareNatural(2, 2)","compareNatural(5cm, 40mm)",'compareNatural("2", "10")',"compareNatural(2 + 3i, 2 + 4i)","compareNatural([1, 2, 4], [1, 2, 3])","compareNatural([1, 5], [1, 2, 3])","compareNatural([1, 2], [1, 2])","compareNatural({a: 2}, {a: 4})"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare","compareText"]},compareText:{name:"compareText",category:"Relational",syntax:["compareText(x, y)"],description:"Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:['compareText("B", "A")','compareText("A", "B")','compareText("A", "A")','compareText("2", "10")','compare("2", "10")',"compare(2, 10)",'compareNatural("2", "10")','compareText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural"]},deepEqual:{name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["deepEqual([1,3,4], [1,3,4])","deepEqual([1,3,4], [1,3])"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]},equal:{name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual","equalText"]},equalText:{name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},larger:{name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},largerEq:{name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},smaller:{name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},smallerEq:{name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 <= 1+1","2 < 1+1","a = 3.2","b = 6-2.8","(a <= b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]},unequal:{name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]},setCartesian:{name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays and the values will be sorted in ascending order before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},setDifference:{name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},setDistinct:{name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},setIntersect:{name:"setIntersect",category:"Set",syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},setIsSubset:{name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},setMultiplicity:{name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]},setPowerset:{name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},setSize:{name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},setSymDifference:{name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setDifference"]},setUnion:{name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},erf:{name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},mad:{name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},mean:{name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},median:{name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},min:{name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},mode:{name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},prod:{name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},quantileSeq:{name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:"Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.",examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},std:{name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},sum:{name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},variance:{name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},acos:{name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},acosh:{name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},acot:{name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},acoth:{name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},acsc:{name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},acsch:{name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},asec:{name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},asech:{name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},asin:{name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},asinh:{name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},atan:{name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},atanh:{name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},atan2:{name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},cos:{name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},cosh:{name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},cot:{name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},coth:{name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},csc:{name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},csch:{name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},sec:{name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},sech:{name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},sin:{name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},sinh:{name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},tan:{name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},tanh:{name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},to:{name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},clone:{name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},format:{name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},bin:{name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},oct:{name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},hex:{name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},isNaN:{name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isInteger:{name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isNegative:{name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},isNumeric:{name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},hasNumericValue:{name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},isPositive:{name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isPrime:{name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isZero:{name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},typeOf:{name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},numeric:{name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "BigNumber")','numeric("4", "Fraction)','numeric(4, "Fraction")','numeric(fraction(2, 5), "number)'],seealso:["number","fraction","bignumber","string","format"]}},mr="help",hr=W(mr,["typed","mathWithTransform","Help"],(e=>{var{typed:t,mathWithTransform:r,Help:n}=e;return t(mr,{any:function(e){var t,i=e;if("string"!=typeof e)for(t in r)if(V(r,t)&&e===r[t]){i=t;break}var a=Y(pr,i);if(!a){var o="function"==typeof i?i.name:i;throw new Error('No documentation found on "'+o+'"')}return new n(a)}})})),dr=W("derivative",["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:t,config:r,parse:n,simplify:i,equal:a,isZero:o,numeric:s,ConstantNode:u,FunctionNode:c,OperatorNode:l,ParenthesisNode:f,SymbolNode:p}=e,m=t("derivative",{"Node, SymbolNode, Object":function(e,t,r){var n={};d(n,e,t.name);var a=y(e,n);return r.simplify?i(a):a},"Node, SymbolNode":function(e,t){return this(e,t,{simplify:!0})},"string, SymbolNode":function(e,t){return this(n(e),t)},"string, SymbolNode, Object":function(e,t,r){return this(n(e),t,r)},"string, string":function(e,t){return this(n(e),n(t))},"string, string, Object":function(e,t,r){return this(n(e),n(t),r)},"Node, string":function(e,t){return this(e,n(t))},"Node, string, Object":function(e,t,r){return this(e,n(t),r)}});m._simplify=!0,m.toTex=function(e){return h.apply(null,e.args)};var h=t("_derivTex",{"Node, SymbolNode":function(e,t){return B(e)&&"string"===L(e.value)?h(n(e.value).toString(),t.toString(),1):h(e.toString(),t.toString(),1)},"Node, ConstantNode":function(e,t){if("string"===L(t.value))return h(e,n(t.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(e,t,r){return h(e.toString(),t.name,r.value)},"string, string, number":function(e,t,r){return(1===r?"{d\\over d"+t+"}":"{d^{"+r+"}\\over d"+t+"^{"+r+"}}")+"\\left[".concat(e,"\\right]")}}),d=t("constTag",{"Object, ConstantNode, string":function(e,t){return e[t]=!0,!0},"Object, SymbolNode, string":function(e,t,r){return t.name!==r&&(e[t]=!0,!0)},"Object, ParenthesisNode, string":function(e,t,r){return d(e,t.content,r)},"Object, FunctionAssignmentNode, string":function(e,t,r){return-1===t.params.indexOf(r)?(e[t]=!0,!0):d(e,t.expr,r)},"Object, FunctionNode | OperatorNode, string":function(e,t,r){if(t.args.length>0){for(var n=d(e,t.args[0],r),i=1;i0){var n=e.args.filter((function(e){return void 0===t[e]})),i=1===n.length?n[0]:new l("*","multiply",n),s=r.concat(y(i,t));return new l("*","multiply",s)}return new l("+","add",e.args.map((function(r){return new l("*","multiply",e.args.map((function(e){return e===r?y(e,t):e.clone()})))})))}if("/"===e.op&&e.isBinary()){var u=e.args[0],f=e.args[1];return void 0!==t[f]?new l("/","divide",[y(u,t),f]):void 0!==t[u]?new l("*","multiply",[new l("-","unaryMinus",[u]),new l("/","divide",[y(f,t),new l("^","pow",[f.clone(),g(2)])])]):new l("/","divide",[new l("-","subtract",[new l("*","multiply",[y(u,t),f.clone()]),new l("*","multiply",[u.clone(),y(f,t)])]),new l("^","pow",[f.clone(),g(2)])])}if("^"===e.op&&e.isBinary()){var p=e.args[0],m=e.args[1];if(void 0!==t[p])return B(p)&&(o(p.value)||a(p.value,1))?g(0):new l("*","multiply",[e,new l("*","multiply",[new c("log",[p.clone()]),y(m.clone(),t)])]);if(void 0!==t[m]){if(B(m)){if(o(m.value))return g(0);if(a(m.value,1))return y(p,t)}var h=new l("^","pow",[p.clone(),new l("-","subtract",[m,g(1)])]);return new l("*","multiply",[m.clone(),new l("*","multiply",[y(p,t),h])])}return new l("*","multiply",[new l("^","pow",[p.clone(),m.clone()]),new l("+","add",[new l("*","multiply",[y(p,t),new l("/","divide",[m.clone(),p.clone()])]),new l("*","multiply",[y(m,t),new c("log",[p.clone()])])])])}throw new Error('Operator "'+e.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function g(e,t){return new u(s(e,t||r.number))}return m})),yr="parser",gr=W(yr,["typed","Parser"],(e=>{var{typed:t,Parser:r}=e;return t(yr,{"":function(){return new r}})})),vr="compile",xr=W(vr,["typed","parse"],(e=>{var{typed:t,parse:r}=e;return t(vr,{string:function(e){return r(e).compile()},"Array | Matrix":function(e){return $t(e,(function(e){return r(e).compile()}))}})})),br="apply",wr=W(br,["typed","isInteger"],(e=>{var{typed:t,isInteger:r}=e;return t(br,{"Array | Matrix, number | BigNumber, function":function(e,t,n){if(!r(t))throw new TypeError("Integer number expected for dimension");var i=Array.isArray(e)?je(e):e.size();if(t<0||t>=i.length)throw new Pe(t,i.length);return f(e)?e.create(Nr(e.valueOf(),t,n)):Nr(e,t,n)}})}));function Nr(e,t,r){var n,i,a;if(t<=0){if(Array.isArray(e[0])){for(a=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r{var{typed:t,isInteger:r}=e,n=wr({typed:t,isInteger:r});return t("apply",{"...any":function(e){var t=e[1];i(t)?e[1]=t-1:a(t)&&(e[1]=t.minus(1));try{return n.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0});function Sr(e){var t=0,r=1,n=Object.create(null),i=Object.create(null),a=0,o=function(e){var o=i[e];if(o&&(delete n[o],delete i[e],--t,r===o)){if(!t)return a=0,void(r=1);for(;!hasOwnProperty.call(n,++r););}};return e=Math.abs(e),{hit:function(s){var u=i[s],c=++a;if(n[c]=s,i[s]=c,!u){if(++t<=e)return;return s=n[r],o(s),s}if(delete n[u],r===u)for(;!hasOwnProperty.call(n,++r););},delete:o,clear:function(){t=a=0,r=1,n=Object.create(null),i=Object.create(null)}}}function Er(e){var{hasher:t,limit:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r=null==r?Number.POSITIVE_INFINITY:r,t=null==t?JSON.stringify:t,function n(){"object"!=typeof n.cache&&(n.cache={values:new Map,lru:Sr(r||Number.POSITIVE_INFINITY)});for(var i=[],a=0;a{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=P(e[1])||q(e[1])?e[1].compile().evaluate(r):Or(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("filter",{"Array, function":_r,"Matrix, function":function(e,t){return e.create(_r(e.toArray(),t))},"Array, RegExp":it,"Matrix, RegExp":function(e,t){return e.create(it(e.toArray(),t))}});return r}),{isTransformFunction:!0});function _r(e,t){var r=Ar(t);return nt(e,(function(e,n,i){return 1===r?t(e):2===r?t(e,[n+1]):t(e,[n+1],i)}))}var Tr=W("map",["typed"],(e=>{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=P(e[1])||q(e[1])?e[1].compile().evaluate(r):Or(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("map",{"Array, function":function(e,t){return Br(e,t,e)},"Matrix, function":function(e,t){return e.create(Br(e.valueOf(),t,e))}});return r}),{isTransformFunction:!0});function Br(e,t,r){var n=Ar(t);return function e(i,a){return Array.isArray(i)?tt(i,(function(t,r){return e(t,a.concat(r+1))})):1===n?t(i):2===n?t(i,a):t(i,a,r)}(e,[])}var qr=W("forEach",["typed"],(e=>{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=P(e[1])||q(e[1])?e[1].compile().evaluate(r):Or(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("forEach",{"Array | Matrix, function":function(e,t){var r=Ar(t);!function n(i,a){Array.isArray(i)?rt(i,(function(e,t){n(e,a.concat(t+1))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e.valueOf(),[])}});return r}),{isTransformFunction:!0}),zr="subset",Dr=W(zr,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t(zr,{"Array, Index":function(e,t){var n=r(e).subset(t);return t.isScalar()?n:n.valueOf()},"Matrix, Index":function(e,t){return e.subset(t)},"Object, Index":Rr,"string, Index":Ir,"Array, Index, any":function(e,t,n){return r($(e)).subset(t,n,void 0).valueOf()},"Array, Index, any, any":function(e,t,n,i){return r($(e)).subset(t,n,i).valueOf()},"Matrix, Index, any":function(e,t,r){return e.clone().subset(t,r)},"Matrix, Index, any, any":function(e,t,r,n){return e.clone().subset(t,r,n)},"string, Index, string":kr,"string, Index, string, string":kr,"Object, Index, any":Fr})}));function Ir(e,t){if(!y(t))throw new TypeError("Index expected");if(1!==t.size().length)throw new Ue(t.size().length,1);var r=e.length;$e(t.min()[0],r),$e(t.max()[0],r);var n=t.dimension(0),i="";return n.forEach((function(t){i+=e.charAt(t)})),i}function kr(e,t,r,n){if(!t||!0!==t.isIndex)throw new TypeError("Index expected");if(1!==t.size().length)throw new Ue(t.size().length,1);if(void 0!==n){if("string"!=typeof n||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";var i=t.dimension(0);if(i.size()[0]!==r.length)throw new Ue(i.size()[0],r.length);var a=e.length;$e(t.min()[0]),$e(t.max()[0]);for(var o=[],s=0;sa)for(var u=a-1,c=o.length;u{var{typed:t,matrix:r}=e,n=Dr({typed:t,matrix:r});return t("subset",{"...any":function(e){try{return n.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Pr=W("index",["Index"],(e=>{var{Index:t}=e;return function(){for(var e=[],r=0,n=arguments.length;r0?0:2;else if(o&&!0===o.isSet)o=o.map((function(e){return e-1}));else if(l(o)||f(o))o=o.map((function(e){return e-1}));else if(i(o))o--;else if(a(o))o=o.toNumber()-1;else if("string"!=typeof o)throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");e[r]=o}var s=new t;return t.apply(s,e),s}}),{isTransformFunction:!0}),jr="concat",Lr=W(jr,["typed","matrix","isInteger"],(e=>{var{typed:t,matrix:r,isInteger:n}=e;return t(jr,{"...Array | Matrix | number | BigNumber":function(e){var t,o,s=e.length,u=-1,c=!1,l=[];for(t=0;t0&&u>o)throw new Pe(u,o+1)}else{var m=$(p).valueOf(),h=je(m);if(l[t]=m,o=u,u=h.length-1,t>0&&u!==o)throw new Ue(o+1,u+1)}}if(0===l.length)throw new SyntaxError("At least one matrix expected");for(var d=l.shift();l.length;)d=Hr(d,l.shift(),u,0);return c?r(d):d},"...string":function(e){return e.join("")}})}));function Hr(e,t,r,n){if(n{var{typed:t,matrix:r,isInteger:n}=e,o=Lr({typed:t,matrix:r,isInteger:n});return t("concat",{"...any":function(e){var t=e.length-1,r=e[t];i(r)?e[t]=r-1:a(r)&&(e[t]=r.minus(1));try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0});function Gr(e,t,r){var n;return-1!==String(e).indexOf("Unexpected type")?(n=arguments.length>2?" (type: "+L(r)+", value: "+JSON.stringify(r)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+n)):-1!==String(e).indexOf("complex numbers")?(n=arguments.length>2?" (type: "+L(r)+", value: "+JSON.stringify(r)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+n)):e}var Zr=W("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:r,numeric:n,larger:i}=e;return t("max",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){return Gt(e,t.valueOf(),a)},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function max");return o(e)}});function a(e,t){try{return i(e,t)?e:t}catch(e){throw Gr(e,"max",t)}}function o(e){var t;if(Ht(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw Gr(t,"max",e)}})),void 0===t)throw new Error("Cannot calculate max of an empty array");return"string"==typeof t&&(t=n(t,r.number)),t}}));function Vr(e){if(2===e.length&&p(e[0])){var t=(e=e.slice())[1];i(t)?e[1]=t-1:a(t)&&(e[1]=t.minus(1))}return e}var Wr=W("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:r,numeric:n,larger:i}=e,a=Zr({typed:t,config:r,numeric:n,larger:i});return t("max",{"...any":function(e){e=Vr(e);try{return a.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Jr=W("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:r,numeric:n,smaller:i}=e;return t("min",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){return Gt(e,t.valueOf(),a)},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function min");return o(e)}});function a(e,t){try{return i(e,t)?e:t}catch(e){throw Gr(e,"min",t)}}function o(e){var t;if(Ht(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw Gr(t,"min",e)}})),void 0===t)throw new Error("Cannot calculate min of an empty array");return"string"==typeof t&&(t=n(t,r.number)),t}})),Yr=W("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:r,numeric:n,smaller:i}=e,a=Jr({typed:t,config:r,numeric:n,smaller:i});return t("min",{"...any":function(e){e=Vr(e);try{return a.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Xr=W("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:r,add:n,numeric:i}=e;return t("sum",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){try{return Gt(e,t,n)}catch(e){throw Gr(e,"sum")}},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function sum");return a(e)}});function a(e){var t;return Ht(e,(function(e){try{t=void 0===t?e:n(t,e)}catch(t){throw Gr(t,"sum",e)}})),void 0===t&&(t=i(0,r.number)),"string"==typeof t&&(t=i(t,r.number)),t}})),Qr=W("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:r,add:n,numeric:i}=e,a=Xr({typed:t,config:r,add:n,numeric:i});return t("sum",{"...any":function(e){e=Vr(e);try{return a.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Kr="column",en=W(Kr,["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e;return t(Kr,{"Matrix, number":a,"Array, number":function(e,t){return a(n($(e)),t).valueOf()}});function a(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");$e(t,e.size()[1]);var n=i(0,e.size()[0]),a=new r(n,t);return e.subset(a)}})),tn=W("column",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:a}=e,o=en({typed:t,Index:r,matrix:n,range:a});return t("column",{"...any":function(e){var t=e.length-1,r=e[t];i(r)&&(e[t]=r-1);try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),rn="range",nn=W(rn,["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u}=e;return t(rn,{string:l,"string, boolean":l,"number, number":function(e,t){return c(f(e,t,1))},"number, number, number":function(e,t,r){return c(f(e,t,r))},"number, number, boolean":function(e,t,r){return c(r?p(e,t,1):f(e,t,1))},"number, number, number, boolean":function(e,t,r,n){return c(n?p(e,t,r):f(e,t,r))},"BigNumber, BigNumber":function(e,t){return c(m(e,t,new(0,e.constructor)(1)))},"BigNumber, BigNumber, BigNumber":function(e,t,r){return c(m(e,t,r))},"BigNumber, BigNumber, boolean":function(e,t,r){var n=e.constructor;return c(r?h(e,t,new n(1)):m(e,t,new n(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,r,n){return c(n?h(e,t,r):m(e,t,r))}});function c(e){return"Matrix"===r.matrix?n?n(e):nr():e}function l(e,t){var n=function(e){var t=e.split(":").map((function(e){return Number(e)}));if(t.some((function(e){return isNaN(e)})))return null;switch(t.length){case 2:return{start:t[0],end:t[1],step:1};case 3:return{start:t[0],end:t[2],step:t[1]};default:return null}}(e);if(!n)throw new SyntaxError('String "'+e+'" is no valid range');return"BigNumber"===r.number?(void 0===i&&tr(),c((t?h:m)(i(n.start),i(n.end),i(n.step)))):c((t?p:f)(n.start,n.end,n.step))}function f(e,t,r){var n=[],i=e;if(r>0)for(;a(i,t);)n.push(i),i+=r;else if(r<0)for(;s(i,t);)n.push(i),i+=r;return n}function p(e,t,r){var n=[],i=e;if(r>0)for(;o(i,t);)n.push(i),i+=r;else if(r<0)for(;u(i,t);)n.push(i),i+=r;return n}function m(e,t,r){var n=i(0),o=[],u=e;if(r.gt(n))for(;a(u,t);)o.push(u),u=u.plus(r);else if(r.lt(n))for(;s(u,t);)o.push(u),u=u.plus(r);return o}function h(e,t,r){var n=i(0),a=[],s=e;if(r.gt(n))for(;o(s,t);)a.push(s),s=s.plus(r);else if(r.lt(n))for(;u(s,t);)a.push(s),s=s.plus(r);return a}})),an=W("range",["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u}=e,c=nn({typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u});return t("range",{"...any":function(e){return"boolean"!=typeof e[e.length-1]&&e.push(!0),c.apply(null,e)}})}),{isTransformFunction:!0}),on="diff",sn=W(on,["typed","matrix","subtract","number"],(e=>{var{typed:t,matrix:r,subtract:n,number:i}=e;return t(on,{"Array | Matrix":function(e){return f(e)?r(o(e.toArray())):o(e)},"Array | Matrix, number":function(e,t){if(!ce(t))throw new RangeError("Dimension must be a whole number");return f(e)?r(a(e.toArray(),t)):a(e,t)},"Array | Matrix, BigNumber":function(e,t){return this(e,i(t))}});function a(e,t){if(f(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError("Array/Matrix does not have that many dimensions");if(t>0){var r=[];return e.forEach((e=>{r.push(a(e,t-1))})),r}if(0===t)return o(e);throw RangeError("Cannot have negative dimension")}function o(e){var t=[],r=e.length;if(r<2)return e;for(var n=1;n{var{typed:t,matrix:r,subtract:n,number:i,bignumber:a}=e,o=sn({typed:t,matrix:r,subtract:n,number:i,bignumber:a});return t(un,{"...any":function(e){e=Vr(e);try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),ln=W("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e;return t("row",{"Matrix, number":a,"Array, number":function(e,t){return a(n($(e)),t).valueOf()}});function a(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");$e(t,e.size()[0]);var n=i(0,e.size()[1]),a=new r(t,n);return e.subset(a)}})),fn=W("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:a}=e,o=ln({typed:t,Index:r,matrix:n,range:a});return t("row",{"...any":function(e){var t=e.length-1,r=e[t];i(r)&&(e[t]=r-1);try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),pn="mean",mn=W(pn,["typed","add","divide"],(e=>{var{typed:t,add:r,divide:n}=e;return t(pn,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,t){try{var i=Gt(e,t,r),a=Array.isArray(e)?je(e):e.size();return n(i,a[t])}catch(e){throw Gr(e,"mean")}},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function mean");return i(e)}});function i(e){var t,i=0;if(Ht(e,(function(e){try{t=void 0===t?e:r(t,e),i++}catch(t){throw Gr(t,"mean",e)}})),0===i)throw new Error("Cannot calculate the mean of an empty array");return n(t,i)}})),hn=W("mean",["typed","add","divide"],(e=>{var{typed:t,add:r,divide:n}=e,i=mn({typed:t,add:r,divide:n});return t("mean",{"...any":function(e){e=Vr(e);try{return i.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),dn="unbiased",yn="variance",gn=W(yn,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:r,subtract:n,multiply:i,divide:o,apply:s,isNaN:u}=e;return t(yn,{"Array | Matrix":function(e){return c(e,dn)},"Array | Matrix, string":c,"Array | Matrix, number | BigNumber":function(e,t){return l(e,t,dn)},"Array | Matrix, number | BigNumber, string":l,"...":function(e){return c(e,dn)}});function c(e,t){var s,c=0;if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Ht(e,(function(e){try{s=void 0===s?e:r(s,e),c++}catch(t){throw Gr(t,"variance",e)}})),0===c)throw new Error("Cannot calculate variance of an empty array");var l=o(s,c);if(s=void 0,Ht(e,(function(e){var t=n(e,l);s=void 0===s?i(t,t):r(s,i(t,t))})),u(s))return s;switch(t){case"uncorrected":return o(s,c);case"biased":return o(s,c+1);case"unbiased":var f=a(s)?s.mul(0):0;return 1===c?f:o(s,c-1);default:throw new Error('Unknown normalization "'+t+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function l(e,t,r){try{if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return s(e,t,(e=>c(e,r)))}catch(e){throw Gr(e,"variance")}}})),vn="variance",xn=W(vn,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:r,subtract:n,multiply:i,divide:a,apply:o,isNaN:s}=e,u=gn({typed:t,add:r,subtract:n,multiply:i,divide:a,apply:o,isNaN:s});return t(vn,{"...any":function(e){e=Vr(e);try{return u.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),bn=W("std",["typed","sqrt","variance"],(e=>{var{typed:t,sqrt:r,variance:n}=e;return t("std",{"Array | Matrix":i,"Array | Matrix, string":i,"Array | Matrix, number | BigNumber":i,"Array | Matrix, number | BigNumber, string":i,"...":function(e){return i(e)}});function i(e,t){if(0===e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{return r(n.apply(null,arguments))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf(" variance")?new TypeError(e.message.replace(" variance"," std")):e}}})),wn=W("std",["typed","sqrt","variance"],(e=>{var{typed:t,sqrt:r,variance:n}=e,i=bn({typed:t,sqrt:r,variance:n});return t("std",{"...any":function(e){e=Vr(e);try{return i.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Nn=W("ResultSet",[],(()=>{function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=t||[]}return e.prototype.type="ResultSet",e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},e.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},e.fromJSON=function(t){return new e(t.entries)},e}),{isClass:!0}),Mn=r(977),Sn=W("Complex",[],(()=>(Mn.prototype.type="Complex",Mn.prototype.isComplex=!0,Mn.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Mn.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Mn.prototype.format=function(e){var t=this.im,r=this.re,n=ge(this.re,e),a=ge(this.im,e),o=i(e)?e:e?e.precision:null;if(null!==o){var s=Math.pow(10,-o);Math.abs(r/t)t.re?1:e.ret.im?1:e.im{function e(t,r,n){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var i=null!=t,o=null!=r,s=null!=n;if(i)if(a(t))t=t.toNumber();else if("number"!=typeof t)throw new TypeError("Parameter start must be a number");if(o)if(a(r))r=r.toNumber();else if("number"!=typeof r)throw new TypeError("Parameter end must be a number");if(s)if(a(n))n=n.toNumber();else if("number"!=typeof n)throw new TypeError("Parameter step must be a number");this.start=i?parseFloat(t):0,this.end=o?parseFloat(r):0,this.step=s?parseFloat(n):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(t){if("string"!=typeof t)return null;var r=t.split(":").map((function(e){return parseFloat(e)}));if(r.some((function(e){return isNaN(e)})))return null;switch(r.length){case 2:return new e(r[0],r[1]);case 3:return new e(r[0],r[2],r[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var e=0,t=this.start,r=this.step,n=this.end-t;return le(r)===le(n)?e=Math.ceil(n/r):0===n&&(e=0),isNaN(e)&&(e=0),[e]},e.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},e.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},e.prototype.forEach=function(e){var t=this.start,r=this.step,n=this.end,i=0;if(r>0)for(;tn;)e(t,[i],this),t+=r,i++},e.prototype.map=function(e){var t=[];return this.forEach((function(r,n,i){t[n[0]]=e(r,n,i)})),t},e.prototype.toArray=function(){var e=[];return this.forEach((function(t,r){e[r[0]]=t})),e},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(e){var t=ge(this.start,e);return 1!==this.step&&(t+=":"+ge(this.step,e)),t+":"+ge(this.end,e)},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},e.fromJSON=function(t){return new e(t.start,t.end,t.step)},e}),{isClass:!0}),An=Er((function(e){return new e(1).exp()}),{hasher:Tn}),On=Er((function(e){return new e(1).plus(new e(5).sqrt()).div(2)}),{hasher:Tn}),Cn=Er((function(e){return e.acos(-1)}),{hasher:Tn}),_n=Er((function(e){return Cn(e).times(2)}),{hasher:Tn});function Tn(e){return e[0].precision}var Bn=Math.PI,qn=2*Math.PI,zn=Math.E,Dn=W("true",[],(()=>!0)),In=W("false",[],(()=>!1)),kn=W("null",[],(()=>null)),Rn=Xn("Infinity",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1/0):1/0})),Fn=Xn("NaN",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(NaN):NaN})),Un=Xn("pi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?Cn(r):Bn})),Pn=Xn("tau",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?_n(r):qn})),jn=Xn("e",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?An(r):zn})),Ln=Xn("phi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?On(r):1.618033988749895})),Hn=Xn("LN2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(2).ln():Math.LN2})),$n=Xn("LN10",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(10).ln():Math.LN10})),Gn=Xn("LOG2E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1).div(new r(2).ln()):Math.LOG2E})),Zn=Xn("LOG10E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1).div(new r(10).ln()):Math.LOG10E})),Vn=Xn("SQRT1_2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r("0.5").sqrt():Math.SQRT1_2})),Wn=Xn("SQRT2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(2).sqrt():Math.SQRT2})),Jn=Xn("i",["Complex"],(e=>{var{Complex:t}=e;return t.I})),Yn=W("version",[],(()=>"9.5.0"));function Xn(e,t,r){return W(e,t,r,{recreateOnConfigChange:!0})}var Qn=r(776),Kn=W("BigNumber",["?on","config"],(e=>{var{on:t,config:r}=e,n=Qn.clone({precision:r.precision,modulo:Qn.EUCLID});return n.prototype=Object.create(n.prototype),n.prototype.type="BigNumber",n.prototype.isBigNumber=!0,n.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},n.fromJSON=function(e){return new n(e.value)},t&&t("config",(function(e,t){e.precision!==t.precision&&n.config({precision:e.precision})})),n}),{isClass:!0}),ei=W("Matrix",[],(()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(e,t,r){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(e,t,r){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e}),{isClass:!0}),ti=W("replacer",[],(()=>function(e,t){return"number"!=typeof t||isFinite(t)&&!isNaN(t)?t:{mathjs:"number",value:String(t)}})),ri=Qi("speedOfLight","299792458","m s^-1"),ni=Qi("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),ii=Qi("planckConstant","6.62607015e-34","J s"),ai=Qi("reducedPlanckConstant","1.0545718176461565e-34","J s"),oi=Qi("magneticConstant","1.25663706212e-6","N A^-2"),si=Qi("electricConstant","8.8541878128e-12","F m^-1"),ui=Qi("vacuumImpedance","376.730313667","ohm"),ci=Qi("coulomb","8.987551792261171e9","N m^2 C^-2"),li=Qi("elementaryCharge","1.602176634e-19","C"),fi=Qi("bohrMagneton","9.2740100783e-24","J T^-1"),pi=Qi("conductanceQuantum","7.748091729863649e-5","S"),mi=Qi("inverseConductanceQuantum","12906.403729652257","ohm"),hi=Qi("magneticFluxQuantum","2.0678338484619295e-15","Wb"),di=Qi("nuclearMagneton","5.0507837461e-27","J T^-1"),yi=Qi("klitzing","25812.807459304513","ohm"),gi=Qi("bohrRadius","5.29177210903e-11","m"),vi=Qi("classicalElectronRadius","2.8179403262e-15","m"),xi=Qi("electronMass","9.1093837015e-31","kg"),bi=Qi("fermiCoupling","1.1663787e-5","GeV^-2"),wi=Ki("fineStructure",.0072973525693),Ni=Qi("hartreeEnergy","4.3597447222071e-18","J"),Mi=Qi("protonMass","1.67262192369e-27","kg"),Si=Qi("deuteronMass","3.3435830926e-27","kg"),Ei=Qi("neutronMass","1.6749271613e-27","kg"),Ai=Qi("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),Oi=Qi("rydberg","10973731.568160","m^-1"),Ci=Qi("thomsonCrossSection","6.6524587321e-29","m^2"),_i=Ki("weakMixingAngle",.2229),Ti=Ki("efimovFactor",22.7),Bi=Qi("atomicMass","1.66053906660e-27","kg"),qi=Qi("avogadro","6.02214076e23","mol^-1"),zi=Qi("boltzmann","1.380649e-23","J K^-1"),Di=Qi("faraday","96485.33212331001","C mol^-1"),Ii=Qi("firstRadiation","3.7417718521927573e-16","W m^2"),ki=Qi("loschmidt","2.686780111798444e25","m^-3"),Ri=Qi("gasConstant","8.31446261815324","J K^-1 mol^-1"),Fi=Qi("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),Ui=Qi("molarVolume","0.022413969545014137","m^3 mol^-1"),Pi=Ki("sackurTetrode",-1.16487052358),ji=Qi("secondRadiation","0.014387768775039337","m K"),Li=Qi("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),Hi=Qi("wienDisplacement","2.897771955e-3","m K"),$i=Qi("molarMass","0.99999999965e-3","kg mol^-1"),Gi=Qi("molarMassC12","11.9999999958e-3","kg mol^-1"),Zi=Qi("gravity","9.80665","m s^-2"),Vi=Qi("planckLength","1.616255e-35","m"),Wi=Qi("planckMass","2.176435e-8","kg"),Ji=Qi("planckTime","5.391245e-44","s"),Yi=Qi("planckCharge","1.87554603778e-18","C"),Xi=Qi("planckTemperature","1.416785e+32","K");function Qi(e,t,r){return W(e,["config","Unit","BigNumber"],(e=>{var{config:n,Unit:i,BigNumber:a}=e,o=new i("BigNumber"===n.number?new a(t):parseFloat(t),r);return o.fixPrefix=!0,o}))}function Ki(e,t){return W(e,["config","BigNumber"],(e=>{var{config:r,BigNumber:n}=e;return"BigNumber"===r.number?new n(t):t}))}var ea=r(628),ta=W("Fraction",[],(()=>(ea.prototype.type="Fraction",ea.prototype.isFraction=!0,ea.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},ea.fromJSON=function(e){return new ea(e)},ea)),{isClass:!0}),ra=W("DenseMatrix",["Matrix"],(e=>{var{Matrix:t}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!c(t))throw new Error("Invalid datatype: "+t);if(f(e))"DenseMatrix"===e.type?(this._data=$(e._data),this._size=$(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&l(e.data)&&l(e.size))this._data=e.data,this._size=e.size,He(this._data,this._size),this._datatype=t||e.datatype;else if(l(e))this._data=d(e),this._size=je(this._data),He(this._data,this._size),this._datatype=t;else{if(e)throw new TypeError("Unsupported type of data ("+L(e)+")");this._data=[],this._size=[0],this._datatype=t}}function n(e,t){if(!y(t))throw new TypeError("Invalid index");if(t.isScalar())return e.get(t.min());var n=t.size();if(n.length!==e._size.length)throw new Ue(n.length,e._size.length);for(var i=t.min(),a=t.max(),s=0,u=e._size.length;s");h(e,t.max().map((function(e){return e+1})),n);var l=a.length;u(e._data,t,r,l,0)}return e}function u(e,t,r,n,i){var a=i===n-1,o=t.dimension(i);a?o.forEach((function(t,n){$e(t),e[t]=r[n[0]]})):o.forEach((function(a,o){$e(a),u(e[a],t,r[o[0]],n,i+1)}))}function m(e,t,r){if(0===t.length){for(var n=e._data;l(n);)n=n[0];return n}return e._size=t.slice(0),e._data=Ge(e._data,e._size,r),e}function h(e,t,r){for(var n=e._size.slice(0),i=!1;n.lengthn[a]&&(n[a]=t[a],i=!0);i&&m(e,n,r)}function d(e){for(var t=0,r=e.length;tArray.isArray(e)&&1===e.length?e[0]:e));return m(r?this.clone():this,n,t)},r.prototype.reshape=function(e,t){var r=t?this.clone():this;r._data=Ve(r._data,e);var n=r._size.reduce(((e,t)=>e*t));return r._size=We(e,n),r},r.prototype.clone=function(){return new r({data:$(this._data),size:$(this._size),datatype:this._datatype})},r.prototype.size=function(){return this._size.slice(0)},r.prototype.map=function(e){var t=this,n=function r(n,i){return l(n)?n.map((function(e,t){return r(e,i.concat(t))})):e(n,i,t)}(this._data,[]);return new r(n,void 0!==this._datatype?ut(n,L):void 0)},r.prototype.forEach=function(e){var t=this;!function r(n,i){l(n)?n.forEach((function(e,t){r(e,i.concat(t))})):e(n,i,t)}(this._data,[])},r.prototype[Symbol.iterator]=function*(){yield*function*e(t,r){if(l(t))for(var n=0;n[e[n]]));t.push(new r(a,e._datatype))},o=0;o0?e:0,n=e<0?-e:0,o=this._size[0],s=this._size[1],u=Math.min(o-n,s-t),c=[],l=0;l0?n:0,c=n<0?-n:0,p=e[0],m=e[1],h=Math.min(p-c,m-u);if(l(t)){if(t.length!==h)throw new Error("Invalid value array length");s=function(e){return t[e]}}else if(f(t)){var d=t.size();if(1!==d.length||d[0]!==h)throw new Error("Invalid matrix length");s=function(e){return t.get([e])}}else s=function(){return t};o||(o=a(s(0))?s(0).mul(0):0);var y=[];if(e.length>0){y=Ge(y,e,o);for(var g=0;g15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new t(e)}},{from:"number",to:"Complex",convert:function(e){return r||sa(e),new r(e,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(e){return r||sa(e),new r(e.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(e){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(e){return r||sa(e),new r(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){p||ua(e);var t=new p(e);if(t.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return t}},{from:"string",to:"number",convert:function(e){var t=Number(e);if(isNaN(t))throw new Error('Cannot convert "'+e+'" to a number');return t}},{from:"string",to:"BigNumber",convert:function(e){t||oa(e);try{return new t(e)}catch(t){throw new Error('Cannot convert "'+e+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(e){p||ua(e);try{return new p(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(e){r||sa(e);try{return new r(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return t||oa(e),new t(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return p||ua(e),new p(+e)}},{from:"boolean",to:"string",convert:function(e){return String(e)}},{from:"Array",to:"Matrix",convert:function(e){return n||function(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}(),new n(e)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}],L}));function oa(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function sa(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function ua(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var ca="isInteger",la=W(ca,["typed"],(e=>{var{typed:t}=e;return t(ca,{number:ce,BigNumber:function(e){return e.isInt()},Fraction:function(e){return 1===e.d&&isFinite(e.n)},"Array | Matrix":function(e){return $t(e,this)}})})),fa="isNumeric",pa=W(fa,["typed"],(e=>{var{typed:t}=e;return t(fa,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(e){return $t(e,this)}})})),ma="number";function ha(e){return e<0}function da(e){return e>0}function ya(e){return 0===e}function ga(e){return Number.isNaN(e)}ha.signature=ma,da.signature=ma,ya.signature=ma,ga.signature=ma;var va="isPositive",xa=W(va,["typed"],(e=>{var{typed:t}=e;return t(va,{number:da,BigNumber:function(e){return!e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s>0&&e.n>0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),ba="isNaN",wa=W(ba,["typed"],(e=>{var{typed:t}=e;return t(ba,{number:ga,BigNumber:function(e){return e.isNaN()},Fraction:function(e){return!1},Complex:function(e){return e.isNaN()},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":function(e){return $t(e,Number.isNaN)}})}));function Na(e,t,r){if(null==r)return e.eq(t);if(e.eq(t))return!0;if(e.isNaN()||t.isNaN())return!1;if(e.isFinite()&&t.isFinite()){var n=e.minus(t).abs();if(n.isZero())return!0;var i=e.constructor.max(e.abs(),t.abs());return n.lte(i.times(r))}return!1}var Ma="equalScalar",Sa=W(Ma,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(Ma,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return e.equals(t)},"Complex, Complex":function(e,t){return function(e,t,r){return Se(e.re,t.re,r)&&Se(e.im,t.im,r)}(e,t,r.epsilon)},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)}})}));W(Ma,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(Ma,{"number, number":function(e,t){return Se(e,t,r.epsilon)}})}));var Ea=W("number",["typed"],(e=>{var{typed:t}=e,r=t("number",{"":function(){return 0},number:function(e){return e},string:function(e){if("NaN"===e)return NaN;var t,r,n=(r=(t=e).match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/))?{input:t,radix:{"0b":2,"0o":8,"0x":16}[r[1]],integerPart:r[2],fractionalPart:r[3]}:null;if(n)return function(e){for(var t=parseInt(e.integerPart,e.radix),r=0,n=0;n2**i-1)throw new SyntaxError('String "'.concat(e,'" is out of range'));o>=2**(i-1)&&(o-=2**i)}return o},BigNumber:function(e){return e.toNumber()},Fraction:function(e){return e.valueOf()},Unit:function(e){throw new Error("Second argument with valueless unit expected")},null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":function(e){return $t(e,this)}});return r.fromJSON=function(e){return parseFloat(e.value)},r})),Aa="boolean",Oa=W(Aa,["typed"],(e=>{var{typed:t}=e;return t(Aa,{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(e){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;var r=Number(e);if(""!==e&&!isNaN(r))return!!r;throw new Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":function(e){return $t(e,this)}})})),Ca=W("complex",["typed","Complex"],(e=>{var{typed:t,Complex:r}=e;return t("complex",{"":function(){return r.ZERO},number:function(e){return new r(e,0)},"number, number":function(e,t){return new r(e,t)},"BigNumber, BigNumber":function(e,t){return new r(e.toNumber(),t.toNumber())},Fraction:function(e){return new r(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return r(e)},null:function(e){return r(0)},Object:function(e){if("re"in e&&"im"in e)return new r(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new r(e);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(e){return $t(e,this)}})})),_a="splitUnit",Ta=W(_a,["typed"],(e=>{var{typed:t}=e;return t(_a,{"Unit, Array":function(e,t){return e.splitUnit(t)}})})),Ba="number",qa="number, number";function za(e){return Math.abs(e)}function Da(e,t){return e+t}function Ia(e,t){return e*t}function ka(e){return-e}function Ra(e){return e}function Fa(e){return he(e)}function Ua(e){return Math.ceil(e)}function Pa(e){return e*e*e}function ja(e){return Math.exp(e)}function La(e){return de(e)}function Ha(e,t){if(!ce(e)||!ce(t))throw new Error("Parameters in function gcd must be integer numbers");for(var r;0!==t;)r=e%t,e=t,t=r;return e<0?-e:e}function $a(e,t){if(!ce(e)||!ce(t))throw new Error("Parameters in function lcm must be integer numbers");if(0===e||0===t)return 0;for(var r,n=e*t;0!==t;)t=e%(r=t),e=r;return Math.abs(n/e)}function Ga(e){return Math.log(e)}function Za(e){return pe(e)}function Va(e){return fe(e)}function Wa(e,t){if(t>0)return e-t*Math.floor(e/t);if(0===t)return e;throw new Error("Cannot calculate mod for a negative divisor")}function Ja(e,t){var r=t<0;if(r&&(t=-t),0===t)throw new Error("Root must be non-zero");if(e<0&&Math.abs(t)%2!=1)throw new Error("Root must be odd when a is negative.");if(0===e)return r?1/0:0;if(!isFinite(e))return r?0:e;var n=Math.pow(Math.abs(e),1/t);return n=e<0?-n:n,r?1/n:n}function Ya(e){return le(e)}function Xa(e){return e*e}function Qa(e,t){var r,n,i,a=0,o=1,s=1,u=0;if(!ce(e)||!ce(t))throw new Error("Parameters in function xgcd must be integer numbers");for(;t;)i=e-(n=Math.floor(e/t))*t,r=a,a=o-n*a,o=r,r=s,s=u-n*s,u=r,e=t,t=i;return e<0?[-e,-o,-u]:[e,e?o:0,u]}function Ka(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:Math.pow(e,t)}function eo(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return parseFloat(xe(e,t))}za.signature=Ba,Da.signature=qa,Ia.signature=qa,ka.signature=Ba,Ra.signature=Ba,Fa.signature=Ba,Ua.signature=Ba,Pa.signature=Ba,ja.signature=Ba,La.signature=Ba,Ha.signature=qa,$a.signature=qa,Ga.signature=Ba,Za.signature=Ba,Va.signature=Ba,Wa.signature=qa,Ja.signature=qa,Ya.signature=Ba,Xa.signature=Ba,Qa.signature=qa,Ka.signature=qa,eo.signature=qa;var to="unaryPlus",ro=W(to,["typed","config","BigNumber"],(e=>{var{typed:t,config:r,BigNumber:n}=e;return t(to,{number:Ra,Complex:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":function(e){return $t(e,this,!0)},"boolean | string":function(e){return"BigNumber"===r.number?new n(+e):+e}})})),no="cube",io=W(no,["typed"],(e=>{var{typed:t}=e;return t(no,{number:Pa,Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},Fraction:function(e){return e.pow(3)},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.pow(3)}})})),ao="expm1",oo=W(ao,["typed","Complex"],(e=>{var{typed:t,Complex:r}=e;return t(ao,{number:La,Complex:function(e){var t=Math.exp(e.re);return new r(t*Math.cos(e.im)-1,t*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)},"Array | Matrix":function(e){return $t(e,this)}})})),so="log10",uo=W(so,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(so,{number:function(e){return e>=0||r.predictable?Za(e):new n(e,0).log().div(Math.LN10)},Complex:function(e){return new n(e).log().div(Math.LN10)},BigNumber:function(e){return!e.isNegative()||r.predictable?e.log():new n(e.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(e){return $t(e,this)}})})),co=W("multiplyScalar",["typed"],(e=>{var{typed:t}=e;return t("multiplyScalar",{"number, number":Ia,"Complex, Complex":function(e,t){return e.mul(t)},"BigNumber, BigNumber":function(e,t){return e.times(t)},"Fraction, Fraction":function(e,t){return e.mul(t)},"number | Fraction | BigNumber | Complex, Unit":function(e,t){var r=t.clone();return r.value=null===r.value?r._normalize(e):this(r.value,e),r},"Unit, number | Fraction | BigNumber | Complex":function(e,t){var r=e.clone();return r.value=null===r.value?r._normalize(t):this(r.value,t),r},"Unit, Unit":function(e,t){return e.multiply(t)}})})),lo="sign",fo=W(lo,["typed","BigNumber","Fraction","complex"],(e=>{var{typed:t,BigNumber:r,complex:n,Fraction:i}=e;return t(lo,{number:Ya,Complex:function(e){return 0===e.im?n(Ya(e.re)):e.sign()},BigNumber:function(e){return new r(e.cmp(0))},Fraction:function(e){return new i(e.s,1)},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return this(e.value)}})})),po="square",mo=W(po,["typed"],(e=>{var{typed:t}=e;return t(po,{number:Xa,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},Fraction:function(e){return e.mul(e)},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.pow(2)}})}));function ho(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitAnd");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero()||t.eq(-1)||e.eq(t))return e;if(t.isZero()||e.eq(-1))return t;if(!e.isFinite()||!t.isFinite()){if(!e.isFinite()&&!t.isFinite())return e.isNegative()===t.isNegative()?e:new r(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new r(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new r(0):e}return vo(e,t,(function(e,t){return e&t}))}function yo(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var t=e.constructor,r=t.precision;t.config({precision:1e9});var n=e.plus(new t(1));return n.s=-n.s||null,t.config({precision:r}),n}function go(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitOr");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);var n=new r(-1);return e.isZero()||t.eq(n)||e.eq(t)?t:t.isZero()||e.eq(n)?e:e.isFinite()&&t.isFinite()?vo(e,t,(function(e,t){return e|t})):!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?n:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e}function vo(e,t,r){var n,i,a,o,s,u=e.constructor,c=+(e.s<0),l=+(t.s<0);if(c){n=xo(yo(e));for(var f=0;f0;)r(a[--m],o[--h])===d&&(y=y.plus(g)),g=g.times(v);for(;h>0;)r(s,o[--h])===d&&(y=y.plus(g)),g=g.times(v);return u.config({precision:x}),0===d&&(y.s=-y.s),y}function xo(e){for(var t=e.d,r=t[0]+"",n=1;n0)if(++s>c)for(s-=c;s--;)u+="0";else s1&&(null!==l[m+1]&&void 0!==l[m+1]||(l[m+1]=0),l[m+1]+=l[m]>>1,l[m]&=1)}return l.reverse()}function bo(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new r(0);var n=new r(-1);return e.eq(n)?yo(t):t.eq(n)?yo(e):e.isFinite()&&t.isFinite()?vo(e,t,(function(e,t){return e^t})):e.isFinite()||t.isFinite()?new r(e.isNegative()===t.isNegative()?1/0:-1/0):n}function wo(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:e.isFinite()||t.isFinite()?t.lt(55)?e.times(Math.pow(2,t.toNumber())+""):e.times(new r(2).pow(t)):new r(NaN)}function No(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(Math.pow(2,t.toNumber())+"").floor():e.div(new r(2).pow(t)).floor():e.isNegative()?new r(-1):e.isFinite()?new r(0):new r(NaN)}var Mo="number, number";function So(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function bitAnd");return e&t}function Eo(e){if(!ce(e))throw new Error("Integer expected in function bitNot");return~e}function Ao(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function bitOr");return e|t}function Oo(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function bitXor");return e^t}function Co(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function leftShift");return e<>t}function To(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}So.signature=Mo,Eo.signature="number",Ao.signature=Mo,Oo.signature=Mo,Co.signature=Mo,_o.signature=Mo,To.signature=Mo;var Bo="bitNot",qo=W(Bo,["typed"],(e=>{var{typed:t}=e;return t(Bo,{number:Eo,BigNumber:yo,"Array | Matrix":function(e){return $t(e,this)}})})),zo=W("arg",["typed"],(e=>{var{typed:t}=e;return t("arg",{number:function(e){return Math.atan2(0,e)},BigNumber:function(e){return e.constructor.atan2(0,e)},Complex:function(e){return e.arg()},"Array | Matrix":function(e){return $t(e,this)}})})),Do=W("im",["typed"],(e=>{var{typed:t}=e;return t("im",{number:function(e){return 0},BigNumber:function(e){return e.mul(0)},Fraction:function(e){return e.mul(0)},Complex:function(e){return e.im},"Array | Matrix":function(e){return $t(e,this)}})})),Io="number, number";function ko(e){return!e}function Ro(e,t){return!(!e&&!t)}function Fo(e,t){return!!e!=!!t}function Uo(e,t){return!(!e||!t)}ko.signature="number",Ro.signature=Io,Fo.signature=Io,Uo.signature=Io;var Po=W("not",["typed"],(e=>{var{typed:t}=e;return t("not",{number:ko,Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},Unit:function(e){return null===e.value||this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),jo=W("filter",["typed"],(e=>{var{typed:t}=e;return t("filter",{"Array, function":Lo,"Matrix, function":function(e,t){return e.create(Lo(e.toArray(),t))},"Array, RegExp":it,"Matrix, RegExp":function(e,t){return e.create(it(e.toArray(),t))}})}));function Lo(e,t){var r=Ar(t);return nt(e,(function(e,n,i){return 1===r?t(e):2===r?t(e,[n]):t(e,[n],i)}))}var Ho="forEach",$o=W(Ho,["typed"],(e=>{var{typed:t}=e;return t(Ho,{"Array, function":Go,"Matrix, function":function(e,t){return e.forEach(t)}})}));function Go(e,t){var r=Ar(t);!function n(i,a){Array.isArray(i)?rt(i,(function(e,t){n(e,a.concat(t))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e,[])}var Zo=W("map",["typed"],(e=>{var{typed:t}=e;return t("map",{"Array, function":Vo,"Matrix, function":function(e,t){return e.map(t)}})}));function Vo(e,t){var r=Ar(t);return function n(i,a){return Array.isArray(i)?i.map((function(e,t){return n(e,a.concat(t))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e,[])}var Wo=W("erf",["typed"],(e=>{var{typed:t}=e;return t("name",{number:function(e){var t=Math.abs(e);return t>=Ko?le(e):t<=Jo?le(e)*function(e){var t,r=e*e,n=Xo[0][4]*r,i=r;for(t=0;t<3;t+=1)n=(n+Xo[0][t])*r,i=(i+Qo[0][t])*r;return e*(n+Xo[0][3])/(i+Qo[0][3])}(t):t<=4?le(e)*(1-function(e){var t,r=Xo[1][8]*e,n=e;for(t=0;t<7;t+=1)r=(r+Xo[1][t])*e,n=(n+Qo[1][t])*e;var i=(r+Xo[1][7])/(n+Qo[1][7]),a=parseInt(16*e)/16,o=(e-a)*(e+a);return Math.exp(-a*a)*Math.exp(-o)*i}(t)):le(e)*(1-function(e){var t,r=1/(e*e),n=Xo[2][5]*r,i=r;for(t=0;t<4;t+=1)n=(n+Xo[2][t])*r,i=(i+Qo[2][t])*r;var a=r*(n+Xo[2][4])/(i+Qo[2][4]);a=(Yo-a)/e;var o=(e-(r=parseInt(16*e)/16))*(e+r);return Math.exp(-r*r)*Math.exp(-o)*a}(t))},"Array | Matrix":function(e){return $t(e,this)}})})),Jo=.46875,Yo=.5641895835477563,Xo=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],Qo=[[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]],Ko=Math.pow(2,53),es="format",ts=W(es,["typed"],(e=>{var{typed:t}=e;return t(es,{any:De,"any, Object | function | number":De})})),rs=W("oct",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("oct",{"number | BigNumber":function(e){return r(e,{notation:"oct"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"oct",wordSize:t})}})})),ns="print",is=W(ns,["typed"],(e=>{var{typed:t}=e;return t(ns,{"string, Object | Array":as,"string, Object | Array, number | Object":as})}));function as(e,t,r){return e.replace(/\$([\w.]+)/g,(function(e,n){for(var i=n.split("."),a=t[i.shift()];i.length&&void 0!==a;){var o=i.shift();a=o?a[o]:a+"."}return void 0!==a?c(a)?a:De(a,r):e}))}var os="isPrime",ss=W(os,["typed"],(e=>{var{typed:t}=e;return t(os,{number:function(e){if(0*e!=0)return!1;if(e<=3)return e>1;if(e%2==0||e%3==0)return!1;for(var t=5;t*t<=e;t+=6)if(e%t==0||e%(t+2)==0)return!1;return!0},BigNumber:function(e){if(0*e.toNumber()!=0)return!1;if(e.lte(3))return e.gt(1);if(e.mod(2).eq(0)||e.mod(3).eq(0))return!1;if(e.lt(Math.pow(2,32))){for(var t=e.toNumber(),r=5;r*r<=t;r+=6)if(t%r==0||t%(r+2)==0)return!1;return!0}function n(e,t,r){for(var n=1;!t.eq(0);)t.mod(2).eq(0)?(t=t.div(2),e=e.mul(e).mod(r)):(t=t.sub(1),n=e.mul(n).mod(r));return n}for(var i=e.constructor.clone({precision:2*e.toFixed(0).length}),a=0,o=(e=new i(e)).sub(1);o.mod(2).eq(0);)o=o.div(2),a+=1;var s=null;if(e.lt("3317044064679887385961981"))s=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter((t=>t{var{typed:t,config:r,Complex:n}=e;return t(us,{number:function(e){return e>=-1&&e<=1||r.predictable?Math.acos(e):new n(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()},"Array | Matrix":function(e){return $t(e,this)}})})),ls="number";function fs(e){return Ee(e)}function ps(e){return Math.atan(1/e)}function ms(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}function hs(e){return Math.asin(1/e)}function ds(e){var t=1/e;return Math.log(t+Math.sqrt(t*t+1))}function ys(e){return Math.acos(1/e)}function gs(e){var t=1/e,r=Math.sqrt(t*t-1);return Math.log(r+t)}function vs(e){return Ae(e)}function xs(e){return Oe(e)}function bs(e){return 1/Math.tan(e)}function ws(e){var t=Math.exp(2*e);return(t+1)/(t-1)}function Ns(e){return 1/Math.sin(e)}function Ms(e){return 0===e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*le(e)}function Ss(e){return 1/Math.cos(e)}function Es(e){return 2/(Math.exp(e)+Math.exp(-e))}function As(e){return _e(e)}fs.signature=ls,ps.signature=ls,ms.signature=ls,hs.signature=ls,ds.signature=ls,ys.signature=ls,gs.signature=ls,vs.signature=ls,xs.signature=ls,bs.signature=ls,ws.signature=ls,Ns.signature=ls,Ms.signature=ls,Ss.signature=ls,Es.signature=ls,As.signature=ls;var Os="acot",Cs=W(Os,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Os,{number:ps,Complex:function(e){return e.acot()},BigNumber:function(e){return new r(1).div(e).atan()},"Array | Matrix":function(e){return $t(e,this)}})})),_s="acsc",Ts=W(_s,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(_s,{number:function(e){return e<=-1||e>=1||r.predictable?hs(e):new n(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new i(1).div(e).asin()},"Array | Matrix":function(e){return $t(e,this)}})})),Bs="asec",qs=W(Bs,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(Bs,{number:function(e){return e<=-1||e>=1||r.predictable?ys(e):new n(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new i(1).div(e).acos()},"Array | Matrix":function(e){return $t(e,this)}})})),zs="asin",Ds=W(zs,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(zs,{number:function(e){return e>=-1&&e<=1||r.predictable?Math.asin(e):new n(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Is=W("atan",["typed"],(e=>{var{typed:t}=e;return t("atan",{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),ks="atanh",Rs=W(ks,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(ks,{number:function(e){return e<=1&&e>=-1||r.predictable?xs(e):new n(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Fs="cosh",Us=W(Fs,["typed"],(e=>{var{typed:t}=e;return t(Fs,{number:Ce,Complex:function(e){return e.cosh()},BigNumber:function(e){return e.cosh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Ps="coth",js=W(Ps,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Ps,{number:ws,Complex:function(e){return e.coth()},BigNumber:function(e){return new r(1).div(e.tanh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Ls="csch",Hs=W(Ls,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Ls,{number:Ms,Complex:function(e){return e.csch()},BigNumber:function(e){return new r(1).div(e.sinh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),$s="sech",Gs=W($s,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t($s,{number:Es,Complex:function(e){return e.sech()},BigNumber:function(e){return new r(1).div(e.cosh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Zs="sinh",Vs=W(Zs,["typed"],(e=>{var{typed:t}=e;return t(Zs,{number:As,Complex:function(e){return e.sinh()},BigNumber:function(e){return e.sinh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Ws=W("tanh",["typed"],(e=>{var{typed:t}=e;return t("tanh",{number:Te,Complex:function(e){return e.tanh()},BigNumber:function(e){return e.tanh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})}));function Js(e,t){if(t>1;return Js(e,r)*Js(r+1,t)}function Ys(e,t){if(!ce(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!ce(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(t>e)throw new TypeError("k must be less than or equal to n");var r=e-t;return t{var{typed:t}=e;return t(Xs,{"number, number":Ys,"BigNumber, BigNumber":function(e,t){var r,n,i=e.constructor,a=e.minus(t),o=new i(1);if(!Ks(e)||!Ks(t))throw new TypeError("Positive integer value expected in function combinations");if(t.gt(e))throw new TypeError("k must be less than n in function combinations");if(r=o,t.lt(a))for(n=o;n.lte(a);n=n.plus(o))r=r.times(t.plus(n)).dividedBy(n);else for(n=o;n.lte(t);n=n.plus(o))r=r.times(a.plus(n)).dividedBy(n);return r}})}));function Ks(e){return e.isInteger()&&e.gte(0)}var eu=r(377),tu=eu(Date.now());function ru(e){var t,r;return t=null===(r=e)?tu:eu(String(r)),function(){return t()}}var nu="pickRandom",iu=W(nu,["typed","config","?on"],(e=>{var{typed:t,config:r,on:n}=e,a=ru(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(a=ru(e.randomSeed))})),t(nu,{"Array | Matrix":function(e){return o(e,{})},"Array | Matrix, Object":function(e,t){return o(e,t)},"Array | Matrix, number":function(e,t){return o(e,{number:t})},"Array | Matrix, Array | Matrix":function(e,t){return o(e,{weights:t})},"Array | Matrix, Array | Matrix, number":function(e,t,r){return o(e,{number:r,weights:t})},"Array | Matrix, number, Array | Matrix":function(e,t,r){return o(e,{number:t,weights:r})}});function o(e,t){var{number:r,weights:n,elementWise:o=!0}=t,s=void 0===r;s&&(r=1);var u=f(e)?e.create:f(n)?n.create:null;e=e.valueOf(),n&&(n=n.valueOf()),!0===o&&(e=et(e),n=et(n));var c=0;if(void 0!==n){if(n.length!==e.length)throw new Error("Weights must have the same length as possibles");for(var l=0,p=n.length;l1)for(var n=0,i=e.shift();n{var{typed:t,config:r,on:n}=e,i=ru(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(i=ru(e.randomSeed))})),t(ou,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,t)=>o(e,t),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,t)=>a(e,0,t),"Array | Matrix, number, number":(e,t,r)=>a(e,t,r)});function a(e,t,r){var n=au(e.valueOf(),(()=>o(t,r)));return f(e)?e.create(n):n}function o(e,t){return Math.floor(e+i()*(t-e))}})),uu="clone",cu=W(uu,["typed"],(e=>{var{typed:t}=e;return t(uu,{any:$})})),lu="hasNumericValue",fu=W(lu,["typed","isNumeric"],(e=>{var{typed:t,isNumeric:r}=e;return t(lu,{string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return r(e)}})})),pu="typeOf",mu=W(pu,["typed"],(e=>{var{typed:t}=e;return t(pu,{any:L})})),hu="string",du=W(hu,["typed"],(e=>{var{typed:t}=e;return t(hu,{"":function(){return""},number:ge,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":function(e){return $t(e,this)},any:function(e){return String(e)}})})),yu=W("fraction",["typed","Fraction"],(e=>{var{typed:t,Fraction:r}=e;return t("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw new Error(e+" cannot be represented as a fraction");return new r(e)},string:function(e){return new r(e)},"number, number":function(e,t){return new r(e,t)},null:function(e){return new r(0)},BigNumber:function(e){return new r(e.toString())},Fraction:function(e){return e},Object:function(e){return new r(e)},"Array | Matrix":function(e){return $t(e,this)}})})),gu="unaryMinus",vu=W(gu,["typed"],(e=>{var{typed:t}=e;return t(gu,{number:ka,Complex:function(e){return e.neg()},BigNumber:function(e){return e.neg()},Fraction:function(e){return e.neg()},Unit:function(e){var t=e.clone();return t.value=this(e.value),t},"Array | Matrix":function(e){return $t(e,this,!0)}})})),xu="addScalar",bu=W(xu,["typed"],(e=>{var{typed:t}=e;return t(xu,{"number, number":Da,"Complex, Complex":function(e,t){return e.add(t)},"BigNumber, BigNumber":function(e,t){return e.plus(t)},"Fraction, Fraction":function(e,t){return e.add(t)},"Unit, Unit":function(e,t){if(null===e.value||void 0===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value||void 0===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var r=e.clone();return r.value=this(r.value,t.value),r.fixPrefix=!1,r}})})),wu=W("exp",["typed"],(e=>{var{typed:t}=e;return t("exp",{number:ja,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()},"Array | Matrix":function(e){return $t(e,this)}})})),Nu="log2",Mu=W(Nu,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(Nu,{number:function(e){return e>=0||r.predictable?Va(e):i(new n(e,0))},Complex:i,BigNumber:function(e){return!e.isNegative()||r.predictable?e.log(2):i(new n(e.toNumber(),0))},"Array | Matrix":function(e){return $t(e,this)}});function i(e){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new n(Math.log2?Math.log2(t):Math.log(t)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}})),Su=W("sqrt",["config","typed","Complex"],(e=>{var{config:t,typed:r,Complex:n}=e;return r("sqrt",{number:i,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.sqrt():i(e.toNumber())},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.pow(.5)}});function i(e){return isNaN(e)?NaN:e>=0||t.predictable?Math.sqrt(e):new n(e,0).sqrt()}})),Eu="conj",Au=W(Eu,["typed"],(e=>{var{typed:t}=e;return t(Eu,{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.conjugate()},"Array | Matrix":function(e){return $t(e,this)}})})),Ou="getMatrixDataType",Cu=W(Ou,["typed"],(e=>{var{typed:t}=e;return t(Ou,{Array:function(e){return ut(e,L)},Matrix:function(e){return e.getDataType()}})})),_u="mode",Tu=W(_u,["typed","isNaN","isNumeric"],(e=>{var{typed:t,isNaN:r,isNumeric:n}=e;return t(_u,{"Array | Matrix":i,"...":function(e){return i(e)}});function i(e){if(0===(e=et(e.valueOf())).length)throw new Error("Cannot calculate mode of an empty array");for(var t={},i=[],a=0,o=0;oa&&(a=t[s],i=[s])}return i}})),Bu=W("bin",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("bin",{"number | BigNumber":function(e){return r(e,{notation:"bin"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"bin",wordSize:t})}})})),qu="acosh",zu=W(qu,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(qu,{number:function(e){return e>=1||r.predictable?fs(e):e<=-1?new n(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new n(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()},"Array | Matrix":function(e){return $t(e,this)}})})),Du="acsch",Iu=W(Du,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Du,{number:ds,Complex:function(e){return e.acsch()},BigNumber:function(e){return new r(1).div(e).asinh()},"Array | Matrix":function(e){return $t(e,this)}})})),ku=W("asinh",["typed"],(e=>{var{typed:t}=e;return t("asinh",{number:vs,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Ru=W("cos",["typed"],(e=>{var{typed:t}=e;return t("cos",{number:Math.cos,Complex:function(e){return e.cos()},BigNumber:function(e){return e.cos()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Fu=W("csc",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("csc",{number:Ns,Complex:function(e){return e.csc()},BigNumber:function(e){return new r(1).div(e.sin())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Uu=W("sin",["typed"],(e=>{var{typed:t}=e;return t("sin",{number:Math.sin,Complex:function(e){return e.sin()},BigNumber:function(e){return e.sin()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Pu="combinationsWithRep",ju=W(Pu,["typed"],(e=>{var{typed:t}=e;return t(Pu,{"number, number":function(e,t){if(!ce(e)||e<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!ce(t)||t<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e<1)throw new TypeError("k must be less than or equal to n + k - 1");return t{var{typed:t,config:r,on:n}=e,i=ru(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(i=ru(e.randomSeed))})),t(Hu,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,t)=>o(e,t),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,t)=>a(e,0,t),"Array | Matrix, number, number":(e,t,r)=>a(e,t,r)});function a(e,t,r){var n=au(e.valueOf(),(()=>o(t,r)));return f(e)?e.create(n):n}function o(e,t){return e+i()*(t-e)}})),Gu="isNegative",Zu=W(Gu,["typed"],(e=>{var{typed:t}=e;return t(Gu,{number:ha,BigNumber:function(e){return e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s<0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Vu=W("SparseMatrix",["typed","equalScalar","Matrix"],(e=>{var{typed:t,equalScalar:r,Matrix:n}=e;function o(e,t){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!c(t))throw new Error("Invalid datatype: "+t);if(f(e))!function(e,t,r){"SparseMatrix"===t.type?(e._values=t._values?$(t._values):void 0,e._index=$(t._index),e._ptr=$(t._ptr),e._size=$(t._size),e._datatype=r||t._datatype):s(e,t.valueOf(),r||t._datatype)}(this,e,t);else if(e&&l(e.index)&&l(e.ptr)&&l(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=t||e.datatype;else if(l(e))s(this,e,t);else{if(e)throw new TypeError("Unsupported type of data ("+L(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=t}}function s(e,n,i){e._values=[],e._index=[],e._ptr=[],e._datatype=i;var a=n.length,o=0,s=r,u=0;if(c(i)&&(s=t.find(r,[i,i])||r,u=t.convert(0,i)),a>0){var f=0;do{e._ptr.push(e._index.length);for(var p=0;p");for(var c=t.min()[0],l=t.min()[1],p=i[0],m=i[1],h=0;hd){for(f=d;fh){if(m){var y=0;for(f=0;fn-1&&(e._values.splice(p,1),e._index.splice(p,1),v++)}e._ptr[f]=e._values.length}return e._size[0]=n,e._size[1]=i,e}function v(e,t,r,n,i){var a,o,s=n[0],u=n[1],c=[];for(a=0;as-1||o>u-1)&&(g(this,Math.max(a+1,s),Math.max(o+1,u),i),s=this._size[0],u=this._size[1]),$e(a,s),$e(o,u);var m=h(a,this._ptr[o],this._ptr[o+1],this._index);return mArray.isArray(e)&&1===e.length?e[0]:e));if(2!==n.length)throw new Error("Only two dimensions matrix are supported");return n.forEach((function(e){if(!i(e)||!ce(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+De(n)+")")})),g(r?this.clone():this,n[0],n[1],t)},o.prototype.reshape=function(e,t){if(!l(e))throw new TypeError("Array expected");if(2!==e.length)throw new Error("Sparse matrices can only be reshaped in two dimensions");e.forEach((function(t){if(!i(t)||!ce(t)||t<=-2||0===t)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+De(e)+")")}));var r=this._size[0]*this._size[1];if(r!==(e=We(e,r))[0]*e[1])throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var n=t?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return n;for(var a=[],o=0;o=0&&w<=i&&y(e._values[b],w-0,g-0)}else{for(var N={},M=v;M "+(this._values?De(this._values[u],e):"X");return i},o.prototype.toString=function(){return De(this.toArray())},o.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},o.prototype.diagonal=function(e){if(e){if(a(e)&&(e=e.toNumber()),!i(e)||!ce(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var t=e>0?e:0,r=e<0?-e:0,n=this._size[0],s=this._size[1],u=Math.min(n-r,s-t),c=[],l=[],f=[];f[0]=0;for(var p=t;p0?s:0,g=s<0?-s:0,v=e[0],x=e[1],b=Math.min(v-g,x-y);if(l(n)){if(n.length!==b)throw new Error("Invalid value array length");d=function(e){return n[e]}}else if(f(n)){var w=n.size();if(1!==w.length||w[0]!==b)throw new Error("Invalid matrix length");d=function(e){return n.get([e])}}else d=function(){return n};for(var N=[],M=[],S=[],E=0;E=0&&A=u||i[l]!==t)){var p=n?n[c]:void 0;i.splice(l,0,t),n&&n.splice(l,0,p),i.splice(l<=c?c+1:c,1),n&&n.splice(l<=c?c+1:c,1)}else if(l=u||i[c]!==e)){var m=n?n[l]:void 0;i.splice(c,0,e),n&&n.splice(c,0,m),i.splice(c<=l?l+1:l,1),n&&n.splice(c<=l?l+1:l,1)}}},o}),{isClass:!0}),Wu="matrix",Ju=W(Wu,["typed","Matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,Matrix:r,DenseMatrix:n,SparseMatrix:i}=e;return t(Wu,{"":function(){return a([])},string:function(e){return a([],e)},"string, string":function(e,t){return a([],e,t)},Array:function(e){return a(e)},Matrix:function(e){return a(e,e.storage())},"Array | Matrix, string":a,"Array | Matrix, string, string":a});function a(e,t,r){if("dense"===t||"default"===t||void 0===t)return new n(e,r);if("sparse"===t)return new i(e,r);throw new TypeError("Unknown matrix type "+JSON.stringify(t)+".")}})),Yu=W("abs",["typed"],(e=>{var{typed:t}=e;return t("abs",{number:za,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},Fraction:function(e){return e.abs()},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.abs()}})})),Xu=W("algorithm01",["typed"],(e=>{var{typed:t}=e;return function(e,r,n,i){var a=e._data,o=e._size,s=e._datatype,u=r._values,c=r._index,l=r._ptr,f=r._size,p=r._datatype;if(o.length!==f.length)throw new Ue(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m,h,d=o[0],y=o[1],g="string"==typeof s&&s===p?s:void 0,v=g?t.find(n,[g,g]):n,x=[];for(m=0;m{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E,A=a&&l?[]:void 0,O=[],C=[],_=a&&l?[]:void 0,T=a&&l?[]:void 0,B=[],q=[];for(N=0;N{var{typed:t,DenseMatrix:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=i;"string"==typeof l&&(f=l,n=t.convert(n,f),h=t.find(i,[f,f]));for(var d=[],y=[],g=[],v=0;v{var{typed:t}=e;return function(e,n,i){var a,o=e._data,s=e._size,u=e._datatype,c=n._data,l=n._size,f=n._datatype,p=[];if(s.length!==l.length)throw new Ue(s.length,l.length);for(var m=0;m0?r(h,0,p,p[0],o,c):[];return e.createDenseMatrix({data:d,size:p,datatype:a})};function r(e,t,n,i,a,o){var s=[];if(t===n.length-1)for(var u=0;u{var{typed:t}=e;return function(e,n,i,a){var o,s=e._data,u=e._size,c=e._datatype,l=i;"string"==typeof c&&(o=c,n=t.convert(n,o),l=t.find(i,[o,o]));var f=u.length>0?r(l,0,u,u[0],s,n,a):[];return e.createDenseMatrix({data:f,size:$(u),datatype:o})};function r(e,t,n,i,a,o,s){var u=[];if(t===n.length-1)for(var c=0;c{var{typed:t,matrix:r,equalScalar:n,BigNumber:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=Qu({typed:t,equalScalar:n}),u=Ku({typed:t,DenseMatrix:a}),c=ec({typed:t}),l=tc({typed:t});return t("gcd",{"number, number":Ha,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var r=new i(0);!t.isZero();){var n=e.mod(t);e=t,t=n}return e.lt(r)?e.neg():e},"Fraction, Fraction":function(e,t){return e.gcd(t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return u(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return l(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return l(r(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,equalScalar:r}=e;return function(e,n,i,a){var o=e._data,s=e._size,u=e._datatype,c=n._values,l=n._index,f=n._ptr,p=n._size,m=n._datatype;if(s.length!==p.length)throw new Ue(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h,d=s[0],y=s[1],g=r,v=0,x=i;"string"==typeof u&&u===m&&(h=u,g=t.find(r,[h,h]),v=t.convert(0,h),x=t.find(i,[h,h]));for(var b=[],w=[],N=[],M=0;M{var{typed:t}=e;return function(e,r,n,i){var a=e._data,o=e._size,s=e._datatype,u=r._values,c=r._index,l=r._ptr,f=r._size,p=r._datatype;if(o.length!==f.length)throw new Ue(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m,h=o[0],d=o[1],y=0,g=n;"string"==typeof s&&s===p&&(m=s,y=t.convert(0,m),g=t.find(n,[m,m]));for(var v=[],x=0;x{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E=a&&l?[]:void 0,A=[],O=[],C=E?[]:void 0,_=E?[]:void 0,T=[],B=[];for(N=0;N{var{typed:t,equalScalar:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=r,d=0,y=i;"string"==typeof l&&(f=l,h=t.find(r,[f,f]),d=t.convert(0,f),n=t.convert(n,f),y=t.find(i,[f,f]));for(var g=[],v=[],x=[],b=0;b{var{typed:t,DenseMatrix:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=i;"string"==typeof l&&(f=l,n=t.convert(n,f),h=t.find(i,[f,f]));for(var d=[],y=[],g=[],v=0;v{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=nc({typed:t,equalScalar:n}),o=ic({typed:t}),s=ac({typed:t,equalScalar:n}),u=oc({typed:t,equalScalar:n}),c=sc({typed:t,DenseMatrix:i}),l=ec({typed:t}),f=tc({typed:t});return t("mod",{"number, number":Wa,"BigNumber, BigNumber":function(e,t){if(t.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return t.isZero()?e:e.mod(t)},"Fraction, Fraction":function(e,t){if(t.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return e.compare(0)>=0?e.mod(t):e.mod(t).add(t).mod(t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return f(e,t,this,!1)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return f(t,e,this,!0)},"Array, any":function(e,t){return f(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return f(r(t),e,this,!0).valueOf()}})})),cc=W("algorithm06",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._size,s=e._datatype,u=n._values,c=n._size,l=n._datatype;if(o.length!==c.length)throw new Ue(o.length,c.length);if(o[0]!==c[0]||o[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+c+")");var f,p=o[0],m=o[1],h=r,d=0,y=i;"string"==typeof s&&s===l&&(f=s,h=t.find(r,[f,f]),d=t.convert(0,f),y=t.find(i,[f,f]));for(var g=a&&u?[]:void 0,v=[],x=[],b=g?[]:void 0,w=[],N=[],M=0;M{var{typed:t,matrix:r,equalScalar:n,BigNumber:i}=e,a=Xu({typed:t}),o=nc({typed:t,equalScalar:n}),s=cc({typed:t,equalScalar:n}),u=oc({typed:t,equalScalar:n}),c=ec({typed:t}),l=tc({typed:t}),f="Complex number not supported in function nthRoot. Use nthRoots instead.";return t(lc,{number:function(e){return Ja(e,2)},"number, number":Ja,BigNumber:function(e){return p(e,new i(2))},Complex:function(e){throw new Error(f)},"Complex, number":function(e,t){throw new Error(f)},"BigNumber, BigNumber":p,"Array | Matrix":function(e){return this(e,2)},"SparseMatrix, SparseMatrix":function(e,t){if(1===t.density())return s(e,t,this);throw new Error("Root must be non-zero")},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){if(1===t.density())return a(e,t,this,!1);throw new Error("Root must be non-zero")},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){if(1===t.density())return u(t,e,this,!0);throw new Error("Root must be non-zero")},"number | BigNumber, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}});function p(e,t){var r=i.precision,n=i.clone({precision:r+2}),a=new i(0),o=new n(1),s=t.isNegative();if(s&&(t=t.neg()),t.isZero())throw new Error("Root must be non-zero");if(e.isNegative()&&!t.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(e.isZero())return s?new n(1/0):0;if(!e.isFinite())return s?a:e;var u=e.abs().pow(o.div(t));return u=e.isNeg()?u.neg():u,new i((s?o.div(u):u).toPrecision(r))}})),pc="xgcd",mc=W(pc,["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t(pc,{"number, number":function(e,t){var i=Qa(e,t);return"Array"===r.matrix?i:n(i)},"BigNumber, BigNumber":function(e,t){var a,o,s,u,c=new i(0),l=new i(1),f=c,p=l,m=l,h=c;if(!e.isInt()||!t.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!t.isZero();)o=e.div(t).floor(),s=e.mod(t),a=f,f=p.minus(o.times(f)),p=a,a=m,m=h.minus(o.times(m)),h=a,e=t,t=s;return u=e.lt(c)?[e.neg(),p.neg(),h.neg()]:[e,e.isZero()?0:p,h],"Array"===r.matrix?u:n(u)}})})),hc="bitAnd",dc=W(hc,["typed","matrix","equalScalar"],(e=>{var{typed:t,matrix:r,equalScalar:n}=e,i=nc({typed:t,equalScalar:n}),a=cc({typed:t,equalScalar:n}),o=oc({typed:t,equalScalar:n}),s=ec({typed:t}),u=tc({typed:t});return t(hc,{"number, number":So,"BigNumber, BigNumber":ho,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),yc=W("algorithm07",["typed","DenseMatrix"],(e=>{var{typed:t,DenseMatrix:r}=e;return function(e,i,a){var o=e._size,s=e._datatype,u=i._size,c=i._datatype;if(o.length!==u.length)throw new Ue(o.length,u.length);if(o[0]!==u[0]||o[1]!==u[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+u+")");var l,f,p,m=o[0],h=o[1],d=0,y=a;"string"==typeof s&&s===c&&(l=s,d=t.convert(0,l),y=t.find(a,[l,l]));var g=[];for(f=0;f{var{typed:t,matrix:r,DenseMatrix:n}=e,i=ic({typed:t}),a=yc({typed:t,DenseMatrix:n}),o=sc({typed:t,DenseMatrix:n}),s=ec({typed:t}),u=tc({typed:t});return t(gc,{"number, number":Oo,"BigNumber, BigNumber":bo,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),xc=W("or",["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=ic({typed:t}),o=ac({typed:t,equalScalar:n}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t("or",{"number, number":Ro,"Complex, Complex":function(e,t){return 0!==e.re||0!==e.im||0!==t.re||0!==t.im},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!e.isNaN()||!t.isZero()&&!t.isNaN()},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})})),bc="diag",wc=W(bc,["typed","matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:r,DenseMatrix:n,SparseMatrix:i}=e;return t(bc,{Array:function(e){return a(e,0,je(e),null)},"Array, number":function(e,t){return a(e,t,je(e),null)},"Array, BigNumber":function(e,t){return a(e,t.toNumber(),je(e),null)},"Array, string":function(e,t){return a(e,0,je(e),t)},"Array, number, string":function(e,t,r){return a(e,t,je(e),r)},"Array, BigNumber, string":function(e,t,r){return a(e,t.toNumber(),je(e),r)},Matrix:function(e){return a(e,0,e.size(),e.storage())},"Matrix, number":function(e,t){return a(e,t,e.size(),e.storage())},"Matrix, BigNumber":function(e,t){return a(e,t.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,t){return a(e,0,e.size(),t)},"Matrix, number, string":function(e,t,r){return a(e,t,e.size(),r)},"Matrix, BigNumber, string":function(e,t,r){return a(e,t.toNumber(),e.size(),r)}});function a(e,t,a,o){if(!ce(t))throw new TypeError("Second parameter in function diag must be an integer");var s=t>0?t:0,u=t<0?-t:0;switch(a.length){case 1:return function(e,t,r,a,o,s){var u=[a+o,a+s];if(r&&"sparse"!==r&&"dense"!==r)throw new TypeError("Unknown matrix type ".concat(r,'"'));var c="sparse"===r?i.diagonal(u,e,t):n.diagonal(u,e,t);return null!==r?c:c.valueOf()}(e,t,o,a[0],u,s);case 2:return function(e,t,n,i,a,o){if(f(e)){var s=e.diagonal(t);return null!==n?n!==s.storage()?r(s,n):s:s.valueOf()}for(var u=Math.min(i[0]-a,i[1]-o),c=[],l=0;l{var{typed:t,config:r,matrix:n,BigNumber:i,DenseMatrix:o,SparseMatrix:s}=e;return t(Nc,{"":function(){return"Matrix"===r.matrix?n([]):[]},string:function(e){return n(e)},"number | BigNumber":function(e){return c(e,e,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, string":function(e,t){return c(e,e,t)},"number | BigNumber, number | BigNumber":function(e,t){return c(e,t,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(e,t,r){return c(e,t,r)},Array:function(e){return u(e)},"Array, string":function(e,t){return u(e,t)},Matrix:function(e){return u(e.valueOf(),e.storage())},"Matrix, string":function(e,t){return u(e.valueOf(),t)}});function u(e,t){switch(e.length){case 0:return t?n(t):[];case 1:return c(e[0],e[0],t);case 2:return c(e[0],e[1],t);default:throw new Error("Vector containing two values expected")}}function c(e,t,r){var n=a(e)||a(t)?i:null;if(a(e)&&(e=e.toNumber()),a(t)&&(t=t.toNumber()),!ce(e)||e<1)throw new Error("Parameters in function identity must be positive integers");if(!ce(t)||t<1)throw new Error("Parameters in function identity must be positive integers");var u=n?new i(1):1,c=n?new n(0):0,l=[e,t];if(r){if("sparse"===r)return s.diagonal(l,u,0,c);if("dense"===r)return o.diagonal(l,u,0,c);throw new TypeError('Unknown matrix type "'.concat(r,'"'))}for(var f=Ge([],l,c),p=e{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t("ones",{"":function(){return"Array"===r.matrix?o([]):o([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return o(e,t)}return"Array"===r.matrix?o(e):o(e,"default")},Array:o,Matrix:function(e){var t=e.storage();return o(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return o(e.valueOf(),t)}});function o(e,t){var r=function(e){var t=!1;return e.forEach((function(e,r,n){a(e)&&(t=!0,n[r]=e.toNumber())})),t}(e)?new i(1):1;if(function(e){e.forEach((function(e){if("number"!=typeof e||!ce(e)||e<0)throw new Error("Parameters in function ones must be positive integers")}))}(e),t){var o=n(t);return e.length>0?o.resize(e,r):o}var s=[];return e.length>0?Ge(s,e,r):s}})),Ec="reshape",Ac=W(Ec,["typed","isInteger","matrix"],(e=>{var{typed:t,isInteger:r}=e;return t(Ec,{"Matrix, Array":function(e,t){return e.reshape(t)},"Array, Array":function(e,t){return t.forEach((function(e){if(!r(e))throw new TypeError("Invalid size for dimension: "+e)})),Ve(e,t)}})})),Oc="size",Cc=W(Oc,["typed","config","?matrix"],(e=>{var{typed:t,config:r,matrix:n}=e;return t(Oc,{Matrix:function(e){return e.create(e.size())},Array:je,string:function(e){return"Array"===r.matrix?[e.length]:n([e.length])},"number | Complex | BigNumber | Unit | boolean | null":function(e){return"Array"===r.matrix?[]:n?n([]):nr()}})})),_c="zeros",Tc=W(_c,["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t(_c,{"":function(){return"Array"===r.matrix?o([]):o([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return o(e,t)}return"Array"===r.matrix?o(e):o(e,"default")},Array:o,Matrix:function(e){var t=e.storage();return o(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return o(e.valueOf(),t)}});function o(e,t){var r=function(e){var t=!1;return e.forEach((function(e,r,n){a(e)&&(t=!0,n[r]=e.toNumber())})),t}(e)?new i(0):0;if(function(e){e.forEach((function(e){if("number"!=typeof e||!ce(e)||e<0)throw new Error("Parameters in function zeros must be positive integers")}))}(e),t){var o=n(t);return e.length>0?o.resize(e,r):o}var s=[];return e.length>0?Ge(s,e,r):s}})),Bc=W("hex",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("hex",{"number | BigNumber":function(e){return r(e,{notation:"hex"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"hex",wordSize:t})}})}));function qc(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function zc(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Dc(e){for(var t=1;t{var{typed:t,matrix:r,equalScalar:n,zeros:i,BigNumber:a,DenseMatrix:o}=e,s=oc({typed:t,equalScalar:n}),u=sc({typed:t,DenseMatrix:o}),c=tc({typed:t});return t(kc,Dc(Dc({},Fc),{},{Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw new TypeError(Ic);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(Ic);var r=t.toNumber();return e.round(r)},"number, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(Ic);return new a(e).toDecimalPlaces(t.toNumber())},BigNumber:function(e){return e.toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(Ic);return e.toDecimalPlaces(t.toNumber())},Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw new TypeError(Ic);return e.round(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"SparseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | Complex | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):u(t,e,this,!0)},"number | Complex | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return c(r(e),t,this,!1).valueOf()},"number | Complex | BigNumber, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}}))})),Fc={number:eo,"number, number":function(e,t){if(!ce(t))throw new TypeError(Ic);if(t<0||t>15)throw new Error("Number of decimals in function round must be in the range of 0-15");return eo(e,t)}},Uc=W("algorithm08",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");if(!a||!l)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));for(var w,N,M,S,E=[],A=[],O=[],C=[],_=[],T=0;T{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=nc({typed:t,equalScalar:n}),u=Uc({typed:t,equalScalar:n}),c=Ku({typed:t,DenseMatrix:a}),l=oc({typed:t,equalScalar:n}),f=ec({typed:t}),p=tc({typed:t});return t(Pc,{"number, number":Co,"BigNumber, BigNumber":wo,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Lc="rightLogShift",Hc=W(Lc,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=nc({typed:t,equalScalar:n}),u=Uc({typed:t,equalScalar:n}),c=Ku({typed:t,DenseMatrix:a}),l=oc({typed:t,equalScalar:n}),f=ec({typed:t}),p=tc({typed:t});return t(Lc,{"number, number":To,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})})),$c="compare",Gc=W($c,["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],(e=>{var{typed:t,config:r,equalScalar:n,matrix:i,BigNumber:a,Fraction:o,DenseMatrix:s}=e,u=ic({typed:t}),c=ac({typed:t,equalScalar:n}),l=sc({typed:t,DenseMatrix:s}),f=ec({typed:t}),p=tc({typed:t});return t($c,{"boolean, boolean":function(e,t){return e===t?0:e>t?1:-1},"number, number":function(e,t){return Se(e,t,r.epsilon)?0:e>t?1:-1},"BigNumber, BigNumber":function(e,t){return Na(e,t,r.epsilon)?new a(0):new a(e.cmp(t))},"Fraction, Fraction":function(e,t){return new o(e.compare(t))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return c(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(i(e),i(t)).valueOf()},"Array, Matrix":function(e,t){return this(i(e),t)},"Matrix, Array":function(e,t){return this(e,i(t))},"SparseMatrix, any":function(e,t){return l(e,t,this,!1)},"DenseMatrix, any":function(e,t){return p(e,t,this,!1)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(i(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(i(t),e,this,!0).valueOf()}})})),Zc="compareText",Vc=W(Zc,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e,n=ec({typed:t}),i=tc({typed:t});return t(Zc,{"any, any":Fe,"DenseMatrix, DenseMatrix":function(e,t){return n(e,t,Fe)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"DenseMatrix, any":function(e,t){return i(e,t,Fe,!1)},"any, DenseMatrix":function(e,t){return i(t,e,Fe,!0)},"Array, any":function(e,t){return i(r(e),t,Fe,!1).valueOf()},"any, Array":function(e,t){return i(r(t),e,Fe,!0).valueOf()}})})),Wc="smaller",Jc=W(Wc,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Wc,{"boolean, boolean":function(e,t){return e{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Yc,{"boolean, boolean":function(e,t){return e>t},"number, number":function(e,t){return e>t&&!Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gt(t)&&!Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return 1===e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),Qc="unequal",Kc=W(Qc,["typed","config","equalScalar","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,equalScalar:n,matrix:i,DenseMatrix:a}=e,o=ic({typed:t}),s=yc({typed:t,DenseMatrix:a}),u=sc({typed:t,DenseMatrix:a}),c=ec({typed:t}),l=tc({typed:t});return t("unequal",{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:f(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,f)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,f,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,f,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,f)},"Array, Array":function(e,t){return this(i(e),i(t)).valueOf()},"Array, Matrix":function(e,t){return this(i(e),t)},"Matrix, Array":function(e,t){return this(e,i(t))},"SparseMatrix, any":function(e,t){return u(e,t,f,!1)},"DenseMatrix, any":function(e,t){return l(e,t,f,!1)},"any, SparseMatrix":function(e,t){return u(t,e,f,!0)},"any, DenseMatrix":function(e,t){return l(t,e,f,!0)},"Array, any":function(e,t){return l(i(e),t,f,!1).valueOf()},"any, Array":function(e,t){return l(i(t),e,f,!0).valueOf()}});function f(e,t){return!n(e,t)}})),el=(W(Qc,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return t(Qc,{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:!r(e,t)}})})),W("ImmutableDenseMatrix",["smaller","DenseMatrix"],(e=>{var{smaller:t,DenseMatrix:r}=e;function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!c(t))throw new Error("Invalid datatype: "+t);if(f(e)||l(e)){var i=new r(e,t);this._data=i._data,this._size=i._size,this._datatype=i._datatype,this._min=null,this._max=null}else if(e&&l(e.data)&&l(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=void 0!==e.min?e.min:null,this._max=void 0!==e.max?e.max:null;else{if(e)throw new TypeError("Unsupported type of data ("+L(e)+")");this._data=[],this._size=[0],this._datatype=t,this._min=null,this._max=null}}return n.prototype=new r,n.prototype.type="ImmutableDenseMatrix",n.prototype.isImmutableDenseMatrix=!0,n.prototype.subset=function(e){switch(arguments.length){case 1:var t=r.prototype.subset.call(this,e);return f(t)?new n({data:t._data,size:t._size,datatype:t._datatype}):t;case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},n.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},n.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},n.prototype.clone=function(){return new n({data:$(this._data),size:$(this._size),datatype:this._datatype})},n.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.fromJSON=function(e){return new n(e)},n.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},n.prototype.min=function(){if(null===this._min){var e=null;this.forEach((function(r){(null===e||t(r,e))&&(e=r)})),this._min=null!==e?e:void 0}return this._min},n.prototype.max=function(){if(null===this._max){var e=null;this.forEach((function(r){(null===e||t(e,r))&&(e=r)})),this._max=null!==e?e:void 0}return this._max},n}),{isClass:!0})),tl=W("FibonacciHeap",["smaller","larger"],(e=>{var{smaller:t,larger:r}=e,n=1/Math.log((1+Math.sqrt(5))/2);function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}function a(e,t,r){t.left.right=t.right,t.right.left=t.left,r.degree--,r.child===t&&(r.child=t.right),0===r.degree&&(r.child=null),t.left=e,t.right=e.right,e.right=t,t.right.left=t,t.parent=null,t.mark=!1}function o(e,t){var r=t.parent;r&&(t.mark?(a(e,t,r),o(r)):t.mark=!0)}i.prototype.type="FibonacciHeap",i.prototype.isFibonacciHeap=!0,i.prototype.insert=function(e,r){var n={key:e,value:r,degree:0};if(this._minimum){var i=this._minimum;n.left=i,n.right=i.right,i.right=n,n.right.left=n,t(e,i.key)&&(this._minimum=n)}else n.left=n,n.right=n,this._minimum=n;return this._size++,n},i.prototype.size=function(){return this._size},i.prototype.clear=function(){this._minimum=null,this._size=0},i.prototype.isEmpty=function(){return 0===this._size},i.prototype.extractMinimum=function(){var e=this._minimum;if(null===e)return e;for(var i=this._minimum,a=e.degree,o=e.child;a>0;){var u=o.right;o.left.right=o.right,o.right.left=o.left,o.left=i,o.right=i.right,i.right=o,o.right.left=o,o.parent=null,o=u,a--}return e.left.right=e.right,e.right.left=e.left,i=e===e.right?null:function(e,i){var a,o=Math.floor(Math.log(i)*n)+1,u=new Array(o),c=0,l=e;if(l)for(c++,l=l.right;l!==e;)c++,l=l.right;for(;c>0;){for(var f=l.degree,p=l.right;a=u[f];){if(r(l.key,a.key)){var m=a;a=l,l=m}s(a,l),u[f]=null,f++}u[f]=l,l=p,c--}e=null;for(var h=0;h{var{typed:t,SparseMatrix:r}=e;return t(rl,{"":function(){return new r([])},string:function(e){return new r([],e)},"Array | Matrix":function(e){return new r(e)},"Array | Matrix, string":function(e,t){return new r(e,t)}})})),il="acoth",al=W(il,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(il,{number:function(e){return e>=1||e<=-1||r.predictable?ms(e):new n(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new i(1).div(e).atanh()},"Array | Matrix":function(e){return $t(e,this)}})})),ol=W("algorithm09",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E,A=a&&l?[]:void 0,O=[],C=[],_=A?[]:void 0,T=[];for(N=0;N{var{typed:t,matrix:r,equalScalar:n,BigNumber:i,DenseMatrix:a}=e,o=nc({typed:t,equalScalar:n}),s=ic({typed:t}),u=ol({typed:t,equalScalar:n}),c=oc({typed:t,equalScalar:n}),l=sc({typed:t,DenseMatrix:a}),f=ec({typed:t}),p=tc({typed:t});return t(sl,{"number, number":Math.atan2,"BigNumber, BigNumber":function(e,t){return i.atan2(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return l(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return p(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return p(r(t),e,this,!0).valueOf()}})})),cl=W("sec",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("sec",{number:Ss,Complex:function(e){return e.sec()},BigNumber:function(e){return new r(1).div(e.cos())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),ll=W("add",["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:r,addScalar:n,equalScalar:i,DenseMatrix:a,SparseMatrix:o}=e,s=Xu({typed:t}),u=Qu({typed:t,equalScalar:i}),c=Ku({typed:t,DenseMatrix:a}),l=ec({typed:t}),f=tc({typed:t});return t("add",G({"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,n)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,n,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,n,!0)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,n)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"DenseMatrix, any":function(e,t){return f(e,t,n,!1)},"SparseMatrix, any":function(e,t){return c(e,t,n,!1)},"any, DenseMatrix":function(e,t){return f(t,e,n,!0)},"any, SparseMatrix":function(e,t){return c(t,e,n,!0)},"Array, any":function(e,t){return f(r(e),t,n,!1).valueOf()},"any, Array":function(e,t){return f(r(t),e,n,!0).valueOf()},"any, any":n,"any, any, ...any":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,addScalar:r,multiplyScalar:n,conj:i,size:a}=e;return t("dot",{"Array | DenseMatrix, Array | DenseMatrix":function(e,a){var u=o(e,a),c=f(e)?e._data:e,l=f(e)?e._datatype:void 0,p=f(a)?a._data:a,m=f(a)?a._datatype:void 0,h=2===s(e).length,d=2===s(a).length,y=r,g=n;if(l&&m&&l===m&&"string"==typeof l){var v=l;y=t.find(r,[v,v]),g=t.find(n,[v,v])}if(!h&&!d){for(var x=g(i(c[0]),p[0]),b=1;bd?m++:h===d&&(c=l(c,f(a[p],u[m])),p++,m++)}return c}});function o(e,t){var r,n,i=s(e),a=s(t);if(1===i.length)r=i[0];else{if(2!==i.length||1!==i[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+i.join(", ")+")");r=i[0]}if(1===a.length)n=a[0];else{if(2!==a.length||1!==a[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+a.join(", ")+")");n=a[0]}if(r!==n)throw new RangeError("Vectors must have equal length ("+r+" != "+n+")");if(0===r)throw new RangeError("Cannot calculate the dot product of empty vectors");return r}function s(e){return f(e)?e.size():a(e)}})),pl="composition",ml=W(pl,["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],(e=>{var{typed:t,addScalar:r,combinations:n,isPositive:i,isNegative:a,isInteger:o,larger:s}=e;return t(pl,{"number | BigNumber, number | BigNumber":function(e,t){if(!(o(e)&&i(e)&&o(t)&&i(t)))throw new TypeError("Positive integer value expected in function composition");if(s(t,e))throw new TypeError("k must be less than or equal to n in function composition");return n(r(e,-1),r(t,-1))}})})),hl="isZero",dl=W(hl,["typed"],(e=>{var{typed:t}=e;return t(hl,{number:ya,BigNumber:function(e){return e.isZero()},Complex:function(e){return 0===e.re&&0===e.im},Fraction:function(e){return 1===e.d&&0===e.n},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),yl="matrixFromFunction",gl=W(yl,["typed","matrix","isZero"],(e=>{var{typed:t,matrix:r,isZero:n}=e;return t(yl,{"Array | Matrix, function, string, string":function(e,t,r,n){return i(e,t,r,n)},"Array | Matrix, function, string":function(e,t,r){return i(e,t,r)},"Matrix, function":function(e,t){return i(e,t,"dense")},"Array, function":function(e,t){return i(e,t,"dense").toArray()},"Array | Matrix, string, function":function(e,t,r){return i(e,r,t)},"Array | Matrix, string, string, function":function(e,t,r,n){return i(e,n,t,r)}});function i(e,t,i,a){var o;return(o=void 0!==a?r(i,a):r(i)).resize(e),o.forEach((function(e,r){var i=t(r);n(i)||o.set(r,i)})),o}})),vl="cbrt",xl=W(vl,["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],(e=>{var{config:t,typed:r,isNegative:n,unaryMinus:i,matrix:u,Complex:c,BigNumber:l,Fraction:f}=e;return r(vl,{number:Fa,Complex:p,"Complex, boolean":p,BigNumber:function(e){return e.cbrt()},Unit:function(e){if(e.value&&o(e.value)){var t=e.clone();return t.value=1,(t=t.pow(1/3)).value=p(e.value),t}var r,u=n(e.value);u&&(e.value=i(e.value)),r=a(e.value)?new l(1).div(3):s(e.value)?new f(1,3):1/3;var c=e.pow(r);return u&&(c.value=i(c.value)),c},"Array | Matrix":function(e){return $t(e,this,!0)}});function p(e,r){var n=e.arg()/3,i=e.abs(),a=new c(Fa(i),0).mul(new c(0,n).exp());if(r){var o=[a,new c(Fa(i),0).mul(new c(0,n+2*Math.PI/3).exp()),new c(Fa(i),0).mul(new c(0,n-2*Math.PI/3).exp())];return"Array"===t.matrix?o:u(o)}return a}})),bl=W("floor",["typed","config","round","matrix","equalScalar"],(e=>{var{typed:t,config:r,round:n,matrix:i,equalScalar:a}=e,o=oc({typed:t,equalScalar:a}),s=tc({typed:t});return t("floor",{number:function(e){return Se(e,n(e),r.epsilon)?n(e):Math.floor(e)},"number, number":function(e,t){if(Se(e,n(e,t),r.epsilon))return n(e,t);var[i,a]="".concat(e,"e").split("e"),o=Math.floor(Number("".concat(i,"e").concat(Number(a)+t)));return[i,a]="".concat(o,"e").split("e"),Number("".concat(i,"e").concat(Number(a)-t))},Complex:function(e){return e.floor()},"Complex, number":function(e,t){return e.floor(t)},BigNumber:function(e){return Na(e,n(e),r.epsilon)?n(e):e.floor()},"BigNumber, BigNumber":function(e,t){return Na(e,n(e,t),r.epsilon)?n(e,t):e.toDecimalPlaces(t.toNumber(),Qn.ROUND_FLOOR)},Fraction:function(e){return e.floor()},"Fraction, number":function(e,t){return e.floor(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"Array | Matrix, number":function(e,t){return $t(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"number | Complex | BigNumber, Array":function(e,t){return s(i(t),e,this,!0).valueOf()}})})),wl="multiply",Nl=W(wl,["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],(e=>{var{typed:t,matrix:r,addScalar:n,multiplyScalar:i,equalScalar:a,dot:o}=e,s=oc({typed:t,equalScalar:a}),u=tc({typed:t});function c(e,t){switch(e.length){case 1:switch(t.length){case 1:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;case 2:switch(t.length){case 1:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+t[0]+")");break;case 2:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}}var l=t("_multiplyMatrixVector",{"DenseMatrix, any":function(e,r){var a,o=e._data,s=e._size,u=e._datatype,c=r._data,l=r._datatype,f=s[0],p=s[1],m=n,h=i;u&&l&&u===l&&"string"==typeof u&&(a=u,m=t.find(n,[a,a]),h=t.find(i,[a,a]));for(var d=[],y=0;yA)for(var C=0,_=0;_{var{typed:t,matrix:r,equalScalar:n,multiplyScalar:i}=e,a=nc({typed:t,equalScalar:n}),o=ol({typed:t,equalScalar:n}),s=oc({typed:t,equalScalar:n}),u=ec({typed:t}),c=tc({typed:t});return t(Ml,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,i)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,i,!1)},"DenseMatrix, any":function(e,t){return c(e,t,i,!1)},"any, SparseMatrix":function(e,t){return s(t,e,i,!0)},"any, DenseMatrix":function(e,t){return c(t,e,i,!0)},"Array, any":function(e,t){return c(r(e),t,i,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,i,!0).valueOf()}})})),El=W("re",["typed"],(e=>{var{typed:t}=e;return t("re",{number:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Complex:function(e){return e.re},"Array | Matrix":function(e){return $t(e,this)}})})),Al="flatten",Ol=W(Al,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t(Al,{Array:function(e){return et($(e))},Matrix:function(e){var t=et($(e.toArray()));return r(t)}})}));function Cl(e,t,r,n){if(!(this instanceof Cl))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=t,this.min=r,this.max=n,this.message="Wrong number of arguments in function "+e+" ("+t+" provided, "+r+(null!=n?"-"+n:"")+" expected)",this.stack=(new Error).stack}Cl.prototype=new Error,Cl.prototype.constructor=Error,Cl.prototype.name="ArgumentsError",Cl.prototype.isArgumentsError=!0;var _l=W("resize",["config","matrix"],(e=>{var{config:t,matrix:r}=e;return function(e,i,o){if(2!==arguments.length&&3!==arguments.length)throw new Cl("resize",arguments.length,2,3);if(f(i)&&(i=i.valueOf()),a(i[0])&&(i=i.map((function(e){return a(e)?e.toNumber():e}))),f(e))return e.resize(i,o,!0);if("string"==typeof e)return n(e,i,o);var s=!Array.isArray(e)&&"Array"!==t.matrix;if(0===i.length){for(;Array.isArray(e);)e=e[0];return $(e)}Array.isArray(e)||(e=[e]);var u=Ge(e=$(e),i,o);return s?r(u):u};function n(e,t,r){if(void 0!==r){if("string"!=typeof r||1!==r.length)throw new TypeError("Single character expected as defaultValue")}else r=" ";if(1!==t.length)throw new Ue(t.length,1);var n=t[0];if("number"!=typeof n||!ce(n))throw new TypeError("Invalid size, must contain positive integers (size: "+De(t)+")");if(e.length>n)return e.substring(0,n);if(e.length{var{typed:t,matrix:r}=e;return t(Tl,{Array:function(e){return Ye($(e))},Matrix:function(e){var t=Ye(e.toArray());return Array.isArray(t)?r(t):t},any:function(e){return $(e)}})})),ql=W("to",["typed","matrix"],(e=>{var{typed:t,matrix:r}=e,n=ec({typed:t}),i=tc({typed:t});return t("to",{"Unit, Unit | string":function(e,t){return e.to(t)},"Matrix, Matrix":function(e,t){return n(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"Matrix, any":function(e,t){return i(e,t,this,!1)},"any, Matrix":function(e,t){return i(t,e,this,!0)},"Array, any":function(e,t){return i(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return i(r(t),e,this,!0).valueOf()}})})),zl=W("pow",["typed","config","identity","multiply","matrix","fraction","number","Complex"],(e=>{var{typed:t,config:r,identity:n,multiply:i,matrix:a,number:o,fraction:s,Complex:u}=e;return t("pow",{"number, number":c,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(e,t){return t.isInteger()||e>=0||r.predictable?e.pow(t):new u(e.toNumber(),0).pow(t.toNumber(),0)},"Fraction, Fraction":function(e,t){var n=e.pow(t);if(null!=n)return n;if(r.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return c(e.valueOf(),t.valueOf())},"Array, number":l,"Array, BigNumber":function(e,t){return l(e,t.toNumber())},"Matrix, number":f,"Matrix, BigNumber":function(e,t){return f(e,t.toNumber())},"Unit, number | BigNumber":function(e,t){return e.pow(t)}});function c(e,t){if(r.predictable&&!ce(t)&&e<0)try{var n=s(t),i=o(n);if((t===i||Math.abs((t-i)/t)<1e-14)&&n.d%2==1)return(n.n%2==0?1:-1)*Math.pow(-e,t)}catch(e){}return r.predictable&&(e<-1&&t===1/0||e>-1&&e<0&&t===-1/0)?NaN:ce(t)||e>=0||r.predictable?Ka(e,t):e*e<1&&t===1/0||e*e>1&&t===-1/0?0:new u(e,0).pow(t,0)}function l(e,t){if(!ce(t)||t<0)throw new TypeError("For A^b, b must be a positive integer (value is "+t+")");var r=je(e);if(2!==r.length)throw new Error("For A^b, A must be 2 dimensional (A has "+r.length+" dimensions)");if(r[0]!==r[1])throw new Error("For A^b, A must be square (size is "+r[0]+"x"+r[1]+")");for(var a=n(r[0]).valueOf(),o=e;t>=1;)1==(1&t)&&(a=i(o,a)),t>>=1,o=i(o,o);return a}function f(e,t){return a(l(e.valueOf(),t))}})),Dl="dotPow",Il=W(Dl,["typed","equalScalar","matrix","pow","DenseMatrix"],(e=>{var{typed:t,equalScalar:r,matrix:n,pow:i,DenseMatrix:a}=e,o=ic({typed:t}),s=yc({typed:t,DenseMatrix:a}),u=oc({typed:t,equalScalar:r}),c=sc({typed:t,DenseMatrix:a}),l=ec({typed:t}),f=tc({typed:t});return t(Dl,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,i)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return f(e,t,this,!1)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return f(t,e,this,!0)},"Array, any":function(e,t){return f(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return f(n(t),e,this,!0).valueOf()}})})),kl="rightArithShift",Rl=W(kl,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=nc({typed:t,equalScalar:n}),u=Uc({typed:t,equalScalar:n}),c=Ku({typed:t,DenseMatrix:a}),l=oc({typed:t,equalScalar:n}),f=ec({typed:t}),p=tc({typed:t});return t(kl,{"number, number":_o,"BigNumber, BigNumber":No,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Fl=r(228),Ul="compareNatural",Pl=W(Ul,["typed","compare"],(e=>{var{typed:t,compare:r}=e,n=r.signatures["boolean,boolean"];return t(Ul,{"any, any":function(e,t){var o,s=L(e),u=L(t);if(!("number"!==s&&"BigNumber"!==s&&"Fraction"!==s||"number"!==u&&"BigNumber"!==u&&"Fraction"!==u))return"0"!==(o=r(e,t)).toString()?o>0?1:-1:Fl(s,u);if("Array"===s||"Matrix"===s||"Array"===u||"Matrix"===u)return 0!==(o=i(this,e,t))?o:Fl(s,u);if(s!==u)return Fl(s,u);if("Complex"===s)return function(e,t){return e.re>t.re?1:e.ret.im?1:e.imr.length?1:t.length{var{typed:t,compareText:r,isZero:n}=e;return t(jl,{"any, any":function(e,t){return n(r(e,t))}})})),Hl="largerEq",$l=W(Hl,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Hl,{"boolean, boolean":function(e,t){return e>=t},"number, number":function(e,t){return e>=t||Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gte(t)||Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return-1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),Gl="partitionSelect",Zl=W(Gl,["typed","isNumeric","isNaN","compare"],(e=>{var{typed:t,isNumeric:r,isNaN:n,compare:i}=e,a=i,o=(e,t)=>-i(e,t);return t(Gl,{"Array | Matrix, number":function(e,t){return s(e,t,a)},"Array | Matrix, number, string":function(e,t,r){if("asc"===r)return s(e,t,a);if("desc"===r)return s(e,t,o);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":s});function s(e,t,r){if(!ce(t)||t<0)throw new Error("k must be a non-negative integer");if(f(e)){if(e.size().length>1)throw new Error("Only one dimensional matrices supported");return u(e.valueOf(),t,r)}if(Array.isArray(e))return u(e,t,r)}function u(e,t,i){if(t>=e.length)throw new Error("k out of bounds");for(var a=0;a=0){var f=e[c];e[c]=e[u],e[u]=f,--c}else++u;i(e[u],l)>0&&--u,t<=u?s=u:o=u+1}return e[t]}})),Vl=W("Index",["ImmutableDenseMatrix"],(e=>{var{ImmutableDenseMatrix:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var t=0,i=arguments.length;t{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(Wl,{number:function(e){if(e<=1&&e>=-1||r.predictable){var t=1/e;if(t>0||r.predictable)return gs(e);var i=Math.sqrt(t*t-1);return new n(Math.log(i-t),Math.PI)}return new n(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new i(1).div(e).acosh()},"Array | Matrix":function(e){return $t(e,this)}})})),Yl=W("tan",["typed"],(e=>{var{typed:t}=e;return t("tan",{number:Math.tan,Complex:function(e){return e.tan()},BigNumber:function(e){return e.tan()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Xl="setDifference",Ql=W(Xl,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Xl,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(0===n(r(e),new a(0)))s=[];else{if(0===n(r(t),new a(0)))return et(e.toArray());var u,c=ot(et(Array.isArray(e)?e:e.toArray()).sort(i)),l=ot(et(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var f=0;f{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Kl,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(0===n(r(e),new a(0))||0===n(r(t),new a(0)))s=[];else{var u=ot(et(Array.isArray(e)?e:e.toArray()).sort(i)),c=ot(et(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var l=0;l{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(tf,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,t){if(0===n(r(t),new a(0)))return 0;for(var o=et(Array.isArray(t)?t:t.toArray()),s=0,u=0;u{var{typed:t,compareNatural:r}=e;return t(nf,{"Array | Matrix":function(e){return Array.isArray(e)?et(e).length:et(e.toArray()).length},"Array | Matrix, boolean":function(e,t){if(!1===t||0===e.length)return Array.isArray(e)?et(e).length:et(e.toArray()).length;for(var n=et(Array.isArray(e)?e:e.toArray()).sort(r),i=1,a=1;a{var{typed:t,matrix:r,add:n}=e;return t("trace",{Array:function(e){return i(r(e))},SparseMatrix:function(e){var t=e._values,r=e._index,i=e._ptr,a=e._size,o=a[0],s=a[1];if(o===s){var u=0;if(t.length>0)for(var c=0;cc)break}return u}throw new RangeError("Matrix must be square (size: "+De(a)+")")},DenseMatrix:i,any:$});function i(e){var t=e._size,r=e._data;switch(t.length){case 1:if(1===t[0])return $(r[0]);throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:var i=t[0];if(i===t[1]){for(var a=0,o=0;o{var{typed:t,add:r,multiply:n,partitionSelect:o,compare:s}=e;function u(e,t,a){var u=et(e),l=u.length;if(0===l)throw new Error("Cannot calculate quantile of an empty sequence");if(i(t)){var f=t*(l-1),p=f%1;if(0===p){var m=a?u[f]:o(u,f);return c(m),m}var h,d,y=Math.floor(f);if(a)h=u[y],d=u[y+1];else{d=o(u,y+1),h=u[y];for(var g=0;g0&&(h=u[g])}return c(h),c(d),r(n(h,1-p),n(d,p))}var v=t.times(l-1);if(v.isInteger()){v=v.toNumber();var x=a?u[v]:o(u,v);return c(x),x}var b,w,N=v.floor(),M=v.minus(N),S=N.toNumber();if(a)b=u[S],w=u[S+1];else{w=o(u,S+1),b=u[S];for(var E=0;E0&&(b=u[E])}c(b),c(w);var A=new M.constructor(1);return r(n(b,A.minus(M)),n(w,M))}var c=t({"number | BigNumber | Unit":function(e){return e}});return function(e,t,r){var n,o,s;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(p(e)){if("boolean"==typeof(r=r||!1)){if(o=e.valueOf(),i(t)){if(t<0)throw new Error("N/prob must be non-negative");if(t<=1)return u(o,t,r);if(t>1){if(!ce(t))throw new Error("N must be a positive integer");var c=t+1;n=new Array(t);for(var l=0;l4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var h=new f(m+1);n=new Array(m);for(var d=0;d1)throw new Error("Probability must be between 0 and 1, inclusive")}else{if(!a(g))throw new TypeError("Unexpected type of argument in function quantileSeq");if(s=new g.constructor(1),g.isNegative()||g.gt(s))throw new Error("Probability must be between 0 and 1, inclusive")}n[y]=u(o,g,r)}return n}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}}));function uf(e){var t;if(ce(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:Js(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*uf(1-e));if(e>=171.35)return 1/0;if(e>85){var r=e*e,n=r*e,i=n*e,a=i*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*r)-139/(51840*n)-571/(2488320*i)+163879/(209018880*a)+5246819/(75246796800*a*e))}--e,t=lf[0];for(var o=1;o{var{typed:t,config:r,multiplyScalar:n,pow:i,BigNumber:a,Complex:o}=e;return t(ff,{number:uf,Complex:function(e){if(0===e.im)return this(e.re);e=new o(e.re-1,e.im);for(var t=new o(lf[0],0),r=1;r2;)u+=i-=2,o=o.times(u);return new a(o.toPrecision(a.precision))}})),mf=W("bignumber",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("bignumber",{"":function(){return new r(0)},number:function(e){return new r(e+"")},string:function(e){var t=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(t){var n=t[2],i=r(t[1]),a=new r(2).pow(Number(n));if(i.gt(a.sub(1)))throw new SyntaxError('String "'.concat(e,'" is out of range'));var o=new r(2).pow(Number(n)-1);return i.gte(o)?i.sub(a):i}return new r(e)},BigNumber:function(e){return e},Fraction:function(e){return new r(e.n).div(e.d).times(e.s)},null:function(e){return new r(0)},"Array | Matrix":function(e){return $t(e,this)}})})),hf="matrixFromColumns",df=W(hf,["typed","matrix","flatten","size"],(e=>{var{typed:t,matrix:r,flatten:n,size:i}=e;return t(hf,{"...Array":function(e){return a(e)},"...Matrix":function(e){return r(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one column is needed to construct a matrix.");for(var t=o(e[0]),r=[],i=0;i{var{typed:t,matrix:r,equalScalar:n}=e,i=nc({typed:t,equalScalar:n}),a=cc({typed:t,equalScalar:n}),o=oc({typed:t,equalScalar:n}),s=ec({typed:t}),u=tc({typed:t});return t("lcm",{"number, number":$a,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(e.isZero())return e;if(t.isZero())return t;for(var r=e.times(t);!t.isZero();){var n=t;t=e.mod(n),e=n}return r.div(e).abs()},"Fraction, Fraction":function(e,t){return e.lcm(t)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return o(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return u(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return u(r(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=Xu({typed:t}),o=Qu({typed:t,equalScalar:n}),s=Ku({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(gf,{"number, number":Ao,"BigNumber, BigNumber":go,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})})),xf="kron",bf=W(xf,["typed","matrix","multiplyScalar"],(e=>{var{typed:t,matrix:r,multiplyScalar:n}=e;return t(xf,{"Matrix, Matrix":function(e,t){return r(i(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(i(e.toArray(),t))},"Array, Matrix":function(e,t){return r(i(e,t.toArray()))},"Array, Array":i});function i(e,t){if(1===je(e).length&&(e=[e]),1===je(t).length&&(t=[t]),je(e).length>2||je(t).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(e.length)+", y = "+JSON.stringify(t.length)+")");var r=[],i=[];return e.map((function(e){return t.map((function(t){return i=[],r.push(i),e.map((function(e){return t.map((function(t){return i.push(n(e,t))}))}))}))}))&&r}})),wf=W("transpose",["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t("transpose",{Array:function(e){return this(r(e)).valueOf()},Matrix:function(e){var t,r=e.size();switch(r.length){case 1:t=e.clone();break;case 2:var n=r[0],i=r[1];if(0===i)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+De(r)+")");switch(e.storage()){case"dense":t=function(e,t,r){for(var n,i=e._data,a=[],o=0;o{var{number:t,bignumber:r,fraction:n}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},a={number:e=>t(e),BigNumber:r?e=>r(e):tr,Fraction:n?e=>n(e):rr};return function(e,t){var r=L(e);if(!(r in i))throw new TypeError("Cannot convert "+e+' of type "'+r+'"; valid input types are '+Object.keys(i).join(", "));if(!(t in a))throw new TypeError("Cannot convert "+e+' to type "'+t+'"; valid output types are '+Object.keys(a).join(", "));return t===r?e:a[t](e)}})),Mf=W("and",["typed","matrix","equalScalar","zeros","not"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,not:a}=e,o=nc({typed:t,equalScalar:n}),s=cc({typed:t,equalScalar:n}),u=oc({typed:t,equalScalar:n}),c=ec({typed:t}),l=tc({typed:t});return t("and",{"number, number":Uo,"Complex, Complex":function(e,t){return!(0===e.re&&0===e.im||0===t.re&&0===t.im)},"BigNumber, BigNumber":function(e,t){return!(e.isZero()||t.isZero()||e.isNaN()||t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return a(t)?i(e.size(),e.storage()):u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return a(t)?i(e.size(),e.storage()):l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return a(e)?i(e.size(),e.storage()):u(t,e,this,!0)},"any, DenseMatrix":function(e,t){return a(e)?i(e.size(),e.storage()):l(t,e,this,!0)},"Array, any":function(e,t){return this(r(e),t).valueOf()},"any, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Sf="smallerEq",Ef=W(Sf,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Sf,{"boolean, boolean":function(e,t){return e<=t},"number, number":function(e,t){return e<=t||Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.lte(t)||Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return 1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),Af="sort",Of=W(Af,["typed","matrix","compare","compareNatural"],(e=>{var{typed:t,matrix:r,compare:n,compareNatural:i}=e,a=n,o=(e,t)=>-n(e,t);return t(Af,{Array:function(e){return u(e),e.sort(a)},Matrix:function(e){return c(e),r(e.toArray().sort(a),e.storage())},"Array, function":function(e,t){return u(e),e.sort(t)},"Matrix, function":function(e,t){return c(e),r(e.toArray().sort(t),e.storage())},"Array, string":function(e,t){return u(e),e.sort(s(t))},"Matrix, string":function(e,t){return c(e),r(e.toArray().sort(s(t)),e.storage())}});function s(e){if("asc"===e)return a;if("desc"===e)return o;if("natural"===e)return i;throw new Error('String "asc", "desc", or "natural" expected')}function u(e){if(1!==je(e).length)throw new Error("One dimensional array expected")}function c(e){if(1!==e.size().length)throw new Error("One dimensional matrix expected")}})),Cf=W("cot",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("cot",{number:bs,Complex:function(e){return e.cot()},BigNumber:function(e){return new r(1).div(e.tan())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),_f="setDistinct",Tf=W(_f,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(_f,{"Array | Matrix":function(e){var t;if(0===n(r(e),new a(0)))t=[];else{var s=et(Array.isArray(e)?e:e.toArray()).sort(i);(t=[]).push(s[0]);for(var u=1;u{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(Bf,{"Array | Matrix":function(e){if(0===n(r(e),new a(0)))return[];for(var t=et(Array.isArray(e)?e:e.toArray()).sort(i),s=[],u=0;u.toString(2).length<=t.length;)s.push(o(t,u.toString(2).split("").reverse())),u++;return function(e){for(var t=[],r=e.length-1;r>0;r--)for(var n=0;ne[n+1].length&&(t=e[n],e[n]=e[n+1],e[n+1]=t);return e}(s)}});function o(e,t){for(var r=[],n=0;n{var{typed:t,Index:r}=e;return t(zf,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var t=e.map((function(e){return a(e)?e.toNumber():Array.isArray(e)||f(e)?e.map((function(e){return a(e)?e.toNumber():e})):e})),n=new r;return r.apply(n,t),n}})})),If="factorial",kf=W(If,["typed","gamma"],(e=>{var{typed:t,gamma:r}=e;return t(If,{number:function(e){if(e<0)throw new Error("Value must be non-negative");return r(e+1)},BigNumber:function(e){if(e.isNegative())throw new Error("Value must be non-negative");return r(e.plus(1))},"Array | Matrix":function(e){return $t(e,this)}})})),Rf="permutations",Ff=W(Rf,["typed","factorial"],(e=>{var{typed:t,factorial:r}=e;return t(Rf,{"number | BigNumber":r,"number, number":function(e,t){if(!ce(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!ce(t)||t<0)throw new TypeError("Positive integer value expected in function permutations");if(t>e)throw new TypeError("second argument k must be less than or equal to first argument n");return Js(e-t+1,e)},"BigNumber, BigNumber":function(e,t){var r,n;if(!Uf(e)||!Uf(t))throw new TypeError("Positive integer value expected in function permutations");if(t.gt(e))throw new TypeError("second argument k must be less than or equal to first argument n");for(r=e.mul(0).add(1),n=e.minus(t).plus(1);n.lte(e);n=n.plus(1))r=r.times(n);return r}})}));function Uf(e){return e.isInteger()&&e.gte(0)}var Pf="matrixFromRows",jf=W(Pf,["typed","matrix","flatten","size"],(e=>{var{typed:t,matrix:r,flatten:n,size:i}=e;return t(Pf,{"...Array":function(e){return a(e)},"...Matrix":function(e){return r(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one row is needed to construct a matrix.");var t=o(e[0]),r=[];for(var i of e){var a=o(i);if(a!==t)throw new TypeError("The vectors had different length: "+(0|t)+" ≠ "+(0|a));r.push(n(i))}return r}function o(e){var t=i(e);if(1===t.length)return t[0];if(2===t.length){if(1===t[0])return t[1];if(1===t[1])return t[0];throw new TypeError("At least one of the arguments is not a vector.")}throw new TypeError("Only one- or two-dimensional vectors are supported.")}})),Lf="subtract",Hf=W(Lf,["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,addScalar:i,unaryMinus:a,DenseMatrix:o}=e,s=Xu({typed:t}),u=ic({typed:t}),c=ac({typed:t,equalScalar:n}),l=Ku({typed:t,DenseMatrix:o}),f=ec({typed:t}),p=tc({typed:t});return t(Lf,{"number, number":function(e,t){return e-t},"Complex, Complex":function(e,t){return e.sub(t)},"BigNumber, BigNumber":function(e,t){return e.minus(t)},"Fraction, Fraction":function(e,t){return e.sub(t)},"Unit, Unit":function(e,t){if(null===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var r=e.clone();return r.value=this(r.value,t.value),r.fixPrefix=!1,r},"SparseMatrix, SparseMatrix":function(e,t){return $f(e,t),c(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return $f(e,t),u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return $f(e,t),s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return $f(e,t),f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return l(e,a(t),i)},"DenseMatrix, any":function(e,t){return p(e,t,this)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(r(t),e,this,!0).valueOf()}})}));function $f(e,t){var r=e.size(),n=t.size();if(r.length!==n.length)throw new Ue(r.length,n.length)}var Gf="cross",Zf=W(Gf,["typed","matrix","subtract","multiply"],(e=>{var{typed:t,matrix:r,subtract:n,multiply:i}=e;return t(Gf,{"Matrix, Matrix":function(e,t){return r(a(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(a(e.toArray(),t))},"Array, Matrix":function(e,t){return r(a(e,t.toArray()))},"Array, Array":a});function a(e,t){var r=Math.max(je(e).length,je(t).length);e=Ye(e),t=Ye(t);var a=je(e),o=je(t);if(1!==a.length||1!==o.length||3!==a[0]||3!==o[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+a.join(", ")+"], B = ["+o.join(", ")+"])");var s=[n(i(e[1],t[2]),i(e[2],t[1])),n(i(e[2],t[0]),i(e[0],t[2])),n(i(e[0],t[1]),i(e[1],t[0]))];return r>1?[s]:s}})),Vf="prod",Wf=W(Vf,["typed","config","multiplyScalar","numeric"],(e=>{var{typed:t,config:r,multiplyScalar:n,numeric:i}=e;return t(Vf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("prod(A, dim) is not yet supported")},"...":function(e){return a(e)}});function a(e){var t;if(Ht(e,(function(e){try{t=void 0===t?e:n(t,e)}catch(t){throw Gr(t,"prod",e)}})),"string"==typeof t&&(t=i(t,r.number)),void 0===t)throw new Error("Cannot calculate prod of an empty array");return t}})),Jf="equal",Yf=W(Jf,["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Jf,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:n(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,n)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,n,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,n,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,n)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,n,!1)},"DenseMatrix, any":function(e,t){return c(e,t,n,!1)},"any, SparseMatrix":function(e,t){return s(t,e,n,!0)},"any, DenseMatrix":function(e,t){return c(t,e,n,!0)},"Array, any":function(e,t){return c(r(e),t,n,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,n,!0).valueOf()}})})),Xf=(W(Jf,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return t(Jf,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:r(e,t)}})})),"setCartesian"),Qf=W(Xf,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Xf,{"Array | Matrix, Array | Matrix":function(e,t){var s=[];if(0!==n(r(e),new a(0))&&0!==n(r(t),new a(0))){var u=et(Array.isArray(e)?e:e.toArray()).sort(i),c=et(Array.isArray(t)?t:t.toArray()).sort(i);s=[];for(var l=0;l{var{typed:t,size:r,concat:n,subset:i,setDifference:a,Index:o}=e;return t(Kf,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new o(0)))return et(t);if(0===i(r(t),new o(0)))return et(e);var s=et(e),u=et(t);return n(a(s,u),a(u,s))}})})),tp=W("ceil",["typed","config","round","matrix","equalScalar"],(e=>{var{typed:t,config:r,round:n,matrix:i,equalScalar:a}=e,o=oc({typed:t,equalScalar:a}),s=tc({typed:t});return t("ceil",{number:function(e){return Se(e,n(e),r.epsilon)?n(e):Ua(e)},"number, number":function(e,t){if(Se(e,n(e,t),r.epsilon))return n(e,t);var[i,a]="".concat(e,"e").split("e"),o=Math.ceil(Number("".concat(i,"e").concat(Number(a)+t)));return[i,a]="".concat(o,"e").split("e"),Number("".concat(i,"e").concat(Number(a)-t))},Complex:function(e){return e.ceil()},"Complex, number":function(e,t){return e.ceil(t)},BigNumber:function(e){return Na(e,n(e),r.epsilon)?n(e):e.ceil()},"BigNumber, BigNumber":function(e,t){return Na(e,n(e,t),r.epsilon)?n(e,t):e.toDecimalPlaces(t.toNumber(),Qn.ROUND_CEIL)},Fraction:function(e){return e.ceil()},"Fraction, number":function(e,t){return e.ceil(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"Array | Matrix, number":function(e,t){return $t(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"number | Complex | BigNumber, Array":function(e,t){return s(i(t),e,this,!0).valueOf()}})})),rp=W("xor",["typed","matrix","DenseMatrix"],(e=>{var{typed:t,matrix:r,DenseMatrix:n}=e,i=ic({typed:t}),a=yc({typed:t,DenseMatrix:n}),o=sc({typed:t,DenseMatrix:n}),s=ec({typed:t}),u=tc({typed:t});return t("xor",{"number, number":Fo,"Complex, Complex":function(e,t){return(0!==e.re||0!==e.im)!=(0!==t.re||0!==t.im)},"BigNumber, BigNumber":function(e,t){return(!e.isZero()&&!e.isNaN())!=(!t.isZero()&&!t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),np="count",ip=W(np,["typed","size","prod"],(e=>{var{typed:t,size:r,prod:n}=e;return t(np,{string:function(e){return e.length},"Matrix | Array":function(e){return n(r(e))}})})),ap="ctranspose",op=W(ap,["typed","transpose","conj"],(e=>{var{typed:t,transpose:r,conj:n}=e;return t(ap,{any:function(e){return n(r(e))}})})),sp="deepEqual",up=W(sp,["typed","equal"],(e=>{var{typed:t,equal:r}=e;return t(sp,{"any, any":function(e,t){return n(e.valueOf(),t.valueOf())}});function n(e,t){if(Array.isArray(e)){if(Array.isArray(t)){var i=e.length;if(i!==t.length)return!1;for(var a=0;a{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(cp,{"Array | Matrix, Array | Matrix":function(e,t){if(0===n(r(e),new a(0)))return!0;if(0===n(r(t),new a(0)))return!1;for(var o,s=ot(et(Array.isArray(e)?e:e.toArray()).sort(i)),u=ot(et(Array.isArray(t)?t:t.toArray()).sort(i)),c=0;c{var{typed:t,Complex:r,matrix:n,ceil:i,floor:a}=e,o=tc({typed:t});return t("fix",{number:function(e){return e>0?a(e):i(e)},"number, number | BigNumber":function(e,t){return e>0?a(e,t):i(e,t)},Complex:function(e){return new r(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},"Complex, number | BigNumber":function(e,t){return new r(e.re>0?a(e.re,t):i(e.re,t),e.im>0?a(e.im,t):i(e.im,t))},BigNumber:function(e){return e.isNegative()?i(e):a(e)},"BigNumber, number | BigNumber":function(e,t){return e.isNegative()?i(e,t):a(e,t)},Fraction:function(e){return e.s<0?e.ceil():e.floor()},"Fraction, number | BigNumber":function(e,t){return e.s<0?e.ceil(t):e.floor(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"Array | Matrix, number | BigNumber":function(e,t){return $t(e,(e=>this(e,t)),!0)},"number | Complex | BigNumber, Array":function(e,t){return o(n(t),e,this,!0).valueOf()}})})),pp="divideScalar",mp=W(pp,["typed","numeric"],(e=>{var{typed:t,numeric:r}=e;return t(pp,{"number, number":function(e,t){return e/t},"Complex, Complex":function(e,t){return e.div(t)},"BigNumber, BigNumber":function(e,t){return e.div(t)},"Fraction, Fraction":function(e,t){return e.div(t)},"Unit, number | Fraction | BigNumber":function(e,t){var n=e.clone(),i=r(1,L(t));return n.value=this(null===n.value?n._normalize(i):n.value,t),n},"number | Fraction | BigNumber, Unit":function(e,t){var n=t.clone();n=n.pow(-1);var i=r(1,L(e));return n.value=this(e,null===t.value?t._normalize(i):t.value),n},"Unit, Unit":function(e,t){return e.divide(t)}})})),hp="nthRoots",dp=W(hp,["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,Complex:i}=e,a=[function(e){return new i(e,0)},function(e){return new i(0,e)},function(e){return new i(-e,0)},function(e){return new i(0,-e)}];function o(e,t){if(t<0)throw new Error("Root must be greater than zero");if(0===t)throw new Error("Root must be non-zero");if(t%1!=0)throw new Error("Root must be an integer");if(0===e||0===e.abs())return[new i(0,0)];var r,n="number"==typeof e;(n||0===e.re||0===e.im)&&(r=n?2*+(e<0):0===e.im?2*+(e.re<0):2*+(e.im<0)+1);for(var o=e.arg(),s=e.abs(),u=[],c=Math.pow(s,1/t),l=0;l{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(gp,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=(t=u(e,t,!0))._data,c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=[],d=0;dd&&(v.push(f[N]),x.push(M))}if(o(g,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var S=n(y,g),E=0,A=x.length;E{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(xp,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=0;hh&&(v.push(f[M]),x.push(S))}if(o(N,0))if(o(g[h],0)){if(0===y){var E=[...g];E[h]=1;for(var A=0,O=x.length;Anew s({data:e.map((e=>[e])),size:[c,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(r(e),t).map((e=>e.valueOf()))}});function c(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1],p=0;pnew s({data:e.map((e=>[e])),size:[l,1]})))}})),wp=W("Spa",["addScalar","equalScalar","FibonacciHeap"],(e=>{var{addScalar:t,equalScalar:r,FibonacciHeap:n}=e;function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new n}return i.prototype.type="Spa",i.prototype.isSpa=!0,i.prototype.set=function(e,t){if(this._values[e])this._values[e].value=t;else{var r=this._heap.insert(e,t);this._values[e]=r}},i.prototype.get=function(e){var t=this._values[e];return t?t.value:0},i.prototype.accumulate=function(e,r){var n=this._values[e];n?n.value=t(n.value,r):(n=this._heap.insert(e,r),this._values[e]=n)},i.prototype.forEach=function(e,t,n){var i=this._heap,a=this._values,o=[],s=i.extractMinimum();for(s&&o.push(s);s&&s.key<=t;)s.key>=e&&(r(s.value,0)||n(s.key,s.value,this)),(s=i.extractMinimum())&&o.push(s);for(var u=0;u{var{typed:t,size:r,concat:n,subset:i,setIntersect:a,setSymDifference:o,Index:s}=e;return t(Np,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new s(0)))return et(t);if(0===i(r(t),new s(0)))return et(e);var u=et(e),c=et(t);return n(o(u,c),a(u,c))}})})),Sp=W("lup",["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],(e=>{var{typed:t,matrix:r,abs:n,addScalar:i,divideScalar:a,multiplyScalar:o,subtract:s,larger:u,equalScalar:c,unaryMinus:l,DenseMatrix:f,SparseMatrix:p,Spa:m}=e;return t("lup",{DenseMatrix:function(e){return h(e)},SparseMatrix:function(e){return function(e){var t,r,i,s=e._size[0],f=e._size[1],h=Math.min(s,f),d=e._values,y=e._index,g=e._ptr,v=[],x=[],b=[],w=[s,h],N=[],M=[],S=[],E=[h,f],A=[],O=[];for(t=0;t0&&e.forEach(0,r-1,(function(t,r){p._forEachRow(t,v,x,b,(function(n,i){n>t&&e.accumulate(n,l(o(i,r)))}))}));var C,_,T,B,q=r,z=e.get(r),D=n(z);e.forEach(r+1,s-1,(function(e,t){var r=n(t);u(r,D)&&(q=e,D=r,z=t)})),r!==q&&(p._swapRows(r,q,w[1],v,x,b),p._swapRows(r,q,E[1],N,M,S),e.swap(r,q),_=q,T=O[C=r],B=O[_],A[T]=_,A[B]=C,O[C]=B,O[_]=T),e.forEach(0,s-1,(function(e,t){e<=r?(N.push(t),M.push(e)):(t=a(t,z),c(t,0)||(v.push(t),x.push(e)))}))};for(r=0;r0)for(t=0;t=0;){var u=r[o+s],c=r[n+u];-1===c?(s--,a[t++]=u):(r[n+u]=r[i+c],r[o+ ++s]=c)}return t}function Ap(e){return-e-2}var Op=W("csAmd",["add","multiply","transpose"],(e=>{var{add:t,multiply:r,transpose:n}=e;return function(e,o){if(!o||e<=0||e>3)return null;var s=o._size,u=s[0],c=s[1],l=0,f=Math.max(16,10*Math.sqrt(c)),p=function(e,i,a,o,s){var u=n(i);if(1===e&&o===a)return t(i,u);if(2===e){for(var c=u._index,l=u._ptr,f=0,p=0;ps))for(var h=l[p+1];mo)r[s+p]=0,r[i+p]=-1,f++,t[p]=Ap(e),r[s+e]++;else{var h=r[u+m];-1!==h&&(c[h]=p),r[l+p]=r[u+m],r[u+m]=p}}return f}(c,T,z,F,R,U,f,D,k,j,I),$=0;HG?(v=d,x=W,b=z[0+d]-G):(x=T[v=_[W++]],b=z[0+v]),g=1;g<=b;g++)(w=z[D+(m=_[x++])])<=0||(V+=w,z[D+m]=-w,_[Y++]=m,-1!==z[I+m]&&(j[z[I+m]]=j[m]),-1!==j[m]?z[I+j[m]]=z[I+m]:z[k+z[F+m]]=z[I+m]);v!==d&&(T[v]=Ap(d),z[U+v]=0)}for(0!==G&&(B=Y),z[F+d]=V,T[d]=J,z[0+d]=Y-J,z[R+d]=-2,L=i(L,l,z,U,c),N=J;N=L?z[U+v]-=w:0!==z[U+v]&&(z[U+v]=z[F+v]+X)}for(N=J;N0?(C+=Q,_[A++]=v,O+=v):(T[v]=Ap(d),z[U+v]=0)}z[R+m]=A-S+1;var K=A,ee=S+z[0+m];for(W=E+1;W=0))for(m=z[P+(O=j[m])],z[P+O]=-1;-1!==m&&-1!==z[I+m];m=z[I+m],L++){for(b=z[0+m],M=z[R+m],W=T[m]+1;W<=T[m]+b-1;W++)z[U+_[W]]=L;var re=m;for(h=z[I+m];-1!==h;){var ne=z[0+h]===b&&z[R+h]===M;for(W=T[h]+1;ne&&W<=T[h]+b-1;W++)z[U+_[W]]!==L&&(ne=0);ne?(T[h]=Ap(m),z[D+m]+=z[D+h],z[D+h]=0,z[R+h]=-1,h=z[I+h],z[I+re]=h):(re=h,h=z[I+h])}}for(W=J,N=J;N=0;h--)z[D+h]>0||(z[I+h]=z[k+T[h]],z[k+T[h]]=h);for(v=c;v>=0;v--)z[D+v]<=0||-1!==T[v]&&(z[I+v]=z[k+T[v]],z[k+T[v]]=v);for(d=0,m=0;m<=c;m++)-1===T[m]&&(d=Ep(m,d,z,k,I,q,U));return q.splice(q.length-1,1),q};function i(e,t,r,n,i){if(e<2||e+t<0){for(var a=0;a{var{transpose:t}=e;return function(e,r,n,i){if(!e||!r||!n)return null;var a,o,s,u,c,l,f,p=e._size,m=p[0],h=p[1],d=4*h+(i?h+m+1:0),y=[],g=h,v=2*h,x=3*h,b=4*h,w=5*h+1;for(s=0;s=1&&N[o]++,2===A.jleaf&&N[A.q]--}-1!==r[o]&&(y[0+o]=r[o])}for(o=0;o{var{add:t,multiply:r,transpose:n}=e,i=Op({add:t,multiply:r,transpose:n}),a=_p({transpose:n});return function(e,t,r){var n,o=t._ptr,s=t._size[1],u={};if(u.q=i(e,t),e&&!u.q)return null;if(r){var c=e?function(e,t,r,n){for(var i=e._values,a=e._index,o=e._ptr,s=e._size,u=e._datatype,c=s[0],l=s[1],f=null,p=[],m=[],h=0,d=0;d=0;r--)-1!==e[r]&&(a[o+r]=a[0+e[r]],a[0+e[r]]=r);for(r=0;r=0;u--)for(l=r[u],f=r[u+1],c=l;c=0;s--)m[s]=-1,-1!==(u=h[s])&&(0==d[v+u]++&&(d[g+u]=s),d[0+s]=d[y+u],d[y+u]=s);for(t.lnz=0,t.m2=a,u=0;u=0;){e=n[f];var p=i?i[e]:e;Bp(c,e)||(qp(c,e),n[l+f]=p<0?0:zp(c[p]));var m=1;for(o=n[l+f],s=p<0?0:zp(c[p+1]);o{var{divideScalar:t,multiply:r,subtract:n}=e;return function(e,i,a,o,s,u,c){var l,f,p,m,h=e._values,d=e._index,y=e._ptr,g=e._size[1],v=i._values,x=i._index,b=i._ptr,w=function(e,t,r,n,i){var a,o,s,u=e._ptr,c=e._size,l=t._index,f=t._ptr,p=c[1],m=p;for(o=f[r],s=f[r+1],a=o;a{var{abs:t,divideScalar:r,multiply:n,subtract:i,larger:a,largerEq:o,SparseMatrix:s}=e,u=Ip({divideScalar:r,multiply:n,subtract:i});return function(e,i,c){if(!e)return null;var l,f=e._size[1],p=100,m=100;i&&(l=i.q,p=i.lnz||p,m=i.unz||m);var h,d,y=[],g=[],v=[],x=new s({values:y,index:g,ptr:v,size:[f,f]}),b=[],w=[],N=[],M=new s({values:b,index:w,ptr:N,size:[f,f]}),S=[],E=[],A=[];for(h=0;h{var{typed:t,abs:r,add:n,multiply:i,transpose:a,divideScalar:o,subtract:s,larger:u,largerEq:c,SparseMatrix:l}=e,f=Tp({add:n,multiply:i,transpose:a}),p=kp({abs:r,divideScalar:o,multiply:i,subtract:s,larger:u,largerEq:c,SparseMatrix:l});return t("slu",{"SparseMatrix, number, number":function(e,t,r){if(!ce(t)||t<0||t>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(r<0||r>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var n=f(t,e,!1),i=p(e,n,r);return{L:i.L,U:i.U,p:i.pinv,q:n.q,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\np: "+this.p.toString()+(this.q?"\nq: "+this.q.toString():"")+"\n"}}}})})),Fp=W("det",["typed","matrix","subtract","multiply","unaryMinus","lup"],(e=>{var{typed:t,matrix:r,subtract:n,multiply:i,unaryMinus:a,lup:o}=e;return t("det",{any:function(e){return $(e)},"Array | Matrix":function(e){var t;switch((t=f(e)?e.size():Array.isArray(e)?(e=r(e)).size():[]).length){case 0:return $(e);case 1:if(1===t[0])return $(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:var s=t[0];if(s===t[1])return function(e,t,r){if(1===t)return $(e[0][0]);if(2===t)return n(i(e[0][0],e[1][1]),i(e[1][0],e[0][1]));for(var s=o(e),u=s.U[0][0],c=1;c=t)break;for(var m=f,h=0;!p[s.p[m]];)p[s.p[m]]=!0,m=s.p[m],h++;h%2==0&&l++}return l%2==0?u:a(u)}(e.clone().valueOf(),s);throw new RangeError("Matrix must be square (size: "+De(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+De(t)+")")}}})})),Up="distance",Pp=W(Up,["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],(e=>{var{typed:t,addScalar:r,subtract:n,multiplyScalar:i,divideScalar:o,unaryMinus:s,sqrt:u,abs:c}=e;return t(Up,{"Array, Array, Array":function(e,t,r){if(2===e.length&&2===t.length&&2===r.length){if(!f(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!f(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!f(r))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var a=o(n(r[1],r[0]),n(t[1],t[0])),u=i(i(a,a),t[0]),c=s(i(a,t[0])),l=e[1];return y(e[0],e[1],u,c,l)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(e,t,r){if(2===Object.keys(e).length&&2===Object.keys(t).length&&2===Object.keys(r).length){if(!f(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!f(t))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!f(r))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"lineOnePtX"in t&&"lineOnePtY"in t&&"lineTwoPtX"in r&&"lineTwoPtY"in r){var a=o(n(r.lineTwoPtY,r.lineTwoPtX),n(t.lineOnePtY,t.lineOnePtX)),u=i(i(a,a),t.lineOnePtX),c=s(i(a,t.lineOnePtX)),l=e.pointX;return y(e.pointX,e.pointY,u,c,l)}throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(e,t){if(2===e.length&&3===t.length){if(!f(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!p(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return y(e[0],e[1],t[0],t[1],t[2])}if(3===e.length&&6===t.length){if(!p(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!h(t))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return g(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}if(e.length===t.length&&e.length>0){if(!m(e))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!m(t))throw new TypeError("All values of an array should be numbers or BigNumbers");return v(e,t)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,t){if(2===Object.keys(e).length&&3===Object.keys(t).length){if(!f(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"xCoeffLine"in t&&"yCoeffLine"in t&&"constant"in t)return y(e.pointX,e.pointY,t.xCoeffLine,t.yCoeffLine,t.constant);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&6===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!h(t))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"x0"in t&&"y0"in t&&"z0"in t&&"a"in t&&"b"in t&&"c"in t)return g(e.pointX,e.pointY,e.pointZ,t.x0,t.y0,t.z0,t.a,t.b,t.c);throw new TypeError("Key names do not match")}if(2===Object.keys(e).length&&2===Object.keys(t).length){if(!f(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!f(t))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointTwoX"in t&&"pointTwoY"in t)return v([e.pointOneX,e.pointOneY],[t.pointTwoX,t.pointTwoY]);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&3===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointOneZ"in e&&"pointTwoX"in t&&"pointTwoY"in t&&"pointTwoZ"in t)return v([e.pointOneX,e.pointOneY,e.pointOneZ],[t.pointTwoX,t.pointTwoY,t.pointTwoZ]);throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},Array:function(e){if(!function(e){if(2===e[0].length&&l(e[0][0])&&l(e[0][1])){if(e.some((e=>2!==e.length||!l(e[0])||!l(e[1]))))return!1}else{if(!(3===e[0].length&&l(e[0][0])&&l(e[0][1])&&l(e[0][2])))return!1;if(e.some((e=>3!==e.length||!l(e[0])||!l(e[1])||!l(e[2]))))return!1}return!0}(e))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return function(e){for(var t=[],r=[],n=[],i=0;i{var{typed:t,addScalar:r,subtract:n,multiplyScalar:i,divideScalar:a,pow:o,factorial:s,combinations:u,isNegative:c,isInteger:l,larger:f}=e;return t(jp,{"number | BigNumber, number | BigNumber":function(e,t){if(!l(e)||c(e)||!l(t)||c(t))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(f(t,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");for(var p=s(t),m=0,h=0;h<=t;h++){var d=o(-1,n(t,h)),y=u(t,h),g=o(h,e);m=r(m,i(i(y,g),d))}return a(m,p)}})})),Hp="catalan",$p=W(Hp,["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],(e=>{var{typed:t,addScalar:r,divideScalar:n,multiplyScalar:i,combinations:a,isNegative:o,isInteger:s}=e;return t(Hp,{"number | BigNumber":function(e){if(!s(e)||o(e))throw new TypeError("Non-negative integer value expected in function catalan");return n(a(i(e,2),e),r(e,1))}})})),Gp=W("log",["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,Complex:i}=e;return t("log",{number:function(e){return e>=0||r.predictable?Ga(e):new i(e,0).log()},Complex:function(e){return e.log()},BigNumber:function(e){return!e.isNegative()||r.predictable?e.ln():new i(e.toNumber(),0).log()},"Array | Matrix":function(e){return $t(e,this)},"any, any":function(e,t){return n(this(e),this(t))}})})),Zp="dotDivide",Vp=W(Zp,["typed","matrix","equalScalar","divideScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,divideScalar:i,DenseMatrix:a}=e,o=nc({typed:t,equalScalar:n}),s=ic({typed:t}),u=yc({typed:t,DenseMatrix:a}),c=oc({typed:t,equalScalar:n}),l=sc({typed:t,DenseMatrix:a}),f=ec({typed:t}),p=tc({typed:t});return t(Zp,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,i)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return c(e,t,i,!1)},"DenseMatrix, any":function(e,t){return p(e,t,i,!1)},"any, SparseMatrix":function(e,t){return l(t,e,i,!0)},"any, DenseMatrix":function(e,t){return p(t,e,i,!0)},"Array, any":function(e,t){return p(r(e),t,i,!1).valueOf()},"any, Array":function(e,t){return p(r(t),e,i,!0).valueOf()}})})),Wp="usolveAll",Jp=W(Wp,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(Wp,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=l-1;h>=0;h--)for(var d=r.length,y=0;y=b;N--){var M=p[N];M===h?w=f[N]:Mnew s({data:e.map((e=>[e])),size:[c,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(r(e),t).map((e=>e.valueOf()))}});function c(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1]-1;f>=0;f--)for(var p=r.length,m=0;m=0;y--)d[y]=a(d[y],c[y][f]);r.push(d)}}else{if(0===m)return[];r.splice(m,1),m-=1,p-=1}else{h[f]=n(h[f],c[f][f]);for(var g=f-1;g>=0;g--)h[g]=a(h[g],i(h[f],c[g][f]))}}return r.map((e=>new s({data:e.map((e=>[e])),size:[l,1]})))}})),Yp="hypot",Xp=W(Yp,["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],(e=>{var{typed:t,abs:r,addScalar:n,divideScalar:i,multiplyScalar:a,sqrt:o,smaller:s,isPositive:u}=e;return t(Yp,{"... number | BigNumber":function(e){for(var t=0,c=0,l=0;l{var{typed:r,matrix:n,zeros:i,identity:a,isZero:o,equal:s,sign:u,sqrt:c,conj:l,unaryMinus:f,addScalar:p,divideScalar:m,multiplyScalar:h,subtract:d,complex:y}=t;return e(r("qr",{DenseMatrix:function(e){return v(e)},SparseMatrix:function(e){return function(e){throw new Error("qr not implemented for sparse matrices yet")}()},Array:function(e){var t=v(n(e));return{Q:t.Q.valueOf(),R:t.R.valueOf()}}}),{_denseQRimpl:g});function g(e){var t,r,n,y=e._size[0],g=e._size[1],v=a([y],"dense"),x=v._data,b=e.clone(),w=b._data,N=i([y],"");for(n=0;n0)for(var n="Complex"===r[0][0].type?y(0):0,i=0;i{var{typed:t,matrix:r,divideScalar:n,addScalar:i,multiply:a,unaryMinus:o,det:s,identity:u,abs:c}=e;return t("inv",{"Array | Matrix":function(e){var t=f(e)?e.size():je(e);switch(t.length){case 1:if(1===t[0])return f(e)?r([n(1,e.valueOf()[0])]):[n(1,e[0])];throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:var i=t[0],a=t[1];if(i===a)return f(e)?r(l(e.valueOf(),i,a),e.storage()):l(e,i,a);throw new RangeError("Matrix must be square (size: "+De(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+De(t)+")")}},any:function(e){return n(1,e)}});function l(e,t,r){var l,f,p,m,h;if(1===t){if(0===(m=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero");return[[n(1,m)]]}if(2===t){var d=s(e);if(0===d)throw Error("Cannot calculate inverse, determinant is zero");return[[n(e[1][1],d),n(o(e[0][1]),d)],[n(o(e[1][0]),d),n(e[0][0],d)]]}var y=e.concat();for(l=0;lx&&(x=c(y[l][v]),b=l),l++;if(0===x)throw Error("Cannot calculate inverse, determinant is zero");(l=b)!==v&&(h=y[v],y[v]=y[l],y[l]=h,h=g[v],g[v]=g[l],g[l]=h);var w=y[v],N=g[v];for(l=0;l{var{typed:t,abs:r,add:n,identity:i,inv:a,multiply:o}=e;return t(em,{Matrix:function(e){var t=e.size();if(2!==t.length||t[0]!==t[1])throw new RangeError("Matrix must be square (size: "+De(t)+")");for(var u=t[0],c=function(e,t){for(var r=0;r<30;r++)for(var n=0;n<=r;n++){var i=r-n;if(s(e,n,i)<1e-15)return{q:n,j:i}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}(function(e){for(var t=e.size()[0],n=0,i=0;i1&&(g=o(g,p),v=-v),m=n(m,o(y=y*(l-x+1)/((2*l-x+1)*x),g)),d=n(d,o(y*v,g));for(var b=o(a(d),m),w=0;w{var{typed:t,matrix:r,multiply:n,equalScalar:i,divideScalar:a,inv:o}=e,s=oc({typed:t,equalScalar:i}),u=tc({typed:t});return t("divide",G({"Array | Matrix, Array | Matrix":function(e,t){return n(e,o(t))},"DenseMatrix, any":function(e,t){return u(e,t,a,!1)},"SparseMatrix, any":function(e,t){return s(e,t,a,!1)},"Array, any":function(e,t){return u(r(e),t,a,!1).valueOf()},"any, Array | Matrix":function(e,t){return n(e,o(t))}},a.signatures))})),nm="kldivergence",im=W(nm,["typed","matrix","divide","sum","multiply","dotDivide","log","isNumeric"],(e=>{var{typed:t,matrix:r,divide:n,sum:i,multiply:a,dotDivide:o,log:s,isNumeric:u}=e;return t(nm,{"Array, Array":function(e,t){return c(r(e),r(t))},"Matrix, Array":function(e,t){return c(e,r(t))},"Array, Matrix":function(e,t){return c(r(e),t)},"Matrix, Matrix":function(e,t){return c(e,t)}});function c(e,t){var r=t.size().length,c=e.size().length;if(r>1)throw new Error("first object must be one dimensional");if(c>1)throw new Error("second object must be one dimensional");if(r!==c)throw new Error("Length of two vectors must be equal");if(0===i(e))throw new Error("Sum of elements in first object must be non zero");if(0===i(t))throw new Error("Sum of elements in second object must be non zero");var l=n(e,i(e)),f=n(t,i(t)),p=i(a(l,s(o(l,f))));return u(p)?p:Number.NaN}})),am="bellNumbers",om=W(am,["typed","addScalar","isNegative","isInteger","stirlingS2"],(e=>{var{typed:t,addScalar:r,isNegative:n,isInteger:i,stirlingS2:a}=e;return t(am,{"number | BigNumber":function(e){if(!i(e)||n(e))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var t=0,o=0;o<=e;o++)t=r(t,a(e,o));return t}})})),sm="log1p",um=W(sm,["typed","config","divideScalar","log","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,log:i,Complex:a}=e;return t(sm,{number:function(e){return e>=-1||r.predictable?me(e):o(new a(e,0))},Complex:o,BigNumber:function(e){var t=e.plus(1);return!t.isNegative()||r.predictable?t.ln():o(new a(e.toNumber(),0))},"Array | Matrix":function(e){return $t(e,this)},"any, any":function(e,t){return n(this(e),i(t))}});function o(e){var t=e.re+1;return new a(Math.log(Math.sqrt(t*t+e.im*e.im)),Math.atan2(e.im,t))}}));function cm(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function lm(e){for(var t=1;t{var r,n,i,{on:a,config:s,addScalar:c,subtract:l,multiplyScalar:f,divideScalar:p,pow:m,abs:h,fix:d,round:y,equal:g,isNumeric:v,format:x,number:b,Complex:w,BigNumber:N,Fraction:M}=t,S=b;function E(e,t){if(!(this instanceof E))throw new Error("Constructor must be called with the new operator");if(null!=e&&!v(e)&&!o(e))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(void 0!==t&&("string"!=typeof t||""===t))throw new TypeError("Second parameter in Unit constructor must be a string");if(void 0!==t){var r=E.parse(t);this.units=r.units,this.dimensions=r.dimensions}else{this.units=[{unit:U,prefix:I.NONE,power:0}],this.dimensions=[];for(var n=0;n="0"&&e<="9"}function C(){n++,i=r.charAt(n)}function _(e){n=e,i=r.charAt(n)}function T(){var e="",t=n;if("+"===i?C():"-"===i&&(e+=i,C()),!function(e){return e>="0"&&e<="9"||"."===e}(i))return _(t),null;if("."===i){if(e+=i,C(),!O(i))return _(t),null}else{for(;O(i);)e+=i,C();"."===i&&(e+=i,C())}for(;O(i);)e+=i,C();if("E"===i||"e"===i){var r="",a=n;if(r+=i,C(),"+"!==i&&"-"!==i||(r+=i,C()),!O(i))return _(a),e;for(e+=r;O(i);)e+=i,C()}return e}function B(){for(var e="";O(i)||E.isValidAlpha(i);)e+=i,C();var t=e.charAt(0);return E.isValidAlpha(t)?e:null}function q(e){return i===e?(C(),e):null}E.prototype.type="Unit",E.prototype.isUnit=!0,E.parse=function(e,t){if(t=t||{},n=-1,i="","string"!=typeof(r=e))throw new TypeError("Invalid argument in Unit.parse, string expected");var a=new E;a.units=[];var o=1,u=!1;C(),A();var c=T(),l=null;if(c){if("BigNumber"===s.number)l=new N(c);else if("Fraction"===s.number)try{l=new M(c)}catch(e){l=parseFloat(c)}else l=parseFloat(c);A(),q("*")?(o=1,u=!0):q("/")&&(o=-1,u=!0)}for(var f=[],p=1;;){for(A();"("===i;)f.push(o),p*=o,o=1,C(),A();var m;if(!i)break;var h=i;if(null===(m=B()))throw new SyntaxError('Unexpected "'+h+'" in "'+r+'" at index '+n.toString());var d=z(m);if(null===d)throw new SyntaxError('Unit "'+m+'" not found.');var y=o*p;if(A(),q("^")){A();var g=T();if(null===g)throw new SyntaxError('In "'+e+'", "^" must be followed by a floating-point number');y*=g}a.units.push({unit:d.unit,prefix:d.prefix,power:y});for(var v=0;v1||Math.abs(this.units[0].power-1)>1e-15)},E.prototype._normalize=function(e){var t,r,n,i,a;if(null==e||0===this.units.length)return e;if(this._isDerived()){var o=e;a=E._getNumberConverter(L(e));for(var s=0;s{if(V(P,e)){var t=P[e];return{unit:t,prefix:t.prefixes[""]}}for(var r in P)if(V(P,r)&&ze(e,r)){var n=P[r],i=e.length-r.length,a=e.substring(0,i),o=V(n.prefixes,a)?n.prefixes[a]:void 0;if(void 0!==o)return{unit:n,prefix:o}}return null}),{hasher:e=>e[0],limit:100});function D(e){return e.equalBase(R.NONE)&&null!==e.value&&!s.predictable?e.value:e}E.isValuelessUnit=function(e){return null!==z(e)},E.prototype.hasBase=function(e){if("string"==typeof e&&(e=R[e]),!e)return!1;for(var t=0;t1e-12)return!1;return!0},E.prototype.equalBase=function(e){for(var t=0;t1e-12)return!1;return!0},E.prototype.equals=function(e){return this.equalBase(e)&&g(this.value,e.value)},E.prototype.multiply=function(e){for(var t=this.clone(),r=0;r1e-12&&(V(Z,s)?n.push({unit:Z[s].unit,prefix:Z[s].prefix,power:r.dimensions[o]||0}):a=!0)}n.length1e-12){if(!V(G.si,n))throw new Error("Cannot express custom unit "+n+" in SI units");t.push({unit:G.si[n].unit,prefix:G.si[n].prefix,power:e.dimensions[r]||0})}}return e.units=t,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,e},E.prototype.formatUnits=function(){for(var e="",t="",r=0,n=0,i=0;i0?(r++,e+=" "+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power-1)>1e-15&&(e+="^"+this.units[i].power)):this.units[i].power<0&&n++;if(n>0)for(var a=0;a0?(t+=" "+this.units[a].prefix.name+this.units[a].unit.name,Math.abs(this.units[a].power+1)>1e-15&&(t+="^"+-this.units[a].power)):(t+=" "+this.units[a].prefix.name+this.units[a].unit.name,t+="^"+this.units[a].power));e=e.substr(1),t=t.substr(1),r>1&&n>0&&(e="("+e+")"),n>1&&r>0&&(t="("+t+")");var o=e;return r>0&&n>0&&(o+=" / "),o+t},E.prototype.format=function(e){var t=this.skipAutomaticSimplification||null===this.value?this.clone():this.simplify(),r=!1;for(var n in void 0!==t.value&&null!==t.value&&o(t.value)&&(r=Math.abs(t.value.re)<1e-14),t.units)V(t.units,n)&&t.units[n].unit&&("VA"===t.units[n].unit.name&&r?t.units[n].unit=P.VAR:"VAR"!==t.units[n].unit.name||r||(t.units[n].unit=P.VA));1!==t.units.length||t.fixPrefix||Math.abs(t.units[0].power-Math.round(t.units[0].power))<1e-14&&(t.units[0].prefix=t._bestPrefix());var i=t._denormalize(t.value),a=null!==t.value?x(i,e||{}):"",s=t.formatUnits();return t.value&&o(t.value)&&(a="("+a+")"),s.length>0&&a.length>0&&(a+=" "),a+s},E.prototype._bestPrefix=function(){if(1!==this.units.length)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var e=null!==this.value?h(this.value):0,t=h(this.units[0].unit.value),r=this.units[0].prefix;if(0===e)return r;var n=this.units[0].power,i=Math.log(e/Math.pow(r.value*t,n))/Math.LN10-1.2;if(i>-2.200001&&i<1.800001)return r;i=Math.abs(i);var a=this.units[0].unit.prefixes;for(var o in a)if(V(a,o)){var s=a[o];if(s.scientific){var u=Math.abs(Math.log(e/Math.pow(s.value*t,n))/Math.LN10-1.2);(u0))},P={meter:{name:"meter",base:R.LENGTH,prefixes:I.LONG,value:1,offset:0},inch:{name:"inch",base:R.LENGTH,prefixes:I.NONE,value:.0254,offset:0},foot:{name:"foot",base:R.LENGTH,prefixes:I.NONE,value:.3048,offset:0},yard:{name:"yard",base:R.LENGTH,prefixes:I.NONE,value:.9144,offset:0},mile:{name:"mile",base:R.LENGTH,prefixes:I.NONE,value:1609.344,offset:0},link:{name:"link",base:R.LENGTH,prefixes:I.NONE,value:.201168,offset:0},rod:{name:"rod",base:R.LENGTH,prefixes:I.NONE,value:5.0292,offset:0},chain:{name:"chain",base:R.LENGTH,prefixes:I.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:R.LENGTH,prefixes:I.NONE,value:1e-10,offset:0},m:{name:"m",base:R.LENGTH,prefixes:I.SHORT,value:1,offset:0},in:{name:"in",base:R.LENGTH,prefixes:I.NONE,value:.0254,offset:0},ft:{name:"ft",base:R.LENGTH,prefixes:I.NONE,value:.3048,offset:0},yd:{name:"yd",base:R.LENGTH,prefixes:I.NONE,value:.9144,offset:0},mi:{name:"mi",base:R.LENGTH,prefixes:I.NONE,value:1609.344,offset:0},li:{name:"li",base:R.LENGTH,prefixes:I.NONE,value:.201168,offset:0},rd:{name:"rd",base:R.LENGTH,prefixes:I.NONE,value:5.02921,offset:0},ch:{name:"ch",base:R.LENGTH,prefixes:I.NONE,value:20.1168,offset:0},mil:{name:"mil",base:R.LENGTH,prefixes:I.NONE,value:254e-7,offset:0},m2:{name:"m2",base:R.SURFACE,prefixes:I.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:R.SURFACE,prefixes:I.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:R.SURFACE,prefixes:I.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:R.SURFACE,prefixes:I.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:R.SURFACE,prefixes:I.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:R.SURFACE,prefixes:I.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:R.SURFACE,prefixes:I.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:R.SURFACE,prefixes:I.NONE,value:6.4516e-10,offset:0},acre:{name:"acre",base:R.SURFACE,prefixes:I.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:R.SURFACE,prefixes:I.NONE,value:1e4,offset:0},m3:{name:"m3",base:R.VOLUME,prefixes:I.CUBIC,value:1,offset:0},L:{name:"L",base:R.VOLUME,prefixes:I.SHORT,value:.001,offset:0},l:{name:"l",base:R.VOLUME,prefixes:I.SHORT,value:.001,offset:0},litre:{name:"litre",base:R.VOLUME,prefixes:I.LONG,value:.001,offset:0},cuin:{name:"cuin",base:R.VOLUME,prefixes:I.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:R.VOLUME,prefixes:I.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:R.VOLUME,prefixes:I.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:R.VOLUME,prefixes:I.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:R.VOLUME,prefixes:I.NONE,value:15e-6,offset:0},drop:{name:"drop",base:R.VOLUME,prefixes:I.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:R.VOLUME,prefixes:I.NONE,value:5e-8,offset:0},minim:{name:"minim",base:R.VOLUME,prefixes:I.NONE,value:6.161152e-8,offset:0},fluiddram:{name:"fluiddram",base:R.VOLUME,prefixes:I.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:R.VOLUME,prefixes:I.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:R.VOLUME,prefixes:I.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:R.VOLUME,prefixes:I.NONE,value:1e-6,offset:0},cup:{name:"cup",base:R.VOLUME,prefixes:I.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:R.VOLUME,prefixes:I.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:R.VOLUME,prefixes:I.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:R.VOLUME,prefixes:I.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:R.VOLUME,prefixes:I.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:R.VOLUME,prefixes:I.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:R.VOLUME,prefixes:I.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:R.VOLUME,prefixes:I.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:R.VOLUME,prefixes:I.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:R.VOLUME,prefixes:I.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:R.VOLUME,prefixes:I.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:R.VOLUME,prefixes:I.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:R.VOLUME,prefixes:I.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:R.VOLUME,prefixes:I.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:R.VOLUME,prefixes:I.NONE,value:.1173478,offset:0},obl:{name:"obl",base:R.VOLUME,prefixes:I.NONE,value:.1589873,offset:0},g:{name:"g",base:R.MASS,prefixes:I.SHORT,value:.001,offset:0},gram:{name:"gram",base:R.MASS,prefixes:I.LONG,value:.001,offset:0},ton:{name:"ton",base:R.MASS,prefixes:I.SHORT,value:907.18474,offset:0},t:{name:"t",base:R.MASS,prefixes:I.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:R.MASS,prefixes:I.LONG,value:1e3,offset:0},grain:{name:"grain",base:R.MASS,prefixes:I.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:R.MASS,prefixes:I.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:R.MASS,prefixes:I.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:R.MASS,prefixes:I.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:R.MASS,prefixes:I.NONE,value:45.359237,offset:0},stick:{name:"stick",base:R.MASS,prefixes:I.NONE,value:.115,offset:0},stone:{name:"stone",base:R.MASS,prefixes:I.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:R.MASS,prefixes:I.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:R.MASS,prefixes:I.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:R.MASS,prefixes:I.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:R.MASS,prefixes:I.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:R.MASS,prefixes:I.NONE,value:45.359237,offset:0},s:{name:"s",base:R.TIME,prefixes:I.SHORT,value:1,offset:0},min:{name:"min",base:R.TIME,prefixes:I.NONE,value:60,offset:0},h:{name:"h",base:R.TIME,prefixes:I.NONE,value:3600,offset:0},second:{name:"second",base:R.TIME,prefixes:I.LONG,value:1,offset:0},sec:{name:"sec",base:R.TIME,prefixes:I.LONG,value:1,offset:0},minute:{name:"minute",base:R.TIME,prefixes:I.NONE,value:60,offset:0},hour:{name:"hour",base:R.TIME,prefixes:I.NONE,value:3600,offset:0},day:{name:"day",base:R.TIME,prefixes:I.NONE,value:86400,offset:0},week:{name:"week",base:R.TIME,prefixes:I.NONE,value:604800,offset:0},month:{name:"month",base:R.TIME,prefixes:I.NONE,value:2629800,offset:0},year:{name:"year",base:R.TIME,prefixes:I.NONE,value:31557600,offset:0},decade:{name:"decade",base:R.TIME,prefixes:I.NONE,value:315576e3,offset:0},century:{name:"century",base:R.TIME,prefixes:I.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:R.TIME,prefixes:I.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:R.FREQUENCY,prefixes:I.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:R.FREQUENCY,prefixes:I.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:R.ANGLE,prefixes:I.SHORT,value:1,offset:0},radian:{name:"radian",base:R.ANGLE,prefixes:I.LONG,value:1,offset:0},deg:{name:"deg",base:R.ANGLE,prefixes:I.SHORT,value:null,offset:0},degree:{name:"degree",base:R.ANGLE,prefixes:I.LONG,value:null,offset:0},grad:{name:"grad",base:R.ANGLE,prefixes:I.SHORT,value:null,offset:0},gradian:{name:"gradian",base:R.ANGLE,prefixes:I.LONG,value:null,offset:0},cycle:{name:"cycle",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},A:{name:"A",base:R.CURRENT,prefixes:I.SHORT,value:1,offset:0},ampere:{name:"ampere",base:R.CURRENT,prefixes:I.LONG,value:1,offset:0},K:{name:"K",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:0},degC:{name:"degC",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:273.15},degF:{name:"degF",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:0},celsius:{name:"celsius",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:R.AMOUNT_OF_SUBSTANCE,prefixes:I.SHORT,value:1,offset:0},mole:{name:"mole",base:R.AMOUNT_OF_SUBSTANCE,prefixes:I.LONG,value:1,offset:0},cd:{name:"cd",base:R.LUMINOUS_INTENSITY,prefixes:I.SHORT,value:1,offset:0},candela:{name:"candela",base:R.LUMINOUS_INTENSITY,prefixes:I.LONG,value:1,offset:0},N:{name:"N",base:R.FORCE,prefixes:I.SHORT,value:1,offset:0},newton:{name:"newton",base:R.FORCE,prefixes:I.LONG,value:1,offset:0},dyn:{name:"dyn",base:R.FORCE,prefixes:I.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:R.FORCE,prefixes:I.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:R.FORCE,prefixes:I.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:R.FORCE,prefixes:I.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:R.FORCE,prefixes:I.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:R.FORCE,prefixes:I.NONE,value:9.80665,offset:0},J:{name:"J",base:R.ENERGY,prefixes:I.SHORT,value:1,offset:0},joule:{name:"joule",base:R.ENERGY,prefixes:I.SHORT,value:1,offset:0},erg:{name:"erg",base:R.ENERGY,prefixes:I.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:R.ENERGY,prefixes:I.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:R.ENERGY,prefixes:I.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:R.ENERGY,prefixes:I.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:R.ENERGY,prefixes:I.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:R.POWER,prefixes:I.SHORT,value:1,offset:0},watt:{name:"watt",base:R.POWER,prefixes:I.LONG,value:1,offset:0},hp:{name:"hp",base:R.POWER,prefixes:I.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:R.POWER,prefixes:I.SHORT,value:w.I,offset:0},VA:{name:"VA",base:R.POWER,prefixes:I.SHORT,value:1,offset:0},Pa:{name:"Pa",base:R.PRESSURE,prefixes:I.SHORT,value:1,offset:0},psi:{name:"psi",base:R.PRESSURE,prefixes:I.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:R.PRESSURE,prefixes:I.NONE,value:101325,offset:0},bar:{name:"bar",base:R.PRESSURE,prefixes:I.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:R.PRESSURE,prefixes:I.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:R.PRESSURE,prefixes:I.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:R.PRESSURE,prefixes:I.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:R.PRESSURE,prefixes:I.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:R.ELECTRIC_CHARGE,prefixes:I.LONG,value:1,offset:0},C:{name:"C",base:R.ELECTRIC_CHARGE,prefixes:I.SHORT,value:1,offset:0},farad:{name:"farad",base:R.ELECTRIC_CAPACITANCE,prefixes:I.LONG,value:1,offset:0},F:{name:"F",base:R.ELECTRIC_CAPACITANCE,prefixes:I.SHORT,value:1,offset:0},volt:{name:"volt",base:R.ELECTRIC_POTENTIAL,prefixes:I.LONG,value:1,offset:0},V:{name:"V",base:R.ELECTRIC_POTENTIAL,prefixes:I.SHORT,value:1,offset:0},ohm:{name:"ohm",base:R.ELECTRIC_RESISTANCE,prefixes:I.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:R.ELECTRIC_INDUCTANCE,prefixes:I.LONG,value:1,offset:0},H:{name:"H",base:R.ELECTRIC_INDUCTANCE,prefixes:I.SHORT,value:1,offset:0},siemens:{name:"siemens",base:R.ELECTRIC_CONDUCTANCE,prefixes:I.LONG,value:1,offset:0},S:{name:"S",base:R.ELECTRIC_CONDUCTANCE,prefixes:I.SHORT,value:1,offset:0},weber:{name:"weber",base:R.MAGNETIC_FLUX,prefixes:I.LONG,value:1,offset:0},Wb:{name:"Wb",base:R.MAGNETIC_FLUX,prefixes:I.SHORT,value:1,offset:0},tesla:{name:"tesla",base:R.MAGNETIC_FLUX_DENSITY,prefixes:I.LONG,value:1,offset:0},T:{name:"T",base:R.MAGNETIC_FLUX_DENSITY,prefixes:I.SHORT,value:1,offset:0},b:{name:"b",base:R.BIT,prefixes:I.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:R.BIT,prefixes:I.BINARY_LONG,value:1,offset:0},B:{name:"B",base:R.BIT,prefixes:I.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:R.BIT,prefixes:I.BINARY_LONG,value:8,offset:0}},j={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function H(e){if("BigNumber"===e.number){var t=Cn(N);P.rad.value=new N(1),P.deg.value=t.div(180),P.grad.value=t.div(200),P.cycle.value=t.times(2),P.arcsec.value=t.div(648e3),P.arcmin.value=t.div(10800)}else P.rad.value=1,P.deg.value=Math.PI/180,P.grad.value=Math.PI/200,P.cycle.value=2*Math.PI,P.arcsec.value=Math.PI/648e3,P.arcmin.value=Math.PI/10800;P.radian.value=P.rad.value,P.degree.value=P.deg.value,P.gradian.value=P.grad.value}H(s),a&&a("config",(function(e,t){e.number!==t.number&&H(e)}));var G={si:{NONE:{unit:U,prefix:I.NONE[""]},LENGTH:{unit:P.m,prefix:I.SHORT[""]},MASS:{unit:P.g,prefix:I.SHORT.k},TIME:{unit:P.s,prefix:I.SHORT[""]},CURRENT:{unit:P.A,prefix:I.SHORT[""]},TEMPERATURE:{unit:P.K,prefix:I.SHORT[""]},LUMINOUS_INTENSITY:{unit:P.cd,prefix:I.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:P.mol,prefix:I.SHORT[""]},ANGLE:{unit:P.rad,prefix:I.SHORT[""]},BIT:{unit:P.bits,prefix:I.SHORT[""]},FORCE:{unit:P.N,prefix:I.SHORT[""]},ENERGY:{unit:P.J,prefix:I.SHORT[""]},POWER:{unit:P.W,prefix:I.SHORT[""]},PRESSURE:{unit:P.Pa,prefix:I.SHORT[""]},ELECTRIC_CHARGE:{unit:P.C,prefix:I.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:P.F,prefix:I.SHORT[""]},ELECTRIC_POTENTIAL:{unit:P.V,prefix:I.SHORT[""]},ELECTRIC_RESISTANCE:{unit:P.ohm,prefix:I.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:P.H,prefix:I.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:P.S,prefix:I.SHORT[""]},MAGNETIC_FLUX:{unit:P.Wb,prefix:I.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:P.T,prefix:I.SHORT[""]},FREQUENCY:{unit:P.Hz,prefix:I.SHORT[""]}}};G.cgs=JSON.parse(JSON.stringify(G.si)),G.cgs.LENGTH={unit:P.m,prefix:I.SHORT.c},G.cgs.MASS={unit:P.g,prefix:I.SHORT[""]},G.cgs.FORCE={unit:P.dyn,prefix:I.SHORT[""]},G.cgs.ENERGY={unit:P.erg,prefix:I.NONE[""]},G.us=JSON.parse(JSON.stringify(G.si)),G.us.LENGTH={unit:P.ft,prefix:I.NONE[""]},G.us.MASS={unit:P.lbm,prefix:I.NONE[""]},G.us.TEMPERATURE={unit:P.degF,prefix:I.NONE[""]},G.us.FORCE={unit:P.lbf,prefix:I.NONE[""]},G.us.ENERGY={unit:P.BTU,prefix:I.BTU[""]},G.us.POWER={unit:P.hp,prefix:I.NONE[""]},G.us.PRESSURE={unit:P.psi,prefix:I.NONE[""]},G.auto=JSON.parse(JSON.stringify(G.si));var Z=G.auto;for(var W in E.setUnitSystem=function(e){if(!V(G,e))throw new Error("Unit system "+e+" does not exist. Choices are: "+Object.keys(G).join(", "));Z=G[e]},E.getUnitSystem=function(){for(var e in G)if(V(G,e)&&G[e]===Z)return e},E.typeConverters={BigNumber:function(e){return new N(e+"")},Fraction:function(e){return new M(e)},Complex:function(e){return e},number:function(e){return e}},E._getNumberConverter=function(e){if(!E.typeConverters[e])throw new TypeError('Unsupported type "'+e+'"');return E.typeConverters[e]},P)if(V(P,W)){var J=P[W];J.dimensions=J.base.dimensions}for(var Y in j)if(V(j,Y)){var X=P[j[Y]],Q={};for(var K in X)V(X,K)&&(Q[K]=X[K]);Q.name=Y,P[Y]=Q}return E.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)},E.createUnit=function(e,t){if("object"!=typeof e)throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(t&&t.override)for(var r in e)if(V(e,r)&&E.deleteUnit(r),e[r].aliases)for(var n=0;n0&&!E.isValidAlpha(i)&&!O(i))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+e+'"')}}(e);var n,a,o,s=null,u=[],c=0;if(t&&"Unit"===t.type)s=t.clone();else if("string"==typeof t)""!==t&&(n=t);else{if("object"!=typeof t)throw new TypeError('Cannot create unit "'+e+'" from "'+t.toString()+'": expecting "string" or "Unit" or "Object"');n=t.definition,a=t.prefixes,c=t.offset,o=t.baseName,t.aliases&&(u=t.aliases.valueOf())}if(u)for(var l=0;l1e-12){h=!1;break}if(h){p=!0,f.base=R[m];break}}if(!p){o=o||e+"_STUFF";var y={dimensions:s.dimensions.slice(0)};y.key=o,R[o]=y,Z[o]={unit:f,prefix:I.NONE[""]},f.base=R[o]}}else{if(o=o||e+"_STUFF",k.indexOf(o)>=0)throw new Error('Cannot create new base unit "'+e+'": a base unit with that name already exists (and cannot be overridden)');for(var g in k.push(o),R)V(R,g)&&(R[g].dimensions[k.length-1]=0);for(var v={dimensions:[]},x=0;x{var{typed:t,Unit:r}=e;return t(pm,{"Object, Object":function(e,t){return r.createUnit(e,t)},Object:function(e){return r.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,t,n){var i={};return i[e]=t,r.createUnit(i,n)},"string, Unit | string | Object":function(e,t){var n={};return n[e]=t,r.createUnit(n,{})},string:function(e){var t={};return t[e]={},r.createUnit(t,{})}})})),hm="sqrtm",dm=W(hm,["typed","abs","add","multiply","sqrt","subtract","inv","size","max","identity"],(e=>{var{typed:t,abs:r,add:n,multiply:i,sqrt:a,subtract:o,inv:s,size:u,max:c,identity:l}=e,p=1e-6;function m(e){var t,a=0,f=e,m=l(u(e));do{var h=f;if(f=i(.5,n(h,s(m))),m=i(.5,n(m,s(h))),(t=c(r(o(f,h))))>p&&++a>1e3)throw new Error("computing square root of matrix: iterative method could not converge")}while(t>p);return f}return t(hm,{"Array | Matrix":function(e){var t=f(e)?e.size():je(e);switch(t.length){case 1:if(1===t[0])return a(e);throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:if(t[0]===t[1])return m(e);throw new RangeError("Matrix must be square (size: "+De(t)+")");default:throw new RangeError("Matrix must be at most two dimensional (size: "+De(t)+")")}}})})),ym="median",gm=W(ym,["typed","add","divide","compare","partitionSelect"],(e=>{var{typed:t,add:r,divide:n,compare:i,partitionSelect:a}=e;function o(e){try{var t=(e=et(e.valueOf())).length;if(0===t)throw new Error("Cannot calculate median of an empty array");if(t%2==0){for(var r=t/2-1,n=a(e,r+1),o=e[r],c=0;c0&&(o=e[c]);return u(o,n)}var l=a(e,(t-1)/2);return s(l)}catch(e){throw Gr(e,"median")}}var s=t({"number | BigNumber | Complex | Unit":function(e){return e}}),u=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,t){return n(r(e,t),2)}});return t(ym,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("median(A, dim) is not yet supported")},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function median");return o(e)}})})),vm="usolve",xm=W(vm,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(vm,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=(t=u(e,t,!0))._data,c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=[],d=l-1;d>=0;d--){var y=r[d][0]||0;if(o(y,0))h[d]=[0];else{for(var g=0,v=[],x=[],b=m[d],w=m[d+1]-1;w>=b;w--){var N=p[w];N===d?g=f[w]:N=0;m--){var h=r[m][0]||0,d=void 0;if(o(h,0))d=0;else{var y=p[m][m];if(o(y,0))throw new Error("Linear system cannot be solved since matrix is singular");d=n(h,y);for(var g=m-1;g>=0;g--)r[g]=[a(r[g][0]||0,i(d,p[g][m]))]}f[m]=[d]}return new s({data:f,size:[c,1]})}}));function bm(e,t){var r,n=t.length,i=[];if(e)for(r=0;r{var{typed:t,matrix:r,lup:n,slu:i,usolve:a,lsolve:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(wm,{"Array, Array | Matrix":function(e,t){e=r(e);var i=n(e);return p(i.L,i.U,i.p,null,t).valueOf()},"DenseMatrix, Array | Matrix":function(e,t){var r=n(e);return p(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){var r=n(e);return p(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,r,n){var a=i(e,r,n);return p(a.L,a.U,a.p,a.q,t)},"Object, Array | Matrix":function(e,t){return p(e.L,e.U,e.p,e.q,t)}});function c(e){if(f(e))return e;if(l(e))return r(e);throw new TypeError("Invalid Matrix LU decomposition")}function p(e,t,r,n,i){e=c(e),t=c(t),r&&((i=u(e,i,!0))._data=bm(r,i._data));var s=o(e,i),l=a(t,s);return n&&(l._data=bm(n,l._data)),l}}));var Mm=["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","divideScalar","inv","bignumber","multiply","add","larger","column","flatten","number","complex","sqrt","diag","qr","usolve","usolveAll","im","re","smaller","matrixFromColumns","dot"],Sm=W("eigs",Mm,(e=>{var{config:t,typed:r,matrix:n,addScalar:u,subtract:c,equal:l,abs:f,atan:p,cos:m,sin:h,multiplyScalar:d,divideScalar:y,inv:g,bignumber:v,multiply:x,add:b,larger:w,column:N,flatten:M,number:S,complex:E,sqrt:A,diag:O,qr:C,usolve:_,usolveAll:T,im:B,re:q,smaller:z,matrixFromColumns:D,dot:I}=e,k=function(e){var{config:t,addScalar:r,subtract:n,abs:i,atan:a,cos:o,sin:s,multiplyScalar:u,inv:c,bignumber:l,multiply:f,add:p}=e;function m(e,r){for(var n,i=e.length,a=Math.abs(r/i),o=new Array(i),s=0;s=Math.abs(a);){var c=u[0][0],l=u[0][1];e=v(e,(f=e[c][c],p=e[l][l],m=e[c][l],h=void 0,h=p-f,n=Math.abs(h)<=t.epsilon?Math.PI/4:.5*Math.atan(2*m/(p-f))),c,l),o=d(o,n,c,l),u=x(e)}for(var f,p,m,h,y=N(i,0),g=0;g=i(p);){var v=d[0][0],x=d[0][1];e=g(e,(M=e[v][v],S=e[x][x],E=e[v][x],A=void 0,A=n(S,M),o=i(A)<=t.epsilon?l(-1).acos().div(4):u(.5,a(f(2,E,c(A))))),v,x),m=y(m,o,v,x),d=b(e)}for(var M,S,E,A,O=N(s,0),C=0;C2&&void 0!==arguments[2]?arguments[2]:t.epsilon,i=arguments.length>3?arguments[3]:void 0;if("number"===i)return m(e,n);if("BigNumber"===i)return h(e,n);throw TypeError("Unsupported data type: "+i)}}({config:t,addScalar:u,subtract:c,column:N,flatten:M,equal:l,abs:f,atan:p,cos:m,sin:h,multiplyScalar:d,inv:g,bignumber:v,complex:E,multiply:x,add:b}),R=function(e){var{addScalar:t,subtract:r,flatten:n,multiply:i,multiplyScalar:a,divideScalar:o,sqrt:s,abs:u,bignumber:c,diag:l,inv:f,qr:p,usolve:m,usolveAll:h,equal:d,complex:y,larger:g,smaller:v,matrixFromColumns:x,dot:b}=e;function w(e,t,n,i,a,o,s,l){var f="BigNumber"===l,p="Complex"===l,m=f?c(0):p?y(0):0,h=f?c(1):p?y(1):1;if(v(u(n),s))return[[h,m],[m,h]];if(g(u(r(a,o)),s))return[[r(a,i),r(o,i)],[n,n]];var d=r(e,a),x=r(t,a),b=r(n,a),w=r(i,a);return v(u(x),s)?[[d,h],[b,m]]:[[x,m],[w,h]]}function N(e,t){for(var r=0;r=5)return null;for(s=0;;){var u=m(e,a);if(v(O(A(a,[u])),n))break;if(++s>=10)return null;a=C(u)}return a}function E(e,t,r){var n="BigNumber"===r,i="Complex"===r,a=Array(e).fill(0).map((e=>2*Math.random()-1));return n&&(a=a.map((e=>c(e)))),i&&(a=a.map((e=>y(e)))),C(a=A(a,t),r)}function A(e,t){for(var n of t)e=r(e,i(o(b(n,e),b(n,n)),n));return e}function O(e){return u(s(b(e,e)))}function C(e,t){var r="Complex"===t,n="BigNumber"===t?c(1):r?y(1):1;return i(o(n,O(e)),e)}return function(e,m,b,E,A){void 0===A&&(A=!0);var O=function(e,r,n,i,s){var f,p="BigNumber"===i,m="Complex"===i,h=p?c(0):m?y(0):0,x=p?c(1):m?y(1):1,b=p?c(10):2,w=a(b,b);s&&(f=Array(r).fill(x));for(var N=!1;!N;){N=!0;for(var M=0;M1&&(D=l(Array(B-1).fill(g)))),B-=1,_.pop();for(var P=0;P2&&(D=l(Array(B-2).fill(g)))),B-=2,_.pop(),_.pop();for(var L=0;L+r(u(e),u(t)))),I>100){var H=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+T.join(", "));throw H.values=T,H.vectors=[],H}return{values:T,C:m?i(z,function(e,t){for(var r=[],n=0;ni(a,e)))).shift();I.lengthn(e))))}if(0!==B.length){var R=new Error("Failed to find eigenvectors for the following eigenvalues: "+B.join(", "));throw R.values=o,R.vectors=O,R}return O}(e,m,T,_,b,E),C=x(...C)),{values:_,vectors:C}}}({config:t,addScalar:u,subtract:c,multiply:x,multiplyScalar:d,flatten:M,divideScalar:y,sqrt:A,abs:f,bignumber:v,diag:O,qr:C,inv:g,usolve:_,usolveAll:T,equal:l,complex:E,larger:w,smaller:z,matrixFromColumns:D,dot:I});return r("eigs",{Array:function(e){return F(n(e))},"Array, number|BigNumber":function(e,t){return F(n(e),t)},Matrix:function(e){var{values:t,vectors:r}=F(e);return{values:n(t),vectors:n(r)}},"Matrix, number|BigNumber":function(e,t){var{values:r,vectors:i}=F(e,t);return{values:n(r),vectors:n(i)}}});function F(e,r){void 0===r&&(r=t.epsilon);var n=e.size();if(2!==n.length||n[0]!==n[1])throw new RangeError("Matrix must be square (size: "+De(n)+")");var i=e.toArray(),a=n[0];if(function(e,t,r){for(var n=0;n{var{typed:t,abs:r,map:n,median:i,subtract:a}=e;return t("mad",{"Array | Matrix":o,"...":function(e){return o(e)}});function o(e){if(0===(e=et(e.valueOf())).length)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var t=i(e);return i(n(e,(function(e){return r(a(e,t))})))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf("median")?new TypeError(e.message.replace("median","mad")):Gr(e,"mad")}}})),Om="unit",Cm=["typed","Unit"],_m=W(Om,Cm,(e=>{var{typed:t,Unit:r}=e;return t(Om,{Unit:function(e){return e.clone()},string:function(e){return r.isValuelessUnit(e)?new r(null,e):r.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string":function(e,t){return new r(e,t)},"Array | Matrix":function(e){return $t(e,this)}})})),Tm=["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten"],Bm=W("intersect",Tm,(e=>{var{typed:t,config:r,abs:n,add:i,addScalar:o,matrix:s,multiply:u,multiplyScalar:c,divideScalar:l,subtract:f,smaller:p,equalScalar:m,flatten:h}=e;return t("intersect",{"Array, Array, Array":d,"Array, Array, Array, Array":y,"Matrix, Matrix, Matrix":function(e,t,r){var n=d(e.valueOf(),t.valueOf(),r.valueOf());return null===n?null:s(n)},"Matrix, Matrix, Matrix, Matrix":function(e,t,r,n){var i=y(e.valueOf(),t.valueOf(),r.valueOf(),n.valueOf());return null===i?null:s(i)}});function d(e,t,r){if(e=g(e),t=g(t),r=g(r),!b(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!b(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!function(e){return 4===e.length&&v(e[0])&&v(e[1])&&v(e[2])&&v(e[3])}(r))throw new TypeError("Array with 4 numbers expected as third argument");return function(e,t,r,n,i,a,s,u,p,m){var h=c(e,s),d=c(n,s),y=c(t,u),g=c(i,u),v=c(r,p),x=c(a,p),b=f(f(f(m,h),y),v),w=f(f(f(o(o(d,g),x),h),y),v),N=l(b,w);return[o(e,c(N,f(n,e))),o(t,c(N,f(i,t))),o(r,c(N,f(a,r)))]}(e[0],e[1],e[2],t[0],t[1],t[2],r[0],r[1],r[2],r[3])}function y(e,t,a,s){if(e=g(e),t=g(t),a=g(a),s=g(s),2===e.length){if(!x(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!x(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!x(a))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!x(s))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return function(e,t,a,s){var m=e,h=a,d=f(m,t),y=f(h,s),g=f(c(d[0],y[1]),c(y[0],d[1]));if(p(n(g),r.epsilon))return null;var v=c(y[0],m[1]),x=c(y[1],m[0]),b=c(y[0],h[1]),w=c(y[1],h[0]),N=l(o(f(f(v,x),b),w),g);return i(u(d,N),m)}(e,t,a,s)}if(3===e.length){if(!b(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!b(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!b(a))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!b(s))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return h=e[0],d=e[1],y=e[2],v=t[0],N=t[1],M=t[2],S=a[0],E=a[1],A=a[2],T=w(h,S,O=s[0],S,d,E,C=s[1],E,y,A,_=s[2],A),B=w(O,S,v,h,C,E,N,d,_,A,M,y),q=w(h,S,v,h,d,E,N,d,y,A,M,y),z=w(O,S,O,S,C,E,C,E,_,A,_,A),D=w(v,h,v,h,N,d,N,d,M,y,M,y),I=l(f(c(T,B),c(q,z)),f(c(D,z),c(B,B))),k=l(o(T,c(I,B)),z),R=o(h,c(I,f(v,h))),F=o(d,c(I,f(N,d))),U=o(y,c(I,f(M,y))),P=o(S,c(k,f(O,S))),j=o(E,c(k,f(C,E))),L=o(A,c(k,f(_,A))),m(R,P)&&m(F,j)&&m(U,L)?[R,F,U]:null}throw new TypeError("Arrays with two or thee dimensional points expected");var h,d,y,v,N,M,S,E,A,O,C,_,T,B,q,z,D,I,k,R,F,U,P,j,L}function g(e){return 1===e.length?e[0]:e.length>1&&Array.isArray(e[0])&&e.every((e=>Array.isArray(e)&&1===e.length))?h(e):e}function v(e){return"number"==typeof e||a(e)}function x(e){return 2===e.length&&v(e[0])&&v(e[1])}function b(e){return 3===e.length&&v(e[0])&&v(e[1])&&v(e[2])}function w(e,t,r,n,i,a,s,u,l,p,m,h){var d=c(f(e,t),f(r,n)),y=c(f(i,a),f(s,u)),g=c(f(l,p),f(m,h));return o(o(d,y),g)}})),qm="norm",zm=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],Dm=W(qm,zm,(e=>{var{typed:t,abs:r,add:n,pow:i,conj:a,sqrt:o,multiply:s,equalScalar:u,larger:c,smaller:l,matrix:f,ctranspose:p,eigs:m}=e;return t(qm,{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},boolean:function(e){return Math.abs(e)},Array:function(e){return h(f(e),2)},Matrix:function(e){return h(e,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(e){return this(e)},"Array, number | BigNumber | string":function(e,t){return h(f(e),t)},"Matrix, number | BigNumber | string":function(e,t){return h(e,t)}});function h(e,t){var f=e.size();if(1===f.length)return function(e,t){if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=0;return e.forEach((function(e){var n=r(e);c(n,t)&&(t=n)}),!0),t}(e);if(t===Number.NEGATIVE_INFINITY||"-inf"===t)return function(e){var t;return e.forEach((function(e){var n=r(e);t&&!l(n,t)||(t=n)}),!0),t||0}(e);if("fro"===t)return h(e,2);if("number"==typeof t&&!isNaN(t)){if(!u(t,0)){var a=0;return e.forEach((function(e){a=n(i(r(e),t),a)}),!0),i(a,1/t)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}(e,t);if(2===f.length){if(f[0]&&f[1])return function(e,t){if(1===t)return function(e){var t=[],i=0;return e.forEach((function(e,a){var o=a[1],s=n(t[o]||0,r(e));c(s,i)&&(i=s),t[o]=s}),!0),i}(e);if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=[],i=0;return e.forEach((function(e,a){var o=a[0],s=n(t[o]||0,r(e));c(s,i)&&(i=s),t[o]=s}),!0),i}(e);if("fro"===t)return function(e){var t=0;return e.forEach((function(e,r){t=n(t,s(e,a(e)))})),r(o(t))}(e);if(2===t)return function(e){var t=e.size();if(t[0]!==t[1])throw new RangeError("Invalid matrix dimensions");var n=p(e),i=s(n,e),a=m(i).values.toArray(),u=a[a.length-1];return r(o(u))}(e);throw new Error("Unsupported parameter value "+t)}(e,t);throw new RangeError("Invalid matrix dimensions")}}})),Im="rotationMatrix",km=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],Rm=W(Im,km,(e=>{var{typed:t,config:r,multiplyScalar:n,addScalar:i,unaryMinus:o,norm:s,BigNumber:u,matrix:c,DenseMatrix:l,SparseMatrix:f,cos:p,sin:m}=e;return t(Im,{"":function(){return"Matrix"===r.matrix?c([]):[]},string:function(e){return c(e)},"number | BigNumber | Complex | Unit":function(e){return h(e,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(e,t){return h(e,t)},"number | BigNumber | Complex | Unit, Array":function(e,t){var r=c(t);return d(r),v(e,r,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,t){d(t);var n=t.storage()||("Matrix"===r.matrix?"dense":void 0);return v(e,t,n)},"number | BigNumber | Complex | Unit, Array, string":function(e,t,r){var n=c(t);return d(n),v(e,n,r)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,t,r){return d(t),v(e,t,r)}});function h(e,t){var r=a(e)?new u(-1):-1,i=p(e),o=m(e);return g([[i,n(r,o)],[o,i]],t)}function d(e){var t=e.size();if(t.length<1||3!==t[0])throw new RangeError("Vector must be of dimensions 1x3")}function y(e){return e.reduce(((e,t)=>n(e,t)))}function g(e,t){if(t){if("sparse"===t)return new f(e);if("dense"===t)return new l(e);throw new TypeError('Unknown matrix type "'.concat(t,'"'))}return e}function v(e,t,r){var n=s(t);if(0===n)throw new RangeError("Rotation around zero vector");var c=a(e)?u:null,l=c?new c(1):1,f=c?new c(-1):-1,h=c?new c(t.get([0])/n):t.get([0])/n,d=c?new c(t.get([1])/n):t.get([1])/n,v=c?new c(t.get([2])/n):t.get([2])/n,x=p(e),b=i(l,o(x)),w=m(e);return g([[i(x,y([h,h,b])),i(y([h,d,b]),y([f,v,w])),i(y([h,v,b]),y([d,w]))],[i(y([h,d,b]),y([v,w])),i(x,y([d,d,b])),i(y([d,v,b]),y([f,h,w]))],[i(y([h,v,b]),y([f,d,w])),i(y([d,v,b]),y([h,w])),i(x,y([v,v,b]))]],r)}})),Fm="rotate",Um=["typed","multiply","rotationMatrix"],Pm=W(Fm,Um,(e=>{var{typed:t,multiply:r,rotationMatrix:n}=e;return t(Fm,{"Array , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),r(n(t),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),r(n(t),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),r(n(t,a),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),r(n(t,a),e)}});function i(e,t){var r=Array.isArray(e)?je(e):e.size();if(r.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(t));if(2===r.length&&1!==r[1])throw new RangeError("Vector must be of dimensions 1x".concat(t));if(r[0]!==t)throw new RangeError("Vector must be of dimensions 1x".concat(t))}})),jm="multinomial",Lm=["typed","add","divide","multiply","factorial","isInteger","isPositive"],Hm=W(jm,Lm,(e=>{var{typed:t,add:r,divide:n,multiply:i,factorial:a,isInteger:o,isPositive:s}=e;return t(jm,{"Array | Matrix":function(e){var t=0,u=1;return Ht(e,(function(e){if(!o(e)||!s(e))throw new TypeError("Positive integer value expected in function multinomial");t=r(t,e),u=i(u,a(e))})),n(a(t),u)}})})),$m=Nn({}),Gm=Sn({}),Zm=En({}),Vm=In({}),Wm=kn({}),Jm=Dn({}),Ym=Kn({config:n}),Xm=ei({}),Qm=ti({}),Km=Jn({Complex:Gm}),eh=$n({BigNumber:Ym,config:n}),th=Zn({BigNumber:Ym,config:n}),rh=Fn({BigNumber:Ym,config:n}),nh=Un({BigNumber:Ym,config:n}),ih=Vn({BigNumber:Ym,config:n}),ah=Pn({BigNumber:Ym,config:n}),oh=Ti({BigNumber:Ym,config:n}),sh=wi({BigNumber:Ym,config:n}),uh=Pi({BigNumber:Ym,config:n}),ch=_i({BigNumber:Ym,config:n}),lh=ta({}),fh=jn({BigNumber:Ym,config:n}),ph=Rn({BigNumber:Ym,config:n}),mh=Gn({BigNumber:Ym,config:n}),hh=Yn({}),dh=ra({Matrix:Xm}),yh=Ln({BigNumber:Ym,config:n}),gh=aa({BigNumber:Ym,Complex:Gm,DenseMatrix:dh,Fraction:lh}),vh=la({typed:gh}),xh=pa({typed:gh}),bh=xa({typed:gh}),wh=wa({typed:gh}),Nh=Sa({config:n,typed:gh}),Mh=Ea({typed:gh}),Sh=Oa({typed:gh}),Eh=Ca({Complex:Gm,typed:gh}),Ah=Ta({typed:gh}),Oh=ro({BigNumber:Ym,config:n,typed:gh}),Ch=wr({isInteger:vh,typed:gh}),_h=io({typed:gh}),Th=oo({Complex:Gm,typed:gh}),Bh=uo({Complex:Gm,config:n,typed:gh}),qh=co({typed:gh}),zh=fo({BigNumber:Ym,Fraction:lh,complex:Eh,typed:gh}),Dh=mo({typed:gh}),Ih=qo({typed:gh}),kh=zo({typed:gh}),Rh=Do({typed:gh}),Fh=Po({typed:gh}),Uh=jo({typed:gh}),Ph=$o({typed:gh}),jh=Zo({typed:gh}),Lh=Wo({typed:gh}),Hh=ts({typed:gh}),$h=rs({format:Hh,typed:gh}),Gh=is({typed:gh}),Zh=ss({typed:gh}),Vh=cs({Complex:Gm,config:n,typed:gh}),Wh=Cs({BigNumber:Ym,typed:gh}),Jh=Ts({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),Yh=qs({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),Xh=Ds({Complex:Gm,config:n,typed:gh}),Qh=Is({typed:gh}),Kh=Rs({Complex:Gm,config:n,typed:gh}),ed=Us({typed:gh}),td=js({BigNumber:Ym,typed:gh}),rd=Hs({BigNumber:Ym,typed:gh}),nd=Gs({BigNumber:Ym,typed:gh}),id=Vs({typed:gh}),ad=Ws({typed:gh}),od=Qs({typed:gh}),sd=iu({config:n,typed:gh}),ud=su({config:n,typed:gh}),cd=Hn({BigNumber:Ym,config:n}),ld=cu({typed:gh}),fd=fu({isNumeric:xh,typed:gh}),pd=mu({typed:gh}),md=du({typed:gh}),hd=yu({Fraction:lh,typed:gh}),dd=vu({typed:gh}),yd=bu({typed:gh}),gd=wu({typed:gh}),vd=Mu({Complex:Gm,config:n,typed:gh}),xd=Su({Complex:Gm,config:n,typed:gh}),bd=Au({typed:gh}),wd=Cu({typed:gh}),Nd=Tu({isNaN:wh,isNumeric:xh,typed:gh}),Md=Bu({format:Hh,typed:gh}),Sd=zu({Complex:Gm,config:n,typed:gh}),Ed=Iu({BigNumber:Ym,typed:gh}),Ad=ku({typed:gh}),Od=Ru({typed:gh}),Cd=Fu({BigNumber:Ym,typed:gh}),_d=Uu({typed:gh}),Td=ju({typed:gh}),Bd=$u({config:n,typed:gh}),qd=Wn({BigNumber:Ym,config:n}),zd=Zu({typed:gh}),Dd=Vu({Matrix:Xm,equalScalar:Nh,typed:gh}),Id=Ju({DenseMatrix:dh,Matrix:Xm,SparseMatrix:Dd,typed:gh}),kd=Yu({typed:gh}),Rd=rc({BigNumber:Ym,DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),Fd=uc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),Ud=fc({BigNumber:Ym,equalScalar:Nh,matrix:Id,typed:gh}),Pd=mc({BigNumber:Ym,config:n,matrix:Id,typed:gh}),jd=dc({equalScalar:Nh,matrix:Id,typed:gh}),Ld=vc({DenseMatrix:dh,matrix:Id,typed:gh}),Hd=xc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),$d=Lr({isInteger:vh,matrix:Id,typed:gh}),Gd=wc({DenseMatrix:dh,SparseMatrix:Dd,matrix:Id,typed:gh}),Zd=Mc({BigNumber:Ym,DenseMatrix:dh,SparseMatrix:Dd,config:n,matrix:Id,typed:gh}),Vd=Sc({BigNumber:Ym,config:n,matrix:Id,typed:gh}),Wd=Ac({isInteger:vh,matrix:Id,typed:gh}),Jd=Cc({matrix:Id,config:n,typed:gh}),Yd=Dr({matrix:Id,typed:gh}),Xd=Tc({BigNumber:Ym,config:n,matrix:Id,typed:gh}),Qd=Bc({format:Hh,typed:gh}),Kd=Rc({BigNumber:Ym,DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),ey=jc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),ty=Hc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),ry=Gc({BigNumber:Ym,DenseMatrix:dh,Fraction:lh,config:n,equalScalar:Nh,matrix:Id,typed:gh}),ny=Vc({matrix:Id,typed:gh}),iy=Jc({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),ay=Xc({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),oy=Kc({DenseMatrix:dh,config:n,equalScalar:Nh,matrix:Id,typed:gh}),sy=el({DenseMatrix:dh,smaller:iy}),uy=tl({larger:ay,smaller:iy}),cy=nl({SparseMatrix:Dd,typed:gh}),ly=al({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),fy=ul({BigNumber:Ym,DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),py=cl({BigNumber:Ym,typed:gh}),my=ll({DenseMatrix:dh,SparseMatrix:Dd,addScalar:yd,equalScalar:Nh,matrix:Id,typed:gh}),hy=fl({addScalar:yd,conj:bd,multiplyScalar:qh,size:Jd,typed:gh}),dy=ml({addScalar:yd,combinations:od,isInteger:vh,isNegative:zd,isPositive:bh,larger:ay,typed:gh}),yy=dl({typed:gh}),gy=gl({isZero:yy,matrix:Id,typed:gh}),vy=xl({BigNumber:Ym,Complex:Gm,Fraction:lh,config:n,isNegative:zd,matrix:Id,typed:gh,unaryMinus:dd}),xy=bl({config:n,equalScalar:Nh,matrix:Id,round:Kd,typed:gh}),by=Nl({addScalar:yd,dot:hy,equalScalar:Nh,matrix:Id,multiplyScalar:qh,typed:gh}),wy=Sl({equalScalar:Nh,matrix:Id,multiplyScalar:qh,typed:gh}),Ny=El({typed:gh}),My=Ol({matrix:Id,typed:gh}),Sy=_l({config:n,matrix:Id}),Ey=Bl({matrix:Id,typed:gh}),Ay=ql({matrix:Id,typed:gh}),Oy=zl({Complex:Gm,config:n,fraction:hd,identity:Zd,matrix:Id,multiply:by,number:Mh,typed:gh}),Cy=Il({DenseMatrix:dh,equalScalar:Nh,matrix:Id,pow:Oy,typed:gh}),_y=Rl({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),Ty=Pl({compare:ry,typed:gh}),By=Ll({compareText:ny,isZero:yy,typed:gh}),qy=$l({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),zy=Zl({compare:ry,isNaN:wh,isNumeric:xh,typed:gh}),Dy=Vl({ImmutableDenseMatrix:sy}),Iy=Jl({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),ky=Yl({typed:gh}),Ry=Ql({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Fy=ef({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Uy=rf({Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Py=af({compareNatural:Ty,typed:gh}),jy=of({add:my,matrix:Id,typed:gh}),Ly=sf({add:my,compare:ry,multiply:by,partitionSelect:zy,typed:gh}),Hy=pf({BigNumber:Ym,Complex:Gm,config:n,multiplyScalar:qh,pow:Oy,typed:gh}),$y=mf({BigNumber:Ym,typed:gh}),Gy=df({flatten:My,matrix:Id,size:Jd,typed:gh}),Zy=yf({equalScalar:Nh,matrix:Id,typed:gh}),Vy=vf({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),Wy=bf({matrix:Id,multiplyScalar:qh,typed:gh}),Jy=wf({matrix:Id,typed:gh}),Yy=Nf({bignumber:$y,fraction:hd,number:Mh}),Xy=Mf({equalScalar:Nh,matrix:Id,not:Fh,typed:gh,zeros:Xd}),Qy=Ef({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),Ky=Of({compare:ry,compareNatural:Ty,matrix:Id,typed:gh}),eg=Jr({config:n,numeric:Yy,smaller:iy,typed:gh}),tg=Cf({BigNumber:Ym,typed:gh}),rg=Tf({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),ng=qf({Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),ig=Df({Index:Dy,typed:gh}),ag=Xr({add:my,config:n,numeric:Yy,typed:gh}),og=kf({gamma:Hy,typed:gh}),sg=Ff({factorial:og,typed:gh}),ug=jf({flatten:My,matrix:Id,size:Jd,typed:gh}),cg=Hf({DenseMatrix:dh,addScalar:yd,equalScalar:Nh,matrix:Id,typed:gh,unaryMinus:dd}),lg=Zf({matrix:Id,multiply:by,subtract:cg,typed:gh}),fg=nn({bignumber:$y,matrix:Id,config:n,larger:ay,largerEq:qy,smaller:iy,smallerEq:Qy,typed:gh}),pg=ln({Index:Dy,matrix:Id,range:fg,typed:gh}),mg=Wf({config:n,multiplyScalar:qh,numeric:Yy,typed:gh}),hg=Yf({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),dg=Zr({config:n,larger:ay,numeric:Yy,typed:gh}),yg=Qf({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),gg=ep({Index:Dy,concat:$d,setDifference:Ry,size:Jd,subset:Yd,typed:gh}),vg=tp({config:n,equalScalar:Nh,matrix:Id,round:Kd,typed:gh}),xg=rp({DenseMatrix:dh,matrix:Id,typed:gh}),bg=ip({prod:mg,size:Jd,typed:gh}),wg=op({conj:bd,transpose:Jy,typed:gh}),Ng=up({equal:hg,typed:gh}),Mg=lp({Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Sg=fp({Complex:Gm,ceil:vg,floor:xy,matrix:Id,typed:gh}),Eg=sn({matrix:Id,number:Mh,subtract:cg,typed:gh}),Ag=mp({numeric:Yy,typed:gh}),Og=dp({Complex:Gm,config:n,divideScalar:Ag,typed:gh}),Cg=vp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),_g=bp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),Tg=wp({FibonacciHeap:uy,addScalar:yd,equalScalar:Nh}),Bg=Mp({Index:Dy,concat:$d,setIntersect:Fy,setSymDifference:gg,size:Jd,subset:Yd,typed:gh}),qg=Sp({DenseMatrix:dh,Spa:Tg,SparseMatrix:Dd,abs:kd,addScalar:yd,divideScalar:Ag,equalScalar:Nh,larger:ay,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh,unaryMinus:dd}),zg=Rp({SparseMatrix:Dd,abs:kd,add:my,divideScalar:Ag,larger:ay,largerEq:qy,multiply:by,subtract:cg,transpose:Jy,typed:gh}),Dg=Fp({lup:qg,matrix:Id,multiply:by,subtract:cg,typed:gh,unaryMinus:dd}),Ig=Pp({abs:kd,addScalar:yd,divideScalar:Ag,multiplyScalar:qh,sqrt:xd,subtract:cg,typed:gh,unaryMinus:dd}),kg=Lp({addScalar:yd,combinations:od,divideScalar:Ag,factorial:og,isInteger:vh,isNegative:zd,larger:ay,multiplyScalar:qh,pow:Oy,subtract:cg,typed:gh}),Rg=$p({addScalar:yd,combinations:od,divideScalar:Ag,isInteger:vh,isNegative:zd,multiplyScalar:qh,typed:gh}),Fg=en({Index:Dy,matrix:Id,range:fg,typed:gh}),Ug=Gp({Complex:Gm,config:n,divideScalar:Ag,typed:gh}),Pg=Vp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,typed:gh}),jg=Jp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),Lg=Xp({abs:kd,addScalar:yd,divideScalar:Ag,isPositive:bh,multiplyScalar:qh,smaller:iy,sqrt:xd,typed:gh}),Hg=Qp({addScalar:yd,complex:Eh,conj:bd,divideScalar:Ag,equal:hg,identity:Zd,isZero:yy,matrix:Id,multiplyScalar:qh,sign:zh,sqrt:xd,subtract:cg,typed:gh,unaryMinus:dd,zeros:Xd}),$g=Kp({abs:kd,addScalar:yd,det:Dg,divideScalar:Ag,identity:Zd,matrix:Id,multiply:by,typed:gh,unaryMinus:dd}),Gg=tm({abs:kd,add:my,identity:Zd,inv:$g,multiply:by,typed:gh}),Zg=rm({divideScalar:Ag,equalScalar:Nh,inv:$g,matrix:Id,multiply:by,typed:gh}),Vg=mn({add:my,divide:Zg,typed:gh}),Wg=gn({add:my,apply:Ch,divide:Zg,isNaN:wh,multiply:by,subtract:cg,typed:gh}),Jg=im({divide:Zg,dotDivide:Pg,isNumeric:xh,log:Ug,matrix:Id,multiply:by,sum:ag,typed:gh}),Yg=om({addScalar:yd,isInteger:vh,isNegative:zd,stirlingS2:kg,typed:gh}),Xg=um({Complex:Gm,config:n,divideScalar:Ag,log:Ug,typed:gh}),Qg=fm({BigNumber:Ym,Complex:Gm,Fraction:lh,abs:kd,addScalar:yd,config:n,divideScalar:Ag,equal:hg,fix:Sg,format:Hh,isNumeric:xh,multiplyScalar:qh,number:Mh,pow:Oy,round:Kd,subtract:cg}),Kg=mm({Unit:Qg,typed:gh}),ev=dm({abs:kd,add:my,identity:Zd,inv:$g,max:dg,multiply:by,size:Jd,sqrt:xd,subtract:cg,typed:gh}),tv=gm({add:my,compare:ry,divide:Zg,partitionSelect:zy,typed:gh}),rv=bn({sqrt:xd,typed:gh,variance:Wg}),nv=Bi({BigNumber:Ym,Unit:Qg,config:n}),iv=fi({BigNumber:Ym,Unit:Qg,config:n}),av=zi({BigNumber:Ym,Unit:Qg,config:n}),ov=pi({BigNumber:Ym,Unit:Qg,config:n}),sv=Si({BigNumber:Ym,Unit:Qg,config:n}),uv=xi({BigNumber:Ym,Unit:Qg,config:n}),cv=Di({BigNumber:Ym,Unit:Qg,config:n}),lv=Ii({BigNumber:Ym,Unit:Qg,config:n}),fv=ni({BigNumber:Ym,Unit:Qg,config:n}),pv=Ni({BigNumber:Ym,Unit:Qg,config:n}),mv=yi({BigNumber:Ym,Unit:Qg,config:n}),hv=oi({BigNumber:Ym,Unit:Qg,config:n}),dv=$i({BigNumber:Ym,Unit:Qg,config:n}),yv=Fi({BigNumber:Ym,Unit:Qg,config:n}),gv=Ei({BigNumber:Ym,Unit:Qg,config:n}),vv=Yi({BigNumber:Ym,Unit:Qg,config:n}),xv=Vi({BigNumber:Ym,Unit:Qg,config:n}),bv=Xi({BigNumber:Ym,Unit:Qg,config:n}),wv=Mi({BigNumber:Ym,Unit:Qg,config:n}),Nv=ai({BigNumber:Ym,Unit:Qg,config:n}),Mv=ji({BigNumber:Ym,Unit:Qg,config:n}),Sv=Li({BigNumber:Ym,Unit:Qg,config:n}),Ev=ui({BigNumber:Ym,Unit:Qg,config:n}),Av=xm({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),Ov=Nm({DenseMatrix:dh,lsolve:Cg,lup:qg,matrix:Id,slu:zg,typed:gh,usolve:Av}),Cv=Sm({abs:kd,add:my,addScalar:yd,atan:Qh,bignumber:$y,column:Fg,complex:Eh,config:n,cos:Od,diag:Gd,divideScalar:Ag,dot:hy,equal:hg,flatten:My,im:Rh,inv:$g,larger:ay,matrix:Id,matrixFromColumns:Gy,multiply:by,multiplyScalar:qh,number:Mh,qr:Hg,re:Ny,sin:_d,smaller:iy,sqrt:xd,subtract:cg,typed:gh,usolve:Av,usolveAll:jg}),_v=Am({abs:kd,map:jh,median:tv,subtract:cg,typed:gh}),Tv=qi({BigNumber:Ym,Unit:Qg,config:n}),Bv=vi({BigNumber:Ym,Unit:Qg,config:n}),qv=si({BigNumber:Ym,Unit:Qg,config:n}),zv=bi({BigNumber:Ym,Unit:Qg,config:n}),Dv=Zi({BigNumber:Ym,Unit:Qg,config:n}),Iv=ki({BigNumber:Ym,Unit:Qg,config:n}),kv=Gi({BigNumber:Ym,Unit:Qg,config:n}),Rv=di({BigNumber:Ym,Unit:Qg,config:n}),Fv=Wi({BigNumber:Ym,Unit:Qg,config:n}),Uv=Ai({BigNumber:Ym,Unit:Qg,config:n}),Pv=ri({BigNumber:Ym,Unit:Qg,config:n}),jv=Hi({BigNumber:Ym,Unit:Qg,config:n}),Lv=_m({Unit:Qg,typed:gh}),Hv=Bm({abs:kd,add:my,addScalar:yd,config:n,divideScalar:Ag,equalScalar:Nh,flatten:My,matrix:Id,multiply:by,multiplyScalar:qh,smaller:iy,subtract:cg,typed:gh}),$v=ci({BigNumber:Ym,Unit:Qg,config:n}),Gv=Ri({BigNumber:Ym,Unit:Qg,config:n}),Zv=hi({BigNumber:Ym,Unit:Qg,config:n}),Vv=ii({BigNumber:Ym,Unit:Qg,config:n}),Wv=Oi({BigNumber:Ym,Unit:Qg,config:n}),Jv=Dm({abs:kd,add:my,conj:bd,ctranspose:wg,eigs:Cv,equalScalar:Nh,larger:ay,matrix:Id,multiply:by,pow:Oy,smaller:iy,sqrt:xd,typed:gh}),Yv=li({BigNumber:Ym,Unit:Qg,config:n}),Xv=Ui({BigNumber:Ym,Unit:Qg,config:n}),Qv=Ci({BigNumber:Ym,Unit:Qg,config:n}),Kv=Rm({BigNumber:Ym,DenseMatrix:dh,SparseMatrix:Dd,addScalar:yd,config:n,cos:Od,matrix:Id,multiplyScalar:qh,norm:Jv,sin:_d,typed:gh,unaryMinus:dd}),ex=gi({BigNumber:Ym,Unit:Qg,config:n}),tx=Ji({BigNumber:Ym,Unit:Qg,config:n}),rx=Pm({multiply:by,rotationMatrix:Kv,typed:gh}),nx=Hm({add:my,divide:Zg,factorial:og,isInteger:vh,isPositive:bh,multiply:by,typed:gh}),ix=mi({BigNumber:Ym,Unit:Qg,config:n}),ax={},ox={},sx={},ux=ue({mathWithTransform:ox}),cx=ct({Node:ux}),lx=lt({Node:ux,ResultSet:$m}),fx=vt({Node:ux}),px=xt({Node:ux}),mx=bt({Node:ux}),hx=Et({Node:ux}),dx=At({math:ax}),yx=Ot({classes:sx}),gx=Ct({Node:ux}),vx=_t({Node:ux}),xx=Tt({Node:ux}),bx=Bt({Node:ux,typed:gh}),wx=zt({Chain:dx,typed:gh}),Nx=kt({Node:ux,subset:Yd}),Mx=Rt({Node:ux,Range:Zm,size:Jd}),Sx=Ft({matrix:Id,Node:ux,subset:Yd}),Ex=Ut({Unit:Qg,Node:ux,math:ax}),Ax=jt({Node:ux,SymbolNode:Ex,math:ax}),Ox=Jt({AccessorNode:Nx,ArrayNode:cx,AssignmentNode:Sx,BlockNode:lx,ConditionalNode:gx,ConstantNode:fx,FunctionAssignmentNode:bx,FunctionNode:Ax,IndexNode:Mx,ObjectNode:px,OperatorNode:vx,ParenthesisNode:mx,RangeNode:xx,RelationalNode:hx,SymbolNode:Ex,config:n,numeric:Yy,typed:gh}),Cx=Xt({parse:Ox,typed:gh}),_x=Qt({parse:Ox}),Tx=or({bignumber:$y,fraction:hd,ConstantNode:fx,FunctionNode:Ax,OperatorNode:vx,ParenthesisNode:mx,SymbolNode:Ex,add:my,config:n,divide:Zg,equal:hg,isZero:yy,mathWithTransform:ox,multiply:by,parse:Ox,pow:Oy,subtract:cg,typed:gh}),Bx=ur({bignumber:$y,fraction:hd,ConstantNode:fx,FunctionNode:Ax,OperatorNode:vx,ParenthesisNode:mx,SymbolNode:Ex,add:my,config:n,divide:Zg,equal:hg,isZero:yy,mathWithTransform:ox,multiply:by,parse:Ox,pow:Oy,simplify:Tx,subtract:cg,typed:gh}),qx=cr({evaluate:Cx}),zx=hr({Help:_x,mathWithTransform:ox,typed:gh}),Dx=dr({ConstantNode:fx,FunctionNode:Ax,OperatorNode:vx,ParenthesisNode:mx,SymbolNode:Ex,config:n,equal:hg,isZero:yy,numeric:Yy,parse:Ox,simplify:Tx,typed:gh}),Ix=gr({Parser:qx,typed:gh}),kx=xr({parse:Ox,typed:gh});e(ax,{reviver:yx,false:Vm,null:Wm,true:Jm,replacer:Qm,i:Km,LN10:eh,LOG10E:th,NaN:rh,pi:nh,SQRT1_2:ih,tau:ah,efimovFactor:oh,fineStructure:sh,sackurTetrode:uh,weakMixingAngle:ch,e:fh,Infinity:ph,LOG2E:mh,PI:nh,version:hh,E:fh,phi:yh,typed:gh,isInteger:vh,isNumeric:xh,isPositive:bh,isNaN:wh,equalScalar:Nh,number:Mh,boolean:Sh,complex:Eh,splitUnit:Ah,unaryPlus:Oh,apply:Ch,cube:_h,expm1:Th,log10:Bh,multiplyScalar:qh,sign:zh,square:Dh,bitNot:Ih,arg:kh,im:Rh,not:Fh,filter:Uh,forEach:Ph,map:jh,erf:Lh,format:Hh,oct:$h,print:Gh,isPrime:Zh,acos:Vh,acot:Wh,acsc:Jh,asec:Yh,asin:Xh,atan:Qh,atanh:Kh,cosh:ed,coth:td,csch:rd,sech:nd,sinh:id,tanh:ad,chain:wx,combinations:od,pickRandom:sd,randomInt:ud,LN2:cd,clone:ld,hasNumericValue:fd,typeOf:pd,string:md,fraction:hd,unaryMinus:dd,addScalar:yd,exp:gd,log2:vd,sqrt:xd,conj:bd,getMatrixDataType:wd,mode:Nd,bin:Md,acosh:Sd,acsch:Ed,asinh:Ad,cos:Od,csc:Cd,sin:_d,combinationsWithRep:Td,random:Bd,SQRT2:qd,isNegative:zd,matrix:Id,abs:kd,gcd:Rd,mod:Fd,nthRoot:Ud,xgcd:Pd,bitAnd:jd,bitXor:Ld,or:Hd,concat:$d,diag:Gd,identity:Zd,ones:Vd,reshape:Wd,size:Jd,subset:Yd,zeros:Xd,hex:Qd,round:Kd,leftShift:ey,rightLogShift:ty,compare:ry,compareText:ny,smaller:iy,larger:ay,unequal:oy,sparse:cy,acoth:ly,atan2:fy,sec:py,add:my,dot:hy,composition:dy,isZero:yy,matrixFromFunction:gy,cbrt:vy,floor:xy,multiply:by,dotMultiply:wy,re:Ny,flatten:My,resize:Sy,squeeze:Ey,to:Ay,pow:Oy,dotPow:Cy,rightArithShift:_y,compareNatural:Ty,equalText:By,largerEq:qy,partitionSelect:zy,asech:Iy,tan:ky,setDifference:Ry,setIntersect:Fy,setMultiplicity:Uy,setSize:Py,trace:jy,quantileSeq:Ly,gamma:Hy,bignumber:$y,matrixFromColumns:Gy,lcm:Zy,bitOr:Vy,kron:Wy,transpose:Jy,numeric:Yy,and:Xy,smallerEq:Qy,sort:Ky,min:eg,cot:tg,setDistinct:rg,setPowerset:ng,index:ig,sum:ag,factorial:og,permutations:sg,matrixFromRows:ug,subtract:cg,cross:lg,range:fg,row:pg,prod:mg,equal:hg,max:dg,setCartesian:yg,setSymDifference:gg,ceil:vg,xor:xg,count:bg,ctranspose:wg,deepEqual:Ng,setIsSubset:Mg,fix:Sg,diff:Eg,divideScalar:Ag,nthRoots:Og,lsolve:Cg,lsolveAll:_g,setUnion:Bg,lup:qg,slu:zg,det:Dg,distance:Ig,stirlingS2:kg,catalan:Rg,column:Fg,log:Ug,dotDivide:Pg,usolveAll:jg,hypot:Lg,qr:Hg,inv:$g,expm:Gg,divide:Zg,mean:Vg,variance:Wg,kldivergence:Jg,bellNumbers:Yg,log1p:Xg,createUnit:Kg,sqrtm:ev,median:tv,std:rv,atomicMass:nv,bohrMagneton:iv,boltzmann:av,conductanceQuantum:ov,deuteronMass:sv,electronMass:uv,faraday:cv,firstRadiation:lv,gravitationConstant:fv,hartreeEnergy:pv,klitzing:mv,magneticConstant:hv,molarMass:dv,molarPlanckConstant:yv,neutronMass:gv,planckCharge:vv,planckLength:xv,planckTemperature:bv,protonMass:wv,reducedPlanckConstant:Nv,secondRadiation:Mv,stefanBoltzmann:Sv,vacuumImpedance:Ev,usolve:Av,lusolve:Ov,eigs:Cv,mad:_v,avogadro:Tv,classicalElectronRadius:Bv,electricConstant:qv,fermiCoupling:zv,gravity:Dv,loschmidt:Iv,molarMassC12:kv,nuclearMagneton:Rv,planckMass:Fv,quantumOfCirculation:Uv,speedOfLight:Pv,wienDisplacement:jv,unit:Lv,parse:Ox,evaluate:Cx,intersect:Hv,simplify:Tx,rationalize:Bx,coulomb:$v,gasConstant:Gv,magneticFluxQuantum:Zv,planckConstant:Vv,rydberg:Wv,norm:Jv,help:zx,derivative:Dx,elementaryCharge:Yv,molarVolume:Xv,thomsonCrossSection:Qv,rotationMatrix:Kv,parser:Ix,bohrRadius:ex,planckTime:tx,rotate:rx,multinomial:nx,compile:kx,inverseConductanceQuantum:ix,config:n}),e(ox,ax,{apply:Mr({isInteger:vh,typed:gh}),filter:Cr({typed:gh}),map:Tr({typed:gh}),forEach:qr({typed:gh}),subset:Ur({matrix:Id,typed:gh}),index:Pr({Index:Dy}),concat:$r({isInteger:vh,matrix:Id,typed:gh}),max:Wr({config:n,larger:ay,numeric:Yy,typed:gh}),min:Yr({config:n,numeric:Yy,smaller:iy,typed:gh}),sum:Qr({add:my,config:n,numeric:Yy,typed:gh}),column:tn({Index:Dy,matrix:Id,range:fg,typed:gh}),range:an({bignumber:$y,matrix:Id,config:n,larger:ay,largerEq:qy,smaller:iy,smallerEq:Qy,typed:gh}),diff:cn({bignumber:$y,matrix:Id,number:Mh,subtract:cg,typed:gh}),row:fn({Index:Dy,matrix:Id,range:fg,typed:gh}),mean:hn({add:my,divide:Zg,typed:gh}),variance:xn({add:my,apply:Ch,divide:Zg,isNaN:wh,multiply:by,subtract:cg,typed:gh}),std:wn({sqrt:xd,typed:gh,variance:Wg})}),e(sx,{ResultSet:$m,Complex:Gm,Range:Zm,Node:ux,ArrayNode:cx,BlockNode:lx,ConstantNode:fx,ObjectNode:px,ParenthesisNode:mx,RelationalNode:hx,Chain:dx,BigNumber:Ym,Matrix:Xm,ConditionalNode:gx,OperatorNode:vx,Fraction:lh,RangeNode:xx,DenseMatrix:dh,FunctionAssignmentNode:bx,SparseMatrix:Dd,ImmutableDenseMatrix:sy,FibonacciHeap:uy,AccessorNode:Nx,IndexNode:Mx,Index:Dy,AssignmentNode:Sx,Spa:Tg,Unit:Qg,SymbolNode:Ex,FunctionNode:Ax,Help:_x,Parser:qx}),dx.createProxy(ax),browser.omnibox.setDefaultSuggestion({description:"Do most mathematical computations."});const Rx=(e,t)=>{const r=Cx(e);t([{description:String(r),content:String(r)}])};browser.omnibox.onInputStarted.addListener(Rx),browser.omnibox.onInputChanged.addListener(Rx)})()})(); \ No newline at end of file diff --git a/addon/index.js.LICENSE.txt b/addon/index.js.LICENSE.txt index 38eca0b..24c5b24 100644 --- a/addon/index.js.LICENSE.txt +++ b/addon/index.js.LICENSE.txt @@ -1,5 +1,5 @@ /** - * @license Complex.js v2.0.13 12/05/2020 + * @license Complex.js v2.0.15 12/05/2020 * * Copyright (c) 2020, Robert Eisele (robert@xarg.org) * Dual licensed under the MIT or GPL Version 2 licenses. diff --git a/package-lock.json b/package-lock.json index cd263bb..febeb42 100644 --- a/package-lock.json +++ b/package-lock.json @@ -83,9 +83,9 @@ } }, "@babel/runtime": { - "version": "7.14.0", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.14.0.tgz", - "integrity": "sha1-RnlLwgthLF915i3QceJN/ZXxy+Y=", + "version": "7.15.4", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.15.4.tgz", + "integrity": "sha512-99catp6bHCaxr4sJ/DbTGgHS4+Rs2RVd2g7iOap6SLGPDknRK9ztKNsE/Fg6QhSeh1FGE5f6gHGQmvvn3I3xhw==", "requires": { "regenerator-runtime": "^0.13.4" } @@ -431,6 +431,23 @@ "integrity": "sha1-yroksIGFw7VuMWjpfRXtF/TTH9A=", "dev": true }, + "acorn-dynamic-import": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-2.0.2.tgz", + "integrity": "sha1-x1K9IQvvZ5UBtsbLf8hPj0cVjMQ=", + "dev": true, + "requires": { + "acorn": "^4.0.3" + }, + "dependencies": { + "acorn": { + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", + "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", + "dev": true + } + } + }, "acorn-jsx": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz", @@ -507,6 +524,12 @@ "uri-js": "^4.2.2" } }, + "ajv-errors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ajv-errors/-/ajv-errors-1.0.1.tgz", + "integrity": "sha512-DCRfO/4nQ+89p/RK43i8Ezd41EqdGIU4ld7nGF8OQ14oc/we5rEntLCUa7+jrn3nn83BosfwZA0wb4pon2o8iQ==", + "dev": true + }, "ajv-keywords": { "version": "3.5.2", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", @@ -985,6 +1008,12 @@ "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", "dev": true }, + "clone-buffer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz", + "integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg=", + "dev": true + }, "clone-deep": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz", @@ -1005,6 +1034,65 @@ "mimic-response": "^1.0.0" } }, + "clone-stats": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz", + "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=", + "dev": true + }, + "cloneable-readable": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/cloneable-readable/-/cloneable-readable-1.1.3.tgz", + "integrity": "sha512-2EF8zTQOxYq70Y4XKtorQupqF0m49MBz2/yf5Bj+MHjvpG3Hy7sImifnqD6UA+TKYxeSV+u6qqQPawN5UvnpKQ==", + "dev": true, + "requires": { + "inherits": "^2.0.1", + "process-nextick-args": "^2.0.0", + "readable-stream": "^2.3.5" + } + }, + "closure-webpack-plugin": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/closure-webpack-plugin/-/closure-webpack-plugin-2.5.0.tgz", + "integrity": "sha512-mp18Dss/NEj6EazNsT7EiRUCR4wXWFawrIe9Mm2epqELkJWZldVOs+vSPz8y1T2qB4pBYwQuQK2jruDXksOBkg==", + "dev": true, + "requires": { + "acorn": "^5.0.0", + "acorn-dynamic-import": "^2.0.0", + "schema-utils": "1.x", + "unquoted-property-validator": "^1.0.2", + "webpack-sources": "1.x" + }, + "dependencies": { + "acorn": { + "version": "5.7.4", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz", + "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==", + "dev": true + }, + "schema-utils": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-1.0.0.tgz", + "integrity": "sha512-i27Mic4KovM/lnGsy8whRCHhc7VicJajAjTrYg11K9zfZXnYIt4k5F+kZkwjnrhKzLic/HLU4j11mjsz2G/75g==", + "dev": true, + "requires": { + "ajv": "^6.1.0", + "ajv-errors": "^1.0.0", + "ajv-keywords": "^3.1.0" + } + }, + "webpack-sources": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.4.3.tgz", + "integrity": "sha512-lgTS3Xhv1lCOKo7SA5TjKXMjpSM4sBjNV5+q2bqesbSPs5FjGmU6jjtBSkX9b4qW87vDIsCIlUPOEhbZrMdjeQ==", + "dev": true, + "requires": { + "source-list-map": "^2.0.0", + "source-map": "~0.6.1" + } + } + } + }, "color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -1058,9 +1146,9 @@ "dev": true }, "complex.js": { - "version": "2.0.13", - "resolved": "https://registry.npmjs.org/complex.js/-/complex.js-2.0.13.tgz", - "integrity": "sha1-AM97oIJWXhZIE7e7uwztXSq6Fyo=" + "version": "2.0.15", + "resolved": "https://registry.npmjs.org/complex.js/-/complex.js-2.0.15.tgz", + "integrity": "sha512-gDBvQU8IG139ZBQTSo2qvDFP+lANMGluM779csXOr6ny1NUtA3wkUnCFjlDNH/moAVfXtvClYt6G0zarFbtz5w==" }, "concat-map": { "version": "0.0.1", @@ -1173,9 +1261,9 @@ "dev": true }, "decimal.js": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.2.1.tgz", - "integrity": "sha1-I4rnsPDHk9PjzqQQEIs1osAUJqM=" + "version": "10.3.1", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.3.1.tgz", + "integrity": "sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ==" }, "decompress-response": { "version": "3.3.0", @@ -1464,7 +1552,7 @@ "escape-latex": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/escape-latex/-/escape-latex-1.2.0.tgz", - "integrity": "sha1-B8A4GM99rCUMzlF/T9obAB7yvKE=" + "integrity": "sha512-nV5aVWW1K0wEiUIEdZ4erkGGH8mDxGyxSeqPzRNtWP7ataw+/olFObw7hujFWlVjNsaDFw5VZ5NzVSIqRgfTiw==" }, "escape-string-regexp": { "version": "1.0.5", @@ -1858,7 +1946,7 @@ "fraction.js": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.1.1.tgz", - "integrity": "sha1-rE5SBHPa5nAS1hiquR7aCby0AP8=" + "integrity": "sha512-MHOhvvxHTfRFpF1geTK9czMIZ6xclsEor2wkIGYYq+PxcQqT7vStJqjhe6S1TenZrMZzo+wlqOufBDVepUEgPg==" }, "fs-extra": { "version": "9.1.0", @@ -2026,6 +2114,101 @@ } } }, + "google-closure-compiler": { + "version": "20210907.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20210907.0.0.tgz", + "integrity": "sha512-km2Jl0iLoTDHWoj8exQRcVBD+cNZ9sXplUVMyEpKAeWEEFjfSCV6J1Zbpz4doYUHeOxDem5fI1Cr42Pw+xtlMQ==", + "dev": true, + "requires": { + "chalk": "2.x", + "google-closure-compiler-java": "^20210907.0.0", + "google-closure-compiler-linux": "^20210907.0.0", + "google-closure-compiler-osx": "^20210907.0.0", + "google-closure-compiler-windows": "^20210907.0.0", + "minimist": "1.x", + "vinyl": "2.x", + "vinyl-sourcemaps-apply": "^0.2.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "google-closure-compiler-java": { + "version": "20210907.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-java/-/google-closure-compiler-java-20210907.0.0.tgz", + "integrity": "sha512-ASIR8rf3d3Qrf6qHQdLelPHIGRZBnT+AZ9SDT/cLCTYwvvWZhUxh5r4/v6ZAr3XGBbZpX4rgBDa0tZOmpgeRYQ==", + "dev": true + }, + "google-closure-compiler-linux": { + "version": "20210907.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-linux/-/google-closure-compiler-linux-20210907.0.0.tgz", + "integrity": "sha512-hnb3zrXtvdIpC7J+zUdOGyhW7zuk2NYps2J4G6EzVqQ+w1Mp22bhwdeFWeMp/DxueGJn8oenQNSXAANJKOxpiA==", + "dev": true, + "optional": true + }, + "google-closure-compiler-osx": { + "version": "20210907.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-osx/-/google-closure-compiler-osx-20210907.0.0.tgz", + "integrity": "sha512-38dOzEJEt82nXeiIvCiV4rEzX06rdG/4bELg9PpGpGYDLzx4d4ielBNgsflKdkQ2rtvIZY06NsO733knS8gXRQ==", + "dev": true, + "optional": true + }, + "google-closure-compiler-windows": { + "version": "20210907.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-windows/-/google-closure-compiler-windows-20210907.0.0.tgz", + "integrity": "sha512-KJ9baxBaKeo4L5fn8v++vZyclzLQYYStw3fLhEcfW6xU3z6JOHpovN1Ff+DnAljRZhjJ2JbOeB5wg1dy4zkMNA==", + "dev": true, + "optional": true + }, "got": { "version": "9.6.0", "resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz", @@ -2861,13 +3044,13 @@ "dev": true }, "mathjs": { - "version": "9.4.1", - "resolved": "https://registry.npmjs.org/mathjs/-/mathjs-9.4.1.tgz", - "integrity": "sha1-34anmWUT4nC1X1gILUL6xK77pos=", + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/mathjs/-/mathjs-9.5.0.tgz", + "integrity": "sha512-a6QFEoLFLEI1cKr0B7lwAM1TTNAfNTxppimyqS5WhxGKXbV59DK4OX606z05PpuKpTiq7gTtPiSV0OAwFfxSvw==", "requires": { - "@babel/runtime": "^7.14.0", - "complex.js": "^2.0.13", - "decimal.js": "^10.2.1", + "@babel/runtime": "^7.15.4", + "complex.js": "^2.0.15", + "decimal.js": "^10.3.1", "escape-latex": "^1.2.0", "fraction.js": "^4.1.1", "javascript-natural-sort": "^0.7.1", @@ -3643,6 +3826,18 @@ } } }, + "remove-trailing-separator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "dev": true + }, + "replace-ext": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.1.tgz", + "integrity": "sha512-yD5BHCe7quCgBph4rMQ+0KkIRKwWCrHDOX1p1Gp6HwjPM5kVoCdKGNhN7ydqqsX6lJEnQDKZ/tFMiEdQ1dvPEw==", + "dev": true + }, "request": { "version": "2.88.2", "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", @@ -3765,7 +3960,7 @@ "seedrandom": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-3.0.5.tgz", - "integrity": "sha1-VO3IXJUiJSWwx6b2s1Q9jgs6oKc=" + "integrity": "sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg==" }, "semver": { "version": "7.3.5", @@ -4221,7 +4416,7 @@ "tiny-emitter": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", - "integrity": "sha1-HRpW7fxRxD6GPLtTgqcjMONVVCM=" + "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==" }, "tmp": { "version": "0.2.1", @@ -4293,7 +4488,7 @@ "typed-function": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/typed-function/-/typed-function-2.0.0.tgz", - "integrity": "sha1-Fas4JYRROKixETvYnmDNakNXOeg=" + "integrity": "sha512-Hhy1Iwo/e4AtLZNK10ewVVcP2UEs408DS35ubP825w/YgSBK1KVLwALvvIG4yX75QJrxjCpcWkzkVRB0BwwYlA==" }, "typedarray": { "version": "0.0.6", @@ -4325,6 +4520,12 @@ "integrity": "sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==", "dev": true }, + "unquoted-property-validator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/unquoted-property-validator/-/unquoted-property-validator-1.1.0.tgz", + "integrity": "sha512-ZWeQoYZ7HN8DCLeaowNv2GvZIXqJptKB1uUWd08ZYc1qAmJt8tXh9nck26aoYmhJtE3jCjDqdqEfUTqcJ0R7bw==", + "dev": true + }, "upath": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/upath/-/upath-2.0.1.tgz", @@ -4400,6 +4601,45 @@ "extsprintf": "^1.2.0" } }, + "vinyl": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.1.tgz", + "integrity": "sha512-LII3bXRFBZLlezoG5FfZVcXflZgWP/4dCwKtxd5ky9+LOtM4CS3bIRQsmR1KMnMW07jpE8fqR2lcxPZ+8sJIcw==", + "dev": true, + "requires": { + "clone": "^2.1.1", + "clone-buffer": "^1.0.0", + "clone-stats": "^1.0.0", + "cloneable-readable": "^1.0.0", + "remove-trailing-separator": "^1.0.1", + "replace-ext": "^1.0.0" + }, + "dependencies": { + "clone": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=", + "dev": true + } + } + }, + "vinyl-sourcemaps-apply": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz", + "integrity": "sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU=", + "dev": true, + "requires": { + "source-map": "^0.5.1" + }, + "dependencies": { + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + } + } + }, "watchpack": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.2.0.tgz", diff --git a/package.json b/package.json index 463e100..94af586 100644 --- a/package.json +++ b/package.json @@ -10,12 +10,14 @@ "author": "Benjamin Cooper", "license": "SEE LICENSE IN LICENSE.MD", "devDependencies": { + "closure-webpack-plugin": "^2.5.0", + "google-closure-compiler": "^20210907.0.0", "web-ext": "^6.1.0", "webpack": "^5", "webpack-cli": "^4" }, "dependencies": { - "mathjs": "^9" + "mathjs": "^9.5.0" }, "sideEffects": false, "volta": { diff --git a/webpack.config.js b/webpack.config.js index 9a57df1..c7c8866 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,12 +1,20 @@ -const path = require('path'); +const path = require("path"); +const ClosurePlugin = require("closure-webpack-plugin"); module.exports = { + optimization: { + minimizer: [ + new ClosurePlugin( + { mode: "STANDARD" }, + ), + ], + }, entry: { - addon: './index.js', + addon: "./index.js", }, output: { - path: path.resolve(__dirname, './'), - filename: '[name]/index.js', + path: path.resolve(__dirname, "./"), + filename: "[name]/index.js", }, optimization: { usedExports: true }, };