/*! For license information please see mathjs.js.LICENSE.txt */ (()=>{var e={1977:function(e,r){var t;!function(n){"use strict";var i=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:.5*(Math.exp(e)+Math.exp(-e))},a=Math.sinh||function(e){return Math.abs(e)<1e-9?e:.5*(Math.exp(e)-Math.exp(-e))},o=function(){throw SyntaxError("Invalid Param")};function s(e,r){var t=Math.abs(e),n=Math.abs(r);return 0===e?Math.log(n):0===r?Math.log(t):t<3e3&&n<3e3?.5*Math.log(e*e+r*r):(e/=2,r/=2,.5*Math.log(e*e+r*r)+Math.LN2)}function u(e,r){if(!(this instanceof u))return new u(e,r);var t=function(e,r){var t={re:0,im:0};if(null==e)t.re=t.im=0;else if(void 0!==r)t.re=e,t.im=r;else switch(typeof e){case"object":if("im"in e&&"re"in e)t.re=e.re,t.im=e.im;else if("abs"in e&&"arg"in e){if(!Number.isFinite(e.abs)&&Number.isFinite(e.arg))return u.INFINITY;t.re=e.abs*Math.cos(e.arg),t.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!Number.isFinite(e.r)&&Number.isFinite(e.phi))return u.INFINITY;t.re=e.r*Math.cos(e.phi),t.im=e.r*Math.sin(e.phi)}else 2===e.length?(t.re=e[0],t.im=e[1]):o();break;case"string":t.im=t.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":t.im=0,t.re=e;break;default:o()}return isNaN(t.re)||isNaN(t.im),t}(e,r);this.re=t.re,this.im=t.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,r){var t=new u(e,r);return this.isInfinite()&&t.isInfinite()?u.NAN:this.isInfinite()||t.isInfinite()?u.INFINITY:new u(this.re+t.re,this.im+t.im)},sub:function(e,r){var t=new u(e,r);return this.isInfinite()&&t.isInfinite()?u.NAN:this.isInfinite()||t.isInfinite()?u.INFINITY:new u(this.re-t.re,this.im-t.im)},mul:function(e,r){var t=new u(e,r);return this.isInfinite()&&t.isZero()||this.isZero()&&t.isInfinite()?u.NAN:this.isInfinite()||t.isInfinite()?u.INFINITY:0===t.im&&0===this.im?new u(this.re*t.re,0):new u(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)},div:function(e,r){var t=new u(e,r);if(this.isZero()&&t.isZero()||this.isInfinite()&&t.isInfinite())return u.NAN;if(this.isInfinite()||t.isZero())return u.INFINITY;if(this.isZero()||t.isInfinite())return u.ZERO;e=this.re,r=this.im;var n,i,a=t.re,o=t.im;return 0===o?new u(e/a,r/a):Math.abs(a)0)return new u(Math.pow(e,t.re),0);if(0===e)switch((t.re%4+4)%4){case 0:return new u(Math.pow(r,t.re),0);case 1:return new u(0,Math.pow(r,t.re));case 2:return new u(-Math.pow(r,t.re),0);case 3:return new u(0,-Math.pow(r,t.re))}}if(0===e&&0===r&&t.re>0&&t.im>=0)return u.ZERO;var n=Math.atan2(r,e),i=s(e,r);return e=Math.exp(t.re*i-t.im*n),r=t.im*i+t.re*n,new u(e*Math.cos(r),e*Math.sin(r))},sqrt:function(){var e,r,t=this.re,n=this.im,i=this.abs();if(t>=0){if(0===n)return new u(Math.sqrt(t),0);e=.5*Math.sqrt(2*(i+t))}else e=Math.abs(n)/Math.sqrt(2*(i-t));return r=t<=0?.5*Math.sqrt(2*(i-t)):Math.abs(n)/Math.sqrt(2*(i+t)),new u(e,n<0?-r:r)},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,r=this.im;return new u(Math.expm1(e)*Math.cos(r)+function(e){var r=Math.PI/4;if(-r>e||e>r)return Math.cos(e)-1;var t=e*e;return t*(t*(t*(t*(t*(t*(t*(t/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-.5)}(r),Math.exp(e)*Math.sin(r))},log:function(){var e=this.re,r=this.im;return new u(s(e,r),Math.atan2(r,e))},abs:function(){return e=this.re,r=this.im,t=Math.abs(e),n=Math.abs(r),t<3e3&&n<3e3?Math.sqrt(t*t+n*n):(t1&&0===r,n=1-e,i=1+e,a=n*n+r*r,o=0!==a?new u((i*n-r*r)/a,(r*n+i*r)/a):new u(-1!==e?e/0:0,0!==r?r/0:0),c=o.re;return o.re=s(o.re,o.im)/2,o.im=Math.atan2(o.im,c)/2,t&&(o.im=-o.im),o},acoth:function(){var e=this.re,r=this.im;if(0===e&&0===r)return new u(0,Math.PI/2);var t=e*e+r*r;return 0!==t?new u(e/t,-r/t).atanh():new u(0!==e?e/0:0,0!==r?-r/0:0).atanh()},acsch:function(){var e=this.re,r=this.im;if(0===r)return new u(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var t=e*e+r*r;return 0!==t?new u(e/t,-r/t).asinh():new u(0!==e?e/0:0,0!==r?-r/0:0).asinh()},asech:function(){var e=this.re,r=this.im;if(this.isZero())return u.INFINITY;var t=e*e+r*r;return 0!==t?new u(e/t,-r/t).acosh():new u(0!==e?e/0:0,0!==r?-r/0:0).acosh()},inverse:function(){if(this.isZero())return u.INFINITY;if(this.isInfinite())return u.ZERO;var e=this.re,r=this.im,t=e*e+r*r;return new u(e/t,-r/t)},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,r){var t=new u(e,r);return Math.abs(t.re-this.re)<=u.EPSILON&&Math.abs(t.im-this.im)<=u.EPSILON},clone:function(){return new u(this.re,this.im)},toString:function(){var e=this.re,r=this.im,t="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e){"use strict";var r=Object.assign||function(e){for(var r=1;r1&&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(r({},t),s?r({},n):{}),m=Object.keys(p),h=function(){var e=!1;m.forEach((function(r,t){e||l.length>=r.length&&l.slice(0,r.length)===r&&(f+=p[m[t]],l=l.slice(r.length,l.length),e=!0)})),e||(f+=l.slice(0,1),l=l.slice(1,l.length))};l;)h();return f}},5628:function(e,r){var t;!function(n){"use strict";var i={s:1,n:0,d:1};function a(e,r){if(isNaN(e=parseInt(e,10)))throw l.InvalidParameter;return e*r}function o(e,r){if(0===r)throw l.DivisionByZero;var t=Object.create(l.prototype);t.s=e<0?-1:1;var n=c(e=e<0?-e:e,r);return t.n=e/n,t.d=r/n,t}function s(e){for(var r={},t=e,n=2,i=4;i<=t;){for(;t%n==0;)t/=n,r[n]=(r[n]||0)+1;i+=1+2*n++}return t!==e?t>1&&(r[t]=(r[t]||0)+1):r[e]=(r[e]||0)+1,r}var u=function(e,r){var t,n=0,o=1,s=1,u=0,c=0,f=0,p=1,m=1,h=0,d=1,g=1,v=1,y=1e7;if(null==e);else if(void 0!==r){if(s=(n=e)*(o=r),n%1!=0||o%1!=0)throw l.NonIntegerParameter}else switch(typeof e){case"object":if("d"in e&&"n"in e)n=e.n,o=e.d,"s"in e&&(n*=e.s);else{if(!(0 in e))throw l.InvalidParameter;n=e[0],1 in e&&(o=e[1])}s=n*o;break;case"number":if(e<0&&(s=e,e=-e),e%1==0)n=e;else if(e>0){for(e>=1&&(e/=m=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)));d<=y&&v<=y;){if(e===(t=(h+g)/(d+v))){d+v<=y?(n=h+g,o=d+v):v>d?(n=g,o=v):(n=h,o=d);break}e>t?(h+=g,d+=v):(g+=h,v+=d),d>y?(n=g,o=v):(n=h,o=d)}n*=m}else(isNaN(e)||isNaN(r))&&(o=n=NaN);break;case"string":if(null===(d=e.match(/\d+|./g)))throw l.InvalidParameter;if("-"===d[h]?(s=-1,h++):"+"===d[h]&&h++,d.length===h+1?c=a(d[h++],s):"."===d[h+1]||"."===d[h]?("."!==d[h]&&(u=a(d[h++],s)),(++h+1===d.length||"("===d[h+1]&&")"===d[h+3]||"'"===d[h+1]&&"'"===d[h+3])&&(c=a(d[h],s),p=Math.pow(10,d[h].length),h++),("("===d[h]&&")"===d[h+2]||"'"===d[h]&&"'"===d[h+2])&&(f=a(d[h+1],s),m=Math.pow(10,d[h+1].length)-1,h+=3)):"/"===d[h+1]||":"===d[h+1]?(c=a(d[h],s),p=a(d[h+2],1),h+=3):"/"===d[h+3]&&" "===d[h+1]&&(u=a(d[h],s),c=a(d[h+2],s),p=a(d[h+4],1),h+=5),d.length<=h){s=n=f+(o=p*m)*u+m*c;break}default:throw l.InvalidParameter}if(0===o)throw l.DivisionByZero;i.s=s<0?-1:1,i.n=Math.abs(n),i.d=Math.abs(o)};function c(e,r){if(!e)return r;if(!r)return e;for(;;){if(!(e%=r))return r;if(!(r%=e))return e}}function l(e,r){if(u(e,r),!(this instanceof l))return o(i.s*i.n,i.d);e=c(i.d,i.n),this.s=i.s,this.n=i.n/e,this.d=i.d/e}l.DivisionByZero=new Error("Division by Zero"),l.InvalidParameter=new Error("Invalid argument"),l.NonIntegerParameter=new Error("Parameters must be integer"),l.prototype={s:1,n:0,d:1,abs:function(){return o(this.n,this.d)},neg:function(){return o(-this.s*this.n,this.d)},add:function(e,r){return u(e,r),o(this.s*this.n*i.d+i.s*this.d*i.n,this.d*i.d)},sub:function(e,r){return u(e,r),o(this.s*this.n*i.d-i.s*this.d*i.n,this.d*i.d)},mul:function(e,r){return u(e,r),o(this.s*i.s*this.n*i.n,this.d*i.d)},div:function(e,r){return u(e,r),o(this.s*i.s*this.n*i.d,this.d*i.n)},clone:function(){return o(this.s*this.n,this.d)},mod:function(e,r){if(isNaN(this.n)||isNaN(this.d))return new l(NaN);if(void 0===e)return o(this.s*this.n%this.d,1);if(u(e,r),0===i.n&&0===this.d)throw l.DivisionByZero;return o(this.s*(i.d*this.n)%(i.n*this.d),i.d*this.d)},gcd:function(e,r){return u(e,r),o(c(i.n,this.n)*c(i.d,this.d),i.d*this.d)},lcm:function(e,r){return u(e,r),0===i.n&&0===this.n?o(0,1):o(i.n*this.n,c(i.n,this.n)*c(i.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new l(NaN):o(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 l(NaN):o(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 l(NaN):o(Math.round(e*this.s*this.n/this.d),e)},inverse:function(){return o(this.s*this.d,this.n)},pow:function(e,r){if(u(e,r),1===i.d)return i.s<0?o(Math.pow(this.s*this.d,i.n),Math.pow(this.n,i.n)):o(Math.pow(this.s*this.n,i.n),Math.pow(this.d,i.n));if(this.s<0)return null;var t=s(this.n),n=s(this.d),a=1,c=1;for(var l in t)if("1"!==l){if("0"===l){a=0;break}if(t[l]*=i.n,t[l]%i.d!=0)return null;t[l]/=i.d,a*=Math.pow(l,t[l])}for(var l in n)if("1"!==l){if(n[l]*=i.n,n[l]%i.d!=0)return null;n[l]/=i.d,c*=Math.pow(l,n[l])}return i.s<0?o(c,a):o(a,c)},equals:function(e,r){return u(e,r),this.s*this.n*i.d==i.s*i.n*this.d},compare:function(e,r){u(e,r);var t=this.s*this.n*i.d-i.s*i.n*this.d;return(0=0;a--)i=i.inverse().add(t[a]);if(i.sub(r).abs().valueOf()0&&(t+=r,t+=" ",n%=i),t+=n,t+="/",t+=i),t},toLatex:function(e){var r,t="",n=this.n,i=this.d;return this.s<0&&(t+="-"),1===i?t+=n:(e&&(r=Math.floor(n/i))>0&&(t+=r,n%=i),t+="\\frac{",t+=n,t+="}{",t+=i,t+="}"),t},toContinued:function(){var e,r=this.n,t=this.d,n=[];if(isNaN(r)||isNaN(t))return n;do{n.push(Math.floor(r/t)),e=r%t,r=t,t=e}while(1!==r);return n},toString:function(e){var r=this.n,t=this.d;if(isNaN(r)||isNaN(t))return"NaN";e=e||15;var n=function(e,r){for(;r%2==0;r/=2);for(;r%5==0;r/=5);if(1===r)return 0;for(var t=10%r,n=1;1!==t;n++)if(t=10*t%r,n>2e3)return 0;return n}(0,t),i=function(e,r,t){for(var n=1,i=function(e,r,t){for(var n=1;r>0;e=e*e%t,r>>=1)1&r&&(n=n*e%t);return n}(10,t,r),a=0;a<300;a++){if(n===i)return a;n=10*n%r,i=10*i%r}return 0}(0,t,n),a=this.s<0?"-":"";if(a+=r/t|0,r%=t,(r*=10)&&(a+="."),n){for(var o=i;o--;)a+=r/t|0,r%=t,r*=10;a+="(";for(o=n;o--;)a+=r/t|0,r%=t,r*=10;a+=")"}else for(o=e;r&&o--;)a+=r/t|0,r%=t,r*=10;return a}},void 0===(t=function(){return l}.apply(r,[]))||(e.exports=t)}()},3228:e=>{e.exports=function e(r,t){"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(r){return e.insensitive&&(""+r).toLowerCase()||""+r},f=l(r).replace(o,"")||"",p=l(t).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),g=parseInt(p.match(u),16)||d&&p.match(s)&&Date.parse(p)||null;if(g){if(dg)return 1}for(var v=0,y=Math.max(m.length,h.length);vi)return 1}return 0}},6377:(e,r,t)=>{var n=t(4832),i=t(8652),a=t(801),o=t(2030),s=t(3618),u=t(9049),c=t(1971);c.alea=n,c.xor128=i,c.xorwow=a,c.xorshift7=o,c.xor4096=s,c.tychei=u,e.exports=c},4832:function(e,r,t){var n;!function(e,i,a){function o(e){var r,t=this,n=(r=4022871197,function(e){e=String(e);for(var t=0;t>>0,r=(n*=r)>>>0,r+=4294967296*(n-=r)}return 2.3283064365386963e-10*(r>>>0)});t.next=function(){var e=2091639*t.s0+2.3283064365386963e-10*t.c;return t.s0=t.s1,t.s1=t.s2,t.s2=e-(t.c=0|e)},t.c=1,t.s0=n(" "),t.s1=n(" "),t.s2=n(" "),t.s0-=n(e),t.s0<0&&(t.s0+=1),t.s1-=n(e),t.s1<0&&(t.s1+=1),t.s2-=n(e),t.s2<0&&(t.s2+=1),n=null}function s(e,r){return r.c=e.c,r.s0=e.s0,r.s1=e.s1,r.s2=e.s2,r}function u(e,r){var t=new o(e),n=r&&r.state,i=t.next;return i.int32=function(){return 4294967296*t.next()|0},i.double=function(){return i()+11102230246251565e-32*(2097152*i()|0)},i.quick=i,n&&("object"==typeof n&&s(n,t),i.state=function(){return s(t,{})}),i}i&&i.exports?i.exports=u:t.amdD&&t.amdO?void 0===(n=function(){return u}.call(r,t,r,i))||(i.exports=n):this.alea=u}(0,e=t.nmd(e),t.amdD)},9049:function(e,r,t){var n;!function(e,i,a){function o(e){var r=this,t="";r.next=function(){var e=r.b,t=r.c,n=r.d,i=r.a;return e=e<<25^e>>>7^t,t=t-n|0,n=n<<24^n>>>8^i,i=i-e|0,r.b=e=e<<20^e>>>12^t,r.c=t=t-n|0,r.d=n<<16^t>>>16^i,r.a=i-e|0},r.a=0,r.b=0,r.c=-1640531527,r.d=1367130551,e===Math.floor(e)?(r.a=e/4294967296|0,r.b=0|e):t+=e;for(var n=0;n>>0)/4294967296};return i.double=function(){do{var e=((t.next()>>>11)+(t.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=t.next,i.quick=i,n&&("object"==typeof n&&s(n,t),i.state=function(){return s(t,{})}),i}i&&i.exports?i.exports=u:t.amdD&&t.amdO?void 0===(n=function(){return u}.call(r,t,r,i))||(i.exports=n):this.tychei=u}(0,e=t.nmd(e),t.amdD)},8652:function(e,r,t){var n;!function(e,i,a){function o(e){var r=this,t="";r.x=0,r.y=0,r.z=0,r.w=0,r.next=function(){var e=r.x^r.x<<11;return r.x=r.y,r.y=r.z,r.z=r.w,r.w^=r.w>>>19^e^e>>>8},e===(0|e)?r.x=e:t+=e;for(var n=0;n>>0)/4294967296};return i.double=function(){do{var e=((t.next()>>>11)+(t.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=t.next,i.quick=i,n&&("object"==typeof n&&s(n,t),i.state=function(){return s(t,{})}),i}i&&i.exports?i.exports=u:t.amdD&&t.amdO?void 0===(n=function(){return u}.call(r,t,r,i))||(i.exports=n):this.xor128=u}(0,e=t.nmd(e),t.amdD)},3618:function(e,r,t){var n;!function(e,i,a){function o(e){var r=this;r.next=function(){var e,t,n=r.w,i=r.X,a=r.i;return r.w=n=n+1640531527|0,t=i[a+34&127],e=i[a=a+1&127],t^=t<<13,e^=e<<17,t^=t>>>15,e^=e>>>12,t=i[a]=t^e,r.i=a,t+(n^n>>>16)|0},function(e,r){var t,n,i,a,o,s=[],u=128;for(r===(0|r)?(n=r,r=null):(r+="\0",n=0,u=Math.max(u,r.length)),i=0,a=-32;a>>15,n^=n<<4,n^=n>>>13,a>=0&&(o=o+1640531527|0,i=0==(t=s[127&a]^=n+o)?i+1:0);for(i>=128&&(s[127&(r&&r.length||0)]=-1),i=127,a=512;a>0;--a)n=s[i+34&127],t=s[i=i+1&127],n^=n<<13,t^=t<<17,n^=n>>>15,t^=t>>>12,s[i]=n^t;e.w=o,e.X=s,e.i=i}(r,e)}function s(e,r){return r.i=e.i,r.w=e.w,r.X=e.X.slice(),r}function u(e,r){null==e&&(e=+new Date);var t=new o(e),n=r&&r.state,i=function(){return(t.next()>>>0)/4294967296};return i.double=function(){do{var e=((t.next()>>>11)+(t.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=t.next,i.quick=i,n&&(n.X&&s(n,t),i.state=function(){return s(t,{})}),i}i&&i.exports?i.exports=u:t.amdD&&t.amdO?void 0===(n=function(){return u}.call(r,t,r,i))||(i.exports=n):this.xor4096=u}(0,e=t.nmd(e),t.amdD)},2030:function(e,r,t){var n;!function(e,i,a){function o(e){var r=this;r.next=function(){var e,t,n=r.x,i=r.i;return e=n[i],t=(e^=e>>>7)^e<<24,t^=(e=n[i+1&7])^e>>>10,t^=(e=n[i+3&7])^e>>>3,t^=(e=n[i+4&7])^e<<7,e=n[i+7&7],t^=(e^=e<<13)^e<<9,n[i]=t,r.i=i+1&7,t},function(e,r){var t,n=[];if(r===(0|r))n[0]=r;else for(r=""+r,t=0;t0;--t)e.next()}(r,e)}function s(e,r){return r.x=e.x.slice(),r.i=e.i,r}function u(e,r){null==e&&(e=+new Date);var t=new o(e),n=r&&r.state,i=function(){return(t.next()>>>0)/4294967296};return i.double=function(){do{var e=((t.next()>>>11)+(t.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=t.next,i.quick=i,n&&(n.x&&s(n,t),i.state=function(){return s(t,{})}),i}i&&i.exports?i.exports=u:t.amdD&&t.amdO?void 0===(n=function(){return u}.call(r,t,r,i))||(i.exports=n):this.xorshift7=u}(0,e=t.nmd(e),t.amdD)},801:function(e,r,t){var n;!function(e,i,a){function o(e){var r=this,t="";r.next=function(){var e=r.x^r.x>>>2;return r.x=r.y,r.y=r.z,r.z=r.w,r.w=r.v,(r.d=r.d+362437|0)+(r.v=r.v^r.v<<4^e^e<<1)|0},r.x=0,r.y=0,r.z=0,r.w=0,r.v=0,e===(0|e)?r.x=e:t+=e;for(var n=0;n>>4),r.next()}function s(e,r){return r.x=e.x,r.y=e.y,r.z=e.z,r.w=e.w,r.v=e.v,r.d=e.d,r}function u(e,r){var t=new o(e),n=r&&r.state,i=function(){return(t.next()>>>0)/4294967296};return i.double=function(){do{var e=((t.next()>>>11)+(t.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=t.next,i.quick=i,n&&("object"==typeof n&&s(n,t),i.state=function(){return s(t,{})}),i}i&&i.exports?i.exports=u:t.amdD&&t.amdO?void 0===(n=function(){return u}.call(r,t,r,i))||(i.exports=n):this.xorwow=u}(0,e=t.nmd(e),t.amdD)},1971:function(e,r,t){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,r,t){var n=[],p=v(g((r=1==r?{entropy:!0}:r||{}).entropy?[e,y(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)),y(e)}catch(e){var r=i.navigator,t=r&&r.plugins;return[+new Date,i,t,i.screen,y(a)]}}():e,3),n),m=new h(n),x=function(){for(var e=m.g(6),r=c,t=0;e=f;)e/=2,r/=2,t>>>=1;return(e+t)/r};return x.int32=function(){return 0|m.g(4)},x.quick=function(){return m.g(4)/4294967296},x.double=x,v(y(m.S),a),(r.pass||t||function(e,r,t,n){return n&&(n.S&&d(n,m),e.state=function(){return d(m,{})}),t?(o.random=e,r):e})(x,p,"global"in r?r.global:this==o,r.state)}function h(e){var r,t=e.length,n=this,i=0,a=n.i=n.j=0,o=n.S=[];for(t||(e=[t++]);i{function r(){}r.prototype={on:function(e,r,t){var n=this.e||(this.e={});return(n[e]||(n[e]=[])).push({fn:r,ctx:t}),this},once:function(e,r,t){var n=this;function i(){n.off(e,i),r.apply(t,arguments)}return i._=r,this.on(e,i,t)},emit:function(e){for(var r=[].slice.call(arguments,1),t=((this.e||(this.e={}))[e]||[]).slice(),n=0,i=t.length;n{},4814:function(e){e.exports=function(){"use strict";function e(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=r(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw o}}}}function r(e,r){if(e){if("string"==typeof e)return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}function t(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t1&&void 0!==arguments[1]?arguments[1]:"any",n=r?h(r).index:c.length,i=[],a=0;a1&&void 0!==arguments[1]?arguments[1]:",";return e.map((function(e){return e.name})).join(r)}function E(e){var r=0===e.indexOf("..."),t=(r?e.length>3?e.slice(3):"any":e).split("|").map((function(e){return h(e.trim())})),n=!1,i=r?"...":"";return{types:t.map((function(e){return n=e.isAny||n,i+=e.name+"|",{name:e.name,typeIndex:e.index,test:e.test,isAny:e.isAny,conversion:null,conversionIndex:-1}})),name:i.slice(0,-1),hasAny:n,hasConversion:!1,restParam:r}}function A(e){var r=j(e.types.map((function(e){return e.name}))),t=e.hasAny,n=e.name,i=r.map((function(e){var r=h(e.from);return t=r.isAny||t,n+="|"+e.from,{name:e.from,typeIndex:r.index,test:r.test,isAny:r.isAny,conversion:e,conversionIndex:e.index}}));return{types:e.types.concat(i),name:n,hasAny:t,hasConversion:i.length>0,restParam:e.restParam}}function C(e){return e.typeSet||(e.typeSet=new Set,e.types.forEach((function(r){return e.typeSet.add(r.name)}))),e.typeSet}function S(e){var r=[];if("string"!=typeof e)throw new TypeError("Signatures must be strings");var t=e.trim();if(""===t)return r;for(var n=t.split(","),i=0;i=i+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(t=F(e[0]),function(e){return t(e[0])&&1===e.length}):2===e.length?(t=F(e[0]),n=F(e[1]),function(e){return t(e[0])&&n(e[1])&&2===e.length}):(r=e.map(F),function(e){for(var t=0;t0){var t=y(r[o]);return(i=new TypeError("Unexpected type of argument in function "+s+" (expected: "+a.join(" or ")+", actual: "+t.join(" | ")+", index: "+o+")")).data={category:"wrongType",fn:s,index:o,actual:t,expected:a},{v:i}}}else u=e};for(o=0;op)return(i=new TypeError("Too many arguments in function "+s+" (expected: "+p+", actual: "+r.length+")")).data={category:"tooManyArgs",fn:s,index:r.length,expectedLength:p},i;for(var m=[],h=0;h0)return 1;var n=I(e)-I(r);return n<0?-1:n>0?1:0}function P(r,t){var n=r.params,i=t.params,a=Q(n),o=Q(i),s=M(n),u=M(i);if(s&&a.hasAny){if(!u||!o.hasAny)return 1}else if(u&&o.hasAny)return-1;var c,l,f=0,p=0,m=e(n);try{for(m.s();!(l=m.n()).done;)(c=l.value).hasAny&&++f,c.hasConversion&&++p}catch(e){m.e(e)}finally{m.f()}var h,d=0,g=0,v=e(i);try{for(v.s();!(h=v.n()).done;)(c=h.value).hasAny&&++d,c.hasConversion&&++g}catch(e){v.e(e)}finally{v.f()}if(f!==d)return f-d;if(s&&a.hasConversion){if(!u||!o.hasConversion)return 1}else if(u&&o.hasConversion)return-1;if(p!==g)return p-g;if(s){if(!u)return 1}else if(u)return-1;var y=(n.length-i.length)*(s?-1:1);if(0!==y)return y;for(var x,b=[],w=0,N=0;N1&&t.sort((function(e,r){return e.index-r.index}));var n=t[0].conversionsTo;if(1===r.length)return n;n=n.concat([]);for(var i=new Set(r),a=1;a=l:m?l>=f:l===f}function G(e){return e.map((function(e){return oe(e)?ie(e.referToSelf.callback):ae(e)?ne(e.referTo.references,e.referTo.callback):e}))}function Z(r,t,n){var i,a,o=[],s=e(r);try{for(s.s();!(a=s.n()).done;){var u=n[i=a.value];if("number"!=typeof u)throw new TypeError('No definition for referenced signature "'+i+'"');if("function"!=typeof(u=t[u]))return!1;o.push(u)}}catch(e){s.e(e)}finally{s.f()}return o}function V(e,r,t){for(var n=G(e),i=new Array(n.length).fill(!1),a=!0;a;){a=!1;for(var o=!0,s=0;s{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";var e={};function r(){return r=Object.assign?Object.assign.bind():function(e){for(var r=1;rQi,createAccessorNode:()=>Hf,createAcos:()=>il,createAcosh:()=>Dl,createAcot:()=>Al,createAcoth:()=>Sl,createAcsc:()=>Fl,createAcsch:()=>Ol,createAdd:()=>Ff,createAddScalar:()=>na,createAnd:()=>ec,createApply:()=>ea,createApplyTransform:()=>xg,createArg:()=>_o,createArrayNode:()=>Gf,createAsec:()=>_l,createAsech:()=>ql,createAsin:()=>Il,createAsinh:()=>Rl,createAssignmentNode:()=>Kf,createAtan:()=>Pl,createAtan2:()=>Ul,createAtanh:()=>Hl,createAtomicMass:()=>Yd,createAvogadro:()=>Xd,createBellNumbers:()=>Fh,createBigNumberClass:()=>gn,createBignumber:()=>mi,createBin:()=>pu,createBitAnd:()=>Ao,createBitNot:()=>So,createBitOr:()=>Fo,createBitXor:()=>Bo,createBlockNode:()=>rp,createBohrMagneton:()=>Td,createBohrRadius:()=>kd,createBoltzmann:()=>Qd,createBoolean:()=>pi,createCatalan:()=>Oh,createCbrt:()=>aa,createCeil:()=>pa,createChain:()=>dm,createChainClass:()=>um,createClassicalElectronRadius:()=>Id,createClone:()=>Mn,createColumn:()=>Yo,createColumnTransform:()=>bg,createCombinations:()=>Zm,createCombinationsWithRep:()=>Jm,createCompare:()=>tc,createCompareNatural:()=>oc,createCompareText:()=>cc,createCompile:()=>zp,createComplex:()=>hi,createComplexClass:()=>yn,createComposition:()=>_h,createConcat:()=>Vo,createConcatTransform:()=>qg,createConditionalNode:()=>np,createConductanceQuantum:()=>Od,createConj:()=>qo,createConstantNode:()=>pp,createCos:()=>Gl,createCosh:()=>Vl,createCot:()=>Wl,createCoth:()=>Yl,createCoulomb:()=>Md,createCount:()=>Qo,createCreateUnit:()=>tl,createCross:()=>es,createCsc:()=>Xl,createCsch:()=>Kl,createCtranspose:()=>Vs,createCube:()=>ha,createCumSum:()=>Bm,createCumSumTransform:()=>Ug,createDeepEqual:()=>Mc,createDenseMatrixClass:()=>Cn,createDerivative:()=>Vh,createDet:()=>gm,createDeuteronMass:()=>Hd,createDiag:()=>ts,createDiff:()=>xs,createDiffTransform:()=>Ig,createDistance:()=>Mm,createDivide:()=>Cm,createDivideScalar:()=>Du,createDot:()=>zf,createDotDivide:()=>ku,createDotMultiply:()=>oo,createDotPow:()=>zu,createE:()=>ud,createEfimovFactor:()=>Jd,createEigs:()=>wm,createElectricConstant:()=>Cd,createElectronMass:()=>Rd,createElementaryCharge:()=>Fd,createEqual:()=>fc,createEqualScalar:()=>oi,createEqualText:()=>hc,createErf:()=>Ks,createEvaluate:()=>kp,createExp:()=>da,createExpm:()=>Dm,createExpm1:()=>va,createFactorial:()=>uh,createFalse:()=>td,createFaraday:()=>Kd,createFermiCoupling:()=>Pd,createFft:()=>Ys,createFibonacciHeapClass:()=>jc,createFilter:()=>ns,createFilterTransform:()=>Ng,createFineStructure:()=>jd,createFirstRadiation:()=>eg,createFix:()=>wa,createFlatten:()=>os,createFloor:()=>Aa,createForEach:()=>us,createForEachTransform:()=>Eg,createFormat:()=>fu,createFraction:()=>di,createFractionClass:()=>bn,createFunctionAssignmentNode:()=>hp,createFunctionNode:()=>Tp,createGamma:()=>ih,createGasConstant:()=>tg,createGcd:()=>Oa,createGetMatrixDataType:()=>fs,createGravitationConstant:()=>Nd,createGravity:()=>fg,createHartreeEnergy:()=>Ud,createHasNumericValue:()=>Wn,createHelp:()=>mm,createHelpClass:()=>om,createHex:()=>hu,createHypot:()=>Of,createI:()=>gd,createIdentity:()=>ms,createIfft:()=>Qs,createIm:()=>ko,createImmutableDenseMatrixClass:()=>Rc,createIndex:()=>If,createIndexClass:()=>Pc,createIndexNode:()=>gp,createIndexTransform:()=>Ag,createInfinity:()=>id,createIntersect:()=>Fm,createInv:()=>vm,createInverseConductanceQuantum:()=>Bd,createInvmod:()=>no,createIsInteger:()=>In,createIsNaN:()=>ei,createIsNegative:()=>$n,createIsNumeric:()=>Zn,createIsPositive:()=>Yn,createIsPrime:()=>bu,createIsZero:()=>Qn,createKldivergence:()=>lh,createKlitzing:()=>qd,createKron:()=>ds,createLN10:()=>fd,createLN2:()=>ld,createLOG10E:()=>md,createLOG2E:()=>pd,createLarger:()=>Nc,createLargerEq:()=>Ac,createLcm:()=>za,createLeafCount:()=>qh,createLeftShift:()=>Ju,createLgamma:()=>oh,createLog:()=>Mu,createLog10:()=>ka,createLog1p:()=>Tu,createLog2:()=>Ra,createLoschmidt:()=>rg,createLsolve:()=>Pu,createLsolveAll:()=>Hu,createLup:()=>jp,createLusolve:()=>im,createMad:()=>Im,createMagneticConstant:()=>Ad,createMagneticFluxQuantum:()=>_d,createMap:()=>gs,createMapTransform:()=>Cg,createMatrix:()=>vi,createMatrixClass:()=>Nn,createMatrixFromColumns:()=>Di,createMatrixFromFunction:()=>xi,createMatrixFromRows:()=>wi,createMax:()=>kc,createMaxTransform:()=>Fg,createMean:()=>zm,createMeanTransform:()=>Tg,createMedian:()=>km,createMin:()=>Ic,createMinTransform:()=>Og,createMod:()=>Ua,createMode:()=>ou,createMolarMass:()=>cg,createMolarMassC12:()=>lg,createMolarPlanckConstant:()=>ng,createMolarVolume:()=>ig,createMultinomial:()=>ph,createMultiply:()=>$a,createMultiplyScalar:()=>La,createNaN:()=>ad,createNeutronMass:()=>$d,createNode:()=>Pf,createNorm:()=>_f,createNot:()=>Ho,createNthRoot:()=>Za,createNthRoots:()=>Bu,createNuclearMagneton:()=>zd,createNull:()=>nd,createNumber:()=>ui,createNumeric:()=>wu,createObjectNode:()=>yp,createOct:()=>mu,createOnes:()=>bs,createOperatorNode:()=>bp,createOr:()=>$o,createParenthesisNode:()=>Np,createParse:()=>Bp,createParser:()=>Pp,createParserClass:()=>Ip,createPartitionSelect:()=>_c,createPermutations:()=>hh,createPhi:()=>cd,createPi:()=>od,createPickRandom:()=>bh,createPinv:()=>xm,createPlanckCharge:()=>dg,createPlanckConstant:()=>Dd,createPlanckLength:()=>pg,createPlanckMass:()=>mg,createPlanckTemperature:()=>gg,createPlanckTime:()=>hg,createPow:()=>Eu,createPrint:()=>gu,createProd:()=>cu,createProtonMass:()=>Ld,createQr:()=>Up,createQuantileSeq:()=>Um,createQuantumOfCirculation:()=>Gd,createRandom:()=>Dh,createRandomInt:()=>Ah,createRange:()=>As,createRangeClass:()=>wn,createRangeNode:()=>Ep,createRangeTransform:()=>Bg,createRationalize:()=>Jh,createRe:()=>Io,createReducedPlanckConstant:()=>Ed,createRelationalNode:()=>Cp,createReplacer:()=>Xh,createReshape:()=>Ss,createResize:()=>Ms,createResolve:()=>Hh,createResultSet:()=>_r,createReviver:()=>Yh,createRightArithShift:()=>Xu,createRightLogShift:()=>Ku,createRotate:()=>Ts,createRotationMatrix:()=>Bs,createRound:()=>Su,createRow:()=>_s,createRowTransform:()=>_g,createRydberg:()=>Zd,createSQRT1_2:()=>hd,createSQRT2:()=>dd,createSackurTetrode:()=>ag,createSec:()=>ef,createSech:()=>tf,createSecondRadiation:()=>og,createSetCartesian:()=>lf,createSetDifference:()=>pf,createSetDistinct:()=>hf,createSetIntersect:()=>gf,createSetIsSubset:()=>yf,createSetMultiplicity:()=>bf,createSetPowerset:()=>Nf,createSetSize:()=>Ef,createSetSymDifference:()=>Cf,createSetUnion:()=>Mf,createSign:()=>Wa,createSimplify:()=>Ph,createSimplifyConstant:()=>jh,createSimplifyCore:()=>Lh,createSin:()=>nf,createSinh:()=>of,createSize:()=>qs,createSlu:()=>em,createSmaller:()=>gc,createSmallerEq:()=>xc,createSort:()=>qc,createSpaClass:()=>Uc,createSparse:()=>el,createSparseMatrixClass:()=>si,createSpeedOfLight:()=>wd,createSplitUnit:()=>Ai,createSqrt:()=>Ja,createSqrtm:()=>Am,createSquare:()=>Xa,createSqueeze:()=>Is,createStd:()=>Lm,createStdTransform:()=>Rg,createStefanBoltzmann:()=>sg,createStirlingS2:()=>Sh,createString:()=>li,createSubset:()=>Ps,createSubsetTransform:()=>zg,createSubtract:()=>Ka,createSum:()=>Tm,createSumTransform:()=>Pg,createSymbolNode:()=>Sp,createSymbolicEqual:()=>Gh,createTan:()=>sf,createTanh:()=>uf,createTau:()=>sd,createThomsonCrossSection:()=>Vd,createTo:()=>yu,createTrace:()=>qf,createTranspose:()=>Gs,createTrue:()=>rd,createTypeOf:()=>ti,createTyped:()=>Sr,createUnaryMinus:()=>Ji,createUnaryPlus:()=>Xi,createUnequal:()=>Tc,createUnitClass:()=>Yc,createUnitFunction:()=>Qc,createUppercaseE:()=>yd,createUppercasePi:()=>vd,createUsolve:()=>Uu,createUsolveAll:()=>Gu,createVacuumImpedance:()=>Sd,createVariance:()=>jm,createVarianceTransform:()=>Hg,createVersion:()=>xd,createWeakMixingAngle:()=>Wd,createWienDisplacement:()=>ug,createXgcd:()=>ro,createXor:()=>Go,createZeros:()=>Js});var n=t(4814);function i(e){return"number"==typeof e}function a(e){return!(!e||"object"!=typeof e||"function"!=typeof e.constructor)&&(!0===e.isBigNumber&&"object"==typeof e.constructor.prototype&&!0===e.constructor.prototype.isBigNumber||"function"==typeof e.constructor.isDecimal&&!0===e.constructor.isDecimal(e))}function o(e){return e&&"object"==typeof e&&!0===Object.getPrototypeOf(e).isComplex||!1}function s(e){return e&&"object"==typeof e&&!0===Object.getPrototypeOf(e).isFraction||!1}function u(e){return e&&!0===e.constructor.prototype.isUnit||!1}function c(e){return"string"==typeof e}var l=Array.isArray;function f(e){return e&&!0===e.constructor.prototype.isMatrix||!1}function p(e){return Array.isArray(e)||f(e)}function m(e){return e&&e.isDenseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function h(e){return e&&e.isSparseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function d(e){return e&&!0===e.constructor.prototype.isRange||!1}function g(e){return e&&!0===e.constructor.prototype.isIndex||!1}function v(e){return"boolean"==typeof e}function y(e){return e&&!0===e.constructor.prototype.isResultSet||!1}function x(e){return e&&!0===e.constructor.prototype.isHelp||!1}function b(e){return"function"==typeof e}function w(e){return e instanceof Date}function N(e){return e instanceof RegExp}function D(e){return!(!e||"object"!=typeof e||e.constructor!==Object||o(e)||s(e))}function E(e){return null===e}function A(e){return void 0===e}function C(e){return e&&!0===e.isAccessorNode&&!0===e.constructor.prototype.isNode||!1}function S(e){return e&&!0===e.isArrayNode&&!0===e.constructor.prototype.isNode||!1}function M(e){return e&&!0===e.isAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function F(e){return e&&!0===e.isBlockNode&&!0===e.constructor.prototype.isNode||!1}function T(e){return e&&!0===e.isConditionalNode&&!0===e.constructor.prototype.isNode||!1}function O(e){return e&&!0===e.isConstantNode&&!0===e.constructor.prototype.isNode||!1}function B(e){return O(e)||R(e)&&1===e.args.length&&O(e.args[0])&&"-+~".includes(e.op)}function _(e){return e&&!0===e.isFunctionAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function z(e){return e&&!0===e.isFunctionNode&&!0===e.constructor.prototype.isNode||!1}function q(e){return e&&!0===e.isIndexNode&&!0===e.constructor.prototype.isNode||!1}function k(e){return e&&!0===e.isNode&&!0===e.constructor.prototype.isNode||!1}function I(e){return e&&!0===e.isObjectNode&&!0===e.constructor.prototype.isNode||!1}function R(e){return e&&!0===e.isOperatorNode&&!0===e.constructor.prototype.isNode||!1}function P(e){return e&&!0===e.isParenthesisNode&&!0===e.constructor.prototype.isNode||!1}function j(e){return e&&!0===e.isRangeNode&&!0===e.constructor.prototype.isNode||!1}function U(e){return e&&!0===e.isRelationalNode&&!0===e.constructor.prototype.isNode||!1}function L(e){return e&&!0===e.isSymbolNode&&!0===e.constructor.prototype.isNode||!1}function H(e){return e&&!0===e.constructor.prototype.isChain||!1}function $(e){var r=typeof e;return"object"===r?null===e?"null":a(e)?"BigNumber":e.constructor&&e.constructor.name?e.constructor.name:"Object":r}function G(e){var r=typeof e;if("number"===r||"string"===r||"boolean"===r||null==e)return e;if("function"==typeof e.clone)return e.clone();if(Array.isArray(e))return e.map((function(e){return G(e)}));if(e instanceof Date)return new Date(e.valueOf());if(a(e))return e;if(e instanceof RegExp)throw new TypeError("Cannot clone "+e);return Z(e,G)}function Z(e,r){var t={};for(var n in e)K(e,n)&&(t[n]=r(e[n]));return t}function V(e,r){for(var t in r)K(r,t)&&(e[t]=r[t]);return e}function W(e,r){if(Array.isArray(r))throw new TypeError("Arrays are not supported by deepExtend");for(var t in r)if(K(r,t)&&!(t in Object.prototype)&&!(t in Function.prototype))if(r[t]&&r[t].constructor===Object)void 0===e[t]&&(e[t]={}),e[t]&&e[t].constructor===Object?W(e[t],r[t]):e[t]=r[t];else{if(Array.isArray(r[t]))throw new TypeError("Arrays are not supported by deepExtend");e[t]=r[t]}return e}function J(e,r){var t,n,i;if(Array.isArray(e)){if(!Array.isArray(r))return!1;if(e.length!==r.length)return!1;for(n=0,i=e.length;ne[r]))}var re=t(4279);function te(e,r,t,n){function i(n){var i=function(e,r){for(var t={},n=0;n!function(e){return e&&"?"===e[0]}(e))).every((e=>void 0!==t[e]))){var n=r.filter((e=>void 0===t[e]));throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(n.map((e=>'"'.concat(e,'"'))).join(", "),"."))}}(e,r,n),t(i)}return i.isFactory=!0,i.fn=e,i.dependencies=r.slice().sort(),n&&(i.meta=n),i}function ne(e){return"function"==typeof e&&"string"==typeof e.fn&&Array.isArray(e.dependencies)}function ie(e){return e&&"?"===e[0]?e.slice(1):e}function ae(e){return"boolean"==typeof e||!!isFinite(e)&&e===Math.round(e)}var oe=Math.sign||function(e){return e>0?1:e<0?-1:0},se=Math.log2||function(e){return Math.log(e)/Math.LN2},ue=Math.log10||function(e){return Math.log(e)/Math.LN10},ce=Math.log1p||function(e){return Math.log(e+1)},le=Math.cbrt||function(e){if(0===e)return e;var r,t=e<0;return t&&(e=-e),r=isFinite(e)?(e/((r=Math.exp(Math.log(e)/3))*r)+2*r)/3:e,t?-r:r},fe=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function pe(e,r,t){var n={2:"0b",8:"0o",16:"0x"}[r],i="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!ae(t))throw new Error("size must be an integer");if(e>2**(t-1)-1||e<-(2**(t-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!ae(e))throw new Error("Value must be an integer");e<0&&(e+=2**t),i="i".concat(t)}var a="";return e<0&&(e=-e,a="-"),"".concat(a).concat(n).concat(e.toString(r)).concat(i)}function me(e,r){if("function"==typeof r)return r(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var t,n,a="auto";if(r&&(r.notation&&(a=r.notation),i(r)?t=r:i(r.precision)&&(t=r.precision),r.wordSize&&"number"!=typeof(n=r.wordSize)))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return de(e,t);case"exponential":return ge(e,t);case"engineering":return function(e,r){if(isNaN(e)||!isFinite(e))return String(e);var t=ve(he(e),r),n=t.exponent,a=t.coefficients,o=n%3==0?n:n<0?n-3-n%3:n-n%3;if(i(r))for(;r>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(r)&&f.length||f.match(/[1-9]/)?"."+f:"",m=a.slice(0,l).join("")+p+"e"+(n>=0?"+":"")+o.toString();return t.sign+m}(e,t);case"bin":return pe(e,2,n);case"oct":return pe(e,8,n);case"hex":return pe(e,16,n);case"auto":return function(e,r,t){if(isNaN(e)||!isFinite(e))return String(e);var n=t&&void 0!==t.lowerExp?t.lowerExp:-3,i=t&&void 0!==t.upperExp?t.upperExp:5,a=he(e),o=r?ve(a,r):a;if(o.exponent=i)return ge(e,r);var s=o.coefficients,u=o.exponent;s.length0?u:0;return c<(s=ye(-u).concat(s)).length-1&&s.splice(c+1,0,"."),o.sign+s.join("")}(e,t,r&&r).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],r=arguments[4];return"."!==e?e+r:r}));default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function he(e){var r=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!r)throw new SyntaxError("Invalid number "+e);var t=r[1],n=r[2],i=parseFloat(r[4]||"0"),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:t,coefficients:o,exponent:i}}function de(e,r){if(isNaN(e)||!isFinite(e))return String(e);var t=he(e),n="number"==typeof r?ve(t,t.exponent+1+r):t,i=n.coefficients,a=n.exponent+1,o=a+(r||0);return i.length0?"."+i.join(""):"")+"e"+(a>=0?"+":"")+a}function ve(e,r){for(var t={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},n=t.coefficients;r<=0;)n.unshift(0),t.exponent++,r++;if(n.length>r&&n.splice(r,n.length-r)[0]>=5){var i=r-1;for(n[i]++;10===n[i];)n.pop(),0===i&&(n.unshift(0),t.exponent++,i++),n[--i]++}return t}function ye(e){for(var r=[],t=0;t=0?"+":"")+n.toString()}(e,t);case"bin":return Se(e,2,n);case"oct":return Se(e,8,n);case"hex":return Se(e,16,n);case"auto":var a=r&&void 0!==r.lowerExp?r.lowerExp:-3,o=r&&void 0!==r.upperExp?r.upperExp:5;if(e.isZero())return"0";var s=e.toSignificantDigits(t),u=s.e;return(u>=a&&u'"'+t+'": '+Oe(e[t],r))).join(", ")+"}"}return String(e)}(e,r);return r&&"object"==typeof r&&"truncate"in r&&t.length>r.truncate?t.substring(0,r.truncate-3)+"...":t}function Be(e){for(var r=String(e),t="",n=0;n/g,">")}function ze(e,r){if(Array.isArray(e)){for(var t="[",n=e.length,i=0;ir?1:-1}function ke(e,r,t){if(!(this instanceof ke))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=r,this.relation=t,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(r)?"["+r.join(", ")+"]":r)+")",this.stack=(new Error).stack}function Ie(e,r,t){if(!(this instanceof Ie))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=r):(this.min=r,this.max=t),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 Re(e){for(var r=[];Array.isArray(e);)r.push(e.length),e=e[0];return r}function Pe(e,r,t){var n,i=e.length;if(i!==r[t])throw new ke(i,r[t]);if(t")}function je(e,r){if(0===r.length){if(Array.isArray(e))throw new ke(e.length,0)}else Pe(e,r,0)}function Ue(e,r){if(!i(e)||!ae(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof r&&e>=r)throw new Ie(e,r)}function Le(e,r,t){if(!Array.isArray(e)||!Array.isArray(r))throw new TypeError("Array expected");if(0===r.length)throw new Error("Resizing to scalar is not supported");return r.forEach((function(e){if(!i(e)||!ae(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Oe(r)+")")})),He(e,r,0,void 0!==t?t:0),e}function He(e,r,t,n){var i,a,o=e.length,s=r[t],u=Math.min(o,s);if(e.length=s,t=0){if(!(r%t==0))throw new Error("Could not replace wildcard, since "+r+" is no multiple of "+-t);n[i]=-r/t}return n}function Ze(e){return e.reduce(((e,r)=>e*r),1)}function Ve(e,r){for(var t=r||Re(e);Array.isArray(e)&&1===e.length;)e=e[0],t.shift();for(var n=t.length;1===t[n-1];)n--;return nr.test(e)))}function tr(e,r){return Array.prototype.join.call(e,r)}function nr(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;var r=[],t=0;r[0]={value:e[0],identifier:0};for(var n=1;n2&&void 0!==arguments[2]?arguments[2]:r.fn;if(or(a,"."))throw new Error("Factory name should not contain a nested path. Name: "+JSON.stringify(a));var o=g(r)?t.expression.transform:t,s=a in t.expression.transform,u=K(o,a)?o[a]:void 0,c=function(){var n={};r.dependencies.map(ie).forEach((e=>{if(or(e,"."))throw new Error("Factory dependency should not contain a nested path. Name: "+JSON.stringify(e));"math"===e?n.math=t:"mathWithTransform"===e?n.mathWithTransform=t.expression.mathWithTransform:"classes"===e?n.classes=t:n[e]=t[e]}));var o=r(n);if(o&&"function"==typeof o.transform)throw new Error('Transforms cannot be attached to factory functions. Please create a separate function for it with exports.path="expression.transform"');if(void 0===u||i.override)return o;if(e.isTypedFunction(u)&&e.isTypedFunction(o))return e(u,o);if(i.silent)return u;throw new Error('Cannot import "'+a+'": already exists')};r.meta&&!1===r.meta.lazy?(o[a]=c(),u&&s?l(a):(g(r)||d(r))&&Q(t.expression.mathWithTransform,a,(()=>o[a]))):(Q(o,a,c),u&&s?l(a):(g(r)||d(r))&&Q(t.expression.mathWithTransform,a,(()=>o[a]))),n[a]=r,t.emit("import",a,c)}function m(e){return"function"==typeof e||"number"==typeof e||"string"==typeof e||"boolean"==typeof e||null===e||u(e)||o(e)||a(e)||s(e)||f(e)||Array.isArray(e)}function h(e){return!K(v,e)}function d(e){return!(-1!==e.fn.indexOf(".")||K(v,e.fn)||e.meta&&e.meta.isClass)}function g(e){return void 0!==e&&void 0!==e.meta&&!0===e.meta.isTransformFunction||!1}var v={expression:!0,type:!0,docs:!0,error:!0,json:!0,chain:!0};return function(e,r){var t=arguments.length;if(1!==t&&2!==t)throw new sr("import",t,1,2);function n(e,t,i){if(Array.isArray(t))t.forEach((r=>n(e,r)));else if("object"==typeof t)for(var a in t)K(t,a)&&n(e,t[a],a);else if(ne(t)||void 0!==i){var o=ne(t)?g(t)?t.fn+".transform":t.fn:i;if(K(e,o)&&e[o]!==t&&!r.silent)throw new Error('Cannot import "'+o+'" twice');e[o]=t}else if(!r.silent)throw new TypeError("Factory, Object, or Array expected")}r||(r={});var a={};for(var o in n(a,e),a)if(K(a,o)){var s=a[o];if(ne(s))p(s,r);else if(m(s))i(o,s,r);else if(!r.silent)throw new TypeError("Factory, Object, or Array expected")}}}ke.prototype=new RangeError,ke.prototype.constructor=RangeError,ke.prototype.name="DimensionError",ke.prototype.isDimensionError=!0,Ie.prototype=new RangeError,Ie.prototype.constructor=RangeError,Ie.prototype.name="IndexError",Ie.prototype.isIndexError=!0,sr.prototype=new Error,sr.prototype.constructor=Error,sr.prototype.name="ArgumentsError",sr.prototype.isArgumentsError=!0;var cr={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null},lr=["Matrix","Array"],fr=["number","BigNumber","Fraction"];function pr(e,r){function t(t){if(t){var n=Z(e,G);mr(t,"matrix",lr),mr(t,"number",fr),W(e,t);var i=Z(e,G),a=Z(t,G);return r("config",i,n,a),i}return Z(e,G)}return t.MATRIX_OPTIONS=lr,t.NUMBER_OPTIONS=fr,Object.keys(cr).forEach((r=>{Object.defineProperty(t,r,{get:()=>e[r],enumerable:!0,configurable:!0})})),t}function mr(e,r,t){var n,i;void 0!==e[r]&&(n=t,i=e[r],-1===n.indexOf(i))&&console.warn('Warning: Unknown value "'+e[r]+'" for configuration option "'+r+'". Available options: '+t.map((e=>JSON.stringify(e))).join(", ")+".")}function hr(e,r){if(yr(e)&&gr(e,r))return e[r];if("function"==typeof e[r]&&vr(e,r))throw new Error('Cannot access method "'+r+'" as a property');throw new Error('No access to property "'+r+'"')}function dr(e,r,t){if(yr(e)&&gr(e,r))return e[r]=t,t;throw new Error('No access to property "'+r+'"')}function gr(e,r){return!(!e||"object"!=typeof e)&&(!!K(xr,r)||!(r in Object.prototype)&&!(r in Function.prototype))}function vr(e,r){return null!=e&&"function"==typeof e[r]&&(!(K(e,r)&&Object.getPrototypeOf&&r in Object.getPrototypeOf(e))&&(!!K(br,r)||!(r in Object.prototype)&&!(r in Function.prototype)))}function yr(e){return"object"==typeof e&&e&&e.constructor===Object}var xr={length:!0,name:!0},br={toString:!0,valueOf:!0,toLocaleString:!0};class wr{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return hr(this.wrappedObject,e)}set(e,r){return dr(this.wrappedObject,e,r),this}has(e){return r=this.wrappedObject,e in r;var r}}function Nr(){return new Map}function Dr(e){if(!e)return Nr();if(Er(e))return e;if(D(e))return new wr(e);throw new Error("createMap can create maps from objects or Maps")}function Er(e){return!!e&&(e instanceof Map||e instanceof wr||"function"==typeof e.set&&"function"==typeof e.get&&"function"==typeof e.keys&&"function"==typeof e.has)}function Ar(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;nc&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])*$/.test(e)},{name:"string",test:c},{name:"Chain",test:H},{name:"Array",test:l},{name:"Matrix",test:f},{name:"DenseMatrix",test:m},{name:"SparseMatrix",test:h},{name:"Range",test:d},{name:"Index",test:g},{name:"boolean",test:v},{name:"ResultSet",test:y},{name:"Help",test:x},{name:"function",test:b},{name:"Date",test:w},{name:"RegExp",test:N},{name:"null",test:E},{name:"undefined",test:A},{name:"AccessorNode",test:C},{name:"ArrayNode",test:S},{name:"AssignmentNode",test:M},{name:"BlockNode",test:F},{name:"ConditionalNode",test:T},{name:"ConstantNode",test:O},{name:"FunctionNode",test:z},{name:"FunctionAssignmentNode",test:_},{name:"IndexNode",test:q},{name:"Node",test:k},{name:"ObjectNode",test:I},{name:"OperatorNode",test:R},{name:"ParenthesisNode",test:P},{name:"RangeNode",test:j},{name:"RelationalNode",test:U},{name:"SymbolNode",test:L},{name:"Map",test:Er},{name:"Object",test:D}]),$.addConversions([{from:"number",to:"BigNumber",convert:function(e){if(r||Mr(e),e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new r(e)}},{from:"number",to:"Complex",convert:function(e){return t||Fr(e),new t(e,0)}},{from:"BigNumber",to:"Complex",convert:function(e){return t||Fr(e),new t(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 t||Fr(e),new t(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){B||Tr(e);var r=new B(e);if(r.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 r}},{from:"string",to:"number",convert:function(e){var r=Number(e);if(isNaN(r))throw new Error('Cannot convert "'+e+'" to a number');return r}},{from:"string",to:"BigNumber",convert:function(e){r||Mr(e);try{return new r(e)}catch(r){throw new Error('Cannot convert "'+e+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(e){B||Tr(e);try{return new B(e)}catch(r){throw new Error('Cannot convert "'+e+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(e){t||Fr(e);try{return new t(e)}catch(r){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 r||Mr(e),new r(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return B||Tr(e),new B(+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()}}]),$.onMismatch=(e,r,t)=>{var n=$.createError(e,r,t);if(["wrongType","mismatch"].includes(n.data.category)&&1===r.length&&p(r[0])&&t.some((e=>!e.params.includes(",")))){var i=new TypeError("Function '".concat(e,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(e,")'."));throw i.data=n.data,i}throw n},$.onMismatch=(e,r,t)=>{var n=$.createError(e,r,t);if(["wrongType","mismatch"].includes(n.data.category)&&1===r.length&&p(r[0])&&t.some((e=>!e.params.includes(",")))){var i=new TypeError("Function '".concat(e,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(e,")'."));throw i.data=n.data,i}throw n},$}));function Mr(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function Fr(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function Tr(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var Or,Br,_r=te("ResultSet",[],(()=>{function e(r){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=r||[]}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(r){return new e(r.entries)},e}),{isClass:!0}),zr=9e15,qr=1e9,kr="0123456789abcdef",Ir="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Rr="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Pr={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-zr,maxE:zr,crypto:!1},jr=!0,Ur="[DecimalError] ",Lr=Ur+"Invalid argument: ",Hr=Ur+"Precision limit exceeded",$r=Ur+"crypto unavailable",Gr="[object Decimal]",Zr=Math.floor,Vr=Math.pow,Wr=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Jr=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Yr=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Xr=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Qr=1e7,Kr=Ir.length-1,et=Rr.length-1,rt={toStringTag:Gr};function tt(e){var r,t,n,i=e.length-1,a="",o=e[0];if(i>0){for(a+=o,r=1;rt)throw Error(Lr+e)}function it(e,r,t,n){var i,a,o,s;for(a=e[0];a>=10;a/=10)--r;return--r<0?(r+=7,i=0):(i=Math.ceil((r+1)/7),r%=7),a=Vr(10,7-r),s=e[i]%a|0,null==n?r<3?(0==r?s=s/100|0:1==r&&(s=s/10|0),o=t<4&&99999==s||t>3&&49999==s||5e4==s||0==s):o=(t<4&&s+1==a||t>3&&s+1==a/2)&&(e[i+1]/a/100|0)==Vr(10,r-2)-1||(s==a/2||0==s)&&0==(e[i+1]/a/100|0):r<4?(0==r?s=s/1e3|0:1==r?s=s/100|0:2==r&&(s=s/10|0),o=(n||t<4)&&9999==s||!n&&t>3&&4999==s):o=((n||t<4)&&s+1==a||!n&&t>3&&s+1==a/2)&&(e[i+1]/a/1e3|0)==Vr(10,r-3)-1,o}function at(e,r,t){for(var n,i,a=[0],o=0,s=e.length;ot-1&&(void 0===a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/t|0,a[n]%=t)}return a.reverse()}rt.absoluteValue=rt.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),st(e)},rt.ceil=function(){return st(new this.constructor(this),this.e+1,2)},rt.clampedTo=rt.clamp=function(e,r){var t=this,n=t.constructor;if(e=new n(e),r=new n(r),!e.s||!r.s)return new n(NaN);if(e.gt(r))throw Error(Lr+r);return t.cmp(e)<0?e:t.cmp(r)>0?r:new n(t)},rt.comparedTo=rt.cmp=function(e){var r,t,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(r=0,t=(n=o.length)<(i=s.length)?n:i;rs[r]^u<0?1:-1;return n===i?0:n>i^u<0?1:-1},rt.cosine=rt.cos=function(){var e,r,t=this,n=t.constructor;return t.d?t.d[0]?(e=n.precision,r=n.rounding,n.precision=e+Math.max(t.e,t.sd())+7,n.rounding=1,t=function(e,r){var t,n,i;if(r.isZero())return r;(n=r.d.length)<32?i=(1/Dt(4,t=Math.ceil(n/3))).toString():(t=16,i="2.3283064365386962890625e-10");e.precision+=t,r=Nt(e,1,r.times(i),new e(1));for(var a=t;a--;){var o=r.times(r);r=o.times(o).minus(o).times(8).plus(1)}return e.precision-=t,r}(n,Et(n,t)),n.precision=e,n.rounding=r,st(2==Br||3==Br?t.neg():t,e,r,!0)):new n(1):new n(NaN)},rt.cubeRoot=rt.cbrt=function(){var e,r,t,n,i,a,o,s,u,c,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(jr=!1,(a=l.s*Vr(l.s*l,1/3))&&Math.abs(a)!=1/0?n=new f(a.toString()):(t=tt(l.d),(a=((e=l.e)-t.length+1)%3)&&(t+=1==a||-2==a?"0":"00"),a=Vr(t,1/3),e=Zr((e+1)/3)-(e%3==(e<0?-1:2)),(n=new f(t=a==1/0?"5e"+e:(t=a.toExponential()).slice(0,t.indexOf("e")+1)+e)).s=l.s),o=(e=f.precision)+3;;)if(c=(u=(s=n).times(s).times(s)).plus(l),n=ot(c.plus(l).times(s),c.plus(u),o+2,1),tt(s.d).slice(0,o)===(t=tt(n.d)).slice(0,o)){if("9999"!=(t=t.slice(o-3,o+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(st(n,e+1,1),r=!n.times(n).times(n).eq(l));break}if(!i&&(st(s,e+1,0),s.times(s).times(s).eq(l))){n=s;break}o+=4,i=1}return jr=!0,st(n,e,f.rounding,r)},rt.decimalPlaces=rt.dp=function(){var e,r=this.d,t=NaN;if(r){if(t=7*((e=r.length-1)-Zr(this.e/7)),e=r[e])for(;e%10==0;e/=10)t--;t<0&&(t=0)}return t},rt.dividedBy=rt.div=function(e){return ot(this,new this.constructor(e))},rt.dividedToIntegerBy=rt.divToInt=function(e){var r=this.constructor;return st(ot(this,new r(e),0,1,1),r.precision,r.rounding)},rt.equals=rt.eq=function(e){return 0===this.cmp(e)},rt.floor=function(){return st(new this.constructor(this),this.e+1,3)},rt.greaterThan=rt.gt=function(e){return this.cmp(e)>0},rt.greaterThanOrEqualTo=rt.gte=function(e){var r=this.cmp(e);return 1==r||0===r},rt.hyperbolicCosine=rt.cosh=function(){var e,r,t,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;t=o.precision,n=o.rounding,o.precision=t+Math.max(a.e,a.sd())+4,o.rounding=1,(i=a.d.length)<32?r=(1/Dt(4,e=Math.ceil(i/3))).toString():(e=16,r="2.3283064365386962890625e-10"),a=Nt(o,1,a.times(r),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 st(a,o.precision=t,o.rounding=n,!0)},rt.hyperbolicSine=rt.sinh=function(){var e,r,t,n,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(r=a.precision,t=a.rounding,a.precision=r+Math.max(i.e,i.sd())+4,a.rounding=1,(n=i.d.length)<3)i=Nt(a,2,i,i,!0);else{e=(e=1.4*Math.sqrt(n))>16?16:0|e,i=Nt(a,2,i=i.times(1/Dt(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=r,a.rounding=t,st(i,r,t,!0)},rt.hyperbolicTangent=rt.tanh=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+7,n.rounding=1,ot(t.sinh(),t.cosh(),n.precision=e,n.rounding=r)):new n(t.s)},rt.inverseCosine=rt.acos=function(){var e,r=this,t=r.constructor,n=r.abs().cmp(1),i=t.precision,a=t.rounding;return-1!==n?0===n?r.isNeg()?ft(t,i,a):new t(0):new t(NaN):r.isZero()?ft(t,i+4,a).times(.5):(t.precision=i+6,t.rounding=1,r=r.asin(),e=ft(t,i+4,a).times(.5),t.precision=i,t.rounding=a,e.minus(r))},rt.inverseHyperbolicCosine=rt.acosh=function(){var e,r,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(e=n.precision,r=n.rounding,n.precision=e+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,jr=!1,t=t.times(t).minus(1).sqrt().plus(t),jr=!0,n.precision=e,n.rounding=r,t.ln()):new n(t)},rt.inverseHyperbolicSine=rt.asinh=function(){var e,r,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,jr=!1,t=t.times(t).plus(1).sqrt().plus(t),jr=!0,n.precision=e,n.rounding=r,t.ln())},rt.inverseHyperbolicTangent=rt.atanh=function(){var e,r,t,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,r=a.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?st(new a(i),e,r,!0):(a.precision=t=n-i.e,i=ot(i.plus(1),new a(1).minus(i),t+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=r,i.times(.5))):new a(NaN)},rt.inverseSine=rt.asin=function(){var e,r,t,n,i=this,a=i.constructor;return i.isZero()?new a(i):(r=i.abs().cmp(1),t=a.precision,n=a.rounding,-1!==r?0===r?((e=ft(a,t+4,n).times(.5)).s=i.s,e):new a(NaN):(a.precision=t+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=t,a.rounding=n,i.times(2)))},rt.inverseTangent=rt.atan=function(){var e,r,t,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<=et)return(o=ft(l,f+4,p).times(.25)).s=c.s,o}else{if(!c.s)return new l(NaN);if(f+4<=et)return(o=ft(l,f+4,p).times(.5)).s=c.s,o}for(l.precision=s=f+10,l.rounding=1,e=t=Math.min(28,s/7+2|0);e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(jr=!1,r=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[r])for(e=r;o.d[e]===a.d[e]&&e--;);return t&&(o=o.times(2<this.d.length-2},rt.isNaN=function(){return!this.s},rt.isNegative=rt.isNeg=function(){return this.s<0},rt.isPositive=rt.isPos=function(){return this.s>0},rt.isZero=function(){return!!this.d&&0===this.d[0]},rt.lessThan=rt.lt=function(e){return this.cmp(e)<0},rt.lessThanOrEqualTo=rt.lte=function(e){return this.cmp(e)<1},rt.logarithm=rt.log=function(e){var r,t,n,i,a,o,s,u,c=this,l=c.constructor,f=l.precision,p=l.rounding;if(null==e)e=new l(10),r=!0;else{if(t=(e=new l(e)).d,e.s<0||!t||!t[0]||e.eq(1))return new l(NaN);r=e.eq(10)}if(t=c.d,c.s<0||!t||!t[0]||c.eq(1))return new l(t&&!t[0]?-1/0:1!=c.s?NaN:t?0:1/0);if(r)if(t.length>1)a=!0;else{for(i=t[0];i%10==0;)i/=10;a=1!==i}if(jr=!1,o=yt(c,s=f+5),n=r?lt(l,s+10):yt(e,s),it((u=ot(o,n,s,1)).d,i=f,p))do{if(o=yt(c,s+=10),n=r?lt(l,s+10):yt(e,s),u=ot(o,n,s,1),!a){+tt(u.d).slice(i+1,i+15)+1==1e14&&(u=st(u,f+1,0));break}}while(it(u.d,i+=10,p));return jr=!0,st(u,f,p)},rt.minus=rt.sub=function(e){var r,t,n,i,a,o,s,u,c,l,f,p,m=this,h=m.constructor;if(e=new h(e),!m.d||!e.d)return m.s&&e.s?m.d?e.s=-e.s:e=new h(e.d||m.s!==e.s?m:NaN):e=new h(NaN),e;if(m.s!=e.s)return e.s=-e.s,m.plus(e);if(c=m.d,p=e.d,s=h.precision,u=h.rounding,!c[0]||!p[0]){if(p[0])e.s=-e.s;else{if(!c[0])return new h(3===u?-0:0);e=new h(m)}return jr?st(e,s,u):e}if(t=Zr(e.e/7),l=Zr(m.e/7),c=c.slice(),a=l-t){for((f=a<0)?(r=c,a=-a,o=p.length):(r=p,t=l,o=c.length),a>(n=Math.max(Math.ceil(s/7),o)+2)&&(a=n,r.length=1),r.reverse(),n=a;n--;)r.push(0);r.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,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for((o=c.length)-(i=l.length)<0&&(i=o,t=l,l=c,c=t),r=0;i;)r=(c[--i]=c[i]+l[i]+r)/Qr|0,c[i]%=Qr;for(r&&(c.unshift(r),++n),o=c.length;0==c[--o];)c.pop();return e.d=c,e.e=ct(c,n),jr?st(e,s,u):e},rt.precision=rt.sd=function(e){var r,t=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(Lr+e);return t.d?(r=pt(t.d),e&&t.e+1>r&&(r=t.e+1)):r=NaN,r},rt.round=function(){var e=this,r=e.constructor;return st(new r(e),e.e+1,r.rounding)},rt.sine=rt.sin=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+Math.max(t.e,t.sd())+7,n.rounding=1,t=function(e,r){var t,n=r.d.length;if(n<3)return r.isZero()?r:Nt(e,2,r,r);t=(t=1.4*Math.sqrt(n))>16?16:0|t,r=r.times(1/Dt(5,t)),r=Nt(e,2,r,r);for(var i,a=new e(5),o=new e(16),s=new e(20);t--;)i=r.times(r),r=r.times(a.plus(i.times(o.times(i).minus(s))));return r}(n,Et(n,t)),n.precision=e,n.rounding=r,st(Br>2?t.neg():t,e,r,!0)):new n(NaN)},rt.squareRoot=rt.sqrt=function(){var e,r,t,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(jr=!1,0==(c=Math.sqrt(+o))||c==1/0?(((r=tt(s)).length+u)%2==0&&(r+="0"),c=Math.sqrt(r),u=Zr((u+1)/2)-(u<0||u%2),n=new l(r=c==1/0?"5e"+u:(r=c.toExponential()).slice(0,r.indexOf("e")+1)+u)):n=new l(c.toString()),t=(u=l.precision)+3;;)if(n=(a=n).plus(ot(o,a,t+2,1)).times(.5),tt(a.d).slice(0,t)===(r=tt(n.d)).slice(0,t)){if("9999"!=(r=r.slice(t-3,t+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(st(n,u+1,1),e=!n.times(n).eq(o));break}if(!i&&(st(a,u+1,0),a.times(a).eq(o))){n=a;break}t+=4,i=1}return jr=!0,st(n,u,l.rounding,e)},rt.tangent=rt.tan=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+10,n.rounding=1,(t=t.sin()).s=1,t=ot(t,new n(1).minus(t.times(t)).sqrt(),e+10,0),n.precision=e,n.rounding=r,st(2==Br||4==Br?t.neg():t,e,r,!0)):new n(NaN)},rt.times=rt.mul=function(e){var r,t,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(t=Zr(l.e/7)+Zr(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(r=0,i=u+n;i>n;)s=a[i]+m[n]*p[i-n-1]+r,a[i--]=s%Qr|0,r=s/Qr|0;a[i]=(a[i]+r)%Qr|0}for(;!a[--o];)a.pop();return r?++t:a.shift(),e.d=a,e.e=ct(a,t),jr?st(e,f.precision,f.rounding):e},rt.toBinary=function(e,r){return At(this,2,e,r)},rt.toDecimalPlaces=rt.toDP=function(e,r){var t=this,n=t.constructor;return t=new n(t),void 0===e?t:(nt(e,0,qr),void 0===r?r=n.rounding:nt(r,0,8),st(t,e+t.e+1,r))},rt.toExponential=function(e,r){var t,n=this,i=n.constructor;return void 0===e?t=ut(n,!0):(nt(e,0,qr),void 0===r?r=i.rounding:nt(r,0,8),t=ut(n=st(new i(n),e+1,r),!0,e+1)),n.isNeg()&&!n.isZero()?"-"+t:t},rt.toFixed=function(e,r){var t,n,i=this,a=i.constructor;return void 0===e?t=ut(i):(nt(e,0,qr),void 0===r?r=a.rounding:nt(r,0,8),t=ut(n=st(new a(i),e+i.e+1,r),!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t},rt.toFraction=function(e){var r,t,n,i,a,o,s,u,c,l,f,p,m=this,h=m.d,d=m.constructor;if(!h)return new d(m);if(c=t=new d(1),n=u=new d(0),o=(a=(r=new d(n)).e=pt(h)-m.e-1)%7,r.d[0]=Vr(10,o<0?7+o:o),null==e)e=a>0?r:c;else{if(!(s=new d(e)).isInt()||s.lt(c))throw Error(Lr+s);e=s.gt(r)?a>0?r:c:s}for(jr=!1,s=new d(tt(h)),l=d.precision,d.precision=a=7*h.length*2;f=ot(s,r,0,1,1),1!=(i=t.plus(f.times(n))).cmp(e);)t=n,n=i,i=c,c=u.plus(f.times(i)),u=i,i=r,r=s.minus(f.times(i)),s=i;return i=ot(e.minus(t),n,0,1,1),u=u.plus(i.times(c)),t=t.plus(i.times(n)),u.s=c.s=m.s,p=ot(c,n,a,1).minus(m).abs().cmp(ot(u,t,a,1).minus(m).abs())<1?[c,n]:[u,t],d.precision=l,jr=!0,p},rt.toHexadecimal=rt.toHex=function(e,r){return At(this,16,e,r)},rt.toNearest=function(e,r){var t=this,n=t.constructor;if(t=new n(t),null==e){if(!t.d)return t;e=new n(1),r=n.rounding}else{if(e=new n(e),void 0===r?r=n.rounding:nt(r,0,8),!t.d)return e.s?t:e;if(!e.d)return e.s&&(e.s=t.s),e}return e.d[0]?(jr=!1,t=ot(t,e,0,r,1).times(e),jr=!0,st(t)):(e.s=t.s,t=e),t},rt.toNumber=function(){return+this},rt.toOctal=function(e,r){return At(this,8,e,r)},rt.toPower=rt.pow=function(e){var r,t,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(Vr(+s,c));if((s=new u(s)).eq(1))return s;if(n=u.precision,a=u.rounding,e.eq(1))return st(s,n,a);if((r=Zr(e.e/7))>=e.d.length-1&&(t=c<0?-c:c)<=9007199254740991)return i=ht(u,s,t,n),e.s<0?new u(1).div(i):st(i,n,a);if((o=s.s)<0){if(ru.maxE+1||r0?o/0:0):(jr=!1,u.rounding=s.s=1,t=Math.min(12,(r+"").length),(i=vt(e.times(yt(s,n+t)),n)).d&&it((i=st(i,n+5,1)).d,n,a)&&(r=n+10,+tt((i=st(vt(e.times(yt(s,r+t)),r),r+5,1)).d).slice(n+1,n+15)+1==1e14&&(i=st(i,n+1,0))),i.s=o,jr=!0,u.rounding=a,st(i,n,a))},rt.toPrecision=function(e,r){var t,n=this,i=n.constructor;return void 0===e?t=ut(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(nt(e,1,qr),void 0===r?r=i.rounding:nt(r,0,8),t=ut(n=st(new i(n),e,r),e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+t:t},rt.toSignificantDigits=rt.toSD=function(e,r){var t=this.constructor;return void 0===e?(e=t.precision,r=t.rounding):(nt(e,1,qr),void 0===r?r=t.rounding:nt(r,0,8)),st(new t(this),e,r)},rt.toString=function(){var e=this,r=e.constructor,t=ut(e,e.e<=r.toExpNeg||e.e>=r.toExpPos);return e.isNeg()&&!e.isZero()?"-"+t:t},rt.truncated=rt.trunc=function(){return st(new this.constructor(this),this.e+1,1)},rt.valueOf=rt.toJSON=function(){var e=this,r=e.constructor,t=ut(e,e.e<=r.toExpNeg||e.e>=r.toExpPos);return e.isNeg()?"-"+t:t};var ot=function(){function e(e,r,t){var n,i=0,a=e.length;for(e=e.slice();a--;)n=e[a]*r+i,e[a]=n%t|0,i=n/t|0;return i&&e.unshift(i),e}function r(e,r,t,n){var i,a;if(t!=n)a=t>n?1:-1;else for(i=a=0;ir[i]?1:-1;break}return a}function t(e,r,t,n){for(var i=0;t--;)e[t]-=i,i=e[t]1;)e.shift()}return function(n,i,a,o,s,u){var c,l,f,p,m,h,d,g,v,y,x,b,w,N,D,E,A,C,S,M,F=n.constructor,T=n.s==i.s?1:-1,O=n.d,B=i.d;if(!(O&&O[0]&&B&&B[0]))return new F(n.s&&i.s&&(O?!B||O[0]!=B[0]:B)?O&&0==O[0]||!B?0*T:T/0:NaN);for(u?(m=1,l=n.e-i.e):(u=Qr,m=7,l=Zr(n.e/m)-Zr(i.e/m)),S=B.length,A=O.length,y=(v=new F(T)).d=[],f=0;B[f]==(O[f]||0);f++);if(B[f]>(O[f]||0)&&l--,null==a?(N=a=F.precision,o=F.rounding):N=s?a+(n.e-i.e)+1:a,N<0)y.push(1),h=!0;else{if(N=N/m+2|0,f=0,1==S){for(p=0,B=B[0],N++;(f1&&(B=e(B,p,u),O=e(O,p,u),S=B.length,A=O.length),E=S,b=(x=O.slice(0,S)).length;b=u/2&&++C;do{p=0,(c=r(B,x,S,b))<0?(w=x[0],S!=b&&(w=w*u+(x[1]||0)),(p=w/C|0)>1?(p>=u&&(p=u-1),1==(c=r(d=e(B,p,u),x,g=d.length,b=x.length))&&(p--,t(d,S=10;p/=10)f++;v.e=f+l*m-1,st(v,s?a+v.e+1:a,o,h)}return v}}();function st(e,r,t,n){var i,a,o,s,u,c,l,f,p,m=e.constructor;e:if(null!=r){if(!(f=e.d))return e;for(i=1,s=f[0];s>=10;s/=10)i++;if((a=r-i)<0)a+=7,o=r,u=(l=f[p=0])/Vr(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/Vr(10,i-o-1)%10|0}if(n=n||r<0||void 0!==f[p+1]||(o<0?l:l%Vr(10,i-o-1)),c=t<4?(u||n)&&(0==t||t==(e.s<0?3:2)):u>5||5==u&&(4==t||n||6==t&&(a>0?o>0?l/Vr(10,i-o):0:f[p-1])%10&1||t==(e.s<0?8:7)),r<1||!f[0])return f.length=0,c?(r-=e.e+1,f[0]=Vr(10,(7-r%7)%7),e.e=-r||0):f[0]=e.e=0,e;if(0==a?(f.length=p,s=1,p--):(f.length=p+1,s=Vr(10,7-a),f[p]=o>0?(l/Vr(10,i-o)%Vr(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]==Qr&&(f[0]=1));break}if(f[p]+=s,f[p]!=Qr)break;f[p--]=0,s=1}for(a=f.length;0===f[--a];)f.pop()}return jr&&(e.e>m.maxE?(e.d=null,e.e=NaN):e.e0?a=a.charAt(0)+"."+a.slice(1)+mt(n):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(e.e<0?"e":"e+")+e.e):i<0?(a="0."+mt(-i-1)+a,t&&(n=t-o)>0&&(a+=mt(n))):i>=o?(a+=mt(i+1-o),t&&(n=t-i-1)>0&&(a=a+"."+mt(n))):((n=i+1)0&&(i+1===o&&(a+="."),a+=mt(n))),a}function ct(e,r){var t=e[0];for(r*=7;t>=10;t/=10)r++;return r}function lt(e,r,t){if(r>Kr)throw jr=!0,t&&(e.precision=t),Error(Hr);return st(new e(Ir),r,1,!0)}function ft(e,r,t){if(r>et)throw Error(Hr);return st(new e(Rr),r,t,!0)}function pt(e){var r=e.length-1,t=7*r+1;if(r=e[r]){for(;r%10==0;r/=10)t--;for(r=e[0];r>=10;r/=10)t++}return t}function mt(e){for(var r="";e--;)r+="0";return r}function ht(e,r,t,n){var i,a=new e(1),o=Math.ceil(n/7+4);for(jr=!1;;){if(t%2&&Ct((a=a.times(r)).d,o)&&(i=!0),0===(t=Zr(t/2))){t=a.d.length-1,i&&0===a.d[t]&&++a.d[t];break}Ct((r=r.times(r)).d,o)}return jr=!0,a}function dt(e){return 1&e.d[e.d.length-1]}function gt(e,r,t){for(var n,i=new e(r[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==r?(jr=!1,u=h):u=r,s=new p(.03125);e.e>-2;)e=e.times(s),f+=5;for(u+=n=Math.log(Vr(2,f))/Math.LN10*2+5|0,t=a=o=new p(1),p.precision=u;;){if(a=st(a.times(e),u,1),t=t.times(++l),tt((s=o.plus(ot(a,t,u,1))).d).slice(0,u)===tt(o.d).slice(0,u)){for(i=f;i--;)o=st(o.times(o),u,1);if(null!=r)return p.precision=h,o;if(!(c<3&&it(o.d,u-n,m,c)))return st(o,p.precision=h,m,jr=!0);p.precision=u+=10,t=a=s=new p(1),l=0,c++}o=s}}function yt(e,r){var t,n,i,a,o,s,u,c,l,f,p,m=1,h=e,d=h.d,g=h.constructor,v=g.rounding,y=g.precision;if(h.s<0||!d||!d[0]||!h.e&&1==d[0]&&1==d.length)return new g(d&&!d[0]?-1/0:1!=h.s?NaN:d?0:h);if(null==r?(jr=!1,l=y):l=r,g.precision=l+=10,n=(t=tt(d)).charAt(0),!(Math.abs(a=h.e)<15e14))return c=lt(g,l+2,y).times(a+""),h=yt(new g(n+"."+t.slice(1)),l-10).plus(c),g.precision=y,null==r?st(h,y,v,jr=!0):h;for(;n<7&&1!=n||1==n&&t.charAt(1)>3;)n=(t=tt((h=h.times(e)).d)).charAt(0),m++;for(a=h.e,n>1?(h=new g("0."+t),a++):h=new g(n+"."+t.slice(1)),f=h,u=o=h=ot(h.minus(1),h.plus(1),l,1),p=st(h.times(h),l,1),i=3;;){if(o=st(o.times(p),l,1),tt((c=u.plus(ot(o,new g(i),l,1))).d).slice(0,l)===tt(u.d).slice(0,l)){if(u=u.times(2),0!==a&&(u=u.plus(lt(g,l+2,y).times(a+""))),u=ot(u,new g(m),l,1),null!=r)return g.precision=y,u;if(!it(u.d,l-10,v,s))return st(u,g.precision=y,v,jr=!0);g.precision=l+=10,c=o=h=ot(f.minus(1),f.plus(1),l,1),p=st(h.times(h),l,1),i=s=1}u=c,i+=2}}function xt(e){return String(e.s*e.s/0)}function bt(e,r){var t,n,i;for((t=r.indexOf("."))>-1&&(r=r.replace(".","")),(n=r.search(/e/i))>0?(t<0&&(t=n),t+=+r.slice(n+1),r=r.substring(0,n)):t<0&&(t=r.length),n=0;48===r.charCodeAt(n);n++);for(i=r.length;48===r.charCodeAt(i-1);--i);if(r=r.slice(n,i)){if(i-=n,e.e=t=t-n-1,e.d=[],n=(t+1)%7,t<0&&(n+=7),ne.constructor.maxE?(e.d=null,e.e=NaN):e.e-1){if(r=r.replace(/(\d)_(?=\d)/g,"$1"),Xr.test(r))return bt(e,r)}else if("Infinity"===r||"NaN"===r)return+r||(e.s=NaN),e.e=NaN,e.d=null,e;if(Jr.test(r))t=16,r=r.toLowerCase();else if(Wr.test(r))t=2;else{if(!Yr.test(r))throw Error(Lr+r);t=8}for((a=r.search(/p/i))>0?(u=+r.slice(a+1),r=r.substring(2,a)):r=r.slice(2),o=(a=r.indexOf("."))>=0,n=e.constructor,o&&(a=(s=(r=r.replace(".","")).length)-a,i=ht(n,new n(t),a,2*a)),a=l=(c=at(r,t,Qr)).length-1;0===c[a];--a)c.pop();return a<0?new n(0*e.s):(e.e=ct(c,l),e.d=c,jr=!1,o&&(e=ot(e,i,4*s)),u&&(e=e.times(Math.abs(u)<54?Vr(2,u):hn.pow(2,u))),jr=!0,e)}function Nt(e,r,t,n,i){var a,o,s,u,c=e.precision,l=Math.ceil(c/7);for(jr=!1,u=t.times(t),s=new e(n);;){if(o=ot(s.times(u),new e(r++*r++),c,1),s=i?n.plus(o):n.minus(o),n=ot(o.times(u),new e(r++*r++),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 jr=!0,o.d.length=l+1,o}function Dt(e,r){for(var t=e;--r;)t*=e;return t}function Et(e,r){var t,n=r.s<0,i=ft(e,e.precision,1),a=i.times(.5);if((r=r.abs()).lte(a))return Br=n?4:1,r;if((t=r.divToInt(i)).isZero())Br=n?3:2;else{if((r=r.minus(t.times(i))).lte(a))return Br=dt(t)?n?2:3:n?4:1,r;Br=dt(t)?n?1:4:n?3:2}return r.minus(i).abs()}function At(e,r,t,n){var i,a,o,s,u,c,l,f,p,m=e.constructor,h=void 0!==t;if(h?(nt(t,1,qr),void 0===n?n=m.rounding:nt(n,0,8)):(t=m.precision,n=m.rounding),e.isFinite()){for(h?(i=2,16==r?t=4*t-3:8==r&&(t=3*t-2)):i=r,(o=(l=ut(e)).indexOf("."))>=0&&(l=l.replace(".",""),(p=new m(1)).e=l.length-o,p.d=at(ut(p),10,i),p.e=p.d.length),a=u=(f=at(l,10,i)).length;0==f[--u];)f.pop();if(f[0]){if(o<0?a--:((e=new m(e)).d=f,e.e=a,f=(e=ot(e,p,t,n,0,i)).d,a=e.e,c=Or),o=f[t],s=i/2,c=c||void 0!==f[t+1],c=n<4?(void 0!==o||c)&&(0===n||n===(e.s<0?3:2)):o>s||o===s&&(4===n||c||6===n&&1&f[t-1]||n===(e.s<0?8:7)),f.length=t,c)for(;++f[--t]>i-1;)f[t]=0,t||(++a,f.unshift(1));for(u=f.length;!f[u-1];--u);for(o=0,l="";o1)if(16==r||8==r){for(o=16==r?4:3,--u;u%o;u++)l+="0";for(u=(f=at(l,i,r)).length;!f[u-1];--u);for(o=1,l="1.";ou)for(a-=u;a--;)l+="0";else ar)return e.length=r,!0}function St(e){return new this(e).abs()}function Mt(e){return new this(e).acos()}function Ft(e){return new this(e).acosh()}function Tt(e,r){return new this(e).plus(r)}function Ot(e){return new this(e).asin()}function Bt(e){return new this(e).asinh()}function _t(e){return new this(e).atan()}function zt(e){return new this(e).atanh()}function qt(e,r){e=new this(e),r=new this(r);var t,n=this.precision,i=this.rounding,a=n+4;return e.s&&r.s?e.d||r.d?!r.d||e.isZero()?(t=r.s<0?ft(this,n,i):new this(0)).s=e.s:!e.d||r.isZero()?(t=ft(this,a,1).times(.5)).s=e.s:r.s<0?(this.precision=a,this.rounding=1,t=this.atan(ot(e,r,a,1)),r=ft(this,a,1),this.precision=n,this.rounding=i,t=e.s<0?t.minus(r):t.plus(r)):t=this.atan(ot(e,r,a,1)):(t=ft(this,a,1).times(r.s>0?.25:.75)).s=e.s:t=new this(NaN),t}function kt(e){return new this(e).cbrt()}function It(e){return st(e=new this(e),e.e+1,2)}function Rt(e,r,t){return new this(e).clamp(r,t)}function Pt(e){if(!e||"object"!=typeof e)throw Error(Ur+"Object expected");var r,t,n,i=!0===e.defaults,a=["precision",1,qr,"rounding",0,8,"toExpNeg",-zr,0,"toExpPos",0,zr,"maxE",0,zr,"minE",-zr,0,"modulo",0,9];for(r=0;r=a[r+1]&&n<=a[r+2]))throw Error(Lr+t+": "+n);this[t]=n}if(t="crypto",i&&(this[t]=Pr[t]),void 0!==(n=e[t])){if(!0!==n&&!1!==n&&0!==n&&1!==n)throw Error(Lr+t+": "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error($r);this[t]=!0}else this[t]=!1}return this}function jt(e){return new this(e).cos()}function Ut(e){return new this(e).cosh()}function Lt(e,r){return new this(e).div(r)}function Ht(e){return new this(e).exp()}function $t(e){return st(e=new this(e),e.e+1,3)}function Gt(){var e,r,t=new this(0);for(jr=!1,e=0;e=429e7?r[a]=crypto.getRandomValues(new Uint32Array(1))[0]:s[a++]=i%1e7;else{if(!crypto.randomBytes)throw Error($r);for(r=crypto.randomBytes(n*=4);a=214e7?crypto.randomBytes(4).copy(r,a):(s.push(i%1e7),a+=4);a=n/4}else for(;a=10;i/=10)n++;n<7&&(t-=7-n)}return o.e=t,o.d=s,o}function nn(e){return st(e=new this(e),e.e+1,this.rounding)}function an(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function on(e){return new this(e).sin()}function sn(e){return new this(e).sinh()}function un(e){return new this(e).sqrt()}function cn(e,r){return new this(e).sub(r)}function ln(){var e=0,r=arguments,t=new this(r[e]);for(jr=!1;t.s&&++ea.maxE?(i.e=NaN,i.d=null):e.e=10;t/=10)r++;return void(jr?r>a.maxE?(i.e=NaN,i.d=null):r{var{on:r,config:t}=e,n=dn.clone({precision:t.precision,modulo:dn.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)},r&&r("config",(function(e,r){e.precision!==r.precision&&n.config({precision:e.precision})})),n}),{isClass:!0}),vn=t(1977),yn=te("Complex",[],(()=>(Object.defineProperty(vn,"name",{value:"Complex"}),vn.prototype.constructor=vn,vn.prototype.type="Complex",vn.prototype.isComplex=!0,vn.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},vn.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},vn.prototype.format=function(e){var r=this.im,t=this.re,n=me(this.re,e),a=me(this.im,e),o=i(e)?e:e?e.precision:null;if(null!==o){var s=Math.pow(10,-o);Math.abs(t/r)r.re?1:e.rer.im?1:e.im(Object.defineProperty(xn,"name",{value:"Fraction"}),xn.prototype.constructor=xn,xn.prototype.type="Fraction",xn.prototype.isFraction=!0,xn.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},xn.fromJSON=function(e){return new xn(e)},xn)),{isClass:!0}),wn=te("Range",[],(()=>{function e(r,t,n){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var i=null!=r,o=null!=t,s=null!=n;if(i)if(a(r))r=r.toNumber();else if("number"!=typeof r)throw new TypeError("Parameter start must be a number");if(o)if(a(t))t=t.toNumber();else if("number"!=typeof t)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(r):0,this.end=o?parseFloat(t):0,this.step=s?parseFloat(n):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(r){if("string"!=typeof r)return null;var t=r.split(":").map((function(e){return parseFloat(e)}));if(t.some((function(e){return isNaN(e)})))return null;switch(t.length){case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[2],t[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var e=0,r=this.start,t=this.step,n=this.end-r;return oe(t)===oe(n)?e=Math.ceil(n/t):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 r=this.start,t=this.step,n=this.end,i=0;if(t>0)for(;rn;)e(r,[i],this),r+=t,i++},e.prototype.map=function(e){var r=[];return this.forEach((function(t,n,i){r[n[0]]=e(t,n,i)})),r},e.prototype.toArray=function(){var e=[];return this.forEach((function(r,t){e[t[0]]=r})),e},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(e){var r=me(this.start,e);return 1!==this.step&&(r+=":"+me(this.step,e)),r+=":"+me(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(r){return new e(r.start,r.end,r.step)},e}),{isClass:!0}),Nn=te("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,r){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(e,r,t){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,r,t){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(e,r){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(e,r){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,r){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});function Dn(e){var r=0,t=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],--r,t===o)){if(!r)return a=0,void(t=1);for(;!hasOwnProperty.call(n,++t););}};return e=Math.abs(e),{hit:function(s){var u=i[s],c=++a;if(n[c]=s,i[s]=c,!u){if(++r<=e)return;return s=n[t],o(s),s}if(delete n[u],t===u)for(;!hasOwnProperty.call(n,++t););},delete:o,clear:function(){r=a=0,t=1,n=Object.create(null),i=Object.create(null)}}}function En(e){var{hasher:r,limit:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t=null==t?Number.POSITIVE_INFINITY:t,r=null==r?JSON.stringify:r,function n(){"object"!=typeof n.cache&&(n.cache={values:new Map,lru:Dn(t||Number.POSITIVE_INFINITY)});for(var i=[],a=0;a{var{Matrix:r}=e;function t(e,r){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(r&&!c(r))throw new Error("Invalid datatype: "+r);if(f(e))"DenseMatrix"===e.type?(this._data=G(e._data),this._size=G(e._size),this._datatype=r||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=r||e._datatype);else if(e&&l(e.data)&&l(e.size))this._data=e.data,this._size=e.size,je(this._data,this._size),this._datatype=r||e.datatype;else if(l(e))this._data=d(e),this._size=Re(this._data),je(this._data,this._size),this._datatype=r;else{if(e)throw new TypeError("Unsupported type of data ("+$(e)+")");this._data=[],this._size=[0],this._datatype=r}}function n(e,r){if(!g(r))throw new TypeError("Invalid index");if(r.isScalar())return e.get(r.min());var n=r.size();if(n.length!==e._size.length)throw new ke(n.length,e._size.length);for(var i=r.min(),a=r.max(),s=0,u=e._size.length;s");var l=r.max().map((function(e){return e+1}));h(e,l,n);var p=a.length;u(e._data,r,t,p,0)}return e}function u(e,r,t,n,i){var a=i===n-1,o=r.dimension(i);a?o.forEach((function(r,n){Ue(r),e[r]=t[n[0]]})):o.forEach((function(a,o){Ue(a),u(e[a],r,t[o[0]],n,i+1)}))}function m(e,r,t){if(0===r.length){for(var n=e._data;l(n);)n=n[0];return n}return e._size=r.slice(0),e._data=Le(e._data,e._size,t),e}function h(e,r,t){for(var n=e._size.slice(0),i=!1;n.lengthn[a]&&(n[a]=r[a],i=!0);i&&m(e,n,t)}function d(e){for(var r=0,t=e.length;rArray.isArray(e)&&1===e.length?e[0]:e));return m(t?this.clone():this,n,r)},t.prototype.reshape=function(e,r){var t=r?this.clone():this;t._data=$e(t._data,e);var n=t._size.reduce(((e,r)=>e*r));return t._size=Ge(e,n),t},t.prototype.clone=function(){return new t({data:G(this._data),size:G(this._size),datatype:this._datatype})},t.prototype.size=function(){return this._size.slice(0)},t.prototype.map=function(e){var r=this,n=An(e),i=function t(i,a){return l(i)?i.map((function(e,r){return t(e,a.concat(r))})):1===n?e(i):2===n?e(i,a):e(i,a,r)}(this._data,[]);return new t(i,void 0!==this._datatype?ar(i,$):void 0)},t.prototype.forEach=function(e){var r=this;!function t(n,i){l(n)?n.forEach((function(e,r){t(e,i.concat(r))})):e(n,i,r)}(this._data,[])},t.prototype[Symbol.iterator]=function*(){yield*function*e(r,t){if(l(r))for(var n=0;n[e[n]]));r.push(new t(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-r),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(r)){if(r.length!==h)throw new Error("Invalid value array length");s=function(e){return r[e]}}else if(f(r)){var d=r.size();if(1!==d.length||d[0]!==h)throw new Error("Invalid matrix length");s=function(e){return r.get([e])}}else s=function(){return r};o||(o=a(s(0))?s(0).mul(0):0);var g=[];if(e.length>0){g=Le(g,e,o);for(var v=0;v{var{typed:r}=e;return r(Sn,{any:G})}));function Fn(e){var r,t,n=e.length,i=e[0].length,a=[];for(t=0;t=n.length)throw new Ie(r,n.length);return f(e)?e.create(zn(e.valueOf(),r,t)):zn(e,r,t)}function zn(e,r,t){var n,i,a,o;if(r<=0){if(Array.isArray(e[0])){for(o=Fn(e),i=[],n=0;n{var{typed:r}=e;return r(kn,{number:ae,BigNumber:function(e){return e.isInt()},Fraction:function(e){return 1===e.d&&isFinite(e.n)},"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))})})),Rn="number";function Pn(e){return e<0}function jn(e){return e>0}function Un(e){return 0===e}function Ln(e){return Number.isNaN(e)}Pn.signature=Rn,jn.signature=Rn,Un.signature=Rn,Ln.signature=Rn;var Hn="isNegative",$n=te(Hn,["typed"],(e=>{var{typed:r}=e;return r(Hn,{number:Pn,BigNumber:function(e){return e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s<0},Unit:r.referToSelf((e=>t=>r.find(e,t.valueType())(t.value))),"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))})})),Gn="isNumeric",Zn=te(Gn,["typed"],(e=>{var{typed:r}=e;return r(Gn,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))})})),Vn="hasNumericValue",Wn=te(Vn,["typed","isNumeric"],(e=>{var{typed:r,isNumeric:t}=e;return r(Vn,{boolean:()=>!0,string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return t(e)}})})),Jn="isPositive",Yn=te(Jn,["typed"],(e=>{var{typed:r}=e;return r(Jn,{number:jn,BigNumber:function(e){return!e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s>0&&e.n>0},Unit:r.referToSelf((e=>t=>r.find(e,t.valueType())(t.value))),"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))})})),Xn="isZero",Qn=te(Xn,["typed"],(e=>{var{typed:r}=e;return r(Xn,{number:Un,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:r.referToSelf((e=>t=>r.find(e,t.valueType())(t.value))),"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))})})),Kn="isNaN",ei=te(Kn,["typed"],(e=>{var{typed:r}=e;return r(Kn,{number:Ln,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 Bn(e,Number.isNaN)}})})),ri="typeOf",ti=te(ri,["typed"],(e=>{var{typed:r}=e;return r(ri,{any:$})}));function ni(e,r,t){if(null==t)return e.eq(r);if(e.eq(r))return!0;if(e.isNaN()||r.isNaN())return!1;if(e.isFinite()&&r.isFinite()){var n=e.minus(r).abs();if(n.isZero())return!0;var i=e.constructor.max(e.abs(),r.abs());return n.lte(i.times(t))}return!1}var ii=te("compareUnits",["typed"],(e=>{var{typed:r}=e;return{"Unit, Unit":r.referToSelf((e=>(t,n)=>{if(!t.equalBase(n))throw new Error("Cannot compare units with different base");return r.find(e,[t.valueType(),n.valueType()])(t.value,n.value)}))}})),ai="equalScalar",oi=te(ai,["typed","config"],(e=>{var{typed:r,config:t}=e,n=ii({typed:r});return r(ai,{"boolean, boolean":function(e,r){return e===r},"number, number":function(e,r){return be(e,r,t.epsilon)},"BigNumber, BigNumber":function(e,r){return e.eq(r)||ni(e,r,t.epsilon)},"Fraction, Fraction":function(e,r){return e.equals(r)},"Complex, Complex":function(e,r){return function(e,r,t){return be(e.re,r.re,t)&&be(e.im,r.im,t)}(e,r,t.epsilon)}},n)})),si=(te(ai,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(ai,{"number, number":function(e,r){return be(e,r,t.epsilon)}})})),te("SparseMatrix",["typed","equalScalar","Matrix"],(e=>{var{typed:r,equalScalar:t,Matrix:n}=e;function o(e,r){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(r&&!c(r))throw new Error("Invalid datatype: "+r);if(f(e))!function(e,r,t){"SparseMatrix"===r.type?(e._values=r._values?G(r._values):void 0,e._index=G(r._index),e._ptr=G(r._ptr),e._size=G(r._size),e._datatype=t||r._datatype):s(e,r.valueOf(),t||r._datatype)}(this,e,r);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=r||e.datatype;else if(l(e))s(this,e,r);else{if(e)throw new TypeError("Unsupported type of data ("+$(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=r}}function s(e,n,i){e._values=[],e._index=[],e._ptr=[],e._datatype=i;var a=n.length,o=0,s=t,u=0;if(c(i)&&(s=r.find(t,[i,i])||t,u=r.convert(0,i)),a>0){var f=0;do{e._ptr.push(e._index.length);for(var p=0;p");if(1===a.length){r.dimension(0).forEach((function(r,i){Ue(r),e.set([r,0],t[i[0]],n)}))}else{var c=r.dimension(0),l=r.dimension(1);c.forEach((function(r,i){Ue(r),l.forEach((function(a,o){Ue(a),e.set([r,a],t[i[0]][o[0]],n)}))}))}}return e}function h(e,r,t,n){if(t-r==0)return t;for(var i=r;id){for(f=d;fh){if(m){var g=0;for(f=0;fn-1&&(e._values.splice(p,1),e._index.splice(p,1),y++)}e._ptr[f]=e._values.length}return e._size[0]=n,e._size[1]=i,e}function y(e,r,t,n,i){var a,o,s=n[0],u=n[1],c=[];for(a=0;as-1||o>u-1)&&(v(this,Math.max(a+1,s),Math.max(o+1,u),i),s=this._size[0],u=this._size[1]),Ue(a,s),Ue(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)||!ae(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Oe(n)+")")})),v(t?this.clone():this,n[0],n[1],r)},o.prototype.reshape=function(e,r){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(r){if(!i(r)||!ae(r)||r<=-2||0===r)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Oe(e)+")")}));var t=this._size[0]*this._size[1];if(t!==(e=Ge(e,t))[0]*e[1])throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var n=r?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return n;for(var a=[],o=0;o=n&&w<=i&&g(e._values[b],w-n,v-a)}else{for(var N={},D=y;D "+(this._values?Oe(this._values[u],e):"X")}return i},o.prototype.toString=function(){return Oe(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)||!ae(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var r=e>0?e:0,t=e<0?-e:0,n=this._size[0],s=this._size[1],u=Math.min(n-t,s-r),c=[],l=[],f=[];f[0]=0;for(var p=r;p0?s:0,v=s<0?-s:0,y=e[0],x=e[1],b=Math.min(y-v,x-g);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=[],D=[],E=[],A=0;A=0&&C=u||i[l]!==r)){var p=n?n[c]:void 0;i.splice(l,0,r),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}));var ui=te("number",["typed"],(e=>{var{typed:r}=e,t=r("number",{"":function(){return 0},number:function(e){return e},string:function(e){if("NaN"===e)return NaN;var r,t,n=(t=(r=e).match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/))?{input:r,radix:{"0b":2,"0o":8,"0x":16}[t[1]],integerPart:t[2],fractionalPart:t[3]}:null;if(n)return function(e){for(var r=parseInt(e.integerPart,e.radix),t=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,r){return e.toNumber(r)},"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))});return t.fromJSON=function(e){return parseFloat(e.value)},t})),ci="string",li=te(ci,["typed"],(e=>{var{typed:r}=e;return r(ci,{"":function(){return""},number:me,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e))),any:function(e){return String(e)}})})),fi="boolean",pi=te(fi,["typed"],(e=>{var{typed:r}=e;return r(fi,{"":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 r=e.toLowerCase();if("true"===r)return!0;if("false"===r)return!1;var t=Number(e);if(""!==e&&!isNaN(t))return!!t;throw new Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))})})),mi=te("bignumber",["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r("bignumber",{"":function(){return new t(0)},number:function(e){return new t(e+"")},string:function(e){var r=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(r){var n=r[2],i=t(r[1]),a=new t(2).pow(Number(n));if(i.gt(a.sub(1)))throw new SyntaxError('String "'.concat(e,'" is out of range'));var o=new t(2).pow(Number(n)-1);return i.gte(o)?i.sub(a):i}return new t(e)},BigNumber:function(e){return e},Fraction:function(e){return new t(e.n).div(e.d).times(e.s)},null:function(e){return new t(0)},"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))})})),hi=te("complex",["typed","Complex"],(e=>{var{typed:r,Complex:t}=e;return r("complex",{"":function(){return t.ZERO},number:function(e){return new t(e,0)},"number, number":function(e,r){return new t(e,r)},"BigNumber, BigNumber":function(e,r){return new t(e.toNumber(),r.toNumber())},Fraction:function(e){return new t(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return t(e)},null:function(e){return t(0)},Object:function(e){if("re"in e&&"im"in e)return new t(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new t(e);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))})})),di=te("fraction",["typed","Fraction"],(e=>{var{typed:r,Fraction:t}=e;return r("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw new Error(e+" cannot be represented as a fraction");return new t(e)},string:function(e){return new t(e)},"number, number":function(e,r){return new t(e,r)},null:function(e){return new t(0)},BigNumber:function(e){return new t(e.toString())},Fraction:function(e){return e},Object:function(e){return new t(e)},"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))})})),gi="matrix",vi=te(gi,["typed","Matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:r,Matrix:t,DenseMatrix:n,SparseMatrix:i}=e;return r(gi,{"":function(){return a([])},string:function(e){return a([],e)},"string, string":function(e,r){return a([],e,r)},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,r,t){if("dense"===r||"default"===r||void 0===r)return new n(e,t);if("sparse"===r)return new i(e,t);throw new TypeError("Unknown matrix type "+JSON.stringify(r)+".")}})),yi="matrixFromFunction",xi=te(yi,["typed","matrix","isZero"],(e=>{var{typed:r,matrix:t,isZero:n}=e;return r(yi,{"Array | Matrix, function, string, string":function(e,r,t,n){return i(e,r,t,n)},"Array | Matrix, function, string":function(e,r,t){return i(e,r,t)},"Matrix, function":function(e,r){return i(e,r,"dense")},"Array, function":function(e,r){return i(e,r,"dense").toArray()},"Array | Matrix, string, function":function(e,r,t){return i(e,t,r)},"Array | Matrix, string, string, function":function(e,r,t,n){return i(e,n,r,t)}});function i(e,r,i,a){var o;return(o=void 0!==a?t(i,a):t(i)).resize(e),o.forEach((function(e,t){var i=r(t);n(i)||o.set(t,i)})),o}})),bi="matrixFromRows",wi=te(bi,["typed","matrix","flatten","size"],(e=>{var{typed:r,matrix:t,flatten:n,size:i}=e;return r(bi,{"...Array":function(e){return a(e)},"...Matrix":function(e){return t(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 r=o(e[0]),t=[];for(var i of e){var a=o(i);if(a!==r)throw new TypeError("The vectors had different length: "+(0|r)+" ≠ "+(0|a));t.push(n(i))}return t}function o(e){var r=i(e);if(1===r.length)return r[0];if(2===r.length){if(1===r[0])return r[1];if(1===r[1])return r[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.")}})),Ni="matrixFromColumns",Di=te(Ni,["typed","matrix","flatten","size"],(e=>{var{typed:r,matrix:t,flatten:n,size:i}=e;return r(Ni,{"...Array":function(e){return a(e)},"...Matrix":function(e){return t(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 r=o(e[0]),t=[],i=0;i{var{typed:r}=e;return r(Ei,{"Unit, Array":function(e,r){return e.splitUnit(r)}})})),Ci="number",Si="number, number";function Mi(e){return Math.abs(e)}function Fi(e,r){return e+r}function Ti(e,r){return e*r}function Oi(e){return-e}function Bi(e){return e}function _i(e){return le(e)}function zi(e){return e*e*e}function qi(e){return Math.exp(e)}function ki(e){return fe(e)}function Ii(e,r){if(!ae(e)||!ae(r))throw new Error("Parameters in function gcd must be integer numbers");for(var t;0!==r;)t=e%r,e=r,r=t;return e<0?-e:e}function Ri(e,r){if(!ae(e)||!ae(r))throw new Error("Parameters in function lcm must be integer numbers");if(0===e||0===r)return 0;for(var t,n=e*r;0!==r;)r=e%(t=r),e=t;return Math.abs(n/e)}function Pi(e){return ue(e)}function ji(e){return se(e)}function Ui(e,r){if(r>0)return e-r*Math.floor(e/r);if(0===r)return e;throw new Error("Cannot calculate mod for a negative divisor")}function Li(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,t=r<0;if(t&&(r=-r),0===r)throw new Error("Root must be non-zero");if(e<0&&Math.abs(r)%2!=1)throw new Error("Root must be odd when a is negative.");if(0===e)return t?1/0:0;if(!isFinite(e))return t?0:e;var n=Math.pow(Math.abs(e),1/r);return n=e<0?-n:n,t?1/n:n}function Hi(e){return oe(e)}function $i(e){return e*e}function Gi(e,r){var t,n,i,a=0,o=1,s=1,u=0;if(!ae(e)||!ae(r))throw new Error("Parameters in function xgcd must be integer numbers");for(;r;)i=e-(n=Math.floor(e/r))*r,t=a,a=o-n*a,o=t,t=s,s=u-n*s,u=t,e=r,r=i;return e<0?[-e,-o,-u]:[e,e?o:0,u]}function Zi(e,r){return e*e<1&&r===1/0||e*e>1&&r===-1/0?0:Math.pow(e,r)}function Vi(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!ae(r)||r<0||r>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(de(e,r))}Mi.signature=Ci,Fi.signature=Si,Ti.signature=Si,Oi.signature=Ci,Bi.signature=Ci,_i.signature=Ci,zi.signature=Ci,qi.signature=Ci,ki.signature=Ci,Ii.signature=Si,Ri.signature=Si,Pi.signature=Ci,ji.signature=Ci,Ui.signature=Si,Hi.signature=Ci,$i.signature=Ci,Gi.signature=Si,Zi.signature=Si;var Wi="unaryMinus",Ji=te(Wi,["typed"],(e=>{var{typed:r}=e;return r(Wi,{number:Oi,"Complex | BigNumber | Fraction":e=>e.neg(),Unit:r.referToSelf((e=>t=>{var n=t.clone();return n.value=r.find(e,n.valueType())(t.value),n})),"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e,!0)))})})),Yi="unaryPlus",Xi=te(Yi,["typed","config","BigNumber"],(e=>{var{typed:r,config:t,BigNumber:n}=e;return r(Yi,{number:Bi,Complex:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e,!0))),"boolean | string":function(e){return"BigNumber"===t.number?new n(+e):+e}})})),Qi=te("abs",["typed"],(e=>{var{typed:r}=e;return r("abs",{number:Mi,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e,!0)))})})),Ki="apply",ea=te(Ki,["typed","isInteger"],(e=>{var{typed:r,isInteger:t}=e;return r(Ki,{"Array | Matrix, number | BigNumber, function":function(e,r,n){if(!t(r))throw new TypeError("Integer number expected for dimension");var i=Array.isArray(e)?Re(e):e.size();if(r<0||r>=i.length)throw new Ie(r,i.length);return f(e)?e.create(ra(e.valueOf(),r,n)):ra(e,r,n)}})}));function ra(e,r,t){var n,i,a;if(r<=0){if(Array.isArray(e[0])){for(a=function(e){var r,t,n=e.length,i=e[0].length,a=[];for(t=0;t{var{typed:r}=e;return r(ta,{"number, number":Fi,"Complex, Complex":function(e,r){return e.add(r)},"BigNumber, BigNumber":function(e,r){return e.plus(r)},"Fraction, Fraction":function(e,r){return e.add(r)},"Unit, Unit":r.referToSelf((e=>(t,n)=>{if(null===t.value||void 0===t.value)throw new Error("Parameter x contains a unit with undefined value");if(null===n.value||void 0===n.value)throw new Error("Parameter y contains a unit with undefined value");if(!t.equalBase(n))throw new Error("Units do not match");var i=t.clone();return i.value=r.find(e,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i}))})})),ia="cbrt",aa=te(ia,["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],(e=>{var{config:r,typed:t,isNegative:n,unaryMinus:i,matrix:u,Complex:c,BigNumber:l,Fraction:f}=e;return t(ia,{number:_i,Complex:p,"Complex, boolean":p,BigNumber:function(e){return e.cbrt()},Unit:function(e){if(e.value&&o(e.value)){var r=e.clone();return r.value=1,(r=r.pow(1/3)).value=p(e.value),r}var t,u=n(e.value);u&&(e.value=i(e.value)),t=a(e.value)?new l(1).div(3):s(e.value)?new f(1,3):1/3;var c=e.pow(t);return u&&(c.value=i(c.value)),c}});function p(e,t){var n=e.arg()/3,i=e.abs(),a=new c(_i(i),0).mul(new c(0,n).exp());if(t){var o=[a,new c(_i(i),0).mul(new c(0,n+2*Math.PI/3).exp()),new c(_i(i),0).mul(new c(0,n-2*Math.PI/3).exp())];return"Array"===r.matrix?o:u(o)}return a}})),oa=te("matAlgo11xS0s",["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=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=t,d=0,g=i;"string"==typeof l&&(f=l,h=r.find(t,[f,f]),d=r.convert(0,f),n=r.convert(n,f),g=r.find(i,[f,f]));for(var v=[],y=[],x=[],b=0;b{var{typed:r,DenseMatrix:t}=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=r.convert(n,f),h=r.find(i,[f,f]));for(var d=[],g=[],v=[],y=0;y{var{typed:r}=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=r.convert(n,o),l=r.find(i,[o,o]));var f=u.length>0?t(l,0,u,u[0],s,n,a):[];return e.createDenseMatrix({data:f,size:G(u),datatype:o})};function t(e,r,n,i,a,o,s){var u=[];if(r===n.length-1)for(var c=0;c{var{typed:r,config:t,round:n}=e;return r(ca,{number:function(e){return be(e,n(e),t.epsilon)?n(e):Math.ceil(e)},"number, number":function(e,r){if(be(e,n(e,r),t.epsilon))return n(e,r);var[i,a]="".concat(e,"e").split("e"),o=Math.ceil(Number("".concat(i,"e").concat(Number(a)+r)));return[i,a]="".concat(o,"e").split("e"),Number("".concat(i,"e").concat(Number(a)-r))}})})),pa=te(ca,la,(e=>{var{typed:r,config:t,round:n,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s}=e,u=oa({typed:r,equalScalar:a}),c=sa({typed:r,DenseMatrix:s}),l=ua({typed:r}),f=fa({typed:r,config:t,round:n});return r("ceil",{number:f.signatures.number,"number,number":f.signatures["number,number"],Complex:function(e){return e.ceil()},"Complex, number":function(e,r){return e.ceil(r)},"Complex, BigNumber":function(e,r){return e.ceil(r.toNumber())},BigNumber:function(e){return ni(e,n(e),t.epsilon)?n(e):e.ceil()},"BigNumber, BigNumber":function(e,r){return ni(e,n(e,r),t.epsilon)?n(e,r):e.toDecimalPlaces(r.toNumber(),dn.ROUND_CEIL)},Fraction:function(e){return e.ceil()},"Fraction, number":function(e,r){return e.ceil(r)},"Fraction, BigNumber":function(e,r){return e.ceil(r.toNumber())},"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e,!0))),"Array, number | BigNumber":r.referToSelf((e=>(r,t)=>Bn(r,(r=>e(r,t)),!0))),"SparseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>u(r,t,e,!1))),"DenseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>l(r,t,e,!1))),"number | Complex | Fraction | BigNumber, Array":r.referToSelf((e=>(r,t)=>l(i(t),r,e,!0).valueOf())),"number | Complex | Fraction | BigNumber, Matrix":r.referToSelf((e=>(r,t)=>a(r,0)?o(t.size(),t.storage()):"dense"===t.storage()?l(t,r,e,!0):c(t,r,e,!0)))})})),ma="cube",ha=te(ma,["typed"],(e=>{var{typed:r}=e;return r(ma,{number:zi,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)},Unit:function(e){return e.pow(3)}})})),da=te("exp",["typed"],(e=>{var{typed:r}=e;return r("exp",{number:qi,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()}})})),ga="expm1",va=te(ga,["typed","Complex"],(e=>{var{typed:r,Complex:t}=e;return r(ga,{number:ki,Complex:function(e){var r=Math.exp(e.re);return new t(r*Math.cos(e.im)-1,r*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)}})})),ya="fix",xa=["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],ba=te(ya,["typed","ceil","floor"],(e=>{var{typed:r,ceil:t,floor:n}=e;return r(ya,{number:function(e){return e>0?n(e):t(e)},"number, number":function(e,r){return e>0?n(e,r):t(e,r)}})})),wa=te(ya,xa,(e=>{var{typed:r,Complex:t,matrix:n,ceil:i,floor:a,equalScalar:o,zeros:s,DenseMatrix:u}=e,c=sa({typed:r,DenseMatrix:u}),l=ua({typed:r}),f=ba({typed:r,ceil:i,floor:a});return r("fix",{number:f.signatures.number,"number, number | BigNumber":f.signatures["number,number"],Complex:function(e){return new t(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},"Complex, number":function(e,r){return new t(e.re>0?a(e.re,r):i(e.re,r),e.im>0?a(e.im,r):i(e.im,r))},"Complex, BigNumber":function(e,r){var n=r.toNumber();return new t(e.re>0?a(e.re,n):i(e.re,n),e.im>0?a(e.im,n):i(e.im,n))},BigNumber:function(e){return e.isNegative()?i(e):a(e)},"BigNumber, number | BigNumber":function(e,r){return e.isNegative()?i(e,r):a(e,r)},Fraction:function(e){return e.s<0?e.ceil():e.floor()},"Fraction, number | BigNumber":function(e,r){return e.s<0?i(e,r):a(e,r)},"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e,!0))),"Array | Matrix, number | BigNumber":r.referToSelf((e=>(r,t)=>Bn(r,(r=>e(r,t)),!0))),"number | Complex | Fraction | BigNumber, Array":r.referToSelf((e=>(r,t)=>l(n(t),r,e,!0).valueOf())),"number | Complex | Fraction | BigNumber, Matrix":r.referToSelf((e=>(r,t)=>o(r,0)?s(t.size(),t.storage()):"dense"===t.storage()?l(t,r,e,!0):c(t,r,e,!0)))})})),Na="floor",Da=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],Ea=te(Na,["typed","config","round"],(e=>{var{typed:r,config:t,round:n}=e;return r(Na,{number:function(e){return be(e,n(e),t.epsilon)?n(e):Math.floor(e)},"number, number":function(e,r){if(be(e,n(e,r),t.epsilon))return n(e,r);var[i,a]="".concat(e,"e").split("e"),o=Math.floor(Number("".concat(i,"e").concat(Number(a)+r)));return[i,a]="".concat(o,"e").split("e"),Number("".concat(i,"e").concat(Number(a)-r))}})})),Aa=te(Na,Da,(e=>{var{typed:r,config:t,round:n,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s}=e,u=oa({typed:r,equalScalar:a}),c=sa({typed:r,DenseMatrix:s}),l=ua({typed:r}),f=Ea({typed:r,config:t,round:n});return r("floor",{number:f.signatures.number,"number,number":f.signatures["number,number"],Complex:function(e){return e.floor()},"Complex, number":function(e,r){return e.floor(r)},"Complex, BigNumber":function(e,r){return e.floor(r.toNumber())},BigNumber:function(e){return ni(e,n(e),t.epsilon)?n(e):e.floor()},"BigNumber, BigNumber":function(e,r){return ni(e,n(e,r),t.epsilon)?n(e,r):e.toDecimalPlaces(r.toNumber(),dn.ROUND_FLOOR)},Fraction:function(e){return e.floor()},"Fraction, number":function(e,r){return e.floor(r)},"Fraction, BigNumber":function(e,r){return e.floor(r.toNumber())},"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e,!0))),"Array, number | BigNumber":r.referToSelf((e=>(r,t)=>Bn(r,(r=>e(r,t)),!0))),"SparseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>u(r,t,e,!1))),"DenseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>l(r,t,e,!1))),"number | Complex | Fraction | BigNumber, Array":r.referToSelf((e=>(r,t)=>l(i(t),r,e,!0).valueOf())),"number | Complex | Fraction | BigNumber, Matrix":r.referToSelf((e=>(r,t)=>a(r,0)?o(t.size(),t.storage()):"dense"===t.storage()?l(t,r,e,!0):c(t,r,e,!0)))})})),Ca=te("matAlgo01xDSid",["typed"],(e=>{var{typed:r}=e;return function(e,t,n,i){var a=e._data,o=e._size,s=e._datatype,u=t._values,c=t._index,l=t._ptr,f=t._size,p=t._datatype;if(o.length!==f.length)throw new ke(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],g=o[1],v="string"==typeof s&&s===p?s:void 0,y=v?r.find(n,[v,v]):n,x=[];for(m=0;m{var{typed:r,equalScalar:t}=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 ke(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,g=u[0],v=u[1],y=t,x=0,b=i;"string"==typeof c&&c===h&&(d=c,y=r.find(t,[d,d]),x=r.convert(0,d),b=r.find(i,[d,d]));var w,N,D,E,A,C=a&&l?[]:void 0,S=[],M=[],F=a&&l?[]:void 0,T=a&&l?[]:void 0,O=[],B=[];for(N=0;N{var{typed:r,DenseMatrix:t}=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=r.convert(n,f),h=r.find(i,[f,f]));for(var d=[],g=[],v=[],y=0;y{var{typed:r}=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 ke(s.length,l.length);for(var m=0;m0?t(h,0,p,p[0],o,c):[];return e.createDenseMatrix({data:d,size:p,datatype:a})};function t(e,r,n,i,a,o){var s=[];if(r===n.length-1)for(var u=0;u{var{typed:r,matrix:t}=e,n=Fa({typed:r}),i=ua({typed:r});return function(e){var a,o=e.elop,s=e.SD||e.DS;o?(a={"DenseMatrix, DenseMatrix":(e,r)=>n(e,r,o),"Array, Array":(e,r)=>n(t(e),t(r),o).valueOf(),"Array, DenseMatrix":(e,r)=>n(t(e),r,o),"DenseMatrix, Array":(e,r)=>n(e,t(r),o)},e.SS&&(a["SparseMatrix, SparseMatrix"]=(r,t)=>e.SS(r,t,o,!1)),e.DS&&(a["DenseMatrix, SparseMatrix"]=(r,t)=>e.DS(r,t,o,!1),a["Array, SparseMatrix"]=(r,n)=>e.DS(t(r),n,o,!1)),s&&(a["SparseMatrix, DenseMatrix"]=(e,r)=>s(r,e,o,!0),a["SparseMatrix, Array"]=(e,r)=>s(t(r),e,o,!0))):(a={"DenseMatrix, DenseMatrix":r.referToSelf((e=>(r,t)=>n(r,t,e))),"Array, Array":r.referToSelf((e=>(r,i)=>n(t(r),t(i),e).valueOf())),"Array, DenseMatrix":r.referToSelf((e=>(r,i)=>n(t(r),i,e))),"DenseMatrix, Array":r.referToSelf((e=>(r,i)=>n(r,t(i),e)))},e.SS&&(a["SparseMatrix, SparseMatrix"]=r.referToSelf((r=>(t,n)=>e.SS(t,n,r,!1)))),e.DS&&(a["DenseMatrix, SparseMatrix"]=r.referToSelf((r=>(t,n)=>e.DS(t,n,r,!1))),a["Array, SparseMatrix"]=r.referToSelf((r=>(n,i)=>e.DS(t(n),i,r,!1)))),s&&(a["SparseMatrix, DenseMatrix"]=r.referToSelf((e=>(r,t)=>s(t,r,e,!0))),a["SparseMatrix, Array"]=r.referToSelf((e=>(r,n)=>s(t(n),r,e,!0)))));var u=e.scalar||"any";(e.Ds||e.Ss)&&(o?(a["DenseMatrix,"+u]=(e,r)=>i(e,r,o,!1),a[u+", DenseMatrix"]=(e,r)=>i(r,e,o,!0),a["Array,"+u]=(e,r)=>i(t(e),r,o,!1).valueOf(),a[u+", Array"]=(e,r)=>i(t(r),e,o,!0).valueOf()):(a["DenseMatrix,"+u]=r.referToSelf((e=>(r,t)=>i(r,t,e,!1))),a[u+", DenseMatrix"]=r.referToSelf((e=>(r,t)=>i(t,r,e,!0))),a["Array,"+u]=r.referToSelf((e=>(r,n)=>i(t(r),n,e,!1).valueOf())),a[u+", Array"]=r.referToSelf((e=>(r,n)=>i(t(n),r,e,!0).valueOf()))));var c=void 0!==e.sS?e.sS:e.Ss;return o?(e.Ss&&(a["SparseMatrix,"+u]=(r,t)=>e.Ss(r,t,o,!1)),c&&(a[u+", SparseMatrix"]=(e,r)=>c(r,e,o,!0))):(e.Ss&&(a["SparseMatrix,"+u]=r.referToSelf((r=>(t,n)=>e.Ss(t,n,r,!1)))),c&&(a[u+", SparseMatrix"]=r.referToSelf((e=>(r,t)=>c(t,r,e,!0))))),o&&o.signatures&&V(a,o.signatures),a}})),Oa=te("gcd",["typed","matrix","equalScalar","BigNumber","DenseMatrix"],(e=>{var{typed:r,matrix:t,equalScalar:n,BigNumber:i,DenseMatrix:a}=e,o=Ca({typed:r}),s=Sa({typed:r,equalScalar:n}),u=Ma({typed:r,DenseMatrix:a}),c=Ta({typed:r,matrix:t}),l="number | BigNumber | Fraction | Matrix | Array",f={};return f["".concat(l,", ").concat(l,", ...").concat(l)]=r.referToSelf((e=>(r,t,n)=>{for(var i=e(r,t),a=0;ae.gcd(r)},c({SS:s,DS:o,Ss:u}),f)})),Ba=te("matAlgo02xDS0",["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=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 ke(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],g=s[1],v=t,y=0,x=i;"string"==typeof u&&u===m&&(h=u,v=r.find(t,[h,h]),y=r.convert(0,h),x=r.find(i,[h,h]));for(var b=[],w=[],N=[],D=0;D{var{typed:r,equalScalar:t}=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 ke(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=t,d=0,g=i;"string"==typeof s&&s===l&&(f=s,h=r.find(t,[f,f]),d=r.convert(0,f),g=r.find(i,[f,f]));for(var v=a&&u?[]:void 0,y=[],x=[],b=v?[]:void 0,w=[],N=[],D=0;D{var{typed:r,matrix:t,equalScalar:n}=e,i=Ba({typed:r,equalScalar:n}),a=_a({typed:r,equalScalar:n}),o=oa({typed:r,equalScalar:n}),s=Ta({typed:r,matrix:t}),u="number | BigNumber | Fraction | Matrix | Array",c={};return c["".concat(u,", ").concat(u,", ...").concat(u)]=r.referToSelf((e=>(r,t,n)=>{for(var i=e(r,t),a=0;ae.lcm(r)},s({SS:a,DS:i,Ss:o}),c)})),qa="log10",ka=te(qa,["typed","config","Complex"],(e=>{var{typed:r,config:t,Complex:n}=e;return r(qa,{number:function(e){return e>=0||t.predictable?Pi(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()||t.predictable?e.log():new n(e.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))})})),Ia="log2",Ra=te(Ia,["typed","config","Complex"],(e=>{var{typed:r,config:t,Complex:n}=e;return r(Ia,{number:function(e){return e>=0||t.predictable?ji(e):i(new n(e,0))},Complex:i,BigNumber:function(e){return!e.isNegative()||t.predictable?e.log(2):i(new n(e.toNumber(),0))},"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))});function i(e){var r=Math.sqrt(e.re*e.re+e.im*e.im);return new n(Math.log2?Math.log2(r):Math.log(r)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}})),Pa=te("matAlgo03xDSf",["typed"],(e=>{var{typed:r}=e;return function(e,t,n,i){var a=e._data,o=e._size,s=e._datatype,u=t._values,c=t._index,l=t._ptr,f=t._size,p=t._datatype;if(o.length!==f.length)throw new ke(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],g=0,v=n;"string"==typeof s&&s===p&&(m=s,g=r.convert(0,m),v=r.find(n,[m,m]));for(var y=[],x=0;x{var{typed:r,equalScalar:t}=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 ke(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,g=u[0],v=u[1],y=t,x=0,b=i;"string"==typeof c&&c===h&&(d=c,y=r.find(t,[d,d]),x=r.convert(0,d),b=r.find(i,[d,d]));var w,N,D,E,A=a&&l?[]:void 0,C=[],S=[],M=A?[]:void 0,F=A?[]:void 0,T=[],O=[];for(N=0;N{var{typed:r,matrix:t,equalScalar:n,DenseMatrix:i}=e,a=Ba({typed:r,equalScalar:n}),o=Pa({typed:r}),s=ja({typed:r,equalScalar:n}),u=oa({typed:r,equalScalar:n}),c=sa({typed:r,DenseMatrix:i});return r("mod",{"number, number":Ui,"BigNumber, BigNumber":function(e,r){if(r.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return r.isZero()?e:e.mod(r)},"Fraction, Fraction":function(e,r){if(r.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return e.compare(0)>=0?e.mod(r):e.mod(r).add(r).mod(r)}},Ta({typed:r,matrix:t})({SS:s,DS:o,SD:a,Ss:u,sS:c}))})),La=te("multiplyScalar",["typed"],(e=>{var{typed:r}=e;return r("multiplyScalar",{"number, number":Ti,"Complex, Complex":function(e,r){return e.mul(r)},"BigNumber, BigNumber":function(e,r){return e.times(r)},"Fraction, Fraction":function(e,r){return e.mul(r)},"number | Fraction | BigNumber | Complex, Unit":(e,r)=>r.multiply(e),"Unit, number | Fraction | BigNumber | Complex | Unit":(e,r)=>e.multiply(r)})})),Ha="multiply",$a=te(Ha,["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],(e=>{var{typed:r,matrix:t,addScalar:n,multiplyScalar:i,equalScalar:a,dot:o}=e,s=oa({typed:r,equalScalar:a}),u=ua({typed:r});function c(e,r){switch(e.length){case 1:switch(r.length){case 1:if(e[0]!==r[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==r[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+r[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+r.length+" dimensions)")}break;case 2:switch(r.length){case 1:if(e[1]!==r[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+r[0]+")");break;case 2:if(e[1]!==r[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+r[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+r.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}}function l(e,t){if("dense"!==t.storage())throw new Error("Support for SparseMatrix not implemented");return function(e,t){var a,o=e._data,s=e._size,u=e._datatype,c=t._data,l=t._size,f=t._datatype,p=s[0],m=l[1],h=n,d=i;u&&f&&u===f&&"string"==typeof u&&(a=u,h=r.find(n,[a,a]),d=r.find(i,[a,a]));for(var g=[],v=0;vC)for(var M=0,F=0;F(r,n)=>{c(Re(r),Re(n));var i=e(t(r),t(n));return f(i)?i.valueOf():i})),"Matrix, Matrix":function(e,r){var t=e.size(),n=r.size();return c(t,n),1===t.length?1===n.length?function(e,r,t){if(0===t)throw new Error("Cannot multiply two empty vectors");return o(e,r)}(e,r,t[0]):l(e,r):1===n.length?p(e,r):m(e,r)},"Matrix, Array":r.referTo("Matrix,Matrix",(e=>(r,n)=>e(r,t(n)))),"Array, Matrix":r.referToSelf((e=>(r,n)=>e(t(r,n.storage()),n))),"SparseMatrix, any":function(e,r){return s(e,r,i,!1)},"DenseMatrix, any":function(e,r){return u(e,r,i,!1)},"any, SparseMatrix":function(e,r){return s(r,e,i,!0)},"any, DenseMatrix":function(e,r){return u(r,e,i,!0)},"Array, any":function(e,r){return u(t(e),r,i,!1).valueOf()},"any, Array":function(e,r){return u(t(r),e,i,!0).valueOf()},"any, any":i,"any, any, ...any":r.referToSelf((e=>(r,t,n)=>{for(var i=e(r,t),a=0;a{var{typed:r,matrix:t,equalScalar:n,BigNumber:i}=e,a=Ca({typed:r}),o=Ba({typed:r,equalScalar:n}),s=_a({typed:r,equalScalar:n}),u=oa({typed:r,equalScalar:n}),c=Ta({typed:r,matrix:t});function l(){throw new Error("Complex number not supported in function nthRoot. Use nthRoots instead.")}return r(Ga,{number:Li,"number, number":Li,BigNumber:e=>f(e,new i(2)),"BigNumber, BigNumber":f,Complex:l,"Complex, number":l,Array:r.referTo("DenseMatrix,number",(e=>r=>e(t(r),2).valueOf())),DenseMatrix:r.referTo("DenseMatrix,number",(e=>r=>e(r,2))),SparseMatrix:r.referTo("SparseMatrix,number",(e=>r=>e(r,2))),"SparseMatrix, SparseMatrix":r.referToSelf((e=>(r,t)=>{if(1===t.density())return s(r,t,e);throw new Error("Root must be non-zero")})),"DenseMatrix, SparseMatrix":r.referToSelf((e=>(r,t)=>{if(1===t.density())return a(r,t,e,!1);throw new Error("Root must be non-zero")})),"Array, SparseMatrix":r.referTo("DenseMatrix,SparseMatrix",(e=>(r,n)=>e(t(r),n))),"number | BigNumber, SparseMatrix":r.referToSelf((e=>(r,t)=>{if(1===t.density())return u(t,r,e,!0);throw new Error("Root must be non-zero")}))},c({scalar:"number | BigNumber",SD:o,Ss:u,sS:!1}));function f(e,r){var t=i.precision,n=i.clone({precision:t+2}),a=new i(0),o=new n(1),s=r.isNegative();if(s&&(r=r.neg()),r.isZero())throw new Error("Root must be non-zero");if(e.isNegative()&&!r.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(r));return u=e.isNeg()?u.neg():u,new i((s?o.div(u):u).toPrecision(t))}})),Va="sign",Wa=te(Va,["typed","BigNumber","Fraction","complex"],(e=>{var{typed:r,BigNumber:t,complex:n,Fraction:i}=e;return r(Va,{number:Hi,Complex:function(e){return 0===e.im?n(Hi(e.re)):e.sign()},BigNumber:function(e){return new t(e.cmp(0))},Fraction:function(e){return new i(e.s,1)},"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e,!0))),Unit:r.referToSelf((e=>t=>{if(!t._isDerived()&&0!==t.units[0].unit.offset)throw new TypeError("sign is ambiguous for units with offset");return r.find(e,t.valueType())(t.value)}))})})),Ja=te("sqrt",["config","typed","Complex"],(e=>{var{config:r,typed:t,Complex:n}=e;return t("sqrt",{number:i,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||r.predictable?e.sqrt():i(e.toNumber())},Unit:function(e){return e.pow(.5)}});function i(e){return isNaN(e)?NaN:e>=0||r.predictable?Math.sqrt(e):new n(e,0).sqrt()}})),Ya="square",Xa=te(Ya,["typed"],(e=>{var{typed:r}=e;return r(Ya,{number:$i,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},Fraction:function(e){return e.mul(e)},Unit:function(e){return e.pow(2)}})})),Qa="subtract",Ka=te(Qa,["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix"],(e=>{var{typed:r,matrix:t,equalScalar:n,addScalar:i,unaryMinus:a,DenseMatrix:o}=e,s=Ca({typed:r}),u=Pa({typed:r}),c=ja({typed:r,equalScalar:n}),l=Ma({typed:r,DenseMatrix:o}),f=sa({typed:r,DenseMatrix:o}),p=Ta({typed:r,matrix:t});return r(Qa,{"number, number":(e,r)=>e-r,"Complex, Complex":(e,r)=>e.sub(r),"BigNumber, BigNumber":(e,r)=>e.minus(r),"Fraction, Fraction":(e,r)=>e.sub(r),"Unit, Unit":r.referToSelf((e=>(t,n)=>{if(null===t.value)throw new Error("Parameter x contains a unit with undefined value");if(null===n.value)throw new Error("Parameter y contains a unit with undefined value");if(!t.equalBase(n))throw new Error("Units do not match");var i=t.clone();return i.value=r.find(e,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i}))},p({SS:c,DS:s,SD:u,Ss:f,sS:l}))})),eo="xgcd",ro=te(eo,["typed","config","matrix","BigNumber"],(e=>{var{typed:r,config:t,matrix:n,BigNumber:i}=e;return r(eo,{"number, number":function(e,r){var i=Gi(e,r);return"Array"===t.matrix?i:n(i)},"BigNumber, BigNumber":function(e,r){var a,o,s,u,c=new i(0),l=new i(1),f=c,p=l,m=l,h=c;if(!e.isInt()||!r.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!r.isZero();)o=e.div(r).floor(),s=e.mod(r),a=f,f=p.minus(o.times(f)),p=a,a=m,m=h.minus(o.times(m)),h=a,e=r,r=s;u=e.lt(c)?[e.neg(),p.neg(),h.neg()]:[e,e.isZero()?0:p,h];return"Array"===t.matrix?u:n(u)}})})),to="invmod",no=te(to,["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],(e=>{var{typed:r,config:t,BigNumber:n,xgcd:i,equal:a,smaller:o,mod:s,add:u,isInteger:c}=e;return r(to,{"number, number":l,"BigNumber, BigNumber":l});function l(e,r){if(!c(e)||!c(r))throw new Error("Parameters in function invmod must be integer numbers");if(e=s(e,r),a(r,0))throw new Error("Divisor must be non zero");var t=i(e,r);t=t.valueOf();var[l,f]=t;return a(l,n(1))?(f=s(f,r),o(f,n(0))&&(f=u(f,r)),f):NaN}})),io=te("matAlgo09xS0Sf",["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=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 ke(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,g=u[0],v=u[1],y=t,x=0,b=i;"string"==typeof c&&c===h&&(d=c,y=r.find(t,[d,d]),x=r.convert(0,d),b=r.find(i,[d,d]));var w,N,D,E,A,C=a&&l?[]:void 0,S=[],M=[],F=C?[]:void 0,T=[];for(N=0;N{var{typed:r,matrix:t,equalScalar:n,multiplyScalar:i}=e,a=Ba({typed:r,equalScalar:n}),o=io({typed:r,equalScalar:n}),s=oa({typed:r,equalScalar:n}),u=Ta({typed:r,matrix:t});return r(ao,u({elop:i,SS:o,DS:a,Ss:s}))}));function so(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw new Error("Integers expected in function bitAnd");var t=e.constructor;if(e.isNaN()||r.isNaN())return new t(NaN);if(e.isZero()||r.eq(-1)||e.eq(r))return e;if(r.isZero()||e.eq(-1))return r;if(!e.isFinite()||!r.isFinite()){if(!e.isFinite()&&!r.isFinite())return e.isNegative()===r.isNegative()?e:new t(0);if(!e.isFinite())return r.isNegative()?e:e.isNegative()?new t(0):r;if(!r.isFinite())return e.isNegative()?r:r.isNegative()?new t(0):e}return lo(e,r,(function(e,r){return e&r}))}function uo(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var r=e.constructor,t=r.precision;r.config({precision:1e9});var n=e.plus(new r(1));return n.s=-n.s||null,r.config({precision:t}),n}function co(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw new Error("Integers expected in function bitOr");var t=e.constructor;if(e.isNaN()||r.isNaN())return new t(NaN);var n=new t(-1);return e.isZero()||r.eq(n)||e.eq(r)?r:r.isZero()||e.eq(n)?e:e.isFinite()&&r.isFinite()?lo(e,r,(function(e,r){return e|r})):!e.isFinite()&&!e.isNegative()&&r.isNegative()||e.isNegative()&&!r.isNegative()&&!r.isFinite()?n:e.isNegative()&&r.isNegative()?e.isFinite()?e:r:e.isFinite()?r:e}function lo(e,r,t){var n,i,a,o,s,u=e.constructor,c=+(e.s<0),l=+(r.s<0);if(c){n=fo(uo(e));for(var f=0;f0;)t(a[--m],o[--h])===d&&(g=g.plus(v)),v=v.times(y);for(;h>0;)t(s,o[--h])===d&&(g=g.plus(v)),v=v.times(y);return u.config({precision:x}),0===d&&(g.s=-g.s),g}function fo(e){for(var r=e.d,t=r[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 po(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw new Error("Integers expected in function bitXor");var t=e.constructor;if(e.isNaN()||r.isNaN())return new t(NaN);if(e.isZero())return r;if(r.isZero())return e;if(e.eq(r))return new t(0);var n=new t(-1);return e.eq(n)?uo(r):r.eq(n)?uo(e):e.isFinite()&&r.isFinite()?lo(e,r,(function(e,r){return e^r})):e.isFinite()||r.isFinite()?new t(e.isNegative()===r.isNegative()?1/0:-1/0):n}function mo(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw new Error("Integers expected in function leftShift");var t=e.constructor;return e.isNaN()||r.isNaN()||r.isNegative()&&!r.isZero()?new t(NaN):e.isZero()||r.isZero()?e:e.isFinite()||r.isFinite()?r.lt(55)?e.times(Math.pow(2,r.toNumber())+""):e.times(new t(2).pow(r)):new t(NaN)}function ho(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw new Error("Integers expected in function rightArithShift");var t=e.constructor;return e.isNaN()||r.isNaN()||r.isNegative()&&!r.isZero()?new t(NaN):e.isZero()||r.isZero()?e:r.isFinite()?r.lt(55)?e.div(Math.pow(2,r.toNumber())+"").floor():e.div(new t(2).pow(r)).floor():e.isNegative()?new t(-1):e.isFinite()?new t(0):new t(NaN)}var go="number, number";function vo(e,r){if(!ae(e)||!ae(r))throw new Error("Integers expected in function bitAnd");return e&r}function yo(e){if(!ae(e))throw new Error("Integer expected in function bitNot");return~e}function xo(e,r){if(!ae(e)||!ae(r))throw new Error("Integers expected in function bitOr");return e|r}function bo(e,r){if(!ae(e)||!ae(r))throw new Error("Integers expected in function bitXor");return e^r}function wo(e,r){if(!ae(e)||!ae(r))throw new Error("Integers expected in function leftShift");return e<>r}function Do(e,r){if(!ae(e)||!ae(r))throw new Error("Integers expected in function rightLogShift");return e>>>r}vo.signature=go,yo.signature="number",xo.signature=go,bo.signature=go,wo.signature=go,No.signature=go,Do.signature=go;var Eo="bitAnd",Ao=te(Eo,["typed","matrix","equalScalar"],(e=>{var{typed:r,matrix:t,equalScalar:n}=e,i=Ba({typed:r,equalScalar:n}),a=_a({typed:r,equalScalar:n}),o=oa({typed:r,equalScalar:n}),s=Ta({typed:r,matrix:t});return r(Eo,{"number, number":vo,"BigNumber, BigNumber":so},s({SS:a,DS:i,Ss:o}))})),Co="bitNot",So=te(Co,["typed"],(e=>{var{typed:r}=e;return r(Co,{number:yo,BigNumber:uo,"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))})})),Mo="bitOr",Fo=te(Mo,["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:r,matrix:t,equalScalar:n,DenseMatrix:i}=e,a=Ca({typed:r}),o=Sa({typed:r,equalScalar:n}),s=Ma({typed:r,DenseMatrix:i}),u=Ta({typed:r,matrix:t});return r(Mo,{"number, number":xo,"BigNumber, BigNumber":co},u({SS:o,DS:a,Ss:s}))})),To=te("matAlgo07xSSf",["typed","DenseMatrix"],(e=>{var{typed:r,DenseMatrix:t}=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 ke(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,g=a;"string"==typeof s&&s===c&&(l=s,d=r.convert(0,l),g=r.find(a,[l,l]));var v=[];for(f=0;f{var{typed:r,matrix:t,DenseMatrix:n}=e,i=Pa({typed:r}),a=To({typed:r,DenseMatrix:n}),o=sa({typed:r,DenseMatrix:n}),s=Ta({typed:r,matrix:t});return r(Oo,{"number, number":bo,"BigNumber, BigNumber":po},s({SS:a,DS:i,Ss:o}))})),_o=te("arg",["typed"],(e=>{var{typed:r}=e;return r("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":r.referToSelf((e=>r=>Bn(r,e)))})})),zo="conj",qo=te(zo,["typed"],(e=>{var{typed:r}=e;return r(zo,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))})})),ko=te("im",["typed"],(e=>{var{typed:r}=e;return r("im",{number:()=>0,"BigNumber | Fraction":e=>e.mul(0),Complex:e=>e.im,"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))})})),Io=te("re",["typed"],(e=>{var{typed:r}=e;return r("re",{"number | BigNumber | Fraction":e=>e,Complex:e=>e.re,"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))})})),Ro="number, number";function Po(e){return!e}function jo(e,r){return!(!e&&!r)}function Uo(e,r){return!!e!=!!r}function Lo(e,r){return!(!e||!r)}Po.signature="number",jo.signature=Ro,Uo.signature=Ro,Lo.signature=Ro;var Ho=te("not",["typed"],(e=>{var{typed:r}=e;return r("not",{"null | undefined":()=>!0,number:Po,Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},Unit:r.referToSelf((e=>t=>r.find(e,t.valueType())(t.value))),"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))})})),$o=te("or",["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:r,matrix:t,equalScalar:n,DenseMatrix:i}=e,a=Pa({typed:r}),o=ja({typed:r,equalScalar:n}),s=sa({typed:r,DenseMatrix:i}),u=Ta({typed:r,matrix:t});return r("or",{"number, number":jo,"Complex, Complex":function(e,r){return 0!==e.re||0!==e.im||0!==r.re||0!==r.im},"BigNumber, BigNumber":function(e,r){return!e.isZero()&&!e.isNaN()||!r.isZero()&&!r.isNaN()},"Unit, Unit":r.referToSelf((e=>(r,t)=>e(r.value||0,t.value||0)))},u({SS:o,DS:a,Ss:s}))})),Go=te("xor",["typed","matrix","DenseMatrix"],(e=>{var{typed:r,matrix:t,DenseMatrix:n}=e,i=Pa({typed:r}),a=To({typed:r,DenseMatrix:n}),o=sa({typed:r,DenseMatrix:n}),s=Ta({typed:r,matrix:t});return r("xor",{"number, number":Uo,"Complex, Complex":function(e,r){return(0!==e.re||0!==e.im)!=(0!==r.re||0!==r.im)},"BigNumber, BigNumber":function(e,r){return(!e.isZero()&&!e.isNaN())!=(!r.isZero()&&!r.isNaN())},"Unit, Unit":r.referToSelf((e=>(r,t)=>e(r.value||0,t.value||0)))},s({SS:a,DS:i,Ss:o}))})),Zo="concat",Vo=te(Zo,["typed","matrix","isInteger"],(e=>{var{typed:r,matrix:t,isInteger:n}=e;return r(Zo,{"...Array | Matrix | number | BigNumber":function(e){var r,o,s=e.length,u=-1,c=!1,l=[];for(r=0;r0&&u>o)throw new Ie(u,o+1)}else{var m=G(p).valueOf(),h=Re(m);if(l[r]=m,o=u,u=h.length-1,r>0&&u!==o)throw new ke(o+1,u+1)}}if(0===l.length)throw new SyntaxError("At least one matrix expected");for(var d=l.shift();l.length;)d=Wo(d,l.shift(),u,0);return c?t(d):d},"...string":function(e){return e.join("")}})}));function Wo(e,r,t,n){if(n{var{typed:r,Index:t,matrix:n,range:i}=e;return r(Jo,{"Matrix, number":a,"Array, number":function(e,r){return a(n(G(e)),r).valueOf()}});function a(e,r){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");Ue(r,e.size()[1]);var n=i(0,e.size()[0]),a=new t(n,r);return e.subset(a)}})),Xo="count",Qo=te(Xo,["typed","size","prod"],(e=>{var{typed:r,size:t,prod:n}=e;return r(Xo,{string:function(e){return e.length},"Matrix | Array":function(e){return n(t(e))}})})),Ko="cross",es=te(Ko,["typed","matrix","subtract","multiply"],(e=>{var{typed:r,matrix:t,subtract:n,multiply:i}=e;return r(Ko,{"Matrix, Matrix":function(e,r){return t(a(e.toArray(),r.toArray()))},"Matrix, Array":function(e,r){return t(a(e.toArray(),r))},"Array, Matrix":function(e,r){return t(a(e,r.toArray()))},"Array, Array":a});function a(e,r){var t=Math.max(Re(e).length,Re(r).length);e=Ve(e),r=Ve(r);var a=Re(e),o=Re(r);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],r[2]),i(e[2],r[1])),n(i(e[2],r[0]),i(e[0],r[2])),n(i(e[0],r[1]),i(e[1],r[0]))];return t>1?[s]:s}})),rs="diag",ts=te(rs,["typed","matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:r,matrix:t,DenseMatrix:n,SparseMatrix:i}=e;return r(rs,{Array:function(e){return a(e,0,Re(e),null)},"Array, number":function(e,r){return a(e,r,Re(e),null)},"Array, BigNumber":function(e,r){return a(e,r.toNumber(),Re(e),null)},"Array, string":function(e,r){return a(e,0,Re(e),r)},"Array, number, string":function(e,r,t){return a(e,r,Re(e),t)},"Array, BigNumber, string":function(e,r,t){return a(e,r.toNumber(),Re(e),t)},Matrix:function(e){return a(e,0,e.size(),e.storage())},"Matrix, number":function(e,r){return a(e,r,e.size(),e.storage())},"Matrix, BigNumber":function(e,r){return a(e,r.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,r){return a(e,0,e.size(),r)},"Matrix, number, string":function(e,r,t){return a(e,r,e.size(),t)},"Matrix, BigNumber, string":function(e,r,t){return a(e,r.toNumber(),e.size(),t)}});function a(e,r,a,o){if(!ae(r))throw new TypeError("Second parameter in function diag must be an integer");var s=r>0?r:0,u=r<0?-r:0;switch(a.length){case 1:return function(e,r,t,a,o,s){var u=[a+o,a+s];if(t&&"sparse"!==t&&"dense"!==t)throw new TypeError("Unknown matrix type ".concat(t,'"'));var c="sparse"===t?i.diagonal(u,e,r):n.diagonal(u,e,r);return null!==t?c:c.valueOf()}(e,r,o,a[0],u,s);case 2:return function(e,r,n,i,a,o){if(f(e)){var s=e.diagonal(r);return null!==n?n!==s.storage()?t(s,n):s:s.valueOf()}for(var u=Math.min(i[0]-a,i[1]-o),c=[],l=0;l{var{typed:r}=e;return r("filter",{"Array, function":is,"Matrix, function":function(e,r){return e.create(is(e.toArray(),r))},"Array, RegExp":rr,"Matrix, RegExp":function(e,r){return e.create(rr(e.toArray(),r))}})}));function is(e,r){var t=An(r);return er(e,(function(e,n,i){return 1===t?r(e):2===t?r(e,[n]):r(e,[n],i)}))}var as="flatten",os=te(as,["typed","matrix"],(e=>{var{typed:r,matrix:t}=e;return r(as,{Array:function(e){return Xe(e)},Matrix:function(e){var r=Xe(e.toArray());return t(r)}})})),ss="forEach",us=te(ss,["typed"],(e=>{var{typed:r}=e;return r(ss,{"Array, function":cs,"Matrix, function":function(e,r){return e.forEach(r)}})}));function cs(e,r){var t=An(r);!function n(i,a){Array.isArray(i)?Ke(i,(function(e,r){n(e,a.concat(r))})):1===t?r(i):2===t?r(i,a):r(i,a,e)}(e,[])}var ls="getMatrixDataType",fs=te(ls,["typed"],(e=>{var{typed:r}=e;return r(ls,{Array:function(e){return ar(e,$)},Matrix:function(e){return e.getDataType()}})})),ps="identity",ms=te(ps,["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],(e=>{var{typed:r,config:t,matrix:n,BigNumber:i,DenseMatrix:o,SparseMatrix:s}=e;return r(ps,{"":function(){return"Matrix"===t.matrix?n([]):[]},string:function(e){return n(e)},"number | BigNumber":function(e){return c(e,e,"Matrix"===t.matrix?"dense":void 0)},"number | BigNumber, string":function(e,r){return c(e,e,r)},"number | BigNumber, number | BigNumber":function(e,r){return c(e,r,"Matrix"===t.matrix?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(e,r,t){return c(e,r,t)},Array:function(e){return u(e)},"Array, string":function(e,r){return u(e,r)},Matrix:function(e){return u(e.valueOf(),e.storage())},"Matrix, string":function(e,r){return u(e.valueOf(),r)}});function u(e,r){switch(e.length){case 0:return r?n(r):[];case 1:return c(e[0],e[0],r);case 2:return c(e[0],e[1],r);default:throw new Error("Vector containing two values expected")}}function c(e,r,t){var n=a(e)||a(r)?i:null;if(a(e)&&(e=e.toNumber()),a(r)&&(r=r.toNumber()),!ae(e)||e<1)throw new Error("Parameters in function identity must be positive integers");if(!ae(r)||r<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,r];if(t){if("sparse"===t)return s.diagonal(l,u,0,c);if("dense"===t)return o.diagonal(l,u,0,c);throw new TypeError('Unknown matrix type "'.concat(t,'"'))}for(var f=Le([],l,c),p=e{var{typed:r,matrix:t,multiplyScalar:n}=e;return r(hs,{"Matrix, Matrix":function(e,r){return t(i(e.toArray(),r.toArray()))},"Matrix, Array":function(e,r){return t(i(e.toArray(),r))},"Array, Matrix":function(e,r){return t(i(e,r.toArray()))},"Array, Array":i});function i(e,r){if(1===Re(e).length&&(e=[e]),1===Re(r).length&&(r=[r]),Re(e).length>2||Re(r).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(e.length)+", y = "+JSON.stringify(r.length)+")");var t=[],i=[];return e.map((function(e){return r.map((function(r){return i=[],t.push(i),e.map((function(e){return r.map((function(r){return i.push(n(e,r))}))}))}))}))&&t}})),gs=te("map",["typed"],(e=>{var{typed:r}=e;return r("map",{"Array, function":vs,"Matrix, function":function(e,r){return e.map(r)}})}));function vs(e,r){var t=An(r);return function n(i,a){if(Array.isArray(i))return i.map((function(e,r){return n(e,a.concat(r))}));try{return 1===t?r(i):2===t?r(i,a):r(i,a,e)}catch(r){if(r instanceof TypeError&&"data"in r&&"wrongType"===r.data.category){var o="map attempted to call '".concat(r.data.fn,"(").concat(i),s=JSON.stringify(a);throw 2===t?o+=","+s:1!==t&&(o+=",".concat(s,",").concat(e)),o+=")' but argument ".concat(r.data.index+1," of type "),o+="".concat(r.data.actual," does not match expected type "),o+=r.data.expected.join(" or "),new TypeError(o)}throw r}}(e,[])}var ys="diff",xs=te(ys,["typed","matrix","subtract","number"],(e=>{var{typed:r,matrix:t,subtract:n,number:i}=e;return r(ys,{"Array | Matrix":function(e){return f(e)?t(o(e.toArray())):o(e)},"Array | Matrix, number":function(e,r){if(!ae(r))throw new RangeError("Dimension must be a whole number");return f(e)?t(a(e.toArray(),r)):a(e,r)},"Array, BigNumber":r.referTo("Array,number",(e=>(r,t)=>e(r,i(t)))),"Matrix, BigNumber":r.referTo("Matrix,number",(e=>(r,t)=>e(r,i(t))))});function a(e,r){if(f(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError("Array/Matrix does not have that many dimensions");if(r>0){var t=[];return e.forEach((e=>{t.push(a(e,r-1))})),t}if(0===r)return o(e);throw RangeError("Cannot have negative dimension")}function o(e){for(var r=[],t=e.length,n=1;n{var{typed:r,config:t,matrix:n,BigNumber:i}=e;return r("ones",{"":function(){return"Array"===t.matrix?o([]):o([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var r=e.pop();return o(e,r)}return"Array"===t.matrix?o(e):o(e,"default")},Array:o,Matrix:function(e){var r=e.storage();return o(e.valueOf(),r)},"Array | Matrix, string":function(e,r){return o(e.valueOf(),r)}});function o(e,r){var t=function(e){var r=!1;return e.forEach((function(e,t,n){a(e)&&(r=!0,n[t]=e.toNumber())})),r}(e),o=t?new i(1):1;if(function(e){e.forEach((function(e){if("number"!=typeof e||!ae(e)||e<0)throw new Error("Parameters in function ones must be positive integers")}))}(e),r){var s=n(r);return e.length>0?s.resize(e,o):s}var u=[];return e.length>0?Le(u,e,o):u}}));function ws(){throw new Error('No "bignumber" implementation available')}function Ns(){throw new Error('No "fraction" implementation available')}function Ds(){throw new Error('No "matrix" implementation available')}var Es="range",As=te(Es,["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:r,config:t,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u}=e;return r(Es,{string:l,"string, boolean":l,"number, number":function(e,r){return c(f(e,r,1))},"number, number, number":function(e,r,t){return c(f(e,r,t))},"number, number, boolean":function(e,r,t){return c(t?p(e,r,1):f(e,r,1))},"number, number, number, boolean":function(e,r,t,n){return c(n?p(e,r,t):f(e,r,t))},"BigNumber, BigNumber":function(e,r){return c(m(e,r,new(0,e.constructor)(1)))},"BigNumber, BigNumber, BigNumber":function(e,r,t){return c(m(e,r,t))},"BigNumber, BigNumber, boolean":function(e,r,t){var n=e.constructor;return c(t?h(e,r,new n(1)):m(e,r,new n(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(e,r,t,n){return c(n?h(e,r,t):m(e,r,t))}});function c(e){return"Matrix"===t.matrix?n?n(e):Ds():e}function l(e,r){var n=function(e){var r=e.split(":").map((function(e){return Number(e)}));if(r.some((function(e){return isNaN(e)})))return null;switch(r.length){case 2:return{start:r[0],end:r[1],step:1};case 3:return{start:r[0],end:r[2],step:r[1]};default:return null}}(e);if(!n)throw new SyntaxError('String "'+e+'" is no valid range');return"BigNumber"===t.number?(void 0===i&&ws(),c((r?h:m)(i(n.start),i(n.end),i(n.step)))):c((r?p:f)(n.start,n.end,n.step))}function f(e,r,t){var n=[],i=e;if(t>0)for(;a(i,r);)n.push(i),i+=t;else if(t<0)for(;s(i,r);)n.push(i),i+=t;return n}function p(e,r,t){var n=[],i=e;if(t>0)for(;o(i,r);)n.push(i),i+=t;else if(t<0)for(;u(i,r);)n.push(i),i+=t;return n}function m(e,r,t){var n=i(0),o=[],u=e;if(t.gt(n))for(;a(u,r);)o.push(u),u=u.plus(t);else if(t.lt(n))for(;s(u,r);)o.push(u),u=u.plus(t);return o}function h(e,r,t){var n=i(0),a=[],s=e;if(t.gt(n))for(;o(s,r);)a.push(s),s=s.plus(t);else if(t.lt(n))for(;u(s,r);)a.push(s),s=s.plus(t);return a}})),Cs="reshape",Ss=te(Cs,["typed","isInteger","matrix"],(e=>{var{typed:r,isInteger:t}=e;return r(Cs,{"Matrix, Array":function(e,r){return e.reshape(r)},"Array, Array":function(e,r){return r.forEach((function(e){if(!t(e))throw new TypeError("Invalid size for dimension: "+e)})),$e(e,r)}})})),Ms=te("resize",["config","matrix"],(e=>{var{config:r,matrix:t}=e;return function(e,i,o){if(2!==arguments.length&&3!==arguments.length)throw new sr("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"!==r.matrix;if(0===i.length){for(;Array.isArray(e);)e=e[0];return G(e)}Array.isArray(e)||(e=[e]);var u=Le(e=G(e),i,o);return s?t(u):u};function n(e,r,t){if(void 0!==t){if("string"!=typeof t||1!==t.length)throw new TypeError("Single character expected as defaultValue")}else t=" ";if(1!==r.length)throw new ke(r.length,1);var n=r[0];if("number"!=typeof n||!ae(n))throw new TypeError("Invalid size, must contain positive integers (size: "+Oe(r)+")");if(e.length>n)return e.substring(0,n);if(e.length{var{typed:r,multiply:t,rotationMatrix:n}=e;return r(Fs,{"Array , number | BigNumber | Complex | Unit":function(e,r){return i(e,2),t(n(r),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,r){return i(e,2),t(n(r),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,r,a){return i(e,3),t(n(r,a),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,r,a){return i(e,3),t(n(r,a),e)}});function i(e,r){var t=Array.isArray(e)?Re(e):e.size();if(t.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(r));if(2===t.length&&1!==t[1])throw new RangeError("Vector must be of dimensions 1x".concat(r));if(t[0]!==r)throw new RangeError("Vector must be of dimensions 1x".concat(r))}})),Os="rotationMatrix",Bs=te(Os,["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],(e=>{var{typed:r,config:t,multiplyScalar:n,addScalar:i,unaryMinus:o,norm:s,BigNumber:u,matrix:c,DenseMatrix:l,SparseMatrix:f,cos:p,sin:m}=e;return r(Os,{"":function(){return"Matrix"===t.matrix?c([]):[]},string:function(e){return c(e)},"number | BigNumber | Complex | Unit":function(e){return h(e,"Matrix"===t.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(e,r){return h(e,r)},"number | BigNumber | Complex | Unit, Array":function(e,r){var t=c(r);return d(t),y(e,t,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,r){d(r);var n=r.storage()||("Matrix"===t.matrix?"dense":void 0);return y(e,r,n)},"number | BigNumber | Complex | Unit, Array, string":function(e,r,t){var n=c(r);return d(n),y(e,n,t)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,r,t){return d(r),y(e,r,t)}});function h(e,r){var t=a(e)?new u(-1):-1,i=p(e),o=m(e);return v([[i,n(t,o)],[o,i]],r)}function d(e){var r=e.size();if(r.length<1||3!==r[0])throw new RangeError("Vector must be of dimensions 1x3")}function g(e){return e.reduce(((e,r)=>n(e,r)))}function v(e,r){if(r){if("sparse"===r)return new f(e);if("dense"===r)return new l(e);throw new TypeError('Unknown matrix type "'.concat(r,'"'))}return e}function y(e,r,t){var n=s(r);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(r.get([0])/n):r.get([0])/n,d=c?new c(r.get([1])/n):r.get([1])/n,y=c?new c(r.get([2])/n):r.get([2])/n,x=p(e),b=i(l,o(x)),w=m(e);return v([[i(x,g([h,h,b])),i(g([h,d,b]),g([f,y,w])),i(g([h,y,b]),g([d,w]))],[i(g([h,d,b]),g([y,w])),i(x,g([d,d,b])),i(g([d,y,b]),g([f,h,w]))],[i(g([h,y,b]),g([f,d,w])),i(g([d,y,b]),g([h,w])),i(x,g([y,y,b]))]],t)}})),_s=te("row",["typed","Index","matrix","range"],(e=>{var{typed:r,Index:t,matrix:n,range:i}=e;return r("row",{"Matrix, number":a,"Array, number":function(e,r){return a(n(G(e)),r).valueOf()}});function a(e,r){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");Ue(r,e.size()[0]);var n=i(0,e.size()[1]),a=new t(r,n);return e.subset(a)}})),zs="size",qs=te(zs,["typed","config","?matrix"],(e=>{var{typed:r,config:t,matrix:n}=e;return r(zs,{Matrix:function(e){return e.create(e.size())},Array:Re,string:function(e){return"Array"===t.matrix?[e.length]:n([e.length])},"number | Complex | BigNumber | Unit | boolean | null":function(e){return"Array"===t.matrix?[]:n?n([]):Ds()}})})),ks="squeeze",Is=te(ks,["typed","matrix"],(e=>{var{typed:r,matrix:t}=e;return r(ks,{Array:function(e){return Ve(G(e))},Matrix:function(e){var r=Ve(e.toArray());return Array.isArray(r)?t(r):r},any:function(e){return G(e)}})})),Rs="subset",Ps=te(Rs,["typed","matrix"],(e=>{var{typed:r,matrix:t}=e;return r(Rs,{"Array, Index":function(e,r){var n=t(e).subset(r);return r.isScalar()?n:n.valueOf()},"Matrix, Index":function(e,r){return e.subset(r)},"Object, Index":Ls,"string, Index":js,"Array, Index, any":function(e,r,n){return t(G(e)).subset(r,n,void 0).valueOf()},"Array, Index, any, any":function(e,r,n,i){return t(G(e)).subset(r,n,i).valueOf()},"Matrix, Index, any":function(e,r,t){return e.clone().subset(r,t)},"Matrix, Index, any, any":function(e,r,t,n){return e.clone().subset(r,t,n)},"string, Index, string":Us,"string, Index, string, string":Us,"Object, Index, any":Hs})}));function js(e,r){if(!g(r))throw new TypeError("Index expected");if(1!==r.size().length)throw new ke(r.size().length,1);var t=e.length;Ue(r.min()[0],t),Ue(r.max()[0],t);var n=r.dimension(0),i="";return n.forEach((function(r){i+=e.charAt(r)})),i}function Us(e,r,t,n){if(!r||!0!==r.isIndex)throw new TypeError("Index expected");if(1!==r.size().length)throw new ke(r.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=r.dimension(0);if(i.size()[0]!==t.length)throw new ke(i.size()[0],t.length);var a=e.length;Ue(r.min()[0]),Ue(r.max()[0]);for(var o=[],s=0;sa)for(var u=a-1,c=o.length;u{var{typed:r,matrix:t}=e;return r($s,{Array:e=>n(t(e)).valueOf(),Matrix:n,any:G});function n(e){var r,t=e.size();switch(t.length){case 1:r=e.clone();break;case 2:var n=t[0],i=t[1];if(0===i)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+Oe(t)+")");switch(e.storage()){case"dense":r=function(e,r,t){for(var n,i=e._data,a=[],o=0;o{var{typed:r,transpose:t,conj:n}=e;return r(Zs,{any:function(e){return n(t(e))}})})),Ws="zeros",Js=te(Ws,["typed","config","matrix","BigNumber"],(e=>{var{typed:r,config:t,matrix:n,BigNumber:i}=e;return r(Ws,{"":function(){return"Array"===t.matrix?o([]):o([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var r=e.pop();return o(e,r)}return"Array"===t.matrix?o(e):o(e,"default")},Array:o,Matrix:function(e){var r=e.storage();return o(e.valueOf(),r)},"Array | Matrix, string":function(e,r){return o(e.valueOf(),r)}});function o(e,r){var t=function(e){var r=!1;return e.forEach((function(e,t,n){a(e)&&(r=!0,n[t]=e.toNumber())})),r}(e),o=t?new i(0):0;if(function(e){e.forEach((function(e){if("number"!=typeof e||!ae(e)||e<0)throw new Error("Parameters in function zeros must be positive integers")}))}(e),r){var s=n(r);return e.length>0?s.resize(e,o):s}var u=[];return e.length>0?Le(u,e,o):u}})),Ys=te("fft",["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i"],(e=>{var{typed:r,matrix:t,addScalar:n,multiplyScalar:i,divideScalar:a,exp:o,tau:s,i:u}=e;return r("fft",{Array:c,Matrix:function(e){return e.create(c(e.toArray()))}});function c(e){var r=Re(e);return 1===r.length?f(e,r[0]):l(e.map((e=>c(e,r.slice(1)))),0)}function l(e,r){var t=Re(e);if(0!==r)return new Array(t[0]).fill(0).map(((t,n)=>l(e[n],r-1)));if(1===t.length)return f(e);function n(e){var r=Re(e);return new Array(r[1]).fill(0).map(((t,n)=>new Array(r[0]).fill(0).map(((r,t)=>e[t][n]))))}return n(l(n(e),1))}function f(e){var r=e.length;if(1===r)return[e[0]];if(r%2==0){for(var t=[...f(e.filter(((e,r)=>r%2==0))),...f(e.filter(((e,r)=>r%2==1)))],c=0;c{var{typed:r,fft:t,dotDivide:n,conj:i}=e;return r(Xs,{"Array | Matrix":function(e){var r=f(e)?e.size():Re(e);return n(i(t(i(e))),r.reduce(((e,r)=>e*r),1))}})})),Ks=te("erf",["typed"],(e=>{var{typed:r}=e;return r("name",{number:function(e){var r=Math.abs(e);return r>=iu?oe(e):r<=eu?oe(e)*function(e){var r,t=e*e,n=tu[0][4]*t,i=t;for(r=0;r<3;r+=1)n=(n+tu[0][r])*t,i=(i+nu[0][r])*t;return e*(n+tu[0][3])/(i+nu[0][3])}(r):r<=4?oe(e)*(1-function(e){var r,t=tu[1][8]*e,n=e;for(r=0;r<7;r+=1)t=(t+tu[1][r])*e,n=(n+nu[1][r])*e;var i=(t+tu[1][7])/(n+nu[1][7]),a=parseInt(16*e)/16,o=(e-a)*(e+a);return Math.exp(-a*a)*Math.exp(-o)*i}(r)):oe(e)*(1-function(e){var r,t=1/(e*e),n=tu[2][5]*t,i=t;for(r=0;r<4;r+=1)n=(n+tu[2][r])*t,i=(i+nu[2][r])*t;var a=t*(n+tu[2][4])/(i+nu[2][4]);a=(ru-a)/e,t=parseInt(16*e)/16;var o=(e-t)*(e+t);return Math.exp(-t*t)*Math.exp(-o)*a}(r))},"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))})})),eu=.46875,ru=.5641895835477563,tu=[[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]],nu=[[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]],iu=Math.pow(2,53),au="mode",ou=te(au,["typed","isNaN","isNumeric"],(e=>{var{typed:r,isNaN:t,isNumeric:n}=e;return r(au,{"Array | Matrix":i,"...":function(e){return i(e)}});function i(e){if(0===(e=Xe(e.valueOf())).length)throw new Error("Cannot calculate mode of an empty array");for(var r={},i=[],a=0,o=0;oa&&(a=r[s],i=[s])}return i}}));function su(e,r,t){var n;return-1!==String(e).indexOf("Unexpected type")?(n=arguments.length>2?" (type: "+$(t)+", value: "+JSON.stringify(t)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+r+", unexpected type of argument"+n)):-1!==String(e).indexOf("complex numbers")?(n=arguments.length>2?" (type: "+$(t)+", value: "+JSON.stringify(t)+")":"",new TypeError("Cannot calculate "+r+", no ordering relation is defined for complex numbers"+n)):e}var uu="prod",cu=te(uu,["typed","config","multiplyScalar","numeric"],(e=>{var{typed:r,config:t,multiplyScalar:n,numeric:i}=e;return r(uu,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,r){throw new Error("prod(A, dim) is not yet supported")},"...":function(e){return a(e)}});function a(e){var r;if(On(e,(function(e){try{r=void 0===r?e:n(r,e)}catch(r){throw su(r,"prod",e)}})),"string"==typeof r&&(r=i(r,t.number)),void 0===r)throw new Error("Cannot calculate prod of an empty array");return r}})),lu="format",fu=te(lu,["typed"],(e=>{var{typed:r}=e;return r(lu,{any:Oe,"any, Object | function | number":Oe})})),pu=te("bin",["typed","format"],(e=>{var{typed:r,format:t}=e;return r("bin",{"number | BigNumber":function(e){return t(e,{notation:"bin"})},"number | BigNumber, number":function(e,r){return t(e,{notation:"bin",wordSize:r})}})})),mu=te("oct",["typed","format"],(e=>{var{typed:r,format:t}=e;return r("oct",{"number | BigNumber":function(e){return t(e,{notation:"oct"})},"number | BigNumber, number":function(e,r){return t(e,{notation:"oct",wordSize:r})}})})),hu=te("hex",["typed","format"],(e=>{var{typed:r,format:t}=e;return r("hex",{"number | BigNumber":function(e){return t(e,{notation:"hex"})},"number | BigNumber, number":function(e,r){return t(e,{notation:"hex",wordSize:r})}})})),du="print",gu=te(du,["typed"],(e=>{var{typed:r}=e;return r(du,{"string, Object | Array":vu,"string, Object | Array, number | Object":vu})}));function vu(e,r,t){return e.replace(/\$([\w.]+)/g,(function(e,n){for(var i=n.split("."),a=r[i.shift()];i.length&&void 0!==a;){var o=i.shift();a=o?a[o]:a+"."}return void 0!==a?c(a)?a:Oe(a,t):e}))}var yu=te("to",["typed","matrix"],(e=>{var{typed:r,matrix:t}=e;return r("to",{"Unit, Unit | string":(e,r)=>e.to(r)},Ta({typed:r,matrix:t})({Ds:!0}))})),xu="isPrime",bu=te(xu,["typed"],(e=>{var{typed:r}=e;return r(xu,{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 r=5;r*r<=e;r+=6)if(e%r==0||e%(r+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 r=e.toNumber(),t=5;t*t<=r;t+=6)if(r%t==0||r%(t+2)==0)return!1;return!0}function n(e,r,t){for(var n=1;!r.eq(0);)r.mod(2).eq(0)?(r=r.div(2),e=e.mul(e).mod(t)):(r=r.sub(1),n=e.mul(n).mod(t));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((r=>rr=>Bn(r,e)))})})),wu=te("numeric",["number","?bignumber","?fraction"],(e=>{var{number:r,bignumber:t,fraction:n}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},a={number:e=>r(e),BigNumber:t?e=>t(e):ws,Fraction:n?e=>n(e):Ns};return function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"number",t=arguments.length>2?arguments[2]:void 0;if(void 0!==t)throw new SyntaxError("numeric() takes one or two arguments");var n=$(e);if(!(n in i))throw new TypeError("Cannot convert "+e+' of type "'+n+'"; valid input types are '+Object.keys(i).join(", "));if(!(r in a))throw new TypeError("Cannot convert "+e+' to type "'+r+'"; valid output types are '+Object.keys(a).join(", "));return r===n?e:a[r](e)}})),Nu="divideScalar",Du=te(Nu,["typed","numeric"],(e=>{var{typed:r,numeric:t}=e;return r(Nu,{"number, number":function(e,r){return e/r},"Complex, Complex":function(e,r){return e.div(r)},"BigNumber, BigNumber":function(e,r){return e.div(r)},"Fraction, Fraction":function(e,r){return e.div(r)},"Unit, number | Complex | Fraction | BigNumber | Unit":(e,r)=>e.divide(r),"number | Fraction | Complex | BigNumber, Unit":(e,r)=>r.divideInto(e)})})),Eu=te("pow",["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],(e=>{var{typed:r,config:t,identity:n,multiply:i,matrix:a,inv:o,number:s,fraction:u,Complex:c}=e;return r("pow",{"number, number":l,"Complex, Complex":function(e,r){return e.pow(r)},"BigNumber, BigNumber":function(e,r){return r.isInteger()||e>=0||t.predictable?e.pow(r):new c(e.toNumber(),0).pow(r.toNumber(),0)},"Fraction, Fraction":function(e,r){var n=e.pow(r);if(null!=n)return n;if(t.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return l(e.valueOf(),r.valueOf())},"Array, number":f,"Array, BigNumber":function(e,r){return f(e,r.toNumber())},"Matrix, number":p,"Matrix, BigNumber":function(e,r){return p(e,r.toNumber())},"Unit, number | BigNumber":function(e,r){return e.pow(r)}});function l(e,r){if(t.predictable&&!ae(r)&&e<0)try{var n=u(r),i=s(n);if((r===i||Math.abs((r-i)/r)<1e-14)&&n.d%2==1)return(n.n%2==0?1:-1)*Math.pow(-e,r)}catch(e){}return t.predictable&&(e<-1&&r===1/0||e>-1&&e<0&&r===-1/0)?NaN:ae(r)||e>=0||t.predictable?Zi(e,r):e*e<1&&r===1/0||e*e>1&&r===-1/0?0:new c(e,0).pow(r,0)}function f(e,r){if(!ae(r))throw new TypeError("For A^b, b must be an integer (value is "+r+")");var t=Re(e);if(2!==t.length)throw new Error("For A^b, A must be 2 dimensional (A has "+t.length+" dimensions)");if(t[0]!==t[1])throw new Error("For A^b, A must be square (size is "+t[0]+"x"+t[1]+")");if(r<0)try{return f(o(e),-r)}catch(e){if("Cannot calculate inverse, determinant is zero"===e.message)throw new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+r+")");throw e}for(var a=n(t[0]).valueOf(),s=e;r>=1;)1==(1&r)&&(a=i(s,a)),r>>=1,s=i(s,s);return a}function p(e,r){return a(f(e.valueOf(),r))}})),Au="Number of decimals in function round must be an integer",Cu="round",Su=te(Cu,["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],(e=>{var{typed:r,matrix:t,equalScalar:n,zeros:i,BigNumber:a,DenseMatrix:o}=e,s=oa({typed:r,equalScalar:n}),u=sa({typed:r,DenseMatrix:o}),c=ua({typed:r});return r(Cu,{number:Vi,"number, number":Vi,"number, BigNumber":function(e,r){if(!r.isInteger())throw new TypeError(Au);return new a(e).toDecimalPlaces(r.toNumber())},Complex:function(e){return e.round()},"Complex, number":function(e,r){if(r%1)throw new TypeError(Au);return e.round(r)},"Complex, BigNumber":function(e,r){if(!r.isInteger())throw new TypeError(Au);var t=r.toNumber();return e.round(t)},BigNumber:function(e){return e.toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,r){if(!r.isInteger())throw new TypeError(Au);return e.toDecimalPlaces(r.toNumber())},Fraction:function(e){return e.round()},"Fraction, number":function(e,r){if(r%1)throw new TypeError(Au);return e.round(r)},"Fraction, BigNumber":function(e,r){if(!r.isInteger())throw new TypeError(Au);return e.round(r.toNumber())},"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e,!0))),"SparseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>s(r,t,e,!1))),"DenseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>c(r,t,e,!1))),"Array, number | BigNumber":r.referToSelf((e=>(r,n)=>c(t(r),n,e,!1).valueOf())),"number | Complex | BigNumber | Fraction, SparseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):u(t,r,e,!0))),"number | Complex | BigNumber | Fraction, DenseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):c(t,r,e,!0))),"number | Complex | BigNumber | Fraction, Array":r.referToSelf((e=>(r,n)=>c(t(n),r,e,!0).valueOf()))})})),Mu=te("log",["config","typed","divideScalar","Complex"],(e=>{var{typed:r,config:t,divideScalar:n,Complex:i}=e;return r("log",{number:function(e){return e>=0||t.predictable?function(e,r){return r?Math.log(e)/Math.log(r):Math.log(e)}(e):new i(e,0).log()},Complex:function(e){return e.log()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.ln():new i(e.toNumber(),0).log()},"any, any":r.referToSelf((e=>(r,t)=>n(e(r),e(t))))})})),Fu="log1p",Tu=te(Fu,["typed","config","divideScalar","log","Complex"],(e=>{var{typed:r,config:t,divideScalar:n,log:i,Complex:a}=e;return r(Fu,{number:function(e){return e>=-1||t.predictable?ce(e):o(new a(e,0))},Complex:o,BigNumber:function(e){var r=e.plus(1);return!r.isNegative()||t.predictable?r.ln():o(new a(e.toNumber(),0))},"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e))),"any, any":r.referToSelf((e=>(r,t)=>n(e(r),i(t))))});function o(e){var r=e.re+1;return new a(Math.log(Math.sqrt(r*r+e.im*e.im)),Math.atan2(e.im,r))}})),Ou="nthRoots",Bu=te(Ou,["config","typed","divideScalar","Complex"],(e=>{var{typed:r,config:t,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,r){if(r<0)throw new Error("Root must be greater than zero");if(0===r)throw new Error("Root must be non-zero");if(r%1!=0)throw new Error("Root must be an integer");if(0===e||0===e.abs())return[new i(0,0)];var t,n="number"==typeof e;(n||0===e.re||0===e.im)&&(t=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/r),l=0;l{var{typed:r,equalScalar:t,matrix:n,pow:i,DenseMatrix:a}=e,o=Pa({typed:r}),s=To({typed:r,DenseMatrix:a}),u=oa({typed:r,equalScalar:t}),c=sa({typed:r,DenseMatrix:a}),l=Ta({typed:r,matrix:n}),f={};for(var p in i.signatures)Object.prototype.hasOwnProperty.call(i.signatures,p)&&(p.includes("Matrix")||p.includes("Array")||(f[p]=i.signatures[p]));var m=r(f);return r(_u,l({elop:m,SS:s,DS:o,Ss:u,sS:c}))})),qu="dotDivide",ku=te(qu,["typed","matrix","equalScalar","divideScalar","DenseMatrix"],(e=>{var{typed:r,matrix:t,equalScalar:n,divideScalar:i,DenseMatrix:a}=e,o=Ba({typed:r,equalScalar:n}),s=Pa({typed:r}),u=To({typed:r,DenseMatrix:a}),c=oa({typed:r,equalScalar:n}),l=sa({typed:r,DenseMatrix:a}),f=Ta({typed:r,matrix:t});return r(qu,f({elop:i,SS:u,DS:s,SD:o,Ss:c,sS:l}))}));function Iu(e){var{DenseMatrix:r}=e;return function(e,t,n){var i=e.size();if(2!==i.length)throw new RangeError("Matrix must be two dimensional (size: "+Oe(i)+")");var a=i[0];if(a!==i[1])throw new RangeError("Matrix must be square (size: "+Oe(i)+")");var o=[];if(f(t)){var s=t.size(),u=t._data;if(1===s.length){if(s[0]!==a)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var c=0;c{var{typed:r,matrix:t,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=Iu({DenseMatrix:s});return r(Ru,{"SparseMatrix, Array | Matrix":function(e,r){return function(e,r){for(var t=(r=u(e,r,!0))._data,c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=[],d=0;dd&&(y.push(f[N]),x.push(D))}if(o(v,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var E=n(g,v),A=0,C=x.length;A{var{typed:r,matrix:t,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=Iu({DenseMatrix:s});return r(ju,{"SparseMatrix, Array | Matrix":function(e,r){return function(e,r){for(var t=(r=u(e,r,!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 g=t[d][0]||0;if(o(g,0))h[d]=[0];else{for(var v=0,y=[],x=[],b=m[d],w=m[d+1]-1;w>=b;w--){var N=p[w];N===d?v=f[w]:N=0;m--){var h=t[m][0]||0,d=void 0;if(o(h,0))d=0;else{var g=p[m][m];if(o(g,0))throw new Error("Linear system cannot be solved since matrix is singular");d=n(h,g);for(var v=m-1;v>=0;v--)t[v]=[a(t[v][0]||0,i(d,p[v][m]))]}f[m]=[d]}return new s({data:f,size:[c,1]})}})),Lu="lsolveAll",Hu=te(Lu,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:r,matrix:t,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=Iu({DenseMatrix:s});return r(Lu,{"SparseMatrix, Array | Matrix":function(e,r){return function(e,r){for(var t=[u(e,r,!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&&(y.push(f[D]),x.push(E))}if(o(N,0))if(o(v[h],0)){if(0===g){var A=[...v];A[h]=1;for(var C=0,S=x.length;Cnew s({data:e.map((e=>[e])),size:[c,1]})))}(e,r)},"DenseMatrix, Array | Matrix":function(e,r){return c(e,r)},"Array, Array | Matrix":function(e,r){return c(t(e),r).map((e=>e.valueOf()))}});function c(e,r){for(var t=[u(e,r,!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]})))}})),$u="usolveAll",Gu=te($u,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:r,matrix:t,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=Iu({DenseMatrix:s});return r($u,{"SparseMatrix, Array | Matrix":function(e,r){return function(e,r){for(var t=[u(e,r,!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=t.length,g=0;g=b;N--){var D=p[N];D===h?w=f[N]:Dnew s({data:e.map((e=>[e])),size:[c,1]})))}(e,r)},"DenseMatrix, Array | Matrix":function(e,r){return c(e,r)},"Array, Array | Matrix":function(e,r){return c(t(e),r).map((e=>e.valueOf()))}});function c(e,r){for(var t=[u(e,r,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1]-1;f>=0;f--)for(var p=t.length,m=0;m=0;g--)d[g]=a(d[g],c[g][f]);t.push(d)}}else{if(0===m)return[];t.splice(m,1),m-=1,p-=1}else{h[f]=n(h[f],c[f][f]);for(var v=f-1;v>=0;v--)h[v]=a(h[v],i(h[f],c[v][f]))}}return t.map((e=>new s({data:e.map((e=>[e])),size:[l,1]})))}})),Zu=te("matAlgo08xS0Sid",["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=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 ke(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,g=u[0],v=u[1],y=t,x=0,b=i;"string"==typeof c&&c===h&&(d=c,y=r.find(t,[d,d]),x=r.convert(0,d),b=r.find(i,[d,d]));for(var w,N,D,E,A=[],C=[],S=[],M=[],F=[],T=0;T{var{typed:r,matrix:t}=e;return{"Array, number":r.referTo("DenseMatrix, number",(e=>(r,n)=>e(t(r),n).valueOf())),"Array, BigNumber":r.referTo("DenseMatrix, BigNumber",(e=>(r,n)=>e(t(r),n).valueOf())),"number, Array":r.referTo("number, DenseMatrix",(e=>(r,n)=>e(r,t(n)).valueOf())),"BigNumber, Array":r.referTo("BigNumber, DenseMatrix",(e=>(r,n)=>e(r,t(n)).valueOf()))}})),Wu="leftShift",Ju=te(Wu,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:r,matrix:t,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Ca({typed:r}),s=Ba({typed:r,equalScalar:n}),u=Zu({typed:r,equalScalar:n}),c=Ma({typed:r,DenseMatrix:a}),l=oa({typed:r,equalScalar:n}),f=ua({typed:r}),p=Ta({typed:r,matrix:t}),m=Vu({typed:r,matrix:t});return r(Wu,{"number, number":wo,"BigNumber, BigNumber":mo,"SparseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>n(t,0)?r.clone():l(r,t,e,!1))),"DenseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>n(t,0)?r.clone():f(r,t,e,!1))),"number | BigNumber, SparseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):c(t,r,e,!0))),"number | BigNumber, DenseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):f(t,r,e,!0)))},m,p({SS:u,DS:o,SD:s}))})),Yu="rightArithShift",Xu=te(Yu,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:r,matrix:t,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Ca({typed:r}),s=Ba({typed:r,equalScalar:n}),u=Zu({typed:r,equalScalar:n}),c=Ma({typed:r,DenseMatrix:a}),l=oa({typed:r,equalScalar:n}),f=ua({typed:r}),p=Ta({typed:r,matrix:t}),m=Vu({typed:r,matrix:t});return r(Yu,{"number, number":No,"BigNumber, BigNumber":ho,"SparseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>n(t,0)?r.clone():l(r,t,e,!1))),"DenseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>n(t,0)?r.clone():f(r,t,e,!1))),"number | BigNumber, SparseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):c(t,r,e,!0))),"number | BigNumber, DenseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):f(t,r,e,!0)))},m,p({SS:u,DS:o,SD:s}))})),Qu="rightLogShift",Ku=te(Qu,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:r,matrix:t,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Ca({typed:r}),s=Ba({typed:r,equalScalar:n}),u=Zu({typed:r,equalScalar:n}),c=Ma({typed:r,DenseMatrix:a}),l=oa({typed:r,equalScalar:n}),f=ua({typed:r}),p=Ta({typed:r,matrix:t}),m=Vu({typed:r,matrix:t});return r(Qu,{"number, number":Do,"SparseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>n(t,0)?r.clone():l(r,t,e,!1))),"DenseMatrix, number | BigNumber":r.referToSelf((e=>(r,t)=>n(t,0)?r.clone():f(r,t,e,!1))),"number | BigNumber, SparseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):c(t,r,e,!0))),"number | BigNumber, DenseMatrix":r.referToSelf((e=>(r,t)=>n(r,0)?i(t.size(),t.storage()):f(t,r,e,!0)))},m,p({SS:u,DS:o,SD:s}))})),ec=te("and",["typed","matrix","equalScalar","zeros","not"],(e=>{var{typed:r,matrix:t,equalScalar:n,zeros:i,not:a}=e,o=Ba({typed:r,equalScalar:n}),s=_a({typed:r,equalScalar:n}),u=oa({typed:r,equalScalar:n}),c=ua({typed:r}),l=Ta({typed:r,matrix:t});return r("and",{"number, number":Lo,"Complex, Complex":function(e,r){return!(0===e.re&&0===e.im||0===r.re&&0===r.im)},"BigNumber, BigNumber":function(e,r){return!(e.isZero()||r.isZero()||e.isNaN()||r.isNaN())},"Unit, Unit":r.referToSelf((e=>(r,t)=>e(r.value||0,t.value||0))),"SparseMatrix, any":r.referToSelf((e=>(r,t)=>a(t)?i(r.size(),r.storage()):u(r,t,e,!1))),"DenseMatrix, any":r.referToSelf((e=>(r,t)=>a(t)?i(r.size(),r.storage()):c(r,t,e,!1))),"any, SparseMatrix":r.referToSelf((e=>(r,t)=>a(r)?i(r.size(),r.storage()):u(t,r,e,!0))),"any, DenseMatrix":r.referToSelf((e=>(r,t)=>a(r)?i(r.size(),r.storage()):c(t,r,e,!0))),"Array, any":r.referToSelf((e=>(r,n)=>e(t(r),n).valueOf())),"any, Array":r.referToSelf((e=>(r,n)=>e(r,t(n)).valueOf()))},l({SS:s,DS:o}))})),rc="compare",tc=te(rc,["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],(e=>{var{typed:r,config:t,equalScalar:n,matrix:i,BigNumber:a,Fraction:o,DenseMatrix:s}=e,u=Pa({typed:r}),c=ja({typed:r,equalScalar:n}),l=sa({typed:r,DenseMatrix:s}),f=Ta({typed:r,matrix:i}),p=ii({typed:r});return r(rc,nc({typed:r,config:t}),{"boolean, boolean":function(e,r){return e===r?0:e>r?1:-1},"BigNumber, BigNumber":function(e,r){return ni(e,r,t.epsilon)?new a(0):new a(e.cmp(r))},"Fraction, Fraction":function(e,r){return new o(e.compare(r))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},p,f({SS:c,DS:u,Ss:l}))})),nc=te(rc,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(rc,{"number, number":function(e,r){return be(e,r,t.epsilon)?0:e>r?1:-1}})})),ic=t(3228),ac="compareNatural",oc=te(ac,["typed","compare"],(e=>{var{typed:r,compare:t}=e,n=t.signatures["boolean,boolean"];return r(ac,{"any, any":function e(r,o){var s,u=$(r),c=$(o);if(!("number"!==u&&"BigNumber"!==u&&"Fraction"!==u||"number"!==c&&"BigNumber"!==c&&"Fraction"!==c))return"0"!==(s=t(r,o)).toString()?s>0?1:-1:ic(u,c);var l=["Array","DenseMatrix","SparseMatrix"];if(l.includes(u)||l.includes(c))return s=i(e,r,o),0!==s?s:ic(u,c);if(u!==c)return ic(u,c);if("Complex"===u)return function(e,r){if(e.re>r.re)return 1;if(e.rer.im)return 1;if(e.imt.length?1:r.length{var{typed:r,matrix:t}=e,n=Ta({typed:r,matrix:t});return r(sc,qe,n({elop:qe,Ds:!0}))})),lc="equal",fc=te(lc,["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:r,matrix:t,equalScalar:n,DenseMatrix:i}=e,a=Pa({typed:r}),o=To({typed:r,DenseMatrix:i}),s=sa({typed:r,DenseMatrix:i}),u=Ta({typed:r,matrix:t});return r(lc,pc({typed:r,equalScalar:n}),u({elop:n,SS:o,DS:a,Ss:s}))})),pc=te(lc,["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return r(lc,{"any, any":function(e,r){return null===e?null===r:null===r?null===e:void 0===e?void 0===r:void 0===r?void 0===e:t(e,r)}})})),mc="equalText",hc=te(mc,["typed","compareText","isZero"],(e=>{var{typed:r,compareText:t,isZero:n}=e;return r(mc,{"any, any":function(e,r){return n(t(e,r))}})})),dc="smaller",gc=te(dc,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i}=e,a=Pa({typed:r}),o=To({typed:r,DenseMatrix:i}),s=sa({typed:r,DenseMatrix:i}),u=Ta({typed:r,matrix:n}),c=ii({typed:r});return r(dc,vc({typed:r,config:t}),{"boolean, boolean":(e,r)=>e-1===e.compare(r),"Complex, Complex":function(e,r){throw new TypeError("No ordering relation is defined for complex numbers")}},c,u({SS:o,DS:a,Ss:s}))})),vc=te(dc,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(dc,{"number, number":function(e,r){return e{var{typed:r,config:t,matrix:n,DenseMatrix:i}=e,a=Pa({typed:r}),o=To({typed:r,DenseMatrix:i}),s=sa({typed:r,DenseMatrix:i}),u=Ta({typed:r,matrix:n}),c=ii({typed:r});return r(yc,bc({typed:r,config:t}),{"boolean, boolean":(e,r)=>e<=r,"BigNumber, BigNumber":function(e,r){return e.lte(r)||ni(e,r,t.epsilon)},"Fraction, Fraction":(e,r)=>1!==e.compare(r),"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},c,u({SS:o,DS:a,Ss:s}))})),bc=te(yc,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(yc,{"number, number":function(e,r){return e<=r||be(e,r,t.epsilon)}})})),wc="larger",Nc=te(wc,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i}=e,a=Pa({typed:r}),o=To({typed:r,DenseMatrix:i}),s=sa({typed:r,DenseMatrix:i}),u=Ta({typed:r,matrix:n}),c=ii({typed:r});return r(wc,Dc({typed:r,config:t}),{"boolean, boolean":(e,r)=>e>r,"BigNumber, BigNumber":function(e,r){return e.gt(r)&&!ni(e,r,t.epsilon)},"Fraction, Fraction":(e,r)=>1===e.compare(r),"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},c,u({SS:o,DS:a,Ss:s}))})),Dc=te(wc,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(wc,{"number, number":function(e,r){return e>r&&!be(e,r,t.epsilon)}})})),Ec="largerEq",Ac=te(Ec,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i}=e,a=Pa({typed:r}),o=To({typed:r,DenseMatrix:i}),s=sa({typed:r,DenseMatrix:i}),u=Ta({typed:r,matrix:n}),c=ii({typed:r});return r(Ec,Cc({typed:r,config:t}),{"boolean, boolean":(e,r)=>e>=r,"BigNumber, BigNumber":function(e,r){return e.gte(r)||ni(e,r,t.epsilon)},"Fraction, Fraction":(e,r)=>-1!==e.compare(r),"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},c,u({SS:o,DS:a,Ss:s}))})),Cc=te(Ec,["typed","config"],(e=>{var{typed:r,config:t}=e;return r(Ec,{"number, number":function(e,r){return e>=r||be(e,r,t.epsilon)}})})),Sc="deepEqual",Mc=te(Sc,["typed","equal"],(e=>{var{typed:r,equal:t}=e;return r(Sc,{"any, any":function(e,r){return n(e.valueOf(),r.valueOf())}});function n(e,r){if(Array.isArray(e)){if(Array.isArray(r)){var i=e.length;if(i!==r.length)return!1;for(var a=0;a{var{typed:r,config:t,equalScalar:n,matrix:i,DenseMatrix:a}=e,o=Pa({typed:r}),s=To({typed:r,DenseMatrix:a}),u=sa({typed:r,DenseMatrix:a}),c=Ta({typed:r,matrix:i});return r(Fc,Oc({typed:r,equalScalar:n}),c({elop:function(e,r){return!n(e,r)},SS:s,DS:o,Ss:u}))})),Oc=te(Fc,["typed","equalScalar"],(e=>{var{typed:r,equalScalar:t}=e;return r(Fc,{"any, any":function(e,r){return null===e?null!==r:null===r?null!==e:void 0===e?void 0!==r:void 0===r?void 0!==e:!t(e,r)}})})),Bc="partitionSelect",_c=te(Bc,["typed","isNumeric","isNaN","compare"],(e=>{var{typed:r,isNumeric:t,isNaN:n,compare:i}=e,a=i,o=(e,r)=>-i(e,r);return r(Bc,{"Array | Matrix, number":function(e,r){return s(e,r,a)},"Array | Matrix, number, string":function(e,r,t){if("asc"===t)return s(e,r,a);if("desc"===t)return s(e,r,o);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":s});function s(e,r,t){if(!ae(r)||r<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(),r,t)}if(Array.isArray(e))return u(e,r,t)}function u(e,r,i){if(r>=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,r<=u?s=u:o=u+1}return e[r]}})),zc="sort",qc=te(zc,["typed","matrix","compare","compareNatural"],(e=>{var{typed:r,matrix:t,compare:n,compareNatural:i}=e,a=n,o=(e,r)=>-n(e,r);return r(zc,{Array:function(e){return u(e),e.sort(a)},Matrix:function(e){return c(e),t(e.toArray().sort(a),e.storage())},"Array, function":function(e,r){return u(e),e.sort(r)},"Matrix, function":function(e,r){return c(e),t(e.toArray().sort(r),e.storage())},"Array, string":function(e,r){return u(e),e.sort(s(r))},"Matrix, string":function(e,r){return c(e),t(e.toArray().sort(s(r)),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!==Re(e).length)throw new Error("One dimensional array expected")}function c(e){if(1!==e.size().length)throw new Error("One dimensional matrix expected")}})),kc=te("max",["typed","config","numeric","larger"],(e=>{var{typed:r,config:t,numeric:n,larger:i}=e;return r("max",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,r){return _n(e,r.valueOf(),a)},"...":function(e){if(Tn(e))throw new TypeError("Scalar values expected in function max");return o(e)}});function a(e,r){try{return i(e,r)?e:r}catch(e){throw su(e,"max",r)}}function o(e){var r;if(On(e,(function(e){try{isNaN(e)&&"number"==typeof e?r=NaN:(void 0===r||i(e,r))&&(r=e)}catch(r){throw su(r,"max",e)}})),void 0===r)throw new Error("Cannot calculate max of an empty array");return"string"==typeof r&&(r=n(r,t.number)),r}})),Ic=te("min",["typed","config","numeric","smaller"],(e=>{var{typed:r,config:t,numeric:n,smaller:i}=e;return r("min",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,r){return _n(e,r.valueOf(),a)},"...":function(e){if(Tn(e))throw new TypeError("Scalar values expected in function min");return o(e)}});function a(e,r){try{return i(e,r)?e:r}catch(e){throw su(e,"min",r)}}function o(e){var r;if(On(e,(function(e){try{isNaN(e)&&"number"==typeof e?r=NaN:(void 0===r||i(e,r))&&(r=e)}catch(r){throw su(r,"min",e)}})),void 0===r)throw new Error("Cannot calculate min of an empty array");return"string"==typeof r&&(r=n(r,t.number)),r}})),Rc=te("ImmutableDenseMatrix",["smaller","DenseMatrix"],(e=>{var{smaller:r,DenseMatrix:t}=e;function n(e,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(r&&!c(r))throw new Error("Invalid datatype: "+r);if(f(e)||l(e)){var i=new t(e,r);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 ("+$(e)+")");this._data=[],this._size=[0],this._datatype=r,this._min=null,this._max=null}}return n.prototype=new t,n.prototype.type="ImmutableDenseMatrix",n.prototype.isImmutableDenseMatrix=!0,n.prototype.subset=function(e){switch(arguments.length){case 1:var r=t.prototype.subset.call(this,e);return f(r)?new n({data:r._data,size:r._size,datatype:r._datatype}):r;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:G(this._data),size:G(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(t){(null===e||r(t,e))&&(e=t)})),this._min=null!==e?e:void 0}return this._min},n.prototype.max=function(){if(null===this._max){var e=null;this.forEach((function(t){(null===e||r(e,t))&&(e=t)})),this._max=null!==e?e:void 0}return this._max},n}),{isClass:!0}),Pc=te("Index",["ImmutableDenseMatrix"],(e=>{var{ImmutableDenseMatrix:r}=e;function t(e){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var r=0,i=arguments.length;r{var{smaller:r,larger:t}=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,r,t){r.left.right=r.right,r.right.left=r.left,t.degree--,t.child===r&&(t.child=r.right),0===t.degree&&(t.child=null),r.left=e,r.right=e.right,e.right=r,r.right.left=r,r.parent=null,r.mark=!1}function o(e,r){var t=r.parent;t&&(r.mark?(a(e,r,t),o(t)):r.mark=!0)}i.prototype.type="FibonacciHeap",i.prototype.isFibonacciHeap=!0,i.prototype.insert=function(e,t){var n={key:e,value:t,degree:0};if(this._minimum){var i=this._minimum;n.left=i,n.right=i.right,i.right=n,n.right.left=n,r(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(t(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{addScalar:r,equalScalar:t,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,r){if(this._values[e])this._values[e].value=r;else{var t=this._heap.insert(e,r);this._values[e]=t}},i.prototype.get=function(e){var r=this._values[e];return r?r.value:0},i.prototype.accumulate=function(e,t){var n=this._values[e];n?n.value=r(n.value,t):(n=this._heap.insert(e,t),this._values[e]=n)},i.prototype.forEach=function(e,r,n){var i=this._heap,a=this._values,o=[],s=i.extractMinimum();for(s&&o.push(s);s&&s.key<=r;)s.key>=e&&(t(s.value,0)||n(s.key,s.value,this)),(s=i.extractMinimum())&&o.push(s);for(var u=0;u{var t,n,i,{on:a,config:s,addScalar:c,subtract:l,multiplyScalar:f,divideScalar:p,pow:m,abs:h,fix:d,round:g,equal:v,isNumeric:y,format:x,number:b,Complex:w,BigNumber:N,Fraction:D}=e,E=b;function A(e,t){if(!(this instanceof A))throw new Error("Constructor must be called with the new operator");if(null!=e&&!y(e)&&!o(e))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(this.fixPrefix=!1,this.skipAutomaticSimplification=!0,void 0===t)this.units=[],this.dimensions=k.map((e=>0));else if("string"==typeof t){var n=A.parse(t);this.units=n.units,this.dimensions=n.dimensions}else{if(!u(t)||null!==t.value)throw new TypeError("Second parameter in Unit constructor must be a string or valueless Unit");this.fixPrefix=t.fixPrefix,this.skipAutomaticSimplification=t.skipAutomaticSimplification,this.dimensions=t.dimensions.slice(0),this.units=t.units.map((e=>r({},e)))}this.value=this._normalize(e)}function C(){for(;" "===i||"\t"===i;)M()}function S(e){return e>="0"&&e<="9"}function M(){n++,i=t.charAt(n)}function F(e){n=e,i=t.charAt(n)}function T(){var e="",r=n;if("+"===i?M():"-"===i&&(e+=i,M()),!function(e){return e>="0"&&e<="9"||"."===e}(i))return F(r),null;if("."===i){if(e+=i,M(),!S(i))return F(r),null}else{for(;S(i);)e+=i,M();"."===i&&(e+=i,M())}for(;S(i);)e+=i,M();if("E"===i||"e"===i){var t="",a=n;if(t+=i,M(),"+"!==i&&"-"!==i||(t+=i,M()),!S(i))return F(a),e;for(e+=t;S(i);)e+=i,M()}return e}function O(){for(var e="";S(i)||A.isValidAlpha(i);)e+=i,M();var r=e.charAt(0);return A.isValidAlpha(r)?e:null}function B(e){return i===e?(M(),e):null}Object.defineProperty(A,"name",{value:"Unit"}),A.prototype.constructor=A,A.prototype.type="Unit",A.prototype.isUnit=!0,A.parse=function(e,r){if(r=r||{},n=-1,i="","string"!=typeof(t=e))throw new TypeError("Invalid argument in Unit.parse, string expected");var a=new A;a.units=[];var o=1,u=!1;M(),C();var c=T(),l=null;if(c){if("BigNumber"===s.number)l=new N(c);else if("Fraction"===s.number)try{l=new D(c)}catch(e){l=parseFloat(c)}else l=parseFloat(c);C(),B("*")?(o=1,u=!0):B("/")&&(o=-1,u=!0)}for(var f=[],p=1;;){for(C();"("===i;)f.push(o),p*=o,o=1,M(),C();var m=void 0;if(!i)break;var h=i;if(null===(m=O()))throw new SyntaxError('Unexpected "'+h+'" in "'+t+'" at index '+n.toString());var d=_(m);if(null===d)throw new SyntaxError('Unit "'+m+'" not found.');var g=o*p;if(C(),B("^")){C();var v=T();if(null===v)throw new SyntaxError('In "'+e+'", "^" must be followed by a floating-point number');g*=v}a.units.push({unit:d.unit,prefix:d.prefix,power:g});for(var y=0;y1||Math.abs(this.units[0].power-1)>1e-15)},A.prototype._normalize=function(e){if(null==e||0===this.units.length)return e;for(var r=e,t=A._getNumberConverter($(e)),n=0;n{if(K(j,e)){var r=j[e];return{unit:r,prefix:r.prefixes[""]}}for(var t in j)if(K(j,t)&&Te(e,t)){var n=j[t],i=e.length-t.length,a=e.substring(0,i),o=K(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 z(e){return e.equalBase(I.NONE)&&null!==e.value&&!s.predictable?e.value:e}A.isValuelessUnit=function(e){return null!==_(e)},A.prototype.hasBase=function(e){if("string"==typeof e&&(e=I[e]),!e)return!1;for(var r=0;r1e-12)return!1;return!0},A.prototype.equalBase=function(e){for(var r=0;r1e-12)return!1;return!0},A.prototype.equals=function(e){return this.equalBase(e)&&v(this.value,e.value)},A.prototype.multiply=function(e){for(var r=this.clone(),t=u(e)?e:new A(e),n=0;n1e-12&&(K(Z,s)?n.push({unit:Z[s].unit,prefix:Z[s].prefix,power:t.dimensions[o]||0}):a=!0)}n.length1e-12){if(!K(H.si,n))throw new Error("Cannot express custom unit "+n+" in SI units");r.push({unit:H.si[n].unit,prefix:H.si[n].prefix,power:e.dimensions[t]||0})}}return e.units=r,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,e},A.prototype.formatUnits=function(){for(var e="",r="",t=0,n=0,i=0;i0?(t++,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?(r+=" "+this.units[a].prefix.name+this.units[a].unit.name,Math.abs(this.units[a].power+1)>1e-15&&(r+="^"+-this.units[a].power)):(r+=" "+this.units[a].prefix.name+this.units[a].unit.name,r+="^"+this.units[a].power));e=e.substr(1),r=r.substr(1),t>1&&n>0&&(e="("+e+")"),n>1&&t>0&&(r="("+r+")");var o=e;return t>0&&n>0&&(o+=" / "),o+=r},A.prototype.format=function(e){var r=this.skipAutomaticSimplification||null===this.value?this.clone():this.simplify(),t=!1;for(var n in void 0!==r.value&&null!==r.value&&o(r.value)&&(t=Math.abs(r.value.re)<1e-14),r.units)K(r.units,n)&&r.units[n].unit&&("VA"===r.units[n].unit.name&&t?r.units[n].unit=j.VAR:"VAR"!==r.units[n].unit.name||t||(r.units[n].unit=j.VA));1!==r.units.length||r.fixPrefix||Math.abs(r.units[0].power-Math.round(r.units[0].power))<1e-14&&(r.units[0].prefix=r._bestPrefix());var i=r._denormalize(r.value),a=null!==r.value?x(i,e||{}):"",s=r.formatUnits();return r.value&&o(r.value)&&(a="("+a+")"),s.length>0&&a.length>0&&(a+=" "),a+=s},A.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,r=h(this.units[0].unit.value),t=this.units[0].prefix;if(0===e)return t;var n=this.units[0].power,i=Math.log(e/Math.pow(t.value*r,n))/Math.LN10-1.2;if(i>-2.200001&&i<1.800001)return t;i=Math.abs(i);var a=this.units[0].unit.prefixes;for(var o in a)if(K(a,o)){var s=a[o];if(s.scientific){var u=Math.abs(Math.log(e/Math.pow(s.value*r,n))/Math.LN10-1.2);(u0))},j={meter:{name:"meter",base:I.LENGTH,prefixes:q.LONG,value:1,offset:0},inch:{name:"inch",base:I.LENGTH,prefixes:q.NONE,value:.0254,offset:0},foot:{name:"foot",base:I.LENGTH,prefixes:q.NONE,value:.3048,offset:0},yard:{name:"yard",base:I.LENGTH,prefixes:q.NONE,value:.9144,offset:0},mile:{name:"mile",base:I.LENGTH,prefixes:q.NONE,value:1609.344,offset:0},link:{name:"link",base:I.LENGTH,prefixes:q.NONE,value:.201168,offset:0},rod:{name:"rod",base:I.LENGTH,prefixes:q.NONE,value:5.0292,offset:0},chain:{name:"chain",base:I.LENGTH,prefixes:q.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:I.LENGTH,prefixes:q.NONE,value:1e-10,offset:0},m:{name:"m",base:I.LENGTH,prefixes:q.SHORT,value:1,offset:0},in:{name:"in",base:I.LENGTH,prefixes:q.NONE,value:.0254,offset:0},ft:{name:"ft",base:I.LENGTH,prefixes:q.NONE,value:.3048,offset:0},yd:{name:"yd",base:I.LENGTH,prefixes:q.NONE,value:.9144,offset:0},mi:{name:"mi",base:I.LENGTH,prefixes:q.NONE,value:1609.344,offset:0},li:{name:"li",base:I.LENGTH,prefixes:q.NONE,value:.201168,offset:0},rd:{name:"rd",base:I.LENGTH,prefixes:q.NONE,value:5.02921,offset:0},ch:{name:"ch",base:I.LENGTH,prefixes:q.NONE,value:20.1168,offset:0},mil:{name:"mil",base:I.LENGTH,prefixes:q.NONE,value:254e-7,offset:0},m2:{name:"m2",base:I.SURFACE,prefixes:q.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:I.SURFACE,prefixes:q.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:I.SURFACE,prefixes:q.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:I.SURFACE,prefixes:q.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:I.SURFACE,prefixes:q.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:I.SURFACE,prefixes:q.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:I.SURFACE,prefixes:q.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:I.SURFACE,prefixes:q.NONE,value:6.4516e-10,offset:0},acre:{name:"acre",base:I.SURFACE,prefixes:q.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:I.SURFACE,prefixes:q.NONE,value:1e4,offset:0},m3:{name:"m3",base:I.VOLUME,prefixes:q.CUBIC,value:1,offset:0},L:{name:"L",base:I.VOLUME,prefixes:q.SHORT,value:.001,offset:0},l:{name:"l",base:I.VOLUME,prefixes:q.SHORT,value:.001,offset:0},litre:{name:"litre",base:I.VOLUME,prefixes:q.LONG,value:.001,offset:0},cuin:{name:"cuin",base:I.VOLUME,prefixes:q.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:I.VOLUME,prefixes:q.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:I.VOLUME,prefixes:q.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:I.VOLUME,prefixes:q.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:I.VOLUME,prefixes:q.NONE,value:15e-6,offset:0},drop:{name:"drop",base:I.VOLUME,prefixes:q.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:I.VOLUME,prefixes:q.NONE,value:5e-8,offset:0},minim:{name:"minim",base:I.VOLUME,prefixes:q.NONE,value:6.161152e-8,offset:0},fluiddram:{name:"fluiddram",base:I.VOLUME,prefixes:q.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:I.VOLUME,prefixes:q.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:I.VOLUME,prefixes:q.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:I.VOLUME,prefixes:q.NONE,value:1e-6,offset:0},cup:{name:"cup",base:I.VOLUME,prefixes:q.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:I.VOLUME,prefixes:q.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:I.VOLUME,prefixes:q.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:I.VOLUME,prefixes:q.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:I.VOLUME,prefixes:q.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:I.VOLUME,prefixes:q.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:I.VOLUME,prefixes:q.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:I.VOLUME,prefixes:q.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:I.VOLUME,prefixes:q.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:I.VOLUME,prefixes:q.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:I.VOLUME,prefixes:q.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:I.VOLUME,prefixes:q.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:I.VOLUME,prefixes:q.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:I.VOLUME,prefixes:q.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:I.VOLUME,prefixes:q.NONE,value:.1173478,offset:0},obl:{name:"obl",base:I.VOLUME,prefixes:q.NONE,value:.1589873,offset:0},g:{name:"g",base:I.MASS,prefixes:q.SHORT,value:.001,offset:0},gram:{name:"gram",base:I.MASS,prefixes:q.LONG,value:.001,offset:0},ton:{name:"ton",base:I.MASS,prefixes:q.SHORT,value:907.18474,offset:0},t:{name:"t",base:I.MASS,prefixes:q.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:I.MASS,prefixes:q.LONG,value:1e3,offset:0},grain:{name:"grain",base:I.MASS,prefixes:q.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:I.MASS,prefixes:q.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:I.MASS,prefixes:q.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:I.MASS,prefixes:q.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:I.MASS,prefixes:q.NONE,value:45.359237,offset:0},stick:{name:"stick",base:I.MASS,prefixes:q.NONE,value:.115,offset:0},stone:{name:"stone",base:I.MASS,prefixes:q.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:I.MASS,prefixes:q.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:I.MASS,prefixes:q.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:I.MASS,prefixes:q.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:I.MASS,prefixes:q.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:I.MASS,prefixes:q.NONE,value:45.359237,offset:0},s:{name:"s",base:I.TIME,prefixes:q.SHORT,value:1,offset:0},min:{name:"min",base:I.TIME,prefixes:q.NONE,value:60,offset:0},h:{name:"h",base:I.TIME,prefixes:q.NONE,value:3600,offset:0},second:{name:"second",base:I.TIME,prefixes:q.LONG,value:1,offset:0},sec:{name:"sec",base:I.TIME,prefixes:q.LONG,value:1,offset:0},minute:{name:"minute",base:I.TIME,prefixes:q.NONE,value:60,offset:0},hour:{name:"hour",base:I.TIME,prefixes:q.NONE,value:3600,offset:0},day:{name:"day",base:I.TIME,prefixes:q.NONE,value:86400,offset:0},week:{name:"week",base:I.TIME,prefixes:q.NONE,value:604800,offset:0},month:{name:"month",base:I.TIME,prefixes:q.NONE,value:2629800,offset:0},year:{name:"year",base:I.TIME,prefixes:q.NONE,value:31557600,offset:0},decade:{name:"decade",base:I.TIME,prefixes:q.NONE,value:315576e3,offset:0},century:{name:"century",base:I.TIME,prefixes:q.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:I.TIME,prefixes:q.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:I.FREQUENCY,prefixes:q.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:I.FREQUENCY,prefixes:q.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:I.ANGLE,prefixes:q.SHORT,value:1,offset:0},radian:{name:"radian",base:I.ANGLE,prefixes:q.LONG,value:1,offset:0},deg:{name:"deg",base:I.ANGLE,prefixes:q.SHORT,value:null,offset:0},degree:{name:"degree",base:I.ANGLE,prefixes:q.LONG,value:null,offset:0},grad:{name:"grad",base:I.ANGLE,prefixes:q.SHORT,value:null,offset:0},gradian:{name:"gradian",base:I.ANGLE,prefixes:q.LONG,value:null,offset:0},cycle:{name:"cycle",base:I.ANGLE,prefixes:q.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:I.ANGLE,prefixes:q.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:I.ANGLE,prefixes:q.NONE,value:null,offset:0},A:{name:"A",base:I.CURRENT,prefixes:q.SHORT,value:1,offset:0},ampere:{name:"ampere",base:I.CURRENT,prefixes:q.LONG,value:1,offset:0},K:{name:"K",base:I.TEMPERATURE,prefixes:q.NONE,value:1,offset:0},degC:{name:"degC",base:I.TEMPERATURE,prefixes:q.NONE,value:1,offset:273.15},degF:{name:"degF",base:I.TEMPERATURE,prefixes:q.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:I.TEMPERATURE,prefixes:q.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:I.TEMPERATURE,prefixes:q.NONE,value:1,offset:0},celsius:{name:"celsius",base:I.TEMPERATURE,prefixes:q.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:I.TEMPERATURE,prefixes:q.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:I.TEMPERATURE,prefixes:q.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:I.AMOUNT_OF_SUBSTANCE,prefixes:q.SHORT,value:1,offset:0},mole:{name:"mole",base:I.AMOUNT_OF_SUBSTANCE,prefixes:q.LONG,value:1,offset:0},cd:{name:"cd",base:I.LUMINOUS_INTENSITY,prefixes:q.SHORT,value:1,offset:0},candela:{name:"candela",base:I.LUMINOUS_INTENSITY,prefixes:q.LONG,value:1,offset:0},N:{name:"N",base:I.FORCE,prefixes:q.SHORT,value:1,offset:0},newton:{name:"newton",base:I.FORCE,prefixes:q.LONG,value:1,offset:0},dyn:{name:"dyn",base:I.FORCE,prefixes:q.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:I.FORCE,prefixes:q.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:I.FORCE,prefixes:q.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:I.FORCE,prefixes:q.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:I.FORCE,prefixes:q.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:I.FORCE,prefixes:q.NONE,value:9.80665,offset:0},J:{name:"J",base:I.ENERGY,prefixes:q.SHORT,value:1,offset:0},joule:{name:"joule",base:I.ENERGY,prefixes:q.SHORT,value:1,offset:0},erg:{name:"erg",base:I.ENERGY,prefixes:q.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:I.ENERGY,prefixes:q.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:I.ENERGY,prefixes:q.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:I.ENERGY,prefixes:q.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:I.ENERGY,prefixes:q.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:I.POWER,prefixes:q.SHORT,value:1,offset:0},watt:{name:"watt",base:I.POWER,prefixes:q.LONG,value:1,offset:0},hp:{name:"hp",base:I.POWER,prefixes:q.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:I.POWER,prefixes:q.SHORT,value:w.I,offset:0},VA:{name:"VA",base:I.POWER,prefixes:q.SHORT,value:1,offset:0},Pa:{name:"Pa",base:I.PRESSURE,prefixes:q.SHORT,value:1,offset:0},psi:{name:"psi",base:I.PRESSURE,prefixes:q.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:I.PRESSURE,prefixes:q.NONE,value:101325,offset:0},bar:{name:"bar",base:I.PRESSURE,prefixes:q.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:I.PRESSURE,prefixes:q.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:I.PRESSURE,prefixes:q.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:I.PRESSURE,prefixes:q.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:I.PRESSURE,prefixes:q.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:I.ELECTRIC_CHARGE,prefixes:q.LONG,value:1,offset:0},C:{name:"C",base:I.ELECTRIC_CHARGE,prefixes:q.SHORT,value:1,offset:0},farad:{name:"farad",base:I.ELECTRIC_CAPACITANCE,prefixes:q.LONG,value:1,offset:0},F:{name:"F",base:I.ELECTRIC_CAPACITANCE,prefixes:q.SHORT,value:1,offset:0},volt:{name:"volt",base:I.ELECTRIC_POTENTIAL,prefixes:q.LONG,value:1,offset:0},V:{name:"V",base:I.ELECTRIC_POTENTIAL,prefixes:q.SHORT,value:1,offset:0},ohm:{name:"ohm",base:I.ELECTRIC_RESISTANCE,prefixes:q.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:I.ELECTRIC_INDUCTANCE,prefixes:q.LONG,value:1,offset:0},H:{name:"H",base:I.ELECTRIC_INDUCTANCE,prefixes:q.SHORT,value:1,offset:0},siemens:{name:"siemens",base:I.ELECTRIC_CONDUCTANCE,prefixes:q.LONG,value:1,offset:0},S:{name:"S",base:I.ELECTRIC_CONDUCTANCE,prefixes:q.SHORT,value:1,offset:0},weber:{name:"weber",base:I.MAGNETIC_FLUX,prefixes:q.LONG,value:1,offset:0},Wb:{name:"Wb",base:I.MAGNETIC_FLUX,prefixes:q.SHORT,value:1,offset:0},tesla:{name:"tesla",base:I.MAGNETIC_FLUX_DENSITY,prefixes:q.LONG,value:1,offset:0},T:{name:"T",base:I.MAGNETIC_FLUX_DENSITY,prefixes:q.SHORT,value:1,offset:0},b:{name:"b",base:I.BIT,prefixes:q.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:I.BIT,prefixes:q.BINARY_LONG,value:1,offset:0},B:{name:"B",base:I.BIT,prefixes:q.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:I.BIT,prefixes:q.BINARY_LONG,value:8,offset:0}},U={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function L(e){if("BigNumber"===e.number){var r=Gc(N);j.rad.value=new N(1),j.deg.value=r.div(180),j.grad.value=r.div(200),j.cycle.value=r.times(2),j.arcsec.value=r.div(648e3),j.arcmin.value=r.div(10800)}else j.rad.value=1,j.deg.value=Math.PI/180,j.grad.value=Math.PI/200,j.cycle.value=2*Math.PI,j.arcsec.value=Math.PI/648e3,j.arcmin.value=Math.PI/10800;j.radian.value=j.rad.value,j.degree.value=j.deg.value,j.gradian.value=j.grad.value}L(s),a&&a("config",(function(e,r){e.number!==r.number&&L(e)}));var H={si:{NONE:{unit:P,prefix:q.NONE[""]},LENGTH:{unit:j.m,prefix:q.SHORT[""]},MASS:{unit:j.g,prefix:q.SHORT.k},TIME:{unit:j.s,prefix:q.SHORT[""]},CURRENT:{unit:j.A,prefix:q.SHORT[""]},TEMPERATURE:{unit:j.K,prefix:q.SHORT[""]},LUMINOUS_INTENSITY:{unit:j.cd,prefix:q.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:j.mol,prefix:q.SHORT[""]},ANGLE:{unit:j.rad,prefix:q.SHORT[""]},BIT:{unit:j.bits,prefix:q.SHORT[""]},FORCE:{unit:j.N,prefix:q.SHORT[""]},ENERGY:{unit:j.J,prefix:q.SHORT[""]},POWER:{unit:j.W,prefix:q.SHORT[""]},PRESSURE:{unit:j.Pa,prefix:q.SHORT[""]},ELECTRIC_CHARGE:{unit:j.C,prefix:q.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:j.F,prefix:q.SHORT[""]},ELECTRIC_POTENTIAL:{unit:j.V,prefix:q.SHORT[""]},ELECTRIC_RESISTANCE:{unit:j.ohm,prefix:q.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:j.H,prefix:q.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:j.S,prefix:q.SHORT[""]},MAGNETIC_FLUX:{unit:j.Wb,prefix:q.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:j.T,prefix:q.SHORT[""]},FREQUENCY:{unit:j.Hz,prefix:q.SHORT[""]}}};H.cgs=JSON.parse(JSON.stringify(H.si)),H.cgs.LENGTH={unit:j.m,prefix:q.SHORT.c},H.cgs.MASS={unit:j.g,prefix:q.SHORT[""]},H.cgs.FORCE={unit:j.dyn,prefix:q.SHORT[""]},H.cgs.ENERGY={unit:j.erg,prefix:q.NONE[""]},H.us=JSON.parse(JSON.stringify(H.si)),H.us.LENGTH={unit:j.ft,prefix:q.NONE[""]},H.us.MASS={unit:j.lbm,prefix:q.NONE[""]},H.us.TEMPERATURE={unit:j.degF,prefix:q.NONE[""]},H.us.FORCE={unit:j.lbf,prefix:q.NONE[""]},H.us.ENERGY={unit:j.BTU,prefix:q.BTU[""]},H.us.POWER={unit:j.hp,prefix:q.NONE[""]},H.us.PRESSURE={unit:j.psi,prefix:q.NONE[""]},H.auto=JSON.parse(JSON.stringify(H.si));var Z=H.auto;for(var V in A.setUnitSystem=function(e){if(!K(H,e))throw new Error("Unit system "+e+" does not exist. Choices are: "+Object.keys(H).join(", "));Z=H[e]},A.getUnitSystem=function(){for(var e in H)if(K(H,e)&&H[e]===Z)return e},A.typeConverters={BigNumber:function(e){return new N(e+"")},Fraction:function(e){return new D(e)},Complex:function(e){return e},number:function(e){return e}},A.prototype._numberConverter=function(){var e=A.typeConverters[this.valueType()];if(e)return e;throw new TypeError('Unsupported Unit value type "'+this.valueType()+'"')},A._getNumberConverter=function(e){if(!A.typeConverters[e])throw new TypeError('Unsupported type "'+e+'"');return A.typeConverters[e]},j)if(K(j,V)){var W=j[V];W.dimensions=W.base.dimensions}for(var J in U)if(K(U,J)){var Y=j[U[J]],X={};for(var Q in Y)K(Y,Q)&&(X[Q]=Y[Q]);X.name=J,j[J]=X}return A.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)},A.createUnit=function(e,r){if("object"!=typeof e)throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(r&&r.override)for(var t in e)if(K(e,t)&&A.deleteUnit(t),e[t].aliases)for(var n=0;n0&&!A.isValidAlpha(i)&&!S(i))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+e+'"')}}(e);var n,a,o,s=null,u=[],c=0;if(r&&"Unit"===r.type)s=r.clone();else if("string"==typeof r)""!==r&&(n=r);else{if("object"!=typeof r)throw new TypeError('Cannot create unit "'+e+'" from "'+r.toString()+'": expecting "string" or "Unit" or "Object"');n=r.definition,a=r.prefixes,c=r.offset,o=r.baseName,r.aliases&&(u=r.aliases.valueOf())}if(u)for(var l=0;l1e-12){h=!1;break}if(h){p=!0,f.base=I[m];break}}if(!p){o=o||e+"_STUFF";var g={dimensions:s.dimensions.slice(0)};g.key=o,I[o]=g,Z[o]={unit:f,prefix:q.NONE[""]},f.base=I[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 v in k.push(o),I)K(I,v)&&(I[v].dimensions[k.length-1]=0);for(var y={dimensions:[]},x=0;x{var{typed:r,Unit:t}=e;return r(Xc,{Unit:function(e){return e.clone()},string:function(e){return t.isValuelessUnit(e)?new t(null,e):t.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string | Unit":function(e,r){return new t(e,r)},"number | BigNumber | Fraction":function(e){return new t(e)},"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))})})),Kc="sparse",el=te(Kc,["typed","SparseMatrix"],(e=>{var{typed:r,SparseMatrix:t}=e;return r(Kc,{"":function(){return new t([])},string:function(e){return new t([],e)},"Array | Matrix":function(e){return new t(e)},"Array | Matrix, string":function(e,r){return new t(e,r)}})})),rl="createUnit",tl=te(rl,["typed","Unit"],(e=>{var{typed:r,Unit:t}=e;return r(rl,{"Object, Object":function(e,r){return t.createUnit(e,r)},Object:function(e){return t.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,r,n){var i={};return i[e]=r,t.createUnit(i,n)},"string, Unit | string | Object":function(e,r){var n={};return n[e]=r,t.createUnit(n,{})},string:function(e){var r={};return r[e]={},t.createUnit(r,{})}})})),nl="acos",il=te(nl,["typed","config","Complex"],(e=>{var{typed:r,config:t,Complex:n}=e;return r(nl,{number:function(e){return e>=-1&&e<=1||t.predictable?Math.acos(e):new n(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()}})})),al="number";function ol(e){return we(e)}function sl(e){return Math.atan(1/e)}function ul(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}function cl(e){return Math.asin(1/e)}function ll(e){var r=1/e;return Math.log(r+Math.sqrt(r*r+1))}function fl(e){return Math.acos(1/e)}function pl(e){var r=1/e,t=Math.sqrt(r*r-1);return Math.log(t+r)}function ml(e){return Ne(e)}function hl(e){return De(e)}function dl(e){return 1/Math.tan(e)}function gl(e){var r=Math.exp(2*e);return(r+1)/(r-1)}function vl(e){return 1/Math.sin(e)}function yl(e){return 0===e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*oe(e)}function xl(e){return 1/Math.cos(e)}function bl(e){return 2/(Math.exp(e)+Math.exp(-e))}function wl(e){return Ae(e)}ol.signature=al,sl.signature=al,ul.signature=al,cl.signature=al,ll.signature=al,fl.signature=al,pl.signature=al,ml.signature=al,hl.signature=al,dl.signature=al,gl.signature=al,vl.signature=al,yl.signature=al,xl.signature=al,bl.signature=al,wl.signature=al;var Nl="acosh",Dl=te(Nl,["typed","config","Complex"],(e=>{var{typed:r,config:t,Complex:n}=e;return r(Nl,{number:function(e){return e>=1||t.predictable?ol(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()}})})),El="acot",Al=te(El,["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r(El,{number:sl,Complex:function(e){return e.acot()},BigNumber:function(e){return new t(1).div(e).atan()}})})),Cl="acoth",Sl=te(Cl,["typed","config","Complex","BigNumber"],(e=>{var{typed:r,config:t,Complex:n,BigNumber:i}=e;return r(Cl,{number:function(e){return e>=1||e<=-1||t.predictable?ul(e):new n(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new i(1).div(e).atanh()}})})),Ml="acsc",Fl=te(Ml,["typed","config","Complex","BigNumber"],(e=>{var{typed:r,config:t,Complex:n,BigNumber:i}=e;return r(Ml,{number:function(e){return e<=-1||e>=1||t.predictable?cl(e):new n(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new i(1).div(e).asin()}})})),Tl="acsch",Ol=te(Tl,["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r(Tl,{number:ll,Complex:function(e){return e.acsch()},BigNumber:function(e){return new t(1).div(e).asinh()}})})),Bl="asec",_l=te(Bl,["typed","config","Complex","BigNumber"],(e=>{var{typed:r,config:t,Complex:n,BigNumber:i}=e;return r(Bl,{number:function(e){return e<=-1||e>=1||t.predictable?fl(e):new n(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new i(1).div(e).acos()}})})),zl="asech",ql=te(zl,["typed","config","Complex","BigNumber"],(e=>{var{typed:r,config:t,Complex:n,BigNumber:i}=e;return r(zl,{number:function(e){if(e<=1&&e>=-1||t.predictable){var r=1/e;if(r>0||t.predictable)return pl(e);var i=Math.sqrt(r*r-1);return new n(Math.log(i-r),Math.PI)}return new n(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new i(1).div(e).acosh()}})})),kl="asin",Il=te(kl,["typed","config","Complex"],(e=>{var{typed:r,config:t,Complex:n}=e;return r(kl,{number:function(e){return e>=-1&&e<=1||t.predictable?Math.asin(e):new n(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()}})})),Rl=te("asinh",["typed"],(e=>{var{typed:r}=e;return r("asinh",{number:ml,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()}})})),Pl=te("atan",["typed"],(e=>{var{typed:r}=e;return r("atan",{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()}})})),jl="atan2",Ul=te(jl,["typed","matrix","equalScalar","BigNumber","DenseMatrix"],(e=>{var{typed:r,matrix:t,equalScalar:n,BigNumber:i,DenseMatrix:a}=e,o=Ba({typed:r,equalScalar:n}),s=Pa({typed:r}),u=io({typed:r,equalScalar:n}),c=oa({typed:r,equalScalar:n}),l=sa({typed:r,DenseMatrix:a}),f=Ta({typed:r,matrix:t});return r(jl,{"number, number":Math.atan2,"BigNumber, BigNumber":(e,r)=>i.atan2(e,r)},f({scalar:"number | BigNumber",SS:u,DS:s,SD:o,Ss:c,sS:l}))})),Ll="atanh",Hl=te(Ll,["typed","config","Complex"],(e=>{var{typed:r,config:t,Complex:n}=e;return r(Ll,{number:function(e){return e<=1&&e>=-1||t.predictable?hl(e):new n(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()}})})),$l=te("trigUnit",["typed"],(e=>{var{typed:r}=e;return{Unit:r.referToSelf((e=>t=>{if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return r.find(e,t.valueType())(t.value)}))}})),Gl=te("cos",["typed"],(e=>{var{typed:r}=e,t=$l({typed:r});return r("cos",{number:Math.cos,"Complex | BigNumber":e=>e.cos()},t)})),Zl="cosh",Vl=te(Zl,["typed"],(e=>{var{typed:r}=e;return r(Zl,{number:Ee,"Complex | BigNumber":e=>e.cosh()})})),Wl=te("cot",["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r("cot",{number:dl,Complex:e=>e.cot(),BigNumber:e=>new t(1).div(e.tan())},$l({typed:r}))})),Jl="coth",Yl=te(Jl,["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r(Jl,{number:gl,Complex:e=>e.coth(),BigNumber:e=>new t(1).div(e.tanh())})})),Xl=te("csc",["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r("csc",{number:vl,Complex:e=>e.csc(),BigNumber:e=>new t(1).div(e.sin())},$l({typed:r}))})),Ql="csch",Kl=te(Ql,["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r(Ql,{number:yl,Complex:e=>e.csch(),BigNumber:e=>new t(1).div(e.sinh())})})),ef=te("sec",["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r("sec",{number:xl,Complex:e=>e.sec(),BigNumber:e=>new t(1).div(e.cos())},$l({typed:r}))})),rf="sech",tf=te(rf,["typed","BigNumber"],(e=>{var{typed:r,BigNumber:t}=e;return r(rf,{number:bl,Complex:e=>e.sech(),BigNumber:e=>new t(1).div(e.cosh())})})),nf=te("sin",["typed"],(e=>{var{typed:r}=e,t=$l({typed:r});return r("sin",{number:Math.sin,"Complex | BigNumber":e=>e.sin()},t)})),af="sinh",of=te(af,["typed"],(e=>{var{typed:r}=e;return r(af,{number:wl,"Complex | BigNumber":e=>e.sinh()})})),sf=te("tan",["typed"],(e=>{var{typed:r}=e,t=$l({typed:r});return r("tan",{number:Math.tan,"Complex | BigNumber":e=>e.tan()},t)})),uf=te("tanh",["typed"],(e=>{var{typed:r}=e;return r("tanh",{number:Ce,"Complex | BigNumber":e=>e.tanh()})})),cf="setCartesian",lf=te(cf,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:r,size:t,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return r(cf,{"Array | Matrix, Array | Matrix":function(e,r){var s=[];if(0!==n(t(e),new a(0))&&0!==n(t(r),new a(0))){var u=Xe(Array.isArray(e)?e:e.toArray()).sort(i),c=Xe(Array.isArray(r)?r:r.toArray()).sort(i);s=[];for(var l=0;l{var{typed:r,size:t,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return r(ff,{"Array | Matrix, Array | Matrix":function(e,r){var s;if(0===n(t(e),new a(0)))s=[];else{if(0===n(t(r),new a(0)))return Xe(e.toArray());var u,c=nr(Xe(Array.isArray(e)?e:e.toArray()).sort(i)),l=nr(Xe(Array.isArray(r)?r:r.toArray()).sort(i));s=[];for(var f=0;f{var{typed:r,size:t,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return r(mf,{"Array | Matrix":function(e){var r;if(0===n(t(e),new a(0)))r=[];else{var s=Xe(Array.isArray(e)?e:e.toArray()).sort(i);(r=[]).push(s[0]);for(var u=1;u{var{typed:r,size:t,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return r(df,{"Array | Matrix, Array | Matrix":function(e,r){var s;if(0===n(t(e),new a(0))||0===n(t(r),new a(0)))s=[];else{var u=nr(Xe(Array.isArray(e)?e:e.toArray()).sort(i)),c=nr(Xe(Array.isArray(r)?r:r.toArray()).sort(i));s=[];for(var l=0;l{var{typed:r,size:t,subset:n,compareNatural:i,Index:a}=e;return r(vf,{"Array | Matrix, Array | Matrix":function(e,r){if(0===n(t(e),new a(0)))return!0;if(0===n(t(r),new a(0)))return!1;for(var o,s=nr(Xe(Array.isArray(e)?e:e.toArray()).sort(i)),u=nr(Xe(Array.isArray(r)?r:r.toArray()).sort(i)),c=0;c{var{typed:r,size:t,subset:n,compareNatural:i,Index:a}=e;return r(xf,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,r){if(0===n(t(r),new a(0)))return 0;for(var o=Xe(Array.isArray(r)?r:r.toArray()),s=0,u=0;u{var{typed:r,size:t,subset:n,compareNatural:i,Index:a}=e;return r(wf,{"Array | Matrix":function(e){if(0===n(t(e),new a(0)))return[];for(var r=Xe(Array.isArray(e)?e:e.toArray()).sort(i),s=[],u=0;u.toString(2).length<=r.length;)s.push(o(r,u.toString(2).split("").reverse())),u++;return function(e){for(var r=[],t=e.length-1;t>0;t--)for(var n=0;ne[n+1].length&&(r=e[n],e[n]=e[n+1],e[n+1]=r);return e}(s)}});function o(e,r){for(var t=[],n=0;n{var{typed:r,compareNatural:t}=e;return r(Df,{"Array | Matrix":function(e){return Array.isArray(e)?Xe(e).length:Xe(e.toArray()).length},"Array | Matrix, boolean":function(e,r){if(!1===r||0===e.length)return Array.isArray(e)?Xe(e).length:Xe(e.toArray()).length;for(var n=Xe(Array.isArray(e)?e:e.toArray()).sort(t),i=1,a=1;a{var{typed:r,size:t,concat:n,subset:i,setDifference:a,Index:o}=e;return r(Af,{"Array | Matrix, Array | Matrix":function(e,r){if(0===i(t(e),new o(0)))return Xe(r);if(0===i(t(r),new o(0)))return Xe(e);var s=Xe(e),u=Xe(r);return n(a(s,u),a(u,s))}})})),Sf="setUnion",Mf=te(Sf,["typed","size","concat","subset","setIntersect","setSymDifference","Index"],(e=>{var{typed:r,size:t,concat:n,subset:i,setIntersect:a,setSymDifference:o,Index:s}=e;return r(Sf,{"Array | Matrix, Array | Matrix":function(e,r){if(0===i(t(e),new s(0)))return Xe(r);if(0===i(t(r),new s(0)))return Xe(e);var u=Xe(e),c=Xe(r);return n(o(u,c),a(u,c))}})})),Ff=te("add",["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],(e=>{var{typed:r,matrix:t,addScalar:n,equalScalar:i,DenseMatrix:a,SparseMatrix:o}=e,s=Ca({typed:r}),u=Sa({typed:r,equalScalar:i}),c=Ma({typed:r,DenseMatrix:a}),l=Ta({typed:r,matrix:t});return r("add",{"any, any":n,"any, any, ...any":r.referToSelf((e=>(r,t,n)=>{for(var i=e(r,t),a=0;a{var{typed:r,abs:t,addScalar:n,divideScalar:i,multiplyScalar:a,sqrt:s,smaller:u,isPositive:c}=e;return r(Tf,{"... number | BigNumber":l,Array:l,Matrix:e=>l(Xe(e.toArray()))});function l(e){for(var r=0,l=0,f=0;f{var{typed:r,abs:t,add:n,pow:i,conj:a,sqrt:o,multiply:s,equalScalar:u,larger:c,smaller:l,matrix:f,ctranspose:p,eigs:m}=e;return r(Bf,{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 g(f(e),2)},Matrix:function(e){return g(e,2)},"Array, number | BigNumber | string":function(e,r){return g(f(e),r)},"Matrix, number | BigNumber | string":function(e,r){return g(e,r)}});function h(e,r){if(r===Number.POSITIVE_INFINITY||"inf"===r)return function(e){var r=0;return e.forEach((function(e){var n=t(e);c(n,r)&&(r=n)}),!0),r}(e);if(r===Number.NEGATIVE_INFINITY||"-inf"===r)return function(e){var r;return e.forEach((function(e){var n=t(e);r&&!l(n,r)||(r=n)}),!0),r||0}(e);if("fro"===r)return g(e,2);if("number"==typeof r&&!isNaN(r)){if(!u(r,0)){var a=0;return e.forEach((function(e){a=n(i(t(e),r),a)}),!0),i(a,1/r)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}function d(e,r){if(1===r)return function(e){var r=[],i=0;return e.forEach((function(e,a){var o=a[1],s=n(r[o]||0,t(e));c(s,i)&&(i=s),r[o]=s}),!0),i}(e);if(r===Number.POSITIVE_INFINITY||"inf"===r)return function(e){var r=[],i=0;return e.forEach((function(e,a){var o=a[0],s=n(r[o]||0,t(e));c(s,i)&&(i=s),r[o]=s}),!0),i}(e);if("fro"===r)return function(e){var r=0;return e.forEach((function(e,t){r=n(r,s(e,a(e)))})),t(o(r))}(e);if(2===r)return function(e){var r=e.size();if(r[0]!==r[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 t(o(u))}(e);throw new Error("Unsupported parameter value "+r)}function g(e,r){var t=e.size();if(1===t.length)return h(e,r);if(2===t.length){if(t[0]&&t[1])return d(e,r);throw new RangeError("Invalid matrix dimensions")}}})),zf=te("dot",["typed","addScalar","multiplyScalar","conj","size"],(e=>{var{typed:r,addScalar:t,multiplyScalar:n,conj:i,size:a}=e;return r("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,g=t,v=n;if(l&&m&&l===m&&"string"==typeof l){var y=l;g=r.find(t,[y,y]),v=r.find(n,[y,y])}if(!h&&!d){for(var x=v(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,r){var t,n,i=s(e),a=s(r);if(1===i.length)t=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(", ")+")");t=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(t!==n)throw new RangeError("Vectors must have equal length ("+t+" != "+n+")");if(0===t)throw new RangeError("Cannot calculate the dot product of empty vectors");return t}function s(e){return f(e)?e.size():a(e)}})),qf=te("trace",["typed","matrix","add"],(e=>{var{typed:r,matrix:t,add:n}=e;return r("trace",{Array:function(e){return i(t(e))},SparseMatrix:function(e){var r=e._values,t=e._index,i=e._ptr,a=e._size,o=a[0],s=a[1];if(o===s){var u=0;if(r.length>0)for(var c=0;cc)break}return u}throw new RangeError("Matrix must be square (size: "+Oe(a)+")")},DenseMatrix:i,any:G});function i(e){var r=e._size,t=e._data;switch(r.length){case 1:if(1===r[0])return G(t[0]);throw new RangeError("Matrix must be square (size: "+Oe(r)+")");case 2:var i=r[0];if(i===r[1]){for(var a=0,o=0;o{var{typed:r,Index:t}=e;return r(kf,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var r=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 t;return t.apply(n,r),n}})})),Rf=new Set(["end"]),Pf=te("Node",["mathWithTransform"],(e=>{var{mathWithTransform:r}=e;return class{get type(){return"Node"}get isNode(){return!0}evaluate(e){return this.compile().evaluate(e)}compile(){var e=this._compile(r,{}),t={};return{evaluate:function(r){var n=Dr(r);return function(e){for(var r of[...Rf])if(e.has(r))throw new Error('Scope contains an illegal symbol, "'+r+'" is a reserved keyword')}(n),e(n,t,null)}}}_compile(e,r){throw new Error("Method _compile must be implemented by type "+this.type)}forEach(e){throw new Error("Cannot run forEach on a Node interface")}map(e){throw new Error("Cannot run map on a Node interface")}_ifNode(e){if(!k(e))throw new TypeError("Callback function must return a Node");return e}traverse(e){e(this,null,null),function e(r,t){r.forEach((function(r,n,i){t(r,n,i),e(r,t)}))}(this,e)}transform(e){return function r(t,n,i){var a=e(t,n,i);return a!==t?a:t.map(r)}(this,null,null)}filter(e){var r=[];return this.traverse((function(t,n,i){e(t,n,i)&&r.push(t)})),r}clone(){throw new Error("Cannot clone a Node interface")}cloneDeep(){return this.map((function(e){return e.cloneDeep()}))}equals(e){return!!e&&(this.type===e.type&&J(this,e))}toString(e){var r=this._getCustomString(e);return void 0!==r?r:this._toString(e)}toJSON(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)}toHTML(e){var r=this._getCustomString(e);return void 0!==r?r:this.toHTML(e)}_toString(){throw new Error("_toString not implemented for "+this.type)}toTex(e){var r=this._getCustomString(e);return void 0!==r?r:this._toTex(e)}_toTex(e){throw new Error("_toTex not implemented for "+this.type)}_getCustomString(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")}}getIdentifier(){return this.type}getContent(){return this}}}),{isClass:!0,isNode:!0});function jf(e){return e&&e.isIndexError?new Ie(e.index+1,e.min+1,void 0!==e.max?e.max+1:void 0):e}function Uf(e){var{subset:r}=e;return function(e,t){try{if(Array.isArray(e))return r(e,t);if(e&&"function"==typeof e.subset)return e.subset(t);if("string"==typeof e)return r(e,t);if("object"==typeof e){if(!t.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return hr(e,t.getObjectProperty())}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw jf(e)}}}var Lf="AccessorNode",Hf=te(Lf,["subset","Node"],(e=>{var{subset:r,Node:t}=e,n=Uf({subset:r});function i(e){return!(C(e)||S(e)||O(e)||z(e)||I(e)||P(e)||L(e))}class a extends t{constructor(e,r){if(super(),!k(e))throw new TypeError('Node expected for parameter "object"');if(!q(r))throw new TypeError('IndexNode expected for parameter "index"');this.object=e,this.index=r}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return Lf}get isAccessorNode(){return!0}_compile(e,r){var t=this.object._compile(e,r),i=this.index._compile(e,r);if(this.index.isObjectProperty()){var a=this.index.getObjectProperty();return function(e,r,n){return hr(t(e,r,n),a)}}return function(e,r,a){var o=t(e,r,a),s=i(e,r,o);return n(o,s)}}forEach(e){e(this.object,"object",this),e(this.index,"index",this)}map(e){return new a(this._ifNode(e(this.object,"object",this)),this._ifNode(e(this.index,"index",this)))}clone(){return new a(this.object,this.index)}_toString(e){var r=this.object.toString(e);return i(this.object)&&(r="("+r+")"),r+this.index.toString(e)}toHTML(e){var r=this.object.toHTML(e);return i(this.object)&&(r='('+r+')'),r+this.index.toHTML(e)}_toTex(e){var r=this.object.toTex(e);return i(this.object)&&(r="\\left(' + object + '\\right)"),r+this.index.toTex(e)}toJSON(){return{mathjs:Lf,object:this.object,index:this.index}}static fromJSON(e){return new a(e.object,e.index)}}return Lc(a,"name",Lf),a}),{isClass:!0,isNode:!0}),$f="ArrayNode",Gf=te($f,["Node"],(e=>{var{Node:r}=e;class t extends r{constructor(e){if(super(),this.items=e||[],!Array.isArray(this.items)||!this.items.every(k))throw new TypeError("Array containing Nodes expected")}get type(){return $f}get isArrayNode(){return!0}_compile(e,r){var t=Qe(this.items,(function(t){return t._compile(e,r)}));if("Array"!==e.config.matrix){var n=e.matrix;return function(e,r,i){return n(Qe(t,(function(t){return t(e,r,i)})))}}return function(e,r,n){return Qe(t,(function(t){return t(e,r,n)}))}}forEach(e){for(var r=0;r['+this.items.map((function(r){return r.toHTML(e)})).join(',')+']'}_toTex(e){return function r(t,n){var i=t.some(S)&&!t.every(S),a=n||i,o=a?"&":"\\\\",s=t.map((function(t){return t.items?r(t.items,!n):t.toTex(e)})).join(o);return i||!a||a&&!n?"\\begin{bmatrix}"+s+"\\end{bmatrix}":s}(this.items,!1)}}return Lc(t,"name",$f),t}),{isClass:!0,isNode:!0});var Zf=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{op:"or",associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{op:"xor",associativity:"left",associativeWith:[]}},{"OperatorNode:and":{op:"and",associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{op:"|",associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{op:"^|",associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{op:"&",associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{op:"==",associativity:"left",associativeWith:[]},"OperatorNode:unequal":{op:"!=",associativity:"left",associativeWith:[]},"OperatorNode:smaller":{op:"<",associativity:"left",associativeWith:[]},"OperatorNode:larger":{op:">",associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{op:"<=",associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{op:">=",associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{op:"<<",associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{op:">>",associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{op:">>>",associativity:"left",associativeWith:[]}},{"OperatorNode:to":{op:"to",associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{op:"+",associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{op:"-",associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{op:"*",associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{op:"/",associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{op:".*",associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{op:"./",associativity:"left",associativeWith:[]},"OperatorNode:mod":{op:"mod",associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]}},{"OperatorNode:unaryPlus":{op:"+",associativity:"right"},"OperatorNode:unaryMinus":{op:"-",associativity:"right"},"OperatorNode:bitNot":{op:"~",associativity:"right"},"OperatorNode:not":{op:"not",associativity:"right"}},{"OperatorNode:pow":{op:"^",associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{op:".^",associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{op:"!",associativity:"left"}},{"OperatorNode:ctranspose":{op:"'",associativity:"left"}}];function Vf(e,r){if(!r||"auto"!==r)return e;for(var t=e;P(t);)t=t.content;return t}function Wf(e,r,t,n){var i=e;"keep"!==r&&(i=e.getContent());for(var a=i.getIdentifier(),o=null,s=0;s{var{subset:r,matrix:t,Node:n}=e,i=Uf({subset:r}),a=function(e){var{subset:r,matrix:t}=e;return function(e,n,i){try{if(Array.isArray(e))return t(e).subset(n,i).valueOf();if(e&&"function"==typeof e.subset)return e.subset(n,i);if("string"==typeof e)return r(e,n,i);if("object"==typeof e){if(!n.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return dr(e,n.getObjectProperty(),i),e}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw jf(e)}}}({subset:r,matrix:t});function o(e,r,t){r||(r="keep");var n=Wf(e,r,t),i=Wf(e.value,r,t);return"all"===r||null!==i&&i<=n}class s extends n{constructor(e,r,t){if(super(),this.object=e,this.index=t?r:null,this.value=t||r,!L(e)&&!C(e))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(L(e)&&"end"===e.name)throw new Error('Cannot assign to symbol "end"');if(this.index&&!q(this.index))throw new TypeError('IndexNode expected as "index"');if(!k(this.value))throw new TypeError('Node expected as "value"')}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return Qf}get isAssignmentNode(){return!0}_compile(e,r){var t=this.object._compile(e,r),n=this.index?this.index._compile(e,r):null,o=this.value._compile(e,r),s=this.object.name;if(this.index){if(this.index.isObjectProperty()){var u=this.index.getObjectProperty();return function(e,r,n){var i=t(e,r,n),a=o(e,r,n);return dr(i,u,a),a}}if(L(this.object))return function(e,r,i){var u=t(e,r,i),c=o(e,r,i),l=n(e,r,u);return e.set(s,a(u,l,c)),c};var c=this.object.object._compile(e,r);if(this.object.index.isObjectProperty()){var l=this.object.index.getObjectProperty();return function(e,r,t){var i=c(e,r,t),s=hr(i,l),u=n(e,r,s),f=o(e,r,t);return dr(i,l,a(s,u,f)),f}}var f=this.object.index._compile(e,r);return function(e,r,t){var s=c(e,r,t),u=f(e,r,s),l=i(s,u),p=n(e,r,l),m=o(e,r,t);return a(s,u,a(l,p,m)),m}}if(!L(this.object))throw new TypeError("SymbolNode expected as object");return function(e,r,t){var n=o(e,r,t);return e.set(s,n),n}}forEach(e){e(this.object,"object",this),this.index&&e(this.index,"index",this),e(this.value,"value",this)}map(e){var r=this._ifNode(e(this.object,"object",this)),t=this.index?this._ifNode(e(this.index,"index",this)):null,n=this._ifNode(e(this.value,"value",this));return new s(r,t,n)}clone(){return new s(this.object,this.index,this.value)}_toString(e){var r=this.object.toString(e),t=this.index?this.index.toString(e):"",n=this.value.toString(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(n="("+n+")"),r+t+" = "+n}toJSON(){return{mathjs:Qf,object:this.object,index:this.index,value:this.value}}static fromJSON(e){return new s(e.object,e.index,e.value)}toHTML(e){var r=this.object.toHTML(e),t=this.index?this.index.toHTML(e):"",n=this.value.toHTML(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(n='('+n+')'),r+t+'='+n}_toTex(e){var r=this.object.toTex(e),t=this.index?this.index.toTex(e):"",n=this.value.toTex(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(n="\\left(".concat(n,"\\right)")),r+t+":="+n}}return Lc(s,"name",Qf),s}),{isClass:!0,isNode:!0}),ep="BlockNode",rp=te(ep,["ResultSet","Node"],(e=>{var{ResultSet:r,Node:t}=e;class n extends t{constructor(e){if(super(),!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map((function(e){var r=e&&e.node,t=!e||void 0===e.visible||e.visible;if(!k(r))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof t)throw new TypeError('Property "visible" must be a boolean');return{node:r,visible:t}}))}get type(){return ep}get isBlockNode(){return!0}_compile(e,t){var n=Qe(this.blocks,(function(r){return{evaluate:r.node._compile(e,t),visible:r.visible}}));return function(e,t,i){var a=[];return Ke(n,(function(r){var n=r.evaluate(e,t,i);r.visible&&a.push(n)})),new r(a)}}forEach(e){for(var r=0;r;')})).join('
')}_toTex(e){return this.blocks.map((function(r){return r.node.toTex(e)+(r.visible?"":";")})).join("\\;\\;\n")}}return Lc(n,"name",ep),n}),{isClass:!0,isNode:!0}),tp="ConditionalNode",np=te(tp,["Node"],(e=>{var{Node:r}=e;class t extends r{constructor(e,r,t){if(super(),!k(e))throw new TypeError("Parameter condition must be a Node");if(!k(r))throw new TypeError("Parameter trueExpr must be a Node");if(!k(t))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=r,this.falseExpr=t}get type(){return tp}get isConditionalNode(){return!0}_compile(e,r){var t=this.condition._compile(e,r),n=this.trueExpr._compile(e,r),i=this.falseExpr._compile(e,r);return function(e,r,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 "'+$(e)+'"')}(t(e,r,s))?n(e,r,s):i(e,r,s)}}forEach(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)}map(e){return new t(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))}clone(){return new t(this.condition,this.trueExpr,this.falseExpr)}_toString(e){var r=e&&e.parenthesis?e.parenthesis:"keep",t=Wf(this,r,e&&e.implicit),n=this.condition.toString(e),i=Wf(this.condition,r,e&&e.implicit);("all"===r||"OperatorNode"===this.condition.type||null!==i&&i<=t)&&(n="("+n+")");var a=this.trueExpr.toString(e),o=Wf(this.trueExpr,r,e&&e.implicit);("all"===r||"OperatorNode"===this.trueExpr.type||null!==o&&o<=t)&&(a="("+a+")");var s=this.falseExpr.toString(e),u=Wf(this.falseExpr,r,e&&e.implicit);return("all"===r||"OperatorNode"===this.falseExpr.type||null!==u&&u<=t)&&(s="("+s+")"),n+" ? "+a+" : "+s}toJSON(){return{mathjs:tp,condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}}static fromJSON(e){return new t(e.condition,e.trueExpr,e.falseExpr)}toHTML(e){var r=e&&e.parenthesis?e.parenthesis:"keep",t=Wf(this,r,e&&e.implicit),n=this.condition.toHTML(e),i=Wf(this.condition,r,e&&e.implicit);("all"===r||"OperatorNode"===this.condition.type||null!==i&&i<=t)&&(n='('+n+')');var a=this.trueExpr.toHTML(e),o=Wf(this.trueExpr,r,e&&e.implicit);("all"===r||"OperatorNode"===this.trueExpr.type||null!==o&&o<=t)&&(a='('+a+')');var s=this.falseExpr.toHTML(e),u=Wf(this.falseExpr,r,e&&e.implicit);return("all"===r||"OperatorNode"===this.falseExpr.type||null!==u&&u<=t)&&(s='('+s+')'),n+'?'+a+':'+s}_toTex(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"}}return Lc(t,"name",tp),t}),{isClass:!0,isNode:!0}),ip=t(7928),ap={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{?}"},op={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"},sp={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(op.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(op.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(op.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(op.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(op.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(op.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(op.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(op.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(op.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(op.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(op.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(op.bitAnd,"${args[1]}\\right)")},bitNot:{1:op.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(op.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(op.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(op.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(op.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(op.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(op.and,"${args[1]}\\right)")},not:{1:op.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(op.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(op.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(op.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},pinv:{1:"\\left(${args[0]}\\right)^{+}"},sqrtm:{1:"{${args[0]}}".concat(op.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(op.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(op.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(op.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(op.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(op.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(op.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(op.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(op.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(op.to,"${args[1]}\\right)")},numeric:function(e,r){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(ap.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)"}},up={deg:"^\\circ"};function cp(e){return ip(e,{preserveFormatting:!0})}function lp(e,r){return(r=void 0!==r&&r)?K(up,e)?up[e]:"\\mathrm{"+cp(e)+"}":K(ap,e)?ap[e]:cp(e)}var fp="ConstantNode",pp=te(fp,["Node"],(e=>{var{Node:r}=e;class t extends r{constructor(e){super(),this.value=e}get type(){return fp}get isConstantNode(){return!0}_compile(e,r){var t=this.value;return function(){return t}}forEach(e){}map(e){return this.clone()}clone(){return new t(this.value)}_toString(e){return Oe(this.value,e)}toHTML(e){var r=this._toString(e);switch($(this.value)){case"number":case"BigNumber":case"Fraction":return''+r+"";case"string":return''+r+"";case"boolean":return''+r+"";case"null":return''+r+"";case"undefined":return''+r+"";default:return''+r+""}}toJSON(){return{mathjs:fp,value:this.value}}static fromJSON(e){return new t(e.value)}_toTex(e){var r=this._toString(e);switch($(this.value)){case"string":return"\\mathtt{"+cp(r)+"}";case"number":case"BigNumber":if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var t=r.toLowerCase().indexOf("e");return-1!==t?r.substring(0,t)+"\\cdot10^{"+r.substring(t+1)+"}":r;case"Fraction":return this.value.toLatex();default:return r}}}return Lc(t,"name",fp),t}),{isClass:!0,isNode:!0}),mp="FunctionAssignmentNode",hp=te(mp,["typed","Node"],(e=>{var{typed:r,Node:t}=e;function n(e,r,t){var n=Wf(e,r,t),i=Wf(e.expr,r,t);return"all"===r||null!==i&&i<=n}class i extends t{constructor(e,r,t){if(super(),"string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(r))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!k(t))throw new TypeError('Node expected for parameter "expr"');if(Rf.has(e))throw new Error('Illegal function name, "'+e+'" is a reserved keyword');this.name=e,this.params=r.map((function(e){return e&&e.name||e})),this.types=r.map((function(e){return e&&e.type||"any"})),this.expr=t}get type(){return mp}get isFunctionAssignmentNode(){return!0}_compile(e,t){var n=Object.create(t);Ke(this.params,(function(e){n[e]=!0}));var i=this.expr._compile(e,n),a=this.name,o=this.params,s=tr(this.types,","),u=a+"("+tr(this.params,", ")+")";return function(e,t,n){var c={};c[s]=function(){for(var r=Object.create(t),a=0;a'+_e(this.params[i])+"");var a=this.expr.toHTML(e);return n(this,r,e&&e.implicit)&&(a='('+a+')'),''+_e(this.name)+'('+t.join(',')+')='+a}_toTex(e){var r=e&&e.parenthesis?e.parenthesis:"keep",t=this.expr.toTex(e);return n(this,r,e&&e.implicit)&&(t="\\left(".concat(t,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(lp).join(",")+"\\right):="+t}}return Lc(i,"name",mp),i}),{isClass:!0,isNode:!0}),dp="IndexNode",gp=te(dp,["Node","size"],(e=>{var{Node:r,size:t}=e;class n extends r{constructor(e,r){if(super(),this.dimensions=e,this.dotNotation=r||!1,!Array.isArray(e)||!e.every(k))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}get type(){return dp}get isIndexNode(){return!0}_compile(e,r){var n=Qe(this.dimensions,(function(n,i){if(n.filter((e=>e.isSymbolNode&&"end"===e.name)).length>0){var a=Object.create(r);a.end=!0;var o=n._compile(e,a);return function(e,r,n){if(!f(n)&&!l(n)&&!c(n))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+$(n));var a=t(n).valueOf(),s=Object.create(r);return s.end=a[i],o(e,s,n)}}return n._compile(e,r)})),i=hr(e,"index");return function(e,r,t){var a=Qe(n,(function(n){return n(e,r,t)}));return i(...a)}}forEach(e){for(var r=0;r.'+_e(this.getObjectProperty())+"":'['+r.join(',')+']'}_toTex(e){var r=this.dimensions.map((function(r){return r.toTex(e)}));return this.dotNotation?"."+this.getObjectProperty():"_{"+r.join(",")+"}"}}return Lc(n,"name",dp),n}),{isClass:!0,isNode:!0}),vp="ObjectNode",yp=te(vp,["Node"],(e=>{var{Node:r}=e;class t extends r{constructor(e){if(super(),this.properties=e||{},e&&("object"!=typeof e||!Object.keys(e).every((function(r){return k(e[r])}))))throw new TypeError("Object containing Nodes expected")}get type(){return vp}get isObjectNode(){return!0}_compile(e,r){var t={};for(var n in this.properties)if(K(this.properties,n)){var i=Be(n),a=JSON.parse(i);if(!gr(this.properties,a))throw new Error('No access to property "'+a+'"');t[a]=this.properties[n]._compile(e,r)}return function(e,r,n){var i={};for(var a in t)K(t,a)&&(i[a]=t[a](e,r,n));return i}}forEach(e){for(var r in this.properties)K(this.properties,r)&&e(this.properties[r],"properties["+Be(r)+"]",this)}map(e){var r={};for(var n in this.properties)K(this.properties,n)&&(r[n]=this._ifNode(e(this.properties[n],"properties["+Be(n)+"]",this)));return new t(r)}clone(){var e={};for(var r in this.properties)K(this.properties,r)&&(e[r]=this.properties[r]);return new t(e)}_toString(e){var r=[];for(var t in this.properties)K(this.properties,t)&&r.push(Be(t)+": "+this.properties[t].toString(e));return"{"+r.join(", ")+"}"}toJSON(){return{mathjs:vp,properties:this.properties}}static fromJSON(e){return new t(e.properties)}toHTML(e){var r=[];for(var t in this.properties)K(this.properties,t)&&r.push(''+_e(t)+':'+this.properties[t].toHTML(e));return'{'+r.join(',')+'}'}_toTex(e){var r=[];for(var t in this.properties)K(this.properties,t)&&r.push("\\mathbf{"+t+":} & "+this.properties[t].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}"+r.join("\n")+"\\end{array}\\right\\}"}}return Lc(t,"name",vp),t}),{isClass:!0,isNode:!0}),xp="OperatorNode",bp=te(xp,["Node"],(e=>{var{Node:r}=e;function t(e,r){var n=e;if("auto"===r)for(;P(n);)n=n.content;return!!O(n)||!!R(n)&&t(n.args[0],r)}function n(e,r,n,i,a){var o,s=Wf(e,r,n),u=Jf(e,r);if("all"===r||i.length>2&&"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier())return i.map((function(e){switch(e.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}}));switch(i.length){case 0:o=[];break;case 1:var c=Wf(i[0],r,n,e);if(a&&null!==c){var l,f;if("keep"===r?(l=i[0].getIdentifier(),f=e.getIdentifier()):(l=i[0].getContent().getIdentifier(),f=e.getContent().getIdentifier()),!1===Zf[s][f].latexLeftParens){o=[!1];break}if(!1===Zf[c][l].latexParens){o=[!1];break}}if(null===c){o=[!1];break}if(c<=s){o=[!0];break}o=[!1];break;case 2:var p,m,h=Wf(i[0],r,n,e),d=Yf(e,i[0],r);p=null!==h&&(h===s&&"right"===u&&!d||h=2&&"OperatorNode:multiply"===e.getIdentifier()&&e.implicit&&"all"!==r&&"hide"===n)for(var w=1;w2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var f=i.map((function(r,t){return r=r.toString(e),a[t]&&(r="("+r+")"),r}));return this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===t?f.join(" "):f.join(" "+this.op+" ")}return this.fn+"("+this.args.join(", ")+")"}toJSON(){return{mathjs:xp,op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}}static fromJSON(e){return new i(e.op,e.fn,e.args,e.implicit,e.isPercentage)}toHTML(e){var r=e&&e.parenthesis?e.parenthesis:"keep",t=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,r,t,i,!1);if(1===i.length){var o=Jf(this,r),s=i[0].toHTML(e);return a[0]&&(s='('+s+')'),"right"===o?''+_e(this.op)+""+s:s+''+_e(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"===t?u+''+c:u+''+_e(this.op)+""+c}var l=i.map((function(r,t){return r=r.toHTML(e),a[t]&&(r='('+r+')'),r}));return i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())?this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===t?l.join(''):l.join(''+_e(this.op)+""):''+_e(this.fn)+'('+l.join(',')+')'}_toTex(e){var r=e&&e.parenthesis?e.parenthesis:"keep",t=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,r,t,i,!0),o=op[this.fn];if(o=void 0===o?this.op:o,1===i.length){var s=Jf(this,r),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"===r?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"===t)return l+"~"+p}return l+o+p}if(i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var m=i.map((function(r,t){return r=r.toTex(e),a[t]&&(r="\\left(".concat(r,"\\right)")),r}));return"OperatorNode:multiply"===this.getIdentifier()&&this.implicit&&"hide"===t?m.join("~"):m.join(o)}return"\\mathrm{"+this.fn+"}\\left("+i.map((function(r){return r.toTex(e)})).join(",")+"\\right)"}getIdentifier(){return this.type+":"+this.fn}}return Lc(i,"name",xp),i}),{isClass:!0,isNode:!0}),wp="ParenthesisNode",Np=te(wp,["Node"],(e=>{var{Node:r}=e;class t extends r{constructor(e){if(super(),!k(e))throw new TypeError('Node expected for parameter "content"');this.content=e}get type(){return wp}get isParenthesisNode(){return!0}_compile(e,r){return this.content._compile(e,r)}getContent(){return this.content.getContent()}forEach(e){e(this.content,"content",this)}map(e){var r=e(this.content,"content",this);return new t(r)}clone(){return new t(this.content)}_toString(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)}toJSON(){return{mathjs:wp,content:this.content}}static fromJSON(e){return new t(e.content)}toHTML(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?'('+this.content.toHTML(e)+')':this.content.toHTML(e)}_toTex(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)}}return Lc(t,"name",wp),t}),{isClass:!0,isNode:!0}),Dp="RangeNode",Ep=te(Dp,["Node"],(e=>{var{Node:r}=e;function t(e,r,t){var n=Wf(e,r,t),i={},a=Wf(e.start,r,t);if(i.start=null!==a&&a<=n||"all"===r,e.step){var o=Wf(e.step,r,t);i.step=null!==o&&o<=n||"all"===r}var s=Wf(e.end,r,t);return i.end=null!==s&&s<=n||"all"===r,i}class n extends r{constructor(e,r,t){if(super(),!k(e))throw new TypeError("Node expected");if(!k(r))throw new TypeError("Node expected");if(t&&!k(t))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=e,this.end=r,this.step=t||null}get type(){return Dp}get isRangeNode(){return!0}needsEnd(){return this.filter((function(e){return L(e)&&"end"===e.name})).length>0}_compile(e,r){var t=e.range,n=this.start._compile(e,r),i=this.end._compile(e,r);if(this.step){var a=this.step._compile(e,r);return function(e,r,o){return t(n(e,r,o),i(e,r,o),a(e,r,o))}}return function(e,r,a){return t(n(e,r,a),i(e,r,a))}}forEach(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)}map(e){return new n(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))}clone(){return new n(this.start,this.end,this.step&&this.step)}_toString(e){var r,n=t(this,e&&e.parenthesis?e.parenthesis:"keep",e&&e.implicit),i=this.start.toString(e);if(n.start&&(i="("+i+")"),r=i,this.step){var a=this.step.toString(e);n.step&&(a="("+a+")"),r+=":"+a}var o=this.end.toString(e);return n.end&&(o="("+o+")"),r+=":"+o}toJSON(){return{mathjs:Dp,start:this.start,end:this.end,step:this.step}}static fromJSON(e){return new n(e.start,e.end,e.step)}toHTML(e){var r,n=t(this,e&&e.parenthesis?e.parenthesis:"keep",e&&e.implicit),i=this.start.toHTML(e);if(n.start&&(i='('+i+')'),r=i,this.step){var a=this.step.toHTML(e);n.step&&(a='('+a+')'),r+=':'+a}var o=this.end.toHTML(e);return n.end&&(o='('+o+')'),r+=':'+o}_toTex(e){var r=t(this,e&&e.parenthesis?e.parenthesis:"keep",e&&e.implicit),n=this.start.toTex(e);if(r.start&&(n="\\left(".concat(n,"\\right)")),this.step){var i=this.step.toTex(e);r.step&&(i="\\left(".concat(i,"\\right)")),n+=":"+i}var a=this.end.toTex(e);return r.end&&(a="\\left(".concat(a,"\\right)")),n+=":"+a}}return Lc(n,"name",Dp),n}),{isClass:!0,isNode:!0}),Ap="RelationalNode",Cp=te(Ap,["Node"],(e=>{var{Node:r}=e,t={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="};class n extends r{constructor(e,r){if(super(),!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(r))throw new TypeError("Parameter params must be an array");if(e.length!==r.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=r}get type(){return Ap}get isRelationalNode(){return!0}_compile(e,r){var t=this,n=this.params.map((t=>t._compile(e,r)));return function(r,i,a){for(var o,s=n[0](r,i,a),u=0;ue(r,"params["+t+"]",this)),this)}map(e){return new n(this.conditionals.slice(),this.params.map(((r,t)=>this._ifNode(e(r,"params["+t+"]",this))),this))}clone(){return new n(this.conditionals,this.params)}_toString(e){for(var r=e&&e.parenthesis?e.parenthesis:"keep",n=Wf(this,r,e&&e.implicit),i=this.params.map((function(t,i){var a=Wf(t,r,e&&e.implicit);return"all"===r||null!==a&&a<=n?"("+t.toString(e)+")":t.toString(e)})),a=i[0],o=0;o('+t.toHTML(e)+')':t.toHTML(e)})),a=i[0],o=0;o'+_e(t[this.conditionals[o]])+""+i[o+1];return a}_toTex(e){for(var r=e&&e.parenthesis?e.parenthesis:"keep",t=Wf(this,r,e&&e.implicit),n=this.params.map((function(n,i){var a=Wf(n,r,e&&e.implicit);return"all"===r||null!==a&&a<=t?"\\left("+n.toTex(e)+"\right)":n.toTex(e)})),i=n[0],a=0;a{var{math:r,Unit:t,Node:n}=e;function i(e){return!!t&&t.isValuelessUnit(e)}class a extends n{constructor(e){if(super(),"string"!=typeof e)throw new TypeError('String expected for parameter "name"');this.name=e}get type(){return"SymbolNode"}get isSymbolNode(){return!0}_compile(e,r){var n=this.name;if(!0===r[n])return function(e,r,t){return r[n]};if(n in e)return function(r,t,i){return r.has(n)?r.get(n):hr(e,n)};var o=i(n);return function(e,r,i){return e.has(n)?e.get(n):o?new t(null,n):a.onUndefinedSymbol(n)}}forEach(e){}map(e){return this.clone()}static onUndefinedSymbol(e){throw new Error("Undefined symbol "+e)}clone(){return new a(this.name)}_toString(e){return this.name}toHTML(e){var r=_e(this.name);return"true"===r||"false"===r?''+r+"":"i"===r?''+r+"":"Infinity"===r?''+r+"":"NaN"===r?''+r+"":"null"===r?''+r+"":"undefined"===r?''+r+"":''+r+""}toJSON(){return{mathjs:"SymbolNode",name:this.name}}static fromJSON(e){return new a(e.name)}_toTex(e){var t=!1;void 0===r[this.name]&&i(this.name)&&(t=!0);var n=lp(this.name,t);return"\\"===n[0]?n:" "+n}}return a}),{isClass:!0,isNode:!0});function Mp(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n{var{math:r,Node:t,SymbolNode:n}=e,i=e=>Oe(e,{truncate:78});function a(e,r,t){for(var n,i="",a=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,o=0;null!==(n=a.exec(e));)if(i+=e.substring(o,n.index),o=n.index,"$$"===n[0])i+="$",o++;else{o+=n[0].length;var s=r[n[1]];if(!s)throw new ReferenceError("Template: Property "+n[1]+" does not exist.");if(void 0===n[2])switch(typeof s){case"string":i+=s;break;case"object":if(k(s))i+=s.toTex(t);else{if(!Array.isArray(s))throw new TypeError("Template: "+n[1]+" has to be a Node, String or array of Nodes");i+=s.map((function(e,r){if(k(e))return e.toTex(t);throw new TypeError("Template: "+n[1]+"["+r+"] is not a Node.")})).join(",")}break;default:throw new TypeError("Template: "+n[1]+" has to be a Node, String or array of Nodes")}else{if(!k(s[n[2]]&&s[n[2]]))throw new TypeError("Template: "+n[1]+"["+n[2]+"] is not a Node.");i+=s[n[2]].toTex(t)}}return i+=e.slice(o)}class o extends t{constructor(e,r){if(super(),"string"==typeof e&&(e=new n(e)),!k(e))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(r)||!r.every(k))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=e,this.args=r||[]}get name(){return this.fn.name||""}get type(){return Fp}get isFunctionNode(){return!0}_compile(e,r){var t=this.args.map((t=>t._compile(e,r)));if(!L(this.fn)){if(C(this.fn)&&q(this.fn.index)&&this.fn.index.isObjectProperty()){var n=this.fn.object._compile(e,r),a=this.fn.index.getObjectProperty(),s=this.args;return function(r,i,o){var u=n(r,i,o);if(function(e,r){if(!vr(e,r))throw new Error('No access to method "'+r+'"')}(u,a),u[a]&&u[a].rawArgs)return u[a](s,e,Mp(r,i),r);var c=t.map((e=>e(r,i,o)));return u[a].apply(u,c)}}var u=this.fn.toString(),c=this.fn._compile(e,r),l=this.args;return function(r,n,a){var o=c(r,n,a);if("function"!=typeof o)throw new TypeError("Expression '".concat(u,"' did not evaluate to a function; value is:")+"\n ".concat(i(o)));if(o.rawArgs)return o(l,e,Mp(r,n),r);var s=t.map((e=>e(r,n,a)));return o.apply(o,s)}}var f=this.fn.name;if(r[f]){var p=this.args;return function(r,n,a){var o=n[f];if("function"!=typeof o)throw new TypeError("Argument '".concat(f,"' was not a function; received: ").concat(i(o)));if(o.rawArgs)return o(p,e,Mp(r,n),r);var s=t.map((e=>e(r,n,a)));return o.apply(o,s)}}var m=f in e?hr(e,f):void 0,h="function"==typeof m&&!0===m.rawArgs,d=r=>{var t;if(r.has(f))t=r.get(f);else{if(!(f in e))return o.onUndefinedFunction(f);t=hr(e,f)}if("function"==typeof t)return t;throw new TypeError("'".concat(f,"' is not a function; its value is:\n ").concat(i(t)))};if(h){var g=this.args;return function(r,t,n){return d(r)(g,e,Mp(r,t),r)}}switch(t.length){case 0:return function(e,r,t){return d(e)()};case 1:return function(e,r,n){return d(e)((0,t[0])(e,r,n))};case 2:return function(e,r,n){var i=d(e),a=t[0],o=t[1];return i(a(e,r,n),o(e,r,n))};default:return function(e,r,n){return d(e)(...t.map((t=>t(e,r,n))))}}}forEach(e){e(this.fn,"fn",this);for(var r=0;r'+_e(this.fn)+'('+r.join(',')+')'}toTex(e){var r;return e&&"object"==typeof e.handler&&K(e.handler,this.name)&&(r=e.handler[this.name](this,e)),void 0!==r?r:super.toTex(e)}_toTex(e){var t,n,i=this.args.map((function(r){return r.toTex(e)}));switch(sp[this.name]&&(t=sp[this.name]),!r[this.name]||"function"!=typeof r[this.name].toTex&&"object"!=typeof r[this.name].toTex&&"string"!=typeof r[this.name].toTex||(t=r[this.name].toTex),typeof t){case"function":n=t(this,e);break;case"string":n=a(t,this,e);break;case"object":switch(typeof t[i.length]){case"function":n=t[i.length](this,e);break;case"string":n=a(t[i.length],this,e)}}return void 0!==n?n:a("\\mathrm{${name}}\\left(${args}\\right)",this,e)}getIdentifier(){return this.type+":"+this.name}}return Lc(o,"name",Fp),Lc(o,"onUndefinedFunction",(function(e){throw new Error("Undefined function "+e)})),Lc(o,"fromJSON",(function(e){return new o(e.fn,e.args)})),o}),{isClass:!0,isNode:!0}),Op="parse",Bp=te(Op,["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],(e=>{var{typed:t,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:g,RangeNode:v,RelationalNode:y,SymbolNode:x}=e,b=t(Op,{string:function(e){return Z(e,{})},"Array | Matrix":function(e){return w(e,{})},"string, Object":function(e,r){return Z(e,void 0!==r.nodes?r.nodes:{})},"Array | Matrix, Object":w});function w(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=void 0!==r.nodes?r.nodes:{};return Bn(e,(function(e){if("string"!=typeof e)throw new TypeError("String expected");return Z(e,t)}))}var N=0,D=1,E=2,A=3,S=4,M={",":!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},F={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},T={true:!0,false:!1,null:null,undefined:void 0},_=["NaN","Infinity"];function q(e,r){return e.expression.substr(e.index,r)}function k(e){return q(e,1)}function I(e){e.index++}function P(e){return e.expression.charAt(e.index-1)}function j(e){return e.expression.charAt(e.index+1)}function U(e){for(e.tokenType=N,e.token="",e.comment="";;){if("#"===k(e))for(;"\n"!==k(e)&&""!==k(e);)e.comment+=k(e),I(e);if(!b.isWhitespace(k(e),e.nestingLevel))break;I(e)}if(""!==k(e)){if("\n"===k(e)&&!e.nestingLevel)return e.tokenType=D,e.token=k(e),void I(e);var r=k(e),t=q(e,2),n=q(e,3);if(3===n.length&&M[n])return e.tokenType=D,e.token=n,I(e),I(e),void I(e);if(2===t.length&&M[t])return e.tokenType=D,e.token=t,I(e),void I(e);if(M[r])return e.tokenType=D,e.token=r,void I(e);if(b.isDigitDot(r)){e.tokenType=E;var i=q(e,2);if("0b"===i||"0o"===i||"0x"===i){for(e.token+=k(e),I(e),e.token+=k(e),I(e);b.isHexDigit(k(e));)e.token+=k(e),I(e);if("."===k(e))for(e.token+=".",I(e);b.isHexDigit(k(e));)e.token+=k(e),I(e);else if("i"===k(e))for(e.token+="i",I(e);b.isDigit(k(e));)e.token+=k(e),I(e);return}if("."===k(e)){if(e.token+=k(e),I(e),!b.isDigit(k(e)))return void(e.tokenType=D)}else{for(;b.isDigit(k(e));)e.token+=k(e),I(e);b.isDecimalMark(k(e),j(e))&&(e.token+=k(e),I(e))}for(;b.isDigit(k(e));)e.token+=k(e),I(e);if("E"===k(e)||"e"===k(e))if(b.isDigit(j(e))||"-"===j(e)||"+"===j(e)){if(e.token+=k(e),I(e),"+"!==k(e)&&"-"!==k(e)||(e.token+=k(e),I(e)),!b.isDigit(k(e)))throw de(e,'Digit expected, got "'+k(e)+'"');for(;b.isDigit(k(e));)e.token+=k(e),I(e);if(b.isDecimalMark(k(e),j(e)))throw de(e,'Digit expected, got "'+k(e)+'"')}else if("."===j(e))throw I(e),de(e,'Digit expected, got "'+k(e)+'"')}else{if(!b.isAlpha(k(e),P(e),j(e))){for(e.tokenType=S;""!==k(e);)e.token+=k(e),I(e);throw de(e,'Syntax error in part "'+e.token+'"')}for(;b.isAlpha(k(e),P(e),j(e))||b.isDigit(k(e));)e.token+=k(e),I(e);K(F,e.token)?e.tokenType=D:e.tokenType=A}}else e.tokenType=D}function H(e){do{U(e)}while("\n"===e.token)}function $(e){e.nestingLevel++}function G(e){e.nestingLevel--}function Z(e,t){var n={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:N,nestingLevel:0,conditionalLevel:null};r(n,{expression:e,extraNodes:t}),U(n);var i=function(e){var r,t,n=[];""!==e.token&&"\n"!==e.token&&";"!==e.token&&(r=V(e),e.comment&&(r.comment=e.comment));for(;"\n"===e.token||";"===e.token;)0===n.length&&r&&(t=";"!==e.token,n.push({node:r,visible:t})),U(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&(r=V(e),e.comment&&(r.comment=e.comment),t=";"!==e.token,n.push({node:r,visible:t}));return n.length>0?new u(n):(r||(r=new l(void 0),e.comment&&(r.comment=e.comment)),r)}(n);if(""!==n.token)throw n.tokenType===D?ge(n,"Unexpected operator "+n.token):de(n,'Unexpected part "'+n.token+'"');return i}function V(e){var r,t,n,i,a=function(e){var r=function(e){var r=W(e);for(;"or"===e.token;)H(e),r=new d("or","or",[r,W(e)]);return r}(e);for(;"?"===e.token;){var t=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,H(e);var n=r,i=V(e);if(":"!==e.token)throw de(e,"False part of conditional expression expected");e.conditionalLevel=null,H(e);var a=V(e);r=new c(n,i,a),e.conditionalLevel=t}return r}(e);if("="===e.token){if(L(a))return r=a.name,H(e),n=V(e),new s(new x(r),n);if(C(a))return H(e),n=V(e),new s(a.object,a.index,n);if(z(a)&&L(a.fn)&&(i=!0,t=[],r=a.name,a.args.forEach((function(e,r){L(e)?t[r]=e.name:i=!1})),i))return H(e),n=V(e),new f(r,t,n);throw de(e,"Invalid left hand side of assignment operator =")}return a}function W(e){for(var r=J(e);"xor"===e.token;)H(e),r=new d("xor","xor",[r,J(e)]);return r}function J(e){for(var r=Y(e);"and"===e.token;)H(e),r=new d("and","and",[r,Y(e)]);return r}function Y(e){for(var r=X(e);"|"===e.token;)H(e),r=new d("|","bitOr",[r,X(e)]);return r}function X(e){for(var r=Q(e);"^|"===e.token;)H(e),r=new d("^|","bitXor",[r,Q(e)]);return r}function Q(e){for(var r=ee(e);"&"===e.token;)H(e),r=new d("&","bitAnd",[r,ee(e)]);return r}function ee(e){for(var r=[re(e)],t=[],n={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};K(n,e.token);){var i={name:e.token,fn:n[e.token]};t.push(i),H(e),r.push(re(e))}return 1===r.length?r[0]:2===r.length?new d(t[0].name,t[0].fn,r):new y(t.map((e=>e.fn)),r)}function re(e){var r,t,n,i;r=te(e);for(var a={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};K(a,e.token);)n=a[t=e.token],H(e),i=[r,te(e)],r=new d(t,n,i);return r}function te(e){var r,t,n,i;r=ne(e);for(var a={to:"to",in:"to"};K(a,e.token);)n=a[t=e.token],H(e),"in"===t&&""===e.token?r=new d("*","multiply",[r,new x("in")],!0):(i=[r,ne(e)],r=new d(t,n,i));return r}function ne(e){var r,t=[];if(r=":"===e.token?new l(1):ie(e),":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(t.push(r);":"===e.token&&t.length<3;)H(e),")"===e.token||"]"===e.token||","===e.token||""===e.token?t.push(new x("end")):t.push(ie(e));r=3===t.length?new v(t[0],t[2],t[1]):new v(t[0],t[1])}return r}function ie(e){var r,t,n,i;r=ae(e);for(var a={"+":"add","-":"subtract"};K(a,e.token);){n=a[t=e.token],H(e);var o=ae(e);i=o.isPercentage?[r,new d("*","multiply",[r,o])]:[r,o],r=new d(t,n,i)}return r}function ae(e){var r,t,n,i;t=r=oe(e);for(var a={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};K(a,e.token);)i=a[n=e.token],H(e),t=oe(e),r=new d(n,i,[r,t]);return r}function oe(e){var r,t;for(t=r=se(e);e.tokenType===A||"in"===e.token&&O(r)||!(e.tokenType!==E||O(t)||R(t)&&"!"!==t.op)||"("===e.token;)t=se(e),r=new d("*","multiply",[r,t],!0);return r}function se(e){for(var t=ue(e),n=t,i=[];"/"===e.token&&B(n);){if(i.push(r({},e)),H(e),e.tokenType!==E){r(e,i.pop());break}if(i.push(r({},e)),H(e),e.tokenType!==A&&"("!==e.token){i.pop(),r(e,i.pop());break}r(e,i.pop()),i.pop(),n=ue(e),t=new d("/","divide",[t,n])}return t}function ue(e){var r,t,n,i;r=ce(e);for(var a={"%":"mod",mod:"mod"};K(a,e.token);)n=a[t=e.token],H(e),"%"===t&&e.tokenType===D&&"("!==e.token?r=new d("/","divide",[r,new l(100)],!1,!0):(i=[r,ce(e)],r=new d(t,n,i));return r}function ce(e){var r,t,a,s={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return K(s,e.token)?(a=s[e.token],r=e.token,H(e),t=[ce(e)],new d(r,a,t)):function(e){var r,t,a,s;r=function(e){var r,t,a;r=function(e){var r=[];if(e.tokenType===A&&K(e.extraNodes,e.token)){var t=e.extraNodes[e.token];if(U(e),"("===e.token){if(r=[],$(e),U(e),")"!==e.token)for(r.push(V(e));","===e.token;)U(e),r.push(V(e));if(")"!==e.token)throw de(e,"Parenthesis ) expected");G(e),U(e)}return new t(r)}return function(e){var r;if(e.tokenType===A||e.tokenType===D&&e.token in F)return r=e.token,U(e),le(e,K(T,r)?new l(T[r]):-1!==_.indexOf(r)?new l(n(r,"number")):new x(r));return function(e){var r;if('"'===e.token)return r=fe(e),le(e,new l(r));return function(e){var r;if("'"===e.token)return r=pe(e),le(e,new l(r));return function(e){var r,t,a,s;if("["===e.token){if($(e),U(e),"]"!==e.token){var u=me(e);if(";"===e.token){for(a=1,t=[u];";"===e.token;)U(e),t[a]=me(e),a++;if("]"!==e.token)throw de(e,"End of matrix ] expected");G(e),U(e),s=t[0].items.length;for(var c=1;c0},b.isDecimalMark=function(e,r){return"."===e&&"/"!==r&&"*"!==r&&"^"!==r},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"},t.addConversion({from:"string",to:"Node",convert:b}),b})),_p="compile",zp=te(_p,["typed","parse"],(e=>{var{typed:r,parse:t}=e;return r(_p,{string:function(e){return t(e).compile()},"Array | Matrix":function(e){return Bn(e,(function(e){return t(e).compile()}))}})})),qp="evaluate",kp=te(qp,["typed","parse"],(e=>{var{typed:r,parse:t}=e;return r(qp,{string:function(e){var r=Nr();return t(e).compile().evaluate(r)},"string, Map | Object":function(e,r){return t(e).compile().evaluate(r)},"Array | Matrix":function(e){var r=Nr();return Bn(e,(function(e){return t(e).compile().evaluate(r)}))},"Array | Matrix, Map | Object":function(e,r){return Bn(e,(function(e){return t(e).compile().evaluate(r)}))}})})),Ip=te("Parser",["evaluate"],(e=>{var{evaluate:r}=e;function t(){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:Nr(),writable:!1})}return t.prototype.type="Parser",t.prototype.isParser=!0,t.prototype.evaluate=function(e){return r(e,this.scope)},t.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},t.prototype.getAll=function(){return function(e){if(e instanceof wr)return e.wrappedObject;var r={};for(var t of e.keys())dr(r,t,e.get(t));return r}(this.scope)},t.prototype.getAllAsMap=function(){return this.scope},t.prototype.set=function(e,r){return this.scope.set(e,r),r},t.prototype.remove=function(e){this.scope.delete(e)},t.prototype.clear=function(){this.scope.clear()},t}),{isClass:!0}),Rp="parser",Pp=te(Rp,["typed","Parser"],(e=>{var{typed:r,Parser:t}=e;return r(Rp,{"":function(){return new t}})})),jp=te("lup",["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],(e=>{var{typed:r,matrix:t,abs:n,addScalar:i,divideScalar:a,multiplyScalar:o,subtract:s,larger:u,equalScalar:c,unaryMinus:l,DenseMatrix:f,SparseMatrix:p,Spa:m}=e;return r("lup",{DenseMatrix:function(e){return h(e)},SparseMatrix:function(e){return d(e)},Array:function(e){var r=h(t(e));return{L:r.L.valueOf(),U:r.U.valueOf(),p:r.p}}});function h(e){var r,t,l,p=e._size[0],m=e._size[1],h=Math.min(p,m),d=G(e._data),g=[],v=[p,h],y=[],x=[h,m],b=[];for(r=0;r0)for(r=0;r0&&e.forEach(0,t-1,(function(r,t){p._forEachRow(r,y,x,b,(function(n,i){n>r&&e.accumulate(n,l(o(i,t)))}))}));var M,F,T,O,B=t,_=e.get(t),z=n(_);e.forEach(t+1,s-1,(function(e,r){var t=n(r);u(t,z)&&(B=e,z=t,_=r)})),t!==B&&(p._swapRows(t,B,w[1],y,x,b),p._swapRows(t,B,A[1],N,D,E),e.swap(t,B),F=B,T=S[M=t],O=S[F],C[T]=F,C[O]=M,S[M]=O,S[F]=T),e.forEach(0,s-1,(function(e,r){e<=t?(N.push(r),D.push(e)):(r=a(r,_),c(r,0)||(y.push(r),x.push(e)))}))};for(t=0;t{var{typed:t,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:g}=e;return r(t("qr",{DenseMatrix:function(e){return y(e)},SparseMatrix:function(e){return function(e){throw new Error("qr not implemented for sparse matrices yet")}()},Array:function(e){var r=y(n(e));return{Q:r.Q.valueOf(),R:r.R.valueOf()}}}),{_denseQRimpl:v});function v(e){var r,t,n,g=e._size[0],v=e._size[1],y=a([g],"dense"),x=y._data,b=e.clone(),w=b._data,N=i([g],"");for(n=0;n0)for(var n="Complex"===t[0][0].type?g(0):0,i=0;i=0;){var u=t[o+s],c=t[n+u];-1===c?(s--,a[r++]=u):(t[n+u]=t[i+c],t[o+ ++s]=c)}return r}function Hp(e){return-e-2}var $p=te("csAmd",["add","multiply","transpose"],(e=>{var{add:r,multiply:t,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 r(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)t[s+p]=0,t[i+p]=-1,f++,r[p]=Hp(e),t[s+e]++;else{var h=t[u+m];-1!==h&&(c[h]=p),t[l+p]=t[u+m],t[u+m]=p}}return f}(c,T,_,R,I,P,f,z,k,U,q),$=0;HG?(y=d,x=W,b=_[0+d]-G):(x=T[y=F[W++]],b=_[0+y]),v=1;v<=b;v++)(w=_[z+(m=F[x++])])<=0||(V+=w,_[z+m]=-w,F[Y++]=m,-1!==_[q+m]&&(U[_[q+m]]=U[m]),-1!==U[m]?_[q+U[m]]=_[q+m]:_[k+_[R+m]]=_[q+m]);y!==d&&(T[y]=Hp(d),_[P+y]=0)}for(0!==G&&(O=Y),_[R+d]=V,T[d]=J,_[0+d]=Y-J,_[I+d]=-2,L=i(L,l,_,P,c),N=J;N=L?_[P+y]-=w:0!==_[P+y]&&(_[P+y]=_[R+y]+X)}for(N=J;N0?(M+=Q,F[C++]=y,S+=y):(T[y]=Hp(d),_[P+y]=0)}_[I+m]=C-E+1;var K=C,ee=E+_[0+m];for(W=A+1;W=0))for(m=_[j+(S=U[m])],_[j+S]=-1;-1!==m&&-1!==_[q+m];m=_[q+m],L++){for(b=_[0+m],D=_[I+m],W=T[m]+1;W<=T[m]+b-1;W++)_[P+F[W]]=L;var te=m;for(h=_[q+m];-1!==h;){var ne=_[0+h]===b&&_[I+h]===D;for(W=T[h]+1;ne&&W<=T[h]+b-1;W++)_[P+F[W]]!==L&&(ne=0);ne?(T[h]=Hp(m),_[z+m]+=_[z+h],_[z+h]=0,_[I+h]=-1,h=_[q+h],_[q+te]=h):(te=h,h=_[q+h])}}for(W=J,N=J;N=0;h--)_[z+h]>0||(_[q+h]=_[k+T[h]],_[k+T[h]]=h);for(y=c;y>=0;y--)_[z+y]<=0||-1!==T[y]&&(_[q+y]=_[k+T[y]],_[k+T[y]]=y);for(d=0,m=0;m<=c;m++)-1===T[m]&&(d=Lp(m,d,_,k,q,B,P));return B.splice(B.length-1,1),B};function i(e,r,t,n,i){if(e<2||e+r<0){for(var a=0;a{var{transpose:r}=e;return function(e,t,n,i){if(!e||!t||!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),g=[],v=h,y=2*h,x=3*h,b=4*h,w=5*h+1;for(s=0;s=1&&N[o]++,2===C.jleaf&&N[C.q]--}-1!==t[o]&&(g[0+o]=t[o])}for(o=0;o{var{add:r,multiply:t,transpose:n}=e,i=$p({add:r,multiply:t,transpose:n}),a=Zp({transpose:n});return function(e,r,t){var n,o=r._ptr,s=r._size[1],u={};if(u.q=i(e,r),e&&!u.q)return null;if(t){var c=e?function(e,r,t,n){for(var i=e._values,a=e._index,o=e._ptr,s=e._size,u=e._datatype,c=s[0],l=s[1],f=n&&e._values?[]:null,p=[],m=[],h=0,d=0;d=0;t--)-1!==e[t]&&(a[o+t]=a[0+e[t]],a[0+e[t]]=t);for(t=0;t=0;u--)for(l=t[u],f=t[u+1],c=l;c=0;s--)m[s]=-1,-1!==(u=h[s])&&(0==d[x+u]++&&(d[y+u]=s),d[g+s]=d[v+u],d[v+u]=s);for(r.lnz=0,r.m2=a,u=0;u=0;){e=n[f];var p=i?i[e]:e;Wp(c,e)||(Jp(c,e),n[l+f]=p<0?0:Yp(c[p]));var m=1;for(o=n[l+f],s=p<0?0:Yp(c[p+1]);o{var{divideScalar:r,multiply:t,subtract:n}=e;return function(e,i,a,o,s,u,c){var l,f,p,m,h=e._values,d=e._index,g=e._ptr,v=e._size[1],y=i._values,x=i._index,b=i._ptr,w=function(e,r,t,n,i){var a,o,s,u=e._ptr,c=e._size,l=r._index,f=r._ptr,p=c[1],m=p;for(o=f[t],s=f[t+1],a=o;a{var{abs:r,divideScalar:t,multiply:n,subtract:i,larger:a,largerEq:o,SparseMatrix:s}=e,u=Qp({divideScalar:t,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,g=[],v=[],y=[],x=new s({values:g,index:v,ptr:y,size:[f,f]}),b=[],w=[],N=[],D=new s({values:b,index:w,ptr:N,size:[f,f]}),E=[],A=[],C=[];for(h=0;h{var{typed:r,abs:t,add:n,multiply:i,transpose:a,divideScalar:o,subtract:s,larger:u,largerEq:c,SparseMatrix:l}=e,f=Vp({add:n,multiply:i,transpose:a}),p=Kp({abs:t,divideScalar:o,multiply:i,subtract:s,larger:u,largerEq:c,SparseMatrix:l});return r("slu",{"SparseMatrix, number, number":function(e,r,t){if(!ae(r)||r<0||r>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(t<0||t>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var n=f(r,e,!1),i=p(e,n,t);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"}}}})}));function rm(e,r){var t,n=r.length,i=[];if(e)for(t=0;t{var{typed:r,matrix:t,lup:n,slu:i,usolve:a,lsolve:o,DenseMatrix:s}=e,u=Iu({DenseMatrix:s});return r(tm,{"Array, Array | Matrix":function(e,r){e=t(e);var i=n(e);return p(i.L,i.U,i.p,null,r).valueOf()},"DenseMatrix, Array | Matrix":function(e,r){var t=n(e);return p(t.L,t.U,t.p,null,r)},"SparseMatrix, Array | Matrix":function(e,r){var t=n(e);return p(t.L,t.U,t.p,null,r)},"SparseMatrix, Array | Matrix, number, number":function(e,r,t,n){var a=i(e,t,n);return p(a.L,a.U,a.p,a.q,r)},"Object, Array | Matrix":function(e,r){return p(e.L,e.U,e.p,e.q,r)}});function c(e){if(f(e))return e;if(l(e))return t(e);throw new TypeError("Invalid Matrix LU decomposition")}function p(e,r,t,n,i){e=c(e),r=c(r),t&&((i=u(e,i,!0))._data=rm(t,i._data));var s=o(e,i),l=a(r,s);return n&&(l._data=rm(n,l._data)),l}})),am=["parse"],om=te("Help",am,(e=>{var{parse:r}=e;function t(e){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw new Error('Argument "doc" missing');this.doc=e}return t.prototype.type="Help",t.prototype.isHelp=!0,t.prototype.toString=function(){var e=this.doc||{},t="\n";if(e.name&&(t+="Name: "+e.name+"\n\n"),e.category&&(t+="Category: "+e.category+"\n\n"),e.description&&(t+="Description:\n "+e.description+"\n\n"),e.syntax&&(t+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){t+="Examples:\n";for(var n={},i=0;i"mathjs"!==e)).forEach((t=>{r[t]=e[t]})),new t(r)},t.prototype.valueOf=t.prototype.toString,t}),{isClass:!0}),sm=["?on","math","typed"],um=te("Chain",sm,(e=>{var{on:r,math:t,typed:n}=e;function i(e){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");H(e)?this.value=e.value:this.value=e}function a(e,r){Q(i.prototype,e,(function(){var e=r();if("function"==typeof e)return o(e)}))}function o(e){return function(){if(0===arguments.length)return new i(e(this.value));for(var r=[this.value],t=0;te[r]))};for(var n in e)t(n)}var u,c};var s={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return i.createProxy(t),r&&r("import",(function(e,r,t){t||a(e,r)})),i}),{isClass:!0}),cm={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"]},lm={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"]},fm={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(matrix)","fraction(num,den)","fraction({n: num, d: den})"],description:"Create a fraction from a number or from integer numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)","fraction({n: 333, d: 53})","fraction([sqrt(9), sqrt(10), sqrt(11)])"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},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[1:2, 1: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:cm,E:cm,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:lm,PI:lm,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"]},leafCount:{name:"leafCount",category:"Algebra",syntax:["leafCount(expr)"],description:"Computes the number of leaves in the parse tree of the given expression",examples:['leafCount("e^(i*pi)-1")','leafCount(parse("{a: 22/7, b: 10^(1/2)}"))'],seealso:["simplify"]},resolve:{name:"resolve",category:"Algebra",syntax:["resolve(node, scope)"],description:"Recursively substitute variables in an expression tree.",examples:['resolve(parse("1 + x"), { x: 7 })','resolve(parse("size(text)"), { text: "Hello World" })','resolve(parse("x + y"), { x: parse("3z") })','resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })'],seealso:["simplify","evaluate"],mayThrow:["ReferenceError"]},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:["simplifyCore","derivative","evaluate","parse","rationalize","resolve"]},simplifyConstant:{name:"simplifyConstant",category:"Algebra",syntax:["simplifyConstant(expr)","simplifyConstant(expr, options)"],description:"Replace constant subexpressions of node with their values.",examples:['simplifyConatant("(3-3)*x")','simplifyConstant(parse("z-cos(tau/8)"))'],seealso:["simplify","simplifyCore","evaluate"]},simplifyCore:{name:"simplifyCore",category:"Algebra",syntax:["simplifyCore(node)"],description:"Perform simple one-pass simplifications on an expression tree.",examples:['simplifyCore(parse("0*x"))','simplifyCore(parse("(x+0)*2"))'],seealso:["simplify","simplifyConstant","evaluate"]},symbolicEqual:{name:"symbolicEqual",category:"Algebra",syntax:["symbolicEqual(expr1, expr2)","symbolicEqual(expr1, expr2, options)"],description:"Returns true if the difference of the expressions simplifies to 0",examples:['symbolicEqual("x*y","y*x")','symbolicEqual("abs(x^2)", "x^2")','symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})'],seealso:["simplify","evaluate"]},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)","math.pow([[1, 2], [4, 3]], 2)","math.pow([[1, 2], [4, 3]], -1)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},round:{name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)"],seealso:["ceil","floor","fix"]},sign:{name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},sqrt:{name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},sqrtm:{name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},square:{name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},subtract:{name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},unaryMinus:{name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},invmod:{name:"invmod",category:"Arithmetic",syntax:["invmod(a, b)"],description:"Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)",examples:["invmod(8, 12)=NaN","invmod(7, 13)=2","math.invmod(15151, 15122)=10429"],seealso:["gcd","xgcd"]},bitAnd:{name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitNot:{name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitOr:{name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},bitXor:{name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},leftShift:{name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},rightArithShift:{name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},rightLogShift:{name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},bellNumbers:{name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},catalan:{name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},composition:{name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},stirlingS2:{name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},config:{name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},import:{name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number": 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:["numberOfPets = {}","addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;",'forEach(["Dog","Cat","Cat"], addPet)',"numberOfPets"],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"]},pinv:{name:"pinv",category:"Matrix",syntax:["pinv(x)"],description:"Calculate the Moore–Penrose inverse of a matrix",examples:["pinv([1, 2; 3, 4])","pinv([[1, 0], [0, 1], [0, 1]])","pinv(4)"],seealso:["inv"]},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 the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation `l:u`. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]","f[[1,2], [1,3]] = [9, 10; 11, 12]","f"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},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"]},fft:{name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},ifft:{name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},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:[]},lgamma:{name:"lgamma",category:"Probability",syntax:["lgamma(n)"],description:"Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.",examples:["lgamma(4)","lgamma(1/2)","lgamma(math.i)","lgamma(complex(1.1, 2))"],seealso:["gamma"]},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:[]},cumsum:{name:"cumsum",category:"Statistics",syntax:["cumsum(a, b, c, ...)","cumsum(A)"],description:"Compute the cumulative sum of all values.",examples:["cumsum(2, 3, 4, 1)","cumsum([2, 3, 4, 1])","cumsum([1, 2; 3, 4])","cumsum([1, 2; 3, 4], 1)","cumsum([1, 2; 3, 4], 2)"],seealso:["max","mean","median","min","prod","std","sum","variance"]},mad:{name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},mean:{name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},median:{name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},min:{name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},mode:{name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},prod:{name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},quantileSeq:{name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:"Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.",examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},std:{name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},sum:{name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},variance:{name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},acos:{name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},acosh:{name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},acot:{name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},acoth:{name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},acsc:{name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},acsch:{name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},asec:{name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},asech:{name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},asin:{name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},asinh:{name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},atan:{name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},atanh:{name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},atan2:{name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},cos:{name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},cosh:{name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},cot:{name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},coth:{name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},csc:{name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},csch:{name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},sec:{name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},sech:{name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},sin:{name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},sinh:{name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},tan:{name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},tanh:{name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},to:{name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},clone:{name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},format:{name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},bin:{name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},oct:{name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},hex:{name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},isNaN:{name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isInteger:{name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isNegative:{name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},isNumeric:{name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},hasNumericValue:{name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},isPositive:{name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isPrime:{name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isZero:{name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},print:{name:"print",category:"Utils",syntax:["print(template, values)","print(template, values, precision)"],description:"Interpolate values into a string template.",examples:['print("Lucy is $age years old", {age: 5})','print("The value of pi is $pi", {pi: pi}, 3)','print("Hello, $user.name!", {user: {name: "John"}})','print("Values: $0, $1, $2", [6, 9, 4])'],seealso:["format"]},typeOf:{name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},numeric:{name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "BigNumber")','numeric("4", "Fraction)','numeric(4, "Fraction")','numeric(fraction(2, 5), "number)'],seealso:["number","fraction","bignumber","string","format"]}},pm="help",mm=te(pm,["typed","mathWithTransform","Help"],(e=>{var{typed:r,mathWithTransform:t,Help:n}=e;return r(pm,{any:function(e){var r,i=e;if("string"!=typeof e)for(r in t)if(K(t,r)&&e===t[r]){i=r;break}var a=hr(fm,i);if(!a){var o="function"==typeof i?i.name:i;throw new Error('No documentation found on "'+o+'"')}return new n(a)}})})),hm="chain",dm=te(hm,["typed","Chain"],(e=>{var{typed:r,Chain:t}=e;return r(hm,{"":function(){return new t},any:function(e){return new t(e)}})})),gm=te("det",["typed","matrix","subtract","multiply","divideScalar","isZero","unaryMinus"],(e=>{var{typed:r,matrix:t,subtract:n,multiply:i,divideScalar:a,isZero:o,unaryMinus:s}=e;return r("det",{any:function(e){return G(e)},"Array | Matrix":function(e){var r;switch((r=f(e)?e.size():Array.isArray(e)?(e=t(e)).size():[]).length){case 0:return G(e);case 1:if(1===r[0])return G(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+Oe(r)+")");case 2:var u=r[0],c=r[1];if(u===c)return function(e,r,t){if(1===r)return G(e[0][0]);if(2===r)return n(i(e[0][0],e[1][1]),i(e[1][0],e[0][1]));for(var u=!1,c=new Array(r).fill(0).map(((e,r)=>r)),l=0;l{var{typed:r,matrix:t,divideScalar:n,addScalar:i,multiply:a,unaryMinus:o,det:s,identity:u,abs:c}=e;return r("inv",{"Array | Matrix":function(e){var r=f(e)?e.size():Re(e);switch(r.length){case 1:if(1===r[0])return f(e)?t([n(1,e.valueOf()[0])]):[n(1,e[0])];throw new RangeError("Matrix must be square (size: "+Oe(r)+")");case 2:var i=r[0],a=r[1];if(i===a)return f(e)?t(l(e.valueOf(),i,a),e.storage()):l(e,i,a);throw new RangeError("Matrix must be square (size: "+Oe(r)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+Oe(r)+")")}},any:function(e){return n(1,e)}});function l(e,r,t){var l,f,p,m,h;if(1===r){if(0===(m=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero");return[[n(1,m)]]}if(2===r){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 g=e.concat();for(l=0;lx&&(x=c(g[l][y]),b=l),l++;if(0===x)throw Error("Cannot calculate inverse, determinant is zero");(l=b)!==y&&(h=g[y],g[y]=g[l],g[l]=h,h=v[y],v[y]=v[l],v[l]=h);var w=g[y],N=v[y];for(l=0;l{var{typed:r,matrix:t,inv:n,deepEqual:i,equal:a,dotDivide:o,dot:s,ctranspose:u,divideScalar:c,multiply:l,add:p,Complex:m}=e;return r(ym,{"Array | Matrix":function(e){var r=f(e)?e.size():Re(e);switch(r.length){case 1:return g(e)?u(e):1===r[0]?n(e):o(u(e),s(e,e));case 2:if(g(e))return u(e);var i=r[0],a=r[1];if(i===a)try{return n(e)}catch(e){if(!(e instanceof Error&&e.message.match(/Cannot calculate inverse, determinant is zero/)))throw e}return f(e)?t(h(e.valueOf(),i,a),e.storage()):h(e,i,a);default:throw new RangeError("Matrix must be two dimensional (size: "+Oe(r)+")")}},any:function(e){return a(e,0)?G(e):c(1,e)}});function h(e,r,t){var{C:i,F:a}=function(e,r,t){var n=function(e,r,t){for(var n=G(e),i=0,a=0;ae.filter(((e,t)=>t!d(s(n[r],n[r]))));return{C:i,F:a}}(e,r,t),c=l(n(l(u(i),i)),u(i)),f=l(u(a),n(l(a,u(a))));return l(f,c)}function d(e){return a(p(e,m(1,1)),p(0,m(1,1)))}function g(e){return i(p(e,m(1,1)),p(l(e,0),m(1,1)))}}));function bm(e){var{addScalar:r,subtract:t,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:g,larger:v,smaller:y,matrixFromColumns:x,dot:b}=e;function w(e,n,i,o){var u=r(e,o),c=t(a(e,o),a(n,i)),l=a(u,.5),f=a(s(t(a(u,u),a(4,c))),.5);return[r(l,f),t(l,f)]}function N(e,r,n,i,a,o,s,l){var f="BigNumber"===l,p="Complex"===l,m=f?c(0):p?g(0):0,h=f?c(1):p?g(1):1;if(y(u(n),s))return[[h,m],[m,h]];if(v(u(t(a,o)),s))return[[t(a,i),t(o,i)],[n,n]];var d=t(e,a),x=t(r,a),b=t(n,a),w=t(i,a);return y(u(x),s)?[[d,h],[b,m]]:[[x,m],[w,h]]}function D(e,r){for(var t=0;t=5)return null;for(s=0;;){var u=m(e,a);if(y(M(S(a,[u])),n))break;if(++s>=10)return null;a=F(u)}return a}function C(e,r,t){var n="BigNumber"===t,i="Complex"===t,a=Array(e).fill(0).map((e=>2*Math.random()-1));return n&&(a=a.map((e=>c(e)))),i&&(a=a.map((e=>g(e)))),F(a=S(a,r),t)}function S(e,r){for(var n of r)e=t(e,i(o(b(n,e),b(n,n)),n));return e}function M(e){return u(s(b(e,e)))}function F(e,r){var t="Complex"===r,n="BigNumber"===r?c(1):t?g(1):1;return i(o(n,M(e)),e)}return function(e,s,m,b,C){void 0===C&&(C=!0);var S=function(e,t,n,i,s){var f,p="BigNumber"===i,m="Complex"===i,h=p?c(0):0,x=p?c(1):m?g(1):1,b=p?c(1):1,w=p?c(10):2,N=a(w,w);s&&(f=Array(t).fill(x));var D=!1;for(;!D;){D=!0;for(var E=0;E1&&(A=l(Array(x-1).fill(h)))),x-=1,d.pop();for(var B=0;B2&&(A=l(Array(x-2).fill(h)))),x-=2,d.pop(),d.pop();for(var z=0;z+t(u(e),u(r)))),C>100){var q=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+v.join(", "));throw q.values=v,q.vectors=[],q}var k=s?i(E,function(e,r){for(var t=[],n=0;ni(d,e))),M.push(...l.map((e=>n(e))))},z=0;z{var{config:r,typed:t,matrix:n,addScalar:u,subtract:c,equal:l,abs:f,atan:p,cos:m,sin:h,multiplyScalar:d,divideScalar:g,inv:v,bignumber:y,multiply:x,add:b,larger:w,column:N,flatten:D,number:E,complex:A,sqrt:C,diag:S,qr:M,usolve:F,usolveAll:T,im:O,re:B,smaller:_,matrixFromColumns:z,dot:q}=e,k=function(e){var{config:r,addScalar:t,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 t,n=e.length,i=Math.abs(r/n),a=new Array(n),o=0;o=Math.abs(i);){var u=s[0][0],c=s[0][1];e=b(e,t=d(e[u][u],e[c][c],e[u][c]),u,c),a=v(a,t,u,c),s=w(e)}for(var l=E(n,0),f=0;f=i(a);){var c=u[0][0],l=u[0][1];e=x(e,t=g(e[c][c],e[l][l],e[c][l]),c,l),o=y(o,t,c,l),u=N(e)}for(var f=E(n,0),p=0;p2&&void 0!==arguments[2]?arguments[2]:r.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:r,addScalar:u,subtract:c,column:N,flatten:D,equal:l,abs:f,atan:p,cos:m,sin:h,multiplyScalar:d,inv:v,bignumber:y,complex:A,multiply:x,add:b}),I=bm({config:r,addScalar:u,subtract:c,multiply:x,multiplyScalar:d,flatten:D,divideScalar:g,sqrt:C,abs:f,bignumber:y,diag:S,qr:M,inv:v,usolve:F,usolveAll:T,equal:l,complex:A,larger:w,smaller:_,matrixFromColumns:z,dot:q});return t("eigs",{Array:function(e){return R(n(e))},"Array, number|BigNumber":function(e,r){return R(n(e),r)},Matrix:function(e){var{values:r,vectors:t}=R(e);return{values:n(r),vectors:n(t)}},"Matrix, number|BigNumber":function(e,r){var{values:t,vectors:i}=R(e,r);return{values:n(t),vectors:n(i)}}});function R(e,t){void 0===t&&(t=r.epsilon);var n=e.size();if(2!==n.length||n[0]!==n[1])throw new RangeError("Matrix must be square (size: "+Oe(n)+")");var i=e.toArray(),a=n[0];if(function(e,r,t){for(var n=0;n{var{typed:r,abs:t,add:n,identity:i,inv:a,multiply:o}=e;return r(Nm,{Matrix:function(e){var r=e.size();if(2!==r.length||r[0]!==r[1])throw new RangeError("Matrix must be square (size: "+Oe(r)+")");for(var u=r[0],c=function(e){for(var r=e.size()[0],n=0,i=0;i1&&(y=o(y,m),x=-x),d=n(d,o(v=v*(f-b+1)/((2*f-b+1)*b),y)),g=n(g,o(v*x,y));for(var w=o(a(g),d),N=0;N{var{typed:r,abs:t,add:n,multiply:i,map:a,sqrt:o,subtract:s,inv:u,size:c,max:l,identity:p}=e,m=1e-6;function h(e){var r,a=0,o=e,f=p(c(e));do{var h=o;if(o=i(.5,n(h,u(f))),f=i(.5,n(f,u(h))),(r=l(t(s(o,h))))>m&&++a>1e3)throw new Error("computing square root of matrix: iterative method could not converge")}while(r>m);return o}return r(Em,{"Array | Matrix":function(e){var r=f(e)?e.size():Re(e);switch(r.length){case 1:if(1===r[0])return a(e,o);throw new RangeError("Matrix must be square (size: "+Oe(r)+")");case 2:if(r[0]===r[1])return h(e);throw new RangeError("Matrix must be square (size: "+Oe(r)+")");default:throw new RangeError("Matrix must be at most two dimensional (size: "+Oe(r)+")")}}})})),Cm=te("divide",["typed","matrix","multiply","equalScalar","divideScalar","inv"],(e=>{var{typed:r,matrix:t,multiply:n,equalScalar:i,divideScalar:a,inv:o}=e,s=oa({typed:r,equalScalar:i}),u=ua({typed:r});return r("divide",V({"Array | Matrix, Array | Matrix":function(e,r){return n(e,o(r))},"DenseMatrix, any":function(e,r){return u(e,r,a,!1)},"SparseMatrix, any":function(e,r){return s(e,r,a,!1)},"Array, any":function(e,r){return u(t(e),r,a,!1).valueOf()},"any, Array | Matrix":function(e,r){return n(e,o(r))}},a.signatures))})),Sm="distance",Mm=te(Sm,["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],(e=>{var{typed:r,addScalar:t,subtract:n,multiplyScalar:i,divideScalar:o,unaryMinus:s,sqrt:u,abs:c}=e;return r(Sm,{"Array, Array, Array":function(e,r,t){if(2===e.length&&2===r.length&&2===t.length){if(!f(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!f(r))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!f(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var a=o(n(t[1],t[0]),n(r[1],r[0])),u=i(i(a,a),r[0]),c=s(i(a,r[0])),l=e[1];return g(e[0],e[1],u,c,l)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(e,r,t){if(2===Object.keys(e).length&&2===Object.keys(r).length&&2===Object.keys(t).length){if(!f(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!f(r))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!f(t))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"lineOnePtX"in r&&"lineOnePtY"in r&&"lineTwoPtX"in t&&"lineTwoPtY"in t){var a=o(n(t.lineTwoPtY,t.lineTwoPtX),n(r.lineOnePtY,r.lineOnePtX)),u=i(i(a,a),r.lineOnePtX),c=s(i(a,r.lineOnePtX)),l=e.pointX;return g(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,r){if(2===e.length&&3===r.length){if(!f(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!p(r))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return g(e[0],e[1],r[0],r[1],r[2])}if(3===e.length&&6===r.length){if(!p(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!h(r))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return v(e[0],e[1],e[2],r[0],r[1],r[2],r[3],r[4],r[5])}if(e.length===r.length&&e.length>0){if(!m(e))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!m(r))throw new TypeError("All values of an array should be numbers or BigNumbers");return y(e,r)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,r){if(2===Object.keys(e).length&&3===Object.keys(r).length){if(!f(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!p(r))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"xCoeffLine"in r&&"yCoeffLine"in r&&"constant"in r)return g(e.pointX,e.pointY,r.xCoeffLine,r.yCoeffLine,r.constant);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&6===Object.keys(r).length){if(!p(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!h(r))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 r&&"y0"in r&&"z0"in r&&"a"in r&&"b"in r&&"c"in r)return v(e.pointX,e.pointY,e.pointZ,r.x0,r.y0,r.z0,r.a,r.b,r.c);throw new TypeError("Key names do not match")}if(2===Object.keys(e).length&&2===Object.keys(r).length){if(!f(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!f(r))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointTwoX"in r&&"pointTwoY"in r)return y([e.pointOneX,e.pointOneY],[r.pointTwoX,r.pointTwoY]);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&3===Object.keys(r).length){if(!p(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!p(r))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 r&&"pointTwoY"in r&&"pointTwoZ"in r)return y([e.pointOneX,e.pointOneY,e.pointOneZ],[r.pointTwoX,r.pointTwoY,r.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 r=[],t=[],n=[],i=0;i{var{typed:r,config:t,abs:n,add:i,addScalar:a,matrix:o,multiply:s,multiplyScalar:u,divideScalar:c,subtract:l,smaller:f,equalScalar:p,flatten:m,isZero:h,isNumeric:d}=e;return r("intersect",{"Array, Array, Array":g,"Array, Array, Array, Array":v,"Matrix, Matrix, Matrix":function(e,r,t){var n=g(e.valueOf(),r.valueOf(),t.valueOf());return null===n?null:o(n)},"Matrix, Matrix, Matrix, Matrix":function(e,r,t,n){var i=v(e.valueOf(),r.valueOf(),t.valueOf(),n.valueOf());return null===i?null:o(i)}});function g(e,r,t){if(e=y(e),r=y(r),t=y(t),!b(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!b(r))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!function(e){return 4===e.length&&d(e[0])&&d(e[1])&&d(e[2])&&d(e[3])}(t))throw new TypeError("Array with 4 numbers expected as third argument");return function(e,r,t,n,i,o,s,f,p,m){var h=u(e,s),d=u(n,s),g=u(r,f),v=u(i,f),y=u(t,p),x=u(o,p),b=l(l(l(m,h),g),y),w=l(l(l(a(a(d,v),x),h),g),y),N=c(b,w),D=a(e,u(N,l(n,e))),E=a(r,u(N,l(i,r))),A=a(t,u(N,l(o,t)));return[D,E,A]}(e[0],e[1],e[2],r[0],r[1],r[2],t[0],t[1],t[2],t[3])}function v(e,r,o,m){if(e=y(e),r=y(r),o=y(o),m=y(m),2===e.length){if(!x(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!x(r))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!x(o))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!x(m))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return function(e,r,o,p){var m=e,d=o,g=l(m,r),v=l(d,p),y=l(u(g[0],v[1]),u(v[0],g[1]));if(h(y))return null;if(f(n(y),t.epsilon))return null;var x=u(v[0],m[1]),b=u(v[1],m[0]),w=u(v[0],d[1]),N=u(v[1],d[0]),D=c(a(l(l(x,b),w),N),y);return i(s(g,D),m)}(e,r,o,m)}if(3===e.length){if(!b(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!b(r))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!b(o))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!b(m))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return function(e,r,t,n,i,o,s,f,m,d,g,v){var y=w(e,s,d,s,r,f,g,f,t,m,v,m),x=w(d,s,n,e,g,f,i,r,v,m,o,t),b=w(e,s,n,e,r,f,i,r,t,m,o,t),N=w(d,s,d,s,g,f,g,f,v,m,v,m),D=w(n,e,n,e,i,r,i,r,o,t,o,t),E=l(u(y,x),u(b,N)),A=l(u(D,N),u(x,x));if(h(A))return null;var C=c(E,A),S=c(a(y,u(C,x)),N),M=a(e,u(C,l(n,e))),F=a(r,u(C,l(i,r))),T=a(t,u(C,l(o,t))),O=a(s,u(S,l(d,s))),B=a(f,u(S,l(g,f))),_=a(m,u(S,l(v,m)));return p(M,O)&&p(F,B)&&p(T,_)?[M,F,T]:null}(e[0],e[1],e[2],r[0],r[1],r[2],o[0],o[1],o[2],m[0],m[1],m[2])}throw new TypeError("Arrays with two or thee dimensional points expected")}function y(e){return 1===e.length?e[0]:e.length>1&&Array.isArray(e[0])&&e.every((e=>Array.isArray(e)&&1===e.length))?m(e):e}function x(e){return 2===e.length&&d(e[0])&&d(e[1])}function b(e){return 3===e.length&&d(e[0])&&d(e[1])&&d(e[2])}function w(e,r,t,n,i,o,s,c,f,p,m,h){var d=u(l(e,r),l(t,n)),g=u(l(i,o),l(s,c)),v=u(l(f,p),l(m,h));return a(a(d,g),v)}})),Tm=te("sum",["typed","config","add","numeric"],(e=>{var{typed:r,config:t,add:n,numeric:i}=e;return r("sum",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,r){try{return _n(e,r,n)}catch(e){throw su(e,"sum")}},"...":function(e){if(Tn(e))throw new TypeError("Scalar values expected in function sum");return a(e)}});function a(e){var r;return On(e,(function(e){try{r=void 0===r?e:n(r,e)}catch(r){throw su(r,"sum",e)}})),void 0===r&&(r=i(0,t.number)),"string"==typeof r&&(r=i(r,t.number)),r}})),Om="cumsum",Bm=te(Om,["typed","add","unaryPlus"],(e=>{var{typed:r,add:t,unaryPlus:n}=e;return r(Om,{Array:i,Matrix:function(e){return e.create(i(e.valueOf()))},"Array, number | BigNumber":o,"Matrix, number | BigNumber":function(e,r){return e.create(o(e.valueOf(),r))},"...":function(e){if(Tn(e))throw new TypeError("All values expected to be scalar in function cumsum");return i(e)}});function i(e){try{return a(e)}catch(e){throw su(e,Om)}}function a(e){if(0===e.length)return[];for(var r=[n(e[0])],i=1;i=t.length)throw new Ie(r,t.length);try{return s(e,r)}catch(e){throw su(e,Om)}}function s(e,r){var t,n,i;if(r<=0){var o=e[0][0];if(Array.isArray(o)){for(i=Fn(e),n=[],t=0;t{var{typed:r,add:t,divide:n}=e;return r(_m,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,r){try{var i=_n(e,r,t),a=Array.isArray(e)?Re(e):e.size();return n(i,a[r])}catch(e){throw su(e,"mean")}},"...":function(e){if(Tn(e))throw new TypeError("Scalar values expected in function mean");return i(e)}});function i(e){var r,i=0;if(On(e,(function(e){try{r=void 0===r?e:t(r,e),i++}catch(r){throw su(r,"mean",e)}})),0===i)throw new Error("Cannot calculate the mean of an empty array");return n(r,i)}})),qm="median",km=te(qm,["typed","add","divide","compare","partitionSelect"],(e=>{var{typed:r,add:t,divide:n,compare:i,partitionSelect:a}=e;function o(e){try{var r=(e=Xe(e.valueOf())).length;if(0===r)throw new Error("Cannot calculate median of an empty array");if(r%2==0){for(var t=r/2-1,n=a(e,t+1),o=e[t],c=0;c0&&(o=e[c]);return u(o,n)}var l=a(e,(r-1)/2);return s(l)}catch(e){throw su(e,"median")}}var s=r({"number | BigNumber | Complex | Unit":function(e){return e}}),u=r({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,r){return n(t(e,r),2)}});return r(qm,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,r){throw new Error("median(A, dim) is not yet supported")},"...":function(e){if(Tn(e))throw new TypeError("Scalar values expected in function median");return o(e)}})})),Im=te("mad",["typed","abs","map","median","subtract"],(e=>{var{typed:r,abs:t,map:n,median:i,subtract:a}=e;return r("mad",{"Array | Matrix":o,"...":function(e){return o(e)}});function o(e){if(0===(e=Xe(e.valueOf())).length)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var r=i(e);return i(n(e,(function(e){return t(a(e,r))})))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf("median")?new TypeError(e.message.replace("median","mad")):su(e,"mad")}}})),Rm="unbiased",Pm="variance",jm=te(Pm,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:r,add:t,subtract:n,multiply:i,divide:o,apply:s,isNaN:u}=e;return r(Pm,{"Array | Matrix":function(e){return c(e,Rm)},"Array | Matrix, string":c,"Array | Matrix, number | BigNumber":function(e,r){return l(e,r,Rm)},"Array | Matrix, number | BigNumber, string":l,"...":function(e){return c(e,Rm)}});function c(e,r){var s,c=0;if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(On(e,(function(e){try{s=void 0===s?e:t(s,e),c++}catch(r){throw su(r,"variance",e)}})),0===c)throw new Error("Cannot calculate variance of an empty array");var l=o(s,c);if(s=void 0,On(e,(function(e){var r=n(e,l);s=void 0===s?i(r,r):t(s,i(r,r))})),u(s))return s;switch(r){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 "'+r+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function l(e,r,t){try{if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return s(e,r,(e=>c(e,t)))}catch(e){throw su(e,"variance")}}})),Um=te("quantileSeq",["typed","add","multiply","partitionSelect","compare"],(e=>{var{typed:r,add:t,multiply:n,partitionSelect:o,compare:s}=e;function u(e,r,a){var u=Xe(e),l=u.length;if(0===l)throw new Error("Cannot calculate quantile of an empty sequence");if(i(r)){var f=r*(l-1),p=f%1;if(0===p){var m=a?u[f]:o(u,f);return c(m),m}var h,d,g=Math.floor(f);if(a)h=u[g],d=u[g+1];else{d=o(u,g+1),h=u[g];for(var v=0;v0&&(h=u[v])}return c(h),c(d),t(n(h,1-p),n(d,p))}var y=r.times(l-1);if(y.isInteger()){y=y.toNumber();var x=a?u[y]:o(u,y);return c(x),x}var b,w,N=y.floor(),D=y.minus(N),E=N.toNumber();if(a)b=u[E],w=u[E+1];else{w=o(u,E+1),b=u[E];for(var A=0;A0&&(b=u[A])}c(b),c(w);var C=new D.constructor(1);return t(n(b,C.minus(D)),n(w,D))}var c=r({"number | BigNumber | Unit":function(e){return e}});return function(e,r,t){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(t=t||!1)){if(o=e.valueOf(),i(r)){if(r<0)throw new Error("N/prob must be non-negative");if(r<=1)return u(o,r,t);if(r>1){if(!ae(r))throw new Error("N must be a positive integer");var c=r+1;n=new Array(r);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(v))throw new TypeError("Unexpected type of argument in function quantileSeq");if(s=new v.constructor(1),v.isNegative()||v.gt(s))throw new Error("Probability must be between 0 and 1, inclusive")}n[g]=u(o,v,t)}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")}})),Lm=te("std",["typed","map","sqrt","variance"],(e=>{var{typed:r,map:t,sqrt:n,variance:i}=e;return r("std",{"Array | Matrix":a,"Array | Matrix, string":a,"Array | Matrix, number | BigNumber":a,"Array | Matrix, number | BigNumber, string":a,"...":function(e){return a(e)}});function a(e,r){if(0===e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{var a=i.apply(null,arguments);return p(a)?t(a,n):n(a)}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf(" variance")?new TypeError(e.message.replace(" variance"," std")):e}}}));function Hm(e,r){if(r>1;return Hm(e,t)*Hm(t+1,r)}function $m(e,r){if(!ae(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!ae(r)||r<0)throw new TypeError("Positive integer value expected in function combinations");if(r>e)throw new TypeError("k must be less than or equal to n");for(var t=e-r,n=1,i=2,a=r{var{typed:r}=e;return r(Gm,{"number, number":$m,"BigNumber, BigNumber":function(e,r){var t,n,i=e.constructor,a=e.minus(r),o=new i(1);if(!Vm(e)||!Vm(r))throw new TypeError("Positive integer value expected in function combinations");if(r.gt(e))throw new TypeError("k must be less than n in function combinations");if(t=o,r.lt(a))for(n=o;n.lte(a);n=n.plus(o))t=t.times(r.plus(n)).dividedBy(n);else for(n=o;n.lte(r);n=n.plus(o))t=t.times(a.plus(n)).dividedBy(n);return t}})}));function Vm(e){return e.isInteger()&&e.gte(0)}var Wm="combinationsWithRep",Jm=te(Wm,["typed"],(e=>{var{typed:r}=e;return r(Wm,{"number, number":function(e,r){if(!ae(e)||e<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!ae(r)||r<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e<1)throw new TypeError("k must be less than or equal to n + k - 1");return r171?1/0:Hm(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*Xm(1-e));if(e>=171.35)return 1/0;if(e>85){var t=e*e,n=t*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*t)-139/(51840*n)-571/(2488320*i)+163879/(209018880*a)+5246819/(75246796800*a*e))}--e,r=Km[0];for(var o=1;o=1;n--)t+=rh[n]/(e+n);return eh+(e+.5)*Math.log(r)-r+Math.log(t)}th.signature="number";var nh="gamma",ih=te(nh,["typed","config","multiplyScalar","pow","BigNumber","Complex"],(e=>{var{typed:r,config:t,multiplyScalar:n,pow:i,BigNumber:a,Complex:o}=e;return r(nh,{number:Xm,Complex:function e(r){if(0===r.im)return Xm(r.re);if(r.re<.5){var t=new o(1-r.re,-r.im),n=new o(Math.PI*r.re,Math.PI*r.im);return new o(Math.PI).div(n.sin()).div(e(t))}r=new o(r.re-1,r.im);for(var i=new o(Km[0],0),a=1;a2;)u+=i-=2,o=o.times(u);return new a(o.toPrecision(a.precision))}})),ah="lgamma",oh=te(ah,["Complex","typed"],(e=>{var{Complex:r,typed:t}=e,n=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return t(ah,{number:th,Complex:function e(t){if(t.isNaN())return new r(NaN,NaN);if(0===t.im)return new r(th(t.re),0);if(t.re>=7||Math.abs(t.im)>=7)return i(t);if(t.re<=.1){var n=(u=6.283185307179586,c=t.im,((u>0||!(u<0)&&1/u==1/0)^(c>0||!(c<0)&&1/c==1/0)?-u:u)*Math.floor(.5*t.re+.25)),o=t.mul(Math.PI).sin().log(),s=e(new r(1-t.re,-t.im));return new r(1.1447298858494002,n).sub(o).sub(s)}return t.im>=0?a(t):a(t.conjugate()).conjugate();var u,c},BigNumber:function(){throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function i(e){for(var t=e.sub(.5).mul(e.log()).sub(e).add(eh),i=new r(1,0).div(e),a=i.div(e),o=n[0],s=n[1],u=2*a.re,c=a.re*a.re+a.im*a.im,l=2;l<8;l++){var f=s;s=-c*o+n[l],o=u*o+f}var p=i.mul(a.mul(o).add(s));return t.add(p)}function a(e){var t=0,n=0,a=e;for(e=e.add(1);e.re<=7;){var o=(a=a.mul(e)).im<0?1:0;0!==o&&0===n&&t++,n=o,e=e.add(1)}return i(e).sub(a.log()).sub(new r(0,2*t*Math.PI*1))}})),sh="factorial",uh=te(sh,["typed","gamma"],(e=>{var{typed:r,gamma:t}=e;return r(sh,{number:function(e){if(e<0)throw new Error("Value must be non-negative");return t(e+1)},BigNumber:function(e){if(e.isNegative())throw new Error("Value must be non-negative");return t(e.plus(1))},"Array | Matrix":r.referToSelf((e=>r=>Bn(r,e)))})})),ch="kldivergence",lh=te(ch,["typed","matrix","divide","sum","multiply","map","dotDivide","log","isNumeric"],(e=>{var{typed:r,matrix:t,divide:n,sum:i,multiply:a,map:o,dotDivide:s,log:u,isNumeric:c}=e;return r(ch,{"Array, Array":function(e,r){return l(t(e),t(r))},"Matrix, Array":function(e,r){return l(e,t(r))},"Array, Matrix":function(e,r){return l(t(e),r)},"Matrix, Matrix":function(e,r){return l(e,r)}});function l(e,r){var t=r.size().length,l=e.size().length;if(t>1)throw new Error("first object must be one dimensional");if(l>1)throw new Error("second object must be one dimensional");if(t!==l)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(r))throw new Error("Sum of elements in second object must be non zero");var f=n(e,i(e)),p=n(r,i(r)),m=i(a(f,o(s(f,p),(e=>u(e)))));return c(m)?m:Number.NaN}})),fh="multinomial",ph=te(fh,["typed","add","divide","multiply","factorial","isInteger","isPositive"],(e=>{var{typed:r,add:t,divide:n,multiply:i,factorial:a,isInteger:o,isPositive:s}=e;return r(fh,{"Array | Matrix":function(e){var r=0,u=1;return On(e,(function(e){if(!o(e)||!s(e))throw new TypeError("Positive integer value expected in function multinomial");r=t(r,e),u=i(u,a(e))})),n(a(r),u)}})})),mh="permutations",hh=te(mh,["typed","factorial"],(e=>{var{typed:r,factorial:t}=e;return r(mh,{"number | BigNumber":t,"number, number":function(e,r){if(!ae(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!ae(r)||r<0)throw new TypeError("Positive integer value expected in function permutations");if(r>e)throw new TypeError("second argument k must be less than or equal to first argument n");return Hm(e-r+1,e)},"BigNumber, BigNumber":function(e,r){var t,n;if(!dh(e)||!dh(r))throw new TypeError("Positive integer value expected in function permutations");if(r.gt(e))throw new TypeError("second argument k must be less than or equal to first argument n");for(t=e.mul(0).add(1),n=e.minus(r).plus(1);n.lte(e);n=n.plus(1))t=t.times(n);return t}})}));function dh(e){return e.isInteger()&&e.gte(0)}var gh=t(6377),vh=gh(Date.now());function yh(e){var r,t;return r=null===(t=e)?vh:gh(String(t)),function(){return r()}}var xh="pickRandom",bh=te(xh,["typed","config","?on"],(e=>{var{typed:r,config:t,on:n}=e,a=yh(t.randomSeed);return n&&n("config",(function(e,r){e.randomSeed!==r.randomSeed&&(a=yh(e.randomSeed))})),r(xh,{"Array | Matrix":function(e){return o(e,{})},"Array | Matrix, Object":function(e,r){return o(e,r)},"Array | Matrix, number":function(e,r){return o(e,{number:r})},"Array | Matrix, Array | Matrix":function(e,r){return o(e,{weights:r})},"Array | Matrix, Array | Matrix, number":function(e,r,t){return o(e,{number:t,weights:r})},"Array | Matrix, number, Array | Matrix":function(e,r,t){return o(e,{number:r,weights:t})}});function o(e,r){var{number:t,weights:n,elementWise:o=!0}=r,s=void 0===t;s&&(t=1);var u=f(e)?e.create:f(n)?n.create:null;e=e.valueOf(),n&&(n=n.valueOf()),!0===o&&(e=Xe(e),n=Xe(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:r,config:t,on:n}=e,i=yh(t.randomSeed);return n&&n("config",(function(e,r){e.randomSeed!==r.randomSeed&&(i=yh(e.randomSeed))})),r(Nh,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,r)=>o(e,r),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,r)=>a(e,0,r),"Array | Matrix, number, number":(e,r,t)=>a(e,r,t)});function a(e,r,t){var n=wh(e.valueOf(),(()=>o(r,t)));return f(e)?e.create(n):n}function o(e,r){return e+i()*(r-e)}})),Eh="randomInt",Ah=te(Eh,["typed","config","?on"],(e=>{var{typed:r,config:t,on:n}=e,i=yh(t.randomSeed);return n&&n("config",(function(e,r){e.randomSeed!==r.randomSeed&&(i=yh(e.randomSeed))})),r(Eh,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,r)=>o(e,r),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,r)=>a(e,0,r),"Array | Matrix, number, number":(e,r,t)=>a(e,r,t)});function a(e,r,t){var n=wh(e.valueOf(),(()=>o(r,t)));return f(e)?e.create(n):n}function o(e,r){return Math.floor(e+i()*(r-e))}})),Ch="stirlingS2",Sh=te(Ch,["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],(e=>{var{typed:r,addScalar:t,subtract:n,multiplyScalar:a,divideScalar:o,pow:s,factorial:u,combinations:c,isNegative:l,isInteger:f,number:p,bignumber:m,larger:h}=e,d=[],g=[];return r(Ch,{"number | BigNumber, number | BigNumber":function(e,r){if(!f(e)||l(e)||!f(r)||l(r))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(h(r,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");var n=!(i(e)&&i(r)),o=n?g:d,s=n?m:p,u=p(e),c=p(r);if(o[u]&&o[u].length>c)return o[u][c];for(var v=0;v<=u;++v)if(o[v]||(o[v]=[s(0===v?1:0)]),0!==v)for(var y=o[v],x=o[v-1],b=y.length;b<=v&&b<=c;++b)y[b]=b===v?1:t(a(s(b),x[b]),x[b-1]);return o[u][c]}})})),Mh="bellNumbers",Fh=te(Mh,["typed","addScalar","isNegative","isInteger","stirlingS2"],(e=>{var{typed:r,addScalar:t,isNegative:n,isInteger:i,stirlingS2:a}=e;return r(Mh,{"number | BigNumber":function(e){if(!i(e)||n(e))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var r=0,o=0;o<=e;o++)r=t(r,a(e,o));return r}})})),Th="catalan",Oh=te(Th,["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],(e=>{var{typed:r,addScalar:t,divideScalar:n,multiplyScalar:i,combinations:a,isNegative:o,isInteger:s}=e;return r(Th,{"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),t(e,1))}})})),Bh="composition",_h=te(Bh,["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],(e=>{var{typed:r,addScalar:t,combinations:n,isPositive:i,isNegative:a,isInteger:o,larger:s}=e;return r(Bh,{"number | BigNumber, number | BigNumber":function(e,r){if(!(o(e)&&i(e)&&o(r)&&i(r)))throw new TypeError("Positive integer value expected in function composition");if(s(r,e))throw new TypeError("k must be less than or equal to n in function composition");return n(t(e,-1),t(r,-1))}})})),zh="leafCount",qh=te(zh,["parse","typed"],(e=>{var{parse:r,typed:t}=e;function n(e){var r=0;return e.forEach((e=>{r+=n(e)})),r||1}return t(zh,{Node:function(e){return n(e)}})}));function kh(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function Ih(e){for(var r=1;r{var{FunctionNode:r,OperatorNode:t,SymbolNode:n}=e,i=!0,a=!1,o="defaultF",s={add:{trivial:i,total:i,commutative:i,associative:i},unaryPlus:{trivial:i,total:i,commutative:i,associative:i},subtract:{trivial:a,total:i,commutative:a,associative:a},multiply:{trivial:i,total:i,commutative:i,associative:i},divide:{trivial:a,total:i,commutative:a,associative:a},paren:{trivial:i,total:i,commutative:i,associative:a},defaultF:{trivial:a,total:i,commutative:a,associative:a}};function u(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:s,n=o;if("string"==typeof e?n=e:R(e)?n=e.fn.toString():z(e)?n=e.name:P(e)&&(n="paren"),K(t,n)){var i=t[n];if(K(i,r))return i[r];if(K(s,n))return s[n][r]}if(K(t,o)){var a=t.defaultF;return K(a,r)?a[r]:s.defaultF[r]}if(K(s,n)){var u=s[n];if(K(u,r))return u[r]}return s.defaultF[r]}function c(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s;return u(e,"associative",r)}function l(e,r){var t,n=[];return c(e,r)?(t=e.op,function e(r){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:s;return u(e,"commutative",r)},isAssociative:c,mergeContext:function(e,r){var t=Ih({},e);for(var n in r)K(e,n)?t[n]=Ih(Ih({},r[n]),e[n]):t[n]=r[n];return t},flatten:function e(r,t){if(!r.args||0===r.args.length)return r;r.args=l(r,t);for(var n=0;n2&&c(r,t)){for(var o=r.args.pop();r.args.length>0;)o=n([r.args.pop(),o]);r.args=o.args}}},unflattenl:function e(r,t){if(r.args&&0!==r.args.length){for(var n=f(r),i=r.args.length,a=0;a2&&c(r,t)){for(var o=r.args.shift();r.args.length>0;)o=n([o,r.args.shift()]);r.args=o.args}}},defaultContext:s,realContext:{divide:{total:a},log:{total:a}},positiveContext:{subtract:{total:a},abs:{trivial:i},log:{total:i}}}})),Ph=te("simplify",["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","resolve","simplifyConstant","simplifyCore","?fraction","?bignumber","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{config:r,typed:t,parse:n,add:i,subtract:a,multiply:o,divide:s,pow:u,isZero:c,equal:l,resolve:f,simplifyConstant:p,simplifyCore:m,fraction:h,bignumber:d,mathWithTransform:g,matrix:v,AccessorNode:y,ArrayNode:x,ConstantNode:b,FunctionNode:w,IndexNode:N,ObjectNode:D,OperatorNode:E,ParenthesisNode:A,SymbolNode:C}=e,{hasProperty:S,isCommutative:M,isAssociative:F,mergeContext:T,flatten:B,unflattenr:_,unflattenl:z,createMakeNodeFunction:q,defaultContext:k,realContext:I,positiveContext:R}=Rh({FunctionNode:w,OperatorNode:E,SymbolNode:C});t.addConversion({from:"Object",to:"Map",convert:Dr});var j=t("simplify",{Node:Z,"Node, Map":(e,r)=>Z(e,!1,r),"Node, Map, Object":(e,r,t)=>Z(e,!1,r,t),"Node, Array":Z,"Node, Array, Map":Z,"Node, Array, Map, Object":Z});function U(e){return e.transform((function(e,r,t){return P(e)?U(e.content):e}))}t.removeConversion({from:"Object",to:"Map",convert:Dr}),j.defaultContext=k,j.realContext=I,j.positiveContext=R;var L={true:!0,false:!0,e:!0,i:!0,Infinity:!0,LN2:!0,LN10:!0,LOG2E:!0,LOG10E:!0,NaN:!0,phi:!0,pi:!0,SQRT1_2:!0,SQRT2:!0,tau:!0};function H(e,r){var t={};if(e.s){var i=e.s.split("->");if(2!==i.length)throw SyntaxError("Could not parse rule: "+e.s);t.l=i[0],t.r=i[1]}else t.l=e.l,t.r=e.r;for(var a of(t.l=U(n(t.l)),t.r=U(n(t.r)),["imposeContext","repeat","assuming"]))a in e&&(t[a]=e[a]);if(e.evaluate&&(t.evaluate=n(e.evaluate)),F(t.l,r)){var o=q(t.l),s=new C("_p"+G++);t.expanded={},t.expanded.l=o([t.l.clone(),s]),B(t.expanded.l,r),_(t.expanded.l,r),t.expanded.r=o([t.r,s])}return t}function $(e,r){for(var t=[],n=0;n n+-n1",assuming:{subtract:{total:!0}}},{s:"n-n -> 0",assuming:{subtract:{total:!1}}},{s:"-(c*v) -> v * (-c)",assuming:{multiply:{commutative:!0},subtract:{total:!0}}},{s:"-(c*v) -> (-c) * v",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{s:"-(v*c) -> v * (-c)",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{l:"-(n1/n2)",r:"-n1/n2"},{l:"-v",r:"v * (-1)"},{l:"(n1 + n2)*(-1)",r:"n1*(-1) + n2*(-1)",repeat:!0},{l:"n/n1^n2",r:"n*n1^-n2"},{l:"n/n1",r:"n*n1^-1"},{s:"(n1*n2)^n3 -> n1^n3 * n2^n3",assuming:{multiply:{commutative:!0}}},{s:"(n1*n2)^(-1) -> n2^(-1) * n1^(-1)",assuming:{multiply:{commutative:!1}}},{s:"(n ^ n1) ^ n2 -> n ^ (n1 * n2)",assuming:{divide:{total:!0}}},{l:" v * ( v * n1 + n2)",r:"v^2 * n1 + v * n2"},{s:" v * (v^n4 * n1 + n2) -> v^(1+n4) * n1 + v * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * ( v * n1 + n2) -> v^(n3+1) * n1 + v^n3 * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * (v^n4 * n1 + n2) -> v^(n3+n4) * n1 + v^n3 * n2",assuming:{divide:{total:!0}}},{l:"n*n",r:"n^2"},{s:"n * n^n1 -> n^(n1+1)",assuming:{divide:{total:!0}}},{s:"n^n1 * n^n2 -> n^(n1+n2)",assuming:{divide:{total:!0}}},p,{s:"n+n -> 2*n",assuming:{add:{total:!0}}},{l:"n+-n",r:"0"},{l:"v*n + v",r:"v*(n+1)"},{l:"n3*n1 + n3*n2",r:"n3*(n1+n2)"},{l:"n3^(-n4)*n1 + n3 * n2",r:"n3^(-n4)*(n1 + n3^(n4+1) *n2)"},{l:"n3^(-n4)*n1 + n3^n5 * n2",r:"n3^(-n4)*(n1 + n3^(n4+n5)*n2)"},{s:"n*v + v -> (n+1)*v",assuming:{multiply:{commutative:!1}}},{s:"n1*n3 + n2*n3 -> (n1+n2)*n3",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3 -> (n1 + n2*n3^(n4 + 1))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3^n5 -> (n1 + n2*n3^(n4 + n5))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{l:"n*c + c",r:"(n+1)*c"},{s:"c*n + c -> c*(n+1)",assuming:{multiply:{commutative:!1}}},p,{s:"(-n)*n1 -> -(n*n1)",assuming:{subtract:{total:!0}}},{s:"n1*(-n) -> -(n1*n)",assuming:{subtract:{total:!0},multiply:{commutative:!1}}},{s:"c+v -> v+c",assuming:{add:{commutative:!0}},imposeContext:{add:{commutative:!1}}},{s:"v*c -> c*v",assuming:{multiply:{commutative:!0}},imposeContext:{multiply:{commutative:!1}}},{l:"n+-n1",r:"n-n1"},{s:"n*(n1^-1) -> n/n1",assuming:{multiply:{commutative:!0}}},{s:"n*n1^-n2 -> n/n1^n2",assuming:{multiply:{commutative:!0}}},{s:"n^-1 -> 1/n",assuming:{multiply:{commutative:!0}}},{l:"n^1",r:"n"},{s:"n*(n1/n2) -> (n*n1)/n2",assuming:{multiply:{associative:!0}}},{s:"n-(n1+n2) -> n-n1-n2",assuming:{addition:{associative:!0,commutative:!0}}},{l:"1*n",r:"n",imposeContext:{multiply:{commutative:!0}}},{s:"n1/(n2/n3) -> (n1*n3)/n2",assuming:{multiply:{associative:!0}}},{l:"n1/(-n2)",r:"-n1/n2"}];var G=0;function Z(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Nr(),n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=n.consoleDebug;r=$(r||j.rules,n.context);for(var a=f(e,t),o={},s=(a=U(a)).toString({parenthesis:"all"});!o[s];){o[s]=!0,G=0;var u=s;i&&console.log("Working on: ",s);for(var c=0;c ").concat(r[c].r.toString()))),i){var p=a.toString({parenthesis:"all"});p!==u&&(console.log("Applying",l,"produced",p),u=p)}z(a,n.context)}s=a.toString({parenthesis:"all"})}return a}function V(e,r,t){var n=e;if(e)for(var i=0;i=2&&2===e.args.length){for(var a=function(e,r){var t,n,i=[],a=q(e);if(M(e,r))for(var o=0;o1&&(u=a(e.args.slice(0,s))),t=1===(n=e.args.slice(s)).length?n[0]:a(n),i.push(a([u,t]))}return i}(r,t),o=[],s=0;s2)throw Error("Unexpected non-binary associative function: "+e.toString());return[]}for(var c=[],f=0;f2)throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");var m=X(e.args[0],r.args[1],t);if(0===m.length)return[];var h=X(e.args[1],r.args[0],t);if(0===h.length)return[];c=[m,h]}i=function(e){if(0===e.length)return e;for(var r=e.reduce(Y),t=[],n={},i=0;i{var{typed:r,parse:t,config:n,mathWithTransform:i,matrix:a,fraction:o,bignumber:u,AccessorNode:c,ArrayNode:l,ConstantNode:p,FunctionNode:m,IndexNode:h,ObjectNode:d,OperatorNode:g,SymbolNode:v}=e,{isCommutative:y,isAssociative:x,allChildren:b,createMakeNodeFunction:w}=Rh({FunctionNode:m,OperatorNode:g,SymbolNode:v}),N=r("simplifyConstant",{Node:e=>C(_(e,{})),"Node, Object":function(e,r){return C(_(e,r))}});function D(e){return s(e)?e.valueOf():e instanceof Array?e.map(D):f(e)?a(D(e.valueOf())):e}function E(e,r,t){try{return i[e].apply(null,r)}catch(n){return r=r.map(D),F(i[e].apply(null,r),t)}}var A=r({Fraction:function(e){var r,t=e.s*e.n;r=t<0?new g("-","unaryMinus",[new p(-t)]):new p(t);if(1===e.d)return r;return new g("/","divide",[r,new p(e.d)])},number:function(e){return e<0?T(new p(-e)):new p(e)},BigNumber:function(e){return e<0?T(new p(-e)):new p(e)},Complex:function(e){throw new Error("Cannot convert Complex number to Node")},string:function(e){return new p(e)},Matrix:function(e){return new l(e.valueOf().map((e=>A(e))))}});function C(e){return k(e)?e:A(e)}function M(e,r){if(r&&!1!==r.exactFractions&&isFinite(e)&&o){var t=o(e),n=r&&"number"==typeof r.fractionsLimit?r.fractionsLimit:1/0;if(t.valueOf()===e&&t.n_(e,r)));if(!t.some(k))try{return E(e.name,t,r)}catch(e){}if("size"===e.name&&1===t.length&&S(t[0])){for(var n=[],o=t[0];S(o);)n.push(o.items.length),o=o.items[0];return a(n)}return new m(e.name,t.map(C))}case"OperatorNode":var s,u,g=e.fn.toString(),v=w(e);if(R(e)&&e.isUnary())u=k((s=[_(e.args[0],r)])[0])?v(s):E(g,s,r);else if(x(e,r.context))if(s=(s=b(e,r.context)).map((e=>_(e,r))),y(g,r.context)){for(var D=[],A=[],M=0;M1?(u=B(g,D,v,r),A.unshift(u),u=B(g,A,v,r)):u=B(g,s,v,r)}else u=B(g,s,v,r);else u=B(g,s=e.args.map((e=>_(e,r))),v,r);return u;case"ParenthesisNode":return _(e.content,r);case"AccessorNode":return function(e,r,t){if(!q(r))return new c(C(e),C(r));if(S(e)||f(e)){for(var n=Array.from(r.dimensions);n.length>0;)if(O(n[0])&&"string"!=typeof n[0].value){var i=F(n.shift().value,t);S(e)?e=e.items[i-1]:(e=e.valueOf()[i-1])instanceof Array&&(e=a(e))}else{if(!(n.length>1&&O(n[1])&&"string"!=typeof n[1].value))break;var o=F(n[1].value,t),s=[],u=S(e)?e.items:e.valueOf();for(var m of u)if(S(m))s.push(m.items[o-1]);else{if(!f(e))break;s.push(m[o-1])}if(s.length!==u.length)break;e=S(e)?new l(s):a(s),n.splice(1,1)}return n.length===r.dimensions.length?new c(C(e),r):n.length>0?(r=new h(n),new c(C(e),r)):e}if(I(e)&&1===r.dimensions.length&&O(r.dimensions[0])){var d=r.dimensions[0].value;return d in e.properties?e.properties[d]:new p}return new c(C(e),r)}(_(e.object,r),_(e.index,r),r);case"ArrayNode":var T=e.items.map((e=>_(e,r)));return T.some(k)?new l(T.map(C)):a(T);case"IndexNode":return new h(e.dimensions.map((e=>N(e,r))));case"ObjectNode":var z={};for(var P in e.properties)z[P]=N(e.properties[P],r);return new d(z);default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(e.type))}}return N})),Uh="simplifyCore",Lh=te(Uh,["typed","parse","equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:r,parse:t,equal:n,isZero:i,add:a,subtract:o,multiply:s,divide:u,pow:c,AccessorNode:l,ArrayNode:f,ConstantNode:p,FunctionNode:m,IndexNode:h,ObjectNode:d,OperatorNode:g,ParenthesisNode:v,SymbolNode:y}=e,x=new p(0),b=new p(1),w=new p(!0),N=new p(!1);function D(e){return R(e)&&["and","not","or"].includes(e.op)}var{hasProperty:E,isCommutative:A}=Rh({FunctionNode:m,OperatorNode:g,SymbolNode:y});function M(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=r?r.context:void 0;if(E(e,"trivial",t)){if(z(e)&&1===e.args.length)return M(e.args[0],r);var a=!1,o=0;if(e.forEach((e=>{1===++o&&(a=M(e,r))})),1===o)return a}var s=e;if(z(s)){var u=Xf(s.name);if(!u)return new m(M(s.fn),s.args.map((e=>M(e,r))));if(s.args.length>2&&E(s,"associative",t))for(;s.args.length>2;){var c=s.args.pop(),p=s.args.pop();s.args.push(new g(u,s.name,[c,p]))}s=new g(u,s.name,s.args)}if(R(s)&&s.isUnary()){var v=M(s.args[0],r);if("~"===s.op&&R(v)&&v.isUnary()&&"~"===v.op)return v.args[0];if("not"===s.op&&R(v)&&v.isUnary()&&"not"===v.op&&D(v.args[0]))return v.args[0];var y=!0;if("-"===s.op&&R(v)&&(v.isBinary()&&"subtract"===v.fn&&(s=new g("-","subtract",[v.args[1],v.args[0]]),y=!1),v.isUnary()&&"-"===v.op))return v.args[0];if(y)return new g(s.op,s.fn,[v])}if(R(s)&&s.isBinary()){var F=M(s.args[0],r),T=M(s.args[1],r);if("+"===s.op){if(O(F)&&i(F.value))return T;if(O(T)&&i(T.value))return F;R(T)&&T.isUnary()&&"-"===T.op&&(T=T.args[0],s=new g("-","subtract",[F,T]))}if("-"===s.op)return R(T)&&T.isUnary()&&"-"===T.op?M(new g("+","add",[F,T.args[0]]),r):O(F)&&i(F.value)?M(new g("-","unaryMinus",[T])):O(T)&&i(T.value)?F:new g(s.op,s.fn,[F,T]);if("*"===s.op){if(O(F)){if(i(F.value))return x;if(n(F.value,1))return T}if(O(T)){if(i(T.value))return x;if(n(T.value,1))return F;if(A(s,t))return new g(s.op,s.fn,[T,F],s.implicit)}return new g(s.op,s.fn,[F,T],s.implicit)}if("/"===s.op)return O(F)&&i(F.value)?x:O(T)&&n(T.value,1)?F:new g(s.op,s.fn,[F,T]);if("^"===s.op&&O(T)){if(i(T.value))return b;if(n(T.value,1))return F}if("and"===s.op){if(O(F)){if(!F.value)return N;if(D(T))return T}if(O(T)){if(!T.value)return N;if(D(F))return F}}if("or"===s.op){if(O(F)){if(F.value)return w;if(D(T))return T}if(O(T)){if(T.value)return w;if(D(F))return F}}return new g(s.op,s.fn,[F,T])}if(R(s))return new g(s.op,s.fn,s.args.map((e=>M(e,r))));if(S(s))return new f(s.items.map((e=>M(e,r))));if(C(s))return new l(M(s.object,r),M(s.index,r));if(q(s))return new h(s.dimensions.map((e=>M(e,r))));if(I(s)){var B={};for(var _ in s.properties)B[_]=M(s.properties[_],r);return new d(B)}return s}return r(Uh,{Node:M,"Node,Object":M})})),Hh=te("resolve",["typed","parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],(e=>{var{typed:r,parse:t,ConstantNode:n,FunctionNode:i,OperatorNode:a,ParenthesisNode:o}=e;function s(e,r){var u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set;if(!r)return e;if(L(e)){if(u.has(e.name)){var c=Array.from(u).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(c,"}"))}var l=r.get(e.name);if(k(l)){var f=new Set(u);return f.add(e.name),s(l,r,f)}return"number"==typeof l?t(String(l)):void 0!==l?new n(l):e}if(R(e)){var p=e.args.map((function(e){return s(e,r,u)}));return new a(e.op,e.fn,p,e.implicit)}if(P(e))return new o(s(e.content,r,u));if(z(e)){var m=e.args.map((function(e){return s(e,r,u)}));return new i(e.name,m)}return e.map((e=>s(e,r,u)))}return r("resolve",{Node:s,"Node, Map | null | undefined":s,"Node, Object":(e,r)=>s(e,Dr(r)),"Array | Matrix":r.referToSelf((e=>r=>r.map((r=>e(r))))),"Array | Matrix, null | undefined":r.referToSelf((e=>r=>r.map((r=>e(r))))),"Array, Object":r.referTo("Array,Map",(e=>(r,t)=>e(r,Dr(t)))),"Matrix, Object":r.referTo("Matrix,Map",(e=>(r,t)=>e(r,Dr(t)))),"Array | Matrix, Map":r.referToSelf((e=>(r,t)=>r.map((r=>e(r,t)))))})})),$h="symbolicEqual",Gh=te($h,["parse","simplify","typed","OperatorNode"],(e=>{var{parse:r,simplify:t,typed:n,OperatorNode:i}=e;function a(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=new i("-","subtract",[e,r]),o=t(a,{},n);return O(o)&&!o.value}return n($h,{"Node, Node":a,"Node, Node, Object":a})})),Zh="derivative",Vh=te(Zh,["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:r,config:t,parse:n,simplify:i,equal:a,isZero:o,numeric:s,ConstantNode:u,FunctionNode:c,OperatorNode:l,ParenthesisNode:f,SymbolNode:p}=e;function m(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{simplify:!0},n={};g(n,e,r.name);var a=v(e,n);return t.simplify?i(a):a}r.addConversion({from:"identifier",to:"SymbolNode",convert:n});var h=r(Zh,{"Node, SymbolNode":m,"Node, SymbolNode, Object":m});r.removeConversion({from:"identifier",to:"SymbolNode",convert:n}),h._simplify=!0,h.toTex=function(e){return d.apply(null,e.args)};var d=r("_derivTex",{"Node, SymbolNode":function(e,r){return O(e)&&"string"===$(e.value)?d(n(e.value).toString(),r.toString(),1):d(e.toTex(),r.toString(),1)},"Node, ConstantNode":function(e,r){if("string"===$(r.value))return d(e,n(r.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(e,r,t){return d(e.toString(),r.name,t.value)},"string, string, number":function(e,r,t){return(1===t?"{d\\over d"+r+"}":"{d^{"+t+"}\\over d"+r+"^{"+t+"}}")+"\\left[".concat(e,"\\right]")}}),g=r("constTag",{"Object, ConstantNode, string":function(e,r){return e[r]=!0,!0},"Object, SymbolNode, string":function(e,r,t){return r.name!==t&&(e[r]=!0,!0)},"Object, ParenthesisNode, string":function(e,r,t){return g(e,r.content,t)},"Object, FunctionAssignmentNode, string":function(e,r,t){return-1===r.params.indexOf(t)?(e[r]=!0,!0):g(e,r.expr,t)},"Object, FunctionNode | OperatorNode, string":function(e,r,t){if(r.args.length>0){for(var n=g(e,r.args[0],t),i=1;i0){var n=e.args.filter((function(e){return void 0===r[e]})),i=1===n.length?n[0]:new l("*","multiply",n),s=t.concat(v(i,r));return new l("*","multiply",s)}return new l("+","add",e.args.map((function(t){return new l("*","multiply",e.args.map((function(e){return e===t?v(e,r):e.clone()})))})))}if("/"===e.op&&e.isBinary()){var u=e.args[0],f=e.args[1];return void 0!==r[f]?new l("/","divide",[v(u,r),f]):void 0!==r[u]?new l("*","multiply",[new l("-","unaryMinus",[u]),new l("/","divide",[v(f,r),new l("^","pow",[f.clone(),y(2)])])]):new l("/","divide",[new l("-","subtract",[new l("*","multiply",[v(u,r),f.clone()]),new l("*","multiply",[u.clone(),v(f,r)])]),new l("^","pow",[f.clone(),y(2)])])}if("^"===e.op&&e.isBinary()){var p=e.args[0],m=e.args[1];if(void 0!==r[p])return O(p)&&(o(p.value)||a(p.value,1))?y(0):new l("*","multiply",[e,new l("*","multiply",[new c("log",[p.clone()]),v(m.clone(),r)])]);if(void 0!==r[m]){if(O(m)){if(o(m.value))return y(0);if(a(m.value,1))return v(p,r)}var h=new l("^","pow",[p.clone(),new l("-","subtract",[m,y(1)])]);return new l("*","multiply",[m.clone(),new l("*","multiply",[v(p,r),h])])}return new l("*","multiply",[new l("^","pow",[p.clone(),m.clone()]),new l("+","add",[new l("*","multiply",[v(p,r),new l("/","divide",[m.clone(),p.clone()])]),new l("*","multiply",[v(m,r),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 y(e,r){return new u(s(e,r||t.number))}return h})),Wh="rationalize",Jh=te(Wh,["config","typed","equal","isZero","add","subtract","multiply","divide","pow","parse","simplifyConstant","simplifyCore","simplify","?bignumber","?fraction","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode","ParenthesisNode"],(e=>{var{config:r,typed:t,equal:n,isZero:i,add:a,subtract:o,multiply:s,divide:u,pow:c,parse:l,simplifyConstant:f,simplifyCore:p,simplify:m,fraction:h,bignumber:d,mathWithTransform:g,matrix:v,AccessorNode:y,ArrayNode:x,ConstantNode:b,FunctionNode:w,IndexNode:N,ObjectNode:D,OperatorNode:E,SymbolNode:A,ParenthesisNode:C}=e;function S(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=F(),i=M(e,r,!0,n.firstRules),a=i.variables.length,o={exactFractions:!1},s={exactFractions:!0};if(e=i.expression,a>=1){var u,c;e=T(e);var l,f=!0,p=!1;for(e=m(e,n.firstRules,{},o);c=f?n.distrDivRules:n.sucDivRules,f=!f,(l=(e=m(e,c,{},s)).toString())!==u;)p=!0,u=l;p&&(e=m(e,n.firstRulesAgain,{},o)),e=m(e,n.finalRules,{},o)}var h=[],d={};return"OperatorNode"===e.type&&e.isBinary()&&"/"===e.op?(1===a&&(e.args[0]=O(e.args[0],h),e.args[1]=O(e.args[1])),t&&(d.numerator=e.args[0],d.denominator=e.args[1])):(1===a&&(e=O(e,h)),t&&(d.numerator=e,d.denominator=null)),t?(d.coefficients=h,d.variables=i.variables,d.expression=e,d):e}return t(Wh,{Node:S,"Node, boolean":(e,r)=>S(e,{},r),"Node, Object":S,"Node, Object, boolean":S});function M(e,r,t,n){var i=[],a=m(e,n,r,{exactFractions:!1}),o="+-*"+((t=!!t)?"/":"");!function e(r){var t=r.type;if("FunctionNode"===t)throw new Error("There is an unsolved function call");if("OperatorNode"===t)if("^"===r.op){if("ConstantNode"!==r.args[1].type||!ae(parseFloat(r.args[1].value)))throw new Error("There is a non-integer exponent");e(r.args[0])}else{if(-1===o.indexOf(r.op))throw new Error("Operator "+r.op+" invalid in polynomial expression");for(var n=0;n1;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&&ae(a))),o){if(a>2){var s=e.args[0],u=new E("^","pow",[e.args[0].cloneDeep(),new b(a-1)]);e=new E("*","multiply",[s,u])}else e=new E("*","multiply",[e.args[0],e.args[0].cloneDeep()]);i&&("content"===t?r.content=e:r.args[t]=e)}}if("ParenthesisNode"===n)T(e.content,e,"content");else if("ConstantNode"!==n&&"SymbolNode"!==n)for(var c=0;cn&&(r[c]=0),r[c]+=o.cte*("+"===o.oper?1:-1),void(n=Math.max(c,n))}o.cte=c,""===o.fire&&(r[0]+=o.cte*("+"===o.oper?1:-1))}}(e,null,t);for(var a,o=!0,s=n=r.length-1;s>=0;s--)if(0!==r[s]){var u=new b(o?r[s]:Math.abs(r[s])),c=r[s]<0?"-":"+";if(s>0){var l=new A(i);if(s>1){var f=new b(s);l=new E("^","pow",[l,f])}u=-1===r[s]&&o?new E("-","unaryMinus",[l]):1===Math.abs(r[s])?l:new E("*","multiply",[u,l])}a=o?u:"+"===c?new E("+","add",[a,u]):new E("-","subtract",[a,u]),o=!1}return o?new b(0):a}})),Yh=te("reviver",["classes"],(e=>{var{classes:r}=e;return function(e,t){var n=r[t&&t.mathjs];return n&&"function"==typeof n.fromJSON?n.fromJSON(t):t}})),Xh=te("replacer",[],(()=>function(e,r){return"number"!=typeof r||isFinite(r)&&!isNaN(r)?r:{mathjs:"number",value:String(r)}})),Qh=Math.PI,Kh=2*Math.PI,ed=Math.E,rd=te("true",[],(()=>!0)),td=te("false",[],(()=>!1)),nd=te("null",[],(()=>null)),id=bd("Infinity",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(1/0):1/0})),ad=bd("NaN",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(NaN):NaN})),od=bd("pi",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?Gc(t):Qh})),sd=bd("tau",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?Zc(t):Kh})),ud=bd("e",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?Hc(t):ed})),cd=bd("phi",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?$c(t):1.618033988749895})),ld=bd("LN2",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(2).ln():Math.LN2})),fd=bd("LN10",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(10).ln():Math.LN10})),pd=bd("LOG2E",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(1).div(new t(2).ln()):Math.LOG2E})),md=bd("LOG10E",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(1).div(new t(10).ln()):Math.LOG10E})),hd=bd("SQRT1_2",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t("0.5").sqrt():Math.SQRT1_2})),dd=bd("SQRT2",["config","?BigNumber"],(e=>{var{config:r,BigNumber:t}=e;return"BigNumber"===r.number?new t(2).sqrt():Math.SQRT2})),gd=bd("i",["Complex"],(e=>{var{Complex:r}=e;return r.I})),vd=te("PI",["pi"],(e=>{var{pi:r}=e;return r})),yd=te("E",["e"],(e=>{var{e:r}=e;return r})),xd=te("version",[],(()=>"11.3.0"));function bd(e,r,t){return te(e,r,t,{recreateOnConfigChange:!0})}var wd=vg("speedOfLight","299792458","m s^-1"),Nd=vg("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),Dd=vg("planckConstant","6.62607015e-34","J s"),Ed=vg("reducedPlanckConstant","1.0545718176461565e-34","J s"),Ad=vg("magneticConstant","1.25663706212e-6","N A^-2"),Cd=vg("electricConstant","8.8541878128e-12","F m^-1"),Sd=vg("vacuumImpedance","376.730313667","ohm"),Md=vg("coulomb","8.987551792261171e9","N m^2 C^-2"),Fd=vg("elementaryCharge","1.602176634e-19","C"),Td=vg("bohrMagneton","9.2740100783e-24","J T^-1"),Od=vg("conductanceQuantum","7.748091729863649e-5","S"),Bd=vg("inverseConductanceQuantum","12906.403729652257","ohm"),_d=vg("magneticFluxQuantum","2.0678338484619295e-15","Wb"),zd=vg("nuclearMagneton","5.0507837461e-27","J T^-1"),qd=vg("klitzing","25812.807459304513","ohm"),kd=vg("bohrRadius","5.29177210903e-11","m"),Id=vg("classicalElectronRadius","2.8179403262e-15","m"),Rd=vg("electronMass","9.1093837015e-31","kg"),Pd=vg("fermiCoupling","1.1663787e-5","GeV^-2"),jd=yg("fineStructure",.0072973525693),Ud=vg("hartreeEnergy","4.3597447222071e-18","J"),Ld=vg("protonMass","1.67262192369e-27","kg"),Hd=vg("deuteronMass","3.3435830926e-27","kg"),$d=vg("neutronMass","1.6749271613e-27","kg"),Gd=vg("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),Zd=vg("rydberg","10973731.568160","m^-1"),Vd=vg("thomsonCrossSection","6.6524587321e-29","m^2"),Wd=yg("weakMixingAngle",.2229),Jd=yg("efimovFactor",22.7),Yd=vg("atomicMass","1.66053906660e-27","kg"),Xd=vg("avogadro","6.02214076e23","mol^-1"),Qd=vg("boltzmann","1.380649e-23","J K^-1"),Kd=vg("faraday","96485.33212331001","C mol^-1"),eg=vg("firstRadiation","3.7417718521927573e-16","W m^2"),rg=vg("loschmidt","2.686780111798444e25","m^-3"),tg=vg("gasConstant","8.31446261815324","J K^-1 mol^-1"),ng=vg("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),ig=vg("molarVolume","0.022413969545014137","m^3 mol^-1"),ag=yg("sackurTetrode",-1.16487052358),og=vg("secondRadiation","0.014387768775039337","m K"),sg=vg("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),ug=vg("wienDisplacement","2.897771955e-3","m K"),cg=vg("molarMass","0.99999999965e-3","kg mol^-1"),lg=vg("molarMassC12","11.9999999958e-3","kg mol^-1"),fg=vg("gravity","9.80665","m s^-2"),pg=vg("planckLength","1.616255e-35","m"),mg=vg("planckMass","2.176435e-8","kg"),hg=vg("planckTime","5.391245e-44","s"),dg=vg("planckCharge","1.87554603778e-18","C"),gg=vg("planckTemperature","1.416785e+32","K");function vg(e,r,t){return te(e,["config","Unit","BigNumber"],(e=>{var{config:n,Unit:i,BigNumber:a}=e,o=new i("BigNumber"===n.number?new a(r):parseFloat(r),t);return o.fixPrefix=!0,o}))}function yg(e,r){return te(e,["config","BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(r):r}))}var xg=te("apply",["typed","isInteger"],(e=>{var{typed:r,isInteger:t}=e,n=ea({typed:r,isInteger:t});return r("apply",{"...any":function(e){var r=e[1];i(r)?e[1]=r-1:a(r)&&(e[1]=r.minus(1));try{return n.apply(null,e)}catch(e){throw jf(e)}}})}),{isTransformFunction:!0}),bg=te("column",["typed","Index","matrix","range"],(e=>{var{typed:r,Index:t,matrix:n,range:a}=e,o=Yo({typed:r,Index:t,matrix:n,range:a});return r("column",{"...any":function(e){var r=e.length-1,t=e[r];i(t)&&(e[r]=t-1);try{return o.apply(null,e)}catch(e){throw jf(e)}}})}),{isTransformFunction:!0});function wg(e,r,t){var n=e.filter((function(e){return L(e)&&!(e.name in r)&&!t.has(e.name)}))[0];if(!n)throw new Error('No undefined variable found in inline expression "'+e+'"');var i=n.name,a=Mp(t),o=e.compile();return function(e){return a.set(i,e),o.evaluate(a)}}var Ng=te("filter",["typed"],(e=>{var{typed:r}=e;function t(e,r,t){var i,a;return e[0]&&(i=e[0].compile().evaluate(t)),e[1]&&(a=L(e[1])||_(e[1])?e[1].compile().evaluate(t):wg(e[1],r,t)),n(i,a)}t.rawArgs=!0;var n=r("filter",{"Array, function":Dg,"Matrix, function":function(e,r){return e.create(Dg(e.toArray(),r))},"Array, RegExp":rr,"Matrix, RegExp":function(e,r){return e.create(rr(e.toArray(),r))}});return t}),{isTransformFunction:!0});function Dg(e,r){var t=An(r);return er(e,(function(e,n,i){return 1===t?r(e):2===t?r(e,[n+1]):r(e,[n+1],i)}))}var Eg=te("forEach",["typed"],(e=>{var{typed:r}=e;function t(e,r,t){var i,a;return e[0]&&(i=e[0].compile().evaluate(t)),e[1]&&(a=L(e[1])||_(e[1])?e[1].compile().evaluate(t):wg(e[1],r,t)),n(i,a)}t.rawArgs=!0;var n=r("forEach",{"Array | Matrix, function":function(e,r){var t=An(r);!function n(i,a){Array.isArray(i)?Ke(i,(function(e,r){n(e,a.concat(r+1))})):1===t?r(i):2===t?r(i,a):r(i,a,e)}(e.valueOf(),[])}});return t}),{isTransformFunction:!0}),Ag=te("index",["Index"],(e=>{var{Index:r}=e;return function(){for(var e=[],t=0,n=arguments.length;t0?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[t]=o}var s=new r;return r.apply(s,e),s}}),{isTransformFunction:!0}),Cg=te("map",["typed"],(e=>{var{typed:r}=e;function t(e,r,t){var i,a;return e[0]&&(i=e[0].compile().evaluate(t)),e[1]&&(a=L(e[1])||_(e[1])?e[1].compile().evaluate(t):wg(e[1],r,t)),n(i,a)}t.rawArgs=!0;var n=r("map",{"Array, function":function(e,r){return Sg(e,r,e)},"Matrix, function":function(e,r){return e.create(Sg(e.valueOf(),r,e))}});return t}),{isTransformFunction:!0});function Sg(e,r,t){var n=An(r);return function e(i,a){return Array.isArray(i)?Qe(i,(function(r,t){return e(r,a.concat(t+1))})):1===n?r(i):2===n?r(i,a):r(i,a,t)}(e,[])}function Mg(e){if(2===e.length&&p(e[0])){var r=(e=e.slice())[1];i(r)?e[1]=r-1:a(r)&&(e[1]=r.minus(1))}return e}var Fg=te("max",["typed","config","numeric","larger"],(e=>{var{typed:r,config:t,numeric:n,larger:i}=e,a=kc({typed:r,config:t,numeric:n,larger:i});return r("max",{"...any":function(e){e=Mg(e);try{return a.apply(null,e)}catch(e){throw jf(e)}}})}),{isTransformFunction:!0}),Tg=te("mean",["typed","add","divide"],(e=>{var{typed:r,add:t,divide:n}=e,i=zm({typed:r,add:t,divide:n});return r("mean",{"...any":function(e){e=Mg(e);try{return i.apply(null,e)}catch(e){throw jf(e)}}})}),{isTransformFunction:!0}),Og=te("min",["typed","config","numeric","smaller"],(e=>{var{typed:r,config:t,numeric:n,smaller:i}=e,a=Ic({typed:r,config:t,numeric:n,smaller:i});return r("min",{"...any":function(e){e=Mg(e);try{return a.apply(null,e)}catch(e){throw jf(e)}}})}),{isTransformFunction:!0}),Bg=te("range",["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:r,config:t,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u}=e,c=As({typed:r,config:t,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u});return r("range",{"...any":function(e){return"boolean"!=typeof e[e.length-1]&&e.push(!0),c.apply(null,e)}})}),{isTransformFunction:!0}),_g=te("row",["typed","Index","matrix","range"],(e=>{var{typed:r,Index:t,matrix:n,range:a}=e,o=_s({typed:r,Index:t,matrix:n,range:a});return r("row",{"...any":function(e){var r=e.length-1,t=e[r];i(t)&&(e[r]=t-1);try{return o.apply(null,e)}catch(e){throw jf(e)}}})}),{isTransformFunction:!0}),zg=te("subset",["typed","matrix"],(e=>{var{typed:r,matrix:t}=e,n=Ps({typed:r,matrix:t});return r("subset",{"...any":function(e){try{return n.apply(null,e)}catch(e){throw jf(e)}}})}),{isTransformFunction:!0}),qg=te("concat",["typed","matrix","isInteger"],(e=>{var{typed:r,matrix:t,isInteger:n}=e,o=Vo({typed:r,matrix:t,isInteger:n});return r("concat",{"...any":function(e){var r=e.length-1,t=e[r];i(t)?e[r]=t-1:a(t)&&(e[r]=t.minus(1));try{return o.apply(null,e)}catch(e){throw jf(e)}}})}),{isTransformFunction:!0}),kg="diff",Ig=te(kg,["typed","matrix","subtract","number","bignumber"],(e=>{var{typed:r,matrix:t,subtract:n,number:i,bignumber:a}=e,o=xs({typed:r,matrix:t,subtract:n,number:i,bignumber:a});return r(kg,{"...any":function(e){e=Mg(e);try{return o.apply(null,e)}catch(e){throw jf(e)}}})}),{isTransformFunction:!0}),Rg=te("std",["typed","map","sqrt","variance"],(e=>{var{typed:r,map:t,sqrt:n,variance:i}=e,a=Lm({typed:r,map:t,sqrt:n,variance:i});return r("std",{"...any":function(e){e=Mg(e);try{return a.apply(null,e)}catch(e){throw jf(e)}}})}),{isTransformFunction:!0}),Pg=te("sum",["typed","config","add","numeric"],(e=>{var{typed:r,config:t,add:n,numeric:i}=e,a=Tm({typed:r,config:t,add:n,numeric:i});return r("sum",{"...any":function(e){e=Mg(e);try{return a.apply(null,e)}catch(e){throw jf(e)}}})}),{isTransformFunction:!0}),jg="cumsum",Ug=te(jg,["typed","add","unaryPlus"],(e=>{var{typed:r,add:t,unaryPlus:n}=e,o=Bm({typed:r,add:t,unaryPlus:n});return r(jg,{"...any":function(e){if(2===e.length&&p(e[0])){var r=e[1];i(r)?e[1]=r-1:a(r)&&(e[1]=r.minus(1))}try{return o.apply(null,e)}catch(e){throw jf(e)}}})}),{isTransformFunction:!0}),Lg="variance",Hg=te(Lg,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:r,add:t,subtract:n,multiply:i,divide:a,apply:o,isNaN:s}=e,u=jm({typed:r,add:t,subtract:n,multiply:i,divide:a,apply:o,isNaN:s});return r(Lg,{"...any":function(e){e=Mg(e);try{return u.apply(null,e)}catch(e){throw jf(e)}}})}),{isTransformFunction:!0}),$g=function e(t,B){var $=r({},cr,B);if("function"!=typeof Object.create)throw new Error("ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.");var G,Z,V=(G={isNumber:i,isComplex:o,isBigNumber:a,isFraction:s,isUnit:u,isString:c,isArray:l,isMatrix:f,isCollection:p,isDenseMatrix:m,isSparseMatrix:h,isRange:d,isIndex:g,isBoolean:v,isResultSet:y,isHelp:x,isFunction:b,isDate:w,isRegExp:N,isObject:D,isNull:E,isUndefined:A,isAccessorNode:C,isArrayNode:S,isAssignmentNode:M,isBlockNode:F,isConditionalNode:T,isConstantNode:O,isFunctionAssignmentNode:_,isFunctionNode:z,isIndexNode:q,isNode:k,isObjectNode:I,isOperatorNode:R,isParenthesisNode:P,isRangeNode:j,isRelationalNode:U,isSymbolNode:L,isChain:H},Z=new re,G.on=Z.on.bind(Z),G.off=Z.off.bind(Z),G.once=Z.once.bind(Z),G.emit=Z.emit.bind(Z),G);V.config=pr($,V.emit),V.expression={transform:{},mathWithTransform:{config:V.config}};var W={};function J(){for(var e=arguments.length,r=new Array(e),t=0;t{ee(W).forEach((e=>{e&&e.meta&&e.meta.recreateOnConfigChange&&X(e,{override:!0})}))})),V.create=e.bind(null,t),V.factory=te,V.import(ee(Y(t))),V.ArgumentsError=sr,V.DimensionError=ke,V.IndexError=Ie,V}(e,{number:"BigNumber",precision:20});window.math=$g})()})();