From a57a4a393aee256b8b575a8fe4140633a2986c48 Mon Sep 17 00:00:00 2001 From: Ben Cooper Date: Tue, 21 Sep 2021 20:21:32 -0700 Subject: [PATCH 1/9] first attempt at adding closure plugin --- package-lock.json | 240 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 + webpack.config.js | 10 +- 3 files changed, 248 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index cd263bb..4e6c458 100644 --- a/package-lock.json +++ b/package-lock.json @@ -431,6 +431,23 @@ "integrity": "sha1-yroksIGFw7VuMWjpfRXtF/TTH9A=", "dev": true }, + "acorn-dynamic-import": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-2.0.2.tgz", + "integrity": "sha1-x1K9IQvvZ5UBtsbLf8hPj0cVjMQ=", + "dev": true, + "requires": { + "acorn": "^4.0.3" + }, + "dependencies": { + "acorn": { + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", + "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", + "dev": true + } + } + }, "acorn-jsx": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz", @@ -507,6 +524,12 @@ "uri-js": "^4.2.2" } }, + "ajv-errors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ajv-errors/-/ajv-errors-1.0.1.tgz", + "integrity": "sha512-DCRfO/4nQ+89p/RK43i8Ezd41EqdGIU4ld7nGF8OQ14oc/we5rEntLCUa7+jrn3nn83BosfwZA0wb4pon2o8iQ==", + "dev": true + }, "ajv-keywords": { "version": "3.5.2", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", @@ -985,6 +1008,12 @@ "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", "dev": true }, + "clone-buffer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz", + "integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg=", + "dev": true + }, "clone-deep": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz", @@ -1005,6 +1034,65 @@ "mimic-response": "^1.0.0" } }, + "clone-stats": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz", + "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=", + "dev": true + }, + "cloneable-readable": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/cloneable-readable/-/cloneable-readable-1.1.3.tgz", + "integrity": "sha512-2EF8zTQOxYq70Y4XKtorQupqF0m49MBz2/yf5Bj+MHjvpG3Hy7sImifnqD6UA+TKYxeSV+u6qqQPawN5UvnpKQ==", + "dev": true, + "requires": { + "inherits": "^2.0.1", + "process-nextick-args": "^2.0.0", + "readable-stream": "^2.3.5" + } + }, + "closure-webpack-plugin": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/closure-webpack-plugin/-/closure-webpack-plugin-2.5.0.tgz", + "integrity": "sha512-mp18Dss/NEj6EazNsT7EiRUCR4wXWFawrIe9Mm2epqELkJWZldVOs+vSPz8y1T2qB4pBYwQuQK2jruDXksOBkg==", + "dev": true, + "requires": { + "acorn": "^5.0.0", + "acorn-dynamic-import": "^2.0.0", + "schema-utils": "1.x", + "unquoted-property-validator": "^1.0.2", + "webpack-sources": "1.x" + }, + "dependencies": { + "acorn": { + "version": "5.7.4", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz", + "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==", + "dev": true + }, + "schema-utils": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-1.0.0.tgz", + "integrity": "sha512-i27Mic4KovM/lnGsy8whRCHhc7VicJajAjTrYg11K9zfZXnYIt4k5F+kZkwjnrhKzLic/HLU4j11mjsz2G/75g==", + "dev": true, + "requires": { + "ajv": "^6.1.0", + "ajv-errors": "^1.0.0", + "ajv-keywords": "^3.1.0" + } + }, + "webpack-sources": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.4.3.tgz", + "integrity": "sha512-lgTS3Xhv1lCOKo7SA5TjKXMjpSM4sBjNV5+q2bqesbSPs5FjGmU6jjtBSkX9b4qW87vDIsCIlUPOEhbZrMdjeQ==", + "dev": true, + "requires": { + "source-list-map": "^2.0.0", + "source-map": "~0.6.1" + } + } + } + }, "color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -2026,6 +2114,101 @@ } } }, + "google-closure-compiler": { + "version": "20210907.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20210907.0.0.tgz", + "integrity": "sha512-km2Jl0iLoTDHWoj8exQRcVBD+cNZ9sXplUVMyEpKAeWEEFjfSCV6J1Zbpz4doYUHeOxDem5fI1Cr42Pw+xtlMQ==", + "dev": true, + "requires": { + "chalk": "2.x", + "google-closure-compiler-java": "^20210907.0.0", + "google-closure-compiler-linux": "^20210907.0.0", + "google-closure-compiler-osx": "^20210907.0.0", + "google-closure-compiler-windows": "^20210907.0.0", + "minimist": "1.x", + "vinyl": "2.x", + "vinyl-sourcemaps-apply": "^0.2.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "google-closure-compiler-java": { + "version": "20210907.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-java/-/google-closure-compiler-java-20210907.0.0.tgz", + "integrity": "sha512-ASIR8rf3d3Qrf6qHQdLelPHIGRZBnT+AZ9SDT/cLCTYwvvWZhUxh5r4/v6ZAr3XGBbZpX4rgBDa0tZOmpgeRYQ==", + "dev": true + }, + "google-closure-compiler-linux": { + "version": "20210907.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-linux/-/google-closure-compiler-linux-20210907.0.0.tgz", + "integrity": "sha512-hnb3zrXtvdIpC7J+zUdOGyhW7zuk2NYps2J4G6EzVqQ+w1Mp22bhwdeFWeMp/DxueGJn8oenQNSXAANJKOxpiA==", + "dev": true, + "optional": true + }, + "google-closure-compiler-osx": { + "version": "20210907.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-osx/-/google-closure-compiler-osx-20210907.0.0.tgz", + "integrity": "sha512-38dOzEJEt82nXeiIvCiV4rEzX06rdG/4bELg9PpGpGYDLzx4d4ielBNgsflKdkQ2rtvIZY06NsO733knS8gXRQ==", + "dev": true, + "optional": true + }, + "google-closure-compiler-windows": { + "version": "20210907.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-windows/-/google-closure-compiler-windows-20210907.0.0.tgz", + "integrity": "sha512-KJ9baxBaKeo4L5fn8v++vZyclzLQYYStw3fLhEcfW6xU3z6JOHpovN1Ff+DnAljRZhjJ2JbOeB5wg1dy4zkMNA==", + "dev": true, + "optional": true + }, "got": { "version": "9.6.0", "resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz", @@ -3643,6 +3826,18 @@ } } }, + "remove-trailing-separator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "dev": true + }, + "replace-ext": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.1.tgz", + "integrity": "sha512-yD5BHCe7quCgBph4rMQ+0KkIRKwWCrHDOX1p1Gp6HwjPM5kVoCdKGNhN7ydqqsX6lJEnQDKZ/tFMiEdQ1dvPEw==", + "dev": true + }, "request": { "version": "2.88.2", "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", @@ -4325,6 +4520,12 @@ "integrity": "sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==", "dev": true }, + "unquoted-property-validator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/unquoted-property-validator/-/unquoted-property-validator-1.1.0.tgz", + "integrity": "sha512-ZWeQoYZ7HN8DCLeaowNv2GvZIXqJptKB1uUWd08ZYc1qAmJt8tXh9nck26aoYmhJtE3jCjDqdqEfUTqcJ0R7bw==", + "dev": true + }, "upath": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/upath/-/upath-2.0.1.tgz", @@ -4400,6 +4601,45 @@ "extsprintf": "^1.2.0" } }, + "vinyl": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.1.tgz", + "integrity": "sha512-LII3bXRFBZLlezoG5FfZVcXflZgWP/4dCwKtxd5ky9+LOtM4CS3bIRQsmR1KMnMW07jpE8fqR2lcxPZ+8sJIcw==", + "dev": true, + "requires": { + "clone": "^2.1.1", + "clone-buffer": "^1.0.0", + "clone-stats": "^1.0.0", + "cloneable-readable": "^1.0.0", + "remove-trailing-separator": "^1.0.1", + "replace-ext": "^1.0.0" + }, + "dependencies": { + "clone": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=", + "dev": true + } + } + }, + "vinyl-sourcemaps-apply": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz", + "integrity": "sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU=", + "dev": true, + "requires": { + "source-map": "^0.5.1" + }, + "dependencies": { + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + } + } + }, "watchpack": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.2.0.tgz", diff --git a/package.json b/package.json index 463e100..28518b4 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,8 @@ "author": "Benjamin Cooper", "license": "SEE LICENSE IN LICENSE.MD", "devDependencies": { + "closure-webpack-plugin": "^2.5.0", + "google-closure-compiler": "^20210907.0.0", "web-ext": "^6.1.0", "webpack": "^5", "webpack-cli": "^4" diff --git a/webpack.config.js b/webpack.config.js index 9a57df1..bb937ff 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,12 +1,14 @@ -const path = require('path'); +const path = require("path"); +const ClosurePlugin = require('closure-webpack-plugin'); module.exports = { + optimization: { minimizer: [new ClosurePlugin({ mode: "STANDARD" }, {})] }, entry: { - addon: './index.js', + addon: "./index.js", }, output: { - path: path.resolve(__dirname, './'), - filename: '[name]/index.js', + path: path.resolve(__dirname, "./"), + filename: "[name]/index.js", }, optimization: { usedExports: true }, }; From 8b4e5c434decc51313a3d7f87a320b98315363dd Mon Sep 17 00:00:00 2001 From: Ben Cooper Date: Tue, 21 Sep 2021 20:22:00 -0700 Subject: [PATCH 2/9] first build with closure compiler --- addon/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/index.js b/addon/index.js index f742dee..f78a894 100644 --- a/addon/index.js +++ b/addon/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -(()=>{var e={977:function(e,t){var r;!function(n){"use strict";var i=function(e){return.5*(Math.exp(e)+Math.exp(-e))},a=function(e){return.5*(Math.exp(e)-Math.exp(-e))},o=function(){throw SyntaxError("Invalid Param")};function s(e,t){var r=Math.abs(e),n=Math.abs(t);return 0===e?Math.log(n):0===t?Math.log(r):r<3e3&&n<3e3?.5*Math.log(e*e+t*t):Math.log(e/Math.cos(Math.atan2(t,e)))}function u(e,t){if(!(this instanceof u))return new u(e,t);var r=function(e,t){var r={re:0,im:0};if(null==e)r.re=r.im=0;else if(void 0!==t)r.re=e,r.im=t;else switch(typeof e){case"object":if("im"in e&&"re"in e)r.re=e.re,r.im=e.im;else if("abs"in e&&"arg"in e){if(!Number.isFinite(e.abs)&&Number.isFinite(e.arg))return u.INFINITY;r.re=e.abs*Math.cos(e.arg),r.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!Number.isFinite(e.r)&&Number.isFinite(e.phi))return u.INFINITY;r.re=e.r*Math.cos(e.phi),r.im=e.r*Math.sin(e.phi)}else 2===e.length?(r.re=e[0],r.im=e[1]):o();break;case"string":r.im=r.re=0;var n=e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),i=1,a=0;null===n&&o();for(var s=0;s0&&o();break;case"number":r.im=0,r.re=e;break;default:o()}return isNaN(r.re)||isNaN(r.im),r}(e,t);this.re=r.re,this.im=r.im}u.prototype={re:0,im:0,sign:function(){var e=this.abs();return new u(this.re/e,this.im/e)},add:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:new u(this.re+r.re,this.im+r.im)},sub:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:new u(this.re-r.re,this.im-r.im)},mul:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isZero()||this.isZero()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:0===r.im&&0===this.im?new u(this.re*r.re,0):new u(this.re*r.re-this.im*r.im,this.re*r.im+this.im*r.re)},div:function(e,t){var r=new u(e,t);if(this.isZero()&&r.isZero()||this.isInfinite()&&r.isInfinite())return u.NAN;if(this.isInfinite()||r.isZero())return u.INFINITY;if(this.isZero()||r.isInfinite())return u.ZERO;e=this.re,t=this.im;var n,i,a=r.re,o=r.im;return 0===o?new u(e/a,t/a):Math.abs(a)0)return new u(Math.pow(e,r.re),0);if(0===e)switch((r.re%4+4)%4){case 0:return new u(Math.pow(t,r.re),0);case 1:return new u(0,Math.pow(t,r.re));case 2:return new u(-Math.pow(t,r.re),0);case 3:return new u(0,-Math.pow(t,r.re))}}if(0===e&&0===t&&r.re>0&&r.im>=0)return u.ZERO;var n=Math.atan2(t,e),i=s(e,t);return e=Math.exp(r.re*i-r.im*n),t=r.im*i+r.re*n,new u(e*Math.cos(t),e*Math.sin(t))},sqrt:function(){var e,t,r=this.re,n=this.im,i=this.abs();if(r>=0){if(0===n)return new u(Math.sqrt(r),0);e=.5*Math.sqrt(2*(i+r))}else e=Math.abs(n)/Math.sqrt(2*(i-r));return t=r<=0?.5*Math.sqrt(2*(i-r)):Math.abs(n)/Math.sqrt(2*(i+r)),new u(e,n<0?-t:t)},exp:function(){var e=Math.exp(this.re);return this.im,new u(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){var e=this.re,t=this.im;return new u(Math.expm1(e)*Math.cos(t)+function(e){var t=Math.PI/4;if(e<-t||e>t)return Math.cos(e)-1;var r=e*e;return r*(r*(1/24+r*(-1/720+r*(1/40320+r*(-1/3628800+r*(1/4790014600+r*(-1/87178291200+r*(1/20922789888e3)))))))-.5)}(t),Math.exp(e)*Math.sin(t))},log:function(){var e=this.re,t=this.im;return new u(s(e,t),Math.atan2(t,e))},abs:function(){return e=this.re,t=this.im,r=Math.abs(e),n=Math.abs(t),r<3e3&&n<3e3?Math.sqrt(r*r+n*n):(r1&&0===t,n=1-e,i=1+e,a=n*n+t*t,o=0!==a?new u((i*n-t*t)/a,(t*n+i*t)/a):new u(-1!==e?e/0:0,0!==t?t/0:0),c=o.re;return o.re=s(o.re,o.im)/2,o.im=Math.atan2(o.im,c)/2,r&&(o.im=-o.im),o},acoth:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new u(0,Math.PI/2);var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).atanh():new u(0!==e?e/0:0,0!==t?-t/0:0).atanh()},acsch:function(){var e=this.re,t=this.im;if(0===t)return new u(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).asinh():new u(0!==e?e/0:0,0!==t?-t/0:0).asinh()},asech:function(){var e=this.re,t=this.im;if(this.isZero())return u.INFINITY;var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).acosh():new u(0!==e?e/0:0,0!==t?-t/0:0).acosh()},inverse:function(){if(this.isZero())return u.INFINITY;if(this.isInfinite())return u.ZERO;var e=this.re,t=this.im,r=e*e+t*t;return new u(e/r,-t/r)},conjugate:function(){return new u(this.re,-this.im)},neg:function(){return new u(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new u(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new u(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new u(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){var r=new u(e,t);return Math.abs(r.re-this.re)<=u.EPSILON&&Math.abs(r.im-this.im)<=u.EPSILON},clone:function(){return new u(this.re,this.im)},toString:function(){var e=this.re,t=this.im,r="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)0){for(a+=o,t=1;tr)throw Error(y+e)}function B(e,t,r,n){var i,a,o,s;for(a=e[0];a>=10;a/=10)--t;return--t<0?(t+=7,i=0):(i=Math.ceil((t+1)/7),t%=7),a=b(10,7-t),s=e[i]%a|0,null==n?t<3?(0==t?s=s/100|0:1==t&&(s=s/10|0),o=r<4&&99999==s||r>3&&49999==s||5e4==s||0==s):o=(r<4&&s+1==a||r>3&&s+1==a/2)&&(e[i+1]/a/100|0)==b(10,t-2)-1||(s==a/2||0==s)&&0==(e[i+1]/a/100|0):t<4?(0==t?s=s/1e3|0:1==t?s=s/100|0:2==t&&(s=s/10|0),o=(n||r<4)&&9999==s||!n&&r>3&&4999==s):o=((n||r<4)&&s+1==a||!n&&r>3&&s+1==a/2)&&(e[i+1]/a/1e3|0)==b(10,t-3)-1,o}function q(e,t,r){for(var n,i,a=[0],o=0,s=e.length;or-1&&(void 0===a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/r|0,a[n]%=r)}return a.reverse()}C.absoluteValue=C.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),D(e)},C.ceil=function(){return D(new this.constructor(this),this.e+1,2)},C.comparedTo=C.cmp=function(e){var t,r,n,i,a=this,o=a.d,s=(e=new a.constructor(e)).d,u=a.s,c=e.s;if(!o||!s)return u&&c?u!==c?u:o===s?0:!o^u<0?1:-1:NaN;if(!o[0]||!s[0])return o[0]?u:s[0]?-c:0;if(u!==c)return u;if(a.e!==e.e)return a.e>e.e^u<0?1:-1;for(t=0,r=(n=o.length)<(i=s.length)?n:i;ts[t]^u<0?1:-1;return n===i?0:n>i^u<0?1:-1},C.cosine=C.cos=function(){var e,t,r=this,n=r.constructor;return r.d?r.d[0]?(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(e,t){var r,n,i=t.d.length;i<32?n=(1/Y(4,r=Math.ceil(i/3))).toString():(r=16,n="2.3283064365386962890625e-10"),e.precision+=r,t=J(e,1,t.times(n),new e(1));for(var a=r;a--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=r,t}(n,X(n,r)),n.precision=e,n.rounding=t,D(2==s||3==s?r.neg():r,e,t,!0)):new n(1):new n(NaN)},C.cubeRoot=C.cbrt=function(){var e,t,r,n,i,a,o,s,u,c,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(h=!1,(a=l.s*b(l.s*l,1/3))&&Math.abs(a)!=1/0?n=new f(a.toString()):(r=_(l.d),(a=((e=l.e)-r.length+1)%3)&&(r+=1==a||-2==a?"0":"00"),a=b(r,1/3),e=x((e+1)/3)-(e%3==(e<0?-1:2)),(n=new f(r=a==1/0?"5e"+e:(r=a.toExponential()).slice(0,r.indexOf("e")+1)+e)).s=l.s),o=(e=f.precision)+3;;)if(c=(u=(s=n).times(s).times(s)).plus(l),n=z(c.plus(l).times(s),c.plus(u),o+2,1),_(s.d).slice(0,o)===(r=_(n.d)).slice(0,o)){if("9999"!=(r=r.slice(o-3,o+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(D(n,e+1,1),t=!n.times(n).times(n).eq(l));break}if(!i&&(D(s,e+1,0),s.times(s).times(s).eq(l))){n=s;break}o+=4,i=1}return h=!0,D(n,e,f.rounding,t)},C.decimalPlaces=C.dp=function(){var e,t=this.d,r=NaN;if(t){if(r=7*((e=t.length-1)-x(this.e/7)),e=t[e])for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r},C.dividedBy=C.div=function(e){return z(this,new this.constructor(e))},C.dividedToIntegerBy=C.divToInt=function(e){var t=this.constructor;return D(z(this,new t(e),0,1,1),t.precision,t.rounding)},C.equals=C.eq=function(e){return 0===this.cmp(e)},C.floor=function(){return D(new this.constructor(this),this.e+1,3)},C.greaterThan=C.gt=function(e){return this.cmp(e)>0},C.greaterThanOrEqualTo=C.gte=function(e){var t=this.cmp(e);return 1==t||0===t},C.hyperbolicCosine=C.cosh=function(){var e,t,r,n,i,a=this,o=a.constructor,s=new o(1);if(!a.isFinite())return new o(a.s?1/0:NaN);if(a.isZero())return s;r=o.precision,n=o.rounding,o.precision=r+Math.max(a.e,a.sd())+4,o.rounding=1,(i=a.d.length)<32?t=(1/Y(4,e=Math.ceil(i/3))).toString():(e=16,t="2.3283064365386962890625e-10"),a=J(o,1,a.times(t),new o(1),!0);for(var u,c=e,l=new o(8);c--;)u=a.times(a),a=s.minus(u.times(l.minus(u.times(l))));return D(a,o.precision=r,o.rounding=n,!0)},C.hyperbolicSine=C.sinh=function(){var e,t,r,n,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.precision,r=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,(n=i.d.length)<3)i=J(a,2,i,i,!0);else{e=(e=1.4*Math.sqrt(n))>16?16:0|e,i=J(a,2,i=i.times(1/Y(5,e)),i,!0);for(var o,s=new a(5),u=new a(16),c=new a(20);e--;)o=i.times(i),i=i.times(s.plus(o.times(u.times(o).plus(c))))}return a.precision=t,a.rounding=r,D(i,t,r,!0)},C.hyperbolicTangent=C.tanh=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+7,n.rounding=1,z(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)},C.inverseCosine=C.acos=function(){var e,t=this,r=t.constructor,n=t.abs().cmp(1),i=r.precision,a=r.rounding;return-1!==n?0===n?t.isNeg()?F(r,i,a):new r(0):new r(NaN):t.isZero()?F(r,i+4,a).times(.5):(r.precision=i+6,r.rounding=1,t=t.asin(),e=F(r,i+4,a).times(.5),r.precision=i,r.rounding=a,e.minus(t))},C.inverseHyperbolicCosine=C.acosh=function(){var e,t,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(e=n.precision,t=n.rounding,n.precision=e+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,h=!1,r=r.times(r).minus(1).sqrt().plus(r),h=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)},C.inverseHyperbolicSine=C.asinh=function(){var e,t,r=this,n=r.constructor;return!r.isFinite()||r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,h=!1,r=r.times(r).plus(1).sqrt().plus(r),h=!0,n.precision=e,n.rounding=t,r.ln())},C.inverseHyperbolicTangent=C.atanh=function(){var e,t,r,n,i=this,a=i.constructor;return i.isFinite()?i.e>=0?new a(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=a.precision,t=a.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?D(new a(i),e,t,!0):(a.precision=r=n-i.e,i=z(i.plus(1),new a(1).minus(i),r+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=t,i.times(.5))):new a(NaN)},C.inverseSine=C.asin=function(){var e,t,r,n,i=this,a=i.constructor;return i.isZero()?new a(i):(t=i.abs().cmp(1),r=a.precision,n=a.rounding,-1!==t?0===t?((e=F(a,r+4,n).times(.5)).s=i.s,e):new a(NaN):(a.precision=r+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=r,a.rounding=n,i.times(2)))},C.inverseTangent=C.atan=function(){var e,t,r,n,i,a,o,s,u,c=this,l=c.constructor,f=l.precision,p=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&f+4<=O)return(o=F(l,f+4,p).times(.25)).s=c.s,o}else{if(!c.s)return new l(NaN);if(f+4<=O)return(o=F(l,f+4,p).times(.5)).s=c.s,o}for(l.precision=s=f+10,l.rounding=1,e=r=Math.min(28,s/7+2|0);e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(h=!1,t=Math.ceil(s/7),n=1,u=c.times(c),o=new l(c),i=c;-1!==e;)if(i=i.times(u),a=o.minus(i.div(n+=2)),i=i.times(u),void 0!==(o=a.plus(i.div(n+=2))).d[t])for(e=t;o.d[e]===a.d[e]&&e--;);return r&&(o=o.times(2<this.d.length-2},C.isNaN=function(){return!this.s},C.isNegative=C.isNeg=function(){return this.s<0},C.isPositive=C.isPos=function(){return this.s>0},C.isZero=function(){return!!this.d&&0===this.d[0]},C.lessThan=C.lt=function(e){return this.cmp(e)<0},C.lessThanOrEqualTo=C.lte=function(e){return this.cmp(e)<1},C.logarithm=C.log=function(e){var t,r,n,i,a,o,s,u,c=this,l=c.constructor,f=l.precision,p=l.rounding;if(null==e)e=new l(10),t=!0;else{if(r=(e=new l(e)).d,e.s<0||!r||!r[0]||e.eq(1))return new l(NaN);t=e.eq(10)}if(r=c.d,c.s<0||!r||!r[0]||c.eq(1))return new l(r&&!r[0]?-1/0:1!=c.s?NaN:r?0:1/0);if(t)if(r.length>1)a=!0;else{for(i=r[0];i%10==0;)i/=10;a=1!==i}if(h=!1,o=G(c,s=f+5),n=t?R(l,s+10):G(e,s),B((u=z(o,n,s,1)).d,i=f,p))do{if(o=G(c,s+=10),n=t?R(l,s+10):G(e,s),u=z(o,n,s,1),!a){+_(u.d).slice(i+1,i+15)+1==1e14&&(u=D(u,f+1,0));break}}while(B(u.d,i+=10,p));return h=!0,D(u,f,p)},C.minus=C.sub=function(e){var t,r,n,i,a,o,s,u,c,l,f,p,m=this,d=m.constructor;if(e=new d(e),!m.d||!e.d)return m.s&&e.s?m.d?e.s=-e.s:e=new d(e.d||m.s!==e.s?m:NaN):e=new d(NaN),e;if(m.s!=e.s)return e.s=-e.s,m.plus(e);if(c=m.d,p=e.d,s=d.precision,u=d.rounding,!c[0]||!p[0]){if(p[0])e.s=-e.s;else{if(!c[0])return new d(3===u?-0:0);e=new d(m)}return h?D(e,s,u):e}if(r=x(e.e/7),l=x(m.e/7),c=c.slice(),a=l-r){for((f=a<0)?(t=c,a=-a,o=p.length):(t=p,r=l,o=c.length),a>(n=Math.max(Math.ceil(s/7),o)+2)&&(a=n,t.length=1),t.reverse(),n=a;n--;)t.push(0);t.reverse()}else{for((f=(n=c.length)<(o=p.length))&&(o=n),n=0;n0;--n)c[o++]=0;for(n=p.length;n>a;){if(c[--n](o=(a=Math.ceil(s/7))>o?a+1:o+1)&&(i=o,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for((o=c.length)-(i=l.length)<0&&(i=o,r=l,l=c,c=r),t=0;i;)t=(c[--i]=c[i]+l[i]+t)/E|0,c[i]%=E;for(t&&(c.unshift(t),++n),o=c.length;0==c[--o];)c.pop();return e.d=c,e.e=k(c,n),h?D(e,s,u):e},C.precision=C.sd=function(e){var t,r=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(y+e);return r.d?(t=U(r.d),e&&r.e+1>t&&(t=r.e+1)):t=NaN,t},C.round=function(){var e=this,t=e.constructor;return D(new t(e),e.e+1,t.rounding)},C.sine=C.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(e,t){var r,n=t.d.length;if(n<3)return J(e,2,t,t);r=(r=1.4*Math.sqrt(n))>16?16:0|r,t=J(e,2,t=t.times(1/Y(5,r)),t);for(var i,a=new e(5),o=new e(16),s=new e(20);r--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}(n,X(n,r)),n.precision=e,n.rounding=t,D(s>2?r.neg():r,e,t,!0)):new n(NaN)},C.squareRoot=C.sqrt=function(){var e,t,r,n,i,a,o=this,s=o.d,u=o.e,c=o.s,l=o.constructor;if(1!==c||!s||!s[0])return new l(!c||c<0&&(!s||s[0])?NaN:s?o:1/0);for(h=!1,0==(c=Math.sqrt(+o))||c==1/0?(((t=_(s)).length+u)%2==0&&(t+="0"),c=Math.sqrt(t),u=x((u+1)/2)-(u<0||u%2),n=new l(t=c==1/0?"5e"+u:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+u)):n=new l(c.toString()),r=(u=l.precision)+3;;)if(n=(a=n).plus(z(o,a,r+2,1)).times(.5),_(a.d).slice(0,r)===(t=_(n.d)).slice(0,r)){if("9999"!=(t=t.slice(r-3,r+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(D(n,u+1,1),e=!n.times(n).eq(o));break}if(!i&&(D(a,u+1,0),a.times(a).eq(o))){n=a;break}r+=4,i=1}return h=!0,D(n,u,l.rounding,e)},C.tangent=C.tan=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+10,n.rounding=1,(r=r.sin()).s=1,r=z(r,new n(1).minus(r.times(r)).sqrt(),e+10,0),n.precision=e,n.rounding=t,D(2==s||4==s?r.neg():r,e,t,!0)):new n(NaN)},C.times=C.mul=function(e){var t,r,n,i,a,o,s,u,c,l=this,f=l.constructor,p=l.d,m=(e=new f(e)).d;if(e.s*=l.s,!(p&&p[0]&&m&&m[0]))return new f(!e.s||p&&!p[0]&&!m||m&&!m[0]&&!p?NaN:p&&m?0*e.s:e.s/0);for(r=x(l.e/7)+x(e.e/7),(u=p.length)<(c=m.length)&&(a=p,p=m,m=a,o=u,u=c,c=o),a=[],n=o=u+c;n--;)a.push(0);for(n=c;--n>=0;){for(t=0,i=u+n;i>n;)s=a[i]+m[n]*p[i-n-1]+t,a[i--]=s%E|0,t=s/E|0;a[i]=(a[i]+t)%E|0}for(;!a[--o];)a.pop();return t?++r:a.shift(),e.d=a,e.e=k(a,r),h?D(e,f.precision,f.rounding):e},C.toBinary=function(e,t){return Q(this,2,e,t)},C.toDecimalPlaces=C.toDP=function(e,t){var r=this,n=r.constructor;return r=new n(r),void 0===e?r:(T(e,0,c),void 0===t?t=n.rounding:T(t,0,8),D(r,e+r.e+1,t))},C.toExponential=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=I(n,!0):(T(e,0,c),void 0===t?t=i.rounding:T(t,0,8),r=I(n=D(new i(n),e+1,t),!0,e+1)),n.isNeg()&&!n.isZero()?"-"+r:r},C.toFixed=function(e,t){var r,n,i=this,a=i.constructor;return void 0===e?r=I(i):(T(e,0,c),void 0===t?t=a.rounding:T(t,0,8),r=I(n=D(new a(i),e+i.e+1,t),!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r},C.toFraction=function(e){var t,r,n,i,a,o,s,u,c,l,f,p,m=this,d=m.d,g=m.constructor;if(!d)return new g(m);if(c=r=new g(1),n=u=new g(0),o=(a=(t=new g(n)).e=U(d)-m.e-1)%7,t.d[0]=b(10,o<0?7+o:o),null==e)e=a>0?t:c;else{if(!(s=new g(e)).isInt()||s.lt(c))throw Error(y+s);e=s.gt(t)?a>0?t:c:s}for(h=!1,s=new g(_(d)),l=g.precision,g.precision=a=7*d.length*2;f=z(s,t,0,1,1),1!=(i=r.plus(f.times(n))).cmp(e);)r=n,n=i,i=c,c=u.plus(f.times(i)),u=i,i=t,t=s.minus(f.times(i)),s=i;return i=z(e.minus(r),n,0,1,1),u=u.plus(i.times(c)),r=r.plus(i.times(n)),u.s=c.s=m.s,p=z(c,n,a,1).minus(m).abs().cmp(z(u,r,a,1).minus(m).abs())<1?[c,n]:[u,r],g.precision=l,h=!0,p},C.toHexadecimal=C.toHex=function(e,t){return Q(this,16,e,t)},C.toNearest=function(e,t){var r=this,n=r.constructor;if(r=new n(r),null==e){if(!r.d)return r;e=new n(1),t=n.rounding}else{if(e=new n(e),void 0===t?t=n.rounding:T(t,0,8),!r.d)return e.s?r:e;if(!e.d)return e.s&&(e.s=r.s),e}return e.d[0]?(h=!1,r=z(r,e,0,t,1).times(e),h=!0,D(r)):(e.s=r.s,r=e),r},C.toNumber=function(){return+this},C.toOctal=function(e,t){return Q(this,8,e,t)},C.toPower=C.pow=function(e){var t,r,n,i,a,o,s=this,u=s.constructor,c=+(e=new u(e));if(!(s.d&&e.d&&s.d[0]&&e.d[0]))return new u(b(+s,c));if((s=new u(s)).eq(1))return s;if(n=u.precision,a=u.rounding,e.eq(1))return D(s,n,a);if((t=x(e.e/7))>=e.d.length-1&&(r=c<0?-c:c)<=9007199254740991)return i=j(u,s,r,n),e.s<0?new u(1).div(i):D(i,n,a);if((o=s.s)<0){if(tu.maxE+1||t0?o/0:0):(h=!1,u.rounding=s.s=1,r=Math.min(12,(t+"").length),(i=$(e.times(G(s,n+r)),n)).d&&B((i=D(i,n+5,1)).d,n,a)&&(t=n+10,+_((i=D($(e.times(G(s,t+r)),t),t+5,1)).d).slice(n+1,n+15)+1==1e14&&(i=D(i,n+1,0))),i.s=o,h=!0,u.rounding=a,D(i,n,a))},C.toPrecision=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=I(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(T(e,1,c),void 0===t?t=i.rounding:T(t,0,8),r=I(n=D(new i(n),e,t),e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+r:r},C.toSignificantDigits=C.toSD=function(e,t){var r=this.constructor;return void 0===e?(e=r.precision,t=r.rounding):(T(e,1,c),void 0===t?t=r.rounding:T(t,0,8)),D(new r(this),e,t)},C.toString=function(){var e=this,t=e.constructor,r=I(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r},C.truncated=C.trunc=function(){return D(new this.constructor(this),this.e+1,1)},C.valueOf=C.toJSON=function(){var e=this,t=e.constructor,r=I(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};var z=function(){function e(e,t,r){var n,i=0,a=e.length;for(e=e.slice();a--;)n=e[a]*t+i,e[a]=n%r|0,i=n/r|0;return i&&e.unshift(i),e}function t(e,t,r,n){var i,a;if(r!=n)a=r>n?1:-1;else for(i=a=0;it[i]?1:-1;break}return a}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]1;)e.shift()}return function(n,i,a,s,u,c){var l,f,p,m,h,d,y,g,v,b,w,N,M,S,A,O,C,_,T,B,q=n.constructor,z=n.s==i.s?1:-1,I=n.d,k=i.d;if(!(I&&I[0]&&k&&k[0]))return new q(n.s&&i.s&&(I?!k||I[0]!=k[0]:k)?I&&0==I[0]||!k?0*z:z/0:NaN);for(c?(h=1,f=n.e-i.e):(c=E,h=7,f=x(n.e/h)-x(i.e/h)),T=k.length,C=I.length,b=(v=new q(z)).d=[],p=0;k[p]==(I[p]||0);p++);if(k[p]>(I[p]||0)&&f--,null==a?(S=a=q.precision,s=q.rounding):S=u?a+(n.e-i.e)+1:a,S<0)b.push(1),d=!0;else{if(S=S/h+2|0,p=0,1==T){for(m=0,k=k[0],S++;(p1&&(k=e(k,m,c),I=e(I,m,c),T=k.length,C=I.length),O=T,N=(w=I.slice(0,T)).length;N=c/2&&++_;do{m=0,(l=t(k,w,T,N))<0?(M=w[0],T!=N&&(M=M*c+(w[1]||0)),(m=M/_|0)>1?(m>=c&&(m=c-1),1==(l=t(y=e(k,m,c),w,g=y.length,N=w.length))&&(m--,r(y,T=10;m/=10)p++;v.e=p+f*h-1,D(v,u?a+v.e+1:a,s,d)}return v}}();function D(e,t,r,n){var i,a,o,s,u,c,l,f,p,m=e.constructor;e:if(null!=t){if(!(f=e.d))return e;for(i=1,s=f[0];s>=10;s/=10)i++;if((a=t-i)<0)a+=7,o=t,u=(l=f[p=0])/b(10,i-o-1)%10|0;else if((p=Math.ceil((a+1)/7))>=(s=f.length)){if(!n)break e;for(;s++<=p;)f.push(0);l=u=0,i=1,o=(a%=7)-7+1}else{for(l=s=f[p],i=1;s>=10;s/=10)i++;u=(o=(a%=7)-7+i)<0?0:l/b(10,i-o-1)%10|0}if(n=n||t<0||void 0!==f[p+1]||(o<0?l:l%b(10,i-o-1)),c=r<4?(u||n)&&(0==r||r==(e.s<0?3:2)):u>5||5==u&&(4==r||n||6==r&&(a>0?o>0?l/b(10,i-o):0:f[p-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,c?(t-=e.e+1,f[0]=b(10,(7-t%7)%7),e.e=-t||0):f[0]=e.e=0,e;if(0==a?(f.length=p,s=1,p--):(f.length=p+1,s=b(10,7-a),f[p]=o>0?(l/b(10,i-o)%b(10,o)|0)*s:0),c)for(;;){if(0==p){for(a=1,o=f[0];o>=10;o/=10)a++;for(o=f[0]+=s,s=1;o>=10;o/=10)s++;a!=s&&(e.e++,f[0]==E&&(f[0]=1));break}if(f[p]+=s,f[p]!=E)break;f[p--]=0,s=1}for(a=f.length;0===f[--a];)f.pop()}return h&&(e.e>m.maxE?(e.d=null,e.e=NaN):e.e0?a=a.charAt(0)+"."+a.slice(1)+P(n):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(e.e<0?"e":"e+")+e.e):i<0?(a="0."+P(-i-1)+a,r&&(n=r-o)>0&&(a+=P(n))):i>=o?(a+=P(i+1-o),r&&(n=r-i-1)>0&&(a=a+"."+P(n))):((n=i+1)0&&(i+1===o&&(a+="."),a+=P(n))),a}function k(e,t){var r=e[0];for(t*=7;r>=10;r/=10)t++;return t}function R(e,t,r){if(t>A)throw h=!0,r&&(e.precision=r),Error(g);return D(new e(f),t,1,!0)}function F(e,t,r){if(t>O)throw Error(g);return D(new e(p),t,r,!0)}function U(e){var t=e.length-1,r=7*t+1;if(t=e[t]){for(;t%10==0;t/=10)r--;for(t=e[0];t>=10;t/=10)r++}return r}function P(e){for(var t="";e--;)t+="0";return t}function j(e,t,r,n){var i,a=new e(1),o=Math.ceil(n/7+4);for(h=!1;;){if(r%2&&K((a=a.times(t)).d,o)&&(i=!0),0===(r=x(r/2))){r=a.d.length-1,i&&0===a.d[r]&&++a.d[r];break}K((t=t.times(t)).d,o)}return h=!0,a}function L(e){return 1&e.d[e.d.length-1]}function H(e,t,r){for(var n,i=new e(t[0]),a=0;++a17)return new p(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(h=!1,u=d):u=t,s=new p(.03125);e.e>-2;)e=e.times(s),f+=5;for(u+=n=Math.log(b(2,f))/Math.LN10*2+5|0,r=a=o=new p(1),p.precision=u;;){if(a=D(a.times(e),u,1),r=r.times(++l),_((s=o.plus(z(a,r,u,1))).d).slice(0,u)===_(o.d).slice(0,u)){for(i=f;i--;)o=D(o.times(o),u,1);if(null!=t)return p.precision=d,o;if(!(c<3&&B(o.d,u-n,m,c)))return D(o,p.precision=d,m,h=!0);p.precision=u+=10,r=a=s=new p(1),l=0,c++}o=s}}function G(e,t){var r,n,i,a,o,s,u,c,l,f,p,m=1,d=e,y=d.d,g=d.constructor,v=g.rounding,x=g.precision;if(d.s<0||!y||!y[0]||!d.e&&1==y[0]&&1==y.length)return new g(y&&!y[0]?-1/0:1!=d.s?NaN:y?0:d);if(null==t?(h=!1,l=x):l=t,g.precision=l+=10,n=(r=_(y)).charAt(0),!(Math.abs(a=d.e)<15e14))return c=R(g,l+2,x).times(a+""),d=G(new g(n+"."+r.slice(1)),l-10).plus(c),g.precision=x,null==t?D(d,x,v,h=!0):d;for(;n<7&&1!=n||1==n&&r.charAt(1)>3;)n=(r=_((d=d.times(e)).d)).charAt(0),m++;for(a=d.e,n>1?(d=new g("0."+r),a++):d=new g(n+"."+r.slice(1)),f=d,u=o=d=z(d.minus(1),d.plus(1),l,1),p=D(d.times(d),l,1),i=3;;){if(o=D(o.times(p),l,1),_((c=u.plus(z(o,new g(i),l,1))).d).slice(0,l)===_(u.d).slice(0,l)){if(u=u.times(2),0!==a&&(u=u.plus(R(g,l+2,x).times(a+""))),u=z(u,new g(m),l,1),null!=t)return g.precision=x,u;if(!B(u.d,l-10,v,s))return D(u,g.precision=x,v,h=!0);g.precision=l+=10,c=o=d=z(f.minus(1),f.plus(1),l,1),p=D(d.times(d),l,1),i=s=1}u=c,i+=2}}function V(e){return String(e.s*e.s/0)}function Z(e,t){var r,n,i;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;48===t.charCodeAt(n);n++);for(i=t.length;48===t.charCodeAt(i-1);--i);if(t=t.slice(n,i)){if(i-=n,e.e=r=r-n-1,e.d=[],n=(r+1)%7,r<0&&(n+=7),ne.constructor.maxE?(e.d=null,e.e=NaN):e.e0?(c=+t.slice(o+1),t=t.substring(2,o)):t=t.slice(2),s=(o=t.indexOf("."))>=0,n=e.constructor,s&&(o=(u=(t=t.replace(".","")).length)-o,i=j(n,new n(r),o,2*o)),o=f=(l=q(t,r,E)).length-1;0===l[o];--o)l.pop();return o<0?new n(0*e.s):(e.e=k(l,f),e.d=l,h=!1,s&&(e=z(e,i,4*u)),c&&(e=e.times(Math.abs(c)<54?b(2,c):a.pow(2,c))),h=!0,e)}function J(e,t,r,n,i){var a,o,s,u,c=e.precision,l=Math.ceil(c/7);for(h=!1,u=r.times(r),s=new e(n);;){if(o=z(s.times(u),new e(t++*t++),c,1),s=i?n.plus(o):n.minus(o),n=z(o.times(u),new e(t++*t++),c,1),void 0!==(o=s.plus(n)).d[l]){for(a=l;o.d[a]===s.d[a]&&a--;);if(-1==a)break}a=s,s=n,n=o,o=a}return h=!0,o.d.length=l+1,o}function Y(e,t){for(var r=e;--t;)r*=e;return r}function X(e,t){var r,n=t.s<0,i=F(e,e.precision,1),a=i.times(.5);if((t=t.abs()).lte(a))return s=n?4:1,t;if((r=t.divToInt(i)).isZero())s=n?3:2;else{if((t=t.minus(r.times(i))).lte(a))return s=L(r)?n?2:3:n?4:1,t;s=L(r)?n?1:4:n?3:2}return t.minus(i).abs()}function Q(e,t,r,n){var i,a,s,u,f,p,m,h,d,y=e.constructor,g=void 0!==r;if(g?(T(r,1,c),void 0===n?n=y.rounding:T(n,0,8)):(r=y.precision,n=y.rounding),e.isFinite()){for(g?(i=2,16==t?r=4*r-3:8==t&&(r=3*r-2)):i=t,(s=(m=I(e)).indexOf("."))>=0&&(m=m.replace(".",""),(d=new y(1)).e=m.length-s,d.d=q(I(d),10,i),d.e=d.d.length),a=f=(h=q(m,10,i)).length;0==h[--f];)h.pop();if(h[0]){if(s<0?a--:((e=new y(e)).d=h,e.e=a,h=(e=z(e,d,r,n,0,i)).d,a=e.e,p=o),s=h[r],u=i/2,p=p||void 0!==h[r+1],p=n<4?(void 0!==s||p)&&(0===n||n===(e.s<0?3:2)):s>u||s===u&&(4===n||p||6===n&&1&h[r-1]||n===(e.s<0?8:7)),h.length=r,p)for(;++h[--r]>i-1;)h[r]=0,r||(++a,h.unshift(1));for(f=h.length;!h[f-1];--f);for(s=0,m="";s1)if(16==t||8==t){for(s=16==t?4:3,--f;f%s;f++)m+="0";for(f=(h=q(m,i,t)).length;!h[f-1];--f);for(s=1,m="1.";sf)for(a-=f;a--;)m+="0";else at)return e.length=t,!0}function ee(e){return new this(e).abs()}function te(e){return new this(e).acos()}function re(e){return new this(e).acosh()}function ne(e,t){return new this(e).plus(t)}function ie(e){return new this(e).asin()}function ae(e){return new this(e).asinh()}function oe(e){return new this(e).atan()}function se(e){return new this(e).atanh()}function ue(e,t){e=new this(e),t=new this(t);var r,n=this.precision,i=this.rounding,a=n+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(r=t.s<0?F(this,n,i):new this(0)).s=e.s:!e.d||t.isZero()?(r=F(this,a,1).times(.5)).s=e.s:t.s<0?(this.precision=a,this.rounding=1,r=this.atan(z(e,t,a,1)),t=F(this,a,1),this.precision=n,this.rounding=i,r=e.s<0?r.minus(t):r.plus(t)):r=this.atan(z(e,t,a,1)):(r=F(this,a,1).times(t.s>0?.25:.75)).s=e.s:r=new this(NaN),r}function ce(e){return new this(e).cbrt()}function le(e){return D(e=new this(e),e.e+1,2)}function fe(e){if(!e||"object"!=typeof e)throw Error(d+"Object expected");var t,r,n,i=!0===e.defaults,a=["precision",1,c,"rounding",0,8,"toExpNeg",-u,0,"toExpPos",0,u,"maxE",0,u,"minE",-u,0,"modulo",0,9];for(t=0;t=a[t+1]&&n<=a[t+2]))throw Error(y+r+": "+n);this[r]=n}if(r="crypto",i&&(this[r]=m[r]),void 0!==(n=e[r])){if(!0!==n&&!1!==n&&0!==n&&1!==n)throw Error(y+r+": "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(v);this[r]=!0}else this[r]=!1}return this}function pe(e){return new this(e).cos()}function me(e){return new this(e).cosh()}function he(e,t){return new this(e).div(t)}function de(e){return new this(e).exp()}function ye(e){return D(e=new this(e),e.e+1,3)}function ge(){var e,t,r=new this(0);for(h=!1,e=0;e=429e7?t[a]=crypto.getRandomValues(new Uint32Array(1))[0]:s[a++]=i%1e7;else{if(!crypto.randomBytes)throw Error(v);for(t=crypto.randomBytes(n*=4);a=214e7?crypto.randomBytes(4).copy(t,a):(s.push(i%1e7),a+=4);a=n/4}else for(;a=10;i/=10)n++;n<7&&(r-=7-n)}return o.e=r,o.d=s,o}function _e(e){return D(e=new this(e),e.e+1,this.rounding)}function Te(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function Be(e){return new this(e).sin()}function qe(e){return new this(e).sinh()}function ze(e){return new this(e).sqrt()}function De(e,t){return new this(e).sub(t)}function Ie(e){return new this(e).tan()}function ke(e){return new this(e).tanh()}function Re(e){return D(e=new this(e),e.e+1,1)}(a=function e(t){var r,n,i;function a(e){var t,r,n,i=this;if(!(i instanceof a))return new a(e);if(i.constructor=a,e instanceof a)return i.s=e.s,void(h?!e.d||e.e>a.maxE?(i.e=NaN,i.d=null):e.e=10;r/=10)t++;return void(h?t>a.maxE?(i.e=NaN,i.d=null):t{"use strict";var t=Object.assign||function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{},o=a.preserveFormatting,s=void 0!==o&&o,u=a.escapeMapFn,c=void 0===u?i:u,l=String(e),f="",p=c(t({},r),s?t({},n):{}),m=Object.keys(p),h=function(){var e=!1;m.forEach((function(t,r){e||l.length>=t.length&&l.slice(0,t.length)===t&&(f+=p[m[r]],l=l.slice(t.length,l.length),e=!0)})),e||(f+=l.slice(0,1),l=l.slice(1,l.length))};l;)h();return f}},628:function(e,t){var r;!function(n){"use strict";var i={s:1,n:0,d:1};function a(e){function t(){var t=Error.apply(this,arguments);t.name=this.name=e,this.stack=t.stack,this.message=t.message}function r(){}return r.prototype=Error.prototype,t.prototype=new r,t}var o=m.DivisionByZero=a("DivisionByZero"),s=m.InvalidParameter=a("InvalidParameter");function u(e,t){return isNaN(e=parseInt(e,10))&&c(),e*t}function c(){throw new s}function l(e){for(var t={},r=e,n=2,i=4;i<=r;){for(;r%n==0;)r/=n,t[n]=(t[n]||0)+1;i+=1+2*n++}return r!==e?r>1&&(t[r]=(t[r]||0)+1):t[e]=(t[e]||0)+1,t}var f=function(e,t){var r,n=0,a=1,s=1,l=0,f=0,p=0,m=1,h=1,d=0,y=1,g=1,v=1,x=1e7;if(null==e);else if(void 0!==t)s=(n=e)*(a=t);else switch(typeof e){case"object":"d"in e&&"n"in e?(n=e.n,a=e.d,"s"in e&&(n*=e.s)):0 in e?(n=e[0],1 in e&&(a=e[1])):c(),s=n*a;break;case"number":if(e<0&&(s=e,e=-e),e%1==0)n=e;else if(e>0){for(e>=1&&(e/=h=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)));y<=x&&v<=x;){if(e===(r=(d+g)/(y+v))){y+v<=x?(n=d+g,a=y+v):v>y?(n=g,a=v):(n=d,a=y);break}e>r?(d+=g,y+=v):(g+=d,v+=y),y>x?(n=g,a=v):(n=d,a=y)}n*=h}else(isNaN(e)||isNaN(t))&&(a=n=NaN);break;case"string":if(null===(y=e.match(/\d+|./g))&&c(),"-"===y[d]?(s=-1,d++):"+"===y[d]&&d++,y.length===d+1?f=u(y[d++],s):"."===y[d+1]||"."===y[d]?("."!==y[d]&&(l=u(y[d++],s)),(1+ ++d===y.length||"("===y[d+1]&&")"===y[d+3]||"'"===y[d+1]&&"'"===y[d+3])&&(f=u(y[d],s),m=Math.pow(10,y[d].length),d++),("("===y[d]&&")"===y[d+2]||"'"===y[d]&&"'"===y[d+2])&&(p=u(y[d+1],s),h=Math.pow(10,y[d+1].length)-1,d+=3)):"/"===y[d+1]||":"===y[d+1]?(f=u(y[d],s),m=u(y[d+2],1),d+=3):"/"===y[d+3]&&" "===y[d+1]&&(l=u(y[d],s),f=u(y[d+2],s),m=u(y[d+4],1),d+=5),y.length<=d){s=n=p+(a=m*h)*l+h*f;break}default:c()}if(0===a)throw new o;i.s=s<0?-1:1,i.n=Math.abs(n),i.d=Math.abs(a)};function p(e,t){if(!e)return t;if(!t)return e;for(;;){if(!(e%=t))return t;if(!(t%=e))return e}}function m(e,t){if(!(this instanceof m))return new m(e,t);f(e,t),e=m.REDUCE?p(i.d,i.n):1,this.s=i.s,this.n=i.n/e,this.d=i.d/e}m.REDUCE=1,m.prototype={s:1,n:0,d:1,abs:function(){return new m(this.n,this.d)},neg:function(){return new m(-this.s*this.n,this.d)},add:function(e,t){return f(e,t),new m(this.s*this.n*i.d+i.s*this.d*i.n,this.d*i.d)},sub:function(e,t){return f(e,t),new m(this.s*this.n*i.d-i.s*this.d*i.n,this.d*i.d)},mul:function(e,t){return f(e,t),new m(this.s*i.s*this.n*i.n,this.d*i.d)},div:function(e,t){return f(e,t),new m(this.s*i.s*this.n*i.d,this.d*i.n)},clone:function(){return new m(this)},mod:function(e,t){return isNaN(this.n)||isNaN(this.d)?new m(NaN):void 0===e?new m(this.s*this.n%this.d,1):(f(e,t),0===i.n&&0===this.d&&m(0,0),new m(this.s*(i.d*this.n)%(i.n*this.d),i.d*this.d))},gcd:function(e,t){return f(e,t),new m(p(i.n,this.n)*p(i.d,this.d),i.d*this.d)},lcm:function(e,t){return f(e,t),0===i.n&&0===this.n?new m:new m(i.n*this.n,p(i.n,this.n)*p(i.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.round(e*this.s*this.n/this.d),e)},inverse:function(){return new m(this.s*this.d,this.n)},pow:function(e,t){if(f(e,t),1===i.d)return i.s<0?new m(Math.pow(this.s*this.d,i.n),Math.pow(this.n,i.n)):new m(Math.pow(this.s*this.n,i.n),Math.pow(this.d,i.n));if(this.s<0)return null;var r=l(this.n),n=l(this.d),a=1,o=1;for(var s in r)if("1"!==s){if("0"===s){a=0;break}if(r[s]*=i.n,r[s]%i.d!=0)return null;r[s]/=i.d,a*=Math.pow(s,r[s])}for(var s in n)if("1"!==s){if(n[s]*=i.n,n[s]%i.d!=0)return null;n[s]/=i.d,o*=Math.pow(s,n[s])}return i.s<0?new m(o,a):new m(a,o)},equals:function(e,t){return f(e,t),this.s*this.n*i.d==i.s*i.n*this.d},compare:function(e,t){f(e,t);var r=this.s*this.n*i.d-i.s*i.n*this.d;return(00&&(r+=t,r+=" ",n%=i),r+=n,r+="/",r+=i),r},toLatex:function(e){var t,r="",n=this.n,i=this.d;return this.s<0&&(r+="-"),1===i?r+=n:(e&&(t=Math.floor(n/i))>0&&(r+=t,n%=i),r+="\\frac{",r+=n,r+="}{",r+=i,r+="}"),r},toContinued:function(){var e,t=this.n,r=this.d,n=[];if(isNaN(t)||isNaN(r))return n;do{n.push(Math.floor(t/r)),e=t%r,t=r,r=e}while(1!==t);return n},toString:function(e){var t,r=this.n,n=this.d;if(isNaN(r)||isNaN(n))return"NaN";m.REDUCE||(r/=t=p(r,n),n/=t),e=e||15;var i=function(e,t){for(;t%2==0;t/=2);for(;t%5==0;t/=5);if(1===t)return 0;for(var r=10%t,n=1;1!==r;n++)if(r=10*r%t,n>2e3)return 0;return n}(0,n),a=function(e,t,r){for(var n=1,i=function(e,t,r){for(var n=1;t>0;e=e*e%r,t>>=1)1&t&&(n=n*e%r);return n}(10,r,t),a=0;a<300;a++){if(n===i)return a;n=10*n%t,i=10*i%t}return 0}(0,n,i),o=-1===this.s?"-":"";if(o+=r/n|0,r%=n,(r*=10)&&(o+="."),i){for(var s=a;s--;)o+=r/n|0,r%=n,r*=10;for(o+="(",s=i;s--;)o+=r/n|0,r%=n,r*=10;o+=")"}else for(s=e;r&&s--;)o+=r/n|0,r%=n,r*=10;return o}},void 0===(r=function(){return m}.apply(t,[]))||(e.exports=r)}()},228:e=>{e.exports=function e(t,r){"use strict";var n,i,a=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,o=/(^[ ]*|[ ]*$)/g,s=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,u=/^0x[0-9a-f]+$/i,c=/^0/,l=function(t){return e.insensitive&&(""+t).toLowerCase()||""+t},f=l(t).replace(o,"")||"",p=l(r).replace(o,"")||"",m=f.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),h=p.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),d=parseInt(f.match(u),16)||1!==m.length&&f.match(s)&&Date.parse(f),y=parseInt(p.match(u),16)||d&&p.match(s)&&Date.parse(p)||null;if(y){if(dy)return 1}for(var g=0,v=Math.max(m.length,h.length);gi)return 1}return 0}},377:(e,t,r)=>{var n=r(832),i=r(652),a=r(801),o=r(30),s=r(618),u=r(49),c=r(971);c.alea=n,c.xor128=i,c.xorwow=a,c.xorshift7=o,c.xor4096=s,c.tychei=u,e.exports=c},832:function(e,t,r){var n;!function(e,i,a){function o(e){var t,r=this,n=(t=4022871197,function(e){e=String(e);for(var r=0;r>>0,t=(n*=t)>>>0,t+=4294967296*(n-=t)}return 2.3283064365386963e-10*(t>>>0)});r.next=function(){var e=2091639*r.s0+2.3283064365386963e-10*r.c;return r.s0=r.s1,r.s1=r.s2,r.s2=e-(r.c=0|e)},r.c=1,r.s0=n(" "),r.s1=n(" "),r.s2=n(" "),r.s0-=n(e),r.s0<0&&(r.s0+=1),r.s1-=n(e),r.s1<0&&(r.s1+=1),r.s2-=n(e),r.s2<0&&(r.s2+=1),n=null}function s(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function u(e,t){var r=new o(e),n=t&&t.state,i=r.next;return i.int32=function(){return 4294967296*r.next()|0},i.double=function(){return i()+11102230246251565e-32*(2097152*i()|0)},i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.alea=u}(0,e=r.nmd(e),r.amdD)},49:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.next=function(){var e=t.b,r=t.c,n=t.d,i=t.a;return e=e<<25^e>>>7^r,r=r-n|0,n=n<<24^n>>>8^i,i=i-e|0,t.b=e=e<<20^e>>>12^r,t.c=r=r-n|0,t.d=n<<16^r>>>16^i,t.a=i-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):r+=e;for(var n=0;n>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.tychei=u}(0,e=r.nmd(e),r.amdD)},652:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:r+=e;for(var n=0;n>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xor128=u}(0,e=r.nmd(e),r.amdD)},618:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this;t.next=function(){var e,r,n=t.w,i=t.X,a=t.i;return t.w=n=n+1640531527|0,r=i[a+34&127],e=i[a=a+1&127],r^=r<<13,e^=e<<17,r^=r>>>15,e^=e>>>12,r=i[a]=r^e,t.i=a,r+(n^n>>>16)|0},function(e,t){var r,n,i,a,o,s=[],u=128;for(t===(0|t)?(n=t,t=null):(t+="\0",n=0,u=Math.max(u,t.length)),i=0,a=-32;a>>15,n^=n<<4,n^=n>>>13,a>=0&&(o=o+1640531527|0,i=0==(r=s[127&a]^=n+o)?i+1:0);for(i>=128&&(s[127&(t&&t.length||0)]=-1),i=127,a=512;a>0;--a)n=s[i+34&127],r=s[i=i+1&127],n^=n<<13,r^=r<<17,n^=n>>>15,r^=r>>>12,s[i]=n^r;e.w=o,e.X=s,e.i=i}(t,e)}function s(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function u(e,t){null==e&&(e=+new Date);var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&(n.X&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xor4096=u}(0,e=r.nmd(e),r.amdD)},30:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this;t.next=function(){var e,r,n=t.x,i=t.i;return e=n[i],r=(e^=e>>>7)^e<<24,r^=(e=n[i+1&7])^e>>>10,r^=(e=n[i+3&7])^e>>>3,r^=(e=n[i+4&7])^e<<7,e=n[i+7&7],r^=(e^=e<<13)^e<<9,n[i]=r,t.i=i+1&7,r},function(e,t){var r,n=[];if(t===(0|t))n[0]=t;else for(t=""+t,r=0;r0;--r)e.next()}(t,e)}function s(e,t){return t.x=e.x.slice(),t.i=e.i,t}function u(e,t){null==e&&(e=+new Date);var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&(n.x&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xorshift7=u}(0,e=r.nmd(e),r.amdD)},801:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:r+=e;for(var n=0;n>>4),t.next()}function s(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function u(e,t){var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xorwow=u}(0,e=r.nmd(e),r.amdD)},971:function(e,t,r){var n;!function(i,a,o){var s,u=256,c=o.pow(u,6),l=o.pow(2,52),f=2*l,p=255;function m(e,t,r){var n=[],p=g(y((t=1==t?{entropy:!0}:t||{}).entropy?[e,v(a)]:null==e?function(){try{var e;return s&&(e=s.randomBytes)?e=e(u):(e=new Uint8Array(u),(i.crypto||i.msCrypto).getRandomValues(e)),v(e)}catch(e){var t=i.navigator,r=t&&t.plugins;return[+new Date,i,r,i.screen,v(a)]}}():e,3),n),m=new h(n),x=function(){for(var e=m.g(6),t=c,r=0;e=f;)e/=2,t/=2,r>>>=1;return(e+r)/t};return x.int32=function(){return 0|m.g(4)},x.quick=function(){return m.g(4)/4294967296},x.double=x,g(v(m.S),a),(t.pass||r||function(e,t,r,n){return n&&(n.S&&d(n,m),e.state=function(){return d(m,{})}),r?(o.random=e,t):e})(x,p,"global"in t?t.global:this==o,t.state)}function h(e){var t,r=e.length,n=this,i=0,a=n.i=n.j=0,o=n.S=[];for(r||(e=[r++]);i3?e.slice(3):"any":e).split("|").map(q).filter(z).filter(B),i=function(e,t){var r={};return e.forEach((function(e){-1!==t.indexOf(e.from)||-1===t.indexOf(e.to)||r[e.from]||(r[e.from]=e)})),Object.keys(r).map((function(e){return r[e]}))}(t,n),a=n.map((function(e){var t=c(e);return{name:e,typeIndex:l(t),test:t.test,conversion:null,conversionIndex:-1}})),o=i.map((function(e){var r=c(e.from);return{name:e.from,typeIndex:l(r),test:r.test,conversion:e,conversionIndex:t.indexOf(e)}}));return{types:a.concat(o),restParam:r}}function h(e){var t=k(e);return!!t&&t.restParam}function d(e){return e.types.some((function(e){return null!=e.conversion}))}function y(t){if(t&&0!==t.types.length){if(1===t.types.length)return c(t.types[0].name).test;if(2===t.types.length){var r=c(t.types[0].name).test,n=c(t.types[1].name).test;return function(e){return r(e)||n(e)}}var i=t.types.map((function(e){return c(e.name).test}));return function(e){for(var t=0;t=a+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(r=y(e[0]),function(e){return r(e[0])&&1===e.length}):2===e.length?(r=y(e[0]),n=y(e[1]),function(e){return r(e[0])&&n(e[1])&&2===e.length}):(t=e.map(y),function(e){for(var r=0;r0){var c=f(t[a]);return(n=new TypeError("Unexpected type of argument in function "+o+" (expected: "+i.join(" or ")+", actual: "+c+", index: "+a+")")).data={category:"wrongType",fn:o,index:a,actual:c,expected:i},n}}else s=u}var l=s.map((function(e){return h(e.params)?1/0:e.params.length}));if(t.lengthp?((n=new TypeError("Too many arguments in function "+o+" (expected: "+p+", actual: "+t.length+")")).data={category:"tooManyArgs",fn:o,index:t.length,expectedLength:p},n):((n=new TypeError('Arguments of type "'+t.join(", ")+'" do not match any of the defined signatures of function '+o+".")).data={category:"mismatch",actual:t.map(f)},n)}function S(e){for(var t=999,r=0;r=i:s?i>=a:i===a}(t,e)}));if(t)throw new TypeError('Conflicting signatures "'+p(t.params)+'" and "'+p(e.params)+'".');i.push(e)}));var a=P(i,(function(e){return(e?_(e.params,!1):[]).map((function(t){return{params:t,fn:e.fn}}))})).filter(D);a.sort(O);var o=a[0]&&a[0].params.length<=2&&!h(a[0].params),s=a[1]&&a[1].params.length<=2&&!h(a[1].params),c=a[2]&&a[2].params.length<=2&&!h(a[2].params),l=a[3]&&a[3].params.length<=2&&!h(a[3].params),f=a[4]&&a[4].params.length<=2&&!h(a[4].params),v=a[5]&&a[5].params.length<=2&&!h(a[5].params),b=o&&s&&c&&l&&f&&v,w=a.map((function(e){return g(e.params)})),N=o?y(a[0].params[0]):t,S=s?y(a[1].params[0]):t,E=c?y(a[2].params[0]):t,A=l?y(a[3].params[0]):t,T=f?y(a[4].params[0]):t,B=v?y(a[5].params[0]):t,z=o?y(a[0].params[1]):t,k=s?y(a[1].params[1]):t,j=c?y(a[2].params[1]):t,L=l?y(a[3].params[1]):t,H=f?y(a[4].params[1]):t,$=v?y(a[5].params[1]):t,G=a.map((function(e){return function(e,t){var r=t;if(e.some(d)){var n=h(e),i=e.map(C);r=function(){for(var e=[],r=n?arguments.length-1:arguments.length,a=0;a{}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var a=t[n]={id:n,loaded:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.loaded=!0,a.exports}r.amdD=function(){throw new Error("define cannot be used indirect")},r.amdO={},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";function e(){return(e=Object.assign||function(e){for(var t=1;t!function(e){return e&&"?"===e[0]}(e))).every((e=>void 0!==r[e]))){var n=t.filter((e=>void 0===r[e]));throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(n.map((e=>'"'.concat(e,'"'))).join(", "),"."))}}(e,t,n),r(i)}return i.isFactory=!0,i.fn=e,i.dependencies=t.slice().sort(),n&&(i.meta=n),i}function J(e){return e&&"?"===e[0]?e.slice(1):e}function Y(e,t){if(ee(e)&&Q(e,t))return e[t];if("function"==typeof e[t]&&K(e,t))throw new Error('Cannot access method "'+t+'" as a property');throw new Error('No access to property "'+t+'"')}function X(e,t,r){if(ee(e)&&Q(e,t))return e[t]=r,r;throw new Error('No access to property "'+t+'"')}function Q(e,t){return!(!e||"object"!=typeof e||!Z(te,t)&&(t in Object.prototype||t in Function.prototype))}function K(e,t){return!(null==e||"function"!=typeof e[t]||Z(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e)||!Z(re,t)&&(t in Object.prototype||t in Function.prototype))}function ee(e){return"object"==typeof e&&e&&e.constructor===Object}var te={length:!0,name:!0},re={toString:!0,valueOf:!0,toLocaleString:!0};class ne{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return Y(this.wrappedObject,e)}set(e,t){return X(this.wrappedObject,e,t),this}has(e){return e in this.wrappedObject}}function ie(){return new Map}function ae(e){if(!e)return ie();if(oe(e))return e;if(M(e))return new ne(e);throw new Error("createMap can create maps from objects or Maps")}function oe(e){return!!e&&(e instanceof Map||e instanceof ne||"function"==typeof e.set&&"function"==typeof e.get&&"function"==typeof e.keys&&"function"==typeof e.has)}function se(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{var{mathWithTransform:t}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator")}return r.prototype.evaluate=function(e){return this.compile().evaluate(e)},r.prototype.type="Node",r.prototype.isNode=!0,r.prototype.comment="",r.prototype.compile=function(){var e=this._compile(t,{}),r={};return{evaluate:function(t){var n=ae(t);return function(e){for(var t of[...H])if(e.has(t))throw new Error('Scope contains an illegal symbol, "'+t+'" is a reserved keyword')}(n),e(n,r,null)}}},r.prototype._compile=function(e,t){throw new Error("Method _compile should be implemented by type "+this.type)},r.prototype.forEach=function(e){throw new Error("Cannot run forEach on a Node interface")},r.prototype.map=function(e){throw new Error("Cannot run map on a Node interface")},r.prototype._ifNode=function(e){if(!I(e))throw new TypeError("Callback function must return a Node");return e},r.prototype.traverse=function(e){e(this,null,null),function e(t,r){t.forEach((function(t,n,i){r(t,n,i),e(t,r)}))}(this,e)},r.prototype.transform=function(e){return function t(r,n,i){var a=e(r,n,i);return a!==r?a:r.map(t)}(this,null,null)},r.prototype.filter=function(e){var t=[];return this.traverse((function(r,n,i){e(r,n,i)&&t.push(r)})),t},r.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},r.prototype.cloneDeep=function(){return this.map((function(e){return e.cloneDeep()}))},r.prototype.equals=function(e){return!!e&&V(this,e)},r.prototype.toString=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toString(e)},r.prototype.toJSON=function(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)},r.prototype.toHTML=function(e){var t=this._getCustomString(e);return void 0!==t?t:this.toHTML(e)},r.prototype._toString=function(){throw new Error("_toString not implemented for "+this.type)},r.prototype.toTex=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toTex(e)},r.prototype._toTex=function(e){throw new Error("_toTex not implemented for "+this.type)},r.prototype._getCustomString=function(e){if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":return;case"function":return e.handler(this,e);default:throw new TypeError("Object or function expected as callback")}},r.prototype.getIdentifier=function(){return this.type},r.prototype.getContent=function(){return this},r}),{isClass:!0,isNode:!0});function ce(e){return"boolean"==typeof e||!!isFinite(e)&&e===Math.round(e)}var le=Math.sign||function(e){return e>0?1:e<0?-1:0},fe=Math.log2||function(e){return Math.log(e)/Math.LN2},pe=Math.log10||function(e){return Math.log(e)/Math.LN10},me=Math.log1p||function(e){return Math.log(e+1)},he=Math.cbrt||function(e){if(0===e)return e;var t,r=e<0;return r&&(e=-e),t=isFinite(e)?(e/((t=Math.exp(Math.log(e)/3))*t)+2*t)/3:e,r?-t:t},de=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function ye(e,t,r){var n={2:"0b",8:"0o",16:"0x"}[t],i="";if(r){if(r<1)throw new Error("size must be in greater than 0");if(!ce(r))throw new Error("size must be an integer");if(e>2**(r-1)-1||e<-(2**(r-1)))throw new Error("Value must be in range [-2^".concat(r-1,", 2^").concat(r-1,"-1]"));if(!ce(e))throw new Error("Value must be an integer");e<0&&(e+=2**r),i="i".concat(r)}var a="";return e<0&&(e=-e,a="-"),"".concat(a).concat(n).concat(e.toString(t)).concat(i)}function ge(e,t){if("function"==typeof t)return t(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var r,n,a="auto";if(t&&(t.notation&&(a=t.notation),i(t)?r=t:i(t.precision)&&(r=t.precision),t.wordSize&&"number"!=typeof(n=t.wordSize)))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return xe(e,r);case"exponential":return be(e,r);case"engineering":return function(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=we(ve(e),t),n=r.exponent,a=r.coefficients,o=n%3==0?n:n<0?n-3-n%3:n-n%3;if(i(t))for(;t>a.length||n-o+1>a.length;)a.push(0);else for(var s=Math.abs(n-o)-(a.length-1),u=0;u0;)l++,c--;var f=a.slice(l).join(""),p=i(t)&&f.length||f.match(/[1-9]/)?"."+f:"",m=a.slice(0,l).join("")+p+"e"+(n>=0?"+":"")+o.toString();return r.sign+m}(e,r);case"bin":return ye(e,2,n);case"oct":return ye(e,8,n);case"hex":return ye(e,16,n);case"auto":return function(e,t,r){if(isNaN(e)||!isFinite(e))return String(e);var n=r&&void 0!==r.lowerExp?r.lowerExp:-3,i=r&&void 0!==r.upperExp?r.upperExp:5,a=ve(e),o=t?we(a,t):a;if(o.exponent=i)return be(e,t);var s=o.coefficients,u=o.exponent;s.length0?u:0;return c<(s=Ne(-u).concat(s)).length-1&&s.splice(c+1,0,"."),o.sign+s.join("")}(e,r,t&&t).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t}));default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function ve(e){var t=String(e).toLowerCase().match(/^0*?(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+e);var r=t[1],n=t[2],i=parseFloat(t[4]||"0"),a=n.indexOf(".");i+=-1!==a?a-1:n.length-1;var o=n.replace(".","").replace(/^0*/,(function(e){return i-=e.length,""})).replace(/0*$/,"").split("").map((function(e){return parseInt(e)}));return 0===o.length&&(o.push(0),i++),{sign:r,coefficients:o,exponent:i}}function xe(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=ve(e),n="number"==typeof t?we(r,r.exponent+1+t):r,i=n.coefficients,a=n.exponent+1,o=a+(t||0);return i.length0?"."+i.join(""):"")+"e"+(a>=0?"+":"")+a}function we(e,t){for(var r={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},n=r.coefficients;t<=0;)n.unshift(0),r.exponent++,t++;if(n.length>t&&n.splice(t,n.length-t)[0]>=5){var i=t-1;for(n[i]++;10===n[i];)n.pop(),0===i&&(n.unshift(0),r.exponent++,i++),n[--i]++}return r}function Ne(e){for(var t=[],r=0;r=0?"+":"")+n.toString()}(e,r);case"bin":return Be(e,2,n);case"oct":return Be(e,8,n);case"hex":return Be(e,16,n);case"auto":var a=t&&void 0!==t.lowerExp?t.lowerExp:-3,o=t&&void 0!==t.upperExp?t.upperExp:5;if(e.isZero())return"0";var s=e.toSignificantDigits(r),u=s.e;return(u>=a&&u'"'+r+'": '+De(e[r],t))).join(", ")+"}":String(e)}function Ie(e){for(var t=String(e),r="",n=0;n/g,">")}function Re(e,t){if(Array.isArray(e)){for(var r="[",n=e.length,i=0;it?1:-1}function Ue(e,t,r){if(!(this instanceof Ue))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=t,this.relation=r,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=(new Error).stack}function Pe(e,t,r){if(!(this instanceof Pe))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=r),void 0!==this.min&&this.index=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}function je(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function Le(e,t,r){var n,i=e.length;if(i!==t[r])throw new Ue(i,t[r]);if(r")}function He(e,t){if(0===t.length){if(Array.isArray(e))throw new Ue(e.length,0)}else Le(e,t,0)}function $e(e,t){if(!i(e)||!ce(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&e>=t)throw new Pe(e,t)}function Ge(e,t,r){if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");return t.forEach((function(e){if(!i(e)||!ce(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+De(t)+")")})),Ve(e,t,0,void 0!==r?r:0),e}function Ve(e,t,r,n){var i,a,o=e.length,s=t[r],u=Math.min(o,s);if(e.length=s,r=0){if(t%r!=0)throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-r);n[i]=-t/r}return n}function Je(e){return e.reduce(((e,t)=>e*t),1)}function Ye(e,t){for(var r=t||je(e);Array.isArray(e)&&1===e.length;)e=e[0],r.shift();for(var n=r.length;1===r[n-1];)n--;return nt.test(e)))}function at(e,t){return Array.prototype.join.call(e,t)}function ot(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;var t=[],r=0;t[0]={value:e[0],identifier:0};for(var n=1;n{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=e||[],!Array.isArray(this.items)||!this.items.every(I))throw new TypeError("Array containing Nodes expected")}return r.prototype=new t,r.prototype.type="ArrayNode",r.prototype.isArrayNode=!0,r.prototype._compile=function(e,t){var r=tt(this.items,(function(r){return r._compile(e,t)}));if("Array"!==e.config.matrix){var n=e.matrix;return function(e,t,i){return n(tt(r,(function(r){return r(e,t,i)})))}}return function(e,t,n){return tt(r,(function(r){return r(e,t,n)}))}},r.prototype.forEach=function(e){for(var t=0;t['+this.items.map((function(t){return t.toHTML(e)})).join(',')+']'},r.prototype._toTex=function(e){var t="\\begin{bmatrix}";return this.items.forEach((function(r){r.items?t+=r.items.map((function(t){return t.toTex(e)})).join("&"):t+=r.toTex(e),t+="\\\\"})),t+="\\end{bmatrix}"},r}),{isClass:!0,isNode:!0}),lt=W("BlockNode",["ResultSet","Node"],(e=>{var{ResultSet:t,Node:r}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map((function(e){var t=e&&e.node,r=!e||void 0===e.visible||e.visible;if(!I(t))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof r)throw new TypeError('Property "visible" must be a boolean');return{node:t,visible:r}}))}return n.prototype=new r,n.prototype.type="BlockNode",n.prototype.isBlockNode=!0,n.prototype._compile=function(e,r){var n=tt(this.blocks,(function(t){return{evaluate:t.node._compile(e,r),visible:t.visible}}));return function(e,r,i){var a=[];return rt(n,(function(t){var n=t.evaluate(e,r,i);t.visible&&a.push(n)})),new t(a)}},n.prototype.forEach=function(e){for(var t=0;t;')})).join('
')},n.prototype._toTex=function(e){return this.blocks.map((function(t){return t.node.toTex(e)+(t.visible?"":";")})).join("\\;\\;\n")},n}),{isClass:!0,isNode:!0}),ft=r(928),pt={Alpha:"A",alpha:"\\alpha",Beta:"B",beta:"\\beta",Gamma:"\\Gamma",gamma:"\\gamma",Delta:"\\Delta",delta:"\\delta",Epsilon:"E",epsilon:"\\epsilon",varepsilon:"\\varepsilon",Zeta:"Z",zeta:"\\zeta",Eta:"H",eta:"\\eta",Theta:"\\Theta",theta:"\\theta",vartheta:"\\vartheta",Iota:"I",iota:"\\iota",Kappa:"K",kappa:"\\kappa",varkappa:"\\varkappa",Lambda:"\\Lambda",lambda:"\\lambda",Mu:"M",mu:"\\mu",Nu:"N",nu:"\\nu",Xi:"\\Xi",xi:"\\xi",Omicron:"O",omicron:"o",Pi:"\\Pi",pi:"\\pi",varpi:"\\varpi",Rho:"P",rho:"\\rho",varrho:"\\varrho",Sigma:"\\Sigma",sigma:"\\sigma",varsigma:"\\varsigma",Tau:"T",tau:"\\tau",Upsilon:"\\Upsilon",upsilon:"\\upsilon",Phi:"\\Phi",phi:"\\phi",varphi:"\\varphi",Chi:"X",chi:"\\chi",Psi:"\\Psi",psi:"\\psi",Omega:"\\Omega",omega:"\\omega",true:"\\mathrm{True}",false:"\\mathrm{False}",i:"i",inf:"\\infty",Inf:"\\infty",infinity:"\\infty",Infinity:"\\infty",oo:"\\infty",lim:"\\lim",undefined:"\\mathbf{?}"},mt={transpose:"^\\top",ctranspose:"^H",factorial:"!",pow:"^",dotPow:".^\\wedge",unaryPlus:"+",unaryMinus:"-",bitNot:"\\~",not:"\\neg",multiply:"\\cdot",divide:"\\frac",dotMultiply:".\\cdot",dotDivide:".:",mod:"\\mod",add:"+",subtract:"-",to:"\\rightarrow",leftShift:"<<",rightArithShift:">>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},ht={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(mt.add,"${args[1]}\\right)")},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:"\\left(${args[0]}".concat(mt.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(mt.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(mt.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(mt.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:"\\left(${args[0]}".concat(mt.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(mt.multiply,"${args[1]}\\right)")},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : $y^{args[1]} = {${args[0]}}\\}"},pow:{2:"\\left(${args[0]}\\right)".concat(mt.pow,"{${args[1]}}")},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:"\\left(${args[0]}".concat(mt.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(mt.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(mt.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(mt.bitAnd,"${args[1]}\\right)")},bitNot:{1:mt.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(mt.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(mt.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(mt.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(mt.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(mt.rightLogShift,"${args[1]}\\right)")},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:"\\left(${args[0]}".concat(mt.and,"${args[1]}\\right)")},not:{1:mt.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(mt.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(mt.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(mt.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},sqrtm:{1:"{${args[0]}}".concat(mt.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(mt.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(mt.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(mt.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(mt.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(mt.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(mt.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(mt.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(mt.unequal,"${args[1]}\\right)")},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:"\\left(${args[0]}".concat(mt.to,"${args[1]}\\right)")},numeric:function(e,t){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(pt.i,"\\cdot\\left(${args[1]}\\right)\\right)")},matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},dt={deg:"^\\circ"};function yt(e){return ft(e,{preserveFormatting:!0})}function gt(e,t){return(t=void 0!==t&&t)?Z(dt,e)?dt[e]:"\\mathrm{"+yt(e)+"}":Z(pt,e)?pt[e]:yt(e)}var vt=W("ConstantNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this.value=e}return r.prototype=new t,r.prototype.type="ConstantNode",r.prototype.isConstantNode=!0,r.prototype._compile=function(e,t){var r=this.value;return function(){return r}},r.prototype.forEach=function(e){},r.prototype.map=function(e){return this.clone()},r.prototype.clone=function(){return new r(this.value)},r.prototype._toString=function(e){return De(this.value,e)},r.prototype.toHTML=function(e){var t=this._toString(e);switch(L(this.value)){case"number":case"BigNumber":case"Fraction":return''+t+"";case"string":return''+t+"";case"boolean":return''+t+"";case"null":return''+t+"";case"undefined":return''+t+"";default:return''+t+""}},r.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},r.fromJSON=function(e){return new r(e.value)},r.prototype._toTex=function(e){var t=this._toString(e);switch(L(this.value)){case"string":return"\\mathtt{"+yt(t)+"}";case"number":case"BigNumber":if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var r=t.toLowerCase().indexOf("e");return-1!==r?t.substring(0,r)+"\\cdot10^{"+t.substring(r+1)+"}":t;case"Fraction":return this.value.toLatex();default:return t}},r}),{isClass:!0,isNode:!0}),xt=W("ObjectNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=e||{},e&&("object"!=typeof e||!Object.keys(e).every((function(t){return I(e[t])}))))throw new TypeError("Object containing Nodes expected")}return r.prototype=new t,r.prototype.type="ObjectNode",r.prototype.isObjectNode=!0,r.prototype._compile=function(e,t){var r={};for(var n in this.properties)if(Z(this.properties,n)){var i=Ie(n),a=JSON.parse(i);if(!Q(this.properties,a))throw new Error('No access to property "'+a+'"');r[a]=this.properties[n]._compile(e,t)}return function(e,t,n){var i={};for(var a in r)Z(r,a)&&(i[a]=r[a](e,t,n));return i}},r.prototype.forEach=function(e){for(var t in this.properties)Z(this.properties,t)&&e(this.properties[t],"properties["+Ie(t)+"]",this)},r.prototype.map=function(e){var t={};for(var n in this.properties)Z(this.properties,n)&&(t[n]=this._ifNode(e(this.properties[n],"properties["+Ie(n)+"]",this)));return new r(t)},r.prototype.clone=function(){var e={};for(var t in this.properties)Z(this.properties,t)&&(e[t]=this.properties[t]);return new r(e)},r.prototype._toString=function(e){var t=[];for(var r in this.properties)Z(this.properties,r)&&t.push(Ie(r)+": "+this.properties[r].toString(e));return"{"+t.join(", ")+"}"},r.prototype.toJSON=function(){return{mathjs:"ObjectNode",properties:this.properties}},r.fromJSON=function(e){return new r(e.properties)},r.prototype.toHTML=function(e){var t=[];for(var r in this.properties)Z(this.properties,r)&&t.push(''+ke(r)+':'+this.properties[r].toHTML(e));return'{'+t.join(',')+'}'},r.prototype._toTex=function(e){var t=[];for(var r in this.properties)Z(this.properties,r)&&t.push("\\mathbf{"+r+":} & "+this.properties[r].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(t.join("\n"),"\\end{array}\\right\\}")},r}),{isClass:!0,isNode:!0}),bt=W("ParenthesisNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError('Node expected for parameter "content"');this.content=e}return r.prototype=new t,r.prototype.type="ParenthesisNode",r.prototype.isParenthesisNode=!0,r.prototype._compile=function(e,t){return this.content._compile(e,t)},r.prototype.getContent=function(){return this.content.getContent()},r.prototype.forEach=function(e){e(this.content,"content",this)},r.prototype.map=function(e){return new r(e(this.content,"content",this))},r.prototype.clone=function(){return new r(this.content)},r.prototype._toString=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)},r.prototype.toJSON=function(){return{mathjs:"ParenthesisNode",content:this.content}},r.fromJSON=function(e){return new r(e.content)},r.prototype.toHTML=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?'('+this.content.toHTML(e)+')':this.content.toHTML(e)},r.prototype._toTex=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)},r}),{isClass:!0,isNode:!0}),wt=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{associativity:"left",associativeWith:[]}},{"OperatorNode:and":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{associativity:"left",associativeWith:[]},"OperatorNode:unequal":{associativity:"left",associativeWith:[]},"OperatorNode:smaller":{associativity:"left",associativeWith:[]},"OperatorNode:larger":{associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{associativity:"left",associativeWith:[]}},{"OperatorNode:to":{associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{associativity:"left",associativeWith:[]},"OperatorNode:mod":{associativity:"left",associativeWith:[]}},{"OperatorNode:unaryPlus":{associativity:"right"},"OperatorNode:unaryMinus":{associativity:"right"},"OperatorNode:bitNot":{associativity:"right"},"OperatorNode:not":{associativity:"right"}},{"OperatorNode:pow":{associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{associativity:"left"}},{"OperatorNode:transpose":{associativity:"left"}}];function Nt(e,t){var r=e;"keep"!==t&&(r=e.getContent());for(var n=r.getIdentifier(),i=0;i{var{Node:t}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(t))throw new TypeError("Parameter params must be an array");if(e.length!==t.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=t}return r.prototype=new t,r.prototype.type="RelationalNode",r.prototype.isRelationalNode=!0,r.prototype._compile=function(e,t){var r=this,n=this.params.map((r=>r._compile(e,t)));return function(t,i,a){for(var o,s=n[0](t,i,a),u=0;ue(t,"params["+r+"]",this)),this)},r.prototype.map=function(e){return new r(this.conditionals.slice(),this.params.map(((t,r)=>this._ifNode(e(t,"params["+r+"]",this))),this))},r.prototype.clone=function(){return new r(this.conditionals,this.params)},r.prototype._toString=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.params.map((function(n,i){var a=Nt(n,t);return"all"===t||null!==a&&a<=r?"("+n.toString(e)+")":n.toString(e)})),i={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},a=n[0],o=0;o('+n.toHTML(e)+')':n.toHTML(e)})),i={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},a=n[0],o=0;o'+ke(i[this.conditionals[o]])+""+n[o+1];return a},r.prototype._toTex=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.params.map((function(n,i){var a=Nt(n,t);return"all"===t||null!==a&&a<=r?"\\left("+n.toTex(e)+"\right)":n.toTex(e)})),i=n[0],a=0;a{var{on:t,math:r}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");j(e)?this.value=e.value:this.value=e}function i(e,t){var r,i,o,s,u;r=n.prototype,i=e,o=function(){var e=t();if("function"==typeof e)return a(e)},u=!0,Object.defineProperty(r,i,{get:function(){return u&&(s=o(),u=!1),s},set:function(e){s=e,u=!1},configurable:!0,enumerable:!0})}function a(e){return function(){for(var t=[this.value],r=0;re[t]))};for(var s in e)r(s)}var u,c};var o={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return n.createProxy(r),t&&t("import",(function(e,t,r){r||i(e,t)})),n}),{isClass:!0}),Ot=W("reviver",["classes"],(e=>{var{classes:t}=e;return function(e,r){var n=t[r&&r.mathjs];return n&&"function"==typeof n.fromJSON?n.fromJSON(r):r}})),Ct=W("ConditionalNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError("Parameter condition must be a Node");if(!I(t))throw new TypeError("Parameter trueExpr must be a Node");if(!I(n))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=t,this.falseExpr=n}return r.prototype=new t,r.prototype.type="ConditionalNode",r.prototype.isConditionalNode=!0,r.prototype._compile=function(e,t){var r=this.condition._compile(e,t),n=this.trueExpr._compile(e,t),i=this.falseExpr._compile(e,t);return function(e,t,s){return function(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return!!e;if(e){if(a(e))return!e.isZero();if(o(e))return!(!e.re&&!e.im);if(u(e))return!!e.value}if(null==e)return!1;throw new TypeError('Unsupported type of condition "'+L(e)+'"')}(r(e,t,s))?n(e,t,s):i(e,t,s)}},r.prototype.forEach=function(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)},r.prototype.map=function(e){return new r(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))},r.prototype.clone=function(){return new r(this.condition,this.trueExpr,this.falseExpr)},r.prototype._toString=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.condition.toString(e),i=Nt(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n="("+n+")");var a=this.trueExpr.toString(e),o=Nt(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a="("+a+")");var s=this.falseExpr.toString(e),u=Nt(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s="("+s+")"),n+" ? "+a+" : "+s},r.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},r.fromJSON=function(e){return new r(e.condition,e.trueExpr,e.falseExpr)},r.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.condition.toHTML(e),i=Nt(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n='('+n+')');var a=this.trueExpr.toHTML(e),o=Nt(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a='('+a+')');var s=this.falseExpr.toHTML(e),u=Nt(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s='('+s+')'),n+'?'+a+':'+s},r.prototype._toTex=function(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"},r}),{isClass:!0,isNode:!0}),_t=W("OperatorNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n,i){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('string expected for parameter "op"');if("string"!=typeof t)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(n)||!n.every(I))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=!0===i,this.op=e,this.fn=t,this.args=n||[]}function n(e,t,r,n,i){var a,o=Nt(e,t),s=Mt(e,t);if("all"===t||n.length>2&&"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier())return n.map((function(e){switch(e.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}}));switch(n.length){case 0:a=[];break;case 1:var u=Nt(n[0],t);if(i&&null!==u){var c,l;if("keep"===t?(c=n[0].getIdentifier(),l=e.getIdentifier()):(c=n[0].getContent().getIdentifier(),l=e.getContent().getIdentifier()),!1===wt[o][l].latexLeftParens){a=[!1];break}if(!1===wt[u][c].latexParens){a=[!1];break}}if(null===u){a=[!1];break}if(u<=o){a=[!0];break}a=[!1];break;case 2:var f,p,m=Nt(n[0],t),h=St(e,n[0],t);f=null!==m&&(m===o&&"right"===s&&!h||m=2&&"OperatorNode:multiply"===e.getIdentifier()&&e.implicit&&"auto"===t&&"hide"===r&&(a=n.map((function(e,t){var r="ParenthesisNode"===e.getIdentifier();return!(!a[t]&&!r)}))),a}return r.prototype=new t,r.prototype.type="OperatorNode",r.prototype.isOperatorNode=!0,r.prototype._compile=function(e,t){if("string"!=typeof this.fn||!K(e,this.fn))throw e[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var r=Y(e,this.fn),n=tt(this.args,(function(r){return r._compile(e,t)}));if(1===n.length){var i=n[0];return function(e,t,n){return r(i(e,t,n))}}if(2===n.length){var a=n[0],o=n[1];return function(e,t,n){return r(a(e,t,n),o(e,t,n))}}return function(e,t,i){return r.apply(null,tt(n,(function(r){return r(e,t,i)})))}},r.prototype.forEach=function(e){for(var t=0;t2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var f=i.map((function(t,r){return t=t.toString(e),a[r]&&(t="("+t+")"),t}));return this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?f.join(" "):f.join(" "+this.op+" ")}return this.fn+"("+this.args.join(", ")+")"},r.prototype.toJSON=function(){return{mathjs:"OperatorNode",op:this.op,fn:this.fn,args:this.args,implicit:this.implicit}},r.fromJSON=function(e){return new r(e.op,e.fn,e.args,e.implicit)},r.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,t,r,i,!1);if(1===i.length){var o=Mt(this,t),s=i[0].toHTML(e);return a[0]&&(s='('+s+')'),"right"===o?''+ke(this.op)+""+s:s+''+ke(this.op)+""}if(2===i.length){var u=i[0].toHTML(e),c=i[1].toHTML(e);return a[0]&&(u='('+u+')'),a[1]&&(c='('+c+')'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?u+''+c:u+''+ke(this.op)+""+c}var l=i.map((function(t,r){return t=t.toHTML(e),a[r]&&(t='('+t+')'),t}));return i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())?this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?l.join(''):l.join(''+ke(this.op)+""):''+ke(this.fn)+'('+l.join(',')+')'},r.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,t,r,i,!0),o=mt[this.fn];if(o=void 0===o?this.op:o,1===i.length){var s=Mt(this,t),u=i[0].toTex(e);return a[0]&&(u="\\left(".concat(u,"\\right)")),"right"===s?o+u:u+o}if(2===i.length){var c=i[0],l=c.toTex(e);a[0]&&(l="\\left(".concat(l,"\\right)"));var f,p=i[1].toTex(e);switch(a[1]&&(p="\\left(".concat(p,"\\right)")),f="keep"===t?c.getIdentifier():c.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return o+"{"+l+"}{"+p+"}";case"OperatorNode:pow":switch(l="{"+l+"}",p="{"+p+"}",f){case"ConditionalNode":case"OperatorNode:divide":l="\\left(".concat(l,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&"hide"===r)return l+"~"+p}return l+o+p}if(i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var m=i.map((function(t,r){return t=t.toTex(e),a[r]&&(t="\\left(".concat(t,"\\right)")),t}));return"OperatorNode:multiply"===this.getIdentifier()&&this.implicit?m.join("~"):m.join(o)}return"\\mathrm{"+this.fn+"}\\left("+i.map((function(t){return t.toTex(e)})).join(",")+"\\right)"},r.prototype.getIdentifier=function(){return this.type+":"+this.fn},r}),{isClass:!0,isNode:!0}),Tt=W("RangeNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError("Node expected");if(!I(t))throw new TypeError("Node expected");if(n&&!I(n))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=e,this.end=t,this.step=n||null}function n(e,t){var r=Nt(e,t),n={},i=Nt(e.start,t);if(n.start=null!==i&&i<=r||"all"===t,e.step){var a=Nt(e.step,t);n.step=null!==a&&a<=r||"all"===t}var o=Nt(e.end,t);return n.end=null!==o&&o<=r||"all"===t,n}return r.prototype=new t,r.prototype.type="RangeNode",r.prototype.isRangeNode=!0,r.prototype.needsEnd=function(){return this.filter((function(e){return P(e)&&"end"===e.name})).length>0},r.prototype._compile=function(e,t){var r=e.range,n=this.start._compile(e,t),i=this.end._compile(e,t);if(this.step){var a=this.step._compile(e,t);return function(e,t,o){return r(n(e,t,o),i(e,t,o),a(e,t,o))}}return function(e,t,a){return r(n(e,t,a),i(e,t,a))}},r.prototype.forEach=function(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)},r.prototype.map=function(e){return new r(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))},r.prototype.clone=function(){return new r(this.start,this.end,this.step&&this.step)},r.prototype._toString=function(e){var t,r=n(this,e&&e.parenthesis?e.parenthesis:"keep"),i=this.start.toString(e);if(r.start&&(i="("+i+")"),t=i,this.step){var a=this.step.toString(e);r.step&&(a="("+a+")"),t+=":"+a}var o=this.end.toString(e);return r.end&&(o="("+o+")"),t+":"+o},r.prototype.toJSON=function(){return{mathjs:"RangeNode",start:this.start,end:this.end,step:this.step}},r.fromJSON=function(e){return new r(e.start,e.end,e.step)},r.prototype.toHTML=function(e){var t,r=n(this,e&&e.parenthesis?e.parenthesis:"keep"),i=this.start.toHTML(e);if(r.start&&(i='('+i+')'),t=i,this.step){var a=this.step.toHTML(e);r.step&&(a='('+a+')'),t+=':'+a}var o=this.end.toHTML(e);return r.end&&(o='('+o+')'),t+':'+o},r.prototype._toTex=function(e){var t=n(this,e&&e.parenthesis?e.parenthesis:"keep"),r=this.start.toTex(e);if(t.start&&(r="\\left(".concat(r,"\\right)")),this.step){var i=this.step.toTex(e);t.step&&(i="\\left(".concat(i,"\\right)")),r+=":"+i}var a=this.end.toTex(e);return t.end&&(a="\\left(".concat(a,"\\right)")),r+":"+a},r}),{isClass:!0,isNode:!0}),Bt=W("FunctionAssignmentNode",["typed","Node"],(e=>{var{typed:t,Node:r}=e;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(t))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!I(r))throw new TypeError('Node expected for parameter "expr"');if(H.has(e))throw new Error('Illegal function name, "'+e+'" is a reserved keyword');this.name=e,this.params=t.map((function(e){return e&&e.name||e})),this.types=t.map((function(e){return e&&e.type||"any"})),this.expr=r}function i(e,t){var r=Nt(e,t),n=Nt(e.expr,t);return"all"===t||null!==n&&n<=r}return n.prototype=new r,n.prototype.type="FunctionAssignmentNode",n.prototype.isFunctionAssignmentNode=!0,n.prototype._compile=function(e,r){var n=Object.create(r);rt(this.params,(function(e){n[e]=!0}));var i=this.expr._compile(e,n),a=this.name,o=this.params,s=at(this.types,","),u=a+"("+at(this.params,", ")+")";return function(e,r,n){var c={};c[s]=function(){for(var t=Object.create(r),a=0;a'+ke(this.params[n])+"");var a=this.expr.toHTML(e);return i(this,t)&&(a='('+a+')'),''+ke(this.name)+'('+r.join(',')+')='+a},n.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=this.expr.toTex(e);return i(this,t)&&(r="\\left(".concat(r,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(gt).join(",")+"\\right):="+r},n}),{isClass:!0,isNode:!0}),qt="chain",zt=W(qt,["typed","Chain"],(e=>{var{typed:t,Chain:r}=e;return t(qt,{"":function(){return new r},any:function(e){return new r(e)}})}));function Dt(e){return e&&e.isIndexError?new Pe(e.index+1,e.min+1,void 0!==e.max?e.max+1:void 0):e}function It(e){var{subset:t}=e;return function(e,r){try{if(Array.isArray(e))return t(e,r);if(e&&"function"==typeof e.subset)return e.subset(r);if("string"==typeof e)return t(e,r);if("object"==typeof e){if(!r.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return Y(e,r.getObjectProperty())}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Dt(e)}}}var kt=W("AccessorNode",["subset","Node"],(e=>{var{subset:t,Node:r}=e,n=It({subset:t});function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError('Node expected for parameter "object"');if(!D(t))throw new TypeError('IndexNode expected for parameter "index"');this.object=e||null,this.index=t,Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function a(e){return!(A(e)||O(e)||B(e)||z(e)||k(e)||F(e)||P(e))}return i.prototype=new r,i.prototype.type="AccessorNode",i.prototype.isAccessorNode=!0,i.prototype._compile=function(e,t){var r=this.object._compile(e,t),i=this.index._compile(e,t);if(this.index.isObjectProperty()){var a=this.index.getObjectProperty();return function(e,t,n){return Y(r(e,t,n),a)}}return function(e,t,a){var o=r(e,t,a),s=i(e,t,o);return n(o,s)}},i.prototype.forEach=function(e){e(this.object,"object",this),e(this.index,"index",this)},i.prototype.map=function(e){return new i(this._ifNode(e(this.object,"object",this)),this._ifNode(e(this.index,"index",this)))},i.prototype.clone=function(){return new i(this.object,this.index)},i.prototype._toString=function(e){var t=this.object.toString(e);return a(this.object)&&(t="("+t+")"),t+this.index.toString(e)},i.prototype.toHTML=function(e){var t=this.object.toHTML(e);return a(this.object)&&(t='('+t+')'),t+this.index.toHTML(e)},i.prototype._toTex=function(e){var t=this.object.toTex(e);return a(this.object)&&(t="\\left(' + object + '\\right)"),t+this.index.toTex(e)},i.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},i.fromJSON=function(e){return new i(e.object,e.index)},i}),{isClass:!0,isNode:!0}),Rt=W("IndexNode",["Range","Node","size"],(e=>{var{Range:t,Node:r,size:n}=e;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(this.dimensions=e,this.dotNotation=t||!1,!Array.isArray(e)||!e.every(I))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}function o(e,r,n){return new t(a(e)?e.toNumber():e,a(r)?r.toNumber():r,a(n)?n.toNumber():n)}return i.prototype=new r,i.prototype.type="IndexNode",i.prototype.isIndexNode=!0,i.prototype._compile=function(e,t){var r=tt(this.dimensions,(function(r,i){if(U(r)){if(r.needsEnd()){var a=Object.create(t);a.end=!0;var s=r.start._compile(e,a),u=r.end._compile(e,a),c=r.step?r.step._compile(e,a):function(){return 1};return function(e,t,r){var a=n(r).valueOf(),l=Object.create(t);return l.end=a[i],o(s(e,l,r),u(e,l,r),c(e,l,r))}}var l=r.start._compile(e,t),f=r.end._compile(e,t),p=r.step?r.step._compile(e,t):function(){return 1};return function(e,t,r){return o(l(e,t,r),f(e,t,r),p(e,t,r))}}if(P(r)&&"end"===r.name){var m=Object.create(t);m.end=!0;var h=r._compile(e,m);return function(e,t,r){var a=n(r).valueOf(),o=Object.create(t);return o.end=a[i],h(e,o,r)}}var d=r._compile(e,t);return function(e,t,r){return d(e,t,r)}})),i=Y(e,"index");return function(e,t,n){var a=tt(r,(function(r){return r(e,t,n)}));return i(...a)}},i.prototype.forEach=function(e){for(var t=0;t.'+ke(this.getObjectProperty())+"":'['+t.join(',')+']'},i.prototype._toTex=function(e){var t=this.dimensions.map((function(t){return t.toTex(e)}));return this.dotNotation?"."+this.getObjectProperty():"_{"+t.join(",")+"}"},i}),{isClass:!0,isNode:!0}),Ft=W("AssignmentNode",["subset","?matrix","Node"],(e=>{var{subset:t,matrix:r,Node:n}=e,i=It({subset:t}),a=function(e){var{subset:t,matrix:r}=e;return function(e,n,i){try{if(Array.isArray(e))return r(e).subset(n,i).valueOf();if(e&&"function"==typeof e.subset)return e.subset(n,i);if("string"==typeof e)return t(e,n,i);if("object"==typeof e){if(!n.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return X(e,n.getObjectProperty(),i),e}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Dt(e)}}}({subset:t,matrix:r});function o(e,t,r){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=e,this.index=r?t:null,this.value=r||t,!P(e)&&!A(e))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(P(e)&&"end"===e.name)throw new Error('Cannot assign to symbol "end"');if(this.index&&!D(this.index))throw new TypeError('IndexNode expected as "index"');if(!I(this.value))throw new TypeError('Node expected as "value"');Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function s(e,t){t||(t="keep");var r=Nt(e,t),n=Nt(e.value,t);return"all"===t||null!==n&&n<=r}return o.prototype=new n,o.prototype.type="AssignmentNode",o.prototype.isAssignmentNode=!0,o.prototype._compile=function(e,t){var r=this.object._compile(e,t),n=this.index?this.index._compile(e,t):null,o=this.value._compile(e,t),s=this.object.name;if(this.index){if(this.index.isObjectProperty()){var u=this.index.getObjectProperty();return function(e,t,n){var i=r(e,t,n),a=o(e,t,n);return X(i,u,a),a}}if(P(this.object))return function(e,t,i){var u=r(e,t,i),c=o(e,t,i),l=n(e,t,u);return e.set(s,a(u,l,c)),c};var c=this.object.object._compile(e,t);if(this.object.index.isObjectProperty()){var l=this.object.index.getObjectProperty();return function(e,t,r){var i=c(e,t,r),s=Y(i,l),u=n(e,t,s),f=o(e,t,r);return X(i,l,a(s,u,f)),f}}var f=this.object.index._compile(e,t);return function(e,t,r){var s=c(e,t,r),u=f(e,t,s),l=i(s,u),p=n(e,t,l),m=o(e,t,r);return a(s,u,a(l,p,m)),m}}if(!P(this.object))throw new TypeError("SymbolNode expected as object");return function(e,t,r){var n=o(e,t,r);return e.set(s,n),n}},o.prototype.forEach=function(e){e(this.object,"object",this),this.index&&e(this.index,"index",this),e(this.value,"value",this)},o.prototype.map=function(e){return new o(this._ifNode(e(this.object,"object",this)),this.index?this._ifNode(e(this.index,"index",this)):null,this._ifNode(e(this.value,"value",this)))},o.prototype.clone=function(){return new o(this.object,this.index,this.value)},o.prototype._toString=function(e){var t=this.object.toString(e),r=this.index?this.index.toString(e):"",n=this.value.toString(e);return s(this,e&&e.parenthesis)&&(n="("+n+")"),t+r+" = "+n},o.prototype.toJSON=function(){return{mathjs:"AssignmentNode",object:this.object,index:this.index,value:this.value}},o.fromJSON=function(e){return new o(e.object,e.index,e.value)},o.prototype.toHTML=function(e){var t=this.object.toHTML(e),r=this.index?this.index.toHTML(e):"",n=this.value.toHTML(e);return s(this,e&&e.parenthesis)&&(n='('+n+')'),t+r+'='+n},o.prototype._toTex=function(e){var t=this.object.toTex(e),r=this.index?this.index.toTex(e):"",n=this.value.toTex(e);return s(this,e&&e.parenthesis)&&(n="\\left(".concat(n,"\\right)")),t+r+":="+n},o}),{isClass:!0,isNode:!0}),Ut=W("SymbolNode",["math","?Unit","Node"],(e=>{var{math:t,Unit:r,Node:n}=e;function i(e){return!!r&&r.isValuelessUnit(e)}function a(e){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');this.name=e}return a.prototype=new n,a.prototype.type="SymbolNode",a.prototype.isSymbolNode=!0,a.prototype._compile=function(e,t){var n=this.name;if(!0===t[n])return function(e,t,r){return t[n]};if(n in e)return function(t,r,i){return t.has(n)?t.get(n):Y(e,n)};var o=i(n);return function(e,t,i){return e.has(n)?e.get(n):o?new r(null,n):a.onUndefinedSymbol(n)}},a.prototype.forEach=function(e){},a.prototype.map=function(e){return this.clone()},a.onUndefinedSymbol=function(e){throw new Error("Undefined symbol "+e)},a.prototype.clone=function(){return new a(this.name)},a.prototype._toString=function(e){return this.name},a.prototype.toHTML=function(e){var t=ke(this.name);return"true"===t||"false"===t?''+t+"":"i"===t?''+t+"":"Infinity"===t?''+t+"":"NaN"===t?''+t+"":"null"===t?''+t+"":"undefined"===t?''+t+"":''+t+""},a.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},a.fromJSON=function(e){return new a(e.name)},a.prototype._toTex=function(e){var r=!1;void 0===t[this.name]&&i(this.name)&&(r=!0);var n=gt(this.name,r);return"\\"===n[0]?n:" "+n},a}),{isClass:!0,isNode:!0});function Pt(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{var{math:t,Node:r,SymbolNode:n}=e;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if("string"==typeof e&&(e=new n(e)),!I(e))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(t)||!t.every(I))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=e,this.args=t||[],Object.defineProperty(this,"name",{get:function(){return this.fn.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}i.prototype=new r,i.prototype.type="FunctionNode",i.prototype.isFunctionNode=!0,i.prototype._compile=function(e,t){if(!(this instanceof i))throw new TypeError("No valid FunctionNode");var r=this.args.map((r=>r._compile(e,t)));if(!P(this.fn)){if(A(this.fn)&&D(this.fn.index)&&this.fn.index.isObjectProperty()){var n=this.fn.object._compile(e,t),a=this.fn.index.getObjectProperty(),o=this.args;return function(t,i,s){var u=n(t,i,s);if(function(e,t){if(!K(e,t))throw new Error('No access to method "'+t+'"')}(u,a),u[a]&&u[a].rawArgs)return u[a](o,e,Pt(t,i),t);var c=r.map((e=>e(t,i,s)));return u[a].apply(u,c)}}var s=this.fn._compile(e,t),u=this.args;return function(t,n,i){var a=s(t,n,i);if(a&&a.rawArgs)return a(u,e,Pt(t,n),t);var o=r.map((e=>e(t,n,i)));return a.apply(a,o)}}var c=this.fn.name,l=c in e?Y(e,c):void 0,f="function"==typeof l&&!0===l.rawArgs,p=t=>t.has(c)?t.get(c):c in e?Y(e,c):i.onUndefinedFunction(c);if(f){var m=this.args;return function(t,r,n){return p(t)(m,e,Pt(t,r),t)}}switch(r.length){case 0:return function(e,t,r){return p(e)()};case 1:return function(e,t,n){return p(e)((0,r[0])(e,t,n))};case 2:return function(e,t,n){var i=p(e),a=r[0],o=r[1];return i(a(e,t,n),o(e,t,n))};default:return function(e,t,n){return p(e)(...r.map((r=>r(e,t,n))))}}},i.prototype.forEach=function(e){e(this.fn,"fn",this);for(var t=0;t'+ke(this.fn)+'('+t.join(',')+')'};var s=i.prototype.toTex;return i.prototype.toTex=function(e){var t;return e&&"object"==typeof e.handler&&Z(e.handler,this.name)&&(t=e.handler[this.name](this,e)),void 0!==t?t:s.call(this,e)},i.prototype._toTex=function(e){var r,n,i=this.args.map((function(t){return t.toTex(e)}));switch(ht[this.name]&&(r=ht[this.name]),!t[this.name]||"function"!=typeof t[this.name].toTex&&"object"!=typeof t[this.name].toTex&&"string"!=typeof t[this.name].toTex||(r=t[this.name].toTex),typeof r){case"function":n=r(this,e);break;case"string":n=o(r,this,e);break;case"object":switch(typeof r[i.length]){case"function":n=r[i.length](this,e);break;case"string":n=o(r[i.length],this,e)}}return void 0!==n?n:o("\\mathrm{${name}}\\left(${args}\\right)",this,e)},i.prototype.getIdentifier=function(){return this.type+":"+this.name},i}),{isClass:!0,isNode:!0});function Lt(e){for(var t=0;t=n.length)throw new Pe(t,n.length);return f(e)?e.create(Vt(e.valueOf(),t,r)):Vt(e,t,r)}function Vt(e,t,r){var n,i,a,o;if(t<=0){if(Array.isArray(e[0])){for(o=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r{var{typed:r,numeric:n,config:i,AccessorNode:a,ArrayNode:o,AssignmentNode:s,BlockNode:u,ConditionalNode:c,ConstantNode:l,FunctionAssignmentNode:f,FunctionNode:p,IndexNode:m,ObjectNode:h,OperatorNode:d,ParenthesisNode:y,RangeNode:g,RelationalNode:v,SymbolNode:x}=t,b=r(Wt,{string:function(e){return U(e,{})},"Array | Matrix":function(e){return w(e,{})},"string, Object":function(e,t){return U(e,void 0!==t.nodes?t.nodes:{})},"Array | Matrix, Object":w});function w(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=void 0!==t.nodes?t.nodes:{};return $t(e,(function(e){if("string"!=typeof e)throw new TypeError("String expected");return U(e,r)}))}var N={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},M={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},S={true:!0,false:!1,null:null,undefined:void 0},E=["NaN","Infinity"];function O(e,t){return e.expression.substr(e.index,t)}function C(e){return O(e,1)}function _(e){e.index++}function T(e){return e.expression.charAt(e.index-1)}function q(e){return e.expression.charAt(e.index+1)}function D(e){for(e.tokenType=0,e.token="",e.comment="";b.isWhitespace(C(e),e.nestingLevel);)_(e);if("#"===C(e))for(;"\n"!==C(e)&&""!==C(e);)e.comment+=C(e),_(e);if(""!==C(e)){if("\n"===C(e)&&!e.nestingLevel)return e.tokenType=1,e.token=C(e),void _(e);var t=C(e),r=O(e,2),n=O(e,3);if(3===n.length&&N[n])return e.tokenType=1,e.token=n,_(e),_(e),void _(e);if(2===r.length&&N[r])return e.tokenType=1,e.token=r,_(e),void _(e);if(N[t])return e.tokenType=1,e.token=t,void _(e);if(b.isDigitDot(t)){e.tokenType=2;var i=O(e,2);if("0b"===i||"0o"===i||"0x"===i){for(e.token+=C(e),_(e),e.token+=C(e),_(e);b.isHexDigit(C(e));)e.token+=C(e),_(e);if("."===C(e))for(e.token+=".",_(e);b.isHexDigit(C(e));)e.token+=C(e),_(e);else if("i"===C(e))for(e.token+="i",_(e);b.isDigit(C(e));)e.token+=C(e),_(e);return}if("."===C(e))e.token+=C(e),_(e),b.isDigit(C(e))||(e.tokenType=1);else{for(;b.isDigit(C(e));)e.token+=C(e),_(e);b.isDecimalMark(C(e),q(e))&&(e.token+=C(e),_(e))}for(;b.isDigit(C(e));)e.token+=C(e),_(e);if("E"===C(e)||"e"===C(e))if(b.isDigit(q(e))||"-"===q(e)||"+"===q(e)){if(e.token+=C(e),_(e),"+"!==C(e)&&"-"!==C(e)||(e.token+=C(e),_(e)),!b.isDigit(C(e)))throw ue(e,'Digit expected, got "'+C(e)+'"');for(;b.isDigit(C(e));)e.token+=C(e),_(e);if(b.isDecimalMark(C(e),q(e)))throw ue(e,'Digit expected, got "'+C(e)+'"')}else if("."===q(e))throw _(e),ue(e,'Digit expected, got "'+C(e)+'"')}else{if(!b.isAlpha(C(e),T(e),q(e))){for(e.tokenType=4;""!==C(e);)e.token+=C(e),_(e);throw ue(e,'Syntax error in part "'+e.token+'"')}for(;b.isAlpha(C(e),T(e),q(e))||b.isDigit(C(e));)e.token+=C(e),_(e);Z(M,e.token)?e.tokenType=1:e.tokenType=3}}else e.tokenType=1}function I(e){do{D(e)}while("\n"===e.token)}function k(e){e.nestingLevel++}function F(e){e.nestingLevel--}function U(t,r){var n={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:0,nestingLevel:0,conditionalLevel:null};e(n,{expression:t,extraNodes:r}),D(n);var i=function(e){var t,r,n=[];for(""!==e.token&&"\n"!==e.token&&";"!==e.token&&((t=j(e)).comment=e.comment);"\n"===e.token||";"===e.token;)0===n.length&&t&&(r=";"!==e.token,n.push({node:t,visible:r})),D(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&((t=j(e)).comment=e.comment,r=";"!==e.token,n.push({node:t,visible:r}));return n.length>0?new u(n):(t||((t=new l(void 0)).comment=e.comment),t)}(n);if(""!==n.token)throw 1===n.tokenType?ce(n,"Unexpected operator "+n.token):ue(n,'Unexpected part "'+n.token+'"');return i}function j(e){var t,r,n,i,a=function(e){for(var t=function(e){for(var t=L(e);"or"===e.token;)I(e),t=new d("or","or",[t,L(e)]);return t}(e);"?"===e.token;){var r=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,I(e);var n=t,i=j(e);if(":"!==e.token)throw ue(e,"False part of conditional expression expected");e.conditionalLevel=null,I(e);var a=j(e);t=new c(n,i,a),e.conditionalLevel=r}return t}(e);if("="===e.token){if(P(a))return t=a.name,I(e),n=j(e),new s(new x(t),n);if(A(a))return I(e),n=j(e),new s(a.object,a.index,n);if(z(a)&&P(a.fn)&&(i=!0,r=[],t=a.name,a.args.forEach((function(e,t){P(e)?r[t]=e.name:i=!1})),i))return I(e),n=j(e),new f(t,r,n);throw ue(e,"Invalid left hand side of assignment operator =")}return a}function L(e){for(var t=H(e);"xor"===e.token;)I(e),t=new d("xor","xor",[t,H(e)]);return t}function H(e){for(var t=$(e);"and"===e.token;)I(e),t=new d("and","and",[t,$(e)]);return t}function $(e){for(var t=G(e);"|"===e.token;)I(e),t=new d("|","bitOr",[t,G(e)]);return t}function G(e){for(var t=V(e);"^|"===e.token;)I(e),t=new d("^|","bitXor",[t,V(e)]);return t}function V(e){for(var t=W(e);"&"===e.token;)I(e),t=new d("&","bitAnd",[t,W(e)]);return t}function W(e){for(var t=[J(e)],r=[],n={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};Z(n,e.token);){var i={name:e.token,fn:n[e.token]};r.push(i),I(e),t.push(J(e))}return 1===t.length?t[0]:2===t.length?new d(r[0].name,r[0].fn,t):new v(r.map((e=>e.fn)),t)}function J(e){var t,r,n,i;t=Y(e);for(var a={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Z(a,e.token);)n=a[r=e.token],I(e),i=[t,Y(e)],t=new d(r,n,i);return t}function Y(e){var t,r,n,i;t=X(e);for(var a={to:"to",in:"to"};Z(a,e.token);)n=a[r=e.token],I(e),"in"===r&&""===e.token?t=new d("*","multiply",[t,new x("in")],!0):(i=[t,X(e)],t=new d(r,n,i));return t}function X(e){var t,r=[];if(t=":"===e.token?new l(1):Q(e),":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(r.push(t);":"===e.token&&r.length<3;)I(e),")"===e.token||"]"===e.token||","===e.token||""===e.token?r.push(new x("end")):r.push(Q(e));t=3===r.length?new g(r[0],r[2],r[1]):new g(r[0],r[1])}return t}function Q(e){var t,r,n,i;t=K(e);for(var a={"+":"add","-":"subtract"};Z(a,e.token);)n=a[r=e.token],I(e),i=[t,K(e)],t=new d(r,n,i);return t}function K(e){var t,r,n,i;r=t=ee(e);for(var a={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"};Z(a,e.token);)i=a[n=e.token],I(e),r=ee(e),t=new d(n,i,[t,r]);return t}function ee(e){var t,r;for(r=t=te(e);3===e.tokenType||"in"===e.token&&B(t)||!(2!==e.tokenType||B(r)||R(r)&&"!"!==r.op)||"("===e.token;)r=te(e),t=new d("*","multiply",[t,r],!0);return t}function te(t){for(var r=re(t),n=r,i=[];"/"===t.token&&B(n);){if(i.push(e({},t)),I(t),2!==t.tokenType){e(t,i.pop());break}if(i.push(e({},t)),I(t),3!==t.tokenType&&"("!==t.token){i.pop(),e(t,i.pop());break}e(t,i.pop()),i.pop(),n=re(t),r=new d("/","divide",[r,n])}return r}function re(e){var t,r,a,s={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Z(s,e.token)?(a=s[e.token],t=e.token,I(e),r=[re(e)],new d(t,a,r)):function(e){var t,r,a,s;return t=function(e){var t,r,a;t=function(e){var t=[];if(3===e.tokenType&&Z(e.extraNodes,e.token)){var r=e.extraNodes[e.token];if(D(e),"("===e.token){if(t=[],k(e),D(e),")"!==e.token)for(t.push(j(e));","===e.token;)D(e),t.push(j(e));if(")"!==e.token)throw ue(e,"Parenthesis ) expected");F(e),D(e)}return new r(t)}return function(e){var t;return 3===e.tokenType||1===e.tokenType&&e.token in M?(t=e.token,D(e),ne(e,Z(S,t)?new l(S[t]):-1!==E.indexOf(t)?new l(n(t,"number")):new x(t))):function(e){var t;return'"'===e.token?(t=ie(e),ne(e,new l(t))):function(e){var t;return"'"===e.token?(t=ae(e),ne(e,new l(t))):function(e){var t,r,a,s;if("["===e.token){if(k(e),D(e),"]"!==e.token){var u=oe(e);if(";"===e.token){for(a=1,r=[u];";"===e.token;)D(e),r[a]=oe(e),a++;if("]"!==e.token)throw ue(e,"End of matrix ] expected");F(e),D(e),s=r[0].items.length;for(var c=1;c0},b.isDecimalMark=function(e,t){return"."===e&&"/"!==t&&"*"!==t&&"^"!==t},b.isDigitDot=function(e){return e>="0"&&e<="9"||"."===e},b.isDigit=function(e){return e>="0"&&e<="9"},b.isHexDigit=function(e){return e>="0"&&e<="9"||e>="a"&&e<="f"||e>="A"&&e<="F"},b})),Yt="evaluate",Xt=W(Yt,["typed","parse"],(e=>{var{typed:t,parse:r}=e;return t(Yt,{string:function(e){var t=ie();return r(e).compile().evaluate(t)},"string, Map | Object":function(e,t){return r(e).compile().evaluate(t)},"Array | Matrix":function(e){var t=ie();return $t(e,(function(e){return r(e).compile().evaluate(t)}))},"Array | Matrix, Map | Object":function(e,t){return $t(e,(function(e){return r(e).compile().evaluate(t)}))}})})),Qt=W("Help",["parse"],(e=>{var{parse:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw new Error('Argument "doc" missing');this.doc=e}return r.prototype.type="Help",r.prototype.isHelp=!0,r.prototype.toString=function(){var e=this.doc||{},r="\n";if(e.name&&(r+="Name: "+e.name+"\n\n"),e.category&&(r+="Category: "+e.category+"\n\n"),e.description&&(r+="Description:\n "+e.description+"\n\n"),e.syntax&&(r+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){r+="Examples:\n";for(var n={},i=0;i"mathjs"!==e)).forEach((r=>{t[r]=e[r]})),new r(t)},r.prototype.valueOf=r.prototype.toString,r}),{isClass:!0}),Kt=W("Parser",["parse"],(e=>{var{parse:t}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:ie(),writable:!1})}return r.prototype.type="Parser",r.prototype.isParser=!0,r.prototype.evaluate=function(e){return t(e).compile().evaluate(this.scope)},r.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},r.prototype.getAll=function(){return function(e){if(e instanceof ne)return e.wrappedObject;var t={};for(var r of e.keys())X(t,r,e.get(r));return t}(this.scope)},r.prototype.getAllAsMap=function(){return this.scope},r.prototype.set=function(e,t){return this.scope.set(e,t),t},r.prototype.remove=function(e){this.scope.delete(e)},r.prototype.clear=function(){this.scope.clear()},r}),{isClass:!0}),er={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]},tr={name:"e",category:"Constants",syntax:["e"],description:"Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",examples:["e","e ^ 2","exp(2)","log(e)"],seealso:["exp"]},rr={bignumber:{name:"bignumber",category:"Construction",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","complex","fraction","index","matrix","string","unit"]},boolean:{name:"boolean",category:"Construction",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]},complex:{name:"complex",category:"Construction",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]},createUnit:{name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.",examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]},fraction:{name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(num,den)"],description:"Create a fraction from a number or from a numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},index:{name:"index",category:"Construction",syntax:["[start]","[start:end]","[start:step:end]","[start1, start 2, ...]","[start1:end1, start2:end2, ...]","[start1:step1:end1, start2:step2:end2, ...]"],description:"Create an index to get or replace a subset of a matrix",examples:["[]","[1, 2, 3]","A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[0:2, 0:2] = ones(2, 2)"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]},matrix:{name:"matrix",category:"Construction",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()",'matrix("dense")',"matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])",'matrix([3, 4; 5, 6], "sparse")','matrix([3, 4; 5, 6], "sparse", "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","sparse"]},number:{name:"number",category:"Construction",syntax:["x","number(x)","number(unit, valuelessUnit)"],description:"Create a number or convert a string or boolean into a number.",examples:["2","2e3","4.05","number(2)",'number("7.2")',"number(true)","number([true, false, true, true])",'number(unit("52cm"), "m")'],seealso:["bignumber","boolean","complex","fraction","index","matrix","string","unit"]},sparse:{name:"sparse",category:"Construction",syntax:["sparse()","sparse([a1, b1, ...; a1, b2, ...])",'sparse([a1, b1, ...; a1, b2, ...], "number")'],description:"Create a sparse matrix.",examples:["sparse()","sparse([3, 4; 5, 6])",'sparse([3, 0; 5, 0], "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","matrix"]},splitUnit:{name:"splitUnit",category:"Construction",syntax:["splitUnit(unit: Unit, parts: Unit[])"],description:"Split a unit in an array of units whose sum is equal to the original unit.",examples:['splitUnit(1 m, ["feet", "inch"])'],seealso:["unit","createUnit"]},string:{name:"string",category:"Construction",syntax:['"text"',"string(x)"],description:"Create a string or convert a value to a string",examples:['"Hello World!"',"string(4.2)","string(3 + 2i)"],seealso:["bignumber","boolean","complex","index","matrix","number","unit"]},unit:{name:"unit",category:"Construction",syntax:["value unit","unit(value, unit)","unit(string)"],description:"Create a unit.",examples:["5.5 mm","3 inch",'unit(7.1, "kilogram")','unit("23 deg")'],seealso:["bignumber","boolean","complex","index","matrix","number","string"]},e:tr,E:tr,false:{name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},i:{name:"i",category:"Constants",syntax:["i"],description:"Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",examples:["i","i * i","sqrt(-1)"],seealso:[]},Infinity:{name:"Infinity",category:"Constants",syntax:["Infinity"],description:"Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",examples:["Infinity","1 / 0"],seealso:[]},LN2:{name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},LN10:{name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},LOG2E:{name:"LOG2E",category:"Constants",syntax:["LOG2E"],description:"Returns the base-2 logarithm of E, approximately equal to 1.442",examples:["LOG2E","log(e, 2)"],seealso:[]},LOG10E:{name:"LOG10E",category:"Constants",syntax:["LOG10E"],description:"Returns the base-10 logarithm of E, approximately equal to 0.434",examples:["LOG10E","log(e, 10)"],seealso:[]},NaN:{name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},null:{name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},pi:er,PI:er,phi:{name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["phi"],seealso:[]},SQRT1_2:{name:"SQRT1_2",category:"Constants",syntax:["SQRT1_2"],description:"Returns the square root of 1/2, approximately equal to 0.707",examples:["SQRT1_2","sqrt(1/2)"],seealso:[]},SQRT2:{name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},tau:{name:"tau",category:"Constants",syntax:["tau"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]},true:{name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},version:{name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},speedOfLight:{description:"Speed of light in vacuum",examples:["speedOfLight"]},gravitationConstant:{description:"Newtonian constant of gravitation",examples:["gravitationConstant"]},planckConstant:{description:"Planck constant",examples:["planckConstant"]},reducedPlanckConstant:{description:"Reduced Planck constant",examples:["reducedPlanckConstant"]},magneticConstant:{description:"Magnetic constant (vacuum permeability)",examples:["magneticConstant"]},electricConstant:{description:"Electric constant (vacuum permeability)",examples:["electricConstant"]},vacuumImpedance:{description:"Characteristic impedance of vacuum",examples:["vacuumImpedance"]},coulomb:{description:"Coulomb's constant",examples:["coulomb"]},elementaryCharge:{description:"Elementary charge",examples:["elementaryCharge"]},bohrMagneton:{description:"Borh magneton",examples:["bohrMagneton"]},conductanceQuantum:{description:"Conductance quantum",examples:["conductanceQuantum"]},inverseConductanceQuantum:{description:"Inverse conductance quantum",examples:["inverseConductanceQuantum"]},magneticFluxQuantum:{description:"Magnetic flux quantum",examples:["magneticFluxQuantum"]},nuclearMagneton:{description:"Nuclear magneton",examples:["nuclearMagneton"]},klitzing:{description:"Von Klitzing constant",examples:["klitzing"]},bohrRadius:{description:"Borh radius",examples:["bohrRadius"]},classicalElectronRadius:{description:"Classical electron radius",examples:["classicalElectronRadius"]},electronMass:{description:"Electron mass",examples:["electronMass"]},fermiCoupling:{description:"Fermi coupling constant",examples:["fermiCoupling"]},fineStructure:{description:"Fine-structure constant",examples:["fineStructure"]},hartreeEnergy:{description:"Hartree energy",examples:["hartreeEnergy"]},protonMass:{description:"Proton mass",examples:["protonMass"]},deuteronMass:{description:"Deuteron Mass",examples:["deuteronMass"]},neutronMass:{description:"Neutron mass",examples:["neutronMass"]},quantumOfCirculation:{description:"Quantum of circulation",examples:["quantumOfCirculation"]},rydberg:{description:"Rydberg constant",examples:["rydberg"]},thomsonCrossSection:{description:"Thomson cross section",examples:["thomsonCrossSection"]},weakMixingAngle:{description:"Weak mixing angle",examples:["weakMixingAngle"]},efimovFactor:{description:"Efimov factor",examples:["efimovFactor"]},atomicMass:{description:"Atomic mass constant",examples:["atomicMass"]},avogadro:{description:"Avogadro's number",examples:["avogadro"]},boltzmann:{description:"Boltzmann constant",examples:["boltzmann"]},faraday:{description:"Faraday constant",examples:["faraday"]},firstRadiation:{description:"First radiation constant",examples:["firstRadiation"]},loschmidt:{description:"Loschmidt constant at T=273.15 K and p=101.325 kPa",examples:["loschmidt"]},gasConstant:{description:"Gas constant",examples:["gasConstant"]},molarPlanckConstant:{description:"Molar Planck constant",examples:["molarPlanckConstant"]},molarVolume:{description:"Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",examples:["molarVolume"]},sackurTetrode:{description:"Sackur-Tetrode constant at T=1 K and p=101.325 kPa",examples:["sackurTetrode"]},secondRadiation:{description:"Second radiation constant",examples:["secondRadiation"]},stefanBoltzmann:{description:"Stefan-Boltzmann constant",examples:["stefanBoltzmann"]},wienDisplacement:{description:"Wien displacement law constant",examples:["wienDisplacement"]},molarMass:{description:"Molar mass constant",examples:["molarMass"]},molarMassC12:{description:"Molar mass constant of carbon-12",examples:["molarMassC12"]},gravity:{description:"Standard acceleration of gravity (standard acceleration of free-fall on Earth)",examples:["gravity"]},planckLength:{description:"Planck length",examples:["planckLength"]},planckMass:{description:"Planck mass",examples:["planckMass"]},planckTime:{description:"Planck time",examples:["planckTime"]},planckCharge:{description:"Planck charge",examples:["planckCharge"]},planckTemperature:{description:"Planck temperature",examples:["planckTemperature"]},derivative:{name:"derivative",category:"Algebra",syntax:["derivative(expr, variable)","derivative(expr, variable, {simplify: boolean})"],description:"Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",examples:['derivative("2x^3", "x")','derivative("2x^3", "x", {simplify: false})','derivative("2x^2 + 3x + 4", "x")','derivative("sin(2x)", "x")','f = parse("x^2 + x")','x = parse("x")',"df = derivative(f, x)","df.evaluate({x: 3})"],seealso:["simplify","parse","evaluate"]},lsolve:{name:"lsolve",category:"Algebra",syntax:["x=lsolve(L, b)"],description:"Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolveAll","lup","lusolve","usolve","matrix","sparse"]},lsolveAll:{name:"lsolveAll",category:"Algebra",syntax:["x=lsolveAll(L, b)"],description:"Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolve","lup","lusolve","usolve","matrix","sparse"]},lup:{name:"lup",category:"Algebra",syntax:["lup(m)"],description:"Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",examples:["lup([[2, 1], [1, 4]])","lup(matrix([[2, 1], [1, 4]]))","lup(sparse([[2, 1], [1, 4]]))"],seealso:["lusolve","lsolve","usolve","matrix","sparse","slu","qr"]},lusolve:{name:"lusolve",category:"Algebra",syntax:["x=lusolve(A, b)","x=lusolve(lu, b)"],description:"Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lusolve(a, b)"],seealso:["lup","slu","lsolve","usolve","matrix","sparse"]},simplify:{name:"simplify",category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["derivative","parse","evaluate"]},rationalize:{name:"rationalize",category:"Algebra",syntax:["rationalize(expr)","rationalize(expr, scope)","rationalize(expr, scope, detailed)"],description:"Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",examples:['rationalize("2x/y - y/(x+1)")','rationalize("2x/y - y/(x+1)", true)'],seealso:["simplify"]},slu:{name:"slu",category:"Algebra",syntax:["slu(A, order, threshold)"],description:"Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",examples:["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],seealso:["lusolve","lsolve","usolve","matrix","sparse","lup","qr"]},usolve:{name:"usolve",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolveAll","lup","lusolve","lsolve","matrix","sparse"]},usolveAll:{name:"usolveAll",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolve","lup","lusolve","lsolve","matrix","sparse"]},qr:{name:"qr",category:"Algebra",syntax:["qr(A)"],description:"Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",examples:["qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])"],seealso:["lup","slu","matrix"]},abs:{name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},add:{name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i","3 cm + 2 inch",'"2.3" + "4"'],seealso:["subtract"]},cbrt:{name:"cbrt",category:"Arithmetic",syntax:["cbrt(x)","cbrt(x, allRoots)"],description:"Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",examples:["cbrt(64)","cube(4)","cbrt(-8)","cbrt(2 + 3i)","cbrt(8i)","cbrt(8i, true)","cbrt(27 m^3)"],seealso:["square","sqrt","cube","multiply"]},ceil:{name:"ceil",category:"Arithmetic",syntax:["ceil(x)"],description:"Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)"],seealso:["floor","fix","round"]},cube:{name:"cube",category:"Arithmetic",syntax:["cube(x)"],description:"Compute the cube of a value. The cube of x is x * x * x.",examples:["cube(2)","2^3","2 * 2 * 2"],seealso:["multiply","square","pow"]},divide:{name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["a = 2 / 3","a * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]},dotDivide:{name:"dotDivide",category:"Operators",syntax:["x ./ y","dotDivide(x, y)"],description:"Divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","dotMultiply","divide"]},dotMultiply:{name:"dotMultiply",category:"Operators",syntax:["x .* y","dotMultiply(x, y)"],description:"Multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","dotDivide"]},dotPow:{name:"dotPow",category:"Operators",syntax:["x .^ y","dotPow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]},exp:{name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["expm","expm1","pow","log"]},expm:{name:"expm",category:"Arithmetic",syntax:["exp(x)"],description:"Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",examples:["expm([[0,2],[0,0]])"],seealso:["exp"]},expm1:{name:"expm1",category:"Arithmetic",syntax:["expm1(x)"],description:"Calculate the value of subtracting 1 from the exponential value.",examples:["expm1(2)","pow(e, 2) - 1","log(expm1(2) + 1)"],seealso:["exp","pow","log"]},fix:{name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]},floor:{name:"floor",category:"Arithmetic",syntax:["floor(x)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)"],seealso:["ceil","fix","round"]},gcd:{name:"gcd",category:"Arithmetic",syntax:["gcd(a, b)","gcd(a, b, c, ...)"],description:"Compute the greatest common divisor.",examples:["gcd(8, 12)","gcd(-4, 6)","gcd(25, 15, -10)"],seealso:["lcm","xgcd"]},hypot:{name:"hypot",category:"Arithmetic",syntax:["hypot(a, b, c, ...)","hypot([a, b, c, ...])"],description:"Calculate the hypotenusa of a list with values. ",examples:["hypot(3, 4)","sqrt(3^2 + 4^2)","hypot(-2)","hypot([3, 4, 5])"],seealso:["abs","norm"]},lcm:{name:"lcm",category:"Arithmetic",syntax:["lcm(x, y)"],description:"Compute the least common multiple.",examples:["lcm(4, 6)","lcm(6, 21)","lcm(6, 21, 5)"],seealso:["gcd"]},log:{name:"log",category:"Arithmetic",syntax:["log(x)","log(x, base)"],description:"Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",examples:["log(3.5)","a = log(2.4)","exp(a)","10 ^ 4","log(10000, 10)","log(10000) / log(10)","b = log(1024, 2)","2 ^ b"],seealso:["exp","log1p","log2","log10"]},log2:{name:"log2",category:"Arithmetic",syntax:["log2(x)"],description:"Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",examples:["log2(0.03125)","log2(16)","log2(16) / log2(2)","pow(2, 4)"],seealso:["exp","log1p","log","log10"]},log1p:{name:"log1p",category:"Arithmetic",syntax:["log1p(x)","log1p(x, base)"],description:"Calculate the logarithm of a `value+1`",examples:["log1p(2.5)","exp(log1p(1.4))","pow(10, 4)","log1p(9999, 10)","log1p(9999) / log(10)"],seealso:["exp","log","log2","log10"]},log10:{name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(0.00001)","log10(10000)","10 ^ 4","log(10000) / log(10)","log(10000, 10)"],seealso:["exp","log"]},mod:{name:"mod",category:"Operators",syntax:["x % y","x mod y","mod(x, y)"],description:"Calculates the modulus, the remainder of an integer division.",examples:["7 % 3","11 % 2","10 mod 4","isOdd(x) = x % 2","isOdd(2)","isOdd(3)"],seealso:["divide"]},multiply:{name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["a = 2.1 * 3.4","a / 3.4","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]},norm:{name:"norm",category:"Arithmetic",syntax:["norm(x)","norm(x, p)"],description:"Calculate the norm of a number, vector or matrix.",examples:["abs(-3.5)","norm(-3.5)","norm(3 - 4i)","norm([1, 2, -3], Infinity)","norm([1, 2, -3], -Infinity)","norm([3, 4], 2)","norm([[1, 2], [3, 4]], 1)",'norm([[1, 2], [3, 4]], "inf")','norm([[1, 2], [3, 4]], "fro")']},nthRoot:{name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["nthRoots","pow","sqrt"]},nthRoots:{name:"nthRoots",category:"Arithmetic",syntax:["nthRoots(A)","nthRoots(A, root)"],description:'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',examples:["nthRoots(1)","nthRoots(1, 3)"],seealso:["sqrt","pow","nthRoot"]},pow:{name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3","2*2*2","1 + e ^ (pi * i)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},round:{name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)"],seealso:["ceil","floor","fix"]},sign:{name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},sqrt:{name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},sqrtm:{name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},square:{name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},subtract:{name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},unaryMinus:{name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},bitAnd:{name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitNot:{name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitOr:{name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},bitXor:{name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},leftShift:{name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},rightArithShift:{name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},rightLogShift:{name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},bellNumbers:{name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},catalan:{name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},composition:{name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},stirlingS2:{name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},config:{name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},import:{name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number, number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},arg:{name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},conj:{name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},re:{name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},im:{name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},evaluate:{name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(" + 4 + ")")'],seealso:[]},help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},distance:{name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])","distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},intersect:{name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},and:{name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},not:{name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},or:{name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},xor:{name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},concat:{name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},count:{name:"count",category:"Matrix",syntax:["count(x)"],description:"Count the number of elements of a matrix, array or string.",examples:["a = [1, 2; 3, 4; 5, 6]","count(a)","size(a)",'count("hello world")'],seealso:["size"]},cross:{name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},column:{name:"column",category:"Matrix",syntax:["column(x, index)"],description:"Return a column from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","column(A, 1)","column(A, 2)"],seealso:["row","matrixFromColumns"]},ctranspose:{name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},det:{name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diag:{name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diff:{name:"diff",category:"Matrix",syntax:["diff(arr)","diff(arr, dim)"],description:["Create a new matrix or array with the difference of the passed matrix or array.","Dim parameter is optional and used to indicant the dimension of the array/matrix to apply the difference","If no dimension parameter is passed it is assumed as dimension 0","Dimension is zero-based in javascript and one-based in the parser","Arrays must be 'rectangular' meaning arrays like [1, 2]","If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],examples:["diff([1, 2, 4, 7, 0])","diff([1, 2, 4, 7, 0], 0)","diff(matrix([1, 2, 4, 7, 0]))","diff([[1, 2], [3, 4]])","diff([[1, 2], [3, 4]], 0)","diff([[1, 2], [3, 4]], 1)","diff([[1, 2], [3, 4]], bignumber(1))","diff(matrix([[1, 2], [3, 4]]), 1)","diff([[1, 2], matrix([3, 4])], 1)"],seealso:["subtract","partitionSelect"]},dot:{name:"dot",category:"Matrix",syntax:["dot(A, B)","A * B"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]},getMatrixDataType:{name:"getMatrixDataType",category:"Matrix",syntax:["getMatrixDataType(x)"],description:'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',examples:["getMatrixDataType([1, 2, 3])","getMatrixDataType([[5 cm], [2 inch]])",'getMatrixDataType([1, "text"])',"getMatrixDataType([1, bignumber(4)])"],seealso:["matrix","sparse","typeOf"]},identity:{name:"identity",category:"Matrix",syntax:["identity(n)","identity(m, n)","identity([m, n])"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["identity(3)","identity(3, 5)","a = [1, 2, 3; 4, 5, 6]","identity(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},filter:{name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},flatten:{name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]},forEach:{name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["forEach([1, 2, 3], function(val) { console.log(val) })"],seealso:["map","sort","filter"]},inv:{name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","identity","ones","range","size","squeeze","subset","trace","transpose","zeros"]},eigs:{name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and eigenvectors of a real symmetric matrix",examples:["eigs([[5, 2.3], [2.3, 1]])"],seealso:["inv"]},kron:{name:"kron",category:"Matrix",syntax:["kron(x, y)"],description:"Calculates the kronecker product of 2 matrices or vectors.",examples:["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])","kron([1,1], [2,3,4])"],seealso:["multiply","dot","cross"]},matrixFromFunction:{name:"matrixFromFunction",category:"Matrix",syntax:["math.matrixFromFunction(size, fn)","math.matrixFromFunction(size, fn, format)","math.matrixFromFunction(size, fn, format, datatype)","math.matrixFromFunction(size, format, fn)","math.matrixFromFunction(size, format, datatype, fn)"],description:"Create a matrix by evaluating a generating function at each index.",examples:["f(I) = I[1] - I[2]","matrixFromFunction([3,3], f)","g(I) = I[1] - I[2] == 1 ? 4 : 0",'matrixFromFunction([100, 100], "sparse", g)',"matrixFromFunction([5], random)"],seealso:["matrix","matrixFromRows","matrixFromColumns","zeros"]},matrixFromRows:{name:"matrixFromRows",category:"Matrix",syntax:["math.matrixFromRows(...arr)","math.matrixFromRows(row1, row2)","math.matrixFromRows(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual rows.",examples:["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromColumns","matrixFromFunction","zeros"]},matrixFromColumns:{name:"matrixFromColumns",category:"Matrix",syntax:["math.matrixFromColumns(...arr)","math.matrixFromColumns(row1, row2)","math.matrixFromColumns(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual columns.",examples:["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromRows","matrixFromFunction","zeros"]},map:{name:"map",category:"Matrix",syntax:["map(x, callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",examples:["map([1, 2, 3], square)"],seealso:["filter","forEach"]},ones:{name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","identity","inv","range","size","squeeze","subset","trace","transpose","zeros"]},partitionSelect:{name:"partitionSelect",category:"Matrix",syntax:["partitionSelect(x, k)","partitionSelect(x, k, compare)"],description:"Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",examples:["partitionSelect([5, 10, 1], 2)",'partitionSelect(["C", "B", "A", "D"], 1)'],seealso:["sort"]},range:{name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","identity","inv","ones","size","squeeze","subset","trace","transpose","zeros"]},resize:{name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze","reshape"]},reshape:{name:"reshape",category:"Matrix",syntax:["reshape(x, sizes)"],description:"Reshape a multi dimensional array to fit the specified dimensions.",examples:["reshape([1, 2, 3, 4, 5, 6], [2, 3])","reshape([[1, 2], [3, 4]], [1, 4])","reshape([[1, 2], [3, 4]], [4])"],seealso:["size","squeeze","resize"]},rotate:{name:"rotate",category:"Matrix",syntax:["rotate(w, theta)","rotate(w, theta, v)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotate([1, 0], math.pi / 2)",'rotate(matrix([1, 0]), unit("35deg"))','rotate([1, 0, 0], unit("90deg"), [0, 0, 1])','rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],seealso:["matrix","rotationMatrix"]},rotationMatrix:{name:"rotationMatrix",category:"Matrix",syntax:["rotationMatrix(theta)","rotationMatrix(theta, v)","rotationMatrix(theta, v, format)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotationMatrix(pi / 2)",'rotationMatrix(unit("45deg"), [0, 0, 1])','rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],seealso:["cos","sin"]},row:{name:"row",category:"Matrix",syntax:["row(x, index)"],description:"Return a row from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","row(A, 1)","row(A, 2)"],seealso:["column","matrixFromRows"]},size:{name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","count","det","diag","identity","inv","ones","range","squeeze","subset","trace","transpose","zeros"]},sort:{name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"])',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},squeeze:{name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","identity","inv","ones","range","size","subset","trace","transpose","zeros"]},subset:{name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of a matrix or string. Indexes are one-based. Both the ranges lower-bound and upper-bound are included.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},trace:{name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","transpose","zeros"]},transpose:{name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},zeros:{name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose"]},combinations:{name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},combinationsWithRep:{name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"],seealso:["combinations","permutations","factorial"]},factorial:{name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},gamma:{name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},kldivergence:{name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},multinomial:{name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},permutations:{name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},pickRandom:{name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)","pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])","pickRandom([1, 3, 1, 6], 2)","pickRandom([1, 3, 1, 6], [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],seealso:["random","randomInt"]},random:{name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]},randomInt:{name:"randomInt",category:"Probability",syntax:["randomInt(max)","randomInt(min, max)","randomInt(size)","randomInt(size, max)","randomInt(size, min, max)"],description:"Return a random integer number",examples:["randomInt(10, 20)","randomInt([2, 3], 10)"],seealso:["pickRandom","random"]},compare:{name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compareNatural","compareText"]},compareNatural:{name:"compareNatural",category:"Relational",syntax:["compareNatural(x, y)"],description:"Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compareNatural(2, 3)","compareNatural(3, 2)","compareNatural(2, 2)","compareNatural(5cm, 40mm)",'compareNatural("2", "10")',"compareNatural(2 + 3i, 2 + 4i)","compareNatural([1, 2, 4], [1, 2, 3])","compareNatural([1, 5], [1, 2, 3])","compareNatural([1, 2], [1, 2])","compareNatural({a: 2}, {a: 4})"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare","compareText"]},compareText:{name:"compareText",category:"Relational",syntax:["compareText(x, y)"],description:"Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:['compareText("B", "A")','compareText("A", "B")','compareText("A", "A")','compareText("2", "10")','compare("2", "10")',"compare(2, 10)",'compareNatural("2", "10")','compareText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural"]},deepEqual:{name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["deepEqual([1,3,4], [1,3,4])","deepEqual([1,3,4], [1,3])"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]},equal:{name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual","equalText"]},equalText:{name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},larger:{name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},largerEq:{name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},smaller:{name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},smallerEq:{name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 <= 1+1","2 < 1+1","a = 3.2","b = 6-2.8","(a <= b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]},unequal:{name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]},setCartesian:{name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},setDifference:{name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},setDistinct:{name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},setIntersect:{name:"setIntersect",category:"Set",syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},setIsSubset:{name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},setMultiplicity:{name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]},setPowerset:{name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},setSize:{name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},setSymDifference:{name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setDifference"]},setUnion:{name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},erf:{name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},mad:{name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},mean:{name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},median:{name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},min:{name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},mode:{name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},prod:{name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},quantileSeq:{name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:"Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.",examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},std:{name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},sum:{name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},variance:{name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},acos:{name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},acosh:{name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},acot:{name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},acoth:{name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},acsc:{name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},acsch:{name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},asec:{name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},asech:{name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},asin:{name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},asinh:{name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},atan:{name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},atanh:{name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},atan2:{name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},cos:{name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},cosh:{name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},cot:{name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},coth:{name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},csc:{name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},csch:{name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},sec:{name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},sech:{name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},sin:{name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},sinh:{name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},tan:{name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},tanh:{name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},to:{name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},clone:{name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},format:{name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},bin:{name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},oct:{name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},hex:{name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},isNaN:{name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isInteger:{name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isNegative:{name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},isNumeric:{name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},hasNumericValue:{name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},isPositive:{name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isPrime:{name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isZero:{name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},typeOf:{name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},numeric:{name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "BigNumber")','numeric("4", "Fraction)','numeric(4, "Fraction")','numeric(fraction(2, 5), "number)'],seealso:["number","fraction","bignumber","string","format"]}},nr="help",ir=W(nr,["typed","mathWithTransform","Help"],(e=>{var{typed:t,mathWithTransform:r,Help:n}=e;return t(nr,{any:function(e){var t,i=e;if("string"!=typeof e)for(t in r)if(Z(r,t)&&e===r[t]){i=t;break}var a=Y(rr,i);if(!a){var o="function"==typeof i?i.name:i;throw new Error('No documentation found on "'+o+'"')}return new n(a)}})})),ar="compile",or=W(ar,["typed","parse"],(e=>{var{typed:t,parse:r}=e;return t(ar,{string:function(e){return r(e).compile()},"Array | Matrix":function(e){return $t(e,(function(e){return r(e).compile()}))}})})),sr=W("simplifyUtil",["FunctionNode","OperatorNode","SymbolNode"],(e=>{var{FunctionNode:t,OperatorNode:r,SymbolNode:n}=e,i={add:!0,multiply:!0},a={add:!0,multiply:!0};function o(e,t){if(!R(e))return!1;var r=e.fn.toString();return t&&Z(t,r)&&Z(t[r],"associative")?t[r].associative:a[r]||!1}function s(e){var t,r=[];return o(e)?(t=e.op,function e(n){for(var i=0;i2&&o(t)){for(var a=t.args.pop();t.args.length>0;)a=r([t.args.pop(),a]);t.args=a.args}}},unflattenl:function e(t){if(t.args&&0!==t.args.length){for(var r=u(t),n=t.args.length,i=0;i2&&o(t)){for(var a=t.args.shift();t.args.length>0;)a=r([a,t.args.shift()]);t.args=a.args}}}}})),ur=W("simplifyCore",["equal","isZero","add","subtract","multiply","divide","pow","ConstantNode","OperatorNode","FunctionNode","ParenthesisNode"],(e=>{var{equal:t,isZero:r,add:n,subtract:i,multiply:a,divide:o,pow:s,ConstantNode:u,OperatorNode:c,FunctionNode:l,ParenthesisNode:f}=e,p=new u(0),m=new u(1);return function e(h){if(R(h)&&h.isUnary()){var d=e(h.args[0]);if("+"===h.op)return d;if("-"===h.op){if(R(d)){if(d.isUnary()&&"-"===d.op)return d.args[0];if(d.isBinary()&&"subtract"===d.fn)return new c("-","subtract",[d.args[1],d.args[0]])}return new c(h.op,h.fn,[d])}}else if(R(h)&&h.isBinary()){var y=e(h.args[0]),g=e(h.args[1]);if("+"===h.op){if(B(y)){if(r(y.value))return g;if(B(g))return new u(n(y.value,g.value))}return B(g)&&r(g.value)?y:R(g)&&g.isUnary()&&"-"===g.op?new c("-","subtract",[y,g.args[0]]):new c(h.op,h.fn,g?[y,g]:[y])}if("-"===h.op){if(B(y)&&g){if(B(g))return new u(i(y.value,g.value));if(r(y.value))return new c("-","unaryMinus",[g])}if("subtract"===h.fn)return B(g)&&r(g.value)?y:R(g)&&g.isUnary()&&"-"===g.op?e(new c("+","add",[y,g.args[0]])):new c(h.op,h.fn,[y,g])}else{if("*"===h.op){if(B(y)){if(r(y.value))return p;if(t(y.value,1))return g;if(B(g))return new u(a(y.value,g.value))}if(B(g)){if(r(g.value))return p;if(t(g.value,1))return y;if(R(y)&&y.isBinary()&&y.op===h.op){var v=y.args[0];if(B(v)){var x=new u(a(v.value,g.value));return new c(h.op,h.fn,[x,y.args[1]],h.implicit)}}return new c(h.op,h.fn,[g,y],h.implicit)}return new c(h.op,h.fn,[y,g],h.implicit)}if("/"===h.op){if(B(y)){if(r(y.value))return p;if(B(g)&&(t(g.value,1)||t(g.value,2)||t(g.value,4)))return new u(o(y.value,g.value))}return new c(h.op,h.fn,[y,g])}if("^"===h.op){if(B(g)){if(r(g.value))return m;if(t(g.value,1))return y;if(B(y))return new u(s(y.value,g.value));if(R(y)&&y.isBinary()&&"^"===y.op){var b=y.args[1];if(B(b))return new c(h.op,h.fn,[y.args[0],new u(a(b.value,g.value))])}}return new c(h.op,h.fn,[y,g])}}}else{if(F(h)){var w=e(h.content);return F(w)||P(w)||B(w)?w:new f(w)}if(z(h)){var N=h.args.map(e).map((function(e){return F(e)?e.content:e}));return new l(e(h.fn),N)}}return h}}));function cr(){throw new Error('No "bignumber" implementation available')}function lr(){throw new Error('No "fraction" implementation available')}function fr(){throw new Error('No "matrix" implementation available')}var pr=W("simplifyConstant",["typed","config","mathWithTransform","?fraction","?bignumber","ConstantNode","OperatorNode","FunctionNode","SymbolNode"],(e=>{var{typed:t,config:r,mathWithTransform:n,fraction:i,bignumber:a,ConstantNode:o,OperatorNode:u,FunctionNode:c,SymbolNode:l}=e,{isCommutative:f,isAssociative:p,allChildren:m,createMakeNodeFunction:h}=sr({FunctionNode:c,OperatorNode:u,SymbolNode:l});function d(e,t,r){try{return v(n[e].apply(null,t),r)}catch(i){return t=t.map((function(e){return s(e)?e.valueOf():e})),v(n[e].apply(null,t),r)}}var y=t({Fraction:function(e){var t,r=e.s*e.n;return t=r<0?new u("-","unaryMinus",[new o(-r)]):new o(r),1===e.d?t:new u("/","divide",[t,new o(e.d)])},number:function(e){return e<0?x(new o(-e)):new o(e)},BigNumber:function(e){return e<0?x(new o(-e)):new o(e)},Complex:function(e){throw new Error("Cannot convert Complex number to Node")}});function g(e,t){if(t&&!1!==t.exactFractions&&isFinite(e)&&i){var r=i(e),n=t&&"number"==typeof t.fractionsLimit?t.fractionsLimit:1/0;if(r.valueOf()===e&&r.nw(e,t)));if(!r.some(I))try{return d(e.name,r,t)}catch(e){}return r=r.map((function(e){return I(e)?e:y(e)})),new c(e.name,r)}case"OperatorNode":var i,a,o=e.fn.toString(),s=h(e);if(R(e)&&e.isUnary())a=I((i=[w(e.args[0],t)])[0])?s(i):d(o,i,t);else if(p(e))if(i=(i=m(e)).map((e=>w(e,t))),f(o)){for(var u=[],l=[],g=0;g1?(a=b(o,u,s,t),l.unshift(a),a=b(o,l,s,t)):a=b(o,i,s,t)}else a=b(o,i,s,t);else a=b(o,i=e.args.map((e=>w(e,t))),s,t);return a;case"ParenthesisNode":return w(e.content,t);case"AccessorNode":case"ArrayNode":case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"IndexNode":case"ObjectNode":case"RangeNode":case"ConditionalNode":default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(e.type))}}return function(e,t){var r=w(e,t);return I(r)?r:y(r)}})),mr=W("resolve",["parse","FunctionNode","OperatorNode","ParenthesisNode"],(e=>{var{parse:t,FunctionNode:r,OperatorNode:n,ParenthesisNode:i}=e;return function e(a,o){if(!o)return a;if(oe(o)||(o=ae(o)),P(a)){var s=o.get(a.name);if(I(s))return e(s,o);if("number"==typeof s)return t(String(s))}else{if(R(a)){var u=a.args.map((function(t){return e(t,o)}));return new n(a.op,a.fn,u,a.implicit)}if(F(a))return new i(e(a.content,o));if(z(a)){var c=a.args.map((function(t){return e(t,o)}));return new r(a.name,c)}}return a}})),hr=W("simplify",["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","?fraction","?bignumber","mathWithTransform","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{config:t,typed:r,parse:n,add:i,subtract:a,multiply:o,divide:s,pow:u,isZero:c,equal:l,fraction:f,bignumber:p,mathWithTransform:m,ConstantNode:h,FunctionNode:d,OperatorNode:y,ParenthesisNode:g,SymbolNode:v}=e,x=pr({typed:r,config:t,mathWithTransform:m,fraction:f,bignumber:p,ConstantNode:h,OperatorNode:y,FunctionNode:d,SymbolNode:v}),b=ur({equal:l,isZero:c,add:i,subtract:a,multiply:o,divide:s,pow:u,ConstantNode:h,OperatorNode:y,FunctionNode:d,ParenthesisNode:g}),w=mr({parse:n,FunctionNode:d,OperatorNode:y,ParenthesisNode:g}),{isCommutative:N,isAssociative:M,flatten:S,unflattenr:E,unflattenl:A,createMakeNodeFunction:O}=sr({FunctionNode:d,OperatorNode:y,SymbolNode:v}),C=r("simplify",{string:function(e){return this(n(e),this.rules,ie(),{})},"string, Map | Object":function(e,t){return this(n(e),this.rules,t,{})},"string, Map | Object, Object":function(e,t,r){return this(n(e),this.rules,t,r)},"string, Array":function(e,t){return this(n(e),t,ie(),{})},"string, Array, Map | Object":function(e,t,r){return this(n(e),t,r,{})},"string, Array, Map | Object, Object":function(e,t,r,i){return this(n(e),t,r,i)},"Node, Map | Object":function(e,t){return this(e,this.rules,t,{})},"Node, Map | Object, Object":function(e,t,r){return this(e,this.rules,t,r)},Node:function(e){return this(e,this.rules,ie(),{})},"Node, Array":function(e,t){return this(e,t,ie(),{})},"Node, Array, Map | Object":function(e,t,r){return this(e,t,r,{})},"Node, Array, Object, Object":function(e,t,r,n){return this(e,t,ae(r),n)},"Node, Array, Map, Object":function(e,t,r,i){t=function(e){for(var t=[],r=0;r");if(2!==s.length)throw SyntaxError("Could not parse rule: "+i);i={l:s[0],r:s[1]};case"object":if(a={l:_(n(i.l)),r:_(n(i.r))},i.context&&(a.evaluate=i.context),i.evaluate&&(a.evaluate=n(i.evaluate)),M(a.l)){var u=O(a.l),c=new v("_p"+q++);a.expanded={},a.expanded.l=u([a.l.clone(),c]),S(a.expanded.l),E(a.expanded.l),a.expanded.r=u([a.r,c])}break;case"function":a=i;break;default:throw TypeError("Unsupported type of rule: "+o)}t.push(a)}return t}(t);for(var a=w(e,r),o={},s=(a=_(a)).toString({parenthesis:"all"});!o[s];){o[s]=!0,q=0;for(var u=0;u=2&&2===e.args.length){for(var i=function(e,t){var r,n,i=[],a=O(e);if(N(e,t))for(var o=0;o2)throw Error("Unexpected non-binary associative function: "+e.toString());return[]}for(var u=[],c=0;c{var{config:t,typed:r,equal:n,isZero:i,add:a,subtract:o,multiply:s,divide:u,pow:c,parse:l,simplify:f,fraction:p,bignumber:m,mathWithTransform:h,ConstantNode:d,OperatorNode:y,FunctionNode:g,SymbolNode:v,ParenthesisNode:x}=e,b=pr({typed:r,config:t,mathWithTransform:h,fraction:p,bignumber:m,ConstantNode:d,OperatorNode:y,FunctionNode:g,SymbolNode:v}),w=ur({equal:n,isZero:i,add:a,subtract:o,multiply:s,divide:u,pow:c,ConstantNode:d,OperatorNode:y,FunctionNode:g,ParenthesisNode:x});return r(dr,{string:function(e){return this(l(e),{},!1)},"string, boolean":function(e,t){return this(l(e),{},t)},"string, Object":function(e,t){return this(l(e),t,!1)},"string, Object, boolean":function(e,t,r){return this(l(e),t,r)},Node:function(e){return this(e,{},!1)},"Node, boolean":function(e,t){return this(e,{},t)},"Node, Object":function(e,t){return this(e,t,!1)},"Node, Object, boolean":function(e,t,r){var n=function(){var e=[w,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},b,{l:"n*(n1^-1)",r:"n/n1"},{l:"n*n1^-n2",r:"n/n1^n2"},{l:"n1^-1",r:"1/n1"},{l:"n*(n1/n2)",r:"(n*n1)/n2"},{l:"1*n",r:"n"}],t=[{l:"(-n1)/(-n2)",r:"n1/n2"},{l:"(-n1)*(-n2)",r:"n1*n2"},{l:"n1--n2",r:"n1+n2"},{l:"n1-n2",r:"n1+(-n2)"},{l:"(n1+n2)*n3",r:"(n1*n3 + n2*n3)"},{l:"n1*(n2+n3)",r:"(n1*n2+n1*n3)"},{l:"c1*n + c2*n",r:"(c1+c2)*n"},{l:"c1*n + n",r:"(c1+1)*n"},{l:"c1*n - c2*n",r:"(c1-c2)*n"},{l:"c1*n - n",r:"(c1-1)*n"},{l:"v/c",r:"(1/c)*v"},{l:"v/-c",r:"-(1/c)*v"},{l:"-v*-c",r:"c*v"},{l:"-v*c",r:"-c*v"},{l:"v*-c",r:"-c*v"},{l:"v*c",r:"c*v"},{l:"-(-n1*n2)",r:"(n1*n2)"},{l:"-(n1*n2)",r:"(-n1*n2)"},{l:"-(-n1+n2)",r:"(n1-n2)"},{l:"-(n1+n2)",r:"(-n1-n2)"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"},{l:"-(-n1/n2)",r:"(n1/n2)"},{l:"-(n1/n2)",r:"(-n1/n2)"}],r=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],n={};return n.firstRules=e.concat(t,r),n.distrDivRules=[{l:"(n1/n2 + n3/n4)",r:"((n1*n4 + n3*n2)/(n2*n4))"},{l:"(n1/n2 + n3)",r:"((n1 + n3*n2)/n2)"},{l:"(n1 + n2/n3)",r:"((n1*n3 + n2)/n3)"}],n.sucDivRules=r,n.firstRulesAgain=e.concat(t),n.finalRules=[w,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},b,{l:"n*-n^n1",r:"-n^(n1+1)"},{l:"n*n^n1",r:"n^(n1+1)"},{l:"n^n1*-n^n2",r:"-n^(n1+n2)"},{l:"n^n1*n^n2",r:"n^(n1+n2)"},{l:"n^n1*-n",r:"-n^(n1+1)"},{l:"n^n1*n",r:"n^(n1+1)"},{l:"n^n1/-n",r:"-n^(n1-1)"},{l:"n^n1/n",r:"n^(n1-1)"},{l:"n/-n^n1",r:"-n^(1-n1)"},{l:"n/n^n1",r:"n^(1-n1)"},{l:"n^n1/-n^n2",r:"n^(n1-n2)"},{l:"n^n1/n^n2",r:"n^(n1-n2)"},{l:"n1+(-n2*n3)",r:"n1-n2*n3"},{l:"v*(-c)",r:"-c*v"},{l:"n1+-n2",r:"n1-n2"},{l:"v*c",r:"c*v"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"}],n}(),i=function(e,t,r,n){var i=[],a=f(e,n,t,{exactFractions:!1}),o="+-*"+((r=!!r)?"/":"");!function e(t){var r=t.type;if("FunctionNode"===r)throw new Error("There is an unsolved function call");if("OperatorNode"===r)if("^"===t.op){if("ConstantNode"!==t.args[1].type||!ce(parseFloat(t.args[1].value)))throw new Error("There is a non-integer exponent");e(t.args[0])}else{if(-1===o.indexOf(t.op))throw new Error("Operator "+t.op+" invalid in polynomial expression");for(var n=0;n=1){var o,s;e=N(e);var u,c=!0,l=!1;for(e=f(e,n.firstRules,{},{exactFractions:!1});s=c?n.distrDivRules:n.sucDivRules,c=!c,(u=(e=f(e,s)).toString())!==o;)l=!0,o=u;l&&(e=f(e,n.firstRulesAgain,{},{exactFractions:!1})),e=f(e,n.finalRules,{},{exactFractions:!1})}var p=[],m={};return"OperatorNode"===e.type&&e.isBinary()&&"/"===e.op?(1===a&&(e.args[0]=M(e.args[0],p),e.args[1]=M(e.args[1])),r&&(m.numerator=e.args[0],m.denominator=e.args[1])):(1===a&&(e=M(e,p)),r&&(m.numerator=e,m.denominator=null)),r?(m.coefficients=p,m.variables=i.variables,m.expression=e,m):e}});function N(e,t,r){var n=e.type,i=arguments.length>1;if("OperatorNode"===n&&e.isBinary()){var a,o=!1;if("^"===e.op&&("ParenthesisNode"!==e.args[0].type&&"OperatorNode"!==e.args[0].type||"ConstantNode"!==e.args[1].type||(o=(a=parseFloat(e.args[1].value))>=2&&ce(a))),o){if(a>2){var s=e.args[0],u=new y("^","pow",[e.args[0].cloneDeep(),new d(a-1)]);e=new y("*","multiply",[s,u])}else e=new y("*","multiply",[e.args[0],e.args[0].cloneDeep()]);i&&("content"===r?t.content=e:t.args[r]=e)}}if("ParenthesisNode"===n)N(e.content,e,"content");else if("ConstantNode"!==n&&"SymbolNode"!==n)for(var c=0;cr&&(t[c]=0),t[c]+=o.cte*("+"===o.oper?1:-1),void(r=Math.max(c,r))}o.cte=c,""===o.fire&&(t[0]+=o.cte*("+"===o.oper?1:-1))}}(e,null,{cte:1,oper:"+",fire:""});for(var i,a=!0,o=r=t.length-1;o>=0;o--)if(0!==t[o]){var s=new d(a?t[o]:Math.abs(t[o])),u=t[o]<0?"-":"+";if(o>0){var c=new v(n);if(o>1){var l=new d(o);c=new y("^","pow",[c,l])}s=-1===t[o]&&a?new y("-","unaryMinus",[c]):1===Math.abs(t[o])?c:new y("*","multiply",[s,c])}i=a?s:"+"===u?new y("+","add",[i,s]):new y("-","subtract",[i,s]),a=!1}return a?new d(0):i}})),gr="parser",vr=W(gr,["typed","Parser"],(e=>{var{typed:t,Parser:r}=e;return t(gr,{"":function(){return new r}})})),xr=W("derivative",["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:t,config:r,parse:n,simplify:i,equal:a,isZero:o,numeric:s,ConstantNode:u,FunctionNode:c,OperatorNode:l,ParenthesisNode:f,SymbolNode:p}=e,m=t("derivative",{"Node, SymbolNode, Object":function(e,t,r){var n={};d(n,e,t.name);var a=y(e,n);return r.simplify?i(a):a},"Node, SymbolNode":function(e,t){return this(e,t,{simplify:!0})},"string, SymbolNode":function(e,t){return this(n(e),t)},"string, SymbolNode, Object":function(e,t,r){return this(n(e),t,r)},"string, string":function(e,t){return this(n(e),n(t))},"string, string, Object":function(e,t,r){return this(n(e),n(t),r)},"Node, string":function(e,t){return this(e,n(t))},"Node, string, Object":function(e,t,r){return this(e,n(t),r)}});m._simplify=!0,m.toTex=function(e){return h.apply(null,e.args)};var h=t("_derivTex",{"Node, SymbolNode":function(e,t){return B(e)&&"string"===L(e.value)?h(n(e.value).toString(),t.toString(),1):h(e.toString(),t.toString(),1)},"Node, ConstantNode":function(e,t){if("string"===L(t.value))return h(e,n(t.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(e,t,r){return h(e.toString(),t.name,r.value)},"string, string, number":function(e,t,r){return(1===r?"{d\\over d"+t+"}":"{d^{"+r+"}\\over d"+t+"^{"+r+"}}")+"\\left[".concat(e,"\\right]")}}),d=t("constTag",{"Object, ConstantNode, string":function(e,t){return e[t]=!0,!0},"Object, SymbolNode, string":function(e,t,r){return t.name!==r&&(e[t]=!0,!0)},"Object, ParenthesisNode, string":function(e,t,r){return d(e,t.content,r)},"Object, FunctionAssignmentNode, string":function(e,t,r){return-1===t.params.indexOf(r)?(e[t]=!0,!0):d(e,t.expr,r)},"Object, FunctionNode | OperatorNode, string":function(e,t,r){if(t.args.length>0){for(var n=d(e,t.args[0],r),i=1;i0){var n=e.args.filter((function(e){return void 0===t[e]})),i=1===n.length?n[0]:new l("*","multiply",n),s=r.concat(y(i,t));return new l("*","multiply",s)}return new l("+","add",e.args.map((function(r){return new l("*","multiply",e.args.map((function(e){return e===r?y(e,t):e.clone()})))})))}if("/"===e.op&&e.isBinary()){var u=e.args[0],f=e.args[1];return void 0!==t[f]?new l("/","divide",[y(u,t),f]):void 0!==t[u]?new l("*","multiply",[new l("-","unaryMinus",[u]),new l("/","divide",[y(f,t),new l("^","pow",[f.clone(),g(2)])])]):new l("/","divide",[new l("-","subtract",[new l("*","multiply",[y(u,t),f.clone()]),new l("*","multiply",[u.clone(),y(f,t)])]),new l("^","pow",[f.clone(),g(2)])])}if("^"===e.op&&e.isBinary()){var p=e.args[0],m=e.args[1];if(void 0!==t[p])return B(p)&&(o(p.value)||a(p.value,1))?g(0):new l("*","multiply",[e,new l("*","multiply",[new c("log",[p.clone()]),y(m.clone(),t)])]);if(void 0!==t[m]){if(B(m)){if(o(m.value))return g(0);if(a(m.value,1))return y(p,t)}var h=new l("^","pow",[p.clone(),new l("-","subtract",[m,g(1)])]);return new l("*","multiply",[m.clone(),new l("*","multiply",[y(p,t),h])])}return new l("*","multiply",[new l("^","pow",[p.clone(),m.clone()]),new l("+","add",[new l("*","multiply",[y(p,t),new l("/","divide",[m.clone(),p.clone()])]),new l("*","multiply",[y(m,t),new c("log",[p.clone()])])])])}throw new Error('Operator "'+e.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function g(e,t){return new u(s(e,t||r.number))}return m})),br="apply",wr=W(br,["typed","isInteger"],(e=>{var{typed:t,isInteger:r}=e;return t(br,{"Array | Matrix, number | BigNumber, function":function(e,t,n){if(!r(t))throw new TypeError("Integer number expected for dimension");var i=Array.isArray(e)?je(e):e.size();if(t<0||t>=i.length)throw new Pe(t,i.length);return f(e)?e.create(Nr(e.valueOf(),t,n)):Nr(e,t,n)}})}));function Nr(e,t,r){var n,i,a;if(t<=0){if(Array.isArray(e[0])){for(a=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r{var{typed:t,isInteger:r}=e,n=wr({typed:t,isInteger:r});return t("apply",{"...any":function(e){var t=e[1];i(t)?e[1]=t-1:a(t)&&(e[1]=t.minus(1));try{return n.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0});function Sr(e){var t=0,r=1,n=Object.create(null),i=Object.create(null),a=0,o=function(e){var o=i[e];if(o&&(delete n[o],delete i[e],--t,r===o)){if(!t)return a=0,void(r=1);for(;!hasOwnProperty.call(n,++r););}};return e=Math.abs(e),{hit:function(s){var u=i[s],c=++a;if(n[c]=s,i[s]=c,!u){if(++t<=e)return;return s=n[r],o(s),s}if(delete n[u],r===u)for(;!hasOwnProperty.call(n,++r););},delete:o,clear:function(){t=a=0,r=1,n=Object.create(null),i=Object.create(null)}}}function Er(e){var{hasher:t,limit:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r=null==r?Number.POSITIVE_INFINITY:r,t=null==t?JSON.stringify:t,function n(){"object"!=typeof n.cache&&(n.cache={values:new Map,lru:Sr(r||Number.POSITIVE_INFINITY)});for(var i=[],a=0;a{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=P(e[1])||q(e[1])?e[1].compile().evaluate(r):Or(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("filter",{"Array, function":_r,"Matrix, function":function(e,t){return e.create(_r(e.toArray(),t))},"Array, RegExp":it,"Matrix, RegExp":function(e,t){return e.create(it(e.toArray(),t))}});return r}),{isTransformFunction:!0});function _r(e,t){var r=Ar(t);return nt(e,(function(e,n,i){return 1===r?t(e):2===r?t(e,[n+1]):t(e,[n+1],i)}))}var Tr=W("map",["typed"],(e=>{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=P(e[1])||q(e[1])?e[1].compile().evaluate(r):Or(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("map",{"Array, function":function(e,t){return Br(e,t,e)},"Matrix, function":function(e,t){return e.create(Br(e.valueOf(),t,e))}});return r}),{isTransformFunction:!0});function Br(e,t,r){var n=Ar(t);return function e(i,a){return Array.isArray(i)?tt(i,(function(t,r){return e(t,a.concat(r+1))})):1===n?t(i):2===n?t(i,a):t(i,a,r)}(e,[])}var qr=W("forEach",["typed"],(e=>{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=P(e[1])||q(e[1])?e[1].compile().evaluate(r):Or(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("forEach",{"Array | Matrix, function":function(e,t){var r=Ar(t);!function n(i,a){Array.isArray(i)?rt(i,(function(e,t){n(e,a.concat(t+1))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e.valueOf(),[])}});return r}),{isTransformFunction:!0}),zr="subset",Dr=W(zr,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t(zr,{"Array, Index":function(e,t){var n=r(e).subset(t);return t.isScalar()?n:n.valueOf()},"Matrix, Index":function(e,t){return e.subset(t)},"Object, Index":Rr,"string, Index":Ir,"Array, Index, any":function(e,t,n){return r($(e)).subset(t,n,void 0).valueOf()},"Array, Index, any, any":function(e,t,n,i){return r($(e)).subset(t,n,i).valueOf()},"Matrix, Index, any":function(e,t,r){return e.clone().subset(t,r)},"Matrix, Index, any, any":function(e,t,r,n){return e.clone().subset(t,r,n)},"string, Index, string":kr,"string, Index, string, string":kr,"Object, Index, any":Fr})}));function Ir(e,t){if(!y(t))throw new TypeError("Index expected");if(1!==t.size().length)throw new Ue(t.size().length,1);var r=e.length;$e(t.min()[0],r),$e(t.max()[0],r);var n=t.dimension(0),i="";return n.forEach((function(t){i+=e.charAt(t)})),i}function kr(e,t,r,n){if(!t||!0!==t.isIndex)throw new TypeError("Index expected");if(1!==t.size().length)throw new Ue(t.size().length,1);if(void 0!==n){if("string"!=typeof n||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";var i=t.dimension(0);if(i.size()[0]!==r.length)throw new Ue(i.size()[0],r.length);var a=e.length;$e(t.min()[0]),$e(t.max()[0]);for(var o=[],s=0;sa)for(var u=a-1,c=o.length;u{var{typed:t,matrix:r}=e,n=Dr({typed:t,matrix:r});return t("subset",{"...any":function(e){try{return n.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Pr=W("index",["Index"],(e=>{var{Index:t}=e;return function(){for(var e=[],r=0,n=arguments.length;r0?0:2;else if(o&&!0===o.isSet)o=o.map((function(e){return e-1}));else if(l(o)||f(o))o=o.map((function(e){return e-1}));else if(i(o))o--;else if(a(o))o=o.toNumber()-1;else if("string"!=typeof o)throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");e[r]=o}var s=new t;return t.apply(s,e),s}}),{isTransformFunction:!0}),jr="concat",Lr=W(jr,["typed","matrix","isInteger"],(e=>{var{typed:t,matrix:r,isInteger:n}=e;return t(jr,{"...Array | Matrix | number | BigNumber":function(e){var t,o,s=e.length,u=-1,c=!1,l=[];for(t=0;t0&&u>o)throw new Pe(u,o+1)}else{var m=$(p).valueOf(),h=je(m);if(l[t]=m,o=u,u=h.length-1,t>0&&u!==o)throw new Ue(o+1,u+1)}}if(0===l.length)throw new SyntaxError("At least one matrix expected");for(var d=l.shift();l.length;)d=Hr(d,l.shift(),u,0);return c?r(d):d},"...string":function(e){return e.join("")}})}));function Hr(e,t,r,n){if(n{var{typed:t,matrix:r,isInteger:n}=e,o=Lr({typed:t,matrix:r,isInteger:n});return t("concat",{"...any":function(e){var t=e.length-1,r=e[t];i(r)?e[t]=r-1:a(r)&&(e[t]=r.minus(1));try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0});function Gr(e,t,r){var n;return-1!==String(e).indexOf("Unexpected type")?(n=arguments.length>2?" (type: "+L(r)+", value: "+JSON.stringify(r)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+n)):-1!==String(e).indexOf("complex numbers")?(n=arguments.length>2?" (type: "+L(r)+", value: "+JSON.stringify(r)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+n)):e}var Vr=W("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:r,numeric:n,larger:i}=e;return t("max",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){return Gt(e,t.valueOf(),a)},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function max");return o(e)}});function a(e,t){try{return i(e,t)?e:t}catch(e){throw Gr(e,"max",t)}}function o(e){var t;if(Ht(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw Gr(t,"max",e)}})),void 0===t)throw new Error("Cannot calculate max of an empty array");return"string"==typeof t&&(t=n(t,r.number)),t}}));function Zr(e){if(2===e.length&&p(e[0])){var t=(e=e.slice())[1];i(t)?e[1]=t-1:a(t)&&(e[1]=t.minus(1))}return e}var Wr=W("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:r,numeric:n,larger:i}=e,a=Vr({typed:t,config:r,numeric:n,larger:i});return t("max",{"...any":function(e){e=Zr(e);try{return a.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Jr=W("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:r,numeric:n,smaller:i}=e;return t("min",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){return Gt(e,t.valueOf(),a)},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function min");return o(e)}});function a(e,t){try{return i(e,t)?e:t}catch(e){throw Gr(e,"min",t)}}function o(e){var t;if(Ht(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw Gr(t,"min",e)}})),void 0===t)throw new Error("Cannot calculate min of an empty array");return"string"==typeof t&&(t=n(t,r.number)),t}})),Yr=W("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:r,numeric:n,smaller:i}=e,a=Jr({typed:t,config:r,numeric:n,smaller:i});return t("min",{"...any":function(e){e=Zr(e);try{return a.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Xr=W("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:r,add:n,numeric:i}=e;return t("sum",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){try{return Gt(e,t,n)}catch(e){throw Gr(e,"sum")}},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function sum");return a(e)}});function a(e){var t;return Ht(e,(function(e){try{t=void 0===t?e:n(t,e)}catch(t){throw Gr(t,"sum",e)}})),void 0===t&&(t=i(0,r.number)),"string"==typeof t&&(t=i(t,r.number)),t}})),Qr=W("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:r,add:n,numeric:i}=e,a=Xr({typed:t,config:r,add:n,numeric:i});return t("sum",{"...any":function(e){e=Zr(e);try{return a.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Kr="column",en=W(Kr,["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e;return t(Kr,{"Matrix, number":a,"Array, number":function(e,t){return a(n($(e)),t).valueOf()}});function a(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");$e(t,e.size()[1]);var n=i(0,e.size()[0]),a=new r(n,t);return e.subset(a)}})),tn=W("column",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:a}=e,o=en({typed:t,Index:r,matrix:n,range:a});return t("column",{"...any":function(e){var t=e.length-1,r=e[t];i(r)&&(e[t]=r-1);try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),rn="range",nn=W(rn,["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u}=e;return t(rn,{string:l,"string, boolean":l,"number, number":function(e,t){return c(f(e,t,1))},"number, number, number":function(e,t,r){return c(f(e,t,r))},"number, number, boolean":function(e,t,r){return c(r?p(e,t,1):f(e,t,1))},"number, number, number, boolean":function(e,t,r,n){return c(n?p(e,t,r):f(e,t,r))},"BigNumber, BigNumber":function(e,t){return c(m(e,t,new(0,e.constructor)(1)))},"BigNumber, BigNumber, BigNumber":function(e,t,r){return c(m(e,t,r))},"BigNumber, BigNumber, boolean":function(e,t,r){var n=e.constructor;return c(r?h(e,t,new n(1)):m(e,t,new n(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,r,n){return c(n?h(e,t,r):m(e,t,r))}});function c(e){return"Matrix"===r.matrix?n?n(e):fr():e}function l(e,t){var n=function(e){var t=e.split(":").map((function(e){return Number(e)}));if(t.some((function(e){return isNaN(e)})))return null;switch(t.length){case 2:return{start:t[0],end:t[1],step:1};case 3:return{start:t[0],end:t[2],step:t[1]};default:return null}}(e);if(!n)throw new SyntaxError('String "'+e+'" is no valid range');return"BigNumber"===r.number?(void 0===i&&cr(),c((t?h:m)(i(n.start),i(n.end),i(n.step)))):c((t?p:f)(n.start,n.end,n.step))}function f(e,t,r){var n=[],i=e;if(r>0)for(;a(i,t);)n.push(i),i+=r;else if(r<0)for(;s(i,t);)n.push(i),i+=r;return n}function p(e,t,r){var n=[],i=e;if(r>0)for(;o(i,t);)n.push(i),i+=r;else if(r<0)for(;u(i,t);)n.push(i),i+=r;return n}function m(e,t,r){var n=i(0),o=[],u=e;if(r.gt(n))for(;a(u,t);)o.push(u),u=u.plus(r);else if(r.lt(n))for(;s(u,t);)o.push(u),u=u.plus(r);return o}function h(e,t,r){var n=i(0),a=[],s=e;if(r.gt(n))for(;o(s,t);)a.push(s),s=s.plus(r);else if(r.lt(n))for(;u(s,t);)a.push(s),s=s.plus(r);return a}})),an=W("range",["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u}=e,c=nn({typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u});return t("range",{"...any":function(e){return"boolean"!=typeof e[e.length-1]&&e.push(!0),c.apply(null,e)}})}),{isTransformFunction:!0}),on="diff",sn=W(on,["typed","matrix","subtract","number"],(e=>{var{typed:t,matrix:r,subtract:n,number:i}=e;return t(on,{"Array | Matrix":function(e){return f(e)?r(o(e.toArray())):o(e)},"Array | Matrix, number":function(e,t){if(!ce(t))throw new RangeError("Dimension must be a whole number");return f(e)?r(a(e.toArray(),t)):a(e,t)},"Array | Matrix, BigNumber":function(e,t){return this(e,i(t))}});function a(e,t){if(f(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError("Array/Matrix does not have that many dimensions");if(t>0){var r=[];return e.forEach((e=>{r.push(a(e,t-1))})),r}if(0===t)return o(e);throw RangeError("Cannot have negative dimension")}function o(e){var t=[],r=e.length;if(r<2)return e;for(var n=1;n{var{typed:t,matrix:r,subtract:n,number:i,bignumber:a}=e,o=sn({typed:t,matrix:r,subtract:n,number:i,bignumber:a});return t(un,{"...any":function(e){e=Zr(e);try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),ln=W("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e;return t("row",{"Matrix, number":a,"Array, number":function(e,t){return a(n($(e)),t).valueOf()}});function a(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");$e(t,e.size()[0]);var n=i(0,e.size()[1]),a=new r(t,n);return e.subset(a)}})),fn=W("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:a}=e,o=ln({typed:t,Index:r,matrix:n,range:a});return t("row",{"...any":function(e){var t=e.length-1,r=e[t];i(r)&&(e[t]=r-1);try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),pn="mean",mn=W(pn,["typed","add","divide"],(e=>{var{typed:t,add:r,divide:n}=e;return t(pn,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,t){try{var i=Gt(e,t,r),a=Array.isArray(e)?je(e):e.size();return n(i,a[t])}catch(e){throw Gr(e,"mean")}},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function mean");return i(e)}});function i(e){var t,i=0;if(Ht(e,(function(e){try{t=void 0===t?e:r(t,e),i++}catch(t){throw Gr(t,"mean",e)}})),0===i)throw new Error("Cannot calculate the mean of an empty array");return n(t,i)}})),hn=W("mean",["typed","add","divide"],(e=>{var{typed:t,add:r,divide:n}=e,i=mn({typed:t,add:r,divide:n});return t("mean",{"...any":function(e){e=Zr(e);try{return i.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),dn="unbiased",yn="variance",gn=W(yn,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:r,subtract:n,multiply:i,divide:o,apply:s,isNaN:u}=e;return t(yn,{"Array | Matrix":function(e){return c(e,dn)},"Array | Matrix, string":c,"Array | Matrix, number | BigNumber":function(e,t){return l(e,t,dn)},"Array | Matrix, number | BigNumber, string":l,"...":function(e){return c(e,dn)}});function c(e,t){var s,c=0;if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Ht(e,(function(e){try{s=void 0===s?e:r(s,e),c++}catch(t){throw Gr(t,"variance",e)}})),0===c)throw new Error("Cannot calculate variance of an empty array");var l=o(s,c);if(s=void 0,Ht(e,(function(e){var t=n(e,l);s=void 0===s?i(t,t):r(s,i(t,t))})),u(s))return s;switch(t){case"uncorrected":return o(s,c);case"biased":return o(s,c+1);case"unbiased":var f=a(s)?s.mul(0):0;return 1===c?f:o(s,c-1);default:throw new Error('Unknown normalization "'+t+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function l(e,t,r){try{if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return s(e,t,(e=>c(e,r)))}catch(e){throw Gr(e,"variance")}}})),vn="variance",xn=W(vn,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:r,subtract:n,multiply:i,divide:a,apply:o,isNaN:s}=e,u=gn({typed:t,add:r,subtract:n,multiply:i,divide:a,apply:o,isNaN:s});return t(vn,{"...any":function(e){e=Zr(e);try{return u.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),bn=W("std",["typed","sqrt","variance"],(e=>{var{typed:t,sqrt:r,variance:n}=e;return t("std",{"Array | Matrix":i,"Array | Matrix, string":i,"Array | Matrix, number | BigNumber":i,"Array | Matrix, number | BigNumber, string":i,"...":function(e){return i(e)}});function i(e,t){if(0===e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{return r(n.apply(null,arguments))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf(" variance")?new TypeError(e.message.replace(" variance"," std")):e}}})),wn=W("std",["typed","sqrt","variance"],(e=>{var{typed:t,sqrt:r,variance:n}=e,i=bn({typed:t,sqrt:r,variance:n});return t("std",{"...any":function(e){e=Zr(e);try{return i.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Nn=W("ResultSet",[],(()=>{function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=t||[]}return e.prototype.type="ResultSet",e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},e.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},e.fromJSON=function(t){return new e(t.entries)},e}),{isClass:!0}),Mn=r(977),Sn=W("Complex",[],(()=>(Mn.prototype.type="Complex",Mn.prototype.isComplex=!0,Mn.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Mn.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Mn.prototype.format=function(e){var t=this.im,r=this.re,n=ge(this.re,e),a=ge(this.im,e),o=i(e)?e:e?e.precision:null;if(null!==o){var s=Math.pow(10,-o);Math.abs(r/t)t.re?1:e.ret.im?1:e.im{function e(t,r,n){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var i=null!=t,o=null!=r,s=null!=n;if(i)if(a(t))t=t.toNumber();else if("number"!=typeof t)throw new TypeError("Parameter start must be a number");if(o)if(a(r))r=r.toNumber();else if("number"!=typeof r)throw new TypeError("Parameter end must be a number");if(s)if(a(n))n=n.toNumber();else if("number"!=typeof n)throw new TypeError("Parameter step must be a number");this.start=i?parseFloat(t):0,this.end=o?parseFloat(r):0,this.step=s?parseFloat(n):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(t){if("string"!=typeof t)return null;var r=t.split(":").map((function(e){return parseFloat(e)}));if(r.some((function(e){return isNaN(e)})))return null;switch(r.length){case 2:return new e(r[0],r[1]);case 3:return new e(r[0],r[2],r[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var e=0,t=this.start,r=this.step,n=this.end-t;return le(r)===le(n)?e=Math.ceil(n/r):0===n&&(e=0),isNaN(e)&&(e=0),[e]},e.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},e.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},e.prototype.forEach=function(e){var t=this.start,r=this.step,n=this.end,i=0;if(r>0)for(;tn;)e(t,[i],this),t+=r,i++},e.prototype.map=function(e){var t=[];return this.forEach((function(r,n,i){t[n[0]]=e(r,n,i)})),t},e.prototype.toArray=function(){var e=[];return this.forEach((function(t,r){e[r[0]]=t})),e},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(e){var t=ge(this.start,e);return 1!==this.step&&(t+=":"+ge(this.step,e)),t+":"+ge(this.end,e)},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},e.fromJSON=function(t){return new e(t.start,t.end,t.step)},e}),{isClass:!0}),An=Er((function(e){return new e(1).exp()}),{hasher:Tn}),On=Er((function(e){return new e(1).plus(new e(5).sqrt()).div(2)}),{hasher:Tn}),Cn=Er((function(e){return e.acos(-1)}),{hasher:Tn}),_n=Er((function(e){return Cn(e).times(2)}),{hasher:Tn});function Tn(e){return e[0].precision}var Bn=Math.PI,qn=2*Math.PI,zn=Math.E,Dn=W("true",[],(()=>!0)),In=W("false",[],(()=>!1)),kn=W("null",[],(()=>null)),Rn=Xn("Infinity",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1/0):1/0})),Fn=Xn("NaN",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(NaN):NaN})),Un=Xn("pi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?Cn(r):Bn})),Pn=Xn("tau",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?_n(r):qn})),jn=Xn("e",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?An(r):zn})),Ln=Xn("phi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?On(r):1.618033988749895})),Hn=Xn("LN2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(2).ln():Math.LN2})),$n=Xn("LN10",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(10).ln():Math.LN10})),Gn=Xn("LOG2E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1).div(new r(2).ln()):Math.LOG2E})),Vn=Xn("LOG10E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1).div(new r(10).ln()):Math.LOG10E})),Zn=Xn("SQRT1_2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r("0.5").sqrt():Math.SQRT1_2})),Wn=Xn("SQRT2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(2).sqrt():Math.SQRT2})),Jn=Xn("i",["Complex"],(e=>{var{Complex:t}=e;return t.I})),Yn=W("version",[],(()=>"9.4.1"));function Xn(e,t,r){return W(e,t,r,{recreateOnConfigChange:!0})}var Qn=r(776),Kn=W("BigNumber",["?on","config"],(e=>{var{on:t,config:r}=e,n=Qn.clone({precision:r.precision,modulo:9});return n.prototype.type="BigNumber",n.prototype.isBigNumber=!0,n.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},n.fromJSON=function(e){return new n(e.value)},t&&t("config",(function(e,t){e.precision!==t.precision&&n.config({precision:e.precision})})),n}),{isClass:!0}),ei=W("Matrix",[],(()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(e,t,r){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(e,t,r){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e}),{isClass:!0}),ti=W("replacer",[],(()=>function(e,t){return"number"!=typeof t||isFinite(t)&&!isNaN(t)?t:{mathjs:"number",value:String(t)}})),ri=Qi("speedOfLight","299792458","m s^-1"),ni=Qi("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),ii=Qi("planckConstant","6.62607015e-34","J s"),ai=Qi("reducedPlanckConstant","1.0545718176461565e-34","J s"),oi=Qi("magneticConstant","1.25663706212e-6","N A^-2"),si=Qi("electricConstant","8.8541878128e-12","F m^-1"),ui=Qi("vacuumImpedance","376.730313667","ohm"),ci=Qi("coulomb","8.987551792261171e9","N m^2 C^-2"),li=Qi("elementaryCharge","1.602176634e-19","C"),fi=Qi("bohrMagneton","9.2740100783e-24","J T^-1"),pi=Qi("conductanceQuantum","7.748091729863649e-5","S"),mi=Qi("inverseConductanceQuantum","12906.403729652257","ohm"),hi=Qi("magneticFluxQuantum","2.0678338484619295e-15","Wb"),di=Qi("nuclearMagneton","5.0507837461e-27","J T^-1"),yi=Qi("klitzing","25812.807459304513","ohm"),gi=Qi("bohrRadius","5.29177210903e-11","m"),vi=Qi("classicalElectronRadius","2.8179403262e-15","m"),xi=Qi("electronMass","9.1093837015e-31","kg"),bi=Qi("fermiCoupling","1.1663787e-5","GeV^-2"),wi=Ki("fineStructure",.0072973525693),Ni=Qi("hartreeEnergy","4.3597447222071e-18","J"),Mi=Qi("protonMass","1.67262192369e-27","kg"),Si=Qi("deuteronMass","3.3435830926e-27","kg"),Ei=Qi("neutronMass","1.6749271613e-27","kg"),Ai=Qi("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),Oi=Qi("rydberg","10973731.568160","m^-1"),Ci=Qi("thomsonCrossSection","6.6524587321e-29","m^2"),_i=Ki("weakMixingAngle",.2229),Ti=Ki("efimovFactor",22.7),Bi=Qi("atomicMass","1.66053906660e-27","kg"),qi=Qi("avogadro","6.02214076e23","mol^-1"),zi=Qi("boltzmann","1.380649e-23","J K^-1"),Di=Qi("faraday","96485.33212331001","C mol^-1"),Ii=Qi("firstRadiation","3.7417718521927573e-16","W m^2"),ki=Qi("loschmidt","2.686780111798444e25","m^-3"),Ri=Qi("gasConstant","8.31446261815324","J K^-1 mol^-1"),Fi=Qi("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),Ui=Qi("molarVolume","0.022413969545014137","m^3 mol^-1"),Pi=Ki("sackurTetrode",-1.16487052358),ji=Qi("secondRadiation","0.014387768775039337","m K"),Li=Qi("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),Hi=Qi("wienDisplacement","2.897771955e-3","m K"),$i=Qi("molarMass","0.99999999965e-3","kg mol^-1"),Gi=Qi("molarMassC12","11.9999999958e-3","kg mol^-1"),Vi=Qi("gravity","9.80665","m s^-2"),Zi=Qi("planckLength","1.616255e-35","m"),Wi=Qi("planckMass","2.176435e-8","kg"),Ji=Qi("planckTime","5.391245e-44","s"),Yi=Qi("planckCharge","1.87554603778e-18","C"),Xi=Qi("planckTemperature","1.416785e+32","K");function Qi(e,t,r){return W(e,["config","Unit","BigNumber"],(e=>{var{config:n,Unit:i,BigNumber:a}=e,o=new i("BigNumber"===n.number?new a(t):parseFloat(t),r);return o.fixPrefix=!0,o}))}function Ki(e,t){return W(e,["config","BigNumber"],(e=>{var{config:r,BigNumber:n}=e;return"BigNumber"===r.number?new n(t):t}))}var ea=r(628),ta=W("Fraction",[],(()=>(ea.prototype.type="Fraction",ea.prototype.isFraction=!0,ea.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},ea.fromJSON=function(e){return new ea(e)},ea)),{isClass:!0}),ra=W("DenseMatrix",["Matrix"],(e=>{var{Matrix:t}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!c(t))throw new Error("Invalid datatype: "+t);if(f(e))"DenseMatrix"===e.type?(this._data=$(e._data),this._size=$(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&l(e.data)&&l(e.size))this._data=e.data,this._size=e.size,He(this._data,this._size),this._datatype=t||e.datatype;else if(l(e))this._data=d(e),this._size=je(this._data),He(this._data,this._size),this._datatype=t;else{if(e)throw new TypeError("Unsupported type of data ("+L(e)+")");this._data=[],this._size=[0],this._datatype=t}}function n(e,t){if(!y(t))throw new TypeError("Invalid index");if(t.isScalar())return e.get(t.min());var n=t.size();if(n.length!==e._size.length)throw new Ue(n.length,e._size.length);for(var i=t.min(),a=t.max(),s=0,u=e._size.length;s");h(e,t.max().map((function(e){return e+1})),n);var l=a.length;u(e._data,t,r,l,0)}return e}function u(e,t,r,n,i){var a=i===n-1,o=t.dimension(i);a?o.forEach((function(t,n){$e(t),e[t]=r[n[0]]})):o.forEach((function(a,o){$e(a),u(e[a],t,r[o[0]],n,i+1)}))}function m(e,t,r){if(0===t.length){for(var n=e._data;l(n);)n=n[0];return n}return e._size=t.slice(0),e._data=Ge(e._data,e._size,r),e}function h(e,t,r){for(var n=e._size.slice(0),i=!1;n.lengthn[a]&&(n[a]=t[a],i=!0);i&&m(e,n,r)}function d(e){for(var t=0,r=e.length;tArray.isArray(e)&&1===e.length?e[0]:e));return m(r?this.clone():this,n,t)},r.prototype.reshape=function(e,t){var r=t?this.clone():this;r._data=Ze(r._data,e);var n=r._size.reduce(((e,t)=>e*t));return r._size=We(e,n),r},r.prototype.clone=function(){return new r({data:$(this._data),size:$(this._size),datatype:this._datatype})},r.prototype.size=function(){return this._size.slice(0)},r.prototype.map=function(e){var t=this,n=function r(n,i){return l(n)?n.map((function(e,t){return r(e,i.concat(t))})):e(n,i,t)}(this._data,[]);return new r(n,void 0!==this._datatype?ut(n,L):void 0)},r.prototype.forEach=function(e){var t=this;!function r(n,i){l(n)?n.forEach((function(e,t){r(e,i.concat(t))})):e(n,i,t)}(this._data,[])},r.prototype[Symbol.iterator]=function*(){yield*function*e(t,r){if(l(t))for(var n=0;n[e[n]]));t.push(new r(a,e._datatype))},o=0;o0?e:0,n=e<0?-e:0,o=this._size[0],s=this._size[1],u=Math.min(o-n,s-t),c=[],l=0;l0?n:0,c=n<0?-n:0,p=e[0],m=e[1],h=Math.min(p-c,m-u);if(l(t)){if(t.length!==h)throw new Error("Invalid value array length");s=function(e){return t[e]}}else if(f(t)){var d=t.size();if(1!==d.length||d[0]!==h)throw new Error("Invalid matrix length");s=function(e){return t.get([e])}}else s=function(){return t};o||(o=a(s(0))?s(0).mul(0):0);var y=[];if(e.length>0){y=Ge(y,e,o);for(var g=0;g15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new t(e)}},{from:"number",to:"Complex",convert:function(e){return r||sa(e),new r(e,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(e){return r||sa(e),new r(e.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(e){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(e){return r||sa(e),new r(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){p||ua(e);var t=new p(e);if(t.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return t}},{from:"string",to:"number",convert:function(e){var t=Number(e);if(isNaN(t))throw new Error('Cannot convert "'+e+'" to a number');return t}},{from:"string",to:"BigNumber",convert:function(e){t||oa(e);try{return new t(e)}catch(t){throw new Error('Cannot convert "'+e+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(e){p||ua(e);try{return new p(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(e){r||sa(e);try{return new r(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return t||oa(e),new t(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return p||ua(e),new p(+e)}},{from:"boolean",to:"string",convert:function(e){return String(e)}},{from:"Array",to:"Matrix",convert:function(e){return n||function(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}(),new n(e)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}],L}));function oa(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function sa(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function ua(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var ca="isInteger",la=W(ca,["typed"],(e=>{var{typed:t}=e;return t(ca,{number:ce,BigNumber:function(e){return e.isInt()},Fraction:function(e){return 1===e.d&&isFinite(e.n)},"Array | Matrix":function(e){return $t(e,this)}})})),fa="isNumeric",pa=W(fa,["typed"],(e=>{var{typed:t}=e;return t(fa,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(e){return $t(e,this)}})})),ma="number";function ha(e){return e<0}function da(e){return e>0}function ya(e){return 0===e}function ga(e){return Number.isNaN(e)}ha.signature=ma,da.signature=ma,ya.signature=ma,ga.signature=ma;var va="isPositive",xa=W(va,["typed"],(e=>{var{typed:t}=e;return t(va,{number:da,BigNumber:function(e){return!e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s>0&&e.n>0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),ba="isNaN",wa=W(ba,["typed"],(e=>{var{typed:t}=e;return t(ba,{number:ga,BigNumber:function(e){return e.isNaN()},Fraction:function(e){return!1},Complex:function(e){return e.isNaN()},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":function(e){return $t(e,Number.isNaN)}})}));function Na(e,t,r){if(null==r)return e.eq(t);if(e.eq(t))return!0;if(e.isNaN()||t.isNaN())return!1;if(e.isFinite()&&t.isFinite()){var n=e.minus(t).abs();if(n.isZero())return!0;var i=e.constructor.max(e.abs(),t.abs());return n.lte(i.times(r))}return!1}var Ma="equalScalar",Sa=W(Ma,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(Ma,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return e.equals(t)},"Complex, Complex":function(e,t){return function(e,t,r){return Se(e.re,t.re,r)&&Se(e.im,t.im,r)}(e,t,r.epsilon)},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)}})}));W(Ma,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(Ma,{"number, number":function(e,t){return Se(e,t,r.epsilon)}})}));var Ea=W("number",["typed"],(e=>{var{typed:t}=e,r=t("number",{"":function(){return 0},number:function(e){return e},string:function(e){if("NaN"===e)return NaN;var t,r,n=(r=(t=e).match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/))?{input:t,radix:{"0b":2,"0o":8,"0x":16}[r[1]],integerPart:r[2],fractionalPart:r[3]}:null;if(n)return function(e){for(var t=parseInt(e.integerPart,e.radix),r=0,n=0;n2**i-1)throw new SyntaxError('String "'.concat(e,'" is out of range'));o>=2**(i-1)&&(o-=2**i)}return o},BigNumber:function(e){return e.toNumber()},Fraction:function(e){return e.valueOf()},Unit:function(e){throw new Error("Second argument with valueless unit expected")},null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":function(e){return $t(e,this)}});return r.fromJSON=function(e){return parseFloat(e.value)},r})),Aa="boolean",Oa=W(Aa,["typed"],(e=>{var{typed:t}=e;return t(Aa,{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(e){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;var r=Number(e);if(""!==e&&!isNaN(r))return!!r;throw new Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":function(e){return $t(e,this)}})})),Ca=W("complex",["typed","Complex"],(e=>{var{typed:t,Complex:r}=e;return t("complex",{"":function(){return r.ZERO},number:function(e){return new r(e,0)},"number, number":function(e,t){return new r(e,t)},"BigNumber, BigNumber":function(e,t){return new r(e.toNumber(),t.toNumber())},Fraction:function(e){return new r(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return r(e)},null:function(e){return r(0)},Object:function(e){if("re"in e&&"im"in e)return new r(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new r(e);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(e){return $t(e,this)}})})),_a="splitUnit",Ta=W(_a,["typed"],(e=>{var{typed:t}=e;return t(_a,{"Unit, Array":function(e,t){return e.splitUnit(t)}})})),Ba="number",qa="number, number";function za(e){return Math.abs(e)}function Da(e,t){return e+t}function Ia(e,t){return e*t}function ka(e){return-e}function Ra(e){return e}function Fa(e){return he(e)}function Ua(e){return Math.ceil(e)}function Pa(e){return e*e*e}function ja(e){return Math.exp(e)}function La(e){return de(e)}function Ha(e,t){if(!ce(e)||!ce(t))throw new Error("Parameters in function gcd must be integer numbers");for(var r;0!==t;)r=e%t,e=t,t=r;return e<0?-e:e}function $a(e,t){if(!ce(e)||!ce(t))throw new Error("Parameters in function lcm must be integer numbers");if(0===e||0===t)return 0;for(var r,n=e*t;0!==t;)t=e%(r=t),e=r;return Math.abs(n/e)}function Ga(e){return Math.log(e)}function Va(e){return pe(e)}function Za(e){return fe(e)}function Wa(e,t){if(t>0)return e-t*Math.floor(e/t);if(0===t)return e;throw new Error("Cannot calculate mod for a negative divisor")}function Ja(e,t){var r=t<0;if(r&&(t=-t),0===t)throw new Error("Root must be non-zero");if(e<0&&Math.abs(t)%2!=1)throw new Error("Root must be odd when a is negative.");if(0===e)return r?1/0:0;if(!isFinite(e))return r?0:e;var n=Math.pow(Math.abs(e),1/t);return n=e<0?-n:n,r?1/n:n}function Ya(e){return le(e)}function Xa(e){return e*e}function Qa(e,t){var r,n,i,a=0,o=1,s=1,u=0;if(!ce(e)||!ce(t))throw new Error("Parameters in function xgcd must be integer numbers");for(;t;)i=e-(n=Math.floor(e/t))*t,r=a,a=o-n*a,o=r,r=s,s=u-n*s,u=r,e=t,t=i;return e<0?[-e,-o,-u]:[e,e?o:0,u]}function Ka(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:Math.pow(e,t)}function eo(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return parseFloat(xe(e,t))}za.signature=Ba,Da.signature=qa,Ia.signature=qa,ka.signature=Ba,Ra.signature=Ba,Fa.signature=Ba,Ua.signature=Ba,Pa.signature=Ba,ja.signature=Ba,La.signature=Ba,Ha.signature=qa,$a.signature=qa,Ga.signature=Ba,Va.signature=Ba,Za.signature=Ba,Wa.signature=qa,Ja.signature=qa,Ya.signature=Ba,Xa.signature=Ba,Qa.signature=qa,Ka.signature=qa,eo.signature=qa;var to="unaryPlus",ro=W(to,["typed","config","BigNumber"],(e=>{var{typed:t,config:r,BigNumber:n}=e;return t(to,{number:Ra,Complex:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":function(e){return $t(e,this,!0)},"boolean | string":function(e){return"BigNumber"===r.number?new n(+e):+e}})})),no="cube",io=W(no,["typed"],(e=>{var{typed:t}=e;return t(no,{number:Pa,Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},Fraction:function(e){return e.pow(3)},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.pow(3)}})})),ao="expm1",oo=W(ao,["typed","Complex"],(e=>{var{typed:t,Complex:r}=e;return t(ao,{number:La,Complex:function(e){var t=Math.exp(e.re);return new r(t*Math.cos(e.im)-1,t*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)},"Array | Matrix":function(e){return $t(e,this)}})})),so="log10",uo=W(so,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(so,{number:function(e){return e>=0||r.predictable?Va(e):new n(e,0).log().div(Math.LN10)},Complex:function(e){return new n(e).log().div(Math.LN10)},BigNumber:function(e){return!e.isNegative()||r.predictable?e.log():new n(e.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(e){return $t(e,this)}})})),co=W("multiplyScalar",["typed"],(e=>{var{typed:t}=e;return t("multiplyScalar",{"number, number":Ia,"Complex, Complex":function(e,t){return e.mul(t)},"BigNumber, BigNumber":function(e,t){return e.times(t)},"Fraction, Fraction":function(e,t){return e.mul(t)},"number | Fraction | BigNumber | Complex, Unit":function(e,t){var r=t.clone();return r.value=null===r.value?r._normalize(e):this(r.value,e),r},"Unit, number | Fraction | BigNumber | Complex":function(e,t){var r=e.clone();return r.value=null===r.value?r._normalize(t):this(r.value,t),r},"Unit, Unit":function(e,t){return e.multiply(t)}})})),lo="sign",fo=W(lo,["typed","BigNumber","Fraction","complex"],(e=>{var{typed:t,BigNumber:r,complex:n,Fraction:i}=e;return t(lo,{number:Ya,Complex:function(e){return 0===e.im?n(Ya(e.re)):e.sign()},BigNumber:function(e){return new r(e.cmp(0))},Fraction:function(e){return new i(e.s,1)},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return this(e.value)}})})),po="square",mo=W(po,["typed"],(e=>{var{typed:t}=e;return t(po,{number:Xa,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},Fraction:function(e){return e.mul(e)},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.pow(2)}})}));function ho(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitAnd");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero()||t.eq(-1)||e.eq(t))return e;if(t.isZero()||e.eq(-1))return t;if(!e.isFinite()||!t.isFinite()){if(!e.isFinite()&&!t.isFinite())return e.isNegative()===t.isNegative()?e:new r(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new r(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new r(0):e}return vo(e,t,(function(e,t){return e&t}))}function yo(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var t=e.constructor,r=t.precision;t.config({precision:1e9});var n=e.plus(new t(1));return n.s=-n.s||null,t.config({precision:r}),n}function go(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitOr");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);var n=new r(-1);return e.isZero()||t.eq(n)||e.eq(t)?t:t.isZero()||e.eq(n)?e:e.isFinite()&&t.isFinite()?vo(e,t,(function(e,t){return e|t})):!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?n:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e}function vo(e,t,r){var n,i,a,o,s,u=e.constructor,c=+(e.s<0),l=+(t.s<0);if(c){n=xo(yo(e));for(var f=0;f0;)r(a[--m],o[--h])===d&&(y=y.plus(g)),g=g.times(v);for(;h>0;)r(s,o[--h])===d&&(y=y.plus(g)),g=g.times(v);return u.config({precision:x}),0===d&&(y.s=-y.s),y}function xo(e){for(var t=e.d,r=t[0]+"",n=1;n0)if(++s>c)for(s-=c;s--;)u+="0";else s1&&(null!==l[m+1]&&void 0!==l[m+1]||(l[m+1]=0),l[m+1]+=l[m]>>1,l[m]&=1)}return l.reverse()}function bo(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new r(0);var n=new r(-1);return e.eq(n)?yo(t):t.eq(n)?yo(e):e.isFinite()&&t.isFinite()?vo(e,t,(function(e,t){return e^t})):e.isFinite()||t.isFinite()?new r(e.isNegative()===t.isNegative()?1/0:-1/0):n}function wo(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:e.isFinite()||t.isFinite()?t.lt(55)?e.times(Math.pow(2,t.toNumber())+""):e.times(new r(2).pow(t)):new r(NaN)}function No(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(Math.pow(2,t.toNumber())+"").floor():e.div(new r(2).pow(t)).floor():e.isNegative()?new r(-1):e.isFinite()?new r(0):new r(NaN)}var Mo="number, number";function So(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function bitAnd");return e&t}function Eo(e){if(!ce(e))throw new Error("Integer expected in function bitNot");return~e}function Ao(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function bitOr");return e|t}function Oo(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function bitXor");return e^t}function Co(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function leftShift");return e<>t}function To(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}So.signature=Mo,Eo.signature="number",Ao.signature=Mo,Oo.signature=Mo,Co.signature=Mo,_o.signature=Mo,To.signature=Mo;var Bo="bitNot",qo=W(Bo,["typed"],(e=>{var{typed:t}=e;return t(Bo,{number:Eo,BigNumber:yo,"Array | Matrix":function(e){return $t(e,this)}})})),zo=W("arg",["typed"],(e=>{var{typed:t}=e;return t("arg",{number:function(e){return Math.atan2(0,e)},BigNumber:function(e){return e.constructor.atan2(0,e)},Complex:function(e){return e.arg()},"Array | Matrix":function(e){return $t(e,this)}})})),Do=W("im",["typed"],(e=>{var{typed:t}=e;return t("im",{number:function(e){return 0},BigNumber:function(e){return e.mul(0)},Fraction:function(e){return e.mul(0)},Complex:function(e){return e.im},"Array | Matrix":function(e){return $t(e,this)}})})),Io="number, number";function ko(e){return!e}function Ro(e,t){return!(!e&&!t)}function Fo(e,t){return!!e!=!!t}function Uo(e,t){return!(!e||!t)}ko.signature="number",Ro.signature=Io,Fo.signature=Io,Uo.signature=Io;var Po=W("not",["typed"],(e=>{var{typed:t}=e;return t("not",{number:ko,Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},Unit:function(e){return null===e.value||this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),jo=W("filter",["typed"],(e=>{var{typed:t}=e;return t("filter",{"Array, function":Lo,"Matrix, function":function(e,t){return e.create(Lo(e.toArray(),t))},"Array, RegExp":it,"Matrix, RegExp":function(e,t){return e.create(it(e.toArray(),t))}})}));function Lo(e,t){var r=Ar(t);return nt(e,(function(e,n,i){return 1===r?t(e):2===r?t(e,[n]):t(e,[n],i)}))}var Ho="forEach",$o=W(Ho,["typed"],(e=>{var{typed:t}=e;return t(Ho,{"Array, function":Go,"Matrix, function":function(e,t){return e.forEach(t)}})}));function Go(e,t){var r=Ar(t);!function n(i,a){Array.isArray(i)?rt(i,(function(e,t){n(e,a.concat(t))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e,[])}var Vo=W("map",["typed"],(e=>{var{typed:t}=e;return t("map",{"Array, function":Zo,"Matrix, function":function(e,t){return e.map(t)}})}));function Zo(e,t){var r=Ar(t);return function n(i,a){return Array.isArray(i)?i.map((function(e,t){return n(e,a.concat(t))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e,[])}var Wo=W("erf",["typed"],(e=>{var{typed:t}=e;return t("name",{number:function(e){var t=Math.abs(e);return t>=Ko?le(e):t<=Jo?le(e)*function(e){var t,r=e*e,n=Xo[0][4]*r,i=r;for(t=0;t<3;t+=1)n=(n+Xo[0][t])*r,i=(i+Qo[0][t])*r;return e*(n+Xo[0][3])/(i+Qo[0][3])}(t):t<=4?le(e)*(1-function(e){var t,r=Xo[1][8]*e,n=e;for(t=0;t<7;t+=1)r=(r+Xo[1][t])*e,n=(n+Qo[1][t])*e;var i=(r+Xo[1][7])/(n+Qo[1][7]),a=parseInt(16*e)/16,o=(e-a)*(e+a);return Math.exp(-a*a)*Math.exp(-o)*i}(t)):le(e)*(1-function(e){var t,r=1/(e*e),n=Xo[2][5]*r,i=r;for(t=0;t<4;t+=1)n=(n+Xo[2][t])*r,i=(i+Qo[2][t])*r;var a=r*(n+Xo[2][4])/(i+Qo[2][4]);a=(Yo-a)/e;var o=(e-(r=parseInt(16*e)/16))*(e+r);return Math.exp(-r*r)*Math.exp(-o)*a}(t))},"Array | Matrix":function(e){return $t(e,this)}})})),Jo=.46875,Yo=.5641895835477563,Xo=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],Qo=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],Ko=Math.pow(2,53),es="format",ts=W(es,["typed"],(e=>{var{typed:t}=e;return t(es,{any:De,"any, Object | function | number":De})})),rs=W("oct",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("oct",{"number | BigNumber":function(e){return r(e,{notation:"oct"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"oct",wordSize:t})}})})),ns="print",is=W(ns,["typed"],(e=>{var{typed:t}=e;return t(ns,{"string, Object | Array":as,"string, Object | Array, number | Object":as})}));function as(e,t,r){return e.replace(/\$([\w.]+)/g,(function(e,n){for(var i=n.split("."),a=t[i.shift()];i.length&&void 0!==a;){var o=i.shift();a=o?a[o]:a+"."}return void 0!==a?c(a)?a:De(a,r):e}))}var os="isPrime",ss=W(os,["typed"],(e=>{var{typed:t}=e;return t(os,{number:function(e){if(0*e!=0)return!1;if(e<=3)return e>1;if(e%2==0||e%3==0)return!1;for(var t=5;t*t<=e;t+=6)if(e%t==0||e%(t+2)==0)return!1;return!0},BigNumber:function(e){if(0*e.toNumber()!=0)return!1;if(e.lte(3))return e.gt(1);if(e.mod(2).eq(0)||e.mod(3).eq(0))return!1;if(e.lt(Math.pow(2,32))){for(var t=e.toNumber(),r=5;r*r<=t;r+=6)if(t%r==0||t%(r+2)==0)return!1;return!0}function n(e,t,r){for(var n=1;!t.eq(0);)t.mod(2).eq(0)?(t=t.div(2),e=e.mul(e).mod(r)):(t=t.sub(1),n=e.mul(n).mod(r));return n}for(var i=e.constructor.clone({precision:2*e.toFixed(0).length}),a=0,o=(e=new i(e)).sub(1);o.mod(2).eq(0);)o=o.div(2),a+=1;var s=null;if(e.lt("3317044064679887385961981"))s=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter((t=>t{var{typed:t,config:r,Complex:n}=e;return t(us,{number:function(e){return e>=-1&&e<=1||r.predictable?Math.acos(e):new n(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()},"Array | Matrix":function(e){return $t(e,this)}})})),ls="number";function fs(e){return Ee(e)}function ps(e){return Math.atan(1/e)}function ms(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}function hs(e){return Math.asin(1/e)}function ds(e){var t=1/e;return Math.log(t+Math.sqrt(t*t+1))}function ys(e){return Math.acos(1/e)}function gs(e){var t=1/e,r=Math.sqrt(t*t-1);return Math.log(r+t)}function vs(e){return Ae(e)}function xs(e){return Oe(e)}function bs(e){return 1/Math.tan(e)}function ws(e){var t=Math.exp(2*e);return(t+1)/(t-1)}function Ns(e){return 1/Math.sin(e)}function Ms(e){return 0===e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*le(e)}function Ss(e){return 1/Math.cos(e)}function Es(e){return 2/(Math.exp(e)+Math.exp(-e))}function As(e){return _e(e)}fs.signature=ls,ps.signature=ls,ms.signature=ls,hs.signature=ls,ds.signature=ls,ys.signature=ls,gs.signature=ls,vs.signature=ls,xs.signature=ls,bs.signature=ls,ws.signature=ls,Ns.signature=ls,Ms.signature=ls,Ss.signature=ls,Es.signature=ls,As.signature=ls;var Os="acot",Cs=W(Os,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Os,{number:ps,Complex:function(e){return e.acot()},BigNumber:function(e){return new r(1).div(e).atan()},"Array | Matrix":function(e){return $t(e,this)}})})),_s="acsc",Ts=W(_s,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(_s,{number:function(e){return e<=-1||e>=1||r.predictable?hs(e):new n(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new i(1).div(e).asin()},"Array | Matrix":function(e){return $t(e,this)}})})),Bs="asec",qs=W(Bs,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(Bs,{number:function(e){return e<=-1||e>=1||r.predictable?ys(e):new n(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new i(1).div(e).acos()},"Array | Matrix":function(e){return $t(e,this)}})})),zs="asin",Ds=W(zs,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(zs,{number:function(e){return e>=-1&&e<=1||r.predictable?Math.asin(e):new n(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Is=W("atan",["typed"],(e=>{var{typed:t}=e;return t("atan",{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),ks="atanh",Rs=W(ks,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(ks,{number:function(e){return e<=1&&e>=-1||r.predictable?xs(e):new n(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Fs="cosh",Us=W(Fs,["typed"],(e=>{var{typed:t}=e;return t(Fs,{number:Ce,Complex:function(e){return e.cosh()},BigNumber:function(e){return e.cosh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Ps="coth",js=W(Ps,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Ps,{number:ws,Complex:function(e){return e.coth()},BigNumber:function(e){return new r(1).div(e.tanh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Ls="csch",Hs=W(Ls,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Ls,{number:Ms,Complex:function(e){return e.csch()},BigNumber:function(e){return new r(1).div(e.sinh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),$s="sech",Gs=W($s,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t($s,{number:Es,Complex:function(e){return e.sech()},BigNumber:function(e){return new r(1).div(e.cosh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Vs="sinh",Zs=W(Vs,["typed"],(e=>{var{typed:t}=e;return t(Vs,{number:As,Complex:function(e){return e.sinh()},BigNumber:function(e){return e.sinh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Ws=W("tanh",["typed"],(e=>{var{typed:t}=e;return t("tanh",{number:Te,Complex:function(e){return e.tanh()},BigNumber:function(e){return e.tanh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})}));function Js(e,t){if(t>1;return Js(e,r)*Js(r+1,t)}function Ys(e,t){if(!ce(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!ce(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(t>e)throw new TypeError("k must be less than or equal to n");var r=e-t;return t{var{typed:t}=e;return t(Xs,{"number, number":Ys,"BigNumber, BigNumber":function(e,t){var r,n,i=e.constructor,a=e.minus(t),o=new i(1);if(!Ks(e)||!Ks(t))throw new TypeError("Positive integer value expected in function combinations");if(t.gt(e))throw new TypeError("k must be less than n in function combinations");if(r=o,t.lt(a))for(n=o;n.lte(a);n=n.plus(o))r=r.times(t.plus(n)).dividedBy(n);else for(n=o;n.lte(t);n=n.plus(o))r=r.times(a.plus(n)).dividedBy(n);return r}})}));function Ks(e){return e.isInteger()&&e.gte(0)}var eu=r(377),tu=eu(Date.now());function ru(e){var t,r;return t=null===(r=e)?tu:eu(String(r)),function(){return t()}}var nu="pickRandom",iu=W(nu,["typed","config","?on"],(e=>{var{typed:t,config:r,on:n}=e,a=ru(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(a=ru(e.randomSeed))})),t(nu,{"Array | Matrix":function(e){return o(e,{})},"Array | Matrix, Object":function(e,t){return o(e,t)},"Array | Matrix, number":function(e,t){return o(e,{number:t})},"Array | Matrix, Array | Matrix":function(e,t){return o(e,{weights:t})},"Array | Matrix, Array | Matrix, number":function(e,t,r){return o(e,{number:r,weights:t})},"Array | Matrix, number, Array | Matrix":function(e,t,r){return o(e,{number:t,weights:r})}});function o(e,t){var{number:r,weights:n,elementWise:o=!0}=t,s=void 0===r;s&&(r=1);var u=f(e)?e.create:f(n)?n.create:null;e=e.valueOf(),n&&(n=n.valueOf()),!0===o&&(e=et(e),n=et(n));var c=0;if(void 0!==n){if(n.length!==e.length)throw new Error("Weights must have the same length as possibles");for(var l=0,p=n.length;l1)for(var n=0,i=e.shift();n{var{typed:t,config:r,on:n}=e,i=ru(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(i=ru(e.randomSeed))})),t(ou,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,t)=>o(e,t),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,t)=>a(e,0,t),"Array | Matrix, number, number":(e,t,r)=>a(e,t,r)});function a(e,t,r){var n=au(e.valueOf(),(()=>o(t,r)));return f(e)?e.create(n):n}function o(e,t){return Math.floor(e+i()*(t-e))}})),uu="clone",cu=W(uu,["typed"],(e=>{var{typed:t}=e;return t(uu,{any:$})})),lu="hasNumericValue",fu=W(lu,["typed","isNumeric"],(e=>{var{typed:t,isNumeric:r}=e;return t(lu,{string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return r(e)}})})),pu="typeOf",mu=W(pu,["typed"],(e=>{var{typed:t}=e;return t(pu,{any:L})})),hu="string",du=W(hu,["typed"],(e=>{var{typed:t}=e;return t(hu,{"":function(){return""},number:ge,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":function(e){return $t(e,this)},any:function(e){return String(e)}})})),yu=W("fraction",["typed","Fraction"],(e=>{var{typed:t,Fraction:r}=e;return t("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw new Error(e+" cannot be represented as a fraction");return new r(e)},string:function(e){return new r(e)},"number, number":function(e,t){return new r(e,t)},null:function(e){return new r(0)},BigNumber:function(e){return new r(e.toString())},Fraction:function(e){return e},Object:function(e){return new r(e)},"Array | Matrix":function(e){return $t(e,this)}})})),gu="unaryMinus",vu=W(gu,["typed"],(e=>{var{typed:t}=e;return t(gu,{number:ka,Complex:function(e){return e.neg()},BigNumber:function(e){return e.neg()},Fraction:function(e){return e.neg()},Unit:function(e){var t=e.clone();return t.value=this(e.value),t},"Array | Matrix":function(e){return $t(e,this,!0)}})})),xu="addScalar",bu=W(xu,["typed"],(e=>{var{typed:t}=e;return t(xu,{"number, number":Da,"Complex, Complex":function(e,t){return e.add(t)},"BigNumber, BigNumber":function(e,t){return e.plus(t)},"Fraction, Fraction":function(e,t){return e.add(t)},"Unit, Unit":function(e,t){if(null===e.value||void 0===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value||void 0===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var r=e.clone();return r.value=this(r.value,t.value),r.fixPrefix=!1,r}})})),wu=W("exp",["typed"],(e=>{var{typed:t}=e;return t("exp",{number:ja,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()},"Array | Matrix":function(e){return $t(e,this)}})})),Nu="log2",Mu=W(Nu,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(Nu,{number:function(e){return e>=0||r.predictable?Za(e):i(new n(e,0))},Complex:i,BigNumber:function(e){return!e.isNegative()||r.predictable?e.log(2):i(new n(e.toNumber(),0))},"Array | Matrix":function(e){return $t(e,this)}});function i(e){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new n(Math.log2?Math.log2(t):Math.log(t)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}})),Su=W("sqrt",["config","typed","Complex"],(e=>{var{config:t,typed:r,Complex:n}=e;return r("sqrt",{number:i,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.sqrt():i(e.toNumber())},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.pow(.5)}});function i(e){return isNaN(e)?NaN:e>=0||t.predictable?Math.sqrt(e):new n(e,0).sqrt()}})),Eu="conj",Au=W(Eu,["typed"],(e=>{var{typed:t}=e;return t(Eu,{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.conjugate()},"Array | Matrix":function(e){return $t(e,this)}})})),Ou="getMatrixDataType",Cu=W(Ou,["typed"],(e=>{var{typed:t}=e;return t(Ou,{Array:function(e){return ut(e,L)},Matrix:function(e){return e.getDataType()}})})),_u="mode",Tu=W(_u,["typed","isNaN","isNumeric"],(e=>{var{typed:t,isNaN:r,isNumeric:n}=e;return t(_u,{"Array | Matrix":i,"...":function(e){return i(e)}});function i(e){if(0===(e=et(e.valueOf())).length)throw new Error("Cannot calculate mode of an empty array");for(var t={},i=[],a=0,o=0;oa&&(a=t[s],i=[s])}return i}})),Bu=W("bin",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("bin",{"number | BigNumber":function(e){return r(e,{notation:"bin"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"bin",wordSize:t})}})})),qu="acosh",zu=W(qu,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(qu,{number:function(e){return e>=1||r.predictable?fs(e):e<=-1?new n(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new n(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()},"Array | Matrix":function(e){return $t(e,this)}})})),Du="acsch",Iu=W(Du,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Du,{number:ds,Complex:function(e){return e.acsch()},BigNumber:function(e){return new r(1).div(e).asinh()},"Array | Matrix":function(e){return $t(e,this)}})})),ku=W("asinh",["typed"],(e=>{var{typed:t}=e;return t("asinh",{number:vs,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Ru=W("cos",["typed"],(e=>{var{typed:t}=e;return t("cos",{number:Math.cos,Complex:function(e){return e.cos()},BigNumber:function(e){return e.cos()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Fu=W("csc",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("csc",{number:Ns,Complex:function(e){return e.csc()},BigNumber:function(e){return new r(1).div(e.sin())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Uu=W("sin",["typed"],(e=>{var{typed:t}=e;return t("sin",{number:Math.sin,Complex:function(e){return e.sin()},BigNumber:function(e){return e.sin()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Pu="combinationsWithRep",ju=W(Pu,["typed"],(e=>{var{typed:t}=e;return t(Pu,{"number, number":function(e,t){if(!ce(e)||e<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!ce(t)||t<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e<1)throw new TypeError("k must be less than or equal to n + k - 1");return t{var{typed:t,config:r,on:n}=e,i=ru(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(i=ru(e.randomSeed))})),t(Hu,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,t)=>o(e,t),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,t)=>a(e,0,t),"Array | Matrix, number, number":(e,t,r)=>a(e,t,r)});function a(e,t,r){var n=au(e.valueOf(),(()=>o(t,r)));return f(e)?e.create(n):n}function o(e,t){return e+i()*(t-e)}})),Gu="isNegative",Vu=W(Gu,["typed"],(e=>{var{typed:t}=e;return t(Gu,{number:ha,BigNumber:function(e){return e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s<0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Zu=W("SparseMatrix",["typed","equalScalar","Matrix"],(e=>{var{typed:t,equalScalar:r,Matrix:n}=e;function o(e,t){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!c(t))throw new Error("Invalid datatype: "+t);if(f(e))!function(e,t,r){"SparseMatrix"===t.type?(e._values=t._values?$(t._values):void 0,e._index=$(t._index),e._ptr=$(t._ptr),e._size=$(t._size),e._datatype=r||t._datatype):s(e,t.valueOf(),r||t._datatype)}(this,e,t);else if(e&&l(e.index)&&l(e.ptr)&&l(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=t||e.datatype;else if(l(e))s(this,e,t);else{if(e)throw new TypeError("Unsupported type of data ("+L(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=t}}function s(e,n,i){e._values=[],e._index=[],e._ptr=[],e._datatype=i;var a=n.length,o=0,s=r,u=0;if(c(i)&&(s=t.find(r,[i,i])||r,u=t.convert(0,i)),a>0){var f=0;do{e._ptr.push(e._index.length);for(var p=0;p");for(var c=t.min()[0],l=t.min()[1],p=i[0],m=i[1],h=0;hd){for(f=d;fh){if(m){var y=0;for(f=0;fn-1&&(e._values.splice(p,1),e._index.splice(p,1),v++)}e._ptr[f]=e._values.length}return e._size[0]=n,e._size[1]=i,e}function v(e,t,r,n,i){var a,o,s=n[0],u=n[1],c=[];for(a=0;as-1||o>u-1)&&(g(this,Math.max(a+1,s),Math.max(o+1,u),i),s=this._size[0],u=this._size[1]),$e(a,s),$e(o,u);var m=h(a,this._ptr[o],this._ptr[o+1],this._index);return mArray.isArray(e)&&1===e.length?e[0]:e));if(2!==n.length)throw new Error("Only two dimensions matrix are supported");return n.forEach((function(e){if(!i(e)||!ce(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+De(n)+")")})),g(r?this.clone():this,n[0],n[1],t)},o.prototype.reshape=function(e,t){if(!l(e))throw new TypeError("Array expected");if(2!==e.length)throw new Error("Sparse matrices can only be reshaped in two dimensions");e.forEach((function(t){if(!i(t)||!ce(t)||t<=-2||0===t)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+De(e)+")")}));var r=this._size[0]*this._size[1];if(r!==(e=We(e,r))[0]*e[1])throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var n=t?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return n;for(var a=[],o=0;o=0&&w<=i&&y(e._values[b],w-0,g-0)}else{for(var N={},M=v;M "+(this._values?De(this._values[u],e):"X");return i},o.prototype.toString=function(){return De(this.toArray())},o.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},o.prototype.diagonal=function(e){if(e){if(a(e)&&(e=e.toNumber()),!i(e)||!ce(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var t=e>0?e:0,r=e<0?-e:0,n=this._size[0],s=this._size[1],u=Math.min(n-r,s-t),c=[],l=[],f=[];f[0]=0;for(var p=t;p0?s:0,g=s<0?-s:0,v=e[0],x=e[1],b=Math.min(v-g,x-y);if(l(n)){if(n.length!==b)throw new Error("Invalid value array length");d=function(e){return n[e]}}else if(f(n)){var w=n.size();if(1!==w.length||w[0]!==b)throw new Error("Invalid matrix length");d=function(e){return n.get([e])}}else d=function(){return n};for(var N=[],M=[],S=[],E=0;E=0&&A=u||i[l]!==t)){var p=n?n[c]:void 0;i.splice(l,0,t),n&&n.splice(l,0,p),i.splice(l<=c?c+1:c,1),n&&n.splice(l<=c?c+1:c,1)}else if(l=u||i[c]!==e)){var m=n?n[l]:void 0;i.splice(c,0,e),n&&n.splice(c,0,m),i.splice(c<=l?l+1:l,1),n&&n.splice(c<=l?l+1:l,1)}}},o}),{isClass:!0}),Wu="matrix",Ju=W(Wu,["typed","Matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,Matrix:r,DenseMatrix:n,SparseMatrix:i}=e;return t(Wu,{"":function(){return a([])},string:function(e){return a([],e)},"string, string":function(e,t){return a([],e,t)},Array:function(e){return a(e)},Matrix:function(e){return a(e,e.storage())},"Array | Matrix, string":a,"Array | Matrix, string, string":a});function a(e,t,r){if("dense"===t||"default"===t||void 0===t)return new n(e,r);if("sparse"===t)return new i(e,r);throw new TypeError("Unknown matrix type "+JSON.stringify(t)+".")}})),Yu=W("abs",["typed"],(e=>{var{typed:t}=e;return t("abs",{number:za,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},Fraction:function(e){return e.abs()},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.abs()}})})),Xu=W("algorithm01",["typed"],(e=>{var{typed:t}=e;return function(e,r,n,i){var a=e._data,o=e._size,s=e._datatype,u=r._values,c=r._index,l=r._ptr,f=r._size,p=r._datatype;if(o.length!==f.length)throw new Ue(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m,h,d=o[0],y=o[1],g="string"==typeof s&&s===p?s:void 0,v=g?t.find(n,[g,g]):n,x=[];for(m=0;m{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E,A=a&&l?[]:void 0,O=[],C=[],_=a&&l?[]:void 0,T=a&&l?[]:void 0,B=[],q=[];for(N=0;N{var{typed:t,DenseMatrix:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=i;"string"==typeof l&&(f=l,n=t.convert(n,f),h=t.find(i,[f,f]));for(var d=[],y=[],g=[],v=0;v{var{typed:t}=e;return function(e,n,i){var a,o=e._data,s=e._size,u=e._datatype,c=n._data,l=n._size,f=n._datatype,p=[];if(s.length!==l.length)throw new Ue(s.length,l.length);for(var m=0;m0?r(h,0,p,p[0],o,c):[];return e.createDenseMatrix({data:d,size:p,datatype:a})};function r(e,t,n,i,a,o){var s=[];if(t===n.length-1)for(var u=0;u{var{typed:t}=e;return function(e,n,i,a){var o,s=e._data,u=e._size,c=e._datatype,l=i;"string"==typeof c&&(o=c,n=t.convert(n,o),l=t.find(i,[o,o]));var f=u.length>0?r(l,0,u,u[0],s,n,a):[];return e.createDenseMatrix({data:f,size:$(u),datatype:o})};function r(e,t,n,i,a,o,s){var u=[];if(t===n.length-1)for(var c=0;c{var{typed:t,matrix:r,equalScalar:n,BigNumber:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=Qu({typed:t,equalScalar:n}),u=Ku({typed:t,DenseMatrix:a}),c=ec({typed:t}),l=tc({typed:t});return t("gcd",{"number, number":Ha,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var r=new i(0);!t.isZero();){var n=e.mod(t);e=t,t=n}return e.lt(r)?e.neg():e},"Fraction, Fraction":function(e,t){return e.gcd(t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return u(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return l(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return l(r(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,equalScalar:r}=e;return function(e,n,i,a){var o=e._data,s=e._size,u=e._datatype,c=n._values,l=n._index,f=n._ptr,p=n._size,m=n._datatype;if(s.length!==p.length)throw new Ue(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h,d=s[0],y=s[1],g=r,v=0,x=i;"string"==typeof u&&u===m&&(h=u,g=t.find(r,[h,h]),v=t.convert(0,h),x=t.find(i,[h,h]));for(var b=[],w=[],N=[],M=0;M{var{typed:t}=e;return function(e,r,n,i){var a=e._data,o=e._size,s=e._datatype,u=r._values,c=r._index,l=r._ptr,f=r._size,p=r._datatype;if(o.length!==f.length)throw new Ue(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m,h=o[0],d=o[1],y=0,g=n;"string"==typeof s&&s===p&&(m=s,y=t.convert(0,m),g=t.find(n,[m,m]));for(var v=[],x=0;x{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E=a&&l?[]:void 0,A=[],O=[],C=E?[]:void 0,_=E?[]:void 0,T=[],B=[];for(N=0;N{var{typed:t,equalScalar:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=r,d=0,y=i;"string"==typeof l&&(f=l,h=t.find(r,[f,f]),d=t.convert(0,f),n=t.convert(n,f),y=t.find(i,[f,f]));for(var g=[],v=[],x=[],b=0;b{var{typed:t,DenseMatrix:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=i;"string"==typeof l&&(f=l,n=t.convert(n,f),h=t.find(i,[f,f]));for(var d=[],y=[],g=[],v=0;v{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=nc({typed:t,equalScalar:n}),o=ic({typed:t}),s=ac({typed:t,equalScalar:n}),u=oc({typed:t,equalScalar:n}),c=sc({typed:t,DenseMatrix:i}),l=ec({typed:t}),f=tc({typed:t});return t("mod",{"number, number":Wa,"BigNumber, BigNumber":function(e,t){if(t.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return t.isZero()?e:e.mod(t)},"Fraction, Fraction":function(e,t){if(t.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return e.compare(0)>=0?e.mod(t):e.mod(t).add(t).mod(t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return f(e,t,this,!1)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return f(t,e,this,!0)},"Array, any":function(e,t){return f(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return f(r(t),e,this,!0).valueOf()}})})),cc=W("algorithm06",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._size,s=e._datatype,u=n._values,c=n._size,l=n._datatype;if(o.length!==c.length)throw new Ue(o.length,c.length);if(o[0]!==c[0]||o[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+c+")");var f,p=o[0],m=o[1],h=r,d=0,y=i;"string"==typeof s&&s===l&&(f=s,h=t.find(r,[f,f]),d=t.convert(0,f),y=t.find(i,[f,f]));for(var g=a&&u?[]:void 0,v=[],x=[],b=g?[]:void 0,w=[],N=[],M=0;M{var{typed:t,matrix:r,equalScalar:n,BigNumber:i}=e,a=Xu({typed:t}),o=nc({typed:t,equalScalar:n}),s=cc({typed:t,equalScalar:n}),u=oc({typed:t,equalScalar:n}),c=ec({typed:t}),l=tc({typed:t}),f="Complex number not supported in function nthRoot. Use nthRoots instead.";return t(lc,{number:function(e){return Ja(e,2)},"number, number":Ja,BigNumber:function(e){return p(e,new i(2))},Complex:function(e){throw new Error(f)},"Complex, number":function(e,t){throw new Error(f)},"BigNumber, BigNumber":p,"Array | Matrix":function(e){return this(e,2)},"SparseMatrix, SparseMatrix":function(e,t){if(1===t.density())return s(e,t,this);throw new Error("Root must be non-zero")},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){if(1===t.density())return a(e,t,this,!1);throw new Error("Root must be non-zero")},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){if(1===t.density())return u(t,e,this,!0);throw new Error("Root must be non-zero")},"number | BigNumber, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}});function p(e,t){var r=i.precision,n=i.clone({precision:r+2}),a=new i(0),o=new n(1),s=t.isNegative();if(s&&(t=t.neg()),t.isZero())throw new Error("Root must be non-zero");if(e.isNegative()&&!t.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(e.isZero())return s?new n(1/0):0;if(!e.isFinite())return s?a:e;var u=e.abs().pow(o.div(t));return u=e.isNeg()?u.neg():u,new i((s?o.div(u):u).toPrecision(r))}})),pc="xgcd",mc=W(pc,["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t(pc,{"number, number":function(e,t){var i=Qa(e,t);return"Array"===r.matrix?i:n(i)},"BigNumber, BigNumber":function(e,t){var a,o,s,u,c=new i(0),l=new i(1),f=c,p=l,m=l,h=c;if(!e.isInt()||!t.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!t.isZero();)o=e.div(t).floor(),s=e.mod(t),a=f,f=p.minus(o.times(f)),p=a,a=m,m=h.minus(o.times(m)),h=a,e=t,t=s;return u=e.lt(c)?[e.neg(),p.neg(),h.neg()]:[e,e.isZero()?0:p,h],"Array"===r.matrix?u:n(u)}})})),hc="bitAnd",dc=W(hc,["typed","matrix","equalScalar"],(e=>{var{typed:t,matrix:r,equalScalar:n}=e,i=nc({typed:t,equalScalar:n}),a=cc({typed:t,equalScalar:n}),o=oc({typed:t,equalScalar:n}),s=ec({typed:t}),u=tc({typed:t});return t(hc,{"number, number":So,"BigNumber, BigNumber":ho,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),yc=W("algorithm07",["typed","DenseMatrix"],(e=>{var{typed:t,DenseMatrix:r}=e;return function(e,i,a){var o=e._size,s=e._datatype,u=i._size,c=i._datatype;if(o.length!==u.length)throw new Ue(o.length,u.length);if(o[0]!==u[0]||o[1]!==u[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+u+")");var l,f,p,m=o[0],h=o[1],d=0,y=a;"string"==typeof s&&s===c&&(l=s,d=t.convert(0,l),y=t.find(a,[l,l]));var g=[];for(f=0;f{var{typed:t,matrix:r,DenseMatrix:n}=e,i=ic({typed:t}),a=yc({typed:t,DenseMatrix:n}),o=sc({typed:t,DenseMatrix:n}),s=ec({typed:t}),u=tc({typed:t});return t(gc,{"number, number":Oo,"BigNumber, BigNumber":bo,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),xc=W("or",["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=ic({typed:t}),o=ac({typed:t,equalScalar:n}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t("or",{"number, number":Ro,"Complex, Complex":function(e,t){return 0!==e.re||0!==e.im||0!==t.re||0!==t.im},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!e.isNaN()||!t.isZero()&&!t.isNaN()},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})})),bc="diag",wc=W(bc,["typed","matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:r,DenseMatrix:n,SparseMatrix:i}=e;return t(bc,{Array:function(e){return a(e,0,je(e),null)},"Array, number":function(e,t){return a(e,t,je(e),null)},"Array, BigNumber":function(e,t){return a(e,t.toNumber(),je(e),null)},"Array, string":function(e,t){return a(e,0,je(e),t)},"Array, number, string":function(e,t,r){return a(e,t,je(e),r)},"Array, BigNumber, string":function(e,t,r){return a(e,t.toNumber(),je(e),r)},Matrix:function(e){return a(e,0,e.size(),e.storage())},"Matrix, number":function(e,t){return a(e,t,e.size(),e.storage())},"Matrix, BigNumber":function(e,t){return a(e,t.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,t){return a(e,0,e.size(),t)},"Matrix, number, string":function(e,t,r){return a(e,t,e.size(),r)},"Matrix, BigNumber, string":function(e,t,r){return a(e,t.toNumber(),e.size(),r)}});function a(e,t,a,o){if(!ce(t))throw new TypeError("Second parameter in function diag must be an integer");var s=t>0?t:0,u=t<0?-t:0;switch(a.length){case 1:return function(e,t,r,a,o,s){var u=[a+o,a+s];if(r&&"sparse"!==r&&"dense"!==r)throw new TypeError("Unknown matrix type ".concat(r,'"'));var c="sparse"===r?i.diagonal(u,e,t):n.diagonal(u,e,t);return null!==r?c:c.valueOf()}(e,t,o,a[0],u,s);case 2:return function(e,t,n,i,a,o){if(f(e)){var s=e.diagonal(t);return null!==n?n!==s.storage()?r(s,n):s:s.valueOf()}for(var u=Math.min(i[0]-a,i[1]-o),c=[],l=0;l{var{typed:t,config:r,matrix:n,BigNumber:i,DenseMatrix:o,SparseMatrix:s}=e;return t(Nc,{"":function(){return"Matrix"===r.matrix?n([]):[]},string:function(e){return n(e)},"number | BigNumber":function(e){return c(e,e,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, string":function(e,t){return c(e,e,t)},"number | BigNumber, number | BigNumber":function(e,t){return c(e,t,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(e,t,r){return c(e,t,r)},Array:function(e){return u(e)},"Array, string":function(e,t){return u(e,t)},Matrix:function(e){return u(e.valueOf(),e.storage())},"Matrix, string":function(e,t){return u(e.valueOf(),t)}});function u(e,t){switch(e.length){case 0:return t?n(t):[];case 1:return c(e[0],e[0],t);case 2:return c(e[0],e[1],t);default:throw new Error("Vector containing two values expected")}}function c(e,t,r){var n=a(e)||a(t)?i:null;if(a(e)&&(e=e.toNumber()),a(t)&&(t=t.toNumber()),!ce(e)||e<1)throw new Error("Parameters in function identity must be positive integers");if(!ce(t)||t<1)throw new Error("Parameters in function identity must be positive integers");var u=n?new i(1):1,c=n?new n(0):0,l=[e,t];if(r){if("sparse"===r)return s.diagonal(l,u,0,c);if("dense"===r)return o.diagonal(l,u,0,c);throw new TypeError('Unknown matrix type "'.concat(r,'"'))}for(var f=Ge([],l,c),p=e{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t("ones",{"":function(){return"Array"===r.matrix?o([]):o([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return o(e,t)}return"Array"===r.matrix?o(e):o(e,"default")},Array:o,Matrix:function(e){var t=e.storage();return o(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return o(e.valueOf(),t)}});function o(e,t){var r=function(e){var t=!1;return e.forEach((function(e,r,n){a(e)&&(t=!0,n[r]=e.toNumber())})),t}(e)?new i(1):1;if(function(e){e.forEach((function(e){if("number"!=typeof e||!ce(e)||e<0)throw new Error("Parameters in function ones must be positive integers")}))}(e),t){var o=n(t);return e.length>0?o.resize(e,r):o}var s=[];return e.length>0?Ge(s,e,r):s}})),Ec="reshape",Ac=W(Ec,["typed","isInteger","matrix"],(e=>{var{typed:t,isInteger:r}=e;return t(Ec,{"Matrix, Array":function(e,t){return e.reshape(t)},"Array, Array":function(e,t){return t.forEach((function(e){if(!r(e))throw new TypeError("Invalid size for dimension: "+e)})),Ze(e,t)}})})),Oc="size",Cc=W(Oc,["typed","config","?matrix"],(e=>{var{typed:t,config:r,matrix:n}=e;return t(Oc,{Matrix:function(e){return e.create(e.size())},Array:je,string:function(e){return"Array"===r.matrix?[e.length]:n([e.length])},"number | Complex | BigNumber | Unit | boolean | null":function(e){return"Array"===r.matrix?[]:n?n([]):fr()}})})),_c="zeros",Tc=W(_c,["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t(_c,{"":function(){return"Array"===r.matrix?o([]):o([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return o(e,t)}return"Array"===r.matrix?o(e):o(e,"default")},Array:o,Matrix:function(e){var t=e.storage();return o(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return o(e.valueOf(),t)}});function o(e,t){var r=function(e){var t=!1;return e.forEach((function(e,r,n){a(e)&&(t=!0,n[r]=e.toNumber())})),t}(e)?new i(0):0;if(function(e){e.forEach((function(e){if("number"!=typeof e||!ce(e)||e<0)throw new Error("Parameters in function zeros must be positive integers")}))}(e),t){var o=n(t);return e.length>0?o.resize(e,r):o}var s=[];return e.length>0?Ge(s,e,r):s}})),Bc=W("hex",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("hex",{"number | BigNumber":function(e){return r(e,{notation:"hex"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"hex",wordSize:t})}})}));function qc(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function zc(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Dc(e){for(var t=1;t{var{typed:t,matrix:r,equalScalar:n,zeros:i,BigNumber:a,DenseMatrix:o}=e,s=oc({typed:t,equalScalar:n}),u=sc({typed:t,DenseMatrix:o}),c=tc({typed:t});return t(kc,Dc(Dc({},Fc),{},{Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw new TypeError(Ic);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(Ic);var r=t.toNumber();return e.round(r)},"number, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(Ic);return new a(e).toDecimalPlaces(t.toNumber())},BigNumber:function(e){return e.toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(Ic);return e.toDecimalPlaces(t.toNumber())},Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw new TypeError(Ic);return e.round(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"SparseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | Complex | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):u(t,e,this,!0)},"number | Complex | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return c(r(e),t,this,!1).valueOf()},"number | Complex | BigNumber, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}}))})),Fc={number:eo,"number, number":function(e,t){if(!ce(t))throw new TypeError(Ic);if(t<0||t>15)throw new Error("Number of decimals in function round must be in the range of 0-15");return eo(e,t)}},Uc=W("algorithm08",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");if(!a||!l)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));for(var w,N,M,S,E=[],A=[],O=[],C=[],_=[],T=0;T{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=nc({typed:t,equalScalar:n}),u=Uc({typed:t,equalScalar:n}),c=Ku({typed:t,DenseMatrix:a}),l=oc({typed:t,equalScalar:n}),f=ec({typed:t}),p=tc({typed:t});return t(Pc,{"number, number":Co,"BigNumber, BigNumber":wo,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Lc="rightLogShift",Hc=W(Lc,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=nc({typed:t,equalScalar:n}),u=Uc({typed:t,equalScalar:n}),c=Ku({typed:t,DenseMatrix:a}),l=oc({typed:t,equalScalar:n}),f=ec({typed:t}),p=tc({typed:t});return t(Lc,{"number, number":To,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})})),$c="compare",Gc=W($c,["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],(e=>{var{typed:t,config:r,equalScalar:n,matrix:i,BigNumber:a,Fraction:o,DenseMatrix:s}=e,u=ic({typed:t}),c=ac({typed:t,equalScalar:n}),l=sc({typed:t,DenseMatrix:s}),f=ec({typed:t}),p=tc({typed:t});return t($c,{"boolean, boolean":function(e,t){return e===t?0:e>t?1:-1},"number, number":function(e,t){return Se(e,t,r.epsilon)?0:e>t?1:-1},"BigNumber, BigNumber":function(e,t){return Na(e,t,r.epsilon)?new a(0):new a(e.cmp(t))},"Fraction, Fraction":function(e,t){return new o(e.compare(t))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return c(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(i(e),i(t)).valueOf()},"Array, Matrix":function(e,t){return this(i(e),t)},"Matrix, Array":function(e,t){return this(e,i(t))},"SparseMatrix, any":function(e,t){return l(e,t,this,!1)},"DenseMatrix, any":function(e,t){return p(e,t,this,!1)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(i(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(i(t),e,this,!0).valueOf()}})})),Vc="compareText",Zc=W(Vc,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e,n=ec({typed:t}),i=tc({typed:t});return t(Vc,{"any, any":Fe,"DenseMatrix, DenseMatrix":function(e,t){return n(e,t,Fe)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"DenseMatrix, any":function(e,t){return i(e,t,Fe,!1)},"any, DenseMatrix":function(e,t){return i(t,e,Fe,!0)},"Array, any":function(e,t){return i(r(e),t,Fe,!1).valueOf()},"any, Array":function(e,t){return i(r(t),e,Fe,!0).valueOf()}})})),Wc="smaller",Jc=W(Wc,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Wc,{"boolean, boolean":function(e,t){return e{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Yc,{"boolean, boolean":function(e,t){return e>t},"number, number":function(e,t){return e>t&&!Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gt(t)&&!Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return 1===e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),Qc="unequal",Kc=W(Qc,["typed","config","equalScalar","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,equalScalar:n,matrix:i,DenseMatrix:a}=e,o=ic({typed:t}),s=yc({typed:t,DenseMatrix:a}),u=sc({typed:t,DenseMatrix:a}),c=ec({typed:t}),l=tc({typed:t});return t("unequal",{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:f(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,f)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,f,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,f,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,f)},"Array, Array":function(e,t){return this(i(e),i(t)).valueOf()},"Array, Matrix":function(e,t){return this(i(e),t)},"Matrix, Array":function(e,t){return this(e,i(t))},"SparseMatrix, any":function(e,t){return u(e,t,f,!1)},"DenseMatrix, any":function(e,t){return l(e,t,f,!1)},"any, SparseMatrix":function(e,t){return u(t,e,f,!0)},"any, DenseMatrix":function(e,t){return l(t,e,f,!0)},"Array, any":function(e,t){return l(i(e),t,f,!1).valueOf()},"any, Array":function(e,t){return l(i(t),e,f,!0).valueOf()}});function f(e,t){return!n(e,t)}})),el=(W(Qc,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return t(Qc,{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:!r(e,t)}})})),W("ImmutableDenseMatrix",["smaller","DenseMatrix"],(e=>{var{smaller:t,DenseMatrix:r}=e;function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!c(t))throw new Error("Invalid datatype: "+t);if(f(e)||l(e)){var i=new r(e,t);this._data=i._data,this._size=i._size,this._datatype=i._datatype,this._min=null,this._max=null}else if(e&&l(e.data)&&l(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=void 0!==e.min?e.min:null,this._max=void 0!==e.max?e.max:null;else{if(e)throw new TypeError("Unsupported type of data ("+L(e)+")");this._data=[],this._size=[0],this._datatype=t,this._min=null,this._max=null}}return n.prototype=new r,n.prototype.type="ImmutableDenseMatrix",n.prototype.isImmutableDenseMatrix=!0,n.prototype.subset=function(e){switch(arguments.length){case 1:var t=r.prototype.subset.call(this,e);return f(t)?new n({data:t._data,size:t._size,datatype:t._datatype}):t;case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},n.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},n.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},n.prototype.clone=function(){return new n({data:$(this._data),size:$(this._size),datatype:this._datatype})},n.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.fromJSON=function(e){return new n(e)},n.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},n.prototype.min=function(){if(null===this._min){var e=null;this.forEach((function(r){(null===e||t(r,e))&&(e=r)})),this._min=null!==e?e:void 0}return this._min},n.prototype.max=function(){if(null===this._max){var e=null;this.forEach((function(r){(null===e||t(e,r))&&(e=r)})),this._max=null!==e?e:void 0}return this._max},n}),{isClass:!0})),tl=W("FibonacciHeap",["smaller","larger"],(e=>{var{smaller:t,larger:r}=e,n=1/Math.log((1+Math.sqrt(5))/2);function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}function a(e,t,r){t.left.right=t.right,t.right.left=t.left,r.degree--,r.child===t&&(r.child=t.right),0===r.degree&&(r.child=null),t.left=e,t.right=e.right,e.right=t,t.right.left=t,t.parent=null,t.mark=!1}function o(e,t){var r=t.parent;r&&(t.mark?(a(e,t,r),o(r)):t.mark=!0)}i.prototype.type="FibonacciHeap",i.prototype.isFibonacciHeap=!0,i.prototype.insert=function(e,r){var n={key:e,value:r,degree:0};if(this._minimum){var i=this._minimum;n.left=i,n.right=i.right,i.right=n,n.right.left=n,t(e,i.key)&&(this._minimum=n)}else n.left=n,n.right=n,this._minimum=n;return this._size++,n},i.prototype.size=function(){return this._size},i.prototype.clear=function(){this._minimum=null,this._size=0},i.prototype.isEmpty=function(){return 0===this._size},i.prototype.extractMinimum=function(){var e=this._minimum;if(null===e)return e;for(var i=this._minimum,a=e.degree,o=e.child;a>0;){var u=o.right;o.left.right=o.right,o.right.left=o.left,o.left=i,o.right=i.right,i.right=o,o.right.left=o,o.parent=null,o=u,a--}return e.left.right=e.right,e.right.left=e.left,i=e===e.right?null:function(e,i){var a,o=Math.floor(Math.log(i)*n)+1,u=new Array(o),c=0,l=e;if(l)for(c++,l=l.right;l!==e;)c++,l=l.right;for(;c>0;){for(var f=l.degree,p=l.right;a=u[f];){if(r(l.key,a.key)){var m=a;a=l,l=m}s(a,l),u[f]=null,f++}u[f]=l,l=p,c--}e=null;for(var h=0;h{var{typed:t,SparseMatrix:r}=e;return t(rl,{"":function(){return new r([])},string:function(e){return new r([],e)},"Array | Matrix":function(e){return new r(e)},"Array | Matrix, string":function(e,t){return new r(e,t)}})})),il="acoth",al=W(il,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(il,{number:function(e){return e>=1||e<=-1||r.predictable?ms(e):new n(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new i(1).div(e).atanh()},"Array | Matrix":function(e){return $t(e,this)}})})),ol=W("algorithm09",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E,A=a&&l?[]:void 0,O=[],C=[],_=A?[]:void 0,T=[];for(N=0;N{var{typed:t,matrix:r,equalScalar:n,BigNumber:i,DenseMatrix:a}=e,o=nc({typed:t,equalScalar:n}),s=ic({typed:t}),u=ol({typed:t,equalScalar:n}),c=oc({typed:t,equalScalar:n}),l=sc({typed:t,DenseMatrix:a}),f=ec({typed:t}),p=tc({typed:t});return t(sl,{"number, number":Math.atan2,"BigNumber, BigNumber":function(e,t){return i.atan2(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return l(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return p(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return p(r(t),e,this,!0).valueOf()}})})),cl=W("sec",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("sec",{number:Ss,Complex:function(e){return e.sec()},BigNumber:function(e){return new r(1).div(e.cos())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),ll=W("add",["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:r,addScalar:n,equalScalar:i,DenseMatrix:a,SparseMatrix:o}=e,s=Xu({typed:t}),u=Qu({typed:t,equalScalar:i}),c=Ku({typed:t,DenseMatrix:a}),l=ec({typed:t}),f=tc({typed:t});return t("add",G({"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,n)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,n,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,n,!0)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,n)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"DenseMatrix, any":function(e,t){return f(e,t,n,!1)},"SparseMatrix, any":function(e,t){return c(e,t,n,!1)},"any, DenseMatrix":function(e,t){return f(t,e,n,!0)},"any, SparseMatrix":function(e,t){return c(t,e,n,!0)},"Array, any":function(e,t){return f(r(e),t,n,!1).valueOf()},"any, Array":function(e,t){return f(r(t),e,n,!0).valueOf()},"any, any":n,"any, any, ...any":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,addScalar:r,multiplyScalar:n,conj:i,size:a}=e;return t("dot",{"Array | DenseMatrix, Array | DenseMatrix":function(e,a){var u=o(e,a),c=f(e)?e._data:e,l=f(e)?e._datatype:void 0,p=f(a)?a._data:a,m=f(a)?a._datatype:void 0,h=2===s(e).length,d=2===s(a).length,y=r,g=n;if(l&&m&&l===m&&"string"==typeof l){var v=l;y=t.find(r,[v,v]),g=t.find(n,[v,v])}if(!h&&!d){for(var x=g(i(c[0]),p[0]),b=1;bd?m++:h===d&&(c=l(c,f(a[p],u[m])),p++,m++)}return c}});function o(e,t){var r,n,i=s(e),a=s(t);if(1===i.length)r=i[0];else{if(2!==i.length||1!==i[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+i.join(", ")+")");r=i[0]}if(1===a.length)n=a[0];else{if(2!==a.length||1!==a[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+a.join(", ")+")");n=a[0]}if(r!==n)throw new RangeError("Vectors must have equal length ("+r+" != "+n+")");if(0===r)throw new RangeError("Cannot calculate the dot product of empty vectors");return r}function s(e){return f(e)?e.size():a(e)}})),pl="composition",ml=W(pl,["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],(e=>{var{typed:t,addScalar:r,combinations:n,isPositive:i,isNegative:a,isInteger:o,larger:s}=e;return t(pl,{"number | BigNumber, number | BigNumber":function(e,t){if(!(o(e)&&i(e)&&o(t)&&i(t)))throw new TypeError("Positive integer value expected in function composition");if(s(t,e))throw new TypeError("k must be less than or equal to n in function composition");return n(r(e,-1),r(t,-1))}})})),hl="isZero",dl=W(hl,["typed"],(e=>{var{typed:t}=e;return t(hl,{number:ya,BigNumber:function(e){return e.isZero()},Complex:function(e){return 0===e.re&&0===e.im},Fraction:function(e){return 1===e.d&&0===e.n},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),yl="matrixFromFunction",gl=W(yl,["typed","matrix","isZero"],(e=>{var{typed:t,matrix:r,isZero:n}=e;return t(yl,{"Array | Matrix, function, string, string":function(e,t,r,n){return i(e,t,r,n)},"Array | Matrix, function, string":function(e,t,r){return i(e,t,r)},"Matrix, function":function(e,t){return i(e,t,"dense")},"Array, function":function(e,t){return i(e,t,"dense").toArray()},"Array | Matrix, string, function":function(e,t,r){return i(e,r,t)},"Array | Matrix, string, string, function":function(e,t,r,n){return i(e,n,t,r)}});function i(e,t,i,a){var o;return(o=void 0!==a?r(i,a):r(i)).resize(e),o.forEach((function(e,r){var i=t(r);n(i)||o.set(r,i)})),o}})),vl="cbrt",xl=W(vl,["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],(e=>{var{config:t,typed:r,isNegative:n,unaryMinus:i,matrix:u,Complex:c,BigNumber:l,Fraction:f}=e;return r(vl,{number:Fa,Complex:p,"Complex, boolean":p,BigNumber:function(e){return e.cbrt()},Unit:function(e){if(e.value&&o(e.value)){var t=e.clone();return t.value=1,(t=t.pow(1/3)).value=p(e.value),t}var r,u=n(e.value);u&&(e.value=i(e.value)),r=a(e.value)?new l(1).div(3):s(e.value)?new f(1,3):1/3;var c=e.pow(r);return u&&(c.value=i(c.value)),c},"Array | Matrix":function(e){return $t(e,this,!0)}});function p(e,r){var n=e.arg()/3,i=e.abs(),a=new c(Fa(i),0).mul(new c(0,n).exp());if(r){var o=[a,new c(Fa(i),0).mul(new c(0,n+2*Math.PI/3).exp()),new c(Fa(i),0).mul(new c(0,n-2*Math.PI/3).exp())];return"Array"===t.matrix?o:u(o)}return a}})),bl=W("floor",["typed","config","round","matrix","equalScalar"],(e=>{var{typed:t,config:r,round:n,matrix:i,equalScalar:a}=e,o=oc({typed:t,equalScalar:a}),s=tc({typed:t});return t("floor",{number:function(e){return Se(e,n(e),r.epsilon)?n(e):Math.floor(e)},"number, number":function(e,t){if(Se(e,n(e,t),r.epsilon))return n(e,t);var[i,a]="".concat(e,"e").split("e"),o=Math.floor(Number("".concat(i,"e").concat(Number(a)+t)));return[i,a]="".concat(o,"e").split("e"),Number("".concat(i,"e").concat(Number(a)-t))},Complex:function(e){return e.floor()},"Complex, number":function(e,t){return e.floor(t)},BigNumber:function(e){return Na(e,n(e),r.epsilon)?n(e):e.floor()},"BigNumber, BigNumber":function(e,t){return Na(e,n(e,t),r.epsilon)?n(e,t):e.toDecimalPlaces(t.toNumber(),Qn.ROUND_FLOOR)},Fraction:function(e){return e.floor()},"Fraction, number":function(e,t){return e.floor(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"Array | Matrix, number":function(e,t){return $t(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"number | Complex | BigNumber, Array":function(e,t){return s(i(t),e,this,!0).valueOf()}})})),wl="multiply",Nl=W(wl,["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],(e=>{var{typed:t,matrix:r,addScalar:n,multiplyScalar:i,equalScalar:a,dot:o}=e,s=oc({typed:t,equalScalar:a}),u=tc({typed:t});function c(e,t){switch(e.length){case 1:switch(t.length){case 1:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;case 2:switch(t.length){case 1:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+t[0]+")");break;case 2:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}}var l=t("_multiplyMatrixVector",{"DenseMatrix, any":function(e,r){var a,o=e._data,s=e._size,u=e._datatype,c=r._data,l=r._datatype,f=s[0],p=s[1],m=n,h=i;u&&l&&u===l&&"string"==typeof u&&(a=u,m=t.find(n,[a,a]),h=t.find(i,[a,a]));for(var d=[],y=0;yA)for(var C=0,_=0;_{var{typed:t,matrix:r,equalScalar:n,multiplyScalar:i}=e,a=nc({typed:t,equalScalar:n}),o=ol({typed:t,equalScalar:n}),s=oc({typed:t,equalScalar:n}),u=ec({typed:t}),c=tc({typed:t});return t(Ml,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,i)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,i,!1)},"DenseMatrix, any":function(e,t){return c(e,t,i,!1)},"any, SparseMatrix":function(e,t){return s(t,e,i,!0)},"any, DenseMatrix":function(e,t){return c(t,e,i,!0)},"Array, any":function(e,t){return c(r(e),t,i,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,i,!0).valueOf()}})})),El=W("re",["typed"],(e=>{var{typed:t}=e;return t("re",{number:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Complex:function(e){return e.re},"Array | Matrix":function(e){return $t(e,this)}})})),Al="flatten",Ol=W(Al,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t(Al,{Array:function(e){return et($(e))},Matrix:function(e){var t=et($(e.toArray()));return r(t)}})}));function Cl(e,t,r,n){if(!(this instanceof Cl))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=t,this.min=r,this.max=n,this.message="Wrong number of arguments in function "+e+" ("+t+" provided, "+r+(null!=n?"-"+n:"")+" expected)",this.stack=(new Error).stack}Cl.prototype=new Error,Cl.prototype.constructor=Error,Cl.prototype.name="ArgumentsError",Cl.prototype.isArgumentsError=!0;var _l=W("resize",["config","matrix"],(e=>{var{config:t,matrix:r}=e;return function(e,i,o){if(2!==arguments.length&&3!==arguments.length)throw new Cl("resize",arguments.length,2,3);if(f(i)&&(i=i.valueOf()),a(i[0])&&(i=i.map((function(e){return a(e)?e.toNumber():e}))),f(e))return e.resize(i,o,!0);if("string"==typeof e)return n(e,i,o);var s=!Array.isArray(e)&&"Array"!==t.matrix;if(0===i.length){for(;Array.isArray(e);)e=e[0];return $(e)}Array.isArray(e)||(e=[e]);var u=Ge(e=$(e),i,o);return s?r(u):u};function n(e,t,r){if(void 0!==r){if("string"!=typeof r||1!==r.length)throw new TypeError("Single character expected as defaultValue")}else r=" ";if(1!==t.length)throw new Ue(t.length,1);var n=t[0];if("number"!=typeof n||!ce(n))throw new TypeError("Invalid size, must contain positive integers (size: "+De(t)+")");if(e.length>n)return e.substring(0,n);if(e.length{var{typed:t,matrix:r}=e;return t(Tl,{Array:function(e){return Ye($(e))},Matrix:function(e){var t=Ye(e.toArray());return Array.isArray(t)?r(t):t},any:function(e){return $(e)}})})),ql=W("to",["typed","matrix"],(e=>{var{typed:t,matrix:r}=e,n=ec({typed:t}),i=tc({typed:t});return t("to",{"Unit, Unit | string":function(e,t){return e.to(t)},"Matrix, Matrix":function(e,t){return n(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"Matrix, any":function(e,t){return i(e,t,this,!1)},"any, Matrix":function(e,t){return i(t,e,this,!0)},"Array, any":function(e,t){return i(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return i(r(t),e,this,!0).valueOf()}})})),zl=W("pow",["typed","config","identity","multiply","matrix","fraction","number","Complex"],(e=>{var{typed:t,config:r,identity:n,multiply:i,matrix:a,number:o,fraction:s,Complex:u}=e;return t("pow",{"number, number":c,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(e,t){return t.isInteger()||e>=0||r.predictable?e.pow(t):new u(e.toNumber(),0).pow(t.toNumber(),0)},"Fraction, Fraction":function(e,t){var n=e.pow(t);if(null!=n)return n;if(r.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return c(e.valueOf(),t.valueOf())},"Array, number":l,"Array, BigNumber":function(e,t){return l(e,t.toNumber())},"Matrix, number":f,"Matrix, BigNumber":function(e,t){return f(e,t.toNumber())},"Unit, number | BigNumber":function(e,t){return e.pow(t)}});function c(e,t){if(r.predictable&&!ce(t)&&e<0)try{var n=s(t),i=o(n);if((t===i||Math.abs((t-i)/t)<1e-14)&&n.d%2==1)return(n.n%2==0?1:-1)*Math.pow(-e,t)}catch(e){}return r.predictable&&(e<-1&&t===1/0||e>-1&&e<0&&t===-1/0)?NaN:ce(t)||e>=0||r.predictable?Ka(e,t):e*e<1&&t===1/0||e*e>1&&t===-1/0?0:new u(e,0).pow(t,0)}function l(e,t){if(!ce(t)||t<0)throw new TypeError("For A^b, b must be a positive integer (value is "+t+")");var r=je(e);if(2!==r.length)throw new Error("For A^b, A must be 2 dimensional (A has "+r.length+" dimensions)");if(r[0]!==r[1])throw new Error("For A^b, A must be square (size is "+r[0]+"x"+r[1]+")");for(var a=n(r[0]).valueOf(),o=e;t>=1;)1==(1&t)&&(a=i(o,a)),t>>=1,o=i(o,o);return a}function f(e,t){return a(l(e.valueOf(),t))}})),Dl="dotPow",Il=W(Dl,["typed","equalScalar","matrix","pow","DenseMatrix"],(e=>{var{typed:t,equalScalar:r,matrix:n,pow:i,DenseMatrix:a}=e,o=ic({typed:t}),s=yc({typed:t,DenseMatrix:a}),u=oc({typed:t,equalScalar:r}),c=sc({typed:t,DenseMatrix:a}),l=ec({typed:t}),f=tc({typed:t});return t(Dl,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,i)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return f(e,t,this,!1)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return f(t,e,this,!0)},"Array, any":function(e,t){return f(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return f(n(t),e,this,!0).valueOf()}})})),kl="rightArithShift",Rl=W(kl,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=nc({typed:t,equalScalar:n}),u=Uc({typed:t,equalScalar:n}),c=Ku({typed:t,DenseMatrix:a}),l=oc({typed:t,equalScalar:n}),f=ec({typed:t}),p=tc({typed:t});return t(kl,{"number, number":_o,"BigNumber, BigNumber":No,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Fl=r(228),Ul="compareNatural",Pl=W(Ul,["typed","compare"],(e=>{var{typed:t,compare:r}=e,n=r.signatures["boolean,boolean"];return t(Ul,{"any, any":function(e,t){var o,s=L(e),u=L(t);if(!("number"!==s&&"BigNumber"!==s&&"Fraction"!==s||"number"!==u&&"BigNumber"!==u&&"Fraction"!==u))return"0"!==(o=r(e,t)).toString()?o>0?1:-1:Fl(s,u);if("Array"===s||"Matrix"===s||"Array"===u||"Matrix"===u)return 0!==(o=i(this,e,t))?o:Fl(s,u);if(s!==u)return Fl(s,u);if("Complex"===s)return function(e,t){return e.re>t.re?1:e.ret.im?1:e.imr.length?1:t.length{var{typed:t,compareText:r,isZero:n}=e;return t(jl,{"any, any":function(e,t){return n(r(e,t))}})})),Hl="largerEq",$l=W(Hl,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Hl,{"boolean, boolean":function(e,t){return e>=t},"number, number":function(e,t){return e>=t||Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gte(t)||Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return-1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),Gl="partitionSelect",Vl=W(Gl,["typed","isNumeric","isNaN","compare"],(e=>{var{typed:t,isNumeric:r,isNaN:n,compare:i}=e,a=i,o=(e,t)=>-i(e,t);return t(Gl,{"Array | Matrix, number":function(e,t){return s(e,t,a)},"Array | Matrix, number, string":function(e,t,r){if("asc"===r)return s(e,t,a);if("desc"===r)return s(e,t,o);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":s});function s(e,t,r){if(!ce(t)||t<0)throw new Error("k must be a non-negative integer");if(f(e)){if(e.size().length>1)throw new Error("Only one dimensional matrices supported");return u(e.valueOf(),t,r)}if(Array.isArray(e))return u(e,t,r)}function u(e,t,i){if(t>=e.length)throw new Error("k out of bounds");for(var a=0;a=0){var f=e[c];e[c]=e[u],e[u]=f,--c}else++u;i(e[u],l)>0&&--u,t<=u?s=u:o=u+1}return e[t]}})),Zl=W("Index",["ImmutableDenseMatrix"],(e=>{var{ImmutableDenseMatrix:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var t=0,i=arguments.length;t{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(Wl,{number:function(e){if(e<=1&&e>=-1||r.predictable){var t=1/e;if(t>0||r.predictable)return gs(e);var i=Math.sqrt(t*t-1);return new n(Math.log(i-t),Math.PI)}return new n(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new i(1).div(e).acosh()},"Array | Matrix":function(e){return $t(e,this)}})})),Yl=W("tan",["typed"],(e=>{var{typed:t}=e;return t("tan",{number:Math.tan,Complex:function(e){return e.tan()},BigNumber:function(e){return e.tan()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Xl="setDifference",Ql=W(Xl,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Xl,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(0===n(r(e),new a(0)))s=[];else{if(0===n(r(t),new a(0)))return et(e.toArray());var u,c=ot(et(Array.isArray(e)?e:e.toArray()).sort(i)),l=ot(et(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var f=0;f{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Kl,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(0===n(r(e),new a(0))||0===n(r(t),new a(0)))s=[];else{var u=ot(et(Array.isArray(e)?e:e.toArray()).sort(i)),c=ot(et(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var l=0;l{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(tf,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,t){if(0===n(r(t),new a(0)))return 0;for(var o=et(Array.isArray(t)?t:t.toArray()),s=0,u=0;u{var{typed:t,compareNatural:r}=e;return t(nf,{"Array | Matrix":function(e){return Array.isArray(e)?et(e).length:et(e.toArray()).length},"Array | Matrix, boolean":function(e,t){if(!1===t||0===e.length)return Array.isArray(e)?et(e).length:et(e.toArray()).length;for(var n=et(Array.isArray(e)?e:e.toArray()).sort(r),i=1,a=1;a{var{typed:t,matrix:r,add:n}=e;return t("trace",{Array:function(e){return i(r(e))},SparseMatrix:function(e){var t=e._values,r=e._index,i=e._ptr,a=e._size,o=a[0],s=a[1];if(o===s){var u=0;if(t.length>0)for(var c=0;cc)break}return u}throw new RangeError("Matrix must be square (size: "+De(a)+")")},DenseMatrix:i,any:$});function i(e){var t=e._size,r=e._data;switch(t.length){case 1:if(1===t[0])return $(r[0]);throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:var i=t[0];if(i===t[1]){for(var a=0,o=0;o{var{typed:t,add:r,multiply:n,partitionSelect:o,compare:s}=e;function u(e,t,a){var u=et(e),l=u.length;if(0===l)throw new Error("Cannot calculate quantile of an empty sequence");if(i(t)){var f=t*(l-1),p=f%1;if(0===p){var m=a?u[f]:o(u,f);return c(m),m}var h,d,y=Math.floor(f);if(a)h=u[y],d=u[y+1];else{d=o(u,y+1),h=u[y];for(var g=0;g0&&(h=u[g])}return c(h),c(d),r(n(h,1-p),n(d,p))}var v=t.times(l-1);if(v.isInteger()){v=v.toNumber();var x=a?u[v]:o(u,v);return c(x),x}var b,w,N=v.floor(),M=v.minus(N),S=N.toNumber();if(a)b=u[S],w=u[S+1];else{w=o(u,S+1),b=u[S];for(var E=0;E0&&(b=u[E])}c(b),c(w);var A=new M.constructor(1);return r(n(b,A.minus(M)),n(w,M))}var c=t({"number | BigNumber | Unit":function(e){return e}});return function(e,t,r){var n,o,s;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(p(e)){if("boolean"==typeof(r=r||!1)){if(o=e.valueOf(),i(t)){if(t<0)throw new Error("N/prob must be non-negative");if(t<=1)return u(o,t,r);if(t>1){if(!ce(t))throw new Error("N must be a positive integer");var c=t+1;n=new Array(t);for(var l=0;l4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var h=new f(m+1);n=new Array(m);for(var d=0;d1)throw new Error("Probability must be between 0 and 1, inclusive")}else{if(!a(g))throw new TypeError("Unexpected type of argument in function quantileSeq");if(s=new g.constructor(1),g.isNegative()||g.gt(s))throw new Error("Probability must be between 0 and 1, inclusive")}n[y]=u(o,g,r)}return n}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}}));function uf(e){var t;if(ce(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:Js(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*uf(1-e));if(e>=171.35)return 1/0;if(e>85){var r=e*e,n=r*e,i=n*e,a=i*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*r)-139/(51840*n)-571/(2488320*i)+163879/(209018880*a)+5246819/(75246796800*a*e))}--e,t=lf[0];for(var o=1;o{var{typed:t,config:r,multiplyScalar:n,pow:i,BigNumber:a,Complex:o}=e;return t(ff,{number:uf,Complex:function(e){if(0===e.im)return this(e.re);e=new o(e.re-1,e.im);for(var t=new o(lf[0],0),r=1;r2;)u+=i-=2,o=o.times(u);return new a(o.toPrecision(a.precision))}})),mf=W("bignumber",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("bignumber",{"":function(){return new r(0)},number:function(e){return new r(e+"")},string:function(e){var t=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(t){var n=t[2],i=r(t[1]),a=new r(2).pow(Number(n));if(i.gt(a.sub(1)))throw new SyntaxError('String "'.concat(e,'" is out of range'));var o=new r(2).pow(Number(n)-1);return i.gte(o)?i.sub(a):i}return new r(e)},BigNumber:function(e){return e},Fraction:function(e){return new r(e.n).div(e.d).times(e.s)},null:function(e){return new r(0)},"Array | Matrix":function(e){return $t(e,this)}})})),hf="matrixFromColumns",df=W(hf,["typed","matrix","flatten","size"],(e=>{var{typed:t,matrix:r,flatten:n,size:i}=e;return t(hf,{"...Array":function(e){return a(e)},"...Matrix":function(e){return r(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one column is needed to construct a matrix.");for(var t=o(e[0]),r=[],i=0;i{var{typed:t,matrix:r,equalScalar:n}=e,i=nc({typed:t,equalScalar:n}),a=cc({typed:t,equalScalar:n}),o=oc({typed:t,equalScalar:n}),s=ec({typed:t}),u=tc({typed:t});return t("lcm",{"number, number":$a,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(e.isZero())return e;if(t.isZero())return t;for(var r=e.times(t);!t.isZero();){var n=t;t=e.mod(n),e=n}return r.div(e).abs()},"Fraction, Fraction":function(e,t){return e.lcm(t)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return o(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return u(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return u(r(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=Xu({typed:t}),o=Qu({typed:t,equalScalar:n}),s=Ku({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(gf,{"number, number":Ao,"BigNumber, BigNumber":go,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})})),xf="kron",bf=W(xf,["typed","matrix","multiplyScalar"],(e=>{var{typed:t,matrix:r,multiplyScalar:n}=e;return t(xf,{"Matrix, Matrix":function(e,t){return r(i(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(i(e.toArray(),t))},"Array, Matrix":function(e,t){return r(i(e,t.toArray()))},"Array, Array":i});function i(e,t){if(1===je(e).length&&(e=[e]),1===je(t).length&&(t=[t]),je(e).length>2||je(t).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(e.length)+", y = "+JSON.stringify(t.length)+")");var r=[],i=[];return e.map((function(e){return t.map((function(t){return i=[],r.push(i),e.map((function(e){return t.map((function(t){return i.push(n(e,t))}))}))}))}))&&r}})),wf=W("transpose",["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t("transpose",{Array:function(e){return this(r(e)).valueOf()},Matrix:function(e){var t,r=e.size();switch(r.length){case 1:t=e.clone();break;case 2:var n=r[0],i=r[1];if(0===i)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+De(r)+")");switch(e.storage()){case"dense":t=function(e,t,r){for(var n,i=e._data,a=[],o=0;o{var{number:t,bignumber:r,fraction:n}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},a={number:e=>t(e),BigNumber:r?e=>r(e):cr,Fraction:n?e=>n(e):lr};return function(e,t){var r=L(e);if(!(r in i))throw new TypeError("Cannot convert "+e+' of type "'+r+'"; valid input types are '+Object.keys(i).join(", "));if(!(t in a))throw new TypeError("Cannot convert "+e+' to type "'+t+'"; valid output types are '+Object.keys(a).join(", "));return t===r?e:a[t](e)}})),Mf=W("and",["typed","matrix","equalScalar","zeros","not"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,not:a}=e,o=nc({typed:t,equalScalar:n}),s=cc({typed:t,equalScalar:n}),u=oc({typed:t,equalScalar:n}),c=ec({typed:t}),l=tc({typed:t});return t("and",{"number, number":Uo,"Complex, Complex":function(e,t){return!(0===e.re&&0===e.im||0===t.re&&0===t.im)},"BigNumber, BigNumber":function(e,t){return!(e.isZero()||t.isZero()||e.isNaN()||t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return a(t)?i(e.size(),e.storage()):u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return a(t)?i(e.size(),e.storage()):l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return a(e)?i(e.size(),e.storage()):u(t,e,this,!0)},"any, DenseMatrix":function(e,t){return a(e)?i(e.size(),e.storage()):l(t,e,this,!0)},"Array, any":function(e,t){return this(r(e),t).valueOf()},"any, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Sf="smallerEq",Ef=W(Sf,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Sf,{"boolean, boolean":function(e,t){return e<=t},"number, number":function(e,t){return e<=t||Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.lte(t)||Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return 1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),Af="sort",Of=W(Af,["typed","matrix","compare","compareNatural"],(e=>{var{typed:t,matrix:r,compare:n,compareNatural:i}=e,a=n,o=(e,t)=>-n(e,t);return t(Af,{Array:function(e){return u(e),e.sort(a)},Matrix:function(e){return c(e),r(e.toArray().sort(a),e.storage())},"Array, function":function(e,t){return u(e),e.sort(t)},"Matrix, function":function(e,t){return c(e),r(e.toArray().sort(t),e.storage())},"Array, string":function(e,t){return u(e),e.sort(s(t))},"Matrix, string":function(e,t){return c(e),r(e.toArray().sort(s(t)),e.storage())}});function s(e){if("asc"===e)return a;if("desc"===e)return o;if("natural"===e)return i;throw new Error('String "asc", "desc", or "natural" expected')}function u(e){if(1!==je(e).length)throw new Error("One dimensional array expected")}function c(e){if(1!==e.size().length)throw new Error("One dimensional matrix expected")}})),Cf=W("cot",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("cot",{number:bs,Complex:function(e){return e.cot()},BigNumber:function(e){return new r(1).div(e.tan())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),_f="setDistinct",Tf=W(_f,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(_f,{"Array | Matrix":function(e){var t;if(0===n(r(e),new a(0)))t=[];else{var s=et(Array.isArray(e)?e:e.toArray()).sort(i);(t=[]).push(s[0]);for(var u=1;u{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(Bf,{"Array | Matrix":function(e){if(0===n(r(e),new a(0)))return[];for(var t=et(Array.isArray(e)?e:e.toArray()).sort(i),s=[],u=0;u.toString(2).length<=t.length;)s.push(o(t,u.toString(2).split("").reverse())),u++;return function(e){for(var t=[],r=e.length-1;r>0;r--)for(var n=0;ne[n+1].length&&(t=e[n],e[n]=e[n+1],e[n+1]=t);return e}(s)}});function o(e,t){for(var r=[],n=0;n{var{typed:t,Index:r}=e;return t(zf,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var t=e.map((function(e){return a(e)?e.toNumber():Array.isArray(e)||f(e)?e.map((function(e){return a(e)?e.toNumber():e})):e})),n=new r;return r.apply(n,t),n}})})),If="factorial",kf=W(If,["typed","gamma"],(e=>{var{typed:t,gamma:r}=e;return t(If,{number:function(e){if(e<0)throw new Error("Value must be non-negative");return r(e+1)},BigNumber:function(e){if(e.isNegative())throw new Error("Value must be non-negative");return r(e.plus(1))},"Array | Matrix":function(e){return $t(e,this)}})})),Rf="permutations",Ff=W(Rf,["typed","factorial"],(e=>{var{typed:t,factorial:r}=e;return t(Rf,{"number | BigNumber":r,"number, number":function(e,t){if(!ce(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!ce(t)||t<0)throw new TypeError("Positive integer value expected in function permutations");if(t>e)throw new TypeError("second argument k must be less than or equal to first argument n");return Js(e-t+1,e)},"BigNumber, BigNumber":function(e,t){var r,n;if(!Uf(e)||!Uf(t))throw new TypeError("Positive integer value expected in function permutations");if(t.gt(e))throw new TypeError("second argument k must be less than or equal to first argument n");for(r=e.mul(0).add(1),n=e.minus(t).plus(1);n.lte(e);n=n.plus(1))r=r.times(n);return r}})}));function Uf(e){return e.isInteger()&&e.gte(0)}var Pf="matrixFromRows",jf=W(Pf,["typed","matrix","flatten","size"],(e=>{var{typed:t,matrix:r,flatten:n,size:i}=e;return t(Pf,{"...Array":function(e){return a(e)},"...Matrix":function(e){return r(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one row is needed to construct a matrix.");var t=o(e[0]),r=[];for(var i of e){var a=o(i);if(a!==t)throw new TypeError("The vectors had different length: "+(0|t)+" ≠ "+(0|a));r.push(n(i))}return r}function o(e){var t=i(e);if(1===t.length)return t[0];if(2===t.length){if(1===t[0])return t[1];if(1===t[1])return t[0];throw new TypeError("At least one of the arguments is not a vector.")}throw new TypeError("Only one- or two-dimensional vectors are supported.")}})),Lf="subtract",Hf=W(Lf,["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,addScalar:i,unaryMinus:a,DenseMatrix:o}=e,s=Xu({typed:t}),u=ic({typed:t}),c=ac({typed:t,equalScalar:n}),l=Ku({typed:t,DenseMatrix:o}),f=ec({typed:t}),p=tc({typed:t});return t(Lf,{"number, number":function(e,t){return e-t},"Complex, Complex":function(e,t){return e.sub(t)},"BigNumber, BigNumber":function(e,t){return e.minus(t)},"Fraction, Fraction":function(e,t){return e.sub(t)},"Unit, Unit":function(e,t){if(null===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var r=e.clone();return r.value=this(r.value,t.value),r.fixPrefix=!1,r},"SparseMatrix, SparseMatrix":function(e,t){return $f(e,t),c(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return $f(e,t),u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return $f(e,t),s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return $f(e,t),f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return l(e,a(t),i)},"DenseMatrix, any":function(e,t){return p(e,t,this)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(r(t),e,this,!0).valueOf()}})}));function $f(e,t){var r=e.size(),n=t.size();if(r.length!==n.length)throw new Ue(r.length,n.length)}var Gf="cross",Vf=W(Gf,["typed","matrix","subtract","multiply"],(e=>{var{typed:t,matrix:r,subtract:n,multiply:i}=e;return t(Gf,{"Matrix, Matrix":function(e,t){return r(a(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(a(e.toArray(),t))},"Array, Matrix":function(e,t){return r(a(e,t.toArray()))},"Array, Array":a});function a(e,t){var r=Math.max(je(e).length,je(t).length);e=Ye(e),t=Ye(t);var a=je(e),o=je(t);if(1!==a.length||1!==o.length||3!==a[0]||3!==o[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+a.join(", ")+"], B = ["+o.join(", ")+"])");var s=[n(i(e[1],t[2]),i(e[2],t[1])),n(i(e[2],t[0]),i(e[0],t[2])),n(i(e[0],t[1]),i(e[1],t[0]))];return r>1?[s]:s}})),Zf="prod",Wf=W(Zf,["typed","config","multiplyScalar","numeric"],(e=>{var{typed:t,config:r,multiplyScalar:n,numeric:i}=e;return t(Zf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("prod(A, dim) is not yet supported")},"...":function(e){return a(e)}});function a(e){var t;if(Ht(e,(function(e){try{t=void 0===t?e:n(t,e)}catch(t){throw Gr(t,"prod",e)}})),"string"==typeof t&&(t=i(t,r.number)),void 0===t)throw new Error("Cannot calculate prod of an empty array");return t}})),Jf="equal",Yf=W(Jf,["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Jf,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:n(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,n)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,n,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,n,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,n)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,n,!1)},"DenseMatrix, any":function(e,t){return c(e,t,n,!1)},"any, SparseMatrix":function(e,t){return s(t,e,n,!0)},"any, DenseMatrix":function(e,t){return c(t,e,n,!0)},"Array, any":function(e,t){return c(r(e),t,n,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,n,!0).valueOf()}})})),Xf=(W(Jf,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return t(Jf,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:r(e,t)}})})),"setCartesian"),Qf=W(Xf,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Xf,{"Array | Matrix, Array | Matrix":function(e,t){var s=[];if(0!==n(r(e),new a(0))&&0!==n(r(t),new a(0))){var u=et(Array.isArray(e)?e:e.toArray()).sort(i),c=et(Array.isArray(t)?t:t.toArray()).sort(i);s=[];for(var l=0;l{var{typed:t,size:r,concat:n,subset:i,setDifference:a,Index:o}=e;return t(Kf,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new o(0)))return et(t);if(0===i(r(t),new o(0)))return et(e);var s=et(e),u=et(t);return n(a(s,u),a(u,s))}})})),tp=W("ceil",["typed","config","round","matrix","equalScalar"],(e=>{var{typed:t,config:r,round:n,matrix:i,equalScalar:a}=e,o=oc({typed:t,equalScalar:a}),s=tc({typed:t});return t("ceil",{number:function(e){return Se(e,n(e),r.epsilon)?n(e):Ua(e)},"number, number":function(e,t){if(Se(e,n(e,t),r.epsilon))return n(e,t);var[i,a]="".concat(e,"e").split("e"),o=Math.ceil(Number("".concat(i,"e").concat(Number(a)+t)));return[i,a]="".concat(o,"e").split("e"),Number("".concat(i,"e").concat(Number(a)-t))},Complex:function(e){return e.ceil()},"Complex, number":function(e,t){return e.ceil(t)},BigNumber:function(e){return Na(e,n(e),r.epsilon)?n(e):e.ceil()},"BigNumber, BigNumber":function(e,t){return Na(e,n(e,t),r.epsilon)?n(e,t):e.toDecimalPlaces(t.toNumber(),Qn.ROUND_CEIL)},Fraction:function(e){return e.ceil()},"Fraction, number":function(e,t){return e.ceil(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"Array | Matrix, number":function(e,t){return $t(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"number | Complex | BigNumber, Array":function(e,t){return s(i(t),e,this,!0).valueOf()}})})),rp=W("xor",["typed","matrix","DenseMatrix"],(e=>{var{typed:t,matrix:r,DenseMatrix:n}=e,i=ic({typed:t}),a=yc({typed:t,DenseMatrix:n}),o=sc({typed:t,DenseMatrix:n}),s=ec({typed:t}),u=tc({typed:t});return t("xor",{"number, number":Fo,"Complex, Complex":function(e,t){return(0!==e.re||0!==e.im)!=(0!==t.re||0!==t.im)},"BigNumber, BigNumber":function(e,t){return(!e.isZero()&&!e.isNaN())!=(!t.isZero()&&!t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),np="count",ip=W(np,["typed","size","prod"],(e=>{var{typed:t,size:r,prod:n}=e;return t(np,{string:function(e){return e.length},"Matrix | Array":function(e){return n(r(e))}})})),ap="ctranspose",op=W(ap,["typed","transpose","conj"],(e=>{var{typed:t,transpose:r,conj:n}=e;return t(ap,{any:function(e){return n(r(e))}})})),sp="deepEqual",up=W(sp,["typed","equal"],(e=>{var{typed:t,equal:r}=e;return t(sp,{"any, any":function(e,t){return n(e.valueOf(),t.valueOf())}});function n(e,t){if(Array.isArray(e)){if(Array.isArray(t)){var i=e.length;if(i!==t.length)return!1;for(var a=0;a{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(cp,{"Array | Matrix, Array | Matrix":function(e,t){if(0===n(r(e),new a(0)))return!0;if(0===n(r(t),new a(0)))return!1;for(var o,s=ot(et(Array.isArray(e)?e:e.toArray()).sort(i)),u=ot(et(Array.isArray(t)?t:t.toArray()).sort(i)),c=0;c{var{typed:t,Complex:r,matrix:n,ceil:i,floor:a}=e,o=tc({typed:t});return t("fix",{number:function(e){return e>0?a(e):i(e)},"number, number | BigNumber":function(e,t){return e>0?a(e,t):i(e,t)},Complex:function(e){return new r(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},"Complex, number | BigNumber":function(e,t){return new r(e.re>0?a(e.re,t):i(e.re,t),e.im>0?a(e.im,t):i(e.im,t))},BigNumber:function(e){return e.isNegative()?i(e):a(e)},"BigNumber, number | BigNumber":function(e,t){return e.isNegative()?i(e,t):a(e,t)},Fraction:function(e){return e.s<0?e.ceil():e.floor()},"Fraction, number | BigNumber":function(e,t){return e.s<0?e.ceil(t):e.floor(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"Array | Matrix, number | BigNumber":function(e,t){return $t(e,(e=>this(e,t)),!0)},"number | Complex | BigNumber, Array":function(e,t){return o(n(t),e,this,!0).valueOf()}})})),pp="divideScalar",mp=W(pp,["typed","numeric"],(e=>{var{typed:t,numeric:r}=e;return t(pp,{"number, number":function(e,t){return e/t},"Complex, Complex":function(e,t){return e.div(t)},"BigNumber, BigNumber":function(e,t){return e.div(t)},"Fraction, Fraction":function(e,t){return e.div(t)},"Unit, number | Fraction | BigNumber":function(e,t){var n=e.clone(),i=r(1,L(t));return n.value=this(null===n.value?n._normalize(i):n.value,t),n},"number | Fraction | BigNumber, Unit":function(e,t){var n=t.clone();n=n.pow(-1);var i=r(1,L(e));return n.value=this(e,null===t.value?t._normalize(i):t.value),n},"Unit, Unit":function(e,t){return e.divide(t)}})})),hp="nthRoots",dp=W(hp,["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,Complex:i}=e,a=[function(e){return new i(e,0)},function(e){return new i(0,e)},function(e){return new i(-e,0)},function(e){return new i(0,-e)}];function o(e,t){if(t<0)throw new Error("Root must be greater than zero");if(0===t)throw new Error("Root must be non-zero");if(t%1!=0)throw new Error("Root must be an integer");if(0===e||0===e.abs())return[new i(0,0)];var r,n="number"==typeof e;(n||0===e.re||0===e.im)&&(r=n?2*+(e<0):0===e.im?2*+(e.re<0):2*+(e.im<0)+1);for(var o=e.arg(),s=e.abs(),u=[],c=Math.pow(s,1/t),l=0;l{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(gp,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=(t=u(e,t,!0))._data,c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=[],d=0;dd&&(v.push(f[N]),x.push(M))}if(o(g,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var S=n(y,g),E=0,A=x.length;E{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(xp,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=0;hh&&(v.push(f[M]),x.push(S))}if(o(N,0))if(o(g[h],0)){if(0===y){var E=[...g];E[h]=1;for(var A=0,O=x.length;Anew s({data:e.map((e=>[e])),size:[c,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(r(e),t).map((e=>e.valueOf()))}});function c(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1],p=0;pnew s({data:e.map((e=>[e])),size:[l,1]})))}})),wp=W("Spa",["addScalar","equalScalar","FibonacciHeap"],(e=>{var{addScalar:t,equalScalar:r,FibonacciHeap:n}=e;function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new n}return i.prototype.type="Spa",i.prototype.isSpa=!0,i.prototype.set=function(e,t){if(this._values[e])this._values[e].value=t;else{var r=this._heap.insert(e,t);this._values[e]=r}},i.prototype.get=function(e){var t=this._values[e];return t?t.value:0},i.prototype.accumulate=function(e,r){var n=this._values[e];n?n.value=t(n.value,r):(n=this._heap.insert(e,r),this._values[e]=n)},i.prototype.forEach=function(e,t,n){var i=this._heap,a=this._values,o=[],s=i.extractMinimum();for(s&&o.push(s);s&&s.key<=t;)s.key>=e&&(r(s.value,0)||n(s.key,s.value,this)),(s=i.extractMinimum())&&o.push(s);for(var u=0;u{var{typed:t,size:r,concat:n,subset:i,setIntersect:a,setSymDifference:o,Index:s}=e;return t(Np,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new s(0)))return et(t);if(0===i(r(t),new s(0)))return et(e);var u=et(e),c=et(t);return n(o(u,c),a(u,c))}})})),Sp=W("lup",["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],(e=>{var{typed:t,matrix:r,abs:n,addScalar:i,divideScalar:a,multiplyScalar:o,subtract:s,larger:u,equalScalar:c,unaryMinus:l,DenseMatrix:f,SparseMatrix:p,Spa:m}=e;return t("lup",{DenseMatrix:function(e){return h(e)},SparseMatrix:function(e){return function(e){var t,r,i,s=e._size[0],f=e._size[1],h=Math.min(s,f),d=e._values,y=e._index,g=e._ptr,v=[],x=[],b=[],w=[s,h],N=[],M=[],S=[],E=[h,f],A=[],O=[];for(t=0;t0&&e.forEach(0,r-1,(function(t,r){p._forEachRow(t,v,x,b,(function(n,i){n>t&&e.accumulate(n,l(o(i,r)))}))}));var C,_,T,B,q=r,z=e.get(r),D=n(z);e.forEach(r+1,s-1,(function(e,t){var r=n(t);u(r,D)&&(q=e,D=r,z=t)})),r!==q&&(p._swapRows(r,q,w[1],v,x,b),p._swapRows(r,q,E[1],N,M,S),e.swap(r,q),_=q,T=O[C=r],B=O[_],A[T]=_,A[B]=C,O[C]=B,O[_]=T),e.forEach(0,s-1,(function(e,t){e<=r?(N.push(t),M.push(e)):(t=a(t,z),c(t,0)||(v.push(t),x.push(e)))}))};for(r=0;r0)for(t=0;t=0;){var u=r[o+s],c=r[n+u];-1===c?(s--,a[t++]=u):(r[n+u]=r[i+c],r[o+ ++s]=c)}return t}function Ap(e){return-e-2}var Op=W("csAmd",["add","multiply","transpose"],(e=>{var{add:t,multiply:r,transpose:n}=e;return function(e,o){if(!o||e<=0||e>3)return null;var s=o._size,u=s[0],c=s[1],l=0,f=Math.max(16,10*Math.sqrt(c)),p=function(e,i,a,o,s){var u=n(i);if(1===e&&o===a)return t(i,u);if(2===e){for(var c=u._index,l=u._ptr,f=0,p=0;ps))for(var h=l[p+1];mo)r[s+p]=0,r[i+p]=-1,f++,t[p]=Ap(e),r[s+e]++;else{var h=r[u+m];-1!==h&&(c[h]=p),r[l+p]=r[u+m],r[u+m]=p}}return f}(c,T,z,F,R,U,f,D,k,j,I),$=0;HG?(v=d,x=W,b=z[0+d]-G):(x=T[v=_[W++]],b=z[0+v]),g=1;g<=b;g++)(w=z[D+(m=_[x++])])<=0||(Z+=w,z[D+m]=-w,_[Y++]=m,-1!==z[I+m]&&(j[z[I+m]]=j[m]),-1!==j[m]?z[I+j[m]]=z[I+m]:z[k+z[F+m]]=z[I+m]);v!==d&&(T[v]=Ap(d),z[U+v]=0)}for(0!==G&&(B=Y),z[F+d]=Z,T[d]=J,z[0+d]=Y-J,z[R+d]=-2,L=i(L,l,z,U,c),N=J;N=L?z[U+v]-=w:0!==z[U+v]&&(z[U+v]=z[F+v]+X)}for(N=J;N0?(C+=Q,_[A++]=v,O+=v):(T[v]=Ap(d),z[U+v]=0)}z[R+m]=A-S+1;var K=A,ee=S+z[0+m];for(W=E+1;W=0))for(m=z[P+(O=j[m])],z[P+O]=-1;-1!==m&&-1!==z[I+m];m=z[I+m],L++){for(b=z[0+m],M=z[R+m],W=T[m]+1;W<=T[m]+b-1;W++)z[U+_[W]]=L;var re=m;for(h=z[I+m];-1!==h;){var ne=z[0+h]===b&&z[R+h]===M;for(W=T[h]+1;ne&&W<=T[h]+b-1;W++)z[U+_[W]]!==L&&(ne=0);ne?(T[h]=Ap(m),z[D+m]+=z[D+h],z[D+h]=0,z[R+h]=-1,h=z[I+h],z[I+re]=h):(re=h,h=z[I+h])}}for(W=J,N=J;N=0;h--)z[D+h]>0||(z[I+h]=z[k+T[h]],z[k+T[h]]=h);for(v=c;v>=0;v--)z[D+v]<=0||-1!==T[v]&&(z[I+v]=z[k+T[v]],z[k+T[v]]=v);for(d=0,m=0;m<=c;m++)-1===T[m]&&(d=Ep(m,d,z,k,I,q,U));return q.splice(q.length-1,1),q};function i(e,t,r,n,i){if(e<2||e+t<0){for(var a=0;a{var{transpose:t}=e;return function(e,r,n,i){if(!e||!r||!n)return null;var a,o,s,u,c,l,f,p=e._size,m=p[0],h=p[1],d=4*h+(i?h+m+1:0),y=[],g=h,v=2*h,x=3*h,b=4*h,w=5*h+1;for(s=0;s=1&&N[o]++,2===A.jleaf&&N[A.q]--}-1!==r[o]&&(y[0+o]=r[o])}for(o=0;o{var{add:t,multiply:r,transpose:n}=e,i=Op({add:t,multiply:r,transpose:n}),a=_p({transpose:n});return function(e,t,r){var n,o=t._ptr,s=t._size[1],u={};if(u.q=i(e,t),e&&!u.q)return null;if(r){var c=e?function(e,t,r,n){for(var i=e._values,a=e._index,o=e._ptr,s=e._size,u=e._datatype,c=s[0],l=s[1],f=null,p=[],m=[],h=0,d=0;d=0;r--)-1!==e[r]&&(a[o+r]=a[0+e[r]],a[0+e[r]]=r);for(r=0;r=0;u--)for(l=r[u],f=r[u+1],c=l;c=0;s--)m[s]=-1,-1!==(u=h[s])&&(0==d[v+u]++&&(d[g+u]=s),d[0+s]=d[y+u],d[y+u]=s);for(t.lnz=0,t.m2=a,u=0;u=0;){e=n[f];var p=i?i[e]:e;Bp(c,e)||(qp(c,e),n[l+f]=p<0?0:zp(c[p]));var m=1;for(o=n[l+f],s=p<0?0:zp(c[p+1]);o{var{divideScalar:t,multiply:r,subtract:n}=e;return function(e,i,a,o,s,u,c){var l,f,p,m,h=e._values,d=e._index,y=e._ptr,g=e._size[1],v=i._values,x=i._index,b=i._ptr,w=function(e,t,r,n,i){var a,o,s,u=e._ptr,c=e._size,l=t._index,f=t._ptr,p=c[1],m=p;for(o=f[r],s=f[r+1],a=o;a{var{abs:t,divideScalar:r,multiply:n,subtract:i,larger:a,largerEq:o,SparseMatrix:s}=e,u=Ip({divideScalar:r,multiply:n,subtract:i});return function(e,i,c){if(!e)return null;var l,f=e._size[1],p=100,m=100;i&&(l=i.q,p=i.lnz||p,m=i.unz||m);var h,d,y=[],g=[],v=[],x=new s({values:y,index:g,ptr:v,size:[f,f]}),b=[],w=[],N=[],M=new s({values:b,index:w,ptr:N,size:[f,f]}),S=[],E=[],A=[];for(h=0;h{var{typed:t,abs:r,add:n,multiply:i,transpose:a,divideScalar:o,subtract:s,larger:u,largerEq:c,SparseMatrix:l}=e,f=Tp({add:n,multiply:i,transpose:a}),p=kp({abs:r,divideScalar:o,multiply:i,subtract:s,larger:u,largerEq:c,SparseMatrix:l});return t("slu",{"SparseMatrix, number, number":function(e,t,r){if(!ce(t)||t<0||t>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(r<0||r>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var n=f(t,e,!1),i=p(e,n,r);return{L:i.L,U:i.U,p:i.pinv,q:n.q,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\np: "+this.p.toString()+(this.q?"\nq: "+this.q.toString():"")+"\n"}}}})})),Fp=W("det",["typed","matrix","subtract","multiply","unaryMinus","lup"],(e=>{var{typed:t,matrix:r,subtract:n,multiply:i,unaryMinus:a,lup:o}=e;return t("det",{any:function(e){return $(e)},"Array | Matrix":function(e){var t;switch((t=f(e)?e.size():Array.isArray(e)?(e=r(e)).size():[]).length){case 0:return $(e);case 1:if(1===t[0])return $(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:var s=t[0];if(s===t[1])return function(e,t,r){if(1===t)return $(e[0][0]);if(2===t)return n(i(e[0][0],e[1][1]),i(e[1][0],e[0][1]));for(var s=o(e),u=s.U[0][0],c=1;c=t)break;for(var m=f,h=0;!p[s.p[m]];)p[s.p[m]]=!0,m=s.p[m],h++;h%2==0&&l++}return l%2==0?u:a(u)}(e.clone().valueOf(),s);throw new RangeError("Matrix must be square (size: "+De(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+De(t)+")")}}})})),Up="distance",Pp=W(Up,["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],(e=>{var{typed:t,addScalar:r,subtract:n,multiplyScalar:i,divideScalar:o,unaryMinus:s,sqrt:u,abs:c}=e;return t(Up,{"Array, Array, Array":function(e,t,r){if(2===e.length&&2===t.length&&2===r.length){if(!f(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!f(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!f(r))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var a=o(n(r[1],r[0]),n(t[1],t[0])),u=i(i(a,a),t[0]),c=s(i(a,t[0])),l=e[1];return y(e[0],e[1],u,c,l)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(e,t,r){if(2===Object.keys(e).length&&2===Object.keys(t).length&&2===Object.keys(r).length){if(!f(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!f(t))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!f(r))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"lineOnePtX"in t&&"lineOnePtY"in t&&"lineTwoPtX"in r&&"lineTwoPtY"in r){var a=o(n(r.lineTwoPtY,r.lineTwoPtX),n(t.lineOnePtY,t.lineOnePtX)),u=i(i(a,a),t.lineOnePtX),c=s(i(a,t.lineOnePtX)),l=e.pointX;return y(e.pointX,e.pointY,u,c,l)}throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(e,t){if(2===e.length&&3===t.length){if(!f(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!p(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return y(e[0],e[1],t[0],t[1],t[2])}if(3===e.length&&6===t.length){if(!p(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!h(t))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return g(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}if(e.length===t.length&&e.length>0){if(!m(e))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!m(t))throw new TypeError("All values of an array should be numbers or BigNumbers");return v(e,t)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,t){if(2===Object.keys(e).length&&3===Object.keys(t).length){if(!f(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"xCoeffLine"in t&&"yCoeffLine"in t&&"constant"in t)return y(e.pointX,e.pointY,t.xCoeffLine,t.yCoeffLine,t.constant);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&6===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!h(t))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"x0"in t&&"y0"in t&&"z0"in t&&"a"in t&&"b"in t&&"c"in t)return g(e.pointX,e.pointY,e.pointZ,t.x0,t.y0,t.z0,t.a,t.b,t.c);throw new TypeError("Key names do not match")}if(2===Object.keys(e).length&&2===Object.keys(t).length){if(!f(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!f(t))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointTwoX"in t&&"pointTwoY"in t)return v([e.pointOneX,e.pointOneY],[t.pointTwoX,t.pointTwoY]);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&3===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointOneZ"in e&&"pointTwoX"in t&&"pointTwoY"in t&&"pointTwoZ"in t)return v([e.pointOneX,e.pointOneY,e.pointOneZ],[t.pointTwoX,t.pointTwoY,t.pointTwoZ]);throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},Array:function(e){if(!function(e){if(2===e[0].length&&l(e[0][0])&&l(e[0][1])){if(e.some((e=>2!==e.length||!l(e[0])||!l(e[1]))))return!1}else{if(!(3===e[0].length&&l(e[0][0])&&l(e[0][1])&&l(e[0][2])))return!1;if(e.some((e=>3!==e.length||!l(e[0])||!l(e[1])||!l(e[2]))))return!1}return!0}(e))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return function(e){for(var t=[],r=[],n=[],i=0;i{var{typed:t,addScalar:r,subtract:n,multiplyScalar:i,divideScalar:a,pow:o,factorial:s,combinations:u,isNegative:c,isInteger:l,larger:f}=e;return t(jp,{"number | BigNumber, number | BigNumber":function(e,t){if(!l(e)||c(e)||!l(t)||c(t))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(f(t,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");for(var p=s(t),m=0,h=0;h<=t;h++){var d=o(-1,n(t,h)),y=u(t,h),g=o(h,e);m=r(m,i(i(y,g),d))}return a(m,p)}})})),Hp="catalan",$p=W(Hp,["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],(e=>{var{typed:t,addScalar:r,divideScalar:n,multiplyScalar:i,combinations:a,isNegative:o,isInteger:s}=e;return t(Hp,{"number | BigNumber":function(e){if(!s(e)||o(e))throw new TypeError("Non-negative integer value expected in function catalan");return n(a(i(e,2),e),r(e,1))}})})),Gp=W("log",["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,Complex:i}=e;return t("log",{number:function(e){return e>=0||r.predictable?Ga(e):new i(e,0).log()},Complex:function(e){return e.log()},BigNumber:function(e){return!e.isNegative()||r.predictable?e.ln():new i(e.toNumber(),0).log()},"Array | Matrix":function(e){return $t(e,this)},"any, any":function(e,t){return n(this(e),this(t))}})})),Vp="dotDivide",Zp=W(Vp,["typed","matrix","equalScalar","divideScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,divideScalar:i,DenseMatrix:a}=e,o=nc({typed:t,equalScalar:n}),s=ic({typed:t}),u=yc({typed:t,DenseMatrix:a}),c=oc({typed:t,equalScalar:n}),l=sc({typed:t,DenseMatrix:a}),f=ec({typed:t}),p=tc({typed:t});return t(Vp,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,i)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return c(e,t,i,!1)},"DenseMatrix, any":function(e,t){return p(e,t,i,!1)},"any, SparseMatrix":function(e,t){return l(t,e,i,!0)},"any, DenseMatrix":function(e,t){return p(t,e,i,!0)},"Array, any":function(e,t){return p(r(e),t,i,!1).valueOf()},"any, Array":function(e,t){return p(r(t),e,i,!0).valueOf()}})})),Wp="usolveAll",Jp=W(Wp,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(Wp,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=l-1;h>=0;h--)for(var d=r.length,y=0;y=b;N--){var M=p[N];M===h?w=f[N]:Mnew s({data:e.map((e=>[e])),size:[c,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(r(e),t).map((e=>e.valueOf()))}});function c(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1]-1;f>=0;f--)for(var p=r.length,m=0;m=0;y--)d[y]=a(d[y],c[y][f]);r.push(d)}}else{if(0===m)return[];r.splice(m,1),m-=1,p-=1}else{h[f]=n(h[f],c[f][f]);for(var g=f-1;g>=0;g--)h[g]=a(h[g],i(h[f],c[g][f]))}}return r.map((e=>new s({data:e.map((e=>[e])),size:[l,1]})))}})),Yp="hypot",Xp=W(Yp,["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],(e=>{var{typed:t,abs:r,addScalar:n,divideScalar:i,multiplyScalar:a,sqrt:o,smaller:s,isPositive:u}=e;return t(Yp,{"... number | BigNumber":function(e){for(var t=0,c=0,l=0;l{var{typed:r,matrix:n,zeros:i,identity:a,isZero:o,equal:s,sign:u,sqrt:c,conj:l,unaryMinus:f,addScalar:p,divideScalar:m,multiplyScalar:h,subtract:d,complex:y}=t;return e(r("qr",{DenseMatrix:function(e){return v(e)},SparseMatrix:function(e){return function(e){throw new Error("qr not implemented for sparse matrices yet")}()},Array:function(e){var t=v(n(e));return{Q:t.Q.valueOf(),R:t.R.valueOf()}}}),{_denseQRimpl:g});function g(e){var t,r,n,y=e._size[0],g=e._size[1],v=a([y],"dense"),x=v._data,b=e.clone(),w=b._data,N=i([y],"");for(n=0;n0)for(var n="Complex"===r[0][0].type?y(0):0,i=0;i{var{typed:t,matrix:r,divideScalar:n,addScalar:i,multiply:a,unaryMinus:o,det:s,identity:u,abs:c}=e;return t("inv",{"Array | Matrix":function(e){var t=f(e)?e.size():je(e);switch(t.length){case 1:if(1===t[0])return f(e)?r([n(1,e.valueOf()[0])]):[n(1,e[0])];throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:var i=t[0],a=t[1];if(i===a)return f(e)?r(l(e.valueOf(),i,a),e.storage()):l(e,i,a);throw new RangeError("Matrix must be square (size: "+De(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+De(t)+")")}},any:function(e){return n(1,e)}});function l(e,t,r){var l,f,p,m,h;if(1===t){if(0===(m=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero");return[[n(1,m)]]}if(2===t){var d=s(e);if(0===d)throw Error("Cannot calculate inverse, determinant is zero");return[[n(e[1][1],d),n(o(e[0][1]),d)],[n(o(e[1][0]),d),n(e[0][0],d)]]}var y=e.concat();for(l=0;lx&&(x=c(y[l][v]),b=l),l++;if(0===x)throw Error("Cannot calculate inverse, determinant is zero");(l=b)!==v&&(h=y[v],y[v]=y[l],y[l]=h,h=g[v],g[v]=g[l],g[l]=h);var w=y[v],N=g[v];for(l=0;l{var{typed:t,abs:r,add:n,identity:i,inv:a,multiply:o}=e;return t(em,{Matrix:function(e){var t=e.size();if(2!==t.length||t[0]!==t[1])throw new RangeError("Matrix must be square (size: "+De(t)+")");for(var u=t[0],c=function(e,t){for(var r=0;r<30;r++)for(var n=0;n<=r;n++){var i=r-n;if(s(e,n,i)<1e-15)return{q:n,j:i}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}(function(e){for(var t=e.size()[0],n=0,i=0;i1&&(g=o(g,p),v=-v),m=n(m,o(y=y*(l-x+1)/((2*l-x+1)*x),g)),d=n(d,o(y*v,g));for(var b=o(a(d),m),w=0;w{var{typed:t,matrix:r,multiply:n,equalScalar:i,divideScalar:a,inv:o}=e,s=oc({typed:t,equalScalar:i}),u=tc({typed:t});return t("divide",G({"Array | Matrix, Array | Matrix":function(e,t){return n(e,o(t))},"DenseMatrix, any":function(e,t){return u(e,t,a,!1)},"SparseMatrix, any":function(e,t){return s(e,t,a,!1)},"Array, any":function(e,t){return u(r(e),t,a,!1).valueOf()},"any, Array | Matrix":function(e,t){return n(e,o(t))}},a.signatures))})),nm="kldivergence",im=W(nm,["typed","matrix","divide","sum","multiply","dotDivide","log","isNumeric"],(e=>{var{typed:t,matrix:r,divide:n,sum:i,multiply:a,dotDivide:o,log:s,isNumeric:u}=e;return t(nm,{"Array, Array":function(e,t){return c(r(e),r(t))},"Matrix, Array":function(e,t){return c(e,r(t))},"Array, Matrix":function(e,t){return c(r(e),t)},"Matrix, Matrix":function(e,t){return c(e,t)}});function c(e,t){var r=t.size().length,c=e.size().length;if(r>1)throw new Error("first object must be one dimensional");if(c>1)throw new Error("second object must be one dimensional");if(r!==c)throw new Error("Length of two vectors must be equal");if(0===i(e))throw new Error("Sum of elements in first object must be non zero");if(0===i(t))throw new Error("Sum of elements in second object must be non zero");var l=n(e,i(e)),f=n(t,i(t)),p=i(a(l,s(o(l,f))));return u(p)?p:Number.NaN}})),am="bellNumbers",om=W(am,["typed","addScalar","isNegative","isInteger","stirlingS2"],(e=>{var{typed:t,addScalar:r,isNegative:n,isInteger:i,stirlingS2:a}=e;return t(am,{"number | BigNumber":function(e){if(!i(e)||n(e))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var t=0,o=0;o<=e;o++)t=r(t,a(e,o));return t}})})),sm="log1p",um=W(sm,["typed","config","divideScalar","log","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,log:i,Complex:a}=e;return t(sm,{number:function(e){return e>=-1||r.predictable?me(e):o(new a(e,0))},Complex:o,BigNumber:function(e){var t=e.plus(1);return!t.isNegative()||r.predictable?t.ln():o(new a(e.toNumber(),0))},"Array | Matrix":function(e){return $t(e,this)},"any, any":function(e,t){return n(this(e),i(t))}});function o(e){var t=e.re+1;return new a(Math.log(Math.sqrt(t*t+e.im*e.im)),Math.atan2(e.im,t))}}));function cm(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function lm(e){for(var t=1;t{var r,n,i,{on:a,config:s,addScalar:c,subtract:l,multiplyScalar:f,divideScalar:p,pow:m,abs:h,fix:d,round:y,equal:g,isNumeric:v,format:x,number:b,Complex:w,BigNumber:N,Fraction:M}=t,S=b;function E(e,t){if(!(this instanceof E))throw new Error("Constructor must be called with the new operator");if(null!=e&&!v(e)&&!o(e))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(void 0!==t&&("string"!=typeof t||""===t))throw new TypeError("Second parameter in Unit constructor must be a string");if(void 0!==t){var r=E.parse(t);this.units=r.units,this.dimensions=r.dimensions}else{this.units=[{unit:U,prefix:I.NONE,power:0}],this.dimensions=[];for(var n=0;n="0"&&e<="9"}function C(){n++,i=r.charAt(n)}function _(e){n=e,i=r.charAt(n)}function T(){var e="",t=n;if("+"===i?C():"-"===i&&(e+=i,C()),!function(e){return e>="0"&&e<="9"||"."===e}(i))return _(t),null;if("."===i){if(e+=i,C(),!O(i))return _(t),null}else{for(;O(i);)e+=i,C();"."===i&&(e+=i,C())}for(;O(i);)e+=i,C();if("E"===i||"e"===i){var r="",a=n;if(r+=i,C(),"+"!==i&&"-"!==i||(r+=i,C()),!O(i))return _(a),e;for(e+=r;O(i);)e+=i,C()}return e}function B(){for(var e="";O(i)||E.isValidAlpha(i);)e+=i,C();var t=e.charAt(0);return E.isValidAlpha(t)?e:null}function q(e){return i===e?(C(),e):null}E.prototype.type="Unit",E.prototype.isUnit=!0,E.parse=function(e,t){if(t=t||{},n=-1,i="","string"!=typeof(r=e))throw new TypeError("Invalid argument in Unit.parse, string expected");var a=new E;a.units=[];var o=1,u=!1;C(),A();var c=T(),l=null;if(c){if("BigNumber"===s.number)l=new N(c);else if("Fraction"===s.number)try{l=new M(c)}catch(e){l=parseFloat(c)}else l=parseFloat(c);A(),q("*")?(o=1,u=!0):q("/")&&(o=-1,u=!0)}for(var f=[],p=1;;){for(A();"("===i;)f.push(o),p*=o,o=1,C(),A();var m;if(!i)break;var h=i;if(null===(m=B()))throw new SyntaxError('Unexpected "'+h+'" in "'+r+'" at index '+n.toString());var d=z(m);if(null===d)throw new SyntaxError('Unit "'+m+'" not found.');var y=o*p;if(A(),q("^")){A();var g=T();if(null===g)throw new SyntaxError('In "'+e+'", "^" must be followed by a floating-point number');y*=g}a.units.push({unit:d.unit,prefix:d.prefix,power:y});for(var v=0;v1||Math.abs(this.units[0].power-1)>1e-15)},E.prototype._normalize=function(e){var t,r,n,i,a;if(null==e||0===this.units.length)return e;if(this._isDerived()){var o=e;a=E._getNumberConverter(L(e));for(var s=0;s{if(Z(P,e)){var t=P[e];return{unit:t,prefix:t.prefixes[""]}}for(var r in P)if(Z(P,r)&&ze(e,r)){var n=P[r],i=e.length-r.length,a=e.substring(0,i),o=Z(n.prefixes,a)?n.prefixes[a]:void 0;if(void 0!==o)return{unit:n,prefix:o}}return null}),{hasher:e=>e[0],limit:100});function D(e){return e.equalBase(R.NONE)&&null!==e.value&&!s.predictable?e.value:e}E.isValuelessUnit=function(e){return null!==z(e)},E.prototype.hasBase=function(e){if("string"==typeof e&&(e=R[e]),!e)return!1;for(var t=0;t1e-12)return!1;return!0},E.prototype.equalBase=function(e){for(var t=0;t1e-12)return!1;return!0},E.prototype.equals=function(e){return this.equalBase(e)&&g(this.value,e.value)},E.prototype.multiply=function(e){for(var t=this.clone(),r=0;r1e-12&&(Z(V,s)?n.push({unit:V[s].unit,prefix:V[s].prefix,power:r.dimensions[o]||0}):a=!0)}n.length1e-12){if(!Z(G.si,n))throw new Error("Cannot express custom unit "+n+" in SI units");t.push({unit:G.si[n].unit,prefix:G.si[n].prefix,power:e.dimensions[r]||0})}}return e.units=t,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,e},E.prototype.formatUnits=function(){for(var e="",t="",r=0,n=0,i=0;i0?(r++,e+=" "+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power-1)>1e-15&&(e+="^"+this.units[i].power)):this.units[i].power<0&&n++;if(n>0)for(var a=0;a0?(t+=" "+this.units[a].prefix.name+this.units[a].unit.name,Math.abs(this.units[a].power+1)>1e-15&&(t+="^"+-this.units[a].power)):(t+=" "+this.units[a].prefix.name+this.units[a].unit.name,t+="^"+this.units[a].power));e=e.substr(1),t=t.substr(1),r>1&&n>0&&(e="("+e+")"),n>1&&r>0&&(t="("+t+")");var o=e;return r>0&&n>0&&(o+=" / "),o+t},E.prototype.format=function(e){var t=this.skipAutomaticSimplification||null===this.value?this.clone():this.simplify(),r=!1;for(var n in void 0!==t.value&&null!==t.value&&o(t.value)&&(r=Math.abs(t.value.re)<1e-14),t.units)Z(t.units,n)&&t.units[n].unit&&("VA"===t.units[n].unit.name&&r?t.units[n].unit=P.VAR:"VAR"!==t.units[n].unit.name||r||(t.units[n].unit=P.VA));1!==t.units.length||t.fixPrefix||Math.abs(t.units[0].power-Math.round(t.units[0].power))<1e-14&&(t.units[0].prefix=t._bestPrefix());var i=t._denormalize(t.value),a=null!==t.value?x(i,e||{}):"",s=t.formatUnits();return t.value&&o(t.value)&&(a="("+a+")"),s.length>0&&a.length>0&&(a+=" "),a+s},E.prototype._bestPrefix=function(){if(1!==this.units.length)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var e=null!==this.value?h(this.value):0,t=h(this.units[0].unit.value),r=this.units[0].prefix;if(0===e)return r;var n=this.units[0].power,i=Math.log(e/Math.pow(r.value*t,n))/Math.LN10-1.2;if(i>-2.200001&&i<1.800001)return r;i=Math.abs(i);var a=this.units[0].unit.prefixes;for(var o in a)if(Z(a,o)){var s=a[o];if(s.scientific){var u=Math.abs(Math.log(e/Math.pow(s.value*t,n))/Math.LN10-1.2);(u0))},P={meter:{name:"meter",base:R.LENGTH,prefixes:I.LONG,value:1,offset:0},inch:{name:"inch",base:R.LENGTH,prefixes:I.NONE,value:.0254,offset:0},foot:{name:"foot",base:R.LENGTH,prefixes:I.NONE,value:.3048,offset:0},yard:{name:"yard",base:R.LENGTH,prefixes:I.NONE,value:.9144,offset:0},mile:{name:"mile",base:R.LENGTH,prefixes:I.NONE,value:1609.344,offset:0},link:{name:"link",base:R.LENGTH,prefixes:I.NONE,value:.201168,offset:0},rod:{name:"rod",base:R.LENGTH,prefixes:I.NONE,value:5.0292,offset:0},chain:{name:"chain",base:R.LENGTH,prefixes:I.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:R.LENGTH,prefixes:I.NONE,value:1e-10,offset:0},m:{name:"m",base:R.LENGTH,prefixes:I.SHORT,value:1,offset:0},in:{name:"in",base:R.LENGTH,prefixes:I.NONE,value:.0254,offset:0},ft:{name:"ft",base:R.LENGTH,prefixes:I.NONE,value:.3048,offset:0},yd:{name:"yd",base:R.LENGTH,prefixes:I.NONE,value:.9144,offset:0},mi:{name:"mi",base:R.LENGTH,prefixes:I.NONE,value:1609.344,offset:0},li:{name:"li",base:R.LENGTH,prefixes:I.NONE,value:.201168,offset:0},rd:{name:"rd",base:R.LENGTH,prefixes:I.NONE,value:5.02921,offset:0},ch:{name:"ch",base:R.LENGTH,prefixes:I.NONE,value:20.1168,offset:0},mil:{name:"mil",base:R.LENGTH,prefixes:I.NONE,value:254e-7,offset:0},m2:{name:"m2",base:R.SURFACE,prefixes:I.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:R.SURFACE,prefixes:I.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:R.SURFACE,prefixes:I.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:R.SURFACE,prefixes:I.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:R.SURFACE,prefixes:I.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:R.SURFACE,prefixes:I.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:R.SURFACE,prefixes:I.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:R.SURFACE,prefixes:I.NONE,value:6.4516e-10,offset:0},acre:{name:"acre",base:R.SURFACE,prefixes:I.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:R.SURFACE,prefixes:I.NONE,value:1e4,offset:0},m3:{name:"m3",base:R.VOLUME,prefixes:I.CUBIC,value:1,offset:0},L:{name:"L",base:R.VOLUME,prefixes:I.SHORT,value:.001,offset:0},l:{name:"l",base:R.VOLUME,prefixes:I.SHORT,value:.001,offset:0},litre:{name:"litre",base:R.VOLUME,prefixes:I.LONG,value:.001,offset:0},cuin:{name:"cuin",base:R.VOLUME,prefixes:I.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:R.VOLUME,prefixes:I.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:R.VOLUME,prefixes:I.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:R.VOLUME,prefixes:I.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:R.VOLUME,prefixes:I.NONE,value:15e-6,offset:0},drop:{name:"drop",base:R.VOLUME,prefixes:I.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:R.VOLUME,prefixes:I.NONE,value:5e-8,offset:0},minim:{name:"minim",base:R.VOLUME,prefixes:I.NONE,value:6.161152e-8,offset:0},fluiddram:{name:"fluiddram",base:R.VOLUME,prefixes:I.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:R.VOLUME,prefixes:I.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:R.VOLUME,prefixes:I.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:R.VOLUME,prefixes:I.NONE,value:1e-6,offset:0},cup:{name:"cup",base:R.VOLUME,prefixes:I.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:R.VOLUME,prefixes:I.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:R.VOLUME,prefixes:I.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:R.VOLUME,prefixes:I.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:R.VOLUME,prefixes:I.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:R.VOLUME,prefixes:I.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:R.VOLUME,prefixes:I.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:R.VOLUME,prefixes:I.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:R.VOLUME,prefixes:I.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:R.VOLUME,prefixes:I.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:R.VOLUME,prefixes:I.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:R.VOLUME,prefixes:I.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:R.VOLUME,prefixes:I.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:R.VOLUME,prefixes:I.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:R.VOLUME,prefixes:I.NONE,value:.1173478,offset:0},obl:{name:"obl",base:R.VOLUME,prefixes:I.NONE,value:.1589873,offset:0},g:{name:"g",base:R.MASS,prefixes:I.SHORT,value:.001,offset:0},gram:{name:"gram",base:R.MASS,prefixes:I.LONG,value:.001,offset:0},ton:{name:"ton",base:R.MASS,prefixes:I.SHORT,value:907.18474,offset:0},t:{name:"t",base:R.MASS,prefixes:I.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:R.MASS,prefixes:I.LONG,value:1e3,offset:0},grain:{name:"grain",base:R.MASS,prefixes:I.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:R.MASS,prefixes:I.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:R.MASS,prefixes:I.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:R.MASS,prefixes:I.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:R.MASS,prefixes:I.NONE,value:45.359237,offset:0},stick:{name:"stick",base:R.MASS,prefixes:I.NONE,value:.115,offset:0},stone:{name:"stone",base:R.MASS,prefixes:I.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:R.MASS,prefixes:I.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:R.MASS,prefixes:I.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:R.MASS,prefixes:I.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:R.MASS,prefixes:I.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:R.MASS,prefixes:I.NONE,value:45.359237,offset:0},s:{name:"s",base:R.TIME,prefixes:I.SHORT,value:1,offset:0},min:{name:"min",base:R.TIME,prefixes:I.NONE,value:60,offset:0},h:{name:"h",base:R.TIME,prefixes:I.NONE,value:3600,offset:0},second:{name:"second",base:R.TIME,prefixes:I.LONG,value:1,offset:0},sec:{name:"sec",base:R.TIME,prefixes:I.LONG,value:1,offset:0},minute:{name:"minute",base:R.TIME,prefixes:I.NONE,value:60,offset:0},hour:{name:"hour",base:R.TIME,prefixes:I.NONE,value:3600,offset:0},day:{name:"day",base:R.TIME,prefixes:I.NONE,value:86400,offset:0},week:{name:"week",base:R.TIME,prefixes:I.NONE,value:604800,offset:0},month:{name:"month",base:R.TIME,prefixes:I.NONE,value:2629800,offset:0},year:{name:"year",base:R.TIME,prefixes:I.NONE,value:31557600,offset:0},decade:{name:"decade",base:R.TIME,prefixes:I.NONE,value:315576e3,offset:0},century:{name:"century",base:R.TIME,prefixes:I.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:R.TIME,prefixes:I.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:R.FREQUENCY,prefixes:I.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:R.FREQUENCY,prefixes:I.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:R.ANGLE,prefixes:I.SHORT,value:1,offset:0},radian:{name:"radian",base:R.ANGLE,prefixes:I.LONG,value:1,offset:0},deg:{name:"deg",base:R.ANGLE,prefixes:I.SHORT,value:null,offset:0},degree:{name:"degree",base:R.ANGLE,prefixes:I.LONG,value:null,offset:0},grad:{name:"grad",base:R.ANGLE,prefixes:I.SHORT,value:null,offset:0},gradian:{name:"gradian",base:R.ANGLE,prefixes:I.LONG,value:null,offset:0},cycle:{name:"cycle",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},A:{name:"A",base:R.CURRENT,prefixes:I.SHORT,value:1,offset:0},ampere:{name:"ampere",base:R.CURRENT,prefixes:I.LONG,value:1,offset:0},K:{name:"K",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:0},degC:{name:"degC",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:273.15},degF:{name:"degF",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:0},celsius:{name:"celsius",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:R.AMOUNT_OF_SUBSTANCE,prefixes:I.SHORT,value:1,offset:0},mole:{name:"mole",base:R.AMOUNT_OF_SUBSTANCE,prefixes:I.LONG,value:1,offset:0},cd:{name:"cd",base:R.LUMINOUS_INTENSITY,prefixes:I.SHORT,value:1,offset:0},candela:{name:"candela",base:R.LUMINOUS_INTENSITY,prefixes:I.LONG,value:1,offset:0},N:{name:"N",base:R.FORCE,prefixes:I.SHORT,value:1,offset:0},newton:{name:"newton",base:R.FORCE,prefixes:I.LONG,value:1,offset:0},dyn:{name:"dyn",base:R.FORCE,prefixes:I.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:R.FORCE,prefixes:I.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:R.FORCE,prefixes:I.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:R.FORCE,prefixes:I.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:R.FORCE,prefixes:I.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:R.FORCE,prefixes:I.NONE,value:9.80665,offset:0},J:{name:"J",base:R.ENERGY,prefixes:I.SHORT,value:1,offset:0},joule:{name:"joule",base:R.ENERGY,prefixes:I.SHORT,value:1,offset:0},erg:{name:"erg",base:R.ENERGY,prefixes:I.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:R.ENERGY,prefixes:I.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:R.ENERGY,prefixes:I.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:R.ENERGY,prefixes:I.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:R.ENERGY,prefixes:I.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:R.POWER,prefixes:I.SHORT,value:1,offset:0},watt:{name:"watt",base:R.POWER,prefixes:I.LONG,value:1,offset:0},hp:{name:"hp",base:R.POWER,prefixes:I.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:R.POWER,prefixes:I.SHORT,value:w.I,offset:0},VA:{name:"VA",base:R.POWER,prefixes:I.SHORT,value:1,offset:0},Pa:{name:"Pa",base:R.PRESSURE,prefixes:I.SHORT,value:1,offset:0},psi:{name:"psi",base:R.PRESSURE,prefixes:I.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:R.PRESSURE,prefixes:I.NONE,value:101325,offset:0},bar:{name:"bar",base:R.PRESSURE,prefixes:I.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:R.PRESSURE,prefixes:I.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:R.PRESSURE,prefixes:I.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:R.PRESSURE,prefixes:I.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:R.PRESSURE,prefixes:I.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:R.ELECTRIC_CHARGE,prefixes:I.LONG,value:1,offset:0},C:{name:"C",base:R.ELECTRIC_CHARGE,prefixes:I.SHORT,value:1,offset:0},farad:{name:"farad",base:R.ELECTRIC_CAPACITANCE,prefixes:I.LONG,value:1,offset:0},F:{name:"F",base:R.ELECTRIC_CAPACITANCE,prefixes:I.SHORT,value:1,offset:0},volt:{name:"volt",base:R.ELECTRIC_POTENTIAL,prefixes:I.LONG,value:1,offset:0},V:{name:"V",base:R.ELECTRIC_POTENTIAL,prefixes:I.SHORT,value:1,offset:0},ohm:{name:"ohm",base:R.ELECTRIC_RESISTANCE,prefixes:I.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:R.ELECTRIC_INDUCTANCE,prefixes:I.LONG,value:1,offset:0},H:{name:"H",base:R.ELECTRIC_INDUCTANCE,prefixes:I.SHORT,value:1,offset:0},siemens:{name:"siemens",base:R.ELECTRIC_CONDUCTANCE,prefixes:I.LONG,value:1,offset:0},S:{name:"S",base:R.ELECTRIC_CONDUCTANCE,prefixes:I.SHORT,value:1,offset:0},weber:{name:"weber",base:R.MAGNETIC_FLUX,prefixes:I.LONG,value:1,offset:0},Wb:{name:"Wb",base:R.MAGNETIC_FLUX,prefixes:I.SHORT,value:1,offset:0},tesla:{name:"tesla",base:R.MAGNETIC_FLUX_DENSITY,prefixes:I.LONG,value:1,offset:0},T:{name:"T",base:R.MAGNETIC_FLUX_DENSITY,prefixes:I.SHORT,value:1,offset:0},b:{name:"b",base:R.BIT,prefixes:I.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:R.BIT,prefixes:I.BINARY_LONG,value:1,offset:0},B:{name:"B",base:R.BIT,prefixes:I.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:R.BIT,prefixes:I.BINARY_LONG,value:8,offset:0}},j={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function H(e){if("BigNumber"===e.number){var t=Cn(N);P.rad.value=new N(1),P.deg.value=t.div(180),P.grad.value=t.div(200),P.cycle.value=t.times(2),P.arcsec.value=t.div(648e3),P.arcmin.value=t.div(10800)}else P.rad.value=1,P.deg.value=Math.PI/180,P.grad.value=Math.PI/200,P.cycle.value=2*Math.PI,P.arcsec.value=Math.PI/648e3,P.arcmin.value=Math.PI/10800;P.radian.value=P.rad.value,P.degree.value=P.deg.value,P.gradian.value=P.grad.value}H(s),a&&a("config",(function(e,t){e.number!==t.number&&H(e)}));var G={si:{NONE:{unit:U,prefix:I.NONE[""]},LENGTH:{unit:P.m,prefix:I.SHORT[""]},MASS:{unit:P.g,prefix:I.SHORT.k},TIME:{unit:P.s,prefix:I.SHORT[""]},CURRENT:{unit:P.A,prefix:I.SHORT[""]},TEMPERATURE:{unit:P.K,prefix:I.SHORT[""]},LUMINOUS_INTENSITY:{unit:P.cd,prefix:I.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:P.mol,prefix:I.SHORT[""]},ANGLE:{unit:P.rad,prefix:I.SHORT[""]},BIT:{unit:P.bits,prefix:I.SHORT[""]},FORCE:{unit:P.N,prefix:I.SHORT[""]},ENERGY:{unit:P.J,prefix:I.SHORT[""]},POWER:{unit:P.W,prefix:I.SHORT[""]},PRESSURE:{unit:P.Pa,prefix:I.SHORT[""]},ELECTRIC_CHARGE:{unit:P.C,prefix:I.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:P.F,prefix:I.SHORT[""]},ELECTRIC_POTENTIAL:{unit:P.V,prefix:I.SHORT[""]},ELECTRIC_RESISTANCE:{unit:P.ohm,prefix:I.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:P.H,prefix:I.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:P.S,prefix:I.SHORT[""]},MAGNETIC_FLUX:{unit:P.Wb,prefix:I.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:P.T,prefix:I.SHORT[""]},FREQUENCY:{unit:P.Hz,prefix:I.SHORT[""]}}};G.cgs=JSON.parse(JSON.stringify(G.si)),G.cgs.LENGTH={unit:P.m,prefix:I.SHORT.c},G.cgs.MASS={unit:P.g,prefix:I.SHORT[""]},G.cgs.FORCE={unit:P.dyn,prefix:I.SHORT[""]},G.cgs.ENERGY={unit:P.erg,prefix:I.NONE[""]},G.us=JSON.parse(JSON.stringify(G.si)),G.us.LENGTH={unit:P.ft,prefix:I.NONE[""]},G.us.MASS={unit:P.lbm,prefix:I.NONE[""]},G.us.TEMPERATURE={unit:P.degF,prefix:I.NONE[""]},G.us.FORCE={unit:P.lbf,prefix:I.NONE[""]},G.us.ENERGY={unit:P.BTU,prefix:I.BTU[""]},G.us.POWER={unit:P.hp,prefix:I.NONE[""]},G.us.PRESSURE={unit:P.psi,prefix:I.NONE[""]},G.auto=JSON.parse(JSON.stringify(G.si));var V=G.auto;for(var W in E.setUnitSystem=function(e){if(!Z(G,e))throw new Error("Unit system "+e+" does not exist. Choices are: "+Object.keys(G).join(", "));V=G[e]},E.getUnitSystem=function(){for(var e in G)if(Z(G,e)&&G[e]===V)return e},E.typeConverters={BigNumber:function(e){return new N(e+"")},Fraction:function(e){return new M(e)},Complex:function(e){return e},number:function(e){return e}},E._getNumberConverter=function(e){if(!E.typeConverters[e])throw new TypeError('Unsupported type "'+e+'"');return E.typeConverters[e]},P)if(Z(P,W)){var J=P[W];J.dimensions=J.base.dimensions}for(var Y in j)if(Z(j,Y)){var X=P[j[Y]],Q={};for(var K in X)Z(X,K)&&(Q[K]=X[K]);Q.name=Y,P[Y]=Q}return E.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)},E.createUnit=function(e,t){if("object"!=typeof e)throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(t&&t.override)for(var r in e)if(Z(e,r)&&E.deleteUnit(r),e[r].aliases)for(var n=0;n0&&!E.isValidAlpha(i)&&!O(i))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+e+'"')}}(e);var n,a,o,s=null,u=[],c=0;if(t&&"Unit"===t.type)s=t.clone();else if("string"==typeof t)""!==t&&(n=t);else{if("object"!=typeof t)throw new TypeError('Cannot create unit "'+e+'" from "'+t.toString()+'": expecting "string" or "Unit" or "Object"');n=t.definition,a=t.prefixes,c=t.offset,o=t.baseName,t.aliases&&(u=t.aliases.valueOf())}if(u)for(var l=0;l1e-12){h=!1;break}if(h){p=!0,f.base=R[m];break}}if(!p){o=o||e+"_STUFF";var y={dimensions:s.dimensions.slice(0)};y.key=o,R[o]=y,V[o]={unit:f,prefix:I.NONE[""]},f.base=R[o]}}else{if(o=o||e+"_STUFF",k.indexOf(o)>=0)throw new Error('Cannot create new base unit "'+e+'": a base unit with that name already exists (and cannot be overridden)');for(var g in k.push(o),R)Z(R,g)&&(R[g].dimensions[k.length-1]=0);for(var v={dimensions:[]},x=0;x{var{typed:t,Unit:r}=e;return t(pm,{"Object, Object":function(e,t){return r.createUnit(e,t)},Object:function(e){return r.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,t,n){var i={};return i[e]=t,r.createUnit(i,n)},"string, Unit | string | Object":function(e,t){var n={};return n[e]=t,r.createUnit(n,{})},string:function(e){var t={};return t[e]={},r.createUnit(t,{})}})}));var hm=W("eigs",["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","divideScalar","inv","bignumber","multiply","add","larger","column","flatten","number","complex","sqrt","diag","qr","usolveAll","im","re","smaller","round","log10","transpose","matrixFromColumns"],(e=>{var{config:t,typed:r,matrix:n,addScalar:u,subtract:c,equal:l,abs:f,atan:p,cos:m,sin:h,multiplyScalar:d,divideScalar:y,inv:g,bignumber:v,multiply:x,add:b,larger:w,column:N,flatten:M,number:S,complex:E,sqrt:A,diag:O,qr:C,usolveAll:_,im:T,re:B,smaller:q,round:z,log10:D,transpose:I,matrixFromColumns:k}=e,R=function(e){var{config:t,addScalar:r,subtract:n,abs:i,atan:a,cos:o,sin:s,multiplyScalar:u,inv:c,bignumber:l,multiply:f,add:p}=e;function m(e,r){for(var n,i=e.length,a=Math.abs(r/i),o=new Array(i),s=0;s=Math.abs(a);){var c=u[0][0],l=u[0][1];e=v(e,(f=e[c][c],p=e[l][l],m=e[c][l],h=void 0,h=p-f,n=Math.abs(h)<=t.epsilon?Math.PI/4:.5*Math.atan(2*m/(p-f))),c,l),o=d(o,n,c,l),u=x(e)}for(var f,p,m,h,y=N(i,0),g=0;g=i(p);){var v=d[0][0],x=d[0][1];e=g(e,(M=e[v][v],S=e[x][x],E=e[v][x],A=void 0,A=n(S,M),o=i(A)<=t.epsilon?l(-1).acos().div(4):u(.5,a(f(2,E,c(A))))),v,x),m=y(m,o,v,x),d=b(e)}for(var M,S,E,A,O=N(s,0),C=0;C2&&void 0!==arguments[2]?arguments[2]:t.epsilon,i=arguments.length>3?arguments[3]:void 0;if("number"===i)return m(e,n);if("BigNumber"===i)return h(e,n);throw TypeError("Unsupported data type: "+i)}}({config:t,addScalar:u,subtract:c,column:N,flatten:M,equal:l,abs:f,atan:p,cos:m,sin:h,multiplyScalar:d,inv:g,bignumber:v,complex:E,multiply:x,add:b}),F=function(e){var{addScalar:t,subtract:r,flatten:n,multiply:i,multiplyScalar:a,divideScalar:o,sqrt:s,abs:u,bignumber:c,diag:l,inv:f,qr:p,usolveAll:m,equal:h,complex:d,larger:y,smaller:g,round:v,log10:x,transpose:b,matrixFromColumns:w}=e;function N(e,t,n,i,a,o,s,l){var f="BigNumber"===l,p="Complex"===l,m=f?c(0):p?d(0):0,h=f?c(1):p?d(1):1;if(g(u(n),s))return[[h,m],[m,h]];if(y(u(r(a,o)),s))return[[r(a,i),r(o,i)],[n,n]];var v=r(e,a),x=r(t,a),b=r(n,a),w=r(i,a);return g(u(x),s)?[[v,h],[b,m]]:[[x,m],[w,h]]}function M(e,t){for(var r=0;r1&&(D=l(Array(B-1).fill(v)))),B-=1,_.pop();for(var P=0;P2&&(D=l(Array(B-2).fill(v)))),B-=2,_.pop(),_.pop();for(var L=0;L+r(u(e),u(t)))),I>100){var H=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+T.join(", "));throw H.values=T,H.vectors=[],H}return{values:T,C:m?i(z,function(e,t){for(var r=[],n=0;ni(a,e)))).shift(),_.lengthn(e))))}if(0!==A.length){var T=new Error("Failed to find eigenvectors for the following eigenvalues: "+A.join(", "));throw T.values=o,T.vectors=w,T}return w}(e,b,B,T,E),_=w(..._)),{values:T,vectors:_}}}({config:t,addScalar:u,subtract:c,multiply:x,multiplyScalar:d,flatten:M,divideScalar:y,sqrt:A,abs:f,bignumber:v,diag:O,qr:C,inv:g,usolveAll:_,equal:l,complex:E,larger:w,smaller:q,round:z,log10:D,transpose:I,matrixFromColumns:k});return r("eigs",{Array:function(e){return U(n(e))},"Array, number|BigNumber":function(e,t){return U(n(e),t)},Matrix:function(e){var{values:t,vectors:r}=U(e);return{values:n(t),vectors:n(r)}},"Matrix, number|BigNumber":function(e,t){var{values:r,vectors:i}=U(e,t);return{values:n(r),vectors:n(i)}}});function U(e,r){void 0===r&&(r=t.epsilon);var n=e.size();if(2!==n.length||n[0]!==n[1])throw new RangeError("Matrix must be square (size: "+De(n)+")");var i=e.toArray(),a=n[0];if(function(e,t,r){for(var n=0;n{var{typed:t,config:r,abs:n,add:i,addScalar:o,matrix:s,multiply:u,multiplyScalar:c,divideScalar:l,subtract:f,smaller:p,equalScalar:m}=e;return t("intersect",{"Array, Array, Array":function(e,t,r){if(!y(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!y(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!function(e){return 4===e.length&&h(e[0])&&h(e[1])&&h(e[2])&&h(e[3])}(r))throw new TypeError("Array with 4 numbers expected as third argument");return function(e,t,r,n,i,a,s,u,p,m){var h=c(e,s),d=c(n,s),y=c(t,u),g=c(i,u),v=c(r,p),x=c(a,p),b=l(f(f(f(m,h),y),v),f(f(f(o(o(d,g),x),h),y),v));return[o(e,c(b,f(n,e))),o(t,c(b,f(i,t))),o(r,c(b,f(a,r)))]}(e[0],e[1],e[2],t[0],t[1],t[2],r[0],r[1],r[2],r[3])},"Array, Array, Array, Array":function(e,t,a,s){if(2===e.length){if(!d(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!d(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!d(a))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!d(s))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return function(e,t,a,s){var m=e,h=a,d=f(m,t),y=f(h,s),g=f(c(d[0],y[1]),c(y[0],d[1]));if(p(n(g),r.epsilon))return null;var v=c(y[0],m[1]),x=c(y[1],m[0]),b=c(y[0],h[1]),w=c(y[1],h[0]),N=l(o(f(f(v,x),b),w),g);return i(u(d,N),m)}(e,t,a,s)}if(3===e.length){if(!y(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!y(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!y(a))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!y(s))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return h=e[0],v=e[1],x=e[2],b=t[0],w=t[1],N=t[2],M=a[0],S=a[1],E=a[2],_=g(h,M,A=s[0],M,v,S,O=s[1],S,x,E,C=s[2],E),T=g(A,M,b,h,O,S,w,v,C,E,N,x),B=g(h,M,b,h,v,S,w,v,x,E,N,x),q=g(A,M,A,M,O,S,O,S,C,E,C,E),z=g(b,h,b,h,w,v,w,v,N,x,N,x),D=l(f(c(_,T),c(B,q)),f(c(z,q),c(T,T))),I=l(o(_,c(D,T)),q),k=o(h,c(D,f(b,h))),R=o(v,c(D,f(w,v))),F=o(x,c(D,f(N,x))),U=o(M,c(I,f(A,M))),P=o(S,c(I,f(O,S))),j=o(E,c(I,f(C,E))),m(k,U)&&m(R,P)&&m(F,j)?[k,R,F]:null}throw new TypeError("Arrays with two or thee dimensional points expected");var h,v,x,b,w,N,M,S,E,A,O,C,_,T,B,q,z,D,I,k,R,F,U,P,j},"Matrix, Matrix, Matrix":function(e,t,r){return s(this(e.valueOf(),t.valueOf(),r.valueOf()))},"Matrix, Matrix, Matrix, Matrix":function(e,t,r,n){return s(this(e.valueOf(),t.valueOf(),r.valueOf(),n.valueOf()))}});function h(e){return"number"==typeof e||a(e)}function d(e){return 2===e.length&&h(e[0])&&h(e[1])}function y(e){return 3===e.length&&h(e[0])&&h(e[1])&&h(e[2])}function g(e,t,r,n,i,a,s,u,l,p,m,h){var d=c(f(e,t),f(r,n)),y=c(f(i,a),f(s,u)),g=c(f(l,p),f(m,h));return o(o(d,y),g)}})),ym="usolve",gm=W(ym,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(ym,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=(t=u(e,t,!0))._data,c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=[],d=l-1;d>=0;d--){var y=r[d][0]||0;if(o(y,0))h[d]=[0];else{for(var g=0,v=[],x=[],b=m[d],w=m[d+1]-1;w>=b;w--){var N=p[w];N===d?g=f[w]:N=0;m--){var h=r[m][0]||0,d=void 0;if(o(h,0))d=0;else{var y=p[m][m];if(o(y,0))throw new Error("Linear system cannot be solved since matrix is singular");d=n(h,y);for(var g=m-1;g>=0;g--)r[g]=[a(r[g][0]||0,i(d,p[g][m]))]}f[m]=[d]}return new s({data:f,size:[c,1]})}})),vm="norm",xm=W(vm,["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],(e=>{var{typed:t,abs:r,add:n,pow:i,conj:a,sqrt:o,multiply:s,equalScalar:u,larger:c,smaller:l,matrix:f,ctranspose:p,eigs:m}=e;return t(vm,{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},boolean:function(e){return Math.abs(e)},Array:function(e){return h(f(e),2)},Matrix:function(e){return h(e,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(e){return this(e)},"Array, number | BigNumber | string":function(e,t){return h(f(e),t)},"Matrix, number | BigNumber | string":function(e,t){return h(e,t)}});function h(e,t){var f=e.size();if(1===f.length)return function(e,t){if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=0;return e.forEach((function(e){var n=r(e);c(n,t)&&(t=n)}),!0),t}(e);if(t===Number.NEGATIVE_INFINITY||"-inf"===t)return function(e){var t;return e.forEach((function(e){var n=r(e);t&&!l(n,t)||(t=n)}),!0),t||0}(e);if("fro"===t)return h(e,2);if("number"==typeof t&&!isNaN(t)){if(!u(t,0)){var a=0;return e.forEach((function(e){a=n(i(r(e),t),a)}),!0),i(a,1/t)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}(e,t);if(2===f.length){if(f[0]&&f[1])return function(e,t){if(1===t)return function(e){var t=[],i=0;return e.forEach((function(e,a){var o=a[1],s=n(t[o]||0,r(e));c(s,i)&&(i=s),t[o]=s}),!0),i}(e);if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=[],i=0;return e.forEach((function(e,a){var o=a[0],s=n(t[o]||0,r(e));c(s,i)&&(i=s),t[o]=s}),!0),i}(e);if("fro"===t)return function(e){var t=0;return e.forEach((function(e,r){t=n(t,s(e,a(e)))})),r(o(t))}(e);if(2===t)return function(e){var t=e.size();if(t[0]!==t[1])throw new RangeError("Invalid matrix dimensions");var n=p(e),i=s(n,e),a=m(i).values.toArray(),u=a[a.length-1];return r(o(u))}(e);throw new Error("Unsupported parameter value "+t)}(e,t);throw new RangeError("Invalid matrix dimensions")}}}));function bm(e,t){var r,n=t.length,i=[];if(e)for(r=0;r{var{typed:t,matrix:r,lup:n,slu:i,usolve:a,lsolve:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(wm,{"Array, Array | Matrix":function(e,t){e=r(e);var i=n(e);return p(i.L,i.U,i.p,null,t).valueOf()},"DenseMatrix, Array | Matrix":function(e,t){var r=n(e);return p(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){var r=n(e);return p(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,r,n){var a=i(e,r,n);return p(a.L,a.U,a.p,a.q,t)},"Object, Array | Matrix":function(e,t){return p(e.L,e.U,e.p,e.q,t)}});function c(e){if(f(e))return e;if(l(e))return r(e);throw new TypeError("Invalid Matrix LU decomposition")}function p(e,t,r,n,i){e=c(e),t=c(t),r&&((i=u(e,i,!0))._data=bm(r,i._data));var s=o(e,i),l=a(t,s);return n&&(l._data=bm(n,l._data)),l}})),Sm="sqrtm",Em=["typed","abs","add","multiply","sqrt","subtract","inv","size","max","identity"],Am=W(Sm,Em,(e=>{var{typed:t,abs:r,add:n,multiply:i,sqrt:a,subtract:o,inv:s,size:u,max:c,identity:l}=e,p=1e-6;function m(e){var t,a=0,f=e,m=l(u(e));do{var h=f;if(f=i(.5,n(h,s(m))),m=i(.5,n(m,s(h))),(t=c(r(o(f,h))))>p&&++a>1e3)throw new Error("computing square root of matrix: iterative method could not converge")}while(t>p);return f}return t(Sm,{"Array | Matrix":function(e){var t=f(e)?e.size():je(e);switch(t.length){case 1:if(1===t[0])return a(e);throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:if(t[0]===t[1])return m(e);throw new RangeError("Matrix must be square (size: "+De(t)+")");default:throw new RangeError("Matrix must be at most two dimensional (size: "+De(t)+")")}}})})),Om="multinomial",Cm=["typed","add","divide","multiply","factorial","isInteger","isPositive"],_m=W(Om,Cm,(e=>{var{typed:t,add:r,divide:n,multiply:i,factorial:a,isInteger:o,isPositive:s}=e;return t(Om,{"Array | Matrix":function(e){var t=0,u=1;return Ht(e,(function(e){if(!o(e)||!s(e))throw new TypeError("Positive integer value expected in function multinomial");t=r(t,e),u=i(u,a(e))})),n(a(t),u)}})})),Tm="rotationMatrix",Bm=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],qm=W(Tm,Bm,(e=>{var{typed:t,config:r,multiplyScalar:n,addScalar:i,unaryMinus:o,norm:s,BigNumber:u,matrix:c,DenseMatrix:l,SparseMatrix:f,cos:p,sin:m}=e;return t(Tm,{"":function(){return"Matrix"===r.matrix?c([]):[]},string:function(e){return c(e)},"number | BigNumber | Complex | Unit":function(e){return h(e,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(e,t){return h(e,t)},"number | BigNumber | Complex | Unit, Array":function(e,t){var r=c(t);return d(r),v(e,r,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,t){d(t);var n=t.storage()||("Matrix"===r.matrix?"dense":void 0);return v(e,t,n)},"number | BigNumber | Complex | Unit, Array, string":function(e,t,r){var n=c(t);return d(n),v(e,n,r)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,t,r){return d(t),v(e,t,r)}});function h(e,t){var r=a(e)?new u(-1):-1,i=p(e),o=m(e);return g([[i,n(r,o)],[o,i]],t)}function d(e){var t=e.size();if(t.length<1||3!==t[0])throw new RangeError("Vector must be of dimensions 1x3")}function y(e){return e.reduce(((e,t)=>n(e,t)))}function g(e,t){if(t){if("sparse"===t)return new f(e);if("dense"===t)return new l(e);throw new TypeError('Unknown matrix type "'.concat(t,'"'))}return e}function v(e,t,r){var n=s(t);if(0===n)throw new RangeError("Rotation around zero vector");var c=a(e)?u:null,l=c?new c(1):1,f=c?new c(-1):-1,h=c?new c(t.get([0])/n):t.get([0])/n,d=c?new c(t.get([1])/n):t.get([1])/n,v=c?new c(t.get([2])/n):t.get([2])/n,x=p(e),b=i(l,o(x)),w=m(e);return g([[i(x,y([h,h,b])),i(y([h,d,b]),y([f,v,w])),i(y([h,v,b]),y([d,w]))],[i(y([h,d,b]),y([v,w])),i(x,y([d,d,b])),i(y([d,v,b]),y([f,h,w]))],[i(y([h,v,b]),y([f,d,w])),i(y([d,v,b]),y([h,w])),i(x,y([v,v,b]))]],r)}})),zm="median",Dm=["typed","add","divide","compare","partitionSelect"],Im=W(zm,Dm,(e=>{var{typed:t,add:r,divide:n,compare:i,partitionSelect:a}=e;function o(e){try{var t=(e=et(e.valueOf())).length;if(0===t)throw new Error("Cannot calculate median of an empty array");if(t%2==0){for(var r=t/2-1,n=a(e,r+1),o=e[r],c=0;c0&&(o=e[c]);return u(o,n)}var l=a(e,(t-1)/2);return s(l)}catch(e){throw Gr(e,"median")}}var s=t({"number | BigNumber | Complex | Unit":function(e){return e}}),u=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,t){return n(r(e,t),2)}});return t(zm,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("median(A, dim) is not yet supported")},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function median");return o(e)}})})),km="rotate",Rm=["typed","multiply","rotationMatrix"],Fm=W(km,Rm,(e=>{var{typed:t,multiply:r,rotationMatrix:n}=e;return t(km,{"Array , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),r(n(t),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),r(n(t),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),r(n(t,a),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),r(n(t,a),e)}});function i(e,t){var r=Array.isArray(e)?je(e):e.size();if(r.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(t));if(2===r.length&&1!==r[1])throw new RangeError("Vector must be of dimensions 1x".concat(t));if(r[0]!==t)throw new RangeError("Vector must be of dimensions 1x".concat(t))}})),Um=["typed","abs","map","median","subtract"],Pm=W("mad",Um,(e=>{var{typed:t,abs:r,map:n,median:i,subtract:a}=e;return t("mad",{"Array | Matrix":o,"...":function(e){return o(e)}});function o(e){if(0===(e=et(e.valueOf())).length)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var t=i(e);return i(n(e,(function(e){return r(a(e,t))})))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf("median")?new TypeError(e.message.replace("median","mad")):Gr(e,"mad")}}})),jm="unit",Lm=["typed","Unit"],Hm=W(jm,Lm,(e=>{var{typed:t,Unit:r}=e;return t(jm,{Unit:function(e){return e.clone()},string:function(e){return r.isValuelessUnit(e)?new r(null,e):r.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string":function(e,t){return new r(e,t)},"Array | Matrix":function(e){return $t(e,this)}})})),$m=Nn({}),Gm=Sn({}),Vm=En({}),Zm=In({}),Wm=kn({}),Jm=Dn({}),Ym=Kn({config:n}),Xm=ei({}),Qm=ti({}),Km=Jn({Complex:Gm}),eh=$n({BigNumber:Ym,config:n}),th=Vn({BigNumber:Ym,config:n}),rh=Fn({BigNumber:Ym,config:n}),nh=Un({BigNumber:Ym,config:n}),ih=Zn({BigNumber:Ym,config:n}),ah=Pn({BigNumber:Ym,config:n}),oh=Ti({BigNumber:Ym,config:n}),sh=wi({BigNumber:Ym,config:n}),uh=Pi({BigNumber:Ym,config:n}),ch=_i({BigNumber:Ym,config:n}),lh=ta({}),fh=jn({BigNumber:Ym,config:n}),ph=Rn({BigNumber:Ym,config:n}),mh=Gn({BigNumber:Ym,config:n}),hh=Yn({}),dh=ra({Matrix:Xm}),yh=Ln({BigNumber:Ym,config:n}),gh=aa({BigNumber:Ym,Complex:Gm,DenseMatrix:dh,Fraction:lh}),vh=la({typed:gh}),xh=pa({typed:gh}),bh=xa({typed:gh}),wh=wa({typed:gh}),Nh=Sa({config:n,typed:gh}),Mh=Ea({typed:gh}),Sh=Oa({typed:gh}),Eh=Ca({Complex:Gm,typed:gh}),Ah=Ta({typed:gh}),Oh=ro({BigNumber:Ym,config:n,typed:gh}),Ch=wr({isInteger:vh,typed:gh}),_h=io({typed:gh}),Th=oo({Complex:Gm,typed:gh}),Bh=uo({Complex:Gm,config:n,typed:gh}),qh=co({typed:gh}),zh=fo({BigNumber:Ym,Fraction:lh,complex:Eh,typed:gh}),Dh=mo({typed:gh}),Ih=qo({typed:gh}),kh=zo({typed:gh}),Rh=Do({typed:gh}),Fh=Po({typed:gh}),Uh=jo({typed:gh}),Ph=$o({typed:gh}),jh=Vo({typed:gh}),Lh=Wo({typed:gh}),Hh=ts({typed:gh}),$h=rs({format:Hh,typed:gh}),Gh=is({typed:gh}),Vh=ss({typed:gh}),Zh=cs({Complex:Gm,config:n,typed:gh}),Wh=Cs({BigNumber:Ym,typed:gh}),Jh=Ts({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),Yh=qs({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),Xh=Ds({Complex:Gm,config:n,typed:gh}),Qh=Is({typed:gh}),Kh=Rs({Complex:Gm,config:n,typed:gh}),ed=Us({typed:gh}),td=js({BigNumber:Ym,typed:gh}),rd=Hs({BigNumber:Ym,typed:gh}),nd=Gs({BigNumber:Ym,typed:gh}),id=Zs({typed:gh}),ad=Ws({typed:gh}),od=Qs({typed:gh}),sd=iu({config:n,typed:gh}),ud=su({config:n,typed:gh}),cd=Hn({BigNumber:Ym,config:n}),ld=cu({typed:gh}),fd=fu({isNumeric:xh,typed:gh}),pd=mu({typed:gh}),md=du({typed:gh}),hd=yu({Fraction:lh,typed:gh}),dd=vu({typed:gh}),yd=bu({typed:gh}),gd=wu({typed:gh}),vd=Mu({Complex:Gm,config:n,typed:gh}),xd=Su({Complex:Gm,config:n,typed:gh}),bd=Au({typed:gh}),wd=Cu({typed:gh}),Nd=Tu({isNaN:wh,isNumeric:xh,typed:gh}),Md=Bu({format:Hh,typed:gh}),Sd=zu({Complex:Gm,config:n,typed:gh}),Ed=Iu({BigNumber:Ym,typed:gh}),Ad=ku({typed:gh}),Od=Ru({typed:gh}),Cd=Fu({BigNumber:Ym,typed:gh}),_d=Uu({typed:gh}),Td=ju({typed:gh}),Bd=$u({config:n,typed:gh}),qd=Wn({BigNumber:Ym,config:n}),zd=Vu({typed:gh}),Dd=Zu({Matrix:Xm,equalScalar:Nh,typed:gh}),Id=Ju({DenseMatrix:dh,Matrix:Xm,SparseMatrix:Dd,typed:gh}),kd=Yu({typed:gh}),Rd=rc({BigNumber:Ym,DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),Fd=uc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),Ud=fc({BigNumber:Ym,equalScalar:Nh,matrix:Id,typed:gh}),Pd=mc({BigNumber:Ym,config:n,matrix:Id,typed:gh}),jd=dc({equalScalar:Nh,matrix:Id,typed:gh}),Ld=vc({DenseMatrix:dh,matrix:Id,typed:gh}),Hd=xc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),$d=Lr({isInteger:vh,matrix:Id,typed:gh}),Gd=wc({DenseMatrix:dh,SparseMatrix:Dd,matrix:Id,typed:gh}),Vd=Mc({BigNumber:Ym,DenseMatrix:dh,SparseMatrix:Dd,config:n,matrix:Id,typed:gh}),Zd=Sc({BigNumber:Ym,config:n,matrix:Id,typed:gh}),Wd=Ac({isInteger:vh,matrix:Id,typed:gh}),Jd=Cc({matrix:Id,config:n,typed:gh}),Yd=Dr({matrix:Id,typed:gh}),Xd=Tc({BigNumber:Ym,config:n,matrix:Id,typed:gh}),Qd=Bc({format:Hh,typed:gh}),Kd=Rc({BigNumber:Ym,DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),ey=jc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),ty=Hc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),ry=Gc({BigNumber:Ym,DenseMatrix:dh,Fraction:lh,config:n,equalScalar:Nh,matrix:Id,typed:gh}),ny=Zc({matrix:Id,typed:gh}),iy=Jc({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),ay=Xc({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),oy=Kc({DenseMatrix:dh,config:n,equalScalar:Nh,matrix:Id,typed:gh}),sy=el({DenseMatrix:dh,smaller:iy}),uy=tl({larger:ay,smaller:iy}),cy=nl({SparseMatrix:Dd,typed:gh}),ly=al({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),fy=ul({BigNumber:Ym,DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),py=cl({BigNumber:Ym,typed:gh}),my=ll({DenseMatrix:dh,SparseMatrix:Dd,addScalar:yd,equalScalar:Nh,matrix:Id,typed:gh}),hy=fl({addScalar:yd,conj:bd,multiplyScalar:qh,size:Jd,typed:gh}),dy=ml({addScalar:yd,combinations:od,isInteger:vh,isNegative:zd,isPositive:bh,larger:ay,typed:gh}),yy=dl({typed:gh}),gy=gl({isZero:yy,matrix:Id,typed:gh}),vy=xl({BigNumber:Ym,Complex:Gm,Fraction:lh,config:n,isNegative:zd,matrix:Id,typed:gh,unaryMinus:dd}),xy=bl({config:n,equalScalar:Nh,matrix:Id,round:Kd,typed:gh}),by=Nl({addScalar:yd,dot:hy,equalScalar:Nh,matrix:Id,multiplyScalar:qh,typed:gh}),wy=Sl({equalScalar:Nh,matrix:Id,multiplyScalar:qh,typed:gh}),Ny=El({typed:gh}),My=Ol({matrix:Id,typed:gh}),Sy=_l({config:n,matrix:Id}),Ey=Bl({matrix:Id,typed:gh}),Ay=ql({matrix:Id,typed:gh}),Oy=zl({Complex:Gm,config:n,fraction:hd,identity:Vd,matrix:Id,multiply:by,number:Mh,typed:gh}),Cy=Il({DenseMatrix:dh,equalScalar:Nh,matrix:Id,pow:Oy,typed:gh}),_y=Rl({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),Ty=Pl({compare:ry,typed:gh}),By=Ll({compareText:ny,isZero:yy,typed:gh}),qy=$l({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),zy=Vl({compare:ry,isNaN:wh,isNumeric:xh,typed:gh}),Dy=Zl({ImmutableDenseMatrix:sy}),Iy=Jl({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),ky=Yl({typed:gh}),Ry=Ql({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Fy=ef({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Uy=rf({Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Py=af({compareNatural:Ty,typed:gh}),jy=of({add:my,matrix:Id,typed:gh}),Ly=sf({add:my,compare:ry,multiply:by,partitionSelect:zy,typed:gh}),Hy=pf({BigNumber:Ym,Complex:Gm,config:n,multiplyScalar:qh,pow:Oy,typed:gh}),$y=mf({BigNumber:Ym,typed:gh}),Gy=df({flatten:My,matrix:Id,size:Jd,typed:gh}),Vy=yf({equalScalar:Nh,matrix:Id,typed:gh}),Zy=vf({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),Wy=bf({matrix:Id,multiplyScalar:qh,typed:gh}),Jy=wf({matrix:Id,typed:gh}),Yy=Nf({bignumber:$y,fraction:hd,number:Mh}),Xy=Mf({equalScalar:Nh,matrix:Id,not:Fh,typed:gh,zeros:Xd}),Qy=Ef({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),Ky=Of({compare:ry,compareNatural:Ty,matrix:Id,typed:gh}),eg=Jr({config:n,numeric:Yy,smaller:iy,typed:gh}),tg=Cf({BigNumber:Ym,typed:gh}),rg=Tf({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),ng=qf({Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),ig=Df({Index:Dy,typed:gh}),ag=Xr({add:my,config:n,numeric:Yy,typed:gh}),og=kf({gamma:Hy,typed:gh}),sg=Ff({factorial:og,typed:gh}),ug=jf({flatten:My,matrix:Id,size:Jd,typed:gh}),cg=Hf({DenseMatrix:dh,addScalar:yd,equalScalar:Nh,matrix:Id,typed:gh,unaryMinus:dd}),lg=Vf({matrix:Id,multiply:by,subtract:cg,typed:gh}),fg=nn({bignumber:$y,matrix:Id,config:n,larger:ay,largerEq:qy,smaller:iy,smallerEq:Qy,typed:gh}),pg=ln({Index:Dy,matrix:Id,range:fg,typed:gh}),mg=Wf({config:n,multiplyScalar:qh,numeric:Yy,typed:gh}),hg=Yf({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),dg=Vr({config:n,larger:ay,numeric:Yy,typed:gh}),yg=Qf({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),gg=ep({Index:Dy,concat:$d,setDifference:Ry,size:Jd,subset:Yd,typed:gh}),vg=tp({config:n,equalScalar:Nh,matrix:Id,round:Kd,typed:gh}),xg=rp({DenseMatrix:dh,matrix:Id,typed:gh}),bg=ip({prod:mg,size:Jd,typed:gh}),wg=op({conj:bd,transpose:Jy,typed:gh}),Ng=up({equal:hg,typed:gh}),Mg=lp({Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Sg=fp({Complex:Gm,ceil:vg,floor:xy,matrix:Id,typed:gh}),Eg=sn({matrix:Id,number:Mh,subtract:cg,typed:gh}),Ag=mp({numeric:Yy,typed:gh}),Og=dp({Complex:Gm,config:n,divideScalar:Ag,typed:gh}),Cg=vp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),_g=bp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),Tg=wp({FibonacciHeap:uy,addScalar:yd,equalScalar:Nh}),Bg=Mp({Index:Dy,concat:$d,setIntersect:Fy,setSymDifference:gg,size:Jd,subset:Yd,typed:gh}),qg=Sp({DenseMatrix:dh,Spa:Tg,SparseMatrix:Dd,abs:kd,addScalar:yd,divideScalar:Ag,equalScalar:Nh,larger:ay,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh,unaryMinus:dd}),zg=Rp({SparseMatrix:Dd,abs:kd,add:my,divideScalar:Ag,larger:ay,largerEq:qy,multiply:by,subtract:cg,transpose:Jy,typed:gh}),Dg=Fp({lup:qg,matrix:Id,multiply:by,subtract:cg,typed:gh,unaryMinus:dd}),Ig=Pp({abs:kd,addScalar:yd,divideScalar:Ag,multiplyScalar:qh,sqrt:xd,subtract:cg,typed:gh,unaryMinus:dd}),kg=Lp({addScalar:yd,combinations:od,divideScalar:Ag,factorial:og,isInteger:vh,isNegative:zd,larger:ay,multiplyScalar:qh,pow:Oy,subtract:cg,typed:gh}),Rg=$p({addScalar:yd,combinations:od,divideScalar:Ag,isInteger:vh,isNegative:zd,multiplyScalar:qh,typed:gh}),Fg=en({Index:Dy,matrix:Id,range:fg,typed:gh}),Ug=Gp({Complex:Gm,config:n,divideScalar:Ag,typed:gh}),Pg=Zp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,typed:gh}),jg=Jp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),Lg=Xp({abs:kd,addScalar:yd,divideScalar:Ag,isPositive:bh,multiplyScalar:qh,smaller:iy,sqrt:xd,typed:gh}),Hg=Qp({addScalar:yd,complex:Eh,conj:bd,divideScalar:Ag,equal:hg,identity:Vd,isZero:yy,matrix:Id,multiplyScalar:qh,sign:zh,sqrt:xd,subtract:cg,typed:gh,unaryMinus:dd,zeros:Xd}),$g=Kp({abs:kd,addScalar:yd,det:Dg,divideScalar:Ag,identity:Vd,matrix:Id,multiply:by,typed:gh,unaryMinus:dd}),Gg=tm({abs:kd,add:my,identity:Vd,inv:$g,multiply:by,typed:gh}),Vg=rm({divideScalar:Ag,equalScalar:Nh,inv:$g,matrix:Id,multiply:by,typed:gh}),Zg=mn({add:my,divide:Vg,typed:gh}),Wg=gn({add:my,apply:Ch,divide:Vg,isNaN:wh,multiply:by,subtract:cg,typed:gh}),Jg=im({divide:Vg,dotDivide:Pg,isNumeric:xh,log:Ug,matrix:Id,multiply:by,sum:ag,typed:gh}),Yg=om({addScalar:yd,isInteger:vh,isNegative:zd,stirlingS2:kg,typed:gh}),Xg=um({Complex:Gm,config:n,divideScalar:Ag,log:Ug,typed:gh}),Qg=fm({BigNumber:Ym,Complex:Gm,Fraction:lh,abs:kd,addScalar:yd,config:n,divideScalar:Ag,equal:hg,fix:Sg,format:Hh,isNumeric:xh,multiplyScalar:qh,number:Mh,pow:Oy,round:Kd,subtract:cg}),Kg=mm({Unit:Qg,typed:gh}),ev=hm({abs:kd,add:my,addScalar:yd,atan:Qh,bignumber:$y,column:Fg,complex:Eh,config:n,cos:Od,diag:Gd,divideScalar:Ag,equal:hg,flatten:My,im:Rh,inv:$g,larger:ay,log10:Bh,matrix:Id,matrixFromColumns:Gy,multiply:by,multiplyScalar:qh,number:Mh,qr:Hg,re:Ny,round:Kd,sin:_d,smaller:iy,sqrt:xd,subtract:cg,transpose:Jy,typed:gh,usolveAll:jg}),tv=dm({abs:kd,add:my,addScalar:yd,config:n,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiply:by,multiplyScalar:qh,smaller:iy,subtract:cg,typed:gh}),rv=bn({sqrt:xd,typed:gh,variance:Wg}),nv=Bi({BigNumber:Ym,Unit:Qg,config:n}),iv=fi({BigNumber:Ym,Unit:Qg,config:n}),av=zi({BigNumber:Ym,Unit:Qg,config:n}),ov=pi({BigNumber:Ym,Unit:Qg,config:n}),sv=Si({BigNumber:Ym,Unit:Qg,config:n}),uv=xi({BigNumber:Ym,Unit:Qg,config:n}),cv=Di({BigNumber:Ym,Unit:Qg,config:n}),lv=Ii({BigNumber:Ym,Unit:Qg,config:n}),fv=ni({BigNumber:Ym,Unit:Qg,config:n}),pv=Ni({BigNumber:Ym,Unit:Qg,config:n}),mv=yi({BigNumber:Ym,Unit:Qg,config:n}),hv=oi({BigNumber:Ym,Unit:Qg,config:n}),dv=$i({BigNumber:Ym,Unit:Qg,config:n}),yv=Fi({BigNumber:Ym,Unit:Qg,config:n}),gv=Ei({BigNumber:Ym,Unit:Qg,config:n}),vv=Yi({BigNumber:Ym,Unit:Qg,config:n}),xv=Zi({BigNumber:Ym,Unit:Qg,config:n}),bv=Xi({BigNumber:Ym,Unit:Qg,config:n}),wv=Mi({BigNumber:Ym,Unit:Qg,config:n}),Nv=ai({BigNumber:Ym,Unit:Qg,config:n}),Mv=ji({BigNumber:Ym,Unit:Qg,config:n}),Sv=Li({BigNumber:Ym,Unit:Qg,config:n}),Ev=ui({BigNumber:Ym,Unit:Qg,config:n}),Av=gm({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),Ov=xm({abs:kd,add:my,conj:bd,ctranspose:wg,eigs:ev,equalScalar:Nh,larger:ay,matrix:Id,multiply:by,pow:Oy,smaller:iy,sqrt:xd,typed:gh}),Cv=Mm({DenseMatrix:dh,lsolve:Cg,lup:qg,matrix:Id,slu:zg,typed:gh,usolve:Av}),_v=Am({abs:kd,add:my,identity:Vd,inv:$g,max:dg,multiply:by,size:Jd,sqrt:xd,subtract:cg,typed:gh}),Tv=_m({add:my,divide:Vg,factorial:og,isInteger:vh,isPositive:bh,multiply:by,typed:gh}),Bv=qi({BigNumber:Ym,Unit:Qg,config:n}),qv=vi({BigNumber:Ym,Unit:Qg,config:n}),zv=si({BigNumber:Ym,Unit:Qg,config:n}),Dv=bi({BigNumber:Ym,Unit:Qg,config:n}),Iv=Vi({BigNumber:Ym,Unit:Qg,config:n}),kv=ki({BigNumber:Ym,Unit:Qg,config:n}),Rv=Gi({BigNumber:Ym,Unit:Qg,config:n}),Fv=di({BigNumber:Ym,Unit:Qg,config:n}),Uv=Wi({BigNumber:Ym,Unit:Qg,config:n}),Pv=Ai({BigNumber:Ym,Unit:Qg,config:n}),jv=ri({BigNumber:Ym,Unit:Qg,config:n}),Lv=Hi({BigNumber:Ym,Unit:Qg,config:n}),Hv=qm({BigNumber:Ym,DenseMatrix:dh,SparseMatrix:Dd,addScalar:yd,config:n,cos:Od,matrix:Id,multiplyScalar:qh,norm:Ov,sin:_d,typed:gh,unaryMinus:dd}),$v=Im({add:my,compare:ry,divide:Vg,partitionSelect:zy,typed:gh}),Gv=gi({BigNumber:Ym,Unit:Qg,config:n}),Vv=li({BigNumber:Ym,Unit:Qg,config:n}),Zv=mi({BigNumber:Ym,Unit:Qg,config:n}),Wv=Ui({BigNumber:Ym,Unit:Qg,config:n}),Jv=Ji({BigNumber:Ym,Unit:Qg,config:n}),Yv=Ci({BigNumber:Ym,Unit:Qg,config:n}),Xv=Fm({multiply:by,rotationMatrix:Hv,typed:gh}),Qv=Pm({abs:kd,map:jh,median:$v,subtract:cg,typed:gh}),Kv=ci({BigNumber:Ym,Unit:Qg,config:n}),ex=hi({BigNumber:Ym,Unit:Qg,config:n}),tx=Oi({BigNumber:Ym,Unit:Qg,config:n}),rx=Hm({Unit:Qg,typed:gh}),nx=Ri({BigNumber:Ym,Unit:Qg,config:n}),ix=ii({BigNumber:Ym,Unit:Qg,config:n}),ax={},ox={},sx={},ux=ue({mathWithTransform:ox}),cx=ct({Node:ux}),lx=lt({Node:ux,ResultSet:$m}),fx=vt({Node:ux}),px=xt({Node:ux}),mx=bt({Node:ux}),hx=Et({Node:ux}),dx=At({math:ax}),yx=Ot({classes:sx}),gx=Ct({Node:ux}),vx=_t({Node:ux}),xx=Tt({Node:ux}),bx=Bt({Node:ux,typed:gh}),wx=zt({Chain:dx,typed:gh}),Nx=kt({Node:ux,subset:Yd}),Mx=Rt({Node:ux,Range:Vm,size:Jd}),Sx=Ft({matrix:Id,Node:ux,subset:Yd}),Ex=Ut({Unit:Qg,Node:ux,math:ax}),Ax=jt({Node:ux,SymbolNode:Ex,math:ax}),Ox=Jt({AccessorNode:Nx,ArrayNode:cx,AssignmentNode:Sx,BlockNode:lx,ConditionalNode:gx,ConstantNode:fx,FunctionAssignmentNode:bx,FunctionNode:Ax,IndexNode:Mx,ObjectNode:px,OperatorNode:vx,ParenthesisNode:mx,RangeNode:xx,RelationalNode:hx,SymbolNode:Ex,config:n,numeric:Yy,typed:gh}),Cx=Xt({parse:Ox,typed:gh}),_x=Qt({parse:Ox}),Tx=Kt({parse:Ox}),Bx=ir({Help:_x,mathWithTransform:ox,typed:gh}),qx=or({parse:Ox,typed:gh}),zx=hr({bignumber:$y,fraction:hd,ConstantNode:fx,FunctionNode:Ax,OperatorNode:vx,ParenthesisNode:mx,SymbolNode:Ex,add:my,config:n,divide:Vg,equal:hg,isZero:yy,mathWithTransform:ox,multiply:by,parse:Ox,pow:Oy,subtract:cg,typed:gh}),Dx=yr({bignumber:$y,fraction:hd,ConstantNode:fx,FunctionNode:Ax,OperatorNode:vx,ParenthesisNode:mx,SymbolNode:Ex,add:my,config:n,divide:Vg,equal:hg,isZero:yy,mathWithTransform:ox,multiply:by,parse:Ox,pow:Oy,simplify:zx,subtract:cg,typed:gh}),Ix=vr({Parser:Tx,typed:gh}),kx=xr({ConstantNode:fx,FunctionNode:Ax,OperatorNode:vx,ParenthesisNode:mx,SymbolNode:Ex,config:n,equal:hg,isZero:yy,numeric:Yy,parse:Ox,simplify:zx,typed:gh});e(ax,{reviver:yx,false:Zm,null:Wm,true:Jm,replacer:Qm,i:Km,LN10:eh,LOG10E:th,NaN:rh,pi:nh,SQRT1_2:ih,tau:ah,efimovFactor:oh,fineStructure:sh,sackurTetrode:uh,weakMixingAngle:ch,e:fh,Infinity:ph,LOG2E:mh,PI:nh,version:hh,E:fh,phi:yh,typed:gh,isInteger:vh,isNumeric:xh,isPositive:bh,isNaN:wh,equalScalar:Nh,number:Mh,boolean:Sh,complex:Eh,splitUnit:Ah,unaryPlus:Oh,apply:Ch,cube:_h,expm1:Th,log10:Bh,multiplyScalar:qh,sign:zh,square:Dh,bitNot:Ih,arg:kh,im:Rh,not:Fh,filter:Uh,forEach:Ph,map:jh,erf:Lh,format:Hh,oct:$h,print:Gh,isPrime:Vh,acos:Zh,acot:Wh,acsc:Jh,asec:Yh,asin:Xh,atan:Qh,atanh:Kh,cosh:ed,coth:td,csch:rd,sech:nd,sinh:id,tanh:ad,chain:wx,combinations:od,pickRandom:sd,randomInt:ud,LN2:cd,clone:ld,hasNumericValue:fd,typeOf:pd,string:md,fraction:hd,unaryMinus:dd,addScalar:yd,exp:gd,log2:vd,sqrt:xd,conj:bd,getMatrixDataType:wd,mode:Nd,bin:Md,acosh:Sd,acsch:Ed,asinh:Ad,cos:Od,csc:Cd,sin:_d,combinationsWithRep:Td,random:Bd,SQRT2:qd,isNegative:zd,matrix:Id,abs:kd,gcd:Rd,mod:Fd,nthRoot:Ud,xgcd:Pd,bitAnd:jd,bitXor:Ld,or:Hd,concat:$d,diag:Gd,identity:Vd,ones:Zd,reshape:Wd,size:Jd,subset:Yd,zeros:Xd,hex:Qd,round:Kd,leftShift:ey,rightLogShift:ty,compare:ry,compareText:ny,smaller:iy,larger:ay,unequal:oy,sparse:cy,acoth:ly,atan2:fy,sec:py,add:my,dot:hy,composition:dy,isZero:yy,matrixFromFunction:gy,cbrt:vy,floor:xy,multiply:by,dotMultiply:wy,re:Ny,flatten:My,resize:Sy,squeeze:Ey,to:Ay,pow:Oy,dotPow:Cy,rightArithShift:_y,compareNatural:Ty,equalText:By,largerEq:qy,partitionSelect:zy,asech:Iy,tan:ky,setDifference:Ry,setIntersect:Fy,setMultiplicity:Uy,setSize:Py,trace:jy,quantileSeq:Ly,gamma:Hy,bignumber:$y,matrixFromColumns:Gy,lcm:Vy,bitOr:Zy,kron:Wy,transpose:Jy,numeric:Yy,and:Xy,smallerEq:Qy,sort:Ky,min:eg,cot:tg,setDistinct:rg,setPowerset:ng,index:ig,sum:ag,factorial:og,permutations:sg,matrixFromRows:ug,subtract:cg,cross:lg,range:fg,row:pg,prod:mg,equal:hg,max:dg,setCartesian:yg,setSymDifference:gg,ceil:vg,xor:xg,count:bg,ctranspose:wg,deepEqual:Ng,setIsSubset:Mg,fix:Sg,diff:Eg,divideScalar:Ag,nthRoots:Og,lsolve:Cg,lsolveAll:_g,setUnion:Bg,lup:qg,slu:zg,det:Dg,distance:Ig,stirlingS2:kg,catalan:Rg,column:Fg,log:Ug,dotDivide:Pg,usolveAll:jg,hypot:Lg,qr:Hg,inv:$g,expm:Gg,divide:Vg,mean:Zg,variance:Wg,kldivergence:Jg,bellNumbers:Yg,log1p:Xg,createUnit:Kg,eigs:ev,intersect:tv,std:rv,atomicMass:nv,bohrMagneton:iv,boltzmann:av,conductanceQuantum:ov,deuteronMass:sv,electronMass:uv,faraday:cv,firstRadiation:lv,gravitationConstant:fv,hartreeEnergy:pv,klitzing:mv,magneticConstant:hv,molarMass:dv,molarPlanckConstant:yv,neutronMass:gv,planckCharge:vv,planckLength:xv,planckTemperature:bv,protonMass:wv,reducedPlanckConstant:Nv,secondRadiation:Mv,stefanBoltzmann:Sv,vacuumImpedance:Ev,usolve:Av,norm:Ov,lusolve:Cv,sqrtm:_v,multinomial:Tv,avogadro:Bv,classicalElectronRadius:qv,electricConstant:zv,fermiCoupling:Dv,gravity:Iv,loschmidt:kv,molarMassC12:Rv,nuclearMagneton:Fv,planckMass:Uv,quantumOfCirculation:Pv,speedOfLight:jv,wienDisplacement:Lv,rotationMatrix:Hv,median:$v,bohrRadius:Gv,elementaryCharge:Vv,inverseConductanceQuantum:Zv,molarVolume:Wv,planckTime:Jv,thomsonCrossSection:Yv,rotate:Xv,parse:Ox,evaluate:Cx,mad:Qv,coulomb:Kv,magneticFluxQuantum:ex,rydberg:tx,unit:rx,help:Bx,gasConstant:nx,compile:qx,simplify:zx,rationalize:Dx,parser:Ix,planckConstant:ix,derivative:kx,config:n}),e(ox,ax,{apply:Mr({isInteger:vh,typed:gh}),filter:Cr({typed:gh}),map:Tr({typed:gh}),forEach:qr({typed:gh}),subset:Ur({matrix:Id,typed:gh}),index:Pr({Index:Dy}),concat:$r({isInteger:vh,matrix:Id,typed:gh}),max:Wr({config:n,larger:ay,numeric:Yy,typed:gh}),min:Yr({config:n,numeric:Yy,smaller:iy,typed:gh}),sum:Qr({add:my,config:n,numeric:Yy,typed:gh}),column:tn({Index:Dy,matrix:Id,range:fg,typed:gh}),range:an({bignumber:$y,matrix:Id,config:n,larger:ay,largerEq:qy,smaller:iy,smallerEq:Qy,typed:gh}),diff:cn({bignumber:$y,matrix:Id,number:Mh,subtract:cg,typed:gh}),row:fn({Index:Dy,matrix:Id,range:fg,typed:gh}),mean:hn({add:my,divide:Vg,typed:gh}),variance:xn({add:my,apply:Ch,divide:Vg,isNaN:wh,multiply:by,subtract:cg,typed:gh}),std:wn({sqrt:xd,typed:gh,variance:Wg})}),e(sx,{ResultSet:$m,Complex:Gm,Range:Vm,Node:ux,ArrayNode:cx,BlockNode:lx,ConstantNode:fx,ObjectNode:px,ParenthesisNode:mx,RelationalNode:hx,Chain:dx,BigNumber:Ym,Matrix:Xm,ConditionalNode:gx,OperatorNode:vx,Fraction:lh,RangeNode:xx,DenseMatrix:dh,FunctionAssignmentNode:bx,SparseMatrix:Dd,ImmutableDenseMatrix:sy,FibonacciHeap:uy,AccessorNode:Nx,IndexNode:Mx,Index:Dy,AssignmentNode:Sx,Spa:Tg,Unit:Qg,SymbolNode:Ex,FunctionNode:Ax,Help:_x,Parser:Tx}),dx.createProxy(ax),browser.omnibox.setDefaultSuggestion({description:"Do most mathematical computations."});const Rx=(e,t)=>{console.log(e);const r=Cx(e);console.log(e,r),t([{description:String(r),content:String(r)}])};browser.omnibox.onInputStarted.addListener(Rx),browser.omnibox.onInputChanged.addListener(Rx)})()})(); \ No newline at end of file +(()=>{var e={977:function(e,t){var r;!function(n){"use strict";var i=function(e){return.5*(Math.exp(e)+Math.exp(-e))},a=function(e){return.5*(Math.exp(e)-Math.exp(-e))},o=function(){throw SyntaxError("Invalid Param")};function s(e,t){var r=Math.abs(e),n=Math.abs(t);return 0===e?Math.log(n):0===t?Math.log(r):r<3e3&&n<3e3?.5*Math.log(e*e+t*t):Math.log(e/Math.cos(Math.atan2(t,e)))}function u(e,t){if(!(this instanceof u))return new u(e,t);var r=function(e,t){var r={re:0,im:0};if(null==e)r.re=r.im=0;else if(void 0!==t)r.re=e,r.im=t;else switch(typeof e){case"object":if("im"in e&&"re"in e)r.re=e.re,r.im=e.im;else if("abs"in e&&"arg"in e){if(!Number.isFinite(e.abs)&&Number.isFinite(e.arg))return u.INFINITY;r.re=e.abs*Math.cos(e.arg),r.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!Number.isFinite(e.r)&&Number.isFinite(e.phi))return u.INFINITY;r.re=e.r*Math.cos(e.phi),r.im=e.r*Math.sin(e.phi)}else 2===e.length?(r.re=e[0],r.im=e[1]):o();break;case"string":r.im=r.re=0;var n=e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),i=1,a=0;null===n&&o();for(var s=0;s0&&o();break;case"number":r.im=0,r.re=e;break;default:o()}return isNaN(r.re)||isNaN(r.im),r}(e,t);this.re=r.re,this.im=r.im}u.prototype={re:0,im:0,sign:function(){var e=this.abs();return new u(this.re/e,this.im/e)},add:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:new u(this.re+r.re,this.im+r.im)},sub:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:new u(this.re-r.re,this.im-r.im)},mul:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isZero()||this.isZero()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:0===r.im&&0===this.im?new u(this.re*r.re,0):new u(this.re*r.re-this.im*r.im,this.re*r.im+this.im*r.re)},div:function(e,t){var r=new u(e,t);if(this.isZero()&&r.isZero()||this.isInfinite()&&r.isInfinite())return u.NAN;if(this.isInfinite()||r.isZero())return u.INFINITY;if(this.isZero()||r.isInfinite())return u.ZERO;e=this.re,t=this.im;var n,i,a=r.re,o=r.im;return 0===o?new u(e/a,t/a):Math.abs(a)0)return new u(Math.pow(e,r.re),0);if(0===e)switch((r.re%4+4)%4){case 0:return new u(Math.pow(t,r.re),0);case 1:return new u(0,Math.pow(t,r.re));case 2:return new u(-Math.pow(t,r.re),0);case 3:return new u(0,-Math.pow(t,r.re))}}if(0===e&&0===t&&r.re>0&&r.im>=0)return u.ZERO;var n=Math.atan2(t,e),i=s(e,t);return e=Math.exp(r.re*i-r.im*n),t=r.im*i+r.re*n,new u(e*Math.cos(t),e*Math.sin(t))},sqrt:function(){var e,t,r=this.re,n=this.im,i=this.abs();if(r>=0){if(0===n)return new u(Math.sqrt(r),0);e=.5*Math.sqrt(2*(i+r))}else e=Math.abs(n)/Math.sqrt(2*(i-r));return t=r<=0?.5*Math.sqrt(2*(i-r)):Math.abs(n)/Math.sqrt(2*(i+r)),new u(e,n<0?-t:t)},exp:function(){var e=Math.exp(this.re);return this.im,new u(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){var e=this.re,t=this.im;return new u(Math.expm1(e)*Math.cos(t)+function(e){var t=Math.PI/4;if(e<-t||e>t)return Math.cos(e)-1;var r=e*e;return r*(r*(1/24+r*(-1/720+r*(1/40320+r*(-1/3628800+r*(1/4790014600+r*(-1/87178291200+r*(1/20922789888e3)))))))-.5)}(t),Math.exp(e)*Math.sin(t))},log:function(){var e=this.re,t=this.im;return new u(s(e,t),Math.atan2(t,e))},abs:function(){return e=this.re,t=this.im,r=Math.abs(e),n=Math.abs(t),r<3e3&&n<3e3?Math.sqrt(r*r+n*n):(r1&&0===t,n=1-e,i=1+e,a=n*n+t*t,o=0!==a?new u((i*n-t*t)/a,(t*n+i*t)/a):new u(-1!==e?e/0:0,0!==t?t/0:0),c=o.re;return o.re=s(o.re,o.im)/2,o.im=Math.atan2(o.im,c)/2,r&&(o.im=-o.im),o},acoth:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new u(0,Math.PI/2);var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).atanh():new u(0!==e?e/0:0,0!==t?-t/0:0).atanh()},acsch:function(){var e=this.re,t=this.im;if(0===t)return new u(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).asinh():new u(0!==e?e/0:0,0!==t?-t/0:0).asinh()},asech:function(){var e=this.re,t=this.im;if(this.isZero())return u.INFINITY;var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).acosh():new u(0!==e?e/0:0,0!==t?-t/0:0).acosh()},inverse:function(){if(this.isZero())return u.INFINITY;if(this.isInfinite())return u.ZERO;var e=this.re,t=this.im,r=e*e+t*t;return new u(e/r,-t/r)},conjugate:function(){return new u(this.re,-this.im)},neg:function(){return new u(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new u(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new u(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new u(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){var r=new u(e,t);return Math.abs(r.re-this.re)<=u.EPSILON&&Math.abs(r.im-this.im)<=u.EPSILON},clone:function(){return new u(this.re,this.im)},toString:function(){var e=this.re,t=this.im,r="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)0){for(a+=o,t=1;tr)throw Error(y+e)}function B(e,t,r,n){var i,a,o,s;for(a=e[0];a>=10;a/=10)--t;return--t<0?(t+=7,i=0):(i=Math.ceil((t+1)/7),t%=7),a=b(10,7-t),s=e[i]%a|0,null==n?t<3?(0==t?s=s/100|0:1==t&&(s=s/10|0),o=r<4&&99999==s||r>3&&49999==s||5e4==s||0==s):o=(r<4&&s+1==a||r>3&&s+1==a/2)&&(e[i+1]/a/100|0)==b(10,t-2)-1||(s==a/2||0==s)&&0==(e[i+1]/a/100|0):t<4?(0==t?s=s/1e3|0:1==t?s=s/100|0:2==t&&(s=s/10|0),o=(n||r<4)&&9999==s||!n&&r>3&&4999==s):o=((n||r<4)&&s+1==a||!n&&r>3&&s+1==a/2)&&(e[i+1]/a/1e3|0)==b(10,t-3)-1,o}function q(e,t,r){for(var n,i,a=[0],o=0,s=e.length;or-1&&(void 0===a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/r|0,a[n]%=r)}return a.reverse()}C.absoluteValue=C.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),D(e)},C.ceil=function(){return D(new this.constructor(this),this.e+1,2)},C.comparedTo=C.cmp=function(e){var t,r,n,i,a=this,o=a.d,s=(e=new a.constructor(e)).d,u=a.s,c=e.s;if(!o||!s)return u&&c?u!==c?u:o===s?0:!o^u<0?1:-1:NaN;if(!o[0]||!s[0])return o[0]?u:s[0]?-c:0;if(u!==c)return u;if(a.e!==e.e)return a.e>e.e^u<0?1:-1;for(t=0,r=(n=o.length)<(i=s.length)?n:i;ts[t]^u<0?1:-1;return n===i?0:n>i^u<0?1:-1},C.cosine=C.cos=function(){var e,t,r=this,n=r.constructor;return r.d?r.d[0]?(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(e,t){var r,n,i=t.d.length;i<32?n=(1/Y(4,r=Math.ceil(i/3))).toString():(r=16,n="2.3283064365386962890625e-10"),e.precision+=r,t=J(e,1,t.times(n),new e(1));for(var a=r;a--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=r,t}(n,X(n,r)),n.precision=e,n.rounding=t,D(2==s||3==s?r.neg():r,e,t,!0)):new n(1):new n(NaN)},C.cubeRoot=C.cbrt=function(){var e,t,r,n,i,a,o,s,u,c,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(h=!1,(a=l.s*b(l.s*l,1/3))&&Math.abs(a)!=1/0?n=new f(a.toString()):(r=_(l.d),(a=((e=l.e)-r.length+1)%3)&&(r+=1==a||-2==a?"0":"00"),a=b(r,1/3),e=x((e+1)/3)-(e%3==(e<0?-1:2)),(n=new f(r=a==1/0?"5e"+e:(r=a.toExponential()).slice(0,r.indexOf("e")+1)+e)).s=l.s),o=(e=f.precision)+3;;)if(c=(u=(s=n).times(s).times(s)).plus(l),n=z(c.plus(l).times(s),c.plus(u),o+2,1),_(s.d).slice(0,o)===(r=_(n.d)).slice(0,o)){if("9999"!=(r=r.slice(o-3,o+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(D(n,e+1,1),t=!n.times(n).times(n).eq(l));break}if(!i&&(D(s,e+1,0),s.times(s).times(s).eq(l))){n=s;break}o+=4,i=1}return h=!0,D(n,e,f.rounding,t)},C.decimalPlaces=C.dp=function(){var e,t=this.d,r=NaN;if(t){if(r=7*((e=t.length-1)-x(this.e/7)),e=t[e])for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r},C.dividedBy=C.div=function(e){return z(this,new this.constructor(e))},C.dividedToIntegerBy=C.divToInt=function(e){var t=this.constructor;return D(z(this,new t(e),0,1,1),t.precision,t.rounding)},C.equals=C.eq=function(e){return 0===this.cmp(e)},C.floor=function(){return D(new this.constructor(this),this.e+1,3)},C.greaterThan=C.gt=function(e){return this.cmp(e)>0},C.greaterThanOrEqualTo=C.gte=function(e){var t=this.cmp(e);return 1==t||0===t},C.hyperbolicCosine=C.cosh=function(){var e,t,r,n,i,a=this,o=a.constructor,s=new o(1);if(!a.isFinite())return new o(a.s?1/0:NaN);if(a.isZero())return s;r=o.precision,n=o.rounding,o.precision=r+Math.max(a.e,a.sd())+4,o.rounding=1,(i=a.d.length)<32?t=(1/Y(4,e=Math.ceil(i/3))).toString():(e=16,t="2.3283064365386962890625e-10"),a=J(o,1,a.times(t),new o(1),!0);for(var u,c=e,l=new o(8);c--;)u=a.times(a),a=s.minus(u.times(l.minus(u.times(l))));return D(a,o.precision=r,o.rounding=n,!0)},C.hyperbolicSine=C.sinh=function(){var e,t,r,n,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.precision,r=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,(n=i.d.length)<3)i=J(a,2,i,i,!0);else{e=(e=1.4*Math.sqrt(n))>16?16:0|e,i=J(a,2,i=i.times(1/Y(5,e)),i,!0);for(var o,s=new a(5),u=new a(16),c=new a(20);e--;)o=i.times(i),i=i.times(s.plus(o.times(u.times(o).plus(c))))}return a.precision=t,a.rounding=r,D(i,t,r,!0)},C.hyperbolicTangent=C.tanh=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+7,n.rounding=1,z(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)},C.inverseCosine=C.acos=function(){var e,t=this,r=t.constructor,n=t.abs().cmp(1),i=r.precision,a=r.rounding;return-1!==n?0===n?t.isNeg()?F(r,i,a):new r(0):new r(NaN):t.isZero()?F(r,i+4,a).times(.5):(r.precision=i+6,r.rounding=1,t=t.asin(),e=F(r,i+4,a).times(.5),r.precision=i,r.rounding=a,e.minus(t))},C.inverseHyperbolicCosine=C.acosh=function(){var e,t,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(e=n.precision,t=n.rounding,n.precision=e+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,h=!1,r=r.times(r).minus(1).sqrt().plus(r),h=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)},C.inverseHyperbolicSine=C.asinh=function(){var e,t,r=this,n=r.constructor;return!r.isFinite()||r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,h=!1,r=r.times(r).plus(1).sqrt().plus(r),h=!0,n.precision=e,n.rounding=t,r.ln())},C.inverseHyperbolicTangent=C.atanh=function(){var e,t,r,n,i=this,a=i.constructor;return i.isFinite()?i.e>=0?new a(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=a.precision,t=a.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?D(new a(i),e,t,!0):(a.precision=r=n-i.e,i=z(i.plus(1),new a(1).minus(i),r+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=t,i.times(.5))):new a(NaN)},C.inverseSine=C.asin=function(){var e,t,r,n,i=this,a=i.constructor;return i.isZero()?new a(i):(t=i.abs().cmp(1),r=a.precision,n=a.rounding,-1!==t?0===t?((e=F(a,r+4,n).times(.5)).s=i.s,e):new a(NaN):(a.precision=r+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=r,a.rounding=n,i.times(2)))},C.inverseTangent=C.atan=function(){var e,t,r,n,i,a,o,s,u,c=this,l=c.constructor,f=l.precision,p=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&f+4<=O)return(o=F(l,f+4,p).times(.25)).s=c.s,o}else{if(!c.s)return new l(NaN);if(f+4<=O)return(o=F(l,f+4,p).times(.5)).s=c.s,o}for(l.precision=s=f+10,l.rounding=1,e=r=Math.min(28,s/7+2|0);e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(h=!1,t=Math.ceil(s/7),n=1,u=c.times(c),o=new l(c),i=c;-1!==e;)if(i=i.times(u),a=o.minus(i.div(n+=2)),i=i.times(u),void 0!==(o=a.plus(i.div(n+=2))).d[t])for(e=t;o.d[e]===a.d[e]&&e--;);return r&&(o=o.times(2<this.d.length-2},C.isNaN=function(){return!this.s},C.isNegative=C.isNeg=function(){return this.s<0},C.isPositive=C.isPos=function(){return this.s>0},C.isZero=function(){return!!this.d&&0===this.d[0]},C.lessThan=C.lt=function(e){return this.cmp(e)<0},C.lessThanOrEqualTo=C.lte=function(e){return this.cmp(e)<1},C.logarithm=C.log=function(e){var t,r,n,i,a,o,s,u,c=this,l=c.constructor,f=l.precision,p=l.rounding;if(null==e)e=new l(10),t=!0;else{if(r=(e=new l(e)).d,e.s<0||!r||!r[0]||e.eq(1))return new l(NaN);t=e.eq(10)}if(r=c.d,c.s<0||!r||!r[0]||c.eq(1))return new l(r&&!r[0]?-1/0:1!=c.s?NaN:r?0:1/0);if(t)if(r.length>1)a=!0;else{for(i=r[0];i%10==0;)i/=10;a=1!==i}if(h=!1,o=G(c,s=f+5),n=t?R(l,s+10):G(e,s),B((u=z(o,n,s,1)).d,i=f,p))do{if(o=G(c,s+=10),n=t?R(l,s+10):G(e,s),u=z(o,n,s,1),!a){+_(u.d).slice(i+1,i+15)+1==1e14&&(u=D(u,f+1,0));break}}while(B(u.d,i+=10,p));return h=!0,D(u,f,p)},C.minus=C.sub=function(e){var t,r,n,i,a,o,s,u,c,l,f,p,m=this,d=m.constructor;if(e=new d(e),!m.d||!e.d)return m.s&&e.s?m.d?e.s=-e.s:e=new d(e.d||m.s!==e.s?m:NaN):e=new d(NaN),e;if(m.s!=e.s)return e.s=-e.s,m.plus(e);if(c=m.d,p=e.d,s=d.precision,u=d.rounding,!c[0]||!p[0]){if(p[0])e.s=-e.s;else{if(!c[0])return new d(3===u?-0:0);e=new d(m)}return h?D(e,s,u):e}if(r=x(e.e/7),l=x(m.e/7),c=c.slice(),a=l-r){for((f=a<0)?(t=c,a=-a,o=p.length):(t=p,r=l,o=c.length),a>(n=Math.max(Math.ceil(s/7),o)+2)&&(a=n,t.length=1),t.reverse(),n=a;n--;)t.push(0);t.reverse()}else{for((f=(n=c.length)<(o=p.length))&&(o=n),n=0;n0;--n)c[o++]=0;for(n=p.length;n>a;){if(c[--n](o=(a=Math.ceil(s/7))>o?a+1:o+1)&&(i=o,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for((o=c.length)-(i=l.length)<0&&(i=o,r=l,l=c,c=r),t=0;i;)t=(c[--i]=c[i]+l[i]+t)/E|0,c[i]%=E;for(t&&(c.unshift(t),++n),o=c.length;0==c[--o];)c.pop();return e.d=c,e.e=k(c,n),h?D(e,s,u):e},C.precision=C.sd=function(e){var t,r=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(y+e);return r.d?(t=U(r.d),e&&r.e+1>t&&(t=r.e+1)):t=NaN,t},C.round=function(){var e=this,t=e.constructor;return D(new t(e),e.e+1,t.rounding)},C.sine=C.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(e,t){var r,n=t.d.length;if(n<3)return J(e,2,t,t);r=(r=1.4*Math.sqrt(n))>16?16:0|r,t=J(e,2,t=t.times(1/Y(5,r)),t);for(var i,a=new e(5),o=new e(16),s=new e(20);r--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}(n,X(n,r)),n.precision=e,n.rounding=t,D(s>2?r.neg():r,e,t,!0)):new n(NaN)},C.squareRoot=C.sqrt=function(){var e,t,r,n,i,a,o=this,s=o.d,u=o.e,c=o.s,l=o.constructor;if(1!==c||!s||!s[0])return new l(!c||c<0&&(!s||s[0])?NaN:s?o:1/0);for(h=!1,0==(c=Math.sqrt(+o))||c==1/0?(((t=_(s)).length+u)%2==0&&(t+="0"),c=Math.sqrt(t),u=x((u+1)/2)-(u<0||u%2),n=new l(t=c==1/0?"5e"+u:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+u)):n=new l(c.toString()),r=(u=l.precision)+3;;)if(n=(a=n).plus(z(o,a,r+2,1)).times(.5),_(a.d).slice(0,r)===(t=_(n.d)).slice(0,r)){if("9999"!=(t=t.slice(r-3,r+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(D(n,u+1,1),e=!n.times(n).eq(o));break}if(!i&&(D(a,u+1,0),a.times(a).eq(o))){n=a;break}r+=4,i=1}return h=!0,D(n,u,l.rounding,e)},C.tangent=C.tan=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+10,n.rounding=1,(r=r.sin()).s=1,r=z(r,new n(1).minus(r.times(r)).sqrt(),e+10,0),n.precision=e,n.rounding=t,D(2==s||4==s?r.neg():r,e,t,!0)):new n(NaN)},C.times=C.mul=function(e){var t,r,n,i,a,o,s,u,c,l=this,f=l.constructor,p=l.d,m=(e=new f(e)).d;if(e.s*=l.s,!(p&&p[0]&&m&&m[0]))return new f(!e.s||p&&!p[0]&&!m||m&&!m[0]&&!p?NaN:p&&m?0*e.s:e.s/0);for(r=x(l.e/7)+x(e.e/7),(u=p.length)<(c=m.length)&&(a=p,p=m,m=a,o=u,u=c,c=o),a=[],n=o=u+c;n--;)a.push(0);for(n=c;--n>=0;){for(t=0,i=u+n;i>n;)s=a[i]+m[n]*p[i-n-1]+t,a[i--]=s%E|0,t=s/E|0;a[i]=(a[i]+t)%E|0}for(;!a[--o];)a.pop();return t?++r:a.shift(),e.d=a,e.e=k(a,r),h?D(e,f.precision,f.rounding):e},C.toBinary=function(e,t){return Q(this,2,e,t)},C.toDecimalPlaces=C.toDP=function(e,t){var r=this,n=r.constructor;return r=new n(r),void 0===e?r:(T(e,0,c),void 0===t?t=n.rounding:T(t,0,8),D(r,e+r.e+1,t))},C.toExponential=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=I(n,!0):(T(e,0,c),void 0===t?t=i.rounding:T(t,0,8),r=I(n=D(new i(n),e+1,t),!0,e+1)),n.isNeg()&&!n.isZero()?"-"+r:r},C.toFixed=function(e,t){var r,n,i=this,a=i.constructor;return void 0===e?r=I(i):(T(e,0,c),void 0===t?t=a.rounding:T(t,0,8),r=I(n=D(new a(i),e+i.e+1,t),!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r},C.toFraction=function(e){var t,r,n,i,a,o,s,u,c,l,f,p,m=this,d=m.d,g=m.constructor;if(!d)return new g(m);if(c=r=new g(1),n=u=new g(0),o=(a=(t=new g(n)).e=U(d)-m.e-1)%7,t.d[0]=b(10,o<0?7+o:o),null==e)e=a>0?t:c;else{if(!(s=new g(e)).isInt()||s.lt(c))throw Error(y+s);e=s.gt(t)?a>0?t:c:s}for(h=!1,s=new g(_(d)),l=g.precision,g.precision=a=7*d.length*2;f=z(s,t,0,1,1),1!=(i=r.plus(f.times(n))).cmp(e);)r=n,n=i,i=c,c=u.plus(f.times(i)),u=i,i=t,t=s.minus(f.times(i)),s=i;return i=z(e.minus(r),n,0,1,1),u=u.plus(i.times(c)),r=r.plus(i.times(n)),u.s=c.s=m.s,p=z(c,n,a,1).minus(m).abs().cmp(z(u,r,a,1).minus(m).abs())<1?[c,n]:[u,r],g.precision=l,h=!0,p},C.toHexadecimal=C.toHex=function(e,t){return Q(this,16,e,t)},C.toNearest=function(e,t){var r=this,n=r.constructor;if(r=new n(r),null==e){if(!r.d)return r;e=new n(1),t=n.rounding}else{if(e=new n(e),void 0===t?t=n.rounding:T(t,0,8),!r.d)return e.s?r:e;if(!e.d)return e.s&&(e.s=r.s),e}return e.d[0]?(h=!1,r=z(r,e,0,t,1).times(e),h=!0,D(r)):(e.s=r.s,r=e),r},C.toNumber=function(){return+this},C.toOctal=function(e,t){return Q(this,8,e,t)},C.toPower=C.pow=function(e){var t,r,n,i,a,o,s=this,u=s.constructor,c=+(e=new u(e));if(!(s.d&&e.d&&s.d[0]&&e.d[0]))return new u(b(+s,c));if((s=new u(s)).eq(1))return s;if(n=u.precision,a=u.rounding,e.eq(1))return D(s,n,a);if((t=x(e.e/7))>=e.d.length-1&&(r=c<0?-c:c)<=9007199254740991)return i=j(u,s,r,n),e.s<0?new u(1).div(i):D(i,n,a);if((o=s.s)<0){if(tu.maxE+1||t0?o/0:0):(h=!1,u.rounding=s.s=1,r=Math.min(12,(t+"").length),(i=$(e.times(G(s,n+r)),n)).d&&B((i=D(i,n+5,1)).d,n,a)&&(t=n+10,+_((i=D($(e.times(G(s,t+r)),t),t+5,1)).d).slice(n+1,n+15)+1==1e14&&(i=D(i,n+1,0))),i.s=o,h=!0,u.rounding=a,D(i,n,a))},C.toPrecision=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=I(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(T(e,1,c),void 0===t?t=i.rounding:T(t,0,8),r=I(n=D(new i(n),e,t),e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+r:r},C.toSignificantDigits=C.toSD=function(e,t){var r=this.constructor;return void 0===e?(e=r.precision,t=r.rounding):(T(e,1,c),void 0===t?t=r.rounding:T(t,0,8)),D(new r(this),e,t)},C.toString=function(){var e=this,t=e.constructor,r=I(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r},C.truncated=C.trunc=function(){return D(new this.constructor(this),this.e+1,1)},C.valueOf=C.toJSON=function(){var e=this,t=e.constructor,r=I(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};var z=function(){function e(e,t,r){var n,i=0,a=e.length;for(e=e.slice();a--;)n=e[a]*t+i,e[a]=n%r|0,i=n/r|0;return i&&e.unshift(i),e}function t(e,t,r,n){var i,a;if(r!=n)a=r>n?1:-1;else for(i=a=0;it[i]?1:-1;break}return a}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]1;)e.shift()}return function(n,i,a,s,u,c){var l,f,p,m,h,d,y,g,v,b,w,N,M,S,A,O,C,_,T,B,q=n.constructor,z=n.s==i.s?1:-1,I=n.d,k=i.d;if(!(I&&I[0]&&k&&k[0]))return new q(n.s&&i.s&&(I?!k||I[0]!=k[0]:k)?I&&0==I[0]||!k?0*z:z/0:NaN);for(c?(h=1,f=n.e-i.e):(c=E,h=7,f=x(n.e/h)-x(i.e/h)),T=k.length,C=I.length,b=(v=new q(z)).d=[],p=0;k[p]==(I[p]||0);p++);if(k[p]>(I[p]||0)&&f--,null==a?(S=a=q.precision,s=q.rounding):S=u?a+(n.e-i.e)+1:a,S<0)b.push(1),d=!0;else{if(S=S/h+2|0,p=0,1==T){for(m=0,k=k[0],S++;(p1&&(k=e(k,m,c),I=e(I,m,c),T=k.length,C=I.length),O=T,N=(w=I.slice(0,T)).length;N=c/2&&++_;do{m=0,(l=t(k,w,T,N))<0?(M=w[0],T!=N&&(M=M*c+(w[1]||0)),(m=M/_|0)>1?(m>=c&&(m=c-1),1==(l=t(y=e(k,m,c),w,g=y.length,N=w.length))&&(m--,r(y,T=10;m/=10)p++;v.e=p+f*h-1,D(v,u?a+v.e+1:a,s,d)}return v}}();function D(e,t,r,n){var i,a,o,s,u,c,l,f,p,m=e.constructor;e:if(null!=t){if(!(f=e.d))return e;for(i=1,s=f[0];s>=10;s/=10)i++;if((a=t-i)<0)a+=7,o=t,u=(l=f[p=0])/b(10,i-o-1)%10|0;else if((p=Math.ceil((a+1)/7))>=(s=f.length)){if(!n)break e;for(;s++<=p;)f.push(0);l=u=0,i=1,o=(a%=7)-7+1}else{for(l=s=f[p],i=1;s>=10;s/=10)i++;u=(o=(a%=7)-7+i)<0?0:l/b(10,i-o-1)%10|0}if(n=n||t<0||void 0!==f[p+1]||(o<0?l:l%b(10,i-o-1)),c=r<4?(u||n)&&(0==r||r==(e.s<0?3:2)):u>5||5==u&&(4==r||n||6==r&&(a>0?o>0?l/b(10,i-o):0:f[p-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,c?(t-=e.e+1,f[0]=b(10,(7-t%7)%7),e.e=-t||0):f[0]=e.e=0,e;if(0==a?(f.length=p,s=1,p--):(f.length=p+1,s=b(10,7-a),f[p]=o>0?(l/b(10,i-o)%b(10,o)|0)*s:0),c)for(;;){if(0==p){for(a=1,o=f[0];o>=10;o/=10)a++;for(o=f[0]+=s,s=1;o>=10;o/=10)s++;a!=s&&(e.e++,f[0]==E&&(f[0]=1));break}if(f[p]+=s,f[p]!=E)break;f[p--]=0,s=1}for(a=f.length;0===f[--a];)f.pop()}return h&&(e.e>m.maxE?(e.d=null,e.e=NaN):e.e0?a=a.charAt(0)+"."+a.slice(1)+P(n):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(e.e<0?"e":"e+")+e.e):i<0?(a="0."+P(-i-1)+a,r&&(n=r-o)>0&&(a+=P(n))):i>=o?(a+=P(i+1-o),r&&(n=r-i-1)>0&&(a=a+"."+P(n))):((n=i+1)0&&(i+1===o&&(a+="."),a+=P(n))),a}function k(e,t){var r=e[0];for(t*=7;r>=10;r/=10)t++;return t}function R(e,t,r){if(t>A)throw h=!0,r&&(e.precision=r),Error(g);return D(new e(f),t,1,!0)}function F(e,t,r){if(t>O)throw Error(g);return D(new e(p),t,r,!0)}function U(e){var t=e.length-1,r=7*t+1;if(t=e[t]){for(;t%10==0;t/=10)r--;for(t=e[0];t>=10;t/=10)r++}return r}function P(e){for(var t="";e--;)t+="0";return t}function j(e,t,r,n){var i,a=new e(1),o=Math.ceil(n/7+4);for(h=!1;;){if(r%2&&K((a=a.times(t)).d,o)&&(i=!0),0===(r=x(r/2))){r=a.d.length-1,i&&0===a.d[r]&&++a.d[r];break}K((t=t.times(t)).d,o)}return h=!0,a}function L(e){return 1&e.d[e.d.length-1]}function H(e,t,r){for(var n,i=new e(t[0]),a=0;++a17)return new p(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(h=!1,u=d):u=t,s=new p(.03125);e.e>-2;)e=e.times(s),f+=5;for(u+=n=Math.log(b(2,f))/Math.LN10*2+5|0,r=a=o=new p(1),p.precision=u;;){if(a=D(a.times(e),u,1),r=r.times(++l),_((s=o.plus(z(a,r,u,1))).d).slice(0,u)===_(o.d).slice(0,u)){for(i=f;i--;)o=D(o.times(o),u,1);if(null!=t)return p.precision=d,o;if(!(c<3&&B(o.d,u-n,m,c)))return D(o,p.precision=d,m,h=!0);p.precision=u+=10,r=a=s=new p(1),l=0,c++}o=s}}function G(e,t){var r,n,i,a,o,s,u,c,l,f,p,m=1,d=e,y=d.d,g=d.constructor,v=g.rounding,x=g.precision;if(d.s<0||!y||!y[0]||!d.e&&1==y[0]&&1==y.length)return new g(y&&!y[0]?-1/0:1!=d.s?NaN:y?0:d);if(null==t?(h=!1,l=x):l=t,g.precision=l+=10,n=(r=_(y)).charAt(0),!(Math.abs(a=d.e)<15e14))return c=R(g,l+2,x).times(a+""),d=G(new g(n+"."+r.slice(1)),l-10).plus(c),g.precision=x,null==t?D(d,x,v,h=!0):d;for(;n<7&&1!=n||1==n&&r.charAt(1)>3;)n=(r=_((d=d.times(e)).d)).charAt(0),m++;for(a=d.e,n>1?(d=new g("0."+r),a++):d=new g(n+"."+r.slice(1)),f=d,u=o=d=z(d.minus(1),d.plus(1),l,1),p=D(d.times(d),l,1),i=3;;){if(o=D(o.times(p),l,1),_((c=u.plus(z(o,new g(i),l,1))).d).slice(0,l)===_(u.d).slice(0,l)){if(u=u.times(2),0!==a&&(u=u.plus(R(g,l+2,x).times(a+""))),u=z(u,new g(m),l,1),null!=t)return g.precision=x,u;if(!B(u.d,l-10,v,s))return D(u,g.precision=x,v,h=!0);g.precision=l+=10,c=o=d=z(f.minus(1),f.plus(1),l,1),p=D(d.times(d),l,1),i=s=1}u=c,i+=2}}function V(e){return String(e.s*e.s/0)}function Z(e,t){var r,n,i;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;48===t.charCodeAt(n);n++);for(i=t.length;48===t.charCodeAt(i-1);--i);if(t=t.slice(n,i)){if(i-=n,e.e=r=r-n-1,e.d=[],n=(r+1)%7,r<0&&(n+=7),ne.constructor.maxE?(e.d=null,e.e=NaN):e.e0?(c=+t.slice(o+1),t=t.substring(2,o)):t=t.slice(2),s=(o=t.indexOf("."))>=0,n=e.constructor,s&&(o=(u=(t=t.replace(".","")).length)-o,i=j(n,new n(r),o,2*o)),o=f=(l=q(t,r,E)).length-1;0===l[o];--o)l.pop();return o<0?new n(0*e.s):(e.e=k(l,f),e.d=l,h=!1,s&&(e=z(e,i,4*u)),c&&(e=e.times(Math.abs(c)<54?b(2,c):a.pow(2,c))),h=!0,e)}function J(e,t,r,n,i){var a,o,s,u,c=e.precision,l=Math.ceil(c/7);for(h=!1,u=r.times(r),s=new e(n);;){if(o=z(s.times(u),new e(t++*t++),c,1),s=i?n.plus(o):n.minus(o),n=z(o.times(u),new e(t++*t++),c,1),void 0!==(o=s.plus(n)).d[l]){for(a=l;o.d[a]===s.d[a]&&a--;);if(-1==a)break}a=s,s=n,n=o,o=a}return h=!0,o.d.length=l+1,o}function Y(e,t){for(var r=e;--t;)r*=e;return r}function X(e,t){var r,n=t.s<0,i=F(e,e.precision,1),a=i.times(.5);if((t=t.abs()).lte(a))return s=n?4:1,t;if((r=t.divToInt(i)).isZero())s=n?3:2;else{if((t=t.minus(r.times(i))).lte(a))return s=L(r)?n?2:3:n?4:1,t;s=L(r)?n?1:4:n?3:2}return t.minus(i).abs()}function Q(e,t,r,n){var i,a,s,u,f,p,m,h,d,y=e.constructor,g=void 0!==r;if(g?(T(r,1,c),void 0===n?n=y.rounding:T(n,0,8)):(r=y.precision,n=y.rounding),e.isFinite()){for(g?(i=2,16==t?r=4*r-3:8==t&&(r=3*r-2)):i=t,(s=(m=I(e)).indexOf("."))>=0&&(m=m.replace(".",""),(d=new y(1)).e=m.length-s,d.d=q(I(d),10,i),d.e=d.d.length),a=f=(h=q(m,10,i)).length;0==h[--f];)h.pop();if(h[0]){if(s<0?a--:((e=new y(e)).d=h,e.e=a,h=(e=z(e,d,r,n,0,i)).d,a=e.e,p=o),s=h[r],u=i/2,p=p||void 0!==h[r+1],p=n<4?(void 0!==s||p)&&(0===n||n===(e.s<0?3:2)):s>u||s===u&&(4===n||p||6===n&&1&h[r-1]||n===(e.s<0?8:7)),h.length=r,p)for(;++h[--r]>i-1;)h[r]=0,r||(++a,h.unshift(1));for(f=h.length;!h[f-1];--f);for(s=0,m="";s1)if(16==t||8==t){for(s=16==t?4:3,--f;f%s;f++)m+="0";for(f=(h=q(m,i,t)).length;!h[f-1];--f);for(s=1,m="1.";sf)for(a-=f;a--;)m+="0";else at)return e.length=t,!0}function ee(e){return new this(e).abs()}function te(e){return new this(e).acos()}function re(e){return new this(e).acosh()}function ne(e,t){return new this(e).plus(t)}function ie(e){return new this(e).asin()}function ae(e){return new this(e).asinh()}function oe(e){return new this(e).atan()}function se(e){return new this(e).atanh()}function ue(e,t){e=new this(e),t=new this(t);var r,n=this.precision,i=this.rounding,a=n+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(r=t.s<0?F(this,n,i):new this(0)).s=e.s:!e.d||t.isZero()?(r=F(this,a,1).times(.5)).s=e.s:t.s<0?(this.precision=a,this.rounding=1,r=this.atan(z(e,t,a,1)),t=F(this,a,1),this.precision=n,this.rounding=i,r=e.s<0?r.minus(t):r.plus(t)):r=this.atan(z(e,t,a,1)):(r=F(this,a,1).times(t.s>0?.25:.75)).s=e.s:r=new this(NaN),r}function ce(e){return new this(e).cbrt()}function le(e){return D(e=new this(e),e.e+1,2)}function fe(e){if(!e||"object"!=typeof e)throw Error(d+"Object expected");var t,r,n,i=!0===e.defaults,a=["precision",1,c,"rounding",0,8,"toExpNeg",-u,0,"toExpPos",0,u,"maxE",0,u,"minE",-u,0,"modulo",0,9];for(t=0;t=a[t+1]&&n<=a[t+2]))throw Error(y+r+": "+n);this[r]=n}if(r="crypto",i&&(this[r]=m[r]),void 0!==(n=e[r])){if(!0!==n&&!1!==n&&0!==n&&1!==n)throw Error(y+r+": "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(v);this[r]=!0}else this[r]=!1}return this}function pe(e){return new this(e).cos()}function me(e){return new this(e).cosh()}function he(e,t){return new this(e).div(t)}function de(e){return new this(e).exp()}function ye(e){return D(e=new this(e),e.e+1,3)}function ge(){var e,t,r=new this(0);for(h=!1,e=0;e=429e7?t[a]=crypto.getRandomValues(new Uint32Array(1))[0]:s[a++]=i%1e7;else{if(!crypto.randomBytes)throw Error(v);for(t=crypto.randomBytes(n*=4);a=214e7?crypto.randomBytes(4).copy(t,a):(s.push(i%1e7),a+=4);a=n/4}else for(;a=10;i/=10)n++;n<7&&(r-=7-n)}return o.e=r,o.d=s,o}function _e(e){return D(e=new this(e),e.e+1,this.rounding)}function Te(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function Be(e){return new this(e).sin()}function qe(e){return new this(e).sinh()}function ze(e){return new this(e).sqrt()}function De(e,t){return new this(e).sub(t)}function Ie(e){return new this(e).tan()}function ke(e){return new this(e).tanh()}function Re(e){return D(e=new this(e),e.e+1,1)}(a=function e(t){var r,n,i;function a(e){var t,r,n,i=this;if(!(i instanceof a))return new a(e);if(i.constructor=a,e instanceof a)return i.s=e.s,void(h?!e.d||e.e>a.maxE?(i.e=NaN,i.d=null):e.e=10;r/=10)t++;return void(h?t>a.maxE?(i.e=NaN,i.d=null):t{"use strict";var t=Object.assign||function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{},o=a.preserveFormatting,s=void 0!==o&&o,u=a.escapeMapFn,c=void 0===u?i:u,l=String(e),f="",p=c(t({},r),s?t({},n):{}),m=Object.keys(p),h=function(){var e=!1;m.forEach((function(t,r){e||l.length>=t.length&&l.slice(0,t.length)===t&&(f+=p[m[r]],l=l.slice(t.length,l.length),e=!0)})),e||(f+=l.slice(0,1),l=l.slice(1,l.length))};l;)h();return f}},628:function(e,t){var r;!function(n){"use strict";var i={s:1,n:0,d:1};function a(e){function t(){var t=Error.apply(this,arguments);t.name=this.name=e,this.stack=t.stack,this.message=t.message}function r(){}return r.prototype=Error.prototype,t.prototype=new r,t}var o=m.DivisionByZero=a("DivisionByZero"),s=m.InvalidParameter=a("InvalidParameter");function u(e,t){return isNaN(e=parseInt(e,10))&&c(),e*t}function c(){throw new s}function l(e){for(var t={},r=e,n=2,i=4;i<=r;){for(;r%n==0;)r/=n,t[n]=(t[n]||0)+1;i+=1+2*n++}return r!==e?r>1&&(t[r]=(t[r]||0)+1):t[e]=(t[e]||0)+1,t}var f=function(e,t){var r,n=0,a=1,s=1,l=0,f=0,p=0,m=1,h=1,d=0,y=1,g=1,v=1,x=1e7;if(null==e);else if(void 0!==t)s=(n=e)*(a=t);else switch(typeof e){case"object":"d"in e&&"n"in e?(n=e.n,a=e.d,"s"in e&&(n*=e.s)):0 in e?(n=e[0],1 in e&&(a=e[1])):c(),s=n*a;break;case"number":if(e<0&&(s=e,e=-e),e%1==0)n=e;else if(e>0){for(e>=1&&(e/=h=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)));y<=x&&v<=x;){if(e===(r=(d+g)/(y+v))){y+v<=x?(n=d+g,a=y+v):v>y?(n=g,a=v):(n=d,a=y);break}e>r?(d+=g,y+=v):(g+=d,v+=y),y>x?(n=g,a=v):(n=d,a=y)}n*=h}else(isNaN(e)||isNaN(t))&&(a=n=NaN);break;case"string":if(null===(y=e.match(/\d+|./g))&&c(),"-"===y[d]?(s=-1,d++):"+"===y[d]&&d++,y.length===d+1?f=u(y[d++],s):"."===y[d+1]||"."===y[d]?("."!==y[d]&&(l=u(y[d++],s)),(1+ ++d===y.length||"("===y[d+1]&&")"===y[d+3]||"'"===y[d+1]&&"'"===y[d+3])&&(f=u(y[d],s),m=Math.pow(10,y[d].length),d++),("("===y[d]&&")"===y[d+2]||"'"===y[d]&&"'"===y[d+2])&&(p=u(y[d+1],s),h=Math.pow(10,y[d+1].length)-1,d+=3)):"/"===y[d+1]||":"===y[d+1]?(f=u(y[d],s),m=u(y[d+2],1),d+=3):"/"===y[d+3]&&" "===y[d+1]&&(l=u(y[d],s),f=u(y[d+2],s),m=u(y[d+4],1),d+=5),y.length<=d){s=n=p+(a=m*h)*l+h*f;break}default:c()}if(0===a)throw new o;i.s=s<0?-1:1,i.n=Math.abs(n),i.d=Math.abs(a)};function p(e,t){if(!e)return t;if(!t)return e;for(;;){if(!(e%=t))return t;if(!(t%=e))return e}}function m(e,t){if(!(this instanceof m))return new m(e,t);f(e,t),e=m.REDUCE?p(i.d,i.n):1,this.s=i.s,this.n=i.n/e,this.d=i.d/e}m.REDUCE=1,m.prototype={s:1,n:0,d:1,abs:function(){return new m(this.n,this.d)},neg:function(){return new m(-this.s*this.n,this.d)},add:function(e,t){return f(e,t),new m(this.s*this.n*i.d+i.s*this.d*i.n,this.d*i.d)},sub:function(e,t){return f(e,t),new m(this.s*this.n*i.d-i.s*this.d*i.n,this.d*i.d)},mul:function(e,t){return f(e,t),new m(this.s*i.s*this.n*i.n,this.d*i.d)},div:function(e,t){return f(e,t),new m(this.s*i.s*this.n*i.d,this.d*i.n)},clone:function(){return new m(this)},mod:function(e,t){return isNaN(this.n)||isNaN(this.d)?new m(NaN):void 0===e?new m(this.s*this.n%this.d,1):(f(e,t),0===i.n&&0===this.d&&m(0,0),new m(this.s*(i.d*this.n)%(i.n*this.d),i.d*this.d))},gcd:function(e,t){return f(e,t),new m(p(i.n,this.n)*p(i.d,this.d),i.d*this.d)},lcm:function(e,t){return f(e,t),0===i.n&&0===this.n?new m:new m(i.n*this.n,p(i.n,this.n)*p(i.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.round(e*this.s*this.n/this.d),e)},inverse:function(){return new m(this.s*this.d,this.n)},pow:function(e,t){if(f(e,t),1===i.d)return i.s<0?new m(Math.pow(this.s*this.d,i.n),Math.pow(this.n,i.n)):new m(Math.pow(this.s*this.n,i.n),Math.pow(this.d,i.n));if(this.s<0)return null;var r=l(this.n),n=l(this.d),a=1,o=1;for(var s in r)if("1"!==s){if("0"===s){a=0;break}if(r[s]*=i.n,r[s]%i.d!=0)return null;r[s]/=i.d,a*=Math.pow(s,r[s])}for(var s in n)if("1"!==s){if(n[s]*=i.n,n[s]%i.d!=0)return null;n[s]/=i.d,o*=Math.pow(s,n[s])}return i.s<0?new m(o,a):new m(a,o)},equals:function(e,t){return f(e,t),this.s*this.n*i.d==i.s*i.n*this.d},compare:function(e,t){f(e,t);var r=this.s*this.n*i.d-i.s*i.n*this.d;return(00&&(r+=t,r+=" ",n%=i),r+=n,r+="/",r+=i),r},toLatex:function(e){var t,r="",n=this.n,i=this.d;return this.s<0&&(r+="-"),1===i?r+=n:(e&&(t=Math.floor(n/i))>0&&(r+=t,n%=i),r+="\\frac{",r+=n,r+="}{",r+=i,r+="}"),r},toContinued:function(){var e,t=this.n,r=this.d,n=[];if(isNaN(t)||isNaN(r))return n;do{n.push(Math.floor(t/r)),e=t%r,t=r,r=e}while(1!==t);return n},toString:function(e){var t,r=this.n,n=this.d;if(isNaN(r)||isNaN(n))return"NaN";m.REDUCE||(r/=t=p(r,n),n/=t),e=e||15;var i=function(e,t){for(;t%2==0;t/=2);for(;t%5==0;t/=5);if(1===t)return 0;for(var r=10%t,n=1;1!==r;n++)if(r=10*r%t,n>2e3)return 0;return n}(0,n),a=function(e,t,r){for(var n=1,i=function(e,t,r){for(var n=1;t>0;e=e*e%r,t>>=1)1&t&&(n=n*e%r);return n}(10,r,t),a=0;a<300;a++){if(n===i)return a;n=10*n%t,i=10*i%t}return 0}(0,n,i),o=-1===this.s?"-":"";if(o+=r/n|0,r%=n,(r*=10)&&(o+="."),i){for(var s=a;s--;)o+=r/n|0,r%=n,r*=10;for(o+="(",s=i;s--;)o+=r/n|0,r%=n,r*=10;o+=")"}else for(s=e;r&&s--;)o+=r/n|0,r%=n,r*=10;return o}},void 0===(r=function(){return m}.apply(t,[]))||(e.exports=r)}()},228:e=>{e.exports=function e(t,r){"use strict";var n,i,a=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,o=/(^[ ]*|[ ]*$)/g,s=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,u=/^0x[0-9a-f]+$/i,c=/^0/,l=function(t){return e.insensitive&&(""+t).toLowerCase()||""+t},f=l(t).replace(o,"")||"",p=l(r).replace(o,"")||"",m=f.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),h=p.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),d=parseInt(f.match(u),16)||1!==m.length&&f.match(s)&&Date.parse(f),y=parseInt(p.match(u),16)||d&&p.match(s)&&Date.parse(p)||null;if(y){if(dy)return 1}for(var g=0,v=Math.max(m.length,h.length);gi)return 1}return 0}},377:(e,t,r)=>{var n=r(832),i=r(652),a=r(801),o=r(30),s=r(618),u=r(49),c=r(971);c.alea=n,c.xor128=i,c.xorwow=a,c.xorshift7=o,c.xor4096=s,c.tychei=u,e.exports=c},832:function(e,t,r){var n;!function(e,i,a){function o(e){var t,r=this,n=(t=4022871197,function(e){e=String(e);for(var r=0;r>>0,t=(n*=t)>>>0,t+=4294967296*(n-=t)}return 2.3283064365386963e-10*(t>>>0)});r.next=function(){var e=2091639*r.s0+2.3283064365386963e-10*r.c;return r.s0=r.s1,r.s1=r.s2,r.s2=e-(r.c=0|e)},r.c=1,r.s0=n(" "),r.s1=n(" "),r.s2=n(" "),r.s0-=n(e),r.s0<0&&(r.s0+=1),r.s1-=n(e),r.s1<0&&(r.s1+=1),r.s2-=n(e),r.s2<0&&(r.s2+=1),n=null}function s(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function u(e,t){var r=new o(e),n=t&&t.state,i=r.next;return i.int32=function(){return 4294967296*r.next()|0},i.double=function(){return i()+11102230246251565e-32*(2097152*i()|0)},i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.alea=u}(0,e=r.nmd(e),r.amdD)},49:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.next=function(){var e=t.b,r=t.c,n=t.d,i=t.a;return e=e<<25^e>>>7^r,r=r-n|0,n=n<<24^n>>>8^i,i=i-e|0,t.b=e=e<<20^e>>>12^r,t.c=r=r-n|0,t.d=n<<16^r>>>16^i,t.a=i-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):r+=e;for(var n=0;n>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.tychei=u}(0,e=r.nmd(e),r.amdD)},652:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:r+=e;for(var n=0;n>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xor128=u}(0,e=r.nmd(e),r.amdD)},618:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this;t.next=function(){var e,r,n=t.w,i=t.X,a=t.i;return t.w=n=n+1640531527|0,r=i[a+34&127],e=i[a=a+1&127],r^=r<<13,e^=e<<17,r^=r>>>15,e^=e>>>12,r=i[a]=r^e,t.i=a,r+(n^n>>>16)|0},function(e,t){var r,n,i,a,o,s=[],u=128;for(t===(0|t)?(n=t,t=null):(t+="\0",n=0,u=Math.max(u,t.length)),i=0,a=-32;a>>15,n^=n<<4,n^=n>>>13,a>=0&&(o=o+1640531527|0,i=0==(r=s[127&a]^=n+o)?i+1:0);for(i>=128&&(s[127&(t&&t.length||0)]=-1),i=127,a=512;a>0;--a)n=s[i+34&127],r=s[i=i+1&127],n^=n<<13,r^=r<<17,n^=n>>>15,r^=r>>>12,s[i]=n^r;e.w=o,e.X=s,e.i=i}(t,e)}function s(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function u(e,t){null==e&&(e=+new Date);var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&(n.X&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xor4096=u}(0,e=r.nmd(e),r.amdD)},30:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this;t.next=function(){var e,r,n=t.x,i=t.i;return e=n[i],r=(e^=e>>>7)^e<<24,r^=(e=n[i+1&7])^e>>>10,r^=(e=n[i+3&7])^e>>>3,r^=(e=n[i+4&7])^e<<7,e=n[i+7&7],r^=(e^=e<<13)^e<<9,n[i]=r,t.i=i+1&7,r},function(e,t){var r,n=[];if(t===(0|t))n[0]=t;else for(t=""+t,r=0;r0;--r)e.next()}(t,e)}function s(e,t){return t.x=e.x.slice(),t.i=e.i,t}function u(e,t){null==e&&(e=+new Date);var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&(n.x&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xorshift7=u}(0,e=r.nmd(e),r.amdD)},801:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:r+=e;for(var n=0;n>>4),t.next()}function s(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function u(e,t){var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xorwow=u}(0,e=r.nmd(e),r.amdD)},971:function(e,t,r){var n;!function(i,a,o){var s,u=256,c=o.pow(u,6),l=o.pow(2,52),f=2*l,p=255;function m(e,t,r){var n=[],p=g(y((t=1==t?{entropy:!0}:t||{}).entropy?[e,v(a)]:null==e?function(){try{var e;return s&&(e=s.randomBytes)?e=e(u):(e=new Uint8Array(u),(i.crypto||i.msCrypto).getRandomValues(e)),v(e)}catch(e){var t=i.navigator,r=t&&t.plugins;return[+new Date,i,r,i.screen,v(a)]}}():e,3),n),m=new h(n),x=function(){for(var e=m.g(6),t=c,r=0;e=f;)e/=2,t/=2,r>>>=1;return(e+r)/t};return x.int32=function(){return 0|m.g(4)},x.quick=function(){return m.g(4)/4294967296},x.double=x,g(v(m.S),a),(t.pass||r||function(e,t,r,n){return n&&(n.S&&d(n,m),e.state=function(){return d(m,{})}),r?(o.random=e,t):e})(x,p,"global"in t?t.global:this==o,t.state)}function h(e){var t,r=e.length,n=this,i=0,a=n.i=n.j=0,o=n.S=[];for(r||(e=[r++]);i3?e.slice(3):"any":e).split("|").map(q).filter(z).filter(B),i=function(e,t){var r={};return e.forEach((function(e){-1!==t.indexOf(e.from)||-1===t.indexOf(e.to)||r[e.from]||(r[e.from]=e)})),Object.keys(r).map((function(e){return r[e]}))}(t,n),a=n.map((function(e){var t=c(e);return{name:e,typeIndex:l(t),test:t.test,conversion:null,conversionIndex:-1}})),o=i.map((function(e){var r=c(e.from);return{name:e.from,typeIndex:l(r),test:r.test,conversion:e,conversionIndex:t.indexOf(e)}}));return{types:a.concat(o),restParam:r}}function h(e){var t=k(e);return!!t&&t.restParam}function d(e){return e.types.some((function(e){return null!=e.conversion}))}function y(t){if(t&&0!==t.types.length){if(1===t.types.length)return c(t.types[0].name).test;if(2===t.types.length){var r=c(t.types[0].name).test,n=c(t.types[1].name).test;return function(e){return r(e)||n(e)}}var i=t.types.map((function(e){return c(e.name).test}));return function(e){for(var t=0;t=a+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(r=y(e[0]),function(e){return r(e[0])&&1===e.length}):2===e.length?(r=y(e[0]),n=y(e[1]),function(e){return r(e[0])&&n(e[1])&&2===e.length}):(t=e.map(y),function(e){for(var r=0;r0){var c=f(t[a]);return(n=new TypeError("Unexpected type of argument in function "+o+" (expected: "+i.join(" or ")+", actual: "+c+", index: "+a+")")).data={category:"wrongType",fn:o,index:a,actual:c,expected:i},n}}else s=u}var l=s.map((function(e){return h(e.params)?1/0:e.params.length}));if(t.lengthp?((n=new TypeError("Too many arguments in function "+o+" (expected: "+p+", actual: "+t.length+")")).data={category:"tooManyArgs",fn:o,index:t.length,expectedLength:p},n):((n=new TypeError('Arguments of type "'+t.join(", ")+'" do not match any of the defined signatures of function '+o+".")).data={category:"mismatch",actual:t.map(f)},n)}function S(e){for(var t=999,r=0;r=i:s?i>=a:i===a}(t,e)}));if(t)throw new TypeError('Conflicting signatures "'+p(t.params)+'" and "'+p(e.params)+'".');i.push(e)}));var a=P(i,(function(e){return(e?_(e.params,!1):[]).map((function(t){return{params:t,fn:e.fn}}))})).filter(D);a.sort(O);var o=a[0]&&a[0].params.length<=2&&!h(a[0].params),s=a[1]&&a[1].params.length<=2&&!h(a[1].params),c=a[2]&&a[2].params.length<=2&&!h(a[2].params),l=a[3]&&a[3].params.length<=2&&!h(a[3].params),f=a[4]&&a[4].params.length<=2&&!h(a[4].params),v=a[5]&&a[5].params.length<=2&&!h(a[5].params),b=o&&s&&c&&l&&f&&v,w=a.map((function(e){return g(e.params)})),N=o?y(a[0].params[0]):t,S=s?y(a[1].params[0]):t,E=c?y(a[2].params[0]):t,A=l?y(a[3].params[0]):t,T=f?y(a[4].params[0]):t,B=v?y(a[5].params[0]):t,z=o?y(a[0].params[1]):t,k=s?y(a[1].params[1]):t,j=c?y(a[2].params[1]):t,L=l?y(a[3].params[1]):t,H=f?y(a[4].params[1]):t,$=v?y(a[5].params[1]):t,G=a.map((function(e){return function(e,t){var r=t;if(e.some(d)){var n=h(e),i=e.map(C);r=function(){for(var e=[],r=n?arguments.length-1:arguments.length,a=0;a{}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var a=t[n]={id:n,loaded:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.loaded=!0,a.exports}r.amdD=function(){throw new Error("define cannot be used indirect")},r.amdO={},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";function e(){return(e=Object.assign||function(e){for(var t=1;t!function(e){return e&&"?"===e[0]}(e))).every((e=>void 0!==r[e]))){var n=t.filter((e=>void 0===r[e]));throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(n.map((e=>'"'.concat(e,'"'))).join(", "),"."))}}(e,t,n),r(i)}return i.isFactory=!0,i.fn=e,i.dependencies=t.slice().sort(),n&&(i.meta=n),i}function J(e){return e&&"?"===e[0]?e.slice(1):e}function Y(e,t){if(ee(e)&&Q(e,t))return e[t];if("function"==typeof e[t]&&K(e,t))throw new Error('Cannot access method "'+t+'" as a property');throw new Error('No access to property "'+t+'"')}function X(e,t,r){if(ee(e)&&Q(e,t))return e[t]=r,r;throw new Error('No access to property "'+t+'"')}function Q(e,t){return!(!e||"object"!=typeof e||!Z(te,t)&&(t in Object.prototype||t in Function.prototype))}function K(e,t){return!(null==e||"function"!=typeof e[t]||Z(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e)||!Z(re,t)&&(t in Object.prototype||t in Function.prototype))}function ee(e){return"object"==typeof e&&e&&e.constructor===Object}var te={length:!0,name:!0},re={toString:!0,valueOf:!0,toLocaleString:!0};class ne{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return Y(this.wrappedObject,e)}set(e,t){return X(this.wrappedObject,e,t),this}has(e){return e in this.wrappedObject}}function ie(){return new Map}function ae(e){if(!e)return ie();if(oe(e))return e;if(M(e))return new ne(e);throw new Error("createMap can create maps from objects or Maps")}function oe(e){return!!e&&(e instanceof Map||e instanceof ne||"function"==typeof e.set&&"function"==typeof e.get&&"function"==typeof e.keys&&"function"==typeof e.has)}function se(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{var{mathWithTransform:t}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator")}return r.prototype.evaluate=function(e){return this.compile().evaluate(e)},r.prototype.type="Node",r.prototype.isNode=!0,r.prototype.comment="",r.prototype.compile=function(){var e=this._compile(t,{}),r={};return{evaluate:function(t){var n=ae(t);return function(e){for(var t of[...H])if(e.has(t))throw new Error('Scope contains an illegal symbol, "'+t+'" is a reserved keyword')}(n),e(n,r,null)}}},r.prototype._compile=function(e,t){throw new Error("Method _compile should be implemented by type "+this.type)},r.prototype.forEach=function(e){throw new Error("Cannot run forEach on a Node interface")},r.prototype.map=function(e){throw new Error("Cannot run map on a Node interface")},r.prototype._ifNode=function(e){if(!I(e))throw new TypeError("Callback function must return a Node");return e},r.prototype.traverse=function(e){e(this,null,null),function e(t,r){t.forEach((function(t,n,i){r(t,n,i),e(t,r)}))}(this,e)},r.prototype.transform=function(e){return function t(r,n,i){var a=e(r,n,i);return a!==r?a:r.map(t)}(this,null,null)},r.prototype.filter=function(e){var t=[];return this.traverse((function(r,n,i){e(r,n,i)&&t.push(r)})),t},r.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},r.prototype.cloneDeep=function(){return this.map((function(e){return e.cloneDeep()}))},r.prototype.equals=function(e){return!!e&&V(this,e)},r.prototype.toString=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toString(e)},r.prototype.toJSON=function(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)},r.prototype.toHTML=function(e){var t=this._getCustomString(e);return void 0!==t?t:this.toHTML(e)},r.prototype._toString=function(){throw new Error("_toString not implemented for "+this.type)},r.prototype.toTex=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toTex(e)},r.prototype._toTex=function(e){throw new Error("_toTex not implemented for "+this.type)},r.prototype._getCustomString=function(e){if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":return;case"function":return e.handler(this,e);default:throw new TypeError("Object or function expected as callback")}},r.prototype.getIdentifier=function(){return this.type},r.prototype.getContent=function(){return this},r}),{isClass:!0,isNode:!0});function ce(e){return"boolean"==typeof e||!!isFinite(e)&&e===Math.round(e)}var le=Math.sign||function(e){return e>0?1:e<0?-1:0},fe=Math.log2||function(e){return Math.log(e)/Math.LN2},pe=Math.log10||function(e){return Math.log(e)/Math.LN10},me=Math.log1p||function(e){return Math.log(e+1)},he=Math.cbrt||function(e){if(0===e)return e;var t,r=e<0;return r&&(e=-e),t=isFinite(e)?(e/((t=Math.exp(Math.log(e)/3))*t)+2*t)/3:e,r?-t:t},de=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function ye(e,t,r){var n={2:"0b",8:"0o",16:"0x"}[t],i="";if(r){if(r<1)throw new Error("size must be in greater than 0");if(!ce(r))throw new Error("size must be an integer");if(e>2**(r-1)-1||e<-(2**(r-1)))throw new Error("Value must be in range [-2^".concat(r-1,", 2^").concat(r-1,"-1]"));if(!ce(e))throw new Error("Value must be an integer");e<0&&(e+=2**r),i="i".concat(r)}var a="";return e<0&&(e=-e,a="-"),"".concat(a).concat(n).concat(e.toString(t)).concat(i)}function ge(e,t){if("function"==typeof t)return t(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var r,n,a="auto";if(t&&(t.notation&&(a=t.notation),i(t)?r=t:i(t.precision)&&(r=t.precision),t.wordSize&&"number"!=typeof(n=t.wordSize)))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return xe(e,r);case"exponential":return be(e,r);case"engineering":return function(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=we(ve(e),t),n=r.exponent,a=r.coefficients,o=n%3==0?n:n<0?n-3-n%3:n-n%3;if(i(t))for(;t>a.length||n-o+1>a.length;)a.push(0);else for(var s=Math.abs(n-o)-(a.length-1),u=0;u0;)l++,c--;var f=a.slice(l).join(""),p=i(t)&&f.length||f.match(/[1-9]/)?"."+f:"",m=a.slice(0,l).join("")+p+"e"+(n>=0?"+":"")+o.toString();return r.sign+m}(e,r);case"bin":return ye(e,2,n);case"oct":return ye(e,8,n);case"hex":return ye(e,16,n);case"auto":return function(e,t,r){if(isNaN(e)||!isFinite(e))return String(e);var n=r&&void 0!==r.lowerExp?r.lowerExp:-3,i=r&&void 0!==r.upperExp?r.upperExp:5,a=ve(e),o=t?we(a,t):a;if(o.exponent=i)return be(e,t);var s=o.coefficients,u=o.exponent;s.length0?u:0;return c<(s=Ne(-u).concat(s)).length-1&&s.splice(c+1,0,"."),o.sign+s.join("")}(e,r,t&&t).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t}));default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function ve(e){var t=String(e).toLowerCase().match(/^0*?(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+e);var r=t[1],n=t[2],i=parseFloat(t[4]||"0"),a=n.indexOf(".");i+=-1!==a?a-1:n.length-1;var o=n.replace(".","").replace(/^0*/,(function(e){return i-=e.length,""})).replace(/0*$/,"").split("").map((function(e){return parseInt(e)}));return 0===o.length&&(o.push(0),i++),{sign:r,coefficients:o,exponent:i}}function xe(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=ve(e),n="number"==typeof t?we(r,r.exponent+1+t):r,i=n.coefficients,a=n.exponent+1,o=a+(t||0);return i.length0?"."+i.join(""):"")+"e"+(a>=0?"+":"")+a}function we(e,t){for(var r={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},n=r.coefficients;t<=0;)n.unshift(0),r.exponent++,t++;if(n.length>t&&n.splice(t,n.length-t)[0]>=5){var i=t-1;for(n[i]++;10===n[i];)n.pop(),0===i&&(n.unshift(0),r.exponent++,i++),n[--i]++}return r}function Ne(e){for(var t=[],r=0;r=0?"+":"")+n.toString()}(e,r);case"bin":return Be(e,2,n);case"oct":return Be(e,8,n);case"hex":return Be(e,16,n);case"auto":var a=t&&void 0!==t.lowerExp?t.lowerExp:-3,o=t&&void 0!==t.upperExp?t.upperExp:5;if(e.isZero())return"0";var s=e.toSignificantDigits(r),u=s.e;return(u>=a&&u'"'+r+'": '+De(e[r],t))).join(", ")+"}":String(e)}function Ie(e){for(var t=String(e),r="",n=0;n/g,">")}function Re(e,t){if(Array.isArray(e)){for(var r="[",n=e.length,i=0;it?1:-1}function Ue(e,t,r){if(!(this instanceof Ue))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=t,this.relation=r,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=(new Error).stack}function Pe(e,t,r){if(!(this instanceof Pe))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=r),void 0!==this.min&&this.index=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}function je(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function Le(e,t,r){var n,i=e.length;if(i!==t[r])throw new Ue(i,t[r]);if(r")}function He(e,t){if(0===t.length){if(Array.isArray(e))throw new Ue(e.length,0)}else Le(e,t,0)}function $e(e,t){if(!i(e)||!ce(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&e>=t)throw new Pe(e,t)}function Ge(e,t,r){if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");return t.forEach((function(e){if(!i(e)||!ce(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+De(t)+")")})),Ve(e,t,0,void 0!==r?r:0),e}function Ve(e,t,r,n){var i,a,o=e.length,s=t[r],u=Math.min(o,s);if(e.length=s,r=0){if(t%r!=0)throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-r);n[i]=-t/r}return n}function Je(e){return e.reduce(((e,t)=>e*t),1)}function Ye(e,t){for(var r=t||je(e);Array.isArray(e)&&1===e.length;)e=e[0],r.shift();for(var n=r.length;1===r[n-1];)n--;return nt.test(e)))}function at(e,t){return Array.prototype.join.call(e,t)}function ot(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;var t=[],r=0;t[0]={value:e[0],identifier:0};for(var n=1;n{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=e||[],!Array.isArray(this.items)||!this.items.every(I))throw new TypeError("Array containing Nodes expected")}return r.prototype=new t,r.prototype.type="ArrayNode",r.prototype.isArrayNode=!0,r.prototype._compile=function(e,t){var r=tt(this.items,(function(r){return r._compile(e,t)}));if("Array"!==e.config.matrix){var n=e.matrix;return function(e,t,i){return n(tt(r,(function(r){return r(e,t,i)})))}}return function(e,t,n){return tt(r,(function(r){return r(e,t,n)}))}},r.prototype.forEach=function(e){for(var t=0;t['+this.items.map((function(t){return t.toHTML(e)})).join(',')+']'},r.prototype._toTex=function(e){var t="\\begin{bmatrix}";return this.items.forEach((function(r){r.items?t+=r.items.map((function(t){return t.toTex(e)})).join("&"):t+=r.toTex(e),t+="\\\\"})),t+="\\end{bmatrix}"},r}),{isClass:!0,isNode:!0}),lt=W("BlockNode",["ResultSet","Node"],(e=>{var{ResultSet:t,Node:r}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map((function(e){var t=e&&e.node,r=!e||void 0===e.visible||e.visible;if(!I(t))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof r)throw new TypeError('Property "visible" must be a boolean');return{node:t,visible:r}}))}return n.prototype=new r,n.prototype.type="BlockNode",n.prototype.isBlockNode=!0,n.prototype._compile=function(e,r){var n=tt(this.blocks,(function(t){return{evaluate:t.node._compile(e,r),visible:t.visible}}));return function(e,r,i){var a=[];return rt(n,(function(t){var n=t.evaluate(e,r,i);t.visible&&a.push(n)})),new t(a)}},n.prototype.forEach=function(e){for(var t=0;t;')})).join('
')},n.prototype._toTex=function(e){return this.blocks.map((function(t){return t.node.toTex(e)+(t.visible?"":";")})).join("\\;\\;\n")},n}),{isClass:!0,isNode:!0}),ft=r(928),pt={Alpha:"A",alpha:"\\alpha",Beta:"B",beta:"\\beta",Gamma:"\\Gamma",gamma:"\\gamma",Delta:"\\Delta",delta:"\\delta",Epsilon:"E",epsilon:"\\epsilon",varepsilon:"\\varepsilon",Zeta:"Z",zeta:"\\zeta",Eta:"H",eta:"\\eta",Theta:"\\Theta",theta:"\\theta",vartheta:"\\vartheta",Iota:"I",iota:"\\iota",Kappa:"K",kappa:"\\kappa",varkappa:"\\varkappa",Lambda:"\\Lambda",lambda:"\\lambda",Mu:"M",mu:"\\mu",Nu:"N",nu:"\\nu",Xi:"\\Xi",xi:"\\xi",Omicron:"O",omicron:"o",Pi:"\\Pi",pi:"\\pi",varpi:"\\varpi",Rho:"P",rho:"\\rho",varrho:"\\varrho",Sigma:"\\Sigma",sigma:"\\sigma",varsigma:"\\varsigma",Tau:"T",tau:"\\tau",Upsilon:"\\Upsilon",upsilon:"\\upsilon",Phi:"\\Phi",phi:"\\phi",varphi:"\\varphi",Chi:"X",chi:"\\chi",Psi:"\\Psi",psi:"\\psi",Omega:"\\Omega",omega:"\\omega",true:"\\mathrm{True}",false:"\\mathrm{False}",i:"i",inf:"\\infty",Inf:"\\infty",infinity:"\\infty",Infinity:"\\infty",oo:"\\infty",lim:"\\lim",undefined:"\\mathbf{?}"},mt={transpose:"^\\top",ctranspose:"^H",factorial:"!",pow:"^",dotPow:".^\\wedge",unaryPlus:"+",unaryMinus:"-",bitNot:"\\~",not:"\\neg",multiply:"\\cdot",divide:"\\frac",dotMultiply:".\\cdot",dotDivide:".:",mod:"\\mod",add:"+",subtract:"-",to:"\\rightarrow",leftShift:"<<",rightArithShift:">>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},ht={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(mt.add,"${args[1]}\\right)")},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:"\\left(${args[0]}".concat(mt.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(mt.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(mt.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(mt.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:"\\left(${args[0]}".concat(mt.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(mt.multiply,"${args[1]}\\right)")},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : $y^{args[1]} = {${args[0]}}\\}"},pow:{2:"\\left(${args[0]}\\right)".concat(mt.pow,"{${args[1]}}")},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:"\\left(${args[0]}".concat(mt.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(mt.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(mt.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(mt.bitAnd,"${args[1]}\\right)")},bitNot:{1:mt.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(mt.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(mt.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(mt.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(mt.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(mt.rightLogShift,"${args[1]}\\right)")},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:"\\left(${args[0]}".concat(mt.and,"${args[1]}\\right)")},not:{1:mt.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(mt.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(mt.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(mt.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},sqrtm:{1:"{${args[0]}}".concat(mt.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(mt.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(mt.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(mt.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(mt.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(mt.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(mt.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(mt.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(mt.unequal,"${args[1]}\\right)")},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:"\\left(${args[0]}".concat(mt.to,"${args[1]}\\right)")},numeric:function(e,t){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(pt.i,"\\cdot\\left(${args[1]}\\right)\\right)")},matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},dt={deg:"^\\circ"};function yt(e){return ft(e,{preserveFormatting:!0})}function gt(e,t){return(t=void 0!==t&&t)?Z(dt,e)?dt[e]:"\\mathrm{"+yt(e)+"}":Z(pt,e)?pt[e]:yt(e)}var vt=W("ConstantNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this.value=e}return r.prototype=new t,r.prototype.type="ConstantNode",r.prototype.isConstantNode=!0,r.prototype._compile=function(e,t){var r=this.value;return function(){return r}},r.prototype.forEach=function(e){},r.prototype.map=function(e){return this.clone()},r.prototype.clone=function(){return new r(this.value)},r.prototype._toString=function(e){return De(this.value,e)},r.prototype.toHTML=function(e){var t=this._toString(e);switch(L(this.value)){case"number":case"BigNumber":case"Fraction":return''+t+"";case"string":return''+t+"";case"boolean":return''+t+"";case"null":return''+t+"";case"undefined":return''+t+"";default:return''+t+""}},r.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},r.fromJSON=function(e){return new r(e.value)},r.prototype._toTex=function(e){var t=this._toString(e);switch(L(this.value)){case"string":return"\\mathtt{"+yt(t)+"}";case"number":case"BigNumber":if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var r=t.toLowerCase().indexOf("e");return-1!==r?t.substring(0,r)+"\\cdot10^{"+t.substring(r+1)+"}":t;case"Fraction":return this.value.toLatex();default:return t}},r}),{isClass:!0,isNode:!0}),xt=W("ObjectNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=e||{},e&&("object"!=typeof e||!Object.keys(e).every((function(t){return I(e[t])}))))throw new TypeError("Object containing Nodes expected")}return r.prototype=new t,r.prototype.type="ObjectNode",r.prototype.isObjectNode=!0,r.prototype._compile=function(e,t){var r={};for(var n in this.properties)if(Z(this.properties,n)){var i=Ie(n),a=JSON.parse(i);if(!Q(this.properties,a))throw new Error('No access to property "'+a+'"');r[a]=this.properties[n]._compile(e,t)}return function(e,t,n){var i={};for(var a in r)Z(r,a)&&(i[a]=r[a](e,t,n));return i}},r.prototype.forEach=function(e){for(var t in this.properties)Z(this.properties,t)&&e(this.properties[t],"properties["+Ie(t)+"]",this)},r.prototype.map=function(e){var t={};for(var n in this.properties)Z(this.properties,n)&&(t[n]=this._ifNode(e(this.properties[n],"properties["+Ie(n)+"]",this)));return new r(t)},r.prototype.clone=function(){var e={};for(var t in this.properties)Z(this.properties,t)&&(e[t]=this.properties[t]);return new r(e)},r.prototype._toString=function(e){var t=[];for(var r in this.properties)Z(this.properties,r)&&t.push(Ie(r)+": "+this.properties[r].toString(e));return"{"+t.join(", ")+"}"},r.prototype.toJSON=function(){return{mathjs:"ObjectNode",properties:this.properties}},r.fromJSON=function(e){return new r(e.properties)},r.prototype.toHTML=function(e){var t=[];for(var r in this.properties)Z(this.properties,r)&&t.push(''+ke(r)+':'+this.properties[r].toHTML(e));return'{'+t.join(',')+'}'},r.prototype._toTex=function(e){var t=[];for(var r in this.properties)Z(this.properties,r)&&t.push("\\mathbf{"+r+":} & "+this.properties[r].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(t.join("\n"),"\\end{array}\\right\\}")},r}),{isClass:!0,isNode:!0}),bt=W("ParenthesisNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError('Node expected for parameter "content"');this.content=e}return r.prototype=new t,r.prototype.type="ParenthesisNode",r.prototype.isParenthesisNode=!0,r.prototype._compile=function(e,t){return this.content._compile(e,t)},r.prototype.getContent=function(){return this.content.getContent()},r.prototype.forEach=function(e){e(this.content,"content",this)},r.prototype.map=function(e){return new r(e(this.content,"content",this))},r.prototype.clone=function(){return new r(this.content)},r.prototype._toString=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)},r.prototype.toJSON=function(){return{mathjs:"ParenthesisNode",content:this.content}},r.fromJSON=function(e){return new r(e.content)},r.prototype.toHTML=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?'('+this.content.toHTML(e)+')':this.content.toHTML(e)},r.prototype._toTex=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)},r}),{isClass:!0,isNode:!0}),wt=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{associativity:"left",associativeWith:[]}},{"OperatorNode:and":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{associativity:"left",associativeWith:[]},"OperatorNode:unequal":{associativity:"left",associativeWith:[]},"OperatorNode:smaller":{associativity:"left",associativeWith:[]},"OperatorNode:larger":{associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{associativity:"left",associativeWith:[]}},{"OperatorNode:to":{associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{associativity:"left",associativeWith:[]},"OperatorNode:mod":{associativity:"left",associativeWith:[]}},{"OperatorNode:unaryPlus":{associativity:"right"},"OperatorNode:unaryMinus":{associativity:"right"},"OperatorNode:bitNot":{associativity:"right"},"OperatorNode:not":{associativity:"right"}},{"OperatorNode:pow":{associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{associativity:"left"}},{"OperatorNode:transpose":{associativity:"left"}}];function Nt(e,t){var r=e;"keep"!==t&&(r=e.getContent());for(var n=r.getIdentifier(),i=0;i{var{Node:t}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(t))throw new TypeError("Parameter params must be an array");if(e.length!==t.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=t}return r.prototype=new t,r.prototype.type="RelationalNode",r.prototype.isRelationalNode=!0,r.prototype._compile=function(e,t){var r=this,n=this.params.map((r=>r._compile(e,t)));return function(t,i,a){for(var o,s=n[0](t,i,a),u=0;ue(t,"params["+r+"]",this)),this)},r.prototype.map=function(e){return new r(this.conditionals.slice(),this.params.map(((t,r)=>this._ifNode(e(t,"params["+r+"]",this))),this))},r.prototype.clone=function(){return new r(this.conditionals,this.params)},r.prototype._toString=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.params.map((function(n,i){var a=Nt(n,t);return"all"===t||null!==a&&a<=r?"("+n.toString(e)+")":n.toString(e)})),i={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},a=n[0],o=0;o('+n.toHTML(e)+')':n.toHTML(e)})),i={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},a=n[0],o=0;o'+ke(i[this.conditionals[o]])+""+n[o+1];return a},r.prototype._toTex=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.params.map((function(n,i){var a=Nt(n,t);return"all"===t||null!==a&&a<=r?"\\left("+n.toTex(e)+"\right)":n.toTex(e)})),i=n[0],a=0;a{var{on:t,math:r}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");j(e)?this.value=e.value:this.value=e}function i(e,t){var r,i,o,s,u;r=n.prototype,i=e,o=function(){var e=t();if("function"==typeof e)return a(e)},u=!0,Object.defineProperty(r,i,{get:function(){return u&&(s=o(),u=!1),s},set:function(e){s=e,u=!1},configurable:!0,enumerable:!0})}function a(e){return function(){for(var t=[this.value],r=0;re[t]))};for(var s in e)r(s)}var u,c};var o={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return n.createProxy(r),t&&t("import",(function(e,t,r){r||i(e,t)})),n}),{isClass:!0}),Ot=W("reviver",["classes"],(e=>{var{classes:t}=e;return function(e,r){var n=t[r&&r.mathjs];return n&&"function"==typeof n.fromJSON?n.fromJSON(r):r}})),Ct=W("ConditionalNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError("Parameter condition must be a Node");if(!I(t))throw new TypeError("Parameter trueExpr must be a Node");if(!I(n))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=t,this.falseExpr=n}return r.prototype=new t,r.prototype.type="ConditionalNode",r.prototype.isConditionalNode=!0,r.prototype._compile=function(e,t){var r=this.condition._compile(e,t),n=this.trueExpr._compile(e,t),i=this.falseExpr._compile(e,t);return function(e,t,s){return function(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return!!e;if(e){if(a(e))return!e.isZero();if(o(e))return!(!e.re&&!e.im);if(u(e))return!!e.value}if(null==e)return!1;throw new TypeError('Unsupported type of condition "'+L(e)+'"')}(r(e,t,s))?n(e,t,s):i(e,t,s)}},r.prototype.forEach=function(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)},r.prototype.map=function(e){return new r(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))},r.prototype.clone=function(){return new r(this.condition,this.trueExpr,this.falseExpr)},r.prototype._toString=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.condition.toString(e),i=Nt(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n="("+n+")");var a=this.trueExpr.toString(e),o=Nt(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a="("+a+")");var s=this.falseExpr.toString(e),u=Nt(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s="("+s+")"),n+" ? "+a+" : "+s},r.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},r.fromJSON=function(e){return new r(e.condition,e.trueExpr,e.falseExpr)},r.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.condition.toHTML(e),i=Nt(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n='('+n+')');var a=this.trueExpr.toHTML(e),o=Nt(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a='('+a+')');var s=this.falseExpr.toHTML(e),u=Nt(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s='('+s+')'),n+'?'+a+':'+s},r.prototype._toTex=function(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"},r}),{isClass:!0,isNode:!0}),_t=W("OperatorNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n,i){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('string expected for parameter "op"');if("string"!=typeof t)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(n)||!n.every(I))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=!0===i,this.op=e,this.fn=t,this.args=n||[]}function n(e,t,r,n,i){var a,o=Nt(e,t),s=Mt(e,t);if("all"===t||n.length>2&&"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier())return n.map((function(e){switch(e.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}}));switch(n.length){case 0:a=[];break;case 1:var u=Nt(n[0],t);if(i&&null!==u){var c,l;if("keep"===t?(c=n[0].getIdentifier(),l=e.getIdentifier()):(c=n[0].getContent().getIdentifier(),l=e.getContent().getIdentifier()),!1===wt[o][l].latexLeftParens){a=[!1];break}if(!1===wt[u][c].latexParens){a=[!1];break}}if(null===u){a=[!1];break}if(u<=o){a=[!0];break}a=[!1];break;case 2:var f,p,m=Nt(n[0],t),h=St(e,n[0],t);f=null!==m&&(m===o&&"right"===s&&!h||m=2&&"OperatorNode:multiply"===e.getIdentifier()&&e.implicit&&"auto"===t&&"hide"===r&&(a=n.map((function(e,t){var r="ParenthesisNode"===e.getIdentifier();return!(!a[t]&&!r)}))),a}return r.prototype=new t,r.prototype.type="OperatorNode",r.prototype.isOperatorNode=!0,r.prototype._compile=function(e,t){if("string"!=typeof this.fn||!K(e,this.fn))throw e[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var r=Y(e,this.fn),n=tt(this.args,(function(r){return r._compile(e,t)}));if(1===n.length){var i=n[0];return function(e,t,n){return r(i(e,t,n))}}if(2===n.length){var a=n[0],o=n[1];return function(e,t,n){return r(a(e,t,n),o(e,t,n))}}return function(e,t,i){return r.apply(null,tt(n,(function(r){return r(e,t,i)})))}},r.prototype.forEach=function(e){for(var t=0;t2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var f=i.map((function(t,r){return t=t.toString(e),a[r]&&(t="("+t+")"),t}));return this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?f.join(" "):f.join(" "+this.op+" ")}return this.fn+"("+this.args.join(", ")+")"},r.prototype.toJSON=function(){return{mathjs:"OperatorNode",op:this.op,fn:this.fn,args:this.args,implicit:this.implicit}},r.fromJSON=function(e){return new r(e.op,e.fn,e.args,e.implicit)},r.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,t,r,i,!1);if(1===i.length){var o=Mt(this,t),s=i[0].toHTML(e);return a[0]&&(s='('+s+')'),"right"===o?''+ke(this.op)+""+s:s+''+ke(this.op)+""}if(2===i.length){var u=i[0].toHTML(e),c=i[1].toHTML(e);return a[0]&&(u='('+u+')'),a[1]&&(c='('+c+')'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?u+''+c:u+''+ke(this.op)+""+c}var l=i.map((function(t,r){return t=t.toHTML(e),a[r]&&(t='('+t+')'),t}));return i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())?this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?l.join(''):l.join(''+ke(this.op)+""):''+ke(this.fn)+'('+l.join(',')+')'},r.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,t,r,i,!0),o=mt[this.fn];if(o=void 0===o?this.op:o,1===i.length){var s=Mt(this,t),u=i[0].toTex(e);return a[0]&&(u="\\left(".concat(u,"\\right)")),"right"===s?o+u:u+o}if(2===i.length){var c=i[0],l=c.toTex(e);a[0]&&(l="\\left(".concat(l,"\\right)"));var f,p=i[1].toTex(e);switch(a[1]&&(p="\\left(".concat(p,"\\right)")),f="keep"===t?c.getIdentifier():c.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return o+"{"+l+"}{"+p+"}";case"OperatorNode:pow":switch(l="{"+l+"}",p="{"+p+"}",f){case"ConditionalNode":case"OperatorNode:divide":l="\\left(".concat(l,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&"hide"===r)return l+"~"+p}return l+o+p}if(i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var m=i.map((function(t,r){return t=t.toTex(e),a[r]&&(t="\\left(".concat(t,"\\right)")),t}));return"OperatorNode:multiply"===this.getIdentifier()&&this.implicit?m.join("~"):m.join(o)}return"\\mathrm{"+this.fn+"}\\left("+i.map((function(t){return t.toTex(e)})).join(",")+"\\right)"},r.prototype.getIdentifier=function(){return this.type+":"+this.fn},r}),{isClass:!0,isNode:!0}),Tt=W("RangeNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError("Node expected");if(!I(t))throw new TypeError("Node expected");if(n&&!I(n))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=e,this.end=t,this.step=n||null}function n(e,t){var r=Nt(e,t),n={},i=Nt(e.start,t);if(n.start=null!==i&&i<=r||"all"===t,e.step){var a=Nt(e.step,t);n.step=null!==a&&a<=r||"all"===t}var o=Nt(e.end,t);return n.end=null!==o&&o<=r||"all"===t,n}return r.prototype=new t,r.prototype.type="RangeNode",r.prototype.isRangeNode=!0,r.prototype.needsEnd=function(){return this.filter((function(e){return P(e)&&"end"===e.name})).length>0},r.prototype._compile=function(e,t){var r=e.range,n=this.start._compile(e,t),i=this.end._compile(e,t);if(this.step){var a=this.step._compile(e,t);return function(e,t,o){return r(n(e,t,o),i(e,t,o),a(e,t,o))}}return function(e,t,a){return r(n(e,t,a),i(e,t,a))}},r.prototype.forEach=function(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)},r.prototype.map=function(e){return new r(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))},r.prototype.clone=function(){return new r(this.start,this.end,this.step&&this.step)},r.prototype._toString=function(e){var t,r=n(this,e&&e.parenthesis?e.parenthesis:"keep"),i=this.start.toString(e);if(r.start&&(i="("+i+")"),t=i,this.step){var a=this.step.toString(e);r.step&&(a="("+a+")"),t+=":"+a}var o=this.end.toString(e);return r.end&&(o="("+o+")"),t+":"+o},r.prototype.toJSON=function(){return{mathjs:"RangeNode",start:this.start,end:this.end,step:this.step}},r.fromJSON=function(e){return new r(e.start,e.end,e.step)},r.prototype.toHTML=function(e){var t,r=n(this,e&&e.parenthesis?e.parenthesis:"keep"),i=this.start.toHTML(e);if(r.start&&(i='('+i+')'),t=i,this.step){var a=this.step.toHTML(e);r.step&&(a='('+a+')'),t+=':'+a}var o=this.end.toHTML(e);return r.end&&(o='('+o+')'),t+':'+o},r.prototype._toTex=function(e){var t=n(this,e&&e.parenthesis?e.parenthesis:"keep"),r=this.start.toTex(e);if(t.start&&(r="\\left(".concat(r,"\\right)")),this.step){var i=this.step.toTex(e);t.step&&(i="\\left(".concat(i,"\\right)")),r+=":"+i}var a=this.end.toTex(e);return t.end&&(a="\\left(".concat(a,"\\right)")),r+":"+a},r}),{isClass:!0,isNode:!0}),Bt=W("FunctionAssignmentNode",["typed","Node"],(e=>{var{typed:t,Node:r}=e;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(t))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!I(r))throw new TypeError('Node expected for parameter "expr"');if(H.has(e))throw new Error('Illegal function name, "'+e+'" is a reserved keyword');this.name=e,this.params=t.map((function(e){return e&&e.name||e})),this.types=t.map((function(e){return e&&e.type||"any"})),this.expr=r}function i(e,t){var r=Nt(e,t),n=Nt(e.expr,t);return"all"===t||null!==n&&n<=r}return n.prototype=new r,n.prototype.type="FunctionAssignmentNode",n.prototype.isFunctionAssignmentNode=!0,n.prototype._compile=function(e,r){var n=Object.create(r);rt(this.params,(function(e){n[e]=!0}));var i=this.expr._compile(e,n),a=this.name,o=this.params,s=at(this.types,","),u=a+"("+at(this.params,", ")+")";return function(e,r,n){var c={};c[s]=function(){for(var t=Object.create(r),a=0;a'+ke(this.params[n])+"");var a=this.expr.toHTML(e);return i(this,t)&&(a='('+a+')'),''+ke(this.name)+'('+r.join(',')+')='+a},n.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=this.expr.toTex(e);return i(this,t)&&(r="\\left(".concat(r,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(gt).join(",")+"\\right):="+r},n}),{isClass:!0,isNode:!0}),qt="chain",zt=W(qt,["typed","Chain"],(e=>{var{typed:t,Chain:r}=e;return t(qt,{"":function(){return new r},any:function(e){return new r(e)}})}));function Dt(e){return e&&e.isIndexError?new Pe(e.index+1,e.min+1,void 0!==e.max?e.max+1:void 0):e}function It(e){var{subset:t}=e;return function(e,r){try{if(Array.isArray(e))return t(e,r);if(e&&"function"==typeof e.subset)return e.subset(r);if("string"==typeof e)return t(e,r);if("object"==typeof e){if(!r.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return Y(e,r.getObjectProperty())}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Dt(e)}}}var kt=W("AccessorNode",["subset","Node"],(e=>{var{subset:t,Node:r}=e,n=It({subset:t});function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError('Node expected for parameter "object"');if(!D(t))throw new TypeError('IndexNode expected for parameter "index"');this.object=e||null,this.index=t,Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function a(e){return!(A(e)||O(e)||B(e)||z(e)||k(e)||F(e)||P(e))}return i.prototype=new r,i.prototype.type="AccessorNode",i.prototype.isAccessorNode=!0,i.prototype._compile=function(e,t){var r=this.object._compile(e,t),i=this.index._compile(e,t);if(this.index.isObjectProperty()){var a=this.index.getObjectProperty();return function(e,t,n){return Y(r(e,t,n),a)}}return function(e,t,a){var o=r(e,t,a),s=i(e,t,o);return n(o,s)}},i.prototype.forEach=function(e){e(this.object,"object",this),e(this.index,"index",this)},i.prototype.map=function(e){return new i(this._ifNode(e(this.object,"object",this)),this._ifNode(e(this.index,"index",this)))},i.prototype.clone=function(){return new i(this.object,this.index)},i.prototype._toString=function(e){var t=this.object.toString(e);return a(this.object)&&(t="("+t+")"),t+this.index.toString(e)},i.prototype.toHTML=function(e){var t=this.object.toHTML(e);return a(this.object)&&(t='('+t+')'),t+this.index.toHTML(e)},i.prototype._toTex=function(e){var t=this.object.toTex(e);return a(this.object)&&(t="\\left(' + object + '\\right)"),t+this.index.toTex(e)},i.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},i.fromJSON=function(e){return new i(e.object,e.index)},i}),{isClass:!0,isNode:!0}),Rt=W("IndexNode",["Range","Node","size"],(e=>{var{Range:t,Node:r,size:n}=e;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(this.dimensions=e,this.dotNotation=t||!1,!Array.isArray(e)||!e.every(I))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}function o(e,r,n){return new t(a(e)?e.toNumber():e,a(r)?r.toNumber():r,a(n)?n.toNumber():n)}return i.prototype=new r,i.prototype.type="IndexNode",i.prototype.isIndexNode=!0,i.prototype._compile=function(e,t){var r=tt(this.dimensions,(function(r,i){if(U(r)){if(r.needsEnd()){var a=Object.create(t);a.end=!0;var s=r.start._compile(e,a),u=r.end._compile(e,a),c=r.step?r.step._compile(e,a):function(){return 1};return function(e,t,r){var a=n(r).valueOf(),l=Object.create(t);return l.end=a[i],o(s(e,l,r),u(e,l,r),c(e,l,r))}}var l=r.start._compile(e,t),f=r.end._compile(e,t),p=r.step?r.step._compile(e,t):function(){return 1};return function(e,t,r){return o(l(e,t,r),f(e,t,r),p(e,t,r))}}if(P(r)&&"end"===r.name){var m=Object.create(t);m.end=!0;var h=r._compile(e,m);return function(e,t,r){var a=n(r).valueOf(),o=Object.create(t);return o.end=a[i],h(e,o,r)}}var d=r._compile(e,t);return function(e,t,r){return d(e,t,r)}})),i=Y(e,"index");return function(e,t,n){var a=tt(r,(function(r){return r(e,t,n)}));return i(...a)}},i.prototype.forEach=function(e){for(var t=0;t.'+ke(this.getObjectProperty())+"":'['+t.join(',')+']'},i.prototype._toTex=function(e){var t=this.dimensions.map((function(t){return t.toTex(e)}));return this.dotNotation?"."+this.getObjectProperty():"_{"+t.join(",")+"}"},i}),{isClass:!0,isNode:!0}),Ft=W("AssignmentNode",["subset","?matrix","Node"],(e=>{var{subset:t,matrix:r,Node:n}=e,i=It({subset:t}),a=function(e){var{subset:t,matrix:r}=e;return function(e,n,i){try{if(Array.isArray(e))return r(e).subset(n,i).valueOf();if(e&&"function"==typeof e.subset)return e.subset(n,i);if("string"==typeof e)return t(e,n,i);if("object"==typeof e){if(!n.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return X(e,n.getObjectProperty(),i),e}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Dt(e)}}}({subset:t,matrix:r});function o(e,t,r){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=e,this.index=r?t:null,this.value=r||t,!P(e)&&!A(e))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(P(e)&&"end"===e.name)throw new Error('Cannot assign to symbol "end"');if(this.index&&!D(this.index))throw new TypeError('IndexNode expected as "index"');if(!I(this.value))throw new TypeError('Node expected as "value"');Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function s(e,t){t||(t="keep");var r=Nt(e,t),n=Nt(e.value,t);return"all"===t||null!==n&&n<=r}return o.prototype=new n,o.prototype.type="AssignmentNode",o.prototype.isAssignmentNode=!0,o.prototype._compile=function(e,t){var r=this.object._compile(e,t),n=this.index?this.index._compile(e,t):null,o=this.value._compile(e,t),s=this.object.name;if(this.index){if(this.index.isObjectProperty()){var u=this.index.getObjectProperty();return function(e,t,n){var i=r(e,t,n),a=o(e,t,n);return X(i,u,a),a}}if(P(this.object))return function(e,t,i){var u=r(e,t,i),c=o(e,t,i),l=n(e,t,u);return e.set(s,a(u,l,c)),c};var c=this.object.object._compile(e,t);if(this.object.index.isObjectProperty()){var l=this.object.index.getObjectProperty();return function(e,t,r){var i=c(e,t,r),s=Y(i,l),u=n(e,t,s),f=o(e,t,r);return X(i,l,a(s,u,f)),f}}var f=this.object.index._compile(e,t);return function(e,t,r){var s=c(e,t,r),u=f(e,t,s),l=i(s,u),p=n(e,t,l),m=o(e,t,r);return a(s,u,a(l,p,m)),m}}if(!P(this.object))throw new TypeError("SymbolNode expected as object");return function(e,t,r){var n=o(e,t,r);return e.set(s,n),n}},o.prototype.forEach=function(e){e(this.object,"object",this),this.index&&e(this.index,"index",this),e(this.value,"value",this)},o.prototype.map=function(e){return new o(this._ifNode(e(this.object,"object",this)),this.index?this._ifNode(e(this.index,"index",this)):null,this._ifNode(e(this.value,"value",this)))},o.prototype.clone=function(){return new o(this.object,this.index,this.value)},o.prototype._toString=function(e){var t=this.object.toString(e),r=this.index?this.index.toString(e):"",n=this.value.toString(e);return s(this,e&&e.parenthesis)&&(n="("+n+")"),t+r+" = "+n},o.prototype.toJSON=function(){return{mathjs:"AssignmentNode",object:this.object,index:this.index,value:this.value}},o.fromJSON=function(e){return new o(e.object,e.index,e.value)},o.prototype.toHTML=function(e){var t=this.object.toHTML(e),r=this.index?this.index.toHTML(e):"",n=this.value.toHTML(e);return s(this,e&&e.parenthesis)&&(n='('+n+')'),t+r+'='+n},o.prototype._toTex=function(e){var t=this.object.toTex(e),r=this.index?this.index.toTex(e):"",n=this.value.toTex(e);return s(this,e&&e.parenthesis)&&(n="\\left(".concat(n,"\\right)")),t+r+":="+n},o}),{isClass:!0,isNode:!0}),Ut=W("SymbolNode",["math","?Unit","Node"],(e=>{var{math:t,Unit:r,Node:n}=e;function i(e){return!!r&&r.isValuelessUnit(e)}function a(e){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');this.name=e}return a.prototype=new n,a.prototype.type="SymbolNode",a.prototype.isSymbolNode=!0,a.prototype._compile=function(e,t){var n=this.name;if(!0===t[n])return function(e,t,r){return t[n]};if(n in e)return function(t,r,i){return t.has(n)?t.get(n):Y(e,n)};var o=i(n);return function(e,t,i){return e.has(n)?e.get(n):o?new r(null,n):a.onUndefinedSymbol(n)}},a.prototype.forEach=function(e){},a.prototype.map=function(e){return this.clone()},a.onUndefinedSymbol=function(e){throw new Error("Undefined symbol "+e)},a.prototype.clone=function(){return new a(this.name)},a.prototype._toString=function(e){return this.name},a.prototype.toHTML=function(e){var t=ke(this.name);return"true"===t||"false"===t?''+t+"":"i"===t?''+t+"":"Infinity"===t?''+t+"":"NaN"===t?''+t+"":"null"===t?''+t+"":"undefined"===t?''+t+"":''+t+""},a.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},a.fromJSON=function(e){return new a(e.name)},a.prototype._toTex=function(e){var r=!1;void 0===t[this.name]&&i(this.name)&&(r=!0);var n=gt(this.name,r);return"\\"===n[0]?n:" "+n},a}),{isClass:!0,isNode:!0});function Pt(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{var{math:t,Node:r,SymbolNode:n}=e;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if("string"==typeof e&&(e=new n(e)),!I(e))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(t)||!t.every(I))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=e,this.args=t||[],Object.defineProperty(this,"name",{get:function(){return this.fn.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}i.prototype=new r,i.prototype.type="FunctionNode",i.prototype.isFunctionNode=!0,i.prototype._compile=function(e,t){if(!(this instanceof i))throw new TypeError("No valid FunctionNode");var r=this.args.map((r=>r._compile(e,t)));if(!P(this.fn)){if(A(this.fn)&&D(this.fn.index)&&this.fn.index.isObjectProperty()){var n=this.fn.object._compile(e,t),a=this.fn.index.getObjectProperty(),o=this.args;return function(t,i,s){var u=n(t,i,s);if(function(e,t){if(!K(e,t))throw new Error('No access to method "'+t+'"')}(u,a),u[a]&&u[a].rawArgs)return u[a](o,e,Pt(t,i),t);var c=r.map((e=>e(t,i,s)));return u[a].apply(u,c)}}var s=this.fn._compile(e,t),u=this.args;return function(t,n,i){var a=s(t,n,i);if(a&&a.rawArgs)return a(u,e,Pt(t,n),t);var o=r.map((e=>e(t,n,i)));return a.apply(a,o)}}var c=this.fn.name,l=c in e?Y(e,c):void 0,f="function"==typeof l&&!0===l.rawArgs,p=t=>t.has(c)?t.get(c):c in e?Y(e,c):i.onUndefinedFunction(c);if(f){var m=this.args;return function(t,r,n){return p(t)(m,e,Pt(t,r),t)}}switch(r.length){case 0:return function(e,t,r){return p(e)()};case 1:return function(e,t,n){return p(e)((0,r[0])(e,t,n))};case 2:return function(e,t,n){var i=p(e),a=r[0],o=r[1];return i(a(e,t,n),o(e,t,n))};default:return function(e,t,n){return p(e)(...r.map((r=>r(e,t,n))))}}},i.prototype.forEach=function(e){e(this.fn,"fn",this);for(var t=0;t'+ke(this.fn)+'('+t.join(',')+')'};var s=i.prototype.toTex;return i.prototype.toTex=function(e){var t;return e&&"object"==typeof e.handler&&Z(e.handler,this.name)&&(t=e.handler[this.name](this,e)),void 0!==t?t:s.call(this,e)},i.prototype._toTex=function(e){var r,n,i=this.args.map((function(t){return t.toTex(e)}));switch(ht[this.name]&&(r=ht[this.name]),!t[this.name]||"function"!=typeof t[this.name].toTex&&"object"!=typeof t[this.name].toTex&&"string"!=typeof t[this.name].toTex||(r=t[this.name].toTex),typeof r){case"function":n=r(this,e);break;case"string":n=o(r,this,e);break;case"object":switch(typeof r[i.length]){case"function":n=r[i.length](this,e);break;case"string":n=o(r[i.length],this,e)}}return void 0!==n?n:o("\\mathrm{${name}}\\left(${args}\\right)",this,e)},i.prototype.getIdentifier=function(){return this.type+":"+this.name},i}),{isClass:!0,isNode:!0});function Lt(e){for(var t=0;t=n.length)throw new Pe(t,n.length);return f(e)?e.create(Vt(e.valueOf(),t,r)):Vt(e,t,r)}function Vt(e,t,r){var n,i,a,o;if(t<=0){if(Array.isArray(e[0])){for(o=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r{var{typed:r,numeric:n,config:i,AccessorNode:a,ArrayNode:o,AssignmentNode:s,BlockNode:u,ConditionalNode:c,ConstantNode:l,FunctionAssignmentNode:f,FunctionNode:p,IndexNode:m,ObjectNode:h,OperatorNode:d,ParenthesisNode:y,RangeNode:g,RelationalNode:v,SymbolNode:x}=t,b=r(Wt,{string:function(e){return U(e,{})},"Array | Matrix":function(e){return w(e,{})},"string, Object":function(e,t){return U(e,void 0!==t.nodes?t.nodes:{})},"Array | Matrix, Object":w});function w(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=void 0!==t.nodes?t.nodes:{};return $t(e,(function(e){if("string"!=typeof e)throw new TypeError("String expected");return U(e,r)}))}var N={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},M={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},S={true:!0,false:!1,null:null,undefined:void 0},E=["NaN","Infinity"];function O(e,t){return e.expression.substr(e.index,t)}function C(e){return O(e,1)}function _(e){e.index++}function T(e){return e.expression.charAt(e.index-1)}function q(e){return e.expression.charAt(e.index+1)}function D(e){for(e.tokenType=0,e.token="",e.comment="";b.isWhitespace(C(e),e.nestingLevel);)_(e);if("#"===C(e))for(;"\n"!==C(e)&&""!==C(e);)e.comment+=C(e),_(e);if(""!==C(e)){if("\n"===C(e)&&!e.nestingLevel)return e.tokenType=1,e.token=C(e),void _(e);var t=C(e),r=O(e,2),n=O(e,3);if(3===n.length&&N[n])return e.tokenType=1,e.token=n,_(e),_(e),void _(e);if(2===r.length&&N[r])return e.tokenType=1,e.token=r,_(e),void _(e);if(N[t])return e.tokenType=1,e.token=t,void _(e);if(b.isDigitDot(t)){e.tokenType=2;var i=O(e,2);if("0b"===i||"0o"===i||"0x"===i){for(e.token+=C(e),_(e),e.token+=C(e),_(e);b.isHexDigit(C(e));)e.token+=C(e),_(e);if("."===C(e))for(e.token+=".",_(e);b.isHexDigit(C(e));)e.token+=C(e),_(e);else if("i"===C(e))for(e.token+="i",_(e);b.isDigit(C(e));)e.token+=C(e),_(e);return}if("."===C(e))e.token+=C(e),_(e),b.isDigit(C(e))||(e.tokenType=1);else{for(;b.isDigit(C(e));)e.token+=C(e),_(e);b.isDecimalMark(C(e),q(e))&&(e.token+=C(e),_(e))}for(;b.isDigit(C(e));)e.token+=C(e),_(e);if("E"===C(e)||"e"===C(e))if(b.isDigit(q(e))||"-"===q(e)||"+"===q(e)){if(e.token+=C(e),_(e),"+"!==C(e)&&"-"!==C(e)||(e.token+=C(e),_(e)),!b.isDigit(C(e)))throw ue(e,'Digit expected, got "'+C(e)+'"');for(;b.isDigit(C(e));)e.token+=C(e),_(e);if(b.isDecimalMark(C(e),q(e)))throw ue(e,'Digit expected, got "'+C(e)+'"')}else if("."===q(e))throw _(e),ue(e,'Digit expected, got "'+C(e)+'"')}else{if(!b.isAlpha(C(e),T(e),q(e))){for(e.tokenType=4;""!==C(e);)e.token+=C(e),_(e);throw ue(e,'Syntax error in part "'+e.token+'"')}for(;b.isAlpha(C(e),T(e),q(e))||b.isDigit(C(e));)e.token+=C(e),_(e);Z(M,e.token)?e.tokenType=1:e.tokenType=3}}else e.tokenType=1}function I(e){do{D(e)}while("\n"===e.token)}function k(e){e.nestingLevel++}function F(e){e.nestingLevel--}function U(t,r){var n={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:0,nestingLevel:0,conditionalLevel:null};e(n,{expression:t,extraNodes:r}),D(n);var i=function(e){var t,r,n=[];for(""!==e.token&&"\n"!==e.token&&";"!==e.token&&((t=j(e)).comment=e.comment);"\n"===e.token||";"===e.token;)0===n.length&&t&&(r=";"!==e.token,n.push({node:t,visible:r})),D(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&((t=j(e)).comment=e.comment,r=";"!==e.token,n.push({node:t,visible:r}));return n.length>0?new u(n):(t||((t=new l(void 0)).comment=e.comment),t)}(n);if(""!==n.token)throw 1===n.tokenType?ce(n,"Unexpected operator "+n.token):ue(n,'Unexpected part "'+n.token+'"');return i}function j(e){var t,r,n,i,a=function(e){for(var t=function(e){for(var t=L(e);"or"===e.token;)I(e),t=new d("or","or",[t,L(e)]);return t}(e);"?"===e.token;){var r=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,I(e);var n=t,i=j(e);if(":"!==e.token)throw ue(e,"False part of conditional expression expected");e.conditionalLevel=null,I(e);var a=j(e);t=new c(n,i,a),e.conditionalLevel=r}return t}(e);if("="===e.token){if(P(a))return t=a.name,I(e),n=j(e),new s(new x(t),n);if(A(a))return I(e),n=j(e),new s(a.object,a.index,n);if(z(a)&&P(a.fn)&&(i=!0,r=[],t=a.name,a.args.forEach((function(e,t){P(e)?r[t]=e.name:i=!1})),i))return I(e),n=j(e),new f(t,r,n);throw ue(e,"Invalid left hand side of assignment operator =")}return a}function L(e){for(var t=H(e);"xor"===e.token;)I(e),t=new d("xor","xor",[t,H(e)]);return t}function H(e){for(var t=$(e);"and"===e.token;)I(e),t=new d("and","and",[t,$(e)]);return t}function $(e){for(var t=G(e);"|"===e.token;)I(e),t=new d("|","bitOr",[t,G(e)]);return t}function G(e){for(var t=V(e);"^|"===e.token;)I(e),t=new d("^|","bitXor",[t,V(e)]);return t}function V(e){for(var t=W(e);"&"===e.token;)I(e),t=new d("&","bitAnd",[t,W(e)]);return t}function W(e){for(var t=[J(e)],r=[],n={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};Z(n,e.token);){var i={name:e.token,fn:n[e.token]};r.push(i),I(e),t.push(J(e))}return 1===t.length?t[0]:2===t.length?new d(r[0].name,r[0].fn,t):new v(r.map((e=>e.fn)),t)}function J(e){var t,r,n,i;t=Y(e);for(var a={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Z(a,e.token);)n=a[r=e.token],I(e),i=[t,Y(e)],t=new d(r,n,i);return t}function Y(e){var t,r,n,i;t=X(e);for(var a={to:"to",in:"to"};Z(a,e.token);)n=a[r=e.token],I(e),"in"===r&&""===e.token?t=new d("*","multiply",[t,new x("in")],!0):(i=[t,X(e)],t=new d(r,n,i));return t}function X(e){var t,r=[];if(t=":"===e.token?new l(1):Q(e),":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(r.push(t);":"===e.token&&r.length<3;)I(e),")"===e.token||"]"===e.token||","===e.token||""===e.token?r.push(new x("end")):r.push(Q(e));t=3===r.length?new g(r[0],r[2],r[1]):new g(r[0],r[1])}return t}function Q(e){var t,r,n,i;t=K(e);for(var a={"+":"add","-":"subtract"};Z(a,e.token);)n=a[r=e.token],I(e),i=[t,K(e)],t=new d(r,n,i);return t}function K(e){var t,r,n,i;r=t=ee(e);for(var a={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"};Z(a,e.token);)i=a[n=e.token],I(e),r=ee(e),t=new d(n,i,[t,r]);return t}function ee(e){var t,r;for(r=t=te(e);3===e.tokenType||"in"===e.token&&B(t)||!(2!==e.tokenType||B(r)||R(r)&&"!"!==r.op)||"("===e.token;)r=te(e),t=new d("*","multiply",[t,r],!0);return t}function te(t){for(var r=re(t),n=r,i=[];"/"===t.token&&B(n);){if(i.push(e({},t)),I(t),2!==t.tokenType){e(t,i.pop());break}if(i.push(e({},t)),I(t),3!==t.tokenType&&"("!==t.token){i.pop(),e(t,i.pop());break}e(t,i.pop()),i.pop(),n=re(t),r=new d("/","divide",[r,n])}return r}function re(e){var t,r,a,s={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Z(s,e.token)?(a=s[e.token],t=e.token,I(e),r=[re(e)],new d(t,a,r)):function(e){var t,r,a,s;return t=function(e){var t,r,a;t=function(e){var t=[];if(3===e.tokenType&&Z(e.extraNodes,e.token)){var r=e.extraNodes[e.token];if(D(e),"("===e.token){if(t=[],k(e),D(e),")"!==e.token)for(t.push(j(e));","===e.token;)D(e),t.push(j(e));if(")"!==e.token)throw ue(e,"Parenthesis ) expected");F(e),D(e)}return new r(t)}return function(e){var t;return 3===e.tokenType||1===e.tokenType&&e.token in M?(t=e.token,D(e),ne(e,Z(S,t)?new l(S[t]):-1!==E.indexOf(t)?new l(n(t,"number")):new x(t))):function(e){var t;return'"'===e.token?(t=ie(e),ne(e,new l(t))):function(e){var t;return"'"===e.token?(t=ae(e),ne(e,new l(t))):function(e){var t,r,a,s;if("["===e.token){if(k(e),D(e),"]"!==e.token){var u=oe(e);if(";"===e.token){for(a=1,r=[u];";"===e.token;)D(e),r[a]=oe(e),a++;if("]"!==e.token)throw ue(e,"End of matrix ] expected");F(e),D(e),s=r[0].items.length;for(var c=1;c0},b.isDecimalMark=function(e,t){return"."===e&&"/"!==t&&"*"!==t&&"^"!==t},b.isDigitDot=function(e){return e>="0"&&e<="9"||"."===e},b.isDigit=function(e){return e>="0"&&e<="9"},b.isHexDigit=function(e){return e>="0"&&e<="9"||e>="a"&&e<="f"||e>="A"&&e<="F"},b})),Yt="evaluate",Xt=W(Yt,["typed","parse"],(e=>{var{typed:t,parse:r}=e;return t(Yt,{string:function(e){var t=ie();return r(e).compile().evaluate(t)},"string, Map | Object":function(e,t){return r(e).compile().evaluate(t)},"Array | Matrix":function(e){var t=ie();return $t(e,(function(e){return r(e).compile().evaluate(t)}))},"Array | Matrix, Map | Object":function(e,t){return $t(e,(function(e){return r(e).compile().evaluate(t)}))}})})),Qt=W("Help",["parse"],(e=>{var{parse:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw new Error('Argument "doc" missing');this.doc=e}return r.prototype.type="Help",r.prototype.isHelp=!0,r.prototype.toString=function(){var e=this.doc||{},r="\n";if(e.name&&(r+="Name: "+e.name+"\n\n"),e.category&&(r+="Category: "+e.category+"\n\n"),e.description&&(r+="Description:\n "+e.description+"\n\n"),e.syntax&&(r+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){r+="Examples:\n";for(var n={},i=0;i"mathjs"!==e)).forEach((r=>{t[r]=e[r]})),new r(t)},r.prototype.valueOf=r.prototype.toString,r}),{isClass:!0}),Kt=W("Parser",["parse"],(e=>{var{parse:t}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:ie(),writable:!1})}return r.prototype.type="Parser",r.prototype.isParser=!0,r.prototype.evaluate=function(e){return t(e).compile().evaluate(this.scope)},r.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},r.prototype.getAll=function(){return function(e){if(e instanceof ne)return e.wrappedObject;var t={};for(var r of e.keys())X(t,r,e.get(r));return t}(this.scope)},r.prototype.getAllAsMap=function(){return this.scope},r.prototype.set=function(e,t){return this.scope.set(e,t),t},r.prototype.remove=function(e){this.scope.delete(e)},r.prototype.clear=function(){this.scope.clear()},r}),{isClass:!0}),er={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]},tr={name:"e",category:"Constants",syntax:["e"],description:"Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",examples:["e","e ^ 2","exp(2)","log(e)"],seealso:["exp"]},rr={bignumber:{name:"bignumber",category:"Construction",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","complex","fraction","index","matrix","string","unit"]},boolean:{name:"boolean",category:"Construction",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]},complex:{name:"complex",category:"Construction",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]},createUnit:{name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.",examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]},fraction:{name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(num,den)"],description:"Create a fraction from a number or from a numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},index:{name:"index",category:"Construction",syntax:["[start]","[start:end]","[start:step:end]","[start1, start 2, ...]","[start1:end1, start2:end2, ...]","[start1:step1:end1, start2:step2:end2, ...]"],description:"Create an index to get or replace a subset of a matrix",examples:["[]","[1, 2, 3]","A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[0:2, 0:2] = ones(2, 2)"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]},matrix:{name:"matrix",category:"Construction",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()",'matrix("dense")',"matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])",'matrix([3, 4; 5, 6], "sparse")','matrix([3, 4; 5, 6], "sparse", "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","sparse"]},number:{name:"number",category:"Construction",syntax:["x","number(x)","number(unit, valuelessUnit)"],description:"Create a number or convert a string or boolean into a number.",examples:["2","2e3","4.05","number(2)",'number("7.2")',"number(true)","number([true, false, true, true])",'number(unit("52cm"), "m")'],seealso:["bignumber","boolean","complex","fraction","index","matrix","string","unit"]},sparse:{name:"sparse",category:"Construction",syntax:["sparse()","sparse([a1, b1, ...; a1, b2, ...])",'sparse([a1, b1, ...; a1, b2, ...], "number")'],description:"Create a sparse matrix.",examples:["sparse()","sparse([3, 4; 5, 6])",'sparse([3, 0; 5, 0], "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","matrix"]},splitUnit:{name:"splitUnit",category:"Construction",syntax:["splitUnit(unit: Unit, parts: Unit[])"],description:"Split a unit in an array of units whose sum is equal to the original unit.",examples:['splitUnit(1 m, ["feet", "inch"])'],seealso:["unit","createUnit"]},string:{name:"string",category:"Construction",syntax:['"text"',"string(x)"],description:"Create a string or convert a value to a string",examples:['"Hello World!"',"string(4.2)","string(3 + 2i)"],seealso:["bignumber","boolean","complex","index","matrix","number","unit"]},unit:{name:"unit",category:"Construction",syntax:["value unit","unit(value, unit)","unit(string)"],description:"Create a unit.",examples:["5.5 mm","3 inch",'unit(7.1, "kilogram")','unit("23 deg")'],seealso:["bignumber","boolean","complex","index","matrix","number","string"]},e:tr,E:tr,false:{name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},i:{name:"i",category:"Constants",syntax:["i"],description:"Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",examples:["i","i * i","sqrt(-1)"],seealso:[]},Infinity:{name:"Infinity",category:"Constants",syntax:["Infinity"],description:"Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",examples:["Infinity","1 / 0"],seealso:[]},LN2:{name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},LN10:{name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},LOG2E:{name:"LOG2E",category:"Constants",syntax:["LOG2E"],description:"Returns the base-2 logarithm of E, approximately equal to 1.442",examples:["LOG2E","log(e, 2)"],seealso:[]},LOG10E:{name:"LOG10E",category:"Constants",syntax:["LOG10E"],description:"Returns the base-10 logarithm of E, approximately equal to 0.434",examples:["LOG10E","log(e, 10)"],seealso:[]},NaN:{name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},null:{name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},pi:er,PI:er,phi:{name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["phi"],seealso:[]},SQRT1_2:{name:"SQRT1_2",category:"Constants",syntax:["SQRT1_2"],description:"Returns the square root of 1/2, approximately equal to 0.707",examples:["SQRT1_2","sqrt(1/2)"],seealso:[]},SQRT2:{name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},tau:{name:"tau",category:"Constants",syntax:["tau"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]},true:{name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},version:{name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},speedOfLight:{description:"Speed of light in vacuum",examples:["speedOfLight"]},gravitationConstant:{description:"Newtonian constant of gravitation",examples:["gravitationConstant"]},planckConstant:{description:"Planck constant",examples:["planckConstant"]},reducedPlanckConstant:{description:"Reduced Planck constant",examples:["reducedPlanckConstant"]},magneticConstant:{description:"Magnetic constant (vacuum permeability)",examples:["magneticConstant"]},electricConstant:{description:"Electric constant (vacuum permeability)",examples:["electricConstant"]},vacuumImpedance:{description:"Characteristic impedance of vacuum",examples:["vacuumImpedance"]},coulomb:{description:"Coulomb's constant",examples:["coulomb"]},elementaryCharge:{description:"Elementary charge",examples:["elementaryCharge"]},bohrMagneton:{description:"Borh magneton",examples:["bohrMagneton"]},conductanceQuantum:{description:"Conductance quantum",examples:["conductanceQuantum"]},inverseConductanceQuantum:{description:"Inverse conductance quantum",examples:["inverseConductanceQuantum"]},magneticFluxQuantum:{description:"Magnetic flux quantum",examples:["magneticFluxQuantum"]},nuclearMagneton:{description:"Nuclear magneton",examples:["nuclearMagneton"]},klitzing:{description:"Von Klitzing constant",examples:["klitzing"]},bohrRadius:{description:"Borh radius",examples:["bohrRadius"]},classicalElectronRadius:{description:"Classical electron radius",examples:["classicalElectronRadius"]},electronMass:{description:"Electron mass",examples:["electronMass"]},fermiCoupling:{description:"Fermi coupling constant",examples:["fermiCoupling"]},fineStructure:{description:"Fine-structure constant",examples:["fineStructure"]},hartreeEnergy:{description:"Hartree energy",examples:["hartreeEnergy"]},protonMass:{description:"Proton mass",examples:["protonMass"]},deuteronMass:{description:"Deuteron Mass",examples:["deuteronMass"]},neutronMass:{description:"Neutron mass",examples:["neutronMass"]},quantumOfCirculation:{description:"Quantum of circulation",examples:["quantumOfCirculation"]},rydberg:{description:"Rydberg constant",examples:["rydberg"]},thomsonCrossSection:{description:"Thomson cross section",examples:["thomsonCrossSection"]},weakMixingAngle:{description:"Weak mixing angle",examples:["weakMixingAngle"]},efimovFactor:{description:"Efimov factor",examples:["efimovFactor"]},atomicMass:{description:"Atomic mass constant",examples:["atomicMass"]},avogadro:{description:"Avogadro's number",examples:["avogadro"]},boltzmann:{description:"Boltzmann constant",examples:["boltzmann"]},faraday:{description:"Faraday constant",examples:["faraday"]},firstRadiation:{description:"First radiation constant",examples:["firstRadiation"]},loschmidt:{description:"Loschmidt constant at T=273.15 K and p=101.325 kPa",examples:["loschmidt"]},gasConstant:{description:"Gas constant",examples:["gasConstant"]},molarPlanckConstant:{description:"Molar Planck constant",examples:["molarPlanckConstant"]},molarVolume:{description:"Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",examples:["molarVolume"]},sackurTetrode:{description:"Sackur-Tetrode constant at T=1 K and p=101.325 kPa",examples:["sackurTetrode"]},secondRadiation:{description:"Second radiation constant",examples:["secondRadiation"]},stefanBoltzmann:{description:"Stefan-Boltzmann constant",examples:["stefanBoltzmann"]},wienDisplacement:{description:"Wien displacement law constant",examples:["wienDisplacement"]},molarMass:{description:"Molar mass constant",examples:["molarMass"]},molarMassC12:{description:"Molar mass constant of carbon-12",examples:["molarMassC12"]},gravity:{description:"Standard acceleration of gravity (standard acceleration of free-fall on Earth)",examples:["gravity"]},planckLength:{description:"Planck length",examples:["planckLength"]},planckMass:{description:"Planck mass",examples:["planckMass"]},planckTime:{description:"Planck time",examples:["planckTime"]},planckCharge:{description:"Planck charge",examples:["planckCharge"]},planckTemperature:{description:"Planck temperature",examples:["planckTemperature"]},derivative:{name:"derivative",category:"Algebra",syntax:["derivative(expr, variable)","derivative(expr, variable, {simplify: boolean})"],description:"Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",examples:['derivative("2x^3", "x")','derivative("2x^3", "x", {simplify: false})','derivative("2x^2 + 3x + 4", "x")','derivative("sin(2x)", "x")','f = parse("x^2 + x")','x = parse("x")',"df = derivative(f, x)","df.evaluate({x: 3})"],seealso:["simplify","parse","evaluate"]},lsolve:{name:"lsolve",category:"Algebra",syntax:["x=lsolve(L, b)"],description:"Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolveAll","lup","lusolve","usolve","matrix","sparse"]},lsolveAll:{name:"lsolveAll",category:"Algebra",syntax:["x=lsolveAll(L, b)"],description:"Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolve","lup","lusolve","usolve","matrix","sparse"]},lup:{name:"lup",category:"Algebra",syntax:["lup(m)"],description:"Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",examples:["lup([[2, 1], [1, 4]])","lup(matrix([[2, 1], [1, 4]]))","lup(sparse([[2, 1], [1, 4]]))"],seealso:["lusolve","lsolve","usolve","matrix","sparse","slu","qr"]},lusolve:{name:"lusolve",category:"Algebra",syntax:["x=lusolve(A, b)","x=lusolve(lu, b)"],description:"Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lusolve(a, b)"],seealso:["lup","slu","lsolve","usolve","matrix","sparse"]},simplify:{name:"simplify",category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["derivative","parse","evaluate"]},rationalize:{name:"rationalize",category:"Algebra",syntax:["rationalize(expr)","rationalize(expr, scope)","rationalize(expr, scope, detailed)"],description:"Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",examples:['rationalize("2x/y - y/(x+1)")','rationalize("2x/y - y/(x+1)", true)'],seealso:["simplify"]},slu:{name:"slu",category:"Algebra",syntax:["slu(A, order, threshold)"],description:"Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",examples:["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],seealso:["lusolve","lsolve","usolve","matrix","sparse","lup","qr"]},usolve:{name:"usolve",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolveAll","lup","lusolve","lsolve","matrix","sparse"]},usolveAll:{name:"usolveAll",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolve","lup","lusolve","lsolve","matrix","sparse"]},qr:{name:"qr",category:"Algebra",syntax:["qr(A)"],description:"Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",examples:["qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])"],seealso:["lup","slu","matrix"]},abs:{name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},add:{name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i","3 cm + 2 inch",'"2.3" + "4"'],seealso:["subtract"]},cbrt:{name:"cbrt",category:"Arithmetic",syntax:["cbrt(x)","cbrt(x, allRoots)"],description:"Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",examples:["cbrt(64)","cube(4)","cbrt(-8)","cbrt(2 + 3i)","cbrt(8i)","cbrt(8i, true)","cbrt(27 m^3)"],seealso:["square","sqrt","cube","multiply"]},ceil:{name:"ceil",category:"Arithmetic",syntax:["ceil(x)"],description:"Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)"],seealso:["floor","fix","round"]},cube:{name:"cube",category:"Arithmetic",syntax:["cube(x)"],description:"Compute the cube of a value. The cube of x is x * x * x.",examples:["cube(2)","2^3","2 * 2 * 2"],seealso:["multiply","square","pow"]},divide:{name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["a = 2 / 3","a * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]},dotDivide:{name:"dotDivide",category:"Operators",syntax:["x ./ y","dotDivide(x, y)"],description:"Divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","dotMultiply","divide"]},dotMultiply:{name:"dotMultiply",category:"Operators",syntax:["x .* y","dotMultiply(x, y)"],description:"Multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","dotDivide"]},dotPow:{name:"dotPow",category:"Operators",syntax:["x .^ y","dotPow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]},exp:{name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["expm","expm1","pow","log"]},expm:{name:"expm",category:"Arithmetic",syntax:["exp(x)"],description:"Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",examples:["expm([[0,2],[0,0]])"],seealso:["exp"]},expm1:{name:"expm1",category:"Arithmetic",syntax:["expm1(x)"],description:"Calculate the value of subtracting 1 from the exponential value.",examples:["expm1(2)","pow(e, 2) - 1","log(expm1(2) + 1)"],seealso:["exp","pow","log"]},fix:{name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]},floor:{name:"floor",category:"Arithmetic",syntax:["floor(x)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)"],seealso:["ceil","fix","round"]},gcd:{name:"gcd",category:"Arithmetic",syntax:["gcd(a, b)","gcd(a, b, c, ...)"],description:"Compute the greatest common divisor.",examples:["gcd(8, 12)","gcd(-4, 6)","gcd(25, 15, -10)"],seealso:["lcm","xgcd"]},hypot:{name:"hypot",category:"Arithmetic",syntax:["hypot(a, b, c, ...)","hypot([a, b, c, ...])"],description:"Calculate the hypotenusa of a list with values. ",examples:["hypot(3, 4)","sqrt(3^2 + 4^2)","hypot(-2)","hypot([3, 4, 5])"],seealso:["abs","norm"]},lcm:{name:"lcm",category:"Arithmetic",syntax:["lcm(x, y)"],description:"Compute the least common multiple.",examples:["lcm(4, 6)","lcm(6, 21)","lcm(6, 21, 5)"],seealso:["gcd"]},log:{name:"log",category:"Arithmetic",syntax:["log(x)","log(x, base)"],description:"Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",examples:["log(3.5)","a = log(2.4)","exp(a)","10 ^ 4","log(10000, 10)","log(10000) / log(10)","b = log(1024, 2)","2 ^ b"],seealso:["exp","log1p","log2","log10"]},log2:{name:"log2",category:"Arithmetic",syntax:["log2(x)"],description:"Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",examples:["log2(0.03125)","log2(16)","log2(16) / log2(2)","pow(2, 4)"],seealso:["exp","log1p","log","log10"]},log1p:{name:"log1p",category:"Arithmetic",syntax:["log1p(x)","log1p(x, base)"],description:"Calculate the logarithm of a `value+1`",examples:["log1p(2.5)","exp(log1p(1.4))","pow(10, 4)","log1p(9999, 10)","log1p(9999) / log(10)"],seealso:["exp","log","log2","log10"]},log10:{name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(0.00001)","log10(10000)","10 ^ 4","log(10000) / log(10)","log(10000, 10)"],seealso:["exp","log"]},mod:{name:"mod",category:"Operators",syntax:["x % y","x mod y","mod(x, y)"],description:"Calculates the modulus, the remainder of an integer division.",examples:["7 % 3","11 % 2","10 mod 4","isOdd(x) = x % 2","isOdd(2)","isOdd(3)"],seealso:["divide"]},multiply:{name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["a = 2.1 * 3.4","a / 3.4","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]},norm:{name:"norm",category:"Arithmetic",syntax:["norm(x)","norm(x, p)"],description:"Calculate the norm of a number, vector or matrix.",examples:["abs(-3.5)","norm(-3.5)","norm(3 - 4i)","norm([1, 2, -3], Infinity)","norm([1, 2, -3], -Infinity)","norm([3, 4], 2)","norm([[1, 2], [3, 4]], 1)",'norm([[1, 2], [3, 4]], "inf")','norm([[1, 2], [3, 4]], "fro")']},nthRoot:{name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["nthRoots","pow","sqrt"]},nthRoots:{name:"nthRoots",category:"Arithmetic",syntax:["nthRoots(A)","nthRoots(A, root)"],description:'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',examples:["nthRoots(1)","nthRoots(1, 3)"],seealso:["sqrt","pow","nthRoot"]},pow:{name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3","2*2*2","1 + e ^ (pi * i)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},round:{name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)"],seealso:["ceil","floor","fix"]},sign:{name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},sqrt:{name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},sqrtm:{name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},square:{name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},subtract:{name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},unaryMinus:{name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},bitAnd:{name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitNot:{name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitOr:{name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},bitXor:{name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},leftShift:{name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},rightArithShift:{name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},rightLogShift:{name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},bellNumbers:{name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},catalan:{name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},composition:{name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},stirlingS2:{name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},config:{name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},import:{name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number, number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},arg:{name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},conj:{name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},re:{name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},im:{name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},evaluate:{name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(" + 4 + ")")'],seealso:[]},help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},distance:{name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])","distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},intersect:{name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},and:{name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},not:{name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},or:{name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},xor:{name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},concat:{name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},count:{name:"count",category:"Matrix",syntax:["count(x)"],description:"Count the number of elements of a matrix, array or string.",examples:["a = [1, 2; 3, 4; 5, 6]","count(a)","size(a)",'count("hello world")'],seealso:["size"]},cross:{name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},column:{name:"column",category:"Matrix",syntax:["column(x, index)"],description:"Return a column from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","column(A, 1)","column(A, 2)"],seealso:["row","matrixFromColumns"]},ctranspose:{name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},det:{name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diag:{name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diff:{name:"diff",category:"Matrix",syntax:["diff(arr)","diff(arr, dim)"],description:["Create a new matrix or array with the difference of the passed matrix or array.","Dim parameter is optional and used to indicant the dimension of the array/matrix to apply the difference","If no dimension parameter is passed it is assumed as dimension 0","Dimension is zero-based in javascript and one-based in the parser","Arrays must be 'rectangular' meaning arrays like [1, 2]","If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],examples:["diff([1, 2, 4, 7, 0])","diff([1, 2, 4, 7, 0], 0)","diff(matrix([1, 2, 4, 7, 0]))","diff([[1, 2], [3, 4]])","diff([[1, 2], [3, 4]], 0)","diff([[1, 2], [3, 4]], 1)","diff([[1, 2], [3, 4]], bignumber(1))","diff(matrix([[1, 2], [3, 4]]), 1)","diff([[1, 2], matrix([3, 4])], 1)"],seealso:["subtract","partitionSelect"]},dot:{name:"dot",category:"Matrix",syntax:["dot(A, B)","A * B"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]},getMatrixDataType:{name:"getMatrixDataType",category:"Matrix",syntax:["getMatrixDataType(x)"],description:'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',examples:["getMatrixDataType([1, 2, 3])","getMatrixDataType([[5 cm], [2 inch]])",'getMatrixDataType([1, "text"])',"getMatrixDataType([1, bignumber(4)])"],seealso:["matrix","sparse","typeOf"]},identity:{name:"identity",category:"Matrix",syntax:["identity(n)","identity(m, n)","identity([m, n])"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["identity(3)","identity(3, 5)","a = [1, 2, 3; 4, 5, 6]","identity(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},filter:{name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},flatten:{name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]},forEach:{name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["forEach([1, 2, 3], function(val) { console.log(val) })"],seealso:["map","sort","filter"]},inv:{name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","identity","ones","range","size","squeeze","subset","trace","transpose","zeros"]},eigs:{name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and eigenvectors of a real symmetric matrix",examples:["eigs([[5, 2.3], [2.3, 1]])"],seealso:["inv"]},kron:{name:"kron",category:"Matrix",syntax:["kron(x, y)"],description:"Calculates the kronecker product of 2 matrices or vectors.",examples:["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])","kron([1,1], [2,3,4])"],seealso:["multiply","dot","cross"]},matrixFromFunction:{name:"matrixFromFunction",category:"Matrix",syntax:["math.matrixFromFunction(size, fn)","math.matrixFromFunction(size, fn, format)","math.matrixFromFunction(size, fn, format, datatype)","math.matrixFromFunction(size, format, fn)","math.matrixFromFunction(size, format, datatype, fn)"],description:"Create a matrix by evaluating a generating function at each index.",examples:["f(I) = I[1] - I[2]","matrixFromFunction([3,3], f)","g(I) = I[1] - I[2] == 1 ? 4 : 0",'matrixFromFunction([100, 100], "sparse", g)',"matrixFromFunction([5], random)"],seealso:["matrix","matrixFromRows","matrixFromColumns","zeros"]},matrixFromRows:{name:"matrixFromRows",category:"Matrix",syntax:["math.matrixFromRows(...arr)","math.matrixFromRows(row1, row2)","math.matrixFromRows(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual rows.",examples:["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromColumns","matrixFromFunction","zeros"]},matrixFromColumns:{name:"matrixFromColumns",category:"Matrix",syntax:["math.matrixFromColumns(...arr)","math.matrixFromColumns(row1, row2)","math.matrixFromColumns(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual columns.",examples:["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromRows","matrixFromFunction","zeros"]},map:{name:"map",category:"Matrix",syntax:["map(x, callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",examples:["map([1, 2, 3], square)"],seealso:["filter","forEach"]},ones:{name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","identity","inv","range","size","squeeze","subset","trace","transpose","zeros"]},partitionSelect:{name:"partitionSelect",category:"Matrix",syntax:["partitionSelect(x, k)","partitionSelect(x, k, compare)"],description:"Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",examples:["partitionSelect([5, 10, 1], 2)",'partitionSelect(["C", "B", "A", "D"], 1)'],seealso:["sort"]},range:{name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","identity","inv","ones","size","squeeze","subset","trace","transpose","zeros"]},resize:{name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze","reshape"]},reshape:{name:"reshape",category:"Matrix",syntax:["reshape(x, sizes)"],description:"Reshape a multi dimensional array to fit the specified dimensions.",examples:["reshape([1, 2, 3, 4, 5, 6], [2, 3])","reshape([[1, 2], [3, 4]], [1, 4])","reshape([[1, 2], [3, 4]], [4])"],seealso:["size","squeeze","resize"]},rotate:{name:"rotate",category:"Matrix",syntax:["rotate(w, theta)","rotate(w, theta, v)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotate([1, 0], math.pi / 2)",'rotate(matrix([1, 0]), unit("35deg"))','rotate([1, 0, 0], unit("90deg"), [0, 0, 1])','rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],seealso:["matrix","rotationMatrix"]},rotationMatrix:{name:"rotationMatrix",category:"Matrix",syntax:["rotationMatrix(theta)","rotationMatrix(theta, v)","rotationMatrix(theta, v, format)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotationMatrix(pi / 2)",'rotationMatrix(unit("45deg"), [0, 0, 1])','rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],seealso:["cos","sin"]},row:{name:"row",category:"Matrix",syntax:["row(x, index)"],description:"Return a row from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","row(A, 1)","row(A, 2)"],seealso:["column","matrixFromRows"]},size:{name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","count","det","diag","identity","inv","ones","range","squeeze","subset","trace","transpose","zeros"]},sort:{name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"])',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},squeeze:{name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","identity","inv","ones","range","size","subset","trace","transpose","zeros"]},subset:{name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of a matrix or string. Indexes are one-based. Both the ranges lower-bound and upper-bound are included.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},trace:{name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","transpose","zeros"]},transpose:{name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},zeros:{name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose"]},combinations:{name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},combinationsWithRep:{name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"],seealso:["combinations","permutations","factorial"]},factorial:{name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},gamma:{name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},kldivergence:{name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},multinomial:{name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},permutations:{name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},pickRandom:{name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)","pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])","pickRandom([1, 3, 1, 6], 2)","pickRandom([1, 3, 1, 6], [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],seealso:["random","randomInt"]},random:{name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]},randomInt:{name:"randomInt",category:"Probability",syntax:["randomInt(max)","randomInt(min, max)","randomInt(size)","randomInt(size, max)","randomInt(size, min, max)"],description:"Return a random integer number",examples:["randomInt(10, 20)","randomInt([2, 3], 10)"],seealso:["pickRandom","random"]},compare:{name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compareNatural","compareText"]},compareNatural:{name:"compareNatural",category:"Relational",syntax:["compareNatural(x, y)"],description:"Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compareNatural(2, 3)","compareNatural(3, 2)","compareNatural(2, 2)","compareNatural(5cm, 40mm)",'compareNatural("2", "10")',"compareNatural(2 + 3i, 2 + 4i)","compareNatural([1, 2, 4], [1, 2, 3])","compareNatural([1, 5], [1, 2, 3])","compareNatural([1, 2], [1, 2])","compareNatural({a: 2}, {a: 4})"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare","compareText"]},compareText:{name:"compareText",category:"Relational",syntax:["compareText(x, y)"],description:"Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:['compareText("B", "A")','compareText("A", "B")','compareText("A", "A")','compareText("2", "10")','compare("2", "10")',"compare(2, 10)",'compareNatural("2", "10")','compareText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural"]},deepEqual:{name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["deepEqual([1,3,4], [1,3,4])","deepEqual([1,3,4], [1,3])"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]},equal:{name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual","equalText"]},equalText:{name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},larger:{name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},largerEq:{name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},smaller:{name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},smallerEq:{name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 <= 1+1","2 < 1+1","a = 3.2","b = 6-2.8","(a <= b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]},unequal:{name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]},setCartesian:{name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},setDifference:{name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},setDistinct:{name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},setIntersect:{name:"setIntersect",category:"Set",syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},setIsSubset:{name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},setMultiplicity:{name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]},setPowerset:{name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},setSize:{name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},setSymDifference:{name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setDifference"]},setUnion:{name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},erf:{name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},mad:{name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},mean:{name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},median:{name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},min:{name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},mode:{name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},prod:{name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},quantileSeq:{name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:"Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.",examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},std:{name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},sum:{name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},variance:{name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},acos:{name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},acosh:{name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},acot:{name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},acoth:{name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},acsc:{name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},acsch:{name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},asec:{name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},asech:{name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},asin:{name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},asinh:{name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},atan:{name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},atanh:{name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},atan2:{name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},cos:{name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},cosh:{name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},cot:{name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},coth:{name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},csc:{name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},csch:{name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},sec:{name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},sech:{name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},sin:{name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},sinh:{name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},tan:{name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},tanh:{name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},to:{name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},clone:{name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},format:{name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},bin:{name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},oct:{name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},hex:{name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},isNaN:{name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isInteger:{name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isNegative:{name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},isNumeric:{name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},hasNumericValue:{name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},isPositive:{name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isPrime:{name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isZero:{name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},typeOf:{name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},numeric:{name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "BigNumber")','numeric("4", "Fraction)','numeric(4, "Fraction")','numeric(fraction(2, 5), "number)'],seealso:["number","fraction","bignumber","string","format"]}},nr="help",ir=W(nr,["typed","mathWithTransform","Help"],(e=>{var{typed:t,mathWithTransform:r,Help:n}=e;return t(nr,{any:function(e){var t,i=e;if("string"!=typeof e)for(t in r)if(Z(r,t)&&e===r[t]){i=t;break}var a=Y(rr,i);if(!a){var o="function"==typeof i?i.name:i;throw new Error('No documentation found on "'+o+'"')}return new n(a)}})})),ar="compile",or=W(ar,["typed","parse"],(e=>{var{typed:t,parse:r}=e;return t(ar,{string:function(e){return r(e).compile()},"Array | Matrix":function(e){return $t(e,(function(e){return r(e).compile()}))}})})),sr=W("simplifyUtil",["FunctionNode","OperatorNode","SymbolNode"],(e=>{var{FunctionNode:t,OperatorNode:r,SymbolNode:n}=e,i={add:!0,multiply:!0},a={add:!0,multiply:!0};function o(e,t){if(!R(e))return!1;var r=e.fn.toString();return t&&Z(t,r)&&Z(t[r],"associative")?t[r].associative:a[r]||!1}function s(e){var t,r=[];return o(e)?(t=e.op,function e(n){for(var i=0;i2&&o(t)){for(var a=t.args.pop();t.args.length>0;)a=r([t.args.pop(),a]);t.args=a.args}}},unflattenl:function e(t){if(t.args&&0!==t.args.length){for(var r=u(t),n=t.args.length,i=0;i2&&o(t)){for(var a=t.args.shift();t.args.length>0;)a=r([a,t.args.shift()]);t.args=a.args}}}}})),ur=W("simplifyCore",["equal","isZero","add","subtract","multiply","divide","pow","ConstantNode","OperatorNode","FunctionNode","ParenthesisNode"],(e=>{var{equal:t,isZero:r,add:n,subtract:i,multiply:a,divide:o,pow:s,ConstantNode:u,OperatorNode:c,FunctionNode:l,ParenthesisNode:f}=e,p=new u(0),m=new u(1);return function e(h){if(R(h)&&h.isUnary()){var d=e(h.args[0]);if("+"===h.op)return d;if("-"===h.op){if(R(d)){if(d.isUnary()&&"-"===d.op)return d.args[0];if(d.isBinary()&&"subtract"===d.fn)return new c("-","subtract",[d.args[1],d.args[0]])}return new c(h.op,h.fn,[d])}}else if(R(h)&&h.isBinary()){var y=e(h.args[0]),g=e(h.args[1]);if("+"===h.op){if(B(y)){if(r(y.value))return g;if(B(g))return new u(n(y.value,g.value))}return B(g)&&r(g.value)?y:R(g)&&g.isUnary()&&"-"===g.op?new c("-","subtract",[y,g.args[0]]):new c(h.op,h.fn,g?[y,g]:[y])}if("-"===h.op){if(B(y)&&g){if(B(g))return new u(i(y.value,g.value));if(r(y.value))return new c("-","unaryMinus",[g])}if("subtract"===h.fn)return B(g)&&r(g.value)?y:R(g)&&g.isUnary()&&"-"===g.op?e(new c("+","add",[y,g.args[0]])):new c(h.op,h.fn,[y,g])}else{if("*"===h.op){if(B(y)){if(r(y.value))return p;if(t(y.value,1))return g;if(B(g))return new u(a(y.value,g.value))}if(B(g)){if(r(g.value))return p;if(t(g.value,1))return y;if(R(y)&&y.isBinary()&&y.op===h.op){var v=y.args[0];if(B(v)){var x=new u(a(v.value,g.value));return new c(h.op,h.fn,[x,y.args[1]],h.implicit)}}return new c(h.op,h.fn,[g,y],h.implicit)}return new c(h.op,h.fn,[y,g],h.implicit)}if("/"===h.op){if(B(y)){if(r(y.value))return p;if(B(g)&&(t(g.value,1)||t(g.value,2)||t(g.value,4)))return new u(o(y.value,g.value))}return new c(h.op,h.fn,[y,g])}if("^"===h.op){if(B(g)){if(r(g.value))return m;if(t(g.value,1))return y;if(B(y))return new u(s(y.value,g.value));if(R(y)&&y.isBinary()&&"^"===y.op){var b=y.args[1];if(B(b))return new c(h.op,h.fn,[y.args[0],new u(a(b.value,g.value))])}}return new c(h.op,h.fn,[y,g])}}}else{if(F(h)){var w=e(h.content);return F(w)||P(w)||B(w)?w:new f(w)}if(z(h)){var N=h.args.map(e).map((function(e){return F(e)?e.content:e}));return new l(e(h.fn),N)}}return h}}));function cr(){throw new Error('No "bignumber" implementation available')}function lr(){throw new Error('No "fraction" implementation available')}function fr(){throw new Error('No "matrix" implementation available')}var pr=W("simplifyConstant",["typed","config","mathWithTransform","?fraction","?bignumber","ConstantNode","OperatorNode","FunctionNode","SymbolNode"],(e=>{var{typed:t,config:r,mathWithTransform:n,fraction:i,bignumber:a,ConstantNode:o,OperatorNode:u,FunctionNode:c,SymbolNode:l}=e,{isCommutative:f,isAssociative:p,allChildren:m,createMakeNodeFunction:h}=sr({FunctionNode:c,OperatorNode:u,SymbolNode:l});function d(e,t,r){try{return v(n[e].apply(null,t),r)}catch(i){return t=t.map((function(e){return s(e)?e.valueOf():e})),v(n[e].apply(null,t),r)}}var y=t({Fraction:function(e){var t,r=e.s*e.n;return t=r<0?new u("-","unaryMinus",[new o(-r)]):new o(r),1===e.d?t:new u("/","divide",[t,new o(e.d)])},number:function(e){return e<0?x(new o(-e)):new o(e)},BigNumber:function(e){return e<0?x(new o(-e)):new o(e)},Complex:function(e){throw new Error("Cannot convert Complex number to Node")}});function g(e,t){if(t&&!1!==t.exactFractions&&isFinite(e)&&i){var r=i(e),n=t&&"number"==typeof t.fractionsLimit?t.fractionsLimit:1/0;if(r.valueOf()===e&&r.nw(e,t)));if(!r.some(I))try{return d(e.name,r,t)}catch(e){}return r=r.map((function(e){return I(e)?e:y(e)})),new c(e.name,r)}case"OperatorNode":var i,a,o=e.fn.toString(),s=h(e);if(R(e)&&e.isUnary())a=I((i=[w(e.args[0],t)])[0])?s(i):d(o,i,t);else if(p(e))if(i=(i=m(e)).map((e=>w(e,t))),f(o)){for(var u=[],l=[],g=0;g1?(a=b(o,u,s,t),l.unshift(a),a=b(o,l,s,t)):a=b(o,i,s,t)}else a=b(o,i,s,t);else a=b(o,i=e.args.map((e=>w(e,t))),s,t);return a;case"ParenthesisNode":return w(e.content,t);case"AccessorNode":case"ArrayNode":case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"IndexNode":case"ObjectNode":case"RangeNode":case"ConditionalNode":default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(e.type))}}return function(e,t){var r=w(e,t);return I(r)?r:y(r)}})),mr=W("resolve",["parse","FunctionNode","OperatorNode","ParenthesisNode"],(e=>{var{parse:t,FunctionNode:r,OperatorNode:n,ParenthesisNode:i}=e;return function e(a,o){if(!o)return a;if(oe(o)||(o=ae(o)),P(a)){var s=o.get(a.name);if(I(s))return e(s,o);if("number"==typeof s)return t(String(s))}else{if(R(a)){var u=a.args.map((function(t){return e(t,o)}));return new n(a.op,a.fn,u,a.implicit)}if(F(a))return new i(e(a.content,o));if(z(a)){var c=a.args.map((function(t){return e(t,o)}));return new r(a.name,c)}}return a}})),hr=W("simplify",["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","?fraction","?bignumber","mathWithTransform","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{config:t,typed:r,parse:n,add:i,subtract:a,multiply:o,divide:s,pow:u,isZero:c,equal:l,fraction:f,bignumber:p,mathWithTransform:m,ConstantNode:h,FunctionNode:d,OperatorNode:y,ParenthesisNode:g,SymbolNode:v}=e,x=pr({typed:r,config:t,mathWithTransform:m,fraction:f,bignumber:p,ConstantNode:h,OperatorNode:y,FunctionNode:d,SymbolNode:v}),b=ur({equal:l,isZero:c,add:i,subtract:a,multiply:o,divide:s,pow:u,ConstantNode:h,OperatorNode:y,FunctionNode:d,ParenthesisNode:g}),w=mr({parse:n,FunctionNode:d,OperatorNode:y,ParenthesisNode:g}),{isCommutative:N,isAssociative:M,flatten:S,unflattenr:E,unflattenl:A,createMakeNodeFunction:O}=sr({FunctionNode:d,OperatorNode:y,SymbolNode:v}),C=r("simplify",{string:function(e){return this(n(e),this.rules,ie(),{})},"string, Map | Object":function(e,t){return this(n(e),this.rules,t,{})},"string, Map | Object, Object":function(e,t,r){return this(n(e),this.rules,t,r)},"string, Array":function(e,t){return this(n(e),t,ie(),{})},"string, Array, Map | Object":function(e,t,r){return this(n(e),t,r,{})},"string, Array, Map | Object, Object":function(e,t,r,i){return this(n(e),t,r,i)},"Node, Map | Object":function(e,t){return this(e,this.rules,t,{})},"Node, Map | Object, Object":function(e,t,r){return this(e,this.rules,t,r)},Node:function(e){return this(e,this.rules,ie(),{})},"Node, Array":function(e,t){return this(e,t,ie(),{})},"Node, Array, Map | Object":function(e,t,r){return this(e,t,r,{})},"Node, Array, Object, Object":function(e,t,r,n){return this(e,t,ae(r),n)},"Node, Array, Map, Object":function(e,t,r,i){t=function(e){for(var t=[],r=0;r");if(2!==s.length)throw SyntaxError("Could not parse rule: "+i);i={l:s[0],r:s[1]};case"object":if(a={l:_(n(i.l)),r:_(n(i.r))},i.context&&(a.evaluate=i.context),i.evaluate&&(a.evaluate=n(i.evaluate)),M(a.l)){var u=O(a.l),c=new v("_p"+q++);a.expanded={},a.expanded.l=u([a.l.clone(),c]),S(a.expanded.l),E(a.expanded.l),a.expanded.r=u([a.r,c])}break;case"function":a=i;break;default:throw TypeError("Unsupported type of rule: "+o)}t.push(a)}return t}(t);for(var a=w(e,r),o={},s=(a=_(a)).toString({parenthesis:"all"});!o[s];){o[s]=!0,q=0;for(var u=0;u=2&&2===e.args.length){for(var i=function(e,t){var r,n,i=[],a=O(e);if(N(e,t))for(var o=0;o2)throw Error("Unexpected non-binary associative function: "+e.toString());return[]}for(var u=[],c=0;c{var{config:t,typed:r,equal:n,isZero:i,add:a,subtract:o,multiply:s,divide:u,pow:c,parse:l,simplify:f,fraction:p,bignumber:m,mathWithTransform:h,ConstantNode:d,OperatorNode:y,FunctionNode:g,SymbolNode:v,ParenthesisNode:x}=e,b=pr({typed:r,config:t,mathWithTransform:h,fraction:p,bignumber:m,ConstantNode:d,OperatorNode:y,FunctionNode:g,SymbolNode:v}),w=ur({equal:n,isZero:i,add:a,subtract:o,multiply:s,divide:u,pow:c,ConstantNode:d,OperatorNode:y,FunctionNode:g,ParenthesisNode:x});return r(dr,{string:function(e){return this(l(e),{},!1)},"string, boolean":function(e,t){return this(l(e),{},t)},"string, Object":function(e,t){return this(l(e),t,!1)},"string, Object, boolean":function(e,t,r){return this(l(e),t,r)},Node:function(e){return this(e,{},!1)},"Node, boolean":function(e,t){return this(e,{},t)},"Node, Object":function(e,t){return this(e,t,!1)},"Node, Object, boolean":function(e,t,r){var n=function(){var e=[w,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},b,{l:"n*(n1^-1)",r:"n/n1"},{l:"n*n1^-n2",r:"n/n1^n2"},{l:"n1^-1",r:"1/n1"},{l:"n*(n1/n2)",r:"(n*n1)/n2"},{l:"1*n",r:"n"}],t=[{l:"(-n1)/(-n2)",r:"n1/n2"},{l:"(-n1)*(-n2)",r:"n1*n2"},{l:"n1--n2",r:"n1+n2"},{l:"n1-n2",r:"n1+(-n2)"},{l:"(n1+n2)*n3",r:"(n1*n3 + n2*n3)"},{l:"n1*(n2+n3)",r:"(n1*n2+n1*n3)"},{l:"c1*n + c2*n",r:"(c1+c2)*n"},{l:"c1*n + n",r:"(c1+1)*n"},{l:"c1*n - c2*n",r:"(c1-c2)*n"},{l:"c1*n - n",r:"(c1-1)*n"},{l:"v/c",r:"(1/c)*v"},{l:"v/-c",r:"-(1/c)*v"},{l:"-v*-c",r:"c*v"},{l:"-v*c",r:"-c*v"},{l:"v*-c",r:"-c*v"},{l:"v*c",r:"c*v"},{l:"-(-n1*n2)",r:"(n1*n2)"},{l:"-(n1*n2)",r:"(-n1*n2)"},{l:"-(-n1+n2)",r:"(n1-n2)"},{l:"-(n1+n2)",r:"(-n1-n2)"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"},{l:"-(-n1/n2)",r:"(n1/n2)"},{l:"-(n1/n2)",r:"(-n1/n2)"}],r=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],n={};return n.firstRules=e.concat(t,r),n.distrDivRules=[{l:"(n1/n2 + n3/n4)",r:"((n1*n4 + n3*n2)/(n2*n4))"},{l:"(n1/n2 + n3)",r:"((n1 + n3*n2)/n2)"},{l:"(n1 + n2/n3)",r:"((n1*n3 + n2)/n3)"}],n.sucDivRules=r,n.firstRulesAgain=e.concat(t),n.finalRules=[w,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},b,{l:"n*-n^n1",r:"-n^(n1+1)"},{l:"n*n^n1",r:"n^(n1+1)"},{l:"n^n1*-n^n2",r:"-n^(n1+n2)"},{l:"n^n1*n^n2",r:"n^(n1+n2)"},{l:"n^n1*-n",r:"-n^(n1+1)"},{l:"n^n1*n",r:"n^(n1+1)"},{l:"n^n1/-n",r:"-n^(n1-1)"},{l:"n^n1/n",r:"n^(n1-1)"},{l:"n/-n^n1",r:"-n^(1-n1)"},{l:"n/n^n1",r:"n^(1-n1)"},{l:"n^n1/-n^n2",r:"n^(n1-n2)"},{l:"n^n1/n^n2",r:"n^(n1-n2)"},{l:"n1+(-n2*n3)",r:"n1-n2*n3"},{l:"v*(-c)",r:"-c*v"},{l:"n1+-n2",r:"n1-n2"},{l:"v*c",r:"c*v"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"}],n}(),i=function(e,t,r,n){var i=[],a=f(e,n,t,{exactFractions:!1}),o="+-*"+((r=!!r)?"/":"");!function e(t){var r=t.type;if("FunctionNode"===r)throw new Error("There is an unsolved function call");if("OperatorNode"===r)if("^"===t.op){if("ConstantNode"!==t.args[1].type||!ce(parseFloat(t.args[1].value)))throw new Error("There is a non-integer exponent");e(t.args[0])}else{if(-1===o.indexOf(t.op))throw new Error("Operator "+t.op+" invalid in polynomial expression");for(var n=0;n=1){var o,s;e=N(e);var u,c=!0,l=!1;for(e=f(e,n.firstRules,{},{exactFractions:!1});s=c?n.distrDivRules:n.sucDivRules,c=!c,(u=(e=f(e,s)).toString())!==o;)l=!0,o=u;l&&(e=f(e,n.firstRulesAgain,{},{exactFractions:!1})),e=f(e,n.finalRules,{},{exactFractions:!1})}var p=[],m={};return"OperatorNode"===e.type&&e.isBinary()&&"/"===e.op?(1===a&&(e.args[0]=M(e.args[0],p),e.args[1]=M(e.args[1])),r&&(m.numerator=e.args[0],m.denominator=e.args[1])):(1===a&&(e=M(e,p)),r&&(m.numerator=e,m.denominator=null)),r?(m.coefficients=p,m.variables=i.variables,m.expression=e,m):e}});function N(e,t,r){var n=e.type,i=arguments.length>1;if("OperatorNode"===n&&e.isBinary()){var a,o=!1;if("^"===e.op&&("ParenthesisNode"!==e.args[0].type&&"OperatorNode"!==e.args[0].type||"ConstantNode"!==e.args[1].type||(o=(a=parseFloat(e.args[1].value))>=2&&ce(a))),o){if(a>2){var s=e.args[0],u=new y("^","pow",[e.args[0].cloneDeep(),new d(a-1)]);e=new y("*","multiply",[s,u])}else e=new y("*","multiply",[e.args[0],e.args[0].cloneDeep()]);i&&("content"===r?t.content=e:t.args[r]=e)}}if("ParenthesisNode"===n)N(e.content,e,"content");else if("ConstantNode"!==n&&"SymbolNode"!==n)for(var c=0;cr&&(t[c]=0),t[c]+=o.cte*("+"===o.oper?1:-1),void(r=Math.max(c,r))}o.cte=c,""===o.fire&&(t[0]+=o.cte*("+"===o.oper?1:-1))}}(e,null,{cte:1,oper:"+",fire:""});for(var i,a=!0,o=r=t.length-1;o>=0;o--)if(0!==t[o]){var s=new d(a?t[o]:Math.abs(t[o])),u=t[o]<0?"-":"+";if(o>0){var c=new v(n);if(o>1){var l=new d(o);c=new y("^","pow",[c,l])}s=-1===t[o]&&a?new y("-","unaryMinus",[c]):1===Math.abs(t[o])?c:new y("*","multiply",[s,c])}i=a?s:"+"===u?new y("+","add",[i,s]):new y("-","subtract",[i,s]),a=!1}return a?new d(0):i}})),gr="parser",vr=W(gr,["typed","Parser"],(e=>{var{typed:t,Parser:r}=e;return t(gr,{"":function(){return new r}})})),xr=W("derivative",["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:t,config:r,parse:n,simplify:i,equal:a,isZero:o,numeric:s,ConstantNode:u,FunctionNode:c,OperatorNode:l,ParenthesisNode:f,SymbolNode:p}=e,m=t("derivative",{"Node, SymbolNode, Object":function(e,t,r){var n={};d(n,e,t.name);var a=y(e,n);return r.simplify?i(a):a},"Node, SymbolNode":function(e,t){return this(e,t,{simplify:!0})},"string, SymbolNode":function(e,t){return this(n(e),t)},"string, SymbolNode, Object":function(e,t,r){return this(n(e),t,r)},"string, string":function(e,t){return this(n(e),n(t))},"string, string, Object":function(e,t,r){return this(n(e),n(t),r)},"Node, string":function(e,t){return this(e,n(t))},"Node, string, Object":function(e,t,r){return this(e,n(t),r)}});m._simplify=!0,m.toTex=function(e){return h.apply(null,e.args)};var h=t("_derivTex",{"Node, SymbolNode":function(e,t){return B(e)&&"string"===L(e.value)?h(n(e.value).toString(),t.toString(),1):h(e.toString(),t.toString(),1)},"Node, ConstantNode":function(e,t){if("string"===L(t.value))return h(e,n(t.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(e,t,r){return h(e.toString(),t.name,r.value)},"string, string, number":function(e,t,r){return(1===r?"{d\\over d"+t+"}":"{d^{"+r+"}\\over d"+t+"^{"+r+"}}")+"\\left[".concat(e,"\\right]")}}),d=t("constTag",{"Object, ConstantNode, string":function(e,t){return e[t]=!0,!0},"Object, SymbolNode, string":function(e,t,r){return t.name!==r&&(e[t]=!0,!0)},"Object, ParenthesisNode, string":function(e,t,r){return d(e,t.content,r)},"Object, FunctionAssignmentNode, string":function(e,t,r){return-1===t.params.indexOf(r)?(e[t]=!0,!0):d(e,t.expr,r)},"Object, FunctionNode | OperatorNode, string":function(e,t,r){if(t.args.length>0){for(var n=d(e,t.args[0],r),i=1;i0){var n=e.args.filter((function(e){return void 0===t[e]})),i=1===n.length?n[0]:new l("*","multiply",n),s=r.concat(y(i,t));return new l("*","multiply",s)}return new l("+","add",e.args.map((function(r){return new l("*","multiply",e.args.map((function(e){return e===r?y(e,t):e.clone()})))})))}if("/"===e.op&&e.isBinary()){var u=e.args[0],f=e.args[1];return void 0!==t[f]?new l("/","divide",[y(u,t),f]):void 0!==t[u]?new l("*","multiply",[new l("-","unaryMinus",[u]),new l("/","divide",[y(f,t),new l("^","pow",[f.clone(),g(2)])])]):new l("/","divide",[new l("-","subtract",[new l("*","multiply",[y(u,t),f.clone()]),new l("*","multiply",[u.clone(),y(f,t)])]),new l("^","pow",[f.clone(),g(2)])])}if("^"===e.op&&e.isBinary()){var p=e.args[0],m=e.args[1];if(void 0!==t[p])return B(p)&&(o(p.value)||a(p.value,1))?g(0):new l("*","multiply",[e,new l("*","multiply",[new c("log",[p.clone()]),y(m.clone(),t)])]);if(void 0!==t[m]){if(B(m)){if(o(m.value))return g(0);if(a(m.value,1))return y(p,t)}var h=new l("^","pow",[p.clone(),new l("-","subtract",[m,g(1)])]);return new l("*","multiply",[m.clone(),new l("*","multiply",[y(p,t),h])])}return new l("*","multiply",[new l("^","pow",[p.clone(),m.clone()]),new l("+","add",[new l("*","multiply",[y(p,t),new l("/","divide",[m.clone(),p.clone()])]),new l("*","multiply",[y(m,t),new c("log",[p.clone()])])])])}throw new Error('Operator "'+e.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function g(e,t){return new u(s(e,t||r.number))}return m})),br="apply",wr=W(br,["typed","isInteger"],(e=>{var{typed:t,isInteger:r}=e;return t(br,{"Array | Matrix, number | BigNumber, function":function(e,t,n){if(!r(t))throw new TypeError("Integer number expected for dimension");var i=Array.isArray(e)?je(e):e.size();if(t<0||t>=i.length)throw new Pe(t,i.length);return f(e)?e.create(Nr(e.valueOf(),t,n)):Nr(e,t,n)}})}));function Nr(e,t,r){var n,i,a;if(t<=0){if(Array.isArray(e[0])){for(a=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r{var{typed:t,isInteger:r}=e,n=wr({typed:t,isInteger:r});return t("apply",{"...any":function(e){var t=e[1];i(t)?e[1]=t-1:a(t)&&(e[1]=t.minus(1));try{return n.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0});function Sr(e){var t=0,r=1,n=Object.create(null),i=Object.create(null),a=0,o=function(e){var o=i[e];if(o&&(delete n[o],delete i[e],--t,r===o)){if(!t)return a=0,void(r=1);for(;!hasOwnProperty.call(n,++r););}};return e=Math.abs(e),{hit:function(s){var u=i[s],c=++a;if(n[c]=s,i[s]=c,!u){if(++t<=e)return;return s=n[r],o(s),s}if(delete n[u],r===u)for(;!hasOwnProperty.call(n,++r););},delete:o,clear:function(){t=a=0,r=1,n=Object.create(null),i=Object.create(null)}}}function Er(e){var{hasher:t,limit:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r=null==r?Number.POSITIVE_INFINITY:r,t=null==t?JSON.stringify:t,function n(){"object"!=typeof n.cache&&(n.cache={values:new Map,lru:Sr(r||Number.POSITIVE_INFINITY)});for(var i=[],a=0;a{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=P(e[1])||q(e[1])?e[1].compile().evaluate(r):Or(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("filter",{"Array, function":_r,"Matrix, function":function(e,t){return e.create(_r(e.toArray(),t))},"Array, RegExp":it,"Matrix, RegExp":function(e,t){return e.create(it(e.toArray(),t))}});return r}),{isTransformFunction:!0});function _r(e,t){var r=Ar(t);return nt(e,(function(e,n,i){return 1===r?t(e):2===r?t(e,[n+1]):t(e,[n+1],i)}))}var Tr=W("map",["typed"],(e=>{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=P(e[1])||q(e[1])?e[1].compile().evaluate(r):Or(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("map",{"Array, function":function(e,t){return Br(e,t,e)},"Matrix, function":function(e,t){return e.create(Br(e.valueOf(),t,e))}});return r}),{isTransformFunction:!0});function Br(e,t,r){var n=Ar(t);return function e(i,a){return Array.isArray(i)?tt(i,(function(t,r){return e(t,a.concat(r+1))})):1===n?t(i):2===n?t(i,a):t(i,a,r)}(e,[])}var qr=W("forEach",["typed"],(e=>{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=P(e[1])||q(e[1])?e[1].compile().evaluate(r):Or(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("forEach",{"Array | Matrix, function":function(e,t){var r=Ar(t);!function n(i,a){Array.isArray(i)?rt(i,(function(e,t){n(e,a.concat(t+1))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e.valueOf(),[])}});return r}),{isTransformFunction:!0}),zr="subset",Dr=W(zr,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t(zr,{"Array, Index":function(e,t){var n=r(e).subset(t);return t.isScalar()?n:n.valueOf()},"Matrix, Index":function(e,t){return e.subset(t)},"Object, Index":Rr,"string, Index":Ir,"Array, Index, any":function(e,t,n){return r($(e)).subset(t,n,void 0).valueOf()},"Array, Index, any, any":function(e,t,n,i){return r($(e)).subset(t,n,i).valueOf()},"Matrix, Index, any":function(e,t,r){return e.clone().subset(t,r)},"Matrix, Index, any, any":function(e,t,r,n){return e.clone().subset(t,r,n)},"string, Index, string":kr,"string, Index, string, string":kr,"Object, Index, any":Fr})}));function Ir(e,t){if(!y(t))throw new TypeError("Index expected");if(1!==t.size().length)throw new Ue(t.size().length,1);var r=e.length;$e(t.min()[0],r),$e(t.max()[0],r);var n=t.dimension(0),i="";return n.forEach((function(t){i+=e.charAt(t)})),i}function kr(e,t,r,n){if(!t||!0!==t.isIndex)throw new TypeError("Index expected");if(1!==t.size().length)throw new Ue(t.size().length,1);if(void 0!==n){if("string"!=typeof n||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";var i=t.dimension(0);if(i.size()[0]!==r.length)throw new Ue(i.size()[0],r.length);var a=e.length;$e(t.min()[0]),$e(t.max()[0]);for(var o=[],s=0;sa)for(var u=a-1,c=o.length;u{var{typed:t,matrix:r}=e,n=Dr({typed:t,matrix:r});return t("subset",{"...any":function(e){try{return n.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Pr=W("index",["Index"],(e=>{var{Index:t}=e;return function(){for(var e=[],r=0,n=arguments.length;r0?0:2;else if(o&&!0===o.isSet)o=o.map((function(e){return e-1}));else if(l(o)||f(o))o=o.map((function(e){return e-1}));else if(i(o))o--;else if(a(o))o=o.toNumber()-1;else if("string"!=typeof o)throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");e[r]=o}var s=new t;return t.apply(s,e),s}}),{isTransformFunction:!0}),jr="concat",Lr=W(jr,["typed","matrix","isInteger"],(e=>{var{typed:t,matrix:r,isInteger:n}=e;return t(jr,{"...Array | Matrix | number | BigNumber":function(e){var t,o,s=e.length,u=-1,c=!1,l=[];for(t=0;t0&&u>o)throw new Pe(u,o+1)}else{var m=$(p).valueOf(),h=je(m);if(l[t]=m,o=u,u=h.length-1,t>0&&u!==o)throw new Ue(o+1,u+1)}}if(0===l.length)throw new SyntaxError("At least one matrix expected");for(var d=l.shift();l.length;)d=Hr(d,l.shift(),u,0);return c?r(d):d},"...string":function(e){return e.join("")}})}));function Hr(e,t,r,n){if(n{var{typed:t,matrix:r,isInteger:n}=e,o=Lr({typed:t,matrix:r,isInteger:n});return t("concat",{"...any":function(e){var t=e.length-1,r=e[t];i(r)?e[t]=r-1:a(r)&&(e[t]=r.minus(1));try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0});function Gr(e,t,r){var n;return-1!==String(e).indexOf("Unexpected type")?(n=arguments.length>2?" (type: "+L(r)+", value: "+JSON.stringify(r)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+n)):-1!==String(e).indexOf("complex numbers")?(n=arguments.length>2?" (type: "+L(r)+", value: "+JSON.stringify(r)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+n)):e}var Vr=W("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:r,numeric:n,larger:i}=e;return t("max",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){return Gt(e,t.valueOf(),a)},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function max");return o(e)}});function a(e,t){try{return i(e,t)?e:t}catch(e){throw Gr(e,"max",t)}}function o(e){var t;if(Ht(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw Gr(t,"max",e)}})),void 0===t)throw new Error("Cannot calculate max of an empty array");return"string"==typeof t&&(t=n(t,r.number)),t}}));function Zr(e){if(2===e.length&&p(e[0])){var t=(e=e.slice())[1];i(t)?e[1]=t-1:a(t)&&(e[1]=t.minus(1))}return e}var Wr=W("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:r,numeric:n,larger:i}=e,a=Vr({typed:t,config:r,numeric:n,larger:i});return t("max",{"...any":function(e){e=Zr(e);try{return a.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Jr=W("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:r,numeric:n,smaller:i}=e;return t("min",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){return Gt(e,t.valueOf(),a)},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function min");return o(e)}});function a(e,t){try{return i(e,t)?e:t}catch(e){throw Gr(e,"min",t)}}function o(e){var t;if(Ht(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw Gr(t,"min",e)}})),void 0===t)throw new Error("Cannot calculate min of an empty array");return"string"==typeof t&&(t=n(t,r.number)),t}})),Yr=W("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:r,numeric:n,smaller:i}=e,a=Jr({typed:t,config:r,numeric:n,smaller:i});return t("min",{"...any":function(e){e=Zr(e);try{return a.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Xr=W("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:r,add:n,numeric:i}=e;return t("sum",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){try{return Gt(e,t,n)}catch(e){throw Gr(e,"sum")}},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function sum");return a(e)}});function a(e){var t;return Ht(e,(function(e){try{t=void 0===t?e:n(t,e)}catch(t){throw Gr(t,"sum",e)}})),void 0===t&&(t=i(0,r.number)),"string"==typeof t&&(t=i(t,r.number)),t}})),Qr=W("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:r,add:n,numeric:i}=e,a=Xr({typed:t,config:r,add:n,numeric:i});return t("sum",{"...any":function(e){e=Zr(e);try{return a.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Kr="column",en=W(Kr,["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e;return t(Kr,{"Matrix, number":a,"Array, number":function(e,t){return a(n($(e)),t).valueOf()}});function a(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");$e(t,e.size()[1]);var n=i(0,e.size()[0]),a=new r(n,t);return e.subset(a)}})),tn=W("column",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:a}=e,o=en({typed:t,Index:r,matrix:n,range:a});return t("column",{"...any":function(e){var t=e.length-1,r=e[t];i(r)&&(e[t]=r-1);try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),rn="range",nn=W(rn,["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u}=e;return t(rn,{string:l,"string, boolean":l,"number, number":function(e,t){return c(f(e,t,1))},"number, number, number":function(e,t,r){return c(f(e,t,r))},"number, number, boolean":function(e,t,r){return c(r?p(e,t,1):f(e,t,1))},"number, number, number, boolean":function(e,t,r,n){return c(n?p(e,t,r):f(e,t,r))},"BigNumber, BigNumber":function(e,t){return c(m(e,t,new(0,e.constructor)(1)))},"BigNumber, BigNumber, BigNumber":function(e,t,r){return c(m(e,t,r))},"BigNumber, BigNumber, boolean":function(e,t,r){var n=e.constructor;return c(r?h(e,t,new n(1)):m(e,t,new n(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,r,n){return c(n?h(e,t,r):m(e,t,r))}});function c(e){return"Matrix"===r.matrix?n?n(e):fr():e}function l(e,t){var n=function(e){var t=e.split(":").map((function(e){return Number(e)}));if(t.some((function(e){return isNaN(e)})))return null;switch(t.length){case 2:return{start:t[0],end:t[1],step:1};case 3:return{start:t[0],end:t[2],step:t[1]};default:return null}}(e);if(!n)throw new SyntaxError('String "'+e+'" is no valid range');return"BigNumber"===r.number?(void 0===i&&cr(),c((t?h:m)(i(n.start),i(n.end),i(n.step)))):c((t?p:f)(n.start,n.end,n.step))}function f(e,t,r){var n=[],i=e;if(r>0)for(;a(i,t);)n.push(i),i+=r;else if(r<0)for(;s(i,t);)n.push(i),i+=r;return n}function p(e,t,r){var n=[],i=e;if(r>0)for(;o(i,t);)n.push(i),i+=r;else if(r<0)for(;u(i,t);)n.push(i),i+=r;return n}function m(e,t,r){var n=i(0),o=[],u=e;if(r.gt(n))for(;a(u,t);)o.push(u),u=u.plus(r);else if(r.lt(n))for(;s(u,t);)o.push(u),u=u.plus(r);return o}function h(e,t,r){var n=i(0),a=[],s=e;if(r.gt(n))for(;o(s,t);)a.push(s),s=s.plus(r);else if(r.lt(n))for(;u(s,t);)a.push(s),s=s.plus(r);return a}})),an=W("range",["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u}=e,c=nn({typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u});return t("range",{"...any":function(e){return"boolean"!=typeof e[e.length-1]&&e.push(!0),c.apply(null,e)}})}),{isTransformFunction:!0}),on="diff",sn=W(on,["typed","matrix","subtract","number"],(e=>{var{typed:t,matrix:r,subtract:n,number:i}=e;return t(on,{"Array | Matrix":function(e){return f(e)?r(o(e.toArray())):o(e)},"Array | Matrix, number":function(e,t){if(!ce(t))throw new RangeError("Dimension must be a whole number");return f(e)?r(a(e.toArray(),t)):a(e,t)},"Array | Matrix, BigNumber":function(e,t){return this(e,i(t))}});function a(e,t){if(f(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError("Array/Matrix does not have that many dimensions");if(t>0){var r=[];return e.forEach((e=>{r.push(a(e,t-1))})),r}if(0===t)return o(e);throw RangeError("Cannot have negative dimension")}function o(e){var t=[],r=e.length;if(r<2)return e;for(var n=1;n{var{typed:t,matrix:r,subtract:n,number:i,bignumber:a}=e,o=sn({typed:t,matrix:r,subtract:n,number:i,bignumber:a});return t(un,{"...any":function(e){e=Zr(e);try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),ln=W("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e;return t("row",{"Matrix, number":a,"Array, number":function(e,t){return a(n($(e)),t).valueOf()}});function a(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");$e(t,e.size()[0]);var n=i(0,e.size()[1]),a=new r(t,n);return e.subset(a)}})),fn=W("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:a}=e,o=ln({typed:t,Index:r,matrix:n,range:a});return t("row",{"...any":function(e){var t=e.length-1,r=e[t];i(r)&&(e[t]=r-1);try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),pn="mean",mn=W(pn,["typed","add","divide"],(e=>{var{typed:t,add:r,divide:n}=e;return t(pn,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,t){try{var i=Gt(e,t,r),a=Array.isArray(e)?je(e):e.size();return n(i,a[t])}catch(e){throw Gr(e,"mean")}},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function mean");return i(e)}});function i(e){var t,i=0;if(Ht(e,(function(e){try{t=void 0===t?e:r(t,e),i++}catch(t){throw Gr(t,"mean",e)}})),0===i)throw new Error("Cannot calculate the mean of an empty array");return n(t,i)}})),hn=W("mean",["typed","add","divide"],(e=>{var{typed:t,add:r,divide:n}=e,i=mn({typed:t,add:r,divide:n});return t("mean",{"...any":function(e){e=Zr(e);try{return i.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),dn="unbiased",yn="variance",gn=W(yn,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:r,subtract:n,multiply:i,divide:o,apply:s,isNaN:u}=e;return t(yn,{"Array | Matrix":function(e){return c(e,dn)},"Array | Matrix, string":c,"Array | Matrix, number | BigNumber":function(e,t){return l(e,t,dn)},"Array | Matrix, number | BigNumber, string":l,"...":function(e){return c(e,dn)}});function c(e,t){var s,c=0;if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Ht(e,(function(e){try{s=void 0===s?e:r(s,e),c++}catch(t){throw Gr(t,"variance",e)}})),0===c)throw new Error("Cannot calculate variance of an empty array");var l=o(s,c);if(s=void 0,Ht(e,(function(e){var t=n(e,l);s=void 0===s?i(t,t):r(s,i(t,t))})),u(s))return s;switch(t){case"uncorrected":return o(s,c);case"biased":return o(s,c+1);case"unbiased":var f=a(s)?s.mul(0):0;return 1===c?f:o(s,c-1);default:throw new Error('Unknown normalization "'+t+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function l(e,t,r){try{if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return s(e,t,(e=>c(e,r)))}catch(e){throw Gr(e,"variance")}}})),vn="variance",xn=W(vn,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:r,subtract:n,multiply:i,divide:a,apply:o,isNaN:s}=e,u=gn({typed:t,add:r,subtract:n,multiply:i,divide:a,apply:o,isNaN:s});return t(vn,{"...any":function(e){e=Zr(e);try{return u.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),bn=W("std",["typed","sqrt","variance"],(e=>{var{typed:t,sqrt:r,variance:n}=e;return t("std",{"Array | Matrix":i,"Array | Matrix, string":i,"Array | Matrix, number | BigNumber":i,"Array | Matrix, number | BigNumber, string":i,"...":function(e){return i(e)}});function i(e,t){if(0===e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{return r(n.apply(null,arguments))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf(" variance")?new TypeError(e.message.replace(" variance"," std")):e}}})),wn=W("std",["typed","sqrt","variance"],(e=>{var{typed:t,sqrt:r,variance:n}=e,i=bn({typed:t,sqrt:r,variance:n});return t("std",{"...any":function(e){e=Zr(e);try{return i.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Nn=W("ResultSet",[],(()=>{function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=t||[]}return e.prototype.type="ResultSet",e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},e.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},e.fromJSON=function(t){return new e(t.entries)},e}),{isClass:!0}),Mn=r(977),Sn=W("Complex",[],(()=>(Mn.prototype.type="Complex",Mn.prototype.isComplex=!0,Mn.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Mn.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Mn.prototype.format=function(e){var t=this.im,r=this.re,n=ge(this.re,e),a=ge(this.im,e),o=i(e)?e:e?e.precision:null;if(null!==o){var s=Math.pow(10,-o);Math.abs(r/t)t.re?1:e.ret.im?1:e.im{function e(t,r,n){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var i=null!=t,o=null!=r,s=null!=n;if(i)if(a(t))t=t.toNumber();else if("number"!=typeof t)throw new TypeError("Parameter start must be a number");if(o)if(a(r))r=r.toNumber();else if("number"!=typeof r)throw new TypeError("Parameter end must be a number");if(s)if(a(n))n=n.toNumber();else if("number"!=typeof n)throw new TypeError("Parameter step must be a number");this.start=i?parseFloat(t):0,this.end=o?parseFloat(r):0,this.step=s?parseFloat(n):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(t){if("string"!=typeof t)return null;var r=t.split(":").map((function(e){return parseFloat(e)}));if(r.some((function(e){return isNaN(e)})))return null;switch(r.length){case 2:return new e(r[0],r[1]);case 3:return new e(r[0],r[2],r[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var e=0,t=this.start,r=this.step,n=this.end-t;return le(r)===le(n)?e=Math.ceil(n/r):0===n&&(e=0),isNaN(e)&&(e=0),[e]},e.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},e.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},e.prototype.forEach=function(e){var t=this.start,r=this.step,n=this.end,i=0;if(r>0)for(;tn;)e(t,[i],this),t+=r,i++},e.prototype.map=function(e){var t=[];return this.forEach((function(r,n,i){t[n[0]]=e(r,n,i)})),t},e.prototype.toArray=function(){var e=[];return this.forEach((function(t,r){e[r[0]]=t})),e},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(e){var t=ge(this.start,e);return 1!==this.step&&(t+=":"+ge(this.step,e)),t+":"+ge(this.end,e)},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},e.fromJSON=function(t){return new e(t.start,t.end,t.step)},e}),{isClass:!0}),An=Er((function(e){return new e(1).exp()}),{hasher:Tn}),On=Er((function(e){return new e(1).plus(new e(5).sqrt()).div(2)}),{hasher:Tn}),Cn=Er((function(e){return e.acos(-1)}),{hasher:Tn}),_n=Er((function(e){return Cn(e).times(2)}),{hasher:Tn});function Tn(e){return e[0].precision}var Bn=Math.PI,qn=2*Math.PI,zn=Math.E,Dn=W("true",[],(()=>!0)),In=W("false",[],(()=>!1)),kn=W("null",[],(()=>null)),Rn=Xn("Infinity",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1/0):1/0})),Fn=Xn("NaN",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(NaN):NaN})),Un=Xn("pi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?Cn(r):Bn})),Pn=Xn("tau",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?_n(r):qn})),jn=Xn("e",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?An(r):zn})),Ln=Xn("phi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?On(r):1.618033988749895})),Hn=Xn("LN2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(2).ln():Math.LN2})),$n=Xn("LN10",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(10).ln():Math.LN10})),Gn=Xn("LOG2E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1).div(new r(2).ln()):Math.LOG2E})),Vn=Xn("LOG10E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1).div(new r(10).ln()):Math.LOG10E})),Zn=Xn("SQRT1_2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r("0.5").sqrt():Math.SQRT1_2})),Wn=Xn("SQRT2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(2).sqrt():Math.SQRT2})),Jn=Xn("i",["Complex"],(e=>{var{Complex:t}=e;return t.I})),Yn=W("version",[],(()=>"9.4.1"));function Xn(e,t,r){return W(e,t,r,{recreateOnConfigChange:!0})}var Qn=r(776),Kn=W("BigNumber",["?on","config"],(e=>{var{on:t,config:r}=e,n=Qn.clone({precision:r.precision,modulo:9});return n.prototype.type="BigNumber",n.prototype.isBigNumber=!0,n.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},n.fromJSON=function(e){return new n(e.value)},t&&t("config",(function(e,t){e.precision!==t.precision&&n.config({precision:e.precision})})),n}),{isClass:!0}),ei=W("Matrix",[],(()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(e,t,r){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(e,t,r){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e}),{isClass:!0}),ti=W("replacer",[],(()=>function(e,t){return"number"!=typeof t||isFinite(t)&&!isNaN(t)?t:{mathjs:"number",value:String(t)}})),ri=Qi("speedOfLight","299792458","m s^-1"),ni=Qi("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),ii=Qi("planckConstant","6.62607015e-34","J s"),ai=Qi("reducedPlanckConstant","1.0545718176461565e-34","J s"),oi=Qi("magneticConstant","1.25663706212e-6","N A^-2"),si=Qi("electricConstant","8.8541878128e-12","F m^-1"),ui=Qi("vacuumImpedance","376.730313667","ohm"),ci=Qi("coulomb","8.987551792261171e9","N m^2 C^-2"),li=Qi("elementaryCharge","1.602176634e-19","C"),fi=Qi("bohrMagneton","9.2740100783e-24","J T^-1"),pi=Qi("conductanceQuantum","7.748091729863649e-5","S"),mi=Qi("inverseConductanceQuantum","12906.403729652257","ohm"),hi=Qi("magneticFluxQuantum","2.0678338484619295e-15","Wb"),di=Qi("nuclearMagneton","5.0507837461e-27","J T^-1"),yi=Qi("klitzing","25812.807459304513","ohm"),gi=Qi("bohrRadius","5.29177210903e-11","m"),vi=Qi("classicalElectronRadius","2.8179403262e-15","m"),xi=Qi("electronMass","9.1093837015e-31","kg"),bi=Qi("fermiCoupling","1.1663787e-5","GeV^-2"),wi=Ki("fineStructure",.0072973525693),Ni=Qi("hartreeEnergy","4.3597447222071e-18","J"),Mi=Qi("protonMass","1.67262192369e-27","kg"),Si=Qi("deuteronMass","3.3435830926e-27","kg"),Ei=Qi("neutronMass","1.6749271613e-27","kg"),Ai=Qi("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),Oi=Qi("rydberg","10973731.568160","m^-1"),Ci=Qi("thomsonCrossSection","6.6524587321e-29","m^2"),_i=Ki("weakMixingAngle",.2229),Ti=Ki("efimovFactor",22.7),Bi=Qi("atomicMass","1.66053906660e-27","kg"),qi=Qi("avogadro","6.02214076e23","mol^-1"),zi=Qi("boltzmann","1.380649e-23","J K^-1"),Di=Qi("faraday","96485.33212331001","C mol^-1"),Ii=Qi("firstRadiation","3.7417718521927573e-16","W m^2"),ki=Qi("loschmidt","2.686780111798444e25","m^-3"),Ri=Qi("gasConstant","8.31446261815324","J K^-1 mol^-1"),Fi=Qi("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),Ui=Qi("molarVolume","0.022413969545014137","m^3 mol^-1"),Pi=Ki("sackurTetrode",-1.16487052358),ji=Qi("secondRadiation","0.014387768775039337","m K"),Li=Qi("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),Hi=Qi("wienDisplacement","2.897771955e-3","m K"),$i=Qi("molarMass","0.99999999965e-3","kg mol^-1"),Gi=Qi("molarMassC12","11.9999999958e-3","kg mol^-1"),Vi=Qi("gravity","9.80665","m s^-2"),Zi=Qi("planckLength","1.616255e-35","m"),Wi=Qi("planckMass","2.176435e-8","kg"),Ji=Qi("planckTime","5.391245e-44","s"),Yi=Qi("planckCharge","1.87554603778e-18","C"),Xi=Qi("planckTemperature","1.416785e+32","K");function Qi(e,t,r){return W(e,["config","Unit","BigNumber"],(e=>{var{config:n,Unit:i,BigNumber:a}=e,o=new i("BigNumber"===n.number?new a(t):parseFloat(t),r);return o.fixPrefix=!0,o}))}function Ki(e,t){return W(e,["config","BigNumber"],(e=>{var{config:r,BigNumber:n}=e;return"BigNumber"===r.number?new n(t):t}))}var ea=r(628),ta=W("Fraction",[],(()=>(ea.prototype.type="Fraction",ea.prototype.isFraction=!0,ea.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},ea.fromJSON=function(e){return new ea(e)},ea)),{isClass:!0}),ra=W("DenseMatrix",["Matrix"],(e=>{var{Matrix:t}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!c(t))throw new Error("Invalid datatype: "+t);if(f(e))"DenseMatrix"===e.type?(this._data=$(e._data),this._size=$(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&l(e.data)&&l(e.size))this._data=e.data,this._size=e.size,He(this._data,this._size),this._datatype=t||e.datatype;else if(l(e))this._data=d(e),this._size=je(this._data),He(this._data,this._size),this._datatype=t;else{if(e)throw new TypeError("Unsupported type of data ("+L(e)+")");this._data=[],this._size=[0],this._datatype=t}}function n(e,t){if(!y(t))throw new TypeError("Invalid index");if(t.isScalar())return e.get(t.min());var n=t.size();if(n.length!==e._size.length)throw new Ue(n.length,e._size.length);for(var i=t.min(),a=t.max(),s=0,u=e._size.length;s");h(e,t.max().map((function(e){return e+1})),n);var l=a.length;u(e._data,t,r,l,0)}return e}function u(e,t,r,n,i){var a=i===n-1,o=t.dimension(i);a?o.forEach((function(t,n){$e(t),e[t]=r[n[0]]})):o.forEach((function(a,o){$e(a),u(e[a],t,r[o[0]],n,i+1)}))}function m(e,t,r){if(0===t.length){for(var n=e._data;l(n);)n=n[0];return n}return e._size=t.slice(0),e._data=Ge(e._data,e._size,r),e}function h(e,t,r){for(var n=e._size.slice(0),i=!1;n.lengthn[a]&&(n[a]=t[a],i=!0);i&&m(e,n,r)}function d(e){for(var t=0,r=e.length;tArray.isArray(e)&&1===e.length?e[0]:e));return m(r?this.clone():this,n,t)},r.prototype.reshape=function(e,t){var r=t?this.clone():this;r._data=Ze(r._data,e);var n=r._size.reduce(((e,t)=>e*t));return r._size=We(e,n),r},r.prototype.clone=function(){return new r({data:$(this._data),size:$(this._size),datatype:this._datatype})},r.prototype.size=function(){return this._size.slice(0)},r.prototype.map=function(e){var t=this,n=function r(n,i){return l(n)?n.map((function(e,t){return r(e,i.concat(t))})):e(n,i,t)}(this._data,[]);return new r(n,void 0!==this._datatype?ut(n,L):void 0)},r.prototype.forEach=function(e){var t=this;!function r(n,i){l(n)?n.forEach((function(e,t){r(e,i.concat(t))})):e(n,i,t)}(this._data,[])},r.prototype[Symbol.iterator]=function*(){yield*function*e(t,r){if(l(t))for(var n=0;n[e[n]]));t.push(new r(a,e._datatype))},o=0;o0?e:0,n=e<0?-e:0,o=this._size[0],s=this._size[1],u=Math.min(o-n,s-t),c=[],l=0;l0?n:0,c=n<0?-n:0,p=e[0],m=e[1],h=Math.min(p-c,m-u);if(l(t)){if(t.length!==h)throw new Error("Invalid value array length");s=function(e){return t[e]}}else if(f(t)){var d=t.size();if(1!==d.length||d[0]!==h)throw new Error("Invalid matrix length");s=function(e){return t.get([e])}}else s=function(){return t};o||(o=a(s(0))?s(0).mul(0):0);var y=[];if(e.length>0){y=Ge(y,e,o);for(var g=0;g15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new t(e)}},{from:"number",to:"Complex",convert:function(e){return r||sa(e),new r(e,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(e){return r||sa(e),new r(e.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(e){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(e){return r||sa(e),new r(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){p||ua(e);var t=new p(e);if(t.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return t}},{from:"string",to:"number",convert:function(e){var t=Number(e);if(isNaN(t))throw new Error('Cannot convert "'+e+'" to a number');return t}},{from:"string",to:"BigNumber",convert:function(e){t||oa(e);try{return new t(e)}catch(t){throw new Error('Cannot convert "'+e+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(e){p||ua(e);try{return new p(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(e){r||sa(e);try{return new r(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return t||oa(e),new t(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return p||ua(e),new p(+e)}},{from:"boolean",to:"string",convert:function(e){return String(e)}},{from:"Array",to:"Matrix",convert:function(e){return n||function(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}(),new n(e)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}],L}));function oa(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function sa(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function ua(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var ca="isInteger",la=W(ca,["typed"],(e=>{var{typed:t}=e;return t(ca,{number:ce,BigNumber:function(e){return e.isInt()},Fraction:function(e){return 1===e.d&&isFinite(e.n)},"Array | Matrix":function(e){return $t(e,this)}})})),fa="isNumeric",pa=W(fa,["typed"],(e=>{var{typed:t}=e;return t(fa,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(e){return $t(e,this)}})})),ma="number";function ha(e){return e<0}function da(e){return e>0}function ya(e){return 0===e}function ga(e){return Number.isNaN(e)}ha.signature=ma,da.signature=ma,ya.signature=ma,ga.signature=ma;var va="isPositive",xa=W(va,["typed"],(e=>{var{typed:t}=e;return t(va,{number:da,BigNumber:function(e){return!e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s>0&&e.n>0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),ba="isNaN",wa=W(ba,["typed"],(e=>{var{typed:t}=e;return t(ba,{number:ga,BigNumber:function(e){return e.isNaN()},Fraction:function(e){return!1},Complex:function(e){return e.isNaN()},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":function(e){return $t(e,Number.isNaN)}})}));function Na(e,t,r){if(null==r)return e.eq(t);if(e.eq(t))return!0;if(e.isNaN()||t.isNaN())return!1;if(e.isFinite()&&t.isFinite()){var n=e.minus(t).abs();if(n.isZero())return!0;var i=e.constructor.max(e.abs(),t.abs());return n.lte(i.times(r))}return!1}var Ma="equalScalar",Sa=W(Ma,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(Ma,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return e.equals(t)},"Complex, Complex":function(e,t){return function(e,t,r){return Se(e.re,t.re,r)&&Se(e.im,t.im,r)}(e,t,r.epsilon)},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)}})}));W(Ma,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(Ma,{"number, number":function(e,t){return Se(e,t,r.epsilon)}})}));var Ea=W("number",["typed"],(e=>{var{typed:t}=e,r=t("number",{"":function(){return 0},number:function(e){return e},string:function(e){if("NaN"===e)return NaN;var t,r,n=(r=(t=e).match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/))?{input:t,radix:{"0b":2,"0o":8,"0x":16}[r[1]],integerPart:r[2],fractionalPart:r[3]}:null;if(n)return function(e){for(var t=parseInt(e.integerPart,e.radix),r=0,n=0;n2**i-1)throw new SyntaxError('String "'.concat(e,'" is out of range'));o>=2**(i-1)&&(o-=2**i)}return o},BigNumber:function(e){return e.toNumber()},Fraction:function(e){return e.valueOf()},Unit:function(e){throw new Error("Second argument with valueless unit expected")},null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":function(e){return $t(e,this)}});return r.fromJSON=function(e){return parseFloat(e.value)},r})),Aa="boolean",Oa=W(Aa,["typed"],(e=>{var{typed:t}=e;return t(Aa,{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(e){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;var r=Number(e);if(""!==e&&!isNaN(r))return!!r;throw new Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":function(e){return $t(e,this)}})})),Ca=W("complex",["typed","Complex"],(e=>{var{typed:t,Complex:r}=e;return t("complex",{"":function(){return r.ZERO},number:function(e){return new r(e,0)},"number, number":function(e,t){return new r(e,t)},"BigNumber, BigNumber":function(e,t){return new r(e.toNumber(),t.toNumber())},Fraction:function(e){return new r(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return r(e)},null:function(e){return r(0)},Object:function(e){if("re"in e&&"im"in e)return new r(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new r(e);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(e){return $t(e,this)}})})),_a="splitUnit",Ta=W(_a,["typed"],(e=>{var{typed:t}=e;return t(_a,{"Unit, Array":function(e,t){return e.splitUnit(t)}})})),Ba="number",qa="number, number";function za(e){return Math.abs(e)}function Da(e,t){return e+t}function Ia(e,t){return e*t}function ka(e){return-e}function Ra(e){return e}function Fa(e){return he(e)}function Ua(e){return Math.ceil(e)}function Pa(e){return e*e*e}function ja(e){return Math.exp(e)}function La(e){return de(e)}function Ha(e,t){if(!ce(e)||!ce(t))throw new Error("Parameters in function gcd must be integer numbers");for(var r;0!==t;)r=e%t,e=t,t=r;return e<0?-e:e}function $a(e,t){if(!ce(e)||!ce(t))throw new Error("Parameters in function lcm must be integer numbers");if(0===e||0===t)return 0;for(var r,n=e*t;0!==t;)t=e%(r=t),e=r;return Math.abs(n/e)}function Ga(e){return Math.log(e)}function Va(e){return pe(e)}function Za(e){return fe(e)}function Wa(e,t){if(t>0)return e-t*Math.floor(e/t);if(0===t)return e;throw new Error("Cannot calculate mod for a negative divisor")}function Ja(e,t){var r=t<0;if(r&&(t=-t),0===t)throw new Error("Root must be non-zero");if(e<0&&Math.abs(t)%2!=1)throw new Error("Root must be odd when a is negative.");if(0===e)return r?1/0:0;if(!isFinite(e))return r?0:e;var n=Math.pow(Math.abs(e),1/t);return n=e<0?-n:n,r?1/n:n}function Ya(e){return le(e)}function Xa(e){return e*e}function Qa(e,t){var r,n,i,a=0,o=1,s=1,u=0;if(!ce(e)||!ce(t))throw new Error("Parameters in function xgcd must be integer numbers");for(;t;)i=e-(n=Math.floor(e/t))*t,r=a,a=o-n*a,o=r,r=s,s=u-n*s,u=r,e=t,t=i;return e<0?[-e,-o,-u]:[e,e?o:0,u]}function Ka(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:Math.pow(e,t)}function eo(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return parseFloat(xe(e,t))}za.signature=Ba,Da.signature=qa,Ia.signature=qa,ka.signature=Ba,Ra.signature=Ba,Fa.signature=Ba,Ua.signature=Ba,Pa.signature=Ba,ja.signature=Ba,La.signature=Ba,Ha.signature=qa,$a.signature=qa,Ga.signature=Ba,Va.signature=Ba,Za.signature=Ba,Wa.signature=qa,Ja.signature=qa,Ya.signature=Ba,Xa.signature=Ba,Qa.signature=qa,Ka.signature=qa,eo.signature=qa;var to="unaryPlus",ro=W(to,["typed","config","BigNumber"],(e=>{var{typed:t,config:r,BigNumber:n}=e;return t(to,{number:Ra,Complex:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":function(e){return $t(e,this,!0)},"boolean | string":function(e){return"BigNumber"===r.number?new n(+e):+e}})})),no="cube",io=W(no,["typed"],(e=>{var{typed:t}=e;return t(no,{number:Pa,Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},Fraction:function(e){return e.pow(3)},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.pow(3)}})})),ao="expm1",oo=W(ao,["typed","Complex"],(e=>{var{typed:t,Complex:r}=e;return t(ao,{number:La,Complex:function(e){var t=Math.exp(e.re);return new r(t*Math.cos(e.im)-1,t*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)},"Array | Matrix":function(e){return $t(e,this)}})})),so="log10",uo=W(so,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(so,{number:function(e){return e>=0||r.predictable?Va(e):new n(e,0).log().div(Math.LN10)},Complex:function(e){return new n(e).log().div(Math.LN10)},BigNumber:function(e){return!e.isNegative()||r.predictable?e.log():new n(e.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(e){return $t(e,this)}})})),co=W("multiplyScalar",["typed"],(e=>{var{typed:t}=e;return t("multiplyScalar",{"number, number":Ia,"Complex, Complex":function(e,t){return e.mul(t)},"BigNumber, BigNumber":function(e,t){return e.times(t)},"Fraction, Fraction":function(e,t){return e.mul(t)},"number | Fraction | BigNumber | Complex, Unit":function(e,t){var r=t.clone();return r.value=null===r.value?r._normalize(e):this(r.value,e),r},"Unit, number | Fraction | BigNumber | Complex":function(e,t){var r=e.clone();return r.value=null===r.value?r._normalize(t):this(r.value,t),r},"Unit, Unit":function(e,t){return e.multiply(t)}})})),lo="sign",fo=W(lo,["typed","BigNumber","Fraction","complex"],(e=>{var{typed:t,BigNumber:r,complex:n,Fraction:i}=e;return t(lo,{number:Ya,Complex:function(e){return 0===e.im?n(Ya(e.re)):e.sign()},BigNumber:function(e){return new r(e.cmp(0))},Fraction:function(e){return new i(e.s,1)},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return this(e.value)}})})),po="square",mo=W(po,["typed"],(e=>{var{typed:t}=e;return t(po,{number:Xa,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},Fraction:function(e){return e.mul(e)},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.pow(2)}})}));function ho(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitAnd");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero()||t.eq(-1)||e.eq(t))return e;if(t.isZero()||e.eq(-1))return t;if(!e.isFinite()||!t.isFinite()){if(!e.isFinite()&&!t.isFinite())return e.isNegative()===t.isNegative()?e:new r(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new r(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new r(0):e}return vo(e,t,(function(e,t){return e&t}))}function yo(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var t=e.constructor,r=t.precision;t.config({precision:1e9});var n=e.plus(new t(1));return n.s=-n.s||null,t.config({precision:r}),n}function go(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitOr");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);var n=new r(-1);return e.isZero()||t.eq(n)||e.eq(t)?t:t.isZero()||e.eq(n)?e:e.isFinite()&&t.isFinite()?vo(e,t,(function(e,t){return e|t})):!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?n:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e}function vo(e,t,r){var n,i,a,o,s,u=e.constructor,c=+(e.s<0),l=+(t.s<0);if(c){n=xo(yo(e));for(var f=0;f0;)r(a[--m],o[--h])===d&&(y=y.plus(g)),g=g.times(v);for(;h>0;)r(s,o[--h])===d&&(y=y.plus(g)),g=g.times(v);return u.config({precision:x}),0===d&&(y.s=-y.s),y}function xo(e){for(var t=e.d,r=t[0]+"",n=1;n0)if(++s>c)for(s-=c;s--;)u+="0";else s1&&(null!==l[m+1]&&void 0!==l[m+1]||(l[m+1]=0),l[m+1]+=l[m]>>1,l[m]&=1)}return l.reverse()}function bo(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new r(0);var n=new r(-1);return e.eq(n)?yo(t):t.eq(n)?yo(e):e.isFinite()&&t.isFinite()?vo(e,t,(function(e,t){return e^t})):e.isFinite()||t.isFinite()?new r(e.isNegative()===t.isNegative()?1/0:-1/0):n}function wo(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:e.isFinite()||t.isFinite()?t.lt(55)?e.times(Math.pow(2,t.toNumber())+""):e.times(new r(2).pow(t)):new r(NaN)}function No(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(Math.pow(2,t.toNumber())+"").floor():e.div(new r(2).pow(t)).floor():e.isNegative()?new r(-1):e.isFinite()?new r(0):new r(NaN)}var Mo="number, number";function So(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function bitAnd");return e&t}function Eo(e){if(!ce(e))throw new Error("Integer expected in function bitNot");return~e}function Ao(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function bitOr");return e|t}function Oo(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function bitXor");return e^t}function Co(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function leftShift");return e<>t}function To(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}So.signature=Mo,Eo.signature="number",Ao.signature=Mo,Oo.signature=Mo,Co.signature=Mo,_o.signature=Mo,To.signature=Mo;var Bo="bitNot",qo=W(Bo,["typed"],(e=>{var{typed:t}=e;return t(Bo,{number:Eo,BigNumber:yo,"Array | Matrix":function(e){return $t(e,this)}})})),zo=W("arg",["typed"],(e=>{var{typed:t}=e;return t("arg",{number:function(e){return Math.atan2(0,e)},BigNumber:function(e){return e.constructor.atan2(0,e)},Complex:function(e){return e.arg()},"Array | Matrix":function(e){return $t(e,this)}})})),Do=W("im",["typed"],(e=>{var{typed:t}=e;return t("im",{number:function(e){return 0},BigNumber:function(e){return e.mul(0)},Fraction:function(e){return e.mul(0)},Complex:function(e){return e.im},"Array | Matrix":function(e){return $t(e,this)}})})),Io="number, number";function ko(e){return!e}function Ro(e,t){return!(!e&&!t)}function Fo(e,t){return!!e!=!!t}function Uo(e,t){return!(!e||!t)}ko.signature="number",Ro.signature=Io,Fo.signature=Io,Uo.signature=Io;var Po=W("not",["typed"],(e=>{var{typed:t}=e;return t("not",{number:ko,Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},Unit:function(e){return null===e.value||this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),jo=W("filter",["typed"],(e=>{var{typed:t}=e;return t("filter",{"Array, function":Lo,"Matrix, function":function(e,t){return e.create(Lo(e.toArray(),t))},"Array, RegExp":it,"Matrix, RegExp":function(e,t){return e.create(it(e.toArray(),t))}})}));function Lo(e,t){var r=Ar(t);return nt(e,(function(e,n,i){return 1===r?t(e):2===r?t(e,[n]):t(e,[n],i)}))}var Ho="forEach",$o=W(Ho,["typed"],(e=>{var{typed:t}=e;return t(Ho,{"Array, function":Go,"Matrix, function":function(e,t){return e.forEach(t)}})}));function Go(e,t){var r=Ar(t);!function n(i,a){Array.isArray(i)?rt(i,(function(e,t){n(e,a.concat(t))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e,[])}var Vo=W("map",["typed"],(e=>{var{typed:t}=e;return t("map",{"Array, function":Zo,"Matrix, function":function(e,t){return e.map(t)}})}));function Zo(e,t){var r=Ar(t);return function n(i,a){return Array.isArray(i)?i.map((function(e,t){return n(e,a.concat(t))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e,[])}var Wo=W("erf",["typed"],(e=>{var{typed:t}=e;return t("name",{number:function(e){var t=Math.abs(e);return t>=Ko?le(e):t<=Jo?le(e)*function(e){var t,r=e*e,n=Xo[0][4]*r,i=r;for(t=0;t<3;t+=1)n=(n+Xo[0][t])*r,i=(i+Qo[0][t])*r;return e*(n+Xo[0][3])/(i+Qo[0][3])}(t):t<=4?le(e)*(1-function(e){var t,r=Xo[1][8]*e,n=e;for(t=0;t<7;t+=1)r=(r+Xo[1][t])*e,n=(n+Qo[1][t])*e;var i=(r+Xo[1][7])/(n+Qo[1][7]),a=parseInt(16*e)/16,o=(e-a)*(e+a);return Math.exp(-a*a)*Math.exp(-o)*i}(t)):le(e)*(1-function(e){var t,r=1/(e*e),n=Xo[2][5]*r,i=r;for(t=0;t<4;t+=1)n=(n+Xo[2][t])*r,i=(i+Qo[2][t])*r;var a=r*(n+Xo[2][4])/(i+Qo[2][4]);a=(Yo-a)/e;var o=(e-(r=parseInt(16*e)/16))*(e+r);return Math.exp(-r*r)*Math.exp(-o)*a}(t))},"Array | Matrix":function(e){return $t(e,this)}})})),Jo=.46875,Yo=.5641895835477563,Xo=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],Qo=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],Ko=Math.pow(2,53),es="format",ts=W(es,["typed"],(e=>{var{typed:t}=e;return t(es,{any:De,"any, Object | function | number":De})})),rs=W("oct",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("oct",{"number | BigNumber":function(e){return r(e,{notation:"oct"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"oct",wordSize:t})}})})),ns="print",is=W(ns,["typed"],(e=>{var{typed:t}=e;return t(ns,{"string, Object | Array":as,"string, Object | Array, number | Object":as})}));function as(e,t,r){return e.replace(/\$([\w.]+)/g,(function(e,n){for(var i=n.split("."),a=t[i.shift()];i.length&&void 0!==a;){var o=i.shift();a=o?a[o]:a+"."}return void 0!==a?c(a)?a:De(a,r):e}))}var os="isPrime",ss=W(os,["typed"],(e=>{var{typed:t}=e;return t(os,{number:function(e){if(0*e!=0)return!1;if(e<=3)return e>1;if(e%2==0||e%3==0)return!1;for(var t=5;t*t<=e;t+=6)if(e%t==0||e%(t+2)==0)return!1;return!0},BigNumber:function(e){if(0*e.toNumber()!=0)return!1;if(e.lte(3))return e.gt(1);if(e.mod(2).eq(0)||e.mod(3).eq(0))return!1;if(e.lt(Math.pow(2,32))){for(var t=e.toNumber(),r=5;r*r<=t;r+=6)if(t%r==0||t%(r+2)==0)return!1;return!0}function n(e,t,r){for(var n=1;!t.eq(0);)t.mod(2).eq(0)?(t=t.div(2),e=e.mul(e).mod(r)):(t=t.sub(1),n=e.mul(n).mod(r));return n}for(var i=e.constructor.clone({precision:2*e.toFixed(0).length}),a=0,o=(e=new i(e)).sub(1);o.mod(2).eq(0);)o=o.div(2),a+=1;var s=null;if(e.lt("3317044064679887385961981"))s=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter((t=>t{var{typed:t,config:r,Complex:n}=e;return t(us,{number:function(e){return e>=-1&&e<=1||r.predictable?Math.acos(e):new n(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()},"Array | Matrix":function(e){return $t(e,this)}})})),ls="number";function fs(e){return Ee(e)}function ps(e){return Math.atan(1/e)}function ms(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}function hs(e){return Math.asin(1/e)}function ds(e){var t=1/e;return Math.log(t+Math.sqrt(t*t+1))}function ys(e){return Math.acos(1/e)}function gs(e){var t=1/e,r=Math.sqrt(t*t-1);return Math.log(r+t)}function vs(e){return Ae(e)}function xs(e){return Oe(e)}function bs(e){return 1/Math.tan(e)}function ws(e){var t=Math.exp(2*e);return(t+1)/(t-1)}function Ns(e){return 1/Math.sin(e)}function Ms(e){return 0===e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*le(e)}function Ss(e){return 1/Math.cos(e)}function Es(e){return 2/(Math.exp(e)+Math.exp(-e))}function As(e){return _e(e)}fs.signature=ls,ps.signature=ls,ms.signature=ls,hs.signature=ls,ds.signature=ls,ys.signature=ls,gs.signature=ls,vs.signature=ls,xs.signature=ls,bs.signature=ls,ws.signature=ls,Ns.signature=ls,Ms.signature=ls,Ss.signature=ls,Es.signature=ls,As.signature=ls;var Os="acot",Cs=W(Os,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Os,{number:ps,Complex:function(e){return e.acot()},BigNumber:function(e){return new r(1).div(e).atan()},"Array | Matrix":function(e){return $t(e,this)}})})),_s="acsc",Ts=W(_s,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(_s,{number:function(e){return e<=-1||e>=1||r.predictable?hs(e):new n(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new i(1).div(e).asin()},"Array | Matrix":function(e){return $t(e,this)}})})),Bs="asec",qs=W(Bs,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(Bs,{number:function(e){return e<=-1||e>=1||r.predictable?ys(e):new n(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new i(1).div(e).acos()},"Array | Matrix":function(e){return $t(e,this)}})})),zs="asin",Ds=W(zs,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(zs,{number:function(e){return e>=-1&&e<=1||r.predictable?Math.asin(e):new n(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Is=W("atan",["typed"],(e=>{var{typed:t}=e;return t("atan",{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),ks="atanh",Rs=W(ks,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(ks,{number:function(e){return e<=1&&e>=-1||r.predictable?xs(e):new n(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Fs="cosh",Us=W(Fs,["typed"],(e=>{var{typed:t}=e;return t(Fs,{number:Ce,Complex:function(e){return e.cosh()},BigNumber:function(e){return e.cosh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Ps="coth",js=W(Ps,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Ps,{number:ws,Complex:function(e){return e.coth()},BigNumber:function(e){return new r(1).div(e.tanh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Ls="csch",Hs=W(Ls,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Ls,{number:Ms,Complex:function(e){return e.csch()},BigNumber:function(e){return new r(1).div(e.sinh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),$s="sech",Gs=W($s,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t($s,{number:Es,Complex:function(e){return e.sech()},BigNumber:function(e){return new r(1).div(e.cosh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Vs="sinh",Zs=W(Vs,["typed"],(e=>{var{typed:t}=e;return t(Vs,{number:As,Complex:function(e){return e.sinh()},BigNumber:function(e){return e.sinh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Ws=W("tanh",["typed"],(e=>{var{typed:t}=e;return t("tanh",{number:Te,Complex:function(e){return e.tanh()},BigNumber:function(e){return e.tanh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})}));function Js(e,t){if(t>1;return Js(e,r)*Js(r+1,t)}function Ys(e,t){if(!ce(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!ce(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(t>e)throw new TypeError("k must be less than or equal to n");var r=e-t;return t{var{typed:t}=e;return t(Xs,{"number, number":Ys,"BigNumber, BigNumber":function(e,t){var r,n,i=e.constructor,a=e.minus(t),o=new i(1);if(!Ks(e)||!Ks(t))throw new TypeError("Positive integer value expected in function combinations");if(t.gt(e))throw new TypeError("k must be less than n in function combinations");if(r=o,t.lt(a))for(n=o;n.lte(a);n=n.plus(o))r=r.times(t.plus(n)).dividedBy(n);else for(n=o;n.lte(t);n=n.plus(o))r=r.times(a.plus(n)).dividedBy(n);return r}})}));function Ks(e){return e.isInteger()&&e.gte(0)}var eu=r(377),tu=eu(Date.now());function ru(e){var t,r;return t=null===(r=e)?tu:eu(String(r)),function(){return t()}}var nu="pickRandom",iu=W(nu,["typed","config","?on"],(e=>{var{typed:t,config:r,on:n}=e,a=ru(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(a=ru(e.randomSeed))})),t(nu,{"Array | Matrix":function(e){return o(e,{})},"Array | Matrix, Object":function(e,t){return o(e,t)},"Array | Matrix, number":function(e,t){return o(e,{number:t})},"Array | Matrix, Array | Matrix":function(e,t){return o(e,{weights:t})},"Array | Matrix, Array | Matrix, number":function(e,t,r){return o(e,{number:r,weights:t})},"Array | Matrix, number, Array | Matrix":function(e,t,r){return o(e,{number:t,weights:r})}});function o(e,t){var{number:r,weights:n,elementWise:o=!0}=t,s=void 0===r;s&&(r=1);var u=f(e)?e.create:f(n)?n.create:null;e=e.valueOf(),n&&(n=n.valueOf()),!0===o&&(e=et(e),n=et(n));var c=0;if(void 0!==n){if(n.length!==e.length)throw new Error("Weights must have the same length as possibles");for(var l=0,p=n.length;l1)for(var n=0,i=e.shift();n{var{typed:t,config:r,on:n}=e,i=ru(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(i=ru(e.randomSeed))})),t(ou,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,t)=>o(e,t),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,t)=>a(e,0,t),"Array | Matrix, number, number":(e,t,r)=>a(e,t,r)});function a(e,t,r){var n=au(e.valueOf(),(()=>o(t,r)));return f(e)?e.create(n):n}function o(e,t){return Math.floor(e+i()*(t-e))}})),uu="clone",cu=W(uu,["typed"],(e=>{var{typed:t}=e;return t(uu,{any:$})})),lu="hasNumericValue",fu=W(lu,["typed","isNumeric"],(e=>{var{typed:t,isNumeric:r}=e;return t(lu,{string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return r(e)}})})),pu="typeOf",mu=W(pu,["typed"],(e=>{var{typed:t}=e;return t(pu,{any:L})})),hu="string",du=W(hu,["typed"],(e=>{var{typed:t}=e;return t(hu,{"":function(){return""},number:ge,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":function(e){return $t(e,this)},any:function(e){return String(e)}})})),yu=W("fraction",["typed","Fraction"],(e=>{var{typed:t,Fraction:r}=e;return t("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw new Error(e+" cannot be represented as a fraction");return new r(e)},string:function(e){return new r(e)},"number, number":function(e,t){return new r(e,t)},null:function(e){return new r(0)},BigNumber:function(e){return new r(e.toString())},Fraction:function(e){return e},Object:function(e){return new r(e)},"Array | Matrix":function(e){return $t(e,this)}})})),gu="unaryMinus",vu=W(gu,["typed"],(e=>{var{typed:t}=e;return t(gu,{number:ka,Complex:function(e){return e.neg()},BigNumber:function(e){return e.neg()},Fraction:function(e){return e.neg()},Unit:function(e){var t=e.clone();return t.value=this(e.value),t},"Array | Matrix":function(e){return $t(e,this,!0)}})})),xu="addScalar",bu=W(xu,["typed"],(e=>{var{typed:t}=e;return t(xu,{"number, number":Da,"Complex, Complex":function(e,t){return e.add(t)},"BigNumber, BigNumber":function(e,t){return e.plus(t)},"Fraction, Fraction":function(e,t){return e.add(t)},"Unit, Unit":function(e,t){if(null===e.value||void 0===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value||void 0===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var r=e.clone();return r.value=this(r.value,t.value),r.fixPrefix=!1,r}})})),wu=W("exp",["typed"],(e=>{var{typed:t}=e;return t("exp",{number:ja,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()},"Array | Matrix":function(e){return $t(e,this)}})})),Nu="log2",Mu=W(Nu,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(Nu,{number:function(e){return e>=0||r.predictable?Za(e):i(new n(e,0))},Complex:i,BigNumber:function(e){return!e.isNegative()||r.predictable?e.log(2):i(new n(e.toNumber(),0))},"Array | Matrix":function(e){return $t(e,this)}});function i(e){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new n(Math.log2?Math.log2(t):Math.log(t)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}})),Su=W("sqrt",["config","typed","Complex"],(e=>{var{config:t,typed:r,Complex:n}=e;return r("sqrt",{number:i,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.sqrt():i(e.toNumber())},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.pow(.5)}});function i(e){return isNaN(e)?NaN:e>=0||t.predictable?Math.sqrt(e):new n(e,0).sqrt()}})),Eu="conj",Au=W(Eu,["typed"],(e=>{var{typed:t}=e;return t(Eu,{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.conjugate()},"Array | Matrix":function(e){return $t(e,this)}})})),Ou="getMatrixDataType",Cu=W(Ou,["typed"],(e=>{var{typed:t}=e;return t(Ou,{Array:function(e){return ut(e,L)},Matrix:function(e){return e.getDataType()}})})),_u="mode",Tu=W(_u,["typed","isNaN","isNumeric"],(e=>{var{typed:t,isNaN:r,isNumeric:n}=e;return t(_u,{"Array | Matrix":i,"...":function(e){return i(e)}});function i(e){if(0===(e=et(e.valueOf())).length)throw new Error("Cannot calculate mode of an empty array");for(var t={},i=[],a=0,o=0;oa&&(a=t[s],i=[s])}return i}})),Bu=W("bin",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("bin",{"number | BigNumber":function(e){return r(e,{notation:"bin"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"bin",wordSize:t})}})})),qu="acosh",zu=W(qu,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(qu,{number:function(e){return e>=1||r.predictable?fs(e):e<=-1?new n(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new n(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()},"Array | Matrix":function(e){return $t(e,this)}})})),Du="acsch",Iu=W(Du,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Du,{number:ds,Complex:function(e){return e.acsch()},BigNumber:function(e){return new r(1).div(e).asinh()},"Array | Matrix":function(e){return $t(e,this)}})})),ku=W("asinh",["typed"],(e=>{var{typed:t}=e;return t("asinh",{number:vs,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Ru=W("cos",["typed"],(e=>{var{typed:t}=e;return t("cos",{number:Math.cos,Complex:function(e){return e.cos()},BigNumber:function(e){return e.cos()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Fu=W("csc",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("csc",{number:Ns,Complex:function(e){return e.csc()},BigNumber:function(e){return new r(1).div(e.sin())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Uu=W("sin",["typed"],(e=>{var{typed:t}=e;return t("sin",{number:Math.sin,Complex:function(e){return e.sin()},BigNumber:function(e){return e.sin()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Pu="combinationsWithRep",ju=W(Pu,["typed"],(e=>{var{typed:t}=e;return t(Pu,{"number, number":function(e,t){if(!ce(e)||e<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!ce(t)||t<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e<1)throw new TypeError("k must be less than or equal to n + k - 1");return t{var{typed:t,config:r,on:n}=e,i=ru(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(i=ru(e.randomSeed))})),t(Hu,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,t)=>o(e,t),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,t)=>a(e,0,t),"Array | Matrix, number, number":(e,t,r)=>a(e,t,r)});function a(e,t,r){var n=au(e.valueOf(),(()=>o(t,r)));return f(e)?e.create(n):n}function o(e,t){return e+i()*(t-e)}})),Gu="isNegative",Vu=W(Gu,["typed"],(e=>{var{typed:t}=e;return t(Gu,{number:ha,BigNumber:function(e){return e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s<0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Zu=W("SparseMatrix",["typed","equalScalar","Matrix"],(e=>{var{typed:t,equalScalar:r,Matrix:n}=e;function o(e,t){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!c(t))throw new Error("Invalid datatype: "+t);if(f(e))!function(e,t,r){"SparseMatrix"===t.type?(e._values=t._values?$(t._values):void 0,e._index=$(t._index),e._ptr=$(t._ptr),e._size=$(t._size),e._datatype=r||t._datatype):s(e,t.valueOf(),r||t._datatype)}(this,e,t);else if(e&&l(e.index)&&l(e.ptr)&&l(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=t||e.datatype;else if(l(e))s(this,e,t);else{if(e)throw new TypeError("Unsupported type of data ("+L(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=t}}function s(e,n,i){e._values=[],e._index=[],e._ptr=[],e._datatype=i;var a=n.length,o=0,s=r,u=0;if(c(i)&&(s=t.find(r,[i,i])||r,u=t.convert(0,i)),a>0){var f=0;do{e._ptr.push(e._index.length);for(var p=0;p");for(var c=t.min()[0],l=t.min()[1],p=i[0],m=i[1],h=0;hd){for(f=d;fh){if(m){var y=0;for(f=0;fn-1&&(e._values.splice(p,1),e._index.splice(p,1),v++)}e._ptr[f]=e._values.length}return e._size[0]=n,e._size[1]=i,e}function v(e,t,r,n,i){var a,o,s=n[0],u=n[1],c=[];for(a=0;as-1||o>u-1)&&(g(this,Math.max(a+1,s),Math.max(o+1,u),i),s=this._size[0],u=this._size[1]),$e(a,s),$e(o,u);var m=h(a,this._ptr[o],this._ptr[o+1],this._index);return mArray.isArray(e)&&1===e.length?e[0]:e));if(2!==n.length)throw new Error("Only two dimensions matrix are supported");return n.forEach((function(e){if(!i(e)||!ce(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+De(n)+")")})),g(r?this.clone():this,n[0],n[1],t)},o.prototype.reshape=function(e,t){if(!l(e))throw new TypeError("Array expected");if(2!==e.length)throw new Error("Sparse matrices can only be reshaped in two dimensions");e.forEach((function(t){if(!i(t)||!ce(t)||t<=-2||0===t)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+De(e)+")")}));var r=this._size[0]*this._size[1];if(r!==(e=We(e,r))[0]*e[1])throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var n=t?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return n;for(var a=[],o=0;o=0&&w<=i&&y(e._values[b],w-0,g-0)}else{for(var N={},M=v;M "+(this._values?De(this._values[u],e):"X");return i},o.prototype.toString=function(){return De(this.toArray())},o.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},o.prototype.diagonal=function(e){if(e){if(a(e)&&(e=e.toNumber()),!i(e)||!ce(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var t=e>0?e:0,r=e<0?-e:0,n=this._size[0],s=this._size[1],u=Math.min(n-r,s-t),c=[],l=[],f=[];f[0]=0;for(var p=t;p0?s:0,g=s<0?-s:0,v=e[0],x=e[1],b=Math.min(v-g,x-y);if(l(n)){if(n.length!==b)throw new Error("Invalid value array length");d=function(e){return n[e]}}else if(f(n)){var w=n.size();if(1!==w.length||w[0]!==b)throw new Error("Invalid matrix length");d=function(e){return n.get([e])}}else d=function(){return n};for(var N=[],M=[],S=[],E=0;E=0&&A=u||i[l]!==t)){var p=n?n[c]:void 0;i.splice(l,0,t),n&&n.splice(l,0,p),i.splice(l<=c?c+1:c,1),n&&n.splice(l<=c?c+1:c,1)}else if(l=u||i[c]!==e)){var m=n?n[l]:void 0;i.splice(c,0,e),n&&n.splice(c,0,m),i.splice(c<=l?l+1:l,1),n&&n.splice(c<=l?l+1:l,1)}}},o}),{isClass:!0}),Wu="matrix",Ju=W(Wu,["typed","Matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,Matrix:r,DenseMatrix:n,SparseMatrix:i}=e;return t(Wu,{"":function(){return a([])},string:function(e){return a([],e)},"string, string":function(e,t){return a([],e,t)},Array:function(e){return a(e)},Matrix:function(e){return a(e,e.storage())},"Array | Matrix, string":a,"Array | Matrix, string, string":a});function a(e,t,r){if("dense"===t||"default"===t||void 0===t)return new n(e,r);if("sparse"===t)return new i(e,r);throw new TypeError("Unknown matrix type "+JSON.stringify(t)+".")}})),Yu=W("abs",["typed"],(e=>{var{typed:t}=e;return t("abs",{number:za,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},Fraction:function(e){return e.abs()},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.abs()}})})),Xu=W("algorithm01",["typed"],(e=>{var{typed:t}=e;return function(e,r,n,i){var a=e._data,o=e._size,s=e._datatype,u=r._values,c=r._index,l=r._ptr,f=r._size,p=r._datatype;if(o.length!==f.length)throw new Ue(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m,h,d=o[0],y=o[1],g="string"==typeof s&&s===p?s:void 0,v=g?t.find(n,[g,g]):n,x=[];for(m=0;m{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E,A=a&&l?[]:void 0,O=[],C=[],_=a&&l?[]:void 0,T=a&&l?[]:void 0,B=[],q=[];for(N=0;N{var{typed:t,DenseMatrix:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=i;"string"==typeof l&&(f=l,n=t.convert(n,f),h=t.find(i,[f,f]));for(var d=[],y=[],g=[],v=0;v{var{typed:t}=e;return function(e,n,i){var a,o=e._data,s=e._size,u=e._datatype,c=n._data,l=n._size,f=n._datatype,p=[];if(s.length!==l.length)throw new Ue(s.length,l.length);for(var m=0;m0?r(h,0,p,p[0],o,c):[];return e.createDenseMatrix({data:d,size:p,datatype:a})};function r(e,t,n,i,a,o){var s=[];if(t===n.length-1)for(var u=0;u{var{typed:t}=e;return function(e,n,i,a){var o,s=e._data,u=e._size,c=e._datatype,l=i;"string"==typeof c&&(o=c,n=t.convert(n,o),l=t.find(i,[o,o]));var f=u.length>0?r(l,0,u,u[0],s,n,a):[];return e.createDenseMatrix({data:f,size:$(u),datatype:o})};function r(e,t,n,i,a,o,s){var u=[];if(t===n.length-1)for(var c=0;c{var{typed:t,matrix:r,equalScalar:n,BigNumber:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=Qu({typed:t,equalScalar:n}),u=Ku({typed:t,DenseMatrix:a}),c=ec({typed:t}),l=tc({typed:t});return t("gcd",{"number, number":Ha,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var r=new i(0);!t.isZero();){var n=e.mod(t);e=t,t=n}return e.lt(r)?e.neg():e},"Fraction, Fraction":function(e,t){return e.gcd(t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return u(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return l(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return l(r(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,equalScalar:r}=e;return function(e,n,i,a){var o=e._data,s=e._size,u=e._datatype,c=n._values,l=n._index,f=n._ptr,p=n._size,m=n._datatype;if(s.length!==p.length)throw new Ue(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h,d=s[0],y=s[1],g=r,v=0,x=i;"string"==typeof u&&u===m&&(h=u,g=t.find(r,[h,h]),v=t.convert(0,h),x=t.find(i,[h,h]));for(var b=[],w=[],N=[],M=0;M{var{typed:t}=e;return function(e,r,n,i){var a=e._data,o=e._size,s=e._datatype,u=r._values,c=r._index,l=r._ptr,f=r._size,p=r._datatype;if(o.length!==f.length)throw new Ue(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m,h=o[0],d=o[1],y=0,g=n;"string"==typeof s&&s===p&&(m=s,y=t.convert(0,m),g=t.find(n,[m,m]));for(var v=[],x=0;x{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E=a&&l?[]:void 0,A=[],O=[],C=E?[]:void 0,_=E?[]:void 0,T=[],B=[];for(N=0;N{var{typed:t,equalScalar:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=r,d=0,y=i;"string"==typeof l&&(f=l,h=t.find(r,[f,f]),d=t.convert(0,f),n=t.convert(n,f),y=t.find(i,[f,f]));for(var g=[],v=[],x=[],b=0;b{var{typed:t,DenseMatrix:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=i;"string"==typeof l&&(f=l,n=t.convert(n,f),h=t.find(i,[f,f]));for(var d=[],y=[],g=[],v=0;v{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=nc({typed:t,equalScalar:n}),o=ic({typed:t}),s=ac({typed:t,equalScalar:n}),u=oc({typed:t,equalScalar:n}),c=sc({typed:t,DenseMatrix:i}),l=ec({typed:t}),f=tc({typed:t});return t("mod",{"number, number":Wa,"BigNumber, BigNumber":function(e,t){if(t.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return t.isZero()?e:e.mod(t)},"Fraction, Fraction":function(e,t){if(t.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return e.compare(0)>=0?e.mod(t):e.mod(t).add(t).mod(t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return f(e,t,this,!1)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return f(t,e,this,!0)},"Array, any":function(e,t){return f(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return f(r(t),e,this,!0).valueOf()}})})),cc=W("algorithm06",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._size,s=e._datatype,u=n._values,c=n._size,l=n._datatype;if(o.length!==c.length)throw new Ue(o.length,c.length);if(o[0]!==c[0]||o[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+c+")");var f,p=o[0],m=o[1],h=r,d=0,y=i;"string"==typeof s&&s===l&&(f=s,h=t.find(r,[f,f]),d=t.convert(0,f),y=t.find(i,[f,f]));for(var g=a&&u?[]:void 0,v=[],x=[],b=g?[]:void 0,w=[],N=[],M=0;M{var{typed:t,matrix:r,equalScalar:n,BigNumber:i}=e,a=Xu({typed:t}),o=nc({typed:t,equalScalar:n}),s=cc({typed:t,equalScalar:n}),u=oc({typed:t,equalScalar:n}),c=ec({typed:t}),l=tc({typed:t}),f="Complex number not supported in function nthRoot. Use nthRoots instead.";return t(lc,{number:function(e){return Ja(e,2)},"number, number":Ja,BigNumber:function(e){return p(e,new i(2))},Complex:function(e){throw new Error(f)},"Complex, number":function(e,t){throw new Error(f)},"BigNumber, BigNumber":p,"Array | Matrix":function(e){return this(e,2)},"SparseMatrix, SparseMatrix":function(e,t){if(1===t.density())return s(e,t,this);throw new Error("Root must be non-zero")},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){if(1===t.density())return a(e,t,this,!1);throw new Error("Root must be non-zero")},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){if(1===t.density())return u(t,e,this,!0);throw new Error("Root must be non-zero")},"number | BigNumber, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}});function p(e,t){var r=i.precision,n=i.clone({precision:r+2}),a=new i(0),o=new n(1),s=t.isNegative();if(s&&(t=t.neg()),t.isZero())throw new Error("Root must be non-zero");if(e.isNegative()&&!t.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(e.isZero())return s?new n(1/0):0;if(!e.isFinite())return s?a:e;var u=e.abs().pow(o.div(t));return u=e.isNeg()?u.neg():u,new i((s?o.div(u):u).toPrecision(r))}})),pc="xgcd",mc=W(pc,["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t(pc,{"number, number":function(e,t){var i=Qa(e,t);return"Array"===r.matrix?i:n(i)},"BigNumber, BigNumber":function(e,t){var a,o,s,u,c=new i(0),l=new i(1),f=c,p=l,m=l,h=c;if(!e.isInt()||!t.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!t.isZero();)o=e.div(t).floor(),s=e.mod(t),a=f,f=p.minus(o.times(f)),p=a,a=m,m=h.minus(o.times(m)),h=a,e=t,t=s;return u=e.lt(c)?[e.neg(),p.neg(),h.neg()]:[e,e.isZero()?0:p,h],"Array"===r.matrix?u:n(u)}})})),hc="bitAnd",dc=W(hc,["typed","matrix","equalScalar"],(e=>{var{typed:t,matrix:r,equalScalar:n}=e,i=nc({typed:t,equalScalar:n}),a=cc({typed:t,equalScalar:n}),o=oc({typed:t,equalScalar:n}),s=ec({typed:t}),u=tc({typed:t});return t(hc,{"number, number":So,"BigNumber, BigNumber":ho,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),yc=W("algorithm07",["typed","DenseMatrix"],(e=>{var{typed:t,DenseMatrix:r}=e;return function(e,i,a){var o=e._size,s=e._datatype,u=i._size,c=i._datatype;if(o.length!==u.length)throw new Ue(o.length,u.length);if(o[0]!==u[0]||o[1]!==u[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+u+")");var l,f,p,m=o[0],h=o[1],d=0,y=a;"string"==typeof s&&s===c&&(l=s,d=t.convert(0,l),y=t.find(a,[l,l]));var g=[];for(f=0;f{var{typed:t,matrix:r,DenseMatrix:n}=e,i=ic({typed:t}),a=yc({typed:t,DenseMatrix:n}),o=sc({typed:t,DenseMatrix:n}),s=ec({typed:t}),u=tc({typed:t});return t(gc,{"number, number":Oo,"BigNumber, BigNumber":bo,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),xc=W("or",["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=ic({typed:t}),o=ac({typed:t,equalScalar:n}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t("or",{"number, number":Ro,"Complex, Complex":function(e,t){return 0!==e.re||0!==e.im||0!==t.re||0!==t.im},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!e.isNaN()||!t.isZero()&&!t.isNaN()},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})})),bc="diag",wc=W(bc,["typed","matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:r,DenseMatrix:n,SparseMatrix:i}=e;return t(bc,{Array:function(e){return a(e,0,je(e),null)},"Array, number":function(e,t){return a(e,t,je(e),null)},"Array, BigNumber":function(e,t){return a(e,t.toNumber(),je(e),null)},"Array, string":function(e,t){return a(e,0,je(e),t)},"Array, number, string":function(e,t,r){return a(e,t,je(e),r)},"Array, BigNumber, string":function(e,t,r){return a(e,t.toNumber(),je(e),r)},Matrix:function(e){return a(e,0,e.size(),e.storage())},"Matrix, number":function(e,t){return a(e,t,e.size(),e.storage())},"Matrix, BigNumber":function(e,t){return a(e,t.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,t){return a(e,0,e.size(),t)},"Matrix, number, string":function(e,t,r){return a(e,t,e.size(),r)},"Matrix, BigNumber, string":function(e,t,r){return a(e,t.toNumber(),e.size(),r)}});function a(e,t,a,o){if(!ce(t))throw new TypeError("Second parameter in function diag must be an integer");var s=t>0?t:0,u=t<0?-t:0;switch(a.length){case 1:return function(e,t,r,a,o,s){var u=[a+o,a+s];if(r&&"sparse"!==r&&"dense"!==r)throw new TypeError("Unknown matrix type ".concat(r,'"'));var c="sparse"===r?i.diagonal(u,e,t):n.diagonal(u,e,t);return null!==r?c:c.valueOf()}(e,t,o,a[0],u,s);case 2:return function(e,t,n,i,a,o){if(f(e)){var s=e.diagonal(t);return null!==n?n!==s.storage()?r(s,n):s:s.valueOf()}for(var u=Math.min(i[0]-a,i[1]-o),c=[],l=0;l{var{typed:t,config:r,matrix:n,BigNumber:i,DenseMatrix:o,SparseMatrix:s}=e;return t(Nc,{"":function(){return"Matrix"===r.matrix?n([]):[]},string:function(e){return n(e)},"number | BigNumber":function(e){return c(e,e,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, string":function(e,t){return c(e,e,t)},"number | BigNumber, number | BigNumber":function(e,t){return c(e,t,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(e,t,r){return c(e,t,r)},Array:function(e){return u(e)},"Array, string":function(e,t){return u(e,t)},Matrix:function(e){return u(e.valueOf(),e.storage())},"Matrix, string":function(e,t){return u(e.valueOf(),t)}});function u(e,t){switch(e.length){case 0:return t?n(t):[];case 1:return c(e[0],e[0],t);case 2:return c(e[0],e[1],t);default:throw new Error("Vector containing two values expected")}}function c(e,t,r){var n=a(e)||a(t)?i:null;if(a(e)&&(e=e.toNumber()),a(t)&&(t=t.toNumber()),!ce(e)||e<1)throw new Error("Parameters in function identity must be positive integers");if(!ce(t)||t<1)throw new Error("Parameters in function identity must be positive integers");var u=n?new i(1):1,c=n?new n(0):0,l=[e,t];if(r){if("sparse"===r)return s.diagonal(l,u,0,c);if("dense"===r)return o.diagonal(l,u,0,c);throw new TypeError('Unknown matrix type "'.concat(r,'"'))}for(var f=Ge([],l,c),p=e{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t("ones",{"":function(){return"Array"===r.matrix?o([]):o([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return o(e,t)}return"Array"===r.matrix?o(e):o(e,"default")},Array:o,Matrix:function(e){var t=e.storage();return o(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return o(e.valueOf(),t)}});function o(e,t){var r=function(e){var t=!1;return e.forEach((function(e,r,n){a(e)&&(t=!0,n[r]=e.toNumber())})),t}(e)?new i(1):1;if(function(e){e.forEach((function(e){if("number"!=typeof e||!ce(e)||e<0)throw new Error("Parameters in function ones must be positive integers")}))}(e),t){var o=n(t);return e.length>0?o.resize(e,r):o}var s=[];return e.length>0?Ge(s,e,r):s}})),Ec="reshape",Ac=W(Ec,["typed","isInteger","matrix"],(e=>{var{typed:t,isInteger:r}=e;return t(Ec,{"Matrix, Array":function(e,t){return e.reshape(t)},"Array, Array":function(e,t){return t.forEach((function(e){if(!r(e))throw new TypeError("Invalid size for dimension: "+e)})),Ze(e,t)}})})),Oc="size",Cc=W(Oc,["typed","config","?matrix"],(e=>{var{typed:t,config:r,matrix:n}=e;return t(Oc,{Matrix:function(e){return e.create(e.size())},Array:je,string:function(e){return"Array"===r.matrix?[e.length]:n([e.length])},"number | Complex | BigNumber | Unit | boolean | null":function(e){return"Array"===r.matrix?[]:n?n([]):fr()}})})),_c="zeros",Tc=W(_c,["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t(_c,{"":function(){return"Array"===r.matrix?o([]):o([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return o(e,t)}return"Array"===r.matrix?o(e):o(e,"default")},Array:o,Matrix:function(e){var t=e.storage();return o(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return o(e.valueOf(),t)}});function o(e,t){var r=function(e){var t=!1;return e.forEach((function(e,r,n){a(e)&&(t=!0,n[r]=e.toNumber())})),t}(e)?new i(0):0;if(function(e){e.forEach((function(e){if("number"!=typeof e||!ce(e)||e<0)throw new Error("Parameters in function zeros must be positive integers")}))}(e),t){var o=n(t);return e.length>0?o.resize(e,r):o}var s=[];return e.length>0?Ge(s,e,r):s}})),Bc=W("hex",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("hex",{"number | BigNumber":function(e){return r(e,{notation:"hex"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"hex",wordSize:t})}})}));function qc(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function zc(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Dc(e){for(var t=1;t{var{typed:t,matrix:r,equalScalar:n,zeros:i,BigNumber:a,DenseMatrix:o}=e,s=oc({typed:t,equalScalar:n}),u=sc({typed:t,DenseMatrix:o}),c=tc({typed:t});return t(kc,Dc(Dc({},Fc),{},{Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw new TypeError(Ic);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(Ic);var r=t.toNumber();return e.round(r)},"number, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(Ic);return new a(e).toDecimalPlaces(t.toNumber())},BigNumber:function(e){return e.toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(Ic);return e.toDecimalPlaces(t.toNumber())},Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw new TypeError(Ic);return e.round(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"SparseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | Complex | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):u(t,e,this,!0)},"number | Complex | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return c(r(e),t,this,!1).valueOf()},"number | Complex | BigNumber, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}}))})),Fc={number:eo,"number, number":function(e,t){if(!ce(t))throw new TypeError(Ic);if(t<0||t>15)throw new Error("Number of decimals in function round must be in the range of 0-15");return eo(e,t)}},Uc=W("algorithm08",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");if(!a||!l)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));for(var w,N,M,S,E=[],A=[],O=[],C=[],_=[],T=0;T{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=nc({typed:t,equalScalar:n}),u=Uc({typed:t,equalScalar:n}),c=Ku({typed:t,DenseMatrix:a}),l=oc({typed:t,equalScalar:n}),f=ec({typed:t}),p=tc({typed:t});return t(Pc,{"number, number":Co,"BigNumber, BigNumber":wo,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Lc="rightLogShift",Hc=W(Lc,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=nc({typed:t,equalScalar:n}),u=Uc({typed:t,equalScalar:n}),c=Ku({typed:t,DenseMatrix:a}),l=oc({typed:t,equalScalar:n}),f=ec({typed:t}),p=tc({typed:t});return t(Lc,{"number, number":To,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})})),$c="compare",Gc=W($c,["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],(e=>{var{typed:t,config:r,equalScalar:n,matrix:i,BigNumber:a,Fraction:o,DenseMatrix:s}=e,u=ic({typed:t}),c=ac({typed:t,equalScalar:n}),l=sc({typed:t,DenseMatrix:s}),f=ec({typed:t}),p=tc({typed:t});return t($c,{"boolean, boolean":function(e,t){return e===t?0:e>t?1:-1},"number, number":function(e,t){return Se(e,t,r.epsilon)?0:e>t?1:-1},"BigNumber, BigNumber":function(e,t){return Na(e,t,r.epsilon)?new a(0):new a(e.cmp(t))},"Fraction, Fraction":function(e,t){return new o(e.compare(t))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return c(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(i(e),i(t)).valueOf()},"Array, Matrix":function(e,t){return this(i(e),t)},"Matrix, Array":function(e,t){return this(e,i(t))},"SparseMatrix, any":function(e,t){return l(e,t,this,!1)},"DenseMatrix, any":function(e,t){return p(e,t,this,!1)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(i(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(i(t),e,this,!0).valueOf()}})})),Vc="compareText",Zc=W(Vc,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e,n=ec({typed:t}),i=tc({typed:t});return t(Vc,{"any, any":Fe,"DenseMatrix, DenseMatrix":function(e,t){return n(e,t,Fe)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"DenseMatrix, any":function(e,t){return i(e,t,Fe,!1)},"any, DenseMatrix":function(e,t){return i(t,e,Fe,!0)},"Array, any":function(e,t){return i(r(e),t,Fe,!1).valueOf()},"any, Array":function(e,t){return i(r(t),e,Fe,!0).valueOf()}})})),Wc="smaller",Jc=W(Wc,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Wc,{"boolean, boolean":function(e,t){return e{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Yc,{"boolean, boolean":function(e,t){return e>t},"number, number":function(e,t){return e>t&&!Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gt(t)&&!Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return 1===e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),Qc="unequal",Kc=W(Qc,["typed","config","equalScalar","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,equalScalar:n,matrix:i,DenseMatrix:a}=e,o=ic({typed:t}),s=yc({typed:t,DenseMatrix:a}),u=sc({typed:t,DenseMatrix:a}),c=ec({typed:t}),l=tc({typed:t});return t("unequal",{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:f(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,f)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,f,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,f,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,f)},"Array, Array":function(e,t){return this(i(e),i(t)).valueOf()},"Array, Matrix":function(e,t){return this(i(e),t)},"Matrix, Array":function(e,t){return this(e,i(t))},"SparseMatrix, any":function(e,t){return u(e,t,f,!1)},"DenseMatrix, any":function(e,t){return l(e,t,f,!1)},"any, SparseMatrix":function(e,t){return u(t,e,f,!0)},"any, DenseMatrix":function(e,t){return l(t,e,f,!0)},"Array, any":function(e,t){return l(i(e),t,f,!1).valueOf()},"any, Array":function(e,t){return l(i(t),e,f,!0).valueOf()}});function f(e,t){return!n(e,t)}})),el=(W(Qc,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return t(Qc,{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:!r(e,t)}})})),W("ImmutableDenseMatrix",["smaller","DenseMatrix"],(e=>{var{smaller:t,DenseMatrix:r}=e;function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!c(t))throw new Error("Invalid datatype: "+t);if(f(e)||l(e)){var i=new r(e,t);this._data=i._data,this._size=i._size,this._datatype=i._datatype,this._min=null,this._max=null}else if(e&&l(e.data)&&l(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=void 0!==e.min?e.min:null,this._max=void 0!==e.max?e.max:null;else{if(e)throw new TypeError("Unsupported type of data ("+L(e)+")");this._data=[],this._size=[0],this._datatype=t,this._min=null,this._max=null}}return n.prototype=new r,n.prototype.type="ImmutableDenseMatrix",n.prototype.isImmutableDenseMatrix=!0,n.prototype.subset=function(e){switch(arguments.length){case 1:var t=r.prototype.subset.call(this,e);return f(t)?new n({data:t._data,size:t._size,datatype:t._datatype}):t;case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},n.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},n.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},n.prototype.clone=function(){return new n({data:$(this._data),size:$(this._size),datatype:this._datatype})},n.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.fromJSON=function(e){return new n(e)},n.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},n.prototype.min=function(){if(null===this._min){var e=null;this.forEach((function(r){(null===e||t(r,e))&&(e=r)})),this._min=null!==e?e:void 0}return this._min},n.prototype.max=function(){if(null===this._max){var e=null;this.forEach((function(r){(null===e||t(e,r))&&(e=r)})),this._max=null!==e?e:void 0}return this._max},n}),{isClass:!0})),tl=W("FibonacciHeap",["smaller","larger"],(e=>{var{smaller:t,larger:r}=e,n=1/Math.log((1+Math.sqrt(5))/2);function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}function a(e,t,r){t.left.right=t.right,t.right.left=t.left,r.degree--,r.child===t&&(r.child=t.right),0===r.degree&&(r.child=null),t.left=e,t.right=e.right,e.right=t,t.right.left=t,t.parent=null,t.mark=!1}function o(e,t){var r=t.parent;r&&(t.mark?(a(e,t,r),o(r)):t.mark=!0)}i.prototype.type="FibonacciHeap",i.prototype.isFibonacciHeap=!0,i.prototype.insert=function(e,r){var n={key:e,value:r,degree:0};if(this._minimum){var i=this._minimum;n.left=i,n.right=i.right,i.right=n,n.right.left=n,t(e,i.key)&&(this._minimum=n)}else n.left=n,n.right=n,this._minimum=n;return this._size++,n},i.prototype.size=function(){return this._size},i.prototype.clear=function(){this._minimum=null,this._size=0},i.prototype.isEmpty=function(){return 0===this._size},i.prototype.extractMinimum=function(){var e=this._minimum;if(null===e)return e;for(var i=this._minimum,a=e.degree,o=e.child;a>0;){var u=o.right;o.left.right=o.right,o.right.left=o.left,o.left=i,o.right=i.right,i.right=o,o.right.left=o,o.parent=null,o=u,a--}return e.left.right=e.right,e.right.left=e.left,i=e===e.right?null:function(e,i){var a,o=Math.floor(Math.log(i)*n)+1,u=new Array(o),c=0,l=e;if(l)for(c++,l=l.right;l!==e;)c++,l=l.right;for(;c>0;){for(var f=l.degree,p=l.right;a=u[f];){if(r(l.key,a.key)){var m=a;a=l,l=m}s(a,l),u[f]=null,f++}u[f]=l,l=p,c--}e=null;for(var h=0;h{var{typed:t,SparseMatrix:r}=e;return t(rl,{"":function(){return new r([])},string:function(e){return new r([],e)},"Array | Matrix":function(e){return new r(e)},"Array | Matrix, string":function(e,t){return new r(e,t)}})})),il="acoth",al=W(il,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(il,{number:function(e){return e>=1||e<=-1||r.predictable?ms(e):new n(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new i(1).div(e).atanh()},"Array | Matrix":function(e){return $t(e,this)}})})),ol=W("algorithm09",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E,A=a&&l?[]:void 0,O=[],C=[],_=A?[]:void 0,T=[];for(N=0;N{var{typed:t,matrix:r,equalScalar:n,BigNumber:i,DenseMatrix:a}=e,o=nc({typed:t,equalScalar:n}),s=ic({typed:t}),u=ol({typed:t,equalScalar:n}),c=oc({typed:t,equalScalar:n}),l=sc({typed:t,DenseMatrix:a}),f=ec({typed:t}),p=tc({typed:t});return t(sl,{"number, number":Math.atan2,"BigNumber, BigNumber":function(e,t){return i.atan2(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return l(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return p(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return p(r(t),e,this,!0).valueOf()}})})),cl=W("sec",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("sec",{number:Ss,Complex:function(e){return e.sec()},BigNumber:function(e){return new r(1).div(e.cos())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),ll=W("add",["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:r,addScalar:n,equalScalar:i,DenseMatrix:a,SparseMatrix:o}=e,s=Xu({typed:t}),u=Qu({typed:t,equalScalar:i}),c=Ku({typed:t,DenseMatrix:a}),l=ec({typed:t}),f=tc({typed:t});return t("add",G({"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,n)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,n,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,n,!0)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,n)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"DenseMatrix, any":function(e,t){return f(e,t,n,!1)},"SparseMatrix, any":function(e,t){return c(e,t,n,!1)},"any, DenseMatrix":function(e,t){return f(t,e,n,!0)},"any, SparseMatrix":function(e,t){return c(t,e,n,!0)},"Array, any":function(e,t){return f(r(e),t,n,!1).valueOf()},"any, Array":function(e,t){return f(r(t),e,n,!0).valueOf()},"any, any":n,"any, any, ...any":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,addScalar:r,multiplyScalar:n,conj:i,size:a}=e;return t("dot",{"Array | DenseMatrix, Array | DenseMatrix":function(e,a){var u=o(e,a),c=f(e)?e._data:e,l=f(e)?e._datatype:void 0,p=f(a)?a._data:a,m=f(a)?a._datatype:void 0,h=2===s(e).length,d=2===s(a).length,y=r,g=n;if(l&&m&&l===m&&"string"==typeof l){var v=l;y=t.find(r,[v,v]),g=t.find(n,[v,v])}if(!h&&!d){for(var x=g(i(c[0]),p[0]),b=1;bd?m++:h===d&&(c=l(c,f(a[p],u[m])),p++,m++)}return c}});function o(e,t){var r,n,i=s(e),a=s(t);if(1===i.length)r=i[0];else{if(2!==i.length||1!==i[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+i.join(", ")+")");r=i[0]}if(1===a.length)n=a[0];else{if(2!==a.length||1!==a[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+a.join(", ")+")");n=a[0]}if(r!==n)throw new RangeError("Vectors must have equal length ("+r+" != "+n+")");if(0===r)throw new RangeError("Cannot calculate the dot product of empty vectors");return r}function s(e){return f(e)?e.size():a(e)}})),pl="composition",ml=W(pl,["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],(e=>{var{typed:t,addScalar:r,combinations:n,isPositive:i,isNegative:a,isInteger:o,larger:s}=e;return t(pl,{"number | BigNumber, number | BigNumber":function(e,t){if(!(o(e)&&i(e)&&o(t)&&i(t)))throw new TypeError("Positive integer value expected in function composition");if(s(t,e))throw new TypeError("k must be less than or equal to n in function composition");return n(r(e,-1),r(t,-1))}})})),hl="isZero",dl=W(hl,["typed"],(e=>{var{typed:t}=e;return t(hl,{number:ya,BigNumber:function(e){return e.isZero()},Complex:function(e){return 0===e.re&&0===e.im},Fraction:function(e){return 1===e.d&&0===e.n},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),yl="matrixFromFunction",gl=W(yl,["typed","matrix","isZero"],(e=>{var{typed:t,matrix:r,isZero:n}=e;return t(yl,{"Array | Matrix, function, string, string":function(e,t,r,n){return i(e,t,r,n)},"Array | Matrix, function, string":function(e,t,r){return i(e,t,r)},"Matrix, function":function(e,t){return i(e,t,"dense")},"Array, function":function(e,t){return i(e,t,"dense").toArray()},"Array | Matrix, string, function":function(e,t,r){return i(e,r,t)},"Array | Matrix, string, string, function":function(e,t,r,n){return i(e,n,t,r)}});function i(e,t,i,a){var o;return(o=void 0!==a?r(i,a):r(i)).resize(e),o.forEach((function(e,r){var i=t(r);n(i)||o.set(r,i)})),o}})),vl="cbrt",xl=W(vl,["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],(e=>{var{config:t,typed:r,isNegative:n,unaryMinus:i,matrix:u,Complex:c,BigNumber:l,Fraction:f}=e;return r(vl,{number:Fa,Complex:p,"Complex, boolean":p,BigNumber:function(e){return e.cbrt()},Unit:function(e){if(e.value&&o(e.value)){var t=e.clone();return t.value=1,(t=t.pow(1/3)).value=p(e.value),t}var r,u=n(e.value);u&&(e.value=i(e.value)),r=a(e.value)?new l(1).div(3):s(e.value)?new f(1,3):1/3;var c=e.pow(r);return u&&(c.value=i(c.value)),c},"Array | Matrix":function(e){return $t(e,this,!0)}});function p(e,r){var n=e.arg()/3,i=e.abs(),a=new c(Fa(i),0).mul(new c(0,n).exp());if(r){var o=[a,new c(Fa(i),0).mul(new c(0,n+2*Math.PI/3).exp()),new c(Fa(i),0).mul(new c(0,n-2*Math.PI/3).exp())];return"Array"===t.matrix?o:u(o)}return a}})),bl=W("floor",["typed","config","round","matrix","equalScalar"],(e=>{var{typed:t,config:r,round:n,matrix:i,equalScalar:a}=e,o=oc({typed:t,equalScalar:a}),s=tc({typed:t});return t("floor",{number:function(e){return Se(e,n(e),r.epsilon)?n(e):Math.floor(e)},"number, number":function(e,t){if(Se(e,n(e,t),r.epsilon))return n(e,t);var[i,a]="".concat(e,"e").split("e"),o=Math.floor(Number("".concat(i,"e").concat(Number(a)+t)));return[i,a]="".concat(o,"e").split("e"),Number("".concat(i,"e").concat(Number(a)-t))},Complex:function(e){return e.floor()},"Complex, number":function(e,t){return e.floor(t)},BigNumber:function(e){return Na(e,n(e),r.epsilon)?n(e):e.floor()},"BigNumber, BigNumber":function(e,t){return Na(e,n(e,t),r.epsilon)?n(e,t):e.toDecimalPlaces(t.toNumber(),Qn.ROUND_FLOOR)},Fraction:function(e){return e.floor()},"Fraction, number":function(e,t){return e.floor(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"Array | Matrix, number":function(e,t){return $t(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"number | Complex | BigNumber, Array":function(e,t){return s(i(t),e,this,!0).valueOf()}})})),wl="multiply",Nl=W(wl,["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],(e=>{var{typed:t,matrix:r,addScalar:n,multiplyScalar:i,equalScalar:a,dot:o}=e,s=oc({typed:t,equalScalar:a}),u=tc({typed:t});function c(e,t){switch(e.length){case 1:switch(t.length){case 1:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;case 2:switch(t.length){case 1:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+t[0]+")");break;case 2:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}}var l=t("_multiplyMatrixVector",{"DenseMatrix, any":function(e,r){var a,o=e._data,s=e._size,u=e._datatype,c=r._data,l=r._datatype,f=s[0],p=s[1],m=n,h=i;u&&l&&u===l&&"string"==typeof u&&(a=u,m=t.find(n,[a,a]),h=t.find(i,[a,a]));for(var d=[],y=0;yA)for(var C=0,_=0;_{var{typed:t,matrix:r,equalScalar:n,multiplyScalar:i}=e,a=nc({typed:t,equalScalar:n}),o=ol({typed:t,equalScalar:n}),s=oc({typed:t,equalScalar:n}),u=ec({typed:t}),c=tc({typed:t});return t(Ml,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,i)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,i,!1)},"DenseMatrix, any":function(e,t){return c(e,t,i,!1)},"any, SparseMatrix":function(e,t){return s(t,e,i,!0)},"any, DenseMatrix":function(e,t){return c(t,e,i,!0)},"Array, any":function(e,t){return c(r(e),t,i,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,i,!0).valueOf()}})})),El=W("re",["typed"],(e=>{var{typed:t}=e;return t("re",{number:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Complex:function(e){return e.re},"Array | Matrix":function(e){return $t(e,this)}})})),Al="flatten",Ol=W(Al,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t(Al,{Array:function(e){return et($(e))},Matrix:function(e){var t=et($(e.toArray()));return r(t)}})}));function Cl(e,t,r,n){if(!(this instanceof Cl))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=t,this.min=r,this.max=n,this.message="Wrong number of arguments in function "+e+" ("+t+" provided, "+r+(null!=n?"-"+n:"")+" expected)",this.stack=(new Error).stack}Cl.prototype=new Error,Cl.prototype.constructor=Error,Cl.prototype.name="ArgumentsError",Cl.prototype.isArgumentsError=!0;var _l=W("resize",["config","matrix"],(e=>{var{config:t,matrix:r}=e;return function(e,i,o){if(2!==arguments.length&&3!==arguments.length)throw new Cl("resize",arguments.length,2,3);if(f(i)&&(i=i.valueOf()),a(i[0])&&(i=i.map((function(e){return a(e)?e.toNumber():e}))),f(e))return e.resize(i,o,!0);if("string"==typeof e)return n(e,i,o);var s=!Array.isArray(e)&&"Array"!==t.matrix;if(0===i.length){for(;Array.isArray(e);)e=e[0];return $(e)}Array.isArray(e)||(e=[e]);var u=Ge(e=$(e),i,o);return s?r(u):u};function n(e,t,r){if(void 0!==r){if("string"!=typeof r||1!==r.length)throw new TypeError("Single character expected as defaultValue")}else r=" ";if(1!==t.length)throw new Ue(t.length,1);var n=t[0];if("number"!=typeof n||!ce(n))throw new TypeError("Invalid size, must contain positive integers (size: "+De(t)+")");if(e.length>n)return e.substring(0,n);if(e.length{var{typed:t,matrix:r}=e;return t(Tl,{Array:function(e){return Ye($(e))},Matrix:function(e){var t=Ye(e.toArray());return Array.isArray(t)?r(t):t},any:function(e){return $(e)}})})),ql=W("to",["typed","matrix"],(e=>{var{typed:t,matrix:r}=e,n=ec({typed:t}),i=tc({typed:t});return t("to",{"Unit, Unit | string":function(e,t){return e.to(t)},"Matrix, Matrix":function(e,t){return n(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"Matrix, any":function(e,t){return i(e,t,this,!1)},"any, Matrix":function(e,t){return i(t,e,this,!0)},"Array, any":function(e,t){return i(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return i(r(t),e,this,!0).valueOf()}})})),zl=W("pow",["typed","config","identity","multiply","matrix","fraction","number","Complex"],(e=>{var{typed:t,config:r,identity:n,multiply:i,matrix:a,number:o,fraction:s,Complex:u}=e;return t("pow",{"number, number":c,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(e,t){return t.isInteger()||e>=0||r.predictable?e.pow(t):new u(e.toNumber(),0).pow(t.toNumber(),0)},"Fraction, Fraction":function(e,t){var n=e.pow(t);if(null!=n)return n;if(r.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return c(e.valueOf(),t.valueOf())},"Array, number":l,"Array, BigNumber":function(e,t){return l(e,t.toNumber())},"Matrix, number":f,"Matrix, BigNumber":function(e,t){return f(e,t.toNumber())},"Unit, number | BigNumber":function(e,t){return e.pow(t)}});function c(e,t){if(r.predictable&&!ce(t)&&e<0)try{var n=s(t),i=o(n);if((t===i||Math.abs((t-i)/t)<1e-14)&&n.d%2==1)return(n.n%2==0?1:-1)*Math.pow(-e,t)}catch(e){}return r.predictable&&(e<-1&&t===1/0||e>-1&&e<0&&t===-1/0)?NaN:ce(t)||e>=0||r.predictable?Ka(e,t):e*e<1&&t===1/0||e*e>1&&t===-1/0?0:new u(e,0).pow(t,0)}function l(e,t){if(!ce(t)||t<0)throw new TypeError("For A^b, b must be a positive integer (value is "+t+")");var r=je(e);if(2!==r.length)throw new Error("For A^b, A must be 2 dimensional (A has "+r.length+" dimensions)");if(r[0]!==r[1])throw new Error("For A^b, A must be square (size is "+r[0]+"x"+r[1]+")");for(var a=n(r[0]).valueOf(),o=e;t>=1;)1==(1&t)&&(a=i(o,a)),t>>=1,o=i(o,o);return a}function f(e,t){return a(l(e.valueOf(),t))}})),Dl="dotPow",Il=W(Dl,["typed","equalScalar","matrix","pow","DenseMatrix"],(e=>{var{typed:t,equalScalar:r,matrix:n,pow:i,DenseMatrix:a}=e,o=ic({typed:t}),s=yc({typed:t,DenseMatrix:a}),u=oc({typed:t,equalScalar:r}),c=sc({typed:t,DenseMatrix:a}),l=ec({typed:t}),f=tc({typed:t});return t(Dl,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,i)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return f(e,t,this,!1)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return f(t,e,this,!0)},"Array, any":function(e,t){return f(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return f(n(t),e,this,!0).valueOf()}})})),kl="rightArithShift",Rl=W(kl,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=nc({typed:t,equalScalar:n}),u=Uc({typed:t,equalScalar:n}),c=Ku({typed:t,DenseMatrix:a}),l=oc({typed:t,equalScalar:n}),f=ec({typed:t}),p=tc({typed:t});return t(kl,{"number, number":_o,"BigNumber, BigNumber":No,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Fl=r(228),Ul="compareNatural",Pl=W(Ul,["typed","compare"],(e=>{var{typed:t,compare:r}=e,n=r.signatures["boolean,boolean"];return t(Ul,{"any, any":function(e,t){var o,s=L(e),u=L(t);if(!("number"!==s&&"BigNumber"!==s&&"Fraction"!==s||"number"!==u&&"BigNumber"!==u&&"Fraction"!==u))return"0"!==(o=r(e,t)).toString()?o>0?1:-1:Fl(s,u);if("Array"===s||"Matrix"===s||"Array"===u||"Matrix"===u)return 0!==(o=i(this,e,t))?o:Fl(s,u);if(s!==u)return Fl(s,u);if("Complex"===s)return function(e,t){return e.re>t.re?1:e.ret.im?1:e.imr.length?1:t.length{var{typed:t,compareText:r,isZero:n}=e;return t(jl,{"any, any":function(e,t){return n(r(e,t))}})})),Hl="largerEq",$l=W(Hl,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Hl,{"boolean, boolean":function(e,t){return e>=t},"number, number":function(e,t){return e>=t||Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gte(t)||Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return-1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),Gl="partitionSelect",Vl=W(Gl,["typed","isNumeric","isNaN","compare"],(e=>{var{typed:t,isNumeric:r,isNaN:n,compare:i}=e,a=i,o=(e,t)=>-i(e,t);return t(Gl,{"Array | Matrix, number":function(e,t){return s(e,t,a)},"Array | Matrix, number, string":function(e,t,r){if("asc"===r)return s(e,t,a);if("desc"===r)return s(e,t,o);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":s});function s(e,t,r){if(!ce(t)||t<0)throw new Error("k must be a non-negative integer");if(f(e)){if(e.size().length>1)throw new Error("Only one dimensional matrices supported");return u(e.valueOf(),t,r)}if(Array.isArray(e))return u(e,t,r)}function u(e,t,i){if(t>=e.length)throw new Error("k out of bounds");for(var a=0;a=0){var f=e[c];e[c]=e[u],e[u]=f,--c}else++u;i(e[u],l)>0&&--u,t<=u?s=u:o=u+1}return e[t]}})),Zl=W("Index",["ImmutableDenseMatrix"],(e=>{var{ImmutableDenseMatrix:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var t=0,i=arguments.length;t{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(Wl,{number:function(e){if(e<=1&&e>=-1||r.predictable){var t=1/e;if(t>0||r.predictable)return gs(e);var i=Math.sqrt(t*t-1);return new n(Math.log(i-t),Math.PI)}return new n(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new i(1).div(e).acosh()},"Array | Matrix":function(e){return $t(e,this)}})})),Yl=W("tan",["typed"],(e=>{var{typed:t}=e;return t("tan",{number:Math.tan,Complex:function(e){return e.tan()},BigNumber:function(e){return e.tan()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Xl="setDifference",Ql=W(Xl,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Xl,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(0===n(r(e),new a(0)))s=[];else{if(0===n(r(t),new a(0)))return et(e.toArray());var u,c=ot(et(Array.isArray(e)?e:e.toArray()).sort(i)),l=ot(et(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var f=0;f{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Kl,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(0===n(r(e),new a(0))||0===n(r(t),new a(0)))s=[];else{var u=ot(et(Array.isArray(e)?e:e.toArray()).sort(i)),c=ot(et(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var l=0;l{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(tf,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,t){if(0===n(r(t),new a(0)))return 0;for(var o=et(Array.isArray(t)?t:t.toArray()),s=0,u=0;u{var{typed:t,compareNatural:r}=e;return t(nf,{"Array | Matrix":function(e){return Array.isArray(e)?et(e).length:et(e.toArray()).length},"Array | Matrix, boolean":function(e,t){if(!1===t||0===e.length)return Array.isArray(e)?et(e).length:et(e.toArray()).length;for(var n=et(Array.isArray(e)?e:e.toArray()).sort(r),i=1,a=1;a{var{typed:t,matrix:r,add:n}=e;return t("trace",{Array:function(e){return i(r(e))},SparseMatrix:function(e){var t=e._values,r=e._index,i=e._ptr,a=e._size,o=a[0],s=a[1];if(o===s){var u=0;if(t.length>0)for(var c=0;cc)break}return u}throw new RangeError("Matrix must be square (size: "+De(a)+")")},DenseMatrix:i,any:$});function i(e){var t=e._size,r=e._data;switch(t.length){case 1:if(1===t[0])return $(r[0]);throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:var i=t[0];if(i===t[1]){for(var a=0,o=0;o{var{typed:t,add:r,multiply:n,partitionSelect:o,compare:s}=e;function u(e,t,a){var u=et(e),l=u.length;if(0===l)throw new Error("Cannot calculate quantile of an empty sequence");if(i(t)){var f=t*(l-1),p=f%1;if(0===p){var m=a?u[f]:o(u,f);return c(m),m}var h,d,y=Math.floor(f);if(a)h=u[y],d=u[y+1];else{d=o(u,y+1),h=u[y];for(var g=0;g0&&(h=u[g])}return c(h),c(d),r(n(h,1-p),n(d,p))}var v=t.times(l-1);if(v.isInteger()){v=v.toNumber();var x=a?u[v]:o(u,v);return c(x),x}var b,w,N=v.floor(),M=v.minus(N),S=N.toNumber();if(a)b=u[S],w=u[S+1];else{w=o(u,S+1),b=u[S];for(var E=0;E0&&(b=u[E])}c(b),c(w);var A=new M.constructor(1);return r(n(b,A.minus(M)),n(w,M))}var c=t({"number | BigNumber | Unit":function(e){return e}});return function(e,t,r){var n,o,s;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(p(e)){if("boolean"==typeof(r=r||!1)){if(o=e.valueOf(),i(t)){if(t<0)throw new Error("N/prob must be non-negative");if(t<=1)return u(o,t,r);if(t>1){if(!ce(t))throw new Error("N must be a positive integer");var c=t+1;n=new Array(t);for(var l=0;l4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var h=new f(m+1);n=new Array(m);for(var d=0;d1)throw new Error("Probability must be between 0 and 1, inclusive")}else{if(!a(g))throw new TypeError("Unexpected type of argument in function quantileSeq");if(s=new g.constructor(1),g.isNegative()||g.gt(s))throw new Error("Probability must be between 0 and 1, inclusive")}n[y]=u(o,g,r)}return n}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}}));function uf(e){var t;if(ce(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:Js(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*uf(1-e));if(e>=171.35)return 1/0;if(e>85){var r=e*e,n=r*e,i=n*e,a=i*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*r)-139/(51840*n)-571/(2488320*i)+163879/(209018880*a)+5246819/(75246796800*a*e))}--e,t=lf[0];for(var o=1;o{var{typed:t,config:r,multiplyScalar:n,pow:i,BigNumber:a,Complex:o}=e;return t(ff,{number:uf,Complex:function(e){if(0===e.im)return this(e.re);e=new o(e.re-1,e.im);for(var t=new o(lf[0],0),r=1;r2;)u+=i-=2,o=o.times(u);return new a(o.toPrecision(a.precision))}})),mf=W("bignumber",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("bignumber",{"":function(){return new r(0)},number:function(e){return new r(e+"")},string:function(e){var t=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(t){var n=t[2],i=r(t[1]),a=new r(2).pow(Number(n));if(i.gt(a.sub(1)))throw new SyntaxError('String "'.concat(e,'" is out of range'));var o=new r(2).pow(Number(n)-1);return i.gte(o)?i.sub(a):i}return new r(e)},BigNumber:function(e){return e},Fraction:function(e){return new r(e.n).div(e.d).times(e.s)},null:function(e){return new r(0)},"Array | Matrix":function(e){return $t(e,this)}})})),hf="matrixFromColumns",df=W(hf,["typed","matrix","flatten","size"],(e=>{var{typed:t,matrix:r,flatten:n,size:i}=e;return t(hf,{"...Array":function(e){return a(e)},"...Matrix":function(e){return r(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one column is needed to construct a matrix.");for(var t=o(e[0]),r=[],i=0;i{var{typed:t,matrix:r,equalScalar:n}=e,i=nc({typed:t,equalScalar:n}),a=cc({typed:t,equalScalar:n}),o=oc({typed:t,equalScalar:n}),s=ec({typed:t}),u=tc({typed:t});return t("lcm",{"number, number":$a,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(e.isZero())return e;if(t.isZero())return t;for(var r=e.times(t);!t.isZero();){var n=t;t=e.mod(n),e=n}return r.div(e).abs()},"Fraction, Fraction":function(e,t){return e.lcm(t)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return o(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return u(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return u(r(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=Xu({typed:t}),o=Qu({typed:t,equalScalar:n}),s=Ku({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(gf,{"number, number":Ao,"BigNumber, BigNumber":go,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})})),xf="kron",bf=W(xf,["typed","matrix","multiplyScalar"],(e=>{var{typed:t,matrix:r,multiplyScalar:n}=e;return t(xf,{"Matrix, Matrix":function(e,t){return r(i(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(i(e.toArray(),t))},"Array, Matrix":function(e,t){return r(i(e,t.toArray()))},"Array, Array":i});function i(e,t){if(1===je(e).length&&(e=[e]),1===je(t).length&&(t=[t]),je(e).length>2||je(t).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(e.length)+", y = "+JSON.stringify(t.length)+")");var r=[],i=[];return e.map((function(e){return t.map((function(t){return i=[],r.push(i),e.map((function(e){return t.map((function(t){return i.push(n(e,t))}))}))}))}))&&r}})),wf=W("transpose",["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t("transpose",{Array:function(e){return this(r(e)).valueOf()},Matrix:function(e){var t,r=e.size();switch(r.length){case 1:t=e.clone();break;case 2:var n=r[0],i=r[1];if(0===i)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+De(r)+")");switch(e.storage()){case"dense":t=function(e,t,r){for(var n,i=e._data,a=[],o=0;o{var{number:t,bignumber:r,fraction:n}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},a={number:e=>t(e),BigNumber:r?e=>r(e):cr,Fraction:n?e=>n(e):lr};return function(e,t){var r=L(e);if(!(r in i))throw new TypeError("Cannot convert "+e+' of type "'+r+'"; valid input types are '+Object.keys(i).join(", "));if(!(t in a))throw new TypeError("Cannot convert "+e+' to type "'+t+'"; valid output types are '+Object.keys(a).join(", "));return t===r?e:a[t](e)}})),Mf=W("and",["typed","matrix","equalScalar","zeros","not"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,not:a}=e,o=nc({typed:t,equalScalar:n}),s=cc({typed:t,equalScalar:n}),u=oc({typed:t,equalScalar:n}),c=ec({typed:t}),l=tc({typed:t});return t("and",{"number, number":Uo,"Complex, Complex":function(e,t){return!(0===e.re&&0===e.im||0===t.re&&0===t.im)},"BigNumber, BigNumber":function(e,t){return!(e.isZero()||t.isZero()||e.isNaN()||t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return a(t)?i(e.size(),e.storage()):u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return a(t)?i(e.size(),e.storage()):l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return a(e)?i(e.size(),e.storage()):u(t,e,this,!0)},"any, DenseMatrix":function(e,t){return a(e)?i(e.size(),e.storage()):l(t,e,this,!0)},"Array, any":function(e,t){return this(r(e),t).valueOf()},"any, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Sf="smallerEq",Ef=W(Sf,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Sf,{"boolean, boolean":function(e,t){return e<=t},"number, number":function(e,t){return e<=t||Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.lte(t)||Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return 1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),Af="sort",Of=W(Af,["typed","matrix","compare","compareNatural"],(e=>{var{typed:t,matrix:r,compare:n,compareNatural:i}=e,a=n,o=(e,t)=>-n(e,t);return t(Af,{Array:function(e){return u(e),e.sort(a)},Matrix:function(e){return c(e),r(e.toArray().sort(a),e.storage())},"Array, function":function(e,t){return u(e),e.sort(t)},"Matrix, function":function(e,t){return c(e),r(e.toArray().sort(t),e.storage())},"Array, string":function(e,t){return u(e),e.sort(s(t))},"Matrix, string":function(e,t){return c(e),r(e.toArray().sort(s(t)),e.storage())}});function s(e){if("asc"===e)return a;if("desc"===e)return o;if("natural"===e)return i;throw new Error('String "asc", "desc", or "natural" expected')}function u(e){if(1!==je(e).length)throw new Error("One dimensional array expected")}function c(e){if(1!==e.size().length)throw new Error("One dimensional matrix expected")}})),Cf=W("cot",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("cot",{number:bs,Complex:function(e){return e.cot()},BigNumber:function(e){return new r(1).div(e.tan())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),_f="setDistinct",Tf=W(_f,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(_f,{"Array | Matrix":function(e){var t;if(0===n(r(e),new a(0)))t=[];else{var s=et(Array.isArray(e)?e:e.toArray()).sort(i);(t=[]).push(s[0]);for(var u=1;u{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(Bf,{"Array | Matrix":function(e){if(0===n(r(e),new a(0)))return[];for(var t=et(Array.isArray(e)?e:e.toArray()).sort(i),s=[],u=0;u.toString(2).length<=t.length;)s.push(o(t,u.toString(2).split("").reverse())),u++;return function(e){for(var t=[],r=e.length-1;r>0;r--)for(var n=0;ne[n+1].length&&(t=e[n],e[n]=e[n+1],e[n+1]=t);return e}(s)}});function o(e,t){for(var r=[],n=0;n{var{typed:t,Index:r}=e;return t(zf,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var t=e.map((function(e){return a(e)?e.toNumber():Array.isArray(e)||f(e)?e.map((function(e){return a(e)?e.toNumber():e})):e})),n=new r;return r.apply(n,t),n}})})),If="factorial",kf=W(If,["typed","gamma"],(e=>{var{typed:t,gamma:r}=e;return t(If,{number:function(e){if(e<0)throw new Error("Value must be non-negative");return r(e+1)},BigNumber:function(e){if(e.isNegative())throw new Error("Value must be non-negative");return r(e.plus(1))},"Array | Matrix":function(e){return $t(e,this)}})})),Rf="permutations",Ff=W(Rf,["typed","factorial"],(e=>{var{typed:t,factorial:r}=e;return t(Rf,{"number | BigNumber":r,"number, number":function(e,t){if(!ce(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!ce(t)||t<0)throw new TypeError("Positive integer value expected in function permutations");if(t>e)throw new TypeError("second argument k must be less than or equal to first argument n");return Js(e-t+1,e)},"BigNumber, BigNumber":function(e,t){var r,n;if(!Uf(e)||!Uf(t))throw new TypeError("Positive integer value expected in function permutations");if(t.gt(e))throw new TypeError("second argument k must be less than or equal to first argument n");for(r=e.mul(0).add(1),n=e.minus(t).plus(1);n.lte(e);n=n.plus(1))r=r.times(n);return r}})}));function Uf(e){return e.isInteger()&&e.gte(0)}var Pf="matrixFromRows",jf=W(Pf,["typed","matrix","flatten","size"],(e=>{var{typed:t,matrix:r,flatten:n,size:i}=e;return t(Pf,{"...Array":function(e){return a(e)},"...Matrix":function(e){return r(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one row is needed to construct a matrix.");var t=o(e[0]),r=[];for(var i of e){var a=o(i);if(a!==t)throw new TypeError("The vectors had different length: "+(0|t)+" ≠ "+(0|a));r.push(n(i))}return r}function o(e){var t=i(e);if(1===t.length)return t[0];if(2===t.length){if(1===t[0])return t[1];if(1===t[1])return t[0];throw new TypeError("At least one of the arguments is not a vector.")}throw new TypeError("Only one- or two-dimensional vectors are supported.")}})),Lf="subtract",Hf=W(Lf,["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,addScalar:i,unaryMinus:a,DenseMatrix:o}=e,s=Xu({typed:t}),u=ic({typed:t}),c=ac({typed:t,equalScalar:n}),l=Ku({typed:t,DenseMatrix:o}),f=ec({typed:t}),p=tc({typed:t});return t(Lf,{"number, number":function(e,t){return e-t},"Complex, Complex":function(e,t){return e.sub(t)},"BigNumber, BigNumber":function(e,t){return e.minus(t)},"Fraction, Fraction":function(e,t){return e.sub(t)},"Unit, Unit":function(e,t){if(null===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var r=e.clone();return r.value=this(r.value,t.value),r.fixPrefix=!1,r},"SparseMatrix, SparseMatrix":function(e,t){return $f(e,t),c(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return $f(e,t),u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return $f(e,t),s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return $f(e,t),f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return l(e,a(t),i)},"DenseMatrix, any":function(e,t){return p(e,t,this)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(r(t),e,this,!0).valueOf()}})}));function $f(e,t){var r=e.size(),n=t.size();if(r.length!==n.length)throw new Ue(r.length,n.length)}var Gf="cross",Vf=W(Gf,["typed","matrix","subtract","multiply"],(e=>{var{typed:t,matrix:r,subtract:n,multiply:i}=e;return t(Gf,{"Matrix, Matrix":function(e,t){return r(a(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(a(e.toArray(),t))},"Array, Matrix":function(e,t){return r(a(e,t.toArray()))},"Array, Array":a});function a(e,t){var r=Math.max(je(e).length,je(t).length);e=Ye(e),t=Ye(t);var a=je(e),o=je(t);if(1!==a.length||1!==o.length||3!==a[0]||3!==o[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+a.join(", ")+"], B = ["+o.join(", ")+"])");var s=[n(i(e[1],t[2]),i(e[2],t[1])),n(i(e[2],t[0]),i(e[0],t[2])),n(i(e[0],t[1]),i(e[1],t[0]))];return r>1?[s]:s}})),Zf="prod",Wf=W(Zf,["typed","config","multiplyScalar","numeric"],(e=>{var{typed:t,config:r,multiplyScalar:n,numeric:i}=e;return t(Zf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("prod(A, dim) is not yet supported")},"...":function(e){return a(e)}});function a(e){var t;if(Ht(e,(function(e){try{t=void 0===t?e:n(t,e)}catch(t){throw Gr(t,"prod",e)}})),"string"==typeof t&&(t=i(t,r.number)),void 0===t)throw new Error("Cannot calculate prod of an empty array");return t}})),Jf="equal",Yf=W(Jf,["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Jf,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:n(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,n)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,n,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,n,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,n)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,n,!1)},"DenseMatrix, any":function(e,t){return c(e,t,n,!1)},"any, SparseMatrix":function(e,t){return s(t,e,n,!0)},"any, DenseMatrix":function(e,t){return c(t,e,n,!0)},"Array, any":function(e,t){return c(r(e),t,n,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,n,!0).valueOf()}})})),Xf=(W(Jf,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return t(Jf,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:r(e,t)}})})),"setCartesian"),Qf=W(Xf,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Xf,{"Array | Matrix, Array | Matrix":function(e,t){var s=[];if(0!==n(r(e),new a(0))&&0!==n(r(t),new a(0))){var u=et(Array.isArray(e)?e:e.toArray()).sort(i),c=et(Array.isArray(t)?t:t.toArray()).sort(i);s=[];for(var l=0;l{var{typed:t,size:r,concat:n,subset:i,setDifference:a,Index:o}=e;return t(Kf,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new o(0)))return et(t);if(0===i(r(t),new o(0)))return et(e);var s=et(e),u=et(t);return n(a(s,u),a(u,s))}})})),tp=W("ceil",["typed","config","round","matrix","equalScalar"],(e=>{var{typed:t,config:r,round:n,matrix:i,equalScalar:a}=e,o=oc({typed:t,equalScalar:a}),s=tc({typed:t});return t("ceil",{number:function(e){return Se(e,n(e),r.epsilon)?n(e):Ua(e)},"number, number":function(e,t){if(Se(e,n(e,t),r.epsilon))return n(e,t);var[i,a]="".concat(e,"e").split("e"),o=Math.ceil(Number("".concat(i,"e").concat(Number(a)+t)));return[i,a]="".concat(o,"e").split("e"),Number("".concat(i,"e").concat(Number(a)-t))},Complex:function(e){return e.ceil()},"Complex, number":function(e,t){return e.ceil(t)},BigNumber:function(e){return Na(e,n(e),r.epsilon)?n(e):e.ceil()},"BigNumber, BigNumber":function(e,t){return Na(e,n(e,t),r.epsilon)?n(e,t):e.toDecimalPlaces(t.toNumber(),Qn.ROUND_CEIL)},Fraction:function(e){return e.ceil()},"Fraction, number":function(e,t){return e.ceil(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"Array | Matrix, number":function(e,t){return $t(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"number | Complex | BigNumber, Array":function(e,t){return s(i(t),e,this,!0).valueOf()}})})),rp=W("xor",["typed","matrix","DenseMatrix"],(e=>{var{typed:t,matrix:r,DenseMatrix:n}=e,i=ic({typed:t}),a=yc({typed:t,DenseMatrix:n}),o=sc({typed:t,DenseMatrix:n}),s=ec({typed:t}),u=tc({typed:t});return t("xor",{"number, number":Fo,"Complex, Complex":function(e,t){return(0!==e.re||0!==e.im)!=(0!==t.re||0!==t.im)},"BigNumber, BigNumber":function(e,t){return(!e.isZero()&&!e.isNaN())!=(!t.isZero()&&!t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),np="count",ip=W(np,["typed","size","prod"],(e=>{var{typed:t,size:r,prod:n}=e;return t(np,{string:function(e){return e.length},"Matrix | Array":function(e){return n(r(e))}})})),ap="ctranspose",op=W(ap,["typed","transpose","conj"],(e=>{var{typed:t,transpose:r,conj:n}=e;return t(ap,{any:function(e){return n(r(e))}})})),sp="deepEqual",up=W(sp,["typed","equal"],(e=>{var{typed:t,equal:r}=e;return t(sp,{"any, any":function(e,t){return n(e.valueOf(),t.valueOf())}});function n(e,t){if(Array.isArray(e)){if(Array.isArray(t)){var i=e.length;if(i!==t.length)return!1;for(var a=0;a{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(cp,{"Array | Matrix, Array | Matrix":function(e,t){if(0===n(r(e),new a(0)))return!0;if(0===n(r(t),new a(0)))return!1;for(var o,s=ot(et(Array.isArray(e)?e:e.toArray()).sort(i)),u=ot(et(Array.isArray(t)?t:t.toArray()).sort(i)),c=0;c{var{typed:t,Complex:r,matrix:n,ceil:i,floor:a}=e,o=tc({typed:t});return t("fix",{number:function(e){return e>0?a(e):i(e)},"number, number | BigNumber":function(e,t){return e>0?a(e,t):i(e,t)},Complex:function(e){return new r(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},"Complex, number | BigNumber":function(e,t){return new r(e.re>0?a(e.re,t):i(e.re,t),e.im>0?a(e.im,t):i(e.im,t))},BigNumber:function(e){return e.isNegative()?i(e):a(e)},"BigNumber, number | BigNumber":function(e,t){return e.isNegative()?i(e,t):a(e,t)},Fraction:function(e){return e.s<0?e.ceil():e.floor()},"Fraction, number | BigNumber":function(e,t){return e.s<0?e.ceil(t):e.floor(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"Array | Matrix, number | BigNumber":function(e,t){return $t(e,(e=>this(e,t)),!0)},"number | Complex | BigNumber, Array":function(e,t){return o(n(t),e,this,!0).valueOf()}})})),pp="divideScalar",mp=W(pp,["typed","numeric"],(e=>{var{typed:t,numeric:r}=e;return t(pp,{"number, number":function(e,t){return e/t},"Complex, Complex":function(e,t){return e.div(t)},"BigNumber, BigNumber":function(e,t){return e.div(t)},"Fraction, Fraction":function(e,t){return e.div(t)},"Unit, number | Fraction | BigNumber":function(e,t){var n=e.clone(),i=r(1,L(t));return n.value=this(null===n.value?n._normalize(i):n.value,t),n},"number | Fraction | BigNumber, Unit":function(e,t){var n=t.clone();n=n.pow(-1);var i=r(1,L(e));return n.value=this(e,null===t.value?t._normalize(i):t.value),n},"Unit, Unit":function(e,t){return e.divide(t)}})})),hp="nthRoots",dp=W(hp,["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,Complex:i}=e,a=[function(e){return new i(e,0)},function(e){return new i(0,e)},function(e){return new i(-e,0)},function(e){return new i(0,-e)}];function o(e,t){if(t<0)throw new Error("Root must be greater than zero");if(0===t)throw new Error("Root must be non-zero");if(t%1!=0)throw new Error("Root must be an integer");if(0===e||0===e.abs())return[new i(0,0)];var r,n="number"==typeof e;(n||0===e.re||0===e.im)&&(r=n?2*+(e<0):0===e.im?2*+(e.re<0):2*+(e.im<0)+1);for(var o=e.arg(),s=e.abs(),u=[],c=Math.pow(s,1/t),l=0;l{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(gp,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=(t=u(e,t,!0))._data,c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=[],d=0;dd&&(v.push(f[N]),x.push(M))}if(o(g,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var S=n(y,g),E=0,A=x.length;E{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(xp,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=0;hh&&(v.push(f[M]),x.push(S))}if(o(N,0))if(o(g[h],0)){if(0===y){var E=[...g];E[h]=1;for(var A=0,O=x.length;Anew s({data:e.map((e=>[e])),size:[c,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(r(e),t).map((e=>e.valueOf()))}});function c(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1],p=0;pnew s({data:e.map((e=>[e])),size:[l,1]})))}})),wp=W("Spa",["addScalar","equalScalar","FibonacciHeap"],(e=>{var{addScalar:t,equalScalar:r,FibonacciHeap:n}=e;function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new n}return i.prototype.type="Spa",i.prototype.isSpa=!0,i.prototype.set=function(e,t){if(this._values[e])this._values[e].value=t;else{var r=this._heap.insert(e,t);this._values[e]=r}},i.prototype.get=function(e){var t=this._values[e];return t?t.value:0},i.prototype.accumulate=function(e,r){var n=this._values[e];n?n.value=t(n.value,r):(n=this._heap.insert(e,r),this._values[e]=n)},i.prototype.forEach=function(e,t,n){var i=this._heap,a=this._values,o=[],s=i.extractMinimum();for(s&&o.push(s);s&&s.key<=t;)s.key>=e&&(r(s.value,0)||n(s.key,s.value,this)),(s=i.extractMinimum())&&o.push(s);for(var u=0;u{var{typed:t,size:r,concat:n,subset:i,setIntersect:a,setSymDifference:o,Index:s}=e;return t(Np,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new s(0)))return et(t);if(0===i(r(t),new s(0)))return et(e);var u=et(e),c=et(t);return n(o(u,c),a(u,c))}})})),Sp=W("lup",["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],(e=>{var{typed:t,matrix:r,abs:n,addScalar:i,divideScalar:a,multiplyScalar:o,subtract:s,larger:u,equalScalar:c,unaryMinus:l,DenseMatrix:f,SparseMatrix:p,Spa:m}=e;return t("lup",{DenseMatrix:function(e){return h(e)},SparseMatrix:function(e){return function(e){var t,r,i,s=e._size[0],f=e._size[1],h=Math.min(s,f),d=e._values,y=e._index,g=e._ptr,v=[],x=[],b=[],w=[s,h],N=[],M=[],S=[],E=[h,f],A=[],O=[];for(t=0;t0&&e.forEach(0,r-1,(function(t,r){p._forEachRow(t,v,x,b,(function(n,i){n>t&&e.accumulate(n,l(o(i,r)))}))}));var C,_,T,B,q=r,z=e.get(r),D=n(z);e.forEach(r+1,s-1,(function(e,t){var r=n(t);u(r,D)&&(q=e,D=r,z=t)})),r!==q&&(p._swapRows(r,q,w[1],v,x,b),p._swapRows(r,q,E[1],N,M,S),e.swap(r,q),_=q,T=O[C=r],B=O[_],A[T]=_,A[B]=C,O[C]=B,O[_]=T),e.forEach(0,s-1,(function(e,t){e<=r?(N.push(t),M.push(e)):(t=a(t,z),c(t,0)||(v.push(t),x.push(e)))}))};for(r=0;r0)for(t=0;t=0;){var u=r[o+s],c=r[n+u];-1===c?(s--,a[t++]=u):(r[n+u]=r[i+c],r[o+ ++s]=c)}return t}function Ap(e){return-e-2}var Op=W("csAmd",["add","multiply","transpose"],(e=>{var{add:t,multiply:r,transpose:n}=e;return function(e,o){if(!o||e<=0||e>3)return null;var s=o._size,u=s[0],c=s[1],l=0,f=Math.max(16,10*Math.sqrt(c)),p=function(e,i,a,o,s){var u=n(i);if(1===e&&o===a)return t(i,u);if(2===e){for(var c=u._index,l=u._ptr,f=0,p=0;ps))for(var h=l[p+1];mo)r[s+p]=0,r[i+p]=-1,f++,t[p]=Ap(e),r[s+e]++;else{var h=r[u+m];-1!==h&&(c[h]=p),r[l+p]=r[u+m],r[u+m]=p}}return f}(c,T,z,F,R,U,f,D,k,j,I),$=0;HG?(v=d,x=W,b=z[0+d]-G):(x=T[v=_[W++]],b=z[0+v]),g=1;g<=b;g++)(w=z[D+(m=_[x++])])<=0||(Z+=w,z[D+m]=-w,_[Y++]=m,-1!==z[I+m]&&(j[z[I+m]]=j[m]),-1!==j[m]?z[I+j[m]]=z[I+m]:z[k+z[F+m]]=z[I+m]);v!==d&&(T[v]=Ap(d),z[U+v]=0)}for(0!==G&&(B=Y),z[F+d]=Z,T[d]=J,z[0+d]=Y-J,z[R+d]=-2,L=i(L,l,z,U,c),N=J;N=L?z[U+v]-=w:0!==z[U+v]&&(z[U+v]=z[F+v]+X)}for(N=J;N0?(C+=Q,_[A++]=v,O+=v):(T[v]=Ap(d),z[U+v]=0)}z[R+m]=A-S+1;var K=A,ee=S+z[0+m];for(W=E+1;W=0))for(m=z[P+(O=j[m])],z[P+O]=-1;-1!==m&&-1!==z[I+m];m=z[I+m],L++){for(b=z[0+m],M=z[R+m],W=T[m]+1;W<=T[m]+b-1;W++)z[U+_[W]]=L;var re=m;for(h=z[I+m];-1!==h;){var ne=z[0+h]===b&&z[R+h]===M;for(W=T[h]+1;ne&&W<=T[h]+b-1;W++)z[U+_[W]]!==L&&(ne=0);ne?(T[h]=Ap(m),z[D+m]+=z[D+h],z[D+h]=0,z[R+h]=-1,h=z[I+h],z[I+re]=h):(re=h,h=z[I+h])}}for(W=J,N=J;N=0;h--)z[D+h]>0||(z[I+h]=z[k+T[h]],z[k+T[h]]=h);for(v=c;v>=0;v--)z[D+v]<=0||-1!==T[v]&&(z[I+v]=z[k+T[v]],z[k+T[v]]=v);for(d=0,m=0;m<=c;m++)-1===T[m]&&(d=Ep(m,d,z,k,I,q,U));return q.splice(q.length-1,1),q};function i(e,t,r,n,i){if(e<2||e+t<0){for(var a=0;a{var{transpose:t}=e;return function(e,r,n,i){if(!e||!r||!n)return null;var a,o,s,u,c,l,f,p=e._size,m=p[0],h=p[1],d=4*h+(i?h+m+1:0),y=[],g=h,v=2*h,x=3*h,b=4*h,w=5*h+1;for(s=0;s=1&&N[o]++,2===A.jleaf&&N[A.q]--}-1!==r[o]&&(y[0+o]=r[o])}for(o=0;o{var{add:t,multiply:r,transpose:n}=e,i=Op({add:t,multiply:r,transpose:n}),a=_p({transpose:n});return function(e,t,r){var n,o=t._ptr,s=t._size[1],u={};if(u.q=i(e,t),e&&!u.q)return null;if(r){var c=e?function(e,t,r,n){for(var i=e._values,a=e._index,o=e._ptr,s=e._size,u=e._datatype,c=s[0],l=s[1],f=null,p=[],m=[],h=0,d=0;d=0;r--)-1!==e[r]&&(a[o+r]=a[0+e[r]],a[0+e[r]]=r);for(r=0;r=0;u--)for(l=r[u],f=r[u+1],c=l;c=0;s--)m[s]=-1,-1!==(u=h[s])&&(0==d[v+u]++&&(d[g+u]=s),d[0+s]=d[y+u],d[y+u]=s);for(t.lnz=0,t.m2=a,u=0;u=0;){e=n[f];var p=i?i[e]:e;Bp(c,e)||(qp(c,e),n[l+f]=p<0?0:zp(c[p]));var m=1;for(o=n[l+f],s=p<0?0:zp(c[p+1]);o{var{divideScalar:t,multiply:r,subtract:n}=e;return function(e,i,a,o,s,u,c){var l,f,p,m,h=e._values,d=e._index,y=e._ptr,g=e._size[1],v=i._values,x=i._index,b=i._ptr,w=function(e,t,r,n,i){var a,o,s,u=e._ptr,c=e._size,l=t._index,f=t._ptr,p=c[1],m=p;for(o=f[r],s=f[r+1],a=o;a{var{abs:t,divideScalar:r,multiply:n,subtract:i,larger:a,largerEq:o,SparseMatrix:s}=e,u=Ip({divideScalar:r,multiply:n,subtract:i});return function(e,i,c){if(!e)return null;var l,f=e._size[1],p=100,m=100;i&&(l=i.q,p=i.lnz||p,m=i.unz||m);var h,d,y=[],g=[],v=[],x=new s({values:y,index:g,ptr:v,size:[f,f]}),b=[],w=[],N=[],M=new s({values:b,index:w,ptr:N,size:[f,f]}),S=[],E=[],A=[];for(h=0;h{var{typed:t,abs:r,add:n,multiply:i,transpose:a,divideScalar:o,subtract:s,larger:u,largerEq:c,SparseMatrix:l}=e,f=Tp({add:n,multiply:i,transpose:a}),p=kp({abs:r,divideScalar:o,multiply:i,subtract:s,larger:u,largerEq:c,SparseMatrix:l});return t("slu",{"SparseMatrix, number, number":function(e,t,r){if(!ce(t)||t<0||t>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(r<0||r>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var n=f(t,e,!1),i=p(e,n,r);return{L:i.L,U:i.U,p:i.pinv,q:n.q,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\np: "+this.p.toString()+(this.q?"\nq: "+this.q.toString():"")+"\n"}}}})})),Fp=W("det",["typed","matrix","subtract","multiply","unaryMinus","lup"],(e=>{var{typed:t,matrix:r,subtract:n,multiply:i,unaryMinus:a,lup:o}=e;return t("det",{any:function(e){return $(e)},"Array | Matrix":function(e){var t;switch((t=f(e)?e.size():Array.isArray(e)?(e=r(e)).size():[]).length){case 0:return $(e);case 1:if(1===t[0])return $(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:var s=t[0];if(s===t[1])return function(e,t,r){if(1===t)return $(e[0][0]);if(2===t)return n(i(e[0][0],e[1][1]),i(e[1][0],e[0][1]));for(var s=o(e),u=s.U[0][0],c=1;c=t)break;for(var m=f,h=0;!p[s.p[m]];)p[s.p[m]]=!0,m=s.p[m],h++;h%2==0&&l++}return l%2==0?u:a(u)}(e.clone().valueOf(),s);throw new RangeError("Matrix must be square (size: "+De(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+De(t)+")")}}})})),Up="distance",Pp=W(Up,["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],(e=>{var{typed:t,addScalar:r,subtract:n,multiplyScalar:i,divideScalar:o,unaryMinus:s,sqrt:u,abs:c}=e;return t(Up,{"Array, Array, Array":function(e,t,r){if(2===e.length&&2===t.length&&2===r.length){if(!f(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!f(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!f(r))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var a=o(n(r[1],r[0]),n(t[1],t[0])),u=i(i(a,a),t[0]),c=s(i(a,t[0])),l=e[1];return y(e[0],e[1],u,c,l)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(e,t,r){if(2===Object.keys(e).length&&2===Object.keys(t).length&&2===Object.keys(r).length){if(!f(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!f(t))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!f(r))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"lineOnePtX"in t&&"lineOnePtY"in t&&"lineTwoPtX"in r&&"lineTwoPtY"in r){var a=o(n(r.lineTwoPtY,r.lineTwoPtX),n(t.lineOnePtY,t.lineOnePtX)),u=i(i(a,a),t.lineOnePtX),c=s(i(a,t.lineOnePtX)),l=e.pointX;return y(e.pointX,e.pointY,u,c,l)}throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(e,t){if(2===e.length&&3===t.length){if(!f(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!p(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return y(e[0],e[1],t[0],t[1],t[2])}if(3===e.length&&6===t.length){if(!p(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!h(t))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return g(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}if(e.length===t.length&&e.length>0){if(!m(e))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!m(t))throw new TypeError("All values of an array should be numbers or BigNumbers");return v(e,t)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,t){if(2===Object.keys(e).length&&3===Object.keys(t).length){if(!f(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"xCoeffLine"in t&&"yCoeffLine"in t&&"constant"in t)return y(e.pointX,e.pointY,t.xCoeffLine,t.yCoeffLine,t.constant);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&6===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!h(t))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"x0"in t&&"y0"in t&&"z0"in t&&"a"in t&&"b"in t&&"c"in t)return g(e.pointX,e.pointY,e.pointZ,t.x0,t.y0,t.z0,t.a,t.b,t.c);throw new TypeError("Key names do not match")}if(2===Object.keys(e).length&&2===Object.keys(t).length){if(!f(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!f(t))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointTwoX"in t&&"pointTwoY"in t)return v([e.pointOneX,e.pointOneY],[t.pointTwoX,t.pointTwoY]);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&3===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointOneZ"in e&&"pointTwoX"in t&&"pointTwoY"in t&&"pointTwoZ"in t)return v([e.pointOneX,e.pointOneY,e.pointOneZ],[t.pointTwoX,t.pointTwoY,t.pointTwoZ]);throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},Array:function(e){if(!function(e){if(2===e[0].length&&l(e[0][0])&&l(e[0][1])){if(e.some((e=>2!==e.length||!l(e[0])||!l(e[1]))))return!1}else{if(!(3===e[0].length&&l(e[0][0])&&l(e[0][1])&&l(e[0][2])))return!1;if(e.some((e=>3!==e.length||!l(e[0])||!l(e[1])||!l(e[2]))))return!1}return!0}(e))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return function(e){for(var t=[],r=[],n=[],i=0;i{var{typed:t,addScalar:r,subtract:n,multiplyScalar:i,divideScalar:a,pow:o,factorial:s,combinations:u,isNegative:c,isInteger:l,larger:f}=e;return t(jp,{"number | BigNumber, number | BigNumber":function(e,t){if(!l(e)||c(e)||!l(t)||c(t))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(f(t,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");for(var p=s(t),m=0,h=0;h<=t;h++){var d=o(-1,n(t,h)),y=u(t,h),g=o(h,e);m=r(m,i(i(y,g),d))}return a(m,p)}})})),Hp="catalan",$p=W(Hp,["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],(e=>{var{typed:t,addScalar:r,divideScalar:n,multiplyScalar:i,combinations:a,isNegative:o,isInteger:s}=e;return t(Hp,{"number | BigNumber":function(e){if(!s(e)||o(e))throw new TypeError("Non-negative integer value expected in function catalan");return n(a(i(e,2),e),r(e,1))}})})),Gp=W("log",["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,Complex:i}=e;return t("log",{number:function(e){return e>=0||r.predictable?Ga(e):new i(e,0).log()},Complex:function(e){return e.log()},BigNumber:function(e){return!e.isNegative()||r.predictable?e.ln():new i(e.toNumber(),0).log()},"Array | Matrix":function(e){return $t(e,this)},"any, any":function(e,t){return n(this(e),this(t))}})})),Vp="dotDivide",Zp=W(Vp,["typed","matrix","equalScalar","divideScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,divideScalar:i,DenseMatrix:a}=e,o=nc({typed:t,equalScalar:n}),s=ic({typed:t}),u=yc({typed:t,DenseMatrix:a}),c=oc({typed:t,equalScalar:n}),l=sc({typed:t,DenseMatrix:a}),f=ec({typed:t}),p=tc({typed:t});return t(Vp,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,i)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return c(e,t,i,!1)},"DenseMatrix, any":function(e,t){return p(e,t,i,!1)},"any, SparseMatrix":function(e,t){return l(t,e,i,!0)},"any, DenseMatrix":function(e,t){return p(t,e,i,!0)},"Array, any":function(e,t){return p(r(e),t,i,!1).valueOf()},"any, Array":function(e,t){return p(r(t),e,i,!0).valueOf()}})})),Wp="usolveAll",Jp=W(Wp,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(Wp,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=l-1;h>=0;h--)for(var d=r.length,y=0;y=b;N--){var M=p[N];M===h?w=f[N]:Mnew s({data:e.map((e=>[e])),size:[c,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(r(e),t).map((e=>e.valueOf()))}});function c(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1]-1;f>=0;f--)for(var p=r.length,m=0;m=0;y--)d[y]=a(d[y],c[y][f]);r.push(d)}}else{if(0===m)return[];r.splice(m,1),m-=1,p-=1}else{h[f]=n(h[f],c[f][f]);for(var g=f-1;g>=0;g--)h[g]=a(h[g],i(h[f],c[g][f]))}}return r.map((e=>new s({data:e.map((e=>[e])),size:[l,1]})))}})),Yp="hypot",Xp=W(Yp,["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],(e=>{var{typed:t,abs:r,addScalar:n,divideScalar:i,multiplyScalar:a,sqrt:o,smaller:s,isPositive:u}=e;return t(Yp,{"... number | BigNumber":function(e){for(var t=0,c=0,l=0;l{var{typed:r,matrix:n,zeros:i,identity:a,isZero:o,equal:s,sign:u,sqrt:c,conj:l,unaryMinus:f,addScalar:p,divideScalar:m,multiplyScalar:h,subtract:d,complex:y}=t;return e(r("qr",{DenseMatrix:function(e){return v(e)},SparseMatrix:function(e){return function(e){throw new Error("qr not implemented for sparse matrices yet")}()},Array:function(e){var t=v(n(e));return{Q:t.Q.valueOf(),R:t.R.valueOf()}}}),{_denseQRimpl:g});function g(e){var t,r,n,y=e._size[0],g=e._size[1],v=a([y],"dense"),x=v._data,b=e.clone(),w=b._data,N=i([y],"");for(n=0;n0)for(var n="Complex"===r[0][0].type?y(0):0,i=0;i{var{typed:t,matrix:r,divideScalar:n,addScalar:i,multiply:a,unaryMinus:o,det:s,identity:u,abs:c}=e;return t("inv",{"Array | Matrix":function(e){var t=f(e)?e.size():je(e);switch(t.length){case 1:if(1===t[0])return f(e)?r([n(1,e.valueOf()[0])]):[n(1,e[0])];throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:var i=t[0],a=t[1];if(i===a)return f(e)?r(l(e.valueOf(),i,a),e.storage()):l(e,i,a);throw new RangeError("Matrix must be square (size: "+De(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+De(t)+")")}},any:function(e){return n(1,e)}});function l(e,t,r){var l,f,p,m,h;if(1===t){if(0===(m=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero");return[[n(1,m)]]}if(2===t){var d=s(e);if(0===d)throw Error("Cannot calculate inverse, determinant is zero");return[[n(e[1][1],d),n(o(e[0][1]),d)],[n(o(e[1][0]),d),n(e[0][0],d)]]}var y=e.concat();for(l=0;lx&&(x=c(y[l][v]),b=l),l++;if(0===x)throw Error("Cannot calculate inverse, determinant is zero");(l=b)!==v&&(h=y[v],y[v]=y[l],y[l]=h,h=g[v],g[v]=g[l],g[l]=h);var w=y[v],N=g[v];for(l=0;l{var{typed:t,abs:r,add:n,identity:i,inv:a,multiply:o}=e;return t(em,{Matrix:function(e){var t=e.size();if(2!==t.length||t[0]!==t[1])throw new RangeError("Matrix must be square (size: "+De(t)+")");for(var u=t[0],c=function(e,t){for(var r=0;r<30;r++)for(var n=0;n<=r;n++){var i=r-n;if(s(e,n,i)<1e-15)return{q:n,j:i}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}(function(e){for(var t=e.size()[0],n=0,i=0;i1&&(g=o(g,p),v=-v),m=n(m,o(y=y*(l-x+1)/((2*l-x+1)*x),g)),d=n(d,o(y*v,g));for(var b=o(a(d),m),w=0;w{var{typed:t,matrix:r,multiply:n,equalScalar:i,divideScalar:a,inv:o}=e,s=oc({typed:t,equalScalar:i}),u=tc({typed:t});return t("divide",G({"Array | Matrix, Array | Matrix":function(e,t){return n(e,o(t))},"DenseMatrix, any":function(e,t){return u(e,t,a,!1)},"SparseMatrix, any":function(e,t){return s(e,t,a,!1)},"Array, any":function(e,t){return u(r(e),t,a,!1).valueOf()},"any, Array | Matrix":function(e,t){return n(e,o(t))}},a.signatures))})),nm="kldivergence",im=W(nm,["typed","matrix","divide","sum","multiply","dotDivide","log","isNumeric"],(e=>{var{typed:t,matrix:r,divide:n,sum:i,multiply:a,dotDivide:o,log:s,isNumeric:u}=e;return t(nm,{"Array, Array":function(e,t){return c(r(e),r(t))},"Matrix, Array":function(e,t){return c(e,r(t))},"Array, Matrix":function(e,t){return c(r(e),t)},"Matrix, Matrix":function(e,t){return c(e,t)}});function c(e,t){var r=t.size().length,c=e.size().length;if(r>1)throw new Error("first object must be one dimensional");if(c>1)throw new Error("second object must be one dimensional");if(r!==c)throw new Error("Length of two vectors must be equal");if(0===i(e))throw new Error("Sum of elements in first object must be non zero");if(0===i(t))throw new Error("Sum of elements in second object must be non zero");var l=n(e,i(e)),f=n(t,i(t)),p=i(a(l,s(o(l,f))));return u(p)?p:Number.NaN}})),am="bellNumbers",om=W(am,["typed","addScalar","isNegative","isInteger","stirlingS2"],(e=>{var{typed:t,addScalar:r,isNegative:n,isInteger:i,stirlingS2:a}=e;return t(am,{"number | BigNumber":function(e){if(!i(e)||n(e))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var t=0,o=0;o<=e;o++)t=r(t,a(e,o));return t}})})),sm="log1p",um=W(sm,["typed","config","divideScalar","log","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,log:i,Complex:a}=e;return t(sm,{number:function(e){return e>=-1||r.predictable?me(e):o(new a(e,0))},Complex:o,BigNumber:function(e){var t=e.plus(1);return!t.isNegative()||r.predictable?t.ln():o(new a(e.toNumber(),0))},"Array | Matrix":function(e){return $t(e,this)},"any, any":function(e,t){return n(this(e),i(t))}});function o(e){var t=e.re+1;return new a(Math.log(Math.sqrt(t*t+e.im*e.im)),Math.atan2(e.im,t))}}));function cm(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function lm(e){for(var t=1;t{var r,n,i,{on:a,config:s,addScalar:c,subtract:l,multiplyScalar:f,divideScalar:p,pow:m,abs:h,fix:d,round:y,equal:g,isNumeric:v,format:x,number:b,Complex:w,BigNumber:N,Fraction:M}=t,S=b;function E(e,t){if(!(this instanceof E))throw new Error("Constructor must be called with the new operator");if(null!=e&&!v(e)&&!o(e))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(void 0!==t&&("string"!=typeof t||""===t))throw new TypeError("Second parameter in Unit constructor must be a string");if(void 0!==t){var r=E.parse(t);this.units=r.units,this.dimensions=r.dimensions}else{this.units=[{unit:U,prefix:I.NONE,power:0}],this.dimensions=[];for(var n=0;n="0"&&e<="9"}function C(){n++,i=r.charAt(n)}function _(e){n=e,i=r.charAt(n)}function T(){var e="",t=n;if("+"===i?C():"-"===i&&(e+=i,C()),!function(e){return e>="0"&&e<="9"||"."===e}(i))return _(t),null;if("."===i){if(e+=i,C(),!O(i))return _(t),null}else{for(;O(i);)e+=i,C();"."===i&&(e+=i,C())}for(;O(i);)e+=i,C();if("E"===i||"e"===i){var r="",a=n;if(r+=i,C(),"+"!==i&&"-"!==i||(r+=i,C()),!O(i))return _(a),e;for(e+=r;O(i);)e+=i,C()}return e}function B(){for(var e="";O(i)||E.isValidAlpha(i);)e+=i,C();var t=e.charAt(0);return E.isValidAlpha(t)?e:null}function q(e){return i===e?(C(),e):null}E.prototype.type="Unit",E.prototype.isUnit=!0,E.parse=function(e,t){if(t=t||{},n=-1,i="","string"!=typeof(r=e))throw new TypeError("Invalid argument in Unit.parse, string expected");var a=new E;a.units=[];var o=1,u=!1;C(),A();var c=T(),l=null;if(c){if("BigNumber"===s.number)l=new N(c);else if("Fraction"===s.number)try{l=new M(c)}catch(e){l=parseFloat(c)}else l=parseFloat(c);A(),q("*")?(o=1,u=!0):q("/")&&(o=-1,u=!0)}for(var f=[],p=1;;){for(A();"("===i;)f.push(o),p*=o,o=1,C(),A();var m;if(!i)break;var h=i;if(null===(m=B()))throw new SyntaxError('Unexpected "'+h+'" in "'+r+'" at index '+n.toString());var d=z(m);if(null===d)throw new SyntaxError('Unit "'+m+'" not found.');var y=o*p;if(A(),q("^")){A();var g=T();if(null===g)throw new SyntaxError('In "'+e+'", "^" must be followed by a floating-point number');y*=g}a.units.push({unit:d.unit,prefix:d.prefix,power:y});for(var v=0;v1||Math.abs(this.units[0].power-1)>1e-15)},E.prototype._normalize=function(e){var t,r,n,i,a;if(null==e||0===this.units.length)return e;if(this._isDerived()){var o=e;a=E._getNumberConverter(L(e));for(var s=0;s{if(Z(P,e)){var t=P[e];return{unit:t,prefix:t.prefixes[""]}}for(var r in P)if(Z(P,r)&&ze(e,r)){var n=P[r],i=e.length-r.length,a=e.substring(0,i),o=Z(n.prefixes,a)?n.prefixes[a]:void 0;if(void 0!==o)return{unit:n,prefix:o}}return null}),{hasher:e=>e[0],limit:100});function D(e){return e.equalBase(R.NONE)&&null!==e.value&&!s.predictable?e.value:e}E.isValuelessUnit=function(e){return null!==z(e)},E.prototype.hasBase=function(e){if("string"==typeof e&&(e=R[e]),!e)return!1;for(var t=0;t1e-12)return!1;return!0},E.prototype.equalBase=function(e){for(var t=0;t1e-12)return!1;return!0},E.prototype.equals=function(e){return this.equalBase(e)&&g(this.value,e.value)},E.prototype.multiply=function(e){for(var t=this.clone(),r=0;r1e-12&&(Z(V,s)?n.push({unit:V[s].unit,prefix:V[s].prefix,power:r.dimensions[o]||0}):a=!0)}n.length1e-12){if(!Z(G.si,n))throw new Error("Cannot express custom unit "+n+" in SI units");t.push({unit:G.si[n].unit,prefix:G.si[n].prefix,power:e.dimensions[r]||0})}}return e.units=t,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,e},E.prototype.formatUnits=function(){for(var e="",t="",r=0,n=0,i=0;i0?(r++,e+=" "+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power-1)>1e-15&&(e+="^"+this.units[i].power)):this.units[i].power<0&&n++;if(n>0)for(var a=0;a0?(t+=" "+this.units[a].prefix.name+this.units[a].unit.name,Math.abs(this.units[a].power+1)>1e-15&&(t+="^"+-this.units[a].power)):(t+=" "+this.units[a].prefix.name+this.units[a].unit.name,t+="^"+this.units[a].power));e=e.substr(1),t=t.substr(1),r>1&&n>0&&(e="("+e+")"),n>1&&r>0&&(t="("+t+")");var o=e;return r>0&&n>0&&(o+=" / "),o+t},E.prototype.format=function(e){var t=this.skipAutomaticSimplification||null===this.value?this.clone():this.simplify(),r=!1;for(var n in void 0!==t.value&&null!==t.value&&o(t.value)&&(r=Math.abs(t.value.re)<1e-14),t.units)Z(t.units,n)&&t.units[n].unit&&("VA"===t.units[n].unit.name&&r?t.units[n].unit=P.VAR:"VAR"!==t.units[n].unit.name||r||(t.units[n].unit=P.VA));1!==t.units.length||t.fixPrefix||Math.abs(t.units[0].power-Math.round(t.units[0].power))<1e-14&&(t.units[0].prefix=t._bestPrefix());var i=t._denormalize(t.value),a=null!==t.value?x(i,e||{}):"",s=t.formatUnits();return t.value&&o(t.value)&&(a="("+a+")"),s.length>0&&a.length>0&&(a+=" "),a+s},E.prototype._bestPrefix=function(){if(1!==this.units.length)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var e=null!==this.value?h(this.value):0,t=h(this.units[0].unit.value),r=this.units[0].prefix;if(0===e)return r;var n=this.units[0].power,i=Math.log(e/Math.pow(r.value*t,n))/Math.LN10-1.2;if(i>-2.200001&&i<1.800001)return r;i=Math.abs(i);var a=this.units[0].unit.prefixes;for(var o in a)if(Z(a,o)){var s=a[o];if(s.scientific){var u=Math.abs(Math.log(e/Math.pow(s.value*t,n))/Math.LN10-1.2);(u0))},P={meter:{name:"meter",base:R.LENGTH,prefixes:I.LONG,value:1,offset:0},inch:{name:"inch",base:R.LENGTH,prefixes:I.NONE,value:.0254,offset:0},foot:{name:"foot",base:R.LENGTH,prefixes:I.NONE,value:.3048,offset:0},yard:{name:"yard",base:R.LENGTH,prefixes:I.NONE,value:.9144,offset:0},mile:{name:"mile",base:R.LENGTH,prefixes:I.NONE,value:1609.344,offset:0},link:{name:"link",base:R.LENGTH,prefixes:I.NONE,value:.201168,offset:0},rod:{name:"rod",base:R.LENGTH,prefixes:I.NONE,value:5.0292,offset:0},chain:{name:"chain",base:R.LENGTH,prefixes:I.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:R.LENGTH,prefixes:I.NONE,value:1e-10,offset:0},m:{name:"m",base:R.LENGTH,prefixes:I.SHORT,value:1,offset:0},in:{name:"in",base:R.LENGTH,prefixes:I.NONE,value:.0254,offset:0},ft:{name:"ft",base:R.LENGTH,prefixes:I.NONE,value:.3048,offset:0},yd:{name:"yd",base:R.LENGTH,prefixes:I.NONE,value:.9144,offset:0},mi:{name:"mi",base:R.LENGTH,prefixes:I.NONE,value:1609.344,offset:0},li:{name:"li",base:R.LENGTH,prefixes:I.NONE,value:.201168,offset:0},rd:{name:"rd",base:R.LENGTH,prefixes:I.NONE,value:5.02921,offset:0},ch:{name:"ch",base:R.LENGTH,prefixes:I.NONE,value:20.1168,offset:0},mil:{name:"mil",base:R.LENGTH,prefixes:I.NONE,value:254e-7,offset:0},m2:{name:"m2",base:R.SURFACE,prefixes:I.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:R.SURFACE,prefixes:I.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:R.SURFACE,prefixes:I.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:R.SURFACE,prefixes:I.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:R.SURFACE,prefixes:I.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:R.SURFACE,prefixes:I.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:R.SURFACE,prefixes:I.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:R.SURFACE,prefixes:I.NONE,value:6.4516e-10,offset:0},acre:{name:"acre",base:R.SURFACE,prefixes:I.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:R.SURFACE,prefixes:I.NONE,value:1e4,offset:0},m3:{name:"m3",base:R.VOLUME,prefixes:I.CUBIC,value:1,offset:0},L:{name:"L",base:R.VOLUME,prefixes:I.SHORT,value:.001,offset:0},l:{name:"l",base:R.VOLUME,prefixes:I.SHORT,value:.001,offset:0},litre:{name:"litre",base:R.VOLUME,prefixes:I.LONG,value:.001,offset:0},cuin:{name:"cuin",base:R.VOLUME,prefixes:I.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:R.VOLUME,prefixes:I.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:R.VOLUME,prefixes:I.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:R.VOLUME,prefixes:I.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:R.VOLUME,prefixes:I.NONE,value:15e-6,offset:0},drop:{name:"drop",base:R.VOLUME,prefixes:I.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:R.VOLUME,prefixes:I.NONE,value:5e-8,offset:0},minim:{name:"minim",base:R.VOLUME,prefixes:I.NONE,value:6.161152e-8,offset:0},fluiddram:{name:"fluiddram",base:R.VOLUME,prefixes:I.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:R.VOLUME,prefixes:I.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:R.VOLUME,prefixes:I.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:R.VOLUME,prefixes:I.NONE,value:1e-6,offset:0},cup:{name:"cup",base:R.VOLUME,prefixes:I.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:R.VOLUME,prefixes:I.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:R.VOLUME,prefixes:I.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:R.VOLUME,prefixes:I.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:R.VOLUME,prefixes:I.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:R.VOLUME,prefixes:I.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:R.VOLUME,prefixes:I.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:R.VOLUME,prefixes:I.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:R.VOLUME,prefixes:I.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:R.VOLUME,prefixes:I.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:R.VOLUME,prefixes:I.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:R.VOLUME,prefixes:I.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:R.VOLUME,prefixes:I.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:R.VOLUME,prefixes:I.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:R.VOLUME,prefixes:I.NONE,value:.1173478,offset:0},obl:{name:"obl",base:R.VOLUME,prefixes:I.NONE,value:.1589873,offset:0},g:{name:"g",base:R.MASS,prefixes:I.SHORT,value:.001,offset:0},gram:{name:"gram",base:R.MASS,prefixes:I.LONG,value:.001,offset:0},ton:{name:"ton",base:R.MASS,prefixes:I.SHORT,value:907.18474,offset:0},t:{name:"t",base:R.MASS,prefixes:I.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:R.MASS,prefixes:I.LONG,value:1e3,offset:0},grain:{name:"grain",base:R.MASS,prefixes:I.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:R.MASS,prefixes:I.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:R.MASS,prefixes:I.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:R.MASS,prefixes:I.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:R.MASS,prefixes:I.NONE,value:45.359237,offset:0},stick:{name:"stick",base:R.MASS,prefixes:I.NONE,value:.115,offset:0},stone:{name:"stone",base:R.MASS,prefixes:I.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:R.MASS,prefixes:I.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:R.MASS,prefixes:I.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:R.MASS,prefixes:I.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:R.MASS,prefixes:I.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:R.MASS,prefixes:I.NONE,value:45.359237,offset:0},s:{name:"s",base:R.TIME,prefixes:I.SHORT,value:1,offset:0},min:{name:"min",base:R.TIME,prefixes:I.NONE,value:60,offset:0},h:{name:"h",base:R.TIME,prefixes:I.NONE,value:3600,offset:0},second:{name:"second",base:R.TIME,prefixes:I.LONG,value:1,offset:0},sec:{name:"sec",base:R.TIME,prefixes:I.LONG,value:1,offset:0},minute:{name:"minute",base:R.TIME,prefixes:I.NONE,value:60,offset:0},hour:{name:"hour",base:R.TIME,prefixes:I.NONE,value:3600,offset:0},day:{name:"day",base:R.TIME,prefixes:I.NONE,value:86400,offset:0},week:{name:"week",base:R.TIME,prefixes:I.NONE,value:604800,offset:0},month:{name:"month",base:R.TIME,prefixes:I.NONE,value:2629800,offset:0},year:{name:"year",base:R.TIME,prefixes:I.NONE,value:31557600,offset:0},decade:{name:"decade",base:R.TIME,prefixes:I.NONE,value:315576e3,offset:0},century:{name:"century",base:R.TIME,prefixes:I.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:R.TIME,prefixes:I.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:R.FREQUENCY,prefixes:I.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:R.FREQUENCY,prefixes:I.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:R.ANGLE,prefixes:I.SHORT,value:1,offset:0},radian:{name:"radian",base:R.ANGLE,prefixes:I.LONG,value:1,offset:0},deg:{name:"deg",base:R.ANGLE,prefixes:I.SHORT,value:null,offset:0},degree:{name:"degree",base:R.ANGLE,prefixes:I.LONG,value:null,offset:0},grad:{name:"grad",base:R.ANGLE,prefixes:I.SHORT,value:null,offset:0},gradian:{name:"gradian",base:R.ANGLE,prefixes:I.LONG,value:null,offset:0},cycle:{name:"cycle",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},A:{name:"A",base:R.CURRENT,prefixes:I.SHORT,value:1,offset:0},ampere:{name:"ampere",base:R.CURRENT,prefixes:I.LONG,value:1,offset:0},K:{name:"K",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:0},degC:{name:"degC",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:273.15},degF:{name:"degF",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:0},celsius:{name:"celsius",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:R.AMOUNT_OF_SUBSTANCE,prefixes:I.SHORT,value:1,offset:0},mole:{name:"mole",base:R.AMOUNT_OF_SUBSTANCE,prefixes:I.LONG,value:1,offset:0},cd:{name:"cd",base:R.LUMINOUS_INTENSITY,prefixes:I.SHORT,value:1,offset:0},candela:{name:"candela",base:R.LUMINOUS_INTENSITY,prefixes:I.LONG,value:1,offset:0},N:{name:"N",base:R.FORCE,prefixes:I.SHORT,value:1,offset:0},newton:{name:"newton",base:R.FORCE,prefixes:I.LONG,value:1,offset:0},dyn:{name:"dyn",base:R.FORCE,prefixes:I.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:R.FORCE,prefixes:I.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:R.FORCE,prefixes:I.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:R.FORCE,prefixes:I.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:R.FORCE,prefixes:I.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:R.FORCE,prefixes:I.NONE,value:9.80665,offset:0},J:{name:"J",base:R.ENERGY,prefixes:I.SHORT,value:1,offset:0},joule:{name:"joule",base:R.ENERGY,prefixes:I.SHORT,value:1,offset:0},erg:{name:"erg",base:R.ENERGY,prefixes:I.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:R.ENERGY,prefixes:I.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:R.ENERGY,prefixes:I.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:R.ENERGY,prefixes:I.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:R.ENERGY,prefixes:I.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:R.POWER,prefixes:I.SHORT,value:1,offset:0},watt:{name:"watt",base:R.POWER,prefixes:I.LONG,value:1,offset:0},hp:{name:"hp",base:R.POWER,prefixes:I.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:R.POWER,prefixes:I.SHORT,value:w.I,offset:0},VA:{name:"VA",base:R.POWER,prefixes:I.SHORT,value:1,offset:0},Pa:{name:"Pa",base:R.PRESSURE,prefixes:I.SHORT,value:1,offset:0},psi:{name:"psi",base:R.PRESSURE,prefixes:I.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:R.PRESSURE,prefixes:I.NONE,value:101325,offset:0},bar:{name:"bar",base:R.PRESSURE,prefixes:I.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:R.PRESSURE,prefixes:I.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:R.PRESSURE,prefixes:I.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:R.PRESSURE,prefixes:I.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:R.PRESSURE,prefixes:I.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:R.ELECTRIC_CHARGE,prefixes:I.LONG,value:1,offset:0},C:{name:"C",base:R.ELECTRIC_CHARGE,prefixes:I.SHORT,value:1,offset:0},farad:{name:"farad",base:R.ELECTRIC_CAPACITANCE,prefixes:I.LONG,value:1,offset:0},F:{name:"F",base:R.ELECTRIC_CAPACITANCE,prefixes:I.SHORT,value:1,offset:0},volt:{name:"volt",base:R.ELECTRIC_POTENTIAL,prefixes:I.LONG,value:1,offset:0},V:{name:"V",base:R.ELECTRIC_POTENTIAL,prefixes:I.SHORT,value:1,offset:0},ohm:{name:"ohm",base:R.ELECTRIC_RESISTANCE,prefixes:I.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:R.ELECTRIC_INDUCTANCE,prefixes:I.LONG,value:1,offset:0},H:{name:"H",base:R.ELECTRIC_INDUCTANCE,prefixes:I.SHORT,value:1,offset:0},siemens:{name:"siemens",base:R.ELECTRIC_CONDUCTANCE,prefixes:I.LONG,value:1,offset:0},S:{name:"S",base:R.ELECTRIC_CONDUCTANCE,prefixes:I.SHORT,value:1,offset:0},weber:{name:"weber",base:R.MAGNETIC_FLUX,prefixes:I.LONG,value:1,offset:0},Wb:{name:"Wb",base:R.MAGNETIC_FLUX,prefixes:I.SHORT,value:1,offset:0},tesla:{name:"tesla",base:R.MAGNETIC_FLUX_DENSITY,prefixes:I.LONG,value:1,offset:0},T:{name:"T",base:R.MAGNETIC_FLUX_DENSITY,prefixes:I.SHORT,value:1,offset:0},b:{name:"b",base:R.BIT,prefixes:I.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:R.BIT,prefixes:I.BINARY_LONG,value:1,offset:0},B:{name:"B",base:R.BIT,prefixes:I.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:R.BIT,prefixes:I.BINARY_LONG,value:8,offset:0}},j={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function H(e){if("BigNumber"===e.number){var t=Cn(N);P.rad.value=new N(1),P.deg.value=t.div(180),P.grad.value=t.div(200),P.cycle.value=t.times(2),P.arcsec.value=t.div(648e3),P.arcmin.value=t.div(10800)}else P.rad.value=1,P.deg.value=Math.PI/180,P.grad.value=Math.PI/200,P.cycle.value=2*Math.PI,P.arcsec.value=Math.PI/648e3,P.arcmin.value=Math.PI/10800;P.radian.value=P.rad.value,P.degree.value=P.deg.value,P.gradian.value=P.grad.value}H(s),a&&a("config",(function(e,t){e.number!==t.number&&H(e)}));var G={si:{NONE:{unit:U,prefix:I.NONE[""]},LENGTH:{unit:P.m,prefix:I.SHORT[""]},MASS:{unit:P.g,prefix:I.SHORT.k},TIME:{unit:P.s,prefix:I.SHORT[""]},CURRENT:{unit:P.A,prefix:I.SHORT[""]},TEMPERATURE:{unit:P.K,prefix:I.SHORT[""]},LUMINOUS_INTENSITY:{unit:P.cd,prefix:I.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:P.mol,prefix:I.SHORT[""]},ANGLE:{unit:P.rad,prefix:I.SHORT[""]},BIT:{unit:P.bits,prefix:I.SHORT[""]},FORCE:{unit:P.N,prefix:I.SHORT[""]},ENERGY:{unit:P.J,prefix:I.SHORT[""]},POWER:{unit:P.W,prefix:I.SHORT[""]},PRESSURE:{unit:P.Pa,prefix:I.SHORT[""]},ELECTRIC_CHARGE:{unit:P.C,prefix:I.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:P.F,prefix:I.SHORT[""]},ELECTRIC_POTENTIAL:{unit:P.V,prefix:I.SHORT[""]},ELECTRIC_RESISTANCE:{unit:P.ohm,prefix:I.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:P.H,prefix:I.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:P.S,prefix:I.SHORT[""]},MAGNETIC_FLUX:{unit:P.Wb,prefix:I.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:P.T,prefix:I.SHORT[""]},FREQUENCY:{unit:P.Hz,prefix:I.SHORT[""]}}};G.cgs=JSON.parse(JSON.stringify(G.si)),G.cgs.LENGTH={unit:P.m,prefix:I.SHORT.c},G.cgs.MASS={unit:P.g,prefix:I.SHORT[""]},G.cgs.FORCE={unit:P.dyn,prefix:I.SHORT[""]},G.cgs.ENERGY={unit:P.erg,prefix:I.NONE[""]},G.us=JSON.parse(JSON.stringify(G.si)),G.us.LENGTH={unit:P.ft,prefix:I.NONE[""]},G.us.MASS={unit:P.lbm,prefix:I.NONE[""]},G.us.TEMPERATURE={unit:P.degF,prefix:I.NONE[""]},G.us.FORCE={unit:P.lbf,prefix:I.NONE[""]},G.us.ENERGY={unit:P.BTU,prefix:I.BTU[""]},G.us.POWER={unit:P.hp,prefix:I.NONE[""]},G.us.PRESSURE={unit:P.psi,prefix:I.NONE[""]},G.auto=JSON.parse(JSON.stringify(G.si));var V=G.auto;for(var W in E.setUnitSystem=function(e){if(!Z(G,e))throw new Error("Unit system "+e+" does not exist. Choices are: "+Object.keys(G).join(", "));V=G[e]},E.getUnitSystem=function(){for(var e in G)if(Z(G,e)&&G[e]===V)return e},E.typeConverters={BigNumber:function(e){return new N(e+"")},Fraction:function(e){return new M(e)},Complex:function(e){return e},number:function(e){return e}},E._getNumberConverter=function(e){if(!E.typeConverters[e])throw new TypeError('Unsupported type "'+e+'"');return E.typeConverters[e]},P)if(Z(P,W)){var J=P[W];J.dimensions=J.base.dimensions}for(var Y in j)if(Z(j,Y)){var X=P[j[Y]],Q={};for(var K in X)Z(X,K)&&(Q[K]=X[K]);Q.name=Y,P[Y]=Q}return E.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)},E.createUnit=function(e,t){if("object"!=typeof e)throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(t&&t.override)for(var r in e)if(Z(e,r)&&E.deleteUnit(r),e[r].aliases)for(var n=0;n0&&!E.isValidAlpha(i)&&!O(i))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+e+'"')}}(e);var n,a,o,s=null,u=[],c=0;if(t&&"Unit"===t.type)s=t.clone();else if("string"==typeof t)""!==t&&(n=t);else{if("object"!=typeof t)throw new TypeError('Cannot create unit "'+e+'" from "'+t.toString()+'": expecting "string" or "Unit" or "Object"');n=t.definition,a=t.prefixes,c=t.offset,o=t.baseName,t.aliases&&(u=t.aliases.valueOf())}if(u)for(var l=0;l1e-12){h=!1;break}if(h){p=!0,f.base=R[m];break}}if(!p){o=o||e+"_STUFF";var y={dimensions:s.dimensions.slice(0)};y.key=o,R[o]=y,V[o]={unit:f,prefix:I.NONE[""]},f.base=R[o]}}else{if(o=o||e+"_STUFF",k.indexOf(o)>=0)throw new Error('Cannot create new base unit "'+e+'": a base unit with that name already exists (and cannot be overridden)');for(var g in k.push(o),R)Z(R,g)&&(R[g].dimensions[k.length-1]=0);for(var v={dimensions:[]},x=0;x{var{typed:t,Unit:r}=e;return t(pm,{"Object, Object":function(e,t){return r.createUnit(e,t)},Object:function(e){return r.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,t,n){var i={};return i[e]=t,r.createUnit(i,n)},"string, Unit | string | Object":function(e,t){var n={};return n[e]=t,r.createUnit(n,{})},string:function(e){var t={};return t[e]={},r.createUnit(t,{})}})}));var hm=W("eigs",["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","divideScalar","inv","bignumber","multiply","add","larger","column","flatten","number","complex","sqrt","diag","qr","usolveAll","im","re","smaller","round","log10","transpose","matrixFromColumns"],(e=>{var{config:t,typed:r,matrix:n,addScalar:u,subtract:c,equal:l,abs:f,atan:p,cos:m,sin:h,multiplyScalar:d,divideScalar:y,inv:g,bignumber:v,multiply:x,add:b,larger:w,column:N,flatten:M,number:S,complex:E,sqrt:A,diag:O,qr:C,usolveAll:_,im:T,re:B,smaller:q,round:z,log10:D,transpose:I,matrixFromColumns:k}=e,R=function(e){var{config:t,addScalar:r,subtract:n,abs:i,atan:a,cos:o,sin:s,multiplyScalar:u,inv:c,bignumber:l,multiply:f,add:p}=e;function m(e,r){for(var n,i=e.length,a=Math.abs(r/i),o=new Array(i),s=0;s=Math.abs(a);){var c=u[0][0],l=u[0][1];e=v(e,(f=e[c][c],p=e[l][l],m=e[c][l],h=void 0,h=p-f,n=Math.abs(h)<=t.epsilon?Math.PI/4:.5*Math.atan(2*m/(p-f))),c,l),o=d(o,n,c,l),u=x(e)}for(var f,p,m,h,y=N(i,0),g=0;g=i(p);){var v=d[0][0],x=d[0][1];e=g(e,(M=e[v][v],S=e[x][x],E=e[v][x],A=void 0,A=n(S,M),o=i(A)<=t.epsilon?l(-1).acos().div(4):u(.5,a(f(2,E,c(A))))),v,x),m=y(m,o,v,x),d=b(e)}for(var M,S,E,A,O=N(s,0),C=0;C2&&void 0!==arguments[2]?arguments[2]:t.epsilon,i=arguments.length>3?arguments[3]:void 0;if("number"===i)return m(e,n);if("BigNumber"===i)return h(e,n);throw TypeError("Unsupported data type: "+i)}}({config:t,addScalar:u,subtract:c,column:N,flatten:M,equal:l,abs:f,atan:p,cos:m,sin:h,multiplyScalar:d,inv:g,bignumber:v,complex:E,multiply:x,add:b}),F=function(e){var{addScalar:t,subtract:r,flatten:n,multiply:i,multiplyScalar:a,divideScalar:o,sqrt:s,abs:u,bignumber:c,diag:l,inv:f,qr:p,usolveAll:m,equal:h,complex:d,larger:y,smaller:g,round:v,log10:x,transpose:b,matrixFromColumns:w}=e;function N(e,t,n,i,a,o,s,l){var f="BigNumber"===l,p="Complex"===l,m=f?c(0):p?d(0):0,h=f?c(1):p?d(1):1;if(g(u(n),s))return[[h,m],[m,h]];if(y(u(r(a,o)),s))return[[r(a,i),r(o,i)],[n,n]];var v=r(e,a),x=r(t,a),b=r(n,a),w=r(i,a);return g(u(x),s)?[[v,h],[b,m]]:[[x,m],[w,h]]}function M(e,t){for(var r=0;r1&&(D=l(Array(B-1).fill(v)))),B-=1,_.pop();for(var P=0;P2&&(D=l(Array(B-2).fill(v)))),B-=2,_.pop(),_.pop();for(var L=0;L+r(u(e),u(t)))),I>100){var H=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+T.join(", "));throw H.values=T,H.vectors=[],H}return{values:T,C:m?i(z,function(e,t){for(var r=[],n=0;ni(a,e)))).shift(),_.lengthn(e))))}if(0!==A.length){var T=new Error("Failed to find eigenvectors for the following eigenvalues: "+A.join(", "));throw T.values=o,T.vectors=w,T}return w}(e,b,B,T,E),_=w(..._)),{values:T,vectors:_}}}({config:t,addScalar:u,subtract:c,multiply:x,multiplyScalar:d,flatten:M,divideScalar:y,sqrt:A,abs:f,bignumber:v,diag:O,qr:C,inv:g,usolveAll:_,equal:l,complex:E,larger:w,smaller:q,round:z,log10:D,transpose:I,matrixFromColumns:k});return r("eigs",{Array:function(e){return U(n(e))},"Array, number|BigNumber":function(e,t){return U(n(e),t)},Matrix:function(e){var{values:t,vectors:r}=U(e);return{values:n(t),vectors:n(r)}},"Matrix, number|BigNumber":function(e,t){var{values:r,vectors:i}=U(e,t);return{values:n(r),vectors:n(i)}}});function U(e,r){void 0===r&&(r=t.epsilon);var n=e.size();if(2!==n.length||n[0]!==n[1])throw new RangeError("Matrix must be square (size: "+De(n)+")");var i=e.toArray(),a=n[0];if(function(e,t,r){for(var n=0;n{var{typed:t,config:r,abs:n,add:i,addScalar:o,matrix:s,multiply:u,multiplyScalar:c,divideScalar:l,subtract:f,smaller:p,equalScalar:m}=e;return t("intersect",{"Array, Array, Array":function(e,t,r){if(!y(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!y(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!function(e){return 4===e.length&&h(e[0])&&h(e[1])&&h(e[2])&&h(e[3])}(r))throw new TypeError("Array with 4 numbers expected as third argument");return function(e,t,r,n,i,a,s,u,p,m){var h=c(e,s),d=c(n,s),y=c(t,u),g=c(i,u),v=c(r,p),x=c(a,p),b=l(f(f(f(m,h),y),v),f(f(f(o(o(d,g),x),h),y),v));return[o(e,c(b,f(n,e))),o(t,c(b,f(i,t))),o(r,c(b,f(a,r)))]}(e[0],e[1],e[2],t[0],t[1],t[2],r[0],r[1],r[2],r[3])},"Array, Array, Array, Array":function(e,t,a,s){if(2===e.length){if(!d(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!d(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!d(a))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!d(s))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return function(e,t,a,s){var m=e,h=a,d=f(m,t),y=f(h,s),g=f(c(d[0],y[1]),c(y[0],d[1]));if(p(n(g),r.epsilon))return null;var v=c(y[0],m[1]),x=c(y[1],m[0]),b=c(y[0],h[1]),w=c(y[1],h[0]),N=l(o(f(f(v,x),b),w),g);return i(u(d,N),m)}(e,t,a,s)}if(3===e.length){if(!y(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!y(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!y(a))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!y(s))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return h=e[0],v=e[1],x=e[2],b=t[0],w=t[1],N=t[2],M=a[0],S=a[1],E=a[2],_=g(h,M,A=s[0],M,v,S,O=s[1],S,x,E,C=s[2],E),T=g(A,M,b,h,O,S,w,v,C,E,N,x),B=g(h,M,b,h,v,S,w,v,x,E,N,x),q=g(A,M,A,M,O,S,O,S,C,E,C,E),z=g(b,h,b,h,w,v,w,v,N,x,N,x),D=l(f(c(_,T),c(B,q)),f(c(z,q),c(T,T))),I=l(o(_,c(D,T)),q),k=o(h,c(D,f(b,h))),R=o(v,c(D,f(w,v))),F=o(x,c(D,f(N,x))),U=o(M,c(I,f(A,M))),P=o(S,c(I,f(O,S))),j=o(E,c(I,f(C,E))),m(k,U)&&m(R,P)&&m(F,j)?[k,R,F]:null}throw new TypeError("Arrays with two or thee dimensional points expected");var h,v,x,b,w,N,M,S,E,A,O,C,_,T,B,q,z,D,I,k,R,F,U,P,j},"Matrix, Matrix, Matrix":function(e,t,r){return s(this(e.valueOf(),t.valueOf(),r.valueOf()))},"Matrix, Matrix, Matrix, Matrix":function(e,t,r,n){return s(this(e.valueOf(),t.valueOf(),r.valueOf(),n.valueOf()))}});function h(e){return"number"==typeof e||a(e)}function d(e){return 2===e.length&&h(e[0])&&h(e[1])}function y(e){return 3===e.length&&h(e[0])&&h(e[1])&&h(e[2])}function g(e,t,r,n,i,a,s,u,l,p,m,h){var d=c(f(e,t),f(r,n)),y=c(f(i,a),f(s,u)),g=c(f(l,p),f(m,h));return o(o(d,y),g)}})),ym="usolve",gm=W(ym,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(ym,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=(t=u(e,t,!0))._data,c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=[],d=l-1;d>=0;d--){var y=r[d][0]||0;if(o(y,0))h[d]=[0];else{for(var g=0,v=[],x=[],b=m[d],w=m[d+1]-1;w>=b;w--){var N=p[w];N===d?g=f[w]:N=0;m--){var h=r[m][0]||0,d=void 0;if(o(h,0))d=0;else{var y=p[m][m];if(o(y,0))throw new Error("Linear system cannot be solved since matrix is singular");d=n(h,y);for(var g=m-1;g>=0;g--)r[g]=[a(r[g][0]||0,i(d,p[g][m]))]}f[m]=[d]}return new s({data:f,size:[c,1]})}})),vm="norm",xm=W(vm,["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],(e=>{var{typed:t,abs:r,add:n,pow:i,conj:a,sqrt:o,multiply:s,equalScalar:u,larger:c,smaller:l,matrix:f,ctranspose:p,eigs:m}=e;return t(vm,{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},boolean:function(e){return Math.abs(e)},Array:function(e){return h(f(e),2)},Matrix:function(e){return h(e,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(e){return this(e)},"Array, number | BigNumber | string":function(e,t){return h(f(e),t)},"Matrix, number | BigNumber | string":function(e,t){return h(e,t)}});function h(e,t){var f=e.size();if(1===f.length)return function(e,t){if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=0;return e.forEach((function(e){var n=r(e);c(n,t)&&(t=n)}),!0),t}(e);if(t===Number.NEGATIVE_INFINITY||"-inf"===t)return function(e){var t;return e.forEach((function(e){var n=r(e);t&&!l(n,t)||(t=n)}),!0),t||0}(e);if("fro"===t)return h(e,2);if("number"==typeof t&&!isNaN(t)){if(!u(t,0)){var a=0;return e.forEach((function(e){a=n(i(r(e),t),a)}),!0),i(a,1/t)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}(e,t);if(2===f.length){if(f[0]&&f[1])return function(e,t){if(1===t)return function(e){var t=[],i=0;return e.forEach((function(e,a){var o=a[1],s=n(t[o]||0,r(e));c(s,i)&&(i=s),t[o]=s}),!0),i}(e);if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=[],i=0;return e.forEach((function(e,a){var o=a[0],s=n(t[o]||0,r(e));c(s,i)&&(i=s),t[o]=s}),!0),i}(e);if("fro"===t)return function(e){var t=0;return e.forEach((function(e,r){t=n(t,s(e,a(e)))})),r(o(t))}(e);if(2===t)return function(e){var t=e.size();if(t[0]!==t[1])throw new RangeError("Invalid matrix dimensions");var n=p(e),i=s(n,e),a=m(i).values.toArray(),u=a[a.length-1];return r(o(u))}(e);throw new Error("Unsupported parameter value "+t)}(e,t);throw new RangeError("Invalid matrix dimensions")}}}));function bm(e,t){var r,n=t.length,i=[];if(e)for(r=0;r{var{typed:t,matrix:r,lup:n,slu:i,usolve:a,lsolve:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(wm,{"Array, Array | Matrix":function(e,t){e=r(e);var i=n(e);return p(i.L,i.U,i.p,null,t).valueOf()},"DenseMatrix, Array | Matrix":function(e,t){var r=n(e);return p(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){var r=n(e);return p(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,r,n){var a=i(e,r,n);return p(a.L,a.U,a.p,a.q,t)},"Object, Array | Matrix":function(e,t){return p(e.L,e.U,e.p,e.q,t)}});function c(e){if(f(e))return e;if(l(e))return r(e);throw new TypeError("Invalid Matrix LU decomposition")}function p(e,t,r,n,i){e=c(e),t=c(t),r&&((i=u(e,i,!0))._data=bm(r,i._data));var s=o(e,i),l=a(t,s);return n&&(l._data=bm(n,l._data)),l}})),Sm="sqrtm",Em=["typed","abs","add","multiply","sqrt","subtract","inv","size","max","identity"],Am=W(Sm,Em,(e=>{var{typed:t,abs:r,add:n,multiply:i,sqrt:a,subtract:o,inv:s,size:u,max:c,identity:l}=e,p=1e-6;function m(e){var t,a=0,f=e,m=l(u(e));do{var h=f;if(f=i(.5,n(h,s(m))),m=i(.5,n(m,s(h))),(t=c(r(o(f,h))))>p&&++a>1e3)throw new Error("computing square root of matrix: iterative method could not converge")}while(t>p);return f}return t(Sm,{"Array | Matrix":function(e){var t=f(e)?e.size():je(e);switch(t.length){case 1:if(1===t[0])return a(e);throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:if(t[0]===t[1])return m(e);throw new RangeError("Matrix must be square (size: "+De(t)+")");default:throw new RangeError("Matrix must be at most two dimensional (size: "+De(t)+")")}}})})),Om="multinomial",Cm=["typed","add","divide","multiply","factorial","isInteger","isPositive"],_m=W(Om,Cm,(e=>{var{typed:t,add:r,divide:n,multiply:i,factorial:a,isInteger:o,isPositive:s}=e;return t(Om,{"Array | Matrix":function(e){var t=0,u=1;return Ht(e,(function(e){if(!o(e)||!s(e))throw new TypeError("Positive integer value expected in function multinomial");t=r(t,e),u=i(u,a(e))})),n(a(t),u)}})})),Tm="rotationMatrix",Bm=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],qm=W(Tm,Bm,(e=>{var{typed:t,config:r,multiplyScalar:n,addScalar:i,unaryMinus:o,norm:s,BigNumber:u,matrix:c,DenseMatrix:l,SparseMatrix:f,cos:p,sin:m}=e;return t(Tm,{"":function(){return"Matrix"===r.matrix?c([]):[]},string:function(e){return c(e)},"number | BigNumber | Complex | Unit":function(e){return h(e,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(e,t){return h(e,t)},"number | BigNumber | Complex | Unit, Array":function(e,t){var r=c(t);return d(r),v(e,r,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,t){d(t);var n=t.storage()||("Matrix"===r.matrix?"dense":void 0);return v(e,t,n)},"number | BigNumber | Complex | Unit, Array, string":function(e,t,r){var n=c(t);return d(n),v(e,n,r)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,t,r){return d(t),v(e,t,r)}});function h(e,t){var r=a(e)?new u(-1):-1,i=p(e),o=m(e);return g([[i,n(r,o)],[o,i]],t)}function d(e){var t=e.size();if(t.length<1||3!==t[0])throw new RangeError("Vector must be of dimensions 1x3")}function y(e){return e.reduce(((e,t)=>n(e,t)))}function g(e,t){if(t){if("sparse"===t)return new f(e);if("dense"===t)return new l(e);throw new TypeError('Unknown matrix type "'.concat(t,'"'))}return e}function v(e,t,r){var n=s(t);if(0===n)throw new RangeError("Rotation around zero vector");var c=a(e)?u:null,l=c?new c(1):1,f=c?new c(-1):-1,h=c?new c(t.get([0])/n):t.get([0])/n,d=c?new c(t.get([1])/n):t.get([1])/n,v=c?new c(t.get([2])/n):t.get([2])/n,x=p(e),b=i(l,o(x)),w=m(e);return g([[i(x,y([h,h,b])),i(y([h,d,b]),y([f,v,w])),i(y([h,v,b]),y([d,w]))],[i(y([h,d,b]),y([v,w])),i(x,y([d,d,b])),i(y([d,v,b]),y([f,h,w]))],[i(y([h,v,b]),y([f,d,w])),i(y([d,v,b]),y([h,w])),i(x,y([v,v,b]))]],r)}})),zm="median",Dm=["typed","add","divide","compare","partitionSelect"],Im=W(zm,Dm,(e=>{var{typed:t,add:r,divide:n,compare:i,partitionSelect:a}=e;function o(e){try{var t=(e=et(e.valueOf())).length;if(0===t)throw new Error("Cannot calculate median of an empty array");if(t%2==0){for(var r=t/2-1,n=a(e,r+1),o=e[r],c=0;c0&&(o=e[c]);return u(o,n)}var l=a(e,(t-1)/2);return s(l)}catch(e){throw Gr(e,"median")}}var s=t({"number | BigNumber | Complex | Unit":function(e){return e}}),u=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,t){return n(r(e,t),2)}});return t(zm,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("median(A, dim) is not yet supported")},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function median");return o(e)}})})),km="rotate",Rm=["typed","multiply","rotationMatrix"],Fm=W(km,Rm,(e=>{var{typed:t,multiply:r,rotationMatrix:n}=e;return t(km,{"Array , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),r(n(t),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),r(n(t),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),r(n(t,a),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),r(n(t,a),e)}});function i(e,t){var r=Array.isArray(e)?je(e):e.size();if(r.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(t));if(2===r.length&&1!==r[1])throw new RangeError("Vector must be of dimensions 1x".concat(t));if(r[0]!==t)throw new RangeError("Vector must be of dimensions 1x".concat(t))}})),Um=["typed","abs","map","median","subtract"],Pm=W("mad",Um,(e=>{var{typed:t,abs:r,map:n,median:i,subtract:a}=e;return t("mad",{"Array | Matrix":o,"...":function(e){return o(e)}});function o(e){if(0===(e=et(e.valueOf())).length)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var t=i(e);return i(n(e,(function(e){return r(a(e,t))})))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf("median")?new TypeError(e.message.replace("median","mad")):Gr(e,"mad")}}})),jm="unit",Lm=["typed","Unit"],Hm=W(jm,Lm,(e=>{var{typed:t,Unit:r}=e;return t(jm,{Unit:function(e){return e.clone()},string:function(e){return r.isValuelessUnit(e)?new r(null,e):r.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string":function(e,t){return new r(e,t)},"Array | Matrix":function(e){return $t(e,this)}})})),$m=Nn({}),Gm=Sn({}),Vm=En({}),Zm=In({}),Wm=kn({}),Jm=Dn({}),Ym=Kn({config:n}),Xm=ei({}),Qm=ti({}),Km=Jn({Complex:Gm}),eh=$n({BigNumber:Ym,config:n}),th=Vn({BigNumber:Ym,config:n}),rh=Fn({BigNumber:Ym,config:n}),nh=Un({BigNumber:Ym,config:n}),ih=Zn({BigNumber:Ym,config:n}),ah=Pn({BigNumber:Ym,config:n}),oh=Ti({BigNumber:Ym,config:n}),sh=wi({BigNumber:Ym,config:n}),uh=Pi({BigNumber:Ym,config:n}),ch=_i({BigNumber:Ym,config:n}),lh=ta({}),fh=jn({BigNumber:Ym,config:n}),ph=Rn({BigNumber:Ym,config:n}),mh=Gn({BigNumber:Ym,config:n}),hh=Yn({}),dh=ra({Matrix:Xm}),yh=Ln({BigNumber:Ym,config:n}),gh=aa({BigNumber:Ym,Complex:Gm,DenseMatrix:dh,Fraction:lh}),vh=la({typed:gh}),xh=pa({typed:gh}),bh=xa({typed:gh}),wh=wa({typed:gh}),Nh=Sa({config:n,typed:gh}),Mh=Ea({typed:gh}),Sh=Oa({typed:gh}),Eh=Ca({Complex:Gm,typed:gh}),Ah=Ta({typed:gh}),Oh=ro({BigNumber:Ym,config:n,typed:gh}),Ch=wr({isInteger:vh,typed:gh}),_h=io({typed:gh}),Th=oo({Complex:Gm,typed:gh}),Bh=uo({Complex:Gm,config:n,typed:gh}),qh=co({typed:gh}),zh=fo({BigNumber:Ym,Fraction:lh,complex:Eh,typed:gh}),Dh=mo({typed:gh}),Ih=qo({typed:gh}),kh=zo({typed:gh}),Rh=Do({typed:gh}),Fh=Po({typed:gh}),Uh=jo({typed:gh}),Ph=$o({typed:gh}),jh=Vo({typed:gh}),Lh=Wo({typed:gh}),Hh=ts({typed:gh}),$h=rs({format:Hh,typed:gh}),Gh=is({typed:gh}),Vh=ss({typed:gh}),Zh=cs({Complex:Gm,config:n,typed:gh}),Wh=Cs({BigNumber:Ym,typed:gh}),Jh=Ts({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),Yh=qs({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),Xh=Ds({Complex:Gm,config:n,typed:gh}),Qh=Is({typed:gh}),Kh=Rs({Complex:Gm,config:n,typed:gh}),ed=Us({typed:gh}),td=js({BigNumber:Ym,typed:gh}),rd=Hs({BigNumber:Ym,typed:gh}),nd=Gs({BigNumber:Ym,typed:gh}),id=Zs({typed:gh}),ad=Ws({typed:gh}),od=Qs({typed:gh}),sd=iu({config:n,typed:gh}),ud=su({config:n,typed:gh}),cd=Hn({BigNumber:Ym,config:n}),ld=cu({typed:gh}),fd=fu({isNumeric:xh,typed:gh}),pd=mu({typed:gh}),md=du({typed:gh}),hd=yu({Fraction:lh,typed:gh}),dd=vu({typed:gh}),yd=bu({typed:gh}),gd=wu({typed:gh}),vd=Mu({Complex:Gm,config:n,typed:gh}),xd=Su({Complex:Gm,config:n,typed:gh}),bd=Au({typed:gh}),wd=Cu({typed:gh}),Nd=Tu({isNaN:wh,isNumeric:xh,typed:gh}),Md=Bu({format:Hh,typed:gh}),Sd=zu({Complex:Gm,config:n,typed:gh}),Ed=Iu({BigNumber:Ym,typed:gh}),Ad=ku({typed:gh}),Od=Ru({typed:gh}),Cd=Fu({BigNumber:Ym,typed:gh}),_d=Uu({typed:gh}),Td=ju({typed:gh}),Bd=$u({config:n,typed:gh}),qd=Wn({BigNumber:Ym,config:n}),zd=Vu({typed:gh}),Dd=Zu({Matrix:Xm,equalScalar:Nh,typed:gh}),Id=Ju({DenseMatrix:dh,Matrix:Xm,SparseMatrix:Dd,typed:gh}),kd=Yu({typed:gh}),Rd=rc({BigNumber:Ym,DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),Fd=uc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),Ud=fc({BigNumber:Ym,equalScalar:Nh,matrix:Id,typed:gh}),Pd=mc({BigNumber:Ym,config:n,matrix:Id,typed:gh}),jd=dc({equalScalar:Nh,matrix:Id,typed:gh}),Ld=vc({DenseMatrix:dh,matrix:Id,typed:gh}),Hd=xc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),$d=Lr({isInteger:vh,matrix:Id,typed:gh}),Gd=wc({DenseMatrix:dh,SparseMatrix:Dd,matrix:Id,typed:gh}),Vd=Mc({BigNumber:Ym,DenseMatrix:dh,SparseMatrix:Dd,config:n,matrix:Id,typed:gh}),Zd=Sc({BigNumber:Ym,config:n,matrix:Id,typed:gh}),Wd=Ac({isInteger:vh,matrix:Id,typed:gh}),Jd=Cc({matrix:Id,config:n,typed:gh}),Yd=Dr({matrix:Id,typed:gh}),Xd=Tc({BigNumber:Ym,config:n,matrix:Id,typed:gh}),Qd=Bc({format:Hh,typed:gh}),Kd=Rc({BigNumber:Ym,DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),ey=jc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),ty=Hc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),ry=Gc({BigNumber:Ym,DenseMatrix:dh,Fraction:lh,config:n,equalScalar:Nh,matrix:Id,typed:gh}),ny=Zc({matrix:Id,typed:gh}),iy=Jc({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),ay=Xc({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),oy=Kc({DenseMatrix:dh,config:n,equalScalar:Nh,matrix:Id,typed:gh}),sy=el({DenseMatrix:dh,smaller:iy}),uy=tl({larger:ay,smaller:iy}),cy=nl({SparseMatrix:Dd,typed:gh}),ly=al({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),fy=ul({BigNumber:Ym,DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),py=cl({BigNumber:Ym,typed:gh}),my=ll({DenseMatrix:dh,SparseMatrix:Dd,addScalar:yd,equalScalar:Nh,matrix:Id,typed:gh}),hy=fl({addScalar:yd,conj:bd,multiplyScalar:qh,size:Jd,typed:gh}),dy=ml({addScalar:yd,combinations:od,isInteger:vh,isNegative:zd,isPositive:bh,larger:ay,typed:gh}),yy=dl({typed:gh}),gy=gl({isZero:yy,matrix:Id,typed:gh}),vy=xl({BigNumber:Ym,Complex:Gm,Fraction:lh,config:n,isNegative:zd,matrix:Id,typed:gh,unaryMinus:dd}),xy=bl({config:n,equalScalar:Nh,matrix:Id,round:Kd,typed:gh}),by=Nl({addScalar:yd,dot:hy,equalScalar:Nh,matrix:Id,multiplyScalar:qh,typed:gh}),wy=Sl({equalScalar:Nh,matrix:Id,multiplyScalar:qh,typed:gh}),Ny=El({typed:gh}),My=Ol({matrix:Id,typed:gh}),Sy=_l({config:n,matrix:Id}),Ey=Bl({matrix:Id,typed:gh}),Ay=ql({matrix:Id,typed:gh}),Oy=zl({Complex:Gm,config:n,fraction:hd,identity:Vd,matrix:Id,multiply:by,number:Mh,typed:gh}),Cy=Il({DenseMatrix:dh,equalScalar:Nh,matrix:Id,pow:Oy,typed:gh}),_y=Rl({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),Ty=Pl({compare:ry,typed:gh}),By=Ll({compareText:ny,isZero:yy,typed:gh}),qy=$l({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),zy=Vl({compare:ry,isNaN:wh,isNumeric:xh,typed:gh}),Dy=Zl({ImmutableDenseMatrix:sy}),Iy=Jl({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),ky=Yl({typed:gh}),Ry=Ql({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Fy=ef({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Uy=rf({Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Py=af({compareNatural:Ty,typed:gh}),jy=of({add:my,matrix:Id,typed:gh}),Ly=sf({add:my,compare:ry,multiply:by,partitionSelect:zy,typed:gh}),Hy=pf({BigNumber:Ym,Complex:Gm,config:n,multiplyScalar:qh,pow:Oy,typed:gh}),$y=mf({BigNumber:Ym,typed:gh}),Gy=df({flatten:My,matrix:Id,size:Jd,typed:gh}),Vy=yf({equalScalar:Nh,matrix:Id,typed:gh}),Zy=vf({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),Wy=bf({matrix:Id,multiplyScalar:qh,typed:gh}),Jy=wf({matrix:Id,typed:gh}),Yy=Nf({bignumber:$y,fraction:hd,number:Mh}),Xy=Mf({equalScalar:Nh,matrix:Id,not:Fh,typed:gh,zeros:Xd}),Qy=Ef({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),Ky=Of({compare:ry,compareNatural:Ty,matrix:Id,typed:gh}),eg=Jr({config:n,numeric:Yy,smaller:iy,typed:gh}),tg=Cf({BigNumber:Ym,typed:gh}),rg=Tf({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),ng=qf({Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),ig=Df({Index:Dy,typed:gh}),ag=Xr({add:my,config:n,numeric:Yy,typed:gh}),og=kf({gamma:Hy,typed:gh}),sg=Ff({factorial:og,typed:gh}),ug=jf({flatten:My,matrix:Id,size:Jd,typed:gh}),cg=Hf({DenseMatrix:dh,addScalar:yd,equalScalar:Nh,matrix:Id,typed:gh,unaryMinus:dd}),lg=Vf({matrix:Id,multiply:by,subtract:cg,typed:gh}),fg=nn({bignumber:$y,matrix:Id,config:n,larger:ay,largerEq:qy,smaller:iy,smallerEq:Qy,typed:gh}),pg=ln({Index:Dy,matrix:Id,range:fg,typed:gh}),mg=Wf({config:n,multiplyScalar:qh,numeric:Yy,typed:gh}),hg=Yf({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),dg=Vr({config:n,larger:ay,numeric:Yy,typed:gh}),yg=Qf({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),gg=ep({Index:Dy,concat:$d,setDifference:Ry,size:Jd,subset:Yd,typed:gh}),vg=tp({config:n,equalScalar:Nh,matrix:Id,round:Kd,typed:gh}),xg=rp({DenseMatrix:dh,matrix:Id,typed:gh}),bg=ip({prod:mg,size:Jd,typed:gh}),wg=op({conj:bd,transpose:Jy,typed:gh}),Ng=up({equal:hg,typed:gh}),Mg=lp({Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Sg=fp({Complex:Gm,ceil:vg,floor:xy,matrix:Id,typed:gh}),Eg=sn({matrix:Id,number:Mh,subtract:cg,typed:gh}),Ag=mp({numeric:Yy,typed:gh}),Og=dp({Complex:Gm,config:n,divideScalar:Ag,typed:gh}),Cg=vp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),_g=bp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),Tg=wp({FibonacciHeap:uy,addScalar:yd,equalScalar:Nh}),Bg=Mp({Index:Dy,concat:$d,setIntersect:Fy,setSymDifference:gg,size:Jd,subset:Yd,typed:gh}),qg=Sp({DenseMatrix:dh,Spa:Tg,SparseMatrix:Dd,abs:kd,addScalar:yd,divideScalar:Ag,equalScalar:Nh,larger:ay,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh,unaryMinus:dd}),zg=Rp({SparseMatrix:Dd,abs:kd,add:my,divideScalar:Ag,larger:ay,largerEq:qy,multiply:by,subtract:cg,transpose:Jy,typed:gh}),Dg=Fp({lup:qg,matrix:Id,multiply:by,subtract:cg,typed:gh,unaryMinus:dd}),Ig=Pp({abs:kd,addScalar:yd,divideScalar:Ag,multiplyScalar:qh,sqrt:xd,subtract:cg,typed:gh,unaryMinus:dd}),kg=Lp({addScalar:yd,combinations:od,divideScalar:Ag,factorial:og,isInteger:vh,isNegative:zd,larger:ay,multiplyScalar:qh,pow:Oy,subtract:cg,typed:gh}),Rg=$p({addScalar:yd,combinations:od,divideScalar:Ag,isInteger:vh,isNegative:zd,multiplyScalar:qh,typed:gh}),Fg=en({Index:Dy,matrix:Id,range:fg,typed:gh}),Ug=Gp({Complex:Gm,config:n,divideScalar:Ag,typed:gh}),Pg=Zp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,typed:gh}),jg=Jp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),Lg=Xp({abs:kd,addScalar:yd,divideScalar:Ag,isPositive:bh,multiplyScalar:qh,smaller:iy,sqrt:xd,typed:gh}),Hg=Qp({addScalar:yd,complex:Eh,conj:bd,divideScalar:Ag,equal:hg,identity:Vd,isZero:yy,matrix:Id,multiplyScalar:qh,sign:zh,sqrt:xd,subtract:cg,typed:gh,unaryMinus:dd,zeros:Xd}),$g=Kp({abs:kd,addScalar:yd,det:Dg,divideScalar:Ag,identity:Vd,matrix:Id,multiply:by,typed:gh,unaryMinus:dd}),Gg=tm({abs:kd,add:my,identity:Vd,inv:$g,multiply:by,typed:gh}),Vg=rm({divideScalar:Ag,equalScalar:Nh,inv:$g,matrix:Id,multiply:by,typed:gh}),Zg=mn({add:my,divide:Vg,typed:gh}),Wg=gn({add:my,apply:Ch,divide:Vg,isNaN:wh,multiply:by,subtract:cg,typed:gh}),Jg=im({divide:Vg,dotDivide:Pg,isNumeric:xh,log:Ug,matrix:Id,multiply:by,sum:ag,typed:gh}),Yg=om({addScalar:yd,isInteger:vh,isNegative:zd,stirlingS2:kg,typed:gh}),Xg=um({Complex:Gm,config:n,divideScalar:Ag,log:Ug,typed:gh}),Qg=fm({BigNumber:Ym,Complex:Gm,Fraction:lh,abs:kd,addScalar:yd,config:n,divideScalar:Ag,equal:hg,fix:Sg,format:Hh,isNumeric:xh,multiplyScalar:qh,number:Mh,pow:Oy,round:Kd,subtract:cg}),Kg=mm({Unit:Qg,typed:gh}),ev=hm({abs:kd,add:my,addScalar:yd,atan:Qh,bignumber:$y,column:Fg,complex:Eh,config:n,cos:Od,diag:Gd,divideScalar:Ag,equal:hg,flatten:My,im:Rh,inv:$g,larger:ay,log10:Bh,matrix:Id,matrixFromColumns:Gy,multiply:by,multiplyScalar:qh,number:Mh,qr:Hg,re:Ny,round:Kd,sin:_d,smaller:iy,sqrt:xd,subtract:cg,transpose:Jy,typed:gh,usolveAll:jg}),tv=dm({abs:kd,add:my,addScalar:yd,config:n,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiply:by,multiplyScalar:qh,smaller:iy,subtract:cg,typed:gh}),rv=bn({sqrt:xd,typed:gh,variance:Wg}),nv=Bi({BigNumber:Ym,Unit:Qg,config:n}),iv=fi({BigNumber:Ym,Unit:Qg,config:n}),av=zi({BigNumber:Ym,Unit:Qg,config:n}),ov=pi({BigNumber:Ym,Unit:Qg,config:n}),sv=Si({BigNumber:Ym,Unit:Qg,config:n}),uv=xi({BigNumber:Ym,Unit:Qg,config:n}),cv=Di({BigNumber:Ym,Unit:Qg,config:n}),lv=Ii({BigNumber:Ym,Unit:Qg,config:n}),fv=ni({BigNumber:Ym,Unit:Qg,config:n}),pv=Ni({BigNumber:Ym,Unit:Qg,config:n}),mv=yi({BigNumber:Ym,Unit:Qg,config:n}),hv=oi({BigNumber:Ym,Unit:Qg,config:n}),dv=$i({BigNumber:Ym,Unit:Qg,config:n}),yv=Fi({BigNumber:Ym,Unit:Qg,config:n}),gv=Ei({BigNumber:Ym,Unit:Qg,config:n}),vv=Yi({BigNumber:Ym,Unit:Qg,config:n}),xv=Zi({BigNumber:Ym,Unit:Qg,config:n}),bv=Xi({BigNumber:Ym,Unit:Qg,config:n}),wv=Mi({BigNumber:Ym,Unit:Qg,config:n}),Nv=ai({BigNumber:Ym,Unit:Qg,config:n}),Mv=ji({BigNumber:Ym,Unit:Qg,config:n}),Sv=Li({BigNumber:Ym,Unit:Qg,config:n}),Ev=ui({BigNumber:Ym,Unit:Qg,config:n}),Av=gm({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),Ov=xm({abs:kd,add:my,conj:bd,ctranspose:wg,eigs:ev,equalScalar:Nh,larger:ay,matrix:Id,multiply:by,pow:Oy,smaller:iy,sqrt:xd,typed:gh}),Cv=Mm({DenseMatrix:dh,lsolve:Cg,lup:qg,matrix:Id,slu:zg,typed:gh,usolve:Av}),_v=Am({abs:kd,add:my,identity:Vd,inv:$g,max:dg,multiply:by,size:Jd,sqrt:xd,subtract:cg,typed:gh}),Tv=_m({add:my,divide:Vg,factorial:og,isInteger:vh,isPositive:bh,multiply:by,typed:gh}),Bv=qi({BigNumber:Ym,Unit:Qg,config:n}),qv=vi({BigNumber:Ym,Unit:Qg,config:n}),zv=si({BigNumber:Ym,Unit:Qg,config:n}),Dv=bi({BigNumber:Ym,Unit:Qg,config:n}),Iv=Vi({BigNumber:Ym,Unit:Qg,config:n}),kv=ki({BigNumber:Ym,Unit:Qg,config:n}),Rv=Gi({BigNumber:Ym,Unit:Qg,config:n}),Fv=di({BigNumber:Ym,Unit:Qg,config:n}),Uv=Wi({BigNumber:Ym,Unit:Qg,config:n}),Pv=Ai({BigNumber:Ym,Unit:Qg,config:n}),jv=ri({BigNumber:Ym,Unit:Qg,config:n}),Lv=Hi({BigNumber:Ym,Unit:Qg,config:n}),Hv=qm({BigNumber:Ym,DenseMatrix:dh,SparseMatrix:Dd,addScalar:yd,config:n,cos:Od,matrix:Id,multiplyScalar:qh,norm:Ov,sin:_d,typed:gh,unaryMinus:dd}),$v=Im({add:my,compare:ry,divide:Vg,partitionSelect:zy,typed:gh}),Gv=gi({BigNumber:Ym,Unit:Qg,config:n}),Vv=li({BigNumber:Ym,Unit:Qg,config:n}),Zv=mi({BigNumber:Ym,Unit:Qg,config:n}),Wv=Ui({BigNumber:Ym,Unit:Qg,config:n}),Jv=Ji({BigNumber:Ym,Unit:Qg,config:n}),Yv=Ci({BigNumber:Ym,Unit:Qg,config:n}),Xv=Fm({multiply:by,rotationMatrix:Hv,typed:gh}),Qv=Pm({abs:kd,map:jh,median:$v,subtract:cg,typed:gh}),Kv=ci({BigNumber:Ym,Unit:Qg,config:n}),ex=hi({BigNumber:Ym,Unit:Qg,config:n}),tx=Oi({BigNumber:Ym,Unit:Qg,config:n}),rx=Hm({Unit:Qg,typed:gh}),nx=Ri({BigNumber:Ym,Unit:Qg,config:n}),ix=ii({BigNumber:Ym,Unit:Qg,config:n}),ax={},ox={},sx={},ux=ue({mathWithTransform:ox}),cx=ct({Node:ux}),lx=lt({Node:ux,ResultSet:$m}),fx=vt({Node:ux}),px=xt({Node:ux}),mx=bt({Node:ux}),hx=Et({Node:ux}),dx=At({math:ax}),yx=Ot({classes:sx}),gx=Ct({Node:ux}),vx=_t({Node:ux}),xx=Tt({Node:ux}),bx=Bt({Node:ux,typed:gh}),wx=zt({Chain:dx,typed:gh}),Nx=kt({Node:ux,subset:Yd}),Mx=Rt({Node:ux,Range:Vm,size:Jd}),Sx=Ft({matrix:Id,Node:ux,subset:Yd}),Ex=Ut({Unit:Qg,Node:ux,math:ax}),Ax=jt({Node:ux,SymbolNode:Ex,math:ax}),Ox=Jt({AccessorNode:Nx,ArrayNode:cx,AssignmentNode:Sx,BlockNode:lx,ConditionalNode:gx,ConstantNode:fx,FunctionAssignmentNode:bx,FunctionNode:Ax,IndexNode:Mx,ObjectNode:px,OperatorNode:vx,ParenthesisNode:mx,RangeNode:xx,RelationalNode:hx,SymbolNode:Ex,config:n,numeric:Yy,typed:gh}),Cx=Xt({parse:Ox,typed:gh}),_x=Qt({parse:Ox}),Tx=Kt({parse:Ox}),Bx=ir({Help:_x,mathWithTransform:ox,typed:gh}),qx=or({parse:Ox,typed:gh}),zx=hr({bignumber:$y,fraction:hd,ConstantNode:fx,FunctionNode:Ax,OperatorNode:vx,ParenthesisNode:mx,SymbolNode:Ex,add:my,config:n,divide:Vg,equal:hg,isZero:yy,mathWithTransform:ox,multiply:by,parse:Ox,pow:Oy,subtract:cg,typed:gh}),Dx=yr({bignumber:$y,fraction:hd,ConstantNode:fx,FunctionNode:Ax,OperatorNode:vx,ParenthesisNode:mx,SymbolNode:Ex,add:my,config:n,divide:Vg,equal:hg,isZero:yy,mathWithTransform:ox,multiply:by,parse:Ox,pow:Oy,simplify:zx,subtract:cg,typed:gh}),Ix=vr({Parser:Tx,typed:gh}),kx=xr({ConstantNode:fx,FunctionNode:Ax,OperatorNode:vx,ParenthesisNode:mx,SymbolNode:Ex,config:n,equal:hg,isZero:yy,numeric:Yy,parse:Ox,simplify:zx,typed:gh});e(ax,{reviver:yx,false:Zm,null:Wm,true:Jm,replacer:Qm,i:Km,LN10:eh,LOG10E:th,NaN:rh,pi:nh,SQRT1_2:ih,tau:ah,efimovFactor:oh,fineStructure:sh,sackurTetrode:uh,weakMixingAngle:ch,e:fh,Infinity:ph,LOG2E:mh,PI:nh,version:hh,E:fh,phi:yh,typed:gh,isInteger:vh,isNumeric:xh,isPositive:bh,isNaN:wh,equalScalar:Nh,number:Mh,boolean:Sh,complex:Eh,splitUnit:Ah,unaryPlus:Oh,apply:Ch,cube:_h,expm1:Th,log10:Bh,multiplyScalar:qh,sign:zh,square:Dh,bitNot:Ih,arg:kh,im:Rh,not:Fh,filter:Uh,forEach:Ph,map:jh,erf:Lh,format:Hh,oct:$h,print:Gh,isPrime:Vh,acos:Zh,acot:Wh,acsc:Jh,asec:Yh,asin:Xh,atan:Qh,atanh:Kh,cosh:ed,coth:td,csch:rd,sech:nd,sinh:id,tanh:ad,chain:wx,combinations:od,pickRandom:sd,randomInt:ud,LN2:cd,clone:ld,hasNumericValue:fd,typeOf:pd,string:md,fraction:hd,unaryMinus:dd,addScalar:yd,exp:gd,log2:vd,sqrt:xd,conj:bd,getMatrixDataType:wd,mode:Nd,bin:Md,acosh:Sd,acsch:Ed,asinh:Ad,cos:Od,csc:Cd,sin:_d,combinationsWithRep:Td,random:Bd,SQRT2:qd,isNegative:zd,matrix:Id,abs:kd,gcd:Rd,mod:Fd,nthRoot:Ud,xgcd:Pd,bitAnd:jd,bitXor:Ld,or:Hd,concat:$d,diag:Gd,identity:Vd,ones:Zd,reshape:Wd,size:Jd,subset:Yd,zeros:Xd,hex:Qd,round:Kd,leftShift:ey,rightLogShift:ty,compare:ry,compareText:ny,smaller:iy,larger:ay,unequal:oy,sparse:cy,acoth:ly,atan2:fy,sec:py,add:my,dot:hy,composition:dy,isZero:yy,matrixFromFunction:gy,cbrt:vy,floor:xy,multiply:by,dotMultiply:wy,re:Ny,flatten:My,resize:Sy,squeeze:Ey,to:Ay,pow:Oy,dotPow:Cy,rightArithShift:_y,compareNatural:Ty,equalText:By,largerEq:qy,partitionSelect:zy,asech:Iy,tan:ky,setDifference:Ry,setIntersect:Fy,setMultiplicity:Uy,setSize:Py,trace:jy,quantileSeq:Ly,gamma:Hy,bignumber:$y,matrixFromColumns:Gy,lcm:Vy,bitOr:Zy,kron:Wy,transpose:Jy,numeric:Yy,and:Xy,smallerEq:Qy,sort:Ky,min:eg,cot:tg,setDistinct:rg,setPowerset:ng,index:ig,sum:ag,factorial:og,permutations:sg,matrixFromRows:ug,subtract:cg,cross:lg,range:fg,row:pg,prod:mg,equal:hg,max:dg,setCartesian:yg,setSymDifference:gg,ceil:vg,xor:xg,count:bg,ctranspose:wg,deepEqual:Ng,setIsSubset:Mg,fix:Sg,diff:Eg,divideScalar:Ag,nthRoots:Og,lsolve:Cg,lsolveAll:_g,setUnion:Bg,lup:qg,slu:zg,det:Dg,distance:Ig,stirlingS2:kg,catalan:Rg,column:Fg,log:Ug,dotDivide:Pg,usolveAll:jg,hypot:Lg,qr:Hg,inv:$g,expm:Gg,divide:Vg,mean:Zg,variance:Wg,kldivergence:Jg,bellNumbers:Yg,log1p:Xg,createUnit:Kg,eigs:ev,intersect:tv,std:rv,atomicMass:nv,bohrMagneton:iv,boltzmann:av,conductanceQuantum:ov,deuteronMass:sv,electronMass:uv,faraday:cv,firstRadiation:lv,gravitationConstant:fv,hartreeEnergy:pv,klitzing:mv,magneticConstant:hv,molarMass:dv,molarPlanckConstant:yv,neutronMass:gv,planckCharge:vv,planckLength:xv,planckTemperature:bv,protonMass:wv,reducedPlanckConstant:Nv,secondRadiation:Mv,stefanBoltzmann:Sv,vacuumImpedance:Ev,usolve:Av,norm:Ov,lusolve:Cv,sqrtm:_v,multinomial:Tv,avogadro:Bv,classicalElectronRadius:qv,electricConstant:zv,fermiCoupling:Dv,gravity:Iv,loschmidt:kv,molarMassC12:Rv,nuclearMagneton:Fv,planckMass:Uv,quantumOfCirculation:Pv,speedOfLight:jv,wienDisplacement:Lv,rotationMatrix:Hv,median:$v,bohrRadius:Gv,elementaryCharge:Vv,inverseConductanceQuantum:Zv,molarVolume:Wv,planckTime:Jv,thomsonCrossSection:Yv,rotate:Xv,parse:Ox,evaluate:Cx,mad:Qv,coulomb:Kv,magneticFluxQuantum:ex,rydberg:tx,unit:rx,help:Bx,gasConstant:nx,compile:qx,simplify:zx,rationalize:Dx,parser:Ix,planckConstant:ix,derivative:kx,config:n}),e(ox,ax,{apply:Mr({isInteger:vh,typed:gh}),filter:Cr({typed:gh}),map:Tr({typed:gh}),forEach:qr({typed:gh}),subset:Ur({matrix:Id,typed:gh}),index:Pr({Index:Dy}),concat:$r({isInteger:vh,matrix:Id,typed:gh}),max:Wr({config:n,larger:ay,numeric:Yy,typed:gh}),min:Yr({config:n,numeric:Yy,smaller:iy,typed:gh}),sum:Qr({add:my,config:n,numeric:Yy,typed:gh}),column:tn({Index:Dy,matrix:Id,range:fg,typed:gh}),range:an({bignumber:$y,matrix:Id,config:n,larger:ay,largerEq:qy,smaller:iy,smallerEq:Qy,typed:gh}),diff:cn({bignumber:$y,matrix:Id,number:Mh,subtract:cg,typed:gh}),row:fn({Index:Dy,matrix:Id,range:fg,typed:gh}),mean:hn({add:my,divide:Vg,typed:gh}),variance:xn({add:my,apply:Ch,divide:Vg,isNaN:wh,multiply:by,subtract:cg,typed:gh}),std:wn({sqrt:xd,typed:gh,variance:Wg})}),e(sx,{ResultSet:$m,Complex:Gm,Range:Vm,Node:ux,ArrayNode:cx,BlockNode:lx,ConstantNode:fx,ObjectNode:px,ParenthesisNode:mx,RelationalNode:hx,Chain:dx,BigNumber:Ym,Matrix:Xm,ConditionalNode:gx,OperatorNode:vx,Fraction:lh,RangeNode:xx,DenseMatrix:dh,FunctionAssignmentNode:bx,SparseMatrix:Dd,ImmutableDenseMatrix:sy,FibonacciHeap:uy,AccessorNode:Nx,IndexNode:Mx,Index:Dy,AssignmentNode:Sx,Spa:Tg,Unit:Qg,SymbolNode:Ex,FunctionNode:Ax,Help:_x,Parser:Tx}),dx.createProxy(ax),browser.omnibox.setDefaultSuggestion({description:"Do most mathematical computations."});const Rx=(e,t)=>{const r=Cx(e);t([{description:String(r),content:String(r)}])};browser.omnibox.onInputStarted.addListener(Rx),browser.omnibox.onInputChanged.addListener(Rx)})()})(); \ No newline at end of file From bcdea66fc90a1761fec780d18d6b51cc3bf2da61 Mon Sep 17 00:00:00 2001 From: Ben Cooper Date: Tue, 21 Sep 2021 20:32:59 -0700 Subject: [PATCH 3/9] more struggles with webpack closure --- README.md | 3 +++ webpack.config.js | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 051727e..f77d3c7 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,6 @@ The source code can be found in `index.js`. The `manifest.json` can be found in the `addon` directory which is what is zipped. `npm run build` to compile `./addon/index.js`. Should just need a simple node setup to run (currently on node 11.12.0 and npm 6.7.0). + + +./node_modules/.bin/google-closure-compiler -O ADVANCED addon/index.js --js_output_file addon/index.prod.js --language_out ECMASCRIPT_2015 \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index bb937ff..1577f7f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,8 +1,15 @@ const path = require("path"); -const ClosurePlugin = require('closure-webpack-plugin'); +const ClosurePlugin = require("closure-webpack-plugin"); module.exports = { - optimization: { minimizer: [new ClosurePlugin({ mode: "STANDARD" }, {})] }, + optimization: { + minimizer: [ + new ClosurePlugin( + { mode: "AGGRESSIVE_BUNDLE" }, + { externs: ["./index.extern.js"] } + ), + ], + }, entry: { addon: "./index.js", }, From a8ceaa0482bf27225a060f8a7338ba7b38768429 Mon Sep 17 00:00:00 2001 From: Ben Cooper Date: Tue, 21 Sep 2021 20:33:07 -0700 Subject: [PATCH 4/9] add extern --- index.extern.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 index.extern.js diff --git a/index.extern.js b/index.extern.js new file mode 100644 index 0000000..fdde65c --- /dev/null +++ b/index.extern.js @@ -0,0 +1,9 @@ +/** + * @fileoverview Clarifying the browser global is available. + * @externs + */ + +const browser = {}; + +browser.omnibox.onInputStarted.addListener = function (cb) {}; +browser.omnibox.onInputChanged.addListener = function (cb) {}; From 5d3ed827838e75f02a3e9654d034df38876f3cc4 Mon Sep 17 00:00:00 2001 From: Ben Cooper Date: Tue, 21 Sep 2021 20:40:32 -0700 Subject: [PATCH 5/9] extern change --- addon/index.js | 1114 ++++++++++++++++++++++++++++++++++++++++++++++- index.extern.js | 1 + 2 files changed, 1113 insertions(+), 2 deletions(-) diff --git a/addon/index.js b/addon/index.js index f78a894..9cd0271 100644 --- a/addon/index.js +++ b/addon/index.js @@ -1,2 +1,1112 @@ -/*! For license information please see index.js.LICENSE.txt */ -(()=>{var e={977:function(e,t){var r;!function(n){"use strict";var i=function(e){return.5*(Math.exp(e)+Math.exp(-e))},a=function(e){return.5*(Math.exp(e)-Math.exp(-e))},o=function(){throw SyntaxError("Invalid Param")};function s(e,t){var r=Math.abs(e),n=Math.abs(t);return 0===e?Math.log(n):0===t?Math.log(r):r<3e3&&n<3e3?.5*Math.log(e*e+t*t):Math.log(e/Math.cos(Math.atan2(t,e)))}function u(e,t){if(!(this instanceof u))return new u(e,t);var r=function(e,t){var r={re:0,im:0};if(null==e)r.re=r.im=0;else if(void 0!==t)r.re=e,r.im=t;else switch(typeof e){case"object":if("im"in e&&"re"in e)r.re=e.re,r.im=e.im;else if("abs"in e&&"arg"in e){if(!Number.isFinite(e.abs)&&Number.isFinite(e.arg))return u.INFINITY;r.re=e.abs*Math.cos(e.arg),r.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!Number.isFinite(e.r)&&Number.isFinite(e.phi))return u.INFINITY;r.re=e.r*Math.cos(e.phi),r.im=e.r*Math.sin(e.phi)}else 2===e.length?(r.re=e[0],r.im=e[1]):o();break;case"string":r.im=r.re=0;var n=e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),i=1,a=0;null===n&&o();for(var s=0;s0&&o();break;case"number":r.im=0,r.re=e;break;default:o()}return isNaN(r.re)||isNaN(r.im),r}(e,t);this.re=r.re,this.im=r.im}u.prototype={re:0,im:0,sign:function(){var e=this.abs();return new u(this.re/e,this.im/e)},add:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:new u(this.re+r.re,this.im+r.im)},sub:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:new u(this.re-r.re,this.im-r.im)},mul:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isZero()||this.isZero()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:0===r.im&&0===this.im?new u(this.re*r.re,0):new u(this.re*r.re-this.im*r.im,this.re*r.im+this.im*r.re)},div:function(e,t){var r=new u(e,t);if(this.isZero()&&r.isZero()||this.isInfinite()&&r.isInfinite())return u.NAN;if(this.isInfinite()||r.isZero())return u.INFINITY;if(this.isZero()||r.isInfinite())return u.ZERO;e=this.re,t=this.im;var n,i,a=r.re,o=r.im;return 0===o?new u(e/a,t/a):Math.abs(a)0)return new u(Math.pow(e,r.re),0);if(0===e)switch((r.re%4+4)%4){case 0:return new u(Math.pow(t,r.re),0);case 1:return new u(0,Math.pow(t,r.re));case 2:return new u(-Math.pow(t,r.re),0);case 3:return new u(0,-Math.pow(t,r.re))}}if(0===e&&0===t&&r.re>0&&r.im>=0)return u.ZERO;var n=Math.atan2(t,e),i=s(e,t);return e=Math.exp(r.re*i-r.im*n),t=r.im*i+r.re*n,new u(e*Math.cos(t),e*Math.sin(t))},sqrt:function(){var e,t,r=this.re,n=this.im,i=this.abs();if(r>=0){if(0===n)return new u(Math.sqrt(r),0);e=.5*Math.sqrt(2*(i+r))}else e=Math.abs(n)/Math.sqrt(2*(i-r));return t=r<=0?.5*Math.sqrt(2*(i-r)):Math.abs(n)/Math.sqrt(2*(i+r)),new u(e,n<0?-t:t)},exp:function(){var e=Math.exp(this.re);return this.im,new u(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){var e=this.re,t=this.im;return new u(Math.expm1(e)*Math.cos(t)+function(e){var t=Math.PI/4;if(e<-t||e>t)return Math.cos(e)-1;var r=e*e;return r*(r*(1/24+r*(-1/720+r*(1/40320+r*(-1/3628800+r*(1/4790014600+r*(-1/87178291200+r*(1/20922789888e3)))))))-.5)}(t),Math.exp(e)*Math.sin(t))},log:function(){var e=this.re,t=this.im;return new u(s(e,t),Math.atan2(t,e))},abs:function(){return e=this.re,t=this.im,r=Math.abs(e),n=Math.abs(t),r<3e3&&n<3e3?Math.sqrt(r*r+n*n):(r1&&0===t,n=1-e,i=1+e,a=n*n+t*t,o=0!==a?new u((i*n-t*t)/a,(t*n+i*t)/a):new u(-1!==e?e/0:0,0!==t?t/0:0),c=o.re;return o.re=s(o.re,o.im)/2,o.im=Math.atan2(o.im,c)/2,r&&(o.im=-o.im),o},acoth:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new u(0,Math.PI/2);var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).atanh():new u(0!==e?e/0:0,0!==t?-t/0:0).atanh()},acsch:function(){var e=this.re,t=this.im;if(0===t)return new u(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).asinh():new u(0!==e?e/0:0,0!==t?-t/0:0).asinh()},asech:function(){var e=this.re,t=this.im;if(this.isZero())return u.INFINITY;var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).acosh():new u(0!==e?e/0:0,0!==t?-t/0:0).acosh()},inverse:function(){if(this.isZero())return u.INFINITY;if(this.isInfinite())return u.ZERO;var e=this.re,t=this.im,r=e*e+t*t;return new u(e/r,-t/r)},conjugate:function(){return new u(this.re,-this.im)},neg:function(){return new u(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new u(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new u(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new u(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){var r=new u(e,t);return Math.abs(r.re-this.re)<=u.EPSILON&&Math.abs(r.im-this.im)<=u.EPSILON},clone:function(){return new u(this.re,this.im)},toString:function(){var e=this.re,t=this.im,r="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)0){for(a+=o,t=1;tr)throw Error(y+e)}function B(e,t,r,n){var i,a,o,s;for(a=e[0];a>=10;a/=10)--t;return--t<0?(t+=7,i=0):(i=Math.ceil((t+1)/7),t%=7),a=b(10,7-t),s=e[i]%a|0,null==n?t<3?(0==t?s=s/100|0:1==t&&(s=s/10|0),o=r<4&&99999==s||r>3&&49999==s||5e4==s||0==s):o=(r<4&&s+1==a||r>3&&s+1==a/2)&&(e[i+1]/a/100|0)==b(10,t-2)-1||(s==a/2||0==s)&&0==(e[i+1]/a/100|0):t<4?(0==t?s=s/1e3|0:1==t?s=s/100|0:2==t&&(s=s/10|0),o=(n||r<4)&&9999==s||!n&&r>3&&4999==s):o=((n||r<4)&&s+1==a||!n&&r>3&&s+1==a/2)&&(e[i+1]/a/1e3|0)==b(10,t-3)-1,o}function q(e,t,r){for(var n,i,a=[0],o=0,s=e.length;or-1&&(void 0===a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/r|0,a[n]%=r)}return a.reverse()}C.absoluteValue=C.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),D(e)},C.ceil=function(){return D(new this.constructor(this),this.e+1,2)},C.comparedTo=C.cmp=function(e){var t,r,n,i,a=this,o=a.d,s=(e=new a.constructor(e)).d,u=a.s,c=e.s;if(!o||!s)return u&&c?u!==c?u:o===s?0:!o^u<0?1:-1:NaN;if(!o[0]||!s[0])return o[0]?u:s[0]?-c:0;if(u!==c)return u;if(a.e!==e.e)return a.e>e.e^u<0?1:-1;for(t=0,r=(n=o.length)<(i=s.length)?n:i;ts[t]^u<0?1:-1;return n===i?0:n>i^u<0?1:-1},C.cosine=C.cos=function(){var e,t,r=this,n=r.constructor;return r.d?r.d[0]?(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(e,t){var r,n,i=t.d.length;i<32?n=(1/Y(4,r=Math.ceil(i/3))).toString():(r=16,n="2.3283064365386962890625e-10"),e.precision+=r,t=J(e,1,t.times(n),new e(1));for(var a=r;a--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=r,t}(n,X(n,r)),n.precision=e,n.rounding=t,D(2==s||3==s?r.neg():r,e,t,!0)):new n(1):new n(NaN)},C.cubeRoot=C.cbrt=function(){var e,t,r,n,i,a,o,s,u,c,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(h=!1,(a=l.s*b(l.s*l,1/3))&&Math.abs(a)!=1/0?n=new f(a.toString()):(r=_(l.d),(a=((e=l.e)-r.length+1)%3)&&(r+=1==a||-2==a?"0":"00"),a=b(r,1/3),e=x((e+1)/3)-(e%3==(e<0?-1:2)),(n=new f(r=a==1/0?"5e"+e:(r=a.toExponential()).slice(0,r.indexOf("e")+1)+e)).s=l.s),o=(e=f.precision)+3;;)if(c=(u=(s=n).times(s).times(s)).plus(l),n=z(c.plus(l).times(s),c.plus(u),o+2,1),_(s.d).slice(0,o)===(r=_(n.d)).slice(0,o)){if("9999"!=(r=r.slice(o-3,o+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(D(n,e+1,1),t=!n.times(n).times(n).eq(l));break}if(!i&&(D(s,e+1,0),s.times(s).times(s).eq(l))){n=s;break}o+=4,i=1}return h=!0,D(n,e,f.rounding,t)},C.decimalPlaces=C.dp=function(){var e,t=this.d,r=NaN;if(t){if(r=7*((e=t.length-1)-x(this.e/7)),e=t[e])for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r},C.dividedBy=C.div=function(e){return z(this,new this.constructor(e))},C.dividedToIntegerBy=C.divToInt=function(e){var t=this.constructor;return D(z(this,new t(e),0,1,1),t.precision,t.rounding)},C.equals=C.eq=function(e){return 0===this.cmp(e)},C.floor=function(){return D(new this.constructor(this),this.e+1,3)},C.greaterThan=C.gt=function(e){return this.cmp(e)>0},C.greaterThanOrEqualTo=C.gte=function(e){var t=this.cmp(e);return 1==t||0===t},C.hyperbolicCosine=C.cosh=function(){var e,t,r,n,i,a=this,o=a.constructor,s=new o(1);if(!a.isFinite())return new o(a.s?1/0:NaN);if(a.isZero())return s;r=o.precision,n=o.rounding,o.precision=r+Math.max(a.e,a.sd())+4,o.rounding=1,(i=a.d.length)<32?t=(1/Y(4,e=Math.ceil(i/3))).toString():(e=16,t="2.3283064365386962890625e-10"),a=J(o,1,a.times(t),new o(1),!0);for(var u,c=e,l=new o(8);c--;)u=a.times(a),a=s.minus(u.times(l.minus(u.times(l))));return D(a,o.precision=r,o.rounding=n,!0)},C.hyperbolicSine=C.sinh=function(){var e,t,r,n,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.precision,r=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,(n=i.d.length)<3)i=J(a,2,i,i,!0);else{e=(e=1.4*Math.sqrt(n))>16?16:0|e,i=J(a,2,i=i.times(1/Y(5,e)),i,!0);for(var o,s=new a(5),u=new a(16),c=new a(20);e--;)o=i.times(i),i=i.times(s.plus(o.times(u.times(o).plus(c))))}return a.precision=t,a.rounding=r,D(i,t,r,!0)},C.hyperbolicTangent=C.tanh=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+7,n.rounding=1,z(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)},C.inverseCosine=C.acos=function(){var e,t=this,r=t.constructor,n=t.abs().cmp(1),i=r.precision,a=r.rounding;return-1!==n?0===n?t.isNeg()?F(r,i,a):new r(0):new r(NaN):t.isZero()?F(r,i+4,a).times(.5):(r.precision=i+6,r.rounding=1,t=t.asin(),e=F(r,i+4,a).times(.5),r.precision=i,r.rounding=a,e.minus(t))},C.inverseHyperbolicCosine=C.acosh=function(){var e,t,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(e=n.precision,t=n.rounding,n.precision=e+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,h=!1,r=r.times(r).minus(1).sqrt().plus(r),h=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)},C.inverseHyperbolicSine=C.asinh=function(){var e,t,r=this,n=r.constructor;return!r.isFinite()||r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,h=!1,r=r.times(r).plus(1).sqrt().plus(r),h=!0,n.precision=e,n.rounding=t,r.ln())},C.inverseHyperbolicTangent=C.atanh=function(){var e,t,r,n,i=this,a=i.constructor;return i.isFinite()?i.e>=0?new a(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=a.precision,t=a.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?D(new a(i),e,t,!0):(a.precision=r=n-i.e,i=z(i.plus(1),new a(1).minus(i),r+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=t,i.times(.5))):new a(NaN)},C.inverseSine=C.asin=function(){var e,t,r,n,i=this,a=i.constructor;return i.isZero()?new a(i):(t=i.abs().cmp(1),r=a.precision,n=a.rounding,-1!==t?0===t?((e=F(a,r+4,n).times(.5)).s=i.s,e):new a(NaN):(a.precision=r+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=r,a.rounding=n,i.times(2)))},C.inverseTangent=C.atan=function(){var e,t,r,n,i,a,o,s,u,c=this,l=c.constructor,f=l.precision,p=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&f+4<=O)return(o=F(l,f+4,p).times(.25)).s=c.s,o}else{if(!c.s)return new l(NaN);if(f+4<=O)return(o=F(l,f+4,p).times(.5)).s=c.s,o}for(l.precision=s=f+10,l.rounding=1,e=r=Math.min(28,s/7+2|0);e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(h=!1,t=Math.ceil(s/7),n=1,u=c.times(c),o=new l(c),i=c;-1!==e;)if(i=i.times(u),a=o.minus(i.div(n+=2)),i=i.times(u),void 0!==(o=a.plus(i.div(n+=2))).d[t])for(e=t;o.d[e]===a.d[e]&&e--;);return r&&(o=o.times(2<this.d.length-2},C.isNaN=function(){return!this.s},C.isNegative=C.isNeg=function(){return this.s<0},C.isPositive=C.isPos=function(){return this.s>0},C.isZero=function(){return!!this.d&&0===this.d[0]},C.lessThan=C.lt=function(e){return this.cmp(e)<0},C.lessThanOrEqualTo=C.lte=function(e){return this.cmp(e)<1},C.logarithm=C.log=function(e){var t,r,n,i,a,o,s,u,c=this,l=c.constructor,f=l.precision,p=l.rounding;if(null==e)e=new l(10),t=!0;else{if(r=(e=new l(e)).d,e.s<0||!r||!r[0]||e.eq(1))return new l(NaN);t=e.eq(10)}if(r=c.d,c.s<0||!r||!r[0]||c.eq(1))return new l(r&&!r[0]?-1/0:1!=c.s?NaN:r?0:1/0);if(t)if(r.length>1)a=!0;else{for(i=r[0];i%10==0;)i/=10;a=1!==i}if(h=!1,o=G(c,s=f+5),n=t?R(l,s+10):G(e,s),B((u=z(o,n,s,1)).d,i=f,p))do{if(o=G(c,s+=10),n=t?R(l,s+10):G(e,s),u=z(o,n,s,1),!a){+_(u.d).slice(i+1,i+15)+1==1e14&&(u=D(u,f+1,0));break}}while(B(u.d,i+=10,p));return h=!0,D(u,f,p)},C.minus=C.sub=function(e){var t,r,n,i,a,o,s,u,c,l,f,p,m=this,d=m.constructor;if(e=new d(e),!m.d||!e.d)return m.s&&e.s?m.d?e.s=-e.s:e=new d(e.d||m.s!==e.s?m:NaN):e=new d(NaN),e;if(m.s!=e.s)return e.s=-e.s,m.plus(e);if(c=m.d,p=e.d,s=d.precision,u=d.rounding,!c[0]||!p[0]){if(p[0])e.s=-e.s;else{if(!c[0])return new d(3===u?-0:0);e=new d(m)}return h?D(e,s,u):e}if(r=x(e.e/7),l=x(m.e/7),c=c.slice(),a=l-r){for((f=a<0)?(t=c,a=-a,o=p.length):(t=p,r=l,o=c.length),a>(n=Math.max(Math.ceil(s/7),o)+2)&&(a=n,t.length=1),t.reverse(),n=a;n--;)t.push(0);t.reverse()}else{for((f=(n=c.length)<(o=p.length))&&(o=n),n=0;n0;--n)c[o++]=0;for(n=p.length;n>a;){if(c[--n](o=(a=Math.ceil(s/7))>o?a+1:o+1)&&(i=o,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for((o=c.length)-(i=l.length)<0&&(i=o,r=l,l=c,c=r),t=0;i;)t=(c[--i]=c[i]+l[i]+t)/E|0,c[i]%=E;for(t&&(c.unshift(t),++n),o=c.length;0==c[--o];)c.pop();return e.d=c,e.e=k(c,n),h?D(e,s,u):e},C.precision=C.sd=function(e){var t,r=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(y+e);return r.d?(t=U(r.d),e&&r.e+1>t&&(t=r.e+1)):t=NaN,t},C.round=function(){var e=this,t=e.constructor;return D(new t(e),e.e+1,t.rounding)},C.sine=C.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(e,t){var r,n=t.d.length;if(n<3)return J(e,2,t,t);r=(r=1.4*Math.sqrt(n))>16?16:0|r,t=J(e,2,t=t.times(1/Y(5,r)),t);for(var i,a=new e(5),o=new e(16),s=new e(20);r--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}(n,X(n,r)),n.precision=e,n.rounding=t,D(s>2?r.neg():r,e,t,!0)):new n(NaN)},C.squareRoot=C.sqrt=function(){var e,t,r,n,i,a,o=this,s=o.d,u=o.e,c=o.s,l=o.constructor;if(1!==c||!s||!s[0])return new l(!c||c<0&&(!s||s[0])?NaN:s?o:1/0);for(h=!1,0==(c=Math.sqrt(+o))||c==1/0?(((t=_(s)).length+u)%2==0&&(t+="0"),c=Math.sqrt(t),u=x((u+1)/2)-(u<0||u%2),n=new l(t=c==1/0?"5e"+u:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+u)):n=new l(c.toString()),r=(u=l.precision)+3;;)if(n=(a=n).plus(z(o,a,r+2,1)).times(.5),_(a.d).slice(0,r)===(t=_(n.d)).slice(0,r)){if("9999"!=(t=t.slice(r-3,r+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(D(n,u+1,1),e=!n.times(n).eq(o));break}if(!i&&(D(a,u+1,0),a.times(a).eq(o))){n=a;break}r+=4,i=1}return h=!0,D(n,u,l.rounding,e)},C.tangent=C.tan=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+10,n.rounding=1,(r=r.sin()).s=1,r=z(r,new n(1).minus(r.times(r)).sqrt(),e+10,0),n.precision=e,n.rounding=t,D(2==s||4==s?r.neg():r,e,t,!0)):new n(NaN)},C.times=C.mul=function(e){var t,r,n,i,a,o,s,u,c,l=this,f=l.constructor,p=l.d,m=(e=new f(e)).d;if(e.s*=l.s,!(p&&p[0]&&m&&m[0]))return new f(!e.s||p&&!p[0]&&!m||m&&!m[0]&&!p?NaN:p&&m?0*e.s:e.s/0);for(r=x(l.e/7)+x(e.e/7),(u=p.length)<(c=m.length)&&(a=p,p=m,m=a,o=u,u=c,c=o),a=[],n=o=u+c;n--;)a.push(0);for(n=c;--n>=0;){for(t=0,i=u+n;i>n;)s=a[i]+m[n]*p[i-n-1]+t,a[i--]=s%E|0,t=s/E|0;a[i]=(a[i]+t)%E|0}for(;!a[--o];)a.pop();return t?++r:a.shift(),e.d=a,e.e=k(a,r),h?D(e,f.precision,f.rounding):e},C.toBinary=function(e,t){return Q(this,2,e,t)},C.toDecimalPlaces=C.toDP=function(e,t){var r=this,n=r.constructor;return r=new n(r),void 0===e?r:(T(e,0,c),void 0===t?t=n.rounding:T(t,0,8),D(r,e+r.e+1,t))},C.toExponential=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=I(n,!0):(T(e,0,c),void 0===t?t=i.rounding:T(t,0,8),r=I(n=D(new i(n),e+1,t),!0,e+1)),n.isNeg()&&!n.isZero()?"-"+r:r},C.toFixed=function(e,t){var r,n,i=this,a=i.constructor;return void 0===e?r=I(i):(T(e,0,c),void 0===t?t=a.rounding:T(t,0,8),r=I(n=D(new a(i),e+i.e+1,t),!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r},C.toFraction=function(e){var t,r,n,i,a,o,s,u,c,l,f,p,m=this,d=m.d,g=m.constructor;if(!d)return new g(m);if(c=r=new g(1),n=u=new g(0),o=(a=(t=new g(n)).e=U(d)-m.e-1)%7,t.d[0]=b(10,o<0?7+o:o),null==e)e=a>0?t:c;else{if(!(s=new g(e)).isInt()||s.lt(c))throw Error(y+s);e=s.gt(t)?a>0?t:c:s}for(h=!1,s=new g(_(d)),l=g.precision,g.precision=a=7*d.length*2;f=z(s,t,0,1,1),1!=(i=r.plus(f.times(n))).cmp(e);)r=n,n=i,i=c,c=u.plus(f.times(i)),u=i,i=t,t=s.minus(f.times(i)),s=i;return i=z(e.minus(r),n,0,1,1),u=u.plus(i.times(c)),r=r.plus(i.times(n)),u.s=c.s=m.s,p=z(c,n,a,1).minus(m).abs().cmp(z(u,r,a,1).minus(m).abs())<1?[c,n]:[u,r],g.precision=l,h=!0,p},C.toHexadecimal=C.toHex=function(e,t){return Q(this,16,e,t)},C.toNearest=function(e,t){var r=this,n=r.constructor;if(r=new n(r),null==e){if(!r.d)return r;e=new n(1),t=n.rounding}else{if(e=new n(e),void 0===t?t=n.rounding:T(t,0,8),!r.d)return e.s?r:e;if(!e.d)return e.s&&(e.s=r.s),e}return e.d[0]?(h=!1,r=z(r,e,0,t,1).times(e),h=!0,D(r)):(e.s=r.s,r=e),r},C.toNumber=function(){return+this},C.toOctal=function(e,t){return Q(this,8,e,t)},C.toPower=C.pow=function(e){var t,r,n,i,a,o,s=this,u=s.constructor,c=+(e=new u(e));if(!(s.d&&e.d&&s.d[0]&&e.d[0]))return new u(b(+s,c));if((s=new u(s)).eq(1))return s;if(n=u.precision,a=u.rounding,e.eq(1))return D(s,n,a);if((t=x(e.e/7))>=e.d.length-1&&(r=c<0?-c:c)<=9007199254740991)return i=j(u,s,r,n),e.s<0?new u(1).div(i):D(i,n,a);if((o=s.s)<0){if(tu.maxE+1||t0?o/0:0):(h=!1,u.rounding=s.s=1,r=Math.min(12,(t+"").length),(i=$(e.times(G(s,n+r)),n)).d&&B((i=D(i,n+5,1)).d,n,a)&&(t=n+10,+_((i=D($(e.times(G(s,t+r)),t),t+5,1)).d).slice(n+1,n+15)+1==1e14&&(i=D(i,n+1,0))),i.s=o,h=!0,u.rounding=a,D(i,n,a))},C.toPrecision=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=I(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(T(e,1,c),void 0===t?t=i.rounding:T(t,0,8),r=I(n=D(new i(n),e,t),e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+r:r},C.toSignificantDigits=C.toSD=function(e,t){var r=this.constructor;return void 0===e?(e=r.precision,t=r.rounding):(T(e,1,c),void 0===t?t=r.rounding:T(t,0,8)),D(new r(this),e,t)},C.toString=function(){var e=this,t=e.constructor,r=I(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r},C.truncated=C.trunc=function(){return D(new this.constructor(this),this.e+1,1)},C.valueOf=C.toJSON=function(){var e=this,t=e.constructor,r=I(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};var z=function(){function e(e,t,r){var n,i=0,a=e.length;for(e=e.slice();a--;)n=e[a]*t+i,e[a]=n%r|0,i=n/r|0;return i&&e.unshift(i),e}function t(e,t,r,n){var i,a;if(r!=n)a=r>n?1:-1;else for(i=a=0;it[i]?1:-1;break}return a}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]1;)e.shift()}return function(n,i,a,s,u,c){var l,f,p,m,h,d,y,g,v,b,w,N,M,S,A,O,C,_,T,B,q=n.constructor,z=n.s==i.s?1:-1,I=n.d,k=i.d;if(!(I&&I[0]&&k&&k[0]))return new q(n.s&&i.s&&(I?!k||I[0]!=k[0]:k)?I&&0==I[0]||!k?0*z:z/0:NaN);for(c?(h=1,f=n.e-i.e):(c=E,h=7,f=x(n.e/h)-x(i.e/h)),T=k.length,C=I.length,b=(v=new q(z)).d=[],p=0;k[p]==(I[p]||0);p++);if(k[p]>(I[p]||0)&&f--,null==a?(S=a=q.precision,s=q.rounding):S=u?a+(n.e-i.e)+1:a,S<0)b.push(1),d=!0;else{if(S=S/h+2|0,p=0,1==T){for(m=0,k=k[0],S++;(p1&&(k=e(k,m,c),I=e(I,m,c),T=k.length,C=I.length),O=T,N=(w=I.slice(0,T)).length;N=c/2&&++_;do{m=0,(l=t(k,w,T,N))<0?(M=w[0],T!=N&&(M=M*c+(w[1]||0)),(m=M/_|0)>1?(m>=c&&(m=c-1),1==(l=t(y=e(k,m,c),w,g=y.length,N=w.length))&&(m--,r(y,T=10;m/=10)p++;v.e=p+f*h-1,D(v,u?a+v.e+1:a,s,d)}return v}}();function D(e,t,r,n){var i,a,o,s,u,c,l,f,p,m=e.constructor;e:if(null!=t){if(!(f=e.d))return e;for(i=1,s=f[0];s>=10;s/=10)i++;if((a=t-i)<0)a+=7,o=t,u=(l=f[p=0])/b(10,i-o-1)%10|0;else if((p=Math.ceil((a+1)/7))>=(s=f.length)){if(!n)break e;for(;s++<=p;)f.push(0);l=u=0,i=1,o=(a%=7)-7+1}else{for(l=s=f[p],i=1;s>=10;s/=10)i++;u=(o=(a%=7)-7+i)<0?0:l/b(10,i-o-1)%10|0}if(n=n||t<0||void 0!==f[p+1]||(o<0?l:l%b(10,i-o-1)),c=r<4?(u||n)&&(0==r||r==(e.s<0?3:2)):u>5||5==u&&(4==r||n||6==r&&(a>0?o>0?l/b(10,i-o):0:f[p-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,c?(t-=e.e+1,f[0]=b(10,(7-t%7)%7),e.e=-t||0):f[0]=e.e=0,e;if(0==a?(f.length=p,s=1,p--):(f.length=p+1,s=b(10,7-a),f[p]=o>0?(l/b(10,i-o)%b(10,o)|0)*s:0),c)for(;;){if(0==p){for(a=1,o=f[0];o>=10;o/=10)a++;for(o=f[0]+=s,s=1;o>=10;o/=10)s++;a!=s&&(e.e++,f[0]==E&&(f[0]=1));break}if(f[p]+=s,f[p]!=E)break;f[p--]=0,s=1}for(a=f.length;0===f[--a];)f.pop()}return h&&(e.e>m.maxE?(e.d=null,e.e=NaN):e.e0?a=a.charAt(0)+"."+a.slice(1)+P(n):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(e.e<0?"e":"e+")+e.e):i<0?(a="0."+P(-i-1)+a,r&&(n=r-o)>0&&(a+=P(n))):i>=o?(a+=P(i+1-o),r&&(n=r-i-1)>0&&(a=a+"."+P(n))):((n=i+1)0&&(i+1===o&&(a+="."),a+=P(n))),a}function k(e,t){var r=e[0];for(t*=7;r>=10;r/=10)t++;return t}function R(e,t,r){if(t>A)throw h=!0,r&&(e.precision=r),Error(g);return D(new e(f),t,1,!0)}function F(e,t,r){if(t>O)throw Error(g);return D(new e(p),t,r,!0)}function U(e){var t=e.length-1,r=7*t+1;if(t=e[t]){for(;t%10==0;t/=10)r--;for(t=e[0];t>=10;t/=10)r++}return r}function P(e){for(var t="";e--;)t+="0";return t}function j(e,t,r,n){var i,a=new e(1),o=Math.ceil(n/7+4);for(h=!1;;){if(r%2&&K((a=a.times(t)).d,o)&&(i=!0),0===(r=x(r/2))){r=a.d.length-1,i&&0===a.d[r]&&++a.d[r];break}K((t=t.times(t)).d,o)}return h=!0,a}function L(e){return 1&e.d[e.d.length-1]}function H(e,t,r){for(var n,i=new e(t[0]),a=0;++a17)return new p(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(h=!1,u=d):u=t,s=new p(.03125);e.e>-2;)e=e.times(s),f+=5;for(u+=n=Math.log(b(2,f))/Math.LN10*2+5|0,r=a=o=new p(1),p.precision=u;;){if(a=D(a.times(e),u,1),r=r.times(++l),_((s=o.plus(z(a,r,u,1))).d).slice(0,u)===_(o.d).slice(0,u)){for(i=f;i--;)o=D(o.times(o),u,1);if(null!=t)return p.precision=d,o;if(!(c<3&&B(o.d,u-n,m,c)))return D(o,p.precision=d,m,h=!0);p.precision=u+=10,r=a=s=new p(1),l=0,c++}o=s}}function G(e,t){var r,n,i,a,o,s,u,c,l,f,p,m=1,d=e,y=d.d,g=d.constructor,v=g.rounding,x=g.precision;if(d.s<0||!y||!y[0]||!d.e&&1==y[0]&&1==y.length)return new g(y&&!y[0]?-1/0:1!=d.s?NaN:y?0:d);if(null==t?(h=!1,l=x):l=t,g.precision=l+=10,n=(r=_(y)).charAt(0),!(Math.abs(a=d.e)<15e14))return c=R(g,l+2,x).times(a+""),d=G(new g(n+"."+r.slice(1)),l-10).plus(c),g.precision=x,null==t?D(d,x,v,h=!0):d;for(;n<7&&1!=n||1==n&&r.charAt(1)>3;)n=(r=_((d=d.times(e)).d)).charAt(0),m++;for(a=d.e,n>1?(d=new g("0."+r),a++):d=new g(n+"."+r.slice(1)),f=d,u=o=d=z(d.minus(1),d.plus(1),l,1),p=D(d.times(d),l,1),i=3;;){if(o=D(o.times(p),l,1),_((c=u.plus(z(o,new g(i),l,1))).d).slice(0,l)===_(u.d).slice(0,l)){if(u=u.times(2),0!==a&&(u=u.plus(R(g,l+2,x).times(a+""))),u=z(u,new g(m),l,1),null!=t)return g.precision=x,u;if(!B(u.d,l-10,v,s))return D(u,g.precision=x,v,h=!0);g.precision=l+=10,c=o=d=z(f.minus(1),f.plus(1),l,1),p=D(d.times(d),l,1),i=s=1}u=c,i+=2}}function V(e){return String(e.s*e.s/0)}function Z(e,t){var r,n,i;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;48===t.charCodeAt(n);n++);for(i=t.length;48===t.charCodeAt(i-1);--i);if(t=t.slice(n,i)){if(i-=n,e.e=r=r-n-1,e.d=[],n=(r+1)%7,r<0&&(n+=7),ne.constructor.maxE?(e.d=null,e.e=NaN):e.e0?(c=+t.slice(o+1),t=t.substring(2,o)):t=t.slice(2),s=(o=t.indexOf("."))>=0,n=e.constructor,s&&(o=(u=(t=t.replace(".","")).length)-o,i=j(n,new n(r),o,2*o)),o=f=(l=q(t,r,E)).length-1;0===l[o];--o)l.pop();return o<0?new n(0*e.s):(e.e=k(l,f),e.d=l,h=!1,s&&(e=z(e,i,4*u)),c&&(e=e.times(Math.abs(c)<54?b(2,c):a.pow(2,c))),h=!0,e)}function J(e,t,r,n,i){var a,o,s,u,c=e.precision,l=Math.ceil(c/7);for(h=!1,u=r.times(r),s=new e(n);;){if(o=z(s.times(u),new e(t++*t++),c,1),s=i?n.plus(o):n.minus(o),n=z(o.times(u),new e(t++*t++),c,1),void 0!==(o=s.plus(n)).d[l]){for(a=l;o.d[a]===s.d[a]&&a--;);if(-1==a)break}a=s,s=n,n=o,o=a}return h=!0,o.d.length=l+1,o}function Y(e,t){for(var r=e;--t;)r*=e;return r}function X(e,t){var r,n=t.s<0,i=F(e,e.precision,1),a=i.times(.5);if((t=t.abs()).lte(a))return s=n?4:1,t;if((r=t.divToInt(i)).isZero())s=n?3:2;else{if((t=t.minus(r.times(i))).lte(a))return s=L(r)?n?2:3:n?4:1,t;s=L(r)?n?1:4:n?3:2}return t.minus(i).abs()}function Q(e,t,r,n){var i,a,s,u,f,p,m,h,d,y=e.constructor,g=void 0!==r;if(g?(T(r,1,c),void 0===n?n=y.rounding:T(n,0,8)):(r=y.precision,n=y.rounding),e.isFinite()){for(g?(i=2,16==t?r=4*r-3:8==t&&(r=3*r-2)):i=t,(s=(m=I(e)).indexOf("."))>=0&&(m=m.replace(".",""),(d=new y(1)).e=m.length-s,d.d=q(I(d),10,i),d.e=d.d.length),a=f=(h=q(m,10,i)).length;0==h[--f];)h.pop();if(h[0]){if(s<0?a--:((e=new y(e)).d=h,e.e=a,h=(e=z(e,d,r,n,0,i)).d,a=e.e,p=o),s=h[r],u=i/2,p=p||void 0!==h[r+1],p=n<4?(void 0!==s||p)&&(0===n||n===(e.s<0?3:2)):s>u||s===u&&(4===n||p||6===n&&1&h[r-1]||n===(e.s<0?8:7)),h.length=r,p)for(;++h[--r]>i-1;)h[r]=0,r||(++a,h.unshift(1));for(f=h.length;!h[f-1];--f);for(s=0,m="";s1)if(16==t||8==t){for(s=16==t?4:3,--f;f%s;f++)m+="0";for(f=(h=q(m,i,t)).length;!h[f-1];--f);for(s=1,m="1.";sf)for(a-=f;a--;)m+="0";else at)return e.length=t,!0}function ee(e){return new this(e).abs()}function te(e){return new this(e).acos()}function re(e){return new this(e).acosh()}function ne(e,t){return new this(e).plus(t)}function ie(e){return new this(e).asin()}function ae(e){return new this(e).asinh()}function oe(e){return new this(e).atan()}function se(e){return new this(e).atanh()}function ue(e,t){e=new this(e),t=new this(t);var r,n=this.precision,i=this.rounding,a=n+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(r=t.s<0?F(this,n,i):new this(0)).s=e.s:!e.d||t.isZero()?(r=F(this,a,1).times(.5)).s=e.s:t.s<0?(this.precision=a,this.rounding=1,r=this.atan(z(e,t,a,1)),t=F(this,a,1),this.precision=n,this.rounding=i,r=e.s<0?r.minus(t):r.plus(t)):r=this.atan(z(e,t,a,1)):(r=F(this,a,1).times(t.s>0?.25:.75)).s=e.s:r=new this(NaN),r}function ce(e){return new this(e).cbrt()}function le(e){return D(e=new this(e),e.e+1,2)}function fe(e){if(!e||"object"!=typeof e)throw Error(d+"Object expected");var t,r,n,i=!0===e.defaults,a=["precision",1,c,"rounding",0,8,"toExpNeg",-u,0,"toExpPos",0,u,"maxE",0,u,"minE",-u,0,"modulo",0,9];for(t=0;t=a[t+1]&&n<=a[t+2]))throw Error(y+r+": "+n);this[r]=n}if(r="crypto",i&&(this[r]=m[r]),void 0!==(n=e[r])){if(!0!==n&&!1!==n&&0!==n&&1!==n)throw Error(y+r+": "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(v);this[r]=!0}else this[r]=!1}return this}function pe(e){return new this(e).cos()}function me(e){return new this(e).cosh()}function he(e,t){return new this(e).div(t)}function de(e){return new this(e).exp()}function ye(e){return D(e=new this(e),e.e+1,3)}function ge(){var e,t,r=new this(0);for(h=!1,e=0;e=429e7?t[a]=crypto.getRandomValues(new Uint32Array(1))[0]:s[a++]=i%1e7;else{if(!crypto.randomBytes)throw Error(v);for(t=crypto.randomBytes(n*=4);a=214e7?crypto.randomBytes(4).copy(t,a):(s.push(i%1e7),a+=4);a=n/4}else for(;a=10;i/=10)n++;n<7&&(r-=7-n)}return o.e=r,o.d=s,o}function _e(e){return D(e=new this(e),e.e+1,this.rounding)}function Te(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function Be(e){return new this(e).sin()}function qe(e){return new this(e).sinh()}function ze(e){return new this(e).sqrt()}function De(e,t){return new this(e).sub(t)}function Ie(e){return new this(e).tan()}function ke(e){return new this(e).tanh()}function Re(e){return D(e=new this(e),e.e+1,1)}(a=function e(t){var r,n,i;function a(e){var t,r,n,i=this;if(!(i instanceof a))return new a(e);if(i.constructor=a,e instanceof a)return i.s=e.s,void(h?!e.d||e.e>a.maxE?(i.e=NaN,i.d=null):e.e=10;r/=10)t++;return void(h?t>a.maxE?(i.e=NaN,i.d=null):t{"use strict";var t=Object.assign||function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{},o=a.preserveFormatting,s=void 0!==o&&o,u=a.escapeMapFn,c=void 0===u?i:u,l=String(e),f="",p=c(t({},r),s?t({},n):{}),m=Object.keys(p),h=function(){var e=!1;m.forEach((function(t,r){e||l.length>=t.length&&l.slice(0,t.length)===t&&(f+=p[m[r]],l=l.slice(t.length,l.length),e=!0)})),e||(f+=l.slice(0,1),l=l.slice(1,l.length))};l;)h();return f}},628:function(e,t){var r;!function(n){"use strict";var i={s:1,n:0,d:1};function a(e){function t(){var t=Error.apply(this,arguments);t.name=this.name=e,this.stack=t.stack,this.message=t.message}function r(){}return r.prototype=Error.prototype,t.prototype=new r,t}var o=m.DivisionByZero=a("DivisionByZero"),s=m.InvalidParameter=a("InvalidParameter");function u(e,t){return isNaN(e=parseInt(e,10))&&c(),e*t}function c(){throw new s}function l(e){for(var t={},r=e,n=2,i=4;i<=r;){for(;r%n==0;)r/=n,t[n]=(t[n]||0)+1;i+=1+2*n++}return r!==e?r>1&&(t[r]=(t[r]||0)+1):t[e]=(t[e]||0)+1,t}var f=function(e,t){var r,n=0,a=1,s=1,l=0,f=0,p=0,m=1,h=1,d=0,y=1,g=1,v=1,x=1e7;if(null==e);else if(void 0!==t)s=(n=e)*(a=t);else switch(typeof e){case"object":"d"in e&&"n"in e?(n=e.n,a=e.d,"s"in e&&(n*=e.s)):0 in e?(n=e[0],1 in e&&(a=e[1])):c(),s=n*a;break;case"number":if(e<0&&(s=e,e=-e),e%1==0)n=e;else if(e>0){for(e>=1&&(e/=h=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)));y<=x&&v<=x;){if(e===(r=(d+g)/(y+v))){y+v<=x?(n=d+g,a=y+v):v>y?(n=g,a=v):(n=d,a=y);break}e>r?(d+=g,y+=v):(g+=d,v+=y),y>x?(n=g,a=v):(n=d,a=y)}n*=h}else(isNaN(e)||isNaN(t))&&(a=n=NaN);break;case"string":if(null===(y=e.match(/\d+|./g))&&c(),"-"===y[d]?(s=-1,d++):"+"===y[d]&&d++,y.length===d+1?f=u(y[d++],s):"."===y[d+1]||"."===y[d]?("."!==y[d]&&(l=u(y[d++],s)),(1+ ++d===y.length||"("===y[d+1]&&")"===y[d+3]||"'"===y[d+1]&&"'"===y[d+3])&&(f=u(y[d],s),m=Math.pow(10,y[d].length),d++),("("===y[d]&&")"===y[d+2]||"'"===y[d]&&"'"===y[d+2])&&(p=u(y[d+1],s),h=Math.pow(10,y[d+1].length)-1,d+=3)):"/"===y[d+1]||":"===y[d+1]?(f=u(y[d],s),m=u(y[d+2],1),d+=3):"/"===y[d+3]&&" "===y[d+1]&&(l=u(y[d],s),f=u(y[d+2],s),m=u(y[d+4],1),d+=5),y.length<=d){s=n=p+(a=m*h)*l+h*f;break}default:c()}if(0===a)throw new o;i.s=s<0?-1:1,i.n=Math.abs(n),i.d=Math.abs(a)};function p(e,t){if(!e)return t;if(!t)return e;for(;;){if(!(e%=t))return t;if(!(t%=e))return e}}function m(e,t){if(!(this instanceof m))return new m(e,t);f(e,t),e=m.REDUCE?p(i.d,i.n):1,this.s=i.s,this.n=i.n/e,this.d=i.d/e}m.REDUCE=1,m.prototype={s:1,n:0,d:1,abs:function(){return new m(this.n,this.d)},neg:function(){return new m(-this.s*this.n,this.d)},add:function(e,t){return f(e,t),new m(this.s*this.n*i.d+i.s*this.d*i.n,this.d*i.d)},sub:function(e,t){return f(e,t),new m(this.s*this.n*i.d-i.s*this.d*i.n,this.d*i.d)},mul:function(e,t){return f(e,t),new m(this.s*i.s*this.n*i.n,this.d*i.d)},div:function(e,t){return f(e,t),new m(this.s*i.s*this.n*i.d,this.d*i.n)},clone:function(){return new m(this)},mod:function(e,t){return isNaN(this.n)||isNaN(this.d)?new m(NaN):void 0===e?new m(this.s*this.n%this.d,1):(f(e,t),0===i.n&&0===this.d&&m(0,0),new m(this.s*(i.d*this.n)%(i.n*this.d),i.d*this.d))},gcd:function(e,t){return f(e,t),new m(p(i.n,this.n)*p(i.d,this.d),i.d*this.d)},lcm:function(e,t){return f(e,t),0===i.n&&0===this.n?new m:new m(i.n*this.n,p(i.n,this.n)*p(i.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.round(e*this.s*this.n/this.d),e)},inverse:function(){return new m(this.s*this.d,this.n)},pow:function(e,t){if(f(e,t),1===i.d)return i.s<0?new m(Math.pow(this.s*this.d,i.n),Math.pow(this.n,i.n)):new m(Math.pow(this.s*this.n,i.n),Math.pow(this.d,i.n));if(this.s<0)return null;var r=l(this.n),n=l(this.d),a=1,o=1;for(var s in r)if("1"!==s){if("0"===s){a=0;break}if(r[s]*=i.n,r[s]%i.d!=0)return null;r[s]/=i.d,a*=Math.pow(s,r[s])}for(var s in n)if("1"!==s){if(n[s]*=i.n,n[s]%i.d!=0)return null;n[s]/=i.d,o*=Math.pow(s,n[s])}return i.s<0?new m(o,a):new m(a,o)},equals:function(e,t){return f(e,t),this.s*this.n*i.d==i.s*i.n*this.d},compare:function(e,t){f(e,t);var r=this.s*this.n*i.d-i.s*i.n*this.d;return(00&&(r+=t,r+=" ",n%=i),r+=n,r+="/",r+=i),r},toLatex:function(e){var t,r="",n=this.n,i=this.d;return this.s<0&&(r+="-"),1===i?r+=n:(e&&(t=Math.floor(n/i))>0&&(r+=t,n%=i),r+="\\frac{",r+=n,r+="}{",r+=i,r+="}"),r},toContinued:function(){var e,t=this.n,r=this.d,n=[];if(isNaN(t)||isNaN(r))return n;do{n.push(Math.floor(t/r)),e=t%r,t=r,r=e}while(1!==t);return n},toString:function(e){var t,r=this.n,n=this.d;if(isNaN(r)||isNaN(n))return"NaN";m.REDUCE||(r/=t=p(r,n),n/=t),e=e||15;var i=function(e,t){for(;t%2==0;t/=2);for(;t%5==0;t/=5);if(1===t)return 0;for(var r=10%t,n=1;1!==r;n++)if(r=10*r%t,n>2e3)return 0;return n}(0,n),a=function(e,t,r){for(var n=1,i=function(e,t,r){for(var n=1;t>0;e=e*e%r,t>>=1)1&t&&(n=n*e%r);return n}(10,r,t),a=0;a<300;a++){if(n===i)return a;n=10*n%t,i=10*i%t}return 0}(0,n,i),o=-1===this.s?"-":"";if(o+=r/n|0,r%=n,(r*=10)&&(o+="."),i){for(var s=a;s--;)o+=r/n|0,r%=n,r*=10;for(o+="(",s=i;s--;)o+=r/n|0,r%=n,r*=10;o+=")"}else for(s=e;r&&s--;)o+=r/n|0,r%=n,r*=10;return o}},void 0===(r=function(){return m}.apply(t,[]))||(e.exports=r)}()},228:e=>{e.exports=function e(t,r){"use strict";var n,i,a=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,o=/(^[ ]*|[ ]*$)/g,s=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,u=/^0x[0-9a-f]+$/i,c=/^0/,l=function(t){return e.insensitive&&(""+t).toLowerCase()||""+t},f=l(t).replace(o,"")||"",p=l(r).replace(o,"")||"",m=f.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),h=p.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),d=parseInt(f.match(u),16)||1!==m.length&&f.match(s)&&Date.parse(f),y=parseInt(p.match(u),16)||d&&p.match(s)&&Date.parse(p)||null;if(y){if(dy)return 1}for(var g=0,v=Math.max(m.length,h.length);gi)return 1}return 0}},377:(e,t,r)=>{var n=r(832),i=r(652),a=r(801),o=r(30),s=r(618),u=r(49),c=r(971);c.alea=n,c.xor128=i,c.xorwow=a,c.xorshift7=o,c.xor4096=s,c.tychei=u,e.exports=c},832:function(e,t,r){var n;!function(e,i,a){function o(e){var t,r=this,n=(t=4022871197,function(e){e=String(e);for(var r=0;r>>0,t=(n*=t)>>>0,t+=4294967296*(n-=t)}return 2.3283064365386963e-10*(t>>>0)});r.next=function(){var e=2091639*r.s0+2.3283064365386963e-10*r.c;return r.s0=r.s1,r.s1=r.s2,r.s2=e-(r.c=0|e)},r.c=1,r.s0=n(" "),r.s1=n(" "),r.s2=n(" "),r.s0-=n(e),r.s0<0&&(r.s0+=1),r.s1-=n(e),r.s1<0&&(r.s1+=1),r.s2-=n(e),r.s2<0&&(r.s2+=1),n=null}function s(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function u(e,t){var r=new o(e),n=t&&t.state,i=r.next;return i.int32=function(){return 4294967296*r.next()|0},i.double=function(){return i()+11102230246251565e-32*(2097152*i()|0)},i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.alea=u}(0,e=r.nmd(e),r.amdD)},49:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.next=function(){var e=t.b,r=t.c,n=t.d,i=t.a;return e=e<<25^e>>>7^r,r=r-n|0,n=n<<24^n>>>8^i,i=i-e|0,t.b=e=e<<20^e>>>12^r,t.c=r=r-n|0,t.d=n<<16^r>>>16^i,t.a=i-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):r+=e;for(var n=0;n>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.tychei=u}(0,e=r.nmd(e),r.amdD)},652:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:r+=e;for(var n=0;n>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xor128=u}(0,e=r.nmd(e),r.amdD)},618:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this;t.next=function(){var e,r,n=t.w,i=t.X,a=t.i;return t.w=n=n+1640531527|0,r=i[a+34&127],e=i[a=a+1&127],r^=r<<13,e^=e<<17,r^=r>>>15,e^=e>>>12,r=i[a]=r^e,t.i=a,r+(n^n>>>16)|0},function(e,t){var r,n,i,a,o,s=[],u=128;for(t===(0|t)?(n=t,t=null):(t+="\0",n=0,u=Math.max(u,t.length)),i=0,a=-32;a>>15,n^=n<<4,n^=n>>>13,a>=0&&(o=o+1640531527|0,i=0==(r=s[127&a]^=n+o)?i+1:0);for(i>=128&&(s[127&(t&&t.length||0)]=-1),i=127,a=512;a>0;--a)n=s[i+34&127],r=s[i=i+1&127],n^=n<<13,r^=r<<17,n^=n>>>15,r^=r>>>12,s[i]=n^r;e.w=o,e.X=s,e.i=i}(t,e)}function s(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function u(e,t){null==e&&(e=+new Date);var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&(n.X&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xor4096=u}(0,e=r.nmd(e),r.amdD)},30:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this;t.next=function(){var e,r,n=t.x,i=t.i;return e=n[i],r=(e^=e>>>7)^e<<24,r^=(e=n[i+1&7])^e>>>10,r^=(e=n[i+3&7])^e>>>3,r^=(e=n[i+4&7])^e<<7,e=n[i+7&7],r^=(e^=e<<13)^e<<9,n[i]=r,t.i=i+1&7,r},function(e,t){var r,n=[];if(t===(0|t))n[0]=t;else for(t=""+t,r=0;r0;--r)e.next()}(t,e)}function s(e,t){return t.x=e.x.slice(),t.i=e.i,t}function u(e,t){null==e&&(e=+new Date);var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&(n.x&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xorshift7=u}(0,e=r.nmd(e),r.amdD)},801:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:r+=e;for(var n=0;n>>4),t.next()}function s(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function u(e,t){var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xorwow=u}(0,e=r.nmd(e),r.amdD)},971:function(e,t,r){var n;!function(i,a,o){var s,u=256,c=o.pow(u,6),l=o.pow(2,52),f=2*l,p=255;function m(e,t,r){var n=[],p=g(y((t=1==t?{entropy:!0}:t||{}).entropy?[e,v(a)]:null==e?function(){try{var e;return s&&(e=s.randomBytes)?e=e(u):(e=new Uint8Array(u),(i.crypto||i.msCrypto).getRandomValues(e)),v(e)}catch(e){var t=i.navigator,r=t&&t.plugins;return[+new Date,i,r,i.screen,v(a)]}}():e,3),n),m=new h(n),x=function(){for(var e=m.g(6),t=c,r=0;e=f;)e/=2,t/=2,r>>>=1;return(e+r)/t};return x.int32=function(){return 0|m.g(4)},x.quick=function(){return m.g(4)/4294967296},x.double=x,g(v(m.S),a),(t.pass||r||function(e,t,r,n){return n&&(n.S&&d(n,m),e.state=function(){return d(m,{})}),r?(o.random=e,t):e})(x,p,"global"in t?t.global:this==o,t.state)}function h(e){var t,r=e.length,n=this,i=0,a=n.i=n.j=0,o=n.S=[];for(r||(e=[r++]);i3?e.slice(3):"any":e).split("|").map(q).filter(z).filter(B),i=function(e,t){var r={};return e.forEach((function(e){-1!==t.indexOf(e.from)||-1===t.indexOf(e.to)||r[e.from]||(r[e.from]=e)})),Object.keys(r).map((function(e){return r[e]}))}(t,n),a=n.map((function(e){var t=c(e);return{name:e,typeIndex:l(t),test:t.test,conversion:null,conversionIndex:-1}})),o=i.map((function(e){var r=c(e.from);return{name:e.from,typeIndex:l(r),test:r.test,conversion:e,conversionIndex:t.indexOf(e)}}));return{types:a.concat(o),restParam:r}}function h(e){var t=k(e);return!!t&&t.restParam}function d(e){return e.types.some((function(e){return null!=e.conversion}))}function y(t){if(t&&0!==t.types.length){if(1===t.types.length)return c(t.types[0].name).test;if(2===t.types.length){var r=c(t.types[0].name).test,n=c(t.types[1].name).test;return function(e){return r(e)||n(e)}}var i=t.types.map((function(e){return c(e.name).test}));return function(e){for(var t=0;t=a+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(r=y(e[0]),function(e){return r(e[0])&&1===e.length}):2===e.length?(r=y(e[0]),n=y(e[1]),function(e){return r(e[0])&&n(e[1])&&2===e.length}):(t=e.map(y),function(e){for(var r=0;r0){var c=f(t[a]);return(n=new TypeError("Unexpected type of argument in function "+o+" (expected: "+i.join(" or ")+", actual: "+c+", index: "+a+")")).data={category:"wrongType",fn:o,index:a,actual:c,expected:i},n}}else s=u}var l=s.map((function(e){return h(e.params)?1/0:e.params.length}));if(t.lengthp?((n=new TypeError("Too many arguments in function "+o+" (expected: "+p+", actual: "+t.length+")")).data={category:"tooManyArgs",fn:o,index:t.length,expectedLength:p},n):((n=new TypeError('Arguments of type "'+t.join(", ")+'" do not match any of the defined signatures of function '+o+".")).data={category:"mismatch",actual:t.map(f)},n)}function S(e){for(var t=999,r=0;r=i:s?i>=a:i===a}(t,e)}));if(t)throw new TypeError('Conflicting signatures "'+p(t.params)+'" and "'+p(e.params)+'".');i.push(e)}));var a=P(i,(function(e){return(e?_(e.params,!1):[]).map((function(t){return{params:t,fn:e.fn}}))})).filter(D);a.sort(O);var o=a[0]&&a[0].params.length<=2&&!h(a[0].params),s=a[1]&&a[1].params.length<=2&&!h(a[1].params),c=a[2]&&a[2].params.length<=2&&!h(a[2].params),l=a[3]&&a[3].params.length<=2&&!h(a[3].params),f=a[4]&&a[4].params.length<=2&&!h(a[4].params),v=a[5]&&a[5].params.length<=2&&!h(a[5].params),b=o&&s&&c&&l&&f&&v,w=a.map((function(e){return g(e.params)})),N=o?y(a[0].params[0]):t,S=s?y(a[1].params[0]):t,E=c?y(a[2].params[0]):t,A=l?y(a[3].params[0]):t,T=f?y(a[4].params[0]):t,B=v?y(a[5].params[0]):t,z=o?y(a[0].params[1]):t,k=s?y(a[1].params[1]):t,j=c?y(a[2].params[1]):t,L=l?y(a[3].params[1]):t,H=f?y(a[4].params[1]):t,$=v?y(a[5].params[1]):t,G=a.map((function(e){return function(e,t){var r=t;if(e.some(d)){var n=h(e),i=e.map(C);r=function(){for(var e=[],r=n?arguments.length-1:arguments.length,a=0;a{}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var a=t[n]={id:n,loaded:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.loaded=!0,a.exports}r.amdD=function(){throw new Error("define cannot be used indirect")},r.amdO={},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";function e(){return(e=Object.assign||function(e){for(var t=1;t!function(e){return e&&"?"===e[0]}(e))).every((e=>void 0!==r[e]))){var n=t.filter((e=>void 0===r[e]));throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(n.map((e=>'"'.concat(e,'"'))).join(", "),"."))}}(e,t,n),r(i)}return i.isFactory=!0,i.fn=e,i.dependencies=t.slice().sort(),n&&(i.meta=n),i}function J(e){return e&&"?"===e[0]?e.slice(1):e}function Y(e,t){if(ee(e)&&Q(e,t))return e[t];if("function"==typeof e[t]&&K(e,t))throw new Error('Cannot access method "'+t+'" as a property');throw new Error('No access to property "'+t+'"')}function X(e,t,r){if(ee(e)&&Q(e,t))return e[t]=r,r;throw new Error('No access to property "'+t+'"')}function Q(e,t){return!(!e||"object"!=typeof e||!Z(te,t)&&(t in Object.prototype||t in Function.prototype))}function K(e,t){return!(null==e||"function"!=typeof e[t]||Z(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e)||!Z(re,t)&&(t in Object.prototype||t in Function.prototype))}function ee(e){return"object"==typeof e&&e&&e.constructor===Object}var te={length:!0,name:!0},re={toString:!0,valueOf:!0,toLocaleString:!0};class ne{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return Y(this.wrappedObject,e)}set(e,t){return X(this.wrappedObject,e,t),this}has(e){return e in this.wrappedObject}}function ie(){return new Map}function ae(e){if(!e)return ie();if(oe(e))return e;if(M(e))return new ne(e);throw new Error("createMap can create maps from objects or Maps")}function oe(e){return!!e&&(e instanceof Map||e instanceof ne||"function"==typeof e.set&&"function"==typeof e.get&&"function"==typeof e.keys&&"function"==typeof e.has)}function se(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{var{mathWithTransform:t}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator")}return r.prototype.evaluate=function(e){return this.compile().evaluate(e)},r.prototype.type="Node",r.prototype.isNode=!0,r.prototype.comment="",r.prototype.compile=function(){var e=this._compile(t,{}),r={};return{evaluate:function(t){var n=ae(t);return function(e){for(var t of[...H])if(e.has(t))throw new Error('Scope contains an illegal symbol, "'+t+'" is a reserved keyword')}(n),e(n,r,null)}}},r.prototype._compile=function(e,t){throw new Error("Method _compile should be implemented by type "+this.type)},r.prototype.forEach=function(e){throw new Error("Cannot run forEach on a Node interface")},r.prototype.map=function(e){throw new Error("Cannot run map on a Node interface")},r.prototype._ifNode=function(e){if(!I(e))throw new TypeError("Callback function must return a Node");return e},r.prototype.traverse=function(e){e(this,null,null),function e(t,r){t.forEach((function(t,n,i){r(t,n,i),e(t,r)}))}(this,e)},r.prototype.transform=function(e){return function t(r,n,i){var a=e(r,n,i);return a!==r?a:r.map(t)}(this,null,null)},r.prototype.filter=function(e){var t=[];return this.traverse((function(r,n,i){e(r,n,i)&&t.push(r)})),t},r.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},r.prototype.cloneDeep=function(){return this.map((function(e){return e.cloneDeep()}))},r.prototype.equals=function(e){return!!e&&V(this,e)},r.prototype.toString=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toString(e)},r.prototype.toJSON=function(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)},r.prototype.toHTML=function(e){var t=this._getCustomString(e);return void 0!==t?t:this.toHTML(e)},r.prototype._toString=function(){throw new Error("_toString not implemented for "+this.type)},r.prototype.toTex=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toTex(e)},r.prototype._toTex=function(e){throw new Error("_toTex not implemented for "+this.type)},r.prototype._getCustomString=function(e){if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":return;case"function":return e.handler(this,e);default:throw new TypeError("Object or function expected as callback")}},r.prototype.getIdentifier=function(){return this.type},r.prototype.getContent=function(){return this},r}),{isClass:!0,isNode:!0});function ce(e){return"boolean"==typeof e||!!isFinite(e)&&e===Math.round(e)}var le=Math.sign||function(e){return e>0?1:e<0?-1:0},fe=Math.log2||function(e){return Math.log(e)/Math.LN2},pe=Math.log10||function(e){return Math.log(e)/Math.LN10},me=Math.log1p||function(e){return Math.log(e+1)},he=Math.cbrt||function(e){if(0===e)return e;var t,r=e<0;return r&&(e=-e),t=isFinite(e)?(e/((t=Math.exp(Math.log(e)/3))*t)+2*t)/3:e,r?-t:t},de=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function ye(e,t,r){var n={2:"0b",8:"0o",16:"0x"}[t],i="";if(r){if(r<1)throw new Error("size must be in greater than 0");if(!ce(r))throw new Error("size must be an integer");if(e>2**(r-1)-1||e<-(2**(r-1)))throw new Error("Value must be in range [-2^".concat(r-1,", 2^").concat(r-1,"-1]"));if(!ce(e))throw new Error("Value must be an integer");e<0&&(e+=2**r),i="i".concat(r)}var a="";return e<0&&(e=-e,a="-"),"".concat(a).concat(n).concat(e.toString(t)).concat(i)}function ge(e,t){if("function"==typeof t)return t(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var r,n,a="auto";if(t&&(t.notation&&(a=t.notation),i(t)?r=t:i(t.precision)&&(r=t.precision),t.wordSize&&"number"!=typeof(n=t.wordSize)))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return xe(e,r);case"exponential":return be(e,r);case"engineering":return function(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=we(ve(e),t),n=r.exponent,a=r.coefficients,o=n%3==0?n:n<0?n-3-n%3:n-n%3;if(i(t))for(;t>a.length||n-o+1>a.length;)a.push(0);else for(var s=Math.abs(n-o)-(a.length-1),u=0;u0;)l++,c--;var f=a.slice(l).join(""),p=i(t)&&f.length||f.match(/[1-9]/)?"."+f:"",m=a.slice(0,l).join("")+p+"e"+(n>=0?"+":"")+o.toString();return r.sign+m}(e,r);case"bin":return ye(e,2,n);case"oct":return ye(e,8,n);case"hex":return ye(e,16,n);case"auto":return function(e,t,r){if(isNaN(e)||!isFinite(e))return String(e);var n=r&&void 0!==r.lowerExp?r.lowerExp:-3,i=r&&void 0!==r.upperExp?r.upperExp:5,a=ve(e),o=t?we(a,t):a;if(o.exponent=i)return be(e,t);var s=o.coefficients,u=o.exponent;s.length0?u:0;return c<(s=Ne(-u).concat(s)).length-1&&s.splice(c+1,0,"."),o.sign+s.join("")}(e,r,t&&t).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t}));default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function ve(e){var t=String(e).toLowerCase().match(/^0*?(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+e);var r=t[1],n=t[2],i=parseFloat(t[4]||"0"),a=n.indexOf(".");i+=-1!==a?a-1:n.length-1;var o=n.replace(".","").replace(/^0*/,(function(e){return i-=e.length,""})).replace(/0*$/,"").split("").map((function(e){return parseInt(e)}));return 0===o.length&&(o.push(0),i++),{sign:r,coefficients:o,exponent:i}}function xe(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=ve(e),n="number"==typeof t?we(r,r.exponent+1+t):r,i=n.coefficients,a=n.exponent+1,o=a+(t||0);return i.length0?"."+i.join(""):"")+"e"+(a>=0?"+":"")+a}function we(e,t){for(var r={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},n=r.coefficients;t<=0;)n.unshift(0),r.exponent++,t++;if(n.length>t&&n.splice(t,n.length-t)[0]>=5){var i=t-1;for(n[i]++;10===n[i];)n.pop(),0===i&&(n.unshift(0),r.exponent++,i++),n[--i]++}return r}function Ne(e){for(var t=[],r=0;r=0?"+":"")+n.toString()}(e,r);case"bin":return Be(e,2,n);case"oct":return Be(e,8,n);case"hex":return Be(e,16,n);case"auto":var a=t&&void 0!==t.lowerExp?t.lowerExp:-3,o=t&&void 0!==t.upperExp?t.upperExp:5;if(e.isZero())return"0";var s=e.toSignificantDigits(r),u=s.e;return(u>=a&&u'"'+r+'": '+De(e[r],t))).join(", ")+"}":String(e)}function Ie(e){for(var t=String(e),r="",n=0;n/g,">")}function Re(e,t){if(Array.isArray(e)){for(var r="[",n=e.length,i=0;it?1:-1}function Ue(e,t,r){if(!(this instanceof Ue))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=t,this.relation=r,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=(new Error).stack}function Pe(e,t,r){if(!(this instanceof Pe))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=r),void 0!==this.min&&this.index=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}function je(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function Le(e,t,r){var n,i=e.length;if(i!==t[r])throw new Ue(i,t[r]);if(r")}function He(e,t){if(0===t.length){if(Array.isArray(e))throw new Ue(e.length,0)}else Le(e,t,0)}function $e(e,t){if(!i(e)||!ce(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&e>=t)throw new Pe(e,t)}function Ge(e,t,r){if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");return t.forEach((function(e){if(!i(e)||!ce(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+De(t)+")")})),Ve(e,t,0,void 0!==r?r:0),e}function Ve(e,t,r,n){var i,a,o=e.length,s=t[r],u=Math.min(o,s);if(e.length=s,r=0){if(t%r!=0)throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-r);n[i]=-t/r}return n}function Je(e){return e.reduce(((e,t)=>e*t),1)}function Ye(e,t){for(var r=t||je(e);Array.isArray(e)&&1===e.length;)e=e[0],r.shift();for(var n=r.length;1===r[n-1];)n--;return nt.test(e)))}function at(e,t){return Array.prototype.join.call(e,t)}function ot(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;var t=[],r=0;t[0]={value:e[0],identifier:0};for(var n=1;n{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=e||[],!Array.isArray(this.items)||!this.items.every(I))throw new TypeError("Array containing Nodes expected")}return r.prototype=new t,r.prototype.type="ArrayNode",r.prototype.isArrayNode=!0,r.prototype._compile=function(e,t){var r=tt(this.items,(function(r){return r._compile(e,t)}));if("Array"!==e.config.matrix){var n=e.matrix;return function(e,t,i){return n(tt(r,(function(r){return r(e,t,i)})))}}return function(e,t,n){return tt(r,(function(r){return r(e,t,n)}))}},r.prototype.forEach=function(e){for(var t=0;t['+this.items.map((function(t){return t.toHTML(e)})).join(',')+']'},r.prototype._toTex=function(e){var t="\\begin{bmatrix}";return this.items.forEach((function(r){r.items?t+=r.items.map((function(t){return t.toTex(e)})).join("&"):t+=r.toTex(e),t+="\\\\"})),t+="\\end{bmatrix}"},r}),{isClass:!0,isNode:!0}),lt=W("BlockNode",["ResultSet","Node"],(e=>{var{ResultSet:t,Node:r}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map((function(e){var t=e&&e.node,r=!e||void 0===e.visible||e.visible;if(!I(t))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof r)throw new TypeError('Property "visible" must be a boolean');return{node:t,visible:r}}))}return n.prototype=new r,n.prototype.type="BlockNode",n.prototype.isBlockNode=!0,n.prototype._compile=function(e,r){var n=tt(this.blocks,(function(t){return{evaluate:t.node._compile(e,r),visible:t.visible}}));return function(e,r,i){var a=[];return rt(n,(function(t){var n=t.evaluate(e,r,i);t.visible&&a.push(n)})),new t(a)}},n.prototype.forEach=function(e){for(var t=0;t;')})).join('
')},n.prototype._toTex=function(e){return this.blocks.map((function(t){return t.node.toTex(e)+(t.visible?"":";")})).join("\\;\\;\n")},n}),{isClass:!0,isNode:!0}),ft=r(928),pt={Alpha:"A",alpha:"\\alpha",Beta:"B",beta:"\\beta",Gamma:"\\Gamma",gamma:"\\gamma",Delta:"\\Delta",delta:"\\delta",Epsilon:"E",epsilon:"\\epsilon",varepsilon:"\\varepsilon",Zeta:"Z",zeta:"\\zeta",Eta:"H",eta:"\\eta",Theta:"\\Theta",theta:"\\theta",vartheta:"\\vartheta",Iota:"I",iota:"\\iota",Kappa:"K",kappa:"\\kappa",varkappa:"\\varkappa",Lambda:"\\Lambda",lambda:"\\lambda",Mu:"M",mu:"\\mu",Nu:"N",nu:"\\nu",Xi:"\\Xi",xi:"\\xi",Omicron:"O",omicron:"o",Pi:"\\Pi",pi:"\\pi",varpi:"\\varpi",Rho:"P",rho:"\\rho",varrho:"\\varrho",Sigma:"\\Sigma",sigma:"\\sigma",varsigma:"\\varsigma",Tau:"T",tau:"\\tau",Upsilon:"\\Upsilon",upsilon:"\\upsilon",Phi:"\\Phi",phi:"\\phi",varphi:"\\varphi",Chi:"X",chi:"\\chi",Psi:"\\Psi",psi:"\\psi",Omega:"\\Omega",omega:"\\omega",true:"\\mathrm{True}",false:"\\mathrm{False}",i:"i",inf:"\\infty",Inf:"\\infty",infinity:"\\infty",Infinity:"\\infty",oo:"\\infty",lim:"\\lim",undefined:"\\mathbf{?}"},mt={transpose:"^\\top",ctranspose:"^H",factorial:"!",pow:"^",dotPow:".^\\wedge",unaryPlus:"+",unaryMinus:"-",bitNot:"\\~",not:"\\neg",multiply:"\\cdot",divide:"\\frac",dotMultiply:".\\cdot",dotDivide:".:",mod:"\\mod",add:"+",subtract:"-",to:"\\rightarrow",leftShift:"<<",rightArithShift:">>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},ht={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(mt.add,"${args[1]}\\right)")},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:"\\left(${args[0]}".concat(mt.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(mt.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(mt.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(mt.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:"\\left(${args[0]}".concat(mt.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(mt.multiply,"${args[1]}\\right)")},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : $y^{args[1]} = {${args[0]}}\\}"},pow:{2:"\\left(${args[0]}\\right)".concat(mt.pow,"{${args[1]}}")},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:"\\left(${args[0]}".concat(mt.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(mt.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(mt.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(mt.bitAnd,"${args[1]}\\right)")},bitNot:{1:mt.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(mt.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(mt.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(mt.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(mt.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(mt.rightLogShift,"${args[1]}\\right)")},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:"\\left(${args[0]}".concat(mt.and,"${args[1]}\\right)")},not:{1:mt.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(mt.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(mt.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(mt.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},sqrtm:{1:"{${args[0]}}".concat(mt.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(mt.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(mt.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(mt.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(mt.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(mt.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(mt.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(mt.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(mt.unequal,"${args[1]}\\right)")},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:"\\left(${args[0]}".concat(mt.to,"${args[1]}\\right)")},numeric:function(e,t){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(pt.i,"\\cdot\\left(${args[1]}\\right)\\right)")},matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},dt={deg:"^\\circ"};function yt(e){return ft(e,{preserveFormatting:!0})}function gt(e,t){return(t=void 0!==t&&t)?Z(dt,e)?dt[e]:"\\mathrm{"+yt(e)+"}":Z(pt,e)?pt[e]:yt(e)}var vt=W("ConstantNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this.value=e}return r.prototype=new t,r.prototype.type="ConstantNode",r.prototype.isConstantNode=!0,r.prototype._compile=function(e,t){var r=this.value;return function(){return r}},r.prototype.forEach=function(e){},r.prototype.map=function(e){return this.clone()},r.prototype.clone=function(){return new r(this.value)},r.prototype._toString=function(e){return De(this.value,e)},r.prototype.toHTML=function(e){var t=this._toString(e);switch(L(this.value)){case"number":case"BigNumber":case"Fraction":return''+t+"";case"string":return''+t+"";case"boolean":return''+t+"";case"null":return''+t+"";case"undefined":return''+t+"";default:return''+t+""}},r.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},r.fromJSON=function(e){return new r(e.value)},r.prototype._toTex=function(e){var t=this._toString(e);switch(L(this.value)){case"string":return"\\mathtt{"+yt(t)+"}";case"number":case"BigNumber":if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var r=t.toLowerCase().indexOf("e");return-1!==r?t.substring(0,r)+"\\cdot10^{"+t.substring(r+1)+"}":t;case"Fraction":return this.value.toLatex();default:return t}},r}),{isClass:!0,isNode:!0}),xt=W("ObjectNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=e||{},e&&("object"!=typeof e||!Object.keys(e).every((function(t){return I(e[t])}))))throw new TypeError("Object containing Nodes expected")}return r.prototype=new t,r.prototype.type="ObjectNode",r.prototype.isObjectNode=!0,r.prototype._compile=function(e,t){var r={};for(var n in this.properties)if(Z(this.properties,n)){var i=Ie(n),a=JSON.parse(i);if(!Q(this.properties,a))throw new Error('No access to property "'+a+'"');r[a]=this.properties[n]._compile(e,t)}return function(e,t,n){var i={};for(var a in r)Z(r,a)&&(i[a]=r[a](e,t,n));return i}},r.prototype.forEach=function(e){for(var t in this.properties)Z(this.properties,t)&&e(this.properties[t],"properties["+Ie(t)+"]",this)},r.prototype.map=function(e){var t={};for(var n in this.properties)Z(this.properties,n)&&(t[n]=this._ifNode(e(this.properties[n],"properties["+Ie(n)+"]",this)));return new r(t)},r.prototype.clone=function(){var e={};for(var t in this.properties)Z(this.properties,t)&&(e[t]=this.properties[t]);return new r(e)},r.prototype._toString=function(e){var t=[];for(var r in this.properties)Z(this.properties,r)&&t.push(Ie(r)+": "+this.properties[r].toString(e));return"{"+t.join(", ")+"}"},r.prototype.toJSON=function(){return{mathjs:"ObjectNode",properties:this.properties}},r.fromJSON=function(e){return new r(e.properties)},r.prototype.toHTML=function(e){var t=[];for(var r in this.properties)Z(this.properties,r)&&t.push(''+ke(r)+':'+this.properties[r].toHTML(e));return'{'+t.join(',')+'}'},r.prototype._toTex=function(e){var t=[];for(var r in this.properties)Z(this.properties,r)&&t.push("\\mathbf{"+r+":} & "+this.properties[r].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(t.join("\n"),"\\end{array}\\right\\}")},r}),{isClass:!0,isNode:!0}),bt=W("ParenthesisNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError('Node expected for parameter "content"');this.content=e}return r.prototype=new t,r.prototype.type="ParenthesisNode",r.prototype.isParenthesisNode=!0,r.prototype._compile=function(e,t){return this.content._compile(e,t)},r.prototype.getContent=function(){return this.content.getContent()},r.prototype.forEach=function(e){e(this.content,"content",this)},r.prototype.map=function(e){return new r(e(this.content,"content",this))},r.prototype.clone=function(){return new r(this.content)},r.prototype._toString=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)},r.prototype.toJSON=function(){return{mathjs:"ParenthesisNode",content:this.content}},r.fromJSON=function(e){return new r(e.content)},r.prototype.toHTML=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?'('+this.content.toHTML(e)+')':this.content.toHTML(e)},r.prototype._toTex=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)},r}),{isClass:!0,isNode:!0}),wt=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{associativity:"left",associativeWith:[]}},{"OperatorNode:and":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{associativity:"left",associativeWith:[]},"OperatorNode:unequal":{associativity:"left",associativeWith:[]},"OperatorNode:smaller":{associativity:"left",associativeWith:[]},"OperatorNode:larger":{associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{associativity:"left",associativeWith:[]}},{"OperatorNode:to":{associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{associativity:"left",associativeWith:[]},"OperatorNode:mod":{associativity:"left",associativeWith:[]}},{"OperatorNode:unaryPlus":{associativity:"right"},"OperatorNode:unaryMinus":{associativity:"right"},"OperatorNode:bitNot":{associativity:"right"},"OperatorNode:not":{associativity:"right"}},{"OperatorNode:pow":{associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{associativity:"left"}},{"OperatorNode:transpose":{associativity:"left"}}];function Nt(e,t){var r=e;"keep"!==t&&(r=e.getContent());for(var n=r.getIdentifier(),i=0;i{var{Node:t}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(t))throw new TypeError("Parameter params must be an array");if(e.length!==t.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=t}return r.prototype=new t,r.prototype.type="RelationalNode",r.prototype.isRelationalNode=!0,r.prototype._compile=function(e,t){var r=this,n=this.params.map((r=>r._compile(e,t)));return function(t,i,a){for(var o,s=n[0](t,i,a),u=0;ue(t,"params["+r+"]",this)),this)},r.prototype.map=function(e){return new r(this.conditionals.slice(),this.params.map(((t,r)=>this._ifNode(e(t,"params["+r+"]",this))),this))},r.prototype.clone=function(){return new r(this.conditionals,this.params)},r.prototype._toString=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.params.map((function(n,i){var a=Nt(n,t);return"all"===t||null!==a&&a<=r?"("+n.toString(e)+")":n.toString(e)})),i={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},a=n[0],o=0;o('+n.toHTML(e)+')':n.toHTML(e)})),i={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},a=n[0],o=0;o'+ke(i[this.conditionals[o]])+""+n[o+1];return a},r.prototype._toTex=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.params.map((function(n,i){var a=Nt(n,t);return"all"===t||null!==a&&a<=r?"\\left("+n.toTex(e)+"\right)":n.toTex(e)})),i=n[0],a=0;a{var{on:t,math:r}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");j(e)?this.value=e.value:this.value=e}function i(e,t){var r,i,o,s,u;r=n.prototype,i=e,o=function(){var e=t();if("function"==typeof e)return a(e)},u=!0,Object.defineProperty(r,i,{get:function(){return u&&(s=o(),u=!1),s},set:function(e){s=e,u=!1},configurable:!0,enumerable:!0})}function a(e){return function(){for(var t=[this.value],r=0;re[t]))};for(var s in e)r(s)}var u,c};var o={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return n.createProxy(r),t&&t("import",(function(e,t,r){r||i(e,t)})),n}),{isClass:!0}),Ot=W("reviver",["classes"],(e=>{var{classes:t}=e;return function(e,r){var n=t[r&&r.mathjs];return n&&"function"==typeof n.fromJSON?n.fromJSON(r):r}})),Ct=W("ConditionalNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError("Parameter condition must be a Node");if(!I(t))throw new TypeError("Parameter trueExpr must be a Node");if(!I(n))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=t,this.falseExpr=n}return r.prototype=new t,r.prototype.type="ConditionalNode",r.prototype.isConditionalNode=!0,r.prototype._compile=function(e,t){var r=this.condition._compile(e,t),n=this.trueExpr._compile(e,t),i=this.falseExpr._compile(e,t);return function(e,t,s){return function(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return!!e;if(e){if(a(e))return!e.isZero();if(o(e))return!(!e.re&&!e.im);if(u(e))return!!e.value}if(null==e)return!1;throw new TypeError('Unsupported type of condition "'+L(e)+'"')}(r(e,t,s))?n(e,t,s):i(e,t,s)}},r.prototype.forEach=function(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)},r.prototype.map=function(e){return new r(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))},r.prototype.clone=function(){return new r(this.condition,this.trueExpr,this.falseExpr)},r.prototype._toString=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.condition.toString(e),i=Nt(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n="("+n+")");var a=this.trueExpr.toString(e),o=Nt(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a="("+a+")");var s=this.falseExpr.toString(e),u=Nt(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s="("+s+")"),n+" ? "+a+" : "+s},r.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},r.fromJSON=function(e){return new r(e.condition,e.trueExpr,e.falseExpr)},r.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.condition.toHTML(e),i=Nt(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n='('+n+')');var a=this.trueExpr.toHTML(e),o=Nt(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a='('+a+')');var s=this.falseExpr.toHTML(e),u=Nt(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s='('+s+')'),n+'?'+a+':'+s},r.prototype._toTex=function(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"},r}),{isClass:!0,isNode:!0}),_t=W("OperatorNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n,i){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('string expected for parameter "op"');if("string"!=typeof t)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(n)||!n.every(I))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=!0===i,this.op=e,this.fn=t,this.args=n||[]}function n(e,t,r,n,i){var a,o=Nt(e,t),s=Mt(e,t);if("all"===t||n.length>2&&"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier())return n.map((function(e){switch(e.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}}));switch(n.length){case 0:a=[];break;case 1:var u=Nt(n[0],t);if(i&&null!==u){var c,l;if("keep"===t?(c=n[0].getIdentifier(),l=e.getIdentifier()):(c=n[0].getContent().getIdentifier(),l=e.getContent().getIdentifier()),!1===wt[o][l].latexLeftParens){a=[!1];break}if(!1===wt[u][c].latexParens){a=[!1];break}}if(null===u){a=[!1];break}if(u<=o){a=[!0];break}a=[!1];break;case 2:var f,p,m=Nt(n[0],t),h=St(e,n[0],t);f=null!==m&&(m===o&&"right"===s&&!h||m=2&&"OperatorNode:multiply"===e.getIdentifier()&&e.implicit&&"auto"===t&&"hide"===r&&(a=n.map((function(e,t){var r="ParenthesisNode"===e.getIdentifier();return!(!a[t]&&!r)}))),a}return r.prototype=new t,r.prototype.type="OperatorNode",r.prototype.isOperatorNode=!0,r.prototype._compile=function(e,t){if("string"!=typeof this.fn||!K(e,this.fn))throw e[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var r=Y(e,this.fn),n=tt(this.args,(function(r){return r._compile(e,t)}));if(1===n.length){var i=n[0];return function(e,t,n){return r(i(e,t,n))}}if(2===n.length){var a=n[0],o=n[1];return function(e,t,n){return r(a(e,t,n),o(e,t,n))}}return function(e,t,i){return r.apply(null,tt(n,(function(r){return r(e,t,i)})))}},r.prototype.forEach=function(e){for(var t=0;t2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var f=i.map((function(t,r){return t=t.toString(e),a[r]&&(t="("+t+")"),t}));return this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?f.join(" "):f.join(" "+this.op+" ")}return this.fn+"("+this.args.join(", ")+")"},r.prototype.toJSON=function(){return{mathjs:"OperatorNode",op:this.op,fn:this.fn,args:this.args,implicit:this.implicit}},r.fromJSON=function(e){return new r(e.op,e.fn,e.args,e.implicit)},r.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,t,r,i,!1);if(1===i.length){var o=Mt(this,t),s=i[0].toHTML(e);return a[0]&&(s='('+s+')'),"right"===o?''+ke(this.op)+""+s:s+''+ke(this.op)+""}if(2===i.length){var u=i[0].toHTML(e),c=i[1].toHTML(e);return a[0]&&(u='('+u+')'),a[1]&&(c='('+c+')'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?u+''+c:u+''+ke(this.op)+""+c}var l=i.map((function(t,r){return t=t.toHTML(e),a[r]&&(t='('+t+')'),t}));return i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())?this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?l.join(''):l.join(''+ke(this.op)+""):''+ke(this.fn)+'('+l.join(',')+')'},r.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,t,r,i,!0),o=mt[this.fn];if(o=void 0===o?this.op:o,1===i.length){var s=Mt(this,t),u=i[0].toTex(e);return a[0]&&(u="\\left(".concat(u,"\\right)")),"right"===s?o+u:u+o}if(2===i.length){var c=i[0],l=c.toTex(e);a[0]&&(l="\\left(".concat(l,"\\right)"));var f,p=i[1].toTex(e);switch(a[1]&&(p="\\left(".concat(p,"\\right)")),f="keep"===t?c.getIdentifier():c.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return o+"{"+l+"}{"+p+"}";case"OperatorNode:pow":switch(l="{"+l+"}",p="{"+p+"}",f){case"ConditionalNode":case"OperatorNode:divide":l="\\left(".concat(l,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&"hide"===r)return l+"~"+p}return l+o+p}if(i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var m=i.map((function(t,r){return t=t.toTex(e),a[r]&&(t="\\left(".concat(t,"\\right)")),t}));return"OperatorNode:multiply"===this.getIdentifier()&&this.implicit?m.join("~"):m.join(o)}return"\\mathrm{"+this.fn+"}\\left("+i.map((function(t){return t.toTex(e)})).join(",")+"\\right)"},r.prototype.getIdentifier=function(){return this.type+":"+this.fn},r}),{isClass:!0,isNode:!0}),Tt=W("RangeNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError("Node expected");if(!I(t))throw new TypeError("Node expected");if(n&&!I(n))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=e,this.end=t,this.step=n||null}function n(e,t){var r=Nt(e,t),n={},i=Nt(e.start,t);if(n.start=null!==i&&i<=r||"all"===t,e.step){var a=Nt(e.step,t);n.step=null!==a&&a<=r||"all"===t}var o=Nt(e.end,t);return n.end=null!==o&&o<=r||"all"===t,n}return r.prototype=new t,r.prototype.type="RangeNode",r.prototype.isRangeNode=!0,r.prototype.needsEnd=function(){return this.filter((function(e){return P(e)&&"end"===e.name})).length>0},r.prototype._compile=function(e,t){var r=e.range,n=this.start._compile(e,t),i=this.end._compile(e,t);if(this.step){var a=this.step._compile(e,t);return function(e,t,o){return r(n(e,t,o),i(e,t,o),a(e,t,o))}}return function(e,t,a){return r(n(e,t,a),i(e,t,a))}},r.prototype.forEach=function(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)},r.prototype.map=function(e){return new r(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))},r.prototype.clone=function(){return new r(this.start,this.end,this.step&&this.step)},r.prototype._toString=function(e){var t,r=n(this,e&&e.parenthesis?e.parenthesis:"keep"),i=this.start.toString(e);if(r.start&&(i="("+i+")"),t=i,this.step){var a=this.step.toString(e);r.step&&(a="("+a+")"),t+=":"+a}var o=this.end.toString(e);return r.end&&(o="("+o+")"),t+":"+o},r.prototype.toJSON=function(){return{mathjs:"RangeNode",start:this.start,end:this.end,step:this.step}},r.fromJSON=function(e){return new r(e.start,e.end,e.step)},r.prototype.toHTML=function(e){var t,r=n(this,e&&e.parenthesis?e.parenthesis:"keep"),i=this.start.toHTML(e);if(r.start&&(i='('+i+')'),t=i,this.step){var a=this.step.toHTML(e);r.step&&(a='('+a+')'),t+=':'+a}var o=this.end.toHTML(e);return r.end&&(o='('+o+')'),t+':'+o},r.prototype._toTex=function(e){var t=n(this,e&&e.parenthesis?e.parenthesis:"keep"),r=this.start.toTex(e);if(t.start&&(r="\\left(".concat(r,"\\right)")),this.step){var i=this.step.toTex(e);t.step&&(i="\\left(".concat(i,"\\right)")),r+=":"+i}var a=this.end.toTex(e);return t.end&&(a="\\left(".concat(a,"\\right)")),r+":"+a},r}),{isClass:!0,isNode:!0}),Bt=W("FunctionAssignmentNode",["typed","Node"],(e=>{var{typed:t,Node:r}=e;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(t))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!I(r))throw new TypeError('Node expected for parameter "expr"');if(H.has(e))throw new Error('Illegal function name, "'+e+'" is a reserved keyword');this.name=e,this.params=t.map((function(e){return e&&e.name||e})),this.types=t.map((function(e){return e&&e.type||"any"})),this.expr=r}function i(e,t){var r=Nt(e,t),n=Nt(e.expr,t);return"all"===t||null!==n&&n<=r}return n.prototype=new r,n.prototype.type="FunctionAssignmentNode",n.prototype.isFunctionAssignmentNode=!0,n.prototype._compile=function(e,r){var n=Object.create(r);rt(this.params,(function(e){n[e]=!0}));var i=this.expr._compile(e,n),a=this.name,o=this.params,s=at(this.types,","),u=a+"("+at(this.params,", ")+")";return function(e,r,n){var c={};c[s]=function(){for(var t=Object.create(r),a=0;a'+ke(this.params[n])+"");var a=this.expr.toHTML(e);return i(this,t)&&(a='('+a+')'),''+ke(this.name)+'('+r.join(',')+')='+a},n.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=this.expr.toTex(e);return i(this,t)&&(r="\\left(".concat(r,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(gt).join(",")+"\\right):="+r},n}),{isClass:!0,isNode:!0}),qt="chain",zt=W(qt,["typed","Chain"],(e=>{var{typed:t,Chain:r}=e;return t(qt,{"":function(){return new r},any:function(e){return new r(e)}})}));function Dt(e){return e&&e.isIndexError?new Pe(e.index+1,e.min+1,void 0!==e.max?e.max+1:void 0):e}function It(e){var{subset:t}=e;return function(e,r){try{if(Array.isArray(e))return t(e,r);if(e&&"function"==typeof e.subset)return e.subset(r);if("string"==typeof e)return t(e,r);if("object"==typeof e){if(!r.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return Y(e,r.getObjectProperty())}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Dt(e)}}}var kt=W("AccessorNode",["subset","Node"],(e=>{var{subset:t,Node:r}=e,n=It({subset:t});function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError('Node expected for parameter "object"');if(!D(t))throw new TypeError('IndexNode expected for parameter "index"');this.object=e||null,this.index=t,Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function a(e){return!(A(e)||O(e)||B(e)||z(e)||k(e)||F(e)||P(e))}return i.prototype=new r,i.prototype.type="AccessorNode",i.prototype.isAccessorNode=!0,i.prototype._compile=function(e,t){var r=this.object._compile(e,t),i=this.index._compile(e,t);if(this.index.isObjectProperty()){var a=this.index.getObjectProperty();return function(e,t,n){return Y(r(e,t,n),a)}}return function(e,t,a){var o=r(e,t,a),s=i(e,t,o);return n(o,s)}},i.prototype.forEach=function(e){e(this.object,"object",this),e(this.index,"index",this)},i.prototype.map=function(e){return new i(this._ifNode(e(this.object,"object",this)),this._ifNode(e(this.index,"index",this)))},i.prototype.clone=function(){return new i(this.object,this.index)},i.prototype._toString=function(e){var t=this.object.toString(e);return a(this.object)&&(t="("+t+")"),t+this.index.toString(e)},i.prototype.toHTML=function(e){var t=this.object.toHTML(e);return a(this.object)&&(t='('+t+')'),t+this.index.toHTML(e)},i.prototype._toTex=function(e){var t=this.object.toTex(e);return a(this.object)&&(t="\\left(' + object + '\\right)"),t+this.index.toTex(e)},i.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},i.fromJSON=function(e){return new i(e.object,e.index)},i}),{isClass:!0,isNode:!0}),Rt=W("IndexNode",["Range","Node","size"],(e=>{var{Range:t,Node:r,size:n}=e;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(this.dimensions=e,this.dotNotation=t||!1,!Array.isArray(e)||!e.every(I))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}function o(e,r,n){return new t(a(e)?e.toNumber():e,a(r)?r.toNumber():r,a(n)?n.toNumber():n)}return i.prototype=new r,i.prototype.type="IndexNode",i.prototype.isIndexNode=!0,i.prototype._compile=function(e,t){var r=tt(this.dimensions,(function(r,i){if(U(r)){if(r.needsEnd()){var a=Object.create(t);a.end=!0;var s=r.start._compile(e,a),u=r.end._compile(e,a),c=r.step?r.step._compile(e,a):function(){return 1};return function(e,t,r){var a=n(r).valueOf(),l=Object.create(t);return l.end=a[i],o(s(e,l,r),u(e,l,r),c(e,l,r))}}var l=r.start._compile(e,t),f=r.end._compile(e,t),p=r.step?r.step._compile(e,t):function(){return 1};return function(e,t,r){return o(l(e,t,r),f(e,t,r),p(e,t,r))}}if(P(r)&&"end"===r.name){var m=Object.create(t);m.end=!0;var h=r._compile(e,m);return function(e,t,r){var a=n(r).valueOf(),o=Object.create(t);return o.end=a[i],h(e,o,r)}}var d=r._compile(e,t);return function(e,t,r){return d(e,t,r)}})),i=Y(e,"index");return function(e,t,n){var a=tt(r,(function(r){return r(e,t,n)}));return i(...a)}},i.prototype.forEach=function(e){for(var t=0;t.'+ke(this.getObjectProperty())+"":'['+t.join(',')+']'},i.prototype._toTex=function(e){var t=this.dimensions.map((function(t){return t.toTex(e)}));return this.dotNotation?"."+this.getObjectProperty():"_{"+t.join(",")+"}"},i}),{isClass:!0,isNode:!0}),Ft=W("AssignmentNode",["subset","?matrix","Node"],(e=>{var{subset:t,matrix:r,Node:n}=e,i=It({subset:t}),a=function(e){var{subset:t,matrix:r}=e;return function(e,n,i){try{if(Array.isArray(e))return r(e).subset(n,i).valueOf();if(e&&"function"==typeof e.subset)return e.subset(n,i);if("string"==typeof e)return t(e,n,i);if("object"==typeof e){if(!n.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return X(e,n.getObjectProperty(),i),e}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Dt(e)}}}({subset:t,matrix:r});function o(e,t,r){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=e,this.index=r?t:null,this.value=r||t,!P(e)&&!A(e))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(P(e)&&"end"===e.name)throw new Error('Cannot assign to symbol "end"');if(this.index&&!D(this.index))throw new TypeError('IndexNode expected as "index"');if(!I(this.value))throw new TypeError('Node expected as "value"');Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function s(e,t){t||(t="keep");var r=Nt(e,t),n=Nt(e.value,t);return"all"===t||null!==n&&n<=r}return o.prototype=new n,o.prototype.type="AssignmentNode",o.prototype.isAssignmentNode=!0,o.prototype._compile=function(e,t){var r=this.object._compile(e,t),n=this.index?this.index._compile(e,t):null,o=this.value._compile(e,t),s=this.object.name;if(this.index){if(this.index.isObjectProperty()){var u=this.index.getObjectProperty();return function(e,t,n){var i=r(e,t,n),a=o(e,t,n);return X(i,u,a),a}}if(P(this.object))return function(e,t,i){var u=r(e,t,i),c=o(e,t,i),l=n(e,t,u);return e.set(s,a(u,l,c)),c};var c=this.object.object._compile(e,t);if(this.object.index.isObjectProperty()){var l=this.object.index.getObjectProperty();return function(e,t,r){var i=c(e,t,r),s=Y(i,l),u=n(e,t,s),f=o(e,t,r);return X(i,l,a(s,u,f)),f}}var f=this.object.index._compile(e,t);return function(e,t,r){var s=c(e,t,r),u=f(e,t,s),l=i(s,u),p=n(e,t,l),m=o(e,t,r);return a(s,u,a(l,p,m)),m}}if(!P(this.object))throw new TypeError("SymbolNode expected as object");return function(e,t,r){var n=o(e,t,r);return e.set(s,n),n}},o.prototype.forEach=function(e){e(this.object,"object",this),this.index&&e(this.index,"index",this),e(this.value,"value",this)},o.prototype.map=function(e){return new o(this._ifNode(e(this.object,"object",this)),this.index?this._ifNode(e(this.index,"index",this)):null,this._ifNode(e(this.value,"value",this)))},o.prototype.clone=function(){return new o(this.object,this.index,this.value)},o.prototype._toString=function(e){var t=this.object.toString(e),r=this.index?this.index.toString(e):"",n=this.value.toString(e);return s(this,e&&e.parenthesis)&&(n="("+n+")"),t+r+" = "+n},o.prototype.toJSON=function(){return{mathjs:"AssignmentNode",object:this.object,index:this.index,value:this.value}},o.fromJSON=function(e){return new o(e.object,e.index,e.value)},o.prototype.toHTML=function(e){var t=this.object.toHTML(e),r=this.index?this.index.toHTML(e):"",n=this.value.toHTML(e);return s(this,e&&e.parenthesis)&&(n='('+n+')'),t+r+'='+n},o.prototype._toTex=function(e){var t=this.object.toTex(e),r=this.index?this.index.toTex(e):"",n=this.value.toTex(e);return s(this,e&&e.parenthesis)&&(n="\\left(".concat(n,"\\right)")),t+r+":="+n},o}),{isClass:!0,isNode:!0}),Ut=W("SymbolNode",["math","?Unit","Node"],(e=>{var{math:t,Unit:r,Node:n}=e;function i(e){return!!r&&r.isValuelessUnit(e)}function a(e){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');this.name=e}return a.prototype=new n,a.prototype.type="SymbolNode",a.prototype.isSymbolNode=!0,a.prototype._compile=function(e,t){var n=this.name;if(!0===t[n])return function(e,t,r){return t[n]};if(n in e)return function(t,r,i){return t.has(n)?t.get(n):Y(e,n)};var o=i(n);return function(e,t,i){return e.has(n)?e.get(n):o?new r(null,n):a.onUndefinedSymbol(n)}},a.prototype.forEach=function(e){},a.prototype.map=function(e){return this.clone()},a.onUndefinedSymbol=function(e){throw new Error("Undefined symbol "+e)},a.prototype.clone=function(){return new a(this.name)},a.prototype._toString=function(e){return this.name},a.prototype.toHTML=function(e){var t=ke(this.name);return"true"===t||"false"===t?''+t+"":"i"===t?''+t+"":"Infinity"===t?''+t+"":"NaN"===t?''+t+"":"null"===t?''+t+"":"undefined"===t?''+t+"":''+t+""},a.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},a.fromJSON=function(e){return new a(e.name)},a.prototype._toTex=function(e){var r=!1;void 0===t[this.name]&&i(this.name)&&(r=!0);var n=gt(this.name,r);return"\\"===n[0]?n:" "+n},a}),{isClass:!0,isNode:!0});function Pt(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{var{math:t,Node:r,SymbolNode:n}=e;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if("string"==typeof e&&(e=new n(e)),!I(e))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(t)||!t.every(I))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=e,this.args=t||[],Object.defineProperty(this,"name",{get:function(){return this.fn.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}i.prototype=new r,i.prototype.type="FunctionNode",i.prototype.isFunctionNode=!0,i.prototype._compile=function(e,t){if(!(this instanceof i))throw new TypeError("No valid FunctionNode");var r=this.args.map((r=>r._compile(e,t)));if(!P(this.fn)){if(A(this.fn)&&D(this.fn.index)&&this.fn.index.isObjectProperty()){var n=this.fn.object._compile(e,t),a=this.fn.index.getObjectProperty(),o=this.args;return function(t,i,s){var u=n(t,i,s);if(function(e,t){if(!K(e,t))throw new Error('No access to method "'+t+'"')}(u,a),u[a]&&u[a].rawArgs)return u[a](o,e,Pt(t,i),t);var c=r.map((e=>e(t,i,s)));return u[a].apply(u,c)}}var s=this.fn._compile(e,t),u=this.args;return function(t,n,i){var a=s(t,n,i);if(a&&a.rawArgs)return a(u,e,Pt(t,n),t);var o=r.map((e=>e(t,n,i)));return a.apply(a,o)}}var c=this.fn.name,l=c in e?Y(e,c):void 0,f="function"==typeof l&&!0===l.rawArgs,p=t=>t.has(c)?t.get(c):c in e?Y(e,c):i.onUndefinedFunction(c);if(f){var m=this.args;return function(t,r,n){return p(t)(m,e,Pt(t,r),t)}}switch(r.length){case 0:return function(e,t,r){return p(e)()};case 1:return function(e,t,n){return p(e)((0,r[0])(e,t,n))};case 2:return function(e,t,n){var i=p(e),a=r[0],o=r[1];return i(a(e,t,n),o(e,t,n))};default:return function(e,t,n){return p(e)(...r.map((r=>r(e,t,n))))}}},i.prototype.forEach=function(e){e(this.fn,"fn",this);for(var t=0;t'+ke(this.fn)+'('+t.join(',')+')'};var s=i.prototype.toTex;return i.prototype.toTex=function(e){var t;return e&&"object"==typeof e.handler&&Z(e.handler,this.name)&&(t=e.handler[this.name](this,e)),void 0!==t?t:s.call(this,e)},i.prototype._toTex=function(e){var r,n,i=this.args.map((function(t){return t.toTex(e)}));switch(ht[this.name]&&(r=ht[this.name]),!t[this.name]||"function"!=typeof t[this.name].toTex&&"object"!=typeof t[this.name].toTex&&"string"!=typeof t[this.name].toTex||(r=t[this.name].toTex),typeof r){case"function":n=r(this,e);break;case"string":n=o(r,this,e);break;case"object":switch(typeof r[i.length]){case"function":n=r[i.length](this,e);break;case"string":n=o(r[i.length],this,e)}}return void 0!==n?n:o("\\mathrm{${name}}\\left(${args}\\right)",this,e)},i.prototype.getIdentifier=function(){return this.type+":"+this.name},i}),{isClass:!0,isNode:!0});function Lt(e){for(var t=0;t=n.length)throw new Pe(t,n.length);return f(e)?e.create(Vt(e.valueOf(),t,r)):Vt(e,t,r)}function Vt(e,t,r){var n,i,a,o;if(t<=0){if(Array.isArray(e[0])){for(o=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r{var{typed:r,numeric:n,config:i,AccessorNode:a,ArrayNode:o,AssignmentNode:s,BlockNode:u,ConditionalNode:c,ConstantNode:l,FunctionAssignmentNode:f,FunctionNode:p,IndexNode:m,ObjectNode:h,OperatorNode:d,ParenthesisNode:y,RangeNode:g,RelationalNode:v,SymbolNode:x}=t,b=r(Wt,{string:function(e){return U(e,{})},"Array | Matrix":function(e){return w(e,{})},"string, Object":function(e,t){return U(e,void 0!==t.nodes?t.nodes:{})},"Array | Matrix, Object":w});function w(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=void 0!==t.nodes?t.nodes:{};return $t(e,(function(e){if("string"!=typeof e)throw new TypeError("String expected");return U(e,r)}))}var N={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},M={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},S={true:!0,false:!1,null:null,undefined:void 0},E=["NaN","Infinity"];function O(e,t){return e.expression.substr(e.index,t)}function C(e){return O(e,1)}function _(e){e.index++}function T(e){return e.expression.charAt(e.index-1)}function q(e){return e.expression.charAt(e.index+1)}function D(e){for(e.tokenType=0,e.token="",e.comment="";b.isWhitespace(C(e),e.nestingLevel);)_(e);if("#"===C(e))for(;"\n"!==C(e)&&""!==C(e);)e.comment+=C(e),_(e);if(""!==C(e)){if("\n"===C(e)&&!e.nestingLevel)return e.tokenType=1,e.token=C(e),void _(e);var t=C(e),r=O(e,2),n=O(e,3);if(3===n.length&&N[n])return e.tokenType=1,e.token=n,_(e),_(e),void _(e);if(2===r.length&&N[r])return e.tokenType=1,e.token=r,_(e),void _(e);if(N[t])return e.tokenType=1,e.token=t,void _(e);if(b.isDigitDot(t)){e.tokenType=2;var i=O(e,2);if("0b"===i||"0o"===i||"0x"===i){for(e.token+=C(e),_(e),e.token+=C(e),_(e);b.isHexDigit(C(e));)e.token+=C(e),_(e);if("."===C(e))for(e.token+=".",_(e);b.isHexDigit(C(e));)e.token+=C(e),_(e);else if("i"===C(e))for(e.token+="i",_(e);b.isDigit(C(e));)e.token+=C(e),_(e);return}if("."===C(e))e.token+=C(e),_(e),b.isDigit(C(e))||(e.tokenType=1);else{for(;b.isDigit(C(e));)e.token+=C(e),_(e);b.isDecimalMark(C(e),q(e))&&(e.token+=C(e),_(e))}for(;b.isDigit(C(e));)e.token+=C(e),_(e);if("E"===C(e)||"e"===C(e))if(b.isDigit(q(e))||"-"===q(e)||"+"===q(e)){if(e.token+=C(e),_(e),"+"!==C(e)&&"-"!==C(e)||(e.token+=C(e),_(e)),!b.isDigit(C(e)))throw ue(e,'Digit expected, got "'+C(e)+'"');for(;b.isDigit(C(e));)e.token+=C(e),_(e);if(b.isDecimalMark(C(e),q(e)))throw ue(e,'Digit expected, got "'+C(e)+'"')}else if("."===q(e))throw _(e),ue(e,'Digit expected, got "'+C(e)+'"')}else{if(!b.isAlpha(C(e),T(e),q(e))){for(e.tokenType=4;""!==C(e);)e.token+=C(e),_(e);throw ue(e,'Syntax error in part "'+e.token+'"')}for(;b.isAlpha(C(e),T(e),q(e))||b.isDigit(C(e));)e.token+=C(e),_(e);Z(M,e.token)?e.tokenType=1:e.tokenType=3}}else e.tokenType=1}function I(e){do{D(e)}while("\n"===e.token)}function k(e){e.nestingLevel++}function F(e){e.nestingLevel--}function U(t,r){var n={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:0,nestingLevel:0,conditionalLevel:null};e(n,{expression:t,extraNodes:r}),D(n);var i=function(e){var t,r,n=[];for(""!==e.token&&"\n"!==e.token&&";"!==e.token&&((t=j(e)).comment=e.comment);"\n"===e.token||";"===e.token;)0===n.length&&t&&(r=";"!==e.token,n.push({node:t,visible:r})),D(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&((t=j(e)).comment=e.comment,r=";"!==e.token,n.push({node:t,visible:r}));return n.length>0?new u(n):(t||((t=new l(void 0)).comment=e.comment),t)}(n);if(""!==n.token)throw 1===n.tokenType?ce(n,"Unexpected operator "+n.token):ue(n,'Unexpected part "'+n.token+'"');return i}function j(e){var t,r,n,i,a=function(e){for(var t=function(e){for(var t=L(e);"or"===e.token;)I(e),t=new d("or","or",[t,L(e)]);return t}(e);"?"===e.token;){var r=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,I(e);var n=t,i=j(e);if(":"!==e.token)throw ue(e,"False part of conditional expression expected");e.conditionalLevel=null,I(e);var a=j(e);t=new c(n,i,a),e.conditionalLevel=r}return t}(e);if("="===e.token){if(P(a))return t=a.name,I(e),n=j(e),new s(new x(t),n);if(A(a))return I(e),n=j(e),new s(a.object,a.index,n);if(z(a)&&P(a.fn)&&(i=!0,r=[],t=a.name,a.args.forEach((function(e,t){P(e)?r[t]=e.name:i=!1})),i))return I(e),n=j(e),new f(t,r,n);throw ue(e,"Invalid left hand side of assignment operator =")}return a}function L(e){for(var t=H(e);"xor"===e.token;)I(e),t=new d("xor","xor",[t,H(e)]);return t}function H(e){for(var t=$(e);"and"===e.token;)I(e),t=new d("and","and",[t,$(e)]);return t}function $(e){for(var t=G(e);"|"===e.token;)I(e),t=new d("|","bitOr",[t,G(e)]);return t}function G(e){for(var t=V(e);"^|"===e.token;)I(e),t=new d("^|","bitXor",[t,V(e)]);return t}function V(e){for(var t=W(e);"&"===e.token;)I(e),t=new d("&","bitAnd",[t,W(e)]);return t}function W(e){for(var t=[J(e)],r=[],n={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};Z(n,e.token);){var i={name:e.token,fn:n[e.token]};r.push(i),I(e),t.push(J(e))}return 1===t.length?t[0]:2===t.length?new d(r[0].name,r[0].fn,t):new v(r.map((e=>e.fn)),t)}function J(e){var t,r,n,i;t=Y(e);for(var a={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Z(a,e.token);)n=a[r=e.token],I(e),i=[t,Y(e)],t=new d(r,n,i);return t}function Y(e){var t,r,n,i;t=X(e);for(var a={to:"to",in:"to"};Z(a,e.token);)n=a[r=e.token],I(e),"in"===r&&""===e.token?t=new d("*","multiply",[t,new x("in")],!0):(i=[t,X(e)],t=new d(r,n,i));return t}function X(e){var t,r=[];if(t=":"===e.token?new l(1):Q(e),":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(r.push(t);":"===e.token&&r.length<3;)I(e),")"===e.token||"]"===e.token||","===e.token||""===e.token?r.push(new x("end")):r.push(Q(e));t=3===r.length?new g(r[0],r[2],r[1]):new g(r[0],r[1])}return t}function Q(e){var t,r,n,i;t=K(e);for(var a={"+":"add","-":"subtract"};Z(a,e.token);)n=a[r=e.token],I(e),i=[t,K(e)],t=new d(r,n,i);return t}function K(e){var t,r,n,i;r=t=ee(e);for(var a={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"};Z(a,e.token);)i=a[n=e.token],I(e),r=ee(e),t=new d(n,i,[t,r]);return t}function ee(e){var t,r;for(r=t=te(e);3===e.tokenType||"in"===e.token&&B(t)||!(2!==e.tokenType||B(r)||R(r)&&"!"!==r.op)||"("===e.token;)r=te(e),t=new d("*","multiply",[t,r],!0);return t}function te(t){for(var r=re(t),n=r,i=[];"/"===t.token&&B(n);){if(i.push(e({},t)),I(t),2!==t.tokenType){e(t,i.pop());break}if(i.push(e({},t)),I(t),3!==t.tokenType&&"("!==t.token){i.pop(),e(t,i.pop());break}e(t,i.pop()),i.pop(),n=re(t),r=new d("/","divide",[r,n])}return r}function re(e){var t,r,a,s={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Z(s,e.token)?(a=s[e.token],t=e.token,I(e),r=[re(e)],new d(t,a,r)):function(e){var t,r,a,s;return t=function(e){var t,r,a;t=function(e){var t=[];if(3===e.tokenType&&Z(e.extraNodes,e.token)){var r=e.extraNodes[e.token];if(D(e),"("===e.token){if(t=[],k(e),D(e),")"!==e.token)for(t.push(j(e));","===e.token;)D(e),t.push(j(e));if(")"!==e.token)throw ue(e,"Parenthesis ) expected");F(e),D(e)}return new r(t)}return function(e){var t;return 3===e.tokenType||1===e.tokenType&&e.token in M?(t=e.token,D(e),ne(e,Z(S,t)?new l(S[t]):-1!==E.indexOf(t)?new l(n(t,"number")):new x(t))):function(e){var t;return'"'===e.token?(t=ie(e),ne(e,new l(t))):function(e){var t;return"'"===e.token?(t=ae(e),ne(e,new l(t))):function(e){var t,r,a,s;if("["===e.token){if(k(e),D(e),"]"!==e.token){var u=oe(e);if(";"===e.token){for(a=1,r=[u];";"===e.token;)D(e),r[a]=oe(e),a++;if("]"!==e.token)throw ue(e,"End of matrix ] expected");F(e),D(e),s=r[0].items.length;for(var c=1;c0},b.isDecimalMark=function(e,t){return"."===e&&"/"!==t&&"*"!==t&&"^"!==t},b.isDigitDot=function(e){return e>="0"&&e<="9"||"."===e},b.isDigit=function(e){return e>="0"&&e<="9"},b.isHexDigit=function(e){return e>="0"&&e<="9"||e>="a"&&e<="f"||e>="A"&&e<="F"},b})),Yt="evaluate",Xt=W(Yt,["typed","parse"],(e=>{var{typed:t,parse:r}=e;return t(Yt,{string:function(e){var t=ie();return r(e).compile().evaluate(t)},"string, Map | Object":function(e,t){return r(e).compile().evaluate(t)},"Array | Matrix":function(e){var t=ie();return $t(e,(function(e){return r(e).compile().evaluate(t)}))},"Array | Matrix, Map | Object":function(e,t){return $t(e,(function(e){return r(e).compile().evaluate(t)}))}})})),Qt=W("Help",["parse"],(e=>{var{parse:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw new Error('Argument "doc" missing');this.doc=e}return r.prototype.type="Help",r.prototype.isHelp=!0,r.prototype.toString=function(){var e=this.doc||{},r="\n";if(e.name&&(r+="Name: "+e.name+"\n\n"),e.category&&(r+="Category: "+e.category+"\n\n"),e.description&&(r+="Description:\n "+e.description+"\n\n"),e.syntax&&(r+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){r+="Examples:\n";for(var n={},i=0;i"mathjs"!==e)).forEach((r=>{t[r]=e[r]})),new r(t)},r.prototype.valueOf=r.prototype.toString,r}),{isClass:!0}),Kt=W("Parser",["parse"],(e=>{var{parse:t}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:ie(),writable:!1})}return r.prototype.type="Parser",r.prototype.isParser=!0,r.prototype.evaluate=function(e){return t(e).compile().evaluate(this.scope)},r.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},r.prototype.getAll=function(){return function(e){if(e instanceof ne)return e.wrappedObject;var t={};for(var r of e.keys())X(t,r,e.get(r));return t}(this.scope)},r.prototype.getAllAsMap=function(){return this.scope},r.prototype.set=function(e,t){return this.scope.set(e,t),t},r.prototype.remove=function(e){this.scope.delete(e)},r.prototype.clear=function(){this.scope.clear()},r}),{isClass:!0}),er={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]},tr={name:"e",category:"Constants",syntax:["e"],description:"Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",examples:["e","e ^ 2","exp(2)","log(e)"],seealso:["exp"]},rr={bignumber:{name:"bignumber",category:"Construction",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","complex","fraction","index","matrix","string","unit"]},boolean:{name:"boolean",category:"Construction",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]},complex:{name:"complex",category:"Construction",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]},createUnit:{name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.",examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]},fraction:{name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(num,den)"],description:"Create a fraction from a number or from a numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},index:{name:"index",category:"Construction",syntax:["[start]","[start:end]","[start:step:end]","[start1, start 2, ...]","[start1:end1, start2:end2, ...]","[start1:step1:end1, start2:step2:end2, ...]"],description:"Create an index to get or replace a subset of a matrix",examples:["[]","[1, 2, 3]","A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[0:2, 0:2] = ones(2, 2)"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]},matrix:{name:"matrix",category:"Construction",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()",'matrix("dense")',"matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])",'matrix([3, 4; 5, 6], "sparse")','matrix([3, 4; 5, 6], "sparse", "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","sparse"]},number:{name:"number",category:"Construction",syntax:["x","number(x)","number(unit, valuelessUnit)"],description:"Create a number or convert a string or boolean into a number.",examples:["2","2e3","4.05","number(2)",'number("7.2")',"number(true)","number([true, false, true, true])",'number(unit("52cm"), "m")'],seealso:["bignumber","boolean","complex","fraction","index","matrix","string","unit"]},sparse:{name:"sparse",category:"Construction",syntax:["sparse()","sparse([a1, b1, ...; a1, b2, ...])",'sparse([a1, b1, ...; a1, b2, ...], "number")'],description:"Create a sparse matrix.",examples:["sparse()","sparse([3, 4; 5, 6])",'sparse([3, 0; 5, 0], "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","matrix"]},splitUnit:{name:"splitUnit",category:"Construction",syntax:["splitUnit(unit: Unit, parts: Unit[])"],description:"Split a unit in an array of units whose sum is equal to the original unit.",examples:['splitUnit(1 m, ["feet", "inch"])'],seealso:["unit","createUnit"]},string:{name:"string",category:"Construction",syntax:['"text"',"string(x)"],description:"Create a string or convert a value to a string",examples:['"Hello World!"',"string(4.2)","string(3 + 2i)"],seealso:["bignumber","boolean","complex","index","matrix","number","unit"]},unit:{name:"unit",category:"Construction",syntax:["value unit","unit(value, unit)","unit(string)"],description:"Create a unit.",examples:["5.5 mm","3 inch",'unit(7.1, "kilogram")','unit("23 deg")'],seealso:["bignumber","boolean","complex","index","matrix","number","string"]},e:tr,E:tr,false:{name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},i:{name:"i",category:"Constants",syntax:["i"],description:"Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",examples:["i","i * i","sqrt(-1)"],seealso:[]},Infinity:{name:"Infinity",category:"Constants",syntax:["Infinity"],description:"Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",examples:["Infinity","1 / 0"],seealso:[]},LN2:{name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},LN10:{name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},LOG2E:{name:"LOG2E",category:"Constants",syntax:["LOG2E"],description:"Returns the base-2 logarithm of E, approximately equal to 1.442",examples:["LOG2E","log(e, 2)"],seealso:[]},LOG10E:{name:"LOG10E",category:"Constants",syntax:["LOG10E"],description:"Returns the base-10 logarithm of E, approximately equal to 0.434",examples:["LOG10E","log(e, 10)"],seealso:[]},NaN:{name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},null:{name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},pi:er,PI:er,phi:{name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["phi"],seealso:[]},SQRT1_2:{name:"SQRT1_2",category:"Constants",syntax:["SQRT1_2"],description:"Returns the square root of 1/2, approximately equal to 0.707",examples:["SQRT1_2","sqrt(1/2)"],seealso:[]},SQRT2:{name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},tau:{name:"tau",category:"Constants",syntax:["tau"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]},true:{name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},version:{name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},speedOfLight:{description:"Speed of light in vacuum",examples:["speedOfLight"]},gravitationConstant:{description:"Newtonian constant of gravitation",examples:["gravitationConstant"]},planckConstant:{description:"Planck constant",examples:["planckConstant"]},reducedPlanckConstant:{description:"Reduced Planck constant",examples:["reducedPlanckConstant"]},magneticConstant:{description:"Magnetic constant (vacuum permeability)",examples:["magneticConstant"]},electricConstant:{description:"Electric constant (vacuum permeability)",examples:["electricConstant"]},vacuumImpedance:{description:"Characteristic impedance of vacuum",examples:["vacuumImpedance"]},coulomb:{description:"Coulomb's constant",examples:["coulomb"]},elementaryCharge:{description:"Elementary charge",examples:["elementaryCharge"]},bohrMagneton:{description:"Borh magneton",examples:["bohrMagneton"]},conductanceQuantum:{description:"Conductance quantum",examples:["conductanceQuantum"]},inverseConductanceQuantum:{description:"Inverse conductance quantum",examples:["inverseConductanceQuantum"]},magneticFluxQuantum:{description:"Magnetic flux quantum",examples:["magneticFluxQuantum"]},nuclearMagneton:{description:"Nuclear magneton",examples:["nuclearMagneton"]},klitzing:{description:"Von Klitzing constant",examples:["klitzing"]},bohrRadius:{description:"Borh radius",examples:["bohrRadius"]},classicalElectronRadius:{description:"Classical electron radius",examples:["classicalElectronRadius"]},electronMass:{description:"Electron mass",examples:["electronMass"]},fermiCoupling:{description:"Fermi coupling constant",examples:["fermiCoupling"]},fineStructure:{description:"Fine-structure constant",examples:["fineStructure"]},hartreeEnergy:{description:"Hartree energy",examples:["hartreeEnergy"]},protonMass:{description:"Proton mass",examples:["protonMass"]},deuteronMass:{description:"Deuteron Mass",examples:["deuteronMass"]},neutronMass:{description:"Neutron mass",examples:["neutronMass"]},quantumOfCirculation:{description:"Quantum of circulation",examples:["quantumOfCirculation"]},rydberg:{description:"Rydberg constant",examples:["rydberg"]},thomsonCrossSection:{description:"Thomson cross section",examples:["thomsonCrossSection"]},weakMixingAngle:{description:"Weak mixing angle",examples:["weakMixingAngle"]},efimovFactor:{description:"Efimov factor",examples:["efimovFactor"]},atomicMass:{description:"Atomic mass constant",examples:["atomicMass"]},avogadro:{description:"Avogadro's number",examples:["avogadro"]},boltzmann:{description:"Boltzmann constant",examples:["boltzmann"]},faraday:{description:"Faraday constant",examples:["faraday"]},firstRadiation:{description:"First radiation constant",examples:["firstRadiation"]},loschmidt:{description:"Loschmidt constant at T=273.15 K and p=101.325 kPa",examples:["loschmidt"]},gasConstant:{description:"Gas constant",examples:["gasConstant"]},molarPlanckConstant:{description:"Molar Planck constant",examples:["molarPlanckConstant"]},molarVolume:{description:"Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",examples:["molarVolume"]},sackurTetrode:{description:"Sackur-Tetrode constant at T=1 K and p=101.325 kPa",examples:["sackurTetrode"]},secondRadiation:{description:"Second radiation constant",examples:["secondRadiation"]},stefanBoltzmann:{description:"Stefan-Boltzmann constant",examples:["stefanBoltzmann"]},wienDisplacement:{description:"Wien displacement law constant",examples:["wienDisplacement"]},molarMass:{description:"Molar mass constant",examples:["molarMass"]},molarMassC12:{description:"Molar mass constant of carbon-12",examples:["molarMassC12"]},gravity:{description:"Standard acceleration of gravity (standard acceleration of free-fall on Earth)",examples:["gravity"]},planckLength:{description:"Planck length",examples:["planckLength"]},planckMass:{description:"Planck mass",examples:["planckMass"]},planckTime:{description:"Planck time",examples:["planckTime"]},planckCharge:{description:"Planck charge",examples:["planckCharge"]},planckTemperature:{description:"Planck temperature",examples:["planckTemperature"]},derivative:{name:"derivative",category:"Algebra",syntax:["derivative(expr, variable)","derivative(expr, variable, {simplify: boolean})"],description:"Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",examples:['derivative("2x^3", "x")','derivative("2x^3", "x", {simplify: false})','derivative("2x^2 + 3x + 4", "x")','derivative("sin(2x)", "x")','f = parse("x^2 + x")','x = parse("x")',"df = derivative(f, x)","df.evaluate({x: 3})"],seealso:["simplify","parse","evaluate"]},lsolve:{name:"lsolve",category:"Algebra",syntax:["x=lsolve(L, b)"],description:"Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolveAll","lup","lusolve","usolve","matrix","sparse"]},lsolveAll:{name:"lsolveAll",category:"Algebra",syntax:["x=lsolveAll(L, b)"],description:"Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolve","lup","lusolve","usolve","matrix","sparse"]},lup:{name:"lup",category:"Algebra",syntax:["lup(m)"],description:"Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",examples:["lup([[2, 1], [1, 4]])","lup(matrix([[2, 1], [1, 4]]))","lup(sparse([[2, 1], [1, 4]]))"],seealso:["lusolve","lsolve","usolve","matrix","sparse","slu","qr"]},lusolve:{name:"lusolve",category:"Algebra",syntax:["x=lusolve(A, b)","x=lusolve(lu, b)"],description:"Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lusolve(a, b)"],seealso:["lup","slu","lsolve","usolve","matrix","sparse"]},simplify:{name:"simplify",category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["derivative","parse","evaluate"]},rationalize:{name:"rationalize",category:"Algebra",syntax:["rationalize(expr)","rationalize(expr, scope)","rationalize(expr, scope, detailed)"],description:"Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",examples:['rationalize("2x/y - y/(x+1)")','rationalize("2x/y - y/(x+1)", true)'],seealso:["simplify"]},slu:{name:"slu",category:"Algebra",syntax:["slu(A, order, threshold)"],description:"Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",examples:["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],seealso:["lusolve","lsolve","usolve","matrix","sparse","lup","qr"]},usolve:{name:"usolve",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolveAll","lup","lusolve","lsolve","matrix","sparse"]},usolveAll:{name:"usolveAll",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolve","lup","lusolve","lsolve","matrix","sparse"]},qr:{name:"qr",category:"Algebra",syntax:["qr(A)"],description:"Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",examples:["qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])"],seealso:["lup","slu","matrix"]},abs:{name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},add:{name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i","3 cm + 2 inch",'"2.3" + "4"'],seealso:["subtract"]},cbrt:{name:"cbrt",category:"Arithmetic",syntax:["cbrt(x)","cbrt(x, allRoots)"],description:"Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",examples:["cbrt(64)","cube(4)","cbrt(-8)","cbrt(2 + 3i)","cbrt(8i)","cbrt(8i, true)","cbrt(27 m^3)"],seealso:["square","sqrt","cube","multiply"]},ceil:{name:"ceil",category:"Arithmetic",syntax:["ceil(x)"],description:"Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)"],seealso:["floor","fix","round"]},cube:{name:"cube",category:"Arithmetic",syntax:["cube(x)"],description:"Compute the cube of a value. The cube of x is x * x * x.",examples:["cube(2)","2^3","2 * 2 * 2"],seealso:["multiply","square","pow"]},divide:{name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["a = 2 / 3","a * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]},dotDivide:{name:"dotDivide",category:"Operators",syntax:["x ./ y","dotDivide(x, y)"],description:"Divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","dotMultiply","divide"]},dotMultiply:{name:"dotMultiply",category:"Operators",syntax:["x .* y","dotMultiply(x, y)"],description:"Multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","dotDivide"]},dotPow:{name:"dotPow",category:"Operators",syntax:["x .^ y","dotPow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]},exp:{name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["expm","expm1","pow","log"]},expm:{name:"expm",category:"Arithmetic",syntax:["exp(x)"],description:"Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",examples:["expm([[0,2],[0,0]])"],seealso:["exp"]},expm1:{name:"expm1",category:"Arithmetic",syntax:["expm1(x)"],description:"Calculate the value of subtracting 1 from the exponential value.",examples:["expm1(2)","pow(e, 2) - 1","log(expm1(2) + 1)"],seealso:["exp","pow","log"]},fix:{name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]},floor:{name:"floor",category:"Arithmetic",syntax:["floor(x)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)"],seealso:["ceil","fix","round"]},gcd:{name:"gcd",category:"Arithmetic",syntax:["gcd(a, b)","gcd(a, b, c, ...)"],description:"Compute the greatest common divisor.",examples:["gcd(8, 12)","gcd(-4, 6)","gcd(25, 15, -10)"],seealso:["lcm","xgcd"]},hypot:{name:"hypot",category:"Arithmetic",syntax:["hypot(a, b, c, ...)","hypot([a, b, c, ...])"],description:"Calculate the hypotenusa of a list with values. ",examples:["hypot(3, 4)","sqrt(3^2 + 4^2)","hypot(-2)","hypot([3, 4, 5])"],seealso:["abs","norm"]},lcm:{name:"lcm",category:"Arithmetic",syntax:["lcm(x, y)"],description:"Compute the least common multiple.",examples:["lcm(4, 6)","lcm(6, 21)","lcm(6, 21, 5)"],seealso:["gcd"]},log:{name:"log",category:"Arithmetic",syntax:["log(x)","log(x, base)"],description:"Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",examples:["log(3.5)","a = log(2.4)","exp(a)","10 ^ 4","log(10000, 10)","log(10000) / log(10)","b = log(1024, 2)","2 ^ b"],seealso:["exp","log1p","log2","log10"]},log2:{name:"log2",category:"Arithmetic",syntax:["log2(x)"],description:"Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",examples:["log2(0.03125)","log2(16)","log2(16) / log2(2)","pow(2, 4)"],seealso:["exp","log1p","log","log10"]},log1p:{name:"log1p",category:"Arithmetic",syntax:["log1p(x)","log1p(x, base)"],description:"Calculate the logarithm of a `value+1`",examples:["log1p(2.5)","exp(log1p(1.4))","pow(10, 4)","log1p(9999, 10)","log1p(9999) / log(10)"],seealso:["exp","log","log2","log10"]},log10:{name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(0.00001)","log10(10000)","10 ^ 4","log(10000) / log(10)","log(10000, 10)"],seealso:["exp","log"]},mod:{name:"mod",category:"Operators",syntax:["x % y","x mod y","mod(x, y)"],description:"Calculates the modulus, the remainder of an integer division.",examples:["7 % 3","11 % 2","10 mod 4","isOdd(x) = x % 2","isOdd(2)","isOdd(3)"],seealso:["divide"]},multiply:{name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["a = 2.1 * 3.4","a / 3.4","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]},norm:{name:"norm",category:"Arithmetic",syntax:["norm(x)","norm(x, p)"],description:"Calculate the norm of a number, vector or matrix.",examples:["abs(-3.5)","norm(-3.5)","norm(3 - 4i)","norm([1, 2, -3], Infinity)","norm([1, 2, -3], -Infinity)","norm([3, 4], 2)","norm([[1, 2], [3, 4]], 1)",'norm([[1, 2], [3, 4]], "inf")','norm([[1, 2], [3, 4]], "fro")']},nthRoot:{name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["nthRoots","pow","sqrt"]},nthRoots:{name:"nthRoots",category:"Arithmetic",syntax:["nthRoots(A)","nthRoots(A, root)"],description:'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',examples:["nthRoots(1)","nthRoots(1, 3)"],seealso:["sqrt","pow","nthRoot"]},pow:{name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3","2*2*2","1 + e ^ (pi * i)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},round:{name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)"],seealso:["ceil","floor","fix"]},sign:{name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},sqrt:{name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},sqrtm:{name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},square:{name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},subtract:{name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},unaryMinus:{name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},bitAnd:{name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitNot:{name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitOr:{name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},bitXor:{name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},leftShift:{name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},rightArithShift:{name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},rightLogShift:{name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},bellNumbers:{name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},catalan:{name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},composition:{name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},stirlingS2:{name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},config:{name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},import:{name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number, number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},arg:{name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},conj:{name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},re:{name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},im:{name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},evaluate:{name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(" + 4 + ")")'],seealso:[]},help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},distance:{name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])","distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},intersect:{name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},and:{name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},not:{name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},or:{name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},xor:{name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},concat:{name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},count:{name:"count",category:"Matrix",syntax:["count(x)"],description:"Count the number of elements of a matrix, array or string.",examples:["a = [1, 2; 3, 4; 5, 6]","count(a)","size(a)",'count("hello world")'],seealso:["size"]},cross:{name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},column:{name:"column",category:"Matrix",syntax:["column(x, index)"],description:"Return a column from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","column(A, 1)","column(A, 2)"],seealso:["row","matrixFromColumns"]},ctranspose:{name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},det:{name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diag:{name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diff:{name:"diff",category:"Matrix",syntax:["diff(arr)","diff(arr, dim)"],description:["Create a new matrix or array with the difference of the passed matrix or array.","Dim parameter is optional and used to indicant the dimension of the array/matrix to apply the difference","If no dimension parameter is passed it is assumed as dimension 0","Dimension is zero-based in javascript and one-based in the parser","Arrays must be 'rectangular' meaning arrays like [1, 2]","If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],examples:["diff([1, 2, 4, 7, 0])","diff([1, 2, 4, 7, 0], 0)","diff(matrix([1, 2, 4, 7, 0]))","diff([[1, 2], [3, 4]])","diff([[1, 2], [3, 4]], 0)","diff([[1, 2], [3, 4]], 1)","diff([[1, 2], [3, 4]], bignumber(1))","diff(matrix([[1, 2], [3, 4]]), 1)","diff([[1, 2], matrix([3, 4])], 1)"],seealso:["subtract","partitionSelect"]},dot:{name:"dot",category:"Matrix",syntax:["dot(A, B)","A * B"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]},getMatrixDataType:{name:"getMatrixDataType",category:"Matrix",syntax:["getMatrixDataType(x)"],description:'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',examples:["getMatrixDataType([1, 2, 3])","getMatrixDataType([[5 cm], [2 inch]])",'getMatrixDataType([1, "text"])',"getMatrixDataType([1, bignumber(4)])"],seealso:["matrix","sparse","typeOf"]},identity:{name:"identity",category:"Matrix",syntax:["identity(n)","identity(m, n)","identity([m, n])"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["identity(3)","identity(3, 5)","a = [1, 2, 3; 4, 5, 6]","identity(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},filter:{name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},flatten:{name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]},forEach:{name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["forEach([1, 2, 3], function(val) { console.log(val) })"],seealso:["map","sort","filter"]},inv:{name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","identity","ones","range","size","squeeze","subset","trace","transpose","zeros"]},eigs:{name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and eigenvectors of a real symmetric matrix",examples:["eigs([[5, 2.3], [2.3, 1]])"],seealso:["inv"]},kron:{name:"kron",category:"Matrix",syntax:["kron(x, y)"],description:"Calculates the kronecker product of 2 matrices or vectors.",examples:["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])","kron([1,1], [2,3,4])"],seealso:["multiply","dot","cross"]},matrixFromFunction:{name:"matrixFromFunction",category:"Matrix",syntax:["math.matrixFromFunction(size, fn)","math.matrixFromFunction(size, fn, format)","math.matrixFromFunction(size, fn, format, datatype)","math.matrixFromFunction(size, format, fn)","math.matrixFromFunction(size, format, datatype, fn)"],description:"Create a matrix by evaluating a generating function at each index.",examples:["f(I) = I[1] - I[2]","matrixFromFunction([3,3], f)","g(I) = I[1] - I[2] == 1 ? 4 : 0",'matrixFromFunction([100, 100], "sparse", g)',"matrixFromFunction([5], random)"],seealso:["matrix","matrixFromRows","matrixFromColumns","zeros"]},matrixFromRows:{name:"matrixFromRows",category:"Matrix",syntax:["math.matrixFromRows(...arr)","math.matrixFromRows(row1, row2)","math.matrixFromRows(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual rows.",examples:["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromColumns","matrixFromFunction","zeros"]},matrixFromColumns:{name:"matrixFromColumns",category:"Matrix",syntax:["math.matrixFromColumns(...arr)","math.matrixFromColumns(row1, row2)","math.matrixFromColumns(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual columns.",examples:["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromRows","matrixFromFunction","zeros"]},map:{name:"map",category:"Matrix",syntax:["map(x, callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",examples:["map([1, 2, 3], square)"],seealso:["filter","forEach"]},ones:{name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","identity","inv","range","size","squeeze","subset","trace","transpose","zeros"]},partitionSelect:{name:"partitionSelect",category:"Matrix",syntax:["partitionSelect(x, k)","partitionSelect(x, k, compare)"],description:"Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",examples:["partitionSelect([5, 10, 1], 2)",'partitionSelect(["C", "B", "A", "D"], 1)'],seealso:["sort"]},range:{name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","identity","inv","ones","size","squeeze","subset","trace","transpose","zeros"]},resize:{name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze","reshape"]},reshape:{name:"reshape",category:"Matrix",syntax:["reshape(x, sizes)"],description:"Reshape a multi dimensional array to fit the specified dimensions.",examples:["reshape([1, 2, 3, 4, 5, 6], [2, 3])","reshape([[1, 2], [3, 4]], [1, 4])","reshape([[1, 2], [3, 4]], [4])"],seealso:["size","squeeze","resize"]},rotate:{name:"rotate",category:"Matrix",syntax:["rotate(w, theta)","rotate(w, theta, v)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotate([1, 0], math.pi / 2)",'rotate(matrix([1, 0]), unit("35deg"))','rotate([1, 0, 0], unit("90deg"), [0, 0, 1])','rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],seealso:["matrix","rotationMatrix"]},rotationMatrix:{name:"rotationMatrix",category:"Matrix",syntax:["rotationMatrix(theta)","rotationMatrix(theta, v)","rotationMatrix(theta, v, format)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotationMatrix(pi / 2)",'rotationMatrix(unit("45deg"), [0, 0, 1])','rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],seealso:["cos","sin"]},row:{name:"row",category:"Matrix",syntax:["row(x, index)"],description:"Return a row from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","row(A, 1)","row(A, 2)"],seealso:["column","matrixFromRows"]},size:{name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","count","det","diag","identity","inv","ones","range","squeeze","subset","trace","transpose","zeros"]},sort:{name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"])',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},squeeze:{name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","identity","inv","ones","range","size","subset","trace","transpose","zeros"]},subset:{name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of a matrix or string. Indexes are one-based. Both the ranges lower-bound and upper-bound are included.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},trace:{name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","transpose","zeros"]},transpose:{name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},zeros:{name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose"]},combinations:{name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},combinationsWithRep:{name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"],seealso:["combinations","permutations","factorial"]},factorial:{name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},gamma:{name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},kldivergence:{name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},multinomial:{name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},permutations:{name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},pickRandom:{name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)","pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])","pickRandom([1, 3, 1, 6], 2)","pickRandom([1, 3, 1, 6], [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],seealso:["random","randomInt"]},random:{name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]},randomInt:{name:"randomInt",category:"Probability",syntax:["randomInt(max)","randomInt(min, max)","randomInt(size)","randomInt(size, max)","randomInt(size, min, max)"],description:"Return a random integer number",examples:["randomInt(10, 20)","randomInt([2, 3], 10)"],seealso:["pickRandom","random"]},compare:{name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compareNatural","compareText"]},compareNatural:{name:"compareNatural",category:"Relational",syntax:["compareNatural(x, y)"],description:"Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compareNatural(2, 3)","compareNatural(3, 2)","compareNatural(2, 2)","compareNatural(5cm, 40mm)",'compareNatural("2", "10")',"compareNatural(2 + 3i, 2 + 4i)","compareNatural([1, 2, 4], [1, 2, 3])","compareNatural([1, 5], [1, 2, 3])","compareNatural([1, 2], [1, 2])","compareNatural({a: 2}, {a: 4})"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare","compareText"]},compareText:{name:"compareText",category:"Relational",syntax:["compareText(x, y)"],description:"Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:['compareText("B", "A")','compareText("A", "B")','compareText("A", "A")','compareText("2", "10")','compare("2", "10")',"compare(2, 10)",'compareNatural("2", "10")','compareText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural"]},deepEqual:{name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["deepEqual([1,3,4], [1,3,4])","deepEqual([1,3,4], [1,3])"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]},equal:{name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual","equalText"]},equalText:{name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},larger:{name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},largerEq:{name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},smaller:{name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},smallerEq:{name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 <= 1+1","2 < 1+1","a = 3.2","b = 6-2.8","(a <= b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]},unequal:{name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]},setCartesian:{name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},setDifference:{name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},setDistinct:{name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},setIntersect:{name:"setIntersect",category:"Set",syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},setIsSubset:{name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},setMultiplicity:{name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]},setPowerset:{name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},setSize:{name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},setSymDifference:{name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setDifference"]},setUnion:{name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},erf:{name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},mad:{name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},mean:{name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},median:{name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},min:{name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},mode:{name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},prod:{name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},quantileSeq:{name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:"Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.",examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},std:{name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},sum:{name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},variance:{name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},acos:{name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},acosh:{name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},acot:{name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},acoth:{name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},acsc:{name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},acsch:{name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},asec:{name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},asech:{name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},asin:{name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},asinh:{name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},atan:{name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},atanh:{name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},atan2:{name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},cos:{name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},cosh:{name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},cot:{name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},coth:{name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},csc:{name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},csch:{name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},sec:{name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},sech:{name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},sin:{name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},sinh:{name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},tan:{name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},tanh:{name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},to:{name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},clone:{name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},format:{name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},bin:{name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},oct:{name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},hex:{name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},isNaN:{name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isInteger:{name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isNegative:{name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},isNumeric:{name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},hasNumericValue:{name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},isPositive:{name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isPrime:{name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isZero:{name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},typeOf:{name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},numeric:{name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "BigNumber")','numeric("4", "Fraction)','numeric(4, "Fraction")','numeric(fraction(2, 5), "number)'],seealso:["number","fraction","bignumber","string","format"]}},nr="help",ir=W(nr,["typed","mathWithTransform","Help"],(e=>{var{typed:t,mathWithTransform:r,Help:n}=e;return t(nr,{any:function(e){var t,i=e;if("string"!=typeof e)for(t in r)if(Z(r,t)&&e===r[t]){i=t;break}var a=Y(rr,i);if(!a){var o="function"==typeof i?i.name:i;throw new Error('No documentation found on "'+o+'"')}return new n(a)}})})),ar="compile",or=W(ar,["typed","parse"],(e=>{var{typed:t,parse:r}=e;return t(ar,{string:function(e){return r(e).compile()},"Array | Matrix":function(e){return $t(e,(function(e){return r(e).compile()}))}})})),sr=W("simplifyUtil",["FunctionNode","OperatorNode","SymbolNode"],(e=>{var{FunctionNode:t,OperatorNode:r,SymbolNode:n}=e,i={add:!0,multiply:!0},a={add:!0,multiply:!0};function o(e,t){if(!R(e))return!1;var r=e.fn.toString();return t&&Z(t,r)&&Z(t[r],"associative")?t[r].associative:a[r]||!1}function s(e){var t,r=[];return o(e)?(t=e.op,function e(n){for(var i=0;i2&&o(t)){for(var a=t.args.pop();t.args.length>0;)a=r([t.args.pop(),a]);t.args=a.args}}},unflattenl:function e(t){if(t.args&&0!==t.args.length){for(var r=u(t),n=t.args.length,i=0;i2&&o(t)){for(var a=t.args.shift();t.args.length>0;)a=r([a,t.args.shift()]);t.args=a.args}}}}})),ur=W("simplifyCore",["equal","isZero","add","subtract","multiply","divide","pow","ConstantNode","OperatorNode","FunctionNode","ParenthesisNode"],(e=>{var{equal:t,isZero:r,add:n,subtract:i,multiply:a,divide:o,pow:s,ConstantNode:u,OperatorNode:c,FunctionNode:l,ParenthesisNode:f}=e,p=new u(0),m=new u(1);return function e(h){if(R(h)&&h.isUnary()){var d=e(h.args[0]);if("+"===h.op)return d;if("-"===h.op){if(R(d)){if(d.isUnary()&&"-"===d.op)return d.args[0];if(d.isBinary()&&"subtract"===d.fn)return new c("-","subtract",[d.args[1],d.args[0]])}return new c(h.op,h.fn,[d])}}else if(R(h)&&h.isBinary()){var y=e(h.args[0]),g=e(h.args[1]);if("+"===h.op){if(B(y)){if(r(y.value))return g;if(B(g))return new u(n(y.value,g.value))}return B(g)&&r(g.value)?y:R(g)&&g.isUnary()&&"-"===g.op?new c("-","subtract",[y,g.args[0]]):new c(h.op,h.fn,g?[y,g]:[y])}if("-"===h.op){if(B(y)&&g){if(B(g))return new u(i(y.value,g.value));if(r(y.value))return new c("-","unaryMinus",[g])}if("subtract"===h.fn)return B(g)&&r(g.value)?y:R(g)&&g.isUnary()&&"-"===g.op?e(new c("+","add",[y,g.args[0]])):new c(h.op,h.fn,[y,g])}else{if("*"===h.op){if(B(y)){if(r(y.value))return p;if(t(y.value,1))return g;if(B(g))return new u(a(y.value,g.value))}if(B(g)){if(r(g.value))return p;if(t(g.value,1))return y;if(R(y)&&y.isBinary()&&y.op===h.op){var v=y.args[0];if(B(v)){var x=new u(a(v.value,g.value));return new c(h.op,h.fn,[x,y.args[1]],h.implicit)}}return new c(h.op,h.fn,[g,y],h.implicit)}return new c(h.op,h.fn,[y,g],h.implicit)}if("/"===h.op){if(B(y)){if(r(y.value))return p;if(B(g)&&(t(g.value,1)||t(g.value,2)||t(g.value,4)))return new u(o(y.value,g.value))}return new c(h.op,h.fn,[y,g])}if("^"===h.op){if(B(g)){if(r(g.value))return m;if(t(g.value,1))return y;if(B(y))return new u(s(y.value,g.value));if(R(y)&&y.isBinary()&&"^"===y.op){var b=y.args[1];if(B(b))return new c(h.op,h.fn,[y.args[0],new u(a(b.value,g.value))])}}return new c(h.op,h.fn,[y,g])}}}else{if(F(h)){var w=e(h.content);return F(w)||P(w)||B(w)?w:new f(w)}if(z(h)){var N=h.args.map(e).map((function(e){return F(e)?e.content:e}));return new l(e(h.fn),N)}}return h}}));function cr(){throw new Error('No "bignumber" implementation available')}function lr(){throw new Error('No "fraction" implementation available')}function fr(){throw new Error('No "matrix" implementation available')}var pr=W("simplifyConstant",["typed","config","mathWithTransform","?fraction","?bignumber","ConstantNode","OperatorNode","FunctionNode","SymbolNode"],(e=>{var{typed:t,config:r,mathWithTransform:n,fraction:i,bignumber:a,ConstantNode:o,OperatorNode:u,FunctionNode:c,SymbolNode:l}=e,{isCommutative:f,isAssociative:p,allChildren:m,createMakeNodeFunction:h}=sr({FunctionNode:c,OperatorNode:u,SymbolNode:l});function d(e,t,r){try{return v(n[e].apply(null,t),r)}catch(i){return t=t.map((function(e){return s(e)?e.valueOf():e})),v(n[e].apply(null,t),r)}}var y=t({Fraction:function(e){var t,r=e.s*e.n;return t=r<0?new u("-","unaryMinus",[new o(-r)]):new o(r),1===e.d?t:new u("/","divide",[t,new o(e.d)])},number:function(e){return e<0?x(new o(-e)):new o(e)},BigNumber:function(e){return e<0?x(new o(-e)):new o(e)},Complex:function(e){throw new Error("Cannot convert Complex number to Node")}});function g(e,t){if(t&&!1!==t.exactFractions&&isFinite(e)&&i){var r=i(e),n=t&&"number"==typeof t.fractionsLimit?t.fractionsLimit:1/0;if(r.valueOf()===e&&r.nw(e,t)));if(!r.some(I))try{return d(e.name,r,t)}catch(e){}return r=r.map((function(e){return I(e)?e:y(e)})),new c(e.name,r)}case"OperatorNode":var i,a,o=e.fn.toString(),s=h(e);if(R(e)&&e.isUnary())a=I((i=[w(e.args[0],t)])[0])?s(i):d(o,i,t);else if(p(e))if(i=(i=m(e)).map((e=>w(e,t))),f(o)){for(var u=[],l=[],g=0;g1?(a=b(o,u,s,t),l.unshift(a),a=b(o,l,s,t)):a=b(o,i,s,t)}else a=b(o,i,s,t);else a=b(o,i=e.args.map((e=>w(e,t))),s,t);return a;case"ParenthesisNode":return w(e.content,t);case"AccessorNode":case"ArrayNode":case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"IndexNode":case"ObjectNode":case"RangeNode":case"ConditionalNode":default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(e.type))}}return function(e,t){var r=w(e,t);return I(r)?r:y(r)}})),mr=W("resolve",["parse","FunctionNode","OperatorNode","ParenthesisNode"],(e=>{var{parse:t,FunctionNode:r,OperatorNode:n,ParenthesisNode:i}=e;return function e(a,o){if(!o)return a;if(oe(o)||(o=ae(o)),P(a)){var s=o.get(a.name);if(I(s))return e(s,o);if("number"==typeof s)return t(String(s))}else{if(R(a)){var u=a.args.map((function(t){return e(t,o)}));return new n(a.op,a.fn,u,a.implicit)}if(F(a))return new i(e(a.content,o));if(z(a)){var c=a.args.map((function(t){return e(t,o)}));return new r(a.name,c)}}return a}})),hr=W("simplify",["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","?fraction","?bignumber","mathWithTransform","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{config:t,typed:r,parse:n,add:i,subtract:a,multiply:o,divide:s,pow:u,isZero:c,equal:l,fraction:f,bignumber:p,mathWithTransform:m,ConstantNode:h,FunctionNode:d,OperatorNode:y,ParenthesisNode:g,SymbolNode:v}=e,x=pr({typed:r,config:t,mathWithTransform:m,fraction:f,bignumber:p,ConstantNode:h,OperatorNode:y,FunctionNode:d,SymbolNode:v}),b=ur({equal:l,isZero:c,add:i,subtract:a,multiply:o,divide:s,pow:u,ConstantNode:h,OperatorNode:y,FunctionNode:d,ParenthesisNode:g}),w=mr({parse:n,FunctionNode:d,OperatorNode:y,ParenthesisNode:g}),{isCommutative:N,isAssociative:M,flatten:S,unflattenr:E,unflattenl:A,createMakeNodeFunction:O}=sr({FunctionNode:d,OperatorNode:y,SymbolNode:v}),C=r("simplify",{string:function(e){return this(n(e),this.rules,ie(),{})},"string, Map | Object":function(e,t){return this(n(e),this.rules,t,{})},"string, Map | Object, Object":function(e,t,r){return this(n(e),this.rules,t,r)},"string, Array":function(e,t){return this(n(e),t,ie(),{})},"string, Array, Map | Object":function(e,t,r){return this(n(e),t,r,{})},"string, Array, Map | Object, Object":function(e,t,r,i){return this(n(e),t,r,i)},"Node, Map | Object":function(e,t){return this(e,this.rules,t,{})},"Node, Map | Object, Object":function(e,t,r){return this(e,this.rules,t,r)},Node:function(e){return this(e,this.rules,ie(),{})},"Node, Array":function(e,t){return this(e,t,ie(),{})},"Node, Array, Map | Object":function(e,t,r){return this(e,t,r,{})},"Node, Array, Object, Object":function(e,t,r,n){return this(e,t,ae(r),n)},"Node, Array, Map, Object":function(e,t,r,i){t=function(e){for(var t=[],r=0;r");if(2!==s.length)throw SyntaxError("Could not parse rule: "+i);i={l:s[0],r:s[1]};case"object":if(a={l:_(n(i.l)),r:_(n(i.r))},i.context&&(a.evaluate=i.context),i.evaluate&&(a.evaluate=n(i.evaluate)),M(a.l)){var u=O(a.l),c=new v("_p"+q++);a.expanded={},a.expanded.l=u([a.l.clone(),c]),S(a.expanded.l),E(a.expanded.l),a.expanded.r=u([a.r,c])}break;case"function":a=i;break;default:throw TypeError("Unsupported type of rule: "+o)}t.push(a)}return t}(t);for(var a=w(e,r),o={},s=(a=_(a)).toString({parenthesis:"all"});!o[s];){o[s]=!0,q=0;for(var u=0;u=2&&2===e.args.length){for(var i=function(e,t){var r,n,i=[],a=O(e);if(N(e,t))for(var o=0;o2)throw Error("Unexpected non-binary associative function: "+e.toString());return[]}for(var u=[],c=0;c{var{config:t,typed:r,equal:n,isZero:i,add:a,subtract:o,multiply:s,divide:u,pow:c,parse:l,simplify:f,fraction:p,bignumber:m,mathWithTransform:h,ConstantNode:d,OperatorNode:y,FunctionNode:g,SymbolNode:v,ParenthesisNode:x}=e,b=pr({typed:r,config:t,mathWithTransform:h,fraction:p,bignumber:m,ConstantNode:d,OperatorNode:y,FunctionNode:g,SymbolNode:v}),w=ur({equal:n,isZero:i,add:a,subtract:o,multiply:s,divide:u,pow:c,ConstantNode:d,OperatorNode:y,FunctionNode:g,ParenthesisNode:x});return r(dr,{string:function(e){return this(l(e),{},!1)},"string, boolean":function(e,t){return this(l(e),{},t)},"string, Object":function(e,t){return this(l(e),t,!1)},"string, Object, boolean":function(e,t,r){return this(l(e),t,r)},Node:function(e){return this(e,{},!1)},"Node, boolean":function(e,t){return this(e,{},t)},"Node, Object":function(e,t){return this(e,t,!1)},"Node, Object, boolean":function(e,t,r){var n=function(){var e=[w,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},b,{l:"n*(n1^-1)",r:"n/n1"},{l:"n*n1^-n2",r:"n/n1^n2"},{l:"n1^-1",r:"1/n1"},{l:"n*(n1/n2)",r:"(n*n1)/n2"},{l:"1*n",r:"n"}],t=[{l:"(-n1)/(-n2)",r:"n1/n2"},{l:"(-n1)*(-n2)",r:"n1*n2"},{l:"n1--n2",r:"n1+n2"},{l:"n1-n2",r:"n1+(-n2)"},{l:"(n1+n2)*n3",r:"(n1*n3 + n2*n3)"},{l:"n1*(n2+n3)",r:"(n1*n2+n1*n3)"},{l:"c1*n + c2*n",r:"(c1+c2)*n"},{l:"c1*n + n",r:"(c1+1)*n"},{l:"c1*n - c2*n",r:"(c1-c2)*n"},{l:"c1*n - n",r:"(c1-1)*n"},{l:"v/c",r:"(1/c)*v"},{l:"v/-c",r:"-(1/c)*v"},{l:"-v*-c",r:"c*v"},{l:"-v*c",r:"-c*v"},{l:"v*-c",r:"-c*v"},{l:"v*c",r:"c*v"},{l:"-(-n1*n2)",r:"(n1*n2)"},{l:"-(n1*n2)",r:"(-n1*n2)"},{l:"-(-n1+n2)",r:"(n1-n2)"},{l:"-(n1+n2)",r:"(-n1-n2)"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"},{l:"-(-n1/n2)",r:"(n1/n2)"},{l:"-(n1/n2)",r:"(-n1/n2)"}],r=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],n={};return n.firstRules=e.concat(t,r),n.distrDivRules=[{l:"(n1/n2 + n3/n4)",r:"((n1*n4 + n3*n2)/(n2*n4))"},{l:"(n1/n2 + n3)",r:"((n1 + n3*n2)/n2)"},{l:"(n1 + n2/n3)",r:"((n1*n3 + n2)/n3)"}],n.sucDivRules=r,n.firstRulesAgain=e.concat(t),n.finalRules=[w,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},b,{l:"n*-n^n1",r:"-n^(n1+1)"},{l:"n*n^n1",r:"n^(n1+1)"},{l:"n^n1*-n^n2",r:"-n^(n1+n2)"},{l:"n^n1*n^n2",r:"n^(n1+n2)"},{l:"n^n1*-n",r:"-n^(n1+1)"},{l:"n^n1*n",r:"n^(n1+1)"},{l:"n^n1/-n",r:"-n^(n1-1)"},{l:"n^n1/n",r:"n^(n1-1)"},{l:"n/-n^n1",r:"-n^(1-n1)"},{l:"n/n^n1",r:"n^(1-n1)"},{l:"n^n1/-n^n2",r:"n^(n1-n2)"},{l:"n^n1/n^n2",r:"n^(n1-n2)"},{l:"n1+(-n2*n3)",r:"n1-n2*n3"},{l:"v*(-c)",r:"-c*v"},{l:"n1+-n2",r:"n1-n2"},{l:"v*c",r:"c*v"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"}],n}(),i=function(e,t,r,n){var i=[],a=f(e,n,t,{exactFractions:!1}),o="+-*"+((r=!!r)?"/":"");!function e(t){var r=t.type;if("FunctionNode"===r)throw new Error("There is an unsolved function call");if("OperatorNode"===r)if("^"===t.op){if("ConstantNode"!==t.args[1].type||!ce(parseFloat(t.args[1].value)))throw new Error("There is a non-integer exponent");e(t.args[0])}else{if(-1===o.indexOf(t.op))throw new Error("Operator "+t.op+" invalid in polynomial expression");for(var n=0;n=1){var o,s;e=N(e);var u,c=!0,l=!1;for(e=f(e,n.firstRules,{},{exactFractions:!1});s=c?n.distrDivRules:n.sucDivRules,c=!c,(u=(e=f(e,s)).toString())!==o;)l=!0,o=u;l&&(e=f(e,n.firstRulesAgain,{},{exactFractions:!1})),e=f(e,n.finalRules,{},{exactFractions:!1})}var p=[],m={};return"OperatorNode"===e.type&&e.isBinary()&&"/"===e.op?(1===a&&(e.args[0]=M(e.args[0],p),e.args[1]=M(e.args[1])),r&&(m.numerator=e.args[0],m.denominator=e.args[1])):(1===a&&(e=M(e,p)),r&&(m.numerator=e,m.denominator=null)),r?(m.coefficients=p,m.variables=i.variables,m.expression=e,m):e}});function N(e,t,r){var n=e.type,i=arguments.length>1;if("OperatorNode"===n&&e.isBinary()){var a,o=!1;if("^"===e.op&&("ParenthesisNode"!==e.args[0].type&&"OperatorNode"!==e.args[0].type||"ConstantNode"!==e.args[1].type||(o=(a=parseFloat(e.args[1].value))>=2&&ce(a))),o){if(a>2){var s=e.args[0],u=new y("^","pow",[e.args[0].cloneDeep(),new d(a-1)]);e=new y("*","multiply",[s,u])}else e=new y("*","multiply",[e.args[0],e.args[0].cloneDeep()]);i&&("content"===r?t.content=e:t.args[r]=e)}}if("ParenthesisNode"===n)N(e.content,e,"content");else if("ConstantNode"!==n&&"SymbolNode"!==n)for(var c=0;cr&&(t[c]=0),t[c]+=o.cte*("+"===o.oper?1:-1),void(r=Math.max(c,r))}o.cte=c,""===o.fire&&(t[0]+=o.cte*("+"===o.oper?1:-1))}}(e,null,{cte:1,oper:"+",fire:""});for(var i,a=!0,o=r=t.length-1;o>=0;o--)if(0!==t[o]){var s=new d(a?t[o]:Math.abs(t[o])),u=t[o]<0?"-":"+";if(o>0){var c=new v(n);if(o>1){var l=new d(o);c=new y("^","pow",[c,l])}s=-1===t[o]&&a?new y("-","unaryMinus",[c]):1===Math.abs(t[o])?c:new y("*","multiply",[s,c])}i=a?s:"+"===u?new y("+","add",[i,s]):new y("-","subtract",[i,s]),a=!1}return a?new d(0):i}})),gr="parser",vr=W(gr,["typed","Parser"],(e=>{var{typed:t,Parser:r}=e;return t(gr,{"":function(){return new r}})})),xr=W("derivative",["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:t,config:r,parse:n,simplify:i,equal:a,isZero:o,numeric:s,ConstantNode:u,FunctionNode:c,OperatorNode:l,ParenthesisNode:f,SymbolNode:p}=e,m=t("derivative",{"Node, SymbolNode, Object":function(e,t,r){var n={};d(n,e,t.name);var a=y(e,n);return r.simplify?i(a):a},"Node, SymbolNode":function(e,t){return this(e,t,{simplify:!0})},"string, SymbolNode":function(e,t){return this(n(e),t)},"string, SymbolNode, Object":function(e,t,r){return this(n(e),t,r)},"string, string":function(e,t){return this(n(e),n(t))},"string, string, Object":function(e,t,r){return this(n(e),n(t),r)},"Node, string":function(e,t){return this(e,n(t))},"Node, string, Object":function(e,t,r){return this(e,n(t),r)}});m._simplify=!0,m.toTex=function(e){return h.apply(null,e.args)};var h=t("_derivTex",{"Node, SymbolNode":function(e,t){return B(e)&&"string"===L(e.value)?h(n(e.value).toString(),t.toString(),1):h(e.toString(),t.toString(),1)},"Node, ConstantNode":function(e,t){if("string"===L(t.value))return h(e,n(t.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(e,t,r){return h(e.toString(),t.name,r.value)},"string, string, number":function(e,t,r){return(1===r?"{d\\over d"+t+"}":"{d^{"+r+"}\\over d"+t+"^{"+r+"}}")+"\\left[".concat(e,"\\right]")}}),d=t("constTag",{"Object, ConstantNode, string":function(e,t){return e[t]=!0,!0},"Object, SymbolNode, string":function(e,t,r){return t.name!==r&&(e[t]=!0,!0)},"Object, ParenthesisNode, string":function(e,t,r){return d(e,t.content,r)},"Object, FunctionAssignmentNode, string":function(e,t,r){return-1===t.params.indexOf(r)?(e[t]=!0,!0):d(e,t.expr,r)},"Object, FunctionNode | OperatorNode, string":function(e,t,r){if(t.args.length>0){for(var n=d(e,t.args[0],r),i=1;i0){var n=e.args.filter((function(e){return void 0===t[e]})),i=1===n.length?n[0]:new l("*","multiply",n),s=r.concat(y(i,t));return new l("*","multiply",s)}return new l("+","add",e.args.map((function(r){return new l("*","multiply",e.args.map((function(e){return e===r?y(e,t):e.clone()})))})))}if("/"===e.op&&e.isBinary()){var u=e.args[0],f=e.args[1];return void 0!==t[f]?new l("/","divide",[y(u,t),f]):void 0!==t[u]?new l("*","multiply",[new l("-","unaryMinus",[u]),new l("/","divide",[y(f,t),new l("^","pow",[f.clone(),g(2)])])]):new l("/","divide",[new l("-","subtract",[new l("*","multiply",[y(u,t),f.clone()]),new l("*","multiply",[u.clone(),y(f,t)])]),new l("^","pow",[f.clone(),g(2)])])}if("^"===e.op&&e.isBinary()){var p=e.args[0],m=e.args[1];if(void 0!==t[p])return B(p)&&(o(p.value)||a(p.value,1))?g(0):new l("*","multiply",[e,new l("*","multiply",[new c("log",[p.clone()]),y(m.clone(),t)])]);if(void 0!==t[m]){if(B(m)){if(o(m.value))return g(0);if(a(m.value,1))return y(p,t)}var h=new l("^","pow",[p.clone(),new l("-","subtract",[m,g(1)])]);return new l("*","multiply",[m.clone(),new l("*","multiply",[y(p,t),h])])}return new l("*","multiply",[new l("^","pow",[p.clone(),m.clone()]),new l("+","add",[new l("*","multiply",[y(p,t),new l("/","divide",[m.clone(),p.clone()])]),new l("*","multiply",[y(m,t),new c("log",[p.clone()])])])])}throw new Error('Operator "'+e.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function g(e,t){return new u(s(e,t||r.number))}return m})),br="apply",wr=W(br,["typed","isInteger"],(e=>{var{typed:t,isInteger:r}=e;return t(br,{"Array | Matrix, number | BigNumber, function":function(e,t,n){if(!r(t))throw new TypeError("Integer number expected for dimension");var i=Array.isArray(e)?je(e):e.size();if(t<0||t>=i.length)throw new Pe(t,i.length);return f(e)?e.create(Nr(e.valueOf(),t,n)):Nr(e,t,n)}})}));function Nr(e,t,r){var n,i,a;if(t<=0){if(Array.isArray(e[0])){for(a=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r{var{typed:t,isInteger:r}=e,n=wr({typed:t,isInteger:r});return t("apply",{"...any":function(e){var t=e[1];i(t)?e[1]=t-1:a(t)&&(e[1]=t.minus(1));try{return n.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0});function Sr(e){var t=0,r=1,n=Object.create(null),i=Object.create(null),a=0,o=function(e){var o=i[e];if(o&&(delete n[o],delete i[e],--t,r===o)){if(!t)return a=0,void(r=1);for(;!hasOwnProperty.call(n,++r););}};return e=Math.abs(e),{hit:function(s){var u=i[s],c=++a;if(n[c]=s,i[s]=c,!u){if(++t<=e)return;return s=n[r],o(s),s}if(delete n[u],r===u)for(;!hasOwnProperty.call(n,++r););},delete:o,clear:function(){t=a=0,r=1,n=Object.create(null),i=Object.create(null)}}}function Er(e){var{hasher:t,limit:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r=null==r?Number.POSITIVE_INFINITY:r,t=null==t?JSON.stringify:t,function n(){"object"!=typeof n.cache&&(n.cache={values:new Map,lru:Sr(r||Number.POSITIVE_INFINITY)});for(var i=[],a=0;a{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=P(e[1])||q(e[1])?e[1].compile().evaluate(r):Or(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("filter",{"Array, function":_r,"Matrix, function":function(e,t){return e.create(_r(e.toArray(),t))},"Array, RegExp":it,"Matrix, RegExp":function(e,t){return e.create(it(e.toArray(),t))}});return r}),{isTransformFunction:!0});function _r(e,t){var r=Ar(t);return nt(e,(function(e,n,i){return 1===r?t(e):2===r?t(e,[n+1]):t(e,[n+1],i)}))}var Tr=W("map",["typed"],(e=>{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=P(e[1])||q(e[1])?e[1].compile().evaluate(r):Or(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("map",{"Array, function":function(e,t){return Br(e,t,e)},"Matrix, function":function(e,t){return e.create(Br(e.valueOf(),t,e))}});return r}),{isTransformFunction:!0});function Br(e,t,r){var n=Ar(t);return function e(i,a){return Array.isArray(i)?tt(i,(function(t,r){return e(t,a.concat(r+1))})):1===n?t(i):2===n?t(i,a):t(i,a,r)}(e,[])}var qr=W("forEach",["typed"],(e=>{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=P(e[1])||q(e[1])?e[1].compile().evaluate(r):Or(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("forEach",{"Array | Matrix, function":function(e,t){var r=Ar(t);!function n(i,a){Array.isArray(i)?rt(i,(function(e,t){n(e,a.concat(t+1))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e.valueOf(),[])}});return r}),{isTransformFunction:!0}),zr="subset",Dr=W(zr,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t(zr,{"Array, Index":function(e,t){var n=r(e).subset(t);return t.isScalar()?n:n.valueOf()},"Matrix, Index":function(e,t){return e.subset(t)},"Object, Index":Rr,"string, Index":Ir,"Array, Index, any":function(e,t,n){return r($(e)).subset(t,n,void 0).valueOf()},"Array, Index, any, any":function(e,t,n,i){return r($(e)).subset(t,n,i).valueOf()},"Matrix, Index, any":function(e,t,r){return e.clone().subset(t,r)},"Matrix, Index, any, any":function(e,t,r,n){return e.clone().subset(t,r,n)},"string, Index, string":kr,"string, Index, string, string":kr,"Object, Index, any":Fr})}));function Ir(e,t){if(!y(t))throw new TypeError("Index expected");if(1!==t.size().length)throw new Ue(t.size().length,1);var r=e.length;$e(t.min()[0],r),$e(t.max()[0],r);var n=t.dimension(0),i="";return n.forEach((function(t){i+=e.charAt(t)})),i}function kr(e,t,r,n){if(!t||!0!==t.isIndex)throw new TypeError("Index expected");if(1!==t.size().length)throw new Ue(t.size().length,1);if(void 0!==n){if("string"!=typeof n||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";var i=t.dimension(0);if(i.size()[0]!==r.length)throw new Ue(i.size()[0],r.length);var a=e.length;$e(t.min()[0]),$e(t.max()[0]);for(var o=[],s=0;sa)for(var u=a-1,c=o.length;u{var{typed:t,matrix:r}=e,n=Dr({typed:t,matrix:r});return t("subset",{"...any":function(e){try{return n.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Pr=W("index",["Index"],(e=>{var{Index:t}=e;return function(){for(var e=[],r=0,n=arguments.length;r0?0:2;else if(o&&!0===o.isSet)o=o.map((function(e){return e-1}));else if(l(o)||f(o))o=o.map((function(e){return e-1}));else if(i(o))o--;else if(a(o))o=o.toNumber()-1;else if("string"!=typeof o)throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");e[r]=o}var s=new t;return t.apply(s,e),s}}),{isTransformFunction:!0}),jr="concat",Lr=W(jr,["typed","matrix","isInteger"],(e=>{var{typed:t,matrix:r,isInteger:n}=e;return t(jr,{"...Array | Matrix | number | BigNumber":function(e){var t,o,s=e.length,u=-1,c=!1,l=[];for(t=0;t0&&u>o)throw new Pe(u,o+1)}else{var m=$(p).valueOf(),h=je(m);if(l[t]=m,o=u,u=h.length-1,t>0&&u!==o)throw new Ue(o+1,u+1)}}if(0===l.length)throw new SyntaxError("At least one matrix expected");for(var d=l.shift();l.length;)d=Hr(d,l.shift(),u,0);return c?r(d):d},"...string":function(e){return e.join("")}})}));function Hr(e,t,r,n){if(n{var{typed:t,matrix:r,isInteger:n}=e,o=Lr({typed:t,matrix:r,isInteger:n});return t("concat",{"...any":function(e){var t=e.length-1,r=e[t];i(r)?e[t]=r-1:a(r)&&(e[t]=r.minus(1));try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0});function Gr(e,t,r){var n;return-1!==String(e).indexOf("Unexpected type")?(n=arguments.length>2?" (type: "+L(r)+", value: "+JSON.stringify(r)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+n)):-1!==String(e).indexOf("complex numbers")?(n=arguments.length>2?" (type: "+L(r)+", value: "+JSON.stringify(r)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+n)):e}var Vr=W("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:r,numeric:n,larger:i}=e;return t("max",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){return Gt(e,t.valueOf(),a)},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function max");return o(e)}});function a(e,t){try{return i(e,t)?e:t}catch(e){throw Gr(e,"max",t)}}function o(e){var t;if(Ht(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw Gr(t,"max",e)}})),void 0===t)throw new Error("Cannot calculate max of an empty array");return"string"==typeof t&&(t=n(t,r.number)),t}}));function Zr(e){if(2===e.length&&p(e[0])){var t=(e=e.slice())[1];i(t)?e[1]=t-1:a(t)&&(e[1]=t.minus(1))}return e}var Wr=W("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:r,numeric:n,larger:i}=e,a=Vr({typed:t,config:r,numeric:n,larger:i});return t("max",{"...any":function(e){e=Zr(e);try{return a.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Jr=W("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:r,numeric:n,smaller:i}=e;return t("min",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){return Gt(e,t.valueOf(),a)},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function min");return o(e)}});function a(e,t){try{return i(e,t)?e:t}catch(e){throw Gr(e,"min",t)}}function o(e){var t;if(Ht(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw Gr(t,"min",e)}})),void 0===t)throw new Error("Cannot calculate min of an empty array");return"string"==typeof t&&(t=n(t,r.number)),t}})),Yr=W("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:r,numeric:n,smaller:i}=e,a=Jr({typed:t,config:r,numeric:n,smaller:i});return t("min",{"...any":function(e){e=Zr(e);try{return a.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Xr=W("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:r,add:n,numeric:i}=e;return t("sum",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){try{return Gt(e,t,n)}catch(e){throw Gr(e,"sum")}},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function sum");return a(e)}});function a(e){var t;return Ht(e,(function(e){try{t=void 0===t?e:n(t,e)}catch(t){throw Gr(t,"sum",e)}})),void 0===t&&(t=i(0,r.number)),"string"==typeof t&&(t=i(t,r.number)),t}})),Qr=W("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:r,add:n,numeric:i}=e,a=Xr({typed:t,config:r,add:n,numeric:i});return t("sum",{"...any":function(e){e=Zr(e);try{return a.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Kr="column",en=W(Kr,["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e;return t(Kr,{"Matrix, number":a,"Array, number":function(e,t){return a(n($(e)),t).valueOf()}});function a(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");$e(t,e.size()[1]);var n=i(0,e.size()[0]),a=new r(n,t);return e.subset(a)}})),tn=W("column",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:a}=e,o=en({typed:t,Index:r,matrix:n,range:a});return t("column",{"...any":function(e){var t=e.length-1,r=e[t];i(r)&&(e[t]=r-1);try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),rn="range",nn=W(rn,["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u}=e;return t(rn,{string:l,"string, boolean":l,"number, number":function(e,t){return c(f(e,t,1))},"number, number, number":function(e,t,r){return c(f(e,t,r))},"number, number, boolean":function(e,t,r){return c(r?p(e,t,1):f(e,t,1))},"number, number, number, boolean":function(e,t,r,n){return c(n?p(e,t,r):f(e,t,r))},"BigNumber, BigNumber":function(e,t){return c(m(e,t,new(0,e.constructor)(1)))},"BigNumber, BigNumber, BigNumber":function(e,t,r){return c(m(e,t,r))},"BigNumber, BigNumber, boolean":function(e,t,r){var n=e.constructor;return c(r?h(e,t,new n(1)):m(e,t,new n(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,r,n){return c(n?h(e,t,r):m(e,t,r))}});function c(e){return"Matrix"===r.matrix?n?n(e):fr():e}function l(e,t){var n=function(e){var t=e.split(":").map((function(e){return Number(e)}));if(t.some((function(e){return isNaN(e)})))return null;switch(t.length){case 2:return{start:t[0],end:t[1],step:1};case 3:return{start:t[0],end:t[2],step:t[1]};default:return null}}(e);if(!n)throw new SyntaxError('String "'+e+'" is no valid range');return"BigNumber"===r.number?(void 0===i&&cr(),c((t?h:m)(i(n.start),i(n.end),i(n.step)))):c((t?p:f)(n.start,n.end,n.step))}function f(e,t,r){var n=[],i=e;if(r>0)for(;a(i,t);)n.push(i),i+=r;else if(r<0)for(;s(i,t);)n.push(i),i+=r;return n}function p(e,t,r){var n=[],i=e;if(r>0)for(;o(i,t);)n.push(i),i+=r;else if(r<0)for(;u(i,t);)n.push(i),i+=r;return n}function m(e,t,r){var n=i(0),o=[],u=e;if(r.gt(n))for(;a(u,t);)o.push(u),u=u.plus(r);else if(r.lt(n))for(;s(u,t);)o.push(u),u=u.plus(r);return o}function h(e,t,r){var n=i(0),a=[],s=e;if(r.gt(n))for(;o(s,t);)a.push(s),s=s.plus(r);else if(r.lt(n))for(;u(s,t);)a.push(s),s=s.plus(r);return a}})),an=W("range",["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u}=e,c=nn({typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u});return t("range",{"...any":function(e){return"boolean"!=typeof e[e.length-1]&&e.push(!0),c.apply(null,e)}})}),{isTransformFunction:!0}),on="diff",sn=W(on,["typed","matrix","subtract","number"],(e=>{var{typed:t,matrix:r,subtract:n,number:i}=e;return t(on,{"Array | Matrix":function(e){return f(e)?r(o(e.toArray())):o(e)},"Array | Matrix, number":function(e,t){if(!ce(t))throw new RangeError("Dimension must be a whole number");return f(e)?r(a(e.toArray(),t)):a(e,t)},"Array | Matrix, BigNumber":function(e,t){return this(e,i(t))}});function a(e,t){if(f(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError("Array/Matrix does not have that many dimensions");if(t>0){var r=[];return e.forEach((e=>{r.push(a(e,t-1))})),r}if(0===t)return o(e);throw RangeError("Cannot have negative dimension")}function o(e){var t=[],r=e.length;if(r<2)return e;for(var n=1;n{var{typed:t,matrix:r,subtract:n,number:i,bignumber:a}=e,o=sn({typed:t,matrix:r,subtract:n,number:i,bignumber:a});return t(un,{"...any":function(e){e=Zr(e);try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),ln=W("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e;return t("row",{"Matrix, number":a,"Array, number":function(e,t){return a(n($(e)),t).valueOf()}});function a(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");$e(t,e.size()[0]);var n=i(0,e.size()[1]),a=new r(t,n);return e.subset(a)}})),fn=W("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:a}=e,o=ln({typed:t,Index:r,matrix:n,range:a});return t("row",{"...any":function(e){var t=e.length-1,r=e[t];i(r)&&(e[t]=r-1);try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),pn="mean",mn=W(pn,["typed","add","divide"],(e=>{var{typed:t,add:r,divide:n}=e;return t(pn,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,t){try{var i=Gt(e,t,r),a=Array.isArray(e)?je(e):e.size();return n(i,a[t])}catch(e){throw Gr(e,"mean")}},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function mean");return i(e)}});function i(e){var t,i=0;if(Ht(e,(function(e){try{t=void 0===t?e:r(t,e),i++}catch(t){throw Gr(t,"mean",e)}})),0===i)throw new Error("Cannot calculate the mean of an empty array");return n(t,i)}})),hn=W("mean",["typed","add","divide"],(e=>{var{typed:t,add:r,divide:n}=e,i=mn({typed:t,add:r,divide:n});return t("mean",{"...any":function(e){e=Zr(e);try{return i.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),dn="unbiased",yn="variance",gn=W(yn,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:r,subtract:n,multiply:i,divide:o,apply:s,isNaN:u}=e;return t(yn,{"Array | Matrix":function(e){return c(e,dn)},"Array | Matrix, string":c,"Array | Matrix, number | BigNumber":function(e,t){return l(e,t,dn)},"Array | Matrix, number | BigNumber, string":l,"...":function(e){return c(e,dn)}});function c(e,t){var s,c=0;if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Ht(e,(function(e){try{s=void 0===s?e:r(s,e),c++}catch(t){throw Gr(t,"variance",e)}})),0===c)throw new Error("Cannot calculate variance of an empty array");var l=o(s,c);if(s=void 0,Ht(e,(function(e){var t=n(e,l);s=void 0===s?i(t,t):r(s,i(t,t))})),u(s))return s;switch(t){case"uncorrected":return o(s,c);case"biased":return o(s,c+1);case"unbiased":var f=a(s)?s.mul(0):0;return 1===c?f:o(s,c-1);default:throw new Error('Unknown normalization "'+t+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function l(e,t,r){try{if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return s(e,t,(e=>c(e,r)))}catch(e){throw Gr(e,"variance")}}})),vn="variance",xn=W(vn,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:r,subtract:n,multiply:i,divide:a,apply:o,isNaN:s}=e,u=gn({typed:t,add:r,subtract:n,multiply:i,divide:a,apply:o,isNaN:s});return t(vn,{"...any":function(e){e=Zr(e);try{return u.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),bn=W("std",["typed","sqrt","variance"],(e=>{var{typed:t,sqrt:r,variance:n}=e;return t("std",{"Array | Matrix":i,"Array | Matrix, string":i,"Array | Matrix, number | BigNumber":i,"Array | Matrix, number | BigNumber, string":i,"...":function(e){return i(e)}});function i(e,t){if(0===e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{return r(n.apply(null,arguments))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf(" variance")?new TypeError(e.message.replace(" variance"," std")):e}}})),wn=W("std",["typed","sqrt","variance"],(e=>{var{typed:t,sqrt:r,variance:n}=e,i=bn({typed:t,sqrt:r,variance:n});return t("std",{"...any":function(e){e=Zr(e);try{return i.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Nn=W("ResultSet",[],(()=>{function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=t||[]}return e.prototype.type="ResultSet",e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},e.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},e.fromJSON=function(t){return new e(t.entries)},e}),{isClass:!0}),Mn=r(977),Sn=W("Complex",[],(()=>(Mn.prototype.type="Complex",Mn.prototype.isComplex=!0,Mn.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Mn.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Mn.prototype.format=function(e){var t=this.im,r=this.re,n=ge(this.re,e),a=ge(this.im,e),o=i(e)?e:e?e.precision:null;if(null!==o){var s=Math.pow(10,-o);Math.abs(r/t)t.re?1:e.ret.im?1:e.im{function e(t,r,n){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var i=null!=t,o=null!=r,s=null!=n;if(i)if(a(t))t=t.toNumber();else if("number"!=typeof t)throw new TypeError("Parameter start must be a number");if(o)if(a(r))r=r.toNumber();else if("number"!=typeof r)throw new TypeError("Parameter end must be a number");if(s)if(a(n))n=n.toNumber();else if("number"!=typeof n)throw new TypeError("Parameter step must be a number");this.start=i?parseFloat(t):0,this.end=o?parseFloat(r):0,this.step=s?parseFloat(n):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(t){if("string"!=typeof t)return null;var r=t.split(":").map((function(e){return parseFloat(e)}));if(r.some((function(e){return isNaN(e)})))return null;switch(r.length){case 2:return new e(r[0],r[1]);case 3:return new e(r[0],r[2],r[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var e=0,t=this.start,r=this.step,n=this.end-t;return le(r)===le(n)?e=Math.ceil(n/r):0===n&&(e=0),isNaN(e)&&(e=0),[e]},e.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},e.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},e.prototype.forEach=function(e){var t=this.start,r=this.step,n=this.end,i=0;if(r>0)for(;tn;)e(t,[i],this),t+=r,i++},e.prototype.map=function(e){var t=[];return this.forEach((function(r,n,i){t[n[0]]=e(r,n,i)})),t},e.prototype.toArray=function(){var e=[];return this.forEach((function(t,r){e[r[0]]=t})),e},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(e){var t=ge(this.start,e);return 1!==this.step&&(t+=":"+ge(this.step,e)),t+":"+ge(this.end,e)},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},e.fromJSON=function(t){return new e(t.start,t.end,t.step)},e}),{isClass:!0}),An=Er((function(e){return new e(1).exp()}),{hasher:Tn}),On=Er((function(e){return new e(1).plus(new e(5).sqrt()).div(2)}),{hasher:Tn}),Cn=Er((function(e){return e.acos(-1)}),{hasher:Tn}),_n=Er((function(e){return Cn(e).times(2)}),{hasher:Tn});function Tn(e){return e[0].precision}var Bn=Math.PI,qn=2*Math.PI,zn=Math.E,Dn=W("true",[],(()=>!0)),In=W("false",[],(()=>!1)),kn=W("null",[],(()=>null)),Rn=Xn("Infinity",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1/0):1/0})),Fn=Xn("NaN",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(NaN):NaN})),Un=Xn("pi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?Cn(r):Bn})),Pn=Xn("tau",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?_n(r):qn})),jn=Xn("e",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?An(r):zn})),Ln=Xn("phi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?On(r):1.618033988749895})),Hn=Xn("LN2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(2).ln():Math.LN2})),$n=Xn("LN10",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(10).ln():Math.LN10})),Gn=Xn("LOG2E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1).div(new r(2).ln()):Math.LOG2E})),Vn=Xn("LOG10E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1).div(new r(10).ln()):Math.LOG10E})),Zn=Xn("SQRT1_2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r("0.5").sqrt():Math.SQRT1_2})),Wn=Xn("SQRT2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(2).sqrt():Math.SQRT2})),Jn=Xn("i",["Complex"],(e=>{var{Complex:t}=e;return t.I})),Yn=W("version",[],(()=>"9.4.1"));function Xn(e,t,r){return W(e,t,r,{recreateOnConfigChange:!0})}var Qn=r(776),Kn=W("BigNumber",["?on","config"],(e=>{var{on:t,config:r}=e,n=Qn.clone({precision:r.precision,modulo:9});return n.prototype.type="BigNumber",n.prototype.isBigNumber=!0,n.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},n.fromJSON=function(e){return new n(e.value)},t&&t("config",(function(e,t){e.precision!==t.precision&&n.config({precision:e.precision})})),n}),{isClass:!0}),ei=W("Matrix",[],(()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(e,t,r){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(e,t,r){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e}),{isClass:!0}),ti=W("replacer",[],(()=>function(e,t){return"number"!=typeof t||isFinite(t)&&!isNaN(t)?t:{mathjs:"number",value:String(t)}})),ri=Qi("speedOfLight","299792458","m s^-1"),ni=Qi("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),ii=Qi("planckConstant","6.62607015e-34","J s"),ai=Qi("reducedPlanckConstant","1.0545718176461565e-34","J s"),oi=Qi("magneticConstant","1.25663706212e-6","N A^-2"),si=Qi("electricConstant","8.8541878128e-12","F m^-1"),ui=Qi("vacuumImpedance","376.730313667","ohm"),ci=Qi("coulomb","8.987551792261171e9","N m^2 C^-2"),li=Qi("elementaryCharge","1.602176634e-19","C"),fi=Qi("bohrMagneton","9.2740100783e-24","J T^-1"),pi=Qi("conductanceQuantum","7.748091729863649e-5","S"),mi=Qi("inverseConductanceQuantum","12906.403729652257","ohm"),hi=Qi("magneticFluxQuantum","2.0678338484619295e-15","Wb"),di=Qi("nuclearMagneton","5.0507837461e-27","J T^-1"),yi=Qi("klitzing","25812.807459304513","ohm"),gi=Qi("bohrRadius","5.29177210903e-11","m"),vi=Qi("classicalElectronRadius","2.8179403262e-15","m"),xi=Qi("electronMass","9.1093837015e-31","kg"),bi=Qi("fermiCoupling","1.1663787e-5","GeV^-2"),wi=Ki("fineStructure",.0072973525693),Ni=Qi("hartreeEnergy","4.3597447222071e-18","J"),Mi=Qi("protonMass","1.67262192369e-27","kg"),Si=Qi("deuteronMass","3.3435830926e-27","kg"),Ei=Qi("neutronMass","1.6749271613e-27","kg"),Ai=Qi("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),Oi=Qi("rydberg","10973731.568160","m^-1"),Ci=Qi("thomsonCrossSection","6.6524587321e-29","m^2"),_i=Ki("weakMixingAngle",.2229),Ti=Ki("efimovFactor",22.7),Bi=Qi("atomicMass","1.66053906660e-27","kg"),qi=Qi("avogadro","6.02214076e23","mol^-1"),zi=Qi("boltzmann","1.380649e-23","J K^-1"),Di=Qi("faraday","96485.33212331001","C mol^-1"),Ii=Qi("firstRadiation","3.7417718521927573e-16","W m^2"),ki=Qi("loschmidt","2.686780111798444e25","m^-3"),Ri=Qi("gasConstant","8.31446261815324","J K^-1 mol^-1"),Fi=Qi("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),Ui=Qi("molarVolume","0.022413969545014137","m^3 mol^-1"),Pi=Ki("sackurTetrode",-1.16487052358),ji=Qi("secondRadiation","0.014387768775039337","m K"),Li=Qi("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),Hi=Qi("wienDisplacement","2.897771955e-3","m K"),$i=Qi("molarMass","0.99999999965e-3","kg mol^-1"),Gi=Qi("molarMassC12","11.9999999958e-3","kg mol^-1"),Vi=Qi("gravity","9.80665","m s^-2"),Zi=Qi("planckLength","1.616255e-35","m"),Wi=Qi("planckMass","2.176435e-8","kg"),Ji=Qi("planckTime","5.391245e-44","s"),Yi=Qi("planckCharge","1.87554603778e-18","C"),Xi=Qi("planckTemperature","1.416785e+32","K");function Qi(e,t,r){return W(e,["config","Unit","BigNumber"],(e=>{var{config:n,Unit:i,BigNumber:a}=e,o=new i("BigNumber"===n.number?new a(t):parseFloat(t),r);return o.fixPrefix=!0,o}))}function Ki(e,t){return W(e,["config","BigNumber"],(e=>{var{config:r,BigNumber:n}=e;return"BigNumber"===r.number?new n(t):t}))}var ea=r(628),ta=W("Fraction",[],(()=>(ea.prototype.type="Fraction",ea.prototype.isFraction=!0,ea.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},ea.fromJSON=function(e){return new ea(e)},ea)),{isClass:!0}),ra=W("DenseMatrix",["Matrix"],(e=>{var{Matrix:t}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!c(t))throw new Error("Invalid datatype: "+t);if(f(e))"DenseMatrix"===e.type?(this._data=$(e._data),this._size=$(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&l(e.data)&&l(e.size))this._data=e.data,this._size=e.size,He(this._data,this._size),this._datatype=t||e.datatype;else if(l(e))this._data=d(e),this._size=je(this._data),He(this._data,this._size),this._datatype=t;else{if(e)throw new TypeError("Unsupported type of data ("+L(e)+")");this._data=[],this._size=[0],this._datatype=t}}function n(e,t){if(!y(t))throw new TypeError("Invalid index");if(t.isScalar())return e.get(t.min());var n=t.size();if(n.length!==e._size.length)throw new Ue(n.length,e._size.length);for(var i=t.min(),a=t.max(),s=0,u=e._size.length;s");h(e,t.max().map((function(e){return e+1})),n);var l=a.length;u(e._data,t,r,l,0)}return e}function u(e,t,r,n,i){var a=i===n-1,o=t.dimension(i);a?o.forEach((function(t,n){$e(t),e[t]=r[n[0]]})):o.forEach((function(a,o){$e(a),u(e[a],t,r[o[0]],n,i+1)}))}function m(e,t,r){if(0===t.length){for(var n=e._data;l(n);)n=n[0];return n}return e._size=t.slice(0),e._data=Ge(e._data,e._size,r),e}function h(e,t,r){for(var n=e._size.slice(0),i=!1;n.lengthn[a]&&(n[a]=t[a],i=!0);i&&m(e,n,r)}function d(e){for(var t=0,r=e.length;tArray.isArray(e)&&1===e.length?e[0]:e));return m(r?this.clone():this,n,t)},r.prototype.reshape=function(e,t){var r=t?this.clone():this;r._data=Ze(r._data,e);var n=r._size.reduce(((e,t)=>e*t));return r._size=We(e,n),r},r.prototype.clone=function(){return new r({data:$(this._data),size:$(this._size),datatype:this._datatype})},r.prototype.size=function(){return this._size.slice(0)},r.prototype.map=function(e){var t=this,n=function r(n,i){return l(n)?n.map((function(e,t){return r(e,i.concat(t))})):e(n,i,t)}(this._data,[]);return new r(n,void 0!==this._datatype?ut(n,L):void 0)},r.prototype.forEach=function(e){var t=this;!function r(n,i){l(n)?n.forEach((function(e,t){r(e,i.concat(t))})):e(n,i,t)}(this._data,[])},r.prototype[Symbol.iterator]=function*(){yield*function*e(t,r){if(l(t))for(var n=0;n[e[n]]));t.push(new r(a,e._datatype))},o=0;o0?e:0,n=e<0?-e:0,o=this._size[0],s=this._size[1],u=Math.min(o-n,s-t),c=[],l=0;l0?n:0,c=n<0?-n:0,p=e[0],m=e[1],h=Math.min(p-c,m-u);if(l(t)){if(t.length!==h)throw new Error("Invalid value array length");s=function(e){return t[e]}}else if(f(t)){var d=t.size();if(1!==d.length||d[0]!==h)throw new Error("Invalid matrix length");s=function(e){return t.get([e])}}else s=function(){return t};o||(o=a(s(0))?s(0).mul(0):0);var y=[];if(e.length>0){y=Ge(y,e,o);for(var g=0;g15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new t(e)}},{from:"number",to:"Complex",convert:function(e){return r||sa(e),new r(e,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(e){return r||sa(e),new r(e.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(e){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(e){return r||sa(e),new r(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){p||ua(e);var t=new p(e);if(t.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return t}},{from:"string",to:"number",convert:function(e){var t=Number(e);if(isNaN(t))throw new Error('Cannot convert "'+e+'" to a number');return t}},{from:"string",to:"BigNumber",convert:function(e){t||oa(e);try{return new t(e)}catch(t){throw new Error('Cannot convert "'+e+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(e){p||ua(e);try{return new p(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(e){r||sa(e);try{return new r(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return t||oa(e),new t(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return p||ua(e),new p(+e)}},{from:"boolean",to:"string",convert:function(e){return String(e)}},{from:"Array",to:"Matrix",convert:function(e){return n||function(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}(),new n(e)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}],L}));function oa(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function sa(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function ua(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var ca="isInteger",la=W(ca,["typed"],(e=>{var{typed:t}=e;return t(ca,{number:ce,BigNumber:function(e){return e.isInt()},Fraction:function(e){return 1===e.d&&isFinite(e.n)},"Array | Matrix":function(e){return $t(e,this)}})})),fa="isNumeric",pa=W(fa,["typed"],(e=>{var{typed:t}=e;return t(fa,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(e){return $t(e,this)}})})),ma="number";function ha(e){return e<0}function da(e){return e>0}function ya(e){return 0===e}function ga(e){return Number.isNaN(e)}ha.signature=ma,da.signature=ma,ya.signature=ma,ga.signature=ma;var va="isPositive",xa=W(va,["typed"],(e=>{var{typed:t}=e;return t(va,{number:da,BigNumber:function(e){return!e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s>0&&e.n>0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),ba="isNaN",wa=W(ba,["typed"],(e=>{var{typed:t}=e;return t(ba,{number:ga,BigNumber:function(e){return e.isNaN()},Fraction:function(e){return!1},Complex:function(e){return e.isNaN()},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":function(e){return $t(e,Number.isNaN)}})}));function Na(e,t,r){if(null==r)return e.eq(t);if(e.eq(t))return!0;if(e.isNaN()||t.isNaN())return!1;if(e.isFinite()&&t.isFinite()){var n=e.minus(t).abs();if(n.isZero())return!0;var i=e.constructor.max(e.abs(),t.abs());return n.lte(i.times(r))}return!1}var Ma="equalScalar",Sa=W(Ma,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(Ma,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return e.equals(t)},"Complex, Complex":function(e,t){return function(e,t,r){return Se(e.re,t.re,r)&&Se(e.im,t.im,r)}(e,t,r.epsilon)},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)}})}));W(Ma,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(Ma,{"number, number":function(e,t){return Se(e,t,r.epsilon)}})}));var Ea=W("number",["typed"],(e=>{var{typed:t}=e,r=t("number",{"":function(){return 0},number:function(e){return e},string:function(e){if("NaN"===e)return NaN;var t,r,n=(r=(t=e).match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/))?{input:t,radix:{"0b":2,"0o":8,"0x":16}[r[1]],integerPart:r[2],fractionalPart:r[3]}:null;if(n)return function(e){for(var t=parseInt(e.integerPart,e.radix),r=0,n=0;n2**i-1)throw new SyntaxError('String "'.concat(e,'" is out of range'));o>=2**(i-1)&&(o-=2**i)}return o},BigNumber:function(e){return e.toNumber()},Fraction:function(e){return e.valueOf()},Unit:function(e){throw new Error("Second argument with valueless unit expected")},null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":function(e){return $t(e,this)}});return r.fromJSON=function(e){return parseFloat(e.value)},r})),Aa="boolean",Oa=W(Aa,["typed"],(e=>{var{typed:t}=e;return t(Aa,{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(e){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;var r=Number(e);if(""!==e&&!isNaN(r))return!!r;throw new Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":function(e){return $t(e,this)}})})),Ca=W("complex",["typed","Complex"],(e=>{var{typed:t,Complex:r}=e;return t("complex",{"":function(){return r.ZERO},number:function(e){return new r(e,0)},"number, number":function(e,t){return new r(e,t)},"BigNumber, BigNumber":function(e,t){return new r(e.toNumber(),t.toNumber())},Fraction:function(e){return new r(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return r(e)},null:function(e){return r(0)},Object:function(e){if("re"in e&&"im"in e)return new r(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new r(e);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(e){return $t(e,this)}})})),_a="splitUnit",Ta=W(_a,["typed"],(e=>{var{typed:t}=e;return t(_a,{"Unit, Array":function(e,t){return e.splitUnit(t)}})})),Ba="number",qa="number, number";function za(e){return Math.abs(e)}function Da(e,t){return e+t}function Ia(e,t){return e*t}function ka(e){return-e}function Ra(e){return e}function Fa(e){return he(e)}function Ua(e){return Math.ceil(e)}function Pa(e){return e*e*e}function ja(e){return Math.exp(e)}function La(e){return de(e)}function Ha(e,t){if(!ce(e)||!ce(t))throw new Error("Parameters in function gcd must be integer numbers");for(var r;0!==t;)r=e%t,e=t,t=r;return e<0?-e:e}function $a(e,t){if(!ce(e)||!ce(t))throw new Error("Parameters in function lcm must be integer numbers");if(0===e||0===t)return 0;for(var r,n=e*t;0!==t;)t=e%(r=t),e=r;return Math.abs(n/e)}function Ga(e){return Math.log(e)}function Va(e){return pe(e)}function Za(e){return fe(e)}function Wa(e,t){if(t>0)return e-t*Math.floor(e/t);if(0===t)return e;throw new Error("Cannot calculate mod for a negative divisor")}function Ja(e,t){var r=t<0;if(r&&(t=-t),0===t)throw new Error("Root must be non-zero");if(e<0&&Math.abs(t)%2!=1)throw new Error("Root must be odd when a is negative.");if(0===e)return r?1/0:0;if(!isFinite(e))return r?0:e;var n=Math.pow(Math.abs(e),1/t);return n=e<0?-n:n,r?1/n:n}function Ya(e){return le(e)}function Xa(e){return e*e}function Qa(e,t){var r,n,i,a=0,o=1,s=1,u=0;if(!ce(e)||!ce(t))throw new Error("Parameters in function xgcd must be integer numbers");for(;t;)i=e-(n=Math.floor(e/t))*t,r=a,a=o-n*a,o=r,r=s,s=u-n*s,u=r,e=t,t=i;return e<0?[-e,-o,-u]:[e,e?o:0,u]}function Ka(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:Math.pow(e,t)}function eo(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return parseFloat(xe(e,t))}za.signature=Ba,Da.signature=qa,Ia.signature=qa,ka.signature=Ba,Ra.signature=Ba,Fa.signature=Ba,Ua.signature=Ba,Pa.signature=Ba,ja.signature=Ba,La.signature=Ba,Ha.signature=qa,$a.signature=qa,Ga.signature=Ba,Va.signature=Ba,Za.signature=Ba,Wa.signature=qa,Ja.signature=qa,Ya.signature=Ba,Xa.signature=Ba,Qa.signature=qa,Ka.signature=qa,eo.signature=qa;var to="unaryPlus",ro=W(to,["typed","config","BigNumber"],(e=>{var{typed:t,config:r,BigNumber:n}=e;return t(to,{number:Ra,Complex:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":function(e){return $t(e,this,!0)},"boolean | string":function(e){return"BigNumber"===r.number?new n(+e):+e}})})),no="cube",io=W(no,["typed"],(e=>{var{typed:t}=e;return t(no,{number:Pa,Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},Fraction:function(e){return e.pow(3)},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.pow(3)}})})),ao="expm1",oo=W(ao,["typed","Complex"],(e=>{var{typed:t,Complex:r}=e;return t(ao,{number:La,Complex:function(e){var t=Math.exp(e.re);return new r(t*Math.cos(e.im)-1,t*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)},"Array | Matrix":function(e){return $t(e,this)}})})),so="log10",uo=W(so,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(so,{number:function(e){return e>=0||r.predictable?Va(e):new n(e,0).log().div(Math.LN10)},Complex:function(e){return new n(e).log().div(Math.LN10)},BigNumber:function(e){return!e.isNegative()||r.predictable?e.log():new n(e.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(e){return $t(e,this)}})})),co=W("multiplyScalar",["typed"],(e=>{var{typed:t}=e;return t("multiplyScalar",{"number, number":Ia,"Complex, Complex":function(e,t){return e.mul(t)},"BigNumber, BigNumber":function(e,t){return e.times(t)},"Fraction, Fraction":function(e,t){return e.mul(t)},"number | Fraction | BigNumber | Complex, Unit":function(e,t){var r=t.clone();return r.value=null===r.value?r._normalize(e):this(r.value,e),r},"Unit, number | Fraction | BigNumber | Complex":function(e,t){var r=e.clone();return r.value=null===r.value?r._normalize(t):this(r.value,t),r},"Unit, Unit":function(e,t){return e.multiply(t)}})})),lo="sign",fo=W(lo,["typed","BigNumber","Fraction","complex"],(e=>{var{typed:t,BigNumber:r,complex:n,Fraction:i}=e;return t(lo,{number:Ya,Complex:function(e){return 0===e.im?n(Ya(e.re)):e.sign()},BigNumber:function(e){return new r(e.cmp(0))},Fraction:function(e){return new i(e.s,1)},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return this(e.value)}})})),po="square",mo=W(po,["typed"],(e=>{var{typed:t}=e;return t(po,{number:Xa,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},Fraction:function(e){return e.mul(e)},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.pow(2)}})}));function ho(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitAnd");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero()||t.eq(-1)||e.eq(t))return e;if(t.isZero()||e.eq(-1))return t;if(!e.isFinite()||!t.isFinite()){if(!e.isFinite()&&!t.isFinite())return e.isNegative()===t.isNegative()?e:new r(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new r(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new r(0):e}return vo(e,t,(function(e,t){return e&t}))}function yo(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var t=e.constructor,r=t.precision;t.config({precision:1e9});var n=e.plus(new t(1));return n.s=-n.s||null,t.config({precision:r}),n}function go(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitOr");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);var n=new r(-1);return e.isZero()||t.eq(n)||e.eq(t)?t:t.isZero()||e.eq(n)?e:e.isFinite()&&t.isFinite()?vo(e,t,(function(e,t){return e|t})):!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?n:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e}function vo(e,t,r){var n,i,a,o,s,u=e.constructor,c=+(e.s<0),l=+(t.s<0);if(c){n=xo(yo(e));for(var f=0;f0;)r(a[--m],o[--h])===d&&(y=y.plus(g)),g=g.times(v);for(;h>0;)r(s,o[--h])===d&&(y=y.plus(g)),g=g.times(v);return u.config({precision:x}),0===d&&(y.s=-y.s),y}function xo(e){for(var t=e.d,r=t[0]+"",n=1;n0)if(++s>c)for(s-=c;s--;)u+="0";else s1&&(null!==l[m+1]&&void 0!==l[m+1]||(l[m+1]=0),l[m+1]+=l[m]>>1,l[m]&=1)}return l.reverse()}function bo(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new r(0);var n=new r(-1);return e.eq(n)?yo(t):t.eq(n)?yo(e):e.isFinite()&&t.isFinite()?vo(e,t,(function(e,t){return e^t})):e.isFinite()||t.isFinite()?new r(e.isNegative()===t.isNegative()?1/0:-1/0):n}function wo(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:e.isFinite()||t.isFinite()?t.lt(55)?e.times(Math.pow(2,t.toNumber())+""):e.times(new r(2).pow(t)):new r(NaN)}function No(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(Math.pow(2,t.toNumber())+"").floor():e.div(new r(2).pow(t)).floor():e.isNegative()?new r(-1):e.isFinite()?new r(0):new r(NaN)}var Mo="number, number";function So(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function bitAnd");return e&t}function Eo(e){if(!ce(e))throw new Error("Integer expected in function bitNot");return~e}function Ao(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function bitOr");return e|t}function Oo(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function bitXor");return e^t}function Co(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function leftShift");return e<>t}function To(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}So.signature=Mo,Eo.signature="number",Ao.signature=Mo,Oo.signature=Mo,Co.signature=Mo,_o.signature=Mo,To.signature=Mo;var Bo="bitNot",qo=W(Bo,["typed"],(e=>{var{typed:t}=e;return t(Bo,{number:Eo,BigNumber:yo,"Array | Matrix":function(e){return $t(e,this)}})})),zo=W("arg",["typed"],(e=>{var{typed:t}=e;return t("arg",{number:function(e){return Math.atan2(0,e)},BigNumber:function(e){return e.constructor.atan2(0,e)},Complex:function(e){return e.arg()},"Array | Matrix":function(e){return $t(e,this)}})})),Do=W("im",["typed"],(e=>{var{typed:t}=e;return t("im",{number:function(e){return 0},BigNumber:function(e){return e.mul(0)},Fraction:function(e){return e.mul(0)},Complex:function(e){return e.im},"Array | Matrix":function(e){return $t(e,this)}})})),Io="number, number";function ko(e){return!e}function Ro(e,t){return!(!e&&!t)}function Fo(e,t){return!!e!=!!t}function Uo(e,t){return!(!e||!t)}ko.signature="number",Ro.signature=Io,Fo.signature=Io,Uo.signature=Io;var Po=W("not",["typed"],(e=>{var{typed:t}=e;return t("not",{number:ko,Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},Unit:function(e){return null===e.value||this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),jo=W("filter",["typed"],(e=>{var{typed:t}=e;return t("filter",{"Array, function":Lo,"Matrix, function":function(e,t){return e.create(Lo(e.toArray(),t))},"Array, RegExp":it,"Matrix, RegExp":function(e,t){return e.create(it(e.toArray(),t))}})}));function Lo(e,t){var r=Ar(t);return nt(e,(function(e,n,i){return 1===r?t(e):2===r?t(e,[n]):t(e,[n],i)}))}var Ho="forEach",$o=W(Ho,["typed"],(e=>{var{typed:t}=e;return t(Ho,{"Array, function":Go,"Matrix, function":function(e,t){return e.forEach(t)}})}));function Go(e,t){var r=Ar(t);!function n(i,a){Array.isArray(i)?rt(i,(function(e,t){n(e,a.concat(t))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e,[])}var Vo=W("map",["typed"],(e=>{var{typed:t}=e;return t("map",{"Array, function":Zo,"Matrix, function":function(e,t){return e.map(t)}})}));function Zo(e,t){var r=Ar(t);return function n(i,a){return Array.isArray(i)?i.map((function(e,t){return n(e,a.concat(t))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e,[])}var Wo=W("erf",["typed"],(e=>{var{typed:t}=e;return t("name",{number:function(e){var t=Math.abs(e);return t>=Ko?le(e):t<=Jo?le(e)*function(e){var t,r=e*e,n=Xo[0][4]*r,i=r;for(t=0;t<3;t+=1)n=(n+Xo[0][t])*r,i=(i+Qo[0][t])*r;return e*(n+Xo[0][3])/(i+Qo[0][3])}(t):t<=4?le(e)*(1-function(e){var t,r=Xo[1][8]*e,n=e;for(t=0;t<7;t+=1)r=(r+Xo[1][t])*e,n=(n+Qo[1][t])*e;var i=(r+Xo[1][7])/(n+Qo[1][7]),a=parseInt(16*e)/16,o=(e-a)*(e+a);return Math.exp(-a*a)*Math.exp(-o)*i}(t)):le(e)*(1-function(e){var t,r=1/(e*e),n=Xo[2][5]*r,i=r;for(t=0;t<4;t+=1)n=(n+Xo[2][t])*r,i=(i+Qo[2][t])*r;var a=r*(n+Xo[2][4])/(i+Qo[2][4]);a=(Yo-a)/e;var o=(e-(r=parseInt(16*e)/16))*(e+r);return Math.exp(-r*r)*Math.exp(-o)*a}(t))},"Array | Matrix":function(e){return $t(e,this)}})})),Jo=.46875,Yo=.5641895835477563,Xo=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],Qo=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],Ko=Math.pow(2,53),es="format",ts=W(es,["typed"],(e=>{var{typed:t}=e;return t(es,{any:De,"any, Object | function | number":De})})),rs=W("oct",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("oct",{"number | BigNumber":function(e){return r(e,{notation:"oct"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"oct",wordSize:t})}})})),ns="print",is=W(ns,["typed"],(e=>{var{typed:t}=e;return t(ns,{"string, Object | Array":as,"string, Object | Array, number | Object":as})}));function as(e,t,r){return e.replace(/\$([\w.]+)/g,(function(e,n){for(var i=n.split("."),a=t[i.shift()];i.length&&void 0!==a;){var o=i.shift();a=o?a[o]:a+"."}return void 0!==a?c(a)?a:De(a,r):e}))}var os="isPrime",ss=W(os,["typed"],(e=>{var{typed:t}=e;return t(os,{number:function(e){if(0*e!=0)return!1;if(e<=3)return e>1;if(e%2==0||e%3==0)return!1;for(var t=5;t*t<=e;t+=6)if(e%t==0||e%(t+2)==0)return!1;return!0},BigNumber:function(e){if(0*e.toNumber()!=0)return!1;if(e.lte(3))return e.gt(1);if(e.mod(2).eq(0)||e.mod(3).eq(0))return!1;if(e.lt(Math.pow(2,32))){for(var t=e.toNumber(),r=5;r*r<=t;r+=6)if(t%r==0||t%(r+2)==0)return!1;return!0}function n(e,t,r){for(var n=1;!t.eq(0);)t.mod(2).eq(0)?(t=t.div(2),e=e.mul(e).mod(r)):(t=t.sub(1),n=e.mul(n).mod(r));return n}for(var i=e.constructor.clone({precision:2*e.toFixed(0).length}),a=0,o=(e=new i(e)).sub(1);o.mod(2).eq(0);)o=o.div(2),a+=1;var s=null;if(e.lt("3317044064679887385961981"))s=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter((t=>t{var{typed:t,config:r,Complex:n}=e;return t(us,{number:function(e){return e>=-1&&e<=1||r.predictable?Math.acos(e):new n(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()},"Array | Matrix":function(e){return $t(e,this)}})})),ls="number";function fs(e){return Ee(e)}function ps(e){return Math.atan(1/e)}function ms(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}function hs(e){return Math.asin(1/e)}function ds(e){var t=1/e;return Math.log(t+Math.sqrt(t*t+1))}function ys(e){return Math.acos(1/e)}function gs(e){var t=1/e,r=Math.sqrt(t*t-1);return Math.log(r+t)}function vs(e){return Ae(e)}function xs(e){return Oe(e)}function bs(e){return 1/Math.tan(e)}function ws(e){var t=Math.exp(2*e);return(t+1)/(t-1)}function Ns(e){return 1/Math.sin(e)}function Ms(e){return 0===e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*le(e)}function Ss(e){return 1/Math.cos(e)}function Es(e){return 2/(Math.exp(e)+Math.exp(-e))}function As(e){return _e(e)}fs.signature=ls,ps.signature=ls,ms.signature=ls,hs.signature=ls,ds.signature=ls,ys.signature=ls,gs.signature=ls,vs.signature=ls,xs.signature=ls,bs.signature=ls,ws.signature=ls,Ns.signature=ls,Ms.signature=ls,Ss.signature=ls,Es.signature=ls,As.signature=ls;var Os="acot",Cs=W(Os,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Os,{number:ps,Complex:function(e){return e.acot()},BigNumber:function(e){return new r(1).div(e).atan()},"Array | Matrix":function(e){return $t(e,this)}})})),_s="acsc",Ts=W(_s,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(_s,{number:function(e){return e<=-1||e>=1||r.predictable?hs(e):new n(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new i(1).div(e).asin()},"Array | Matrix":function(e){return $t(e,this)}})})),Bs="asec",qs=W(Bs,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(Bs,{number:function(e){return e<=-1||e>=1||r.predictable?ys(e):new n(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new i(1).div(e).acos()},"Array | Matrix":function(e){return $t(e,this)}})})),zs="asin",Ds=W(zs,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(zs,{number:function(e){return e>=-1&&e<=1||r.predictable?Math.asin(e):new n(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Is=W("atan",["typed"],(e=>{var{typed:t}=e;return t("atan",{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),ks="atanh",Rs=W(ks,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(ks,{number:function(e){return e<=1&&e>=-1||r.predictable?xs(e):new n(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Fs="cosh",Us=W(Fs,["typed"],(e=>{var{typed:t}=e;return t(Fs,{number:Ce,Complex:function(e){return e.cosh()},BigNumber:function(e){return e.cosh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Ps="coth",js=W(Ps,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Ps,{number:ws,Complex:function(e){return e.coth()},BigNumber:function(e){return new r(1).div(e.tanh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Ls="csch",Hs=W(Ls,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Ls,{number:Ms,Complex:function(e){return e.csch()},BigNumber:function(e){return new r(1).div(e.sinh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),$s="sech",Gs=W($s,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t($s,{number:Es,Complex:function(e){return e.sech()},BigNumber:function(e){return new r(1).div(e.cosh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Vs="sinh",Zs=W(Vs,["typed"],(e=>{var{typed:t}=e;return t(Vs,{number:As,Complex:function(e){return e.sinh()},BigNumber:function(e){return e.sinh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Ws=W("tanh",["typed"],(e=>{var{typed:t}=e;return t("tanh",{number:Te,Complex:function(e){return e.tanh()},BigNumber:function(e){return e.tanh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})}));function Js(e,t){if(t>1;return Js(e,r)*Js(r+1,t)}function Ys(e,t){if(!ce(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!ce(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(t>e)throw new TypeError("k must be less than or equal to n");var r=e-t;return t{var{typed:t}=e;return t(Xs,{"number, number":Ys,"BigNumber, BigNumber":function(e,t){var r,n,i=e.constructor,a=e.minus(t),o=new i(1);if(!Ks(e)||!Ks(t))throw new TypeError("Positive integer value expected in function combinations");if(t.gt(e))throw new TypeError("k must be less than n in function combinations");if(r=o,t.lt(a))for(n=o;n.lte(a);n=n.plus(o))r=r.times(t.plus(n)).dividedBy(n);else for(n=o;n.lte(t);n=n.plus(o))r=r.times(a.plus(n)).dividedBy(n);return r}})}));function Ks(e){return e.isInteger()&&e.gte(0)}var eu=r(377),tu=eu(Date.now());function ru(e){var t,r;return t=null===(r=e)?tu:eu(String(r)),function(){return t()}}var nu="pickRandom",iu=W(nu,["typed","config","?on"],(e=>{var{typed:t,config:r,on:n}=e,a=ru(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(a=ru(e.randomSeed))})),t(nu,{"Array | Matrix":function(e){return o(e,{})},"Array | Matrix, Object":function(e,t){return o(e,t)},"Array | Matrix, number":function(e,t){return o(e,{number:t})},"Array | Matrix, Array | Matrix":function(e,t){return o(e,{weights:t})},"Array | Matrix, Array | Matrix, number":function(e,t,r){return o(e,{number:r,weights:t})},"Array | Matrix, number, Array | Matrix":function(e,t,r){return o(e,{number:t,weights:r})}});function o(e,t){var{number:r,weights:n,elementWise:o=!0}=t,s=void 0===r;s&&(r=1);var u=f(e)?e.create:f(n)?n.create:null;e=e.valueOf(),n&&(n=n.valueOf()),!0===o&&(e=et(e),n=et(n));var c=0;if(void 0!==n){if(n.length!==e.length)throw new Error("Weights must have the same length as possibles");for(var l=0,p=n.length;l1)for(var n=0,i=e.shift();n{var{typed:t,config:r,on:n}=e,i=ru(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(i=ru(e.randomSeed))})),t(ou,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,t)=>o(e,t),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,t)=>a(e,0,t),"Array | Matrix, number, number":(e,t,r)=>a(e,t,r)});function a(e,t,r){var n=au(e.valueOf(),(()=>o(t,r)));return f(e)?e.create(n):n}function o(e,t){return Math.floor(e+i()*(t-e))}})),uu="clone",cu=W(uu,["typed"],(e=>{var{typed:t}=e;return t(uu,{any:$})})),lu="hasNumericValue",fu=W(lu,["typed","isNumeric"],(e=>{var{typed:t,isNumeric:r}=e;return t(lu,{string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return r(e)}})})),pu="typeOf",mu=W(pu,["typed"],(e=>{var{typed:t}=e;return t(pu,{any:L})})),hu="string",du=W(hu,["typed"],(e=>{var{typed:t}=e;return t(hu,{"":function(){return""},number:ge,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":function(e){return $t(e,this)},any:function(e){return String(e)}})})),yu=W("fraction",["typed","Fraction"],(e=>{var{typed:t,Fraction:r}=e;return t("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw new Error(e+" cannot be represented as a fraction");return new r(e)},string:function(e){return new r(e)},"number, number":function(e,t){return new r(e,t)},null:function(e){return new r(0)},BigNumber:function(e){return new r(e.toString())},Fraction:function(e){return e},Object:function(e){return new r(e)},"Array | Matrix":function(e){return $t(e,this)}})})),gu="unaryMinus",vu=W(gu,["typed"],(e=>{var{typed:t}=e;return t(gu,{number:ka,Complex:function(e){return e.neg()},BigNumber:function(e){return e.neg()},Fraction:function(e){return e.neg()},Unit:function(e){var t=e.clone();return t.value=this(e.value),t},"Array | Matrix":function(e){return $t(e,this,!0)}})})),xu="addScalar",bu=W(xu,["typed"],(e=>{var{typed:t}=e;return t(xu,{"number, number":Da,"Complex, Complex":function(e,t){return e.add(t)},"BigNumber, BigNumber":function(e,t){return e.plus(t)},"Fraction, Fraction":function(e,t){return e.add(t)},"Unit, Unit":function(e,t){if(null===e.value||void 0===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value||void 0===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var r=e.clone();return r.value=this(r.value,t.value),r.fixPrefix=!1,r}})})),wu=W("exp",["typed"],(e=>{var{typed:t}=e;return t("exp",{number:ja,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()},"Array | Matrix":function(e){return $t(e,this)}})})),Nu="log2",Mu=W(Nu,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(Nu,{number:function(e){return e>=0||r.predictable?Za(e):i(new n(e,0))},Complex:i,BigNumber:function(e){return!e.isNegative()||r.predictable?e.log(2):i(new n(e.toNumber(),0))},"Array | Matrix":function(e){return $t(e,this)}});function i(e){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new n(Math.log2?Math.log2(t):Math.log(t)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}})),Su=W("sqrt",["config","typed","Complex"],(e=>{var{config:t,typed:r,Complex:n}=e;return r("sqrt",{number:i,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.sqrt():i(e.toNumber())},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.pow(.5)}});function i(e){return isNaN(e)?NaN:e>=0||t.predictable?Math.sqrt(e):new n(e,0).sqrt()}})),Eu="conj",Au=W(Eu,["typed"],(e=>{var{typed:t}=e;return t(Eu,{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.conjugate()},"Array | Matrix":function(e){return $t(e,this)}})})),Ou="getMatrixDataType",Cu=W(Ou,["typed"],(e=>{var{typed:t}=e;return t(Ou,{Array:function(e){return ut(e,L)},Matrix:function(e){return e.getDataType()}})})),_u="mode",Tu=W(_u,["typed","isNaN","isNumeric"],(e=>{var{typed:t,isNaN:r,isNumeric:n}=e;return t(_u,{"Array | Matrix":i,"...":function(e){return i(e)}});function i(e){if(0===(e=et(e.valueOf())).length)throw new Error("Cannot calculate mode of an empty array");for(var t={},i=[],a=0,o=0;oa&&(a=t[s],i=[s])}return i}})),Bu=W("bin",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("bin",{"number | BigNumber":function(e){return r(e,{notation:"bin"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"bin",wordSize:t})}})})),qu="acosh",zu=W(qu,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(qu,{number:function(e){return e>=1||r.predictable?fs(e):e<=-1?new n(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new n(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()},"Array | Matrix":function(e){return $t(e,this)}})})),Du="acsch",Iu=W(Du,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Du,{number:ds,Complex:function(e){return e.acsch()},BigNumber:function(e){return new r(1).div(e).asinh()},"Array | Matrix":function(e){return $t(e,this)}})})),ku=W("asinh",["typed"],(e=>{var{typed:t}=e;return t("asinh",{number:vs,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Ru=W("cos",["typed"],(e=>{var{typed:t}=e;return t("cos",{number:Math.cos,Complex:function(e){return e.cos()},BigNumber:function(e){return e.cos()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Fu=W("csc",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("csc",{number:Ns,Complex:function(e){return e.csc()},BigNumber:function(e){return new r(1).div(e.sin())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Uu=W("sin",["typed"],(e=>{var{typed:t}=e;return t("sin",{number:Math.sin,Complex:function(e){return e.sin()},BigNumber:function(e){return e.sin()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Pu="combinationsWithRep",ju=W(Pu,["typed"],(e=>{var{typed:t}=e;return t(Pu,{"number, number":function(e,t){if(!ce(e)||e<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!ce(t)||t<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e<1)throw new TypeError("k must be less than or equal to n + k - 1");return t{var{typed:t,config:r,on:n}=e,i=ru(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(i=ru(e.randomSeed))})),t(Hu,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,t)=>o(e,t),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,t)=>a(e,0,t),"Array | Matrix, number, number":(e,t,r)=>a(e,t,r)});function a(e,t,r){var n=au(e.valueOf(),(()=>o(t,r)));return f(e)?e.create(n):n}function o(e,t){return e+i()*(t-e)}})),Gu="isNegative",Vu=W(Gu,["typed"],(e=>{var{typed:t}=e;return t(Gu,{number:ha,BigNumber:function(e){return e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s<0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Zu=W("SparseMatrix",["typed","equalScalar","Matrix"],(e=>{var{typed:t,equalScalar:r,Matrix:n}=e;function o(e,t){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!c(t))throw new Error("Invalid datatype: "+t);if(f(e))!function(e,t,r){"SparseMatrix"===t.type?(e._values=t._values?$(t._values):void 0,e._index=$(t._index),e._ptr=$(t._ptr),e._size=$(t._size),e._datatype=r||t._datatype):s(e,t.valueOf(),r||t._datatype)}(this,e,t);else if(e&&l(e.index)&&l(e.ptr)&&l(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=t||e.datatype;else if(l(e))s(this,e,t);else{if(e)throw new TypeError("Unsupported type of data ("+L(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=t}}function s(e,n,i){e._values=[],e._index=[],e._ptr=[],e._datatype=i;var a=n.length,o=0,s=r,u=0;if(c(i)&&(s=t.find(r,[i,i])||r,u=t.convert(0,i)),a>0){var f=0;do{e._ptr.push(e._index.length);for(var p=0;p");for(var c=t.min()[0],l=t.min()[1],p=i[0],m=i[1],h=0;hd){for(f=d;fh){if(m){var y=0;for(f=0;fn-1&&(e._values.splice(p,1),e._index.splice(p,1),v++)}e._ptr[f]=e._values.length}return e._size[0]=n,e._size[1]=i,e}function v(e,t,r,n,i){var a,o,s=n[0],u=n[1],c=[];for(a=0;as-1||o>u-1)&&(g(this,Math.max(a+1,s),Math.max(o+1,u),i),s=this._size[0],u=this._size[1]),$e(a,s),$e(o,u);var m=h(a,this._ptr[o],this._ptr[o+1],this._index);return mArray.isArray(e)&&1===e.length?e[0]:e));if(2!==n.length)throw new Error("Only two dimensions matrix are supported");return n.forEach((function(e){if(!i(e)||!ce(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+De(n)+")")})),g(r?this.clone():this,n[0],n[1],t)},o.prototype.reshape=function(e,t){if(!l(e))throw new TypeError("Array expected");if(2!==e.length)throw new Error("Sparse matrices can only be reshaped in two dimensions");e.forEach((function(t){if(!i(t)||!ce(t)||t<=-2||0===t)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+De(e)+")")}));var r=this._size[0]*this._size[1];if(r!==(e=We(e,r))[0]*e[1])throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var n=t?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return n;for(var a=[],o=0;o=0&&w<=i&&y(e._values[b],w-0,g-0)}else{for(var N={},M=v;M "+(this._values?De(this._values[u],e):"X");return i},o.prototype.toString=function(){return De(this.toArray())},o.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},o.prototype.diagonal=function(e){if(e){if(a(e)&&(e=e.toNumber()),!i(e)||!ce(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var t=e>0?e:0,r=e<0?-e:0,n=this._size[0],s=this._size[1],u=Math.min(n-r,s-t),c=[],l=[],f=[];f[0]=0;for(var p=t;p0?s:0,g=s<0?-s:0,v=e[0],x=e[1],b=Math.min(v-g,x-y);if(l(n)){if(n.length!==b)throw new Error("Invalid value array length");d=function(e){return n[e]}}else if(f(n)){var w=n.size();if(1!==w.length||w[0]!==b)throw new Error("Invalid matrix length");d=function(e){return n.get([e])}}else d=function(){return n};for(var N=[],M=[],S=[],E=0;E=0&&A=u||i[l]!==t)){var p=n?n[c]:void 0;i.splice(l,0,t),n&&n.splice(l,0,p),i.splice(l<=c?c+1:c,1),n&&n.splice(l<=c?c+1:c,1)}else if(l=u||i[c]!==e)){var m=n?n[l]:void 0;i.splice(c,0,e),n&&n.splice(c,0,m),i.splice(c<=l?l+1:l,1),n&&n.splice(c<=l?l+1:l,1)}}},o}),{isClass:!0}),Wu="matrix",Ju=W(Wu,["typed","Matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,Matrix:r,DenseMatrix:n,SparseMatrix:i}=e;return t(Wu,{"":function(){return a([])},string:function(e){return a([],e)},"string, string":function(e,t){return a([],e,t)},Array:function(e){return a(e)},Matrix:function(e){return a(e,e.storage())},"Array | Matrix, string":a,"Array | Matrix, string, string":a});function a(e,t,r){if("dense"===t||"default"===t||void 0===t)return new n(e,r);if("sparse"===t)return new i(e,r);throw new TypeError("Unknown matrix type "+JSON.stringify(t)+".")}})),Yu=W("abs",["typed"],(e=>{var{typed:t}=e;return t("abs",{number:za,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},Fraction:function(e){return e.abs()},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.abs()}})})),Xu=W("algorithm01",["typed"],(e=>{var{typed:t}=e;return function(e,r,n,i){var a=e._data,o=e._size,s=e._datatype,u=r._values,c=r._index,l=r._ptr,f=r._size,p=r._datatype;if(o.length!==f.length)throw new Ue(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m,h,d=o[0],y=o[1],g="string"==typeof s&&s===p?s:void 0,v=g?t.find(n,[g,g]):n,x=[];for(m=0;m{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E,A=a&&l?[]:void 0,O=[],C=[],_=a&&l?[]:void 0,T=a&&l?[]:void 0,B=[],q=[];for(N=0;N{var{typed:t,DenseMatrix:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=i;"string"==typeof l&&(f=l,n=t.convert(n,f),h=t.find(i,[f,f]));for(var d=[],y=[],g=[],v=0;v{var{typed:t}=e;return function(e,n,i){var a,o=e._data,s=e._size,u=e._datatype,c=n._data,l=n._size,f=n._datatype,p=[];if(s.length!==l.length)throw new Ue(s.length,l.length);for(var m=0;m0?r(h,0,p,p[0],o,c):[];return e.createDenseMatrix({data:d,size:p,datatype:a})};function r(e,t,n,i,a,o){var s=[];if(t===n.length-1)for(var u=0;u{var{typed:t}=e;return function(e,n,i,a){var o,s=e._data,u=e._size,c=e._datatype,l=i;"string"==typeof c&&(o=c,n=t.convert(n,o),l=t.find(i,[o,o]));var f=u.length>0?r(l,0,u,u[0],s,n,a):[];return e.createDenseMatrix({data:f,size:$(u),datatype:o})};function r(e,t,n,i,a,o,s){var u=[];if(t===n.length-1)for(var c=0;c{var{typed:t,matrix:r,equalScalar:n,BigNumber:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=Qu({typed:t,equalScalar:n}),u=Ku({typed:t,DenseMatrix:a}),c=ec({typed:t}),l=tc({typed:t});return t("gcd",{"number, number":Ha,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var r=new i(0);!t.isZero();){var n=e.mod(t);e=t,t=n}return e.lt(r)?e.neg():e},"Fraction, Fraction":function(e,t){return e.gcd(t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return u(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return l(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return l(r(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,equalScalar:r}=e;return function(e,n,i,a){var o=e._data,s=e._size,u=e._datatype,c=n._values,l=n._index,f=n._ptr,p=n._size,m=n._datatype;if(s.length!==p.length)throw new Ue(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h,d=s[0],y=s[1],g=r,v=0,x=i;"string"==typeof u&&u===m&&(h=u,g=t.find(r,[h,h]),v=t.convert(0,h),x=t.find(i,[h,h]));for(var b=[],w=[],N=[],M=0;M{var{typed:t}=e;return function(e,r,n,i){var a=e._data,o=e._size,s=e._datatype,u=r._values,c=r._index,l=r._ptr,f=r._size,p=r._datatype;if(o.length!==f.length)throw new Ue(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m,h=o[0],d=o[1],y=0,g=n;"string"==typeof s&&s===p&&(m=s,y=t.convert(0,m),g=t.find(n,[m,m]));for(var v=[],x=0;x{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E=a&&l?[]:void 0,A=[],O=[],C=E?[]:void 0,_=E?[]:void 0,T=[],B=[];for(N=0;N{var{typed:t,equalScalar:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=r,d=0,y=i;"string"==typeof l&&(f=l,h=t.find(r,[f,f]),d=t.convert(0,f),n=t.convert(n,f),y=t.find(i,[f,f]));for(var g=[],v=[],x=[],b=0;b{var{typed:t,DenseMatrix:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=i;"string"==typeof l&&(f=l,n=t.convert(n,f),h=t.find(i,[f,f]));for(var d=[],y=[],g=[],v=0;v{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=nc({typed:t,equalScalar:n}),o=ic({typed:t}),s=ac({typed:t,equalScalar:n}),u=oc({typed:t,equalScalar:n}),c=sc({typed:t,DenseMatrix:i}),l=ec({typed:t}),f=tc({typed:t});return t("mod",{"number, number":Wa,"BigNumber, BigNumber":function(e,t){if(t.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return t.isZero()?e:e.mod(t)},"Fraction, Fraction":function(e,t){if(t.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return e.compare(0)>=0?e.mod(t):e.mod(t).add(t).mod(t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return f(e,t,this,!1)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return f(t,e,this,!0)},"Array, any":function(e,t){return f(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return f(r(t),e,this,!0).valueOf()}})})),cc=W("algorithm06",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._size,s=e._datatype,u=n._values,c=n._size,l=n._datatype;if(o.length!==c.length)throw new Ue(o.length,c.length);if(o[0]!==c[0]||o[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+c+")");var f,p=o[0],m=o[1],h=r,d=0,y=i;"string"==typeof s&&s===l&&(f=s,h=t.find(r,[f,f]),d=t.convert(0,f),y=t.find(i,[f,f]));for(var g=a&&u?[]:void 0,v=[],x=[],b=g?[]:void 0,w=[],N=[],M=0;M{var{typed:t,matrix:r,equalScalar:n,BigNumber:i}=e,a=Xu({typed:t}),o=nc({typed:t,equalScalar:n}),s=cc({typed:t,equalScalar:n}),u=oc({typed:t,equalScalar:n}),c=ec({typed:t}),l=tc({typed:t}),f="Complex number not supported in function nthRoot. Use nthRoots instead.";return t(lc,{number:function(e){return Ja(e,2)},"number, number":Ja,BigNumber:function(e){return p(e,new i(2))},Complex:function(e){throw new Error(f)},"Complex, number":function(e,t){throw new Error(f)},"BigNumber, BigNumber":p,"Array | Matrix":function(e){return this(e,2)},"SparseMatrix, SparseMatrix":function(e,t){if(1===t.density())return s(e,t,this);throw new Error("Root must be non-zero")},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){if(1===t.density())return a(e,t,this,!1);throw new Error("Root must be non-zero")},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){if(1===t.density())return u(t,e,this,!0);throw new Error("Root must be non-zero")},"number | BigNumber, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}});function p(e,t){var r=i.precision,n=i.clone({precision:r+2}),a=new i(0),o=new n(1),s=t.isNegative();if(s&&(t=t.neg()),t.isZero())throw new Error("Root must be non-zero");if(e.isNegative()&&!t.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(e.isZero())return s?new n(1/0):0;if(!e.isFinite())return s?a:e;var u=e.abs().pow(o.div(t));return u=e.isNeg()?u.neg():u,new i((s?o.div(u):u).toPrecision(r))}})),pc="xgcd",mc=W(pc,["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t(pc,{"number, number":function(e,t){var i=Qa(e,t);return"Array"===r.matrix?i:n(i)},"BigNumber, BigNumber":function(e,t){var a,o,s,u,c=new i(0),l=new i(1),f=c,p=l,m=l,h=c;if(!e.isInt()||!t.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!t.isZero();)o=e.div(t).floor(),s=e.mod(t),a=f,f=p.minus(o.times(f)),p=a,a=m,m=h.minus(o.times(m)),h=a,e=t,t=s;return u=e.lt(c)?[e.neg(),p.neg(),h.neg()]:[e,e.isZero()?0:p,h],"Array"===r.matrix?u:n(u)}})})),hc="bitAnd",dc=W(hc,["typed","matrix","equalScalar"],(e=>{var{typed:t,matrix:r,equalScalar:n}=e,i=nc({typed:t,equalScalar:n}),a=cc({typed:t,equalScalar:n}),o=oc({typed:t,equalScalar:n}),s=ec({typed:t}),u=tc({typed:t});return t(hc,{"number, number":So,"BigNumber, BigNumber":ho,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),yc=W("algorithm07",["typed","DenseMatrix"],(e=>{var{typed:t,DenseMatrix:r}=e;return function(e,i,a){var o=e._size,s=e._datatype,u=i._size,c=i._datatype;if(o.length!==u.length)throw new Ue(o.length,u.length);if(o[0]!==u[0]||o[1]!==u[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+u+")");var l,f,p,m=o[0],h=o[1],d=0,y=a;"string"==typeof s&&s===c&&(l=s,d=t.convert(0,l),y=t.find(a,[l,l]));var g=[];for(f=0;f{var{typed:t,matrix:r,DenseMatrix:n}=e,i=ic({typed:t}),a=yc({typed:t,DenseMatrix:n}),o=sc({typed:t,DenseMatrix:n}),s=ec({typed:t}),u=tc({typed:t});return t(gc,{"number, number":Oo,"BigNumber, BigNumber":bo,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),xc=W("or",["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=ic({typed:t}),o=ac({typed:t,equalScalar:n}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t("or",{"number, number":Ro,"Complex, Complex":function(e,t){return 0!==e.re||0!==e.im||0!==t.re||0!==t.im},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!e.isNaN()||!t.isZero()&&!t.isNaN()},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})})),bc="diag",wc=W(bc,["typed","matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:r,DenseMatrix:n,SparseMatrix:i}=e;return t(bc,{Array:function(e){return a(e,0,je(e),null)},"Array, number":function(e,t){return a(e,t,je(e),null)},"Array, BigNumber":function(e,t){return a(e,t.toNumber(),je(e),null)},"Array, string":function(e,t){return a(e,0,je(e),t)},"Array, number, string":function(e,t,r){return a(e,t,je(e),r)},"Array, BigNumber, string":function(e,t,r){return a(e,t.toNumber(),je(e),r)},Matrix:function(e){return a(e,0,e.size(),e.storage())},"Matrix, number":function(e,t){return a(e,t,e.size(),e.storage())},"Matrix, BigNumber":function(e,t){return a(e,t.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,t){return a(e,0,e.size(),t)},"Matrix, number, string":function(e,t,r){return a(e,t,e.size(),r)},"Matrix, BigNumber, string":function(e,t,r){return a(e,t.toNumber(),e.size(),r)}});function a(e,t,a,o){if(!ce(t))throw new TypeError("Second parameter in function diag must be an integer");var s=t>0?t:0,u=t<0?-t:0;switch(a.length){case 1:return function(e,t,r,a,o,s){var u=[a+o,a+s];if(r&&"sparse"!==r&&"dense"!==r)throw new TypeError("Unknown matrix type ".concat(r,'"'));var c="sparse"===r?i.diagonal(u,e,t):n.diagonal(u,e,t);return null!==r?c:c.valueOf()}(e,t,o,a[0],u,s);case 2:return function(e,t,n,i,a,o){if(f(e)){var s=e.diagonal(t);return null!==n?n!==s.storage()?r(s,n):s:s.valueOf()}for(var u=Math.min(i[0]-a,i[1]-o),c=[],l=0;l{var{typed:t,config:r,matrix:n,BigNumber:i,DenseMatrix:o,SparseMatrix:s}=e;return t(Nc,{"":function(){return"Matrix"===r.matrix?n([]):[]},string:function(e){return n(e)},"number | BigNumber":function(e){return c(e,e,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, string":function(e,t){return c(e,e,t)},"number | BigNumber, number | BigNumber":function(e,t){return c(e,t,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(e,t,r){return c(e,t,r)},Array:function(e){return u(e)},"Array, string":function(e,t){return u(e,t)},Matrix:function(e){return u(e.valueOf(),e.storage())},"Matrix, string":function(e,t){return u(e.valueOf(),t)}});function u(e,t){switch(e.length){case 0:return t?n(t):[];case 1:return c(e[0],e[0],t);case 2:return c(e[0],e[1],t);default:throw new Error("Vector containing two values expected")}}function c(e,t,r){var n=a(e)||a(t)?i:null;if(a(e)&&(e=e.toNumber()),a(t)&&(t=t.toNumber()),!ce(e)||e<1)throw new Error("Parameters in function identity must be positive integers");if(!ce(t)||t<1)throw new Error("Parameters in function identity must be positive integers");var u=n?new i(1):1,c=n?new n(0):0,l=[e,t];if(r){if("sparse"===r)return s.diagonal(l,u,0,c);if("dense"===r)return o.diagonal(l,u,0,c);throw new TypeError('Unknown matrix type "'.concat(r,'"'))}for(var f=Ge([],l,c),p=e{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t("ones",{"":function(){return"Array"===r.matrix?o([]):o([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return o(e,t)}return"Array"===r.matrix?o(e):o(e,"default")},Array:o,Matrix:function(e){var t=e.storage();return o(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return o(e.valueOf(),t)}});function o(e,t){var r=function(e){var t=!1;return e.forEach((function(e,r,n){a(e)&&(t=!0,n[r]=e.toNumber())})),t}(e)?new i(1):1;if(function(e){e.forEach((function(e){if("number"!=typeof e||!ce(e)||e<0)throw new Error("Parameters in function ones must be positive integers")}))}(e),t){var o=n(t);return e.length>0?o.resize(e,r):o}var s=[];return e.length>0?Ge(s,e,r):s}})),Ec="reshape",Ac=W(Ec,["typed","isInteger","matrix"],(e=>{var{typed:t,isInteger:r}=e;return t(Ec,{"Matrix, Array":function(e,t){return e.reshape(t)},"Array, Array":function(e,t){return t.forEach((function(e){if(!r(e))throw new TypeError("Invalid size for dimension: "+e)})),Ze(e,t)}})})),Oc="size",Cc=W(Oc,["typed","config","?matrix"],(e=>{var{typed:t,config:r,matrix:n}=e;return t(Oc,{Matrix:function(e){return e.create(e.size())},Array:je,string:function(e){return"Array"===r.matrix?[e.length]:n([e.length])},"number | Complex | BigNumber | Unit | boolean | null":function(e){return"Array"===r.matrix?[]:n?n([]):fr()}})})),_c="zeros",Tc=W(_c,["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t(_c,{"":function(){return"Array"===r.matrix?o([]):o([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return o(e,t)}return"Array"===r.matrix?o(e):o(e,"default")},Array:o,Matrix:function(e){var t=e.storage();return o(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return o(e.valueOf(),t)}});function o(e,t){var r=function(e){var t=!1;return e.forEach((function(e,r,n){a(e)&&(t=!0,n[r]=e.toNumber())})),t}(e)?new i(0):0;if(function(e){e.forEach((function(e){if("number"!=typeof e||!ce(e)||e<0)throw new Error("Parameters in function zeros must be positive integers")}))}(e),t){var o=n(t);return e.length>0?o.resize(e,r):o}var s=[];return e.length>0?Ge(s,e,r):s}})),Bc=W("hex",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("hex",{"number | BigNumber":function(e){return r(e,{notation:"hex"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"hex",wordSize:t})}})}));function qc(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function zc(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Dc(e){for(var t=1;t{var{typed:t,matrix:r,equalScalar:n,zeros:i,BigNumber:a,DenseMatrix:o}=e,s=oc({typed:t,equalScalar:n}),u=sc({typed:t,DenseMatrix:o}),c=tc({typed:t});return t(kc,Dc(Dc({},Fc),{},{Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw new TypeError(Ic);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(Ic);var r=t.toNumber();return e.round(r)},"number, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(Ic);return new a(e).toDecimalPlaces(t.toNumber())},BigNumber:function(e){return e.toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(Ic);return e.toDecimalPlaces(t.toNumber())},Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw new TypeError(Ic);return e.round(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"SparseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | Complex | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):u(t,e,this,!0)},"number | Complex | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return c(r(e),t,this,!1).valueOf()},"number | Complex | BigNumber, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}}))})),Fc={number:eo,"number, number":function(e,t){if(!ce(t))throw new TypeError(Ic);if(t<0||t>15)throw new Error("Number of decimals in function round must be in the range of 0-15");return eo(e,t)}},Uc=W("algorithm08",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");if(!a||!l)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));for(var w,N,M,S,E=[],A=[],O=[],C=[],_=[],T=0;T{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=nc({typed:t,equalScalar:n}),u=Uc({typed:t,equalScalar:n}),c=Ku({typed:t,DenseMatrix:a}),l=oc({typed:t,equalScalar:n}),f=ec({typed:t}),p=tc({typed:t});return t(Pc,{"number, number":Co,"BigNumber, BigNumber":wo,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Lc="rightLogShift",Hc=W(Lc,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=nc({typed:t,equalScalar:n}),u=Uc({typed:t,equalScalar:n}),c=Ku({typed:t,DenseMatrix:a}),l=oc({typed:t,equalScalar:n}),f=ec({typed:t}),p=tc({typed:t});return t(Lc,{"number, number":To,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})})),$c="compare",Gc=W($c,["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],(e=>{var{typed:t,config:r,equalScalar:n,matrix:i,BigNumber:a,Fraction:o,DenseMatrix:s}=e,u=ic({typed:t}),c=ac({typed:t,equalScalar:n}),l=sc({typed:t,DenseMatrix:s}),f=ec({typed:t}),p=tc({typed:t});return t($c,{"boolean, boolean":function(e,t){return e===t?0:e>t?1:-1},"number, number":function(e,t){return Se(e,t,r.epsilon)?0:e>t?1:-1},"BigNumber, BigNumber":function(e,t){return Na(e,t,r.epsilon)?new a(0):new a(e.cmp(t))},"Fraction, Fraction":function(e,t){return new o(e.compare(t))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return c(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(i(e),i(t)).valueOf()},"Array, Matrix":function(e,t){return this(i(e),t)},"Matrix, Array":function(e,t){return this(e,i(t))},"SparseMatrix, any":function(e,t){return l(e,t,this,!1)},"DenseMatrix, any":function(e,t){return p(e,t,this,!1)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(i(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(i(t),e,this,!0).valueOf()}})})),Vc="compareText",Zc=W(Vc,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e,n=ec({typed:t}),i=tc({typed:t});return t(Vc,{"any, any":Fe,"DenseMatrix, DenseMatrix":function(e,t){return n(e,t,Fe)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"DenseMatrix, any":function(e,t){return i(e,t,Fe,!1)},"any, DenseMatrix":function(e,t){return i(t,e,Fe,!0)},"Array, any":function(e,t){return i(r(e),t,Fe,!1).valueOf()},"any, Array":function(e,t){return i(r(t),e,Fe,!0).valueOf()}})})),Wc="smaller",Jc=W(Wc,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Wc,{"boolean, boolean":function(e,t){return e{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Yc,{"boolean, boolean":function(e,t){return e>t},"number, number":function(e,t){return e>t&&!Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gt(t)&&!Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return 1===e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),Qc="unequal",Kc=W(Qc,["typed","config","equalScalar","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,equalScalar:n,matrix:i,DenseMatrix:a}=e,o=ic({typed:t}),s=yc({typed:t,DenseMatrix:a}),u=sc({typed:t,DenseMatrix:a}),c=ec({typed:t}),l=tc({typed:t});return t("unequal",{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:f(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,f)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,f,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,f,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,f)},"Array, Array":function(e,t){return this(i(e),i(t)).valueOf()},"Array, Matrix":function(e,t){return this(i(e),t)},"Matrix, Array":function(e,t){return this(e,i(t))},"SparseMatrix, any":function(e,t){return u(e,t,f,!1)},"DenseMatrix, any":function(e,t){return l(e,t,f,!1)},"any, SparseMatrix":function(e,t){return u(t,e,f,!0)},"any, DenseMatrix":function(e,t){return l(t,e,f,!0)},"Array, any":function(e,t){return l(i(e),t,f,!1).valueOf()},"any, Array":function(e,t){return l(i(t),e,f,!0).valueOf()}});function f(e,t){return!n(e,t)}})),el=(W(Qc,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return t(Qc,{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:!r(e,t)}})})),W("ImmutableDenseMatrix",["smaller","DenseMatrix"],(e=>{var{smaller:t,DenseMatrix:r}=e;function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!c(t))throw new Error("Invalid datatype: "+t);if(f(e)||l(e)){var i=new r(e,t);this._data=i._data,this._size=i._size,this._datatype=i._datatype,this._min=null,this._max=null}else if(e&&l(e.data)&&l(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=void 0!==e.min?e.min:null,this._max=void 0!==e.max?e.max:null;else{if(e)throw new TypeError("Unsupported type of data ("+L(e)+")");this._data=[],this._size=[0],this._datatype=t,this._min=null,this._max=null}}return n.prototype=new r,n.prototype.type="ImmutableDenseMatrix",n.prototype.isImmutableDenseMatrix=!0,n.prototype.subset=function(e){switch(arguments.length){case 1:var t=r.prototype.subset.call(this,e);return f(t)?new n({data:t._data,size:t._size,datatype:t._datatype}):t;case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},n.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},n.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},n.prototype.clone=function(){return new n({data:$(this._data),size:$(this._size),datatype:this._datatype})},n.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.fromJSON=function(e){return new n(e)},n.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},n.prototype.min=function(){if(null===this._min){var e=null;this.forEach((function(r){(null===e||t(r,e))&&(e=r)})),this._min=null!==e?e:void 0}return this._min},n.prototype.max=function(){if(null===this._max){var e=null;this.forEach((function(r){(null===e||t(e,r))&&(e=r)})),this._max=null!==e?e:void 0}return this._max},n}),{isClass:!0})),tl=W("FibonacciHeap",["smaller","larger"],(e=>{var{smaller:t,larger:r}=e,n=1/Math.log((1+Math.sqrt(5))/2);function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}function a(e,t,r){t.left.right=t.right,t.right.left=t.left,r.degree--,r.child===t&&(r.child=t.right),0===r.degree&&(r.child=null),t.left=e,t.right=e.right,e.right=t,t.right.left=t,t.parent=null,t.mark=!1}function o(e,t){var r=t.parent;r&&(t.mark?(a(e,t,r),o(r)):t.mark=!0)}i.prototype.type="FibonacciHeap",i.prototype.isFibonacciHeap=!0,i.prototype.insert=function(e,r){var n={key:e,value:r,degree:0};if(this._minimum){var i=this._minimum;n.left=i,n.right=i.right,i.right=n,n.right.left=n,t(e,i.key)&&(this._minimum=n)}else n.left=n,n.right=n,this._minimum=n;return this._size++,n},i.prototype.size=function(){return this._size},i.prototype.clear=function(){this._minimum=null,this._size=0},i.prototype.isEmpty=function(){return 0===this._size},i.prototype.extractMinimum=function(){var e=this._minimum;if(null===e)return e;for(var i=this._minimum,a=e.degree,o=e.child;a>0;){var u=o.right;o.left.right=o.right,o.right.left=o.left,o.left=i,o.right=i.right,i.right=o,o.right.left=o,o.parent=null,o=u,a--}return e.left.right=e.right,e.right.left=e.left,i=e===e.right?null:function(e,i){var a,o=Math.floor(Math.log(i)*n)+1,u=new Array(o),c=0,l=e;if(l)for(c++,l=l.right;l!==e;)c++,l=l.right;for(;c>0;){for(var f=l.degree,p=l.right;a=u[f];){if(r(l.key,a.key)){var m=a;a=l,l=m}s(a,l),u[f]=null,f++}u[f]=l,l=p,c--}e=null;for(var h=0;h{var{typed:t,SparseMatrix:r}=e;return t(rl,{"":function(){return new r([])},string:function(e){return new r([],e)},"Array | Matrix":function(e){return new r(e)},"Array | Matrix, string":function(e,t){return new r(e,t)}})})),il="acoth",al=W(il,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(il,{number:function(e){return e>=1||e<=-1||r.predictable?ms(e):new n(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new i(1).div(e).atanh()},"Array | Matrix":function(e){return $t(e,this)}})})),ol=W("algorithm09",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E,A=a&&l?[]:void 0,O=[],C=[],_=A?[]:void 0,T=[];for(N=0;N{var{typed:t,matrix:r,equalScalar:n,BigNumber:i,DenseMatrix:a}=e,o=nc({typed:t,equalScalar:n}),s=ic({typed:t}),u=ol({typed:t,equalScalar:n}),c=oc({typed:t,equalScalar:n}),l=sc({typed:t,DenseMatrix:a}),f=ec({typed:t}),p=tc({typed:t});return t(sl,{"number, number":Math.atan2,"BigNumber, BigNumber":function(e,t){return i.atan2(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return l(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return p(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return p(r(t),e,this,!0).valueOf()}})})),cl=W("sec",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("sec",{number:Ss,Complex:function(e){return e.sec()},BigNumber:function(e){return new r(1).div(e.cos())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),ll=W("add",["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:r,addScalar:n,equalScalar:i,DenseMatrix:a,SparseMatrix:o}=e,s=Xu({typed:t}),u=Qu({typed:t,equalScalar:i}),c=Ku({typed:t,DenseMatrix:a}),l=ec({typed:t}),f=tc({typed:t});return t("add",G({"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,n)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,n,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,n,!0)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,n)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"DenseMatrix, any":function(e,t){return f(e,t,n,!1)},"SparseMatrix, any":function(e,t){return c(e,t,n,!1)},"any, DenseMatrix":function(e,t){return f(t,e,n,!0)},"any, SparseMatrix":function(e,t){return c(t,e,n,!0)},"Array, any":function(e,t){return f(r(e),t,n,!1).valueOf()},"any, Array":function(e,t){return f(r(t),e,n,!0).valueOf()},"any, any":n,"any, any, ...any":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,addScalar:r,multiplyScalar:n,conj:i,size:a}=e;return t("dot",{"Array | DenseMatrix, Array | DenseMatrix":function(e,a){var u=o(e,a),c=f(e)?e._data:e,l=f(e)?e._datatype:void 0,p=f(a)?a._data:a,m=f(a)?a._datatype:void 0,h=2===s(e).length,d=2===s(a).length,y=r,g=n;if(l&&m&&l===m&&"string"==typeof l){var v=l;y=t.find(r,[v,v]),g=t.find(n,[v,v])}if(!h&&!d){for(var x=g(i(c[0]),p[0]),b=1;bd?m++:h===d&&(c=l(c,f(a[p],u[m])),p++,m++)}return c}});function o(e,t){var r,n,i=s(e),a=s(t);if(1===i.length)r=i[0];else{if(2!==i.length||1!==i[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+i.join(", ")+")");r=i[0]}if(1===a.length)n=a[0];else{if(2!==a.length||1!==a[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+a.join(", ")+")");n=a[0]}if(r!==n)throw new RangeError("Vectors must have equal length ("+r+" != "+n+")");if(0===r)throw new RangeError("Cannot calculate the dot product of empty vectors");return r}function s(e){return f(e)?e.size():a(e)}})),pl="composition",ml=W(pl,["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],(e=>{var{typed:t,addScalar:r,combinations:n,isPositive:i,isNegative:a,isInteger:o,larger:s}=e;return t(pl,{"number | BigNumber, number | BigNumber":function(e,t){if(!(o(e)&&i(e)&&o(t)&&i(t)))throw new TypeError("Positive integer value expected in function composition");if(s(t,e))throw new TypeError("k must be less than or equal to n in function composition");return n(r(e,-1),r(t,-1))}})})),hl="isZero",dl=W(hl,["typed"],(e=>{var{typed:t}=e;return t(hl,{number:ya,BigNumber:function(e){return e.isZero()},Complex:function(e){return 0===e.re&&0===e.im},Fraction:function(e){return 1===e.d&&0===e.n},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),yl="matrixFromFunction",gl=W(yl,["typed","matrix","isZero"],(e=>{var{typed:t,matrix:r,isZero:n}=e;return t(yl,{"Array | Matrix, function, string, string":function(e,t,r,n){return i(e,t,r,n)},"Array | Matrix, function, string":function(e,t,r){return i(e,t,r)},"Matrix, function":function(e,t){return i(e,t,"dense")},"Array, function":function(e,t){return i(e,t,"dense").toArray()},"Array | Matrix, string, function":function(e,t,r){return i(e,r,t)},"Array | Matrix, string, string, function":function(e,t,r,n){return i(e,n,t,r)}});function i(e,t,i,a){var o;return(o=void 0!==a?r(i,a):r(i)).resize(e),o.forEach((function(e,r){var i=t(r);n(i)||o.set(r,i)})),o}})),vl="cbrt",xl=W(vl,["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],(e=>{var{config:t,typed:r,isNegative:n,unaryMinus:i,matrix:u,Complex:c,BigNumber:l,Fraction:f}=e;return r(vl,{number:Fa,Complex:p,"Complex, boolean":p,BigNumber:function(e){return e.cbrt()},Unit:function(e){if(e.value&&o(e.value)){var t=e.clone();return t.value=1,(t=t.pow(1/3)).value=p(e.value),t}var r,u=n(e.value);u&&(e.value=i(e.value)),r=a(e.value)?new l(1).div(3):s(e.value)?new f(1,3):1/3;var c=e.pow(r);return u&&(c.value=i(c.value)),c},"Array | Matrix":function(e){return $t(e,this,!0)}});function p(e,r){var n=e.arg()/3,i=e.abs(),a=new c(Fa(i),0).mul(new c(0,n).exp());if(r){var o=[a,new c(Fa(i),0).mul(new c(0,n+2*Math.PI/3).exp()),new c(Fa(i),0).mul(new c(0,n-2*Math.PI/3).exp())];return"Array"===t.matrix?o:u(o)}return a}})),bl=W("floor",["typed","config","round","matrix","equalScalar"],(e=>{var{typed:t,config:r,round:n,matrix:i,equalScalar:a}=e,o=oc({typed:t,equalScalar:a}),s=tc({typed:t});return t("floor",{number:function(e){return Se(e,n(e),r.epsilon)?n(e):Math.floor(e)},"number, number":function(e,t){if(Se(e,n(e,t),r.epsilon))return n(e,t);var[i,a]="".concat(e,"e").split("e"),o=Math.floor(Number("".concat(i,"e").concat(Number(a)+t)));return[i,a]="".concat(o,"e").split("e"),Number("".concat(i,"e").concat(Number(a)-t))},Complex:function(e){return e.floor()},"Complex, number":function(e,t){return e.floor(t)},BigNumber:function(e){return Na(e,n(e),r.epsilon)?n(e):e.floor()},"BigNumber, BigNumber":function(e,t){return Na(e,n(e,t),r.epsilon)?n(e,t):e.toDecimalPlaces(t.toNumber(),Qn.ROUND_FLOOR)},Fraction:function(e){return e.floor()},"Fraction, number":function(e,t){return e.floor(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"Array | Matrix, number":function(e,t){return $t(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"number | Complex | BigNumber, Array":function(e,t){return s(i(t),e,this,!0).valueOf()}})})),wl="multiply",Nl=W(wl,["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],(e=>{var{typed:t,matrix:r,addScalar:n,multiplyScalar:i,equalScalar:a,dot:o}=e,s=oc({typed:t,equalScalar:a}),u=tc({typed:t});function c(e,t){switch(e.length){case 1:switch(t.length){case 1:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;case 2:switch(t.length){case 1:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+t[0]+")");break;case 2:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}}var l=t("_multiplyMatrixVector",{"DenseMatrix, any":function(e,r){var a,o=e._data,s=e._size,u=e._datatype,c=r._data,l=r._datatype,f=s[0],p=s[1],m=n,h=i;u&&l&&u===l&&"string"==typeof u&&(a=u,m=t.find(n,[a,a]),h=t.find(i,[a,a]));for(var d=[],y=0;yA)for(var C=0,_=0;_{var{typed:t,matrix:r,equalScalar:n,multiplyScalar:i}=e,a=nc({typed:t,equalScalar:n}),o=ol({typed:t,equalScalar:n}),s=oc({typed:t,equalScalar:n}),u=ec({typed:t}),c=tc({typed:t});return t(Ml,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,i)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,i,!1)},"DenseMatrix, any":function(e,t){return c(e,t,i,!1)},"any, SparseMatrix":function(e,t){return s(t,e,i,!0)},"any, DenseMatrix":function(e,t){return c(t,e,i,!0)},"Array, any":function(e,t){return c(r(e),t,i,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,i,!0).valueOf()}})})),El=W("re",["typed"],(e=>{var{typed:t}=e;return t("re",{number:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Complex:function(e){return e.re},"Array | Matrix":function(e){return $t(e,this)}})})),Al="flatten",Ol=W(Al,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t(Al,{Array:function(e){return et($(e))},Matrix:function(e){var t=et($(e.toArray()));return r(t)}})}));function Cl(e,t,r,n){if(!(this instanceof Cl))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=t,this.min=r,this.max=n,this.message="Wrong number of arguments in function "+e+" ("+t+" provided, "+r+(null!=n?"-"+n:"")+" expected)",this.stack=(new Error).stack}Cl.prototype=new Error,Cl.prototype.constructor=Error,Cl.prototype.name="ArgumentsError",Cl.prototype.isArgumentsError=!0;var _l=W("resize",["config","matrix"],(e=>{var{config:t,matrix:r}=e;return function(e,i,o){if(2!==arguments.length&&3!==arguments.length)throw new Cl("resize",arguments.length,2,3);if(f(i)&&(i=i.valueOf()),a(i[0])&&(i=i.map((function(e){return a(e)?e.toNumber():e}))),f(e))return e.resize(i,o,!0);if("string"==typeof e)return n(e,i,o);var s=!Array.isArray(e)&&"Array"!==t.matrix;if(0===i.length){for(;Array.isArray(e);)e=e[0];return $(e)}Array.isArray(e)||(e=[e]);var u=Ge(e=$(e),i,o);return s?r(u):u};function n(e,t,r){if(void 0!==r){if("string"!=typeof r||1!==r.length)throw new TypeError("Single character expected as defaultValue")}else r=" ";if(1!==t.length)throw new Ue(t.length,1);var n=t[0];if("number"!=typeof n||!ce(n))throw new TypeError("Invalid size, must contain positive integers (size: "+De(t)+")");if(e.length>n)return e.substring(0,n);if(e.length{var{typed:t,matrix:r}=e;return t(Tl,{Array:function(e){return Ye($(e))},Matrix:function(e){var t=Ye(e.toArray());return Array.isArray(t)?r(t):t},any:function(e){return $(e)}})})),ql=W("to",["typed","matrix"],(e=>{var{typed:t,matrix:r}=e,n=ec({typed:t}),i=tc({typed:t});return t("to",{"Unit, Unit | string":function(e,t){return e.to(t)},"Matrix, Matrix":function(e,t){return n(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"Matrix, any":function(e,t){return i(e,t,this,!1)},"any, Matrix":function(e,t){return i(t,e,this,!0)},"Array, any":function(e,t){return i(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return i(r(t),e,this,!0).valueOf()}})})),zl=W("pow",["typed","config","identity","multiply","matrix","fraction","number","Complex"],(e=>{var{typed:t,config:r,identity:n,multiply:i,matrix:a,number:o,fraction:s,Complex:u}=e;return t("pow",{"number, number":c,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(e,t){return t.isInteger()||e>=0||r.predictable?e.pow(t):new u(e.toNumber(),0).pow(t.toNumber(),0)},"Fraction, Fraction":function(e,t){var n=e.pow(t);if(null!=n)return n;if(r.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return c(e.valueOf(),t.valueOf())},"Array, number":l,"Array, BigNumber":function(e,t){return l(e,t.toNumber())},"Matrix, number":f,"Matrix, BigNumber":function(e,t){return f(e,t.toNumber())},"Unit, number | BigNumber":function(e,t){return e.pow(t)}});function c(e,t){if(r.predictable&&!ce(t)&&e<0)try{var n=s(t),i=o(n);if((t===i||Math.abs((t-i)/t)<1e-14)&&n.d%2==1)return(n.n%2==0?1:-1)*Math.pow(-e,t)}catch(e){}return r.predictable&&(e<-1&&t===1/0||e>-1&&e<0&&t===-1/0)?NaN:ce(t)||e>=0||r.predictable?Ka(e,t):e*e<1&&t===1/0||e*e>1&&t===-1/0?0:new u(e,0).pow(t,0)}function l(e,t){if(!ce(t)||t<0)throw new TypeError("For A^b, b must be a positive integer (value is "+t+")");var r=je(e);if(2!==r.length)throw new Error("For A^b, A must be 2 dimensional (A has "+r.length+" dimensions)");if(r[0]!==r[1])throw new Error("For A^b, A must be square (size is "+r[0]+"x"+r[1]+")");for(var a=n(r[0]).valueOf(),o=e;t>=1;)1==(1&t)&&(a=i(o,a)),t>>=1,o=i(o,o);return a}function f(e,t){return a(l(e.valueOf(),t))}})),Dl="dotPow",Il=W(Dl,["typed","equalScalar","matrix","pow","DenseMatrix"],(e=>{var{typed:t,equalScalar:r,matrix:n,pow:i,DenseMatrix:a}=e,o=ic({typed:t}),s=yc({typed:t,DenseMatrix:a}),u=oc({typed:t,equalScalar:r}),c=sc({typed:t,DenseMatrix:a}),l=ec({typed:t}),f=tc({typed:t});return t(Dl,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,i)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return f(e,t,this,!1)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return f(t,e,this,!0)},"Array, any":function(e,t){return f(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return f(n(t),e,this,!0).valueOf()}})})),kl="rightArithShift",Rl=W(kl,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=nc({typed:t,equalScalar:n}),u=Uc({typed:t,equalScalar:n}),c=Ku({typed:t,DenseMatrix:a}),l=oc({typed:t,equalScalar:n}),f=ec({typed:t}),p=tc({typed:t});return t(kl,{"number, number":_o,"BigNumber, BigNumber":No,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Fl=r(228),Ul="compareNatural",Pl=W(Ul,["typed","compare"],(e=>{var{typed:t,compare:r}=e,n=r.signatures["boolean,boolean"];return t(Ul,{"any, any":function(e,t){var o,s=L(e),u=L(t);if(!("number"!==s&&"BigNumber"!==s&&"Fraction"!==s||"number"!==u&&"BigNumber"!==u&&"Fraction"!==u))return"0"!==(o=r(e,t)).toString()?o>0?1:-1:Fl(s,u);if("Array"===s||"Matrix"===s||"Array"===u||"Matrix"===u)return 0!==(o=i(this,e,t))?o:Fl(s,u);if(s!==u)return Fl(s,u);if("Complex"===s)return function(e,t){return e.re>t.re?1:e.ret.im?1:e.imr.length?1:t.length{var{typed:t,compareText:r,isZero:n}=e;return t(jl,{"any, any":function(e,t){return n(r(e,t))}})})),Hl="largerEq",$l=W(Hl,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Hl,{"boolean, boolean":function(e,t){return e>=t},"number, number":function(e,t){return e>=t||Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gte(t)||Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return-1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),Gl="partitionSelect",Vl=W(Gl,["typed","isNumeric","isNaN","compare"],(e=>{var{typed:t,isNumeric:r,isNaN:n,compare:i}=e,a=i,o=(e,t)=>-i(e,t);return t(Gl,{"Array | Matrix, number":function(e,t){return s(e,t,a)},"Array | Matrix, number, string":function(e,t,r){if("asc"===r)return s(e,t,a);if("desc"===r)return s(e,t,o);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":s});function s(e,t,r){if(!ce(t)||t<0)throw new Error("k must be a non-negative integer");if(f(e)){if(e.size().length>1)throw new Error("Only one dimensional matrices supported");return u(e.valueOf(),t,r)}if(Array.isArray(e))return u(e,t,r)}function u(e,t,i){if(t>=e.length)throw new Error("k out of bounds");for(var a=0;a=0){var f=e[c];e[c]=e[u],e[u]=f,--c}else++u;i(e[u],l)>0&&--u,t<=u?s=u:o=u+1}return e[t]}})),Zl=W("Index",["ImmutableDenseMatrix"],(e=>{var{ImmutableDenseMatrix:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var t=0,i=arguments.length;t{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(Wl,{number:function(e){if(e<=1&&e>=-1||r.predictable){var t=1/e;if(t>0||r.predictable)return gs(e);var i=Math.sqrt(t*t-1);return new n(Math.log(i-t),Math.PI)}return new n(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new i(1).div(e).acosh()},"Array | Matrix":function(e){return $t(e,this)}})})),Yl=W("tan",["typed"],(e=>{var{typed:t}=e;return t("tan",{number:Math.tan,Complex:function(e){return e.tan()},BigNumber:function(e){return e.tan()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Xl="setDifference",Ql=W(Xl,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Xl,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(0===n(r(e),new a(0)))s=[];else{if(0===n(r(t),new a(0)))return et(e.toArray());var u,c=ot(et(Array.isArray(e)?e:e.toArray()).sort(i)),l=ot(et(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var f=0;f{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Kl,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(0===n(r(e),new a(0))||0===n(r(t),new a(0)))s=[];else{var u=ot(et(Array.isArray(e)?e:e.toArray()).sort(i)),c=ot(et(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var l=0;l{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(tf,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,t){if(0===n(r(t),new a(0)))return 0;for(var o=et(Array.isArray(t)?t:t.toArray()),s=0,u=0;u{var{typed:t,compareNatural:r}=e;return t(nf,{"Array | Matrix":function(e){return Array.isArray(e)?et(e).length:et(e.toArray()).length},"Array | Matrix, boolean":function(e,t){if(!1===t||0===e.length)return Array.isArray(e)?et(e).length:et(e.toArray()).length;for(var n=et(Array.isArray(e)?e:e.toArray()).sort(r),i=1,a=1;a{var{typed:t,matrix:r,add:n}=e;return t("trace",{Array:function(e){return i(r(e))},SparseMatrix:function(e){var t=e._values,r=e._index,i=e._ptr,a=e._size,o=a[0],s=a[1];if(o===s){var u=0;if(t.length>0)for(var c=0;cc)break}return u}throw new RangeError("Matrix must be square (size: "+De(a)+")")},DenseMatrix:i,any:$});function i(e){var t=e._size,r=e._data;switch(t.length){case 1:if(1===t[0])return $(r[0]);throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:var i=t[0];if(i===t[1]){for(var a=0,o=0;o{var{typed:t,add:r,multiply:n,partitionSelect:o,compare:s}=e;function u(e,t,a){var u=et(e),l=u.length;if(0===l)throw new Error("Cannot calculate quantile of an empty sequence");if(i(t)){var f=t*(l-1),p=f%1;if(0===p){var m=a?u[f]:o(u,f);return c(m),m}var h,d,y=Math.floor(f);if(a)h=u[y],d=u[y+1];else{d=o(u,y+1),h=u[y];for(var g=0;g0&&(h=u[g])}return c(h),c(d),r(n(h,1-p),n(d,p))}var v=t.times(l-1);if(v.isInteger()){v=v.toNumber();var x=a?u[v]:o(u,v);return c(x),x}var b,w,N=v.floor(),M=v.minus(N),S=N.toNumber();if(a)b=u[S],w=u[S+1];else{w=o(u,S+1),b=u[S];for(var E=0;E0&&(b=u[E])}c(b),c(w);var A=new M.constructor(1);return r(n(b,A.minus(M)),n(w,M))}var c=t({"number | BigNumber | Unit":function(e){return e}});return function(e,t,r){var n,o,s;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(p(e)){if("boolean"==typeof(r=r||!1)){if(o=e.valueOf(),i(t)){if(t<0)throw new Error("N/prob must be non-negative");if(t<=1)return u(o,t,r);if(t>1){if(!ce(t))throw new Error("N must be a positive integer");var c=t+1;n=new Array(t);for(var l=0;l4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var h=new f(m+1);n=new Array(m);for(var d=0;d1)throw new Error("Probability must be between 0 and 1, inclusive")}else{if(!a(g))throw new TypeError("Unexpected type of argument in function quantileSeq");if(s=new g.constructor(1),g.isNegative()||g.gt(s))throw new Error("Probability must be between 0 and 1, inclusive")}n[y]=u(o,g,r)}return n}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}}));function uf(e){var t;if(ce(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:Js(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*uf(1-e));if(e>=171.35)return 1/0;if(e>85){var r=e*e,n=r*e,i=n*e,a=i*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*r)-139/(51840*n)-571/(2488320*i)+163879/(209018880*a)+5246819/(75246796800*a*e))}--e,t=lf[0];for(var o=1;o{var{typed:t,config:r,multiplyScalar:n,pow:i,BigNumber:a,Complex:o}=e;return t(ff,{number:uf,Complex:function(e){if(0===e.im)return this(e.re);e=new o(e.re-1,e.im);for(var t=new o(lf[0],0),r=1;r2;)u+=i-=2,o=o.times(u);return new a(o.toPrecision(a.precision))}})),mf=W("bignumber",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("bignumber",{"":function(){return new r(0)},number:function(e){return new r(e+"")},string:function(e){var t=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(t){var n=t[2],i=r(t[1]),a=new r(2).pow(Number(n));if(i.gt(a.sub(1)))throw new SyntaxError('String "'.concat(e,'" is out of range'));var o=new r(2).pow(Number(n)-1);return i.gte(o)?i.sub(a):i}return new r(e)},BigNumber:function(e){return e},Fraction:function(e){return new r(e.n).div(e.d).times(e.s)},null:function(e){return new r(0)},"Array | Matrix":function(e){return $t(e,this)}})})),hf="matrixFromColumns",df=W(hf,["typed","matrix","flatten","size"],(e=>{var{typed:t,matrix:r,flatten:n,size:i}=e;return t(hf,{"...Array":function(e){return a(e)},"...Matrix":function(e){return r(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one column is needed to construct a matrix.");for(var t=o(e[0]),r=[],i=0;i{var{typed:t,matrix:r,equalScalar:n}=e,i=nc({typed:t,equalScalar:n}),a=cc({typed:t,equalScalar:n}),o=oc({typed:t,equalScalar:n}),s=ec({typed:t}),u=tc({typed:t});return t("lcm",{"number, number":$a,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(e.isZero())return e;if(t.isZero())return t;for(var r=e.times(t);!t.isZero();){var n=t;t=e.mod(n),e=n}return r.div(e).abs()},"Fraction, Fraction":function(e,t){return e.lcm(t)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return o(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return u(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return u(r(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=Xu({typed:t}),o=Qu({typed:t,equalScalar:n}),s=Ku({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(gf,{"number, number":Ao,"BigNumber, BigNumber":go,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})})),xf="kron",bf=W(xf,["typed","matrix","multiplyScalar"],(e=>{var{typed:t,matrix:r,multiplyScalar:n}=e;return t(xf,{"Matrix, Matrix":function(e,t){return r(i(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(i(e.toArray(),t))},"Array, Matrix":function(e,t){return r(i(e,t.toArray()))},"Array, Array":i});function i(e,t){if(1===je(e).length&&(e=[e]),1===je(t).length&&(t=[t]),je(e).length>2||je(t).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(e.length)+", y = "+JSON.stringify(t.length)+")");var r=[],i=[];return e.map((function(e){return t.map((function(t){return i=[],r.push(i),e.map((function(e){return t.map((function(t){return i.push(n(e,t))}))}))}))}))&&r}})),wf=W("transpose",["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t("transpose",{Array:function(e){return this(r(e)).valueOf()},Matrix:function(e){var t,r=e.size();switch(r.length){case 1:t=e.clone();break;case 2:var n=r[0],i=r[1];if(0===i)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+De(r)+")");switch(e.storage()){case"dense":t=function(e,t,r){for(var n,i=e._data,a=[],o=0;o{var{number:t,bignumber:r,fraction:n}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},a={number:e=>t(e),BigNumber:r?e=>r(e):cr,Fraction:n?e=>n(e):lr};return function(e,t){var r=L(e);if(!(r in i))throw new TypeError("Cannot convert "+e+' of type "'+r+'"; valid input types are '+Object.keys(i).join(", "));if(!(t in a))throw new TypeError("Cannot convert "+e+' to type "'+t+'"; valid output types are '+Object.keys(a).join(", "));return t===r?e:a[t](e)}})),Mf=W("and",["typed","matrix","equalScalar","zeros","not"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,not:a}=e,o=nc({typed:t,equalScalar:n}),s=cc({typed:t,equalScalar:n}),u=oc({typed:t,equalScalar:n}),c=ec({typed:t}),l=tc({typed:t});return t("and",{"number, number":Uo,"Complex, Complex":function(e,t){return!(0===e.re&&0===e.im||0===t.re&&0===t.im)},"BigNumber, BigNumber":function(e,t){return!(e.isZero()||t.isZero()||e.isNaN()||t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return a(t)?i(e.size(),e.storage()):u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return a(t)?i(e.size(),e.storage()):l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return a(e)?i(e.size(),e.storage()):u(t,e,this,!0)},"any, DenseMatrix":function(e,t){return a(e)?i(e.size(),e.storage()):l(t,e,this,!0)},"Array, any":function(e,t){return this(r(e),t).valueOf()},"any, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Sf="smallerEq",Ef=W(Sf,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Sf,{"boolean, boolean":function(e,t){return e<=t},"number, number":function(e,t){return e<=t||Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.lte(t)||Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return 1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),Af="sort",Of=W(Af,["typed","matrix","compare","compareNatural"],(e=>{var{typed:t,matrix:r,compare:n,compareNatural:i}=e,a=n,o=(e,t)=>-n(e,t);return t(Af,{Array:function(e){return u(e),e.sort(a)},Matrix:function(e){return c(e),r(e.toArray().sort(a),e.storage())},"Array, function":function(e,t){return u(e),e.sort(t)},"Matrix, function":function(e,t){return c(e),r(e.toArray().sort(t),e.storage())},"Array, string":function(e,t){return u(e),e.sort(s(t))},"Matrix, string":function(e,t){return c(e),r(e.toArray().sort(s(t)),e.storage())}});function s(e){if("asc"===e)return a;if("desc"===e)return o;if("natural"===e)return i;throw new Error('String "asc", "desc", or "natural" expected')}function u(e){if(1!==je(e).length)throw new Error("One dimensional array expected")}function c(e){if(1!==e.size().length)throw new Error("One dimensional matrix expected")}})),Cf=W("cot",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("cot",{number:bs,Complex:function(e){return e.cot()},BigNumber:function(e){return new r(1).div(e.tan())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),_f="setDistinct",Tf=W(_f,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(_f,{"Array | Matrix":function(e){var t;if(0===n(r(e),new a(0)))t=[];else{var s=et(Array.isArray(e)?e:e.toArray()).sort(i);(t=[]).push(s[0]);for(var u=1;u{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(Bf,{"Array | Matrix":function(e){if(0===n(r(e),new a(0)))return[];for(var t=et(Array.isArray(e)?e:e.toArray()).sort(i),s=[],u=0;u.toString(2).length<=t.length;)s.push(o(t,u.toString(2).split("").reverse())),u++;return function(e){for(var t=[],r=e.length-1;r>0;r--)for(var n=0;ne[n+1].length&&(t=e[n],e[n]=e[n+1],e[n+1]=t);return e}(s)}});function o(e,t){for(var r=[],n=0;n{var{typed:t,Index:r}=e;return t(zf,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var t=e.map((function(e){return a(e)?e.toNumber():Array.isArray(e)||f(e)?e.map((function(e){return a(e)?e.toNumber():e})):e})),n=new r;return r.apply(n,t),n}})})),If="factorial",kf=W(If,["typed","gamma"],(e=>{var{typed:t,gamma:r}=e;return t(If,{number:function(e){if(e<0)throw new Error("Value must be non-negative");return r(e+1)},BigNumber:function(e){if(e.isNegative())throw new Error("Value must be non-negative");return r(e.plus(1))},"Array | Matrix":function(e){return $t(e,this)}})})),Rf="permutations",Ff=W(Rf,["typed","factorial"],(e=>{var{typed:t,factorial:r}=e;return t(Rf,{"number | BigNumber":r,"number, number":function(e,t){if(!ce(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!ce(t)||t<0)throw new TypeError("Positive integer value expected in function permutations");if(t>e)throw new TypeError("second argument k must be less than or equal to first argument n");return Js(e-t+1,e)},"BigNumber, BigNumber":function(e,t){var r,n;if(!Uf(e)||!Uf(t))throw new TypeError("Positive integer value expected in function permutations");if(t.gt(e))throw new TypeError("second argument k must be less than or equal to first argument n");for(r=e.mul(0).add(1),n=e.minus(t).plus(1);n.lte(e);n=n.plus(1))r=r.times(n);return r}})}));function Uf(e){return e.isInteger()&&e.gte(0)}var Pf="matrixFromRows",jf=W(Pf,["typed","matrix","flatten","size"],(e=>{var{typed:t,matrix:r,flatten:n,size:i}=e;return t(Pf,{"...Array":function(e){return a(e)},"...Matrix":function(e){return r(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one row is needed to construct a matrix.");var t=o(e[0]),r=[];for(var i of e){var a=o(i);if(a!==t)throw new TypeError("The vectors had different length: "+(0|t)+" ≠ "+(0|a));r.push(n(i))}return r}function o(e){var t=i(e);if(1===t.length)return t[0];if(2===t.length){if(1===t[0])return t[1];if(1===t[1])return t[0];throw new TypeError("At least one of the arguments is not a vector.")}throw new TypeError("Only one- or two-dimensional vectors are supported.")}})),Lf="subtract",Hf=W(Lf,["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,addScalar:i,unaryMinus:a,DenseMatrix:o}=e,s=Xu({typed:t}),u=ic({typed:t}),c=ac({typed:t,equalScalar:n}),l=Ku({typed:t,DenseMatrix:o}),f=ec({typed:t}),p=tc({typed:t});return t(Lf,{"number, number":function(e,t){return e-t},"Complex, Complex":function(e,t){return e.sub(t)},"BigNumber, BigNumber":function(e,t){return e.minus(t)},"Fraction, Fraction":function(e,t){return e.sub(t)},"Unit, Unit":function(e,t){if(null===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var r=e.clone();return r.value=this(r.value,t.value),r.fixPrefix=!1,r},"SparseMatrix, SparseMatrix":function(e,t){return $f(e,t),c(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return $f(e,t),u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return $f(e,t),s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return $f(e,t),f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return l(e,a(t),i)},"DenseMatrix, any":function(e,t){return p(e,t,this)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(r(t),e,this,!0).valueOf()}})}));function $f(e,t){var r=e.size(),n=t.size();if(r.length!==n.length)throw new Ue(r.length,n.length)}var Gf="cross",Vf=W(Gf,["typed","matrix","subtract","multiply"],(e=>{var{typed:t,matrix:r,subtract:n,multiply:i}=e;return t(Gf,{"Matrix, Matrix":function(e,t){return r(a(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(a(e.toArray(),t))},"Array, Matrix":function(e,t){return r(a(e,t.toArray()))},"Array, Array":a});function a(e,t){var r=Math.max(je(e).length,je(t).length);e=Ye(e),t=Ye(t);var a=je(e),o=je(t);if(1!==a.length||1!==o.length||3!==a[0]||3!==o[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+a.join(", ")+"], B = ["+o.join(", ")+"])");var s=[n(i(e[1],t[2]),i(e[2],t[1])),n(i(e[2],t[0]),i(e[0],t[2])),n(i(e[0],t[1]),i(e[1],t[0]))];return r>1?[s]:s}})),Zf="prod",Wf=W(Zf,["typed","config","multiplyScalar","numeric"],(e=>{var{typed:t,config:r,multiplyScalar:n,numeric:i}=e;return t(Zf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("prod(A, dim) is not yet supported")},"...":function(e){return a(e)}});function a(e){var t;if(Ht(e,(function(e){try{t=void 0===t?e:n(t,e)}catch(t){throw Gr(t,"prod",e)}})),"string"==typeof t&&(t=i(t,r.number)),void 0===t)throw new Error("Cannot calculate prod of an empty array");return t}})),Jf="equal",Yf=W(Jf,["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Jf,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:n(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,n)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,n,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,n,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,n)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,n,!1)},"DenseMatrix, any":function(e,t){return c(e,t,n,!1)},"any, SparseMatrix":function(e,t){return s(t,e,n,!0)},"any, DenseMatrix":function(e,t){return c(t,e,n,!0)},"Array, any":function(e,t){return c(r(e),t,n,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,n,!0).valueOf()}})})),Xf=(W(Jf,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return t(Jf,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:r(e,t)}})})),"setCartesian"),Qf=W(Xf,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Xf,{"Array | Matrix, Array | Matrix":function(e,t){var s=[];if(0!==n(r(e),new a(0))&&0!==n(r(t),new a(0))){var u=et(Array.isArray(e)?e:e.toArray()).sort(i),c=et(Array.isArray(t)?t:t.toArray()).sort(i);s=[];for(var l=0;l{var{typed:t,size:r,concat:n,subset:i,setDifference:a,Index:o}=e;return t(Kf,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new o(0)))return et(t);if(0===i(r(t),new o(0)))return et(e);var s=et(e),u=et(t);return n(a(s,u),a(u,s))}})})),tp=W("ceil",["typed","config","round","matrix","equalScalar"],(e=>{var{typed:t,config:r,round:n,matrix:i,equalScalar:a}=e,o=oc({typed:t,equalScalar:a}),s=tc({typed:t});return t("ceil",{number:function(e){return Se(e,n(e),r.epsilon)?n(e):Ua(e)},"number, number":function(e,t){if(Se(e,n(e,t),r.epsilon))return n(e,t);var[i,a]="".concat(e,"e").split("e"),o=Math.ceil(Number("".concat(i,"e").concat(Number(a)+t)));return[i,a]="".concat(o,"e").split("e"),Number("".concat(i,"e").concat(Number(a)-t))},Complex:function(e){return e.ceil()},"Complex, number":function(e,t){return e.ceil(t)},BigNumber:function(e){return Na(e,n(e),r.epsilon)?n(e):e.ceil()},"BigNumber, BigNumber":function(e,t){return Na(e,n(e,t),r.epsilon)?n(e,t):e.toDecimalPlaces(t.toNumber(),Qn.ROUND_CEIL)},Fraction:function(e){return e.ceil()},"Fraction, number":function(e,t){return e.ceil(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"Array | Matrix, number":function(e,t){return $t(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"number | Complex | BigNumber, Array":function(e,t){return s(i(t),e,this,!0).valueOf()}})})),rp=W("xor",["typed","matrix","DenseMatrix"],(e=>{var{typed:t,matrix:r,DenseMatrix:n}=e,i=ic({typed:t}),a=yc({typed:t,DenseMatrix:n}),o=sc({typed:t,DenseMatrix:n}),s=ec({typed:t}),u=tc({typed:t});return t("xor",{"number, number":Fo,"Complex, Complex":function(e,t){return(0!==e.re||0!==e.im)!=(0!==t.re||0!==t.im)},"BigNumber, BigNumber":function(e,t){return(!e.isZero()&&!e.isNaN())!=(!t.isZero()&&!t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),np="count",ip=W(np,["typed","size","prod"],(e=>{var{typed:t,size:r,prod:n}=e;return t(np,{string:function(e){return e.length},"Matrix | Array":function(e){return n(r(e))}})})),ap="ctranspose",op=W(ap,["typed","transpose","conj"],(e=>{var{typed:t,transpose:r,conj:n}=e;return t(ap,{any:function(e){return n(r(e))}})})),sp="deepEqual",up=W(sp,["typed","equal"],(e=>{var{typed:t,equal:r}=e;return t(sp,{"any, any":function(e,t){return n(e.valueOf(),t.valueOf())}});function n(e,t){if(Array.isArray(e)){if(Array.isArray(t)){var i=e.length;if(i!==t.length)return!1;for(var a=0;a{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(cp,{"Array | Matrix, Array | Matrix":function(e,t){if(0===n(r(e),new a(0)))return!0;if(0===n(r(t),new a(0)))return!1;for(var o,s=ot(et(Array.isArray(e)?e:e.toArray()).sort(i)),u=ot(et(Array.isArray(t)?t:t.toArray()).sort(i)),c=0;c{var{typed:t,Complex:r,matrix:n,ceil:i,floor:a}=e,o=tc({typed:t});return t("fix",{number:function(e){return e>0?a(e):i(e)},"number, number | BigNumber":function(e,t){return e>0?a(e,t):i(e,t)},Complex:function(e){return new r(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},"Complex, number | BigNumber":function(e,t){return new r(e.re>0?a(e.re,t):i(e.re,t),e.im>0?a(e.im,t):i(e.im,t))},BigNumber:function(e){return e.isNegative()?i(e):a(e)},"BigNumber, number | BigNumber":function(e,t){return e.isNegative()?i(e,t):a(e,t)},Fraction:function(e){return e.s<0?e.ceil():e.floor()},"Fraction, number | BigNumber":function(e,t){return e.s<0?e.ceil(t):e.floor(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"Array | Matrix, number | BigNumber":function(e,t){return $t(e,(e=>this(e,t)),!0)},"number | Complex | BigNumber, Array":function(e,t){return o(n(t),e,this,!0).valueOf()}})})),pp="divideScalar",mp=W(pp,["typed","numeric"],(e=>{var{typed:t,numeric:r}=e;return t(pp,{"number, number":function(e,t){return e/t},"Complex, Complex":function(e,t){return e.div(t)},"BigNumber, BigNumber":function(e,t){return e.div(t)},"Fraction, Fraction":function(e,t){return e.div(t)},"Unit, number | Fraction | BigNumber":function(e,t){var n=e.clone(),i=r(1,L(t));return n.value=this(null===n.value?n._normalize(i):n.value,t),n},"number | Fraction | BigNumber, Unit":function(e,t){var n=t.clone();n=n.pow(-1);var i=r(1,L(e));return n.value=this(e,null===t.value?t._normalize(i):t.value),n},"Unit, Unit":function(e,t){return e.divide(t)}})})),hp="nthRoots",dp=W(hp,["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,Complex:i}=e,a=[function(e){return new i(e,0)},function(e){return new i(0,e)},function(e){return new i(-e,0)},function(e){return new i(0,-e)}];function o(e,t){if(t<0)throw new Error("Root must be greater than zero");if(0===t)throw new Error("Root must be non-zero");if(t%1!=0)throw new Error("Root must be an integer");if(0===e||0===e.abs())return[new i(0,0)];var r,n="number"==typeof e;(n||0===e.re||0===e.im)&&(r=n?2*+(e<0):0===e.im?2*+(e.re<0):2*+(e.im<0)+1);for(var o=e.arg(),s=e.abs(),u=[],c=Math.pow(s,1/t),l=0;l{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(gp,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=(t=u(e,t,!0))._data,c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=[],d=0;dd&&(v.push(f[N]),x.push(M))}if(o(g,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var S=n(y,g),E=0,A=x.length;E{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(xp,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=0;hh&&(v.push(f[M]),x.push(S))}if(o(N,0))if(o(g[h],0)){if(0===y){var E=[...g];E[h]=1;for(var A=0,O=x.length;Anew s({data:e.map((e=>[e])),size:[c,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(r(e),t).map((e=>e.valueOf()))}});function c(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1],p=0;pnew s({data:e.map((e=>[e])),size:[l,1]})))}})),wp=W("Spa",["addScalar","equalScalar","FibonacciHeap"],(e=>{var{addScalar:t,equalScalar:r,FibonacciHeap:n}=e;function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new n}return i.prototype.type="Spa",i.prototype.isSpa=!0,i.prototype.set=function(e,t){if(this._values[e])this._values[e].value=t;else{var r=this._heap.insert(e,t);this._values[e]=r}},i.prototype.get=function(e){var t=this._values[e];return t?t.value:0},i.prototype.accumulate=function(e,r){var n=this._values[e];n?n.value=t(n.value,r):(n=this._heap.insert(e,r),this._values[e]=n)},i.prototype.forEach=function(e,t,n){var i=this._heap,a=this._values,o=[],s=i.extractMinimum();for(s&&o.push(s);s&&s.key<=t;)s.key>=e&&(r(s.value,0)||n(s.key,s.value,this)),(s=i.extractMinimum())&&o.push(s);for(var u=0;u{var{typed:t,size:r,concat:n,subset:i,setIntersect:a,setSymDifference:o,Index:s}=e;return t(Np,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new s(0)))return et(t);if(0===i(r(t),new s(0)))return et(e);var u=et(e),c=et(t);return n(o(u,c),a(u,c))}})})),Sp=W("lup",["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],(e=>{var{typed:t,matrix:r,abs:n,addScalar:i,divideScalar:a,multiplyScalar:o,subtract:s,larger:u,equalScalar:c,unaryMinus:l,DenseMatrix:f,SparseMatrix:p,Spa:m}=e;return t("lup",{DenseMatrix:function(e){return h(e)},SparseMatrix:function(e){return function(e){var t,r,i,s=e._size[0],f=e._size[1],h=Math.min(s,f),d=e._values,y=e._index,g=e._ptr,v=[],x=[],b=[],w=[s,h],N=[],M=[],S=[],E=[h,f],A=[],O=[];for(t=0;t0&&e.forEach(0,r-1,(function(t,r){p._forEachRow(t,v,x,b,(function(n,i){n>t&&e.accumulate(n,l(o(i,r)))}))}));var C,_,T,B,q=r,z=e.get(r),D=n(z);e.forEach(r+1,s-1,(function(e,t){var r=n(t);u(r,D)&&(q=e,D=r,z=t)})),r!==q&&(p._swapRows(r,q,w[1],v,x,b),p._swapRows(r,q,E[1],N,M,S),e.swap(r,q),_=q,T=O[C=r],B=O[_],A[T]=_,A[B]=C,O[C]=B,O[_]=T),e.forEach(0,s-1,(function(e,t){e<=r?(N.push(t),M.push(e)):(t=a(t,z),c(t,0)||(v.push(t),x.push(e)))}))};for(r=0;r0)for(t=0;t=0;){var u=r[o+s],c=r[n+u];-1===c?(s--,a[t++]=u):(r[n+u]=r[i+c],r[o+ ++s]=c)}return t}function Ap(e){return-e-2}var Op=W("csAmd",["add","multiply","transpose"],(e=>{var{add:t,multiply:r,transpose:n}=e;return function(e,o){if(!o||e<=0||e>3)return null;var s=o._size,u=s[0],c=s[1],l=0,f=Math.max(16,10*Math.sqrt(c)),p=function(e,i,a,o,s){var u=n(i);if(1===e&&o===a)return t(i,u);if(2===e){for(var c=u._index,l=u._ptr,f=0,p=0;ps))for(var h=l[p+1];mo)r[s+p]=0,r[i+p]=-1,f++,t[p]=Ap(e),r[s+e]++;else{var h=r[u+m];-1!==h&&(c[h]=p),r[l+p]=r[u+m],r[u+m]=p}}return f}(c,T,z,F,R,U,f,D,k,j,I),$=0;HG?(v=d,x=W,b=z[0+d]-G):(x=T[v=_[W++]],b=z[0+v]),g=1;g<=b;g++)(w=z[D+(m=_[x++])])<=0||(Z+=w,z[D+m]=-w,_[Y++]=m,-1!==z[I+m]&&(j[z[I+m]]=j[m]),-1!==j[m]?z[I+j[m]]=z[I+m]:z[k+z[F+m]]=z[I+m]);v!==d&&(T[v]=Ap(d),z[U+v]=0)}for(0!==G&&(B=Y),z[F+d]=Z,T[d]=J,z[0+d]=Y-J,z[R+d]=-2,L=i(L,l,z,U,c),N=J;N=L?z[U+v]-=w:0!==z[U+v]&&(z[U+v]=z[F+v]+X)}for(N=J;N0?(C+=Q,_[A++]=v,O+=v):(T[v]=Ap(d),z[U+v]=0)}z[R+m]=A-S+1;var K=A,ee=S+z[0+m];for(W=E+1;W=0))for(m=z[P+(O=j[m])],z[P+O]=-1;-1!==m&&-1!==z[I+m];m=z[I+m],L++){for(b=z[0+m],M=z[R+m],W=T[m]+1;W<=T[m]+b-1;W++)z[U+_[W]]=L;var re=m;for(h=z[I+m];-1!==h;){var ne=z[0+h]===b&&z[R+h]===M;for(W=T[h]+1;ne&&W<=T[h]+b-1;W++)z[U+_[W]]!==L&&(ne=0);ne?(T[h]=Ap(m),z[D+m]+=z[D+h],z[D+h]=0,z[R+h]=-1,h=z[I+h],z[I+re]=h):(re=h,h=z[I+h])}}for(W=J,N=J;N=0;h--)z[D+h]>0||(z[I+h]=z[k+T[h]],z[k+T[h]]=h);for(v=c;v>=0;v--)z[D+v]<=0||-1!==T[v]&&(z[I+v]=z[k+T[v]],z[k+T[v]]=v);for(d=0,m=0;m<=c;m++)-1===T[m]&&(d=Ep(m,d,z,k,I,q,U));return q.splice(q.length-1,1),q};function i(e,t,r,n,i){if(e<2||e+t<0){for(var a=0;a{var{transpose:t}=e;return function(e,r,n,i){if(!e||!r||!n)return null;var a,o,s,u,c,l,f,p=e._size,m=p[0],h=p[1],d=4*h+(i?h+m+1:0),y=[],g=h,v=2*h,x=3*h,b=4*h,w=5*h+1;for(s=0;s=1&&N[o]++,2===A.jleaf&&N[A.q]--}-1!==r[o]&&(y[0+o]=r[o])}for(o=0;o{var{add:t,multiply:r,transpose:n}=e,i=Op({add:t,multiply:r,transpose:n}),a=_p({transpose:n});return function(e,t,r){var n,o=t._ptr,s=t._size[1],u={};if(u.q=i(e,t),e&&!u.q)return null;if(r){var c=e?function(e,t,r,n){for(var i=e._values,a=e._index,o=e._ptr,s=e._size,u=e._datatype,c=s[0],l=s[1],f=null,p=[],m=[],h=0,d=0;d=0;r--)-1!==e[r]&&(a[o+r]=a[0+e[r]],a[0+e[r]]=r);for(r=0;r=0;u--)for(l=r[u],f=r[u+1],c=l;c=0;s--)m[s]=-1,-1!==(u=h[s])&&(0==d[v+u]++&&(d[g+u]=s),d[0+s]=d[y+u],d[y+u]=s);for(t.lnz=0,t.m2=a,u=0;u=0;){e=n[f];var p=i?i[e]:e;Bp(c,e)||(qp(c,e),n[l+f]=p<0?0:zp(c[p]));var m=1;for(o=n[l+f],s=p<0?0:zp(c[p+1]);o{var{divideScalar:t,multiply:r,subtract:n}=e;return function(e,i,a,o,s,u,c){var l,f,p,m,h=e._values,d=e._index,y=e._ptr,g=e._size[1],v=i._values,x=i._index,b=i._ptr,w=function(e,t,r,n,i){var a,o,s,u=e._ptr,c=e._size,l=t._index,f=t._ptr,p=c[1],m=p;for(o=f[r],s=f[r+1],a=o;a{var{abs:t,divideScalar:r,multiply:n,subtract:i,larger:a,largerEq:o,SparseMatrix:s}=e,u=Ip({divideScalar:r,multiply:n,subtract:i});return function(e,i,c){if(!e)return null;var l,f=e._size[1],p=100,m=100;i&&(l=i.q,p=i.lnz||p,m=i.unz||m);var h,d,y=[],g=[],v=[],x=new s({values:y,index:g,ptr:v,size:[f,f]}),b=[],w=[],N=[],M=new s({values:b,index:w,ptr:N,size:[f,f]}),S=[],E=[],A=[];for(h=0;h{var{typed:t,abs:r,add:n,multiply:i,transpose:a,divideScalar:o,subtract:s,larger:u,largerEq:c,SparseMatrix:l}=e,f=Tp({add:n,multiply:i,transpose:a}),p=kp({abs:r,divideScalar:o,multiply:i,subtract:s,larger:u,largerEq:c,SparseMatrix:l});return t("slu",{"SparseMatrix, number, number":function(e,t,r){if(!ce(t)||t<0||t>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(r<0||r>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var n=f(t,e,!1),i=p(e,n,r);return{L:i.L,U:i.U,p:i.pinv,q:n.q,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\np: "+this.p.toString()+(this.q?"\nq: "+this.q.toString():"")+"\n"}}}})})),Fp=W("det",["typed","matrix","subtract","multiply","unaryMinus","lup"],(e=>{var{typed:t,matrix:r,subtract:n,multiply:i,unaryMinus:a,lup:o}=e;return t("det",{any:function(e){return $(e)},"Array | Matrix":function(e){var t;switch((t=f(e)?e.size():Array.isArray(e)?(e=r(e)).size():[]).length){case 0:return $(e);case 1:if(1===t[0])return $(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:var s=t[0];if(s===t[1])return function(e,t,r){if(1===t)return $(e[0][0]);if(2===t)return n(i(e[0][0],e[1][1]),i(e[1][0],e[0][1]));for(var s=o(e),u=s.U[0][0],c=1;c=t)break;for(var m=f,h=0;!p[s.p[m]];)p[s.p[m]]=!0,m=s.p[m],h++;h%2==0&&l++}return l%2==0?u:a(u)}(e.clone().valueOf(),s);throw new RangeError("Matrix must be square (size: "+De(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+De(t)+")")}}})})),Up="distance",Pp=W(Up,["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],(e=>{var{typed:t,addScalar:r,subtract:n,multiplyScalar:i,divideScalar:o,unaryMinus:s,sqrt:u,abs:c}=e;return t(Up,{"Array, Array, Array":function(e,t,r){if(2===e.length&&2===t.length&&2===r.length){if(!f(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!f(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!f(r))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var a=o(n(r[1],r[0]),n(t[1],t[0])),u=i(i(a,a),t[0]),c=s(i(a,t[0])),l=e[1];return y(e[0],e[1],u,c,l)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(e,t,r){if(2===Object.keys(e).length&&2===Object.keys(t).length&&2===Object.keys(r).length){if(!f(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!f(t))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!f(r))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"lineOnePtX"in t&&"lineOnePtY"in t&&"lineTwoPtX"in r&&"lineTwoPtY"in r){var a=o(n(r.lineTwoPtY,r.lineTwoPtX),n(t.lineOnePtY,t.lineOnePtX)),u=i(i(a,a),t.lineOnePtX),c=s(i(a,t.lineOnePtX)),l=e.pointX;return y(e.pointX,e.pointY,u,c,l)}throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(e,t){if(2===e.length&&3===t.length){if(!f(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!p(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return y(e[0],e[1],t[0],t[1],t[2])}if(3===e.length&&6===t.length){if(!p(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!h(t))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return g(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}if(e.length===t.length&&e.length>0){if(!m(e))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!m(t))throw new TypeError("All values of an array should be numbers or BigNumbers");return v(e,t)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,t){if(2===Object.keys(e).length&&3===Object.keys(t).length){if(!f(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"xCoeffLine"in t&&"yCoeffLine"in t&&"constant"in t)return y(e.pointX,e.pointY,t.xCoeffLine,t.yCoeffLine,t.constant);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&6===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!h(t))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"x0"in t&&"y0"in t&&"z0"in t&&"a"in t&&"b"in t&&"c"in t)return g(e.pointX,e.pointY,e.pointZ,t.x0,t.y0,t.z0,t.a,t.b,t.c);throw new TypeError("Key names do not match")}if(2===Object.keys(e).length&&2===Object.keys(t).length){if(!f(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!f(t))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointTwoX"in t&&"pointTwoY"in t)return v([e.pointOneX,e.pointOneY],[t.pointTwoX,t.pointTwoY]);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&3===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointOneZ"in e&&"pointTwoX"in t&&"pointTwoY"in t&&"pointTwoZ"in t)return v([e.pointOneX,e.pointOneY,e.pointOneZ],[t.pointTwoX,t.pointTwoY,t.pointTwoZ]);throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},Array:function(e){if(!function(e){if(2===e[0].length&&l(e[0][0])&&l(e[0][1])){if(e.some((e=>2!==e.length||!l(e[0])||!l(e[1]))))return!1}else{if(!(3===e[0].length&&l(e[0][0])&&l(e[0][1])&&l(e[0][2])))return!1;if(e.some((e=>3!==e.length||!l(e[0])||!l(e[1])||!l(e[2]))))return!1}return!0}(e))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return function(e){for(var t=[],r=[],n=[],i=0;i{var{typed:t,addScalar:r,subtract:n,multiplyScalar:i,divideScalar:a,pow:o,factorial:s,combinations:u,isNegative:c,isInteger:l,larger:f}=e;return t(jp,{"number | BigNumber, number | BigNumber":function(e,t){if(!l(e)||c(e)||!l(t)||c(t))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(f(t,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");for(var p=s(t),m=0,h=0;h<=t;h++){var d=o(-1,n(t,h)),y=u(t,h),g=o(h,e);m=r(m,i(i(y,g),d))}return a(m,p)}})})),Hp="catalan",$p=W(Hp,["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],(e=>{var{typed:t,addScalar:r,divideScalar:n,multiplyScalar:i,combinations:a,isNegative:o,isInteger:s}=e;return t(Hp,{"number | BigNumber":function(e){if(!s(e)||o(e))throw new TypeError("Non-negative integer value expected in function catalan");return n(a(i(e,2),e),r(e,1))}})})),Gp=W("log",["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,Complex:i}=e;return t("log",{number:function(e){return e>=0||r.predictable?Ga(e):new i(e,0).log()},Complex:function(e){return e.log()},BigNumber:function(e){return!e.isNegative()||r.predictable?e.ln():new i(e.toNumber(),0).log()},"Array | Matrix":function(e){return $t(e,this)},"any, any":function(e,t){return n(this(e),this(t))}})})),Vp="dotDivide",Zp=W(Vp,["typed","matrix","equalScalar","divideScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,divideScalar:i,DenseMatrix:a}=e,o=nc({typed:t,equalScalar:n}),s=ic({typed:t}),u=yc({typed:t,DenseMatrix:a}),c=oc({typed:t,equalScalar:n}),l=sc({typed:t,DenseMatrix:a}),f=ec({typed:t}),p=tc({typed:t});return t(Vp,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,i)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return c(e,t,i,!1)},"DenseMatrix, any":function(e,t){return p(e,t,i,!1)},"any, SparseMatrix":function(e,t){return l(t,e,i,!0)},"any, DenseMatrix":function(e,t){return p(t,e,i,!0)},"Array, any":function(e,t){return p(r(e),t,i,!1).valueOf()},"any, Array":function(e,t){return p(r(t),e,i,!0).valueOf()}})})),Wp="usolveAll",Jp=W(Wp,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(Wp,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=l-1;h>=0;h--)for(var d=r.length,y=0;y=b;N--){var M=p[N];M===h?w=f[N]:Mnew s({data:e.map((e=>[e])),size:[c,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(r(e),t).map((e=>e.valueOf()))}});function c(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1]-1;f>=0;f--)for(var p=r.length,m=0;m=0;y--)d[y]=a(d[y],c[y][f]);r.push(d)}}else{if(0===m)return[];r.splice(m,1),m-=1,p-=1}else{h[f]=n(h[f],c[f][f]);for(var g=f-1;g>=0;g--)h[g]=a(h[g],i(h[f],c[g][f]))}}return r.map((e=>new s({data:e.map((e=>[e])),size:[l,1]})))}})),Yp="hypot",Xp=W(Yp,["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],(e=>{var{typed:t,abs:r,addScalar:n,divideScalar:i,multiplyScalar:a,sqrt:o,smaller:s,isPositive:u}=e;return t(Yp,{"... number | BigNumber":function(e){for(var t=0,c=0,l=0;l{var{typed:r,matrix:n,zeros:i,identity:a,isZero:o,equal:s,sign:u,sqrt:c,conj:l,unaryMinus:f,addScalar:p,divideScalar:m,multiplyScalar:h,subtract:d,complex:y}=t;return e(r("qr",{DenseMatrix:function(e){return v(e)},SparseMatrix:function(e){return function(e){throw new Error("qr not implemented for sparse matrices yet")}()},Array:function(e){var t=v(n(e));return{Q:t.Q.valueOf(),R:t.R.valueOf()}}}),{_denseQRimpl:g});function g(e){var t,r,n,y=e._size[0],g=e._size[1],v=a([y],"dense"),x=v._data,b=e.clone(),w=b._data,N=i([y],"");for(n=0;n0)for(var n="Complex"===r[0][0].type?y(0):0,i=0;i{var{typed:t,matrix:r,divideScalar:n,addScalar:i,multiply:a,unaryMinus:o,det:s,identity:u,abs:c}=e;return t("inv",{"Array | Matrix":function(e){var t=f(e)?e.size():je(e);switch(t.length){case 1:if(1===t[0])return f(e)?r([n(1,e.valueOf()[0])]):[n(1,e[0])];throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:var i=t[0],a=t[1];if(i===a)return f(e)?r(l(e.valueOf(),i,a),e.storage()):l(e,i,a);throw new RangeError("Matrix must be square (size: "+De(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+De(t)+")")}},any:function(e){return n(1,e)}});function l(e,t,r){var l,f,p,m,h;if(1===t){if(0===(m=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero");return[[n(1,m)]]}if(2===t){var d=s(e);if(0===d)throw Error("Cannot calculate inverse, determinant is zero");return[[n(e[1][1],d),n(o(e[0][1]),d)],[n(o(e[1][0]),d),n(e[0][0],d)]]}var y=e.concat();for(l=0;lx&&(x=c(y[l][v]),b=l),l++;if(0===x)throw Error("Cannot calculate inverse, determinant is zero");(l=b)!==v&&(h=y[v],y[v]=y[l],y[l]=h,h=g[v],g[v]=g[l],g[l]=h);var w=y[v],N=g[v];for(l=0;l{var{typed:t,abs:r,add:n,identity:i,inv:a,multiply:o}=e;return t(em,{Matrix:function(e){var t=e.size();if(2!==t.length||t[0]!==t[1])throw new RangeError("Matrix must be square (size: "+De(t)+")");for(var u=t[0],c=function(e,t){for(var r=0;r<30;r++)for(var n=0;n<=r;n++){var i=r-n;if(s(e,n,i)<1e-15)return{q:n,j:i}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}(function(e){for(var t=e.size()[0],n=0,i=0;i1&&(g=o(g,p),v=-v),m=n(m,o(y=y*(l-x+1)/((2*l-x+1)*x),g)),d=n(d,o(y*v,g));for(var b=o(a(d),m),w=0;w{var{typed:t,matrix:r,multiply:n,equalScalar:i,divideScalar:a,inv:o}=e,s=oc({typed:t,equalScalar:i}),u=tc({typed:t});return t("divide",G({"Array | Matrix, Array | Matrix":function(e,t){return n(e,o(t))},"DenseMatrix, any":function(e,t){return u(e,t,a,!1)},"SparseMatrix, any":function(e,t){return s(e,t,a,!1)},"Array, any":function(e,t){return u(r(e),t,a,!1).valueOf()},"any, Array | Matrix":function(e,t){return n(e,o(t))}},a.signatures))})),nm="kldivergence",im=W(nm,["typed","matrix","divide","sum","multiply","dotDivide","log","isNumeric"],(e=>{var{typed:t,matrix:r,divide:n,sum:i,multiply:a,dotDivide:o,log:s,isNumeric:u}=e;return t(nm,{"Array, Array":function(e,t){return c(r(e),r(t))},"Matrix, Array":function(e,t){return c(e,r(t))},"Array, Matrix":function(e,t){return c(r(e),t)},"Matrix, Matrix":function(e,t){return c(e,t)}});function c(e,t){var r=t.size().length,c=e.size().length;if(r>1)throw new Error("first object must be one dimensional");if(c>1)throw new Error("second object must be one dimensional");if(r!==c)throw new Error("Length of two vectors must be equal");if(0===i(e))throw new Error("Sum of elements in first object must be non zero");if(0===i(t))throw new Error("Sum of elements in second object must be non zero");var l=n(e,i(e)),f=n(t,i(t)),p=i(a(l,s(o(l,f))));return u(p)?p:Number.NaN}})),am="bellNumbers",om=W(am,["typed","addScalar","isNegative","isInteger","stirlingS2"],(e=>{var{typed:t,addScalar:r,isNegative:n,isInteger:i,stirlingS2:a}=e;return t(am,{"number | BigNumber":function(e){if(!i(e)||n(e))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var t=0,o=0;o<=e;o++)t=r(t,a(e,o));return t}})})),sm="log1p",um=W(sm,["typed","config","divideScalar","log","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,log:i,Complex:a}=e;return t(sm,{number:function(e){return e>=-1||r.predictable?me(e):o(new a(e,0))},Complex:o,BigNumber:function(e){var t=e.plus(1);return!t.isNegative()||r.predictable?t.ln():o(new a(e.toNumber(),0))},"Array | Matrix":function(e){return $t(e,this)},"any, any":function(e,t){return n(this(e),i(t))}});function o(e){var t=e.re+1;return new a(Math.log(Math.sqrt(t*t+e.im*e.im)),Math.atan2(e.im,t))}}));function cm(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function lm(e){for(var t=1;t{var r,n,i,{on:a,config:s,addScalar:c,subtract:l,multiplyScalar:f,divideScalar:p,pow:m,abs:h,fix:d,round:y,equal:g,isNumeric:v,format:x,number:b,Complex:w,BigNumber:N,Fraction:M}=t,S=b;function E(e,t){if(!(this instanceof E))throw new Error("Constructor must be called with the new operator");if(null!=e&&!v(e)&&!o(e))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(void 0!==t&&("string"!=typeof t||""===t))throw new TypeError("Second parameter in Unit constructor must be a string");if(void 0!==t){var r=E.parse(t);this.units=r.units,this.dimensions=r.dimensions}else{this.units=[{unit:U,prefix:I.NONE,power:0}],this.dimensions=[];for(var n=0;n="0"&&e<="9"}function C(){n++,i=r.charAt(n)}function _(e){n=e,i=r.charAt(n)}function T(){var e="",t=n;if("+"===i?C():"-"===i&&(e+=i,C()),!function(e){return e>="0"&&e<="9"||"."===e}(i))return _(t),null;if("."===i){if(e+=i,C(),!O(i))return _(t),null}else{for(;O(i);)e+=i,C();"."===i&&(e+=i,C())}for(;O(i);)e+=i,C();if("E"===i||"e"===i){var r="",a=n;if(r+=i,C(),"+"!==i&&"-"!==i||(r+=i,C()),!O(i))return _(a),e;for(e+=r;O(i);)e+=i,C()}return e}function B(){for(var e="";O(i)||E.isValidAlpha(i);)e+=i,C();var t=e.charAt(0);return E.isValidAlpha(t)?e:null}function q(e){return i===e?(C(),e):null}E.prototype.type="Unit",E.prototype.isUnit=!0,E.parse=function(e,t){if(t=t||{},n=-1,i="","string"!=typeof(r=e))throw new TypeError("Invalid argument in Unit.parse, string expected");var a=new E;a.units=[];var o=1,u=!1;C(),A();var c=T(),l=null;if(c){if("BigNumber"===s.number)l=new N(c);else if("Fraction"===s.number)try{l=new M(c)}catch(e){l=parseFloat(c)}else l=parseFloat(c);A(),q("*")?(o=1,u=!0):q("/")&&(o=-1,u=!0)}for(var f=[],p=1;;){for(A();"("===i;)f.push(o),p*=o,o=1,C(),A();var m;if(!i)break;var h=i;if(null===(m=B()))throw new SyntaxError('Unexpected "'+h+'" in "'+r+'" at index '+n.toString());var d=z(m);if(null===d)throw new SyntaxError('Unit "'+m+'" not found.');var y=o*p;if(A(),q("^")){A();var g=T();if(null===g)throw new SyntaxError('In "'+e+'", "^" must be followed by a floating-point number');y*=g}a.units.push({unit:d.unit,prefix:d.prefix,power:y});for(var v=0;v1||Math.abs(this.units[0].power-1)>1e-15)},E.prototype._normalize=function(e){var t,r,n,i,a;if(null==e||0===this.units.length)return e;if(this._isDerived()){var o=e;a=E._getNumberConverter(L(e));for(var s=0;s{if(Z(P,e)){var t=P[e];return{unit:t,prefix:t.prefixes[""]}}for(var r in P)if(Z(P,r)&&ze(e,r)){var n=P[r],i=e.length-r.length,a=e.substring(0,i),o=Z(n.prefixes,a)?n.prefixes[a]:void 0;if(void 0!==o)return{unit:n,prefix:o}}return null}),{hasher:e=>e[0],limit:100});function D(e){return e.equalBase(R.NONE)&&null!==e.value&&!s.predictable?e.value:e}E.isValuelessUnit=function(e){return null!==z(e)},E.prototype.hasBase=function(e){if("string"==typeof e&&(e=R[e]),!e)return!1;for(var t=0;t1e-12)return!1;return!0},E.prototype.equalBase=function(e){for(var t=0;t1e-12)return!1;return!0},E.prototype.equals=function(e){return this.equalBase(e)&&g(this.value,e.value)},E.prototype.multiply=function(e){for(var t=this.clone(),r=0;r1e-12&&(Z(V,s)?n.push({unit:V[s].unit,prefix:V[s].prefix,power:r.dimensions[o]||0}):a=!0)}n.length1e-12){if(!Z(G.si,n))throw new Error("Cannot express custom unit "+n+" in SI units");t.push({unit:G.si[n].unit,prefix:G.si[n].prefix,power:e.dimensions[r]||0})}}return e.units=t,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,e},E.prototype.formatUnits=function(){for(var e="",t="",r=0,n=0,i=0;i0?(r++,e+=" "+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power-1)>1e-15&&(e+="^"+this.units[i].power)):this.units[i].power<0&&n++;if(n>0)for(var a=0;a0?(t+=" "+this.units[a].prefix.name+this.units[a].unit.name,Math.abs(this.units[a].power+1)>1e-15&&(t+="^"+-this.units[a].power)):(t+=" "+this.units[a].prefix.name+this.units[a].unit.name,t+="^"+this.units[a].power));e=e.substr(1),t=t.substr(1),r>1&&n>0&&(e="("+e+")"),n>1&&r>0&&(t="("+t+")");var o=e;return r>0&&n>0&&(o+=" / "),o+t},E.prototype.format=function(e){var t=this.skipAutomaticSimplification||null===this.value?this.clone():this.simplify(),r=!1;for(var n in void 0!==t.value&&null!==t.value&&o(t.value)&&(r=Math.abs(t.value.re)<1e-14),t.units)Z(t.units,n)&&t.units[n].unit&&("VA"===t.units[n].unit.name&&r?t.units[n].unit=P.VAR:"VAR"!==t.units[n].unit.name||r||(t.units[n].unit=P.VA));1!==t.units.length||t.fixPrefix||Math.abs(t.units[0].power-Math.round(t.units[0].power))<1e-14&&(t.units[0].prefix=t._bestPrefix());var i=t._denormalize(t.value),a=null!==t.value?x(i,e||{}):"",s=t.formatUnits();return t.value&&o(t.value)&&(a="("+a+")"),s.length>0&&a.length>0&&(a+=" "),a+s},E.prototype._bestPrefix=function(){if(1!==this.units.length)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var e=null!==this.value?h(this.value):0,t=h(this.units[0].unit.value),r=this.units[0].prefix;if(0===e)return r;var n=this.units[0].power,i=Math.log(e/Math.pow(r.value*t,n))/Math.LN10-1.2;if(i>-2.200001&&i<1.800001)return r;i=Math.abs(i);var a=this.units[0].unit.prefixes;for(var o in a)if(Z(a,o)){var s=a[o];if(s.scientific){var u=Math.abs(Math.log(e/Math.pow(s.value*t,n))/Math.LN10-1.2);(u0))},P={meter:{name:"meter",base:R.LENGTH,prefixes:I.LONG,value:1,offset:0},inch:{name:"inch",base:R.LENGTH,prefixes:I.NONE,value:.0254,offset:0},foot:{name:"foot",base:R.LENGTH,prefixes:I.NONE,value:.3048,offset:0},yard:{name:"yard",base:R.LENGTH,prefixes:I.NONE,value:.9144,offset:0},mile:{name:"mile",base:R.LENGTH,prefixes:I.NONE,value:1609.344,offset:0},link:{name:"link",base:R.LENGTH,prefixes:I.NONE,value:.201168,offset:0},rod:{name:"rod",base:R.LENGTH,prefixes:I.NONE,value:5.0292,offset:0},chain:{name:"chain",base:R.LENGTH,prefixes:I.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:R.LENGTH,prefixes:I.NONE,value:1e-10,offset:0},m:{name:"m",base:R.LENGTH,prefixes:I.SHORT,value:1,offset:0},in:{name:"in",base:R.LENGTH,prefixes:I.NONE,value:.0254,offset:0},ft:{name:"ft",base:R.LENGTH,prefixes:I.NONE,value:.3048,offset:0},yd:{name:"yd",base:R.LENGTH,prefixes:I.NONE,value:.9144,offset:0},mi:{name:"mi",base:R.LENGTH,prefixes:I.NONE,value:1609.344,offset:0},li:{name:"li",base:R.LENGTH,prefixes:I.NONE,value:.201168,offset:0},rd:{name:"rd",base:R.LENGTH,prefixes:I.NONE,value:5.02921,offset:0},ch:{name:"ch",base:R.LENGTH,prefixes:I.NONE,value:20.1168,offset:0},mil:{name:"mil",base:R.LENGTH,prefixes:I.NONE,value:254e-7,offset:0},m2:{name:"m2",base:R.SURFACE,prefixes:I.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:R.SURFACE,prefixes:I.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:R.SURFACE,prefixes:I.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:R.SURFACE,prefixes:I.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:R.SURFACE,prefixes:I.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:R.SURFACE,prefixes:I.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:R.SURFACE,prefixes:I.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:R.SURFACE,prefixes:I.NONE,value:6.4516e-10,offset:0},acre:{name:"acre",base:R.SURFACE,prefixes:I.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:R.SURFACE,prefixes:I.NONE,value:1e4,offset:0},m3:{name:"m3",base:R.VOLUME,prefixes:I.CUBIC,value:1,offset:0},L:{name:"L",base:R.VOLUME,prefixes:I.SHORT,value:.001,offset:0},l:{name:"l",base:R.VOLUME,prefixes:I.SHORT,value:.001,offset:0},litre:{name:"litre",base:R.VOLUME,prefixes:I.LONG,value:.001,offset:0},cuin:{name:"cuin",base:R.VOLUME,prefixes:I.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:R.VOLUME,prefixes:I.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:R.VOLUME,prefixes:I.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:R.VOLUME,prefixes:I.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:R.VOLUME,prefixes:I.NONE,value:15e-6,offset:0},drop:{name:"drop",base:R.VOLUME,prefixes:I.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:R.VOLUME,prefixes:I.NONE,value:5e-8,offset:0},minim:{name:"minim",base:R.VOLUME,prefixes:I.NONE,value:6.161152e-8,offset:0},fluiddram:{name:"fluiddram",base:R.VOLUME,prefixes:I.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:R.VOLUME,prefixes:I.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:R.VOLUME,prefixes:I.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:R.VOLUME,prefixes:I.NONE,value:1e-6,offset:0},cup:{name:"cup",base:R.VOLUME,prefixes:I.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:R.VOLUME,prefixes:I.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:R.VOLUME,prefixes:I.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:R.VOLUME,prefixes:I.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:R.VOLUME,prefixes:I.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:R.VOLUME,prefixes:I.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:R.VOLUME,prefixes:I.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:R.VOLUME,prefixes:I.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:R.VOLUME,prefixes:I.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:R.VOLUME,prefixes:I.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:R.VOLUME,prefixes:I.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:R.VOLUME,prefixes:I.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:R.VOLUME,prefixes:I.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:R.VOLUME,prefixes:I.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:R.VOLUME,prefixes:I.NONE,value:.1173478,offset:0},obl:{name:"obl",base:R.VOLUME,prefixes:I.NONE,value:.1589873,offset:0},g:{name:"g",base:R.MASS,prefixes:I.SHORT,value:.001,offset:0},gram:{name:"gram",base:R.MASS,prefixes:I.LONG,value:.001,offset:0},ton:{name:"ton",base:R.MASS,prefixes:I.SHORT,value:907.18474,offset:0},t:{name:"t",base:R.MASS,prefixes:I.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:R.MASS,prefixes:I.LONG,value:1e3,offset:0},grain:{name:"grain",base:R.MASS,prefixes:I.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:R.MASS,prefixes:I.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:R.MASS,prefixes:I.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:R.MASS,prefixes:I.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:R.MASS,prefixes:I.NONE,value:45.359237,offset:0},stick:{name:"stick",base:R.MASS,prefixes:I.NONE,value:.115,offset:0},stone:{name:"stone",base:R.MASS,prefixes:I.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:R.MASS,prefixes:I.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:R.MASS,prefixes:I.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:R.MASS,prefixes:I.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:R.MASS,prefixes:I.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:R.MASS,prefixes:I.NONE,value:45.359237,offset:0},s:{name:"s",base:R.TIME,prefixes:I.SHORT,value:1,offset:0},min:{name:"min",base:R.TIME,prefixes:I.NONE,value:60,offset:0},h:{name:"h",base:R.TIME,prefixes:I.NONE,value:3600,offset:0},second:{name:"second",base:R.TIME,prefixes:I.LONG,value:1,offset:0},sec:{name:"sec",base:R.TIME,prefixes:I.LONG,value:1,offset:0},minute:{name:"minute",base:R.TIME,prefixes:I.NONE,value:60,offset:0},hour:{name:"hour",base:R.TIME,prefixes:I.NONE,value:3600,offset:0},day:{name:"day",base:R.TIME,prefixes:I.NONE,value:86400,offset:0},week:{name:"week",base:R.TIME,prefixes:I.NONE,value:604800,offset:0},month:{name:"month",base:R.TIME,prefixes:I.NONE,value:2629800,offset:0},year:{name:"year",base:R.TIME,prefixes:I.NONE,value:31557600,offset:0},decade:{name:"decade",base:R.TIME,prefixes:I.NONE,value:315576e3,offset:0},century:{name:"century",base:R.TIME,prefixes:I.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:R.TIME,prefixes:I.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:R.FREQUENCY,prefixes:I.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:R.FREQUENCY,prefixes:I.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:R.ANGLE,prefixes:I.SHORT,value:1,offset:0},radian:{name:"radian",base:R.ANGLE,prefixes:I.LONG,value:1,offset:0},deg:{name:"deg",base:R.ANGLE,prefixes:I.SHORT,value:null,offset:0},degree:{name:"degree",base:R.ANGLE,prefixes:I.LONG,value:null,offset:0},grad:{name:"grad",base:R.ANGLE,prefixes:I.SHORT,value:null,offset:0},gradian:{name:"gradian",base:R.ANGLE,prefixes:I.LONG,value:null,offset:0},cycle:{name:"cycle",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},A:{name:"A",base:R.CURRENT,prefixes:I.SHORT,value:1,offset:0},ampere:{name:"ampere",base:R.CURRENT,prefixes:I.LONG,value:1,offset:0},K:{name:"K",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:0},degC:{name:"degC",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:273.15},degF:{name:"degF",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:0},celsius:{name:"celsius",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:R.AMOUNT_OF_SUBSTANCE,prefixes:I.SHORT,value:1,offset:0},mole:{name:"mole",base:R.AMOUNT_OF_SUBSTANCE,prefixes:I.LONG,value:1,offset:0},cd:{name:"cd",base:R.LUMINOUS_INTENSITY,prefixes:I.SHORT,value:1,offset:0},candela:{name:"candela",base:R.LUMINOUS_INTENSITY,prefixes:I.LONG,value:1,offset:0},N:{name:"N",base:R.FORCE,prefixes:I.SHORT,value:1,offset:0},newton:{name:"newton",base:R.FORCE,prefixes:I.LONG,value:1,offset:0},dyn:{name:"dyn",base:R.FORCE,prefixes:I.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:R.FORCE,prefixes:I.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:R.FORCE,prefixes:I.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:R.FORCE,prefixes:I.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:R.FORCE,prefixes:I.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:R.FORCE,prefixes:I.NONE,value:9.80665,offset:0},J:{name:"J",base:R.ENERGY,prefixes:I.SHORT,value:1,offset:0},joule:{name:"joule",base:R.ENERGY,prefixes:I.SHORT,value:1,offset:0},erg:{name:"erg",base:R.ENERGY,prefixes:I.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:R.ENERGY,prefixes:I.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:R.ENERGY,prefixes:I.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:R.ENERGY,prefixes:I.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:R.ENERGY,prefixes:I.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:R.POWER,prefixes:I.SHORT,value:1,offset:0},watt:{name:"watt",base:R.POWER,prefixes:I.LONG,value:1,offset:0},hp:{name:"hp",base:R.POWER,prefixes:I.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:R.POWER,prefixes:I.SHORT,value:w.I,offset:0},VA:{name:"VA",base:R.POWER,prefixes:I.SHORT,value:1,offset:0},Pa:{name:"Pa",base:R.PRESSURE,prefixes:I.SHORT,value:1,offset:0},psi:{name:"psi",base:R.PRESSURE,prefixes:I.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:R.PRESSURE,prefixes:I.NONE,value:101325,offset:0},bar:{name:"bar",base:R.PRESSURE,prefixes:I.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:R.PRESSURE,prefixes:I.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:R.PRESSURE,prefixes:I.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:R.PRESSURE,prefixes:I.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:R.PRESSURE,prefixes:I.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:R.ELECTRIC_CHARGE,prefixes:I.LONG,value:1,offset:0},C:{name:"C",base:R.ELECTRIC_CHARGE,prefixes:I.SHORT,value:1,offset:0},farad:{name:"farad",base:R.ELECTRIC_CAPACITANCE,prefixes:I.LONG,value:1,offset:0},F:{name:"F",base:R.ELECTRIC_CAPACITANCE,prefixes:I.SHORT,value:1,offset:0},volt:{name:"volt",base:R.ELECTRIC_POTENTIAL,prefixes:I.LONG,value:1,offset:0},V:{name:"V",base:R.ELECTRIC_POTENTIAL,prefixes:I.SHORT,value:1,offset:0},ohm:{name:"ohm",base:R.ELECTRIC_RESISTANCE,prefixes:I.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:R.ELECTRIC_INDUCTANCE,prefixes:I.LONG,value:1,offset:0},H:{name:"H",base:R.ELECTRIC_INDUCTANCE,prefixes:I.SHORT,value:1,offset:0},siemens:{name:"siemens",base:R.ELECTRIC_CONDUCTANCE,prefixes:I.LONG,value:1,offset:0},S:{name:"S",base:R.ELECTRIC_CONDUCTANCE,prefixes:I.SHORT,value:1,offset:0},weber:{name:"weber",base:R.MAGNETIC_FLUX,prefixes:I.LONG,value:1,offset:0},Wb:{name:"Wb",base:R.MAGNETIC_FLUX,prefixes:I.SHORT,value:1,offset:0},tesla:{name:"tesla",base:R.MAGNETIC_FLUX_DENSITY,prefixes:I.LONG,value:1,offset:0},T:{name:"T",base:R.MAGNETIC_FLUX_DENSITY,prefixes:I.SHORT,value:1,offset:0},b:{name:"b",base:R.BIT,prefixes:I.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:R.BIT,prefixes:I.BINARY_LONG,value:1,offset:0},B:{name:"B",base:R.BIT,prefixes:I.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:R.BIT,prefixes:I.BINARY_LONG,value:8,offset:0}},j={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function H(e){if("BigNumber"===e.number){var t=Cn(N);P.rad.value=new N(1),P.deg.value=t.div(180),P.grad.value=t.div(200),P.cycle.value=t.times(2),P.arcsec.value=t.div(648e3),P.arcmin.value=t.div(10800)}else P.rad.value=1,P.deg.value=Math.PI/180,P.grad.value=Math.PI/200,P.cycle.value=2*Math.PI,P.arcsec.value=Math.PI/648e3,P.arcmin.value=Math.PI/10800;P.radian.value=P.rad.value,P.degree.value=P.deg.value,P.gradian.value=P.grad.value}H(s),a&&a("config",(function(e,t){e.number!==t.number&&H(e)}));var G={si:{NONE:{unit:U,prefix:I.NONE[""]},LENGTH:{unit:P.m,prefix:I.SHORT[""]},MASS:{unit:P.g,prefix:I.SHORT.k},TIME:{unit:P.s,prefix:I.SHORT[""]},CURRENT:{unit:P.A,prefix:I.SHORT[""]},TEMPERATURE:{unit:P.K,prefix:I.SHORT[""]},LUMINOUS_INTENSITY:{unit:P.cd,prefix:I.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:P.mol,prefix:I.SHORT[""]},ANGLE:{unit:P.rad,prefix:I.SHORT[""]},BIT:{unit:P.bits,prefix:I.SHORT[""]},FORCE:{unit:P.N,prefix:I.SHORT[""]},ENERGY:{unit:P.J,prefix:I.SHORT[""]},POWER:{unit:P.W,prefix:I.SHORT[""]},PRESSURE:{unit:P.Pa,prefix:I.SHORT[""]},ELECTRIC_CHARGE:{unit:P.C,prefix:I.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:P.F,prefix:I.SHORT[""]},ELECTRIC_POTENTIAL:{unit:P.V,prefix:I.SHORT[""]},ELECTRIC_RESISTANCE:{unit:P.ohm,prefix:I.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:P.H,prefix:I.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:P.S,prefix:I.SHORT[""]},MAGNETIC_FLUX:{unit:P.Wb,prefix:I.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:P.T,prefix:I.SHORT[""]},FREQUENCY:{unit:P.Hz,prefix:I.SHORT[""]}}};G.cgs=JSON.parse(JSON.stringify(G.si)),G.cgs.LENGTH={unit:P.m,prefix:I.SHORT.c},G.cgs.MASS={unit:P.g,prefix:I.SHORT[""]},G.cgs.FORCE={unit:P.dyn,prefix:I.SHORT[""]},G.cgs.ENERGY={unit:P.erg,prefix:I.NONE[""]},G.us=JSON.parse(JSON.stringify(G.si)),G.us.LENGTH={unit:P.ft,prefix:I.NONE[""]},G.us.MASS={unit:P.lbm,prefix:I.NONE[""]},G.us.TEMPERATURE={unit:P.degF,prefix:I.NONE[""]},G.us.FORCE={unit:P.lbf,prefix:I.NONE[""]},G.us.ENERGY={unit:P.BTU,prefix:I.BTU[""]},G.us.POWER={unit:P.hp,prefix:I.NONE[""]},G.us.PRESSURE={unit:P.psi,prefix:I.NONE[""]},G.auto=JSON.parse(JSON.stringify(G.si));var V=G.auto;for(var W in E.setUnitSystem=function(e){if(!Z(G,e))throw new Error("Unit system "+e+" does not exist. Choices are: "+Object.keys(G).join(", "));V=G[e]},E.getUnitSystem=function(){for(var e in G)if(Z(G,e)&&G[e]===V)return e},E.typeConverters={BigNumber:function(e){return new N(e+"")},Fraction:function(e){return new M(e)},Complex:function(e){return e},number:function(e){return e}},E._getNumberConverter=function(e){if(!E.typeConverters[e])throw new TypeError('Unsupported type "'+e+'"');return E.typeConverters[e]},P)if(Z(P,W)){var J=P[W];J.dimensions=J.base.dimensions}for(var Y in j)if(Z(j,Y)){var X=P[j[Y]],Q={};for(var K in X)Z(X,K)&&(Q[K]=X[K]);Q.name=Y,P[Y]=Q}return E.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)},E.createUnit=function(e,t){if("object"!=typeof e)throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(t&&t.override)for(var r in e)if(Z(e,r)&&E.deleteUnit(r),e[r].aliases)for(var n=0;n0&&!E.isValidAlpha(i)&&!O(i))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+e+'"')}}(e);var n,a,o,s=null,u=[],c=0;if(t&&"Unit"===t.type)s=t.clone();else if("string"==typeof t)""!==t&&(n=t);else{if("object"!=typeof t)throw new TypeError('Cannot create unit "'+e+'" from "'+t.toString()+'": expecting "string" or "Unit" or "Object"');n=t.definition,a=t.prefixes,c=t.offset,o=t.baseName,t.aliases&&(u=t.aliases.valueOf())}if(u)for(var l=0;l1e-12){h=!1;break}if(h){p=!0,f.base=R[m];break}}if(!p){o=o||e+"_STUFF";var y={dimensions:s.dimensions.slice(0)};y.key=o,R[o]=y,V[o]={unit:f,prefix:I.NONE[""]},f.base=R[o]}}else{if(o=o||e+"_STUFF",k.indexOf(o)>=0)throw new Error('Cannot create new base unit "'+e+'": a base unit with that name already exists (and cannot be overridden)');for(var g in k.push(o),R)Z(R,g)&&(R[g].dimensions[k.length-1]=0);for(var v={dimensions:[]},x=0;x{var{typed:t,Unit:r}=e;return t(pm,{"Object, Object":function(e,t){return r.createUnit(e,t)},Object:function(e){return r.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,t,n){var i={};return i[e]=t,r.createUnit(i,n)},"string, Unit | string | Object":function(e,t){var n={};return n[e]=t,r.createUnit(n,{})},string:function(e){var t={};return t[e]={},r.createUnit(t,{})}})}));var hm=W("eigs",["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","divideScalar","inv","bignumber","multiply","add","larger","column","flatten","number","complex","sqrt","diag","qr","usolveAll","im","re","smaller","round","log10","transpose","matrixFromColumns"],(e=>{var{config:t,typed:r,matrix:n,addScalar:u,subtract:c,equal:l,abs:f,atan:p,cos:m,sin:h,multiplyScalar:d,divideScalar:y,inv:g,bignumber:v,multiply:x,add:b,larger:w,column:N,flatten:M,number:S,complex:E,sqrt:A,diag:O,qr:C,usolveAll:_,im:T,re:B,smaller:q,round:z,log10:D,transpose:I,matrixFromColumns:k}=e,R=function(e){var{config:t,addScalar:r,subtract:n,abs:i,atan:a,cos:o,sin:s,multiplyScalar:u,inv:c,bignumber:l,multiply:f,add:p}=e;function m(e,r){for(var n,i=e.length,a=Math.abs(r/i),o=new Array(i),s=0;s=Math.abs(a);){var c=u[0][0],l=u[0][1];e=v(e,(f=e[c][c],p=e[l][l],m=e[c][l],h=void 0,h=p-f,n=Math.abs(h)<=t.epsilon?Math.PI/4:.5*Math.atan(2*m/(p-f))),c,l),o=d(o,n,c,l),u=x(e)}for(var f,p,m,h,y=N(i,0),g=0;g=i(p);){var v=d[0][0],x=d[0][1];e=g(e,(M=e[v][v],S=e[x][x],E=e[v][x],A=void 0,A=n(S,M),o=i(A)<=t.epsilon?l(-1).acos().div(4):u(.5,a(f(2,E,c(A))))),v,x),m=y(m,o,v,x),d=b(e)}for(var M,S,E,A,O=N(s,0),C=0;C2&&void 0!==arguments[2]?arguments[2]:t.epsilon,i=arguments.length>3?arguments[3]:void 0;if("number"===i)return m(e,n);if("BigNumber"===i)return h(e,n);throw TypeError("Unsupported data type: "+i)}}({config:t,addScalar:u,subtract:c,column:N,flatten:M,equal:l,abs:f,atan:p,cos:m,sin:h,multiplyScalar:d,inv:g,bignumber:v,complex:E,multiply:x,add:b}),F=function(e){var{addScalar:t,subtract:r,flatten:n,multiply:i,multiplyScalar:a,divideScalar:o,sqrt:s,abs:u,bignumber:c,diag:l,inv:f,qr:p,usolveAll:m,equal:h,complex:d,larger:y,smaller:g,round:v,log10:x,transpose:b,matrixFromColumns:w}=e;function N(e,t,n,i,a,o,s,l){var f="BigNumber"===l,p="Complex"===l,m=f?c(0):p?d(0):0,h=f?c(1):p?d(1):1;if(g(u(n),s))return[[h,m],[m,h]];if(y(u(r(a,o)),s))return[[r(a,i),r(o,i)],[n,n]];var v=r(e,a),x=r(t,a),b=r(n,a),w=r(i,a);return g(u(x),s)?[[v,h],[b,m]]:[[x,m],[w,h]]}function M(e,t){for(var r=0;r1&&(D=l(Array(B-1).fill(v)))),B-=1,_.pop();for(var P=0;P2&&(D=l(Array(B-2).fill(v)))),B-=2,_.pop(),_.pop();for(var L=0;L+r(u(e),u(t)))),I>100){var H=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+T.join(", "));throw H.values=T,H.vectors=[],H}return{values:T,C:m?i(z,function(e,t){for(var r=[],n=0;ni(a,e)))).shift(),_.lengthn(e))))}if(0!==A.length){var T=new Error("Failed to find eigenvectors for the following eigenvalues: "+A.join(", "));throw T.values=o,T.vectors=w,T}return w}(e,b,B,T,E),_=w(..._)),{values:T,vectors:_}}}({config:t,addScalar:u,subtract:c,multiply:x,multiplyScalar:d,flatten:M,divideScalar:y,sqrt:A,abs:f,bignumber:v,diag:O,qr:C,inv:g,usolveAll:_,equal:l,complex:E,larger:w,smaller:q,round:z,log10:D,transpose:I,matrixFromColumns:k});return r("eigs",{Array:function(e){return U(n(e))},"Array, number|BigNumber":function(e,t){return U(n(e),t)},Matrix:function(e){var{values:t,vectors:r}=U(e);return{values:n(t),vectors:n(r)}},"Matrix, number|BigNumber":function(e,t){var{values:r,vectors:i}=U(e,t);return{values:n(r),vectors:n(i)}}});function U(e,r){void 0===r&&(r=t.epsilon);var n=e.size();if(2!==n.length||n[0]!==n[1])throw new RangeError("Matrix must be square (size: "+De(n)+")");var i=e.toArray(),a=n[0];if(function(e,t,r){for(var n=0;n{var{typed:t,config:r,abs:n,add:i,addScalar:o,matrix:s,multiply:u,multiplyScalar:c,divideScalar:l,subtract:f,smaller:p,equalScalar:m}=e;return t("intersect",{"Array, Array, Array":function(e,t,r){if(!y(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!y(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!function(e){return 4===e.length&&h(e[0])&&h(e[1])&&h(e[2])&&h(e[3])}(r))throw new TypeError("Array with 4 numbers expected as third argument");return function(e,t,r,n,i,a,s,u,p,m){var h=c(e,s),d=c(n,s),y=c(t,u),g=c(i,u),v=c(r,p),x=c(a,p),b=l(f(f(f(m,h),y),v),f(f(f(o(o(d,g),x),h),y),v));return[o(e,c(b,f(n,e))),o(t,c(b,f(i,t))),o(r,c(b,f(a,r)))]}(e[0],e[1],e[2],t[0],t[1],t[2],r[0],r[1],r[2],r[3])},"Array, Array, Array, Array":function(e,t,a,s){if(2===e.length){if(!d(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!d(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!d(a))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!d(s))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return function(e,t,a,s){var m=e,h=a,d=f(m,t),y=f(h,s),g=f(c(d[0],y[1]),c(y[0],d[1]));if(p(n(g),r.epsilon))return null;var v=c(y[0],m[1]),x=c(y[1],m[0]),b=c(y[0],h[1]),w=c(y[1],h[0]),N=l(o(f(f(v,x),b),w),g);return i(u(d,N),m)}(e,t,a,s)}if(3===e.length){if(!y(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!y(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!y(a))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!y(s))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return h=e[0],v=e[1],x=e[2],b=t[0],w=t[1],N=t[2],M=a[0],S=a[1],E=a[2],_=g(h,M,A=s[0],M,v,S,O=s[1],S,x,E,C=s[2],E),T=g(A,M,b,h,O,S,w,v,C,E,N,x),B=g(h,M,b,h,v,S,w,v,x,E,N,x),q=g(A,M,A,M,O,S,O,S,C,E,C,E),z=g(b,h,b,h,w,v,w,v,N,x,N,x),D=l(f(c(_,T),c(B,q)),f(c(z,q),c(T,T))),I=l(o(_,c(D,T)),q),k=o(h,c(D,f(b,h))),R=o(v,c(D,f(w,v))),F=o(x,c(D,f(N,x))),U=o(M,c(I,f(A,M))),P=o(S,c(I,f(O,S))),j=o(E,c(I,f(C,E))),m(k,U)&&m(R,P)&&m(F,j)?[k,R,F]:null}throw new TypeError("Arrays with two or thee dimensional points expected");var h,v,x,b,w,N,M,S,E,A,O,C,_,T,B,q,z,D,I,k,R,F,U,P,j},"Matrix, Matrix, Matrix":function(e,t,r){return s(this(e.valueOf(),t.valueOf(),r.valueOf()))},"Matrix, Matrix, Matrix, Matrix":function(e,t,r,n){return s(this(e.valueOf(),t.valueOf(),r.valueOf(),n.valueOf()))}});function h(e){return"number"==typeof e||a(e)}function d(e){return 2===e.length&&h(e[0])&&h(e[1])}function y(e){return 3===e.length&&h(e[0])&&h(e[1])&&h(e[2])}function g(e,t,r,n,i,a,s,u,l,p,m,h){var d=c(f(e,t),f(r,n)),y=c(f(i,a),f(s,u)),g=c(f(l,p),f(m,h));return o(o(d,y),g)}})),ym="usolve",gm=W(ym,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(ym,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=(t=u(e,t,!0))._data,c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=[],d=l-1;d>=0;d--){var y=r[d][0]||0;if(o(y,0))h[d]=[0];else{for(var g=0,v=[],x=[],b=m[d],w=m[d+1]-1;w>=b;w--){var N=p[w];N===d?g=f[w]:N=0;m--){var h=r[m][0]||0,d=void 0;if(o(h,0))d=0;else{var y=p[m][m];if(o(y,0))throw new Error("Linear system cannot be solved since matrix is singular");d=n(h,y);for(var g=m-1;g>=0;g--)r[g]=[a(r[g][0]||0,i(d,p[g][m]))]}f[m]=[d]}return new s({data:f,size:[c,1]})}})),vm="norm",xm=W(vm,["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],(e=>{var{typed:t,abs:r,add:n,pow:i,conj:a,sqrt:o,multiply:s,equalScalar:u,larger:c,smaller:l,matrix:f,ctranspose:p,eigs:m}=e;return t(vm,{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},boolean:function(e){return Math.abs(e)},Array:function(e){return h(f(e),2)},Matrix:function(e){return h(e,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(e){return this(e)},"Array, number | BigNumber | string":function(e,t){return h(f(e),t)},"Matrix, number | BigNumber | string":function(e,t){return h(e,t)}});function h(e,t){var f=e.size();if(1===f.length)return function(e,t){if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=0;return e.forEach((function(e){var n=r(e);c(n,t)&&(t=n)}),!0),t}(e);if(t===Number.NEGATIVE_INFINITY||"-inf"===t)return function(e){var t;return e.forEach((function(e){var n=r(e);t&&!l(n,t)||(t=n)}),!0),t||0}(e);if("fro"===t)return h(e,2);if("number"==typeof t&&!isNaN(t)){if(!u(t,0)){var a=0;return e.forEach((function(e){a=n(i(r(e),t),a)}),!0),i(a,1/t)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}(e,t);if(2===f.length){if(f[0]&&f[1])return function(e,t){if(1===t)return function(e){var t=[],i=0;return e.forEach((function(e,a){var o=a[1],s=n(t[o]||0,r(e));c(s,i)&&(i=s),t[o]=s}),!0),i}(e);if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=[],i=0;return e.forEach((function(e,a){var o=a[0],s=n(t[o]||0,r(e));c(s,i)&&(i=s),t[o]=s}),!0),i}(e);if("fro"===t)return function(e){var t=0;return e.forEach((function(e,r){t=n(t,s(e,a(e)))})),r(o(t))}(e);if(2===t)return function(e){var t=e.size();if(t[0]!==t[1])throw new RangeError("Invalid matrix dimensions");var n=p(e),i=s(n,e),a=m(i).values.toArray(),u=a[a.length-1];return r(o(u))}(e);throw new Error("Unsupported parameter value "+t)}(e,t);throw new RangeError("Invalid matrix dimensions")}}}));function bm(e,t){var r,n=t.length,i=[];if(e)for(r=0;r{var{typed:t,matrix:r,lup:n,slu:i,usolve:a,lsolve:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(wm,{"Array, Array | Matrix":function(e,t){e=r(e);var i=n(e);return p(i.L,i.U,i.p,null,t).valueOf()},"DenseMatrix, Array | Matrix":function(e,t){var r=n(e);return p(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){var r=n(e);return p(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,r,n){var a=i(e,r,n);return p(a.L,a.U,a.p,a.q,t)},"Object, Array | Matrix":function(e,t){return p(e.L,e.U,e.p,e.q,t)}});function c(e){if(f(e))return e;if(l(e))return r(e);throw new TypeError("Invalid Matrix LU decomposition")}function p(e,t,r,n,i){e=c(e),t=c(t),r&&((i=u(e,i,!0))._data=bm(r,i._data));var s=o(e,i),l=a(t,s);return n&&(l._data=bm(n,l._data)),l}})),Sm="sqrtm",Em=["typed","abs","add","multiply","sqrt","subtract","inv","size","max","identity"],Am=W(Sm,Em,(e=>{var{typed:t,abs:r,add:n,multiply:i,sqrt:a,subtract:o,inv:s,size:u,max:c,identity:l}=e,p=1e-6;function m(e){var t,a=0,f=e,m=l(u(e));do{var h=f;if(f=i(.5,n(h,s(m))),m=i(.5,n(m,s(h))),(t=c(r(o(f,h))))>p&&++a>1e3)throw new Error("computing square root of matrix: iterative method could not converge")}while(t>p);return f}return t(Sm,{"Array | Matrix":function(e){var t=f(e)?e.size():je(e);switch(t.length){case 1:if(1===t[0])return a(e);throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:if(t[0]===t[1])return m(e);throw new RangeError("Matrix must be square (size: "+De(t)+")");default:throw new RangeError("Matrix must be at most two dimensional (size: "+De(t)+")")}}})})),Om="multinomial",Cm=["typed","add","divide","multiply","factorial","isInteger","isPositive"],_m=W(Om,Cm,(e=>{var{typed:t,add:r,divide:n,multiply:i,factorial:a,isInteger:o,isPositive:s}=e;return t(Om,{"Array | Matrix":function(e){var t=0,u=1;return Ht(e,(function(e){if(!o(e)||!s(e))throw new TypeError("Positive integer value expected in function multinomial");t=r(t,e),u=i(u,a(e))})),n(a(t),u)}})})),Tm="rotationMatrix",Bm=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],qm=W(Tm,Bm,(e=>{var{typed:t,config:r,multiplyScalar:n,addScalar:i,unaryMinus:o,norm:s,BigNumber:u,matrix:c,DenseMatrix:l,SparseMatrix:f,cos:p,sin:m}=e;return t(Tm,{"":function(){return"Matrix"===r.matrix?c([]):[]},string:function(e){return c(e)},"number | BigNumber | Complex | Unit":function(e){return h(e,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(e,t){return h(e,t)},"number | BigNumber | Complex | Unit, Array":function(e,t){var r=c(t);return d(r),v(e,r,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,t){d(t);var n=t.storage()||("Matrix"===r.matrix?"dense":void 0);return v(e,t,n)},"number | BigNumber | Complex | Unit, Array, string":function(e,t,r){var n=c(t);return d(n),v(e,n,r)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,t,r){return d(t),v(e,t,r)}});function h(e,t){var r=a(e)?new u(-1):-1,i=p(e),o=m(e);return g([[i,n(r,o)],[o,i]],t)}function d(e){var t=e.size();if(t.length<1||3!==t[0])throw new RangeError("Vector must be of dimensions 1x3")}function y(e){return e.reduce(((e,t)=>n(e,t)))}function g(e,t){if(t){if("sparse"===t)return new f(e);if("dense"===t)return new l(e);throw new TypeError('Unknown matrix type "'.concat(t,'"'))}return e}function v(e,t,r){var n=s(t);if(0===n)throw new RangeError("Rotation around zero vector");var c=a(e)?u:null,l=c?new c(1):1,f=c?new c(-1):-1,h=c?new c(t.get([0])/n):t.get([0])/n,d=c?new c(t.get([1])/n):t.get([1])/n,v=c?new c(t.get([2])/n):t.get([2])/n,x=p(e),b=i(l,o(x)),w=m(e);return g([[i(x,y([h,h,b])),i(y([h,d,b]),y([f,v,w])),i(y([h,v,b]),y([d,w]))],[i(y([h,d,b]),y([v,w])),i(x,y([d,d,b])),i(y([d,v,b]),y([f,h,w]))],[i(y([h,v,b]),y([f,d,w])),i(y([d,v,b]),y([h,w])),i(x,y([v,v,b]))]],r)}})),zm="median",Dm=["typed","add","divide","compare","partitionSelect"],Im=W(zm,Dm,(e=>{var{typed:t,add:r,divide:n,compare:i,partitionSelect:a}=e;function o(e){try{var t=(e=et(e.valueOf())).length;if(0===t)throw new Error("Cannot calculate median of an empty array");if(t%2==0){for(var r=t/2-1,n=a(e,r+1),o=e[r],c=0;c0&&(o=e[c]);return u(o,n)}var l=a(e,(t-1)/2);return s(l)}catch(e){throw Gr(e,"median")}}var s=t({"number | BigNumber | Complex | Unit":function(e){return e}}),u=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,t){return n(r(e,t),2)}});return t(zm,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("median(A, dim) is not yet supported")},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function median");return o(e)}})})),km="rotate",Rm=["typed","multiply","rotationMatrix"],Fm=W(km,Rm,(e=>{var{typed:t,multiply:r,rotationMatrix:n}=e;return t(km,{"Array , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),r(n(t),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),r(n(t),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),r(n(t,a),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),r(n(t,a),e)}});function i(e,t){var r=Array.isArray(e)?je(e):e.size();if(r.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(t));if(2===r.length&&1!==r[1])throw new RangeError("Vector must be of dimensions 1x".concat(t));if(r[0]!==t)throw new RangeError("Vector must be of dimensions 1x".concat(t))}})),Um=["typed","abs","map","median","subtract"],Pm=W("mad",Um,(e=>{var{typed:t,abs:r,map:n,median:i,subtract:a}=e;return t("mad",{"Array | Matrix":o,"...":function(e){return o(e)}});function o(e){if(0===(e=et(e.valueOf())).length)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var t=i(e);return i(n(e,(function(e){return r(a(e,t))})))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf("median")?new TypeError(e.message.replace("median","mad")):Gr(e,"mad")}}})),jm="unit",Lm=["typed","Unit"],Hm=W(jm,Lm,(e=>{var{typed:t,Unit:r}=e;return t(jm,{Unit:function(e){return e.clone()},string:function(e){return r.isValuelessUnit(e)?new r(null,e):r.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string":function(e,t){return new r(e,t)},"Array | Matrix":function(e){return $t(e,this)}})})),$m=Nn({}),Gm=Sn({}),Vm=En({}),Zm=In({}),Wm=kn({}),Jm=Dn({}),Ym=Kn({config:n}),Xm=ei({}),Qm=ti({}),Km=Jn({Complex:Gm}),eh=$n({BigNumber:Ym,config:n}),th=Vn({BigNumber:Ym,config:n}),rh=Fn({BigNumber:Ym,config:n}),nh=Un({BigNumber:Ym,config:n}),ih=Zn({BigNumber:Ym,config:n}),ah=Pn({BigNumber:Ym,config:n}),oh=Ti({BigNumber:Ym,config:n}),sh=wi({BigNumber:Ym,config:n}),uh=Pi({BigNumber:Ym,config:n}),ch=_i({BigNumber:Ym,config:n}),lh=ta({}),fh=jn({BigNumber:Ym,config:n}),ph=Rn({BigNumber:Ym,config:n}),mh=Gn({BigNumber:Ym,config:n}),hh=Yn({}),dh=ra({Matrix:Xm}),yh=Ln({BigNumber:Ym,config:n}),gh=aa({BigNumber:Ym,Complex:Gm,DenseMatrix:dh,Fraction:lh}),vh=la({typed:gh}),xh=pa({typed:gh}),bh=xa({typed:gh}),wh=wa({typed:gh}),Nh=Sa({config:n,typed:gh}),Mh=Ea({typed:gh}),Sh=Oa({typed:gh}),Eh=Ca({Complex:Gm,typed:gh}),Ah=Ta({typed:gh}),Oh=ro({BigNumber:Ym,config:n,typed:gh}),Ch=wr({isInteger:vh,typed:gh}),_h=io({typed:gh}),Th=oo({Complex:Gm,typed:gh}),Bh=uo({Complex:Gm,config:n,typed:gh}),qh=co({typed:gh}),zh=fo({BigNumber:Ym,Fraction:lh,complex:Eh,typed:gh}),Dh=mo({typed:gh}),Ih=qo({typed:gh}),kh=zo({typed:gh}),Rh=Do({typed:gh}),Fh=Po({typed:gh}),Uh=jo({typed:gh}),Ph=$o({typed:gh}),jh=Vo({typed:gh}),Lh=Wo({typed:gh}),Hh=ts({typed:gh}),$h=rs({format:Hh,typed:gh}),Gh=is({typed:gh}),Vh=ss({typed:gh}),Zh=cs({Complex:Gm,config:n,typed:gh}),Wh=Cs({BigNumber:Ym,typed:gh}),Jh=Ts({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),Yh=qs({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),Xh=Ds({Complex:Gm,config:n,typed:gh}),Qh=Is({typed:gh}),Kh=Rs({Complex:Gm,config:n,typed:gh}),ed=Us({typed:gh}),td=js({BigNumber:Ym,typed:gh}),rd=Hs({BigNumber:Ym,typed:gh}),nd=Gs({BigNumber:Ym,typed:gh}),id=Zs({typed:gh}),ad=Ws({typed:gh}),od=Qs({typed:gh}),sd=iu({config:n,typed:gh}),ud=su({config:n,typed:gh}),cd=Hn({BigNumber:Ym,config:n}),ld=cu({typed:gh}),fd=fu({isNumeric:xh,typed:gh}),pd=mu({typed:gh}),md=du({typed:gh}),hd=yu({Fraction:lh,typed:gh}),dd=vu({typed:gh}),yd=bu({typed:gh}),gd=wu({typed:gh}),vd=Mu({Complex:Gm,config:n,typed:gh}),xd=Su({Complex:Gm,config:n,typed:gh}),bd=Au({typed:gh}),wd=Cu({typed:gh}),Nd=Tu({isNaN:wh,isNumeric:xh,typed:gh}),Md=Bu({format:Hh,typed:gh}),Sd=zu({Complex:Gm,config:n,typed:gh}),Ed=Iu({BigNumber:Ym,typed:gh}),Ad=ku({typed:gh}),Od=Ru({typed:gh}),Cd=Fu({BigNumber:Ym,typed:gh}),_d=Uu({typed:gh}),Td=ju({typed:gh}),Bd=$u({config:n,typed:gh}),qd=Wn({BigNumber:Ym,config:n}),zd=Vu({typed:gh}),Dd=Zu({Matrix:Xm,equalScalar:Nh,typed:gh}),Id=Ju({DenseMatrix:dh,Matrix:Xm,SparseMatrix:Dd,typed:gh}),kd=Yu({typed:gh}),Rd=rc({BigNumber:Ym,DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),Fd=uc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),Ud=fc({BigNumber:Ym,equalScalar:Nh,matrix:Id,typed:gh}),Pd=mc({BigNumber:Ym,config:n,matrix:Id,typed:gh}),jd=dc({equalScalar:Nh,matrix:Id,typed:gh}),Ld=vc({DenseMatrix:dh,matrix:Id,typed:gh}),Hd=xc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),$d=Lr({isInteger:vh,matrix:Id,typed:gh}),Gd=wc({DenseMatrix:dh,SparseMatrix:Dd,matrix:Id,typed:gh}),Vd=Mc({BigNumber:Ym,DenseMatrix:dh,SparseMatrix:Dd,config:n,matrix:Id,typed:gh}),Zd=Sc({BigNumber:Ym,config:n,matrix:Id,typed:gh}),Wd=Ac({isInteger:vh,matrix:Id,typed:gh}),Jd=Cc({matrix:Id,config:n,typed:gh}),Yd=Dr({matrix:Id,typed:gh}),Xd=Tc({BigNumber:Ym,config:n,matrix:Id,typed:gh}),Qd=Bc({format:Hh,typed:gh}),Kd=Rc({BigNumber:Ym,DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),ey=jc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),ty=Hc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),ry=Gc({BigNumber:Ym,DenseMatrix:dh,Fraction:lh,config:n,equalScalar:Nh,matrix:Id,typed:gh}),ny=Zc({matrix:Id,typed:gh}),iy=Jc({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),ay=Xc({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),oy=Kc({DenseMatrix:dh,config:n,equalScalar:Nh,matrix:Id,typed:gh}),sy=el({DenseMatrix:dh,smaller:iy}),uy=tl({larger:ay,smaller:iy}),cy=nl({SparseMatrix:Dd,typed:gh}),ly=al({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),fy=ul({BigNumber:Ym,DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),py=cl({BigNumber:Ym,typed:gh}),my=ll({DenseMatrix:dh,SparseMatrix:Dd,addScalar:yd,equalScalar:Nh,matrix:Id,typed:gh}),hy=fl({addScalar:yd,conj:bd,multiplyScalar:qh,size:Jd,typed:gh}),dy=ml({addScalar:yd,combinations:od,isInteger:vh,isNegative:zd,isPositive:bh,larger:ay,typed:gh}),yy=dl({typed:gh}),gy=gl({isZero:yy,matrix:Id,typed:gh}),vy=xl({BigNumber:Ym,Complex:Gm,Fraction:lh,config:n,isNegative:zd,matrix:Id,typed:gh,unaryMinus:dd}),xy=bl({config:n,equalScalar:Nh,matrix:Id,round:Kd,typed:gh}),by=Nl({addScalar:yd,dot:hy,equalScalar:Nh,matrix:Id,multiplyScalar:qh,typed:gh}),wy=Sl({equalScalar:Nh,matrix:Id,multiplyScalar:qh,typed:gh}),Ny=El({typed:gh}),My=Ol({matrix:Id,typed:gh}),Sy=_l({config:n,matrix:Id}),Ey=Bl({matrix:Id,typed:gh}),Ay=ql({matrix:Id,typed:gh}),Oy=zl({Complex:Gm,config:n,fraction:hd,identity:Vd,matrix:Id,multiply:by,number:Mh,typed:gh}),Cy=Il({DenseMatrix:dh,equalScalar:Nh,matrix:Id,pow:Oy,typed:gh}),_y=Rl({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),Ty=Pl({compare:ry,typed:gh}),By=Ll({compareText:ny,isZero:yy,typed:gh}),qy=$l({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),zy=Vl({compare:ry,isNaN:wh,isNumeric:xh,typed:gh}),Dy=Zl({ImmutableDenseMatrix:sy}),Iy=Jl({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),ky=Yl({typed:gh}),Ry=Ql({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Fy=ef({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Uy=rf({Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Py=af({compareNatural:Ty,typed:gh}),jy=of({add:my,matrix:Id,typed:gh}),Ly=sf({add:my,compare:ry,multiply:by,partitionSelect:zy,typed:gh}),Hy=pf({BigNumber:Ym,Complex:Gm,config:n,multiplyScalar:qh,pow:Oy,typed:gh}),$y=mf({BigNumber:Ym,typed:gh}),Gy=df({flatten:My,matrix:Id,size:Jd,typed:gh}),Vy=yf({equalScalar:Nh,matrix:Id,typed:gh}),Zy=vf({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),Wy=bf({matrix:Id,multiplyScalar:qh,typed:gh}),Jy=wf({matrix:Id,typed:gh}),Yy=Nf({bignumber:$y,fraction:hd,number:Mh}),Xy=Mf({equalScalar:Nh,matrix:Id,not:Fh,typed:gh,zeros:Xd}),Qy=Ef({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),Ky=Of({compare:ry,compareNatural:Ty,matrix:Id,typed:gh}),eg=Jr({config:n,numeric:Yy,smaller:iy,typed:gh}),tg=Cf({BigNumber:Ym,typed:gh}),rg=Tf({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),ng=qf({Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),ig=Df({Index:Dy,typed:gh}),ag=Xr({add:my,config:n,numeric:Yy,typed:gh}),og=kf({gamma:Hy,typed:gh}),sg=Ff({factorial:og,typed:gh}),ug=jf({flatten:My,matrix:Id,size:Jd,typed:gh}),cg=Hf({DenseMatrix:dh,addScalar:yd,equalScalar:Nh,matrix:Id,typed:gh,unaryMinus:dd}),lg=Vf({matrix:Id,multiply:by,subtract:cg,typed:gh}),fg=nn({bignumber:$y,matrix:Id,config:n,larger:ay,largerEq:qy,smaller:iy,smallerEq:Qy,typed:gh}),pg=ln({Index:Dy,matrix:Id,range:fg,typed:gh}),mg=Wf({config:n,multiplyScalar:qh,numeric:Yy,typed:gh}),hg=Yf({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),dg=Vr({config:n,larger:ay,numeric:Yy,typed:gh}),yg=Qf({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),gg=ep({Index:Dy,concat:$d,setDifference:Ry,size:Jd,subset:Yd,typed:gh}),vg=tp({config:n,equalScalar:Nh,matrix:Id,round:Kd,typed:gh}),xg=rp({DenseMatrix:dh,matrix:Id,typed:gh}),bg=ip({prod:mg,size:Jd,typed:gh}),wg=op({conj:bd,transpose:Jy,typed:gh}),Ng=up({equal:hg,typed:gh}),Mg=lp({Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Sg=fp({Complex:Gm,ceil:vg,floor:xy,matrix:Id,typed:gh}),Eg=sn({matrix:Id,number:Mh,subtract:cg,typed:gh}),Ag=mp({numeric:Yy,typed:gh}),Og=dp({Complex:Gm,config:n,divideScalar:Ag,typed:gh}),Cg=vp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),_g=bp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),Tg=wp({FibonacciHeap:uy,addScalar:yd,equalScalar:Nh}),Bg=Mp({Index:Dy,concat:$d,setIntersect:Fy,setSymDifference:gg,size:Jd,subset:Yd,typed:gh}),qg=Sp({DenseMatrix:dh,Spa:Tg,SparseMatrix:Dd,abs:kd,addScalar:yd,divideScalar:Ag,equalScalar:Nh,larger:ay,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh,unaryMinus:dd}),zg=Rp({SparseMatrix:Dd,abs:kd,add:my,divideScalar:Ag,larger:ay,largerEq:qy,multiply:by,subtract:cg,transpose:Jy,typed:gh}),Dg=Fp({lup:qg,matrix:Id,multiply:by,subtract:cg,typed:gh,unaryMinus:dd}),Ig=Pp({abs:kd,addScalar:yd,divideScalar:Ag,multiplyScalar:qh,sqrt:xd,subtract:cg,typed:gh,unaryMinus:dd}),kg=Lp({addScalar:yd,combinations:od,divideScalar:Ag,factorial:og,isInteger:vh,isNegative:zd,larger:ay,multiplyScalar:qh,pow:Oy,subtract:cg,typed:gh}),Rg=$p({addScalar:yd,combinations:od,divideScalar:Ag,isInteger:vh,isNegative:zd,multiplyScalar:qh,typed:gh}),Fg=en({Index:Dy,matrix:Id,range:fg,typed:gh}),Ug=Gp({Complex:Gm,config:n,divideScalar:Ag,typed:gh}),Pg=Zp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,typed:gh}),jg=Jp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),Lg=Xp({abs:kd,addScalar:yd,divideScalar:Ag,isPositive:bh,multiplyScalar:qh,smaller:iy,sqrt:xd,typed:gh}),Hg=Qp({addScalar:yd,complex:Eh,conj:bd,divideScalar:Ag,equal:hg,identity:Vd,isZero:yy,matrix:Id,multiplyScalar:qh,sign:zh,sqrt:xd,subtract:cg,typed:gh,unaryMinus:dd,zeros:Xd}),$g=Kp({abs:kd,addScalar:yd,det:Dg,divideScalar:Ag,identity:Vd,matrix:Id,multiply:by,typed:gh,unaryMinus:dd}),Gg=tm({abs:kd,add:my,identity:Vd,inv:$g,multiply:by,typed:gh}),Vg=rm({divideScalar:Ag,equalScalar:Nh,inv:$g,matrix:Id,multiply:by,typed:gh}),Zg=mn({add:my,divide:Vg,typed:gh}),Wg=gn({add:my,apply:Ch,divide:Vg,isNaN:wh,multiply:by,subtract:cg,typed:gh}),Jg=im({divide:Vg,dotDivide:Pg,isNumeric:xh,log:Ug,matrix:Id,multiply:by,sum:ag,typed:gh}),Yg=om({addScalar:yd,isInteger:vh,isNegative:zd,stirlingS2:kg,typed:gh}),Xg=um({Complex:Gm,config:n,divideScalar:Ag,log:Ug,typed:gh}),Qg=fm({BigNumber:Ym,Complex:Gm,Fraction:lh,abs:kd,addScalar:yd,config:n,divideScalar:Ag,equal:hg,fix:Sg,format:Hh,isNumeric:xh,multiplyScalar:qh,number:Mh,pow:Oy,round:Kd,subtract:cg}),Kg=mm({Unit:Qg,typed:gh}),ev=hm({abs:kd,add:my,addScalar:yd,atan:Qh,bignumber:$y,column:Fg,complex:Eh,config:n,cos:Od,diag:Gd,divideScalar:Ag,equal:hg,flatten:My,im:Rh,inv:$g,larger:ay,log10:Bh,matrix:Id,matrixFromColumns:Gy,multiply:by,multiplyScalar:qh,number:Mh,qr:Hg,re:Ny,round:Kd,sin:_d,smaller:iy,sqrt:xd,subtract:cg,transpose:Jy,typed:gh,usolveAll:jg}),tv=dm({abs:kd,add:my,addScalar:yd,config:n,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiply:by,multiplyScalar:qh,smaller:iy,subtract:cg,typed:gh}),rv=bn({sqrt:xd,typed:gh,variance:Wg}),nv=Bi({BigNumber:Ym,Unit:Qg,config:n}),iv=fi({BigNumber:Ym,Unit:Qg,config:n}),av=zi({BigNumber:Ym,Unit:Qg,config:n}),ov=pi({BigNumber:Ym,Unit:Qg,config:n}),sv=Si({BigNumber:Ym,Unit:Qg,config:n}),uv=xi({BigNumber:Ym,Unit:Qg,config:n}),cv=Di({BigNumber:Ym,Unit:Qg,config:n}),lv=Ii({BigNumber:Ym,Unit:Qg,config:n}),fv=ni({BigNumber:Ym,Unit:Qg,config:n}),pv=Ni({BigNumber:Ym,Unit:Qg,config:n}),mv=yi({BigNumber:Ym,Unit:Qg,config:n}),hv=oi({BigNumber:Ym,Unit:Qg,config:n}),dv=$i({BigNumber:Ym,Unit:Qg,config:n}),yv=Fi({BigNumber:Ym,Unit:Qg,config:n}),gv=Ei({BigNumber:Ym,Unit:Qg,config:n}),vv=Yi({BigNumber:Ym,Unit:Qg,config:n}),xv=Zi({BigNumber:Ym,Unit:Qg,config:n}),bv=Xi({BigNumber:Ym,Unit:Qg,config:n}),wv=Mi({BigNumber:Ym,Unit:Qg,config:n}),Nv=ai({BigNumber:Ym,Unit:Qg,config:n}),Mv=ji({BigNumber:Ym,Unit:Qg,config:n}),Sv=Li({BigNumber:Ym,Unit:Qg,config:n}),Ev=ui({BigNumber:Ym,Unit:Qg,config:n}),Av=gm({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),Ov=xm({abs:kd,add:my,conj:bd,ctranspose:wg,eigs:ev,equalScalar:Nh,larger:ay,matrix:Id,multiply:by,pow:Oy,smaller:iy,sqrt:xd,typed:gh}),Cv=Mm({DenseMatrix:dh,lsolve:Cg,lup:qg,matrix:Id,slu:zg,typed:gh,usolve:Av}),_v=Am({abs:kd,add:my,identity:Vd,inv:$g,max:dg,multiply:by,size:Jd,sqrt:xd,subtract:cg,typed:gh}),Tv=_m({add:my,divide:Vg,factorial:og,isInteger:vh,isPositive:bh,multiply:by,typed:gh}),Bv=qi({BigNumber:Ym,Unit:Qg,config:n}),qv=vi({BigNumber:Ym,Unit:Qg,config:n}),zv=si({BigNumber:Ym,Unit:Qg,config:n}),Dv=bi({BigNumber:Ym,Unit:Qg,config:n}),Iv=Vi({BigNumber:Ym,Unit:Qg,config:n}),kv=ki({BigNumber:Ym,Unit:Qg,config:n}),Rv=Gi({BigNumber:Ym,Unit:Qg,config:n}),Fv=di({BigNumber:Ym,Unit:Qg,config:n}),Uv=Wi({BigNumber:Ym,Unit:Qg,config:n}),Pv=Ai({BigNumber:Ym,Unit:Qg,config:n}),jv=ri({BigNumber:Ym,Unit:Qg,config:n}),Lv=Hi({BigNumber:Ym,Unit:Qg,config:n}),Hv=qm({BigNumber:Ym,DenseMatrix:dh,SparseMatrix:Dd,addScalar:yd,config:n,cos:Od,matrix:Id,multiplyScalar:qh,norm:Ov,sin:_d,typed:gh,unaryMinus:dd}),$v=Im({add:my,compare:ry,divide:Vg,partitionSelect:zy,typed:gh}),Gv=gi({BigNumber:Ym,Unit:Qg,config:n}),Vv=li({BigNumber:Ym,Unit:Qg,config:n}),Zv=mi({BigNumber:Ym,Unit:Qg,config:n}),Wv=Ui({BigNumber:Ym,Unit:Qg,config:n}),Jv=Ji({BigNumber:Ym,Unit:Qg,config:n}),Yv=Ci({BigNumber:Ym,Unit:Qg,config:n}),Xv=Fm({multiply:by,rotationMatrix:Hv,typed:gh}),Qv=Pm({abs:kd,map:jh,median:$v,subtract:cg,typed:gh}),Kv=ci({BigNumber:Ym,Unit:Qg,config:n}),ex=hi({BigNumber:Ym,Unit:Qg,config:n}),tx=Oi({BigNumber:Ym,Unit:Qg,config:n}),rx=Hm({Unit:Qg,typed:gh}),nx=Ri({BigNumber:Ym,Unit:Qg,config:n}),ix=ii({BigNumber:Ym,Unit:Qg,config:n}),ax={},ox={},sx={},ux=ue({mathWithTransform:ox}),cx=ct({Node:ux}),lx=lt({Node:ux,ResultSet:$m}),fx=vt({Node:ux}),px=xt({Node:ux}),mx=bt({Node:ux}),hx=Et({Node:ux}),dx=At({math:ax}),yx=Ot({classes:sx}),gx=Ct({Node:ux}),vx=_t({Node:ux}),xx=Tt({Node:ux}),bx=Bt({Node:ux,typed:gh}),wx=zt({Chain:dx,typed:gh}),Nx=kt({Node:ux,subset:Yd}),Mx=Rt({Node:ux,Range:Vm,size:Jd}),Sx=Ft({matrix:Id,Node:ux,subset:Yd}),Ex=Ut({Unit:Qg,Node:ux,math:ax}),Ax=jt({Node:ux,SymbolNode:Ex,math:ax}),Ox=Jt({AccessorNode:Nx,ArrayNode:cx,AssignmentNode:Sx,BlockNode:lx,ConditionalNode:gx,ConstantNode:fx,FunctionAssignmentNode:bx,FunctionNode:Ax,IndexNode:Mx,ObjectNode:px,OperatorNode:vx,ParenthesisNode:mx,RangeNode:xx,RelationalNode:hx,SymbolNode:Ex,config:n,numeric:Yy,typed:gh}),Cx=Xt({parse:Ox,typed:gh}),_x=Qt({parse:Ox}),Tx=Kt({parse:Ox}),Bx=ir({Help:_x,mathWithTransform:ox,typed:gh}),qx=or({parse:Ox,typed:gh}),zx=hr({bignumber:$y,fraction:hd,ConstantNode:fx,FunctionNode:Ax,OperatorNode:vx,ParenthesisNode:mx,SymbolNode:Ex,add:my,config:n,divide:Vg,equal:hg,isZero:yy,mathWithTransform:ox,multiply:by,parse:Ox,pow:Oy,subtract:cg,typed:gh}),Dx=yr({bignumber:$y,fraction:hd,ConstantNode:fx,FunctionNode:Ax,OperatorNode:vx,ParenthesisNode:mx,SymbolNode:Ex,add:my,config:n,divide:Vg,equal:hg,isZero:yy,mathWithTransform:ox,multiply:by,parse:Ox,pow:Oy,simplify:zx,subtract:cg,typed:gh}),Ix=vr({Parser:Tx,typed:gh}),kx=xr({ConstantNode:fx,FunctionNode:Ax,OperatorNode:vx,ParenthesisNode:mx,SymbolNode:Ex,config:n,equal:hg,isZero:yy,numeric:Yy,parse:Ox,simplify:zx,typed:gh});e(ax,{reviver:yx,false:Zm,null:Wm,true:Jm,replacer:Qm,i:Km,LN10:eh,LOG10E:th,NaN:rh,pi:nh,SQRT1_2:ih,tau:ah,efimovFactor:oh,fineStructure:sh,sackurTetrode:uh,weakMixingAngle:ch,e:fh,Infinity:ph,LOG2E:mh,PI:nh,version:hh,E:fh,phi:yh,typed:gh,isInteger:vh,isNumeric:xh,isPositive:bh,isNaN:wh,equalScalar:Nh,number:Mh,boolean:Sh,complex:Eh,splitUnit:Ah,unaryPlus:Oh,apply:Ch,cube:_h,expm1:Th,log10:Bh,multiplyScalar:qh,sign:zh,square:Dh,bitNot:Ih,arg:kh,im:Rh,not:Fh,filter:Uh,forEach:Ph,map:jh,erf:Lh,format:Hh,oct:$h,print:Gh,isPrime:Vh,acos:Zh,acot:Wh,acsc:Jh,asec:Yh,asin:Xh,atan:Qh,atanh:Kh,cosh:ed,coth:td,csch:rd,sech:nd,sinh:id,tanh:ad,chain:wx,combinations:od,pickRandom:sd,randomInt:ud,LN2:cd,clone:ld,hasNumericValue:fd,typeOf:pd,string:md,fraction:hd,unaryMinus:dd,addScalar:yd,exp:gd,log2:vd,sqrt:xd,conj:bd,getMatrixDataType:wd,mode:Nd,bin:Md,acosh:Sd,acsch:Ed,asinh:Ad,cos:Od,csc:Cd,sin:_d,combinationsWithRep:Td,random:Bd,SQRT2:qd,isNegative:zd,matrix:Id,abs:kd,gcd:Rd,mod:Fd,nthRoot:Ud,xgcd:Pd,bitAnd:jd,bitXor:Ld,or:Hd,concat:$d,diag:Gd,identity:Vd,ones:Zd,reshape:Wd,size:Jd,subset:Yd,zeros:Xd,hex:Qd,round:Kd,leftShift:ey,rightLogShift:ty,compare:ry,compareText:ny,smaller:iy,larger:ay,unequal:oy,sparse:cy,acoth:ly,atan2:fy,sec:py,add:my,dot:hy,composition:dy,isZero:yy,matrixFromFunction:gy,cbrt:vy,floor:xy,multiply:by,dotMultiply:wy,re:Ny,flatten:My,resize:Sy,squeeze:Ey,to:Ay,pow:Oy,dotPow:Cy,rightArithShift:_y,compareNatural:Ty,equalText:By,largerEq:qy,partitionSelect:zy,asech:Iy,tan:ky,setDifference:Ry,setIntersect:Fy,setMultiplicity:Uy,setSize:Py,trace:jy,quantileSeq:Ly,gamma:Hy,bignumber:$y,matrixFromColumns:Gy,lcm:Vy,bitOr:Zy,kron:Wy,transpose:Jy,numeric:Yy,and:Xy,smallerEq:Qy,sort:Ky,min:eg,cot:tg,setDistinct:rg,setPowerset:ng,index:ig,sum:ag,factorial:og,permutations:sg,matrixFromRows:ug,subtract:cg,cross:lg,range:fg,row:pg,prod:mg,equal:hg,max:dg,setCartesian:yg,setSymDifference:gg,ceil:vg,xor:xg,count:bg,ctranspose:wg,deepEqual:Ng,setIsSubset:Mg,fix:Sg,diff:Eg,divideScalar:Ag,nthRoots:Og,lsolve:Cg,lsolveAll:_g,setUnion:Bg,lup:qg,slu:zg,det:Dg,distance:Ig,stirlingS2:kg,catalan:Rg,column:Fg,log:Ug,dotDivide:Pg,usolveAll:jg,hypot:Lg,qr:Hg,inv:$g,expm:Gg,divide:Vg,mean:Zg,variance:Wg,kldivergence:Jg,bellNumbers:Yg,log1p:Xg,createUnit:Kg,eigs:ev,intersect:tv,std:rv,atomicMass:nv,bohrMagneton:iv,boltzmann:av,conductanceQuantum:ov,deuteronMass:sv,electronMass:uv,faraday:cv,firstRadiation:lv,gravitationConstant:fv,hartreeEnergy:pv,klitzing:mv,magneticConstant:hv,molarMass:dv,molarPlanckConstant:yv,neutronMass:gv,planckCharge:vv,planckLength:xv,planckTemperature:bv,protonMass:wv,reducedPlanckConstant:Nv,secondRadiation:Mv,stefanBoltzmann:Sv,vacuumImpedance:Ev,usolve:Av,norm:Ov,lusolve:Cv,sqrtm:_v,multinomial:Tv,avogadro:Bv,classicalElectronRadius:qv,electricConstant:zv,fermiCoupling:Dv,gravity:Iv,loschmidt:kv,molarMassC12:Rv,nuclearMagneton:Fv,planckMass:Uv,quantumOfCirculation:Pv,speedOfLight:jv,wienDisplacement:Lv,rotationMatrix:Hv,median:$v,bohrRadius:Gv,elementaryCharge:Vv,inverseConductanceQuantum:Zv,molarVolume:Wv,planckTime:Jv,thomsonCrossSection:Yv,rotate:Xv,parse:Ox,evaluate:Cx,mad:Qv,coulomb:Kv,magneticFluxQuantum:ex,rydberg:tx,unit:rx,help:Bx,gasConstant:nx,compile:qx,simplify:zx,rationalize:Dx,parser:Ix,planckConstant:ix,derivative:kx,config:n}),e(ox,ax,{apply:Mr({isInteger:vh,typed:gh}),filter:Cr({typed:gh}),map:Tr({typed:gh}),forEach:qr({typed:gh}),subset:Ur({matrix:Id,typed:gh}),index:Pr({Index:Dy}),concat:$r({isInteger:vh,matrix:Id,typed:gh}),max:Wr({config:n,larger:ay,numeric:Yy,typed:gh}),min:Yr({config:n,numeric:Yy,smaller:iy,typed:gh}),sum:Qr({add:my,config:n,numeric:Yy,typed:gh}),column:tn({Index:Dy,matrix:Id,range:fg,typed:gh}),range:an({bignumber:$y,matrix:Id,config:n,larger:ay,largerEq:qy,smaller:iy,smallerEq:Qy,typed:gh}),diff:cn({bignumber:$y,matrix:Id,number:Mh,subtract:cg,typed:gh}),row:fn({Index:Dy,matrix:Id,range:fg,typed:gh}),mean:hn({add:my,divide:Vg,typed:gh}),variance:xn({add:my,apply:Ch,divide:Vg,isNaN:wh,multiply:by,subtract:cg,typed:gh}),std:wn({sqrt:xd,typed:gh,variance:Wg})}),e(sx,{ResultSet:$m,Complex:Gm,Range:Vm,Node:ux,ArrayNode:cx,BlockNode:lx,ConstantNode:fx,ObjectNode:px,ParenthesisNode:mx,RelationalNode:hx,Chain:dx,BigNumber:Ym,Matrix:Xm,ConditionalNode:gx,OperatorNode:vx,Fraction:lh,RangeNode:xx,DenseMatrix:dh,FunctionAssignmentNode:bx,SparseMatrix:Dd,ImmutableDenseMatrix:sy,FibonacciHeap:uy,AccessorNode:Nx,IndexNode:Mx,Index:Dy,AssignmentNode:Sx,Spa:Tg,Unit:Qg,SymbolNode:Ex,FunctionNode:Ax,Help:_x,Parser:Tx}),dx.createProxy(ax),browser.omnibox.setDefaultSuggestion({description:"Do most mathematical computations."});const Rx=(e,t)=>{const r=Cx(e);t([{description:String(r),content:String(r)}])};browser.omnibox.onInputStarted.addListener(Rx),browser.omnibox.onInputChanged.addListener(Rx)})()})(); \ No newline at end of file +/* + For license information please see index.js.LICENSE.txt */ +'use strict';var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(jb){var Rb=0;return function(){return Rb>>0, +$jscomp.propertyToPolyfillSymbol[Qa]=$jscomp.IS_SYMBOL_NATIVE?$jscomp.global.Symbol(Qa):$jscomp.POLYFILL_PREFIX+Nb+"$"+Qa),$jscomp.defineProperty(Ra,$jscomp.propertyToPolyfillSymbol[Qa],{configurable:!0,writable:!0,value:Rb})))};$jscomp.initSymbol=function(){};$jscomp.iteratorPrototype=function(jb){jb={next:jb};jb[Symbol.iterator]=function(){return this};return jb}; +$jscomp.iteratorFromArray=function(jb,Rb){jb instanceof String&&(jb+="");var Nb=0,Ra=!1,Qa={next:function(){if(!Ra&&Nb{function jb(Ra){var Qa=Nb[Ra];if(void 0!==Qa)return Qa.exports;Qa=Nb[Ra]={id:Ra,loaded:!1,exports:{}};return Rb[Ra].call(Qa.exports,Qa,Qa.exports,jb),Qa.loaded=!0,Qa.exports}var Rb={977:function(Ra,Qa){var pa;!function(rb){function Ob(D,H){var K=Math.abs(D),ea=Math.abs(H);return 0===D?Math.log(ea):0===H?Math.log(K):3E3>K&&3E3>ea?.5*Math.log(D*D+H*H):Math.log(D/Math.cos(Math.atan2(H,D)))}function Z(D,H){if(!(this instanceof Z))return new Z(D,H);a:{var K={re:0,im:0};if(null==D)K.re=K.im=0;else if(void 0!== +H)K.re=D,K.im=H;else switch(typeof D){case "object":if("im"in D&&"re"in D)K.re=D.re,K.im=D.im;else if("abs"in D&&"arg"in D){if(!Number.isFinite(D.abs)&&Number.isFinite(D.arg)){K=Z.INFINITY;break a}K.re=D.abs*Math.cos(D.arg);K.im=D.abs*Math.sin(D.arg)}else if("r"in D&&"phi"in D){if(!Number.isFinite(D.r)&&Number.isFinite(D.phi)){K=Z.INFINITY;break a}K.re=D.r*Math.cos(D.phi);K.im=D.r*Math.sin(D.phi)}else 2===D.length?(K.re=D[0],K.im=D[1]):cb();break;case "string":K.im=K.re=0;D=D.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g); +H=1;var ea=0;null===D&&cb();for(var fa=0;fa=H?.5*Math.sqrt(2*(ea-H)):Math.abs(K)/Math.sqrt(2*(ea+H)),new Z(fa,0>K?-D:D)},exp:function(){var D= +Math.exp(this.re);return this.im,new Z(D*Math.cos(this.im),D*Math.sin(this.im))},expm1:function(){var D=this.re,H=this.im,K=Math.expm1(D)*Math.cos(H);var ea=Math.PI/4;H<-ea||H>ea?ea=Math.cos(H)-1:(ea=H*H,ea*=ea*(1/24+ea*(-1/720+ea*(1/40320+ea*(-1/3628800+ea*(1/4790014600+ea*(-1/87178291200+1/20922789888E3*ea))))))-.5);return new Z(K+ea,Math.exp(D)*Math.sin(H))},log:function(){var D=this.re,H=this.im;return new Z(Ob(D,H),Math.atan2(H,D))},abs:function(){return D=this.re,H=this.im,K=Math.abs(D),ea= +Math.abs(H),3E3>K&&3E3>ea?Math.sqrt(K*K+ea*ea):(K=D.im){var H=D.re;D.re=-D.im;D.im=H}else H=D.im,D.im=-D.re,D.re=H;return D},atanh:function(){var D=this.re,H=this.im,K=1H?(H=-H,K+="-"):K+="+",K+=" "):0>H&&(H=-H,K+="-"),1!==H&&(K+=H),K+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return 0===this.im?this.re:null},isNaN:function(){return isNaN(this.re)|| +isNaN(this.im)},isZero:function(){return 0===this.im&&0===this.re},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!(this.isNaN()||this.isFinite())}};Z.ZERO=new Z(0,0);Z.ONE=new Z(1,0);Z.I=new Z(0,1);Z.PI=new Z(Math.PI,0);Z.E=new Z(Math.E,0);Z.INFINITY=new Z(1/0,1/0);Z.NAN=new Z(NaN,NaN);Z.EPSILON=1E-15;void 0===(pa=function(){return Z}.apply(Qa,[]))||(Ra.exports=pa)}()},776:function(Ra,Qa,pa){var rb;!function(Ob){function Z(x){var E,C,A=x.length-1,J=""; +var N=x[0];if(0C)throw Error("[DecimalError] Invalid argument: "+x);}function Fa(x,E,C,A){var J,N,Y,T;for(N=x[0];10<=N;N/=10)--E;return 0>--E?(E+=7,J=0):(J=Math.ceil((E+1)/7),E%=7),N=jc(10,7-E),T=x[J]%N|0,null==A?3>E?(0==E?T=T/100|0:1==E&&(T=T/10|0),Y=4>C&&99999==T||3C&& +T+1==N||3E?(0==E?T=T/1E3|0:1==E?T=T/100|0:2==E&&(T=T/10|0),Y=(A||4>C)&&9999==T||!A&&3C)&&T+1==N||!A&&3C-1&&(void 0===J[A+1]&&(J[A+1]=0),J[A+1]+=J[A]/C|0,J[A]%=C)}return J.reverse()}function D(x, +E,C,A){var J,N,Y,T,aa,la,xa=x.constructor;a:if(null!=E){if(!(aa=x.d))return x;var ya=1;for(N=aa[0];10<=N;N/=10)ya++;if(0>(J=E-ya)){J+=7;var ra=E;var ub=(T=aa[la=0])/jc(10,ya-ra-1)%10|0}else if((la=Math.ceil((J+1)/7))>=(N=aa.length)){if(!A)break a;for(;N++<=la;)aa.push(0);T=ub=0;ya=1;ra=(J%=7)-7+1}else{T=N=aa[la];for(ya=1;10<=N;N/=10)ya++;ub=0>(ra=(J%=7)-7+ya)?0:T/jc(10,ya-ra-1)%10|0}if(A=A||0>E||void 0!==aa[la+1]||(0>ra?T:T%jc(10,ya-ra-1)),Y=4>C?(ub||A)&&(0==C||C==(0>x.s?3:2)):5x.s?8:7)),1>E||!aa[0])return aa.length=0,Y?(E-=x.e+1,aa[0]=jc(10,(7-E%7)%7),x.e=-E||0):aa[0]=x.e=0,x;if(0==J?(aa.length=la,N=1,la--):(aa.length=la+1,N=jc(10,7-J),aa[la]=0 +xa.maxE?(x.d=null,x.e=NaN):x.ex.e?"e":"e+")+x.e):0>J?(N="0."+ia(-J-1)+N,C&&0<(A=C-Y)&&(N+=ia(A))):J>=Y?(N+=ia(J+1-Y),C&&0<(A=C-J-1)&&(N=N+"."+ia(A))):((A=J+1)Kd)throw Ua=!0,C&&(x.precision=C),Error("[DecimalError] Precision limit exceeded");return D(new x(wc),E,1,!0)}function fa(x,E,C){if(E>ud)throw Error("[DecimalError] Precision limit exceeded");return D(new x(yb),E,C,!0)}function V(x){var E=x.length-1,C=7*E+1;if(E=x[E]){for(;0==E%10;E/=10)C--;for(E=x[0];10<=E;E/=10)C++}return C}function ia(x){for(var E="";x--;)E+="0";return E}function za(x,E,C,A){var J;x=new x(1);A=Math.ceil(A/7+4);for(Ua=!1;;){if(C%2&&lb((x= +x.times(E)).d,A)&&(J=!0),0===(C=rc(C/2))){C=x.d.length-1;J&&0===x.d[C]&&++x.d[C];break}lb((E=E.times(E)).d,A)}return Ua=!0,x}function Ca(x,E,C){for(var A,J=new x(E[0]),N=0;++Nx.s?0:1/0:1:x.s?0>x.s?0:x:NaN);null==E?(Ua=!1,Y=ra):Y=E;for(N=new xa(.03125);-2T&&Fa(J.d,Y-C,ya,T)))return D(J,xa.precision=ra,ya,Ua=!0);xa.precision=Y+=10;ub=A=N=new xa(1);aa=0;T++}J=N}}function qb(x,E){var C,A,J,N,Y,T,aa=1;var la=x;var xa=la.d;var ya=la.constructor,ra=ya.rounding,ub=ya.precision;if(0>la.s||!xa||!xa[0]||!la.e&&1==xa[0]&& +1==xa.length)return new ya(xa&&!xa[0]?-1/0:1!=la.s?NaN:xa?0:la);if(null==E?(Ua=!1,T=ub):T=E,ya.precision=T+=10,A=(C=Z(xa)).charAt(0),!(15E14>Math.abs(J=la.e)))return Y=ea(ya,T+2,ub).times(J+""),la=qb(new ya(A+"."+C.slice(1)),T-10).plus(Y),ya.precision=ub,null==E?D(la,ub,ra,Ua=!0):la;for(;7>A&&1!=A||1==A&&3C&&(C=A),C+=+E.slice(A+1),E=E.substring(0,A)): +0>C&&(C=E.length);for(A=0;48===E.charCodeAt(A);A++);for(J=E.length;48===E.charCodeAt(J-1);--J);if(E=E.slice(A,J)){if(J-=A,x.e=C=C-A-1,x.d=[],A=(C+1)%7,0>C&&(A+=7),Ax.constructor.maxE?(x.d=null,x.e=NaN):x.eE.s,A=fa(x,x.precision,1),J=A.times(.5);if((E=E.abs()).lte(J))return Pc=C?4:1,E;if((x=E.divToInt(A)).isZero())Pc=C?3:2;else{if((E=E.minus(x.times(A))).lte(J))return Pc=1&x.d[x.d.length- +1]?C?2:3:C?4:1,E;Pc=1&x.d[x.d.length-1]?C?1:4:C?3:2}return E.minus(A).abs()}function eb(x,E,C,A){var J,N,Y,T,aa,la,xa,ya,ra,ub=x.constructor,Bc=void 0!==C;if(Bc?(Ia(C,1,1E9),void 0===A?A=ub.rounding:Ia(A,0,8)):(C=ub.precision,A=ub.rounding),x.isFinite()){Bc?(J=2,16==E?C=4*C-3:8==E&&(C=3*C-2)):J=E;0<=(Y=(xa=H(x)).indexOf("."))&&(xa=xa.replace(".",""),(ra=new ub(1)).e=xa.length-Y,ra.d=cb(H(ra),10,J),ra.e=ra.d.length);for(N=aa=(ya=cb(xa,10,J)).length;0==ya[--aa];)ya.pop();if(ya[0]){if(0>Y?N--:((x=new ub(x)).d= +ya,x.e=N,ya=(x=Vb(x,ra,C,A,0,J)).d,N=x.e,la=Dc),Y=ya[C],T=J/2,la=la||void 0!==ya[C+1],la=4>A?(void 0!==Y||la)&&(0===A||A===(0>x.s?3:2)):Y>T||Y===T&&(4===A||la||6===A&&1&ya[C-1]||A===(0>x.s?8:7)),ya.length=C,la)for(;++ya[--C]>J-1;)ya[C]=0,C||(++N,ya.unshift(1));for(aa=ya.length;!ya[aa-1];--aa);Y=0;for(xa="";YN?"p":"p+")+N}else if(0>N){for(;++N;)xa="0"+xa;xa="0."+xa}else if(++N>aa)for(N-=aa;N--;)xa+="0";else Nx.s?"-"+xa:xa}function lb(x,E){if(x.length>E)return x.length=E,!0}function uc(x){return(new this(x)).abs()}function Bb(x){return(new this(x)).acos()}function Cc(x){return(new this(x)).acosh()}function Kc(x,E){return(new this(x)).plus(E)} +function nd(x){return(new this(x)).asin()}function Mb(x){return(new this(x)).asinh()}function Ld(x){return(new this(x)).atan()}function xc(x){return(new this(x)).atanh()}function Qc(x,E){x=new this(x);E=new this(E);var C,A=this.precision,J=this.rounding,N=A+4;return x.s&&E.s?x.d||E.d?!E.d||x.isZero()?(C=0>E.s?fa(this,A,J):new this(0)).s=x.s:!x.d||E.isZero()?(C=fa(this,N,1).times(.5)).s=x.s:0>E.s?(this.precision=N,this.rounding=1,C=this.atan(Vb(x,E,N,1)),E=fa(this,N,1),this.precision=A,this.rounding= +J,C=0>x.s?C.minus(E):C.plus(E)):C=this.atan(Vb(x,E,N,1)):(C=fa(this,N,1).times(0=N[E+1]&&A<=N[E+2]))throw Error("[DecimalError] Invalid argument: "+C+": "+A);this[C]=A}if(C="crypto",J&&(this[C]=Gc[C]),void 0!==(A=x[C])){if(!0!==A&&!1!==A&&0!==A&&1!==A)throw Error("[DecimalError] Invalid argument: "+C+": "+A);if(A){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error("[DecimalError] crypto unavailable");this[C]=!0}else this[C]=!1}return this}function Wb(x){return(new this(x)).cos()}function nb(x){return(new this(x)).cosh()} +function xd(x,E){return(new this(x)).div(E)}function Zc(x){return(new this(x)).exp()}function Pa(x){return D(x=new this(x),x.e+1,3)}function B(){var x,E,C=new this(0);Ua=!1;for(x=0;xJ)x=0,Y=[0];else{for(x=-1;0===Y[0];x-=7)Y.shift();C=1;for(A=Y[0];10<=A;A/=10)C++;7>C&&(x-=7-C)}return N.e=x,N.d=Y,N}function yd(x){return D(x= +new this(x),x.e+1,this.rounding)}function Wd(x){return(x=new this(x)).d?x.d[0]?x.s:0*x.s:x.s||NaN}function Xd(x){return(new this(x)).sin()}function zd(x){return(new this(x)).sinh()}function fd(x){return(new this(x)).sqrt()}function Ec(x,E){return(new this(x)).sub(E)}function Md(x){return(new this(x)).tan()}function Yd(x){return(new this(x)).tanh()}function Db(x){return D(x=new this(x),x.e+1,1)}var Lc,Dc,Pc,wc="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058", +yb="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789", +Gc={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-9E15,maxE:9E15,crypto:!1},Ua=!0,rc=Math.floor,jc=Math.pow,Yb=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,gd=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Nd=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Zd=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Kd=wc.length-1,ud=yb.length-1,Ba={name:"[object Decimal]"};Ba.absoluteValue=Ba.abs=function(){var x=new this.constructor(this);return 0>x.s&&(x.s=1),D(x)};Ba.ceil=function(){return D(new this.constructor(this), +this.e+1,2)};Ba.comparedTo=Ba.cmp=function(x){var E,C,A=this.d,J=(x=new this.constructor(x)).d,N=this.s;var Y=x.s;if(!A||!J)return N&&Y?N!==Y?N:A===J?0:!A^0>N?1:-1:NaN;if(!A[0]||!J[0])return A[0]?N:J[0]?-Y:0;if(N!==Y)return N;if(this.e!==x.e)return this.e>x.e^0>N?1:-1;x=0;for(Y=(E=A.length)<(C=J.length)?E:C;xJ[x]^0>N?1:-1;return E===C?0:E>C^0>N?1:-1};Ba.cosine=Ba.cos=function(){var x=this,E=x.constructor;if(x.d){var C;if(x.d[0]){var A=E.precision;var J=E.rounding; +E.precision=A+Math.max(x.e,x.sd())+7;E.rounding=1;var N=vb(E,x),Y,T=N.d.length;32>T?Y=(1/Gb(4,C=Math.ceil(T/3))).toString():(C=16,Y="2.3283064365386962890625e-10");E.precision+=C;N=Hb(E,1,N.times(Y),new E(1));for(Y=C;Y--;)N=N.times(N),N=N.times(N).minus(N).times(8).plus(1);C=(x=(E.precision-=C,N),E.precision=A,E.rounding=J,D(2==Pc||3==Pc?x.neg():x,A,J,!0))}else C=new E(1);A=C}else A=new E(NaN);return A};Ba.cubeRoot=Ba.cbrt=function(){var x,E,C,A,J,N,Y,T,aa=this.constructor;if(!this.isFinite()||this.isZero())return new aa(this); +Ua=!1;(J=this.s*jc(this.s*this,1/3))&&Math.abs(J)!=1/0?A=new aa(J.toString()):(C=Z(this.d),(J=((x=this.e)-C.length+1)%3)&&(C+=1==J||-2==J?"0":"00"),J=jc(C,1/3),x=rc((x+1)/3)-(x%3==(0>x?-1:2)),(A=new aa(C=J==1/0?"5e"+x:(C=J.toExponential()).slice(0,C.indexOf("e")+1)+x)).s=this.s);for(J=(x=aa.precision)+3;;)if(T=(Y=(N=A).times(N).times(N)).plus(this),A=Vb(T.plus(this).times(N),T.plus(Y),J+2,1),Z(N.d).slice(0,J)===(C=Z(A.d)).slice(0,J)){if("9999"!=(C=C.slice(J-3,J+1))&&(la||"4999"!=C)){+C&&(+C.slice(1)|| +"5"!=C.charAt(0))||(D(A,x+1,1),E=!A.times(A).times(A).eq(this));break}if(!la&&(D(N,x+1,0),N.times(N).times(N).eq(this))){A=N;break}J+=4;var la=1}return Ua=!0,D(A,x,aa.rounding,E)};Ba.decimalPlaces=Ba.dp=function(){var x,E=this.d,C=NaN;if(E){if(C=7*((x=E.length-1)-rc(this.e/7)),x=E[x])for(;0==x%10;x/=10)C--;0>C&&(C=0)}return C};Ba.dividedBy=Ba.div=function(x){return Vb(this,new this.constructor(x))};Ba.dividedToIntegerBy=Ba.divToInt=function(x){var E=this.constructor;return D(Vb(this,new E(x),0,1, +1),E.precision,E.rounding)};Ba.equals=Ba.eq=function(x){return 0===this.cmp(x)};Ba.floor=function(){return D(new this.constructor(this),this.e+1,3)};Ba.greaterThan=Ba.gt=function(x){return 0(C=A.d.length)?E=(1/Gb(4,x=Math.ceil(C/3))).toString():(x=16,E="2.3283064365386962890625e-10");A=Hb(J,1,A.times(E),new J(1),!0);for(E=new J(8);x--;)A=A.times(A),A=N.minus(A.times(E.minus(A.times(E))));return D(A,J.precision=Y,J.rounding=T,!0)};Ba.hyperbolicSine=Ba.sinh=function(){var x,E,C,A=this,J=A.constructor;if(!A.isFinite()||A.isZero())return new J(A);if(x=J.precision,E=J.rounding,J.precision=x+Math.max(A.e,A.sd())+4,J.rounding=1,3>(C=A.d.length))A=Hb(J,2,A,A,!0);else{var N=16< +(N=1.4*Math.sqrt(C))?16:0|N;A=Hb(J,2,A=A.times(1/Gb(5,N)),A,!0);for(var Y=new J(5),T=new J(16),aa=new J(20);N--;)C=A.times(A),A=A.times(Y.plus(C.times(T.times(C).plus(aa))))}return J.precision=x,J.rounding=E,D(A,x,E,!0)};Ba.hyperbolicTangent=Ba.tanh=function(){var x,E,C=this.constructor;return this.isFinite()?this.isZero()?new C(this):(x=C.precision,E=C.rounding,C.precision=x+7,C.rounding=1,Vb(this.sinh(),this.cosh(),C.precision=x,C.rounding=E)):new C(this.s)};Ba.inverseCosine=Ba.acos=function(){var x, +E=this,C=E.constructor,A=E.abs().cmp(1),J=C.precision,N=C.rounding;return-1!==A?0===A?E.isNeg()?fa(C,J,N):new C(0):new C(NaN):E.isZero()?fa(C,J+4,N).times(.5):(C.precision=J+6,C.rounding=1,E=E.asin(),x=fa(C,J+4,N).times(.5),C.precision=J,C.rounding=N,x.minus(E))};Ba.inverseHyperbolicCosine=Ba.acosh=function(){var x,E,C=this,A=C.constructor;return C.lte(1)?new A(C.eq(1)?0:NaN):C.isFinite()?(x=A.precision,E=A.rounding,A.precision=x+Math.max(Math.abs(C.e),C.sd())+4,A.rounding=1,Ua=!1,C=C.times(C).minus(1).sqrt().plus(C), +Ua=!0,A.precision=x,A.rounding=E,C.ln()):new A(C)};Ba.inverseHyperbolicSine=Ba.asinh=function(){var x,E,C=this,A=C.constructor;return!C.isFinite()||C.isZero()?new A(C):(x=A.precision,E=A.rounding,A.precision=x+2*Math.max(Math.abs(C.e),C.sd())+6,A.rounding=1,Ua=!1,C=C.times(C).plus(1).sqrt().plus(C),Ua=!0,A.precision=x,A.rounding=E,C.ln())};Ba.inverseHyperbolicTangent=Ba.atanh=function(){var x,E,C,A,J=this,N=J.constructor;return J.isFinite()?0<=J.e?new N(J.abs().eq(1)?J.s/0:J.isZero()?J:NaN):(x=N.precision, +E=N.rounding,A=J.sd(),Math.max(A,x)<2*-J.e-1?D(new N(J),x,E,!0):(N.precision=C=A-J.e,J=Vb(J.plus(1),(new N(1)).minus(J),C+x,1),N.precision=x+4,N.rounding=1,J=J.ln(),N.precision=x,N.rounding=E,J.times(.5))):new N(NaN)};Ba.inverseSine=Ba.asin=function(){var x,E,C,A,J=this,N=J.constructor;return J.isZero()?new N(J):(E=J.abs().cmp(1),C=N.precision,A=N.rounding,-1!==E?0===E?((x=fa(N,C+4,A).times(.5)).s=J.s,x):new N(NaN):(N.precision=C+6,N.rounding=1,J=J.div((new N(1)).minus(J.times(J)).sqrt().plus(1)).atan(), +N.precision=C,N.rounding=A,J.times(2)))};Ba.inverseTangent=Ba.atan=function(){var x,E,C,A,J;var N=this;var Y=N.constructor,T=Y.precision,aa=Y.rounding;if(N.isFinite()){if(N.isZero())return new Y(N);if(N.abs().eq(1)&&T+4<=ud)return(J=fa(Y,T+4,aa).times(.25)).s=N.s,J}else{if(!N.s)return new Y(NaN);if(T+4<=ud)return(J=fa(Y,T+4,aa).times(.5)).s=N.s,J}Y.precision=E=T+10;Y.rounding=1;for(x=C=Math.min(28,E/7+2|0);x;--x)N=N.div(N.times(N).plus(1).sqrt().plus(1));Ua=!1;E=Math.ceil(E/7);var la=1;var xa=N.times(N); +for(J=new Y(N);-1!==x;)if(N=N.times(xa),A=J.minus(N.div(la+=2)),N=N.times(xa),void 0!==(J=A.plus(N.div(la+=2))).d[E])for(x=E;J.d[x]===A.d[x]&&x--;);return C&&(J=J.times(2<this.d.length-2};Ba.isNaN=function(){return!this.s};Ba.isNegative=Ba.isNeg=function(){return 0>this.s};Ba.isPositive=Ba.isPos=function(){return 0this.cmp(x)};Ba.lessThanOrEqualTo=Ba.lte=function(x){return 1>this.cmp(x)};Ba.logarithm=Ba.log=function(x){var E,C,A,J,N,Y=this.constructor,T=Y.precision,aa=Y.rounding;if(null==x){x=new Y(10);var la=!0}else{if(E=(x=new Y(x)).d,0>x.s||!E||!E[0]||x.eq(1))return new Y(NaN);la=x.eq(10)}if(E=this.d,0>this.s||!E||!E[0]||this.eq(1))return new Y(E&&!E[0]?-1/0:1!=this.s?NaN:E?0:1/0);if(la)if(1J)?(E=aa,J=-J,N=ya.length):(E=ya,C=la,N=aa.length);J>(A=Math.max(Math.ceil(Y/7),N)+2)&&(J=A,E.length=1);E.reverse();for(A=J;A--;)E.push(0);E.reverse()}else{(xa=(A=aa.length)<(N=ya.length))&&(N=A);for(A=0;AJ;){if(aa[--A]la?(E=T,la=-la,J=aa.length):(E=aa,C=A,J=T.length);la>(J=(A=Math.ceil(N/7))>J?A+1:J+1)&&(la=J,E.length=1);for(E.reverse();la--;)E.push(0);E.reverse()}0>(J=T.length)-(la=aa.length)&&(la=J,E=aa,aa=T,T=E);for(E=0;la;)E=(T[--la]=T[la]+aa[la]+E)/1E7|0,T[la]%=1E7;E&&(T.unshift(E),++C);for(J=T.length;0==T[--J];)T.pop();return x.d=T,x.e=K(T,C),Ua?D(x,N,Y):x};Ba.precision=Ba.sd=function(x){var E; +if(void 0!==x&&x!==!!x&&1!==x&&0!==x)throw Error("[DecimalError] Invalid argument: "+x);return this.d?(E=V(this.d),x&&this.e+1>E&&(E=this.e+1)):E=NaN,E};Ba.round=function(){var x=this.constructor;return D(new x(this),this.e+1,x.rounding)};Ba.sine=Ba.sin=function(){var x=this,E=x.constructor;if(x.isFinite()){if(x.isZero())var C=new E(x);else{var A=E.precision;var J=E.rounding;E.precision=A+Math.max(x.e,x.sd())+7;E.rounding=1;C=vb(E,x);var N=C.d.length;if(3>N)C=Hb(E,2,C,C);else{var Y=16<(Y=1.4*Math.sqrt(N))? +16:0|Y;C=Hb(E,2,C=C.times(1/Gb(5,Y)),C);for(var T=new E(5),aa=new E(16),la=new E(20);Y--;)N=C.times(C),C=C.times(T.plus(N.times(aa.times(N).minus(la))))}C=(x=C,E.precision=A,E.rounding=J,D(2Y&&(!J||J[0])?NaN:J?this:1/0);Ua=!1;0==(Y=Math.sqrt(+this))||Y==1/0?(0==((E=Z(J)).length+N)%2&&(E+="0"),Y=Math.sqrt(E), +N=rc((N+1)/2)-(0>N||N%2),C=new T(Y==1/0?"5e"+N:(E=Y.toExponential()).slice(0,E.indexOf("e")+1)+N)):C=new T(Y.toString());for(J=(N=T.precision)+3;;)if(C=(A=C).plus(Vb(this,A,J+2,1)).times(.5),Z(A.d).slice(0,J)===(E=Z(C.d)).slice(0,J)){if("9999"!=(E=E.slice(J-3,J+1))&&(aa||"4999"!=E)){+E&&(+E.slice(1)||"5"!=E.charAt(0))||(D(C,N+1,1),x=!C.times(C).eq(this));break}if(!aa&&(D(A,N+1,0),A.times(A).eq(this))){C=A;break}J+=4;var aa=1}return Ua=!0,D(C,N,T.rounding,x)};Ba.tangent=Ba.tan=function(){var x,E,C= +this,A=C.constructor;return C.isFinite()?C.isZero()?new A(C):(x=A.precision,E=A.rounding,A.precision=x+10,A.rounding=1,(C=C.sin()).s=1,C=Vb(C,(new A(1)).minus(C.times(C)).sqrt(),x+10,0),A.precision=x,A.rounding=E,D(2==Pc||4==Pc?C.neg():C,x,E,!0)):new A(NaN)};Ba.times=Ba.mul=function(x){var E,C,A,J,N,Y=this.constructor,T=this.d,aa=(x=new Y(x)).d;if(x.s*=this.s,!(T&&T[0]&&aa&&aa[0]))return new Y(!x.s||T&&!T[0]&&!aa||aa&&!aa[0]&&!T?NaN:T&&aa?0*x.s:x.s/0);var la=rc(this.e/7)+rc(x.e/7);(N=T.length)<(C= +aa.length)&&(A=T,T=aa,aa=A,J=N,N=C,C=J);A=[];for(E=J=N+C;E--;)A.push(0);for(E=C;0<=--E;){var xa=0;for(C=N+E;C>E;)xa=A[C]+aa[E]*T[C-E-1]+xa,A[C--]=xa%1E7|0,xa=xa/1E7|0;A[C]=(A[C]+xa)%1E7|0}for(;!A[--J];)A.pop();return xa?++la:A.shift(),x.d=A,x.e=K(A,la),Ua?D(x,Y.precision,Y.rounding):x};Ba.toBinary=function(x,E){return eb(this,2,x,E)};Ba.toDecimalPlaces=Ba.toDP=function(x,E){var C=this,A=C.constructor;return C=new A(C),void 0===x?C:(Ia(x,0,1E9),void 0===E?E=A.rounding:Ia(E,0,8),D(C,x+C.e+1,E))};Ba.toExponential= +function(x,E){var C,A=this,J=A.constructor;return void 0===x?C=H(A,!0):(Ia(x,0,1E9),void 0===E?E=J.rounding:Ia(E,0,8),C=H(A=D(new J(A),x+1,E),!0,x+1)),A.isNeg()&&!A.isZero()?"-"+C:C};Ba.toFixed=function(x,E){var C,A,J=this.constructor;return void 0===x?C=H(this):(Ia(x,0,1E9),void 0===E?E=J.rounding:Ia(E,0,8),C=H(A=D(new J(this),x+this.e+1,E),!1,x+A.e+1)),this.isNeg()&&!this.isZero()?"-"+C:C};Ba.toFraction=function(x){var E,C,A,J,N,Y,T,aa,la,xa;var ya=this.d;var ra=this.constructor;if(!ya)return new ra(this); +if(aa=C=new ra(1),A=T=new ra(0),N=(J=(E=new ra(A)).e=V(ya)-this.e-1)%7,E.d[0]=jc(10,0>N?7+N:N),null==x)x=0Vb(aa,A,J,1).minus(this).abs().cmp(Vb(T,C,J,1).minus(this).abs())?[aa,A]:[T,C],ra.precision=N,Ua=!0,xa};Ba.toHexadecimal=Ba.toHex=function(x,E){return eb(this,16,x,E)};Ba.toNearest=function(x,E){var C=this,A=C.constructor;if(C=new A(C),null==x){if(!C.d)return C;x=new A(1);E=A.rounding}else{if(x=new A(x),void 0===E?E=A.rounding:Ia(E,0,8),!C.d)return x.s?C:x;if(!x.d)return x.s&&(x.s=C.s),x}return x.d[0]?(Ua=!1,C=Vb(C,x,0,E,1).times(x),Ua=!0,D(C)):(x.s=C.s,C=x),C};Ba.toNumber=function(){return+this}; +Ba.toOctal=function(x,E){return eb(this,8,x,E)};Ba.toPower=Ba.pow=function(x){var E,C,A,J,N,Y,T=this,aa=T.constructor,la=+(x=new aa(x));if(!(T.d&&x.d&&T.d[0]&&x.d[0]))return new aa(jc(+T,la));if((T=new aa(T)).eq(1))return T;if(A=aa.precision,N=aa.rounding,x.eq(1))return D(T,A,N);if((E=rc(x.e/7))>=x.d.length-1&&9007199254740991>=(C=0>la?-la:la))return J=za(aa,T,C,A),0>x.s?(new aa(1)).div(J):D(J,A,N);if(0>(Y=T.s)){if(Eaa.maxE+1||E=J.toExpPos): +(Ia(x,1,1E9),void 0===E?E=J.rounding:Ia(E,0,8),C=H(A=D(new J(A),x,E),x<=A.e||A.e<=J.toExpNeg,x)),A.isNeg()&&!A.isZero()?"-"+C:C};Ba.toSignificantDigits=Ba.toSD=function(x,E){var C=this.constructor;return void 0===x?(x=C.precision,E=C.rounding):(Ia(x,1,1E9),void 0===E?E=C.rounding:Ia(E,0,8)),D(new C(this),x,E)};Ba.toString=function(){var x=this.constructor;x=H(this,this.e<=x.toExpNeg||this.e>=x.toExpPos);return this.isNeg()&&!this.isZero()?"-"+x:x};Ba.truncated=Ba.trunc=function(){return D(new this.constructor(this), +this.e+1,1)};Ba.valueOf=Ba.toJSON=function(){var x=this.constructor;x=H(this,this.e<=x.toExpNeg||this.e>=x.toExpPos);return this.isNeg()?"-"+x:x};var Vb=function(){function x(A,J,N){var Y=0;var T=A.length;for(A=A.slice();T--;)Y=A[T]*J+Y,A[T]=Y%N|0,Y=Y/N|0;return Y&&A.unshift(Y),A}function E(A,J,N,Y){if(N!=Y)var T=N>Y?1:-1;else for(Y=T=0;YJ[Y]?1:-1;break}return T}function C(A,J,N,Y){for(var T=0;N--;)A[N]-=T,T=A[N](Na[Zb]||0)&&xa--,null==N?(ad=N=Rc.precision,Y=Rc.rounding):ad=T?N+(A.e-J.e)+1:N,0>ad)hd.push(1),aa=!0; +else{if(ad=ad/ya+2|0,Zb=0,1==Mc){var gc=0;Xb=Xb[0];for(ad++;(Zb=aa/2&&++me;do gc=0,0>(la=E(Xb,A,Mc,J))?(hc=A[0],Mc!=J&&(hc=hc*aa+(A[1]||0)),1<(gc=hc/me|0)?(gc>=aa&&(gc=aa-1),1==(la=E(ra=x(Xb,gc,aa),A,ub=ra.length,J=A.length))&&(gc--,C(ra, +Mc(la=E(Xb,A,Mc,J=A.length))&&(gc++,C(A,McA.maxE?(this.e=NaN,this.d=null):T.e1/T?-1:1,this.e=0,void(this.d=[0]);if(0>T?(T=-T,this.s=-1):this.s=1,T===~~T&&1E7>T){var xa=0;for(aa=T;10<=aa;aa/=10)xa++;return void(Ua?xa>A.maxE?(this.e=NaN,this.d=null):xaub?new T(0*aa.s):(aa.e=K(ra,hc),aa.d=ra,Ua=!1,la&&(aa=Vb(aa,ya,4*Bc)),xa&&(aa=aa.times(54>Math.abs(xa)?jc(2,xa):Lc.pow(2,xa))),Ua=!0,aa)}}return ya}var J,N;if(A.prototype=Ba,A.ROUND_UP=0,A.ROUND_DOWN=1,A.ROUND_CEIL=2,A.ROUND_FLOOR= +3,A.ROUND_HALF_UP=4,A.ROUND_HALF_DOWN=5,A.ROUND_HALF_EVEN=6,A.ROUND_HALF_CEIL=7,A.ROUND_HALF_FLOOR=8,A.EUCLID=9,A.config=A.set=wd,A.clone=C,A.isDecimal=ta,A.abs=uc,A.acos=Bb,A.acosh=Cc,A.add=Kc,A.asin=nd,A.asinh=Mb,A.atan=Ld,A.atanh=xc,A.atan2=Qc,A.cbrt=vd,A.ceil=kc,A.cos=Wb,A.cosh=nb,A.div=xd,A.exp=Zc,A.floor=Pa,A.hypot=B,A.ln=Aa,A.log=va,A.log10=fb,A.log2=db,A.max=mb,A.min=Va,A.mod=cc,A.mul=Za,A.pow=od,A.random=$c,A.round=yd,A.sign=Wd,A.sin=Xd,A.sinh=zd,A.sqrt=fd,A.sub=Ec,A.tan=Md,A.tanh=Yd,A.trunc= +Db,void 0===E&&(E={}),E&&!0!==E.defaults){var Y="precision rounding toExpNeg toExpPos maxE minE modulo crypto".split(" ");for(J=0;J{var Qa=Object.assign||function(Z){for(var Ia=1;Ia=fa.length&&cb.slice(0,fa.length)===fa&&(D+=H[K[V]],cb=cb.slice(fa.length,cb.length),ea=!0)});ea||(D+=cb.slice(0,1),cb=cb.slice(1,cb.length))};cb;)Ia();return D}},628:function(Ra,Qa){var pa;!function(rb){function Ob(V){function ia(){var Ca=Error.apply(this,arguments);Ca.name=this.name=V;this.stack=Ca.stack;this.message=Ca.message}function za(){}return za.prototype=Error.prototype,ia.prototype=new za,ia}function Z(V,ia){return isNaN(V= +parseInt(V,10))&&Ia(),V*ia}function Ia(){throw new ea;}function Fa(V){for(var ia={},za=V,Ca=2,Oa=4;Oa<=za;){for(;0==za%Ca;)za/=Ca,ia[Ca]=(ia[Ca]||0)+1;Oa+=1+2*Ca++}return za!==V?1V&&(Oa=V,V=-V),0==V%1)za=V;else if(0=lb&&1E7>=Bb;){if(V===(ia=(eb+uc)/(lb+ +Bb))){1E7>=lb+Bb?(za=eb+uc,Ca=lb+Bb):Bb>lb?(za=uc,Ca=Bb):(za=eb,Ca=lb);break}V>ia?(eb+=uc,lb+=Bb):(uc+=eb,Bb+=lb);1E7Oa?-1:1;H.n=Math.abs(za);H.d=Math.abs(Ca)};D.REDUCE=1;D.prototype={s:1,n:0,d:1,abs:function(){return new D(this.n, +this.d)},neg:function(){return new D(-this.s*this.n,this.d)},add:function(V,ia){return fa(V,ia),new D(this.s*this.n*H.d+H.s*this.d*H.n,this.d*H.d)},sub:function(V,ia){return fa(V,ia),new D(this.s*this.n*H.d-H.s*this.d*H.n,this.d*H.d)},mul:function(V,ia){return fa(V,ia),new D(this.s*H.s*this.n*H.n,this.d*H.d)},div:function(V,ia){return fa(V,ia),new D(this.s*H.s*this.n*H.d,this.d*H.n)},clone:function(){return new D(this)},mod:function(V,ia){return isNaN(this.n)||isNaN(this.d)?new D(NaN):void 0===V? +new D(this.s*this.n%this.d,1):(fa(V,ia),0===H.n&&0===this.d&&D(0,0),new D(this.s*H.d*this.n%(H.n*this.d),H.d*this.d))},gcd:function(V,ia){return fa(V,ia),new D(cb(H.n,this.n)*cb(H.d,this.d),H.d*this.d)},lcm:function(V,ia){return fa(V,ia),0===H.n&&0===this.n?new D:new D(H.n*this.n,cb(H.n,this.n)*cb(H.d,this.d))},ceil:function(V){return V=Math.pow(10,V||0),isNaN(this.n)||isNaN(this.d)?new D(NaN):new D(Math.ceil(V*this.s*this.n/this.d),V)},floor:function(V){return V=Math.pow(10,V||0),isNaN(this.n)|| +isNaN(this.d)?new D(NaN):new D(Math.floor(V*this.s*this.n/this.d),V)},round:function(V){return V=Math.pow(10,V||0),isNaN(this.n)||isNaN(this.d)?new D(NaN):new D(Math.round(V*this.s*this.n/this.d),V)},inverse:function(){return new D(this.s*this.d,this.n)},pow:function(V,ia){if(fa(V,ia),1===H.d)return 0>H.s?new D(Math.pow(this.s*this.d,H.n),Math.pow(this.n,H.n)):new D(Math.pow(this.s*this.n,H.n),Math.pow(this.d,H.n));if(0>this.s)return null;V=Fa(this.n);ia=Fa(this.d);var za=1,Ca=1,Oa;for(Oa in V)if("1"!== +Oa){if("0"===Oa){za=0;break}if(V[Oa]*=H.n,0!=V[Oa]%H.d)return null;V[Oa]/=H.d;za*=Math.pow(Oa,V[Oa])}for(Oa in ia)if("1"!==Oa){if(ia[Oa]*=H.n,0!=ia[Oa]%H.d)return null;ia[Oa]/=H.d;Ca*=Math.pow(Oa,ia[Oa])}return 0>H.s?new D(Ca,za):new D(za,Ca)},equals:function(V,ia){return fa(V,ia),this.s*this.n*H.d==H.s*H.n*this.d},compare:function(V,ia){fa(V,ia);V=this.s*this.n*H.d-H.s*H.n*this.d;return(0V)},simplify:function(V){function ia(qb){return 1===qb.length?new D(qb[0]):ia(qb.slice(1)).inverse().add(qb[0])} +if(isNaN(this.n)||isNaN(this.d))return this;var za=this.abs().toContinued();V=V||.001;for(var Ca=0;Cathis.s&&(za+="-"),1===Oa?za+=Ca:(V&&0<(ia=Math.floor(Ca/Oa))&&(za+=ia,za+=" ",Ca%=Oa), +za+=Ca,za+="/",za+=Oa),za},toLatex:function(V){var ia,za="",Ca=this.n,Oa=this.d;return 0>this.s&&(za+="-"),1===Oa?za+=Ca:(V&&0<(ia=Math.floor(Ca/Oa))&&(za+=ia,Ca%=Oa),za+="\\frac{",za+=Ca,za+="}{",za+=Oa,za+="}"),za},toContinued:function(){var V=this.n,ia=this.d,za=[];if(isNaN(V)||isNaN(ia))return za;do{za.push(Math.floor(V/ia));var Ca=V%ia;V=ia;ia=Ca}while(1!==V);return za},toString:function(V){var ia,za=this.n,Ca=this.d;if(isNaN(za)||isNaN(Ca))return"NaN";D.REDUCE||(za/=ia=cb(za,Ca),Ca/=ia);V=V|| +15;ia=function(zb,Hb){for(;0==Hb%2;Hb/=2);for(;0==Hb%5;Hb/=5);if(1===Hb)return 0;zb=10%Hb;for(var Gb=1;1!==zb;Gb++)if(zb=10*zb%Hb,2E3>=1)1&Gb&&(eb=eb*vb%Hb);vb=eb;for(Gb=0;300>Gb;Gb++){if(zb===vb)return Gb;zb=10*zb%Hb;vb=10*vb%Hb}return 0}(0,Ca,ia),qb=-1===this.s?"-":"";if(qb+=za/Ca|0,za%=Ca,(za*=10)&&(qb+="."),ia){for(V=Oa;V--;)qb+=za/Ca|0,za%=Ca,za*=10;qb+="(";for(V=ia;V--;)qb+=za/Ca|0,za%=Ca, +za*=10;qb+=")"}else for(;za&&V--;)qb+=za/Ca|0,za%=Ca,za*=10;return qb}};void 0===(pa=function(){return D}.apply(Qa,[]))||(Ra.exports=pa)}()},228:Ra=>{Ra.exports=function Ob(pa,rb){var Z,Ia,Fa=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,cb=/(^[ ]*|[ ]*$)/g,D=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,H=/^0x[0-9a-f]+$/i,K=/^0/,ea=function(fa){return Ob.insensitive&&(""+fa).toLowerCase()||""+fa};pa= +ea(pa).replace(cb,"")||"";cb=ea(rb).replace(cb,"")||"";rb=pa.replace(Fa,"\x00$1\x00").replace(/\0$/,"").replace(/^\0/,"").split("\x00");Fa=cb.replace(Fa,"\x00$1\x00").replace(/\0$/,"").replace(/^\0/,"").split("\x00");pa=parseInt(pa.match(H),16)||1!==rb.length&&pa.match(D)&&Date.parse(pa);if(D=parseInt(cb.match(H),16)||pa&&cb.match(D)&&Date.parse(cb)||null){if(paD)return 1}D=0;for(H=Math.max(rb.length,Fa.length);DIa)return 1}return 0}},377:(Ra,Qa,pa)=>{Qa=pa(832);var rb=pa(652),Ob=pa(801),Z=pa(30),Ia=pa(618),Fa=pa(49);pa=pa(971);pa.alea=Qa;pa.xor128=rb;pa.xorwow=Ob;pa.xorshift7=Z;pa.xor4096=Ia;pa.tychei=Fa;Ra.exports=pa},832:function(Ra,Qa,pa){var rb;!function(Ob,Z,Ia){function Fa(H){var K,ea=this,fa=(K=4022871197,function(V){V=String(V);for(var ia=0;ia>>0;K=(za*=K)>>>0;K+=4294967296*(za-K)}return 2.3283064365386963E-10*(K>>>0)});ea.next=function(){var V=2091639*ea.s0+2.3283064365386963E-10*ea.c;return ea.s0=ea.s1,ea.s1=ea.s2,ea.s2=V-(ea.c=0|V)};ea.c=1;ea.s0=fa(" ");ea.s1=fa(" ");ea.s2=fa(" ");ea.s0-=fa(H);0>ea.s0&&(ea.s0+=1);ea.s1-=fa(H);0>ea.s1&&(ea.s1+=1);ea.s2-=fa(H);0>ea.s2&&(ea.s2+=1);fa=null}function cb(H,K){return K.c=H.c,K.s0=H.s0,K.s1=H.s1,K.s2=H.s2,K}function D(H,K){var ea=new Fa(H);H= +K&&K.state;var fa=ea.next;return fa.int32=function(){return 4294967296*ea.next()|0},fa.double=function(){return fa()+1.1102230246251565E-16*(2097152*fa()|0)},fa.quick=fa,H&&("object"==typeof H&&cb(H,ea),fa.state=function(){return cb(ea,{})}),fa}Z&&Z.exports?Z.exports=D:pa.amdD&&pa.amdO?void 0===(rb=D)||(Z.exports=rb):this.alea=D}(0,Ra=pa.nmd(Ra),pa.amdD)},49:function(Ra,Qa,pa){var rb;!function(Ob,Z,Ia){function Fa(H){var K=this,ea="";K.next=function(){var fa=K.b,V=K.c,ia=K.d,za=K.a;return fa=fa<< +25^fa>>>7^V,V=V-ia|0,ia=ia<<24^ia>>>8^za,za=za-fa|0,K.b=fa=fa<<20^fa>>>12^V,K.c=V=V-ia|0,K.d=ia<<16^V>>>16^za,K.a=za-fa|0};K.a=0;K.b=0;K.c=-1640531527;K.d=1367130551;H===Math.floor(H)?(K.a=H/4294967296|0,K.b=0|H):ea+=H;for(H=0;H>>0)/4294967296};return K.double=function(){do var fa=((ea.next()>>>11)+(ea.next()>>>0)/ +4294967296)/2097152;while(0===fa);return fa},K.int32=ea.next,K.quick=K,H&&("object"==typeof H&&cb(H,ea),K.state=function(){return cb(ea,{})}),K}Z&&Z.exports?Z.exports=D:pa.amdD&&pa.amdO?void 0===(rb=D)||(Z.exports=rb):this.tychei=D}(0,Ra=pa.nmd(Ra),pa.amdD)},652:function(Ra,Qa,pa){var rb;!function(Ob,Z,Ia){function Fa(H){var K=this,ea="";K.x=0;K.y=0;K.z=0;K.w=0;K.next=function(){var fa=K.x^K.x<<11;return K.x=K.y,K.y=K.z,K.z=K.w,K.w=K.w^K.w>>>19^fa^fa>>>8};H===(0|H)?K.x=H:ea+=H;for(H=0;H>>0)/4294967296};return K.double=function(){do var fa=((ea.next()>>>11)+(ea.next()>>>0)/4294967296)/2097152;while(0===fa);return fa},K.int32=ea.next,K.quick=K,H&&("object"==typeof H&&cb(H,ea),K.state=function(){return cb(ea,{})}),K}Z&&Z.exports?Z.exports=D:pa.amdD&&pa.amdO?void 0===(rb=D)||(Z.exports=rb):this.xor128=D}(0,Ra=pa.nmd(Ra), +pa.amdD)},618:function(Ra,Qa,pa){var rb;!function(Ob,Z,Ia){function Fa(H){var K=this;K.next=function(){var ea,fa,V=K.w,ia=K.X,za=K.i;return K.w=V=V+1640531527|0,fa=ia[za+34&127],ea=ia[za=za+1&127],fa^=fa<<13,ea^=ea<<17,fa^=fa>>>15,ea^=ea>>>12,fa=ia[za]=fa^ea,K.i=za,fa+(V^V>>>16)|0};(function(ea,fa){var V,ia,za,Ca=[],Oa=128;fa===(0|fa)?(V=fa,fa=null):(fa+="\x00",V=0,Oa=Math.max(Oa,fa.length));var qb=0;for(ia=-32;ia>>15, +V^=V<<4,V^=V>>>13,0<=ia&&(za=za+1640531527|0,qb=0==(Ca[127&ia]^=V+za)?qb+1:0);128<=qb&&(Ca[127&(fa&&fa.length||0)]=-1);qb=127;for(ia=512;0>>15,fa^=fa>>>12,Ca[qb]=V^fa;ea.w=za;ea.X=Ca;ea.i=qb})(K,H)}function cb(H,K){return K.i=H.i,K.w=H.w,K.X=H.X.slice(),K}function D(H,K){null==H&&(H=+new Date);var ea=new Fa(H);H=K&&K.state;K=function(){return(ea.next()>>>0)/4294967296};return K.double=function(){do var fa=((ea.next()>>>11)+(ea.next()>>> +0)/4294967296)/2097152;while(0===fa);return fa},K.int32=ea.next,K.quick=K,H&&(H.X&&cb(H,ea),K.state=function(){return cb(ea,{})}),K}Z&&Z.exports?Z.exports=D:pa.amdD&&pa.amdO?void 0===(rb=D)||(Z.exports=rb):this.xor4096=D}(0,Ra=pa.nmd(Ra),pa.amdD)},30:function(Ra,Qa,pa){var rb;!function(Ob,Z,Ia){function Fa(H){var K=this;K.next=function(){var ea,fa,V=K.x,ia=K.i;return ea=V[ia],fa=(ea^=ea>>>7)^ea<<24,fa^=(ea=V[ia+1&7])^ea>>>10,fa^=(ea=V[ia+3&7])^ea>>>3,fa^=(ea=V[ia+4&7])^ea<<7,ea=V[ia+7&7],fa^=(ea^= +ea<<13)^ea<<9,V[ia]=fa,K.i=ia+1&7,fa};(function(ea,fa){var V,ia=[];if(fa===(0|fa))ia[0]=fa;else for(fa=""+fa,V=0;Via.length;)ia.push(0);for(V=0;8>V&&0===ia[V];++V);8==V?ia[7]=-1:ia[V];ea.x=ia;ea.i=0;for(V=256;0>>0)/4294967296};return K.double=function(){do var fa= +((ea.next()>>>11)+(ea.next()>>>0)/4294967296)/2097152;while(0===fa);return fa},K.int32=ea.next,K.quick=K,H&&(H.x&&cb(H,ea),K.state=function(){return cb(ea,{})}),K}Z&&Z.exports?Z.exports=D:pa.amdD&&pa.amdO?void 0===(rb=D)||(Z.exports=rb):this.xorshift7=D}(0,Ra=pa.nmd(Ra),pa.amdD)},801:function(Ra,Qa,pa){var rb;!function(Ob,Z,Ia){function Fa(H){var K=this,ea="";K.next=function(){var fa=K.x^K.x>>>2;return K.x=K.y,K.y=K.z,K.z=K.w,K.w=K.v,(K.d=K.d+362437|0)+(K.v=K.v^K.v<<4^fa^fa<<1)|0};K.x=0;K.y=0;K.z= +0;K.w=0;K.v=0;H===(0|H)?K.x=H:ea+=H;for(H=0;H>>4),K.next()}function cb(H,K){return K.x=H.x,K.y=H.y,K.z=H.z,K.w=H.w,K.v=H.v,K.d=H.d,K}function D(H,K){var ea=new Fa(H);H=K&&K.state;K=function(){return(ea.next()>>>0)/4294967296};return K.double=function(){do var fa=((ea.next()>>>11)+(ea.next()>>>0)/4294967296)/2097152;while(0===fa);return fa},K.int32=ea.next,K.quick=K,H&&("object"==typeof H&&cb(H,ea),K.state=function(){return cb(ea, +{})}),K}Z&&Z.exports?Z.exports=D:pa.amdD&&pa.amdO?void 0===(rb=D)||(Z.exports=rb):this.xorwow=D}(0,Ra=pa.nmd(Ra),pa.amdD)},971:function(Ra,Qa,pa){var rb;!function(Ob,Z,Ia){function Fa(Ca,Oa,qb){var zb=[],Hb=K(H((Oa=1==Oa?{entropy:!0}:Oa||{}).entropy?[Ca,ea(Z)]:null==Ca?function(){try{var vb;return za&&(vb=za.randomBytes)?vb=vb(256):(vb=new Uint8Array(256),(Ob.crypto||Ob.msCrypto).getRandomValues(vb)),ea(vb)}catch(eb){return vb=Ob.navigator,[+new Date,Ob,vb&&vb.plugins,Ob.screen,ea(Z)]}}():Ca,3),zb), +Gb=new cb(zb);Ca=function(){for(var vb=Gb.g(6),eb=fa,lb=0;vb=ia;)vb/=2,eb/=2,lb>>>=1;return(vb+lb)/eb};return Ca.int32=function(){return 0|Gb.g(4)},Ca.quick=function(){return Gb.g(4)/4294967296},Ca.double=Ca,K(ea(Gb.S),Z),(Oa.pass||qb||function(vb,eb,lb,uc){return uc&&(uc.S&&D(uc,Gb),vb.state=function(){return D(Gb,{})}),lb?(Ia.random=vb,eb):vb})(Ca,Hb,"global"in Oa?Oa.global:this==Ia,Oa.state)}function cb(Ca){var Oa,qb=Ca.length,zb=this,Hb=0,Gb=zb.i= +zb.j=0,vb=zb.S=[];for(qb||(Ca=[qb++]);256>Hb;)vb[Hb]=Hb++;for(Hb=0;256>Hb;Hb++)vb[Hb]=vb[Gb=255&Gb+Ca[Hb%qb]+(Oa=vb[Hb])],vb[Gb]=Oa;(zb.g=function(eb){for(var lb,uc=0,Bb=zb.i,Cc=zb.j,Kc=zb.S;eb--;)lb=Kc[Bb=255&Bb+1],uc=256*uc+Kc[255&(Kc[Bb]=Kc[Cc=255&Cc+lb])+(Kc[Cc]=lb)];return zb.i=Bb,zb.j=Cc,uc})(256)}function D(Ca,Oa){return Oa.i=Ca.i,Oa.j=Ca.j,Oa.S=Ca.S.slice(),Oa}function H(Ca,Oa){var qb,zb=[],Hb=typeof Ca;if(Oa&&"object"==Hb)for(qb in Ca)try{zb.push(H(Ca[qb],Oa-1))}catch(Gb){}return zb.length? +zb:"string"==Hb?Ca:Ca+"\x00"}function K(Ca,Oa){var qb;Ca+="";for(var zb=0;zb=db+1}}return 0=== +B.length?function(mb){return 0===mb.length}:1===B.length?(Aa=ia(B[0]),function(mb){return Aa(mb[0])&&1===mb.length}):2===B.length?(Aa=ia(B[0]),va=ia(B[1]),function(mb){return Aa(mb[0])&&va(mb[1])&&2===mb.length}):(ta=B.map(ia),function(mb){for(var Va=0;Vadb?((va=new TypeError("Too many arguments in function "+B+" (expected: "+db+", actual: "+ta.length+")")).data={category:"tooManyArgs",fn:B,index:ta.length,expectedLength:db},va):((va=new TypeError('Arguments of type "'+ta.join(", ")+'" do not match any of the defined signatures of function '+B+".")).data={category:"mismatch",actual:ta.map(H)},va)}function vb(B){for(var ta=999,Aa=0;Aa=N:T?N>=Y:N===Y}return J});if(A)throw new TypeError('Conflicting signatures "'+K(A.params)+'" and "'+K(C.params)+'".');Aa.push(C)});var va=vd(Aa,function(C){return(C?Bb(C.params,!1):[]).map(function(A){return{params:A,fn:C.fn}})}).filter(Ld);va.sort(lb);var db=va[0]&&2>=va[0].params.length&& +!fa(va[0].params),fb=va[1]&&2>=va[1].params.length&&!fa(va[1].params),mb=va[2]&&2>=va[2].params.length&&!fa(va[2].params),Va=va[3]&&2>=va[3].params.length&&!fa(va[3].params),cc=va[4]&&2>=va[4].params.length&&!fa(va[4].params),Za=va[5]&&2>=va[5].params.length&&!fa(va[5].params),od=db&&fb&&mb&&Va&&cc&&Za,$c=va.map(function(C){return za(C.params)}),yd=db?ia(va[0].params[0]):Z,Wd=fb?ia(va[1].params[0]):Z,Xd=mb?ia(va[2].params[0]):Z,zd=Va?ia(va[3].params[0]):Z,fd=cc?ia(va[4].params[0]):Z,Ec=Za?ia(va[5].params[0]): +Z,Md=db?ia(va[0].params[1]):Z,Yd=fb?ia(va[1].params[1]):Z,Db=mb?ia(va[2].params[1]):Z,Lc=Va?ia(va[3].params[1]):Z,Dc=cc?ia(va[4].params[1]):Z,Pc=Za?ia(va[5].params[1]):Z,wc=va.map(function(C){return function(A,J){var N=J;if(A.some(V)){var Y=fa(A),T=A.map(uc);N=function(){for(var xa=[],ya=Y?arguments.length-1:arguments.length,ra=0;ra{}},Nb={};jb.amdD=function(){throw Error("define cannot be used indirect");};jb.amdO= +{};jb.nmd=Ra=>(Ra.paths=[],Ra.children||(Ra.children=[]),Ra);(()=>{function Ra(){return(Ra=Object.assign||function(b){for(var a=1;a!(g&&"?"===g[0])).every(g=>void 0!==n[g]))throw k=k.filter(g=>void 0===n[g]),Error('Cannot create function "'.concat(p,'", ')+"some dependencies are missing: ".concat(k.map(g=>'"'.concat(g,'"')).join(", "),"."));}(b,a,h),d(l)}return f.isFactory=!0,f.fn= +b,f.dependencies=a.slice().sort(),c&&(f.meta=c),f}function ta(b){return b&&"?"===b[0]?b.slice(1):b}function Aa(b,a){if("object"==typeof b&&b&&b.constructor===Object&&db(b,a))return b[a];if("function"==typeof b[a]&&fb(b,a))throw Error('Cannot access method "'+a+'" as a property');throw Error('No access to property "'+a+'"');}function va(b,a,d){if("object"==typeof b&&b&&b.constructor===Object&&db(b,a))return b[a]=d,d;throw Error('No access to property "'+a+'"');}function db(b,a){return!(!b||"object"!= +typeof b||!Pa(qi,a)&&(a in Object.prototype||a in Function.prototype))}function fb(b,a){return!(null==b||"function"!=typeof b[a]||Pa(b,a)&&Object.getPrototypeOf&&a in Object.getPrototypeOf(b)||!Pa(ri,a)&&(a in Object.prototype||a in Function.prototype))}function mb(b){if(!b)return new Map;if(Va(b))return b;if(qb(b))return new We(b);throw Error("createMap can create maps from objects or Maps");}function Va(b){return!!b&&(b instanceof Map||b instanceof We||"function"==typeof b.set&&"function"==typeof b.get&& +"function"==typeof b.keys&&"function"==typeof b.has)}function cc(b){for(var a=arguments.length,d=Array(1d)throw Error("size must be in greater than 0");if(!Za(d))throw Error("size must be an integer"); +if(b>Math.pow(2,d-1)-1||b<-Math.pow(2,d-1))throw Error("Value must be in range [-2^".concat(d-1,", 2^").concat(d-1,"-1]"));if(!Za(b))throw Error("Value must be an integer");0>b&&(b+=Math.pow(2,d));f="i".concat(d)}d="";return 0>b&&(b=-b,d="-"),"".concat(d).concat(c).concat(b.toString(a)).concat(f)}function $c(b,a){if("function"==typeof a)return a(b);if(b===1/0)return"Infinity";if(b===-1/0)return"-Infinity";if(isNaN(b))return"NaN";var d,c,f="auto";if(a&&(a.notation&&(f=a.notation),Qa(a)?d=a:Qa(a.precision)&& +(d=a.precision),a.wordSize&&"number"!=typeof(c=a.wordSize)))throw Error('Option "wordSize" must be a number');switch(f){case "fixed":return Wd(b,d);case "exponential":return Xd(b,d);case "engineering":return function(h,l){if(isNaN(h)||!isFinite(h))return String(h);h=zd(yd(h),l);var p=h.exponent,k=h.coefficients,n=0==p%3?p:0>p?p-3-p%3:p-p%3;if(Qa(l))for(;l>k.length||p-n+1>k.length;)k.push(0);else for(var g=Math.abs(p-n)-(k.length-1),e=0;e=n)return Xd(h,l);h=p.coefficients;k=p.exponent;h.lengthc&&(d=fd(1-c).concat(d),c=1),c=a;)d.unshift(0),b.exponent++,a++;if(d.length>a&&5<=d.splice(a,d.length-a)[0])for(--a,d[a]++;10===d[a];)d.pop(), +0===a&&(d.unshift(0),b.exponent++,a++),d[--a]++;return b}function fd(b){for(var a=[],d=0;dd)throw Error("size must be in greater than 0");if(!Za(d))throw Error("size must be an integer");if(b.greaterThan(c.pow(d- +1).sub(1))||b.lessThan(c.pow(d-1).mul(-1)))throw Error("Value must be in range [-2^".concat(d-1,", 2^").concat(d-1,"-1]"));if(!b.isInteger())throw Error("Value must be an integer");b.lessThan(0)&&(b=b.add(c.pow(d)));f="i".concat(d)}switch(a){case 2:return"".concat(b.toBinary()).concat(f);case 8:return"".concat(b.toOctal()).concat(f);case 16:return"".concat(b.toHexadecimal()).concat(f);default:throw Error("Base ".concat(a," not supported "));}}function Yd(b,a){return void 0!==a?b.toExponential(a-1): +b.toExponential()}function Db(b,a){return"number"==typeof b?$c(b,a):pa(b)?function(d,c){if("function"==typeof c)return c(d);if(!d.isFinite())return d.isNaN()?"NaN":d.gt(0)?"Infinity":"-Infinity";var f,h,l="auto";if(void 0!==c&&(c.notation&&(l=c.notation),"number"==typeof c?f=c:c.precision&&(f=c.precision),c.wordSize&&"number"!=typeof(h=c.wordSize)))throw Error('Option "wordSize" must be a number');switch(l){case "fixed":return d.toFixed(f);case "exponential":return Yd(d,f);case "engineering":return function(k, +n){var g=k.e,e=0==g%3?g:0>g?g-3-g%3:g-g%3;k=k.mul(Math.pow(10,-e));n=k.toPrecision(n);return-1!==n.indexOf("e")&&(n=k.toString()),n+"e"+(0<=g?"+":"")+e.toString()}(d,f);case "bin":return Md(d,2,h);case "oct":return Md(d,8,h);case "hex":return Md(d,16,h);case "auto":h=c&&void 0!==c.lowerExp?c.lowerExp:-3;c=c&&void 0!==c.upperExp?c.upperExp:5;if(d.isZero())return"0";l=d.toSignificantDigits(f);var p=l.e;return(p>=h&&p +'"'+d+'": '+Db(b[d],a)).join(", ")+"}":String(b)}function Lc(b){b=String(b);for(var a="",d=0;d/g,">")}function Pc(b,a){if(Array.isArray(b)){for(var d="[",c=b.length,f=0;fa?1:-1}function yb(b,a,d){if(!(this instanceof yb))throw new SyntaxError("Constructor must be called with the new operator");this.actual=b;this.expected= +a;this.relation=d;this.message="Dimension mismatch ("+(Array.isArray(b)?"["+b.join(", ")+"]":b)+" "+(this.relation||"!=")+" "+(Array.isArray(a)?"["+a.join(", ")+"]":a)+")";this.stack=Error().stack}function Gc(b,a,d){if(!(this instanceof Gc))throw new SyntaxError("Constructor must be called with the new operator");this.index=b;3>arguments.length?(this.min=0,this.max=a):(this.min=a,this.max=d);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=Error().stack}function Ua(b){for(var a=[];Array.isArray(b);)a.push(b.length),b=b[0];return a}function rc(b,a,d){var c=b.length;if(c!==a[d])throw new yb(c,a[d]);if(d");}function jc(b,a){if(0===a.length){if(Array.isArray(b))throw new yb(b.length,0);}else rc(b,a,0)}function Yb(b,a){if(!Qa(b)||!Za(b))throw new TypeError("Index must be an integer (value: "+b+")");if(0>b||"number"==typeof a&&b>=a)throw new Gc(b,a);}function gd(b,a,d){if(!Array.isArray(b)||!Array.isArray(a))throw new TypeError("Array expected");if(0===a.length)throw Error("Resizing to scalar is not supported");return a.forEach(function(c){if(!Qa(c)||!Za(c)||0>c)throw new TypeError("Invalid size, must contain positive integers (size: "+ +Db(a)+")");}),Nd(b,a,0,void 0!==d?d:0),b}function Nd(b,a,d,c){var f=a[d],h=Math.min(b.length,f);if(b.length=f,d +a*d,1)}function Ba(b,a){for(a=a||Ua(b);Array.isArray(b)&&1===b.length;)b=b[0],a.shift();for(var d=a.length;1===a[d-1];)d--;return da.test(d))}function T(b){if(!Array.isArray(b))throw new TypeError("Array input expected");if(0===b.length)return b;var a=[],d=0;a[0]={value:b[0],identifier:0};for(var c=1;ca||a>=c.length)throw new Gc(a,c.length);return Fa(b)?b.create(Mc(b.valueOf(),a,d)):Mc(b,a,d)}function Mc(b,a,d){var c,f;if(0>=a){if(Array.isArray(b[0])){var h=b.length,l=b[0].length,p=[];for(f=0;f=a){if(Array.isArray(b[0])){var h= +b.length,l=b[0].length,p=[];for(f=0;f +h)for(b=h-1,f=l.length;b{var {config:f,Unit:h,BigNumber:l}=c;c=new h("BigNumber"===f.number?new l(a):parseFloat(a),d);return c.fixPrefix=!0,c})}function Ge(b,a){return B(b,["config","BigNumber"], +d=>{var {config:c,BigNumber:f}=d;return"BigNumber"===c.number?new f(a):a})}function Ze(b){throw Error("Cannot convert value ".concat(b," into a BigNumber: no class 'BigNumber' provided"));}function He(b){throw Error("Cannot convert value ".concat(b," into a Complex number: no class 'Complex' provided"));}function $e(b){throw Error("Cannot convert value ".concat(b," into a Fraction, no class 'Fraction' provided."));}function Df(b){return 0>b}function Ef(b){return 0b?-b:b}function Sf(b,a){if(!Za(b)||!Za(a))throw Error("Parameters in function lcm must be integer numbers");if(0===b||0===a)return 0;for(var d=b*a;0!==a;)a=b%(b=a);return Math.abs(d/b)}function Tf(b){return Math.log(b)}function Uf(b,a){if(0a;if(d&&(a=-a),0===a)throw Error("Root must be non-zero");if(0>b&&1!=Math.abs(a)%2)throw Error("Root must be odd when a is negative.");if(0===b)return d?1/0:0;if(!isFinite(b))return d?0:b;a=Math.pow(Math.abs(b),1/a);return a=0>b?-a:a,d?1/a:a}function Vf(b){return pd(b)}function Wf(b){return b*b}function Xf(b,a){var d,c=0,f=1,h=1,l=0;if(!Za(b)||!Za(a))throw Error("Parameters in function xgcd must be integer numbers");for(;a;){var p=b-(d=Math.floor(b/a))*a;b=c;c=f-d*c;f=b; +b=h;h=l-d*h;l=b;b=a;a=p}return 0>b?[-b,-f,-l]:[b,b?f:0,l]}function Yf(b,a){return 1>b*b&&a===1/0||1b.s),k=+(0>a.s);if(p){b=Je(oe(b));for(var n=0;na)for(b-=a;b--;)d+="0";else b>1,b[c]&=1)}return b.reverse()}function Bi(b,a){if(b.isFinite()&&!b.isInteger()||a.isFinite()&& +!a.isInteger())throw Error("Integers expected in function bitXor");var d=b.constructor;if(b.isNaN()||a.isNaN())return new d(NaN);if(b.isZero())return a;if(a.isZero())return b;if(b.eq(a))return new d(0);var c=new d(-1);return b.eq(c)?oe(a):a.eq(c)?oe(b):b.isFinite()&&a.isFinite()?cf(b,a,function(f,h){return f^h}):b.isFinite()||a.isFinite()?new d(b.isNegative()===a.isNegative()?1/0:-1/0):c}function Ci(b,a){if(b.isFinite()&&!b.isInteger()||a.isFinite()&&!a.isInteger())throw Error("Integers expected in function leftShift"); +var d=b.constructor;return b.isNaN()||a.isNaN()||a.isNegative()&&!a.isZero()?new d(NaN):b.isZero()||a.isZero()?b:b.isFinite()||a.isFinite()?a.lt(55)?b.times(Math.pow(2,a.toNumber())+""):b.times((new d(2)).pow(a)):new d(NaN)}function Di(b,a){if(b.isFinite()&&!b.isInteger()||a.isFinite()&&!a.isInteger())throw Error("Integers expected in function rightArithShift");var d=b.constructor;return b.isNaN()||a.isNaN()||a.isNegative()&&!a.isZero()?new d(NaN):b.isZero()||a.isZero()?b:a.isFinite()?a.lt(55)?b.div(Math.pow(2, +a.toNumber())+"").floor():b.div((new d(2)).pow(a)).floor():b.isNegative()?new d(-1):b.isFinite()?new d(0):new d(NaN)}function Zf(b,a){if(!Za(b)||!Za(a))throw Error("Integers expected in function bitAnd");return b&a}function $f(b){if(!Za(b))throw Error("Integer expected in function bitNot");return~b}function ag(b,a){if(!Za(b)||!Za(a))throw Error("Integers expected in function bitOr");return b|a}function bg(b,a){if(!Za(b)||!Za(a))throw Error("Integers expected in function bitXor");return b^a}function cg(b, +a){if(!Za(b)||!Za(a))throw Error("Integers expected in function leftShift");return b<>a}function eg(b,a){if(!Za(b)||!Za(a))throw Error("Integers expected in function rightLogShift");return b>>>a}function fg(b){return!b}function gg(b,a){return!(!b&&!a)}function hg(b,a){return!!b!=!!a}function ig(b,a){return!(!b||!a)}function jg(b,a){var d=$d(a);return N(b,function(c,f,h){return 1===d?a(c):2=== +d?a(c,[f]):a(c,[f],h)})}function Ei(b,a){var d=$d(a);!function l(f,h){Array.isArray(f)?J(f,function(p,k){l(p,h.concat(k))}):1===d?a(f):2===d?a(f,h):a(f,h,b)}(b,[])}function Fi(b,a){var d=$d(a);return function l(f,h){return Array.isArray(f)?f.map(function(p,k){return l(p,h.concat(k))}):1===d?a(f):2===d?a(f,h):a(f,h,b)}(b,[])}function kg(b,a,d){return b.replace(/\$([\w.]+)/g,function(c,f){f=f.split(".");for(var h=a[f.shift()];f.length&&void 0!==h;){var l=f.shift();h=l?h[l]:h+"."}return void 0!==h?Ia(h)? +h:Db(h,d):c})}function lg(b){return Math.atan(1/b)}function mg(b){return isFinite(b)?(Math.log((b+1)/b)+Math.log(b/(b-1)))/2:0}function ng(b){return Math.asin(1/b)}function og(b){b=1/b;return Math.log(b+Math.sqrt(b*b+1))}function pg(b){return Math.acos(1/b)}function qg(b){b=1/b;return Math.log(Math.sqrt(b*b-1)+b)}function rg(b){return Gi(b)}function sg(b){return 1/Math.tan(b)}function tg(b){b=Math.exp(2*b);return(b+1)/(b-1)}function ug(b){return 1/Math.sin(b)}function vg(b){return 0===b?Number.POSITIVE_INFINITY: +Math.abs(2/(Math.exp(b)-Math.exp(-b)))*pd(b)}function wg(b){return 1/Math.cos(b)}function xg(b){return 2/(Math.exp(b)+Math.exp(-b))}function yg(b){return Hi(b)}function Wc(b,a){if(a>1;return Wc(b,d)*Wc(d+1,a)}function zg(b,a){if(!Za(b)||0>b)throw new TypeError("Positive integer value expected in function combinations");if(!Za(a)||0>a)throw new TypeError("Positive integer value expected in function combinations");if(a>b)throw new TypeError("k must be less than or equal to n"); +var d=b-a;return a=b?isFinite(b)?1/0:NaN:171b)return Math.PI/(Math.sin(Math.PI*b)*ef(1-b));if(171.35<=b)return 1/ +0;if(85 +b?-b-2:b}function Kg(b,a){var d=Object.keys(b);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(b);a&&(c=c.filter(function(f){return Object.getOwnPropertyDescriptor(b,f).enumerable}));d.push.apply(d,c)}return d}function ff(b){for(var a=1;a{function a(){if(!(this instanceof +a))throw new SyntaxError("Constructor must be called with the new operator");}var {mathWithTransform:d}=b;return a.prototype.evaluate=function(c){return this.compile().evaluate(c)},a.prototype.type="Node",a.prototype.isNode=!0,a.prototype.comment="",a.prototype.compile=function(){var c=this._compile(d,{}),f={};return{evaluate:function(h){h=mb(h);for(var l of[...Ng])if(h.has(l))throw Error('Scope contains an illegal symbol, "'+l+'" is a reserved keyword');return c(h,f,null)}}},a.prototype._compile= +function(c,f){throw Error("Method _compile should be implemented by type "+this.type);},a.prototype.forEach=function(c){throw Error("Cannot run forEach on a Node interface");},a.prototype.map=function(c){throw Error("Cannot run map on a Node interface");},a.prototype._ifNode=function(c){if(!Mb(c))throw new TypeError("Callback function must return a Node");return c},a.prototype.traverse=function(c){c(this,null,null);(function p(h,l){h.forEach(function(k,n,g){l(k,n,g);p(k,l)})})(this,c)},a.prototype.transform= +function(c){return function k(h,l,p){l=c(h,l,p);return l!==h?l:h.map(k)}(this,null,null)},a.prototype.filter=function(c){var f=[];return this.traverse(function(h,l,p){c(h,l,p)&&f.push(h)}),f},a.prototype.clone=function(){throw Error("Cannot clone a Node interface");},a.prototype.cloneDeep=function(){return this.map(function(c){return c.cloneDeep()})},a.prototype.equals=function(c){return!!c&&Zc(this,c)},a.prototype.toString=function(c){var f=this._getCustomString(c);return void 0!==f?f:this._toString(c)}, +a.prototype.toJSON=function(){throw Error("Cannot serialize object: toJSON not implemented by "+this.type);},a.prototype.toHTML=function(c){var f=this._getCustomString(c);return void 0!==f?f:this.toHTML(c)},a.prototype._toString=function(){throw Error("_toString not implemented for "+this.type);},a.prototype.toTex=function(c){var f=this._getCustomString(c);return void 0!==f?f:this._toTex(c)},a.prototype._toTex=function(c){throw Error("_toTex not implemented for "+this.type);},a.prototype._getCustomString= +function(c){if(c&&"object"==typeof c)switch(typeof c.handler){case "object":case "undefined":break;case "function":return c.handler(this,c);default:throw new TypeError("Object or function expected as callback");}},a.prototype.getIdentifier=function(){return this.type},a.prototype.getContent=function(){return this},a},{isClass:!0,isNode:!0}),pd=Math.sign||function(b){return 0b?-1:0},Ki=Math.log2||function(b){return Math.log(b)/Math.LN2},Li=Math.log10||function(b){return Math.log(b)/Math.LN10}, +Mi=Math.log1p||function(b){return Math.log(b+1)},Ie=Math.cbrt||function(b){if(0===b)return b;var a,d=0>b;return d&&(b=-b),a=isFinite(b)?(b/((a=Math.exp(Math.log(b)/3))*a)+2*a)/3:b,d?-a:a},yi=Math.expm1||function(b){return 2E-4<=b||-2E-4>=b?Math.exp(b)-1:b+b*b/2+b*b*b/6},si=Number.EPSILON||2.220446049250313E-16,Ni=Math.acosh||function(b){return Math.log(Math.sqrt(b*b-1)+b)},Gi=Math.asinh||function(b){return Math.log(Math.sqrt(b*b+1)+b)},Oi=Math.atanh||function(b){return Math.log((1+b)/(1-b))/2},Pi= +Math.cosh||function(b){return(Math.exp(b)+Math.exp(-b))/2},Hi=Math.sinh||function(b){return(Math.exp(b)-Math.exp(-b))/2},Qi=Math.tanh||function(b){b=Math.exp(2*b);return(b-1)/(b+1)};yb.prototype=new RangeError;yb.prototype.constructor=RangeError;yb.prototype.name="DimensionError";yb.prototype.isDimensionError=!0;Gc.prototype=new RangeError;Gc.prototype.constructor=RangeError;Gc.prototype.name="IndexError";Gc.prototype.isIndexError=!0;var Ri=B("ArrayNode",["Node"],b=>{function a(d){if(!(this instanceof +a))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=d||[],!Array.isArray(this.items)||!this.items.every(Mb))throw new TypeError("Array containing Nodes expected");}({Node:b}=b);return a.prototype=new b,a.prototype.type="ArrayNode",a.prototype.isArrayNode=!0,a.prototype._compile=function(d,c){var f=A(this.items,function(l){return l._compile(d,c)});if("Array"!==d.config.matrix){var h=d.matrix;return function(l,p,k){return h(A(f,function(n){return n(l,p,k)}))}}return function(l, +p,k){return A(f,function(n){return n(l,p,k)})}},a.prototype.forEach=function(d){for(var c=0;c['+this.items.map(function(c){return c.toHTML(d)}).join(',')+']'},a.prototype._toTex=function(d){var c="\\begin{bmatrix}";return this.items.forEach(function(f){f.items?c+=f.items.map(function(h){return h.toTex(d)}).join("&"):c+=f.toTex(d); +c+="\\\\"}),c+="\\end{bmatrix}"},a},{isClass:!0,isNode:!0}),Si=B("BlockNode",["ResultSet","Node"],b=>{function a(f){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(f))throw Error("Array expected");this.blocks=f.map(function(h){var l=h&&h.node;h=!h||void 0===h.visible||h.visible;if(!Mb(l))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof h)throw new TypeError('Property "visible" must be a boolean');return{node:l, +visible:h}})}var {ResultSet:d,Node:c}=b;return a.prototype=new c,a.prototype.type="BlockNode",a.prototype.isBlockNode=!0,a.prototype._compile=function(f,h){var l=A(this.blocks,function(p){return{evaluate:p.node._compile(f,h),visible:p.visible}});return function(p,k,n){var g=[];return J(l,function(e){var m=e.evaluate(p,k,n);e.visible&&g.push(m)}),new d(g)}},a.prototype.forEach=function(f){for(var h=0;h;')}).join('
')},a.prototype._toTex=function(f){return this.blocks.map(function(h){return h.node.toTex(f)+(h.visible?"":";")}).join("\\;\\;\n")},a},{isClass:!0,isNode:!0}),ti=jb(928),Xe={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{?}"},Pb={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"},Og={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(Pb.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(Pb.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(Pb.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(Pb.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(Pb.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(Pb.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(Pb.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(Pb.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(Pb.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(Pb.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(Pb.unaryPlus,"\\left(${args[0]}\\right)")}, +bitAnd:{2:"\\left(${args[0]}".concat(Pb.bitAnd,"${args[1]}\\right)")},bitNot:{1:Pb.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(Pb.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(Pb.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(Pb.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(Pb.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(Pb.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(Pb.and,"${args[1]}\\right)")},not:{1:Pb.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(Pb.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(Pb.xor, +"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(Pb.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},sqrtm:{1:"{${args[0]}}".concat(Pb.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(Pb.transpose)}, +combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(Pb.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(Pb.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(Pb.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(Pb.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(Pb.smaller, +"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(Pb.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(Pb.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(Pb.to,"${args[1]}\\right)")},numeric:function(b, +a){return b.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(Xe.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)"}},yf={deg:"^\\circ"},Ti=B("ConstantNode",["Node"],b=>{function a(d){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this.value=d}({Node:b}=b);return a.prototype=new b,a.prototype.type="ConstantNode",a.prototype.isConstantNode=!0,a.prototype._compile=function(d,c){var f=this.value;return function(){return f}},a.prototype.forEach= +function(d){},a.prototype.map=function(d){return this.clone()},a.prototype.clone=function(){return new a(this.value)},a.prototype._toString=function(d){return Db(this.value,d)},a.prototype.toHTML=function(d){d=this._toString(d);switch(Wb(this.value)){case "number":case "BigNumber":case "Fraction":return''+d+"";case "string":return''+d+"";case "boolean":return''+d+"";case "null":return''+ +d+"";case "undefined":return''+d+"";default:return''+d+""}},a.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},a.fromJSON=function(d){return new a(d.value)},a.prototype._toTex=function(d){d=this._toString(d);switch(Wb(this.value)){case "string":return"\\mathtt{"+xa(d)+"}";case "number":case "BigNumber":if(!isFinite(this.value))return 0>this.value.valueOf()?"-\\infty":"\\infty";var c=d.toLowerCase().indexOf("e"); +return-1!==c?d.substring(0,c)+"\\cdot10^{"+d.substring(c+1)+"}":d;case "Fraction":return this.value.toLatex();default:return d}},a},{isClass:!0,isNode:!0}),Ui=B("ObjectNode",["Node"],b=>{function a(d){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=d||{},d&&("object"!=typeof d||!Object.keys(d).every(function(c){return Mb(d[c])})))throw new TypeError("Object containing Nodes expected");}({Node:b}=b);return a.prototype=new b,a.prototype.type= +"ObjectNode",a.prototype.isObjectNode=!0,a.prototype._compile=function(d,c){var f={},h;for(h in this.properties)if(Pa(this.properties,h)){var l=Lc(h);l=JSON.parse(l);if(!db(this.properties,l))throw Error('No access to property "'+l+'"');f[l]=this.properties[h]._compile(d,c)}return function(p,k,n){var g={},e;for(e in f)Pa(f,e)&&(g[e]=f[e](p,k,n));return g}},a.prototype.forEach=function(d){for(var c in this.properties)Pa(this.properties,c)&&d(this.properties[c],"properties["+Lc(c)+"]",this)},a.prototype.map= +function(d){var c={},f;for(f in this.properties)Pa(this.properties,f)&&(c[f]=this._ifNode(d(this.properties[f],"properties["+Lc(f)+"]",this)));return new a(c)},a.prototype.clone=function(){var d={},c;for(c in this.properties)Pa(this.properties,c)&&(d[c]=this.properties[c]);return new a(d)},a.prototype._toString=function(d){var c=[],f;for(f in this.properties)Pa(this.properties,f)&&c.push(Lc(f)+": "+this.properties[f].toString(d));return"{"+c.join(", ")+"}"},a.prototype.toJSON=function(){return{mathjs:"ObjectNode", +properties:this.properties}},a.fromJSON=function(d){return new a(d.properties)},a.prototype.toHTML=function(d){var c=[],f;for(f in this.properties)Pa(this.properties,f)&&c.push(''+Dc(f)+':'+this.properties[f].toHTML(d));return'{'+c.join(',')+ +'}'},a.prototype._toTex=function(d){var c=[],f;for(f in this.properties)Pa(this.properties,f)&&c.push("\\mathbf{"+f+":} & "+this.properties[f].toTex(d)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(c.join("\n"),"\\end{array}\\right\\}")},a},{isClass:!0,isNode:!0}),Vi=B("ParenthesisNode",["Node"],b=>{function a(d){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Mb(d))throw new TypeError('Node expected for parameter "content"'); +this.content=d}({Node:b}=b);return a.prototype=new b,a.prototype.type="ParenthesisNode",a.prototype.isParenthesisNode=!0,a.prototype._compile=function(d,c){return this.content._compile(d,c)},a.prototype.getContent=function(){return this.content.getContent()},a.prototype.forEach=function(d){d(this.content,"content",this)},a.prototype.map=function(d){return new a(d(this.content,"content",this))},a.prototype.clone=function(){return new a(this.content)},a.prototype._toString=function(d){return!d||d&& +!d.parenthesis||d&&"keep"===d.parenthesis?"("+this.content.toString(d)+")":this.content.toString(d)},a.prototype.toJSON=function(){return{mathjs:"ParenthesisNode",content:this.content}},a.fromJSON=function(d){return new a(d.content)},a.prototype.toHTML=function(d){return!d||d&&!d.parenthesis||d&&"keep"===d.parenthesis?'('+this.content.toHTML(d)+')':this.content.toHTML(d)},a.prototype._toTex= +function(d){return!d||d&&!d.parenthesis||d&&"keep"===d.parenthesis?"\\left(".concat(this.content.toTex(d),"\\right)"):this.content.toTex(d)},a},{isClass:!0,isNode:!0}),id=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{associativity:"left",associativeWith:[]}},{"OperatorNode:and":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{associativity:"left", +associativeWith:[]}},{"OperatorNode:bitXor":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{associativity:"left",associativeWith:[]},"OperatorNode:unequal":{associativity:"left",associativeWith:[]},"OperatorNode:smaller":{associativity:"left",associativeWith:[]},"OperatorNode:larger":{associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{associativity:"left", +associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{associativity:"left",associativeWith:[]}},{"OperatorNode:to":{associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{associativity:"left", +associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{associativity:"left", +associativeWith:[]},"OperatorNode:mod":{associativity:"left",associativeWith:[]}},{"OperatorNode:unaryPlus":{associativity:"right"},"OperatorNode:unaryMinus":{associativity:"right"},"OperatorNode:bitNot":{associativity:"right"},"OperatorNode:not":{associativity:"right"}},{"OperatorNode:pow":{associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{associativity:"left"}},{"OperatorNode:transpose":{associativity:"left"}}], +Wi=B("RelationalNode",["Node"],b=>{function a(d,c){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(d))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(c))throw new TypeError("Parameter params must be an array");if(d.length!==c.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=d;this.params=c}({Node:b}=b);return a.prototype= +new b,a.prototype.type="RelationalNode",a.prototype.isRelationalNode=!0,a.prototype._compile=function(d,c){var f=this,h=this.params.map(l=>l._compile(d,c));return function(l,p,k){for(var n,g=h[0](l,p,k),e=0;ed(c,"params["+f+"]",this),this)},a.prototype.map=function(d){return new a(this.conditionals.slice(),this.params.map((c,f)=>this._ifNode(d(c, +"params["+f+"]",this)),this))},a.prototype.clone=function(){return new a(this.conditionals,this.params)},a.prototype._toString=function(d){for(var c=d&&d.parenthesis?d.parenthesis:"keep",f=ra(this,c),h=this.params.map(function(n,g){g=ra(n,c);return"all"===c||null!==g&&g<=f?"("+n.toString(d)+")":n.toString(d)}),l={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},p=h[0],k=0;k('+n.toHTML(d)+')':n.toHTML(d)}),l={equal:"==",unequal:"!=", +smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},p=h[0],k=0;k'+Dc(l[this.conditionals[k]])+""+h[k+1];return p},a.prototype._toTex=function(d){for(var c=d&&d.parenthesis?d.parenthesis:"keep",f=ra(this,c),h=this.params.map(function(k,n){n=ra(k,c);return"all"===c||null!==n&&n<=f?"\\left("+k.toTex(d)+"\right)":k.toTex(d)}),l=h[0],p=0;p{function a(p){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");wd(p)?this.value=p.value:this.value=p}function d(p,k){var n;var g=a.prototype;var e=function(){var q=k();if("function"==typeof q)return c(q)};var m=!0;Object.defineProperty(g,p,{get:function(){return m&&(n=e(),m=!1),n},set:function(q){n=q;m=!1},configurable:!0,enumerable:!0})}function c(p){return function(){for(var k= +[this.value],n=0;np[e])};for(var n in p)k(n)}var g};var l={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return a.createProxy(h),f&&f("import",function(p,k,n){n||d(p,k)}),a},{isClass:!0}),Yi=B("reviver",["classes"],b=>{var {classes:a}=b;return function(d,c){return(d=a[c&&c.mathjs])&&"function"==typeof d.fromJSON?d.fromJSON(c):c}}),Zi=B("ConditionalNode",["Node"],b=>{function a(d,c,f){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator"); +if(!Mb(d))throw new TypeError("Parameter condition must be a Node");if(!Mb(c))throw new TypeError("Parameter trueExpr must be a Node");if(!Mb(f))throw new TypeError("Parameter falseExpr must be a Node");this.condition=d;this.trueExpr=c;this.falseExpr=f}({Node:b}=b);return a.prototype=new b,a.prototype.type="ConditionalNode",a.prototype.isConditionalNode=!0,a.prototype._compile=function(d,c){var f=this.condition._compile(d,c),h=this.trueExpr._compile(d,c),l=this.falseExpr._compile(d,c);return function(p, +k,n){return function(g){if("number"==typeof g||"boolean"==typeof g||"string"==typeof g)return!!g;if(g){if(pa(g))return!g.isZero();if(rb(g))return!(!g.re&&!g.im);if(Z(g))return!!g.value}if(null==g)return!1;throw new TypeError('Unsupported type of condition "'+Wb(g)+'"');}(f(p,k,n))?h(p,k,n):l(p,k,n)}},a.prototype.forEach=function(d){d(this.condition,"condition",this);d(this.trueExpr,"trueExpr",this);d(this.falseExpr,"falseExpr",this)},a.prototype.map=function(d){return new a(this._ifNode(d(this.condition, +"condition",this)),this._ifNode(d(this.trueExpr,"trueExpr",this)),this._ifNode(d(this.falseExpr,"falseExpr",this)))},a.prototype.clone=function(){return new a(this.condition,this.trueExpr,this.falseExpr)},a.prototype._toString=function(d){var c=d&&d.parenthesis?d.parenthesis:"keep",f=ra(this,c),h=this.condition.toString(d),l=ra(this.condition,c);("all"===c||"OperatorNode"===this.condition.type||null!==l&&l<=f)&&(h="("+h+")");l=this.trueExpr.toString(d);var p=ra(this.trueExpr,c);("all"===c||"OperatorNode"=== +this.trueExpr.type||null!==p&&p<=f)&&(l="("+l+")");d=this.falseExpr.toString(d);p=ra(this.falseExpr,c);return("all"===c||"OperatorNode"===this.falseExpr.type||null!==p&&p<=f)&&(d="("+d+")"),h+" ? "+l+" : "+d},a.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},a.fromJSON=function(d){return new a(d.condition,d.trueExpr,d.falseExpr)},a.prototype.toHTML=function(d){var c=d&&d.parenthesis?d.parenthesis:"keep",f=ra(this, +c),h=this.condition.toHTML(d),l=ra(this.condition,c);("all"===c||"OperatorNode"===this.condition.type||null!==l&&l<=f)&&(h='('+h+')');l=this.trueExpr.toHTML(d);var p=ra(this.trueExpr,c);("all"===c||"OperatorNode"===this.trueExpr.type||null!==p&&p<=f)&&(l='('+l+')'); +d=this.falseExpr.toHTML(d);p=ra(this.falseExpr,c);return("all"===c||"OperatorNode"===this.falseExpr.type||null!==p&&p<=f)&&(d='('+d+')'),h+'?'+l+':'+d},a.prototype._toTex=function(d){return"\\begin{cases} {"+this.trueExpr.toTex(d)+"}, &\\quad{\\text{if }\\;"+ +this.condition.toTex(d)+"}\\\\{"+this.falseExpr.toTex(d)+"}, &\\quad{\\text{otherwise}}\\end{cases}"},a},{isClass:!0,isNode:!0}),$i=B("OperatorNode",["Node"],b=>{function a(c,f,h,l){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof c)throw new TypeError('string expected for parameter "op"');if("string"!=typeof f)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(h)||!h.every(Mb))throw new TypeError('Array containing Nodes expected for parameter "args"'); +this.implicit=!0===l;this.op=c;this.fn=f;this.args=h||[]}function d(c,f,h,l,p){var k=ra(c,f),n=ub(c,f);if("all"===f||2('+l+')'), +"right"===h?''+Dc(this.op)+""+l:l+''+Dc(this.op)+"";if(2===l.length)return f=l[0].toHTML(c),l=l[1].toHTML(c),p[0]&&(f='('+f+')'),p[1]&&(l='('+l+')'), +this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===h?f+''+l:f+''+Dc(this.op)+""+l;f=l.map(function(k,n){return k=k.toHTML(c),p[n]&&(k='('+k+')'),k});return 2'):f.join(''+Dc(this.op)+""):''+Dc(this.fn)+'('+f.join(',')+ +')'},a.prototype._toTex=function(c){var f=c&&c.parenthesis?c.parenthesis:"keep",h=c&&c.implicit?c.implicit:"hide",l=this.args,p=d(this,f,h,l,!0),k=Pb[this.fn];if(k=void 0===k?this.op:k,1===l.length)return f=ub(this,f),h=l[0].toTex(c),p[0]&&(h="\\left(".concat(h,"\\right)")),"right"===f?k+h:h+k;if(2===l.length){var n=l[0],g=n.toTex(c);p[0]&&(g="\\left(".concat(g,"\\right)"));var e=l[1].toTex(c);switch(p[1]&&(e="\\left(".concat(e,"\\right)")), +l="keep"===f?n.getIdentifier():n.getContent().getIdentifier(),this.getIdentifier()){case "OperatorNode:divide":return k+"{"+g+"}{"+e+"}";case "OperatorNode:pow":switch(g="{"+g+"}",e="{"+e+"}",l){case "ConditionalNode":case "OperatorNode:divide":g="\\left(".concat(g,"\\right)")}break;case "OperatorNode:multiply":if(this.implicit&&"hide"===h)return g+"~"+e}return g+k+e}return 2{function a(c,f,h){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Mb(c))throw new TypeError("Node expected"); +if(!Mb(f))throw new TypeError("Node expected");if(h&&!Mb(h))throw new TypeError("Node expected");if(3('+l+')'),f=l,this.step)l=this.step.toHTML(c),h.step&&(l='('+l+')'), +f+=':'+l;c=this.end.toHTML(c);return h.end&&(c='('+c+')'),f+':'+c},a.prototype._toTex=function(c){var f=d(this,c&&c.parenthesis?c.parenthesis:"keep"),h=this.start.toTex(c);if(f.start&&(h="\\left(".concat(h,"\\right)")),this.step){var l=this.step.toTex(c);f.step&&(l="\\left(".concat(l, +"\\right)"));h+=":"+l}c=this.end.toTex(c);return f.end&&(c="\\left(".concat(c,"\\right)")),h+":"+c},a},{isClass:!0,isNode:!0}),bj=B("FunctionAssignmentNode",["typed","Node"],b=>{function a(h,l,p){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof h)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(l))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!Mb(p))throw new TypeError('Node expected for parameter "expr"'); +if(Ng.has(h))throw Error('Illegal function name, "'+h+'" is a reserved keyword');this.name=h;this.params=l.map(function(k){return k&&k.name||k});this.types=l.map(function(k){return k&&k.type||"any"});this.expr=p}function d(h,l){var p=ra(h,l);h=ra(h.expr,l);return"all"===l||null!==h&&h<=p}var {typed:c,Node:f}=b;return a.prototype=new f,a.prototype.type="FunctionAssignmentNode",a.prototype.isFunctionAssignmentNode=!0,a.prototype._compile=function(h,l){var p=Object.create(l);J(this.params,function(q){p[q]= +!0});var k=this.expr._compile(h,p),n=this.name,g=this.params,e=Array.prototype.join.call(this.types,","),m=n+"("+Array.prototype.join.call(this.params,", ")+")";return function(q,r,u){var y={};y[e]=function(){for(var v=Object.create(r),t=0;t'+Dc(this.params[k])+"");h=this.expr.toHTML(h);return d(this,l)&&(h='('+h+')'),''+Dc(this.name)+'('+p.join(',')+ +')='+h},a.prototype._toTex=function(h){var l=h&&h.parenthesis?h.parenthesis:"keep";h=this.expr.toTex(h);return d(this,l)&&(h="\\left(".concat(h,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(ya).join(",")+"\\right):="+h},a},{isClass:!0,isNode:!0}),cj=B("chain",["typed","Chain"],b=>{var {typed:a,Chain:d}=b;return a("chain", +{"":function(){return new d},any:function(c){return new d(c)}})}),dj=B("AccessorNode",["subset","Node"],b=>{function a(l,p){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Mb(l))throw new TypeError('Node expected for parameter "object"');if(!nd(p))throw new TypeError('IndexNode expected for parameter "index"');this.object=l||null;this.index=p;Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty(): +"":this.object.name||""}.bind(this),set:function(){throw Error("Cannot assign a new name, name is read-only");}})}function d(l){return!(Gb(l)||vb(l)||Bb(l)||Kc(l)||Ld(l)||Qc(l)||kc(l))}var {subset:c,Node:f}=b,h=ad({subset:c});return a.prototype=new f,a.prototype.type="AccessorNode",a.prototype.isAccessorNode=!0,a.prototype._compile=function(l,p){var k=this.object._compile(l,p),n=this.index._compile(l,p);if(this.index.isObjectProperty()){var g=this.index.getObjectProperty();return function(e,m,q){return Aa(k(e, +m,q),g)}}return function(e,m,q){q=k(e,m,q);e=n(e,m,q);return h(q,e)}},a.prototype.forEach=function(l){l(this.object,"object",this);l(this.index,"index",this)},a.prototype.map=function(l){return new a(this._ifNode(l(this.object,"object",this)),this._ifNode(l(this.index,"index",this)))},a.prototype.clone=function(){return new a(this.object,this.index)},a.prototype._toString=function(l){var p=this.object.toString(l);return d(this.object)&&(p="("+p+")"),p+this.index.toString(l)},a.prototype.toHTML=function(l){var p= +this.object.toHTML(l);return d(this.object)&&(p='('+p+')'),p+this.index.toHTML(l)},a.prototype._toTex=function(l){var p=this.object.toTex(l);return d(this.object)&&(p="\\left(' + object + '\\right)"),p+this.index.toTex(l)},a.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},a.fromJSON=function(l){return new a(l.object,l.index)},a},{isClass:!0, +isNode:!0}),ej=B("IndexNode",["Range","Node","size"],b=>{function a(l,p){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(this.dimensions=l,this.dotNotation=p||!1,!Array.isArray(l)||!l.every(Mb))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw Error("dotNotation only applicable for object properties");}function d(l,p,k){return new c(pa(l)?l.toNumber():l,pa(p)?p.toNumber(): +p,pa(k)?k.toNumber():k)}var {Range:c,Node:f,size:h}=b;return a.prototype=new f,a.prototype.type="IndexNode",a.prototype.isIndexNode=!0,a.prototype._compile=function(l,p){var k=A(this.dimensions,function(g,e){if(vd(g)){if(g.needsEnd()){var m=Object.create(p);m.end=!0;var q=g.start._compile(l,m),r=g.end._compile(l,m),u=g.step?g.step._compile(l,m):function(){return 1};return function(I,F,L){var O=h(L).valueOf();F=Object.create(F);return F.end=O[e],d(q(I,F,L),r(I,F,L),u(I,F,L))}}var y=g.start._compile(l, +p),v=g.end._compile(l,p),t=g.step?g.step._compile(l,p):function(){return 1};return function(I,F,L){return d(y(I,F,L),v(I,F,L),t(I,F,L))}}if(kc(g)&&"end"===g.name){m=Object.create(p);m.end=!0;var w=g._compile(l,m);return function(I,F,L){var O=h(L).valueOf();F=Object.create(F);return F.end=O[e],w(I,F,L)}}var z=g._compile(l,p);return function(I,F,L){return z(I,F,L)}}),n=Aa(l,"index");return function(g,e,m){var q=A(k,function(r){return r(g,e,m)});return n(...q)}},a.prototype.forEach=function(l){for(var p= +0;p.'+Dc(this.getObjectProperty())+"":'['+l.join(',')+']'},a.prototype._toTex=function(l){var p=this.dimensions.map(function(k){return k.toTex(l)});return this.dotNotation?"."+this.getObjectProperty():"_{"+p.join(",")+"}"},a},{isClass:!0, +isNode:!0}),fj=B("AssignmentNode",["subset","?matrix","Node"],b=>{function a(k,n,g){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=k,this.index=g?n:null,this.value=g||n,!kc(k)&&!Gb(k))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(kc(k)&&"end"===k.name)throw Error('Cannot assign to symbol "end"');if(this.index&&!nd(this.index))throw new TypeError('IndexNode expected as "index"');if(!Mb(this.value))throw new TypeError('Node expected as "value"'); +Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw Error("Cannot assign a new name, name is read-only");}})}function d(k,n){n||(n="keep");var g=ra(k,n);k=ra(k.value,n);return"all"===n||null!==k&&k<=g}var {subset:c,matrix:f,Node:h}=b,l=ad({subset:c}),p=function(k){var {subset:n,matrix:g}=k;return function(e,m,q){try{if(Array.isArray(e))return g(e).subset(m,q).valueOf(); +if(e&&"function"==typeof e.subset)return e.subset(m,q);if("string"==typeof e)return n(e,m,q);if("object"==typeof e){if(!m.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return va(e,m.getObjectProperty(),q),e}throw new TypeError("Cannot apply index: unsupported type of object");}catch(r){throw hc(r);}}}({subset:c,matrix:f});return a.prototype=new h,a.prototype.type="AssignmentNode",a.prototype.isAssignmentNode=!0,a.prototype._compile=function(k,n){var g=this.object._compile(k, +n),e=this.index?this.index._compile(k,n):null,m=this.value._compile(k,n),q=this.object.name;if(this.index){if(this.index.isObjectProperty()){var r=this.index.getObjectProperty();return function(t,w,z){var I=g(t,w,z);t=m(t,w,z);return va(I,r,t),t}}if(kc(this.object))return function(t,w,z){var I=g(t,w,z);z=m(t,w,z);w=e(t,w,I);return t.set(q,p(I,w,z)),z};var u=this.object.object._compile(k,n);if(this.object.index.isObjectProperty()){var y=this.object.index.getObjectProperty();return function(t,w,z){var I= +u(t,w,z),F=Aa(I,y),L=e(t,w,F);t=m(t,w,z);return va(I,y,p(F,L,t)),t}}var v=this.object.index._compile(k,n);return function(t,w,z){var I=u(t,w,z),F=v(t,w,I),L=l(I,F),O=e(t,w,L);t=m(t,w,z);return p(I,F,p(L,O,t)),t}}if(!kc(this.object))throw new TypeError("SymbolNode expected as object");return function(t,w,z){w=m(t,w,z);return t.set(q,w),w}},a.prototype.forEach=function(k){k(this.object,"object",this);this.index&&k(this.index,"index",this);k(this.value,"value",this)},a.prototype.map=function(k){return new a(this._ifNode(k(this.object, +"object",this)),this.index?this._ifNode(k(this.index,"index",this)):null,this._ifNode(k(this.value,"value",this)))},a.prototype.clone=function(){return new a(this.object,this.index,this.value)},a.prototype._toString=function(k){var n=this.object.toString(k),g=this.index?this.index.toString(k):"",e=this.value.toString(k);return d(this,k&&k.parenthesis)&&(e="("+e+")"),n+g+" = "+e},a.prototype.toJSON=function(){return{mathjs:"AssignmentNode",object:this.object,index:this.index,value:this.value}},a.fromJSON= +function(k){return new a(k.object,k.index,k.value)},a.prototype.toHTML=function(k){var n=this.object.toHTML(k),g=this.index?this.index.toHTML(k):"",e=this.value.toHTML(k);return d(this,k&&k.parenthesis)&&(e='('+e+')'),n+g+'='+e},a.prototype._toTex=function(k){var n= +this.object.toTex(k),g=this.index?this.index.toTex(k):"",e=this.value.toTex(k);return d(this,k&&k.parenthesis)&&(e="\\left(".concat(e,"\\right)")),n+g+":="+e},a},{isClass:!0,isNode:!0}),gj=B("SymbolNode",["math","?Unit","Node"],b=>{function a(h){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof h)throw new TypeError('String expected for parameter "name"');this.name=h}var {math:d,Unit:c,Node:f}=b;return a.prototype=new f,a.prototype.type= +"SymbolNode",a.prototype.isSymbolNode=!0,a.prototype._compile=function(h,l){var p=this.name;if(!0===l[p])return function(n,g,e){return g[p]};if(p in h)return function(n,g,e){return n.has(p)?n.get(p):Aa(h,p)};var k=!!c&&c.isValuelessUnit(p);return function(n,g,e){return n.has(p)?n.get(p):k?new c(null,p):a.onUndefinedSymbol(p)}},a.prototype.forEach=function(h){},a.prototype.map=function(h){return this.clone()},a.onUndefinedSymbol=function(h){throw Error("Undefined symbol "+h);},a.prototype.clone=function(){return new a(this.name)}, +a.prototype._toString=function(h){return this.name},a.prototype.toHTML=function(h){h=Dc(this.name);return"true"===h||"false"===h?''+h+"":"i"===h?''+h+"":"Infinity"===h?''+h+"":"NaN"===h?''+h+"":"null"===h?''+h+"":"undefined"===h?''+ +h+"":''+h+""},a.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},a.fromJSON=function(h){return new a(h.name)},a.prototype._toTex=function(h){h=!1;void 0===d[this.name]&&c&&c.isValuelessUnit(this.name)&&(h=!0);h=ya(this.name,h);return"\\"===h[0]?h:" "+h},a},{isClass:!0,isNode:!0}),hj=B("FunctionNode",["math","Node","SymbolNode"],b=>{function a(k,n){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator"); +if("string"==typeof k&&(k=new h(k)),!Mb(k))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(n)||!n.every(Mb))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=k;this.args=n||[];Object.defineProperty(this,"name",{get:function(){return this.fn.name||""}.bind(this),set:function(){throw Error("Cannot assign a new name, name is read-only");}})}function d(k,n,g){for(var e,m="",q=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,r=0;null!==(e= +q.exec(k));)if(m+=k.substring(r,e.index),r=e.index,"$$"===e[0])m+="$",r++;else{r+=e[0].length;var u=n[e[1]];if(!u)throw new ReferenceError("Template: Property "+e[1]+" does not exist.");if(void 0===e[2])switch(typeof u){case "string":m+=u;break;case "object":if(Mb(u))m+=u.toTex(g);else{if(!Array.isArray(u))throw new TypeError("Template: "+e[1]+" has to be a Node, String or array of Nodes");m+=u.map(function(y,v){if(Mb(y))return y.toTex(g);throw new TypeError("Template: "+e[1]+"["+v+"] is not a Node."); +}).join(",")}break;default:throw new TypeError("Template: "+e[1]+" has to be a Node, String or array of Nodes");}else{if(!Mb(u[e[2]]&&u[e[2]]))throw new TypeError("Template: "+e[1]+"["+e[2]+"] is not a Node.");m+=u[e[2]].toTex(g)}}return m+k.slice(r)}var {math:c,Node:f,SymbolNode:h}=b;a.prototype=new f;a.prototype.type="FunctionNode";a.prototype.isFunctionNode=!0;a.prototype._compile=function(k,n){if(!(this instanceof a))throw new TypeError("No valid FunctionNode");var g=this.args.map(z=>z._compile(k, +n));if(!kc(this.fn)){if(Gb(this.fn)&&nd(this.fn.index)&&this.fn.index.isObjectProperty()){var e=this.fn.object._compile(k,n),m=this.fn.index.getObjectProperty(),q=this.args;return function(z,I,F){var L=e(z,I,F);if(function(R,ba){if(!fb(R,ba))throw Error('No access to method "'+ba+'"');}(L,m),L[m]&&L[m].rawArgs)return L[m](q,k,Ad(z,I),z);var O=g.map(R=>R(z,I,F));return L[m].apply(L,O)}}var r=this.fn._compile(k,n),u=this.args;return function(z,I,F){var L=r(z,I,F);if(L&&L.rawArgs)return L(u,k,Ad(z,I), +z);var O=g.map(R=>R(z,I,F));return L.apply(L,O)}}var y=this.fn.name,v=y in k?Aa(k,y):void 0,t=z=>z.has(y)?z.get(y):y in k?Aa(k,y):a.onUndefinedFunction(y);if("function"==typeof v&&!0===v.rawArgs){var w=this.args;return function(z,I,F){return t(z)(w,k,Ad(z,I),z)}}switch(g.length){case 0:return function(z,I,F){return t(z)()};case 1:return function(z,I,F){return t(z)((0,g[0])(z,I,F))};case 2:return function(z,I,F){var L=t(z),O=g[1];return L((0,g[0])(z,I,F),O(z,I,F))};default:return function(z,I,F){return t(z)(...g.map(L=> +L(z,I,F)))}}};a.prototype.forEach=function(k){k(this.fn,"fn",this);for(var n=0;n'+Dc(this.fn)+'('+n.join(',')+')'};var p=a.prototype.toTex;return a.prototype.toTex=function(k){var n;return k&&"object"==typeof k.handler&&Pa(k.handler,this.name)&&(n=k.handler[this.name](this,k)),void 0!==n?n:p.call(this,k)},a.prototype._toTex=function(k){var n, +g=this.args.map(function(m){return m.toTex(k)});switch(Og[this.name]&&(n=Og[this.name]),!c[this.name]||"function"!=typeof c[this.name].toTex&&"object"!=typeof c[this.name].toTex&&"string"!=typeof c[this.name].toTex||(n=c[this.name].toTex),typeof n){case "function":var e=n(this,k);break;case "string":e=d(n,this,k);break;case "object":switch(typeof n[g.length]){case "function":e=n[g.length](this,k);break;case "string":e=d(n[g.length],this,k)}}return void 0!==e?e:d("\\mathrm{${name}}\\left(${args}\\right)", +this,k)},a.prototype.getIdentifier=function(){return this.type+":"+this.name},a},{isClass:!0,isNode:!0}),ij=B("parse","typed numeric config AccessorNode ArrayNode AssignmentNode BlockNode ConditionalNode ConstantNode FunctionAssignmentNode FunctionNode IndexNode ObjectNode OperatorNode ParenthesisNode RangeNode RelationalNode SymbolNode".split(" "),b=>{function a(G){var ma=1":"larger","<=":"smallerEq", +">=":"largerEq"};Pa(Sa,G.token);)qa.push({name:G.token,fn:Sa[G.token]}),l(G),ma.push(u(G));return 1===ma.length?ma[0]:2===ma.length?new M(qa[0].name,qa[0].fn,ma):new ha(qa.map(Ya=>Ya.fn),ma)}function u(G){var ma;var qa=y(G);for(var Sa={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Pa(Sa,G.token);){var Ya=Sa[ma=G.token];l(G);qa=[qa,y(G)];qa=new M(ma,Ya,qa)}return qa}function y(G){var ma,qa;var Sa=v(G);for(var Ya={to:"to",in:"to"};Pa(Ya,G.token);){var Ja=Ya[ma=G.token];l(G);"in"=== +ma&&""===G.token?Sa=new M("*","multiply",[Sa,new ja("in")],!0):(qa=[Sa,v(G)],Sa=new M(ma,Ja,qa))}return Sa}function v(G){var ma,qa=[];if(ma=":"===G.token?new da(1):t(G),":"===G.token&&G.conditionalLevel!==G.nestingLevel){for(qa.push(ma);":"===G.token&&3>qa.length;)l(G),")"===G.token||"]"===G.token||","===G.token||""===G.token?qa.push(new ja("end")):qa.push(t(G));ma=3===qa.length?new U(qa[0],qa[2],qa[1]):new U(qa[0],qa[1])}return ma}function t(G){var ma;var qa=w(G);for(var Sa={"+":"add","-":"subtract"};Pa(Sa, +G.token);){var Ya=Sa[ma=G.token];l(G);qa=[qa,w(G)];qa=new M(ma,Ya,qa)}return qa}function w(G){var ma;var qa=z(G);for(var Sa={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"};Pa(Sa,G.token);){var Ya=Sa[ma=G.token];l(G);var Ja=z(G);qa=new M(ma,Ya,[qa,Ja])}return qa}function z(G){var ma,qa;for(qa=ma=I(G);3===G.tokenType||"in"===G.token&&Bb(ma)||!(2!==G.tokenType||Bb(qa)||xc(qa)&&"!"!==qa.op)||"("===G.token;)qa=I(G),ma=new M("*","multiply",[ma,qa],!0);return ma}function I(G){for(var ma= +F(G),qa=ma,Sa=[];"/"===G.token&&Bb(qa);){if(Sa.push(Ra({},G)),l(G),2!==G.tokenType){Ra(G,Sa.pop());break}if(Sa.push(Ra({},G)),l(G),3!==G.tokenType&&"("!==G.token){Sa.pop();Ra(G,Sa.pop());break}Ra(G,Sa.pop());Sa.pop();qa=F(G);ma=new M("/","divide",[ma,qa])}return ma}function F(G){var ma,qa,Sa,Ya={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Pa(Ya,G.token)?(Sa=Ya[G.token],ma=G.token,l(G),qa=[F(G)],new M(ma,Sa,qa)):function(Ja){var $a,Eb,dc,Ab;return $a=function(kb){var Wa;var tb= +function(bb){var ec=[];if(3===bb.tokenType&&Pa(bb.extraNodes,bb.token)){var nc=bb.extraNodes[bb.token];if(h(bb),"("===bb.token){ec=[];bb.nestingLevel++;if(h(bb),")"!==bb.token)for(ec.push(k(bb));","===bb.token;)h(bb),ec.push(k(bb));if(")"!==bb.token)throw ca(bb,"Parenthesis ) expected");bb.nestingLevel--;h(bb)}return new nc(ec)}return function(ab){var Ib;return 3===ab.tokenType||1===ab.tokenType&&ab.token in Xa?(Ib=ab.token,h(ab),L(ab,Pa(pb,Ib)?new da(pb[Ib]):-1!==sb.indexOf(Ib)?new da(Ga(Ib,"number")): +new ja(Ib))):function(ac){var Ub;return'"'===ac.token?(Ub=O(ac),L(ac,new da(Ub))):function(bc){var hb;return"'"===bc.token?(hb=R(bc),L(bc,new da(hb))):function(oa){if("["===oa.token){oa.nestingLevel++;if(h(oa),"]"!==oa.token){var wb=ba(oa);if(";"===oa.token){var Sb=1;for(wb=[wb];";"===oa.token;)h(oa),wb[Sb]=ba(oa),Sb++;if("]"!==oa.token)throw ca(oa,"End of matrix ] expected");oa.nestingLevel--;h(oa);var Jb=wb[0].items.length;for(var Fb=1;Fb":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},Xa={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},pb={true:!0,false:!1,null:null,undefined:void 0},sb=["NaN","Infinity"];return wa.isAlpha=function(G,ma,qa){return wa.isValidLatinOrGreek(G)|| +wa.isValidMathSymbol(G,qa)||wa.isValidMathSymbol(ma,G)},wa.isValidLatinOrGreek=function(G){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(G)},wa.isValidMathSymbol=function(G,ma){return/^[\uD835]$/.test(G)&&/^[\uDC00-\uDFFF]$/.test(ma)&&/^[^\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDFCC\uDFCD]$/.test(ma)},wa.isWhitespace=function(G,ma){return" "===G||"\t"===G||"\n"===G&& +0=G||"."===G},wa.isDigit=function(G){return"0"<=G&&"9">=G},wa.isHexDigit=function(G){return"0"<=G&&"9">=G||"a"<=G&&"f">=G||"A"<=G&&"F">=G},wa}),jj=B("evaluate",["typed","parse"],b=>{var {typed:a,parse:d}=b;return a("evaluate",{string:function(c){var f=new Map;return d(c).compile().evaluate(f)},"string, Map | Object":function(c,f){return d(c).compile().evaluate(f)},"Array | Matrix":function(c){var f= +new Map;return Na(c,function(h){return d(h).compile().evaluate(f)})},"Array | Matrix, Map | Object":function(c,f){return Na(c,function(h){return d(h).compile().evaluate(f)})}})}),kj=B("Help",["parse"],b=>{function a(c){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!c)throw Error('Argument "doc" missing');this.doc=c}var {parse:d}=b;return a.prototype.type="Help",a.prototype.isHelp=!0,a.prototype.toString=function(){var c=this.doc||{},f="\n";if(c.name&& +(f+="Name: "+c.name+"\n\n"),c.category&&(f+="Category: "+c.category+"\n\n"),c.description&&(f+="Description:\n "+c.description+"\n\n"),c.syntax&&(f+="Syntax:\n "+c.syntax.join("\n ")+"\n\n"),c.examples){f+="Examples:\n";for(var h={},l=0;l"mathjs"!==h).forEach(h=>{f[h]=c[h]}),new a(f)},a.prototype.valueOf=a.prototype.toString,a},{isClass:!0}),lj=B("Parser",["parse"],b=>{function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:new Map,writable:!1})}var {parse:d}=b;return a.prototype.type="Parser", +a.prototype.isParser=!0,a.prototype.evaluate=function(c){return d(c).compile().evaluate(this.scope)},a.prototype.get=function(c){if(this.scope.has(c))return this.scope.get(c)},a.prototype.getAll=function(){var c=this.scope;if(c instanceof We)c=c.wrappedObject;else{var f={},h;for(h of c.keys())va(f,h,c.get(h));c=f}return c},a.prototype.getAllAsMap=function(){return this.scope},a.prototype.set=function(c,f){return this.scope.set(c,f),f},a.prototype.remove=function(c){this.scope.delete(c)},a.prototype.clear= +function(){this.scope.clear()},a},{isClass:!0}),Pg={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"]},Qg={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"]},mj= +{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".split(" ")},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])'.split(";"), +seealso:"bignumber complex index matrix number string unit".split(" ")},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".split(" ")},createUnit:{name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.", +examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]},fraction:{name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(num,den)"],description:"Create a fraction from a number or from a numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)"],seealso:"bignumber boolean complex index matrix string unit".split(" ")},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, ...]".split(";"),description:"Create an index to get or replace a subset of a matrix",examples:"[]{[1, 2, 3]{A = [1, 2, 3; 4, 5, 6]{A[1, :]{A[1, 2] = 50{A[0:2, 0:2] = ones(2, 2)".split("{"),seealso:"bignumber boolean complex matrix, number range string unit".split(" ")},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")'.split("{"),seealso:"bignumber boolean complex index number string unit sparse".split(" ")},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")'.split(";"), +seealso:"bignumber boolean complex fraction index matrix string unit".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},e:Qg,E:Qg,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:Pg,PI:Pg,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})'.split(";"),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".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},simplify:{name:"simplify", +category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["derivative","parse","evaluate"]},rationalize:{name:"rationalize",category:"Algebra",syntax:["rationalize(expr)","rationalize(expr, scope)","rationalize(expr, scope, detailed)"],description:"Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.", +examples:['rationalize("2x/y - y/(x+1)")','rationalize("2x/y - y/(x+1)", true)'],seealso:["simplify"]},slu:{name:"slu",category:"Algebra",syntax:["slu(A, order, threshold)"],description:"Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",examples:["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],seealso:"lusolve lsolve usolve matrix sparse lup qr".split(" ")}, +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".split(" ")},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".split(" ")},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)".split(";"),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".split(";"),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".split(";"),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)".split(";"),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")'.split(";")}, +nthRoot:{name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["nthRoots","pow","sqrt"]},nthRoots:{name:"nthRoots",category:"Arithmetic",syntax:["nthRoots(A)","nthRoots(A, root)"],description:'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.', +examples:["nthRoots(1)","nthRoots(1, 3)"],seealso:["sqrt","pow","nthRoot"]},pow:{name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3","2*2*2","1 + e ^ (pi * i)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},round:{name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.", +examples:"round(3.2);round(3.8);round(-4.2);round(-4.8);round(pi, 3);round(123.45678, 2)".split(";"),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".split(" ")},sqrtm:{name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},square:{name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.", +examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},subtract:{name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},unaryMinus:{name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add", +"subtract","unaryPlus"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)", +"gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},bitAnd:{name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:"bitNot bitOr bitXor leftShift rightArithShift rightLogShift".split(" ")}, +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".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},bellNumbers:{name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.", +examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},catalan:{name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},composition:{name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.", +examples:["composition(5, 3)"],seealso:["combinations"]},stirlingS2:{name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},config:{name:"config", +category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},import:{name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)", +"typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number, number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},arg:{name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},conj:{name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.", +examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},re:{name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},im:{name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},evaluate:{name:"evaluate", +category:"Expression",syntax:["evaluate(expression)","evaluate([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(" + 4 + ")")'],seealso:[]},help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},distance:{name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])", +"distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},intersect:{name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},and:{name:"and", +category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},not:{name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},or:{name:"or",category:"Logical",syntax:["x or y","or(x, y)"], +description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},xor:{name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},concat:{name:"concat",category:"Matrix", +syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:"det diag identity inv ones range size squeeze subset trace transpose zeros".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},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".split(";"), +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)".split(";"),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".split(" ")}, +filter:{name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},flatten:{name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size", +"squeeze"]},forEach:{name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["forEach([1, 2, 3], function(val) { console.log(val) })"],seealso:["map","sort","filter"]},inv:{name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:"concat det diag identity ones range size squeeze subset trace transpose zeros".split(" ")}, +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, ...])".split(";"),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".split(" ")},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]'.split("{"), +seealso:"concat det diag identity inv ones size squeeze subset trace transpose zeros".split(" ")},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".split(" ")}, +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".split(" ")},subset:{name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of a matrix or string. Indexes are one-based. Both the ranges lower-bound and upper-bound are included.",examples:"d = [1, 2; 3, 4]{e = []{e[1, 1:2] = [5, 6]{e[2, :] = [7, 8]{f = d * e{f[2, 1]{f[:, 1]".split("{"), +seealso:"concat det diag identity inv ones range size squeeze trace transpose zeros".split(" ")},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".split(" ")},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".split(" ")},zeros:{name:"zeros",category:"Matrix",syntax:"zeros(m);zeros(m, n);zeros(m, n, p, ...);zeros([m]);zeros([m, n]);zeros([m, n, p, ...])".split(";"),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".split(" ")}, +combinations:{name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},combinationsWithRep:{name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"], +seealso:["combinations","permutations","factorial"]},factorial:{name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},gamma:{name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.", +examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},kldivergence:{name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},multinomial:{name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.", +examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},permutations:{name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},pickRandom:{name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)", +"pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:"pickRandom(0:10);pickRandom([1, 3, 1, 6]);pickRandom([1, 3, 1, 6], 2);pickRandom([1, 3, 1, 6], [2, 3, 2, 1]);pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1]);pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)".split(";"),seealso:["random","randomInt"]},random:{name:"random",category:"Probability",syntax:"random();random(max);random(min, max);random(size);random(size, max);random(size, min, max)".split(";"), +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".split(" ")},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})'.split(";"),seealso:"equal unequal smaller smallerEq largerEq compare compareText".split(" ")},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"])'.split(";"),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".split(" ")},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".split(";"),seealso:"unequal smaller larger smallerEq largerEq compare deepEqual equalText".split(" ")},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".split(";"),seealso:"equal unequal smaller smallerEq largerEq compare".split(" ")},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".split(";"),seealso:"equal unequal larger smallerEq largerEq compare".split(" ")},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".split(" ")},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".split(";"),seealso:"equal smaller larger smallerEq largerEq compare deepEqual".split(" ")}, +setCartesian:{name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},setDifference:{name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.", +examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},setDistinct:{name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},setIntersect:{name:"setIntersect",category:"Set", +syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},setIsSubset:{name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.", +examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},setMultiplicity:{name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]}, +setPowerset:{name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},setSize:{name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.', +examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},setSymDifference:{name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion", +"setIntersect","setDifference"]},setUnion:{name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},erf:{name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x", +examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},mad:{name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],description:"Compute the maximum value of a list of values.", +examples:"max(2, 3, 4, 1){max([2, 3, 4, 1]){max([2, 5; 4, 3]){max([2, 5; 4, 3], 1){max([2, 5; 4, 3], 2){max(2.7, 7.1, -4.5, 2.0, 4.1){min(2.7, 7.1, -4.5, 2.0, 4.1)".split("{"),seealso:"mean median min prod std sum variance".split(" ")},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])".split("{"), +seealso:"max median min prod std sum variance".split(" ")},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".split(" ")},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)".split("{"),seealso:"max mean median prod std sum variance".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},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])'.split(";"),seealso:"isInteger isZero isNegative isPositive isNaN hasNumericValue".split(" ")},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])'.split(";"),seealso:"isInteger isZero isNegative isPositive isNaN isNumeric".split(" ")},isPositive:{name:"isPositive",category:"Utils",syntax:["isPositive(x)"], +description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isPrime:{name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isZero:{name:"isZero", +category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},typeOf:{name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},numeric:{name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.", +examples:'numeric("4");numeric("4", "number");numeric("4", "BigNumber");numeric("4", "Fraction);numeric(4, "Fraction");numeric(fraction(2, 5), "number)'.split(";"),seealso:["number","fraction","bignumber","string","format"]}},nj=B("help",["typed","mathWithTransform","Help"],b=>{var {typed:a,mathWithTransform:d,Help:c}=b;return a("help",{any:function(f){var h,l=f;if("string"!=typeof f)for(h in d)if(Pa(d,h)&&f===d[h]){l=h;break}f=Aa(mj,l);if(!f)throw Error('No documentation found on "'+("function"== +typeof l?l.name:l)+'"');return new c(f)}})}),oj=B("compile",["typed","parse"],b=>{var {typed:a,parse:d}=b;return a("compile",{string:function(c){return d(c).compile()},"Array | Matrix":function(c){return Na(c,function(f){return d(f).compile()})}})}),Rg=B("simplifyUtil",["FunctionNode","OperatorNode","SymbolNode"],b=>{function a(n,g){if(!xc(n))return!1;n=n.fn.toString();return g&&Pa(g,n)&&Pa(g[n],"associative")?g[n].associative:k[n]||!1}function d(n){var g,e=[];return a(n)?(g=n.op,function r(q){for(var u= +0;u{var {equal:a,isZero:d,add:c,subtract:f,multiply:h,divide:l,pow:p,ConstantNode:k,OperatorNode:n,FunctionNode:g,ParenthesisNode:e}=b,m=new k(0),q=new k(1);return function y(u){if(xc(u)&&u.isUnary()){var v=y(u.args[0]);if("+"===u.op)return v;if("-"===u.op){if(xc(v)){if(v.isUnary()&&"-"===v.op)return v.args[0]; +if(v.isBinary()&&"subtract"===v.fn)return new n("-","subtract",[v.args[1],v.args[0]])}return new n(u.op,u.fn,[v])}}else if(xc(u)&&u.isBinary()){v=y(u.args[0]);var t=y(u.args[1]);if("+"===u.op){if(Bb(v)){if(d(v.value))return t;if(Bb(t))return new k(c(v.value,t.value))}return Bb(t)&&d(t.value)?v:xc(t)&&t.isUnary()&&"-"===t.op?new n("-","subtract",[v,t.args[0]]):new n(u.op,u.fn,t?[v,t]:[v])}if("-"===u.op){if(Bb(v)&&t){if(Bb(t))return new k(f(v.value,t.value));if(d(v.value))return new n("-","unaryMinus", +[t])}if("subtract"===u.fn)return Bb(t)&&d(t.value)?v:xc(t)&&t.isUnary()&&"-"===t.op?y(new n("+","add",[v,t.args[0]])):new n(u.op,u.fn,[v,t])}else{if("*"===u.op){if(Bb(v)){if(d(v.value))return m;if(a(v.value,1))return t;if(Bb(t))return new k(h(v.value,t.value))}if(Bb(t)){if(d(t.value))return m;if(a(t.value,1))return v;if(xc(v)&&v.isBinary()&&v.op===u.op){var w=v.args[0];if(Bb(w))return t=new k(h(w.value,t.value)),new n(u.op,u.fn,[t,v.args[1]],u.implicit)}return new n(u.op,u.fn,[t,v],u.implicit)}return new n(u.op, +u.fn,[v,t],u.implicit)}if("/"===u.op){if(Bb(v)){if(d(v.value))return m;if(Bb(t)&&(a(t.value,1)||a(t.value,2)||a(t.value,4)))return new k(l(v.value,t.value))}return new n(u.op,u.fn,[v,t])}if("^"===u.op){if(Bb(t)){if(d(t.value))return q;if(a(t.value,1))return v;if(Bb(v))return new k(p(v.value,t.value));if(xc(v)&&v.isBinary()&&"^"===v.op&&(w=v.args[1],Bb(w)))return new n(u.op,u.fn,[v.args[0],new k(h(w.value,t.value))])}return new n(u.op,u.fn,[v,t])}}}else{if(Qc(u))return u=y(u.content),Qc(u)||kc(u)|| +Bb(u)?u:new e(u);if(Kc(u))return v=u.args.map(y).map(function(z){return Qc(z)?z.content:z}),new g(y(u.fn),v)}return u}}),Tg=B("simplifyConstant","typed config mathWithTransform ?fraction ?bignumber ConstantNode OperatorNode FunctionNode SymbolNode".split(" "),b=>{function a(z,I,F){try{return w(p[z].apply(null,I),F)}catch(L){return I=I.map(function(O){return Ob(O)?O.valueOf():O}),w(p[z].apply(null,I),F)}}function d(z,I){if(I&&!1!==I.exactFractions&&isFinite(z)&&k){var F=k(z);I=I&&"number"==typeof I.fractionsLimit? +I.fractionsLimit:1/0;if(F.valueOf()===z&&F.n +f(ka,I));if(!F.some(Mb))try{return a(z.name,F,I)}catch(ka){}return F=F.map(function(ka){return Mb(ka)?ka:t(ka)}),new m(z.name,F)}case "OperatorNode":var L=z.fn.toString(),O=v(z);if(xc(z)&&z.isUnary())var R=Mb((F=[f(z.args[0],I)])[0])?O(F):a(L,F,I);else if(u(z))if(F=(F=y(z)).map(ka=>f(ka,I)),r(L)){z=[];for(var ba=[],ca=0;caf(ka,I)),O, +I);return R;case "ParenthesisNode":return f(z.content,I);default:throw Error("Unimplemented node type in simplifyConstant: ".concat(z.type));}}var {typed:h,config:l,mathWithTransform:p,fraction:k,bignumber:n,ConstantNode:g,OperatorNode:e,FunctionNode:m,SymbolNode:q}=b,{isCommutative:r,isAssociative:u,allChildren:y,createMakeNodeFunction:v}=Rg({FunctionNode:m,OperatorNode:e,SymbolNode:q}),t=h({Fraction:function(z){var I,F=z.s*z.n;return I=0>F?new e("-","unaryMinus",[new g(-F)]):new g(F),1===z.d?I: +new e("/","divide",[I,new g(z.d)])},number:function(z){return 0>z?new e("-","unaryMinus",[new g(-z)]):new g(z)},BigNumber:function(z){return 0>z?new e("-","unaryMinus",[new g(-z)]):new g(z)},Complex:function(z){throw Error("Cannot convert Complex number to Node");}}),w=h({"string, Object":function(z,I){return"BigNumber"===l.number?(void 0===n&&hd(),n(z)):"Fraction"===l.number?(void 0===k&&gc(),k(z)):d(parseFloat(z),I)},"Fraction, Object":function(z,I){return z},"BigNumber, Object":function(z,I){return z}, +"number, Object":function(z,I){return d(z,I)},"Complex, Object":function(z,I){return 0!==z.im?z:d(z.re,I)}});return function(z,I){z=f(z,I);return Mb(z)?z:t(z)}}),pj=B("resolve",["parse","FunctionNode","OperatorNode","ParenthesisNode"],b=>{var {parse:a,FunctionNode:d,OperatorNode:c,ParenthesisNode:f}=b;return function k(l,p){if(!p)return l;if(Va(p)||(p=mb(p)),kc(l)){var n=p.get(l.name);if(Mb(n))return k(n,p);if("number"==typeof n)return a(String(n))}else{if(xc(l))return n=l.args.map(function(g){return k(g, +p)}),new c(l.op,l.fn,n,l.implicit);if(Qc(l))return new f(k(l.content,p));if(Kc(l))return n=l.args.map(function(g){return k(g,p)}),new d(l.name,n)}return l}}),qj=B("simplify","config typed parse add subtract multiply divide pow isZero equal ?fraction ?bignumber mathWithTransform ConstantNode FunctionNode OperatorNode ParenthesisNode SymbolNode".split(" "),b=>{function a(X){return X.transform(function(da,ua,Da){return Qc(da)?a(da.content):da})}function d(X,da){var ua={placeholders:{}};if(!X.placeholders&& +!da.placeholders)return ua;if(!X.placeholders)return da;if(!da.placeholders)return X;for(var Da in X.placeholders)if(Pa(X.placeholders,Da)&&(ua.placeholders[Da]=X.placeholders[Da],Pa(da.placeholders,Da)&&!h(X.placeholders[Da],da.placeholders[Da])))return null;for(var Ha in da.placeholders)Pa(da.placeholders,Ha)&&(ua.placeholders[Ha]=da.placeholders[Ha]);return ua}function c(X,da){var ua,Da=[];if(0===X.length||0===da.length)return Da;for(var Ha=0;Ha");if(2!==U.length)throw SyntaxError("Could not parse rule: "+M);M={l:U[0],r:U[1]};case "object":if(Q={l:a(k(M.l)),r:a(k(M.r))},M.context&&(Q.evaluate=M.context),M.evaluate&&(Q.evaluate=k(M.evaluate)),ca(Q.l))M=P(Q.l),U=new L("_p"+ob++),Q.expanded={},Q.expanded.l=M([Q.l.clone(),U]),ka(Q.expanded.l),Ea(Q.expanded.l), +Q.expanded.r=M([Q.r,U]);break;case "function":Q=M;break;default:throw TypeError("Unsupported type of rule: "+U);}Ha.push(Q)}da=Ha;X=R(X,ua);ua={};for(Ha=(X=a(X)).toString({parenthesis:"all"});!ua[Ha];){ua[Ha]=!0;for(Ha=ob=0;Ha{function a(O, +R,ba){var ca=O.type,ka=1ba&&(R[1]=0),R[1]+=da.cte*("+"===da.oper?1:-1),ba=Math.max(1,ba))}else{if("ConstantNode"!==Da)throw Error("Type "+Da+" is not allowed");na=parseFloat(na.value); +if(null===X)return void(R[0]=na);if("^"===X.op){if(1!==da.noFil)throw Error("Constant cannot be powered");if(!Za(na)||0>=na)throw Error("Non-integer exponent is not allowed");for(X=ba+1;Xba&&(R[na]=0),R[na]+=da.cte*("+"===da.oper?1:-1),void(ba=Math.max(na,ba))}da.cte=na;""===da.fire&&(R[0]+=da.cte*("+"===da.oper?1:-1))}}(O,null,{cte:1,oper:"+",fire:""});O=!0;for(var ka=ba=R.length-1;0<=ka;ka--)if(0!==R[ka]){var Ea=new v(O?R[ka]:Math.abs(R[ka])),Ga=0>R[ka]?"-":"+";if(0{var {typed:a,Parser:d}=b;return a("parser",{"":function(){return new d}})}),tj=B("derivative","typed config parse simplify equal isZero numeric ConstantNode FunctionNode OperatorNode ParenthesisNode SymbolNode".split(" "),b=>{function a(v,t){return new n(k(v,t||c.number))} +var {typed:d,config:c,parse:f,simplify:h,equal:l,isZero:p,numeric:k,ConstantNode:n,FunctionNode:g,OperatorNode:e,ParenthesisNode:m,SymbolNode:q}=b;b=d("derivative",{"Node, SymbolNode, Object":function(v,t,w){var z={};u(z,v,t.name);v=y(v,z);return w.simplify?h(v):v},"Node, SymbolNode":function(v,t){return this(v,t,{simplify:!0})},"string, SymbolNode":function(v,t){return this(f(v),t)},"string, SymbolNode, Object":function(v,t,w){return this(f(v),t,w)},"string, string":function(v,t){return this(f(v), +f(t))},"string, string, Object":function(v,t,w){return this(f(v),f(t),w)},"Node, string":function(v,t){return this(v,f(t))},"Node, string, Object":function(v,t,w){return this(v,f(t),w)}});b._simplify=!0;b.toTex=function(v){return r.apply(null,v.args)};var r=d("_derivTex",{"Node, SymbolNode":function(v,t){return Bb(v)&&"string"===Wb(v.value)?r(f(v.value).toString(),t.toString(),1):r(v.toString(),t.toString(),1)},"Node, ConstantNode":function(v,t){if("string"===Wb(t.value))return r(v,f(t.value));throw Error("The second parameter to 'derivative' is a non-string constant"); +},"Node, SymbolNode, ConstantNode":function(v,t,w){return r(v.toString(),t.name,w.value)},"string, string, number":function(v,t,w){return(1===w?"{d\\over d"+t+"}":"{d^{"+w+"}\\over d"+t+"^{"+w+"}}")+"\\left[".concat(v,"\\right]")}}),u=d("constTag",{"Object, ConstantNode, string":function(v,t){return v[t]=!0,!0},"Object, SymbolNode, string":function(v,t,w){return t.name!==w&&(v[t]=!0,!0)},"Object, ParenthesisNode, string":function(v,t,w){return u(v,t.content,w)},"Object, FunctionAssignmentNode, string":function(v, +t,w){return-1===t.params.indexOf(w)?(v[t]=!0,!0):u(v,t.expr,w)},"Object, FunctionNode | OperatorNode, string":function(v,t,w){if(0{var {typed:a,isInteger:d}=b;return a("apply",{"Array | Matrix, number | BigNumber, function":function(c, +f,h){if(!d(f))throw new TypeError("Integer number expected for dimension");var l=Array.isArray(c)?Ua(c):c.size();if(0>f||f>=l.length)throw new Gc(f,l.length);return Fa(c)?c.create(Ee(c.valueOf(),f,h)):Ee(c,f,h)}})}),uj=B("apply",["typed","isInteger"],b=>{var {typed:a,isInteger:d}=b,c=Ug({typed:a,isInteger:d});return a("apply",{"...any":function(f){var h=f[1];Qa(h)?f[1]=h-1:pa(h)&&(f[1]=h.minus(1));try{return c.apply(null,f)}catch(l){throw hc(l);}}})},{isTransformFunction:!0}),vj=B("filter",["typed"], +b=>{function a(c,f,h){var l,p;return c[0]&&(l=c[0].compile().evaluate(h)),c[1]&&(p=kc(c[1])||Cc(c[1])?c[1].compile().evaluate(h):Ye(c[1],f,h)),d(l,p)}({typed:b}=b);a.rawArgs=!0;var d=b("filter",{"Array, function":zf,"Matrix, function":function(c,f){return c.create(zf(c.toArray(),f))},"Array, RegExp":Y,"Matrix, RegExp":function(c,f){return c.create(Y(c.toArray(),f))}});return a},{isTransformFunction:!0}),wj=B("map",["typed"],b=>{function a(c,f,h){var l,p;return c[0]&&(l=c[0].compile().evaluate(h)), +c[1]&&(p=kc(c[1])||Cc(c[1])?c[1].compile().evaluate(h):Ye(c[1],f,h)),d(l,p)}({typed:b}=b);a.rawArgs=!0;var d=b("map",{"Array, function":function(c,f){return Af(c,f,c)},"Matrix, function":function(c,f){return c.create(Af(c.valueOf(),f,c))}});return a},{isTransformFunction:!0}),xj=B("forEach",["typed"],b=>{function a(c,f,h){var l,p;return c[0]&&(l=c[0].compile().evaluate(h)),c[1]&&(p=kc(c[1])||Cc(c[1])?c[1].compile().evaluate(h):Ye(c[1],f,h)),d(l,p)}({typed:b}=b);a.rawArgs=!0;var d=b("forEach",{"Array | Matrix, function":function(c, +f){var h=$d(f);!function n(p,k){Array.isArray(p)?J(p,function(g,e){n(g,k.concat(e+1))}):1===h?f(p):2===h?f(p,k):f(p,k,c)}(c.valueOf(),[])}});return a},{isTransformFunction:!0}),Vg=B("subset",["typed","matrix"],b=>{var {typed:a,matrix:d}=b;return a("subset",{"Array, Index":function(c,f){c=d(c).subset(f);return f.isScalar()?c:c.valueOf()},"Matrix, Index":function(c,f){return c.subset(f)},"Object, Index":wi,"string, Index":vi,"Array, Index, any":function(c,f,h){return d(nb(c)).subset(f,h,void 0).valueOf()}, +"Array, Index, any, any":function(c,f,h,l){return d(nb(c)).subset(f,h,l).valueOf()},"Matrix, Index, any":function(c,f,h){return c.clone().subset(f,h)},"Matrix, Index, any, any":function(c,f,h,l){return c.clone().subset(f,h,l)},"string, Index, string":Bf,"string, Index, string, string":Bf,"Object, Index, any":xi})}),yj=B("subset",["typed","matrix"],b=>{var {typed:a,matrix:d}=b,c=Vg({typed:a,matrix:d});return a("subset",{"...any":function(f){try{return c.apply(null,f)}catch(h){throw hc(h);}}})},{isTransformFunction:!0}), +zj=B("index",["Index"],b=>{var {Index:a}=b;return function(){for(var d=[],c=0,f=arguments.length;c{var {typed:a,matrix:d,isInteger:c}=b;return a("concat",{"...Array | Matrix | number | BigNumber":function(f){var h,l,p=f.length,k=-1,n=!1,g=[];for(h=0;hk||0l)throw new Gc(k,l+1);}else{e=nb(e).valueOf();var m=Ua(e);if(g[h]=e,l=k,k=m.length- +1,0{var {typed:a,matrix:d,isInteger:c}=b,f=Wg({typed:a,matrix:d,isInteger:c});return a("concat",{"...any":function(h){var l=h.length-1,p=h[l];Qa(p)?h[l]=p-1:pa(p)&&(h[l]=p.minus(1));try{return f.apply(null,h)}catch(k){throw hc(k);}}})},{isTransformFunction:!0}), +Xg=B("max",["typed","config","numeric","larger"],b=>{function a(p,k){try{return l(p,k)?p:k}catch(n){throw Tc(n,"max",k);}}function d(p){var k;if(Zb(p,function(n){try{isNaN(n)&&"number"==typeof n?k=NaN:(void 0===k||l(n,k))&&(k=n)}catch(g){throw Tc(g,"max",n);}}),void 0===k)throw Error("Cannot calculate max of an empty array");return"string"==typeof k&&(k=h(k,f.number)),k}var {typed:c,config:f,numeric:h,larger:l}=b;return c("max",{"Array | Matrix":d,"Array | Matrix, number | BigNumber":function(p,k){return Xb(p, +k.valueOf(),a)},"...":function(p){if(Rc(p))throw new TypeError("Scalar values expected in function max");return d(p)}})}),Bj=B("max",["typed","config","numeric","larger"],b=>{var {typed:a,config:d,numeric:c,larger:f}=b,h=Xg({typed:a,config:d,numeric:c,larger:f});return a("max",{"...any":function(l){l=Pd(l);try{return h.apply(null,l)}catch(p){throw hc(p);}}})},{isTransformFunction:!0}),Yg=B("min",["typed","config","numeric","smaller"],b=>{function a(p,k){try{return l(p,k)?p:k}catch(n){throw Tc(n,"min", +k);}}function d(p){var k;if(Zb(p,function(n){try{isNaN(n)&&"number"==typeof n?k=NaN:(void 0===k||l(n,k))&&(k=n)}catch(g){throw Tc(g,"min",n);}}),void 0===k)throw Error("Cannot calculate min of an empty array");return"string"==typeof k&&(k=h(k,f.number)),k}var {typed:c,config:f,numeric:h,smaller:l}=b;return c("min",{"Array | Matrix":d,"Array | Matrix, number | BigNumber":function(p,k){return Xb(p,k.valueOf(),a)},"...":function(p){if(Rc(p))throw new TypeError("Scalar values expected in function min"); +return d(p)}})}),Cj=B("min",["typed","config","numeric","smaller"],b=>{var {typed:a,config:d,numeric:c,smaller:f}=b,h=Yg({typed:a,config:d,numeric:c,smaller:f});return a("min",{"...any":function(l){l=Pd(l);try{return h.apply(null,l)}catch(p){throw hc(p);}}})},{isTransformFunction:!0}),Zg=B("sum",["typed","config","add","numeric"],b=>{function a(l){var p;return Zb(l,function(k){try{p=void 0===p?k:f(p,k)}catch(n){throw Tc(n,"sum",k);}}),void 0===p&&(p=h(0,c.number)),"string"==typeof p&&(p=h(p,c.number)), +p}var {typed:d,config:c,add:f,numeric:h}=b;return d("sum",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(l,p){try{return Xb(l,p,f)}catch(k){throw Tc(k,"sum");}},"...":function(l){if(Rc(l))throw new TypeError("Scalar values expected in function sum");return a(l)}})}),Dj=B("sum",["typed","config","add","numeric"],b=>{var {typed:a,config:d,add:c,numeric:f}=b,h=Zg({typed:a,config:d,add:c,numeric:f});return a("sum",{"...any":function(l){l=Pd(l);try{return h.apply(null,l)}catch(p){throw hc(p); +}}})},{isTransformFunction:!0}),$g=B("column",["typed","Index","matrix","range"],b=>{function a(l,p){if(2!==l.size().length)throw Error("Only two dimensional matrix is supported");Yb(p,l.size()[1]);var k=h(0,l.size()[0]);p=new c(k,p);return l.subset(p)}var {typed:d,Index:c,matrix:f,range:h}=b;return d("column",{"Matrix, number":a,"Array, number":function(l,p){return a(f(nb(l)),p).valueOf()}})}),Ej=B("column",["typed","Index","matrix","range"],b=>{var {typed:a,Index:d,matrix:c,range:f}=b,h=$g({typed:a, +Index:d,matrix:c,range:f});return a("column",{"...any":function(l){var p=l.length-1,k=l[p];Qa(k)&&(l[p]=k-1);try{return h.apply(null,l)}catch(n){throw hc(n);}}})},{isTransformFunction:!0}),ah=B("range","typed config ?matrix ?bignumber smaller smallerEq larger largerEq".split(" "),b=>{function a(u){return"Matrix"===k.matrix?n?n(u):me():u}function d(u,y){var v=function(t){t=t.split(":").map(function(w){return Number(w)});if(t.some(function(w){return isNaN(w)}))return null;switch(t.length){case 2:return{start:t[0], +end:t[1],step:1};case 3:return{start:t[0],end:t[2],step:t[1]};default:return null}}(u);if(!v)throw new SyntaxError('String "'+u+'" is no valid range');return"BigNumber"===k.number?(void 0===g&&hd(),a((y?l:h)(g(v.start),g(v.end),g(v.step)))):a((y?f:c)(v.start,v.end,v.step))}function c(u,y,v){var t=[];if(0v)for(;q(u,y);)t.push(u),u+=v;return t}function f(u,y,v){var t=[];if(0v)for(;r(u,y);)t.push(u),u+=v;return t}function h(u, +y,v){var t=g(0),w=[];if(v.gt(t))for(;e(u,y);)w.push(u),u=u.plus(v);else if(v.lt(t))for(;q(u,y);)w.push(u),u=u.plus(v);return w}function l(u,y,v){var t=g(0),w=[];if(v.gt(t))for(;m(u,y);)w.push(u),u=u.plus(v);else if(v.lt(t))for(;r(u,y);)w.push(u),u=u.plus(v);return w}var {typed:p,config:k,matrix:n,bignumber:g,smaller:e,smallerEq:m,larger:q,largerEq:r}=b;return p("range",{string:d,"string, boolean":d,"number, number":function(u,y){return a(c(u,y,1))},"number, number, number":function(u,y,v){return a(c(u, +y,v))},"number, number, boolean":function(u,y,v){return a(v?f(u,y,1):c(u,y,1))},"number, number, number, boolean":function(u,y,v,t){return a(t?f(u,y,v):c(u,y,v))},"BigNumber, BigNumber":function(u,y){return a(h(u,y,new (0,u.constructor)(1)))},"BigNumber, BigNumber, BigNumber":function(u,y,v){return a(h(u,y,v))},"BigNumber, BigNumber, boolean":function(u,y,v){var t=u.constructor;return a(v?l(u,y,new t(1)):h(u,y,new t(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(u,y,v,t){return a(t?l(u, +y,v):h(u,y,v))}})}),Fj=B("range","typed config ?matrix ?bignumber smaller smallerEq larger largerEq".split(" "),b=>{var {typed:a,config:d,matrix:c,bignumber:f,smaller:h,smallerEq:l,larger:p,largerEq:k}=b,n=ah({typed:a,config:d,matrix:c,bignumber:f,smaller:h,smallerEq:l,larger:p,largerEq:k});return a("range",{"...any":function(g){return"boolean"!=typeof g[g.length-1]&&g.push(!0),n.apply(null,g)}})},{isTransformFunction:!0}),bh=B("diff",["typed","matrix","subtract","number"],b=>{function a(k,n){if(Fa(k)&& +(k=k.toArray()),!Array.isArray(k))throw RangeError("Array/Matrix does not have that many dimensions");if(0{g.push(a(e,n-1))}),g}if(0===n)return d(k);throw RangeError("Cannot have negative dimension");}function d(k){var n=[],g=k.length;if(2>g)return k;for(var e=1;e{var {typed:a,matrix:d,subtract:c,number:f,bignumber:h}=b,l=bh({typed:a,matrix:d,subtract:c,number:f,bignumber:h});return a("diff",{"...any":function(p){p=Pd(p);try{return l.apply(null,p)}catch(k){throw hc(k);}}})},{isTransformFunction:!0}),ch=B("row",["typed","Index","matrix","range"],b=>{function a(l,p){if(2!==l.size().length)throw Error("Only two dimensional matrix is supported");Yb(p,l.size()[0]);var k=h(0,l.size()[1]); +p=new c(p,k);return l.subset(p)}var {typed:d,Index:c,matrix:f,range:h}=b;return d("row",{"Matrix, number":a,"Array, number":function(l,p){return a(f(nb(l)),p).valueOf()}})}),Hj=B("row",["typed","Index","matrix","range"],b=>{var {typed:a,Index:d,matrix:c,range:f}=b,h=ch({typed:a,Index:d,matrix:c,range:f});return a("row",{"...any":function(l){var p=l.length-1,k=l[p];Qa(k)&&(l[p]=k-1);try{return h.apply(null,l)}catch(n){throw hc(n);}}})},{isTransformFunction:!0}),dh=B("mean",["typed","add","divide"], +b=>{function a(h){var l,p=0;if(Zb(h,function(k){try{l=void 0===l?k:c(l,k),p++}catch(n){throw Tc(n,"mean",k);}}),0===p)throw Error("Cannot calculate the mean of an empty array");return f(l,p)}var {typed:d,add:c,divide:f}=b;return d("mean",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(h,l){try{var p=Xb(h,l,c),k=Array.isArray(h)?Ua(h):h.size();return f(p,k[l])}catch(n){throw Tc(n,"mean");}},"...":function(h){if(Rc(h))throw new TypeError("Scalar values expected in function mean"); +return a(h)}})}),Ij=B("mean",["typed","add","divide"],b=>{var {typed:a,add:d,divide:c}=b,f=dh({typed:a,add:d,divide:c});return a("mean",{"...any":function(h){h=Pd(h);try{return f.apply(null,h)}catch(l){throw hc(l);}}})},{isTransformFunction:!0}),eh=B("variance","typed add subtract multiply divide apply isNaN".split(" "),b=>{function a(g,e){var m,q=0;if(0===g.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Zb(g,function(u){try{m=void 0===m?u:f(m,u), +q++}catch(y){throw Tc(y,"variance",u);}}),0===q)throw Error("Cannot calculate variance of an empty array");var r=p(m,q);if(m=void 0,Zb(g,function(u){u=h(u,r);m=void 0===m?l(u,u):f(m,l(u,u))}),n(m))return m;switch(e){case "uncorrected":return p(m,q);case "biased":return p(m,q+1);case "unbiased":return g=pa(m)?m.mul(0):0,1===q?g:p(m,q-1);default:throw Error('Unknown normalization "'+e+'". Choose "unbiased" (default), "uncorrected", or "biased".');}}function d(g,e,m){try{if(0===g.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)"); +return k(g,e,q=>a(q,m))}catch(q){throw Tc(q,"variance");}}var {typed:c,add:f,subtract:h,multiply:l,divide:p,apply:k,isNaN:n}=b;return c("variance",{"Array | Matrix":function(g){return a(g,"unbiased")},"Array | Matrix, string":a,"Array | Matrix, number | BigNumber":function(g,e){return d(g,e,"unbiased")},"Array | Matrix, number | BigNumber, string":d,"...":function(g){return a(g,"unbiased")}})}),Jj=B("variance","typed add subtract multiply divide apply isNaN".split(" "),b=>{var {typed:a,add:d,subtract:c, +multiply:f,divide:h,apply:l,isNaN:p}=b,k=eh({typed:a,add:d,subtract:c,multiply:f,divide:h,apply:l,isNaN:p});return a("variance",{"...any":function(n){n=Pd(n);try{return k.apply(null,n)}catch(g){throw hc(g);}}})},{isTransformFunction:!0}),fh=B("std",["typed","sqrt","variance"],b=>{function a(h,l){if(0===h.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{return c(f.apply(null,arguments))}catch(p){throw p instanceof TypeError&&-1!==p.message.indexOf(" variance")? +new TypeError(p.message.replace(" variance"," std")):p;}}var {typed:d,sqrt:c,variance:f}=b;return d("std",{"Array | Matrix":a,"Array | Matrix, string":a,"Array | Matrix, number | BigNumber":a,"Array | Matrix, number | BigNumber, string":a,"...":function(h){return a(h)}})}),Kj=B("std",["typed","sqrt","variance"],b=>{var {typed:a,sqrt:d,variance:c}=b,f=fh({typed:a,sqrt:d,variance:c});return a("std",{"...any":function(h){h=Pd(h);try{return f.apply(null,h)}catch(l){throw hc(l);}}})},{isTransformFunction:!0}), +Lj=B("ResultSet",[],()=>{function b(a){if(!(this instanceof b))throw new SyntaxError("Constructor must be called with the new operator");this.entries=a||[]}return b.prototype.type="ResultSet",b.prototype.isResultSet=!0,b.prototype.valueOf=function(){return this.entries},b.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},b.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},b.fromJSON=function(a){return new b(a.entries)},b},{isClass:!0}),Sc=jb(977),Mj=B("Complex", +[],()=>(Sc.prototype.type="Complex",Sc.prototype.isComplex=!0,Sc.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Sc.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Sc.prototype.format=function(b){var a=this.im,d=this.re,c=$c(this.re,b),f=$c(this.im,b);b=Qa(b)?b:b?b.precision:null;null!==b&&(b=Math.pow(10,-b),Math.abs(d/a)a?-1===a?c+" - i":c+" - "+f.substring(1)+"i":1=== +a?c+" + i":c+" + "+f+"i"},Sc.fromPolar=function(b){switch(arguments.length){case 1:var a=arguments[0];if("object"==typeof a)return Sc(a);throw new TypeError("Input has to be an object with r and phi keys.");case 2:a=arguments[0];var d=arguments[1];if(Qa(a)){if(Z(d)&&d.hasBase("ANGLE")&&(d=d.toNumber("rad")),Qa(d))return new Sc({r:a,phi:d});throw new TypeError("Phi is not a number nor an angle unit.");}throw new TypeError("Radius r is not a number.");default:throw new SyntaxError("Wrong number of arguments in function fromPolar"); +}},Sc.prototype.valueOf=Sc.prototype.toString,Sc.fromJSON=function(b){return new Sc(b)},Sc.compare=function(b,a){return b.re>a.re?1:b.rea.im?1:b.im{function b(a,d,c){if(!(this instanceof b))throw new SyntaxError("Constructor must be called with the new operator");var f=null!=a,h=null!=d,l=null!=c;if(f)if(pa(a))a=a.toNumber();else if("number"!=typeof a)throw new TypeError("Parameter start must be a number");if(h)if(pa(d))d=d.toNumber(); +else if("number"!=typeof d)throw new TypeError("Parameter end must be a number");if(l)if(pa(c))c=c.toNumber();else if("number"!=typeof c)throw new TypeError("Parameter step must be a number");this.start=f?parseFloat(a):0;this.end=h?parseFloat(d):0;this.step=l?parseFloat(c):1}return b.prototype.type="Range",b.prototype.isRange=!0,b.parse=function(a){if("string"!=typeof a)return null;a=a.split(":").map(function(d){return parseFloat(d)});if(a.some(function(d){return isNaN(d)}))return null;switch(a.length){case 2:return new b(a[0], +a[1]);case 3:return new b(a[0],a[2],a[1]);default:return null}},b.prototype.clone=function(){return new b(this.start,this.end,this.step)},b.prototype.size=function(){var a=0,d=this.step,c=this.end-this.start;return pd(d)===pd(c)?a=Math.ceil(c/d):0===c&&(a=0),isNaN(a)&&(a=0),[a]},b.prototype.min=function(){var a=this.size()[0];return 0c)for(;d>f;)a(d,[h],this),d+=c,h++},b.prototype.map=function(a){var d=[];return this.forEach(function(c,f,h){d[f[0]]=a(c,f,h)}),d},b.prototype.toArray=function(){var a=[];return this.forEach(function(d,c){a[c[0]]=d}),a},b.prototype.valueOf=function(){return this.toArray()},b.prototype.format=function(a){var d=$c(this.start,a);return 1!==this.step&&(d+=":"+$c(this.step, +a)),d+":"+$c(this.end,a)},b.prototype.toString=function(){return this.format()},b.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},b.fromJSON=function(a){return new b(a.start,a.end,a.step)},b},{isClass:!0}),Oj=ne(function(b){return(new b(1)).exp()},{hasher:Fe}),Pj=ne(function(b){return(new b(1)).plus((new b(5)).sqrt()).div(2)},{hasher:Fe}),gf=ne(function(b){return b.acos(-1)},{hasher:Fe}),Qj=ne(function(b){return gf(b).times(2)},{hasher:Fe}),Rj=Math.PI, +Sj=2*Math.PI,Tj=Math.E,Uj=B("true",[],()=>!0),Vj=B("false",[],()=>!1),Wj=B("null",[],()=>null),Xj=Uc("Infinity",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?new d(1/0):1/0}),Yj=Uc("NaN",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?new d(NaN):NaN}),Zj=Uc("pi",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?gf(d):Rj}),ak=Uc("tau",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}= +b;return"BigNumber"===a.number?Qj(d):Sj}),bk=Uc("e",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?Oj(d):Tj}),ck=Uc("phi",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?Pj(d):1.618033988749895}),dk=Uc("LN2",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?(new d(2)).ln():Math.LN2}),ek=Uc("LN10",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?(new d(10)).ln(): +Math.LN10}),fk=Uc("LOG2E",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?(new d(1)).div((new d(2)).ln()):Math.LOG2E}),gk=Uc("LOG10E",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?(new d(1)).div((new d(10)).ln()):Math.LOG10E}),hk=Uc("SQRT1_2",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?(new d("0.5")).sqrt():Math.SQRT1_2}),ik=Uc("SQRT2",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}= +b;return"BigNumber"===a.number?(new d(2)).sqrt():Math.SQRT2}),jk=Uc("i",["Complex"],b=>{({Complex:b}=b);return b.I}),kk=B("version",[],()=>"9.4.1"),hf=jb(776),lk=B("BigNumber",["?on","config"],b=>{var {on:a,config:d}=b,c=hf.clone({precision:d.precision,modulo:9});return c.prototype.type="BigNumber",c.prototype.isBigNumber=!0,c.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},c.fromJSON=function(f){return new c(f.value)},a&&a("config",function(f,h){f.precision!==h.precision&& +c.config({precision:f.precision})}),c},{isClass:!0}),mk=B("Matrix",[],()=>{function b(){if(!(this instanceof b))throw new SyntaxError("Constructor must be called with the new operator");}return b.prototype.type="Matrix",b.prototype.isMatrix=!0,b.prototype.storage=function(){throw Error("Cannot invoke storage on a Matrix interface");},b.prototype.datatype=function(){throw Error("Cannot invoke datatype on a Matrix interface");},b.prototype.create=function(a,d){throw Error("Cannot invoke create on a Matrix interface"); +},b.prototype.subset=function(a,d,c){throw Error("Cannot invoke subset on a Matrix interface");},b.prototype.get=function(a){throw Error("Cannot invoke get on a Matrix interface");},b.prototype.set=function(a,d,c){throw Error("Cannot invoke set on a Matrix interface");},b.prototype.resize=function(a,d){throw Error("Cannot invoke resize on a Matrix interface");},b.prototype.reshape=function(a,d){throw Error("Cannot invoke reshape on a Matrix interface");},b.prototype.clone=function(){throw Error("Cannot invoke clone on a Matrix interface"); +},b.prototype.size=function(){throw Error("Cannot invoke size on a Matrix interface");},b.prototype.map=function(a,d){throw Error("Cannot invoke map on a Matrix interface");},b.prototype.forEach=function(a){throw Error("Cannot invoke forEach on a Matrix interface");},b.prototype[Symbol.iterator]=function(){throw Error("Cannot iterate a Matrix interface");},b.prototype.toArray=function(){throw Error("Cannot invoke toArray on a Matrix interface");},b.prototype.valueOf=function(){throw Error("Cannot invoke valueOf on a Matrix interface"); +},b.prototype.format=function(a){throw Error("Cannot invoke format on a Matrix interface");},b.prototype.toString=function(){throw Error("Cannot invoke toString on a Matrix interface");},b},{isClass:!0}),nk=B("replacer",[],()=>function(b,a){return"number"!=typeof a||isFinite(a)&&!isNaN(a)?a:{mathjs:"number",value:String(a)}}),ok=Cb("speedOfLight","299792458","m s^-1"),pk=Cb("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),qk=Cb("planckConstant","6.62607015e-34","J s"),rk=Cb("reducedPlanckConstant", +"1.0545718176461565e-34","J s"),sk=Cb("magneticConstant","1.25663706212e-6","N A^-2"),tk=Cb("electricConstant","8.8541878128e-12","F m^-1"),uk=Cb("vacuumImpedance","376.730313667","ohm"),vk=Cb("coulomb","8.987551792261171e9","N m^2 C^-2"),wk=Cb("elementaryCharge","1.602176634e-19","C"),xk=Cb("bohrMagneton","9.2740100783e-24","J T^-1"),yk=Cb("conductanceQuantum","7.748091729863649e-5","S"),zk=Cb("inverseConductanceQuantum","12906.403729652257","ohm"),Ak=Cb("magneticFluxQuantum","2.0678338484619295e-15", +"Wb"),Bk=Cb("nuclearMagneton","5.0507837461e-27","J T^-1"),Ck=Cb("klitzing","25812.807459304513","ohm"),Dk=Cb("bohrRadius","5.29177210903e-11","m"),Ek=Cb("classicalElectronRadius","2.8179403262e-15","m"),Fk=Cb("electronMass","9.1093837015e-31","kg"),Gk=Cb("fermiCoupling","1.1663787e-5","GeV^-2"),Hk=Ge("fineStructure",.0072973525693),Ik=Cb("hartreeEnergy","4.3597447222071e-18","J"),Jk=Cb("protonMass","1.67262192369e-27","kg"),Kk=Cb("deuteronMass","3.3435830926e-27","kg"),Lk=Cb("neutronMass","1.6749271613e-27", +"kg"),Mk=Cb("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),Nk=Cb("rydberg","10973731.568160","m^-1"),Ok=Cb("thomsonCrossSection","6.6524587321e-29","m^2"),Pk=Ge("weakMixingAngle",.2229),Qk=Ge("efimovFactor",22.7),Rk=Cb("atomicMass","1.66053906660e-27","kg"),Sk=Cb("avogadro","6.02214076e23","mol^-1"),Tk=Cb("boltzmann","1.380649e-23","J K^-1"),Uk=Cb("faraday","96485.33212331001","C mol^-1"),Vk=Cb("firstRadiation","3.7417718521927573e-16","W m^2"),Wk=Cb("loschmidt","2.686780111798444e25","m^-3"), +Xk=Cb("gasConstant","8.31446261815324","J K^-1 mol^-1"),Yk=Cb("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),Zk=Cb("molarVolume","0.022413969545014137","m^3 mol^-1"),$k=Ge("sackurTetrode",-1.16487052358),al=Cb("secondRadiation","0.014387768775039337","m K"),bl=Cb("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),cl=Cb("wienDisplacement","2.897771955e-3","m K"),dl=Cb("molarMass","0.99999999965e-3","kg mol^-1"),el=Cb("molarMassC12","11.9999999958e-3","kg mol^-1"),fl=Cb("gravity","9.80665", +"m s^-2"),gl=Cb("planckLength","1.616255e-35","m"),hl=Cb("planckMass","2.176435e-8","kg"),il=Cb("planckTime","5.391245e-44","s"),jl=Cb("planckCharge","1.87554603778e-18","C"),kl=Cb("planckTemperature","1.416785e+32","K"),ce=jb(628),ll=B("Fraction",[],()=>(ce.prototype.type="Fraction",ce.prototype.isFraction=!0,ce.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},ce.fromJSON=function(b){return new ce(b)},ce),{isClass:!0}),ml=B("DenseMatrix",["Matrix"],b=>{function a(k, +n){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(n&&!Ia(n))throw Error("Invalid datatype: "+n);if(Fa(k))"DenseMatrix"===k.type?(this._data=nb(k._data),this._size=nb(k._size),this._datatype=n||k._datatype):(this._data=k.toArray(),this._size=k.size(),this._datatype=n||k._datatype);else if(k&&$b(k.data)&&$b(k.size))this._data=k.data,this._size=k.size,jc(this._data,this._size),this._datatype=n||k.datatype;else{if($b(k))this._data=p(k),this._size= +Ua(this._data),jc(this._data,this._size);else{if(k)throw new TypeError("Unsupported type of data ("+Wb(k)+")");this._data=[];this._size=[0]}this._datatype=n}}function d(k,n,g,e){var m=e===g-1,q=n.dimension(e);return m?q.map(function(r){return Yb(r,k.length),k[r]}).valueOf():q.map(function(r){return Yb(r,k.length),d(k[r],n,g,e+1)}).valueOf()}function c(k,n,g,e){if(!n||!0!==n.isIndex)throw new TypeError("Invalid index");var m,q=n.size(),r=n.isScalar();if(Fa(g)?(m=g.size(),g=g.valueOf()):m=Ua(g),r){if(0!== +m.length)throw new TypeError("Scalar expected");k.set(n.min(),g,e)}else{if(q.length");l(k,n.max().map(function(y){return y+1}),e);f(k._data,n,g,q.length,0)}return k}function f(k,n,g,e,m){var q=m===e-1,r=n.dimension(m);q?r.forEach(function(u,y){Yb(u);k[u]=g[y[0]]}):r.forEach(function(u,y){Yb(u);f(k[u],n,g[y[0]], +e,m+1)})}function h(k,n,g){if(0===n.length){for(k=k._data;$b(k);)k=k[0];return k}return k._size=n.slice(0),k._data=gd(k._data,k._size,g),k}function l(k,n,g){for(var e=k._size.slice(0),m=!1;e.lengthe[q]&&(e[q]=n[q],m=!0);m&&h(k,e,g)}function p(k){for(var n=0,g=k.length;n +Array.isArray(e)&&1===e.length?e[0]:e);return h(g?this.clone():this,k,n)},a.prototype.reshape=function(k,n){n=n?this.clone():this;n._data=Zd(n._data,k);var g=n._size.reduce((e,m)=>e*m);return n._size=Kd(k,g),n},a.prototype.clone=function(){return new a({data:nb(this._data),size:nb(this._size),datatype:this._datatype})},a.prototype.size=function(){return this._size.slice(0)},a.prototype.map=function(k){var n=this,g=function r(m,q){return $b(m)?m.map(function(u,y){return r(u,q.concat(y))}):k(m,q,n)}(this._data, +[]);return new a(g,void 0!==this._datatype?la(g,Wb):void 0)},a.prototype.forEach=function(k){var n=this;!function q(e,m){$b(e)?e.forEach(function(r,u){q(r,m.concat(u))}):k(e,m,n)}(this._data,[])},a.prototype[Symbol.iterator]=function*(){yield*function*e(n,g){if($b(n))for(var m=0;m[y[r]]);n.push(new a(u,k._datatype))},q=0;qk?-k:0;for(var g=Math.min(this._size[0]-k,this._size[1]-n),e=[],m=0;mt)throw Error("Size values must be positive integers");return t}),g){if(pa(g)&&(g=g.toNumber()),!Qa(g)||!Za(g))throw new TypeError("The parameter k must be an integer number");}else g=0;var m=0g?-g:0;var q=k[0],r=k[1],u=Math.min(q-g,r-m);if($b(n)){if(n.length!==u)throw Error("Invalid value array length"); +var y=function(t){return n[t]}}else if(Fa(n)){y=n.size();if(1!==y.length||y[0]!==u)throw Error("Invalid matrix length");y=function(t){return n.get([t])}}else y=function(){return n};e||(e=pa(y(0))?y(0).mul(0):0);var v=[];if(015 significant digits to BigNumber (value: "+ +h+"). Use function bignumber(x) to convert to BigNumber.");return new a(h)}},{from:"number",to:"Complex",convert:function(h){return d||He(h),new d(h,0)}},{from:"number",to:"string",convert:function(h){return h+""}},{from:"BigNumber",to:"Complex",convert:function(h){return d||He(h),new d(h.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(h){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(h){return d||He(h),new d(h.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(h){f||$e(h);var l=new f(h);if(l.valueOf()!==h)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+h+"). Use function fraction(x) to convert to Fraction.");return l}},{from:"string",to:"number",convert:function(h){var l=Number(h);if(isNaN(l))throw Error('Cannot convert "'+h+'" to a number');return l}}, +{from:"string",to:"BigNumber",convert:function(h){a||Ze(h);try{return new a(h)}catch(l){throw Error('Cannot convert "'+h+'" to BigNumber');}}},{from:"string",to:"Fraction",convert:function(h){f||$e(h);try{return new f(h)}catch(l){throw Error('Cannot convert "'+h+'" to Fraction');}}},{from:"string",to:"Complex",convert:function(h){d||He(h);try{return new d(h)}catch(l){throw Error('Cannot convert "'+h+'" to Complex');}}},{from:"boolean",to:"number",convert:function(h){return+h}},{from:"boolean",to:"BigNumber", +convert:function(h){return a||Ze(h),new a(+h)}},{from:"boolean",to:"Fraction",convert:function(h){return f||$e(h),new f(+h)}},{from:"boolean",to:"string",convert:function(h){return String(h)}},{from:"Array",to:"Matrix",convert:function(h){if(!c)throw Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided");return new c(h)}},{from:"Matrix",to:"Array",convert:function(h){return h.valueOf()}}],b}),ol=B("isInteger",["typed"],b=>{({typed:b}=b);return b("isInteger",{number:Za,BigNumber:function(a){return a.isInt()}, +Fraction:function(a){return 1===a.d&&isFinite(a.n)},"Array | Matrix":function(a){return Na(a,this)}})}),pl=B("isNumeric",["typed"],b=>{({typed:b}=b);return b("isNumeric",{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(a){return Na(a,this)}})});Df.signature="number";Ef.signature="number";Ff.signature="number";Gf.signature="number";var ql=B("isPositive",["typed"],b=>{({typed:b}=b);return b("isPositive", +{number:Ef,BigNumber:function(a){return!a.isNeg()&&!a.isZero()&&!a.isNaN()},Fraction:function(a){return 0{({typed:b}=b);return b("isNaN",{number:Gf,BigNumber:function(a){return a.isNaN()},Fraction:function(a){return!1},Complex:function(a){return a.isNaN()},Unit:function(a){return Number.isNaN(a.value)},"Array | Matrix":function(a){return Na(a,Number.isNaN)}})}),sl=B("equalScalar", +["typed","config"],b=>{var {typed:a,config:d}=b;return a("equalScalar",{"boolean, boolean":function(c,f){return c===f},"number, number":function(c,f){return Ec(c,f,d.epsilon)},"BigNumber, BigNumber":function(c,f){return c.eq(f)||jd(c,f,d.epsilon)},"Fraction, Fraction":function(c,f){return c.equals(f)},"Complex, Complex":function(c,f){var h=d.epsilon;return Ec(c.re,f.re,h)&&Ec(c.im,f.im,h)},"Unit, Unit":function(c,f){if(!c.equalBase(f))throw Error("Cannot compare units with different base");return this(c.value, +f.value)}})});B("equalScalar",["typed","config"],b=>{var {typed:a,config:d}=b;return a("equalScalar",{"number, number":function(c,f){return Ec(c,f,d.epsilon)}})});var tl=B("number",["typed"],b=>{({typed:b}=b);b=b("number",{"":function(){return 0},number:function(a){return a},string:function(a){if("NaN"===a)return NaN;var d,c,f=(c=(d=a).match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/))?{input:d,radix:{"0b":2,"0o":8,"0x":16}[c[1]],integerPart:c[2],fractionalPart:c[3]}:null;if(f){a=parseInt(f.integerPart, +f.radix);for(c=d=0;cMath.pow(2,f)-1)throw new SyntaxError('String "'.concat(a,'" is out of range'));c>=Math.pow(2,f-1)&&(c-=Math.pow(2,f))}return c},BigNumber:function(a){return a.toNumber()}, +Fraction:function(a){return a.valueOf()},Unit:function(a){throw Error("Second argument with valueless unit expected");},null:function(a){return 0},"Unit, string | Unit":function(a,d){return a.toNumber(d)},"Array | Matrix":function(a){return Na(a,this)}});return b.fromJSON=function(a){return parseFloat(a.value)},b}),ul=B("boolean",["typed"],b=>{({typed:b}=b);return b("boolean",{"":function(){return!1},boolean:function(a){return a},number:function(a){return!!a},null:function(a){return!1},BigNumber:function(a){return!a.isZero()}, +string:function(a){var d=a.toLowerCase();if("true"===d)return!0;if("false"===d)return!1;d=Number(a);if(""!==a&&!isNaN(d))return!!d;throw Error('Cannot convert "'+a+'" to a boolean');},"Array | Matrix":function(a){return Na(a,this)}})}),vl=B("complex",["typed","Complex"],b=>{var {typed:a,Complex:d}=b;return a("complex",{"":function(){return d.ZERO},number:function(c){return new d(c,0)},"number, number":function(c,f){return new d(c,f)},"BigNumber, BigNumber":function(c,f){return new d(c.toNumber(), +f.toNumber())},Fraction:function(c){return new d(c.valueOf(),0)},Complex:function(c){return c.clone()},string:function(c){return d(c)},null:function(c){return d(0)},Object:function(c){if("re"in c&&"im"in c)return new d(c.re,c.im);if("r"in c&&"phi"in c||"abs"in c&&"arg"in c)return new d(c);throw Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)");},"Array | Matrix":function(c){return Na(c,this)}})}),wl=B("splitUnit",["typed"],b=>{({typed:b}=b);return b("splitUnit", +{"Unit, Array":function(a,d){return a.splitUnit(d)}})});Hf.signature="number";If.signature="number, number";Jf.signature="number, number";Kf.signature="number";Lf.signature="number";Mf.signature="number";Nf.signature="number";Of.signature="number";Pf.signature="number";Qf.signature="number";Rf.signature="number, number";Sf.signature="number, number";Tf.signature="number";Uf.signature="number, number";af.signature="number, number";Vf.signature="number";Wf.signature="number";Xf.signature="number, number"; +Yf.signature="number, number";bf.signature="number, number";var xl=B("unaryPlus",["typed","config","BigNumber"],b=>{var {typed:a,config:d,BigNumber:c}=b;return a("unaryPlus",{number:Lf,Complex:function(f){return f},BigNumber:function(f){return f},Fraction:function(f){return f},Unit:function(f){return f.clone()},"Array | Matrix":function(f){return Na(f,this,!0)},"boolean | string":function(f){return"BigNumber"===d.number?new c(+f):+f}})}),yl=B("cube",["typed"],b=>{({typed:b}=b);return b("cube",{number:Of, +Complex:function(a){return a.mul(a).mul(a)},BigNumber:function(a){return a.times(a).times(a)},Fraction:function(a){return a.pow(3)},"Array | Matrix":function(a){return Na(a,this,!0)},Unit:function(a){return a.pow(3)}})}),zl=B("expm1",["typed","Complex"],b=>{var {typed:a,Complex:d}=b;return a("expm1",{number:Qf,Complex:function(c){var f=Math.exp(c.re);return new d(f*Math.cos(c.im)-1,f*Math.sin(c.im))},BigNumber:function(c){return c.exp().minus(1)},"Array | Matrix":function(c){return Na(c,this)}})}), +Al=B("log10",["typed","config","Complex"],b=>{var {typed:a,config:d,Complex:c}=b;return a("log10",{number:function(f){return 0<=f||d.predictable?Li(f):(new c(f,0)).log().div(Math.LN10)},Complex:function(f){return(new c(f)).log().div(Math.LN10)},BigNumber:function(f){return!f.isNegative()||d.predictable?f.log():(new c(f.toNumber(),0)).log().div(Math.LN10)},"Array | Matrix":function(f){return Na(f,this)}})}),Bl=B("multiplyScalar",["typed"],b=>{({typed:b}=b);return b("multiplyScalar",{"number, number":Jf, +"Complex, Complex":function(a,d){return a.mul(d)},"BigNumber, BigNumber":function(a,d){return a.times(d)},"Fraction, Fraction":function(a,d){return a.mul(d)},"number | Fraction | BigNumber | Complex, Unit":function(a,d){d=d.clone();return d.value=null===d.value?d._normalize(a):this(d.value,a),d},"Unit, number | Fraction | BigNumber | Complex":function(a,d){a=a.clone();return a.value=null===a.value?a._normalize(d):this(a.value,d),a},"Unit, Unit":function(a,d){return a.multiply(d)}})}),Cl=B("sign", +["typed","BigNumber","Fraction","complex"],b=>{var {typed:a,BigNumber:d,complex:c,Fraction:f}=b;return a("sign",{number:Vf,Complex:function(h){return 0===h.im?c(pd(h.re)):h.sign()},BigNumber:function(h){return new d(h.cmp(0))},Fraction:function(h){return new f(h.s,1)},"Array | Matrix":function(h){return Na(h,this,!0)},Unit:function(h){return this(h.value)}})}),Dl=B("square",["typed"],b=>{({typed:b}=b);return b("square",{number:Wf,Complex:function(a){return a.mul(a)},BigNumber:function(a){return a.times(a)}, +Fraction:function(a){return a.mul(a)},"Array | Matrix":function(a){return Na(a,this,!0)},Unit:function(a){return a.pow(2)}})});Zf.signature="number, number";$f.signature="number";ag.signature="number, number";bg.signature="number, number";cg.signature="number, number";dg.signature="number, number";eg.signature="number, number";var El=B("bitNot",["typed"],b=>{({typed:b}=b);return b("bitNot",{number:$f,BigNumber:oe,"Array | Matrix":function(a){return Na(a,this)}})}),Fl=B("arg",["typed"],b=>{({typed:b}= +b);return b("arg",{number:function(a){return Math.atan2(0,a)},BigNumber:function(a){return a.constructor.atan2(0,a)},Complex:function(a){return a.arg()},"Array | Matrix":function(a){return Na(a,this)}})}),Gl=B("im",["typed"],b=>{({typed:b}=b);return b("im",{number:function(a){return 0},BigNumber:function(a){return a.mul(0)},Fraction:function(a){return a.mul(0)},Complex:function(a){return a.im},"Array | Matrix":function(a){return Na(a,this)}})});fg.signature="number";gg.signature="number, number"; +hg.signature="number, number";ig.signature="number, number";var Hl=B("not",["typed"],b=>{({typed:b}=b);return b("not",{number:fg,Complex:function(a){return 0===a.re&&0===a.im},BigNumber:function(a){return a.isZero()||a.isNaN()},Unit:function(a){return null===a.value||this(a.value)},"Array | Matrix":function(a){return Na(a,this)}})}),Il=B("filter",["typed"],b=>{({typed:b}=b);return b("filter",{"Array, function":jg,"Matrix, function":function(a,d){return a.create(jg(a.toArray(),d))},"Array, RegExp":Y, +"Matrix, RegExp":function(a,d){return a.create(Y(a.toArray(),d))}})}),Jl=B("forEach",["typed"],b=>{({typed:b}=b);return b("forEach",{"Array, function":Ei,"Matrix, function":function(a,d){return a.forEach(d)}})}),Kl=B("map",["typed"],b=>{({typed:b}=b);return b("map",{"Array, function":Fi,"Matrix, function":function(a,d){return a.map(d)}})}),Ol=B("erf",["typed"],b=>{({typed:b}=b);return b("name",{number:function(a){var d=Math.abs(a);return d>=Ll?pd(a):d<=Ml?pd(a)*function(c){var f,h=c*c,l=qd[0][4]* +h,p=h;for(f=0;3>f;f+=1)l=(l+qd[0][f])*h,p=(p+de[0][f])*h;return c*(l+qd[0][3])/(p+de[0][3])}(d):4>=d?pd(a)*(1-function(c){var f,h=qd[1][8]*c,l=c;for(f=0;7>f;f+=1)h=(h+qd[1][f])*c,l=(l+de[1][f])*c;f=(h+qd[1][7])/(l+de[1][7]);h=parseInt(16*c)/16;return Math.exp(-h*h)*Math.exp(-((c-h)*(c+h)))*f}(d)):pd(a)*(1-function(c){var f,h=1/(c*c),l=qd[2][5]*h,p=h;for(f=0;4>f;f+=1)l=(l+qd[2][f])*h,p=(p+de[2][f])*h;f=h*(l+qd[2][4])/(p+de[2][4]);f=(Nl-f)/c;l=(c-(h=parseInt(16*c)/16))*(c+h);return Math.exp(-h*h)*Math.exp(-l)* +f}(d))},"Array | Matrix":function(a){return Na(a,this)}})}),Ml=.46875,Nl=.5641895835477563,qd=[[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,6.587491615298378E-4,.016315387137302097]],de=[[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]],Ll=Math.pow(2,53),Pl=B("format",["typed"],b=>{({typed:b}=b);return b("format",{any:Db,"any, Object | function | number":Db})}),Ql=B("oct",["typed","format"],b=>{var {typed:a,format:d}=b;return a("oct", +{"number | BigNumber":function(c){return d(c,{notation:"oct"})},"number | BigNumber, number":function(c,f){return d(c,{notation:"oct",wordSize:f})}})}),Rl=B("print",["typed"],b=>{({typed:b}=b);return b("print",{"string, Object | Array":kg,"string, Object | Array, number | Object":kg})}),Sl=B("isPrime",["typed"],b=>{({typed:b}=b);return b("isPrime",{number:function(a){if(0!=0*a)return!1;if(3>=a)return 1n{var {typed:a,config:d,Complex:c}=b;return a("acos",{number:function(f){return-1<=f&&1>=f|| +d.predictable?Math.acos(f):(new c(f,0)).acos()},Complex:function(f){return f.acos()},BigNumber:function(f){return f.acos()},"Array | Matrix":function(f){return Na(f,this)}})});lg.signature="number";mg.signature="number";ng.signature="number";og.signature="number";pg.signature="number";qg.signature="number";rg.signature="number";sg.signature="number";tg.signature="number";ug.signature="number";vg.signature="number";wg.signature="number";xg.signature="number";yg.signature="number";var Ul=B("acot",["typed", +"BigNumber"],b=>{var {typed:a,BigNumber:d}=b;return a("acot",{number:lg,Complex:function(c){return c.acot()},BigNumber:function(c){return(new d(1)).div(c).atan()},"Array | Matrix":function(c){return Na(c,this)}})}),Vl=B("acsc",["typed","config","Complex","BigNumber"],b=>{var {typed:a,config:d,Complex:c,BigNumber:f}=b;return a("acsc",{number:function(h){return-1>=h||1<=h||d.predictable?ng(h):(new c(h,0)).acsc()},Complex:function(h){return h.acsc()},BigNumber:function(h){return(new f(1)).div(h).asin()}, +"Array | Matrix":function(h){return Na(h,this)}})}),Wl=B("asec",["typed","config","Complex","BigNumber"],b=>{var {typed:a,config:d,Complex:c,BigNumber:f}=b;return a("asec",{number:function(h){return-1>=h||1<=h||d.predictable?pg(h):(new c(h,0)).asec()},Complex:function(h){return h.asec()},BigNumber:function(h){return(new f(1)).div(h).acos()},"Array | Matrix":function(h){return Na(h,this)}})}),Xl=B("asin",["typed","config","Complex"],b=>{var {typed:a,config:d,Complex:c}=b;return a("asin",{number:function(f){return-1<= +f&&1>=f||d.predictable?Math.asin(f):(new c(f,0)).asin()},Complex:function(f){return f.asin()},BigNumber:function(f){return f.asin()},"Array | Matrix":function(f){return Na(f,this,!0)}})}),Yl=B("atan",["typed"],b=>{({typed:b}=b);return b("atan",{number:function(a){return Math.atan(a)},Complex:function(a){return a.atan()},BigNumber:function(a){return a.atan()},"Array | Matrix":function(a){return Na(a,this,!0)}})}),Zl=B("atanh",["typed","config","Complex"],b=>{var {typed:a,config:d,Complex:c}=b;return a("atanh", +{number:function(f){return 1>=f&&-1<=f||d.predictable?Oi(f):(new c(f,0)).atanh()},Complex:function(f){return f.atanh()},BigNumber:function(f){return f.atanh()},"Array | Matrix":function(f){return Na(f,this,!0)}})}),$l=B("cosh",["typed"],b=>{({typed:b}=b);return b("cosh",{number:Pi,Complex:function(a){return a.cosh()},BigNumber:function(a){return a.cosh()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(a.value)},"Array | Matrix":function(a){return Na(a, +this)}})}),am=B("coth",["typed","BigNumber"],b=>{var {typed:a,BigNumber:d}=b;return a("coth",{number:tg,Complex:function(c){return c.coth()},BigNumber:function(c){return(new d(1)).div(c.tanh())},Unit:function(c){if(!c.hasBase(c.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(c.value)},"Array | Matrix":function(c){return Na(c,this)}})}),bm=B("csch",["typed","BigNumber"],b=>{var {typed:a,BigNumber:d}=b;return a("csch",{number:vg,Complex:function(c){return c.csch()}, +BigNumber:function(c){return(new d(1)).div(c.sinh())},Unit:function(c){if(!c.hasBase(c.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(c.value)},"Array | Matrix":function(c){return Na(c,this)}})}),cm=B("sech",["typed","BigNumber"],b=>{var {typed:a,BigNumber:d}=b;return a("sech",{number:xg,Complex:function(c){return c.sech()},BigNumber:function(c){return(new d(1)).div(c.cosh())},Unit:function(c){if(!c.hasBase(c.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle"); +return this(c.value)},"Array | Matrix":function(c){return Na(c,this)}})}),dm=B("sinh",["typed"],b=>{({typed:b}=b);return b("sinh",{number:yg,Complex:function(a){return a.sinh()},BigNumber:function(a){return a.sinh()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(a.value)},"Array | Matrix":function(a){return Na(a,this,!0)}})}),em=B("tanh",["typed"],b=>{({typed:b}=b);return b("tanh",{number:Qi,Complex:function(a){return a.tanh()}, +BigNumber:function(a){return a.tanh()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(a.value)},"Array | Matrix":function(a){return Na(a,this,!0)}})});zg.signature="number, number";var fm=B("combinations",["typed"],b=>{({typed:b}=b);return b("combinations",{"number, number":zg,"BigNumber, BigNumber":function(a,d){var c,f=a.constructor,h=a.minus(d);f=new f(1);if(!Ag(a)||!Ag(d))throw new TypeError("Positive integer value expected in function combinations"); +if(d.gt(a))throw new TypeError("k must be less than n in function combinations");if(a=f,d.lt(h))for(c=f;c.lte(h);c=c.plus(f))a=a.times(d.plus(c)).dividedBy(c);else for(c=f;c.lte(d);c=c.plus(f))a=a.times(h.plus(c)).dividedBy(c);return a}})}),Bg=jb(377),Ii=Bg(Date.now()),gm=B("pickRandom",["typed","config","?on"],b=>{function a(l,p){var {number:k,weights:n,elementWise:g=!0}=p;(p=void 0===k)&&(k=1);var e=Fa(l)?l.create:Fa(n)?n.create:null;l=l.valueOf();n&&(n=n.valueOf());!0===g&&(l=C(l),n=C(n));var m= +0;if(void 0!==n){if(n.length!==l.length)throw Error("Weights must have the same length as possibles");for(var q=0,r=n.length;qn[q])throw Error("Weights must be an array of positive numbers");m+=n[q]}}q=l.length;for(r=[];r.length(y-=n[v])){u=l[v];break}r.push(u)}return p?r[0]:e?e(r):r}var {typed:d,config:c,on:f}=b,h=ae(c.randomSeed);return f&&f("config",function(l,p){l.randomSeed!== +p.randomSeed&&(h=ae(l.randomSeed))}),d("pickRandom",{"Array | Matrix":function(l){return a(l,{})},"Array | Matrix, Object":function(l,p){return a(l,p)},"Array | Matrix, number":function(l,p){return a(l,{number:p})},"Array | Matrix, Array | Matrix":function(l,p){return a(l,{weights:p})},"Array | Matrix, Array | Matrix, number":function(l,p,k){return a(l,{number:k,weights:p})},"Array | Matrix, number, Array | Matrix":function(l,p,k){return a(l,{number:p,weights:k})}})}),hm=B("randomInt",["typed","config", +"?on"],b=>{function a(p,k,n){var g=df(p.valueOf(),()=>d(k,n));return Fa(p)?p.create(g):g}function d(p,k){return Math.floor(p+l()*(k-p))}var {typed:c,config:f,on:h}=b,l=ae(f.randomSeed);return h&&h("config",function(p,k){p.randomSeed!==k.randomSeed&&(l=ae(p.randomSeed))}),c("randomInt",{"":()=>d(0,1),number:p=>d(0,p),"number, number":(p,k)=>d(p,k),"Array | Matrix":p=>a(p,0,1),"Array | Matrix, number":(p,k)=>a(p,0,k),"Array | Matrix, number, number":(p,k,n)=>a(p,k,n)})}),im=B("clone",["typed"],b=>{({typed:b}= +b);return b("clone",{any:nb})}),jm=B("hasNumericValue",["typed","isNumeric"],b=>{var {typed:a,isNumeric:d}=b;return a("hasNumericValue",{string:function(c){return 0{({typed:b}=b);return b("typeOf",{any:Wb})}),lm=B("string",["typed"],b=>{({typed:b}=b);return b("string",{"":function(){return""},number:$c,null:function(a){return"null"},boolean:function(a){return a+""},string:function(a){return a},"Array | Matrix":function(a){return Na(a, +this)},any:function(a){return String(a)}})}),mm=B("fraction",["typed","Fraction"],b=>{var {typed:a,Fraction:d}=b;return a("fraction",{number:function(c){if(!isFinite(c)||isNaN(c))throw Error(c+" cannot be represented as a fraction");return new d(c)},string:function(c){return new d(c)},"number, number":function(c,f){return new d(c,f)},null:function(c){return new d(0)},BigNumber:function(c){return new d(c.toString())},Fraction:function(c){return c},Object:function(c){return new d(c)},"Array | Matrix":function(c){return Na(c, +this)}})}),nm=B("unaryMinus",["typed"],b=>{({typed:b}=b);return b("unaryMinus",{number:Kf,Complex:function(a){return a.neg()},BigNumber:function(a){return a.neg()},Fraction:function(a){return a.neg()},Unit:function(a){var d=a.clone();return d.value=this(a.value),d},"Array | Matrix":function(a){return Na(a,this,!0)}})}),om=B("addScalar",["typed"],b=>{({typed:b}=b);return b("addScalar",{"number, number":If,"Complex, Complex":function(a,d){return a.add(d)},"BigNumber, BigNumber":function(a,d){return a.plus(d)}, +"Fraction, Fraction":function(a,d){return a.add(d)},"Unit, Unit":function(a,d){if(null===a.value||void 0===a.value)throw Error("Parameter x contains a unit with undefined value");if(null===d.value||void 0===d.value)throw Error("Parameter y contains a unit with undefined value");if(!a.equalBase(d))throw Error("Units do not match");a=a.clone();return a.value=this(a.value,d.value),a.fixPrefix=!1,a}})}),pm=B("exp",["typed"],b=>{({typed:b}=b);return b("exp",{number:Pf,Complex:function(a){return a.exp()}, +BigNumber:function(a){return a.exp()},"Array | Matrix":function(a){return Na(a,this)}})}),qm=B("log2",["typed","config","Complex"],b=>{function a(h){var l=Math.sqrt(h.re*h.re+h.im*h.im);return new f(Math.log2?Math.log2(l):Math.log(l)/Math.LN2,Math.atan2(h.im,h.re)/Math.LN2)}var {typed:d,config:c,Complex:f}=b;return d("log2",{number:function(h){return 0<=h||c.predictable?Ki(h):a(new f(h,0))},Complex:a,BigNumber:function(h){return!h.isNegative()||c.predictable?h.log(2):a(new f(h.toNumber(),0))},"Array | Matrix":function(h){return Na(h, +this)}})}),rm=B("sqrt",["config","typed","Complex"],b=>{function a(h){return isNaN(h)?NaN:0<=h||d.predictable?Math.sqrt(h):(new f(h,0)).sqrt()}var {config:d,typed:c,Complex:f}=b;return c("sqrt",{number:a,Complex:function(h){return h.sqrt()},BigNumber:function(h){return!h.isNegative()||d.predictable?h.sqrt():a(h.toNumber())},"Array | Matrix":function(h){return Na(h,this,!0)},Unit:function(h){return h.pow(.5)}})}),sm=B("conj",["typed"],b=>{({typed:b}=b);return b("conj",{number:function(a){return a}, +BigNumber:function(a){return a},Complex:function(a){return a.conjugate()},"Array | Matrix":function(a){return Na(a,this)}})}),tm=B("getMatrixDataType",["typed"],b=>{({typed:b}=b);return b("getMatrixDataType",{Array:function(a){return la(a,Wb)},Matrix:function(a){return a.getDataType()}})}),um=B("mode",["typed","isNaN","isNumeric"],b=>{function a(h){if(0===(h=C(h.valueOf())).length)throw Error("Cannot calculate mode of an empty array");for(var l={},p=[],k=0,n=0;nk&&(k=l[g],p=[g])}return p}var {typed:d,isNaN:c,isNumeric:f}=b;return d("mode",{"Array | Matrix":a,"...":function(h){return a(h)}})}),vm=B("bin",["typed","format"],b=>{var {typed:a,format:d}=b;return a("bin",{"number | BigNumber":function(c){return d(c,{notation:"bin"})},"number | BigNumber, number":function(c,f){return d(c,{notation:"bin",wordSize:f})}})}),wm=B("acosh",["typed", +"config","Complex"],b=>{var {typed:a,config:d,Complex:c}=b;return a("acosh",{number:function(f){return 1<=f||d.predictable?Ni(f):-1>=f?new c(Math.log(Math.sqrt(f*f-1)-f),Math.PI):(new c(f,0)).acosh()},Complex:function(f){return f.acosh()},BigNumber:function(f){return f.acosh()},"Array | Matrix":function(f){return Na(f,this)}})}),xm=B("acsch",["typed","BigNumber"],b=>{var {typed:a,BigNumber:d}=b;return a("acsch",{number:og,Complex:function(c){return c.acsch()},BigNumber:function(c){return(new d(1)).div(c).asinh()}, +"Array | Matrix":function(c){return Na(c,this)}})}),ym=B("asinh",["typed"],b=>{({typed:b}=b);return b("asinh",{number:rg,Complex:function(a){return a.asinh()},BigNumber:function(a){return a.asinh()},"Array | Matrix":function(a){return Na(a,this,!0)}})}),zm=B("cos",["typed"],b=>{({typed:b}=b);return b("cos",{number:Math.cos,Complex:function(a){return a.cos()},BigNumber:function(a){return a.cos()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle"); +return this(a.value)},"Array | Matrix":function(a){return Na(a,this)}})}),Am=B("csc",["typed","BigNumber"],b=>{var {typed:a,BigNumber:d}=b;return a("csc",{number:ug,Complex:function(c){return c.csc()},BigNumber:function(c){return(new d(1)).div(c.sin())},Unit:function(c){if(!c.hasBase(c.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(c.value)},"Array | Matrix":function(c){return Na(c,this)}})}),Bm=B("sin",["typed"],b=>{({typed:b}=b);return b("sin", +{number:Math.sin,Complex:function(a){return a.sin()},BigNumber:function(a){return a.sin()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(a.value)},"Array | Matrix":function(a){return Na(a,this,!0)}})}),Cm=B("combinationsWithRep",["typed"],b=>{({typed:b}=b);return b("combinationsWithRep",{"number, number":function(a,d){if(!Za(a)||0>a)throw new TypeError("Positive integer value expected in function combinationsWithRep"); +if(!Za(d)||0>d)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(1>a)throw new TypeError("k must be less than or equal to n + k - 1");return d{function a(p,k,n){var g=df(p.valueOf(),()=>d(k,n));return Fa(p)?p.create(g):g}function d(p,k){return p+l()*(k-p)}var {typed:c,config:f,on:h}=b,l=ae(f.randomSeed);return h&&h("config",function(p,k){p.randomSeed!==k.randomSeed&&(l=ae(p.randomSeed))}),c("random",{"":()=>d(0,1),number:p=>d(0,p),"number, number":(p, +k)=>d(p,k),"Array | Matrix":p=>a(p,0,1),"Array | Matrix, number":(p,k)=>a(p,0,k),"Array | Matrix, number, number":(p,k,n)=>a(p,k,n)})}),Em=B("isNegative",["typed"],b=>{({typed:b}=b);return b("isNegative",{number:Df,BigNumber:function(a){return a.isNeg()&&!a.isZero()&&!a.isNaN()},Fraction:function(a){return 0>a.s},Unit:function(a){return this(a.value)},"Array | Matrix":function(a){return Na(a,this)}})}),Fm=B("SparseMatrix",["typed","equalScalar","Matrix"],b=>{function a(e,m){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator"); +if(m&&!Ia(m))throw Error("Invalid datatype: "+m);if(Fa(e))"SparseMatrix"===e.type?(this._values=e._values?nb(e._values):void 0,this._index=nb(e._index),this._ptr=nb(e._ptr),this._size=nb(e._size),this._datatype=m||e._datatype):d(this,e.valueOf(),m||e._datatype),!0;else if(e&&$b(e.index)&&$b(e.ptr)&&$b(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=m||e.datatype;else if($b(e))d(this,e,m);else{if(e)throw new TypeError("Unsupported type of data ("+ +Wb(e)+")");this._values=[];this._index=[];this._ptr=[0];this._size=[0,0];this._datatype=m}}function d(e,m,q){e._values=[];e._index=[];e._ptr=[];e._datatype=q;var r=m.length,u=0,y=n,v=0;if(Ia(q)&&(y=k.find(n,[q,q])||n,v=k.convert(0,q)),0u&&(u=1),y(w,v)||(e._values.push(w),e._index.push(t))}q++}while(qy){for(u=y;uw){if(t){var z=0;for(u=0;um-1&&(e._values.splice(t,1),e._index.splice(t,1),r++);e._ptr[u]=e._values.length}return e._size[0]=m,e._size[1]=q,e}function p(e,m,q,r,u){var y,v=r[0],t=r[1],w=[];for(r=0;r"); +y=e.min()[0];v=e.min()[1];t=u[0];u=u[1];for(var w=0;wu-1||e>y-1)&&(l(this,Math.max(r+ +1,u),Math.max(e+1,y),q),u=this._size[0],y=this._size[1]);Yb(r,u);Yb(e,y);q=f(r,this._ptr[e],this._ptr[e+1],this._index);if(qArray.isArray(u)&&1===u.length? +u[0]:u);if(2!==r.length)throw Error("Only two dimensions matrix are supported");return r.forEach(function(u){if(!Qa(u)||!Za(u)||0>u)throw new TypeError("Invalid size, must contain positive integers (size: "+Db(r)+")");}),l(q?this.clone():this,r[0],r[1],m)},a.prototype.reshape=function(e,m){if(!$b(e))throw new TypeError("Array expected");if(2!==e.length)throw Error("Sparse matrices can only be reshaped in two dimensions");e.forEach(function(z){if(!Qa(z)||!Za(z)||-2>=z||0===z)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+ +Db(e)+")");});var q=this._size[0]*this._size[1];if(q!==(e=Kd(e,q))[0]*e[1])throw Error("Reshaping sparse matrix will result in the wrong number of elements");m=m?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return m;q=[];for(var r=0;r "+(this._values?Db(this._values[y],e):"X");return m},a.prototype.toString=function(){return Db(this.toArray())},a.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},a.prototype.diagonal=function(e){if(e){if(pa(e)&& +(e=e.toNumber()),!Qa(e)||!Za(e))throw new TypeError("The parameter k must be an integer number");}else e=0;var m=0e?-e:0;for(var q=this._size[1],r=Math.min(this._size[0]-e,q-m),u=[],y=[],v=[0],t=m;tba)throw Error("Size values must be positive integers");return ba}),q){if(pa(q)&&(q=q.toNumber()),!Qa(q)||!Za(q))throw new TypeError("The parameter k must be an integer number");}else q=0;r=n;var y=0;Ia(u)&&(r=k.find(n,[u,u])||n,y=k.convert(0,u));u=0q?-q:0;var v=e[0];e=e[1];var t=Math.min(v-q,e-u);if($b(m)){if(m.length!==t)throw Error("Invalid value array length"); +var w=function(ba){return m[ba]}}else if(Fa(m)){w=m.size();if(1!==w.length||w[0]!==t)throw Error("Invalid matrix length");w=function(ba){return m.get([ba])}}else w=function(){return m};for(var z=[],I=[],F=[],L=0;L=w||u[t]!==m)?(w=r?r[z]:void 0,u.splice(t,0,m),r&&r.splice(t,0,w),u.splice(t<=z?z+1:z,1),r&&r.splice(t<=z?z+1:z,1)):t=w||u[z]!==e)&&(w=r?r[t]:void 0,u.splice(z,0,e),r&&r.splice(z,0,w),u.splice(z<=t?t+1:t,1),r&&r.splice(z<=t?t+1:t,1))}},a},{isClass:!0}),Gm=B("matrix",["typed","Matrix","DenseMatrix","SparseMatrix"],b=>{function a(h,l,p){if("dense"===l||"default"===l||void 0===l)return new c(h,p);if("sparse"===l)return new f(h,p);throw new TypeError("Unknown matrix type "+JSON.stringify(l)+".");}var {typed:d,DenseMatrix:c,SparseMatrix:f}=b;return d("matrix",{"":function(){return a([])},string:function(h){return a([], +h)},"string, string":function(h,l){return a([],h,l)},Array:function(h){return a(h)},Matrix:function(h){return a(h,h.storage())},"Array | Matrix, string":a,"Array | Matrix, string, string":a})}),Hm=B("abs",["typed"],b=>{({typed:b}=b);return b("abs",{number:Hf,Complex:function(a){return a.abs()},BigNumber:function(a){return a.abs()},Fraction:function(a){return a.abs()},"Array | Matrix":function(a){return Na(a,this,!0)},Unit:function(a){return a.abs()}})}),Cd=B("algorithm01",["typed"],b=>{var {typed:a}= +b;return function(d,c,f,h){var l=d._data,p=d._size,k=d._datatype,n=c._values,g=c._index,e=c._ptr,m=c._size;c=c._datatype;if(p.length!==m.length)throw new yb(p.length,m.length);if(p[0]!==m[0]||p[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+m+")");if(!n)throw Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");m=p[0];p=p[1];var q=(k="string"==typeof k&&k===c?k:void 0)?a.find(f,[k,k]):f,r=[];for(f=0;f{var {typed:a,equalScalar:d}=b;return function(c,f,h){var l=c._values,p=c._index,k=c._ptr,n=c._size,g=c._datatype,e=f._values,m=f._index,q=f._ptr,r=f._size,u=f._datatype;if(n.length!==r.length)throw new yb(n.length,r.length);if(n[0]!== +r[0]||n[1]!==r[1])throw new RangeError("Dimension mismatch. Matrix A ("+n+") must match Matrix B ("+r+")");var y;r=n[0];n=n[1];f=d;var v=0,t=h;"string"==typeof g&&g===u&&(y=g,f=a.find(d,[y,y]),v=a.convert(0,y),t=a.find(h,[y,y]));u=l&&e?[]:void 0;var w=[],z=[],I=l&&e?[]:void 0,F=l&&e?[]:void 0,L=[],O=[];for(h=0;h{var {typed:a,DenseMatrix:d}=b;return function(c,f,h,l){var p=c._values,k=c._index,n=c._ptr,g=c._size,e=c._datatype;if(!p)throw Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value"); +var m;c=g[0];g=g[1];var q=h;"string"==typeof e&&(m=e,f=a.convert(f,m),q=a.find(h,[m,m]));h=[];e=[];for(var r=[],u=0;u{function a(c,f,h,l,p,k){var n=[];if(f===h.length-1)for(f=0;f{function a(c, +f,h,l,p,k,n){var g=[];if(f===h.length-1)for(f=0;f{var {typed:a,matrix:d,equalScalar:c, +BigNumber:f,DenseMatrix:h}=b,l=Cd({typed:a}),p=jf({typed:a,equalScalar:c}),k=Qd({typed:a,DenseMatrix:h}),n=fc({typed:a}),g=Tb({typed:a});return a("gcd",{"number, number":Rf,"BigNumber, BigNumber":function(e,m){if(!e.isInt()||!m.isInt())throw Error("Parameters in function gcd must be integer numbers");for(var q=new f(0);!m.isZero();){var r=e.mod(m);e=m;m=r}return e.lt(q)?e.neg():e},"Fraction, Fraction":function(e,m){return e.gcd(m)},"SparseMatrix, SparseMatrix":function(e,m){return p(e,m,this)},"SparseMatrix, DenseMatrix":function(e, +m){return l(m,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,m){return l(e,m,this,!1)},"DenseMatrix, DenseMatrix":function(e,m){return n(e,m,this)},"Array, Array":function(e,m){return this(d(e),d(m)).valueOf()},"Array, Matrix":function(e,m){return this(d(e),m)},"Matrix, Array":function(e,m){return this(e,d(m))},"SparseMatrix, number | BigNumber":function(e,m){return k(e,m,this,!1)},"DenseMatrix, number | BigNumber":function(e,m){return g(e,m,this,!1)},"number | BigNumber, SparseMatrix":function(e, +m){return k(m,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,m){return g(m,e,this,!0)},"Array, number | BigNumber":function(e,m){return g(d(e),m,this,!1).valueOf()},"number | BigNumber, Array":function(e,m){return g(d(m),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,m,q){e=this(e,m);for(m=0;m{var {typed:a, +equalScalar:d}=b;return function(c,f,h,l){var p=c._data,k=c._size,n=c._datatype;c=f._values;var g=f._index,e=f._ptr,m=f._size,q=f._datatype;if(k.length!==m.length)throw new yb(k.length,m.length);if(k[0]!==m[0]||k[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+k+") must match Matrix B ("+m+")");if(!c)throw Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var r;m=k[0];k=k[1];var u=d,y=0,v=h;"string"==typeof n&&n===q&&(r=n,u=a.find(d,[r,r]),y=a.convert(0,r), +v=a.find(h,[r,r]));h=[];n=[];q=[];for(var t=0;t{var {typed:a}=b;return function(d,c,f,h){var l=d._data,p=d._size,k=d._datatype,n=c._values,g=c._index,e=c._ptr,m=c._size,q=c._datatype;if(p.length!==m.length)throw new yb(p.length,m.length);if(p[0]!== +m[0]||p[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+m+")");if(!n)throw Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var r;m=p[0];p=p[1];c=0;var u=f;"string"==typeof k&&k===q&&(r=k,c=a.convert(0,r),u=a.find(f,[r,r]));f=[];for(k=0;k{var {typed:a,equalScalar:d}=b;return function(c,f,h){var l=c._values,p=c._index,k=c._ptr,n=c._size,g=c._datatype,e=f._values,m=f._index,q=f._ptr,r=f._size,u=f._datatype;if(n.length!==r.length)throw new yb(n.length,r.length);if(n[0]!==r[0]||n[1]!==r[1])throw new RangeError("Dimension mismatch. Matrix A ("+n+") must match Matrix B ("+r+")");var y;r=n[0];n=n[1];f=d;var v= +0,t=h;"string"==typeof g&&g===u&&(y=g,f=a.find(d,[y,y]),v=a.convert(0,y),t=a.find(h,[y,y]));var w;u=l&&e?[]:void 0;var z=[],I=[],F=u?[]:void 0,L=u?[]:void 0,O=[],R=[];for(h=0;h{var {typed:a,equalScalar:d}=b;return function(c,f,h,l){var p=c._values,k=c._index,n=c._ptr,g=c._size,e=c._datatype;if(!p)throw Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var m,q=g[0];g=g[1];var r=d,u=0,y=h;"string"==typeof e&&(m=e,r=a.find(d,[m,m]),u=a.convert(0,m),f=a.convert(f,m),y=a.find(h,[m,m]));h=[];e=[];for(var v= +[],t=0;t{var {typed:a,DenseMatrix:d}=b;return function(c,f,h,l){var p=c._values,k=c._index,n=c._ptr,g=c._size,e=c._datatype;if(!p)throw Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var m;c=g[0];g=g[1];var q=h;"string"== +typeof e&&(m=e,f=a.convert(f,m),q=a.find(h,[m,m]));h=[];e=[];for(var r=[],u=0;u{var {typed:a,matrix:d,equalScalar:c,DenseMatrix:f}=b,h=bd({typed:a,equalScalar:c}),l=Nc({typed:a}),p=Le({typed:a,equalScalar:c}),k=Fc({typed:a, +equalScalar:c}),n=Oc({typed:a,DenseMatrix:f}),g=fc({typed:a}),e=Tb({typed:a});return a("mod",{"number, number":Uf,"BigNumber, BigNumber":function(m,q){if(q.isNeg())throw Error("Cannot calculate mod for a negative divisor");return q.isZero()?m:m.mod(q)},"Fraction, Fraction":function(m,q){if(0>q.compare(0))throw Error("Cannot calculate mod for a negative divisor");return 0<=m.compare(0)?m.mod(q):m.mod(q).add(q).mod(q)},"SparseMatrix, SparseMatrix":function(m,q){return p(m,q,this,!1)},"SparseMatrix, DenseMatrix":function(m, +q){return h(q,m,this,!0)},"DenseMatrix, SparseMatrix":function(m,q){return l(m,q,this,!1)},"DenseMatrix, DenseMatrix":function(m,q){return g(m,q,this)},"Array, Array":function(m,q){return this(d(m),d(q)).valueOf()},"Array, Matrix":function(m,q){return this(d(m),q)},"Matrix, Array":function(m,q){return this(m,d(q))},"SparseMatrix, any":function(m,q){return k(m,q,this,!1)},"DenseMatrix, any":function(m,q){return e(m,q,this,!1)},"any, SparseMatrix":function(m,q){return n(q,m,this,!0)},"any, DenseMatrix":function(m, +q){return e(q,m,this,!0)},"Array, any":function(m,q){return e(d(m),q,this,!1).valueOf()},"any, Array":function(m,q){return e(d(q),m,this,!0).valueOf()}})}),Me=B("algorithm06",["typed","equalScalar"],b=>{var {typed:a,equalScalar:d}=b;return function(c,f,h){var l=c._values,p=c._size,k=c._datatype,n=f._values,g=f._size,e=f._datatype;if(p.length!==g.length)throw new yb(p.length,g.length);if(p[0]!==g[0]||p[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+g+")"); +var m;g=p[0];p=p[1];var q=d,r=0,u=h;"string"==typeof k&&k===e&&(m=k,q=a.find(d,[m,m]),r=a.convert(0,m),u=a.find(h,[m,m]));h=l&&n?[]:void 0;l=[];k=[];n=h?[]:void 0;e=[];for(var y=[],v=0;v{function a(m,q){var r=h.precision,u=h.clone({precision:r+2}),y=new h(0),v=new u(1),t=q.isNegative();if(t&&(q=q.neg()),q.isZero())throw Error("Root must be non-zero");if(m.isNegative()&&!q.abs().mod(2).equals(1))throw Error("Root must be odd when a is negative.");if(m.isZero())return t?new u(1/0):0;if(!m.isFinite())return t?y:m;q=m.abs().pow(v.div(q));return q=m.isNeg()?q.neg():q,new h((t?v.div(q):q).toPrecision(r))} +var {typed:d,matrix:c,equalScalar:f,BigNumber:h}=b,l=Cd({typed:d}),p=bd({typed:d,equalScalar:f}),k=Me({typed:d,equalScalar:f}),n=Fc({typed:d,equalScalar:f}),g=fc({typed:d}),e=Tb({typed:d});return d("nthRoot",{number:function(m){return af(m,2)},"number, number":af,BigNumber:function(m){return a(m,new h(2))},Complex:function(m){throw Error("Complex number not supported in function nthRoot. Use nthRoots instead.");},"Complex, number":function(m,q){throw Error("Complex number not supported in function nthRoot. Use nthRoots instead."); +},"BigNumber, BigNumber":a,"Array | Matrix":function(m){return this(m,2)},"SparseMatrix, SparseMatrix":function(m,q){if(1===q.density())return k(m,q,this);throw Error("Root must be non-zero");},"SparseMatrix, DenseMatrix":function(m,q){return p(q,m,this,!0)},"DenseMatrix, SparseMatrix":function(m,q){if(1===q.density())return l(m,q,this,!1);throw Error("Root must be non-zero");},"DenseMatrix, DenseMatrix":function(m,q){return g(m,q,this)},"Array, Array":function(m,q){return this(c(m),c(q)).valueOf()}, +"Array, Matrix":function(m,q){return this(c(m),q)},"Matrix, Array":function(m,q){return this(m,c(q))},"SparseMatrix, number | BigNumber":function(m,q){return n(m,q,this,!1)},"DenseMatrix, number | BigNumber":function(m,q){return e(m,q,this,!1)},"number | BigNumber, SparseMatrix":function(m,q){if(1===q.density())return n(q,m,this,!0);throw Error("Root must be non-zero");},"number | BigNumber, DenseMatrix":function(m,q){return e(q,m,this,!0)},"Array, number | BigNumber":function(m,q){return this(c(m), +q).valueOf()},"number | BigNumber, Array":function(m,q){return this(m,c(q)).valueOf()}})}),Lm=B("xgcd",["typed","config","matrix","BigNumber"],b=>{var {typed:a,config:d,matrix:c,BigNumber:f}=b;return a("xgcd",{"number, number":function(h,l){h=Xf(h,l);return"Array"===d.matrix?h:c(h)},"BigNumber, BigNumber":function(h,l){var p,k=new f(0);var n=new f(1);var g=k,e=n,m=n,q=k;if(!h.isInt()||!l.isInt())throw Error("Parameters in function xgcd must be integer numbers");for(;!l.isZero();){n=h.div(l).floor(); +var r=h.mod(l);h=g;g=e.minus(n.times(g));e=h;h=m;m=q.minus(n.times(m));q=h;h=l;l=r}return p=h.lt(k)?[h.neg(),e.neg(),q.neg()]:[h,h.isZero()?0:e,q],"Array"===d.matrix?p:c(p)}})}),Mm=B("bitAnd",["typed","matrix","equalScalar"],b=>{var {typed:a,matrix:d,equalScalar:c}=b,f=bd({typed:a,equalScalar:c}),h=Me({typed:a,equalScalar:c}),l=Fc({typed:a,equalScalar:c}),p=fc({typed:a}),k=Tb({typed:a});return a("bitAnd",{"number, number":Zf,"BigNumber, BigNumber":zi,"SparseMatrix, SparseMatrix":function(n,g){return h(n, +g,this,!1)},"SparseMatrix, DenseMatrix":function(n,g){return f(g,n,this,!0)},"DenseMatrix, SparseMatrix":function(n,g){return f(n,g,this,!1)},"DenseMatrix, DenseMatrix":function(n,g){return p(n,g,this)},"Array, Array":function(n,g){return this(d(n),d(g)).valueOf()},"Array, Matrix":function(n,g){return this(d(n),g)},"Matrix, Array":function(n,g){return this(n,d(g))},"SparseMatrix, any":function(n,g){return l(n,g,this,!1)},"DenseMatrix, any":function(n,g){return k(n,g,this,!1)},"any, SparseMatrix":function(n, +g){return l(g,n,this,!0)},"any, DenseMatrix":function(n,g){return k(g,n,this,!0)},"Array, any":function(n,g){return k(d(n),g,this,!1).valueOf()},"any, Array":function(n,g){return k(d(g),n,this,!0).valueOf()}})}),kd=B("algorithm07",["typed","DenseMatrix"],b=>{function a(f,h,l,p,k){var n=f._values,g=f._index,e=f._ptr;f=e[h];for(h=e[h+1];f{var {typed:a, +matrix:d,DenseMatrix:c}=b,f=Nc({typed:a}),h=kd({typed:a,DenseMatrix:c}),l=Oc({typed:a,DenseMatrix:c}),p=fc({typed:a}),k=Tb({typed:a});return a("bitXor",{"number, number":bg,"BigNumber, BigNumber":Bi,"SparseMatrix, SparseMatrix":function(n,g){return h(n,g,this)},"SparseMatrix, DenseMatrix":function(n,g){return f(g,n,this,!0)},"DenseMatrix, SparseMatrix":function(n,g){return f(n,g,this,!1)},"DenseMatrix, DenseMatrix":function(n,g){return p(n,g,this)},"Array, Array":function(n,g){return this(d(n),d(g)).valueOf()}, +"Array, Matrix":function(n,g){return this(d(n),g)},"Matrix, Array":function(n,g){return this(n,d(g))},"SparseMatrix, any":function(n,g){return l(n,g,this,!1)},"DenseMatrix, any":function(n,g){return k(n,g,this,!1)},"any, SparseMatrix":function(n,g){return l(g,n,this,!0)},"any, DenseMatrix":function(n,g){return k(g,n,this,!0)},"Array, any":function(n,g){return k(d(n),g,this,!1).valueOf()},"any, Array":function(n,g){return k(d(g),n,this,!0).valueOf()}})}),Om=B("or",["typed","matrix","equalScalar","DenseMatrix"], +b=>{var {typed:a,matrix:d,equalScalar:c,DenseMatrix:f}=b,h=Nc({typed:a}),l=Le({typed:a,equalScalar:c}),p=Oc({typed:a,DenseMatrix:f}),k=fc({typed:a}),n=Tb({typed:a});return a("or",{"number, number":gg,"Complex, Complex":function(g,e){return 0!==g.re||0!==g.im||0!==e.re||0!==e.im},"BigNumber, BigNumber":function(g,e){return!g.isZero()&&!g.isNaN()||!e.isZero()&&!e.isNaN()},"Unit, Unit":function(g,e){return this(g.value||0,e.value||0)},"SparseMatrix, SparseMatrix":function(g,e){return l(g,e,this)},"SparseMatrix, DenseMatrix":function(g, +e){return h(e,g,this,!0)},"DenseMatrix, SparseMatrix":function(g,e){return h(g,e,this,!1)},"DenseMatrix, DenseMatrix":function(g,e){return k(g,e,this)},"Array, Array":function(g,e){return this(d(g),d(e)).valueOf()},"Array, Matrix":function(g,e){return this(d(g),e)},"Matrix, Array":function(g,e){return this(g,d(e))},"SparseMatrix, any":function(g,e){return p(g,e,this,!1)},"DenseMatrix, any":function(g,e){return n(g,e,this,!1)},"any, SparseMatrix":function(g,e){return p(e,g,this,!0)},"any, DenseMatrix":function(g, +e){return n(e,g,this,!0)},"Array, any":function(g,e){return n(d(g),e,this,!1).valueOf()},"any, Array":function(g,e){return n(d(e),g,this,!0).valueOf()}})}),Pm=B("diag",["typed","matrix","DenseMatrix","SparseMatrix"],b=>{function a(l,p,k,n){if(!Za(p))throw new TypeError("Second parameter in function diag must be an integer");var g=0p?-p:0;switch(k.length){case 1:return function(m,q,r,u,y,v){u=[u+y,u+v];if(r&&"sparse"!==r&&"dense"!==r)throw new TypeError("Unknown matrix type ".concat(r,'"')); +m="sparse"===r?h.diagonal(u,m,q):f.diagonal(u,m,q);return null!==r?m:m.valueOf()}(l,p,n,k[0],e,g);case 2:return function(m,q,r,u,y,v){if(Fa(m))return m=m.diagonal(q),null!==r?r!==m.storage()?c(m,r):m:m.valueOf();q=Math.min(u[0]-y,u[1]-v);u=[];for(var t=0;t{function a(n,g){switch(n.length){case 0:return g?h(g):[];case 1:return d(n[0],n[0],g);case 2:return d(n[0],n[1],g);default:throw Error("Vector containing two values expected");}}function d(n, +g,e){var m=pa(n)||pa(g)?l:null;if(pa(n)&&(n=n.toNumber()),pa(g)&&(g=g.toNumber()),!Za(n)||1>n)throw Error("Parameters in function identity must be positive integers");if(!Za(g)||1>g)throw Error("Parameters in function identity must be positive integers");var q=m?new l(1):1;m=m?new m(0):0;var r=[n,g];if(e){if("sparse"===e)return k.diagonal(r,q,0,m);if("dense"===e)return p.diagonal(r,q,0,m);throw new TypeError('Unknown matrix type "'.concat(e,'"'));}e=gd([],r,m);n=n{function a(l,p){var k=function(n){var g=!1;return n.forEach(function(e,m,q){pa(e)&&(g=!0,q[m]=e.toNumber())}),g}(l)?new h(1):1;if(function(n){n.forEach(function(g){if("number"!=typeof g||!Za(g)||0>g)throw Error("Parameters in function ones must be positive integers"); +})}(l),p)return p=f(p),0{var {typed:a,isInteger:d}=b;return a("reshape",{"Matrix, Array":function(c,f){return c.reshape(f)},"Array, Array":function(c,f){return f.forEach(function(h){if(!d(h))throw new TypeError("Invalid size for dimension: "+h);}),Zd(c,f)}})}),Tm=B("size",["typed","config","?matrix"],b=>{var {typed:a,config:d,matrix:c}=b;return a("size",{Matrix:function(f){return f.create(f.size())},Array:Ua,string:function(f){return"Array"===d.matrix?[f.length]:c([f.length])}, +"number | Complex | BigNumber | Unit | boolean | null":function(f){return"Array"===d.matrix?[]:c?c([]):me()}})}),Um=B("zeros",["typed","config","matrix","BigNumber"],b=>{function a(l,p){var k=function(n){var g=!1;return n.forEach(function(e,m,q){pa(e)&&(g=!0,q[m]=e.toNumber())}),g}(l)?new h(0):0;if(function(n){n.forEach(function(g){if("number"!=typeof g||!Za(g)||0>g)throw Error("Parameters in function zeros must be positive integers");})}(l),p)return p=f(p),0{var {typed:a,format:d}=b;return a("hex", +{"number | BigNumber":function(c){return d(c,{notation:"hex"})},"number | BigNumber, number":function(c,f){return d(c,{notation:"hex",wordSize:f})}})}),Xm=B("round","typed matrix equalScalar zeros BigNumber DenseMatrix".split(" "),b=>{var {typed:a,matrix:d,equalScalar:c,zeros:f,BigNumber:h,DenseMatrix:l}=b,p=Fc({typed:a,equalScalar:c}),k=Oc({typed:a,DenseMatrix:l}),n=Tb({typed:a});return a("round",Fg(Fg({},Wm),{},{Complex:function(g){return g.round()},"Complex, number":function(g,e){if(e%1)throw new TypeError("Number of decimals in function round must be an integer"); +return g.round(e)},"Complex, BigNumber":function(g,e){if(!e.isInteger())throw new TypeError("Number of decimals in function round must be an integer");e=e.toNumber();return g.round(e)},"number, BigNumber":function(g,e){if(!e.isInteger())throw new TypeError("Number of decimals in function round must be an integer");return(new h(g)).toDecimalPlaces(e.toNumber())},BigNumber:function(g){return g.toDecimalPlaces(0)},"BigNumber, BigNumber":function(g,e){if(!e.isInteger())throw new TypeError("Number of decimals in function round must be an integer"); +return g.toDecimalPlaces(e.toNumber())},Fraction:function(g){return g.round()},"Fraction, number":function(g,e){if(e%1)throw new TypeError("Number of decimals in function round must be an integer");return g.round(e)},"Array | Matrix":function(g){return Na(g,this,!0)},"SparseMatrix, number | BigNumber":function(g,e){return p(g,e,this,!1)},"DenseMatrix, number | BigNumber":function(g,e){return n(g,e,this,!1)},"number | Complex | BigNumber, SparseMatrix":function(g,e){return c(g,0)?f(e.size(),e.storage()): +k(e,g,this,!0)},"number | Complex | BigNumber, DenseMatrix":function(g,e){return c(g,0)?f(e.size(),e.storage()):n(e,g,this,!0)},"Array, number | BigNumber":function(g,e){return n(d(g),e,this,!1).valueOf()},"number | Complex | BigNumber, Array":function(g,e){return n(d(e),g,this,!0).valueOf()}}))}),Wm={number:bf,"number, number":function(b,a){if(!Za(a))throw new TypeError("Number of decimals in function round must be an integer");if(0>a||15{var {typed:a,equalScalar:d}=b;return function(c,f,h){var l=c._values,p=c._index,k=c._ptr,n=c._size,g=c._datatype,e=f._values,m=f._index,q=f._ptr,r=f._size,u=f._datatype;if(n.length!==r.length)throw new yb(n.length,r.length);if(n[0]!==r[0]||n[1]!==r[1])throw new RangeError("Dimension mismatch. Matrix A ("+n+") must match Matrix B ("+r+")");if(!l||!e)throw Error("Cannot perform operation on Pattern Sparse Matrices");var y;r=n[0];n=n[1]; +f=d;var v=0,t=h;"string"==typeof g&&g===u&&(y=g,f=a.find(d,[y,y]),v=a.convert(0,y),t=a.find(h,[y,y]));var w,z;h=[];g=[];u=[];for(var I=[],F=[],L=0;L{var {typed:a,matrix:d,equalScalar:c,zeros:f,DenseMatrix:h}=b,l=Cd({typed:a}),p=bd({typed:a,equalScalar:c}),k=kf({typed:a,equalScalar:c}),n=Qd({typed:a,DenseMatrix:h}),g=Fc({typed:a,equalScalar:c}),e=fc({typed:a}),m=Tb({typed:a});return a("leftShift",{"number, number":cg,"BigNumber, BigNumber":Ci,"SparseMatrix, SparseMatrix":function(q,r){return k(q,r,this,!1)},"SparseMatrix, DenseMatrix":function(q,r){return p(r,q,this,!0)},"DenseMatrix, SparseMatrix":function(q, +r){return l(q,r,this,!1)},"DenseMatrix, DenseMatrix":function(q,r){return e(q,r,this)},"Array, Array":function(q,r){return this(d(q),d(r)).valueOf()},"Array, Matrix":function(q,r){return this(d(q),r)},"Matrix, Array":function(q,r){return this(q,d(r))},"SparseMatrix, number | BigNumber":function(q,r){return c(r,0)?q.clone():g(q,r,this,!1)},"DenseMatrix, number | BigNumber":function(q,r){return c(r,0)?q.clone():m(q,r,this,!1)},"number | BigNumber, SparseMatrix":function(q,r){return c(q,0)?f(r.size(), +r.storage()):n(r,q,this,!0)},"number | BigNumber, DenseMatrix":function(q,r){return c(q,0)?f(r.size(),r.storage()):m(r,q,this,!0)},"Array, number | BigNumber":function(q,r){return this(d(q),r).valueOf()},"number | BigNumber, Array":function(q,r){return this(q,d(r)).valueOf()}})}),Zm=B("rightLogShift",["typed","matrix","equalScalar","zeros","DenseMatrix"],b=>{var {typed:a,matrix:d,equalScalar:c,zeros:f,DenseMatrix:h}=b,l=Cd({typed:a}),p=bd({typed:a,equalScalar:c}),k=kf({typed:a,equalScalar:c}),n=Qd({typed:a, +DenseMatrix:h}),g=Fc({typed:a,equalScalar:c}),e=fc({typed:a}),m=Tb({typed:a});return a("rightLogShift",{"number, number":eg,"SparseMatrix, SparseMatrix":function(q,r){return k(q,r,this,!1)},"SparseMatrix, DenseMatrix":function(q,r){return p(r,q,this,!0)},"DenseMatrix, SparseMatrix":function(q,r){return l(q,r,this,!1)},"DenseMatrix, DenseMatrix":function(q,r){return e(q,r,this)},"Array, Array":function(q,r){return this(d(q),d(r)).valueOf()},"Array, Matrix":function(q,r){return this(d(q),r)},"Matrix, Array":function(q, +r){return this(q,d(r))},"SparseMatrix, number | BigNumber":function(q,r){return c(r,0)?q.clone():g(q,r,this,!1)},"DenseMatrix, number | BigNumber":function(q,r){return c(r,0)?q.clone():m(q,r,this,!1)},"number | BigNumber, SparseMatrix":function(q,r){return c(q,0)?f(r.size(),r.storage()):n(r,q,this,!0)},"number | BigNumber, DenseMatrix":function(q,r){return c(q,0)?f(r.size(),r.storage()):m(r,q,this,!0)},"Array, number | BigNumber":function(q,r){return this(d(q),r).valueOf()},"number | BigNumber, Array":function(q, +r){return this(q,d(r)).valueOf()}})}),$m=B("compare","typed config matrix equalScalar BigNumber Fraction DenseMatrix".split(" "),b=>{var {typed:a,config:d,equalScalar:c,matrix:f,BigNumber:h,Fraction:l,DenseMatrix:p}=b,k=Nc({typed:a}),n=Le({typed:a,equalScalar:c}),g=Oc({typed:a,DenseMatrix:p}),e=fc({typed:a}),m=Tb({typed:a});return a("compare",{"boolean, boolean":function(q,r){return q===r?0:q>r?1:-1},"number, number":function(q,r){return Ec(q,r,d.epsilon)?0:q>r?1:-1},"BigNumber, BigNumber":function(q, +r){return jd(q,r,d.epsilon)?new h(0):new h(q.cmp(r))},"Fraction, Fraction":function(q,r){return new l(q.compare(r))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers");},"Unit, Unit":function(q,r){if(!q.equalBase(r))throw Error("Cannot compare units with different base");return this(q.value,r.value)},"SparseMatrix, SparseMatrix":function(q,r){return n(q,r,this)},"SparseMatrix, DenseMatrix":function(q,r){return k(r,q,this,!0)},"DenseMatrix, SparseMatrix":function(q, +r){return k(q,r,this,!1)},"DenseMatrix, DenseMatrix":function(q,r){return e(q,r,this)},"Array, Array":function(q,r){return this(f(q),f(r)).valueOf()},"Array, Matrix":function(q,r){return this(f(q),r)},"Matrix, Array":function(q,r){return this(q,f(r))},"SparseMatrix, any":function(q,r){return g(q,r,this,!1)},"DenseMatrix, any":function(q,r){return m(q,r,this,!1)},"any, SparseMatrix":function(q,r){return g(r,q,this,!0)},"any, DenseMatrix":function(q,r){return m(r,q,this,!0)},"Array, any":function(q, +r){return m(f(q),r,this,!1).valueOf()},"any, Array":function(q,r){return m(f(r),q,this,!0).valueOf()}})}),an=B("compareText",["typed","matrix"],b=>{var {typed:a,matrix:d}=b,c=fc({typed:a}),f=Tb({typed:a});return a("compareText",{"any, any":wc,"DenseMatrix, DenseMatrix":function(h,l){return c(h,l,wc)},"Array, Array":function(h,l){return this(d(h),d(l)).valueOf()},"Array, Matrix":function(h,l){return this(d(h),l)},"Matrix, Array":function(h,l){return this(h,d(l))},"DenseMatrix, any":function(h,l){return f(h, +l,wc,!1)},"any, DenseMatrix":function(h,l){return f(l,h,wc,!0)},"Array, any":function(h,l){return f(d(h),l,wc,!1).valueOf()},"any, Array":function(h,l){return f(d(l),h,wc,!0).valueOf()}})}),bn=B("smaller",["typed","config","matrix","DenseMatrix"],b=>{var {typed:a,config:d,matrix:c,DenseMatrix:f}=b,h=Nc({typed:a}),l=kd({typed:a,DenseMatrix:f}),p=Oc({typed:a,DenseMatrix:f}),k=fc({typed:a}),n=Tb({typed:a});return a("smaller",{"boolean, boolean":function(g,e){return g{var {typed:a,config:d,matrix:c,DenseMatrix:f}=b,h=Nc({typed:a}),l=kd({typed:a,DenseMatrix:f}),p=Oc({typed:a,DenseMatrix:f}),k=fc({typed:a}),n=Tb({typed:a});return a("larger",{"boolean, boolean":function(g,e){return g>e},"number, number":function(g,e){return g>e&&!Ec(g,e,d.epsilon)},"BigNumber, BigNumber":function(g, +e){return g.gt(e)&&!jd(g,e,d.epsilon)},"Fraction, Fraction":function(g,e){return 1===g.compare(e)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers");},"Unit, Unit":function(g,e){if(!g.equalBase(e))throw Error("Cannot compare units with different base");return this(g.value,e.value)},"SparseMatrix, SparseMatrix":function(g,e){return l(g,e,this)},"SparseMatrix, DenseMatrix":function(g,e){return h(e,g,this,!0)},"DenseMatrix, SparseMatrix":function(g, +e){return h(g,e,this,!1)},"DenseMatrix, DenseMatrix":function(g,e){return k(g,e,this)},"Array, Array":function(g,e){return this(c(g),c(e)).valueOf()},"Array, Matrix":function(g,e){return this(c(g),e)},"Matrix, Array":function(g,e){return this(g,c(e))},"SparseMatrix, any":function(g,e){return p(g,e,this,!1)},"DenseMatrix, any":function(g,e){return n(g,e,this,!1)},"any, SparseMatrix":function(g,e){return p(e,g,this,!0)},"any, DenseMatrix":function(g,e){return n(e,g,this,!0)},"Array, any":function(g, +e){return n(c(g),e,this,!1).valueOf()},"any, Array":function(g,e){return n(c(e),g,this,!0).valueOf()}})}),dn=B("unequal",["typed","config","equalScalar","matrix","DenseMatrix"],b=>{function a(e,m){return!c(e,m)}var {typed:d,equalScalar:c,matrix:f,DenseMatrix:h}=b,l=Nc({typed:d}),p=kd({typed:d,DenseMatrix:h}),k=Oc({typed:d,DenseMatrix:h}),n=fc({typed:d}),g=Tb({typed:d});return d("unequal",{"any, any":function(e,m){return null===e?null!==m:null===m?null!==e:void 0===e?void 0!==m:void 0===m?void 0!== +e:!c(e,m)},"SparseMatrix, SparseMatrix":function(e,m){return p(e,m,a)},"SparseMatrix, DenseMatrix":function(e,m){return l(m,e,a,!0)},"DenseMatrix, SparseMatrix":function(e,m){return l(e,m,a,!1)},"DenseMatrix, DenseMatrix":function(e,m){return n(e,m,a)},"Array, Array":function(e,m){return this(f(e),f(m)).valueOf()},"Array, Matrix":function(e,m){return this(f(e),m)},"Matrix, Array":function(e,m){return this(e,f(m))},"SparseMatrix, any":function(e,m){return k(e,m,a,!1)},"DenseMatrix, any":function(e, +m){return g(e,m,a,!1)},"any, SparseMatrix":function(e,m){return k(m,e,a,!0)},"any, DenseMatrix":function(e,m){return g(m,e,a,!0)},"Array, any":function(e,m){return g(f(e),m,a,!1).valueOf()},"any, Array":function(e,m){return g(f(m),e,a,!0).valueOf()}})}),en=(B("unequal",["typed","equalScalar"],b=>{var {typed:a,equalScalar:d}=b;return a("unequal",{"any, any":function(c,f){return null===c?null!==f:null===f?null!==c:void 0===c?void 0!==f:void 0===f?void 0!==c:!d(c,f)}})}),B("ImmutableDenseMatrix",["smaller", +"DenseMatrix"],b=>{function a(f,h){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(h&&!Ia(h))throw Error("Invalid datatype: "+h);if(Fa(f)||$b(f))f=new c(f,h),this._data=f._data,this._size=f._size,this._datatype=f._datatype,this._max=this._min=null;else if(f&&$b(f.data)&&$b(f.size))this._data=f.data,this._size=f.size,this._datatype=f.datatype,this._min=void 0!==f.min?f.min:null,this._max=void 0!==f.max?f.max:null;else{if(f)throw new TypeError("Unsupported type of data ("+ +Wb(f)+")");this._data=[];this._size=[0];this._datatype=h;this._max=this._min=null}}var {smaller:d,DenseMatrix:c}=b;return a.prototype=new c,a.prototype.type="ImmutableDenseMatrix",a.prototype.isImmutableDenseMatrix=!0,a.prototype.subset=function(f){switch(arguments.length){case 1:var h=c.prototype.subset.call(this,f);return Fa(h)?new a({data:h._data,size:h._size,datatype:h._datatype}):h;case 2:case 3:throw Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments"); +}},a.prototype.set=function(){throw Error("Cannot invoke set on an Immutable Matrix instance");},a.prototype.resize=function(){throw Error("Cannot invoke resize on an Immutable Matrix instance");},a.prototype.reshape=function(){throw Error("Cannot invoke reshape on an Immutable Matrix instance");},a.prototype.clone=function(){return new a({data:nb(this._data),size:nb(this._size),datatype:this._datatype})},a.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size, +datatype:this._datatype}},a.fromJSON=function(f){return new a(f)},a.prototype.swapRows=function(){throw Error("Cannot invoke swapRows on an Immutable Matrix instance");},a.prototype.min=function(){if(null===this._min){var f=null;this.forEach(function(h){(null===f||d(h,f))&&(f=h)});this._min=null!==f?f:void 0}return this._min},a.prototype.max=function(){if(null===this._max){var f=null;this.forEach(function(h){(null===f||d(f,h))&&(f=h)});this._max=null!==f?f:void 0}return this._max},a},{isClass:!0})), +fn=B("FibonacciHeap",["smaller","larger"],b=>{function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null;this._size=0}function d(p,k,n){k.left.right=k.right;k.right.left=k.left;n.degree--;n.child===k&&(n.child=k.right);0===n.degree&&(n.child=null);k.left=p;k.right=p.right;p.right=k;k.right.left=k;k.parent=null;k.mark=!1}function c(p,k){var n=k.parent;n&&(k.mark?(d(p,k,n),c(n)):k.mark=!0)}var {smaller:f,larger:h}=b,l=1/Math.log((1+ +Math.sqrt(5))/2);a.prototype.type="FibonacciHeap";a.prototype.isFibonacciHeap=!0;a.prototype.insert=function(p,k){k={key:p,value:k,degree:0};if(this._minimum){var n=this._minimum;k.left=n;k.right=n.right;n.right=k;k.right.left=k;f(p,n.key)&&(this._minimum=k)}else k.left=k,this._minimum=k.right=k;return this._size++,k};a.prototype.size=function(){return this._size};a.prototype.clear=function(){this._minimum=null;this._size=0};a.prototype.isEmpty=function(){return 0===this._size};a.prototype.extractMinimum= +function(){var p=this._minimum;if(null===p)return p;for(var k=this._minimum,n=p.degree,g=p.child;0{var {typed:a,SparseMatrix:d}=b;return a("sparse",{"":function(){return new d([])},string:function(c){return new d([],c)},"Array | Matrix":function(c){return new d(c)},"Array | Matrix, string":function(c,f){return new d(c,f)}})}),hn=B("acoth",["typed","config","Complex","BigNumber"],b=>{var {typed:a,config:d,Complex:c,BigNumber:f}=b;return a("acoth", +{number:function(h){return 1<=h||-1>=h||d.predictable?mg(h):(new c(h,0)).acoth()},Complex:function(h){return h.acoth()},BigNumber:function(h){return(new f(1)).div(h).atanh()},"Array | Matrix":function(h){return Na(h,this)}})}),ih=B("algorithm09",["typed","equalScalar"],b=>{var {typed:a,equalScalar:d}=b;return function(c,f,h){var l=c._values,p=c._index,k=c._ptr,n=c._size,g=c._datatype,e=f._values,m=f._index,q=f._ptr,r=f._size,u=f._datatype;if(n.length!==r.length)throw new yb(n.length,r.length);if(n[0]!== +r[0]||n[1]!==r[1])throw new RangeError("Dimension mismatch. Matrix A ("+n+") must match Matrix B ("+r+")");var y;r=n[0];n=n[1];f=d;var v=0,t=h;"string"==typeof g&&g===u&&(y=g,f=a.find(d,[y,y]),v=a.convert(0,y),t=a.find(h,[y,y]));var w;u=l&&e?[]:void 0;var z=[],I=[],F=u?[]:void 0,L=[];for(h=0;h{var {typed:a,matrix:d,equalScalar:c,BigNumber:f,DenseMatrix:h}=b,l=bd({typed:a,equalScalar:c}),p=Nc({typed:a}),k=ih({typed:a,equalScalar:c}),n=Fc({typed:a,equalScalar:c}),g=Oc({typed:a,DenseMatrix:h}),e=fc({typed:a}),m=Tb({typed:a});return a("atan2",{"number, number":Math.atan2,"BigNumber, BigNumber":function(q,r){return f.atan2(q,r)},"SparseMatrix, SparseMatrix":function(q, +r){return k(q,r,this,!1)},"SparseMatrix, DenseMatrix":function(q,r){return l(r,q,this,!0)},"DenseMatrix, SparseMatrix":function(q,r){return p(q,r,this,!1)},"DenseMatrix, DenseMatrix":function(q,r){return e(q,r,this)},"Array, Array":function(q,r){return this(d(q),d(r)).valueOf()},"Array, Matrix":function(q,r){return this(d(q),r)},"Matrix, Array":function(q,r){return this(q,d(r))},"SparseMatrix, number | BigNumber":function(q,r){return n(q,r,this,!1)},"DenseMatrix, number | BigNumber":function(q,r){return m(q, +r,this,!1)},"number | BigNumber, SparseMatrix":function(q,r){return g(r,q,this,!0)},"number | BigNumber, DenseMatrix":function(q,r){return m(r,q,this,!0)},"Array, number | BigNumber":function(q,r){return m(d(q),r,this,!1).valueOf()},"number | BigNumber, Array":function(q,r){return m(d(r),q,this,!0).valueOf()}})}),kn=B("sec",["typed","BigNumber"],b=>{var {typed:a,BigNumber:d}=b;return a("sec",{number:wg,Complex:function(c){return c.sec()},BigNumber:function(c){return(new d(1)).div(c.cos())},Unit:function(c){if(!c.hasBase(c.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle"); +return this(c.value)},"Array | Matrix":function(c){return Na(c,this)}})}),ln=B("add","typed matrix addScalar equalScalar DenseMatrix SparseMatrix".split(" "),b=>{var {typed:a,matrix:d,addScalar:c,equalScalar:f,DenseMatrix:h}=b,l=Cd({typed:a}),p=jf({typed:a,equalScalar:f}),k=Qd({typed:a,DenseMatrix:h}),n=fc({typed:a}),g=Tb({typed:a});return a("add",xd({"DenseMatrix, DenseMatrix":function(e,m){return n(e,m,c)},"DenseMatrix, SparseMatrix":function(e,m){return l(e,m,c,!1)},"SparseMatrix, DenseMatrix":function(e, +m){return l(m,e,c,!0)},"SparseMatrix, SparseMatrix":function(e,m){return p(e,m,c)},"Array, Array":function(e,m){return this(d(e),d(m)).valueOf()},"Array, Matrix":function(e,m){return this(d(e),m)},"Matrix, Array":function(e,m){return this(e,d(m))},"DenseMatrix, any":function(e,m){return g(e,m,c,!1)},"SparseMatrix, any":function(e,m){return k(e,m,c,!1)},"any, DenseMatrix":function(e,m){return g(m,e,c,!0)},"any, SparseMatrix":function(e,m){return k(m,e,c,!0)},"Array, any":function(e,m){return g(d(e), +m,c,!1).valueOf()},"any, Array":function(e,m){return g(d(m),e,c,!0).valueOf()},"any, any":c,"any, any, ...any":function(e,m,q){e=this(e,m);for(m=0;m{function a(k,n){k=d(k);var g=d(n);if(1!==k.length&&(2!==k.length||1!==k[1]))throw new RangeError("Expected a column vector, instead got a matrix of size ("+k.join(", ")+")");n=k[0];if(1!==g.length&&(2!==g.length||1!==g[1]))throw new RangeError("Expected a column vector, instead got a matrix of size ("+ +g.join(", ")+")");k=g[0];if(n!==k)throw new RangeError("Vectors must have equal length ("+n+" != "+k+")");if(0===n)throw new RangeError("Cannot calculate the dot product of empty vectors");return n}function d(k){return Fa(k)?k.size():p(k)}var {typed:c,addScalar:f,multiplyScalar:h,conj:l,size:p}=b;return c("dot",{"Array | DenseMatrix, Array | DenseMatrix":function(k,n){var g=a(k,n),e=Fa(k)?k._data:k,m=Fa(k)?k._datatype:void 0,q=Fa(n)?n._data:n,r=Fa(n)?n._datatype:void 0,u=2===d(k).length,y=2===d(n).length; +n=f;k=h;m&&r&&m===r&&"string"==typeof m&&(n=c.find(f,[m,m]),k=c.find(h,[m,m]));if(!u&&!y){m=k(l(e[0]),q[0]);for(r=1;ry?r++:u===y&&(m=f(m,h(k[q],n[r])),q++,r++)}return m}})}),nn=B("composition","typed addScalar combinations isNegative isPositive isInteger larger".split(" "),b=>{var {typed:a,addScalar:d,combinations:c,isPositive:f,isInteger:h,larger:l}=b;return a("composition",{"number | BigNumber, number | BigNumber":function(p,k){if(!(h(p)&&f(p)&&h(k)&&f(k)))throw new TypeError("Positive integer value expected in function composition"); +if(l(k,p))throw new TypeError("k must be less than or equal to n in function composition");return c(d(p,-1),d(k,-1))}})}),on=B("isZero",["typed"],b=>{({typed:b}=b);return b("isZero",{number:Ff,BigNumber:function(a){return a.isZero()},Complex:function(a){return 0===a.re&&0===a.im},Fraction:function(a){return 1===a.d&&0===a.n},Unit:function(a){return this(a.value)},"Array | Matrix":function(a){return Na(a,this)}})}),pn=B("matrixFromFunction",["typed","matrix","isZero"],b=>{function a(h,l,p,k){var n; +return(n=void 0!==k?c(p,k):c(p)).resize(h),n.forEach(function(g,e){g=l(e);f(g)||n.set(e,g)}),n}var {typed:d,matrix:c,isZero:f}=b;return d("matrixFromFunction",{"Array | Matrix, function, string, string":function(h,l,p,k){return a(h,l,p,k)},"Array | Matrix, function, string":function(h,l,p){return a(h,l,p)},"Matrix, function":function(h,l){return a(h,l,"dense")},"Array, function":function(h,l){return a(h,l,"dense").toArray()},"Array | Matrix, string, function":function(h,l,p){return a(h,p,l)},"Array | Matrix, string, string, function":function(h, +l,p,k){return a(h,k,l,p)}})}),qn=B("cbrt","config typed isNegative unaryMinus matrix Complex BigNumber Fraction".split(" "),b=>{function a(g,e){var m=g.arg()/3;g=g.abs();var q=(new p(Ie(g),0)).mul((new p(0,m)).exp());return e?(e=[q,(new p(Ie(g),0)).mul((new p(0,m+2*Math.PI/3)).exp()),(new p(Ie(g),0)).mul((new p(0,m-2*Math.PI/3)).exp())],"Array"===d.matrix?e:l(e)):q}var {config:d,typed:c,isNegative:f,unaryMinus:h,matrix:l,Complex:p,BigNumber:k,Fraction:n}=b;return c("cbrt",{number:Mf,Complex:a,"Complex, boolean":a, +BigNumber:function(g){return g.cbrt()},Unit:function(g){if(g.value&&rb(g.value)){var e=g.clone();return e.value=1,(e=e.pow(1/3)).value=a(g.value),e}(e=f(g.value))&&(g.value=h(g.value));var m=pa(g.value)?(new k(1)).div(3):Ob(g.value)?new n(1,3):1/3;g=g.pow(m);return e&&(g.value=h(g.value)),g},"Array | Matrix":function(g){return Na(g,this,!0)}})}),rn=B("floor",["typed","config","round","matrix","equalScalar"],b=>{var {typed:a,config:d,round:c,matrix:f,equalScalar:h}=b,l=Fc({typed:a,equalScalar:h}), +p=Tb({typed:a});return a("floor",{number:function(k){return Ec(k,c(k),d.epsilon)?c(k):Math.floor(k)},"number, number":function(k,n){if(Ec(k,c(k,n),d.epsilon))return c(k,n);var [g,e]="".concat(k,"e").split("e");k=Math.floor(Number("".concat(g,"e").concat(Number(e)+n)));k="".concat(k,"e").split("e");[g,e]=k;return Number("".concat(g,"e").concat(Number(e)-n))},Complex:function(k){return k.floor()},"Complex, number":function(k,n){return k.floor(n)},BigNumber:function(k){return jd(k,c(k),d.epsilon)?c(k): +k.floor()},"BigNumber, BigNumber":function(k,n){return jd(k,c(k,n),d.epsilon)?c(k,n):k.toDecimalPlaces(n.toNumber(),hf.ROUND_FLOOR)},Fraction:function(k){return k.floor()},"Fraction, number":function(k,n){return k.floor(n)},"Array | Matrix":function(k){return Na(k,this,!0)},"Array | Matrix, number":function(k,n){return Na(k,g=>this(g,n),!0)},"SparseMatrix, number | BigNumber":function(k,n){return l(k,n,this,!1)},"DenseMatrix, number | BigNumber":function(k,n){return p(k,n,this,!1)},"number | Complex | BigNumber, Array":function(k, +n){return p(f(n),k,this,!0).valueOf()}})}),sn=B("multiply","typed matrix addScalar multiplyScalar equalScalar dot".split(" "),b=>{function a(m,q){switch(m.length){case 1:switch(q.length){case 1:if(m[0]!==q[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(m[0]!==q[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+m[0]+") must match Matrix rows ("+q[0]+")");break;default:throw Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+ +q.length+" dimensions)");}break;case 2:switch(q.length){case 1:if(m[1]!==q[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+m[1]+") must match Vector length ("+q[0]+")");break;case 2:if(m[1]!==q[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+m[1]+") must match Matrix B rows ("+q[0]+")");break;default:throw Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+q.length+" dimensions)");}break;default:throw Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+ +m.length+" dimensions)");}}var {typed:d,matrix:c,addScalar:f,multiplyScalar:h,equalScalar:l,dot:p}=b,k=Fc({typed:d,equalScalar:l}),n=Tb({typed:d}),g=d("_multiplyMatrixVector",{"DenseMatrix, any":function(m,q){var r,u=m._data,y=m._size,v=m._datatype,t=q._data,w=q._datatype;q=y[0];y=y[1];var z=f,I=h;v&&w&&v===w&&"string"==typeof v&&(r=v,z=d.find(f,[r,r]),I=d.find(h,[r,r]));v=[];for(w=0;wca)for(var Ea=0,Ga=0;Ga{var {typed:a,matrix:d,equalScalar:c,multiplyScalar:f}=b,h=bd({typed:a,equalScalar:c}),l=ih({typed:a,equalScalar:c}),p=Fc({typed:a,equalScalar:c}),k=fc({typed:a}),n=Tb({typed:a});return a("dotMultiply",{"any, any":f,"SparseMatrix, SparseMatrix":function(g,e){return l(g,e,f,!1)},"SparseMatrix, DenseMatrix":function(g, +e){return h(e,g,f,!0)},"DenseMatrix, SparseMatrix":function(g,e){return h(g,e,f,!1)},"DenseMatrix, DenseMatrix":function(g,e){return k(g,e,f)},"Array, Array":function(g,e){return this(d(g),d(e)).valueOf()},"Array, Matrix":function(g,e){return this(d(g),e)},"Matrix, Array":function(g,e){return this(g,d(e))},"SparseMatrix, any":function(g,e){return p(g,e,f,!1)},"DenseMatrix, any":function(g,e){return n(g,e,f,!1)},"any, SparseMatrix":function(g,e){return p(e,g,f,!0)},"any, DenseMatrix":function(g,e){return n(e, +g,f,!0)},"Array, any":function(g,e){return n(d(g),e,f,!1).valueOf()},"any, Array":function(g,e){return n(d(e),g,f,!0).valueOf()}})}),un=B("re",["typed"],b=>{({typed:b}=b);return b("re",{number:function(a){return a},BigNumber:function(a){return a},Fraction:function(a){return a},Complex:function(a){return a.re},"Array | Matrix":function(a){return Na(a,this)}})}),vn=B("flatten",["typed","matrix"],b=>{var {typed:a,matrix:d}=b;return a("flatten",{Array:function(c){return C(nb(c))},Matrix:function(c){c= +C(nb(c.toArray()));return d(c)}})});be.prototype=Error();be.prototype.constructor=Error;be.prototype.name="ArgumentsError";be.prototype.isArgumentsError=!0;var wn=B("resize",["config","matrix"],b=>{function a(f,h,l){if(void 0!==l){if("string"!=typeof l||1!==l.length)throw new TypeError("Single character expected as defaultValue");}else l=" ";if(1!==h.length)throw new yb(h.length,1);var p=h[0];if("number"!=typeof p||!Za(p))throw new TypeError("Invalid size, must contain positive integers (size: "+ +Db(h)+")");if(f.length>p)return f.substring(0,p);if(f.length{var {typed:a,matrix:d}=b;return a("squeeze",{Array:function(c){return Ba(nb(c))},Matrix:function(c){c=Ba(c.toArray());return Array.isArray(c)?d(c):c},any:function(c){return nb(c)}})}),yn=B("to",["typed","matrix"],b=>{var {typed:a,matrix:d}=b,c=fc({typed:a}),f=Tb({typed:a});return a("to",{"Unit, Unit | string":function(h,l){return h.to(l)},"Matrix, Matrix":function(h,l){return c(h, +l,this)},"Array, Array":function(h,l){return this(d(h),d(l)).valueOf()},"Array, Matrix":function(h,l){return this(d(h),l)},"Matrix, Array":function(h,l){return this(h,d(l))},"Matrix, any":function(h,l){return f(h,l,this,!1)},"any, Matrix":function(h,l){return f(l,h,this,!0)},"Array, any":function(h,l){return f(d(h),l,this,!1).valueOf()},"any, Array":function(h,l){return f(d(l),h,this,!0).valueOf()}})}),zn=B("pow","typed config identity multiply matrix fraction number Complex".split(" "),b=>{function a(m, +q){if(h.predictable&&!Za(q)&&0>m)try{var r=g(q),u=n(r);if((q===u||1E-14>Math.abs((q-u)/q))&&1==r.d%2)return(0==r.n%2?1:-1)*Math.pow(-m,q)}catch(y){}return h.predictable&&(-1>m&&q===1/0||-1m&&q===-1/0)?NaN:Za(q)||0<=m||h.predictable?Yf(m,q):1>m*m&&q===1/0||1q)throw new TypeError("For A^b, b must be a positive integer (value is "+q+")");var r=Ua(m);if(2!==r.length)throw Error("For A^b, A must be 2 dimensional (A has "+r.length+ +" dimensions)");if(r[0]!==r[1])throw Error("For A^b, A must be square (size is "+r[0]+"x"+r[1]+")");for(r=l(r[0]).valueOf();1<=q;)1==(1&q)&&(r=p(m,r)),q>>=1,m=p(m,m);return r}function c(m,q){return k(d(m.valueOf(),q))}var {typed:f,config:h,identity:l,multiply:p,matrix:k,number:n,fraction:g,Complex:e}=b;return f("pow",{"number, number":a,"Complex, Complex":function(m,q){return m.pow(q)},"BigNumber, BigNumber":function(m,q){return q.isInteger()||0<=m||h.predictable?m.pow(q):(new e(m.toNumber(),0)).pow(q.toNumber(), +0)},"Fraction, Fraction":function(m,q){var r=m.pow(q);if(null!=r)return r;if(h.predictable)throw Error("Result of pow is non-rational and cannot be expressed as a fraction");return a(m.valueOf(),q.valueOf())},"Array, number":d,"Array, BigNumber":function(m,q){return d(m,q.toNumber())},"Matrix, number":c,"Matrix, BigNumber":function(m,q){return c(m,q.toNumber())},"Unit, number | BigNumber":function(m,q){return m.pow(q)}})}),An=B("dotPow",["typed","equalScalar","matrix","pow","DenseMatrix"],b=>{var {typed:a, +equalScalar:d,matrix:c,pow:f,DenseMatrix:h}=b,l=Nc({typed:a}),p=kd({typed:a,DenseMatrix:h}),k=Fc({typed:a,equalScalar:d}),n=Oc({typed:a,DenseMatrix:h}),g=fc({typed:a}),e=Tb({typed:a});return a("dotPow",{"any, any":f,"SparseMatrix, SparseMatrix":function(m,q){return p(m,q,f,!1)},"SparseMatrix, DenseMatrix":function(m,q){return l(q,m,f,!0)},"DenseMatrix, SparseMatrix":function(m,q){return l(m,q,f,!1)},"DenseMatrix, DenseMatrix":function(m,q){return g(m,q,f)},"Array, Array":function(m,q){return this(c(m), +c(q)).valueOf()},"Array, Matrix":function(m,q){return this(c(m),q)},"Matrix, Array":function(m,q){return this(m,c(q))},"SparseMatrix, any":function(m,q){return k(m,q,this,!1)},"DenseMatrix, any":function(m,q){return e(m,q,this,!1)},"any, SparseMatrix":function(m,q){return n(q,m,this,!0)},"any, DenseMatrix":function(m,q){return e(q,m,this,!0)},"Array, any":function(m,q){return e(c(m),q,this,!1).valueOf()},"any, Array":function(m,q){return e(c(q),m,this,!0).valueOf()}})}),Bn=B("rightArithShift",["typed", +"matrix","equalScalar","zeros","DenseMatrix"],b=>{var {typed:a,matrix:d,equalScalar:c,zeros:f,DenseMatrix:h}=b,l=Cd({typed:a}),p=bd({typed:a,equalScalar:c}),k=kf({typed:a,equalScalar:c}),n=Qd({typed:a,DenseMatrix:h}),g=Fc({typed:a,equalScalar:c}),e=fc({typed:a}),m=Tb({typed:a});return a("rightArithShift",{"number, number":dg,"BigNumber, BigNumber":Di,"SparseMatrix, SparseMatrix":function(q,r){return k(q,r,this,!1)},"SparseMatrix, DenseMatrix":function(q,r){return p(r,q,this,!0)},"DenseMatrix, SparseMatrix":function(q, +r){return l(q,r,this,!1)},"DenseMatrix, DenseMatrix":function(q,r){return e(q,r,this)},"Array, Array":function(q,r){return this(d(q),d(r)).valueOf()},"Array, Matrix":function(q,r){return this(d(q),r)},"Matrix, Array":function(q,r){return this(q,d(r))},"SparseMatrix, number | BigNumber":function(q,r){return c(r,0)?q.clone():g(q,r,this,!1)},"DenseMatrix, number | BigNumber":function(q,r){return c(r,0)?q.clone():m(q,r,this,!1)},"number | BigNumber, SparseMatrix":function(q,r){return c(q,0)?f(r.size(), +r.storage()):n(r,q,this,!0)},"number | BigNumber, DenseMatrix":function(q,r){return c(q,0)?f(r.size(),r.storage()):m(r,q,this,!0)},"Array, number | BigNumber":function(q,r){return this(d(q),r).valueOf()},"number | BigNumber, Array":function(q,r){return this(q,d(r)).valueOf()}})}),ee=jb(228),Cn=B("compareNatural",["typed","compare"],b=>{function a(l,p,k){return H(p)&&H(k)?d(l,p.toJSON().values,k.toJSON().values):H(p)?a(l,p.toArray(),k):H(k)?a(l,p,k.toArray()):D(p)?a(l,p.toJSON().data,k):D(k)?a(l,p, +k.toJSON().data):Array.isArray(p)?Array.isArray(k)?d(l,p,k):a(l,p,[k]):a(l,[p],k)}function d(l,p,k){for(var n=0,g=Math.min(p.length,k.length);nk.length?1:p.lengthp.re?1:l.rep.im?1:l.im{var {typed:a,compareText:d,isZero:c}=b;return a("equalText",{"any, any":function(f,h){return c(d(f,h))}})}),En=B("largerEq",["typed","config","matrix","DenseMatrix"],b=>{var {typed:a,config:d,matrix:c,DenseMatrix:f}=b,h=Nc({typed:a}),l=kd({typed:a,DenseMatrix:f}),p=Oc({typed:a,DenseMatrix:f}), +k=fc({typed:a}),n=Tb({typed:a});return a("largerEq",{"boolean, boolean":function(g,e){return g>=e},"number, number":function(g,e){return g>=e||Ec(g,e,d.epsilon)},"BigNumber, BigNumber":function(g,e){return g.gte(e)||jd(g,e,d.epsilon)},"Fraction, Fraction":function(g,e){return-1!==g.compare(e)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers");},"Unit, Unit":function(g,e){if(!g.equalBase(e))throw Error("Cannot compare units with different base"); +return this(g.value,e.value)},"SparseMatrix, SparseMatrix":function(g,e){return l(g,e,this)},"SparseMatrix, DenseMatrix":function(g,e){return h(e,g,this,!0)},"DenseMatrix, SparseMatrix":function(g,e){return h(g,e,this,!1)},"DenseMatrix, DenseMatrix":function(g,e){return k(g,e,this)},"Array, Array":function(g,e){return this(c(g),c(e)).valueOf()},"Array, Matrix":function(g,e){return this(c(g),e)},"Matrix, Array":function(g,e){return this(g,c(e))},"SparseMatrix, any":function(g,e){return p(g,e,this, +!1)},"DenseMatrix, any":function(g,e){return n(g,e,this,!1)},"any, SparseMatrix":function(g,e){return p(e,g,this,!0)},"any, DenseMatrix":function(g,e){return n(e,g,this,!0)},"Array, any":function(g,e){return n(c(g),e,this,!1).valueOf()},"any, Array":function(g,e){return n(c(e),g,this,!0).valueOf()}})}),Fn=B("partitionSelect",["typed","isNumeric","isNaN","compare"],b=>{function a(k,n,g){if(!Za(n)||0>n)throw Error("k must be a non-negative integer");if(Fa(k)){if(1=k.length)throw Error("k out of bounds");for(var e=0;e-l(k,n);return c("partitionSelect",{"Array | Matrix, number":function(k, +n){return a(k,n,l)},"Array | Matrix, number, string":function(k,n,g){if("asc"===g)return a(k,n,l);if("desc"===g)return a(k,n,p);throw Error('Compare string must be "asc" or "desc"');},"Array | Matrix, number, function":a})}),Gn=B("Index",["ImmutableDenseMatrix"],b=>{function a(f){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[];this._isScalar=!0;for(var h=0,l=arguments.length;h{var {typed:a,config:d,Complex:c,BigNumber:f}=b;return a("asech",{number:function(h){if(1>=h&&-1<=h||d.predictable){var l=1/h;return 0{({typed:b}=b);return b("tan",{number:Math.tan,Complex:function(a){return a.tan()},BigNumber:function(a){return a.tan()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(a.value)},"Array | Matrix":function(a){return Na(a,this,!0)}})}),Jn=B("setDifference","typed size subset compareNatural Index DenseMatrix".split(" "),b=>{var {typed:a,size:d, +subset:c,compareNatural:f,Index:h,DenseMatrix:l}=b;return a("setDifference",{"Array | Matrix, Array | Matrix":function(p,k){if(0===c(d(p),new h(0)))var n=[];else{if(0===c(d(k),new h(0)))return C(p.toArray());var g=T(C(Array.isArray(p)?p:p.toArray()).sort(f)),e=T(C(Array.isArray(k)?k:k.toArray()).sort(f));n=[];for(var m=0;m{var {typed:a,size:d,subset:c,compareNatural:f,Index:h,DenseMatrix:l}=b;return a("setIntersect",{"Array | Matrix, Array | Matrix":function(p,k){if(0===c(d(p),new h(0))||0===c(d(k),new h(0)))var n=[];else{var g=T(C(Array.isArray(p)?p:p.toArray()).sort(f)),e=T(C(Array.isArray(k)?k:k.toArray()).sort(f));n=[];for(var m=0;m{var {typed:a,size:d,subset:c,compareNatural:f,Index:h}=b;return a("setMultiplicity",{"number | BigNumber | Fraction | Complex, Array | Matrix":function(l,p){if(0===c(d(p),new h(0)))return 0;p=C(Array.isArray(p)?p:p.toArray());for(var k=0,n=0;n{var {typed:a,compareNatural:d}=b;return a("setSize",{"Array | Matrix":function(c){return Array.isArray(c)?C(c).length:C(c.toArray()).length},"Array | Matrix, boolean":function(c,f){if(!1===f||0===c.length)return Array.isArray(c)?C(c).length:C(c.toArray()).length;c=C(Array.isArray(c)?c:c.toArray()).sort(d);for(var h=f=1;h{function a(h){var l=h._size;h=h._data;switch(l.length){case 1:if(1=== +l[0])return nb(h[0]);throw new RangeError("Matrix must be square (size: "+Db(l)+")");case 2:var p=l[0];if(p===l[1]){for(var k=l=0;kg)break}return n}throw new RangeError("Matrix must be square (size: "+Db(n)+")");},DenseMatrix:a,any:nb})}),On=B("quantileSeq",["typed","add","multiply","partitionSelect","compare"],b=>{function a(k,n,g){k=C(k);var e=k.length;if(0===e)throw Error("Cannot calculate quantile of an empty sequence");if(Qa(n)){e=n*(e-1);n=e%1;if(0===n)return k=g?k[e]:h(k,e),p(k),k;e=Math.floor(e);if(g){g=k[e];var m=k[e+1]}else{m=h(k, +e+1);g=k[e];for(var q=0;qarguments.length||3n)throw Error("N/prob must be non-negative");if(1>=n)return a(e,n,g);if(1u||1{function a(k){if(8>k)return new l([1,1,2,6,24,120,720,5040][k]);var n=c.precision+(0|Math.log(k.toNumber())),g=l.clone({precision:n});if(1==k%2)return k.times(a(new l(k-1)));n=k;g=new g(k);for(k=k.toNumber();2Bd[g]?-1/0:1/0}g=new p(k.re+Gg+.5,k.im);e=Math.sqrt(2*Math.PI);k.re+=.5;k=h(g,k);0===k.im?k.re*=e:(0===k.re||(k.re*=e),k.im*=e);e=Math.exp(-g.re);return g.re=e*Math.cos(-g.im),g.im=e*Math.sin(-g.im),f(f(k,g),n)},BigNumber:function(k){if(k.isInteger())return k.isNegative()||k.isZero()?new l(1/ +0):a(k.minus(1));if(!k.isFinite())return new l(k.isNegative()?NaN:1/0);throw Error("Integer BigNumber expected");},"Array | Matrix":function(k){return Na(k,this)}})}),Qn=B("bignumber",["typed","BigNumber"],b=>{var {typed:a,BigNumber:d}=b;return a("bignumber",{"":function(){return new d(0)},number:function(c){return new d(c+"")},string:function(c){var f=c.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(f){var h=f[2];f=d(f[1]);var l=(new d(2)).pow(Number(h));if(f.gt(l.sub(1)))throw new SyntaxError('String "'.concat(c, +'" is out of range'));c=(new d(2)).pow(Number(h)-1);return f.gte(c)?f.sub(l):f}return new d(c)},BigNumber:function(c){return c},Fraction:function(c){return(new d(c.n)).div(c.d).times(c.s)},null:function(c){return new d(0)},"Array | Matrix":function(c){return Na(c,this)}})}),Rn=B("matrixFromColumns",["typed","matrix","flatten","size"],b=>{function a(p){if(0===p.length)throw new TypeError("At least one column is needed to construct a matrix.");for(var k=d(p[0]),n=[],g=0;gk.toArray())))}})}),Sn=B("lcm",["typed","matrix","equalScalar"],b=>{var {typed:a,matrix:d,equalScalar:c}=b,f=bd({typed:a,equalScalar:c}),h=Me({typed:a,equalScalar:c}),l=Fc({typed:a,equalScalar:c}),p=fc({typed:a}),k=Tb({typed:a});return a("lcm",{"number, number":Sf,"BigNumber, BigNumber":function(n,g){if(!n.isInt()||!g.isInt())throw Error("Parameters in function lcm must be integer numbers");if(n.isZero())return n;if(g.isZero())return g;for(var e=n.times(g);!g.isZero();){var m= +g;g=n.mod(m);n=m}return e.div(n).abs()},"Fraction, Fraction":function(n,g){return n.lcm(g)},"SparseMatrix, SparseMatrix":function(n,g){return h(n,g,this)},"SparseMatrix, DenseMatrix":function(n,g){return f(g,n,this,!0)},"DenseMatrix, SparseMatrix":function(n,g){return f(n,g,this,!1)},"DenseMatrix, DenseMatrix":function(n,g){return p(n,g,this)},"Array, Array":function(n,g){return this(d(n),d(g)).valueOf()},"Array, Matrix":function(n,g){return this(d(n),g)},"Matrix, Array":function(n,g){return this(n, +d(g))},"SparseMatrix, number | BigNumber":function(n,g){return l(n,g,this,!1)},"DenseMatrix, number | BigNumber":function(n,g){return k(n,g,this,!1)},"number | BigNumber, SparseMatrix":function(n,g){return l(g,n,this,!0)},"number | BigNumber, DenseMatrix":function(n,g){return k(g,n,this,!0)},"Array, number | BigNumber":function(n,g){return k(d(n),g,this,!1).valueOf()},"number | BigNumber, Array":function(n,g){return k(d(g),n,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(n, +g,e){n=this(n,g);for(g=0;g{var {typed:a,matrix:d,equalScalar:c,DenseMatrix:f}=b,h=Cd({typed:a}),l=jf({typed:a,equalScalar:c}),p=Qd({typed:a,DenseMatrix:f}),k=fc({typed:a}),n=Tb({typed:a});return a("bitOr",{"number, number":ag,"BigNumber, BigNumber":Ai,"SparseMatrix, SparseMatrix":function(g,e){return l(g,e,this)},"SparseMatrix, DenseMatrix":function(g,e){return h(e,g,this,!0)},"DenseMatrix, SparseMatrix":function(g, +e){return h(g,e,this,!1)},"DenseMatrix, DenseMatrix":function(g,e){return k(g,e,this)},"Array, Array":function(g,e){return this(d(g),d(e)).valueOf()},"Array, Matrix":function(g,e){return this(d(g),e)},"Matrix, Array":function(g,e){return this(g,d(e))},"SparseMatrix, any":function(g,e){return p(g,e,this,!1)},"DenseMatrix, any":function(g,e){return n(g,e,this,!1)},"any, SparseMatrix":function(g,e){return p(e,g,this,!0)},"any, DenseMatrix":function(g,e){return n(e,g,this,!0)},"Array, any":function(g, +e){return n(d(g),e,this,!1).valueOf()},"any, Array":function(g,e){return n(d(e),g,this,!0).valueOf()}})}),Un=B("kron",["typed","matrix","multiplyScalar"],b=>{function a(h,l){if(1===Ua(h).length&&(h=[h]),1===Ua(l).length&&(l=[l]),2{var {typed:a,matrix:d}=b;return a("transpose",{Array:function(c){return this(d(c)).valueOf()},Matrix:function(c){var f=c.size(); +switch(f.length){case 1:var h=c.clone();break;case 2:var l=f[0],p=f[1];if(0===p)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+Db(f)+")");switch(c.storage()){case "dense":h=function(k,n,g){for(var e,m=k._data,q=[],r=0;r{var {number:a, +bignumber:d,fraction:c}=b,f={string:!0,number:!0,BigNumber:!0,Fraction:!0},h={number:l=>a(l),BigNumber:d?l=>d(l):hd,Fraction:c?l=>c(l):gc};return function(l,p){var k=Wb(l);if(!(k in f))throw new TypeError("Cannot convert "+l+' of type "'+k+'"; valid input types are '+Object.keys(f).join(", "));if(!(p in h))throw new TypeError("Cannot convert "+l+' to type "'+p+'"; valid output types are '+Object.keys(h).join(", "));return p===k?l:h[p](l)}}),Xn=B("and",["typed","matrix","equalScalar","zeros","not"], +b=>{var {typed:a,matrix:d,equalScalar:c,zeros:f,not:h}=b,l=bd({typed:a,equalScalar:c}),p=Me({typed:a,equalScalar:c}),k=Fc({typed:a,equalScalar:c}),n=fc({typed:a}),g=Tb({typed:a});return a("and",{"number, number":ig,"Complex, Complex":function(e,m){return!(0===e.re&&0===e.im||0===m.re&&0===m.im)},"BigNumber, BigNumber":function(e,m){return!(e.isZero()||m.isZero()||e.isNaN()||m.isNaN())},"Unit, Unit":function(e,m){return this(e.value||0,m.value||0)},"SparseMatrix, SparseMatrix":function(e,m){return p(e, +m,this,!1)},"SparseMatrix, DenseMatrix":function(e,m){return l(m,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,m){return l(e,m,this,!1)},"DenseMatrix, DenseMatrix":function(e,m){return n(e,m,this)},"Array, Array":function(e,m){return this(d(e),d(m)).valueOf()},"Array, Matrix":function(e,m){return this(d(e),m)},"Matrix, Array":function(e,m){return this(e,d(m))},"SparseMatrix, any":function(e,m){return h(m)?f(e.size(),e.storage()):k(e,m,this,!1)},"DenseMatrix, any":function(e,m){return h(m)?f(e.size(), +e.storage()):g(e,m,this,!1)},"any, SparseMatrix":function(e,m){return h(e)?f(e.size(),e.storage()):k(m,e,this,!0)},"any, DenseMatrix":function(e,m){return h(e)?f(e.size(),e.storage()):g(m,e,this,!0)},"Array, any":function(e,m){return this(d(e),m).valueOf()},"any, Array":function(e,m){return this(e,d(m)).valueOf()}})}),Yn=B("smallerEq",["typed","config","matrix","DenseMatrix"],b=>{var {typed:a,config:d,matrix:c,DenseMatrix:f}=b,h=Nc({typed:a}),l=kd({typed:a,DenseMatrix:f}),p=Oc({typed:a,DenseMatrix:f}), +k=fc({typed:a}),n=Tb({typed:a});return a("smallerEq",{"boolean, boolean":function(g,e){return g<=e},"number, number":function(g,e){return g<=e||Ec(g,e,d.epsilon)},"BigNumber, BigNumber":function(g,e){return g.lte(e)||jd(g,e,d.epsilon)},"Fraction, Fraction":function(g,e){return 1!==g.compare(e)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers");},"Unit, Unit":function(g,e){if(!g.equalBase(e))throw Error("Cannot compare units with different base"); +return this(g.value,e.value)},"SparseMatrix, SparseMatrix":function(g,e){return l(g,e,this)},"SparseMatrix, DenseMatrix":function(g,e){return h(e,g,this,!0)},"DenseMatrix, SparseMatrix":function(g,e){return h(g,e,this,!1)},"DenseMatrix, DenseMatrix":function(g,e){return k(g,e,this)},"Array, Array":function(g,e){return this(c(g),c(e)).valueOf()},"Array, Matrix":function(g,e){return this(c(g),e)},"Matrix, Array":function(g,e){return this(g,c(e))},"SparseMatrix, any":function(g,e){return p(g,e,this, +!1)},"DenseMatrix, any":function(g,e){return n(g,e,this,!1)},"any, SparseMatrix":function(g,e){return p(e,g,this,!0)},"any, DenseMatrix":function(g,e){return n(e,g,this,!0)},"Array, any":function(g,e){return n(c(g),e,this,!1).valueOf()},"any, Array":function(g,e){return n(c(e),g,this,!0).valueOf()}})}),Zn=B("sort",["typed","matrix","compare","compareNatural"],b=>{function a(g){if("asc"===g)return k;if("desc"===g)return n;if("natural"===g)return p;throw Error('String "asc", "desc", or "natural" expected'); +}function d(g){if(1!==Ua(g).length)throw Error("One dimensional array expected");}function c(g){if(1!==g.size().length)throw Error("One dimensional matrix expected");}var {typed:f,matrix:h,compare:l,compareNatural:p}=b,k=l,n=(g,e)=>-l(g,e);return f("sort",{Array:function(g){return d(g),g.sort(k)},Matrix:function(g){return c(g),h(g.toArray().sort(k),g.storage())},"Array, function":function(g,e){return d(g),g.sort(e)},"Matrix, function":function(g,e){return c(g),h(g.toArray().sort(e),g.storage())}, +"Array, string":function(g,e){return d(g),g.sort(a(e))},"Matrix, string":function(g,e){return c(g),h(g.toArray().sort(a(e)),g.storage())}})}),$n=B("cot",["typed","BigNumber"],b=>{var {typed:a,BigNumber:d}=b;return a("cot",{number:sg,Complex:function(c){return c.cot()},BigNumber:function(c){return(new d(1)).div(c.tan())},Unit:function(c){if(!c.hasBase(c.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(c.value)},"Array | Matrix":function(c){return Na(c, +this)}})}),ao=B("setDistinct","typed size subset compareNatural Index DenseMatrix".split(" "),b=>{var {typed:a,size:d,subset:c,compareNatural:f,Index:h,DenseMatrix:l}=b;return a("setDistinct",{"Array | Matrix":function(p){if(0===c(d(p),new h(0)))var k=[];else{var n=C(Array.isArray(p)?p:p.toArray()).sort(f);(k=[]).push(n[0]);for(var g=1;g{var {typed:a, +size:d,subset:c,compareNatural:f,Index:h}=b;return a("setPowerset",{"Array | Matrix":function(l){if(0===c(d(l),new h(0)))return[];var p=C(Array.isArray(l)?l:l.toArray()).sort(f);l=[];for(var k=0;k.toString(2).length<=p.length;){for(var n=l,g=n.push,e=p,m=k.toString(2).split("").reverse(),q=[],r=0;rl[n+1].length&&(p=l[n],l[n]=l[n+1],l[n+1]=p);return l}})}),co=B("index",["typed","Index"], +b=>{var {typed:a,Index:d}=b;return a("index",{"...number | string | BigNumber | Range | Array | Matrix":function(c){c=c.map(function(h){return pa(h)?h.toNumber():Array.isArray(h)||Fa(h)?h.map(function(l){return pa(l)?l.toNumber():l}):h});var f=new d;return d.apply(f,c),f}})}),eo=B("factorial",["typed","gamma"],b=>{var {typed:a,gamma:d}=b;return a("factorial",{number:function(c){if(0>c)throw Error("Value must be non-negative");return d(c+1)},BigNumber:function(c){if(c.isNegative())throw Error("Value must be non-negative"); +return d(c.plus(1))},"Array | Matrix":function(c){return Na(c,this)}})}),fo=B("permutations",["typed","factorial"],b=>{var {typed:a,factorial:d}=b;return a("permutations",{"number | BigNumber":d,"number, number":function(c,f){if(!Za(c)||0>c)throw new TypeError("Positive integer value expected in function permutations");if(!Za(f)||0>f)throw new TypeError("Positive integer value expected in function permutations");if(f>c)throw new TypeError("second argument k must be less than or equal to first argument n"); +return Wc(c-f+1,c)},"BigNumber, BigNumber":function(c,f){if(!Hg(c)||!Hg(f))throw new TypeError("Positive integer value expected in function permutations");if(f.gt(c))throw new TypeError("second argument k must be less than or equal to first argument n");var h=c.mul(0).add(1);for(f=c.minus(f).plus(1);f.lte(c);f=f.plus(1))h=h.times(f);return h}})}),go=B("matrixFromRows",["typed","matrix","flatten","size"],b=>{function a(p){if(0===p.length)throw new TypeError("At least one row is needed to construct a matrix."); +var k=d(p[0]),n=[],g;for(g of p){p=d(g);if(p!==k)throw new TypeError("The vectors had different length: "+(0|k)+" \u2260 "+(0|p));n.push(h(g))}return n}function d(p){p=l(p);if(1===p.length)return p[0];if(2===p.length){if(1===p[0])return p[1];if(1===p[1])return p[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.");}var {typed:c,matrix:f,flatten:h,size:l}=b;return c("matrixFromRows",{"...Array":function(p){return a(p)}, +"...Matrix":function(p){return f(a(p.map(k=>k.toArray())))}})}),ho=B("subtract","typed matrix equalScalar addScalar unaryMinus DenseMatrix".split(" "),b=>{var {typed:a,matrix:d,equalScalar:c,addScalar:f,unaryMinus:h,DenseMatrix:l}=b,p=Cd({typed:a}),k=Nc({typed:a}),n=Le({typed:a,equalScalar:c}),g=Qd({typed:a,DenseMatrix:l}),e=fc({typed:a}),m=Tb({typed:a});return a("subtract",{"number, number":function(q,r){return q-r},"Complex, Complex":function(q,r){return q.sub(r)},"BigNumber, BigNumber":function(q, +r){return q.minus(r)},"Fraction, Fraction":function(q,r){return q.sub(r)},"Unit, Unit":function(q,r){if(null===q.value)throw Error("Parameter x contains a unit with undefined value");if(null===r.value)throw Error("Parameter y contains a unit with undefined value");if(!q.equalBase(r))throw Error("Units do not match");q=q.clone();return q.value=this(q.value,r.value),q.fixPrefix=!1,q},"SparseMatrix, SparseMatrix":function(q,r){return Ke(q,r),n(q,r,this)},"SparseMatrix, DenseMatrix":function(q,r){return Ke(q, +r),k(r,q,this,!0)},"DenseMatrix, SparseMatrix":function(q,r){return Ke(q,r),p(q,r,this,!1)},"DenseMatrix, DenseMatrix":function(q,r){return Ke(q,r),e(q,r,this)},"Array, Array":function(q,r){return this(d(q),d(r)).valueOf()},"Array, Matrix":function(q,r){return this(d(q),r)},"Matrix, Array":function(q,r){return this(q,d(r))},"SparseMatrix, any":function(q,r){return g(q,h(r),f)},"DenseMatrix, any":function(q,r){return m(q,r,this)},"any, SparseMatrix":function(q,r){return g(r,q,this,!0)},"any, DenseMatrix":function(q, +r){return m(r,q,this,!0)},"Array, any":function(q,r){return m(d(q),r,this,!1).valueOf()},"any, Array":function(q,r){return m(d(r),q,this,!0).valueOf()}})}),io=B("cross",["typed","matrix","subtract","multiply"],b=>{function a(l,p){var k=Math.max(Ua(l).length,Ua(p).length);l=Ba(l);p=Ba(p);var n=Ua(l),g=Ua(p);if(1!==n.length||1!==g.length||3!==n[0]||3!==g[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+n.join(", ")+"], B = ["+g.join(", ")+"])");l=[f(h(l[1],p[2]),h(l[2],p[1])),f(h(l[2], +p[0]),h(l[0],p[2])),f(h(l[0],p[1]),h(l[1],p[0]))];return 1{function a(l){var p;if(Zb(l,function(k){try{p=void 0===p?k:f(p,k)}catch(n){throw Tc(n,"prod",k);}}),"string"== +typeof p&&(p=h(p,c.number)),void 0===p)throw Error("Cannot calculate prod of an empty array");return p}var {typed:d,config:c,multiplyScalar:f,numeric:h}=b;return d("prod",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(l,p){throw Error("prod(A, dim) is not yet supported");},"...":function(l){return a(l)}})}),ko=B("equal",["typed","matrix","equalScalar","DenseMatrix"],b=>{var {typed:a,matrix:d,equalScalar:c,DenseMatrix:f}=b,h=Nc({typed:a}),l=kd({typed:a,DenseMatrix:f}),p=Oc({typed:a, +DenseMatrix:f}),k=fc({typed:a}),n=Tb({typed:a});return a("equal",{"any, any":function(g,e){return null===g?null===e:null===e?null===g:void 0===g?void 0===e:void 0===e?void 0===g:c(g,e)},"SparseMatrix, SparseMatrix":function(g,e){return l(g,e,c)},"SparseMatrix, DenseMatrix":function(g,e){return h(e,g,c,!0)},"DenseMatrix, SparseMatrix":function(g,e){return h(g,e,c,!1)},"DenseMatrix, DenseMatrix":function(g,e){return k(g,e,c)},"Array, Array":function(g,e){return this(d(g),d(e)).valueOf()},"Array, Matrix":function(g, +e){return this(d(g),e)},"Matrix, Array":function(g,e){return this(g,d(e))},"SparseMatrix, any":function(g,e){return p(g,e,c,!1)},"DenseMatrix, any":function(g,e){return n(g,e,c,!1)},"any, SparseMatrix":function(g,e){return p(e,g,c,!0)},"any, DenseMatrix":function(g,e){return n(e,g,c,!0)},"Array, any":function(g,e){return n(d(g),e,c,!1).valueOf()},"any, Array":function(g,e){return n(d(e),g,c,!0).valueOf()}})}),jh=(B("equal",["typed","equalScalar"],b=>{var {typed:a,equalScalar:d}=b;return a("equal", +{"any, any":function(c,f){return null===c?null===f:null===f?null===c:void 0===c?void 0===f:void 0===f?void 0===c:d(c,f)}})}),"setCartesian"),lo=B(jh,"typed size subset compareNatural Index DenseMatrix".split(" "),b=>{var {typed:a,size:d,subset:c,compareNatural:f,Index:h,DenseMatrix:l}=b;return a(jh,{"Array | Matrix, Array | Matrix":function(p,k){var n=[];if(0!==c(d(p),new h(0))&&0!==c(d(k),new h(0))){var g=C(Array.isArray(p)?p:p.toArray()).sort(f),e=C(Array.isArray(k)?k:k.toArray()).sort(f);n=[]; +for(var m=0;m{var {typed:a,size:d,concat:c,subset:f,setDifference:h,Index:l}=b;return a("setSymDifference",{"Array | Matrix, Array | Matrix":function(p,k){if(0===f(d(p),new l(0)))return C(k);if(0===f(d(k),new l(0)))return C(p);p=C(p);k=C(k);return c(h(p,k),h(k,p))}})}),no=B("ceil",["typed","config", +"round","matrix","equalScalar"],b=>{var {typed:a,config:d,round:c,matrix:f,equalScalar:h}=b,l=Fc({typed:a,equalScalar:h}),p=Tb({typed:a});return a("ceil",{number:function(k){return Ec(k,c(k),d.epsilon)?c(k):Nf(k)},"number, number":function(k,n){if(Ec(k,c(k,n),d.epsilon))return c(k,n);var [g,e]="".concat(k,"e").split("e");k=Math.ceil(Number("".concat(g,"e").concat(Number(e)+n)));k="".concat(k,"e").split("e");[g,e]=k;return Number("".concat(g,"e").concat(Number(e)-n))},Complex:function(k){return k.ceil()}, +"Complex, number":function(k,n){return k.ceil(n)},BigNumber:function(k){return jd(k,c(k),d.epsilon)?c(k):k.ceil()},"BigNumber, BigNumber":function(k,n){return jd(k,c(k,n),d.epsilon)?c(k,n):k.toDecimalPlaces(n.toNumber(),hf.ROUND_CEIL)},Fraction:function(k){return k.ceil()},"Fraction, number":function(k,n){return k.ceil(n)},"Array | Matrix":function(k){return Na(k,this,!0)},"Array | Matrix, number":function(k,n){return Na(k,g=>this(g,n),!0)},"SparseMatrix, number | BigNumber":function(k,n){return l(k, +n,this,!1)},"DenseMatrix, number | BigNumber":function(k,n){return p(k,n,this,!1)},"number | Complex | BigNumber, Array":function(k,n){return p(f(n),k,this,!0).valueOf()}})}),oo=B("xor",["typed","matrix","DenseMatrix"],b=>{var {typed:a,matrix:d,DenseMatrix:c}=b,f=Nc({typed:a}),h=kd({typed:a,DenseMatrix:c}),l=Oc({typed:a,DenseMatrix:c}),p=fc({typed:a}),k=Tb({typed:a});return a("xor",{"number, number":hg,"Complex, Complex":function(n,g){return(0!==n.re||0!==n.im)!=(0!==g.re||0!==g.im)},"BigNumber, BigNumber":function(n, +g){return(!n.isZero()&&!n.isNaN())!=(!g.isZero()&&!g.isNaN())},"Unit, Unit":function(n,g){return this(n.value||0,g.value||0)},"SparseMatrix, SparseMatrix":function(n,g){return h(n,g,this)},"SparseMatrix, DenseMatrix":function(n,g){return f(g,n,this,!0)},"DenseMatrix, SparseMatrix":function(n,g){return f(n,g,this,!1)},"DenseMatrix, DenseMatrix":function(n,g){return p(n,g,this)},"Array, Array":function(n,g){return this(d(n),d(g)).valueOf()},"Array, Matrix":function(n,g){return this(d(n),g)},"Matrix, Array":function(n, +g){return this(n,d(g))},"SparseMatrix, any":function(n,g){return l(n,g,this,!1)},"DenseMatrix, any":function(n,g){return k(n,g,this,!1)},"any, SparseMatrix":function(n,g){return l(g,n,this,!0)},"any, DenseMatrix":function(n,g){return k(g,n,this,!0)},"Array, any":function(n,g){return k(d(n),g,this,!1).valueOf()},"any, Array":function(n,g){return k(d(g),n,this,!0).valueOf()}})}),po=B("count",["typed","size","prod"],b=>{var {typed:a,size:d,prod:c}=b;return a("count",{string:function(f){return f.length}, +"Matrix | Array":function(f){return c(d(f))}})}),qo=B("ctranspose",["typed","transpose","conj"],b=>{var {typed:a,transpose:d,conj:c}=b;return a("ctranspose",{any:function(f){return c(d(f))}})}),ro=B("deepEqual",["typed","equal"],b=>{function a(f,h){if(Array.isArray(f)){if(Array.isArray(h)){var l=f.length;if(l!==h.length)return!1;for(var p=0;p{var {typed:a,size:d,subset:c,compareNatural:f,Index:h}=b;return a("setIsSubset",{"Array | Matrix, Array | Matrix":function(l,p){if(0===c(d(l),new h(0)))return!0;if(0===c(d(p),new h(0)))return!1;l=T(C(Array.isArray(l)?l:l.toArray()).sort(f));for(var k=T(C(Array.isArray(p)?p:p.toArray()).sort(f)),n=0;n{var {typed:a,Complex:d,matrix:c,ceil:f,floor:h}=b,l=Tb({typed:a});return a("fix",{number:function(p){return 0p.s?p.ceil():p.floor()},"Fraction, number | BigNumber":function(p,k){return 0>p.s?p.ceil(k):p.floor(k)},"Array | Matrix":function(p){return Na(p,this,!0)},"Array | Matrix, number | BigNumber":function(p,k){return Na(p,n=>this(n,k),!0)},"number | Complex | BigNumber, Array":function(p,k){return l(c(k),p,this,!0).valueOf()}})}), +uo=B("divideScalar",["typed","numeric"],b=>{var {typed:a,numeric:d}=b;return a("divideScalar",{"number, number":function(c,f){return c/f},"Complex, Complex":function(c,f){return c.div(f)},"BigNumber, BigNumber":function(c,f){return c.div(f)},"Fraction, Fraction":function(c,f){return c.div(f)},"Unit, number | Fraction | BigNumber":function(c,f){c=c.clone();var h=d(1,Wb(f));return c.value=this(null===c.value?c._normalize(h):c.value,f),c},"number | Fraction | BigNumber, Unit":function(c,f){var h=f.clone(); +h=h.pow(-1);var l=d(1,Wb(c));return h.value=this(c,null===f.value?f._normalize(l):f.value),h},"Unit, Unit":function(c,f){return c.divide(f)}})}),vo=B("nthRoots",["config","typed","divideScalar","Complex"],b=>{function a(h,l){if(0>l)throw Error("Root must be greater than zero");if(0===l)throw Error("Root must be non-zero");if(0!=l%1)throw Error("Root must be an integer");if(0===h||0===h.abs())return[new c(0,0)];var p,k="number"==typeof h;(k||0===h.re||0===h.im)&&(p=k?2*+(0>h):0===h.im?2*+(0>h.re): +2*+(0>h.im)+1);k=h.arg();var n=h.abs();h=[];n=Math.pow(n,1/l);for(var g=0;g{function a(g,e){e=n(g,e,!0)._data;var m=g._size[0],q=g._size[1],r=[];g=g._data;for(var u=0;uv&&(z.push(r[L]),I.push(O))}if(p(w,0))throw Error("Linear system cannot be solved since matrix is singular");t=f(t,w);w=0;for(F=I.length;w{function a(g,e){e=[n(g,e,!0)._data.map(w=>w[0])];var m=g._data,q=g._size[0];g=g._size[1];for(var r=0;rnew k({data:w.map(z=>[z]),size:[q,1]}))}var {typed:d,matrix:c,divideScalar:f,multiplyScalar:h,subtract:l,equalScalar:p,DenseMatrix:k}=b,n=pe({DenseMatrix:k});return d("lsolveAll",{"SparseMatrix, Array | Matrix":function(g,e){return function(m,q){q=[n(m,q,!0)._data.map(ka=>ka[0])];var r=m._size[0],u=m._size[1],y=m._values,v=m._index;m=m._ptr;for(var t=0;tt&&(F.push(y[ba]),L.push(ca))}if(p(R,0))if(p(I[t],0)){if(0===z){I=[...I];I[t]=1;O=0;for(R=L.length;Onew k({data:ka.map(Ea=>[Ea]),size:[r,1]}))}(g,e)},"DenseMatrix, Array | Matrix":function(g,e){return a(g,e)},"Array, Array | Matrix":function(g,e){return a(c(g), +e).map(m=>m.valueOf())}})}),yo=B("Spa",["addScalar","equalScalar","FibonacciHeap"],b=>{function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._values=[];this._heap=new f}var {addScalar:d,equalScalar:c,FibonacciHeap:f}=b;return a.prototype.type="Spa",a.prototype.isSpa=!0,a.prototype.set=function(h,l){this._values[h]?this._values[h].value=l:(l=this._heap.insert(h,l),this._values[h]=l)},a.prototype.get=function(h){return(h=this._values[h])? +h.value:0},a.prototype.accumulate=function(h,l){var p=this._values[h];p?p.value=d(p.value,l):(p=this._heap.insert(h,l),this._values[h]=p)},a.prototype.forEach=function(h,l,p){var k=this._heap,n=this._values,g=[],e=k.extractMinimum();for(e&&g.push(e);e&&e.key<=l;)e.key>=h&&(c(e.value,0)||p(e.key,e.value,this)),(e=k.extractMinimum())&&g.push(e);for(h=0;h{var {typed:a,size:d,concat:c,subset:f,setIntersect:h,setSymDifference:l,Index:p}=b;return a("setUnion",{"Array | Matrix, Array | Matrix":function(k,n){if(0===f(d(k),new p(0)))return C(n); +if(0===f(d(n),new p(0)))return C(k);k=C(k);n=C(n);return c(l(k,n),h(k,n))}})}),Ao=B("lup","typed matrix abs addScalar divideScalar multiplyScalar subtract larger equalScalar unaryMinus DenseMatrix SparseMatrix Spa".split(" "),b=>{function a(u){var y,v,t=u._size[0],w=u._size[1],z=Math.min(t,w),I=nb(u._data),F=[],L=[t,z],O=[];z=[z,w];var R=[];for(u=0;uha&&X.accumulate(wa,e(p(gb,ja)))})});var ua,Da,Ha,Ka,M=t,Q=X.get(t),U=f(Q);X.forEach(t+1,z-1,function(ha,ja){var wa=f(ja);n(wa,U)&&(M=ha,U=wa,Q=ja)});t!==M&&(q._swapRows(t,M,Ea[1],ba,ca,ka),q._swapRows(t,M,S[1],Ga,P,Ma),X.swap(t,M),Da=M,Ha=na[ua= +t],Ka=na[Da],ob[Ha]=Da,ob[Ka]=ua,na[ua]=Ka,na[Da]=Ha);X.forEach(0,z-1,function(ha,ja){ha<=t?(Ga.push(ja),P.push(ha)):(ja=l(ja,Q),g(ja,0)||(ba.push(ja),ca.push(ha)))})};for(t=0;t{function a(l,p,k,n,g){if(2>l||0>l+p){for(l=0;l=l||3gb))for(var ma=wa[sb+ +1];Gpb)ja[sb+ +Ya]=0,ja[gb+Ya]=-1,Sa++,ha[Ya]=-U-2,ja[sb+U]++;else{var $a=ja[G+Ja];-1!==$a&&(ma[$a]=Ya);ja[qa+Ya]=ja[G+Ja];ja[G+Ja]=Ya}}return Sa}(n,p,F,ca,ba,ka,e,L,R,I,O),Ma=0;PS?(u=e,y=X,v=F[0+e]-S):(y=p[u=l[X++]],v=F[0+u]);for(q=1;q<=v;q++)0>=(t=F[L+(m=l[y++])])||(na+=t,F[L+m]=-t,l[ua++]=m,-1!==F[O+m]&&(I[F[O+m]]=I[m]),-1!== +I[m]?F[O+I[m]]=F[O+m]:F[R+F[ca+m]]=F[O+m]);u!==e&&(p[u]=-e-2,F[ka+u]=0)}0!==S&&(k=ua);F[ca+e]=na;p[e]=da;F[0+e]=ua-da;F[ba+e]=-2;Ga=a(Ga,g,F,ka,n);for(r=da;r=(w=F[ba+(m=l[r])])))for(q=Ga-(t=-F[L+m]),X=p[m],w=p[m]+w-1;X<=w;X++)F[ka+(u=l[X])]>=Ga?F[ka+u]-=t:0!==F[ka+u]&&(F[ka+u]=F[ca+u]+q);for(r=da;r=Q||(Ha+=Q,l[Da++]=q,z+=q)}0===Ha?(p[m]=-e-2,na-=t=-F[L+m],ob+=t,P+=t,F[L+m]=0,F[ba+m]=-1):(F[ca+m]=Math.min(F[ca+m],Ha),l[Da]=l[Ka],l[Ka]=l[w],l[w]=e,F[0+m]=Da-w+1,z=(0>z?-z:z)%n,F[O+m]=F[Ea+z],F[Ea+z]=m,I[m]=z)}F[ca+e]=na;Ga=a(Ga+(g=Math.max(g,na)),g,F,ka,n);for(r=da;r=(t=-F[L+(m=l[r])])||(F[L+m]=t,Ha=F[ca+m]+na-t,-1!==F[R+(Ha=Math.min(Ha,n-P-t))]&&(I[F[R+Ha]]=m),F[O+m]=F[R+Ha],I[m]=-1,F[R+Ha]=m,Ma=Math.min(Ma,Ha),F[ca+m]=Ha,l[X++]=m);F[L+e]=ob;0==(F[0+e]=X-da)&&(p[e]=-1,F[ka+e]=0);0!==S&&(k=X)}for(m=0;m=F[L+u]||-1!==p[u]&&(F[O+u]=F[R+p[u]],F[R+p[u]]=u);for(m=e=0;m<=n;m++)-1===p[m]&&(e=Ig(m,e,F,R,O,I,ka));return I.splice(I.length-1,1),I}}),Co=B("csCounts",["transpose"],b=>{var {transpose:a}=b;return function(d,c,f,h){if(!d||!c||!f)return null;var l,p,k,n,g=d._size;var e=g[0];g=g[1];var m=4*g+(h?g+e+1:0),q=[],r=2*g,u=3*g,y=4*g,v=5*g+1;for(k=0;k{var {add:a,multiply:d,transpose:c}=b,f=Bo({add:a,multiply:d,transpose:c}),h=Co({transpose:c});return function(l,p,k){var n=p._ptr,g=p._size[1],e={};if(e.q=f(l,p),l&&!e.q)return null;if(k){if(l=l?function(m,q,r,u){q=m._index;u=m._ptr;var y=m._size,v=m._datatype,t=y[0];y=y[1];for(var w=[],z=[],I=0,F=0;Fv&&(v=q.m2++),z[v]=t,0>=--O[t])||(q.lnz+=F[O+t],r=w[t],-1!==r&&(0===F[O+r]&&(F[L+r]=F[L+t]),F[0+F[L+t]]=F[m+r],F[m+r]=F[0+v],F[O+r]+=F[O+t]));for(v=0;vz[v]&&(z[v]=t++);return!0}(l,e))for(l=e.unz=0;l{var {divideScalar:a,multiply:d,subtract:c}=b;return function(f,h,l,p,k,n, +g){var e=f._values,m=f._index,q=f._ptr,r=f._size[1],u=h._values,y=h._index,v=h._ptr;var t=f._ptr;var w=h._index;var z=h._ptr;var I=h=f._size[1];var F=z[l];for(z=z[l+1];Ft[L])){var O,R=I,ba=p,ca=n,ka=f._index,Ea=f._ptr,Ga=f._size[1],P=0;for(ba[0]=L;0<=P;){L=ba[P];var Ma=ca?ca[L]:L;0>Ea[L]||(Ea[L]=-Ea[L]-2,ba[Ga+P]=0>Ma?0:Jg(Ea[Ma]));var S=1;I=ba[Ga+P];for(Ma=0>Ma?0:Jg(Ea[Ma+1]);IEa[ob])){ba[Ga+P]=I;ba[++P]=O;S=0;break}}S&&(P--,ba[--R]=L)}I=R}}for(F= +I;Fl))for(f=q[l],l=q[l+1],k[y]=a(k[y],e[g?f:l-1]),f=g?f+1:f,l=g?l:l-1;f{var {abs:a,divideScalar:d,multiply:c,subtract:f,larger:h,largerEq:l,SparseMatrix:p}=b,k=Eo({divideScalar:d,multiply:c,subtract:f});return function(n, +g,e){if(!n)return null;var m,q=n._size[1],r;g&&(m=g.q);var u,y,v=[],t=[],w=[],z=new p({values:v,index:t,ptr:w,size:[q,q]}),I=[],F=[],L=[],O=new p({values:I,index:F,ptr:L,size:[q,q]}),R=[],ba=[],ca=[];for(u=0;uR[u=ca[y]]){var S=a(ba[u]);h(S,Ma)&&(Ma=S,P=u)}else F[r]=R[u],I[r++]=ba[u];if(-1===P||0>=Ma)return null;0>R[Ea]&&l(a(ba[Ea]),c(Ma,e))&&(P=Ea); +Ea=ba[P];F[r]=ka;I[r++]=Ea;R[P]=ka;t[g]=P;v[g++]=1;for(y=Ga;yR[u=ca[y]]&&(t[g]=u,v[g++]=d(ba[u],Ea)),ba[u]=0}w[q]=g;L[q]=r;for(y=0;y{var {typed:a,abs:d,add:c,multiply:f,transpose:h,divideScalar:l,subtract:p,larger:k,largerEq:n,SparseMatrix:g}= +b,e=Do({add:c,multiply:f,transpose:h}),m=Fo({abs:d,divideScalar:l,multiply:f,subtract:p,larger:k,largerEq:n,SparseMatrix:g});return a("slu",{"SparseMatrix, number, number":function(q,r,u){if(!Za(r)||0>r||3u||1{var {typed:a,matrix:d,subtract:c,multiply:f,unaryMinus:h,lup:l}=b;return a("det",{any:function(p){return nb(p)},"Array | Matrix":function(p){var k;switch((k=Fa(p)?p.size():Array.isArray(p)?(p=d(p)).size():[]).length){case 0:return nb(p);case 1:if(1===k[0])return nb(p.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+ +Db(k)+")");case 2:var n=k[0];if(n===k[1]){p=p.clone().valueOf();if(1===n)n=nb(p[0][0]);else if(2===n)n=c(f(p[0][0],p[1][1]),f(p[1][0],p[0][1]));else{p=l(p);k=p.U[0][0];for(var g=1;g=n)break;for(var q=e,r=0;!m[p.p[q]];)m[p.p[q]]=!0,q=p.p[q],r++;0==r%2&&g++}n=0==g%2?k:h(k)}return n}throw new RangeError("Matrix must be square (size: "+Db(k)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+Db(k)+")");}}})}),Io= +B("distance","typed addScalar subtract divideScalar multiplyScalar unaryMinus sqrt abs".split(" "),b=>{function a(t){return"number"==typeof t||pa(t)}function d(t){return t.constructor!==Array&&(t=l(t)),a(t[0])&&a(t[1])}function c(t){return t.constructor!==Array&&(t=l(t)),a(t[0])&&a(t[1])&&a(t[2])}function f(t){return Array.isArray(t)||(t=l(t)),t.every(a)}function h(t){return t.constructor!==Array&&(t=l(t)),a(t[0])&&a(t[1])&&a(t[2])&&a(t[3])&&a(t[4])&&a(t[5])}function l(t){for(var w=Object.keys(t), +z=[],I=0;I2!==z.length|| +!a(z[0])||!a(z[1])))return!1}else if(!(3===w[0].length&&a(w[0][0])&&a(w[0][1])&&a(w[0][2]))||w.some(z=>3!==z.length||!a(z[0])||!a(z[1])||!a(z[2])))return!1;return!0}(t))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return function(w){for(var z=[],I=[],F=[],L=0;L{var {typed:a,addScalar:d,subtract:c,multiplyScalar:f,divideScalar:h,pow:l,factorial:p,combinations:k,isNegative:n,isInteger:g,larger:e}=b;return a("stirlingS2",{"number | BigNumber, number | BigNumber":function(m,q){if(!g(m)||n(m)||!g(q)||n(q))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(e(q,m))throw new TypeError("k must be less than or equal to n in function stirlingS2"); +for(var r=p(q),u=0,y=0;y<=q;y++){var v=l(-1,c(q,y)),t=k(q,y),w=l(y,m);u=d(u,f(f(t,w),v))}return h(u,r)}})}),Ko=B("catalan","typed addScalar divideScalar multiplyScalar combinations isNegative isInteger".split(" "),b=>{var {typed:a,addScalar:d,divideScalar:c,multiplyScalar:f,combinations:h,isNegative:l,isInteger:p}=b;return a("catalan",{"number | BigNumber":function(k){if(!p(k)||l(k))throw new TypeError("Non-negative integer value expected in function catalan");return c(h(f(k,2),k),d(k,1))}})}),Lo= +B("log",["config","typed","divideScalar","Complex"],b=>{var {typed:a,config:d,divideScalar:c,Complex:f}=b;return a("log",{number:function(h){return 0<=h||d.predictable?Tf(h):(new f(h,0)).log()},Complex:function(h){return h.log()},BigNumber:function(h){return!h.isNegative()||d.predictable?h.ln():(new f(h.toNumber(),0)).log()},"Array | Matrix":function(h){return Na(h,this)},"any, any":function(h,l){return c(this(h),this(l))}})}),Mo=B("dotDivide",["typed","matrix","equalScalar","divideScalar","DenseMatrix"], +b=>{var {typed:a,matrix:d,equalScalar:c,divideScalar:f,DenseMatrix:h}=b,l=bd({typed:a,equalScalar:c}),p=Nc({typed:a}),k=kd({typed:a,DenseMatrix:h}),n=Fc({typed:a,equalScalar:c}),g=Oc({typed:a,DenseMatrix:h}),e=fc({typed:a}),m=Tb({typed:a});return a("dotDivide",{"any, any":f,"SparseMatrix, SparseMatrix":function(q,r){return k(q,r,f,!1)},"SparseMatrix, DenseMatrix":function(q,r){return l(r,q,f,!0)},"DenseMatrix, SparseMatrix":function(q,r){return p(q,r,f,!1)},"DenseMatrix, DenseMatrix":function(q,r){return e(q, +r,f)},"Array, Array":function(q,r){return this(d(q),d(r)).valueOf()},"Array, Matrix":function(q,r){return this(d(q),r)},"Matrix, Array":function(q,r){return this(q,d(r))},"SparseMatrix, any":function(q,r){return n(q,r,f,!1)},"DenseMatrix, any":function(q,r){return m(q,r,f,!1)},"any, SparseMatrix":function(q,r){return g(r,q,f,!0)},"any, DenseMatrix":function(q,r){return m(r,q,f,!0)},"Array, any":function(q,r){return m(d(q),r,f,!1).valueOf()},"any, Array":function(q,r){return m(d(r),q,f,!0).valueOf()}})}), +No=B("usolveAll","typed matrix divideScalar multiplyScalar subtract equalScalar DenseMatrix".split(" "),b=>{function a(g,e){e=[n(g,e,!0)._data.map(t=>t[0])];var m=g._data,q=g._size[0];for(g=g._size[1]-1;0<=g;g--)for(var r=e.length,u=0;u +new k({data:t.map(w=>[w]),size:[q,1]}))}var {typed:d,matrix:c,divideScalar:f,multiplyScalar:h,subtract:l,equalScalar:p,DenseMatrix:k}=b,n=pe({DenseMatrix:k});return d("usolveAll",{"SparseMatrix, Array | Matrix":function(g,e){return function(m,q){q=[n(m,q,!0)._data.map(ca=>ca[0])];var r=m._size[0],u=m._values,y=m._index,v=m._ptr;for(m=m._size[1]-1;0<=m;m--)for(var t=q.length,w=0;w=L;R--){var ba=y[R];ba===m?O=u[R]:banew k({data:ca.map(ka=>[ka]),size:[r,1]}))}(g,e)},"DenseMatrix, Array | Matrix":function(g,e){return a(g,e)},"Array, Array | Matrix":function(g,e){return a(c(g),e).map(m=>m.valueOf())}})}),Oo=B("hypot","typed abs addScalar divideScalar multiplyScalar sqrt smaller isPositive".split(" "), +b=>{var {typed:a,abs:d,addScalar:c,divideScalar:f,multiplyScalar:h,sqrt:l,smaller:p,isPositive:k}=b;return a("hypot",{"... number | BigNumber":function(n){for(var g=0,e=0,m=0;m{function a(t){var w,z=t._size[0],I=t._size[1],F=l([z],"dense"),L=F._data,O=t.clone(),R=O._data,ba=h([z],"");for(w=0;w{function a(e,m,q){var r;if(1===m){if(0===(m=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero"); +return[[f(1,m)]]}if(2===m){m=k(e);if(0===m)throw Error("Cannot calculate inverse, determinant is zero");return[[f(e[1][1],m),f(p(e[0][1]),m)],[f(p(e[1][0]),m),f(e[0][0],m)]]}var u=e.concat();for(e=0;et&&(t=g(u[e][v]),w=e),e++;if(0===t)throw Error("Cannot calculate inverse, determinant is zero");(e=w)!==v&&(r=u[v],u[v]=u[e],u[e]=r,r=y[v],y[v]=y[e],y[e]=r);var z=u[v],I=y[v];for(e=0;e{var {typed:a,abs:d,add:c,identity:f,inv:h,multiply:l}=b;return a("expm",{Matrix:function(p){var k=p.size();if(2!==k.length||k[0]!==k[1])throw new RangeError("Matrix must be square (size: "+ +Db(k)+")");var n=k[0];k=function(v,t){for(t=0;30>t;t++)for(var w=0;w<=t;w++){for(var z=t-w,I=1,F=2;F<=w;F++)I*=F;F=I;for(var L=w+1;L<=2*w;L++)F*=L;if(1E-15>8*Math.pow(v/Math.pow(2,z),2*w)*I*I/(F*F*(2*w+1)))return{q:w,j:z}}throw Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)");}(function(v){for(var t=v.size()[0],w=0,z=0;z{var {typed:a,matrix:d,multiply:c,equalScalar:f,divideScalar:h,inv:l}=b,p=Fc({typed:a,equalScalar:f}),k=Tb({typed:a});return a("divide",xd({"Array | Matrix, Array | Matrix":function(n,g){return c(n,l(g))}, +"DenseMatrix, any":function(n,g){return k(n,g,h,!1)},"SparseMatrix, any":function(n,g){return p(n,g,h,!1)},"Array, any":function(n,g){return k(d(n),g,h,!1).valueOf()},"any, Array | Matrix":function(n,g){return c(n,l(g))}},h.signatures))}),To=B("kldivergence","typed matrix divide sum multiply dotDivide log isNumeric".split(" "),b=>{function a(g,e){var m=e.size().length,q=g.size().length;if(1{var {typed:a,addScalar:d,isNegative:c,isInteger:f,stirlingS2:h}=b;return a("bellNumbers",{"number | BigNumber":function(l){if(!f(l)||c(l))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var p=0,k=0;k<=l;k++)p=d(p,h(l,k));return p}})}),Vo=B("log1p",["typed","config","divideScalar","log","Complex"],b=>{function a(p){var k= +p.re+1;return new l(Math.log(Math.sqrt(k*k+p.im*p.im)),Math.atan2(p.im,k))}var {typed:d,config:c,divideScalar:f,log:h,Complex:l}=b;return d("log1p",{number:function(p){return-1<=p||c.predictable?Mi(p):a(new l(p,0))},Complex:a,BigNumber:function(p){var k=p.plus(1);return!k.isNegative()||c.predictable?k.ln():a(new l(p.toNumber(),0))},"Array | Matrix":function(p){return Na(p,this)},"any, any":function(p,k){return f(this(p),h(k))}})}),Wo=B("Unit","?on config addScalar subtract multiplyScalar divideScalar pow abs fix round equal isNumeric format number Complex BigNumber Fraction".split(" "), +b=>{function a(M,Q){if(!(this instanceof a))throw Error("Constructor must be called with the new operator");if(null!=M&&!O(M)&&!rb(M))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(void 0!==Q&&("string"!=typeof Q||""===Q))throw new TypeError("Second parameter in Unit constructor must be a string");if(void 0!==Q)Q=a.parse(Q),this.units=Q.units,this.dimensions=Q.dimensions;else for(this.units=[{unit:ob,prefix:P.NONE,power:0}], +this.dimensions=[],Q=0;Q=M}function f(){e++;m=g.charAt(e)}function h(M){e=M;m=g.charAt(e)}function l(){var M="",Q=e;if("+"===m?f():"-"===m&&(M+=m,f()),!("0"<=m&&"9">=m||"."===m))return h(Q),null;if("."===m){if(M+=m,f(),!c(m))return h(Q),null}else{for(;c(m);)M+=m,f();"."===m&&(M+=m,f())}for(;c(m);)M+= +m,f();if("E"===m||"e"===m){Q="";var U=e;if(Q+=m,f(),"+"!==m&&"-"!==m||(Q+=m,f()),!c(m))return h(U),M;for(M+=Q;c(m);)M+=m,f()}return M}function p(M){return m===M?(f(),M):null}function k(M){return M.equalBase(S.NONE)&&null!==M.value&&!r.predictable?M.value:M}function n(M){"BigNumber"===M.number?(M=gf(ka),na.rad.value=new ka(1),na.deg.value=M.div(180),na.grad.value=M.div(200),na.cycle.value=M.times(2),na.arcsec.value=M.div(648E3),na.arcmin.value=M.div(10800)):(na.rad.value=1,na.deg.value=Math.PI/180, +na.grad.value=Math.PI/200,na.cycle.value=2*Math.PI,na.arcsec.value=Math.PI/648E3,na.arcmin.value=Math.PI/10800);na.radian.value=na.rad.value;na.degree.value=na.deg.value;na.gradian.value=na.grad.value}var g,e,m,{on:q,config:r,addScalar:u,subtract:y,multiplyScalar:v,divideScalar:t,pow:w,abs:z,fix:I,round:F,equal:L,isNumeric:O,format:R,number:ba,Complex:ca,BigNumber:ka,Fraction:Ea}=b;a.prototype.type="Unit";a.prototype.isUnit=!0;a.parse=function(M,Q){if(Q=Q||{},e=-1,m="","string"!=typeof(g=M))throw new TypeError("Invalid argument in Unit.parse, string expected"); +var U=new a;U.units=[];var ha=1,ja=!1;f();d();var wa=l(),gb=null;if(wa){if("BigNumber"===r.number)gb=new ka(wa);else if("Fraction"===r.number)try{gb=new Ea(wa)}catch(G){gb=parseFloat(wa)}else gb=parseFloat(wa);d();p("*")?(ha=1,ja=!0):p("/")&&(ha=-1,ja=!0)}wa=[];for(var Xa=1;;){for(d();"("===m;)wa.push(ha),Xa*=ha,ha=1,f(),d();if(!m)break;var pb=m;for(ja="";c(m)||a.isValidAlpha(m);)ja+=m,f();var sb=ja.charAt(0);if(null===(ja=a.isValidAlpha(sb)?ja:null))throw new SyntaxError('Unexpected "'+pb+'" in "'+ +g+'" at index '+e.toString());pb=Ga(ja);if(null===pb)throw new SyntaxError('Unit "'+ja+'" not found.');ja=ha*Xa;if(d(),p("^")){d();sb=l();if(null===sb)throw new SyntaxError('In "'+M+'", "^" must be followed by a floating-point number');ja*=sb}U.units.push({unit:pb.unit,prefix:pb.prefix,power:ja});for(sb=0;sb{if(Pa(na,M))return M=na[M],{unit:M,prefix:M.prefixes[""]};for(var Q in na){var U;if(U=Pa(na,Q))U=Q,U=M.substring(M.length-U.length,M.length)===U;if(U){U=na[Q]; +var ha=M.substring(0,M.length-Q.length);ha=Pa(U.prefixes,ha)?U.prefixes[ha]:void 0;if(void 0!==ha)return{unit:U,prefix:ha}}}return null},{hasher:M=>M[0],limit:100});a.isValuelessUnit=function(M){return null!==Ga(M)};a.prototype.hasBase=function(M){if("string"==typeof M&&(M=S[M]),!M)return!1;for(var Q=0;Qthis.units[ja].power&&ha++;if(0this.units[ja].power&&(0Math.abs(Q.value.re)),Q.units)Pa(Q.units,ha)&&Q.units[ha].unit&&("VA"===Q.units[ha].unit.name&&U?Q.units[ha].unit=na.VAR:"VAR"!==Q.units[ha].unit.name||U||(Q.units[ha].unit= +na.VA));1!==Q.units.length||Q.fixPrefix||1E-14>Math.abs(Q.units[0].power-Math.round(Q.units[0].power))&&(Q.units[0].prefix=Q._bestPrefix());U=Q._denormalize(Q.value);M=null!==Q.value?R(U,M||{}):"";U=Q.formatUnits();return Q.value&&rb(Q.value)&&(M="("+M+")"),0ja)return U;ja=Math.abs(ja);var wa=this.units[0].unit.prefixes,gb;for(gb in wa)if(Pa(wa,gb)){var Xa=wa[gb];if(Xa.scientific){var pb= +Math.abs(Math.log(M/Math.pow(Xa.value*Q,ha))/Math.LN10-1.2);(pb0)},na={meter:{name:"meter",base:S.LENGTH,prefixes:P.LONG,value:1,offset:0},inch:{name:"inch",base:S.LENGTH,prefixes:P.NONE,value:.0254,offset:0},foot:{name:"foot",base:S.LENGTH,prefixes:P.NONE,value:.3048,offset:0},yard:{name:"yard",base:S.LENGTH,prefixes:P.NONE,value:.9144,offset:0},mile:{name:"mile",base:S.LENGTH,prefixes:P.NONE,value:1609.344,offset:0},link:{name:"link",base:S.LENGTH,prefixes:P.NONE,value:.201168,offset:0},rod:{name:"rod", +base:S.LENGTH,prefixes:P.NONE,value:5.0292,offset:0},chain:{name:"chain",base:S.LENGTH,prefixes:P.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:S.LENGTH,prefixes:P.NONE,value:1E-10,offset:0},m:{name:"m",base:S.LENGTH,prefixes:P.SHORT,value:1,offset:0},in:{name:"in",base:S.LENGTH,prefixes:P.NONE,value:.0254,offset:0},ft:{name:"ft",base:S.LENGTH,prefixes:P.NONE,value:.3048,offset:0},yd:{name:"yd",base:S.LENGTH,prefixes:P.NONE,value:.9144,offset:0},mi:{name:"mi",base:S.LENGTH,prefixes:P.NONE, +value:1609.344,offset:0},li:{name:"li",base:S.LENGTH,prefixes:P.NONE,value:.201168,offset:0},rd:{name:"rd",base:S.LENGTH,prefixes:P.NONE,value:5.02921,offset:0},ch:{name:"ch",base:S.LENGTH,prefixes:P.NONE,value:20.1168,offset:0},mil:{name:"mil",base:S.LENGTH,prefixes:P.NONE,value:2.54E-5,offset:0},m2:{name:"m2",base:S.SURFACE,prefixes:P.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:S.SURFACE,prefixes:P.NONE,value:6.4516E-4,offset:0},sqft:{name:"sqft",base:S.SURFACE,prefixes:P.NONE,value:.09290304, +offset:0},sqyd:{name:"sqyd",base:S.SURFACE,prefixes:P.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:S.SURFACE,prefixes:P.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:S.SURFACE,prefixes:P.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:S.SURFACE,prefixes:P.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:S.SURFACE,prefixes:P.NONE,value:6.4516E-10,offset:0},acre:{name:"acre",base:S.SURFACE,prefixes:P.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:S.SURFACE, +prefixes:P.NONE,value:1E4,offset:0},m3:{name:"m3",base:S.VOLUME,prefixes:P.CUBIC,value:1,offset:0},L:{name:"L",base:S.VOLUME,prefixes:P.SHORT,value:.001,offset:0},l:{name:"l",base:S.VOLUME,prefixes:P.SHORT,value:.001,offset:0},litre:{name:"litre",base:S.VOLUME,prefixes:P.LONG,value:.001,offset:0},cuin:{name:"cuin",base:S.VOLUME,prefixes:P.NONE,value:1.6387064E-5,offset:0},cuft:{name:"cuft",base:S.VOLUME,prefixes:P.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:S.VOLUME,prefixes:P.NONE, +value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:S.VOLUME,prefixes:P.NONE,value:5E-6,offset:0},tablespoon:{name:"tablespoon",base:S.VOLUME,prefixes:P.NONE,value:1.5E-5,offset:0},drop:{name:"drop",base:S.VOLUME,prefixes:P.NONE,value:5E-8,offset:0},gtt:{name:"gtt",base:S.VOLUME,prefixes:P.NONE,value:5E-8,offset:0},minim:{name:"minim",base:S.VOLUME,prefixes:P.NONE,value:6.161152E-8,offset:0},fluiddram:{name:"fluiddram",base:S.VOLUME,prefixes:P.NONE,value:3.6966911E-6,offset:0},fluidounce:{name:"fluidounce", +base:S.VOLUME,prefixes:P.NONE,value:2.957353E-5,offset:0},gill:{name:"gill",base:S.VOLUME,prefixes:P.NONE,value:1.182941E-4,offset:0},cc:{name:"cc",base:S.VOLUME,prefixes:P.NONE,value:1E-6,offset:0},cup:{name:"cup",base:S.VOLUME,prefixes:P.NONE,value:2.365882E-4,offset:0},pint:{name:"pint",base:S.VOLUME,prefixes:P.NONE,value:4.731765E-4,offset:0},quart:{name:"quart",base:S.VOLUME,prefixes:P.NONE,value:9.463529E-4,offset:0},gallon:{name:"gallon",base:S.VOLUME,prefixes:P.NONE,value:.003785412,offset:0}, +beerbarrel:{name:"beerbarrel",base:S.VOLUME,prefixes:P.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:S.VOLUME,prefixes:P.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:S.VOLUME,prefixes:P.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:S.VOLUME,prefixes:P.NONE,value:3.6966911E-6,offset:0},floz:{name:"floz",base:S.VOLUME,prefixes:P.NONE,value:2.957353E-5,offset:0},gi:{name:"gi",base:S.VOLUME,prefixes:P.NONE,value:1.182941E-4,offset:0},cp:{name:"cp",base:S.VOLUME, +prefixes:P.NONE,value:2.365882E-4,offset:0},pt:{name:"pt",base:S.VOLUME,prefixes:P.NONE,value:4.731765E-4,offset:0},qt:{name:"qt",base:S.VOLUME,prefixes:P.NONE,value:9.463529E-4,offset:0},gal:{name:"gal",base:S.VOLUME,prefixes:P.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:S.VOLUME,prefixes:P.NONE,value:.1173478,offset:0},obl:{name:"obl",base:S.VOLUME,prefixes:P.NONE,value:.1589873,offset:0},g:{name:"g",base:S.MASS,prefixes:P.SHORT,value:.001,offset:0},gram:{name:"gram",base:S.MASS,prefixes:P.LONG, +value:.001,offset:0},ton:{name:"ton",base:S.MASS,prefixes:P.SHORT,value:907.18474,offset:0},t:{name:"t",base:S.MASS,prefixes:P.SHORT,value:1E3,offset:0},tonne:{name:"tonne",base:S.MASS,prefixes:P.LONG,value:1E3,offset:0},grain:{name:"grain",base:S.MASS,prefixes:P.NONE,value:6.479891E-5,offset:0},dram:{name:"dram",base:S.MASS,prefixes:P.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:S.MASS,prefixes:P.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:S.MASS,prefixes:P.NONE, +value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:S.MASS,prefixes:P.NONE,value:45.359237,offset:0},stick:{name:"stick",base:S.MASS,prefixes:P.NONE,value:.115,offset:0},stone:{name:"stone",base:S.MASS,prefixes:P.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:S.MASS,prefixes:P.NONE,value:6.479891E-5,offset:0},dr:{name:"dr",base:S.MASS,prefixes:P.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:S.MASS,prefixes:P.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:S.MASS, +prefixes:P.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:S.MASS,prefixes:P.NONE,value:45.359237,offset:0},s:{name:"s",base:S.TIME,prefixes:P.SHORT,value:1,offset:0},min:{name:"min",base:S.TIME,prefixes:P.NONE,value:60,offset:0},h:{name:"h",base:S.TIME,prefixes:P.NONE,value:3600,offset:0},second:{name:"second",base:S.TIME,prefixes:P.LONG,value:1,offset:0},sec:{name:"sec",base:S.TIME,prefixes:P.LONG,value:1,offset:0},minute:{name:"minute",base:S.TIME,prefixes:P.NONE,value:60,offset:0},hour:{name:"hour", +base:S.TIME,prefixes:P.NONE,value:3600,offset:0},day:{name:"day",base:S.TIME,prefixes:P.NONE,value:86400,offset:0},week:{name:"week",base:S.TIME,prefixes:P.NONE,value:604800,offset:0},month:{name:"month",base:S.TIME,prefixes:P.NONE,value:2629800,offset:0},year:{name:"year",base:S.TIME,prefixes:P.NONE,value:31557600,offset:0},decade:{name:"decade",base:S.TIME,prefixes:P.NONE,value:315576E3,offset:0},century:{name:"century",base:S.TIME,prefixes:P.NONE,value:315576E4,offset:0},millennium:{name:"millennium", +base:S.TIME,prefixes:P.NONE,value:315576E5,offset:0},hertz:{name:"Hertz",base:S.FREQUENCY,prefixes:P.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:S.FREQUENCY,prefixes:P.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:S.ANGLE,prefixes:P.SHORT,value:1,offset:0},radian:{name:"radian",base:S.ANGLE,prefixes:P.LONG,value:1,offset:0},deg:{name:"deg",base:S.ANGLE,prefixes:P.SHORT,value:null,offset:0},degree:{name:"degree",base:S.ANGLE,prefixes:P.LONG,value:null,offset:0},grad:{name:"grad", +base:S.ANGLE,prefixes:P.SHORT,value:null,offset:0},gradian:{name:"gradian",base:S.ANGLE,prefixes:P.LONG,value:null,offset:0},cycle:{name:"cycle",base:S.ANGLE,prefixes:P.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:S.ANGLE,prefixes:P.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:S.ANGLE,prefixes:P.NONE,value:null,offset:0},A:{name:"A",base:S.CURRENT,prefixes:P.SHORT,value:1,offset:0},ampere:{name:"ampere",base:S.CURRENT,prefixes:P.LONG,value:1,offset:0},K:{name:"K",base:S.TEMPERATURE, +prefixes:P.NONE,value:1,offset:0},degC:{name:"degC",base:S.TEMPERATURE,prefixes:P.NONE,value:1,offset:273.15},degF:{name:"degF",base:S.TEMPERATURE,prefixes:P.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:S.TEMPERATURE,prefixes:P.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:S.TEMPERATURE,prefixes:P.NONE,value:1,offset:0},celsius:{name:"celsius",base:S.TEMPERATURE,prefixes:P.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:S.TEMPERATURE,prefixes:P.NONE,value:1/1.8,offset:459.67}, +rankine:{name:"rankine",base:S.TEMPERATURE,prefixes:P.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:S.AMOUNT_OF_SUBSTANCE,prefixes:P.SHORT,value:1,offset:0},mole:{name:"mole",base:S.AMOUNT_OF_SUBSTANCE,prefixes:P.LONG,value:1,offset:0},cd:{name:"cd",base:S.LUMINOUS_INTENSITY,prefixes:P.SHORT,value:1,offset:0},candela:{name:"candela",base:S.LUMINOUS_INTENSITY,prefixes:P.LONG,value:1,offset:0},N:{name:"N",base:S.FORCE,prefixes:P.SHORT,value:1,offset:0},newton:{name:"newton",base:S.FORCE,prefixes:P.LONG, +value:1,offset:0},dyn:{name:"dyn",base:S.FORCE,prefixes:P.SHORT,value:1E-5,offset:0},dyne:{name:"dyne",base:S.FORCE,prefixes:P.LONG,value:1E-5,offset:0},lbf:{name:"lbf",base:S.FORCE,prefixes:P.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:S.FORCE,prefixes:P.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:S.FORCE,prefixes:P.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:S.FORCE,prefixes:P.NONE,value:9.80665,offset:0},J:{name:"J",base:S.ENERGY, +prefixes:P.SHORT,value:1,offset:0},joule:{name:"joule",base:S.ENERGY,prefixes:P.SHORT,value:1,offset:0},erg:{name:"erg",base:S.ENERGY,prefixes:P.NONE,value:1E-7,offset:0},Wh:{name:"Wh",base:S.ENERGY,prefixes:P.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:S.ENERGY,prefixes:P.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:S.ENERGY,prefixes:P.SHORT,value:1.602176565E-19,offset:0},electronvolt:{name:"electronvolt",base:S.ENERGY,prefixes:P.LONG,value:1.602176565E-19,offset:0},W:{name:"W",base:S.POWER, +prefixes:P.SHORT,value:1,offset:0},watt:{name:"watt",base:S.POWER,prefixes:P.LONG,value:1,offset:0},hp:{name:"hp",base:S.POWER,prefixes:P.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:S.POWER,prefixes:P.SHORT,value:ca.I,offset:0},VA:{name:"VA",base:S.POWER,prefixes:P.SHORT,value:1,offset:0},Pa:{name:"Pa",base:S.PRESSURE,prefixes:P.SHORT,value:1,offset:0},psi:{name:"psi",base:S.PRESSURE,prefixes:P.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:S.PRESSURE,prefixes:P.NONE,value:101325, +offset:0},bar:{name:"bar",base:S.PRESSURE,prefixes:P.SHORTLONG,value:1E5,offset:0},torr:{name:"torr",base:S.PRESSURE,prefixes:P.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:S.PRESSURE,prefixes:P.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:S.PRESSURE,prefixes:P.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:S.PRESSURE,prefixes:P.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:S.ELECTRIC_CHARGE,prefixes:P.LONG,value:1,offset:0},C:{name:"C",base:S.ELECTRIC_CHARGE,prefixes:P.SHORT, +value:1,offset:0},farad:{name:"farad",base:S.ELECTRIC_CAPACITANCE,prefixes:P.LONG,value:1,offset:0},F:{name:"F",base:S.ELECTRIC_CAPACITANCE,prefixes:P.SHORT,value:1,offset:0},volt:{name:"volt",base:S.ELECTRIC_POTENTIAL,prefixes:P.LONG,value:1,offset:0},V:{name:"V",base:S.ELECTRIC_POTENTIAL,prefixes:P.SHORT,value:1,offset:0},ohm:{name:"ohm",base:S.ELECTRIC_RESISTANCE,prefixes:P.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:S.ELECTRIC_INDUCTANCE,prefixes:P.LONG,value:1,offset:0},H:{name:"H", +base:S.ELECTRIC_INDUCTANCE,prefixes:P.SHORT,value:1,offset:0},siemens:{name:"siemens",base:S.ELECTRIC_CONDUCTANCE,prefixes:P.LONG,value:1,offset:0},S:{name:"S",base:S.ELECTRIC_CONDUCTANCE,prefixes:P.SHORT,value:1,offset:0},weber:{name:"weber",base:S.MAGNETIC_FLUX,prefixes:P.LONG,value:1,offset:0},Wb:{name:"Wb",base:S.MAGNETIC_FLUX,prefixes:P.SHORT,value:1,offset:0},tesla:{name:"tesla",base:S.MAGNETIC_FLUX_DENSITY,prefixes:P.LONG,value:1,offset:0},T:{name:"T",base:S.MAGNETIC_FLUX_DENSITY,prefixes:P.SHORT, +value:1,offset:0},b:{name:"b",base:S.BIT,prefixes:P.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:S.BIT,prefixes:P.BINARY_LONG,value:1,offset:0},B:{name:"B",base:S.BIT,prefixes:P.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:S.BIT,prefixes:P.BINARY_LONG,value:8,offset:0}};b={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"};n(r);q&&q("config",function(M,Q){M.number!==Q.number&&n(M)});var X={si:{NONE:{unit:ob,prefix:P.NONE[""]},LENGTH:{unit:na.m,prefix:P.SHORT[""]},MASS:{unit:na.g,prefix:P.SHORT.k},TIME:{unit:na.s,prefix:P.SHORT[""]},CURRENT:{unit:na.A,prefix:P.SHORT[""]},TEMPERATURE:{unit:na.K,prefix:P.SHORT[""]},LUMINOUS_INTENSITY:{unit:na.cd,prefix:P.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:na.mol,prefix:P.SHORT[""]}, +ANGLE:{unit:na.rad,prefix:P.SHORT[""]},BIT:{unit:na.bits,prefix:P.SHORT[""]},FORCE:{unit:na.N,prefix:P.SHORT[""]},ENERGY:{unit:na.J,prefix:P.SHORT[""]},POWER:{unit:na.W,prefix:P.SHORT[""]},PRESSURE:{unit:na.Pa,prefix:P.SHORT[""]},ELECTRIC_CHARGE:{unit:na.C,prefix:P.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:na.F,prefix:P.SHORT[""]},ELECTRIC_POTENTIAL:{unit:na.V,prefix:P.SHORT[""]},ELECTRIC_RESISTANCE:{unit:na.ohm,prefix:P.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:na.H,prefix:P.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:na.S, +prefix:P.SHORT[""]},MAGNETIC_FLUX:{unit:na.Wb,prefix:P.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:na.T,prefix:P.SHORT[""]},FREQUENCY:{unit:na.Hz,prefix:P.SHORT[""]}}};X.cgs=JSON.parse(JSON.stringify(X.si));X.cgs.LENGTH={unit:na.m,prefix:P.SHORT.c};X.cgs.MASS={unit:na.g,prefix:P.SHORT[""]};X.cgs.FORCE={unit:na.dyn,prefix:P.SHORT[""]};X.cgs.ENERGY={unit:na.erg,prefix:P.NONE[""]};X.us=JSON.parse(JSON.stringify(X.si));X.us.LENGTH={unit:na.ft,prefix:P.NONE[""]};X.us.MASS={unit:na.lbm,prefix:P.NONE[""]};X.us.TEMPERATURE= +{unit:na.degF,prefix:P.NONE[""]};X.us.FORCE={unit:na.lbf,prefix:P.NONE[""]};X.us.ENERGY={unit:na.BTU,prefix:P.BTU[""]};X.us.POWER={unit:na.hp,prefix:P.NONE[""]};X.us.PRESSURE={unit:na.psi,prefix:P.NONE[""]};X.auto=JSON.parse(JSON.stringify(X.si));var da=X.auto;for(Ha in a.setUnitSystem=function(M){if(!Pa(X,M))throw Error("Unit system "+M+" does not exist. Choices are: "+Object.keys(X).join(", "));da=X[M]},a.getUnitSystem=function(){for(var M in X)if(Pa(X,M)&&X[M]===da)return M},a.typeConverters={BigNumber:function(M){return new ka(M+ +"")},Fraction:function(M){return new Ea(M)},Complex:function(M){return M},number:function(M){return M}},a._getNumberConverter=function(M){if(!a.typeConverters[M])throw new TypeError('Unsupported type "'+M+'"');return a.typeConverters[M]},na)if(Pa(na,Ha)){var ua=na[Ha];ua.dimensions=ua.base.dimensions}for(var Da in b)if(Pa(b,Da)){var Ha=na[b[Da]];ua={};for(var Ka in Ha)Pa(Ha,Ka)&&(ua[Ka]=Ha[Ka]);ua.name=Da;na[Da]=ua}return a.isValidAlpha=function(M){return/^[a-zA-Z]$/.test(M)},a.createUnit=function(M, +Q){if("object"!=typeof M)throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(Q&&Q.override)for(var U in M)if(Pa(M,U)&&a.deleteUnit(U),M[U].aliases)for(Q=0;Q{var {typed:a,Unit:d}=b;return a("createUnit",{"Object, Object":function(c,f){return d.createUnit(c,f)},Object:function(c){return d.createUnit(c,{})},"string, Unit | string | Object, Object":function(c,f,h){var l={};return l[c]=f,d.createUnit(l,h)},"string, Unit | string | Object":function(c, +f){var h={};return h[c]=f,d.createUnit(h,{})},string:function(c){var f={};return f[c]={},d.createUnit(f,{})}})}),Zo=B("eigs","config typed matrix addScalar equal subtract abs atan cos sin multiplyScalar divideScalar inv bignumber multiply add larger column flatten number complex sqrt diag qr usolveAll im re smaller round log10 transpose matrixFromColumns".split(" "),b=>{function a(da,ua){void 0===ua&&(ua=c.epsilon);var Da=da.size();if(2!==Da.length||Da[0]!==Da[1])throw new RangeError("Matrix must be square (size: "+ +Db(Da)+")");var Ha=da.toArray();Da=Da[0];if(function(Ka,M,Q){for(var U=0;U=Math.abs(dc);){var kb=$a[0][0];Ya=$a[0][1];var Wa=Ja,tb=(Ub=Ja[kb][kb],bc=Ja[Ya][Ya],hb=Ja[kb][Ya],oa=void 0,oa=bc-Ub,$a=Math.abs(oa)<=M.epsilon?Math.PI/4:.5*Math.atan(2*hb/(bc-Ub)));Ja=kb;var ib=Ya,oc=Wa.length,bb=Math.cos(tb),ec=Math.sin(tb),nc=bb*bb,ab=ec*ec;tb=Ka(oc,0);var Ib=Ka(oc,0),ac=nc*Wa[Ja][Ja]-2*bb*ec*Wa[Ja][ib]+ab*Wa[ib][ib];nc=ab*Wa[Ja][Ja]+2*bb*ec*Wa[Ja][ib]+nc*Wa[ib][ib];for(ab=0;ab=ha(bc);){oa=Ja[0][0];Ja=Ja[0][1];Wa=kb;tb=(Eb=kb[oa][oa],dc=kb[Ja][Ja],$a=kb[oa][Ja],Ab=void 0,Ab=U(dc,Eb),Ya=ha(Ab)<=M.epsilon?sb(-1).acos().div(4):Xa(.5,ja(G(2,$a,pb(Ab)))));kb=oa;ib=Ja;oc=Wa.length;bb=sb(wa(tb));ec=sb(gb(tb));nc=Xa(bb,bb);ab=Xa(ec,ec);tb=Ka(oc,sb(0));Ib=Ka(oc,sb(0));var wb=G(sb(2),bb,ec,Wa[kb][ib]);ac=Q(U(Xa(nc, +Wa[kb][kb]),wb),Xa(ab,Wa[ib][ib]));nc=ma(Xa(ab,Wa[kb][kb]),wb,Xa(nc,Wa[ib][ib]));for(ab=0;ab=re;){re+=1;for(var ic=0;ic+M(gb(Rd),gb(Ed))),100U(ac,yc))).shift();qc.lengthQ(yc)))}if(0!==Jb.length)throw ab=Error("Failed to find eigenvectors for the following eigenvalues: "+Jb.join(", ")),ab.values=Ub,ab.vectors=bc,ab;return bc}(Ab,kb,nc,ec,Wa),bb=dc(...bb)),{values:ec,vectors:bb}}}({config:c,addScalar:l,subtract:p,multiply:v,multiplyScalar:q,flatten:I,divideScalar:r,sqrt:O,abs:n,bignumber:y,diag:R,qr:ba,inv:u,usolveAll:ca, +equal:k,complex:L,larger:w,smaller:Ga,round:P,log10:Ma,transpose:S,matrixFromColumns:ob});return f("eigs",{Array:function(da){return a(h(da))},"Array, number|BigNumber":function(da,ua){return a(h(da),ua)},Matrix:function(da){var {values:ua,vectors:Da}=a(da);return{values:h(ua),vectors:h(Da)}},"Matrix, number|BigNumber":function(da,ua){var {values:Da,vectors:Ha}=a(da,ua);return{values:h(Da),vectors:h(Ha)}}})}),$o=B("intersect","typed config abs add addScalar matrix multiply multiplyScalar divideScalar subtract smaller equalScalar".split(" "), +b=>{function a(v){return"number"==typeof v||pa(v)}function d(v){return 2===v.length&&a(v[0])&&a(v[1])}function c(v){return 3===v.length&&a(v[0])&&a(v[1])&&a(v[2])}function f(v,t,w,z,I,F,L,O,R,ba,ca,ka){v=m(r(v,t),r(w,z));I=m(r(I,F),r(L,O));R=m(r(R,ba),r(ca,ka));return n(n(v,I),R)}var {typed:h,config:l,abs:p,add:k,addScalar:n,matrix:g,multiply:e,multiplyScalar:m,divideScalar:q,subtract:r,smaller:u,equalScalar:y}=b;return h("intersect",{"Array, Array, Array":function(v,t,w){if(!c(v))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument"); +if(!c(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!function(z){return 4===z.length&&a(z[0])&&a(z[1])&&a(z[2])&&a(z[3])}(w))throw new TypeError("Array with 4 numbers expected as third argument");return function(z,I,F,L,O,R,ba,ca,ka,Ea){var Ga=m(z,ba);ba=m(L,ba);var P=m(I,ca);ca=m(O,ca);var Ma=m(F,ka);ka=m(R,ka);Ea=q(r(r(r(Ea,Ga),P),Ma),r(r(r(n(n(ba,ca),ka),Ga),P),Ma));return[n(z,m(Ea,r(L,z))),n(I,m(Ea,r(O,I))),n(F,m(Ea,r(R,F)))]}(v[0],v[1],v[2],t[0], +t[1],t[2],w[0],w[1],w[2],w[3])},"Array, Array, Array, Array":function(v,t,w,z){if(2===v.length){if(!d(v))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!d(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!d(w))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!d(z))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");t=r(v,t);var I=r(w,z);z= +r(m(t[0],I[1]),m(I[0],t[1]));if(u(p(z),l.epsilon))v=null;else{var F=m(I[0],v[1]),L=m(I[1],v[0]),O=m(I[0],w[1]);w=m(I[1],w[0]);w=q(n(r(r(F,L),O),w),z);v=k(e(t,w),v)}return v}if(3===v.length){if(!c(v))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!c(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!c(w))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!c(z))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument"); +return F=v[0],L=v[1],O=v[2],I=t[0],R=t[1],ba=t[2],ca=w[0],ka=w[1],Ea=w[2],S=f(F,ca,Ga=z[0],ca,L,ka,P=z[1],ka,O,Ea,Ma=z[2],Ea),ob=f(Ga,ca,I,F,P,ka,R,L,Ma,Ea,ba,O),na=f(F,ca,I,F,L,ka,R,L,O,Ea,ba,O),X=f(Ga,ca,Ga,ca,P,ka,P,ka,Ma,Ea,Ma,Ea),da=f(I,F,I,F,R,L,R,L,ba,O,ba,O),ua=q(r(m(S,ob),m(na,X)),r(m(da,X),m(ob,ob))),Da=q(n(S,m(ua,ob)),X),Ha=n(F,m(ua,r(I,F))),Ka=n(L,m(ua,r(R,L))),M=n(O,m(ua,r(ba,O))),Q=n(ca,m(Da,r(Ga,ca))),U=n(ka,m(Da,r(P,ka))),ha=n(Ea,m(Da,r(Ma,Ea))),y(Ha,Q)&&y(Ka,U)&&y(M,ha)?[Ha,Ka,M]: +null}throw new TypeError("Arrays with two or thee dimensional points expected");var R,ba,ca,ka,Ea,Ga,P,Ma,S,ob,na,X,da,ua,Da,Ha,Ka,M,Q,U,ha},"Matrix, Matrix, Matrix":function(v,t,w){return g(this(v.valueOf(),t.valueOf(),w.valueOf()))},"Matrix, Matrix, Matrix, Matrix":function(v,t,w,z){return g(this(v.valueOf(),t.valueOf(),w.valueOf(),z.valueOf()))}})}),ap=B("usolve","typed matrix divideScalar multiplyScalar subtract equalScalar DenseMatrix".split(" "),b=>{function a(g,e){e=n(g,e,!0)._data;var m=g._size[0], +q=[],r=g._data;for(g=g._size[1]-1;0<=g;g--){var u=e[g][0]||0;if(p(u,0))u=0;else{var y=r[g][g];if(p(y,0))throw Error("Linear system cannot be solved since matrix is singular");u=f(u,y);for(y=g-1;0<=y;y--)e[y]=[l(e[y][0]||0,h(u,r[y][g]))]}q[g]=[u]}return new k({data:q,size:[m,1]})}var {typed:d,matrix:c,divideScalar:f,multiplyScalar:h,subtract:l,equalScalar:p,DenseMatrix:k}=b,n=pe({DenseMatrix:k});return d("usolve",{"SparseMatrix, Array | Matrix":function(g,e){e=n(g,e,!0)._data;var m=g._size[0],q=g._values, +r=g._index,u=g._ptr,y=[];for(g=g._size[1]-1;0<=g;g--){var v=e[g][0]||0;if(p(v,0))y[g]=[0];else{for(var t=0,w=[],z=[],I=u[g],F=u[g+1]-1;F>=I;F--){var L=r[F];L===g?t=q[F]:L{function a(u,y){var v=u.size();if(1===v.length)return function(t,w){if(w===Number.POSITIVE_INFINITY||"inf"===w)return function(I){var F=0;return I.forEach(function(L){L=c(L);g(L,F)&&(F=L)},!0),F}(t);if(w===Number.NEGATIVE_INFINITY||"-inf"===w)return function(I){var F;return I.forEach(function(L){L=c(L);F&&!e(L,F)||(F=L)},!0),F||0}(t);if("fro"===w)return a(t,2);if("number"== +typeof w&&!isNaN(w)){if(!n(w,0)){var z=0;return t.forEach(function(I){z=f(h(c(I),w),z)},!0),h(z,1/w)}return Number.POSITIVE_INFINITY}throw Error("Unsupported parameter value");}(u,y);if(2===v.length){if(v[0]&&v[1])return function(t,w){if(1===w)return function(z){var I=[],F=0;return z.forEach(function(L,O){O=O[1];L=f(I[O]||0,c(L));g(L,F)&&(F=L);I[O]=L},!0),F}(t);if(w===Number.POSITIVE_INFINITY||"inf"===w)return function(z){var I=[],F=0;return z.forEach(function(L,O){O=O[0];L=f(I[O]||0,c(L));g(L,F)&& +(F=L);I[O]=L},!0),F}(t);if("fro"===w)return function(z){var I=0;return z.forEach(function(F,L){I=f(I,k(F,l(F)))}),c(p(I))}(t);if(2===w)return function(z){var I=z.size();if(I[0]!==I[1])throw new RangeError("Invalid matrix dimensions");I=q(z);z=k(I,z);z=r(z).values.toArray();return c(p(z[z.length-1]))}(t);throw Error("Unsupported parameter value "+w);}(u,y);throw new RangeError("Invalid matrix dimensions");}}var {typed:d,abs:c,add:f,pow:h,conj:l,sqrt:p,multiply:k,equalScalar:n,larger:g,smaller:e,matrix:m, +ctranspose:q,eigs:r}=b;return d("norm",{number:Math.abs,Complex:function(u){return u.abs()},BigNumber:function(u){return u.abs()},boolean:function(u){return Math.abs(u)},Array:function(u){return a(m(u),2)},Matrix:function(u){return a(u,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(u){return this(u)},"Array, number | BigNumber | string":function(u,y){return a(m(u),y)},"Matrix, number | BigNumber | string":function(u,y){return a(u,y)}})}),cp=B("lusolve","typed matrix lup slu usolve lsolve DenseMatrix".split(" "), +b=>{function a(e){if(Fa(e))return e;if($b(e))return f(e);throw new TypeError("Invalid Matrix LU decomposition");}function d(e,m,q,r,u){e=a(e);m=a(m);q&&((u=g(e,u,!0))._data=Lg(q,u._data));e=k(e,u);m=p(m,e);return r&&(m._data=Lg(r,m._data)),m}var {typed:c,matrix:f,lup:h,slu:l,usolve:p,lsolve:k,DenseMatrix:n}=b,g=pe({DenseMatrix:n});return c("lusolve",{"Array, Array | Matrix":function(e,m){e=f(e);e=h(e);return d(e.L,e.U,e.p,null,m).valueOf()},"DenseMatrix, Array | Matrix":function(e,m){e=h(e);return d(e.L, +e.U,e.p,null,m)},"SparseMatrix, Array | Matrix":function(e,m){e=h(e);return d(e.L,e.U,e.p,null,m)},"SparseMatrix, Array | Matrix, number, number":function(e,m,q,r){e=l(e,q,r);return d(e.L,e.U,e.p,e.q,m)},"Object, Array | Matrix":function(e,m){return d(e.L,e.U,e.p,e.q,m)}})}),dp=B("sqrtm","typed abs add multiply sqrt subtract inv size max identity".split(" "),b=>{var {typed:a,abs:d,add:c,multiply:f,sqrt:h,subtract:l,inv:p,size:k,max:n,identity:g}=b;return a("sqrtm",{"Array | Matrix":function(e){var m= +Fa(e)?e.size():Ua(e);switch(m.length){case 1:if(1===m[0])return h(e);throw new RangeError("Matrix must be square (size: "+Db(m)+")");case 2:if(m[0]===m[1]){m=0;var q=e,r=g(k(e));do{var u=q;if(q=f(.5,c(u,p(r))),r=f(.5,c(r,p(u))),1E-6<(e=n(d(l(q,u))))&&1E3<++m)throw Error("computing square root of matrix: iterative method could not converge");}while(1E-6{var {typed:a,add:d,divide:c,multiply:f,factorial:h,isInteger:l,isPositive:p}=b;return a("multinomial",{"Array | Matrix":function(k){var n=0,g=1;return Zb(k,function(e){if(!l(e)||!p(e))throw new TypeError("Positive integer value expected in function multinomial");n=d(n,e);g=f(g,h(e))}),c(h(n),g)}})}),fp=B("rotationMatrix","typed config multiplyScalar addScalar unaryMinus norm matrix BigNumber DenseMatrix SparseMatrix cos sin".split(" "), +b=>{function a(t,w){var z=pa(t)?new m(-1):-1,I=y(t);t=v(t);return f([[I,k(z,t)],[t,I]],w)}function d(t){t=t.size();if(1>t.length||3!==t[0])throw new RangeError("Vector must be of dimensions 1x3");}function c(t){return t.reduce((w,z)=>k(w,z))}function f(t,w){if(w){if("sparse"===w)return new u(t);if("dense"===w)return new r(t);throw new TypeError('Unknown matrix type "'.concat(w,'"'));}return t}function h(t,w,z){var I=e(w);if(0===I)throw new RangeError("Rotation around zero vector");var F=pa(t)?m:null, +L=F?new F(1):1,O=F?new F(-1):-1,R=F?new F(w.get([0])/I):w.get([0])/I,ba=F?new F(w.get([1])/I):w.get([1])/I;w=F?new F(w.get([2])/I):w.get([2])/I;I=y(t);L=n(L,g(I));t=v(t);return f([[n(I,c([R,R,L])),n(c([R,ba,L]),c([O,w,t])),n(c([R,w,L]),c([ba,t]))],[n(c([R,ba,L]),c([w,t])),n(I,c([ba,ba,L])),n(c([ba,w,L]),c([O,R,t]))],[n(c([R,w,L]),c([O,ba,t])),n(c([ba,w,L]),c([R,t])),n(I,c([w,w,L]))]],z)}var {typed:l,config:p,multiplyScalar:k,addScalar:n,unaryMinus:g,norm:e,BigNumber:m,matrix:q,DenseMatrix:r,SparseMatrix:u, +cos:y,sin:v}=b;return l("rotationMatrix",{"":function(){return"Matrix"===p.matrix?q([]):[]},string:function(t){return q(t)},"number | BigNumber | Complex | Unit":function(t){return a(t,"Matrix"===p.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(t,w){return a(t,w)},"number | BigNumber | Complex | Unit, Array":function(t,w){w=q(w);return d(w),h(t,w,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(t,w){d(w);var z=w.storage()||("Matrix"===p.matrix?"dense": +void 0);return h(t,w,z)},"number | BigNumber | Complex | Unit, Array, string":function(t,w,z){w=q(w);return d(w),h(t,w,z)},"number | BigNumber | Complex | Unit, Matrix, string":function(t,w,z){return d(w),h(t,w,z)}})}),gp=B("median",["typed","add","divide","compare","partitionSelect"],b=>{function a(n){try{var g=(n=C(n.valueOf())).length;if(0===g)throw Error("Cannot calculate median of an empty array");if(0==g%2){g=g/2-1;for(var e=l(n,g+1),m=n[g],q=0;q{function a(h,l){h=Array.isArray(h)?Ua(h):h.size();if(2{function a(p){if(0===(p=C(p.valueOf())).length)throw Error("Cannot calculate median absolute deviation (mad) of an empty array"); +try{var k=h(p);return h(f(p,function(n){return c(l(n,k))}))}catch(n){throw n instanceof TypeError&&-1!==n.message.indexOf("median")?new TypeError(n.message.replace("median","mad")):Tc(n,"mad");}}var {typed:d,abs:c,map:f,median:h,subtract:l}=b;return d("mad",{"Array | Matrix":a,"...":function(p){return a(p)}})}),jp=B("unit",["typed","Unit"],b=>{var {typed:a,Unit:d}=b;return a("unit",{Unit:function(c){return c.clone()},string:function(c){return d.isValuelessUnit(c)?new d(null,c):d.parse(c,{allowNoUnits:!0})}, +"number | BigNumber | Fraction | Complex, string":function(c,f){return new d(c,f)},"Array | Matrix":function(c){return Na(c,this)}})}),mh=Lj({}),mc=Mj({}),nh=Nj({}),kp=Vj({}),lp=Wj({}),mp=Uj({}),La=lk({config:sa}),Oe=mk({}),np=nk({}),op=jk({Complex:mc}),pp=ek({BigNumber:La,config:sa}),qp=gk({BigNumber:La,config:sa}),rp=Yj({BigNumber:La,config:sa}),oh=Zj({BigNumber:La,config:sa}),sp=hk({BigNumber:La,config:sa}),tp=ak({BigNumber:La,config:sa}),up=Qk({BigNumber:La,config:sa}),vp=Hk({BigNumber:La,config:sa}), +wp=$k({BigNumber:La,config:sa}),xp=Pk({BigNumber:La,config:sa}),Sd=ll({}),ph=bk({BigNumber:La,config:sa}),yp=Xj({BigNumber:La,config:sa}),zp=fk({BigNumber:La,config:sa}),Ap=kk({}),Kb=ml({Matrix:Oe}),Bp=ck({BigNumber:La,config:sa}),W=nl({BigNumber:La,Complex:mc,DenseMatrix:Kb,Fraction:Sd}),cd=ol({typed:W}),ge=pl({typed:W}),Pe=ql({typed:W}),se=rl({typed:W}),Qb=sl({config:sa,typed:W}),Td=tl({typed:W}),Cp=ul({typed:W}),Qe=vl({Complex:mc,typed:W}),Dp=wl({typed:W}),Ep=xl({BigNumber:La,config:sa,typed:W}), +nf=Ug({isInteger:cd,typed:W}),Fp=yl({typed:W}),Gp=zl({Complex:mc,typed:W}),qh=Al({Complex:mc,config:sa,typed:W}),sc=Bl({typed:W}),rh=Cl({BigNumber:La,Fraction:Sd,complex:Qe,typed:W}),Hp=Dl({typed:W}),Ip=El({typed:W}),Jp=Fl({typed:W}),sh=Gl({typed:W}),th=Hl({typed:W}),Kp=Il({typed:W}),Lp=Jl({typed:W}),uh=Kl({typed:W}),Mp=Ol({typed:W}),te=Pl({typed:W}),Np=Ql({format:te,typed:W}),Op=Rl({typed:W}),Pp=Sl({typed:W}),Qp=Tl({Complex:mc,config:sa,typed:W}),Rp=Ul({BigNumber:La,typed:W}),Sp=Vl({BigNumber:La, +Complex:mc,config:sa,typed:W}),Tp=Wl({BigNumber:La,Complex:mc,config:sa,typed:W}),Up=Xl({Complex:mc,config:sa,typed:W}),vh=Yl({typed:W}),Vp=Zl({Complex:mc,config:sa,typed:W}),Wp=$l({typed:W}),Xp=am({BigNumber:La,typed:W}),Yp=bm({BigNumber:La,typed:W}),Zp=cm({BigNumber:La,typed:W}),$p=dm({typed:W}),aq=em({typed:W}),Re=fm({typed:W}),bq=gm({config:sa,typed:W}),cq=hm({config:sa,typed:W}),dq=dk({BigNumber:La,config:sa}),eq=im({typed:W}),fq=jm({isNumeric:ge,typed:W}),gq=km({typed:W}),hq=lm({typed:W}),ue= +mm({Fraction:Sd,typed:W}),rd=nm({typed:W}),zc=om({typed:W}),iq=pm({typed:W}),jq=qm({Complex:mc,config:sa,typed:W}),sd=rm({Complex:mc,config:sa,typed:W}),ve=sm({typed:W}),kq=tm({typed:W}),lq=um({isNaN:se,isNumeric:ge,typed:W}),mq=vm({format:te,typed:W}),nq=wm({Complex:mc,config:sa,typed:W}),oq=xm({BigNumber:La,typed:W}),pq=ym({typed:W}),of=zm({typed:W}),qq=Am({BigNumber:La,typed:W}),pf=Bm({typed:W}),rq=Cm({typed:W}),sq=Dm({config:sa,typed:W}),tq=ik({BigNumber:La,config:sa}),he=Em({typed:W}),td=Fm({Matrix:Oe, +equalScalar:Qb,typed:W}),Ta=Gm({DenseMatrix:Kb,Matrix:Oe,SparseMatrix:td,typed:W}),Vc=Hm({typed:W}),uq=Im({BigNumber:La,DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,typed:W}),vq=Jm({DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,typed:W}),wq=Km({BigNumber:La,equalScalar:Qb,matrix:Ta,typed:W}),xq=Lm({BigNumber:La,config:sa,matrix:Ta,typed:W}),yq=Mm({equalScalar:Qb,matrix:Ta,typed:W}),zq=Nm({DenseMatrix:Kb,matrix:Ta,typed:W}),Aq=Om({DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,typed:W}),qf=Wg({isInteger:cd,matrix:Ta, +typed:W}),wh=Pm({DenseMatrix:Kb,SparseMatrix:td,matrix:Ta,typed:W}),ie=Qm({BigNumber:La,DenseMatrix:Kb,SparseMatrix:td,config:sa,matrix:Ta,typed:W}),Bq=Rm({BigNumber:La,config:sa,matrix:Ta,typed:W}),Cq=Sm({isInteger:cd,matrix:Ta,typed:W}),Hc=Tm({matrix:Ta,config:sa,typed:W}),Xc=Vg({matrix:Ta,typed:W}),Ud=Um({BigNumber:La,config:sa,matrix:Ta,typed:W}),Dq=Vm({format:te,typed:W}),we=Xm({BigNumber:La,DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,typed:W,zeros:Ud}),Eq=Ym({DenseMatrix:Kb,equalScalar:Qb,matrix:Ta, +typed:W,zeros:Ud}),Fq=Zm({DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,typed:W,zeros:Ud}),je=$m({BigNumber:La,DenseMatrix:Kb,Fraction:Sd,config:sa,equalScalar:Qb,matrix:Ta,typed:W}),xh=an({matrix:Ta,typed:W}),dd=bn({DenseMatrix:Kb,config:sa,matrix:Ta,typed:W}),Yc=cn({DenseMatrix:Kb,config:sa,matrix:Ta,typed:W}),Gq=dn({DenseMatrix:Kb,config:sa,equalScalar:Qb,matrix:Ta,typed:W}),yh=en({DenseMatrix:Kb,smaller:dd}),zh=fn({larger:Yc,smaller:dd}),Hq=gn({SparseMatrix:td,typed:W}),Iq=hn({BigNumber:La,Complex:mc, +config:sa,typed:W}),Jq=jn({BigNumber:La,DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,typed:W}),Kq=kn({BigNumber:La,typed:W}),Ac=ln({DenseMatrix:Kb,SparseMatrix:td,addScalar:zc,equalScalar:Qb,matrix:Ta,typed:W}),Ah=mn({addScalar:zc,conj:ve,multiplyScalar:sc,size:Hc,typed:W}),Lq=nn({addScalar:zc,combinations:Re,isInteger:cd,isNegative:he,isPositive:Pe,larger:Yc,typed:W}),Vd=on({typed:W}),Mq=pn({isZero:Vd,matrix:Ta,typed:W}),Nq=qn({BigNumber:La,Complex:mc,Fraction:Sd,config:sa,isNegative:he,matrix:Ta,typed:W, +unaryMinus:rd}),Bh=rn({config:sa,equalScalar:Qb,matrix:Ta,round:we,typed:W}),vc=sn({addScalar:zc,dot:Ah,equalScalar:Qb,matrix:Ta,multiplyScalar:sc,typed:W}),Oq=tn({equalScalar:Qb,matrix:Ta,multiplyScalar:sc,typed:W}),Ch=un({typed:W}),Se=vn({matrix:Ta,typed:W}),Pq=wn({config:sa,matrix:Ta}),Qq=xn({matrix:Ta,typed:W}),Rq=yn({matrix:Ta,typed:W}),Gd=zn({Complex:mc,config:sa,fraction:ue,identity:ie,matrix:Ta,multiply:vc,number:Td,typed:W}),Sq=An({DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,pow:Gd,typed:W}), +Tq=Bn({DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,typed:W,zeros:Ud}),ld=Cn({compare:je,typed:W}),Uq=Dn({compareText:xh,isZero:Vd,typed:W}),Te=En({DenseMatrix:Kb,config:sa,matrix:Ta,typed:W}),rf=Fn({compare:je,isNaN:se,isNumeric:ge,typed:W}),Ic=Gn({ImmutableDenseMatrix:yh}),Vq=Hn({BigNumber:La,Complex:mc,config:sa,typed:W}),Wq=In({typed:W}),Dh=Jn({DenseMatrix:Kb,Index:Ic,compareNatural:ld,size:Hc,subset:Xc,typed:W}),Eh=Kn({DenseMatrix:Kb,Index:Ic,compareNatural:ld,size:Hc,subset:Xc,typed:W}),Xq=Ln({Index:Ic, +compareNatural:ld,size:Hc,subset:Xc,typed:W}),Yq=Mn({compareNatural:ld,typed:W}),Zq=Nn({add:Ac,matrix:Ta,typed:W}),$q=On({add:Ac,compare:je,multiply:vc,partitionSelect:rf,typed:W}),Fh=Pn({BigNumber:La,Complex:mc,config:sa,multiplyScalar:sc,pow:Gd,typed:W}),Hd=Qn({BigNumber:La,typed:W}),Gh=Rn({flatten:Se,matrix:Ta,size:Hc,typed:W}),ar=Sn({equalScalar:Qb,matrix:Ta,typed:W}),br=Tn({DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,typed:W}),cr=Un({matrix:Ta,multiplyScalar:sc,typed:W}),Ue=Vn({matrix:Ta,typed:W}), +ed=Wn({bignumber:Hd,fraction:ue,number:Td}),dr=Xn({equalScalar:Qb,matrix:Ta,not:th,typed:W,zeros:Ud}),sf=Yn({DenseMatrix:Kb,config:sa,matrix:Ta,typed:W}),er=Zn({compare:je,compareNatural:ld,matrix:Ta,typed:W}),fr=Yg({config:sa,numeric:ed,smaller:dd,typed:W}),gr=$n({BigNumber:La,typed:W}),hr=ao({DenseMatrix:Kb,Index:Ic,compareNatural:ld,size:Hc,subset:Xc,typed:W}),ir=bo({Index:Ic,compareNatural:ld,size:Hc,subset:Xc,typed:W}),jr=co({Index:Ic,typed:W}),Hh=Zg({add:Ac,config:sa,numeric:ed,typed:W}),Ve= +eo({gamma:Fh,typed:W}),kr=fo({factorial:Ve,typed:W}),lr=go({flatten:Se,matrix:Ta,size:Hc,typed:W}),pc=ho({DenseMatrix:Kb,addScalar:zc,equalScalar:Qb,matrix:Ta,typed:W,unaryMinus:rd}),mr=io({matrix:Ta,multiply:vc,subtract:pc,typed:W}),xe=ah({bignumber:Hd,matrix:Ta,config:sa,larger:Yc,largerEq:Te,smaller:dd,smallerEq:sf,typed:W}),nr=ch({Index:Ic,matrix:Ta,range:xe,typed:W}),Ih=jo({config:sa,multiplyScalar:sc,numeric:ed,typed:W}),Id=ko({DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,typed:W}),Jh=Xg({config:sa, +larger:Yc,numeric:ed,typed:W}),or=lo({DenseMatrix:Kb,Index:Ic,compareNatural:ld,size:Hc,subset:Xc,typed:W}),Kh=mo({Index:Ic,concat:qf,setDifference:Dh,size:Hc,subset:Xc,typed:W}),Lh=no({config:sa,equalScalar:Qb,matrix:Ta,round:we,typed:W}),pr=oo({DenseMatrix:Kb,matrix:Ta,typed:W}),qr=po({prod:Ih,size:Hc,typed:W}),Mh=qo({conj:ve,transpose:Ue,typed:W}),rr=ro({equal:Id,typed:W}),sr=so({Index:Ic,compareNatural:ld,size:Hc,subset:Xc,typed:W}),Nh=to({Complex:mc,ceil:Lh,floor:Bh,matrix:Ta,typed:W}),tr=bh({matrix:Ta, +number:Td,subtract:pc,typed:W}),tc=uo({numeric:ed,typed:W}),ur=vo({Complex:mc,config:sa,divideScalar:tc,typed:W}),Oh=wo({DenseMatrix:Kb,divideScalar:tc,equalScalar:Qb,matrix:Ta,multiplyScalar:sc,subtract:pc,typed:W}),vr=xo({DenseMatrix:Kb,divideScalar:tc,equalScalar:Qb,matrix:Ta,multiplyScalar:sc,subtract:pc,typed:W}),Ph=yo({FibonacciHeap:zh,addScalar:zc,equalScalar:Qb}),wr=zo({Index:Ic,concat:qf,setIntersect:Eh,setSymDifference:Kh,size:Hc,subset:Xc,typed:W}),tf=Ao({DenseMatrix:Kb,Spa:Ph,SparseMatrix:td, +abs:Vc,addScalar:zc,divideScalar:tc,equalScalar:Qb,larger:Yc,matrix:Ta,multiplyScalar:sc,subtract:pc,typed:W,unaryMinus:rd}),Qh=Go({SparseMatrix:td,abs:Vc,add:Ac,divideScalar:tc,larger:Yc,largerEq:Te,multiply:vc,subtract:pc,transpose:Ue,typed:W}),Rh=Ho({lup:tf,matrix:Ta,multiply:vc,subtract:pc,typed:W,unaryMinus:rd}),xr=Io({abs:Vc,addScalar:zc,divideScalar:tc,multiplyScalar:sc,sqrt:sd,subtract:pc,typed:W,unaryMinus:rd}),Sh=Jo({addScalar:zc,combinations:Re,divideScalar:tc,factorial:Ve,isInteger:cd, +isNegative:he,larger:Yc,multiplyScalar:sc,pow:Gd,subtract:pc,typed:W}),yr=Ko({addScalar:zc,combinations:Re,divideScalar:tc,isInteger:cd,isNegative:he,multiplyScalar:sc,typed:W}),Th=$g({Index:Ic,matrix:Ta,range:xe,typed:W}),uf=Lo({Complex:mc,config:sa,divideScalar:tc,typed:W}),Uh=Mo({DenseMatrix:Kb,divideScalar:tc,equalScalar:Qb,matrix:Ta,typed:W}),Vh=No({DenseMatrix:Kb,divideScalar:tc,equalScalar:Qb,matrix:Ta,multiplyScalar:sc,subtract:pc,typed:W}),zr=Oo({abs:Vc,addScalar:zc,divideScalar:tc,isPositive:Pe, +multiplyScalar:sc,smaller:dd,sqrt:sd,typed:W}),Wh=Po({addScalar:zc,complex:Qe,conj:ve,divideScalar:tc,equal:Id,identity:ie,isZero:Vd,matrix:Ta,multiplyScalar:sc,sign:rh,sqrt:sd,subtract:pc,typed:W,unaryMinus:rd,zeros:Ud}),ye=Qo({abs:Vc,addScalar:zc,det:Rh,divideScalar:tc,identity:ie,matrix:Ta,multiply:vc,typed:W,unaryMinus:rd}),Ar=Ro({abs:Vc,add:Ac,identity:ie,inv:ye,multiply:vc,typed:W}),md=So({divideScalar:tc,equalScalar:Qb,inv:ye,matrix:Ta,multiply:vc,typed:W}),Br=dh({add:Ac,divide:md,typed:W}), +vf=eh({add:Ac,apply:nf,divide:md,isNaN:se,multiply:vc,subtract:pc,typed:W}),Cr=To({divide:md,dotDivide:Uh,isNumeric:ge,log:uf,matrix:Ta,multiply:vc,sum:Hh,typed:W}),Dr=Uo({addScalar:zc,isInteger:cd,isNegative:he,stirlingS2:Sh,typed:W}),Er=Vo({Complex:mc,config:sa,divideScalar:tc,log:uf,typed:W}),xb=Wo({BigNumber:La,Complex:mc,Fraction:Sd,abs:Vc,addScalar:zc,config:sa,divideScalar:tc,equal:Id,fix:Nh,format:te,isNumeric:ge,multiplyScalar:sc,number:Td,pow:Gd,round:we,subtract:pc}),Fr=Xo({Unit:xb,typed:W}), +Xh=Zo({abs:Vc,add:Ac,addScalar:zc,atan:vh,bignumber:Hd,column:Th,complex:Qe,config:sa,cos:of,diag:wh,divideScalar:tc,equal:Id,flatten:Se,im:sh,inv:ye,larger:Yc,log10:qh,matrix:Ta,matrixFromColumns:Gh,multiply:vc,multiplyScalar:sc,number:Td,qr:Wh,re:Ch,round:we,sin:pf,smaller:dd,sqrt:sd,subtract:pc,transpose:Ue,typed:W,usolveAll:Vh}),Gr=$o({abs:Vc,add:Ac,addScalar:zc,config:sa,divideScalar:tc,equalScalar:Qb,matrix:Ta,multiply:vc,multiplyScalar:sc,smaller:dd,subtract:pc,typed:W}),Hr=fh({sqrt:sd,typed:W, +variance:vf}),Ir=Rk({BigNumber:La,Unit:xb,config:sa}),Jr=xk({BigNumber:La,Unit:xb,config:sa}),Kr=Tk({BigNumber:La,Unit:xb,config:sa}),Lr=yk({BigNumber:La,Unit:xb,config:sa}),Mr=Kk({BigNumber:La,Unit:xb,config:sa}),Nr=Fk({BigNumber:La,Unit:xb,config:sa}),Or=Uk({BigNumber:La,Unit:xb,config:sa}),Pr=Vk({BigNumber:La,Unit:xb,config:sa}),Qr=pk({BigNumber:La,Unit:xb,config:sa}),Rr=Ik({BigNumber:La,Unit:xb,config:sa}),Sr=Ck({BigNumber:La,Unit:xb,config:sa}),Tr=sk({BigNumber:La,Unit:xb,config:sa}),Ur=dl({BigNumber:La, +Unit:xb,config:sa}),Vr=Yk({BigNumber:La,Unit:xb,config:sa}),Wr=Lk({BigNumber:La,Unit:xb,config:sa}),Xr=jl({BigNumber:La,Unit:xb,config:sa}),Yr=gl({BigNumber:La,Unit:xb,config:sa}),Zr=kl({BigNumber:La,Unit:xb,config:sa}),$r=Jk({BigNumber:La,Unit:xb,config:sa}),as=rk({BigNumber:La,Unit:xb,config:sa}),bs=al({BigNumber:La,Unit:xb,config:sa}),cs=bl({BigNumber:La,Unit:xb,config:sa}),ds=uk({BigNumber:La,Unit:xb,config:sa}),Yh=ap({DenseMatrix:Kb,divideScalar:tc,equalScalar:Qb,matrix:Ta,multiplyScalar:sc, +subtract:pc,typed:W}),Zh=bp({abs:Vc,add:Ac,conj:ve,ctranspose:Mh,eigs:Xh,equalScalar:Qb,larger:Yc,matrix:Ta,multiply:vc,pow:Gd,smaller:dd,sqrt:sd,typed:W}),es=cp({DenseMatrix:Kb,lsolve:Oh,lup:tf,matrix:Ta,slu:Qh,typed:W,usolve:Yh}),fs=dp({abs:Vc,add:Ac,identity:ie,inv:ye,max:Jh,multiply:vc,size:Hc,sqrt:sd,subtract:pc,typed:W}),gs=ep({add:Ac,divide:md,factorial:Ve,isInteger:cd,isPositive:Pe,multiply:vc,typed:W}),hs=Sk({BigNumber:La,Unit:xb,config:sa}),is=Ek({BigNumber:La,Unit:xb,config:sa}),js=tk({BigNumber:La, +Unit:xb,config:sa}),ks=Gk({BigNumber:La,Unit:xb,config:sa}),ls=fl({BigNumber:La,Unit:xb,config:sa}),ms=Wk({BigNumber:La,Unit:xb,config:sa}),ns=el({BigNumber:La,Unit:xb,config:sa}),os=Bk({BigNumber:La,Unit:xb,config:sa}),ps=hl({BigNumber:La,Unit:xb,config:sa}),qs=Mk({BigNumber:La,Unit:xb,config:sa}),rs=ok({BigNumber:La,Unit:xb,config:sa}),ss=cl({BigNumber:La,Unit:xb,config:sa}),$h=fp({BigNumber:La,DenseMatrix:Kb,SparseMatrix:td,addScalar:zc,config:sa,cos:of,matrix:Ta,multiplyScalar:sc,norm:Zh,sin:pf, +typed:W,unaryMinus:rd}),ai=gp({add:Ac,compare:je,divide:md,partitionSelect:rf,typed:W}),ts=Dk({BigNumber:La,Unit:xb,config:sa}),us=wk({BigNumber:La,Unit:xb,config:sa}),vs=zk({BigNumber:La,Unit:xb,config:sa}),ws=Zk({BigNumber:La,Unit:xb,config:sa}),xs=il({BigNumber:La,Unit:xb,config:sa}),ys=Ok({BigNumber:La,Unit:xb,config:sa}),zs=hp({multiply:vc,rotationMatrix:$h,typed:W}),As=ip({abs:Vc,map:uh,median:ai,subtract:pc,typed:W}),Bs=vk({BigNumber:La,Unit:xb,config:sa}),Cs=Ak({BigNumber:La,Unit:xb,config:sa}), +Ds=Nk({BigNumber:La,Unit:xb,config:sa}),Es=jp({Unit:xb,typed:W}),Fs=Xk({BigNumber:La,Unit:xb,config:sa}),Gs=qk({BigNumber:La,Unit:xb,config:sa}),ke={},ze={},bi={},Jc=Ji({mathWithTransform:ze}),ci=Ri({Node:Jc}),di=Si({Node:Jc,ResultSet:mh}),Ae=Ti({Node:Jc}),ei=Ui({Node:Jc}),Be=Vi({Node:Jc}),fi=Wi({Node:Jc}),wf=Xi({math:ke}),Hs=Yi({classes:bi}),gi=Zi({Node:Jc}),Ce=$i({Node:Jc}),hi=aj({Node:Jc}),ii=bj({Node:Jc,typed:W}),Is=cj({Chain:wf,typed:W}),ji=dj({Node:Jc,subset:Xc}),ki=ej({Node:Jc,Range:nh,size:Hc}), +li=fj({matrix:Ta,Node:Jc,subset:Xc}),le=gj({Unit:xb,Node:Jc,math:ke}),De=hj({Node:Jc,SymbolNode:le,math:ke}),Jd=ij({AccessorNode:ji,ArrayNode:ci,AssignmentNode:li,BlockNode:di,ConditionalNode:gi,ConstantNode:Ae,FunctionAssignmentNode:ii,FunctionNode:De,IndexNode:ki,ObjectNode:ei,OperatorNode:Ce,ParenthesisNode:Be,RangeNode:hi,RelationalNode:fi,SymbolNode:le,config:sa,numeric:ed,typed:W}),mi=jj({parse:Jd,typed:W}),ni=kj({parse:Jd}),oi=lj({parse:Jd}),Js=nj({Help:ni,mathWithTransform:ze,typed:W}),Ks= +oj({parse:Jd,typed:W}),xf=qj({bignumber:Hd,fraction:ue,ConstantNode:Ae,FunctionNode:De,OperatorNode:Ce,ParenthesisNode:Be,SymbolNode:le,add:Ac,config:sa,divide:md,equal:Id,isZero:Vd,mathWithTransform:ze,multiply:vc,parse:Jd,pow:Gd,subtract:pc,typed:W}),Ls=rj({bignumber:Hd,fraction:ue,ConstantNode:Ae,FunctionNode:De,OperatorNode:Ce,ParenthesisNode:Be,SymbolNode:le,add:Ac,config:sa,divide:md,equal:Id,isZero:Vd,mathWithTransform:ze,multiply:vc,parse:Jd,pow:Gd,simplify:xf,subtract:pc,typed:W}),Ms=sj({Parser:oi, +typed:W}),Ns=tj({ConstantNode:Ae,FunctionNode:De,OperatorNode:Ce,ParenthesisNode:Be,SymbolNode:le,config:sa,equal:Id,isZero:Vd,numeric:ed,parse:Jd,simplify:xf,typed:W});Ra(ke,{reviver:Hs,false:kp,null:lp,true:mp,replacer:np,i:op,LN10:pp,LOG10E:qp,NaN:rp,pi:oh,SQRT1_2:sp,tau:tp,efimovFactor:up,fineStructure:vp,sackurTetrode:wp,weakMixingAngle:xp,e:ph,Infinity:yp,LOG2E:zp,PI:oh,version:Ap,E:ph,phi:Bp,typed:W,isInteger:cd,isNumeric:ge,isPositive:Pe,isNaN:se,equalScalar:Qb,number:Td,boolean:Cp,complex:Qe, +splitUnit:Dp,unaryPlus:Ep,apply:nf,cube:Fp,expm1:Gp,log10:qh,multiplyScalar:sc,sign:rh,square:Hp,bitNot:Ip,arg:Jp,im:sh,not:th,filter:Kp,forEach:Lp,map:uh,erf:Mp,format:te,oct:Np,print:Op,isPrime:Pp,acos:Qp,acot:Rp,acsc:Sp,asec:Tp,asin:Up,atan:vh,atanh:Vp,cosh:Wp,coth:Xp,csch:Yp,sech:Zp,sinh:$p,tanh:aq,chain:Is,combinations:Re,pickRandom:bq,randomInt:cq,LN2:dq,clone:eq,hasNumericValue:fq,typeOf:gq,string:hq,fraction:ue,unaryMinus:rd,addScalar:zc,exp:iq,log2:jq,sqrt:sd,conj:ve,getMatrixDataType:kq, +mode:lq,bin:mq,acosh:nq,acsch:oq,asinh:pq,cos:of,csc:qq,sin:pf,combinationsWithRep:rq,random:sq,SQRT2:tq,isNegative:he,matrix:Ta,abs:Vc,gcd:uq,mod:vq,nthRoot:wq,xgcd:xq,bitAnd:yq,bitXor:zq,or:Aq,concat:qf,diag:wh,identity:ie,ones:Bq,reshape:Cq,size:Hc,subset:Xc,zeros:Ud,hex:Dq,round:we,leftShift:Eq,rightLogShift:Fq,compare:je,compareText:xh,smaller:dd,larger:Yc,unequal:Gq,sparse:Hq,acoth:Iq,atan2:Jq,sec:Kq,add:Ac,dot:Ah,composition:Lq,isZero:Vd,matrixFromFunction:Mq,cbrt:Nq,floor:Bh,multiply:vc,dotMultiply:Oq, +re:Ch,flatten:Se,resize:Pq,squeeze:Qq,to:Rq,pow:Gd,dotPow:Sq,rightArithShift:Tq,compareNatural:ld,equalText:Uq,largerEq:Te,partitionSelect:rf,asech:Vq,tan:Wq,setDifference:Dh,setIntersect:Eh,setMultiplicity:Xq,setSize:Yq,trace:Zq,quantileSeq:$q,gamma:Fh,bignumber:Hd,matrixFromColumns:Gh,lcm:ar,bitOr:br,kron:cr,transpose:Ue,numeric:ed,and:dr,smallerEq:sf,sort:er,min:fr,cot:gr,setDistinct:hr,setPowerset:ir,index:jr,sum:Hh,factorial:Ve,permutations:kr,matrixFromRows:lr,subtract:pc,cross:mr,range:xe, +row:nr,prod:Ih,equal:Id,max:Jh,setCartesian:or,setSymDifference:Kh,ceil:Lh,xor:pr,count:qr,ctranspose:Mh,deepEqual:rr,setIsSubset:sr,fix:Nh,diff:tr,divideScalar:tc,nthRoots:ur,lsolve:Oh,lsolveAll:vr,setUnion:wr,lup:tf,slu:Qh,det:Rh,distance:xr,stirlingS2:Sh,catalan:yr,column:Th,log:uf,dotDivide:Uh,usolveAll:Vh,hypot:zr,qr:Wh,inv:ye,expm:Ar,divide:md,mean:Br,variance:vf,kldivergence:Cr,bellNumbers:Dr,log1p:Er,createUnit:Fr,eigs:Xh,intersect:Gr,std:Hr,atomicMass:Ir,bohrMagneton:Jr,boltzmann:Kr,conductanceQuantum:Lr, +deuteronMass:Mr,electronMass:Nr,faraday:Or,firstRadiation:Pr,gravitationConstant:Qr,hartreeEnergy:Rr,klitzing:Sr,magneticConstant:Tr,molarMass:Ur,molarPlanckConstant:Vr,neutronMass:Wr,planckCharge:Xr,planckLength:Yr,planckTemperature:Zr,protonMass:$r,reducedPlanckConstant:as,secondRadiation:bs,stefanBoltzmann:cs,vacuumImpedance:ds,usolve:Yh,norm:Zh,lusolve:es,sqrtm:fs,multinomial:gs,avogadro:hs,classicalElectronRadius:is,electricConstant:js,fermiCoupling:ks,gravity:ls,loschmidt:ms,molarMassC12:ns, +nuclearMagneton:os,planckMass:ps,quantumOfCirculation:qs,speedOfLight:rs,wienDisplacement:ss,rotationMatrix:$h,median:ai,bohrRadius:ts,elementaryCharge:us,inverseConductanceQuantum:vs,molarVolume:ws,planckTime:xs,thomsonCrossSection:ys,rotate:zs,parse:Jd,evaluate:mi,mad:As,coulomb:Bs,magneticFluxQuantum:Cs,rydberg:Ds,unit:Es,help:Js,gasConstant:Fs,compile:Ks,simplify:xf,rationalize:Ls,parser:Ms,planckConstant:Gs,derivative:Ns,config:sa});Ra(ze,ke,{apply:uj({isInteger:cd,typed:W}),filter:vj({typed:W}), +map:wj({typed:W}),forEach:xj({typed:W}),subset:yj({matrix:Ta,typed:W}),index:zj({Index:Ic}),concat:Aj({isInteger:cd,matrix:Ta,typed:W}),max:Bj({config:sa,larger:Yc,numeric:ed,typed:W}),min:Cj({config:sa,numeric:ed,smaller:dd,typed:W}),sum:Dj({add:Ac,config:sa,numeric:ed,typed:W}),column:Ej({Index:Ic,matrix:Ta,range:xe,typed:W}),range:Fj({bignumber:Hd,matrix:Ta,config:sa,larger:Yc,largerEq:Te,smaller:dd,smallerEq:sf,typed:W}),diff:Gj({bignumber:Hd,matrix:Ta,number:Td,subtract:pc,typed:W}),row:Hj({Index:Ic, +matrix:Ta,range:xe,typed:W}),mean:Ij({add:Ac,divide:md,typed:W}),variance:Jj({add:Ac,apply:nf,divide:md,isNaN:se,multiply:vc,subtract:pc,typed:W}),std:Kj({sqrt:sd,typed:W,variance:vf})});Ra(bi,{ResultSet:mh,Complex:mc,Range:nh,Node:Jc,ArrayNode:ci,BlockNode:di,ConstantNode:Ae,ObjectNode:ei,ParenthesisNode:Be,RelationalNode:fi,Chain:wf,BigNumber:La,Matrix:Oe,ConditionalNode:gi,OperatorNode:Ce,Fraction:Sd,RangeNode:hi,DenseMatrix:Kb,FunctionAssignmentNode:ii,SparseMatrix:td,ImmutableDenseMatrix:yh, +FibonacciHeap:zh,AccessorNode:ji,IndexNode:ki,Index:Ic,AssignmentNode:li,Spa:Ph,Unit:xb,SymbolNode:le,FunctionNode:De,Help:ni,Parser:oi});wf.createProxy(ke);browser.omnibox.setDefaultSuggestion({description:"Do most mathematical computations."});const pi=(b,a)=>{b=mi(b);a([{description:String(b),content:String(b)}])};browser.omnibox.onInputStarted.addListener(pi);browser.omnibox.onInputChanged.addListener(pi)})()})(); diff --git a/index.extern.js b/index.extern.js index fdde65c..3408a20 100644 --- a/index.extern.js +++ b/index.extern.js @@ -7,3 +7,4 @@ const browser = {}; browser.omnibox.onInputStarted.addListener = function (cb) {}; browser.omnibox.onInputChanged.addListener = function (cb) {}; +browser.omnibox.setDefaultSuggestion = function(obj) {} \ No newline at end of file From 548b1c2e12ae18659de2fecd94ed8edf1c3f9395 Mon Sep 17 00:00:00 2001 From: Ben Cooper Date: Wed, 29 Sep 2021 23:51:06 -0700 Subject: [PATCH 6/9] update mathjs and webpack --- package-lock.json | 40 ++++++++++++++++++++-------------------- package.json | 2 +- webpack.config.js | 3 +-- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4e6c458..febeb42 100644 --- a/package-lock.json +++ b/package-lock.json @@ -83,9 +83,9 @@ } }, "@babel/runtime": { - "version": "7.14.0", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.14.0.tgz", - "integrity": "sha1-RnlLwgthLF915i3QceJN/ZXxy+Y=", + "version": "7.15.4", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.15.4.tgz", + "integrity": "sha512-99catp6bHCaxr4sJ/DbTGgHS4+Rs2RVd2g7iOap6SLGPDknRK9ztKNsE/Fg6QhSeh1FGE5f6gHGQmvvn3I3xhw==", "requires": { "regenerator-runtime": "^0.13.4" } @@ -1146,9 +1146,9 @@ "dev": true }, "complex.js": { - "version": "2.0.13", - "resolved": "https://registry.npmjs.org/complex.js/-/complex.js-2.0.13.tgz", - "integrity": "sha1-AM97oIJWXhZIE7e7uwztXSq6Fyo=" + "version": "2.0.15", + "resolved": "https://registry.npmjs.org/complex.js/-/complex.js-2.0.15.tgz", + "integrity": "sha512-gDBvQU8IG139ZBQTSo2qvDFP+lANMGluM779csXOr6ny1NUtA3wkUnCFjlDNH/moAVfXtvClYt6G0zarFbtz5w==" }, "concat-map": { "version": "0.0.1", @@ -1261,9 +1261,9 @@ "dev": true }, "decimal.js": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.2.1.tgz", - "integrity": "sha1-I4rnsPDHk9PjzqQQEIs1osAUJqM=" + "version": "10.3.1", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.3.1.tgz", + "integrity": "sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ==" }, "decompress-response": { "version": "3.3.0", @@ -1552,7 +1552,7 @@ "escape-latex": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/escape-latex/-/escape-latex-1.2.0.tgz", - "integrity": "sha1-B8A4GM99rCUMzlF/T9obAB7yvKE=" + "integrity": "sha512-nV5aVWW1K0wEiUIEdZ4erkGGH8mDxGyxSeqPzRNtWP7ataw+/olFObw7hujFWlVjNsaDFw5VZ5NzVSIqRgfTiw==" }, "escape-string-regexp": { "version": "1.0.5", @@ -1946,7 +1946,7 @@ "fraction.js": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.1.1.tgz", - "integrity": "sha1-rE5SBHPa5nAS1hiquR7aCby0AP8=" + "integrity": "sha512-MHOhvvxHTfRFpF1geTK9czMIZ6xclsEor2wkIGYYq+PxcQqT7vStJqjhe6S1TenZrMZzo+wlqOufBDVepUEgPg==" }, "fs-extra": { "version": "9.1.0", @@ -3044,13 +3044,13 @@ "dev": true }, "mathjs": { - "version": "9.4.1", - "resolved": "https://registry.npmjs.org/mathjs/-/mathjs-9.4.1.tgz", - "integrity": "sha1-34anmWUT4nC1X1gILUL6xK77pos=", + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/mathjs/-/mathjs-9.5.0.tgz", + "integrity": "sha512-a6QFEoLFLEI1cKr0B7lwAM1TTNAfNTxppimyqS5WhxGKXbV59DK4OX606z05PpuKpTiq7gTtPiSV0OAwFfxSvw==", "requires": { - "@babel/runtime": "^7.14.0", - "complex.js": "^2.0.13", - "decimal.js": "^10.2.1", + "@babel/runtime": "^7.15.4", + "complex.js": "^2.0.15", + "decimal.js": "^10.3.1", "escape-latex": "^1.2.0", "fraction.js": "^4.1.1", "javascript-natural-sort": "^0.7.1", @@ -3960,7 +3960,7 @@ "seedrandom": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-3.0.5.tgz", - "integrity": "sha1-VO3IXJUiJSWwx6b2s1Q9jgs6oKc=" + "integrity": "sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg==" }, "semver": { "version": "7.3.5", @@ -4416,7 +4416,7 @@ "tiny-emitter": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", - "integrity": "sha1-HRpW7fxRxD6GPLtTgqcjMONVVCM=" + "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==" }, "tmp": { "version": "0.2.1", @@ -4488,7 +4488,7 @@ "typed-function": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/typed-function/-/typed-function-2.0.0.tgz", - "integrity": "sha1-Fas4JYRROKixETvYnmDNakNXOeg=" + "integrity": "sha512-Hhy1Iwo/e4AtLZNK10ewVVcP2UEs408DS35ubP825w/YgSBK1KVLwALvvIG4yX75QJrxjCpcWkzkVRB0BwwYlA==" }, "typedarray": { "version": "0.0.6", diff --git a/package.json b/package.json index 28518b4..94af586 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "webpack-cli": "^4" }, "dependencies": { - "mathjs": "^9" + "mathjs": "^9.5.0" }, "sideEffects": false, "volta": { diff --git a/webpack.config.js b/webpack.config.js index 1577f7f..c7c8866 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -5,8 +5,7 @@ module.exports = { optimization: { minimizer: [ new ClosurePlugin( - { mode: "AGGRESSIVE_BUNDLE" }, - { externs: ["./index.extern.js"] } + { mode: "STANDARD" }, ), ], }, From 41497b105cf2e2d95722ef165eeba60543b7d40d Mon Sep 17 00:00:00 2001 From: Ben Cooper Date: Wed, 29 Sep 2021 23:51:15 -0700 Subject: [PATCH 7/9] delete extern --- index.extern.js | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 index.extern.js diff --git a/index.extern.js b/index.extern.js deleted file mode 100644 index 3408a20..0000000 --- a/index.extern.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @fileoverview Clarifying the browser global is available. - * @externs - */ - -const browser = {}; - -browser.omnibox.onInputStarted.addListener = function (cb) {}; -browser.omnibox.onInputChanged.addListener = function (cb) {}; -browser.omnibox.setDefaultSuggestion = function(obj) {} \ No newline at end of file From ccaf35050f63633d8fad1dd197d0c829281b62ca Mon Sep 17 00:00:00 2001 From: Ben Cooper Date: Wed, 29 Sep 2021 23:51:29 -0700 Subject: [PATCH 8/9] update built artifact --- addon/index.js | 1114 +----------------------------------- addon/index.js.LICENSE.txt | 2 +- 2 files changed, 3 insertions(+), 1113 deletions(-) diff --git a/addon/index.js b/addon/index.js index 9cd0271..763da61 100644 --- a/addon/index.js +++ b/addon/index.js @@ -1,1112 +1,2 @@ -/* - For license information please see index.js.LICENSE.txt */ -'use strict';var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(jb){var Rb=0;return function(){return Rb>>0, -$jscomp.propertyToPolyfillSymbol[Qa]=$jscomp.IS_SYMBOL_NATIVE?$jscomp.global.Symbol(Qa):$jscomp.POLYFILL_PREFIX+Nb+"$"+Qa),$jscomp.defineProperty(Ra,$jscomp.propertyToPolyfillSymbol[Qa],{configurable:!0,writable:!0,value:Rb})))};$jscomp.initSymbol=function(){};$jscomp.iteratorPrototype=function(jb){jb={next:jb};jb[Symbol.iterator]=function(){return this};return jb}; -$jscomp.iteratorFromArray=function(jb,Rb){jb instanceof String&&(jb+="");var Nb=0,Ra=!1,Qa={next:function(){if(!Ra&&Nb{function jb(Ra){var Qa=Nb[Ra];if(void 0!==Qa)return Qa.exports;Qa=Nb[Ra]={id:Ra,loaded:!1,exports:{}};return Rb[Ra].call(Qa.exports,Qa,Qa.exports,jb),Qa.loaded=!0,Qa.exports}var Rb={977:function(Ra,Qa){var pa;!function(rb){function Ob(D,H){var K=Math.abs(D),ea=Math.abs(H);return 0===D?Math.log(ea):0===H?Math.log(K):3E3>K&&3E3>ea?.5*Math.log(D*D+H*H):Math.log(D/Math.cos(Math.atan2(H,D)))}function Z(D,H){if(!(this instanceof Z))return new Z(D,H);a:{var K={re:0,im:0};if(null==D)K.re=K.im=0;else if(void 0!== -H)K.re=D,K.im=H;else switch(typeof D){case "object":if("im"in D&&"re"in D)K.re=D.re,K.im=D.im;else if("abs"in D&&"arg"in D){if(!Number.isFinite(D.abs)&&Number.isFinite(D.arg)){K=Z.INFINITY;break a}K.re=D.abs*Math.cos(D.arg);K.im=D.abs*Math.sin(D.arg)}else if("r"in D&&"phi"in D){if(!Number.isFinite(D.r)&&Number.isFinite(D.phi)){K=Z.INFINITY;break a}K.re=D.r*Math.cos(D.phi);K.im=D.r*Math.sin(D.phi)}else 2===D.length?(K.re=D[0],K.im=D[1]):cb();break;case "string":K.im=K.re=0;D=D.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g); -H=1;var ea=0;null===D&&cb();for(var fa=0;fa=H?.5*Math.sqrt(2*(ea-H)):Math.abs(K)/Math.sqrt(2*(ea+H)),new Z(fa,0>K?-D:D)},exp:function(){var D= -Math.exp(this.re);return this.im,new Z(D*Math.cos(this.im),D*Math.sin(this.im))},expm1:function(){var D=this.re,H=this.im,K=Math.expm1(D)*Math.cos(H);var ea=Math.PI/4;H<-ea||H>ea?ea=Math.cos(H)-1:(ea=H*H,ea*=ea*(1/24+ea*(-1/720+ea*(1/40320+ea*(-1/3628800+ea*(1/4790014600+ea*(-1/87178291200+1/20922789888E3*ea))))))-.5);return new Z(K+ea,Math.exp(D)*Math.sin(H))},log:function(){var D=this.re,H=this.im;return new Z(Ob(D,H),Math.atan2(H,D))},abs:function(){return D=this.re,H=this.im,K=Math.abs(D),ea= -Math.abs(H),3E3>K&&3E3>ea?Math.sqrt(K*K+ea*ea):(K=D.im){var H=D.re;D.re=-D.im;D.im=H}else H=D.im,D.im=-D.re,D.re=H;return D},atanh:function(){var D=this.re,H=this.im,K=1H?(H=-H,K+="-"):K+="+",K+=" "):0>H&&(H=-H,K+="-"),1!==H&&(K+=H),K+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return 0===this.im?this.re:null},isNaN:function(){return isNaN(this.re)|| -isNaN(this.im)},isZero:function(){return 0===this.im&&0===this.re},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!(this.isNaN()||this.isFinite())}};Z.ZERO=new Z(0,0);Z.ONE=new Z(1,0);Z.I=new Z(0,1);Z.PI=new Z(Math.PI,0);Z.E=new Z(Math.E,0);Z.INFINITY=new Z(1/0,1/0);Z.NAN=new Z(NaN,NaN);Z.EPSILON=1E-15;void 0===(pa=function(){return Z}.apply(Qa,[]))||(Ra.exports=pa)}()},776:function(Ra,Qa,pa){var rb;!function(Ob){function Z(x){var E,C,A=x.length-1,J=""; -var N=x[0];if(0C)throw Error("[DecimalError] Invalid argument: "+x);}function Fa(x,E,C,A){var J,N,Y,T;for(N=x[0];10<=N;N/=10)--E;return 0>--E?(E+=7,J=0):(J=Math.ceil((E+1)/7),E%=7),N=jc(10,7-E),T=x[J]%N|0,null==A?3>E?(0==E?T=T/100|0:1==E&&(T=T/10|0),Y=4>C&&99999==T||3C&& -T+1==N||3E?(0==E?T=T/1E3|0:1==E?T=T/100|0:2==E&&(T=T/10|0),Y=(A||4>C)&&9999==T||!A&&3C)&&T+1==N||!A&&3C-1&&(void 0===J[A+1]&&(J[A+1]=0),J[A+1]+=J[A]/C|0,J[A]%=C)}return J.reverse()}function D(x, -E,C,A){var J,N,Y,T,aa,la,xa=x.constructor;a:if(null!=E){if(!(aa=x.d))return x;var ya=1;for(N=aa[0];10<=N;N/=10)ya++;if(0>(J=E-ya)){J+=7;var ra=E;var ub=(T=aa[la=0])/jc(10,ya-ra-1)%10|0}else if((la=Math.ceil((J+1)/7))>=(N=aa.length)){if(!A)break a;for(;N++<=la;)aa.push(0);T=ub=0;ya=1;ra=(J%=7)-7+1}else{T=N=aa[la];for(ya=1;10<=N;N/=10)ya++;ub=0>(ra=(J%=7)-7+ya)?0:T/jc(10,ya-ra-1)%10|0}if(A=A||0>E||void 0!==aa[la+1]||(0>ra?T:T%jc(10,ya-ra-1)),Y=4>C?(ub||A)&&(0==C||C==(0>x.s?3:2)):5x.s?8:7)),1>E||!aa[0])return aa.length=0,Y?(E-=x.e+1,aa[0]=jc(10,(7-E%7)%7),x.e=-E||0):aa[0]=x.e=0,x;if(0==J?(aa.length=la,N=1,la--):(aa.length=la+1,N=jc(10,7-J),aa[la]=0 -xa.maxE?(x.d=null,x.e=NaN):x.ex.e?"e":"e+")+x.e):0>J?(N="0."+ia(-J-1)+N,C&&0<(A=C-Y)&&(N+=ia(A))):J>=Y?(N+=ia(J+1-Y),C&&0<(A=C-J-1)&&(N=N+"."+ia(A))):((A=J+1)Kd)throw Ua=!0,C&&(x.precision=C),Error("[DecimalError] Precision limit exceeded");return D(new x(wc),E,1,!0)}function fa(x,E,C){if(E>ud)throw Error("[DecimalError] Precision limit exceeded");return D(new x(yb),E,C,!0)}function V(x){var E=x.length-1,C=7*E+1;if(E=x[E]){for(;0==E%10;E/=10)C--;for(E=x[0];10<=E;E/=10)C++}return C}function ia(x){for(var E="";x--;)E+="0";return E}function za(x,E,C,A){var J;x=new x(1);A=Math.ceil(A/7+4);for(Ua=!1;;){if(C%2&&lb((x= -x.times(E)).d,A)&&(J=!0),0===(C=rc(C/2))){C=x.d.length-1;J&&0===x.d[C]&&++x.d[C];break}lb((E=E.times(E)).d,A)}return Ua=!0,x}function Ca(x,E,C){for(var A,J=new x(E[0]),N=0;++Nx.s?0:1/0:1:x.s?0>x.s?0:x:NaN);null==E?(Ua=!1,Y=ra):Y=E;for(N=new xa(.03125);-2T&&Fa(J.d,Y-C,ya,T)))return D(J,xa.precision=ra,ya,Ua=!0);xa.precision=Y+=10;ub=A=N=new xa(1);aa=0;T++}J=N}}function qb(x,E){var C,A,J,N,Y,T,aa=1;var la=x;var xa=la.d;var ya=la.constructor,ra=ya.rounding,ub=ya.precision;if(0>la.s||!xa||!xa[0]||!la.e&&1==xa[0]&& -1==xa.length)return new ya(xa&&!xa[0]?-1/0:1!=la.s?NaN:xa?0:la);if(null==E?(Ua=!1,T=ub):T=E,ya.precision=T+=10,A=(C=Z(xa)).charAt(0),!(15E14>Math.abs(J=la.e)))return Y=ea(ya,T+2,ub).times(J+""),la=qb(new ya(A+"."+C.slice(1)),T-10).plus(Y),ya.precision=ub,null==E?D(la,ub,ra,Ua=!0):la;for(;7>A&&1!=A||1==A&&3C&&(C=A),C+=+E.slice(A+1),E=E.substring(0,A)): -0>C&&(C=E.length);for(A=0;48===E.charCodeAt(A);A++);for(J=E.length;48===E.charCodeAt(J-1);--J);if(E=E.slice(A,J)){if(J-=A,x.e=C=C-A-1,x.d=[],A=(C+1)%7,0>C&&(A+=7),Ax.constructor.maxE?(x.d=null,x.e=NaN):x.eE.s,A=fa(x,x.precision,1),J=A.times(.5);if((E=E.abs()).lte(J))return Pc=C?4:1,E;if((x=E.divToInt(A)).isZero())Pc=C?3:2;else{if((E=E.minus(x.times(A))).lte(J))return Pc=1&x.d[x.d.length- -1]?C?2:3:C?4:1,E;Pc=1&x.d[x.d.length-1]?C?1:4:C?3:2}return E.minus(A).abs()}function eb(x,E,C,A){var J,N,Y,T,aa,la,xa,ya,ra,ub=x.constructor,Bc=void 0!==C;if(Bc?(Ia(C,1,1E9),void 0===A?A=ub.rounding:Ia(A,0,8)):(C=ub.precision,A=ub.rounding),x.isFinite()){Bc?(J=2,16==E?C=4*C-3:8==E&&(C=3*C-2)):J=E;0<=(Y=(xa=H(x)).indexOf("."))&&(xa=xa.replace(".",""),(ra=new ub(1)).e=xa.length-Y,ra.d=cb(H(ra),10,J),ra.e=ra.d.length);for(N=aa=(ya=cb(xa,10,J)).length;0==ya[--aa];)ya.pop();if(ya[0]){if(0>Y?N--:((x=new ub(x)).d= -ya,x.e=N,ya=(x=Vb(x,ra,C,A,0,J)).d,N=x.e,la=Dc),Y=ya[C],T=J/2,la=la||void 0!==ya[C+1],la=4>A?(void 0!==Y||la)&&(0===A||A===(0>x.s?3:2)):Y>T||Y===T&&(4===A||la||6===A&&1&ya[C-1]||A===(0>x.s?8:7)),ya.length=C,la)for(;++ya[--C]>J-1;)ya[C]=0,C||(++N,ya.unshift(1));for(aa=ya.length;!ya[aa-1];--aa);Y=0;for(xa="";YN?"p":"p+")+N}else if(0>N){for(;++N;)xa="0"+xa;xa="0."+xa}else if(++N>aa)for(N-=aa;N--;)xa+="0";else Nx.s?"-"+xa:xa}function lb(x,E){if(x.length>E)return x.length=E,!0}function uc(x){return(new this(x)).abs()}function Bb(x){return(new this(x)).acos()}function Cc(x){return(new this(x)).acosh()}function Kc(x,E){return(new this(x)).plus(E)} -function nd(x){return(new this(x)).asin()}function Mb(x){return(new this(x)).asinh()}function Ld(x){return(new this(x)).atan()}function xc(x){return(new this(x)).atanh()}function Qc(x,E){x=new this(x);E=new this(E);var C,A=this.precision,J=this.rounding,N=A+4;return x.s&&E.s?x.d||E.d?!E.d||x.isZero()?(C=0>E.s?fa(this,A,J):new this(0)).s=x.s:!x.d||E.isZero()?(C=fa(this,N,1).times(.5)).s=x.s:0>E.s?(this.precision=N,this.rounding=1,C=this.atan(Vb(x,E,N,1)),E=fa(this,N,1),this.precision=A,this.rounding= -J,C=0>x.s?C.minus(E):C.plus(E)):C=this.atan(Vb(x,E,N,1)):(C=fa(this,N,1).times(0=N[E+1]&&A<=N[E+2]))throw Error("[DecimalError] Invalid argument: "+C+": "+A);this[C]=A}if(C="crypto",J&&(this[C]=Gc[C]),void 0!==(A=x[C])){if(!0!==A&&!1!==A&&0!==A&&1!==A)throw Error("[DecimalError] Invalid argument: "+C+": "+A);if(A){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error("[DecimalError] crypto unavailable");this[C]=!0}else this[C]=!1}return this}function Wb(x){return(new this(x)).cos()}function nb(x){return(new this(x)).cosh()} -function xd(x,E){return(new this(x)).div(E)}function Zc(x){return(new this(x)).exp()}function Pa(x){return D(x=new this(x),x.e+1,3)}function B(){var x,E,C=new this(0);Ua=!1;for(x=0;xJ)x=0,Y=[0];else{for(x=-1;0===Y[0];x-=7)Y.shift();C=1;for(A=Y[0];10<=A;A/=10)C++;7>C&&(x-=7-C)}return N.e=x,N.d=Y,N}function yd(x){return D(x= -new this(x),x.e+1,this.rounding)}function Wd(x){return(x=new this(x)).d?x.d[0]?x.s:0*x.s:x.s||NaN}function Xd(x){return(new this(x)).sin()}function zd(x){return(new this(x)).sinh()}function fd(x){return(new this(x)).sqrt()}function Ec(x,E){return(new this(x)).sub(E)}function Md(x){return(new this(x)).tan()}function Yd(x){return(new this(x)).tanh()}function Db(x){return D(x=new this(x),x.e+1,1)}var Lc,Dc,Pc,wc="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058", -yb="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789", -Gc={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-9E15,maxE:9E15,crypto:!1},Ua=!0,rc=Math.floor,jc=Math.pow,Yb=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,gd=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Nd=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Zd=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Kd=wc.length-1,ud=yb.length-1,Ba={name:"[object Decimal]"};Ba.absoluteValue=Ba.abs=function(){var x=new this.constructor(this);return 0>x.s&&(x.s=1),D(x)};Ba.ceil=function(){return D(new this.constructor(this), -this.e+1,2)};Ba.comparedTo=Ba.cmp=function(x){var E,C,A=this.d,J=(x=new this.constructor(x)).d,N=this.s;var Y=x.s;if(!A||!J)return N&&Y?N!==Y?N:A===J?0:!A^0>N?1:-1:NaN;if(!A[0]||!J[0])return A[0]?N:J[0]?-Y:0;if(N!==Y)return N;if(this.e!==x.e)return this.e>x.e^0>N?1:-1;x=0;for(Y=(E=A.length)<(C=J.length)?E:C;xJ[x]^0>N?1:-1;return E===C?0:E>C^0>N?1:-1};Ba.cosine=Ba.cos=function(){var x=this,E=x.constructor;if(x.d){var C;if(x.d[0]){var A=E.precision;var J=E.rounding; -E.precision=A+Math.max(x.e,x.sd())+7;E.rounding=1;var N=vb(E,x),Y,T=N.d.length;32>T?Y=(1/Gb(4,C=Math.ceil(T/3))).toString():(C=16,Y="2.3283064365386962890625e-10");E.precision+=C;N=Hb(E,1,N.times(Y),new E(1));for(Y=C;Y--;)N=N.times(N),N=N.times(N).minus(N).times(8).plus(1);C=(x=(E.precision-=C,N),E.precision=A,E.rounding=J,D(2==Pc||3==Pc?x.neg():x,A,J,!0))}else C=new E(1);A=C}else A=new E(NaN);return A};Ba.cubeRoot=Ba.cbrt=function(){var x,E,C,A,J,N,Y,T,aa=this.constructor;if(!this.isFinite()||this.isZero())return new aa(this); -Ua=!1;(J=this.s*jc(this.s*this,1/3))&&Math.abs(J)!=1/0?A=new aa(J.toString()):(C=Z(this.d),(J=((x=this.e)-C.length+1)%3)&&(C+=1==J||-2==J?"0":"00"),J=jc(C,1/3),x=rc((x+1)/3)-(x%3==(0>x?-1:2)),(A=new aa(C=J==1/0?"5e"+x:(C=J.toExponential()).slice(0,C.indexOf("e")+1)+x)).s=this.s);for(J=(x=aa.precision)+3;;)if(T=(Y=(N=A).times(N).times(N)).plus(this),A=Vb(T.plus(this).times(N),T.plus(Y),J+2,1),Z(N.d).slice(0,J)===(C=Z(A.d)).slice(0,J)){if("9999"!=(C=C.slice(J-3,J+1))&&(la||"4999"!=C)){+C&&(+C.slice(1)|| -"5"!=C.charAt(0))||(D(A,x+1,1),E=!A.times(A).times(A).eq(this));break}if(!la&&(D(N,x+1,0),N.times(N).times(N).eq(this))){A=N;break}J+=4;var la=1}return Ua=!0,D(A,x,aa.rounding,E)};Ba.decimalPlaces=Ba.dp=function(){var x,E=this.d,C=NaN;if(E){if(C=7*((x=E.length-1)-rc(this.e/7)),x=E[x])for(;0==x%10;x/=10)C--;0>C&&(C=0)}return C};Ba.dividedBy=Ba.div=function(x){return Vb(this,new this.constructor(x))};Ba.dividedToIntegerBy=Ba.divToInt=function(x){var E=this.constructor;return D(Vb(this,new E(x),0,1, -1),E.precision,E.rounding)};Ba.equals=Ba.eq=function(x){return 0===this.cmp(x)};Ba.floor=function(){return D(new this.constructor(this),this.e+1,3)};Ba.greaterThan=Ba.gt=function(x){return 0(C=A.d.length)?E=(1/Gb(4,x=Math.ceil(C/3))).toString():(x=16,E="2.3283064365386962890625e-10");A=Hb(J,1,A.times(E),new J(1),!0);for(E=new J(8);x--;)A=A.times(A),A=N.minus(A.times(E.minus(A.times(E))));return D(A,J.precision=Y,J.rounding=T,!0)};Ba.hyperbolicSine=Ba.sinh=function(){var x,E,C,A=this,J=A.constructor;if(!A.isFinite()||A.isZero())return new J(A);if(x=J.precision,E=J.rounding,J.precision=x+Math.max(A.e,A.sd())+4,J.rounding=1,3>(C=A.d.length))A=Hb(J,2,A,A,!0);else{var N=16< -(N=1.4*Math.sqrt(C))?16:0|N;A=Hb(J,2,A=A.times(1/Gb(5,N)),A,!0);for(var Y=new J(5),T=new J(16),aa=new J(20);N--;)C=A.times(A),A=A.times(Y.plus(C.times(T.times(C).plus(aa))))}return J.precision=x,J.rounding=E,D(A,x,E,!0)};Ba.hyperbolicTangent=Ba.tanh=function(){var x,E,C=this.constructor;return this.isFinite()?this.isZero()?new C(this):(x=C.precision,E=C.rounding,C.precision=x+7,C.rounding=1,Vb(this.sinh(),this.cosh(),C.precision=x,C.rounding=E)):new C(this.s)};Ba.inverseCosine=Ba.acos=function(){var x, -E=this,C=E.constructor,A=E.abs().cmp(1),J=C.precision,N=C.rounding;return-1!==A?0===A?E.isNeg()?fa(C,J,N):new C(0):new C(NaN):E.isZero()?fa(C,J+4,N).times(.5):(C.precision=J+6,C.rounding=1,E=E.asin(),x=fa(C,J+4,N).times(.5),C.precision=J,C.rounding=N,x.minus(E))};Ba.inverseHyperbolicCosine=Ba.acosh=function(){var x,E,C=this,A=C.constructor;return C.lte(1)?new A(C.eq(1)?0:NaN):C.isFinite()?(x=A.precision,E=A.rounding,A.precision=x+Math.max(Math.abs(C.e),C.sd())+4,A.rounding=1,Ua=!1,C=C.times(C).minus(1).sqrt().plus(C), -Ua=!0,A.precision=x,A.rounding=E,C.ln()):new A(C)};Ba.inverseHyperbolicSine=Ba.asinh=function(){var x,E,C=this,A=C.constructor;return!C.isFinite()||C.isZero()?new A(C):(x=A.precision,E=A.rounding,A.precision=x+2*Math.max(Math.abs(C.e),C.sd())+6,A.rounding=1,Ua=!1,C=C.times(C).plus(1).sqrt().plus(C),Ua=!0,A.precision=x,A.rounding=E,C.ln())};Ba.inverseHyperbolicTangent=Ba.atanh=function(){var x,E,C,A,J=this,N=J.constructor;return J.isFinite()?0<=J.e?new N(J.abs().eq(1)?J.s/0:J.isZero()?J:NaN):(x=N.precision, -E=N.rounding,A=J.sd(),Math.max(A,x)<2*-J.e-1?D(new N(J),x,E,!0):(N.precision=C=A-J.e,J=Vb(J.plus(1),(new N(1)).minus(J),C+x,1),N.precision=x+4,N.rounding=1,J=J.ln(),N.precision=x,N.rounding=E,J.times(.5))):new N(NaN)};Ba.inverseSine=Ba.asin=function(){var x,E,C,A,J=this,N=J.constructor;return J.isZero()?new N(J):(E=J.abs().cmp(1),C=N.precision,A=N.rounding,-1!==E?0===E?((x=fa(N,C+4,A).times(.5)).s=J.s,x):new N(NaN):(N.precision=C+6,N.rounding=1,J=J.div((new N(1)).minus(J.times(J)).sqrt().plus(1)).atan(), -N.precision=C,N.rounding=A,J.times(2)))};Ba.inverseTangent=Ba.atan=function(){var x,E,C,A,J;var N=this;var Y=N.constructor,T=Y.precision,aa=Y.rounding;if(N.isFinite()){if(N.isZero())return new Y(N);if(N.abs().eq(1)&&T+4<=ud)return(J=fa(Y,T+4,aa).times(.25)).s=N.s,J}else{if(!N.s)return new Y(NaN);if(T+4<=ud)return(J=fa(Y,T+4,aa).times(.5)).s=N.s,J}Y.precision=E=T+10;Y.rounding=1;for(x=C=Math.min(28,E/7+2|0);x;--x)N=N.div(N.times(N).plus(1).sqrt().plus(1));Ua=!1;E=Math.ceil(E/7);var la=1;var xa=N.times(N); -for(J=new Y(N);-1!==x;)if(N=N.times(xa),A=J.minus(N.div(la+=2)),N=N.times(xa),void 0!==(J=A.plus(N.div(la+=2))).d[E])for(x=E;J.d[x]===A.d[x]&&x--;);return C&&(J=J.times(2<this.d.length-2};Ba.isNaN=function(){return!this.s};Ba.isNegative=Ba.isNeg=function(){return 0>this.s};Ba.isPositive=Ba.isPos=function(){return 0this.cmp(x)};Ba.lessThanOrEqualTo=Ba.lte=function(x){return 1>this.cmp(x)};Ba.logarithm=Ba.log=function(x){var E,C,A,J,N,Y=this.constructor,T=Y.precision,aa=Y.rounding;if(null==x){x=new Y(10);var la=!0}else{if(E=(x=new Y(x)).d,0>x.s||!E||!E[0]||x.eq(1))return new Y(NaN);la=x.eq(10)}if(E=this.d,0>this.s||!E||!E[0]||this.eq(1))return new Y(E&&!E[0]?-1/0:1!=this.s?NaN:E?0:1/0);if(la)if(1J)?(E=aa,J=-J,N=ya.length):(E=ya,C=la,N=aa.length);J>(A=Math.max(Math.ceil(Y/7),N)+2)&&(J=A,E.length=1);E.reverse();for(A=J;A--;)E.push(0);E.reverse()}else{(xa=(A=aa.length)<(N=ya.length))&&(N=A);for(A=0;AJ;){if(aa[--A]la?(E=T,la=-la,J=aa.length):(E=aa,C=A,J=T.length);la>(J=(A=Math.ceil(N/7))>J?A+1:J+1)&&(la=J,E.length=1);for(E.reverse();la--;)E.push(0);E.reverse()}0>(J=T.length)-(la=aa.length)&&(la=J,E=aa,aa=T,T=E);for(E=0;la;)E=(T[--la]=T[la]+aa[la]+E)/1E7|0,T[la]%=1E7;E&&(T.unshift(E),++C);for(J=T.length;0==T[--J];)T.pop();return x.d=T,x.e=K(T,C),Ua?D(x,N,Y):x};Ba.precision=Ba.sd=function(x){var E; -if(void 0!==x&&x!==!!x&&1!==x&&0!==x)throw Error("[DecimalError] Invalid argument: "+x);return this.d?(E=V(this.d),x&&this.e+1>E&&(E=this.e+1)):E=NaN,E};Ba.round=function(){var x=this.constructor;return D(new x(this),this.e+1,x.rounding)};Ba.sine=Ba.sin=function(){var x=this,E=x.constructor;if(x.isFinite()){if(x.isZero())var C=new E(x);else{var A=E.precision;var J=E.rounding;E.precision=A+Math.max(x.e,x.sd())+7;E.rounding=1;C=vb(E,x);var N=C.d.length;if(3>N)C=Hb(E,2,C,C);else{var Y=16<(Y=1.4*Math.sqrt(N))? -16:0|Y;C=Hb(E,2,C=C.times(1/Gb(5,Y)),C);for(var T=new E(5),aa=new E(16),la=new E(20);Y--;)N=C.times(C),C=C.times(T.plus(N.times(aa.times(N).minus(la))))}C=(x=C,E.precision=A,E.rounding=J,D(2Y&&(!J||J[0])?NaN:J?this:1/0);Ua=!1;0==(Y=Math.sqrt(+this))||Y==1/0?(0==((E=Z(J)).length+N)%2&&(E+="0"),Y=Math.sqrt(E), -N=rc((N+1)/2)-(0>N||N%2),C=new T(Y==1/0?"5e"+N:(E=Y.toExponential()).slice(0,E.indexOf("e")+1)+N)):C=new T(Y.toString());for(J=(N=T.precision)+3;;)if(C=(A=C).plus(Vb(this,A,J+2,1)).times(.5),Z(A.d).slice(0,J)===(E=Z(C.d)).slice(0,J)){if("9999"!=(E=E.slice(J-3,J+1))&&(aa||"4999"!=E)){+E&&(+E.slice(1)||"5"!=E.charAt(0))||(D(C,N+1,1),x=!C.times(C).eq(this));break}if(!aa&&(D(A,N+1,0),A.times(A).eq(this))){C=A;break}J+=4;var aa=1}return Ua=!0,D(C,N,T.rounding,x)};Ba.tangent=Ba.tan=function(){var x,E,C= -this,A=C.constructor;return C.isFinite()?C.isZero()?new A(C):(x=A.precision,E=A.rounding,A.precision=x+10,A.rounding=1,(C=C.sin()).s=1,C=Vb(C,(new A(1)).minus(C.times(C)).sqrt(),x+10,0),A.precision=x,A.rounding=E,D(2==Pc||4==Pc?C.neg():C,x,E,!0)):new A(NaN)};Ba.times=Ba.mul=function(x){var E,C,A,J,N,Y=this.constructor,T=this.d,aa=(x=new Y(x)).d;if(x.s*=this.s,!(T&&T[0]&&aa&&aa[0]))return new Y(!x.s||T&&!T[0]&&!aa||aa&&!aa[0]&&!T?NaN:T&&aa?0*x.s:x.s/0);var la=rc(this.e/7)+rc(x.e/7);(N=T.length)<(C= -aa.length)&&(A=T,T=aa,aa=A,J=N,N=C,C=J);A=[];for(E=J=N+C;E--;)A.push(0);for(E=C;0<=--E;){var xa=0;for(C=N+E;C>E;)xa=A[C]+aa[E]*T[C-E-1]+xa,A[C--]=xa%1E7|0,xa=xa/1E7|0;A[C]=(A[C]+xa)%1E7|0}for(;!A[--J];)A.pop();return xa?++la:A.shift(),x.d=A,x.e=K(A,la),Ua?D(x,Y.precision,Y.rounding):x};Ba.toBinary=function(x,E){return eb(this,2,x,E)};Ba.toDecimalPlaces=Ba.toDP=function(x,E){var C=this,A=C.constructor;return C=new A(C),void 0===x?C:(Ia(x,0,1E9),void 0===E?E=A.rounding:Ia(E,0,8),D(C,x+C.e+1,E))};Ba.toExponential= -function(x,E){var C,A=this,J=A.constructor;return void 0===x?C=H(A,!0):(Ia(x,0,1E9),void 0===E?E=J.rounding:Ia(E,0,8),C=H(A=D(new J(A),x+1,E),!0,x+1)),A.isNeg()&&!A.isZero()?"-"+C:C};Ba.toFixed=function(x,E){var C,A,J=this.constructor;return void 0===x?C=H(this):(Ia(x,0,1E9),void 0===E?E=J.rounding:Ia(E,0,8),C=H(A=D(new J(this),x+this.e+1,E),!1,x+A.e+1)),this.isNeg()&&!this.isZero()?"-"+C:C};Ba.toFraction=function(x){var E,C,A,J,N,Y,T,aa,la,xa;var ya=this.d;var ra=this.constructor;if(!ya)return new ra(this); -if(aa=C=new ra(1),A=T=new ra(0),N=(J=(E=new ra(A)).e=V(ya)-this.e-1)%7,E.d[0]=jc(10,0>N?7+N:N),null==x)x=0Vb(aa,A,J,1).minus(this).abs().cmp(Vb(T,C,J,1).minus(this).abs())?[aa,A]:[T,C],ra.precision=N,Ua=!0,xa};Ba.toHexadecimal=Ba.toHex=function(x,E){return eb(this,16,x,E)};Ba.toNearest=function(x,E){var C=this,A=C.constructor;if(C=new A(C),null==x){if(!C.d)return C;x=new A(1);E=A.rounding}else{if(x=new A(x),void 0===E?E=A.rounding:Ia(E,0,8),!C.d)return x.s?C:x;if(!x.d)return x.s&&(x.s=C.s),x}return x.d[0]?(Ua=!1,C=Vb(C,x,0,E,1).times(x),Ua=!0,D(C)):(x.s=C.s,C=x),C};Ba.toNumber=function(){return+this}; -Ba.toOctal=function(x,E){return eb(this,8,x,E)};Ba.toPower=Ba.pow=function(x){var E,C,A,J,N,Y,T=this,aa=T.constructor,la=+(x=new aa(x));if(!(T.d&&x.d&&T.d[0]&&x.d[0]))return new aa(jc(+T,la));if((T=new aa(T)).eq(1))return T;if(A=aa.precision,N=aa.rounding,x.eq(1))return D(T,A,N);if((E=rc(x.e/7))>=x.d.length-1&&9007199254740991>=(C=0>la?-la:la))return J=za(aa,T,C,A),0>x.s?(new aa(1)).div(J):D(J,A,N);if(0>(Y=T.s)){if(Eaa.maxE+1||E=J.toExpPos): -(Ia(x,1,1E9),void 0===E?E=J.rounding:Ia(E,0,8),C=H(A=D(new J(A),x,E),x<=A.e||A.e<=J.toExpNeg,x)),A.isNeg()&&!A.isZero()?"-"+C:C};Ba.toSignificantDigits=Ba.toSD=function(x,E){var C=this.constructor;return void 0===x?(x=C.precision,E=C.rounding):(Ia(x,1,1E9),void 0===E?E=C.rounding:Ia(E,0,8)),D(new C(this),x,E)};Ba.toString=function(){var x=this.constructor;x=H(this,this.e<=x.toExpNeg||this.e>=x.toExpPos);return this.isNeg()&&!this.isZero()?"-"+x:x};Ba.truncated=Ba.trunc=function(){return D(new this.constructor(this), -this.e+1,1)};Ba.valueOf=Ba.toJSON=function(){var x=this.constructor;x=H(this,this.e<=x.toExpNeg||this.e>=x.toExpPos);return this.isNeg()?"-"+x:x};var Vb=function(){function x(A,J,N){var Y=0;var T=A.length;for(A=A.slice();T--;)Y=A[T]*J+Y,A[T]=Y%N|0,Y=Y/N|0;return Y&&A.unshift(Y),A}function E(A,J,N,Y){if(N!=Y)var T=N>Y?1:-1;else for(Y=T=0;YJ[Y]?1:-1;break}return T}function C(A,J,N,Y){for(var T=0;N--;)A[N]-=T,T=A[N](Na[Zb]||0)&&xa--,null==N?(ad=N=Rc.precision,Y=Rc.rounding):ad=T?N+(A.e-J.e)+1:N,0>ad)hd.push(1),aa=!0; -else{if(ad=ad/ya+2|0,Zb=0,1==Mc){var gc=0;Xb=Xb[0];for(ad++;(Zb=aa/2&&++me;do gc=0,0>(la=E(Xb,A,Mc,J))?(hc=A[0],Mc!=J&&(hc=hc*aa+(A[1]||0)),1<(gc=hc/me|0)?(gc>=aa&&(gc=aa-1),1==(la=E(ra=x(Xb,gc,aa),A,ub=ra.length,J=A.length))&&(gc--,C(ra, -Mc(la=E(Xb,A,Mc,J=A.length))&&(gc++,C(A,McA.maxE?(this.e=NaN,this.d=null):T.e1/T?-1:1,this.e=0,void(this.d=[0]);if(0>T?(T=-T,this.s=-1):this.s=1,T===~~T&&1E7>T){var xa=0;for(aa=T;10<=aa;aa/=10)xa++;return void(Ua?xa>A.maxE?(this.e=NaN,this.d=null):xaub?new T(0*aa.s):(aa.e=K(ra,hc),aa.d=ra,Ua=!1,la&&(aa=Vb(aa,ya,4*Bc)),xa&&(aa=aa.times(54>Math.abs(xa)?jc(2,xa):Lc.pow(2,xa))),Ua=!0,aa)}}return ya}var J,N;if(A.prototype=Ba,A.ROUND_UP=0,A.ROUND_DOWN=1,A.ROUND_CEIL=2,A.ROUND_FLOOR= -3,A.ROUND_HALF_UP=4,A.ROUND_HALF_DOWN=5,A.ROUND_HALF_EVEN=6,A.ROUND_HALF_CEIL=7,A.ROUND_HALF_FLOOR=8,A.EUCLID=9,A.config=A.set=wd,A.clone=C,A.isDecimal=ta,A.abs=uc,A.acos=Bb,A.acosh=Cc,A.add=Kc,A.asin=nd,A.asinh=Mb,A.atan=Ld,A.atanh=xc,A.atan2=Qc,A.cbrt=vd,A.ceil=kc,A.cos=Wb,A.cosh=nb,A.div=xd,A.exp=Zc,A.floor=Pa,A.hypot=B,A.ln=Aa,A.log=va,A.log10=fb,A.log2=db,A.max=mb,A.min=Va,A.mod=cc,A.mul=Za,A.pow=od,A.random=$c,A.round=yd,A.sign=Wd,A.sin=Xd,A.sinh=zd,A.sqrt=fd,A.sub=Ec,A.tan=Md,A.tanh=Yd,A.trunc= -Db,void 0===E&&(E={}),E&&!0!==E.defaults){var Y="precision rounding toExpNeg toExpPos maxE minE modulo crypto".split(" ");for(J=0;J{var Qa=Object.assign||function(Z){for(var Ia=1;Ia=fa.length&&cb.slice(0,fa.length)===fa&&(D+=H[K[V]],cb=cb.slice(fa.length,cb.length),ea=!0)});ea||(D+=cb.slice(0,1),cb=cb.slice(1,cb.length))};cb;)Ia();return D}},628:function(Ra,Qa){var pa;!function(rb){function Ob(V){function ia(){var Ca=Error.apply(this,arguments);Ca.name=this.name=V;this.stack=Ca.stack;this.message=Ca.message}function za(){}return za.prototype=Error.prototype,ia.prototype=new za,ia}function Z(V,ia){return isNaN(V= -parseInt(V,10))&&Ia(),V*ia}function Ia(){throw new ea;}function Fa(V){for(var ia={},za=V,Ca=2,Oa=4;Oa<=za;){for(;0==za%Ca;)za/=Ca,ia[Ca]=(ia[Ca]||0)+1;Oa+=1+2*Ca++}return za!==V?1V&&(Oa=V,V=-V),0==V%1)za=V;else if(0=lb&&1E7>=Bb;){if(V===(ia=(eb+uc)/(lb+ -Bb))){1E7>=lb+Bb?(za=eb+uc,Ca=lb+Bb):Bb>lb?(za=uc,Ca=Bb):(za=eb,Ca=lb);break}V>ia?(eb+=uc,lb+=Bb):(uc+=eb,Bb+=lb);1E7Oa?-1:1;H.n=Math.abs(za);H.d=Math.abs(Ca)};D.REDUCE=1;D.prototype={s:1,n:0,d:1,abs:function(){return new D(this.n, -this.d)},neg:function(){return new D(-this.s*this.n,this.d)},add:function(V,ia){return fa(V,ia),new D(this.s*this.n*H.d+H.s*this.d*H.n,this.d*H.d)},sub:function(V,ia){return fa(V,ia),new D(this.s*this.n*H.d-H.s*this.d*H.n,this.d*H.d)},mul:function(V,ia){return fa(V,ia),new D(this.s*H.s*this.n*H.n,this.d*H.d)},div:function(V,ia){return fa(V,ia),new D(this.s*H.s*this.n*H.d,this.d*H.n)},clone:function(){return new D(this)},mod:function(V,ia){return isNaN(this.n)||isNaN(this.d)?new D(NaN):void 0===V? -new D(this.s*this.n%this.d,1):(fa(V,ia),0===H.n&&0===this.d&&D(0,0),new D(this.s*H.d*this.n%(H.n*this.d),H.d*this.d))},gcd:function(V,ia){return fa(V,ia),new D(cb(H.n,this.n)*cb(H.d,this.d),H.d*this.d)},lcm:function(V,ia){return fa(V,ia),0===H.n&&0===this.n?new D:new D(H.n*this.n,cb(H.n,this.n)*cb(H.d,this.d))},ceil:function(V){return V=Math.pow(10,V||0),isNaN(this.n)||isNaN(this.d)?new D(NaN):new D(Math.ceil(V*this.s*this.n/this.d),V)},floor:function(V){return V=Math.pow(10,V||0),isNaN(this.n)|| -isNaN(this.d)?new D(NaN):new D(Math.floor(V*this.s*this.n/this.d),V)},round:function(V){return V=Math.pow(10,V||0),isNaN(this.n)||isNaN(this.d)?new D(NaN):new D(Math.round(V*this.s*this.n/this.d),V)},inverse:function(){return new D(this.s*this.d,this.n)},pow:function(V,ia){if(fa(V,ia),1===H.d)return 0>H.s?new D(Math.pow(this.s*this.d,H.n),Math.pow(this.n,H.n)):new D(Math.pow(this.s*this.n,H.n),Math.pow(this.d,H.n));if(0>this.s)return null;V=Fa(this.n);ia=Fa(this.d);var za=1,Ca=1,Oa;for(Oa in V)if("1"!== -Oa){if("0"===Oa){za=0;break}if(V[Oa]*=H.n,0!=V[Oa]%H.d)return null;V[Oa]/=H.d;za*=Math.pow(Oa,V[Oa])}for(Oa in ia)if("1"!==Oa){if(ia[Oa]*=H.n,0!=ia[Oa]%H.d)return null;ia[Oa]/=H.d;Ca*=Math.pow(Oa,ia[Oa])}return 0>H.s?new D(Ca,za):new D(za,Ca)},equals:function(V,ia){return fa(V,ia),this.s*this.n*H.d==H.s*H.n*this.d},compare:function(V,ia){fa(V,ia);V=this.s*this.n*H.d-H.s*H.n*this.d;return(0V)},simplify:function(V){function ia(qb){return 1===qb.length?new D(qb[0]):ia(qb.slice(1)).inverse().add(qb[0])} -if(isNaN(this.n)||isNaN(this.d))return this;var za=this.abs().toContinued();V=V||.001;for(var Ca=0;Cathis.s&&(za+="-"),1===Oa?za+=Ca:(V&&0<(ia=Math.floor(Ca/Oa))&&(za+=ia,za+=" ",Ca%=Oa), -za+=Ca,za+="/",za+=Oa),za},toLatex:function(V){var ia,za="",Ca=this.n,Oa=this.d;return 0>this.s&&(za+="-"),1===Oa?za+=Ca:(V&&0<(ia=Math.floor(Ca/Oa))&&(za+=ia,Ca%=Oa),za+="\\frac{",za+=Ca,za+="}{",za+=Oa,za+="}"),za},toContinued:function(){var V=this.n,ia=this.d,za=[];if(isNaN(V)||isNaN(ia))return za;do{za.push(Math.floor(V/ia));var Ca=V%ia;V=ia;ia=Ca}while(1!==V);return za},toString:function(V){var ia,za=this.n,Ca=this.d;if(isNaN(za)||isNaN(Ca))return"NaN";D.REDUCE||(za/=ia=cb(za,Ca),Ca/=ia);V=V|| -15;ia=function(zb,Hb){for(;0==Hb%2;Hb/=2);for(;0==Hb%5;Hb/=5);if(1===Hb)return 0;zb=10%Hb;for(var Gb=1;1!==zb;Gb++)if(zb=10*zb%Hb,2E3>=1)1&Gb&&(eb=eb*vb%Hb);vb=eb;for(Gb=0;300>Gb;Gb++){if(zb===vb)return Gb;zb=10*zb%Hb;vb=10*vb%Hb}return 0}(0,Ca,ia),qb=-1===this.s?"-":"";if(qb+=za/Ca|0,za%=Ca,(za*=10)&&(qb+="."),ia){for(V=Oa;V--;)qb+=za/Ca|0,za%=Ca,za*=10;qb+="(";for(V=ia;V--;)qb+=za/Ca|0,za%=Ca, -za*=10;qb+=")"}else for(;za&&V--;)qb+=za/Ca|0,za%=Ca,za*=10;return qb}};void 0===(pa=function(){return D}.apply(Qa,[]))||(Ra.exports=pa)}()},228:Ra=>{Ra.exports=function Ob(pa,rb){var Z,Ia,Fa=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,cb=/(^[ ]*|[ ]*$)/g,D=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,H=/^0x[0-9a-f]+$/i,K=/^0/,ea=function(fa){return Ob.insensitive&&(""+fa).toLowerCase()||""+fa};pa= -ea(pa).replace(cb,"")||"";cb=ea(rb).replace(cb,"")||"";rb=pa.replace(Fa,"\x00$1\x00").replace(/\0$/,"").replace(/^\0/,"").split("\x00");Fa=cb.replace(Fa,"\x00$1\x00").replace(/\0$/,"").replace(/^\0/,"").split("\x00");pa=parseInt(pa.match(H),16)||1!==rb.length&&pa.match(D)&&Date.parse(pa);if(D=parseInt(cb.match(H),16)||pa&&cb.match(D)&&Date.parse(cb)||null){if(paD)return 1}D=0;for(H=Math.max(rb.length,Fa.length);DIa)return 1}return 0}},377:(Ra,Qa,pa)=>{Qa=pa(832);var rb=pa(652),Ob=pa(801),Z=pa(30),Ia=pa(618),Fa=pa(49);pa=pa(971);pa.alea=Qa;pa.xor128=rb;pa.xorwow=Ob;pa.xorshift7=Z;pa.xor4096=Ia;pa.tychei=Fa;Ra.exports=pa},832:function(Ra,Qa,pa){var rb;!function(Ob,Z,Ia){function Fa(H){var K,ea=this,fa=(K=4022871197,function(V){V=String(V);for(var ia=0;ia>>0;K=(za*=K)>>>0;K+=4294967296*(za-K)}return 2.3283064365386963E-10*(K>>>0)});ea.next=function(){var V=2091639*ea.s0+2.3283064365386963E-10*ea.c;return ea.s0=ea.s1,ea.s1=ea.s2,ea.s2=V-(ea.c=0|V)};ea.c=1;ea.s0=fa(" ");ea.s1=fa(" ");ea.s2=fa(" ");ea.s0-=fa(H);0>ea.s0&&(ea.s0+=1);ea.s1-=fa(H);0>ea.s1&&(ea.s1+=1);ea.s2-=fa(H);0>ea.s2&&(ea.s2+=1);fa=null}function cb(H,K){return K.c=H.c,K.s0=H.s0,K.s1=H.s1,K.s2=H.s2,K}function D(H,K){var ea=new Fa(H);H= -K&&K.state;var fa=ea.next;return fa.int32=function(){return 4294967296*ea.next()|0},fa.double=function(){return fa()+1.1102230246251565E-16*(2097152*fa()|0)},fa.quick=fa,H&&("object"==typeof H&&cb(H,ea),fa.state=function(){return cb(ea,{})}),fa}Z&&Z.exports?Z.exports=D:pa.amdD&&pa.amdO?void 0===(rb=D)||(Z.exports=rb):this.alea=D}(0,Ra=pa.nmd(Ra),pa.amdD)},49:function(Ra,Qa,pa){var rb;!function(Ob,Z,Ia){function Fa(H){var K=this,ea="";K.next=function(){var fa=K.b,V=K.c,ia=K.d,za=K.a;return fa=fa<< -25^fa>>>7^V,V=V-ia|0,ia=ia<<24^ia>>>8^za,za=za-fa|0,K.b=fa=fa<<20^fa>>>12^V,K.c=V=V-ia|0,K.d=ia<<16^V>>>16^za,K.a=za-fa|0};K.a=0;K.b=0;K.c=-1640531527;K.d=1367130551;H===Math.floor(H)?(K.a=H/4294967296|0,K.b=0|H):ea+=H;for(H=0;H>>0)/4294967296};return K.double=function(){do var fa=((ea.next()>>>11)+(ea.next()>>>0)/ -4294967296)/2097152;while(0===fa);return fa},K.int32=ea.next,K.quick=K,H&&("object"==typeof H&&cb(H,ea),K.state=function(){return cb(ea,{})}),K}Z&&Z.exports?Z.exports=D:pa.amdD&&pa.amdO?void 0===(rb=D)||(Z.exports=rb):this.tychei=D}(0,Ra=pa.nmd(Ra),pa.amdD)},652:function(Ra,Qa,pa){var rb;!function(Ob,Z,Ia){function Fa(H){var K=this,ea="";K.x=0;K.y=0;K.z=0;K.w=0;K.next=function(){var fa=K.x^K.x<<11;return K.x=K.y,K.y=K.z,K.z=K.w,K.w=K.w^K.w>>>19^fa^fa>>>8};H===(0|H)?K.x=H:ea+=H;for(H=0;H>>0)/4294967296};return K.double=function(){do var fa=((ea.next()>>>11)+(ea.next()>>>0)/4294967296)/2097152;while(0===fa);return fa},K.int32=ea.next,K.quick=K,H&&("object"==typeof H&&cb(H,ea),K.state=function(){return cb(ea,{})}),K}Z&&Z.exports?Z.exports=D:pa.amdD&&pa.amdO?void 0===(rb=D)||(Z.exports=rb):this.xor128=D}(0,Ra=pa.nmd(Ra), -pa.amdD)},618:function(Ra,Qa,pa){var rb;!function(Ob,Z,Ia){function Fa(H){var K=this;K.next=function(){var ea,fa,V=K.w,ia=K.X,za=K.i;return K.w=V=V+1640531527|0,fa=ia[za+34&127],ea=ia[za=za+1&127],fa^=fa<<13,ea^=ea<<17,fa^=fa>>>15,ea^=ea>>>12,fa=ia[za]=fa^ea,K.i=za,fa+(V^V>>>16)|0};(function(ea,fa){var V,ia,za,Ca=[],Oa=128;fa===(0|fa)?(V=fa,fa=null):(fa+="\x00",V=0,Oa=Math.max(Oa,fa.length));var qb=0;for(ia=-32;ia>>15, -V^=V<<4,V^=V>>>13,0<=ia&&(za=za+1640531527|0,qb=0==(Ca[127&ia]^=V+za)?qb+1:0);128<=qb&&(Ca[127&(fa&&fa.length||0)]=-1);qb=127;for(ia=512;0>>15,fa^=fa>>>12,Ca[qb]=V^fa;ea.w=za;ea.X=Ca;ea.i=qb})(K,H)}function cb(H,K){return K.i=H.i,K.w=H.w,K.X=H.X.slice(),K}function D(H,K){null==H&&(H=+new Date);var ea=new Fa(H);H=K&&K.state;K=function(){return(ea.next()>>>0)/4294967296};return K.double=function(){do var fa=((ea.next()>>>11)+(ea.next()>>> -0)/4294967296)/2097152;while(0===fa);return fa},K.int32=ea.next,K.quick=K,H&&(H.X&&cb(H,ea),K.state=function(){return cb(ea,{})}),K}Z&&Z.exports?Z.exports=D:pa.amdD&&pa.amdO?void 0===(rb=D)||(Z.exports=rb):this.xor4096=D}(0,Ra=pa.nmd(Ra),pa.amdD)},30:function(Ra,Qa,pa){var rb;!function(Ob,Z,Ia){function Fa(H){var K=this;K.next=function(){var ea,fa,V=K.x,ia=K.i;return ea=V[ia],fa=(ea^=ea>>>7)^ea<<24,fa^=(ea=V[ia+1&7])^ea>>>10,fa^=(ea=V[ia+3&7])^ea>>>3,fa^=(ea=V[ia+4&7])^ea<<7,ea=V[ia+7&7],fa^=(ea^= -ea<<13)^ea<<9,V[ia]=fa,K.i=ia+1&7,fa};(function(ea,fa){var V,ia=[];if(fa===(0|fa))ia[0]=fa;else for(fa=""+fa,V=0;Via.length;)ia.push(0);for(V=0;8>V&&0===ia[V];++V);8==V?ia[7]=-1:ia[V];ea.x=ia;ea.i=0;for(V=256;0>>0)/4294967296};return K.double=function(){do var fa= -((ea.next()>>>11)+(ea.next()>>>0)/4294967296)/2097152;while(0===fa);return fa},K.int32=ea.next,K.quick=K,H&&(H.x&&cb(H,ea),K.state=function(){return cb(ea,{})}),K}Z&&Z.exports?Z.exports=D:pa.amdD&&pa.amdO?void 0===(rb=D)||(Z.exports=rb):this.xorshift7=D}(0,Ra=pa.nmd(Ra),pa.amdD)},801:function(Ra,Qa,pa){var rb;!function(Ob,Z,Ia){function Fa(H){var K=this,ea="";K.next=function(){var fa=K.x^K.x>>>2;return K.x=K.y,K.y=K.z,K.z=K.w,K.w=K.v,(K.d=K.d+362437|0)+(K.v=K.v^K.v<<4^fa^fa<<1)|0};K.x=0;K.y=0;K.z= -0;K.w=0;K.v=0;H===(0|H)?K.x=H:ea+=H;for(H=0;H>>4),K.next()}function cb(H,K){return K.x=H.x,K.y=H.y,K.z=H.z,K.w=H.w,K.v=H.v,K.d=H.d,K}function D(H,K){var ea=new Fa(H);H=K&&K.state;K=function(){return(ea.next()>>>0)/4294967296};return K.double=function(){do var fa=((ea.next()>>>11)+(ea.next()>>>0)/4294967296)/2097152;while(0===fa);return fa},K.int32=ea.next,K.quick=K,H&&("object"==typeof H&&cb(H,ea),K.state=function(){return cb(ea, -{})}),K}Z&&Z.exports?Z.exports=D:pa.amdD&&pa.amdO?void 0===(rb=D)||(Z.exports=rb):this.xorwow=D}(0,Ra=pa.nmd(Ra),pa.amdD)},971:function(Ra,Qa,pa){var rb;!function(Ob,Z,Ia){function Fa(Ca,Oa,qb){var zb=[],Hb=K(H((Oa=1==Oa?{entropy:!0}:Oa||{}).entropy?[Ca,ea(Z)]:null==Ca?function(){try{var vb;return za&&(vb=za.randomBytes)?vb=vb(256):(vb=new Uint8Array(256),(Ob.crypto||Ob.msCrypto).getRandomValues(vb)),ea(vb)}catch(eb){return vb=Ob.navigator,[+new Date,Ob,vb&&vb.plugins,Ob.screen,ea(Z)]}}():Ca,3),zb), -Gb=new cb(zb);Ca=function(){for(var vb=Gb.g(6),eb=fa,lb=0;vb=ia;)vb/=2,eb/=2,lb>>>=1;return(vb+lb)/eb};return Ca.int32=function(){return 0|Gb.g(4)},Ca.quick=function(){return Gb.g(4)/4294967296},Ca.double=Ca,K(ea(Gb.S),Z),(Oa.pass||qb||function(vb,eb,lb,uc){return uc&&(uc.S&&D(uc,Gb),vb.state=function(){return D(Gb,{})}),lb?(Ia.random=vb,eb):vb})(Ca,Hb,"global"in Oa?Oa.global:this==Ia,Oa.state)}function cb(Ca){var Oa,qb=Ca.length,zb=this,Hb=0,Gb=zb.i= -zb.j=0,vb=zb.S=[];for(qb||(Ca=[qb++]);256>Hb;)vb[Hb]=Hb++;for(Hb=0;256>Hb;Hb++)vb[Hb]=vb[Gb=255&Gb+Ca[Hb%qb]+(Oa=vb[Hb])],vb[Gb]=Oa;(zb.g=function(eb){for(var lb,uc=0,Bb=zb.i,Cc=zb.j,Kc=zb.S;eb--;)lb=Kc[Bb=255&Bb+1],uc=256*uc+Kc[255&(Kc[Bb]=Kc[Cc=255&Cc+lb])+(Kc[Cc]=lb)];return zb.i=Bb,zb.j=Cc,uc})(256)}function D(Ca,Oa){return Oa.i=Ca.i,Oa.j=Ca.j,Oa.S=Ca.S.slice(),Oa}function H(Ca,Oa){var qb,zb=[],Hb=typeof Ca;if(Oa&&"object"==Hb)for(qb in Ca)try{zb.push(H(Ca[qb],Oa-1))}catch(Gb){}return zb.length? -zb:"string"==Hb?Ca:Ca+"\x00"}function K(Ca,Oa){var qb;Ca+="";for(var zb=0;zb=db+1}}return 0=== -B.length?function(mb){return 0===mb.length}:1===B.length?(Aa=ia(B[0]),function(mb){return Aa(mb[0])&&1===mb.length}):2===B.length?(Aa=ia(B[0]),va=ia(B[1]),function(mb){return Aa(mb[0])&&va(mb[1])&&2===mb.length}):(ta=B.map(ia),function(mb){for(var Va=0;Vadb?((va=new TypeError("Too many arguments in function "+B+" (expected: "+db+", actual: "+ta.length+")")).data={category:"tooManyArgs",fn:B,index:ta.length,expectedLength:db},va):((va=new TypeError('Arguments of type "'+ta.join(", ")+'" do not match any of the defined signatures of function '+B+".")).data={category:"mismatch",actual:ta.map(H)},va)}function vb(B){for(var ta=999,Aa=0;Aa=N:T?N>=Y:N===Y}return J});if(A)throw new TypeError('Conflicting signatures "'+K(A.params)+'" and "'+K(C.params)+'".');Aa.push(C)});var va=vd(Aa,function(C){return(C?Bb(C.params,!1):[]).map(function(A){return{params:A,fn:C.fn}})}).filter(Ld);va.sort(lb);var db=va[0]&&2>=va[0].params.length&& -!fa(va[0].params),fb=va[1]&&2>=va[1].params.length&&!fa(va[1].params),mb=va[2]&&2>=va[2].params.length&&!fa(va[2].params),Va=va[3]&&2>=va[3].params.length&&!fa(va[3].params),cc=va[4]&&2>=va[4].params.length&&!fa(va[4].params),Za=va[5]&&2>=va[5].params.length&&!fa(va[5].params),od=db&&fb&&mb&&Va&&cc&&Za,$c=va.map(function(C){return za(C.params)}),yd=db?ia(va[0].params[0]):Z,Wd=fb?ia(va[1].params[0]):Z,Xd=mb?ia(va[2].params[0]):Z,zd=Va?ia(va[3].params[0]):Z,fd=cc?ia(va[4].params[0]):Z,Ec=Za?ia(va[5].params[0]): -Z,Md=db?ia(va[0].params[1]):Z,Yd=fb?ia(va[1].params[1]):Z,Db=mb?ia(va[2].params[1]):Z,Lc=Va?ia(va[3].params[1]):Z,Dc=cc?ia(va[4].params[1]):Z,Pc=Za?ia(va[5].params[1]):Z,wc=va.map(function(C){return function(A,J){var N=J;if(A.some(V)){var Y=fa(A),T=A.map(uc);N=function(){for(var xa=[],ya=Y?arguments.length-1:arguments.length,ra=0;ra{}},Nb={};jb.amdD=function(){throw Error("define cannot be used indirect");};jb.amdO= -{};jb.nmd=Ra=>(Ra.paths=[],Ra.children||(Ra.children=[]),Ra);(()=>{function Ra(){return(Ra=Object.assign||function(b){for(var a=1;a!(g&&"?"===g[0])).every(g=>void 0!==n[g]))throw k=k.filter(g=>void 0===n[g]),Error('Cannot create function "'.concat(p,'", ')+"some dependencies are missing: ".concat(k.map(g=>'"'.concat(g,'"')).join(", "),"."));}(b,a,h),d(l)}return f.isFactory=!0,f.fn= -b,f.dependencies=a.slice().sort(),c&&(f.meta=c),f}function ta(b){return b&&"?"===b[0]?b.slice(1):b}function Aa(b,a){if("object"==typeof b&&b&&b.constructor===Object&&db(b,a))return b[a];if("function"==typeof b[a]&&fb(b,a))throw Error('Cannot access method "'+a+'" as a property');throw Error('No access to property "'+a+'"');}function va(b,a,d){if("object"==typeof b&&b&&b.constructor===Object&&db(b,a))return b[a]=d,d;throw Error('No access to property "'+a+'"');}function db(b,a){return!(!b||"object"!= -typeof b||!Pa(qi,a)&&(a in Object.prototype||a in Function.prototype))}function fb(b,a){return!(null==b||"function"!=typeof b[a]||Pa(b,a)&&Object.getPrototypeOf&&a in Object.getPrototypeOf(b)||!Pa(ri,a)&&(a in Object.prototype||a in Function.prototype))}function mb(b){if(!b)return new Map;if(Va(b))return b;if(qb(b))return new We(b);throw Error("createMap can create maps from objects or Maps");}function Va(b){return!!b&&(b instanceof Map||b instanceof We||"function"==typeof b.set&&"function"==typeof b.get&& -"function"==typeof b.keys&&"function"==typeof b.has)}function cc(b){for(var a=arguments.length,d=Array(1d)throw Error("size must be in greater than 0");if(!Za(d))throw Error("size must be an integer"); -if(b>Math.pow(2,d-1)-1||b<-Math.pow(2,d-1))throw Error("Value must be in range [-2^".concat(d-1,", 2^").concat(d-1,"-1]"));if(!Za(b))throw Error("Value must be an integer");0>b&&(b+=Math.pow(2,d));f="i".concat(d)}d="";return 0>b&&(b=-b,d="-"),"".concat(d).concat(c).concat(b.toString(a)).concat(f)}function $c(b,a){if("function"==typeof a)return a(b);if(b===1/0)return"Infinity";if(b===-1/0)return"-Infinity";if(isNaN(b))return"NaN";var d,c,f="auto";if(a&&(a.notation&&(f=a.notation),Qa(a)?d=a:Qa(a.precision)&& -(d=a.precision),a.wordSize&&"number"!=typeof(c=a.wordSize)))throw Error('Option "wordSize" must be a number');switch(f){case "fixed":return Wd(b,d);case "exponential":return Xd(b,d);case "engineering":return function(h,l){if(isNaN(h)||!isFinite(h))return String(h);h=zd(yd(h),l);var p=h.exponent,k=h.coefficients,n=0==p%3?p:0>p?p-3-p%3:p-p%3;if(Qa(l))for(;l>k.length||p-n+1>k.length;)k.push(0);else for(var g=Math.abs(p-n)-(k.length-1),e=0;e=n)return Xd(h,l);h=p.coefficients;k=p.exponent;h.lengthc&&(d=fd(1-c).concat(d),c=1),c=a;)d.unshift(0),b.exponent++,a++;if(d.length>a&&5<=d.splice(a,d.length-a)[0])for(--a,d[a]++;10===d[a];)d.pop(), -0===a&&(d.unshift(0),b.exponent++,a++),d[--a]++;return b}function fd(b){for(var a=[],d=0;dd)throw Error("size must be in greater than 0");if(!Za(d))throw Error("size must be an integer");if(b.greaterThan(c.pow(d- -1).sub(1))||b.lessThan(c.pow(d-1).mul(-1)))throw Error("Value must be in range [-2^".concat(d-1,", 2^").concat(d-1,"-1]"));if(!b.isInteger())throw Error("Value must be an integer");b.lessThan(0)&&(b=b.add(c.pow(d)));f="i".concat(d)}switch(a){case 2:return"".concat(b.toBinary()).concat(f);case 8:return"".concat(b.toOctal()).concat(f);case 16:return"".concat(b.toHexadecimal()).concat(f);default:throw Error("Base ".concat(a," not supported "));}}function Yd(b,a){return void 0!==a?b.toExponential(a-1): -b.toExponential()}function Db(b,a){return"number"==typeof b?$c(b,a):pa(b)?function(d,c){if("function"==typeof c)return c(d);if(!d.isFinite())return d.isNaN()?"NaN":d.gt(0)?"Infinity":"-Infinity";var f,h,l="auto";if(void 0!==c&&(c.notation&&(l=c.notation),"number"==typeof c?f=c:c.precision&&(f=c.precision),c.wordSize&&"number"!=typeof(h=c.wordSize)))throw Error('Option "wordSize" must be a number');switch(l){case "fixed":return d.toFixed(f);case "exponential":return Yd(d,f);case "engineering":return function(k, -n){var g=k.e,e=0==g%3?g:0>g?g-3-g%3:g-g%3;k=k.mul(Math.pow(10,-e));n=k.toPrecision(n);return-1!==n.indexOf("e")&&(n=k.toString()),n+"e"+(0<=g?"+":"")+e.toString()}(d,f);case "bin":return Md(d,2,h);case "oct":return Md(d,8,h);case "hex":return Md(d,16,h);case "auto":h=c&&void 0!==c.lowerExp?c.lowerExp:-3;c=c&&void 0!==c.upperExp?c.upperExp:5;if(d.isZero())return"0";l=d.toSignificantDigits(f);var p=l.e;return(p>=h&&p -'"'+d+'": '+Db(b[d],a)).join(", ")+"}":String(b)}function Lc(b){b=String(b);for(var a="",d=0;d/g,">")}function Pc(b,a){if(Array.isArray(b)){for(var d="[",c=b.length,f=0;fa?1:-1}function yb(b,a,d){if(!(this instanceof yb))throw new SyntaxError("Constructor must be called with the new operator");this.actual=b;this.expected= -a;this.relation=d;this.message="Dimension mismatch ("+(Array.isArray(b)?"["+b.join(", ")+"]":b)+" "+(this.relation||"!=")+" "+(Array.isArray(a)?"["+a.join(", ")+"]":a)+")";this.stack=Error().stack}function Gc(b,a,d){if(!(this instanceof Gc))throw new SyntaxError("Constructor must be called with the new operator");this.index=b;3>arguments.length?(this.min=0,this.max=a):(this.min=a,this.max=d);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=Error().stack}function Ua(b){for(var a=[];Array.isArray(b);)a.push(b.length),b=b[0];return a}function rc(b,a,d){var c=b.length;if(c!==a[d])throw new yb(c,a[d]);if(d");}function jc(b,a){if(0===a.length){if(Array.isArray(b))throw new yb(b.length,0);}else rc(b,a,0)}function Yb(b,a){if(!Qa(b)||!Za(b))throw new TypeError("Index must be an integer (value: "+b+")");if(0>b||"number"==typeof a&&b>=a)throw new Gc(b,a);}function gd(b,a,d){if(!Array.isArray(b)||!Array.isArray(a))throw new TypeError("Array expected");if(0===a.length)throw Error("Resizing to scalar is not supported");return a.forEach(function(c){if(!Qa(c)||!Za(c)||0>c)throw new TypeError("Invalid size, must contain positive integers (size: "+ -Db(a)+")");}),Nd(b,a,0,void 0!==d?d:0),b}function Nd(b,a,d,c){var f=a[d],h=Math.min(b.length,f);if(b.length=f,d -a*d,1)}function Ba(b,a){for(a=a||Ua(b);Array.isArray(b)&&1===b.length;)b=b[0],a.shift();for(var d=a.length;1===a[d-1];)d--;return da.test(d))}function T(b){if(!Array.isArray(b))throw new TypeError("Array input expected");if(0===b.length)return b;var a=[],d=0;a[0]={value:b[0],identifier:0};for(var c=1;ca||a>=c.length)throw new Gc(a,c.length);return Fa(b)?b.create(Mc(b.valueOf(),a,d)):Mc(b,a,d)}function Mc(b,a,d){var c,f;if(0>=a){if(Array.isArray(b[0])){var h=b.length,l=b[0].length,p=[];for(f=0;f=a){if(Array.isArray(b[0])){var h= -b.length,l=b[0].length,p=[];for(f=0;f -h)for(b=h-1,f=l.length;b{var {config:f,Unit:h,BigNumber:l}=c;c=new h("BigNumber"===f.number?new l(a):parseFloat(a),d);return c.fixPrefix=!0,c})}function Ge(b,a){return B(b,["config","BigNumber"], -d=>{var {config:c,BigNumber:f}=d;return"BigNumber"===c.number?new f(a):a})}function Ze(b){throw Error("Cannot convert value ".concat(b," into a BigNumber: no class 'BigNumber' provided"));}function He(b){throw Error("Cannot convert value ".concat(b," into a Complex number: no class 'Complex' provided"));}function $e(b){throw Error("Cannot convert value ".concat(b," into a Fraction, no class 'Fraction' provided."));}function Df(b){return 0>b}function Ef(b){return 0b?-b:b}function Sf(b,a){if(!Za(b)||!Za(a))throw Error("Parameters in function lcm must be integer numbers");if(0===b||0===a)return 0;for(var d=b*a;0!==a;)a=b%(b=a);return Math.abs(d/b)}function Tf(b){return Math.log(b)}function Uf(b,a){if(0a;if(d&&(a=-a),0===a)throw Error("Root must be non-zero");if(0>b&&1!=Math.abs(a)%2)throw Error("Root must be odd when a is negative.");if(0===b)return d?1/0:0;if(!isFinite(b))return d?0:b;a=Math.pow(Math.abs(b),1/a);return a=0>b?-a:a,d?1/a:a}function Vf(b){return pd(b)}function Wf(b){return b*b}function Xf(b,a){var d,c=0,f=1,h=1,l=0;if(!Za(b)||!Za(a))throw Error("Parameters in function xgcd must be integer numbers");for(;a;){var p=b-(d=Math.floor(b/a))*a;b=c;c=f-d*c;f=b; -b=h;h=l-d*h;l=b;b=a;a=p}return 0>b?[-b,-f,-l]:[b,b?f:0,l]}function Yf(b,a){return 1>b*b&&a===1/0||1b.s),k=+(0>a.s);if(p){b=Je(oe(b));for(var n=0;na)for(b-=a;b--;)d+="0";else b>1,b[c]&=1)}return b.reverse()}function Bi(b,a){if(b.isFinite()&&!b.isInteger()||a.isFinite()&& -!a.isInteger())throw Error("Integers expected in function bitXor");var d=b.constructor;if(b.isNaN()||a.isNaN())return new d(NaN);if(b.isZero())return a;if(a.isZero())return b;if(b.eq(a))return new d(0);var c=new d(-1);return b.eq(c)?oe(a):a.eq(c)?oe(b):b.isFinite()&&a.isFinite()?cf(b,a,function(f,h){return f^h}):b.isFinite()||a.isFinite()?new d(b.isNegative()===a.isNegative()?1/0:-1/0):c}function Ci(b,a){if(b.isFinite()&&!b.isInteger()||a.isFinite()&&!a.isInteger())throw Error("Integers expected in function leftShift"); -var d=b.constructor;return b.isNaN()||a.isNaN()||a.isNegative()&&!a.isZero()?new d(NaN):b.isZero()||a.isZero()?b:b.isFinite()||a.isFinite()?a.lt(55)?b.times(Math.pow(2,a.toNumber())+""):b.times((new d(2)).pow(a)):new d(NaN)}function Di(b,a){if(b.isFinite()&&!b.isInteger()||a.isFinite()&&!a.isInteger())throw Error("Integers expected in function rightArithShift");var d=b.constructor;return b.isNaN()||a.isNaN()||a.isNegative()&&!a.isZero()?new d(NaN):b.isZero()||a.isZero()?b:a.isFinite()?a.lt(55)?b.div(Math.pow(2, -a.toNumber())+"").floor():b.div((new d(2)).pow(a)).floor():b.isNegative()?new d(-1):b.isFinite()?new d(0):new d(NaN)}function Zf(b,a){if(!Za(b)||!Za(a))throw Error("Integers expected in function bitAnd");return b&a}function $f(b){if(!Za(b))throw Error("Integer expected in function bitNot");return~b}function ag(b,a){if(!Za(b)||!Za(a))throw Error("Integers expected in function bitOr");return b|a}function bg(b,a){if(!Za(b)||!Za(a))throw Error("Integers expected in function bitXor");return b^a}function cg(b, -a){if(!Za(b)||!Za(a))throw Error("Integers expected in function leftShift");return b<>a}function eg(b,a){if(!Za(b)||!Za(a))throw Error("Integers expected in function rightLogShift");return b>>>a}function fg(b){return!b}function gg(b,a){return!(!b&&!a)}function hg(b,a){return!!b!=!!a}function ig(b,a){return!(!b||!a)}function jg(b,a){var d=$d(a);return N(b,function(c,f,h){return 1===d?a(c):2=== -d?a(c,[f]):a(c,[f],h)})}function Ei(b,a){var d=$d(a);!function l(f,h){Array.isArray(f)?J(f,function(p,k){l(p,h.concat(k))}):1===d?a(f):2===d?a(f,h):a(f,h,b)}(b,[])}function Fi(b,a){var d=$d(a);return function l(f,h){return Array.isArray(f)?f.map(function(p,k){return l(p,h.concat(k))}):1===d?a(f):2===d?a(f,h):a(f,h,b)}(b,[])}function kg(b,a,d){return b.replace(/\$([\w.]+)/g,function(c,f){f=f.split(".");for(var h=a[f.shift()];f.length&&void 0!==h;){var l=f.shift();h=l?h[l]:h+"."}return void 0!==h?Ia(h)? -h:Db(h,d):c})}function lg(b){return Math.atan(1/b)}function mg(b){return isFinite(b)?(Math.log((b+1)/b)+Math.log(b/(b-1)))/2:0}function ng(b){return Math.asin(1/b)}function og(b){b=1/b;return Math.log(b+Math.sqrt(b*b+1))}function pg(b){return Math.acos(1/b)}function qg(b){b=1/b;return Math.log(Math.sqrt(b*b-1)+b)}function rg(b){return Gi(b)}function sg(b){return 1/Math.tan(b)}function tg(b){b=Math.exp(2*b);return(b+1)/(b-1)}function ug(b){return 1/Math.sin(b)}function vg(b){return 0===b?Number.POSITIVE_INFINITY: -Math.abs(2/(Math.exp(b)-Math.exp(-b)))*pd(b)}function wg(b){return 1/Math.cos(b)}function xg(b){return 2/(Math.exp(b)+Math.exp(-b))}function yg(b){return Hi(b)}function Wc(b,a){if(a>1;return Wc(b,d)*Wc(d+1,a)}function zg(b,a){if(!Za(b)||0>b)throw new TypeError("Positive integer value expected in function combinations");if(!Za(a)||0>a)throw new TypeError("Positive integer value expected in function combinations");if(a>b)throw new TypeError("k must be less than or equal to n"); -var d=b-a;return a=b?isFinite(b)?1/0:NaN:171b)return Math.PI/(Math.sin(Math.PI*b)*ef(1-b));if(171.35<=b)return 1/ -0;if(85 -b?-b-2:b}function Kg(b,a){var d=Object.keys(b);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(b);a&&(c=c.filter(function(f){return Object.getOwnPropertyDescriptor(b,f).enumerable}));d.push.apply(d,c)}return d}function ff(b){for(var a=1;a{function a(){if(!(this instanceof -a))throw new SyntaxError("Constructor must be called with the new operator");}var {mathWithTransform:d}=b;return a.prototype.evaluate=function(c){return this.compile().evaluate(c)},a.prototype.type="Node",a.prototype.isNode=!0,a.prototype.comment="",a.prototype.compile=function(){var c=this._compile(d,{}),f={};return{evaluate:function(h){h=mb(h);for(var l of[...Ng])if(h.has(l))throw Error('Scope contains an illegal symbol, "'+l+'" is a reserved keyword');return c(h,f,null)}}},a.prototype._compile= -function(c,f){throw Error("Method _compile should be implemented by type "+this.type);},a.prototype.forEach=function(c){throw Error("Cannot run forEach on a Node interface");},a.prototype.map=function(c){throw Error("Cannot run map on a Node interface");},a.prototype._ifNode=function(c){if(!Mb(c))throw new TypeError("Callback function must return a Node");return c},a.prototype.traverse=function(c){c(this,null,null);(function p(h,l){h.forEach(function(k,n,g){l(k,n,g);p(k,l)})})(this,c)},a.prototype.transform= -function(c){return function k(h,l,p){l=c(h,l,p);return l!==h?l:h.map(k)}(this,null,null)},a.prototype.filter=function(c){var f=[];return this.traverse(function(h,l,p){c(h,l,p)&&f.push(h)}),f},a.prototype.clone=function(){throw Error("Cannot clone a Node interface");},a.prototype.cloneDeep=function(){return this.map(function(c){return c.cloneDeep()})},a.prototype.equals=function(c){return!!c&&Zc(this,c)},a.prototype.toString=function(c){var f=this._getCustomString(c);return void 0!==f?f:this._toString(c)}, -a.prototype.toJSON=function(){throw Error("Cannot serialize object: toJSON not implemented by "+this.type);},a.prototype.toHTML=function(c){var f=this._getCustomString(c);return void 0!==f?f:this.toHTML(c)},a.prototype._toString=function(){throw Error("_toString not implemented for "+this.type);},a.prototype.toTex=function(c){var f=this._getCustomString(c);return void 0!==f?f:this._toTex(c)},a.prototype._toTex=function(c){throw Error("_toTex not implemented for "+this.type);},a.prototype._getCustomString= -function(c){if(c&&"object"==typeof c)switch(typeof c.handler){case "object":case "undefined":break;case "function":return c.handler(this,c);default:throw new TypeError("Object or function expected as callback");}},a.prototype.getIdentifier=function(){return this.type},a.prototype.getContent=function(){return this},a},{isClass:!0,isNode:!0}),pd=Math.sign||function(b){return 0b?-1:0},Ki=Math.log2||function(b){return Math.log(b)/Math.LN2},Li=Math.log10||function(b){return Math.log(b)/Math.LN10}, -Mi=Math.log1p||function(b){return Math.log(b+1)},Ie=Math.cbrt||function(b){if(0===b)return b;var a,d=0>b;return d&&(b=-b),a=isFinite(b)?(b/((a=Math.exp(Math.log(b)/3))*a)+2*a)/3:b,d?-a:a},yi=Math.expm1||function(b){return 2E-4<=b||-2E-4>=b?Math.exp(b)-1:b+b*b/2+b*b*b/6},si=Number.EPSILON||2.220446049250313E-16,Ni=Math.acosh||function(b){return Math.log(Math.sqrt(b*b-1)+b)},Gi=Math.asinh||function(b){return Math.log(Math.sqrt(b*b+1)+b)},Oi=Math.atanh||function(b){return Math.log((1+b)/(1-b))/2},Pi= -Math.cosh||function(b){return(Math.exp(b)+Math.exp(-b))/2},Hi=Math.sinh||function(b){return(Math.exp(b)-Math.exp(-b))/2},Qi=Math.tanh||function(b){b=Math.exp(2*b);return(b-1)/(b+1)};yb.prototype=new RangeError;yb.prototype.constructor=RangeError;yb.prototype.name="DimensionError";yb.prototype.isDimensionError=!0;Gc.prototype=new RangeError;Gc.prototype.constructor=RangeError;Gc.prototype.name="IndexError";Gc.prototype.isIndexError=!0;var Ri=B("ArrayNode",["Node"],b=>{function a(d){if(!(this instanceof -a))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=d||[],!Array.isArray(this.items)||!this.items.every(Mb))throw new TypeError("Array containing Nodes expected");}({Node:b}=b);return a.prototype=new b,a.prototype.type="ArrayNode",a.prototype.isArrayNode=!0,a.prototype._compile=function(d,c){var f=A(this.items,function(l){return l._compile(d,c)});if("Array"!==d.config.matrix){var h=d.matrix;return function(l,p,k){return h(A(f,function(n){return n(l,p,k)}))}}return function(l, -p,k){return A(f,function(n){return n(l,p,k)})}},a.prototype.forEach=function(d){for(var c=0;c['+this.items.map(function(c){return c.toHTML(d)}).join(',')+']'},a.prototype._toTex=function(d){var c="\\begin{bmatrix}";return this.items.forEach(function(f){f.items?c+=f.items.map(function(h){return h.toTex(d)}).join("&"):c+=f.toTex(d); -c+="\\\\"}),c+="\\end{bmatrix}"},a},{isClass:!0,isNode:!0}),Si=B("BlockNode",["ResultSet","Node"],b=>{function a(f){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(f))throw Error("Array expected");this.blocks=f.map(function(h){var l=h&&h.node;h=!h||void 0===h.visible||h.visible;if(!Mb(l))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof h)throw new TypeError('Property "visible" must be a boolean');return{node:l, -visible:h}})}var {ResultSet:d,Node:c}=b;return a.prototype=new c,a.prototype.type="BlockNode",a.prototype.isBlockNode=!0,a.prototype._compile=function(f,h){var l=A(this.blocks,function(p){return{evaluate:p.node._compile(f,h),visible:p.visible}});return function(p,k,n){var g=[];return J(l,function(e){var m=e.evaluate(p,k,n);e.visible&&g.push(m)}),new d(g)}},a.prototype.forEach=function(f){for(var h=0;h;')}).join('
')},a.prototype._toTex=function(f){return this.blocks.map(function(h){return h.node.toTex(f)+(h.visible?"":";")}).join("\\;\\;\n")},a},{isClass:!0,isNode:!0}),ti=jb(928),Xe={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{?}"},Pb={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"},Og={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(Pb.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(Pb.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(Pb.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(Pb.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(Pb.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(Pb.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(Pb.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(Pb.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(Pb.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(Pb.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(Pb.unaryPlus,"\\left(${args[0]}\\right)")}, -bitAnd:{2:"\\left(${args[0]}".concat(Pb.bitAnd,"${args[1]}\\right)")},bitNot:{1:Pb.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(Pb.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(Pb.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(Pb.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(Pb.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(Pb.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(Pb.and,"${args[1]}\\right)")},not:{1:Pb.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(Pb.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(Pb.xor, -"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(Pb.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},sqrtm:{1:"{${args[0]}}".concat(Pb.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(Pb.transpose)}, -combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(Pb.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(Pb.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(Pb.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(Pb.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(Pb.smaller, -"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(Pb.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(Pb.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(Pb.to,"${args[1]}\\right)")},numeric:function(b, -a){return b.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(Xe.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)"}},yf={deg:"^\\circ"},Ti=B("ConstantNode",["Node"],b=>{function a(d){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this.value=d}({Node:b}=b);return a.prototype=new b,a.prototype.type="ConstantNode",a.prototype.isConstantNode=!0,a.prototype._compile=function(d,c){var f=this.value;return function(){return f}},a.prototype.forEach= -function(d){},a.prototype.map=function(d){return this.clone()},a.prototype.clone=function(){return new a(this.value)},a.prototype._toString=function(d){return Db(this.value,d)},a.prototype.toHTML=function(d){d=this._toString(d);switch(Wb(this.value)){case "number":case "BigNumber":case "Fraction":return''+d+"";case "string":return''+d+"";case "boolean":return''+d+"";case "null":return''+ -d+"";case "undefined":return''+d+"";default:return''+d+""}},a.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},a.fromJSON=function(d){return new a(d.value)},a.prototype._toTex=function(d){d=this._toString(d);switch(Wb(this.value)){case "string":return"\\mathtt{"+xa(d)+"}";case "number":case "BigNumber":if(!isFinite(this.value))return 0>this.value.valueOf()?"-\\infty":"\\infty";var c=d.toLowerCase().indexOf("e"); -return-1!==c?d.substring(0,c)+"\\cdot10^{"+d.substring(c+1)+"}":d;case "Fraction":return this.value.toLatex();default:return d}},a},{isClass:!0,isNode:!0}),Ui=B("ObjectNode",["Node"],b=>{function a(d){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=d||{},d&&("object"!=typeof d||!Object.keys(d).every(function(c){return Mb(d[c])})))throw new TypeError("Object containing Nodes expected");}({Node:b}=b);return a.prototype=new b,a.prototype.type= -"ObjectNode",a.prototype.isObjectNode=!0,a.prototype._compile=function(d,c){var f={},h;for(h in this.properties)if(Pa(this.properties,h)){var l=Lc(h);l=JSON.parse(l);if(!db(this.properties,l))throw Error('No access to property "'+l+'"');f[l]=this.properties[h]._compile(d,c)}return function(p,k,n){var g={},e;for(e in f)Pa(f,e)&&(g[e]=f[e](p,k,n));return g}},a.prototype.forEach=function(d){for(var c in this.properties)Pa(this.properties,c)&&d(this.properties[c],"properties["+Lc(c)+"]",this)},a.prototype.map= -function(d){var c={},f;for(f in this.properties)Pa(this.properties,f)&&(c[f]=this._ifNode(d(this.properties[f],"properties["+Lc(f)+"]",this)));return new a(c)},a.prototype.clone=function(){var d={},c;for(c in this.properties)Pa(this.properties,c)&&(d[c]=this.properties[c]);return new a(d)},a.prototype._toString=function(d){var c=[],f;for(f in this.properties)Pa(this.properties,f)&&c.push(Lc(f)+": "+this.properties[f].toString(d));return"{"+c.join(", ")+"}"},a.prototype.toJSON=function(){return{mathjs:"ObjectNode", -properties:this.properties}},a.fromJSON=function(d){return new a(d.properties)},a.prototype.toHTML=function(d){var c=[],f;for(f in this.properties)Pa(this.properties,f)&&c.push(''+Dc(f)+':'+this.properties[f].toHTML(d));return'{'+c.join(',')+ -'}'},a.prototype._toTex=function(d){var c=[],f;for(f in this.properties)Pa(this.properties,f)&&c.push("\\mathbf{"+f+":} & "+this.properties[f].toTex(d)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(c.join("\n"),"\\end{array}\\right\\}")},a},{isClass:!0,isNode:!0}),Vi=B("ParenthesisNode",["Node"],b=>{function a(d){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Mb(d))throw new TypeError('Node expected for parameter "content"'); -this.content=d}({Node:b}=b);return a.prototype=new b,a.prototype.type="ParenthesisNode",a.prototype.isParenthesisNode=!0,a.prototype._compile=function(d,c){return this.content._compile(d,c)},a.prototype.getContent=function(){return this.content.getContent()},a.prototype.forEach=function(d){d(this.content,"content",this)},a.prototype.map=function(d){return new a(d(this.content,"content",this))},a.prototype.clone=function(){return new a(this.content)},a.prototype._toString=function(d){return!d||d&& -!d.parenthesis||d&&"keep"===d.parenthesis?"("+this.content.toString(d)+")":this.content.toString(d)},a.prototype.toJSON=function(){return{mathjs:"ParenthesisNode",content:this.content}},a.fromJSON=function(d){return new a(d.content)},a.prototype.toHTML=function(d){return!d||d&&!d.parenthesis||d&&"keep"===d.parenthesis?'('+this.content.toHTML(d)+')':this.content.toHTML(d)},a.prototype._toTex= -function(d){return!d||d&&!d.parenthesis||d&&"keep"===d.parenthesis?"\\left(".concat(this.content.toTex(d),"\\right)"):this.content.toTex(d)},a},{isClass:!0,isNode:!0}),id=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{associativity:"left",associativeWith:[]}},{"OperatorNode:and":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{associativity:"left", -associativeWith:[]}},{"OperatorNode:bitXor":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{associativity:"left",associativeWith:[]},"OperatorNode:unequal":{associativity:"left",associativeWith:[]},"OperatorNode:smaller":{associativity:"left",associativeWith:[]},"OperatorNode:larger":{associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{associativity:"left", -associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{associativity:"left",associativeWith:[]}},{"OperatorNode:to":{associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{associativity:"left", -associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{associativity:"left", -associativeWith:[]},"OperatorNode:mod":{associativity:"left",associativeWith:[]}},{"OperatorNode:unaryPlus":{associativity:"right"},"OperatorNode:unaryMinus":{associativity:"right"},"OperatorNode:bitNot":{associativity:"right"},"OperatorNode:not":{associativity:"right"}},{"OperatorNode:pow":{associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{associativity:"left"}},{"OperatorNode:transpose":{associativity:"left"}}], -Wi=B("RelationalNode",["Node"],b=>{function a(d,c){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(d))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(c))throw new TypeError("Parameter params must be an array");if(d.length!==c.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=d;this.params=c}({Node:b}=b);return a.prototype= -new b,a.prototype.type="RelationalNode",a.prototype.isRelationalNode=!0,a.prototype._compile=function(d,c){var f=this,h=this.params.map(l=>l._compile(d,c));return function(l,p,k){for(var n,g=h[0](l,p,k),e=0;ed(c,"params["+f+"]",this),this)},a.prototype.map=function(d){return new a(this.conditionals.slice(),this.params.map((c,f)=>this._ifNode(d(c, -"params["+f+"]",this)),this))},a.prototype.clone=function(){return new a(this.conditionals,this.params)},a.prototype._toString=function(d){for(var c=d&&d.parenthesis?d.parenthesis:"keep",f=ra(this,c),h=this.params.map(function(n,g){g=ra(n,c);return"all"===c||null!==g&&g<=f?"("+n.toString(d)+")":n.toString(d)}),l={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},p=h[0],k=0;k('+n.toHTML(d)+')':n.toHTML(d)}),l={equal:"==",unequal:"!=", -smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},p=h[0],k=0;k'+Dc(l[this.conditionals[k]])+""+h[k+1];return p},a.prototype._toTex=function(d){for(var c=d&&d.parenthesis?d.parenthesis:"keep",f=ra(this,c),h=this.params.map(function(k,n){n=ra(k,c);return"all"===c||null!==n&&n<=f?"\\left("+k.toTex(d)+"\right)":k.toTex(d)}),l=h[0],p=0;p{function a(p){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");wd(p)?this.value=p.value:this.value=p}function d(p,k){var n;var g=a.prototype;var e=function(){var q=k();if("function"==typeof q)return c(q)};var m=!0;Object.defineProperty(g,p,{get:function(){return m&&(n=e(),m=!1),n},set:function(q){n=q;m=!1},configurable:!0,enumerable:!0})}function c(p){return function(){for(var k= -[this.value],n=0;np[e])};for(var n in p)k(n)}var g};var l={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return a.createProxy(h),f&&f("import",function(p,k,n){n||d(p,k)}),a},{isClass:!0}),Yi=B("reviver",["classes"],b=>{var {classes:a}=b;return function(d,c){return(d=a[c&&c.mathjs])&&"function"==typeof d.fromJSON?d.fromJSON(c):c}}),Zi=B("ConditionalNode",["Node"],b=>{function a(d,c,f){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator"); -if(!Mb(d))throw new TypeError("Parameter condition must be a Node");if(!Mb(c))throw new TypeError("Parameter trueExpr must be a Node");if(!Mb(f))throw new TypeError("Parameter falseExpr must be a Node");this.condition=d;this.trueExpr=c;this.falseExpr=f}({Node:b}=b);return a.prototype=new b,a.prototype.type="ConditionalNode",a.prototype.isConditionalNode=!0,a.prototype._compile=function(d,c){var f=this.condition._compile(d,c),h=this.trueExpr._compile(d,c),l=this.falseExpr._compile(d,c);return function(p, -k,n){return function(g){if("number"==typeof g||"boolean"==typeof g||"string"==typeof g)return!!g;if(g){if(pa(g))return!g.isZero();if(rb(g))return!(!g.re&&!g.im);if(Z(g))return!!g.value}if(null==g)return!1;throw new TypeError('Unsupported type of condition "'+Wb(g)+'"');}(f(p,k,n))?h(p,k,n):l(p,k,n)}},a.prototype.forEach=function(d){d(this.condition,"condition",this);d(this.trueExpr,"trueExpr",this);d(this.falseExpr,"falseExpr",this)},a.prototype.map=function(d){return new a(this._ifNode(d(this.condition, -"condition",this)),this._ifNode(d(this.trueExpr,"trueExpr",this)),this._ifNode(d(this.falseExpr,"falseExpr",this)))},a.prototype.clone=function(){return new a(this.condition,this.trueExpr,this.falseExpr)},a.prototype._toString=function(d){var c=d&&d.parenthesis?d.parenthesis:"keep",f=ra(this,c),h=this.condition.toString(d),l=ra(this.condition,c);("all"===c||"OperatorNode"===this.condition.type||null!==l&&l<=f)&&(h="("+h+")");l=this.trueExpr.toString(d);var p=ra(this.trueExpr,c);("all"===c||"OperatorNode"=== -this.trueExpr.type||null!==p&&p<=f)&&(l="("+l+")");d=this.falseExpr.toString(d);p=ra(this.falseExpr,c);return("all"===c||"OperatorNode"===this.falseExpr.type||null!==p&&p<=f)&&(d="("+d+")"),h+" ? "+l+" : "+d},a.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},a.fromJSON=function(d){return new a(d.condition,d.trueExpr,d.falseExpr)},a.prototype.toHTML=function(d){var c=d&&d.parenthesis?d.parenthesis:"keep",f=ra(this, -c),h=this.condition.toHTML(d),l=ra(this.condition,c);("all"===c||"OperatorNode"===this.condition.type||null!==l&&l<=f)&&(h='('+h+')');l=this.trueExpr.toHTML(d);var p=ra(this.trueExpr,c);("all"===c||"OperatorNode"===this.trueExpr.type||null!==p&&p<=f)&&(l='('+l+')'); -d=this.falseExpr.toHTML(d);p=ra(this.falseExpr,c);return("all"===c||"OperatorNode"===this.falseExpr.type||null!==p&&p<=f)&&(d='('+d+')'),h+'?'+l+':'+d},a.prototype._toTex=function(d){return"\\begin{cases} {"+this.trueExpr.toTex(d)+"}, &\\quad{\\text{if }\\;"+ -this.condition.toTex(d)+"}\\\\{"+this.falseExpr.toTex(d)+"}, &\\quad{\\text{otherwise}}\\end{cases}"},a},{isClass:!0,isNode:!0}),$i=B("OperatorNode",["Node"],b=>{function a(c,f,h,l){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof c)throw new TypeError('string expected for parameter "op"');if("string"!=typeof f)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(h)||!h.every(Mb))throw new TypeError('Array containing Nodes expected for parameter "args"'); -this.implicit=!0===l;this.op=c;this.fn=f;this.args=h||[]}function d(c,f,h,l,p){var k=ra(c,f),n=ub(c,f);if("all"===f||2('+l+')'), -"right"===h?''+Dc(this.op)+""+l:l+''+Dc(this.op)+"";if(2===l.length)return f=l[0].toHTML(c),l=l[1].toHTML(c),p[0]&&(f='('+f+')'),p[1]&&(l='('+l+')'), -this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===h?f+''+l:f+''+Dc(this.op)+""+l;f=l.map(function(k,n){return k=k.toHTML(c),p[n]&&(k='('+k+')'),k});return 2'):f.join(''+Dc(this.op)+""):''+Dc(this.fn)+'('+f.join(',')+ -')'},a.prototype._toTex=function(c){var f=c&&c.parenthesis?c.parenthesis:"keep",h=c&&c.implicit?c.implicit:"hide",l=this.args,p=d(this,f,h,l,!0),k=Pb[this.fn];if(k=void 0===k?this.op:k,1===l.length)return f=ub(this,f),h=l[0].toTex(c),p[0]&&(h="\\left(".concat(h,"\\right)")),"right"===f?k+h:h+k;if(2===l.length){var n=l[0],g=n.toTex(c);p[0]&&(g="\\left(".concat(g,"\\right)"));var e=l[1].toTex(c);switch(p[1]&&(e="\\left(".concat(e,"\\right)")), -l="keep"===f?n.getIdentifier():n.getContent().getIdentifier(),this.getIdentifier()){case "OperatorNode:divide":return k+"{"+g+"}{"+e+"}";case "OperatorNode:pow":switch(g="{"+g+"}",e="{"+e+"}",l){case "ConditionalNode":case "OperatorNode:divide":g="\\left(".concat(g,"\\right)")}break;case "OperatorNode:multiply":if(this.implicit&&"hide"===h)return g+"~"+e}return g+k+e}return 2{function a(c,f,h){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Mb(c))throw new TypeError("Node expected"); -if(!Mb(f))throw new TypeError("Node expected");if(h&&!Mb(h))throw new TypeError("Node expected");if(3('+l+')'),f=l,this.step)l=this.step.toHTML(c),h.step&&(l='('+l+')'), -f+=':'+l;c=this.end.toHTML(c);return h.end&&(c='('+c+')'),f+':'+c},a.prototype._toTex=function(c){var f=d(this,c&&c.parenthesis?c.parenthesis:"keep"),h=this.start.toTex(c);if(f.start&&(h="\\left(".concat(h,"\\right)")),this.step){var l=this.step.toTex(c);f.step&&(l="\\left(".concat(l, -"\\right)"));h+=":"+l}c=this.end.toTex(c);return f.end&&(c="\\left(".concat(c,"\\right)")),h+":"+c},a},{isClass:!0,isNode:!0}),bj=B("FunctionAssignmentNode",["typed","Node"],b=>{function a(h,l,p){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof h)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(l))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!Mb(p))throw new TypeError('Node expected for parameter "expr"'); -if(Ng.has(h))throw Error('Illegal function name, "'+h+'" is a reserved keyword');this.name=h;this.params=l.map(function(k){return k&&k.name||k});this.types=l.map(function(k){return k&&k.type||"any"});this.expr=p}function d(h,l){var p=ra(h,l);h=ra(h.expr,l);return"all"===l||null!==h&&h<=p}var {typed:c,Node:f}=b;return a.prototype=new f,a.prototype.type="FunctionAssignmentNode",a.prototype.isFunctionAssignmentNode=!0,a.prototype._compile=function(h,l){var p=Object.create(l);J(this.params,function(q){p[q]= -!0});var k=this.expr._compile(h,p),n=this.name,g=this.params,e=Array.prototype.join.call(this.types,","),m=n+"("+Array.prototype.join.call(this.params,", ")+")";return function(q,r,u){var y={};y[e]=function(){for(var v=Object.create(r),t=0;t'+Dc(this.params[k])+"");h=this.expr.toHTML(h);return d(this,l)&&(h='('+h+')'),''+Dc(this.name)+'('+p.join(',')+ -')='+h},a.prototype._toTex=function(h){var l=h&&h.parenthesis?h.parenthesis:"keep";h=this.expr.toTex(h);return d(this,l)&&(h="\\left(".concat(h,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(ya).join(",")+"\\right):="+h},a},{isClass:!0,isNode:!0}),cj=B("chain",["typed","Chain"],b=>{var {typed:a,Chain:d}=b;return a("chain", -{"":function(){return new d},any:function(c){return new d(c)}})}),dj=B("AccessorNode",["subset","Node"],b=>{function a(l,p){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Mb(l))throw new TypeError('Node expected for parameter "object"');if(!nd(p))throw new TypeError('IndexNode expected for parameter "index"');this.object=l||null;this.index=p;Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty(): -"":this.object.name||""}.bind(this),set:function(){throw Error("Cannot assign a new name, name is read-only");}})}function d(l){return!(Gb(l)||vb(l)||Bb(l)||Kc(l)||Ld(l)||Qc(l)||kc(l))}var {subset:c,Node:f}=b,h=ad({subset:c});return a.prototype=new f,a.prototype.type="AccessorNode",a.prototype.isAccessorNode=!0,a.prototype._compile=function(l,p){var k=this.object._compile(l,p),n=this.index._compile(l,p);if(this.index.isObjectProperty()){var g=this.index.getObjectProperty();return function(e,m,q){return Aa(k(e, -m,q),g)}}return function(e,m,q){q=k(e,m,q);e=n(e,m,q);return h(q,e)}},a.prototype.forEach=function(l){l(this.object,"object",this);l(this.index,"index",this)},a.prototype.map=function(l){return new a(this._ifNode(l(this.object,"object",this)),this._ifNode(l(this.index,"index",this)))},a.prototype.clone=function(){return new a(this.object,this.index)},a.prototype._toString=function(l){var p=this.object.toString(l);return d(this.object)&&(p="("+p+")"),p+this.index.toString(l)},a.prototype.toHTML=function(l){var p= -this.object.toHTML(l);return d(this.object)&&(p='('+p+')'),p+this.index.toHTML(l)},a.prototype._toTex=function(l){var p=this.object.toTex(l);return d(this.object)&&(p="\\left(' + object + '\\right)"),p+this.index.toTex(l)},a.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},a.fromJSON=function(l){return new a(l.object,l.index)},a},{isClass:!0, -isNode:!0}),ej=B("IndexNode",["Range","Node","size"],b=>{function a(l,p){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(this.dimensions=l,this.dotNotation=p||!1,!Array.isArray(l)||!l.every(Mb))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw Error("dotNotation only applicable for object properties");}function d(l,p,k){return new c(pa(l)?l.toNumber():l,pa(p)?p.toNumber(): -p,pa(k)?k.toNumber():k)}var {Range:c,Node:f,size:h}=b;return a.prototype=new f,a.prototype.type="IndexNode",a.prototype.isIndexNode=!0,a.prototype._compile=function(l,p){var k=A(this.dimensions,function(g,e){if(vd(g)){if(g.needsEnd()){var m=Object.create(p);m.end=!0;var q=g.start._compile(l,m),r=g.end._compile(l,m),u=g.step?g.step._compile(l,m):function(){return 1};return function(I,F,L){var O=h(L).valueOf();F=Object.create(F);return F.end=O[e],d(q(I,F,L),r(I,F,L),u(I,F,L))}}var y=g.start._compile(l, -p),v=g.end._compile(l,p),t=g.step?g.step._compile(l,p):function(){return 1};return function(I,F,L){return d(y(I,F,L),v(I,F,L),t(I,F,L))}}if(kc(g)&&"end"===g.name){m=Object.create(p);m.end=!0;var w=g._compile(l,m);return function(I,F,L){var O=h(L).valueOf();F=Object.create(F);return F.end=O[e],w(I,F,L)}}var z=g._compile(l,p);return function(I,F,L){return z(I,F,L)}}),n=Aa(l,"index");return function(g,e,m){var q=A(k,function(r){return r(g,e,m)});return n(...q)}},a.prototype.forEach=function(l){for(var p= -0;p.'+Dc(this.getObjectProperty())+"":'['+l.join(',')+']'},a.prototype._toTex=function(l){var p=this.dimensions.map(function(k){return k.toTex(l)});return this.dotNotation?"."+this.getObjectProperty():"_{"+p.join(",")+"}"},a},{isClass:!0, -isNode:!0}),fj=B("AssignmentNode",["subset","?matrix","Node"],b=>{function a(k,n,g){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=k,this.index=g?n:null,this.value=g||n,!kc(k)&&!Gb(k))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(kc(k)&&"end"===k.name)throw Error('Cannot assign to symbol "end"');if(this.index&&!nd(this.index))throw new TypeError('IndexNode expected as "index"');if(!Mb(this.value))throw new TypeError('Node expected as "value"'); -Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw Error("Cannot assign a new name, name is read-only");}})}function d(k,n){n||(n="keep");var g=ra(k,n);k=ra(k.value,n);return"all"===n||null!==k&&k<=g}var {subset:c,matrix:f,Node:h}=b,l=ad({subset:c}),p=function(k){var {subset:n,matrix:g}=k;return function(e,m,q){try{if(Array.isArray(e))return g(e).subset(m,q).valueOf(); -if(e&&"function"==typeof e.subset)return e.subset(m,q);if("string"==typeof e)return n(e,m,q);if("object"==typeof e){if(!m.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return va(e,m.getObjectProperty(),q),e}throw new TypeError("Cannot apply index: unsupported type of object");}catch(r){throw hc(r);}}}({subset:c,matrix:f});return a.prototype=new h,a.prototype.type="AssignmentNode",a.prototype.isAssignmentNode=!0,a.prototype._compile=function(k,n){var g=this.object._compile(k, -n),e=this.index?this.index._compile(k,n):null,m=this.value._compile(k,n),q=this.object.name;if(this.index){if(this.index.isObjectProperty()){var r=this.index.getObjectProperty();return function(t,w,z){var I=g(t,w,z);t=m(t,w,z);return va(I,r,t),t}}if(kc(this.object))return function(t,w,z){var I=g(t,w,z);z=m(t,w,z);w=e(t,w,I);return t.set(q,p(I,w,z)),z};var u=this.object.object._compile(k,n);if(this.object.index.isObjectProperty()){var y=this.object.index.getObjectProperty();return function(t,w,z){var I= -u(t,w,z),F=Aa(I,y),L=e(t,w,F);t=m(t,w,z);return va(I,y,p(F,L,t)),t}}var v=this.object.index._compile(k,n);return function(t,w,z){var I=u(t,w,z),F=v(t,w,I),L=l(I,F),O=e(t,w,L);t=m(t,w,z);return p(I,F,p(L,O,t)),t}}if(!kc(this.object))throw new TypeError("SymbolNode expected as object");return function(t,w,z){w=m(t,w,z);return t.set(q,w),w}},a.prototype.forEach=function(k){k(this.object,"object",this);this.index&&k(this.index,"index",this);k(this.value,"value",this)},a.prototype.map=function(k){return new a(this._ifNode(k(this.object, -"object",this)),this.index?this._ifNode(k(this.index,"index",this)):null,this._ifNode(k(this.value,"value",this)))},a.prototype.clone=function(){return new a(this.object,this.index,this.value)},a.prototype._toString=function(k){var n=this.object.toString(k),g=this.index?this.index.toString(k):"",e=this.value.toString(k);return d(this,k&&k.parenthesis)&&(e="("+e+")"),n+g+" = "+e},a.prototype.toJSON=function(){return{mathjs:"AssignmentNode",object:this.object,index:this.index,value:this.value}},a.fromJSON= -function(k){return new a(k.object,k.index,k.value)},a.prototype.toHTML=function(k){var n=this.object.toHTML(k),g=this.index?this.index.toHTML(k):"",e=this.value.toHTML(k);return d(this,k&&k.parenthesis)&&(e='('+e+')'),n+g+'='+e},a.prototype._toTex=function(k){var n= -this.object.toTex(k),g=this.index?this.index.toTex(k):"",e=this.value.toTex(k);return d(this,k&&k.parenthesis)&&(e="\\left(".concat(e,"\\right)")),n+g+":="+e},a},{isClass:!0,isNode:!0}),gj=B("SymbolNode",["math","?Unit","Node"],b=>{function a(h){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof h)throw new TypeError('String expected for parameter "name"');this.name=h}var {math:d,Unit:c,Node:f}=b;return a.prototype=new f,a.prototype.type= -"SymbolNode",a.prototype.isSymbolNode=!0,a.prototype._compile=function(h,l){var p=this.name;if(!0===l[p])return function(n,g,e){return g[p]};if(p in h)return function(n,g,e){return n.has(p)?n.get(p):Aa(h,p)};var k=!!c&&c.isValuelessUnit(p);return function(n,g,e){return n.has(p)?n.get(p):k?new c(null,p):a.onUndefinedSymbol(p)}},a.prototype.forEach=function(h){},a.prototype.map=function(h){return this.clone()},a.onUndefinedSymbol=function(h){throw Error("Undefined symbol "+h);},a.prototype.clone=function(){return new a(this.name)}, -a.prototype._toString=function(h){return this.name},a.prototype.toHTML=function(h){h=Dc(this.name);return"true"===h||"false"===h?''+h+"":"i"===h?''+h+"":"Infinity"===h?''+h+"":"NaN"===h?''+h+"":"null"===h?''+h+"":"undefined"===h?''+ -h+"":''+h+""},a.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},a.fromJSON=function(h){return new a(h.name)},a.prototype._toTex=function(h){h=!1;void 0===d[this.name]&&c&&c.isValuelessUnit(this.name)&&(h=!0);h=ya(this.name,h);return"\\"===h[0]?h:" "+h},a},{isClass:!0,isNode:!0}),hj=B("FunctionNode",["math","Node","SymbolNode"],b=>{function a(k,n){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator"); -if("string"==typeof k&&(k=new h(k)),!Mb(k))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(n)||!n.every(Mb))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=k;this.args=n||[];Object.defineProperty(this,"name",{get:function(){return this.fn.name||""}.bind(this),set:function(){throw Error("Cannot assign a new name, name is read-only");}})}function d(k,n,g){for(var e,m="",q=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,r=0;null!==(e= -q.exec(k));)if(m+=k.substring(r,e.index),r=e.index,"$$"===e[0])m+="$",r++;else{r+=e[0].length;var u=n[e[1]];if(!u)throw new ReferenceError("Template: Property "+e[1]+" does not exist.");if(void 0===e[2])switch(typeof u){case "string":m+=u;break;case "object":if(Mb(u))m+=u.toTex(g);else{if(!Array.isArray(u))throw new TypeError("Template: "+e[1]+" has to be a Node, String or array of Nodes");m+=u.map(function(y,v){if(Mb(y))return y.toTex(g);throw new TypeError("Template: "+e[1]+"["+v+"] is not a Node."); -}).join(",")}break;default:throw new TypeError("Template: "+e[1]+" has to be a Node, String or array of Nodes");}else{if(!Mb(u[e[2]]&&u[e[2]]))throw new TypeError("Template: "+e[1]+"["+e[2]+"] is not a Node.");m+=u[e[2]].toTex(g)}}return m+k.slice(r)}var {math:c,Node:f,SymbolNode:h}=b;a.prototype=new f;a.prototype.type="FunctionNode";a.prototype.isFunctionNode=!0;a.prototype._compile=function(k,n){if(!(this instanceof a))throw new TypeError("No valid FunctionNode");var g=this.args.map(z=>z._compile(k, -n));if(!kc(this.fn)){if(Gb(this.fn)&&nd(this.fn.index)&&this.fn.index.isObjectProperty()){var e=this.fn.object._compile(k,n),m=this.fn.index.getObjectProperty(),q=this.args;return function(z,I,F){var L=e(z,I,F);if(function(R,ba){if(!fb(R,ba))throw Error('No access to method "'+ba+'"');}(L,m),L[m]&&L[m].rawArgs)return L[m](q,k,Ad(z,I),z);var O=g.map(R=>R(z,I,F));return L[m].apply(L,O)}}var r=this.fn._compile(k,n),u=this.args;return function(z,I,F){var L=r(z,I,F);if(L&&L.rawArgs)return L(u,k,Ad(z,I), -z);var O=g.map(R=>R(z,I,F));return L.apply(L,O)}}var y=this.fn.name,v=y in k?Aa(k,y):void 0,t=z=>z.has(y)?z.get(y):y in k?Aa(k,y):a.onUndefinedFunction(y);if("function"==typeof v&&!0===v.rawArgs){var w=this.args;return function(z,I,F){return t(z)(w,k,Ad(z,I),z)}}switch(g.length){case 0:return function(z,I,F){return t(z)()};case 1:return function(z,I,F){return t(z)((0,g[0])(z,I,F))};case 2:return function(z,I,F){var L=t(z),O=g[1];return L((0,g[0])(z,I,F),O(z,I,F))};default:return function(z,I,F){return t(z)(...g.map(L=> -L(z,I,F)))}}};a.prototype.forEach=function(k){k(this.fn,"fn",this);for(var n=0;n'+Dc(this.fn)+'('+n.join(',')+')'};var p=a.prototype.toTex;return a.prototype.toTex=function(k){var n;return k&&"object"==typeof k.handler&&Pa(k.handler,this.name)&&(n=k.handler[this.name](this,k)),void 0!==n?n:p.call(this,k)},a.prototype._toTex=function(k){var n, -g=this.args.map(function(m){return m.toTex(k)});switch(Og[this.name]&&(n=Og[this.name]),!c[this.name]||"function"!=typeof c[this.name].toTex&&"object"!=typeof c[this.name].toTex&&"string"!=typeof c[this.name].toTex||(n=c[this.name].toTex),typeof n){case "function":var e=n(this,k);break;case "string":e=d(n,this,k);break;case "object":switch(typeof n[g.length]){case "function":e=n[g.length](this,k);break;case "string":e=d(n[g.length],this,k)}}return void 0!==e?e:d("\\mathrm{${name}}\\left(${args}\\right)", -this,k)},a.prototype.getIdentifier=function(){return this.type+":"+this.name},a},{isClass:!0,isNode:!0}),ij=B("parse","typed numeric config AccessorNode ArrayNode AssignmentNode BlockNode ConditionalNode ConstantNode FunctionAssignmentNode FunctionNode IndexNode ObjectNode OperatorNode ParenthesisNode RangeNode RelationalNode SymbolNode".split(" "),b=>{function a(G){var ma=1":"larger","<=":"smallerEq", -">=":"largerEq"};Pa(Sa,G.token);)qa.push({name:G.token,fn:Sa[G.token]}),l(G),ma.push(u(G));return 1===ma.length?ma[0]:2===ma.length?new M(qa[0].name,qa[0].fn,ma):new ha(qa.map(Ya=>Ya.fn),ma)}function u(G){var ma;var qa=y(G);for(var Sa={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Pa(Sa,G.token);){var Ya=Sa[ma=G.token];l(G);qa=[qa,y(G)];qa=new M(ma,Ya,qa)}return qa}function y(G){var ma,qa;var Sa=v(G);for(var Ya={to:"to",in:"to"};Pa(Ya,G.token);){var Ja=Ya[ma=G.token];l(G);"in"=== -ma&&""===G.token?Sa=new M("*","multiply",[Sa,new ja("in")],!0):(qa=[Sa,v(G)],Sa=new M(ma,Ja,qa))}return Sa}function v(G){var ma,qa=[];if(ma=":"===G.token?new da(1):t(G),":"===G.token&&G.conditionalLevel!==G.nestingLevel){for(qa.push(ma);":"===G.token&&3>qa.length;)l(G),")"===G.token||"]"===G.token||","===G.token||""===G.token?qa.push(new ja("end")):qa.push(t(G));ma=3===qa.length?new U(qa[0],qa[2],qa[1]):new U(qa[0],qa[1])}return ma}function t(G){var ma;var qa=w(G);for(var Sa={"+":"add","-":"subtract"};Pa(Sa, -G.token);){var Ya=Sa[ma=G.token];l(G);qa=[qa,w(G)];qa=new M(ma,Ya,qa)}return qa}function w(G){var ma;var qa=z(G);for(var Sa={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"};Pa(Sa,G.token);){var Ya=Sa[ma=G.token];l(G);var Ja=z(G);qa=new M(ma,Ya,[qa,Ja])}return qa}function z(G){var ma,qa;for(qa=ma=I(G);3===G.tokenType||"in"===G.token&&Bb(ma)||!(2!==G.tokenType||Bb(qa)||xc(qa)&&"!"!==qa.op)||"("===G.token;)qa=I(G),ma=new M("*","multiply",[ma,qa],!0);return ma}function I(G){for(var ma= -F(G),qa=ma,Sa=[];"/"===G.token&&Bb(qa);){if(Sa.push(Ra({},G)),l(G),2!==G.tokenType){Ra(G,Sa.pop());break}if(Sa.push(Ra({},G)),l(G),3!==G.tokenType&&"("!==G.token){Sa.pop();Ra(G,Sa.pop());break}Ra(G,Sa.pop());Sa.pop();qa=F(G);ma=new M("/","divide",[ma,qa])}return ma}function F(G){var ma,qa,Sa,Ya={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Pa(Ya,G.token)?(Sa=Ya[G.token],ma=G.token,l(G),qa=[F(G)],new M(ma,Sa,qa)):function(Ja){var $a,Eb,dc,Ab;return $a=function(kb){var Wa;var tb= -function(bb){var ec=[];if(3===bb.tokenType&&Pa(bb.extraNodes,bb.token)){var nc=bb.extraNodes[bb.token];if(h(bb),"("===bb.token){ec=[];bb.nestingLevel++;if(h(bb),")"!==bb.token)for(ec.push(k(bb));","===bb.token;)h(bb),ec.push(k(bb));if(")"!==bb.token)throw ca(bb,"Parenthesis ) expected");bb.nestingLevel--;h(bb)}return new nc(ec)}return function(ab){var Ib;return 3===ab.tokenType||1===ab.tokenType&&ab.token in Xa?(Ib=ab.token,h(ab),L(ab,Pa(pb,Ib)?new da(pb[Ib]):-1!==sb.indexOf(Ib)?new da(Ga(Ib,"number")): -new ja(Ib))):function(ac){var Ub;return'"'===ac.token?(Ub=O(ac),L(ac,new da(Ub))):function(bc){var hb;return"'"===bc.token?(hb=R(bc),L(bc,new da(hb))):function(oa){if("["===oa.token){oa.nestingLevel++;if(h(oa),"]"!==oa.token){var wb=ba(oa);if(";"===oa.token){var Sb=1;for(wb=[wb];";"===oa.token;)h(oa),wb[Sb]=ba(oa),Sb++;if("]"!==oa.token)throw ca(oa,"End of matrix ] expected");oa.nestingLevel--;h(oa);var Jb=wb[0].items.length;for(var Fb=1;Fb":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},Xa={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},pb={true:!0,false:!1,null:null,undefined:void 0},sb=["NaN","Infinity"];return wa.isAlpha=function(G,ma,qa){return wa.isValidLatinOrGreek(G)|| -wa.isValidMathSymbol(G,qa)||wa.isValidMathSymbol(ma,G)},wa.isValidLatinOrGreek=function(G){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(G)},wa.isValidMathSymbol=function(G,ma){return/^[\uD835]$/.test(G)&&/^[\uDC00-\uDFFF]$/.test(ma)&&/^[^\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDFCC\uDFCD]$/.test(ma)},wa.isWhitespace=function(G,ma){return" "===G||"\t"===G||"\n"===G&& -0=G||"."===G},wa.isDigit=function(G){return"0"<=G&&"9">=G},wa.isHexDigit=function(G){return"0"<=G&&"9">=G||"a"<=G&&"f">=G||"A"<=G&&"F">=G},wa}),jj=B("evaluate",["typed","parse"],b=>{var {typed:a,parse:d}=b;return a("evaluate",{string:function(c){var f=new Map;return d(c).compile().evaluate(f)},"string, Map | Object":function(c,f){return d(c).compile().evaluate(f)},"Array | Matrix":function(c){var f= -new Map;return Na(c,function(h){return d(h).compile().evaluate(f)})},"Array | Matrix, Map | Object":function(c,f){return Na(c,function(h){return d(h).compile().evaluate(f)})}})}),kj=B("Help",["parse"],b=>{function a(c){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!c)throw Error('Argument "doc" missing');this.doc=c}var {parse:d}=b;return a.prototype.type="Help",a.prototype.isHelp=!0,a.prototype.toString=function(){var c=this.doc||{},f="\n";if(c.name&& -(f+="Name: "+c.name+"\n\n"),c.category&&(f+="Category: "+c.category+"\n\n"),c.description&&(f+="Description:\n "+c.description+"\n\n"),c.syntax&&(f+="Syntax:\n "+c.syntax.join("\n ")+"\n\n"),c.examples){f+="Examples:\n";for(var h={},l=0;l"mathjs"!==h).forEach(h=>{f[h]=c[h]}),new a(f)},a.prototype.valueOf=a.prototype.toString,a},{isClass:!0}),lj=B("Parser",["parse"],b=>{function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:new Map,writable:!1})}var {parse:d}=b;return a.prototype.type="Parser", -a.prototype.isParser=!0,a.prototype.evaluate=function(c){return d(c).compile().evaluate(this.scope)},a.prototype.get=function(c){if(this.scope.has(c))return this.scope.get(c)},a.prototype.getAll=function(){var c=this.scope;if(c instanceof We)c=c.wrappedObject;else{var f={},h;for(h of c.keys())va(f,h,c.get(h));c=f}return c},a.prototype.getAllAsMap=function(){return this.scope},a.prototype.set=function(c,f){return this.scope.set(c,f),f},a.prototype.remove=function(c){this.scope.delete(c)},a.prototype.clear= -function(){this.scope.clear()},a},{isClass:!0}),Pg={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"]},Qg={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"]},mj= -{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".split(" ")},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])'.split(";"), -seealso:"bignumber complex index matrix number string unit".split(" ")},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".split(" ")},createUnit:{name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.", -examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]},fraction:{name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(num,den)"],description:"Create a fraction from a number or from a numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)"],seealso:"bignumber boolean complex index matrix string unit".split(" ")},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, ...]".split(";"),description:"Create an index to get or replace a subset of a matrix",examples:"[]{[1, 2, 3]{A = [1, 2, 3; 4, 5, 6]{A[1, :]{A[1, 2] = 50{A[0:2, 0:2] = ones(2, 2)".split("{"),seealso:"bignumber boolean complex matrix, number range string unit".split(" ")},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")'.split("{"),seealso:"bignumber boolean complex index number string unit sparse".split(" ")},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")'.split(";"), -seealso:"bignumber boolean complex fraction index matrix string unit".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},e:Qg,E:Qg,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:Pg,PI:Pg,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})'.split(";"),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".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},simplify:{name:"simplify", -category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["derivative","parse","evaluate"]},rationalize:{name:"rationalize",category:"Algebra",syntax:["rationalize(expr)","rationalize(expr, scope)","rationalize(expr, scope, detailed)"],description:"Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.", -examples:['rationalize("2x/y - y/(x+1)")','rationalize("2x/y - y/(x+1)", true)'],seealso:["simplify"]},slu:{name:"slu",category:"Algebra",syntax:["slu(A, order, threshold)"],description:"Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",examples:["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],seealso:"lusolve lsolve usolve matrix sparse lup qr".split(" ")}, -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".split(" ")},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".split(" ")},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)".split(";"),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".split(";"),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".split(";"),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)".split(";"),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")'.split(";")}, -nthRoot:{name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["nthRoots","pow","sqrt"]},nthRoots:{name:"nthRoots",category:"Arithmetic",syntax:["nthRoots(A)","nthRoots(A, root)"],description:'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.', -examples:["nthRoots(1)","nthRoots(1, 3)"],seealso:["sqrt","pow","nthRoot"]},pow:{name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3","2*2*2","1 + e ^ (pi * i)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},round:{name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.", -examples:"round(3.2);round(3.8);round(-4.2);round(-4.8);round(pi, 3);round(123.45678, 2)".split(";"),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".split(" ")},sqrtm:{name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},square:{name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.", -examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},subtract:{name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},unaryMinus:{name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add", -"subtract","unaryPlus"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)", -"gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},bitAnd:{name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:"bitNot bitOr bitXor leftShift rightArithShift rightLogShift".split(" ")}, -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".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},bellNumbers:{name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.", -examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},catalan:{name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},composition:{name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.", -examples:["composition(5, 3)"],seealso:["combinations"]},stirlingS2:{name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},config:{name:"config", -category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},import:{name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)", -"typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number, number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},arg:{name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},conj:{name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.", -examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},re:{name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},im:{name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},evaluate:{name:"evaluate", -category:"Expression",syntax:["evaluate(expression)","evaluate([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(" + 4 + ")")'],seealso:[]},help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},distance:{name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])", -"distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},intersect:{name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},and:{name:"and", -category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},not:{name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},or:{name:"or",category:"Logical",syntax:["x or y","or(x, y)"], -description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},xor:{name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},concat:{name:"concat",category:"Matrix", -syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:"det diag identity inv ones range size squeeze subset trace transpose zeros".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},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".split(";"), -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)".split(";"),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".split(" ")}, -filter:{name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},flatten:{name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size", -"squeeze"]},forEach:{name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["forEach([1, 2, 3], function(val) { console.log(val) })"],seealso:["map","sort","filter"]},inv:{name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:"concat det diag identity ones range size squeeze subset trace transpose zeros".split(" ")}, -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, ...])".split(";"),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".split(" ")},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]'.split("{"), -seealso:"concat det diag identity inv ones size squeeze subset trace transpose zeros".split(" ")},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".split(" ")}, -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".split(" ")},subset:{name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of a matrix or string. Indexes are one-based. Both the ranges lower-bound and upper-bound are included.",examples:"d = [1, 2; 3, 4]{e = []{e[1, 1:2] = [5, 6]{e[2, :] = [7, 8]{f = d * e{f[2, 1]{f[:, 1]".split("{"), -seealso:"concat det diag identity inv ones range size squeeze trace transpose zeros".split(" ")},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".split(" ")},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".split(" ")},zeros:{name:"zeros",category:"Matrix",syntax:"zeros(m);zeros(m, n);zeros(m, n, p, ...);zeros([m]);zeros([m, n]);zeros([m, n, p, ...])".split(";"),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".split(" ")}, -combinations:{name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},combinationsWithRep:{name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"], -seealso:["combinations","permutations","factorial"]},factorial:{name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},gamma:{name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.", -examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},kldivergence:{name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},multinomial:{name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.", -examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},permutations:{name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},pickRandom:{name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)", -"pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:"pickRandom(0:10);pickRandom([1, 3, 1, 6]);pickRandom([1, 3, 1, 6], 2);pickRandom([1, 3, 1, 6], [2, 3, 2, 1]);pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1]);pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)".split(";"),seealso:["random","randomInt"]},random:{name:"random",category:"Probability",syntax:"random();random(max);random(min, max);random(size);random(size, max);random(size, min, max)".split(";"), -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".split(" ")},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})'.split(";"),seealso:"equal unequal smaller smallerEq largerEq compare compareText".split(" ")},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"])'.split(";"),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".split(" ")},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".split(";"),seealso:"unequal smaller larger smallerEq largerEq compare deepEqual equalText".split(" ")},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".split(";"),seealso:"equal unequal smaller smallerEq largerEq compare".split(" ")},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".split(";"),seealso:"equal unequal larger smallerEq largerEq compare".split(" ")},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".split(" ")},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".split(";"),seealso:"equal smaller larger smallerEq largerEq compare deepEqual".split(" ")}, -setCartesian:{name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},setDifference:{name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.", -examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},setDistinct:{name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},setIntersect:{name:"setIntersect",category:"Set", -syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},setIsSubset:{name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.", -examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},setMultiplicity:{name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]}, -setPowerset:{name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},setSize:{name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.', -examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},setSymDifference:{name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion", -"setIntersect","setDifference"]},setUnion:{name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},erf:{name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x", -examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},mad:{name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],description:"Compute the maximum value of a list of values.", -examples:"max(2, 3, 4, 1){max([2, 3, 4, 1]){max([2, 5; 4, 3]){max([2, 5; 4, 3], 1){max([2, 5; 4, 3], 2){max(2.7, 7.1, -4.5, 2.0, 4.1){min(2.7, 7.1, -4.5, 2.0, 4.1)".split("{"),seealso:"mean median min prod std sum variance".split(" ")},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])".split("{"), -seealso:"max median min prod std sum variance".split(" ")},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".split(" ")},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)".split("{"),seealso:"max mean median prod std sum variance".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},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".split(" ")},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])'.split(";"),seealso:"isInteger isZero isNegative isPositive isNaN hasNumericValue".split(" ")},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])'.split(";"),seealso:"isInteger isZero isNegative isPositive isNaN isNumeric".split(" ")},isPositive:{name:"isPositive",category:"Utils",syntax:["isPositive(x)"], -description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isPrime:{name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isZero:{name:"isZero", -category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},typeOf:{name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},numeric:{name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.", -examples:'numeric("4");numeric("4", "number");numeric("4", "BigNumber");numeric("4", "Fraction);numeric(4, "Fraction");numeric(fraction(2, 5), "number)'.split(";"),seealso:["number","fraction","bignumber","string","format"]}},nj=B("help",["typed","mathWithTransform","Help"],b=>{var {typed:a,mathWithTransform:d,Help:c}=b;return a("help",{any:function(f){var h,l=f;if("string"!=typeof f)for(h in d)if(Pa(d,h)&&f===d[h]){l=h;break}f=Aa(mj,l);if(!f)throw Error('No documentation found on "'+("function"== -typeof l?l.name:l)+'"');return new c(f)}})}),oj=B("compile",["typed","parse"],b=>{var {typed:a,parse:d}=b;return a("compile",{string:function(c){return d(c).compile()},"Array | Matrix":function(c){return Na(c,function(f){return d(f).compile()})}})}),Rg=B("simplifyUtil",["FunctionNode","OperatorNode","SymbolNode"],b=>{function a(n,g){if(!xc(n))return!1;n=n.fn.toString();return g&&Pa(g,n)&&Pa(g[n],"associative")?g[n].associative:k[n]||!1}function d(n){var g,e=[];return a(n)?(g=n.op,function r(q){for(var u= -0;u{var {equal:a,isZero:d,add:c,subtract:f,multiply:h,divide:l,pow:p,ConstantNode:k,OperatorNode:n,FunctionNode:g,ParenthesisNode:e}=b,m=new k(0),q=new k(1);return function y(u){if(xc(u)&&u.isUnary()){var v=y(u.args[0]);if("+"===u.op)return v;if("-"===u.op){if(xc(v)){if(v.isUnary()&&"-"===v.op)return v.args[0]; -if(v.isBinary()&&"subtract"===v.fn)return new n("-","subtract",[v.args[1],v.args[0]])}return new n(u.op,u.fn,[v])}}else if(xc(u)&&u.isBinary()){v=y(u.args[0]);var t=y(u.args[1]);if("+"===u.op){if(Bb(v)){if(d(v.value))return t;if(Bb(t))return new k(c(v.value,t.value))}return Bb(t)&&d(t.value)?v:xc(t)&&t.isUnary()&&"-"===t.op?new n("-","subtract",[v,t.args[0]]):new n(u.op,u.fn,t?[v,t]:[v])}if("-"===u.op){if(Bb(v)&&t){if(Bb(t))return new k(f(v.value,t.value));if(d(v.value))return new n("-","unaryMinus", -[t])}if("subtract"===u.fn)return Bb(t)&&d(t.value)?v:xc(t)&&t.isUnary()&&"-"===t.op?y(new n("+","add",[v,t.args[0]])):new n(u.op,u.fn,[v,t])}else{if("*"===u.op){if(Bb(v)){if(d(v.value))return m;if(a(v.value,1))return t;if(Bb(t))return new k(h(v.value,t.value))}if(Bb(t)){if(d(t.value))return m;if(a(t.value,1))return v;if(xc(v)&&v.isBinary()&&v.op===u.op){var w=v.args[0];if(Bb(w))return t=new k(h(w.value,t.value)),new n(u.op,u.fn,[t,v.args[1]],u.implicit)}return new n(u.op,u.fn,[t,v],u.implicit)}return new n(u.op, -u.fn,[v,t],u.implicit)}if("/"===u.op){if(Bb(v)){if(d(v.value))return m;if(Bb(t)&&(a(t.value,1)||a(t.value,2)||a(t.value,4)))return new k(l(v.value,t.value))}return new n(u.op,u.fn,[v,t])}if("^"===u.op){if(Bb(t)){if(d(t.value))return q;if(a(t.value,1))return v;if(Bb(v))return new k(p(v.value,t.value));if(xc(v)&&v.isBinary()&&"^"===v.op&&(w=v.args[1],Bb(w)))return new n(u.op,u.fn,[v.args[0],new k(h(w.value,t.value))])}return new n(u.op,u.fn,[v,t])}}}else{if(Qc(u))return u=y(u.content),Qc(u)||kc(u)|| -Bb(u)?u:new e(u);if(Kc(u))return v=u.args.map(y).map(function(z){return Qc(z)?z.content:z}),new g(y(u.fn),v)}return u}}),Tg=B("simplifyConstant","typed config mathWithTransform ?fraction ?bignumber ConstantNode OperatorNode FunctionNode SymbolNode".split(" "),b=>{function a(z,I,F){try{return w(p[z].apply(null,I),F)}catch(L){return I=I.map(function(O){return Ob(O)?O.valueOf():O}),w(p[z].apply(null,I),F)}}function d(z,I){if(I&&!1!==I.exactFractions&&isFinite(z)&&k){var F=k(z);I=I&&"number"==typeof I.fractionsLimit? -I.fractionsLimit:1/0;if(F.valueOf()===z&&F.n -f(ka,I));if(!F.some(Mb))try{return a(z.name,F,I)}catch(ka){}return F=F.map(function(ka){return Mb(ka)?ka:t(ka)}),new m(z.name,F)}case "OperatorNode":var L=z.fn.toString(),O=v(z);if(xc(z)&&z.isUnary())var R=Mb((F=[f(z.args[0],I)])[0])?O(F):a(L,F,I);else if(u(z))if(F=(F=y(z)).map(ka=>f(ka,I)),r(L)){z=[];for(var ba=[],ca=0;caf(ka,I)),O, -I);return R;case "ParenthesisNode":return f(z.content,I);default:throw Error("Unimplemented node type in simplifyConstant: ".concat(z.type));}}var {typed:h,config:l,mathWithTransform:p,fraction:k,bignumber:n,ConstantNode:g,OperatorNode:e,FunctionNode:m,SymbolNode:q}=b,{isCommutative:r,isAssociative:u,allChildren:y,createMakeNodeFunction:v}=Rg({FunctionNode:m,OperatorNode:e,SymbolNode:q}),t=h({Fraction:function(z){var I,F=z.s*z.n;return I=0>F?new e("-","unaryMinus",[new g(-F)]):new g(F),1===z.d?I: -new e("/","divide",[I,new g(z.d)])},number:function(z){return 0>z?new e("-","unaryMinus",[new g(-z)]):new g(z)},BigNumber:function(z){return 0>z?new e("-","unaryMinus",[new g(-z)]):new g(z)},Complex:function(z){throw Error("Cannot convert Complex number to Node");}}),w=h({"string, Object":function(z,I){return"BigNumber"===l.number?(void 0===n&&hd(),n(z)):"Fraction"===l.number?(void 0===k&&gc(),k(z)):d(parseFloat(z),I)},"Fraction, Object":function(z,I){return z},"BigNumber, Object":function(z,I){return z}, -"number, Object":function(z,I){return d(z,I)},"Complex, Object":function(z,I){return 0!==z.im?z:d(z.re,I)}});return function(z,I){z=f(z,I);return Mb(z)?z:t(z)}}),pj=B("resolve",["parse","FunctionNode","OperatorNode","ParenthesisNode"],b=>{var {parse:a,FunctionNode:d,OperatorNode:c,ParenthesisNode:f}=b;return function k(l,p){if(!p)return l;if(Va(p)||(p=mb(p)),kc(l)){var n=p.get(l.name);if(Mb(n))return k(n,p);if("number"==typeof n)return a(String(n))}else{if(xc(l))return n=l.args.map(function(g){return k(g, -p)}),new c(l.op,l.fn,n,l.implicit);if(Qc(l))return new f(k(l.content,p));if(Kc(l))return n=l.args.map(function(g){return k(g,p)}),new d(l.name,n)}return l}}),qj=B("simplify","config typed parse add subtract multiply divide pow isZero equal ?fraction ?bignumber mathWithTransform ConstantNode FunctionNode OperatorNode ParenthesisNode SymbolNode".split(" "),b=>{function a(X){return X.transform(function(da,ua,Da){return Qc(da)?a(da.content):da})}function d(X,da){var ua={placeholders:{}};if(!X.placeholders&& -!da.placeholders)return ua;if(!X.placeholders)return da;if(!da.placeholders)return X;for(var Da in X.placeholders)if(Pa(X.placeholders,Da)&&(ua.placeholders[Da]=X.placeholders[Da],Pa(da.placeholders,Da)&&!h(X.placeholders[Da],da.placeholders[Da])))return null;for(var Ha in da.placeholders)Pa(da.placeholders,Ha)&&(ua.placeholders[Ha]=da.placeholders[Ha]);return ua}function c(X,da){var ua,Da=[];if(0===X.length||0===da.length)return Da;for(var Ha=0;Ha");if(2!==U.length)throw SyntaxError("Could not parse rule: "+M);M={l:U[0],r:U[1]};case "object":if(Q={l:a(k(M.l)),r:a(k(M.r))},M.context&&(Q.evaluate=M.context),M.evaluate&&(Q.evaluate=k(M.evaluate)),ca(Q.l))M=P(Q.l),U=new L("_p"+ob++),Q.expanded={},Q.expanded.l=M([Q.l.clone(),U]),ka(Q.expanded.l),Ea(Q.expanded.l), -Q.expanded.r=M([Q.r,U]);break;case "function":Q=M;break;default:throw TypeError("Unsupported type of rule: "+U);}Ha.push(Q)}da=Ha;X=R(X,ua);ua={};for(Ha=(X=a(X)).toString({parenthesis:"all"});!ua[Ha];){ua[Ha]=!0;for(Ha=ob=0;Ha{function a(O, -R,ba){var ca=O.type,ka=1ba&&(R[1]=0),R[1]+=da.cte*("+"===da.oper?1:-1),ba=Math.max(1,ba))}else{if("ConstantNode"!==Da)throw Error("Type "+Da+" is not allowed");na=parseFloat(na.value); -if(null===X)return void(R[0]=na);if("^"===X.op){if(1!==da.noFil)throw Error("Constant cannot be powered");if(!Za(na)||0>=na)throw Error("Non-integer exponent is not allowed");for(X=ba+1;Xba&&(R[na]=0),R[na]+=da.cte*("+"===da.oper?1:-1),void(ba=Math.max(na,ba))}da.cte=na;""===da.fire&&(R[0]+=da.cte*("+"===da.oper?1:-1))}}(O,null,{cte:1,oper:"+",fire:""});O=!0;for(var ka=ba=R.length-1;0<=ka;ka--)if(0!==R[ka]){var Ea=new v(O?R[ka]:Math.abs(R[ka])),Ga=0>R[ka]?"-":"+";if(0{var {typed:a,Parser:d}=b;return a("parser",{"":function(){return new d}})}),tj=B("derivative","typed config parse simplify equal isZero numeric ConstantNode FunctionNode OperatorNode ParenthesisNode SymbolNode".split(" "),b=>{function a(v,t){return new n(k(v,t||c.number))} -var {typed:d,config:c,parse:f,simplify:h,equal:l,isZero:p,numeric:k,ConstantNode:n,FunctionNode:g,OperatorNode:e,ParenthesisNode:m,SymbolNode:q}=b;b=d("derivative",{"Node, SymbolNode, Object":function(v,t,w){var z={};u(z,v,t.name);v=y(v,z);return w.simplify?h(v):v},"Node, SymbolNode":function(v,t){return this(v,t,{simplify:!0})},"string, SymbolNode":function(v,t){return this(f(v),t)},"string, SymbolNode, Object":function(v,t,w){return this(f(v),t,w)},"string, string":function(v,t){return this(f(v), -f(t))},"string, string, Object":function(v,t,w){return this(f(v),f(t),w)},"Node, string":function(v,t){return this(v,f(t))},"Node, string, Object":function(v,t,w){return this(v,f(t),w)}});b._simplify=!0;b.toTex=function(v){return r.apply(null,v.args)};var r=d("_derivTex",{"Node, SymbolNode":function(v,t){return Bb(v)&&"string"===Wb(v.value)?r(f(v.value).toString(),t.toString(),1):r(v.toString(),t.toString(),1)},"Node, ConstantNode":function(v,t){if("string"===Wb(t.value))return r(v,f(t.value));throw Error("The second parameter to 'derivative' is a non-string constant"); -},"Node, SymbolNode, ConstantNode":function(v,t,w){return r(v.toString(),t.name,w.value)},"string, string, number":function(v,t,w){return(1===w?"{d\\over d"+t+"}":"{d^{"+w+"}\\over d"+t+"^{"+w+"}}")+"\\left[".concat(v,"\\right]")}}),u=d("constTag",{"Object, ConstantNode, string":function(v,t){return v[t]=!0,!0},"Object, SymbolNode, string":function(v,t,w){return t.name!==w&&(v[t]=!0,!0)},"Object, ParenthesisNode, string":function(v,t,w){return u(v,t.content,w)},"Object, FunctionAssignmentNode, string":function(v, -t,w){return-1===t.params.indexOf(w)?(v[t]=!0,!0):u(v,t.expr,w)},"Object, FunctionNode | OperatorNode, string":function(v,t,w){if(0{var {typed:a,isInteger:d}=b;return a("apply",{"Array | Matrix, number | BigNumber, function":function(c, -f,h){if(!d(f))throw new TypeError("Integer number expected for dimension");var l=Array.isArray(c)?Ua(c):c.size();if(0>f||f>=l.length)throw new Gc(f,l.length);return Fa(c)?c.create(Ee(c.valueOf(),f,h)):Ee(c,f,h)}})}),uj=B("apply",["typed","isInteger"],b=>{var {typed:a,isInteger:d}=b,c=Ug({typed:a,isInteger:d});return a("apply",{"...any":function(f){var h=f[1];Qa(h)?f[1]=h-1:pa(h)&&(f[1]=h.minus(1));try{return c.apply(null,f)}catch(l){throw hc(l);}}})},{isTransformFunction:!0}),vj=B("filter",["typed"], -b=>{function a(c,f,h){var l,p;return c[0]&&(l=c[0].compile().evaluate(h)),c[1]&&(p=kc(c[1])||Cc(c[1])?c[1].compile().evaluate(h):Ye(c[1],f,h)),d(l,p)}({typed:b}=b);a.rawArgs=!0;var d=b("filter",{"Array, function":zf,"Matrix, function":function(c,f){return c.create(zf(c.toArray(),f))},"Array, RegExp":Y,"Matrix, RegExp":function(c,f){return c.create(Y(c.toArray(),f))}});return a},{isTransformFunction:!0}),wj=B("map",["typed"],b=>{function a(c,f,h){var l,p;return c[0]&&(l=c[0].compile().evaluate(h)), -c[1]&&(p=kc(c[1])||Cc(c[1])?c[1].compile().evaluate(h):Ye(c[1],f,h)),d(l,p)}({typed:b}=b);a.rawArgs=!0;var d=b("map",{"Array, function":function(c,f){return Af(c,f,c)},"Matrix, function":function(c,f){return c.create(Af(c.valueOf(),f,c))}});return a},{isTransformFunction:!0}),xj=B("forEach",["typed"],b=>{function a(c,f,h){var l,p;return c[0]&&(l=c[0].compile().evaluate(h)),c[1]&&(p=kc(c[1])||Cc(c[1])?c[1].compile().evaluate(h):Ye(c[1],f,h)),d(l,p)}({typed:b}=b);a.rawArgs=!0;var d=b("forEach",{"Array | Matrix, function":function(c, -f){var h=$d(f);!function n(p,k){Array.isArray(p)?J(p,function(g,e){n(g,k.concat(e+1))}):1===h?f(p):2===h?f(p,k):f(p,k,c)}(c.valueOf(),[])}});return a},{isTransformFunction:!0}),Vg=B("subset",["typed","matrix"],b=>{var {typed:a,matrix:d}=b;return a("subset",{"Array, Index":function(c,f){c=d(c).subset(f);return f.isScalar()?c:c.valueOf()},"Matrix, Index":function(c,f){return c.subset(f)},"Object, Index":wi,"string, Index":vi,"Array, Index, any":function(c,f,h){return d(nb(c)).subset(f,h,void 0).valueOf()}, -"Array, Index, any, any":function(c,f,h,l){return d(nb(c)).subset(f,h,l).valueOf()},"Matrix, Index, any":function(c,f,h){return c.clone().subset(f,h)},"Matrix, Index, any, any":function(c,f,h,l){return c.clone().subset(f,h,l)},"string, Index, string":Bf,"string, Index, string, string":Bf,"Object, Index, any":xi})}),yj=B("subset",["typed","matrix"],b=>{var {typed:a,matrix:d}=b,c=Vg({typed:a,matrix:d});return a("subset",{"...any":function(f){try{return c.apply(null,f)}catch(h){throw hc(h);}}})},{isTransformFunction:!0}), -zj=B("index",["Index"],b=>{var {Index:a}=b;return function(){for(var d=[],c=0,f=arguments.length;c{var {typed:a,matrix:d,isInteger:c}=b;return a("concat",{"...Array | Matrix | number | BigNumber":function(f){var h,l,p=f.length,k=-1,n=!1,g=[];for(h=0;hk||0l)throw new Gc(k,l+1);}else{e=nb(e).valueOf();var m=Ua(e);if(g[h]=e,l=k,k=m.length- -1,0{var {typed:a,matrix:d,isInteger:c}=b,f=Wg({typed:a,matrix:d,isInteger:c});return a("concat",{"...any":function(h){var l=h.length-1,p=h[l];Qa(p)?h[l]=p-1:pa(p)&&(h[l]=p.minus(1));try{return f.apply(null,h)}catch(k){throw hc(k);}}})},{isTransformFunction:!0}), -Xg=B("max",["typed","config","numeric","larger"],b=>{function a(p,k){try{return l(p,k)?p:k}catch(n){throw Tc(n,"max",k);}}function d(p){var k;if(Zb(p,function(n){try{isNaN(n)&&"number"==typeof n?k=NaN:(void 0===k||l(n,k))&&(k=n)}catch(g){throw Tc(g,"max",n);}}),void 0===k)throw Error("Cannot calculate max of an empty array");return"string"==typeof k&&(k=h(k,f.number)),k}var {typed:c,config:f,numeric:h,larger:l}=b;return c("max",{"Array | Matrix":d,"Array | Matrix, number | BigNumber":function(p,k){return Xb(p, -k.valueOf(),a)},"...":function(p){if(Rc(p))throw new TypeError("Scalar values expected in function max");return d(p)}})}),Bj=B("max",["typed","config","numeric","larger"],b=>{var {typed:a,config:d,numeric:c,larger:f}=b,h=Xg({typed:a,config:d,numeric:c,larger:f});return a("max",{"...any":function(l){l=Pd(l);try{return h.apply(null,l)}catch(p){throw hc(p);}}})},{isTransformFunction:!0}),Yg=B("min",["typed","config","numeric","smaller"],b=>{function a(p,k){try{return l(p,k)?p:k}catch(n){throw Tc(n,"min", -k);}}function d(p){var k;if(Zb(p,function(n){try{isNaN(n)&&"number"==typeof n?k=NaN:(void 0===k||l(n,k))&&(k=n)}catch(g){throw Tc(g,"min",n);}}),void 0===k)throw Error("Cannot calculate min of an empty array");return"string"==typeof k&&(k=h(k,f.number)),k}var {typed:c,config:f,numeric:h,smaller:l}=b;return c("min",{"Array | Matrix":d,"Array | Matrix, number | BigNumber":function(p,k){return Xb(p,k.valueOf(),a)},"...":function(p){if(Rc(p))throw new TypeError("Scalar values expected in function min"); -return d(p)}})}),Cj=B("min",["typed","config","numeric","smaller"],b=>{var {typed:a,config:d,numeric:c,smaller:f}=b,h=Yg({typed:a,config:d,numeric:c,smaller:f});return a("min",{"...any":function(l){l=Pd(l);try{return h.apply(null,l)}catch(p){throw hc(p);}}})},{isTransformFunction:!0}),Zg=B("sum",["typed","config","add","numeric"],b=>{function a(l){var p;return Zb(l,function(k){try{p=void 0===p?k:f(p,k)}catch(n){throw Tc(n,"sum",k);}}),void 0===p&&(p=h(0,c.number)),"string"==typeof p&&(p=h(p,c.number)), -p}var {typed:d,config:c,add:f,numeric:h}=b;return d("sum",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(l,p){try{return Xb(l,p,f)}catch(k){throw Tc(k,"sum");}},"...":function(l){if(Rc(l))throw new TypeError("Scalar values expected in function sum");return a(l)}})}),Dj=B("sum",["typed","config","add","numeric"],b=>{var {typed:a,config:d,add:c,numeric:f}=b,h=Zg({typed:a,config:d,add:c,numeric:f});return a("sum",{"...any":function(l){l=Pd(l);try{return h.apply(null,l)}catch(p){throw hc(p); -}}})},{isTransformFunction:!0}),$g=B("column",["typed","Index","matrix","range"],b=>{function a(l,p){if(2!==l.size().length)throw Error("Only two dimensional matrix is supported");Yb(p,l.size()[1]);var k=h(0,l.size()[0]);p=new c(k,p);return l.subset(p)}var {typed:d,Index:c,matrix:f,range:h}=b;return d("column",{"Matrix, number":a,"Array, number":function(l,p){return a(f(nb(l)),p).valueOf()}})}),Ej=B("column",["typed","Index","matrix","range"],b=>{var {typed:a,Index:d,matrix:c,range:f}=b,h=$g({typed:a, -Index:d,matrix:c,range:f});return a("column",{"...any":function(l){var p=l.length-1,k=l[p];Qa(k)&&(l[p]=k-1);try{return h.apply(null,l)}catch(n){throw hc(n);}}})},{isTransformFunction:!0}),ah=B("range","typed config ?matrix ?bignumber smaller smallerEq larger largerEq".split(" "),b=>{function a(u){return"Matrix"===k.matrix?n?n(u):me():u}function d(u,y){var v=function(t){t=t.split(":").map(function(w){return Number(w)});if(t.some(function(w){return isNaN(w)}))return null;switch(t.length){case 2:return{start:t[0], -end:t[1],step:1};case 3:return{start:t[0],end:t[2],step:t[1]};default:return null}}(u);if(!v)throw new SyntaxError('String "'+u+'" is no valid range');return"BigNumber"===k.number?(void 0===g&&hd(),a((y?l:h)(g(v.start),g(v.end),g(v.step)))):a((y?f:c)(v.start,v.end,v.step))}function c(u,y,v){var t=[];if(0v)for(;q(u,y);)t.push(u),u+=v;return t}function f(u,y,v){var t=[];if(0v)for(;r(u,y);)t.push(u),u+=v;return t}function h(u, -y,v){var t=g(0),w=[];if(v.gt(t))for(;e(u,y);)w.push(u),u=u.plus(v);else if(v.lt(t))for(;q(u,y);)w.push(u),u=u.plus(v);return w}function l(u,y,v){var t=g(0),w=[];if(v.gt(t))for(;m(u,y);)w.push(u),u=u.plus(v);else if(v.lt(t))for(;r(u,y);)w.push(u),u=u.plus(v);return w}var {typed:p,config:k,matrix:n,bignumber:g,smaller:e,smallerEq:m,larger:q,largerEq:r}=b;return p("range",{string:d,"string, boolean":d,"number, number":function(u,y){return a(c(u,y,1))},"number, number, number":function(u,y,v){return a(c(u, -y,v))},"number, number, boolean":function(u,y,v){return a(v?f(u,y,1):c(u,y,1))},"number, number, number, boolean":function(u,y,v,t){return a(t?f(u,y,v):c(u,y,v))},"BigNumber, BigNumber":function(u,y){return a(h(u,y,new (0,u.constructor)(1)))},"BigNumber, BigNumber, BigNumber":function(u,y,v){return a(h(u,y,v))},"BigNumber, BigNumber, boolean":function(u,y,v){var t=u.constructor;return a(v?l(u,y,new t(1)):h(u,y,new t(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(u,y,v,t){return a(t?l(u, -y,v):h(u,y,v))}})}),Fj=B("range","typed config ?matrix ?bignumber smaller smallerEq larger largerEq".split(" "),b=>{var {typed:a,config:d,matrix:c,bignumber:f,smaller:h,smallerEq:l,larger:p,largerEq:k}=b,n=ah({typed:a,config:d,matrix:c,bignumber:f,smaller:h,smallerEq:l,larger:p,largerEq:k});return a("range",{"...any":function(g){return"boolean"!=typeof g[g.length-1]&&g.push(!0),n.apply(null,g)}})},{isTransformFunction:!0}),bh=B("diff",["typed","matrix","subtract","number"],b=>{function a(k,n){if(Fa(k)&& -(k=k.toArray()),!Array.isArray(k))throw RangeError("Array/Matrix does not have that many dimensions");if(0{g.push(a(e,n-1))}),g}if(0===n)return d(k);throw RangeError("Cannot have negative dimension");}function d(k){var n=[],g=k.length;if(2>g)return k;for(var e=1;e{var {typed:a,matrix:d,subtract:c,number:f,bignumber:h}=b,l=bh({typed:a,matrix:d,subtract:c,number:f,bignumber:h});return a("diff",{"...any":function(p){p=Pd(p);try{return l.apply(null,p)}catch(k){throw hc(k);}}})},{isTransformFunction:!0}),ch=B("row",["typed","Index","matrix","range"],b=>{function a(l,p){if(2!==l.size().length)throw Error("Only two dimensional matrix is supported");Yb(p,l.size()[0]);var k=h(0,l.size()[1]); -p=new c(p,k);return l.subset(p)}var {typed:d,Index:c,matrix:f,range:h}=b;return d("row",{"Matrix, number":a,"Array, number":function(l,p){return a(f(nb(l)),p).valueOf()}})}),Hj=B("row",["typed","Index","matrix","range"],b=>{var {typed:a,Index:d,matrix:c,range:f}=b,h=ch({typed:a,Index:d,matrix:c,range:f});return a("row",{"...any":function(l){var p=l.length-1,k=l[p];Qa(k)&&(l[p]=k-1);try{return h.apply(null,l)}catch(n){throw hc(n);}}})},{isTransformFunction:!0}),dh=B("mean",["typed","add","divide"], -b=>{function a(h){var l,p=0;if(Zb(h,function(k){try{l=void 0===l?k:c(l,k),p++}catch(n){throw Tc(n,"mean",k);}}),0===p)throw Error("Cannot calculate the mean of an empty array");return f(l,p)}var {typed:d,add:c,divide:f}=b;return d("mean",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(h,l){try{var p=Xb(h,l,c),k=Array.isArray(h)?Ua(h):h.size();return f(p,k[l])}catch(n){throw Tc(n,"mean");}},"...":function(h){if(Rc(h))throw new TypeError("Scalar values expected in function mean"); -return a(h)}})}),Ij=B("mean",["typed","add","divide"],b=>{var {typed:a,add:d,divide:c}=b,f=dh({typed:a,add:d,divide:c});return a("mean",{"...any":function(h){h=Pd(h);try{return f.apply(null,h)}catch(l){throw hc(l);}}})},{isTransformFunction:!0}),eh=B("variance","typed add subtract multiply divide apply isNaN".split(" "),b=>{function a(g,e){var m,q=0;if(0===g.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Zb(g,function(u){try{m=void 0===m?u:f(m,u), -q++}catch(y){throw Tc(y,"variance",u);}}),0===q)throw Error("Cannot calculate variance of an empty array");var r=p(m,q);if(m=void 0,Zb(g,function(u){u=h(u,r);m=void 0===m?l(u,u):f(m,l(u,u))}),n(m))return m;switch(e){case "uncorrected":return p(m,q);case "biased":return p(m,q+1);case "unbiased":return g=pa(m)?m.mul(0):0,1===q?g:p(m,q-1);default:throw Error('Unknown normalization "'+e+'". Choose "unbiased" (default), "uncorrected", or "biased".');}}function d(g,e,m){try{if(0===g.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)"); -return k(g,e,q=>a(q,m))}catch(q){throw Tc(q,"variance");}}var {typed:c,add:f,subtract:h,multiply:l,divide:p,apply:k,isNaN:n}=b;return c("variance",{"Array | Matrix":function(g){return a(g,"unbiased")},"Array | Matrix, string":a,"Array | Matrix, number | BigNumber":function(g,e){return d(g,e,"unbiased")},"Array | Matrix, number | BigNumber, string":d,"...":function(g){return a(g,"unbiased")}})}),Jj=B("variance","typed add subtract multiply divide apply isNaN".split(" "),b=>{var {typed:a,add:d,subtract:c, -multiply:f,divide:h,apply:l,isNaN:p}=b,k=eh({typed:a,add:d,subtract:c,multiply:f,divide:h,apply:l,isNaN:p});return a("variance",{"...any":function(n){n=Pd(n);try{return k.apply(null,n)}catch(g){throw hc(g);}}})},{isTransformFunction:!0}),fh=B("std",["typed","sqrt","variance"],b=>{function a(h,l){if(0===h.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{return c(f.apply(null,arguments))}catch(p){throw p instanceof TypeError&&-1!==p.message.indexOf(" variance")? -new TypeError(p.message.replace(" variance"," std")):p;}}var {typed:d,sqrt:c,variance:f}=b;return d("std",{"Array | Matrix":a,"Array | Matrix, string":a,"Array | Matrix, number | BigNumber":a,"Array | Matrix, number | BigNumber, string":a,"...":function(h){return a(h)}})}),Kj=B("std",["typed","sqrt","variance"],b=>{var {typed:a,sqrt:d,variance:c}=b,f=fh({typed:a,sqrt:d,variance:c});return a("std",{"...any":function(h){h=Pd(h);try{return f.apply(null,h)}catch(l){throw hc(l);}}})},{isTransformFunction:!0}), -Lj=B("ResultSet",[],()=>{function b(a){if(!(this instanceof b))throw new SyntaxError("Constructor must be called with the new operator");this.entries=a||[]}return b.prototype.type="ResultSet",b.prototype.isResultSet=!0,b.prototype.valueOf=function(){return this.entries},b.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},b.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},b.fromJSON=function(a){return new b(a.entries)},b},{isClass:!0}),Sc=jb(977),Mj=B("Complex", -[],()=>(Sc.prototype.type="Complex",Sc.prototype.isComplex=!0,Sc.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Sc.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Sc.prototype.format=function(b){var a=this.im,d=this.re,c=$c(this.re,b),f=$c(this.im,b);b=Qa(b)?b:b?b.precision:null;null!==b&&(b=Math.pow(10,-b),Math.abs(d/a)a?-1===a?c+" - i":c+" - "+f.substring(1)+"i":1=== -a?c+" + i":c+" + "+f+"i"},Sc.fromPolar=function(b){switch(arguments.length){case 1:var a=arguments[0];if("object"==typeof a)return Sc(a);throw new TypeError("Input has to be an object with r and phi keys.");case 2:a=arguments[0];var d=arguments[1];if(Qa(a)){if(Z(d)&&d.hasBase("ANGLE")&&(d=d.toNumber("rad")),Qa(d))return new Sc({r:a,phi:d});throw new TypeError("Phi is not a number nor an angle unit.");}throw new TypeError("Radius r is not a number.");default:throw new SyntaxError("Wrong number of arguments in function fromPolar"); -}},Sc.prototype.valueOf=Sc.prototype.toString,Sc.fromJSON=function(b){return new Sc(b)},Sc.compare=function(b,a){return b.re>a.re?1:b.rea.im?1:b.im{function b(a,d,c){if(!(this instanceof b))throw new SyntaxError("Constructor must be called with the new operator");var f=null!=a,h=null!=d,l=null!=c;if(f)if(pa(a))a=a.toNumber();else if("number"!=typeof a)throw new TypeError("Parameter start must be a number");if(h)if(pa(d))d=d.toNumber(); -else if("number"!=typeof d)throw new TypeError("Parameter end must be a number");if(l)if(pa(c))c=c.toNumber();else if("number"!=typeof c)throw new TypeError("Parameter step must be a number");this.start=f?parseFloat(a):0;this.end=h?parseFloat(d):0;this.step=l?parseFloat(c):1}return b.prototype.type="Range",b.prototype.isRange=!0,b.parse=function(a){if("string"!=typeof a)return null;a=a.split(":").map(function(d){return parseFloat(d)});if(a.some(function(d){return isNaN(d)}))return null;switch(a.length){case 2:return new b(a[0], -a[1]);case 3:return new b(a[0],a[2],a[1]);default:return null}},b.prototype.clone=function(){return new b(this.start,this.end,this.step)},b.prototype.size=function(){var a=0,d=this.step,c=this.end-this.start;return pd(d)===pd(c)?a=Math.ceil(c/d):0===c&&(a=0),isNaN(a)&&(a=0),[a]},b.prototype.min=function(){var a=this.size()[0];return 0c)for(;d>f;)a(d,[h],this),d+=c,h++},b.prototype.map=function(a){var d=[];return this.forEach(function(c,f,h){d[f[0]]=a(c,f,h)}),d},b.prototype.toArray=function(){var a=[];return this.forEach(function(d,c){a[c[0]]=d}),a},b.prototype.valueOf=function(){return this.toArray()},b.prototype.format=function(a){var d=$c(this.start,a);return 1!==this.step&&(d+=":"+$c(this.step, -a)),d+":"+$c(this.end,a)},b.prototype.toString=function(){return this.format()},b.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},b.fromJSON=function(a){return new b(a.start,a.end,a.step)},b},{isClass:!0}),Oj=ne(function(b){return(new b(1)).exp()},{hasher:Fe}),Pj=ne(function(b){return(new b(1)).plus((new b(5)).sqrt()).div(2)},{hasher:Fe}),gf=ne(function(b){return b.acos(-1)},{hasher:Fe}),Qj=ne(function(b){return gf(b).times(2)},{hasher:Fe}),Rj=Math.PI, -Sj=2*Math.PI,Tj=Math.E,Uj=B("true",[],()=>!0),Vj=B("false",[],()=>!1),Wj=B("null",[],()=>null),Xj=Uc("Infinity",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?new d(1/0):1/0}),Yj=Uc("NaN",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?new d(NaN):NaN}),Zj=Uc("pi",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?gf(d):Rj}),ak=Uc("tau",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}= -b;return"BigNumber"===a.number?Qj(d):Sj}),bk=Uc("e",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?Oj(d):Tj}),ck=Uc("phi",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?Pj(d):1.618033988749895}),dk=Uc("LN2",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?(new d(2)).ln():Math.LN2}),ek=Uc("LN10",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?(new d(10)).ln(): -Math.LN10}),fk=Uc("LOG2E",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?(new d(1)).div((new d(2)).ln()):Math.LOG2E}),gk=Uc("LOG10E",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?(new d(1)).div((new d(10)).ln()):Math.LOG10E}),hk=Uc("SQRT1_2",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}=b;return"BigNumber"===a.number?(new d("0.5")).sqrt():Math.SQRT1_2}),ik=Uc("SQRT2",["config","?BigNumber"],b=>{var {config:a,BigNumber:d}= -b;return"BigNumber"===a.number?(new d(2)).sqrt():Math.SQRT2}),jk=Uc("i",["Complex"],b=>{({Complex:b}=b);return b.I}),kk=B("version",[],()=>"9.4.1"),hf=jb(776),lk=B("BigNumber",["?on","config"],b=>{var {on:a,config:d}=b,c=hf.clone({precision:d.precision,modulo:9});return c.prototype.type="BigNumber",c.prototype.isBigNumber=!0,c.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},c.fromJSON=function(f){return new c(f.value)},a&&a("config",function(f,h){f.precision!==h.precision&& -c.config({precision:f.precision})}),c},{isClass:!0}),mk=B("Matrix",[],()=>{function b(){if(!(this instanceof b))throw new SyntaxError("Constructor must be called with the new operator");}return b.prototype.type="Matrix",b.prototype.isMatrix=!0,b.prototype.storage=function(){throw Error("Cannot invoke storage on a Matrix interface");},b.prototype.datatype=function(){throw Error("Cannot invoke datatype on a Matrix interface");},b.prototype.create=function(a,d){throw Error("Cannot invoke create on a Matrix interface"); -},b.prototype.subset=function(a,d,c){throw Error("Cannot invoke subset on a Matrix interface");},b.prototype.get=function(a){throw Error("Cannot invoke get on a Matrix interface");},b.prototype.set=function(a,d,c){throw Error("Cannot invoke set on a Matrix interface");},b.prototype.resize=function(a,d){throw Error("Cannot invoke resize on a Matrix interface");},b.prototype.reshape=function(a,d){throw Error("Cannot invoke reshape on a Matrix interface");},b.prototype.clone=function(){throw Error("Cannot invoke clone on a Matrix interface"); -},b.prototype.size=function(){throw Error("Cannot invoke size on a Matrix interface");},b.prototype.map=function(a,d){throw Error("Cannot invoke map on a Matrix interface");},b.prototype.forEach=function(a){throw Error("Cannot invoke forEach on a Matrix interface");},b.prototype[Symbol.iterator]=function(){throw Error("Cannot iterate a Matrix interface");},b.prototype.toArray=function(){throw Error("Cannot invoke toArray on a Matrix interface");},b.prototype.valueOf=function(){throw Error("Cannot invoke valueOf on a Matrix interface"); -},b.prototype.format=function(a){throw Error("Cannot invoke format on a Matrix interface");},b.prototype.toString=function(){throw Error("Cannot invoke toString on a Matrix interface");},b},{isClass:!0}),nk=B("replacer",[],()=>function(b,a){return"number"!=typeof a||isFinite(a)&&!isNaN(a)?a:{mathjs:"number",value:String(a)}}),ok=Cb("speedOfLight","299792458","m s^-1"),pk=Cb("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),qk=Cb("planckConstant","6.62607015e-34","J s"),rk=Cb("reducedPlanckConstant", -"1.0545718176461565e-34","J s"),sk=Cb("magneticConstant","1.25663706212e-6","N A^-2"),tk=Cb("electricConstant","8.8541878128e-12","F m^-1"),uk=Cb("vacuumImpedance","376.730313667","ohm"),vk=Cb("coulomb","8.987551792261171e9","N m^2 C^-2"),wk=Cb("elementaryCharge","1.602176634e-19","C"),xk=Cb("bohrMagneton","9.2740100783e-24","J T^-1"),yk=Cb("conductanceQuantum","7.748091729863649e-5","S"),zk=Cb("inverseConductanceQuantum","12906.403729652257","ohm"),Ak=Cb("magneticFluxQuantum","2.0678338484619295e-15", -"Wb"),Bk=Cb("nuclearMagneton","5.0507837461e-27","J T^-1"),Ck=Cb("klitzing","25812.807459304513","ohm"),Dk=Cb("bohrRadius","5.29177210903e-11","m"),Ek=Cb("classicalElectronRadius","2.8179403262e-15","m"),Fk=Cb("electronMass","9.1093837015e-31","kg"),Gk=Cb("fermiCoupling","1.1663787e-5","GeV^-2"),Hk=Ge("fineStructure",.0072973525693),Ik=Cb("hartreeEnergy","4.3597447222071e-18","J"),Jk=Cb("protonMass","1.67262192369e-27","kg"),Kk=Cb("deuteronMass","3.3435830926e-27","kg"),Lk=Cb("neutronMass","1.6749271613e-27", -"kg"),Mk=Cb("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),Nk=Cb("rydberg","10973731.568160","m^-1"),Ok=Cb("thomsonCrossSection","6.6524587321e-29","m^2"),Pk=Ge("weakMixingAngle",.2229),Qk=Ge("efimovFactor",22.7),Rk=Cb("atomicMass","1.66053906660e-27","kg"),Sk=Cb("avogadro","6.02214076e23","mol^-1"),Tk=Cb("boltzmann","1.380649e-23","J K^-1"),Uk=Cb("faraday","96485.33212331001","C mol^-1"),Vk=Cb("firstRadiation","3.7417718521927573e-16","W m^2"),Wk=Cb("loschmidt","2.686780111798444e25","m^-3"), -Xk=Cb("gasConstant","8.31446261815324","J K^-1 mol^-1"),Yk=Cb("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),Zk=Cb("molarVolume","0.022413969545014137","m^3 mol^-1"),$k=Ge("sackurTetrode",-1.16487052358),al=Cb("secondRadiation","0.014387768775039337","m K"),bl=Cb("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),cl=Cb("wienDisplacement","2.897771955e-3","m K"),dl=Cb("molarMass","0.99999999965e-3","kg mol^-1"),el=Cb("molarMassC12","11.9999999958e-3","kg mol^-1"),fl=Cb("gravity","9.80665", -"m s^-2"),gl=Cb("planckLength","1.616255e-35","m"),hl=Cb("planckMass","2.176435e-8","kg"),il=Cb("planckTime","5.391245e-44","s"),jl=Cb("planckCharge","1.87554603778e-18","C"),kl=Cb("planckTemperature","1.416785e+32","K"),ce=jb(628),ll=B("Fraction",[],()=>(ce.prototype.type="Fraction",ce.prototype.isFraction=!0,ce.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},ce.fromJSON=function(b){return new ce(b)},ce),{isClass:!0}),ml=B("DenseMatrix",["Matrix"],b=>{function a(k, -n){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(n&&!Ia(n))throw Error("Invalid datatype: "+n);if(Fa(k))"DenseMatrix"===k.type?(this._data=nb(k._data),this._size=nb(k._size),this._datatype=n||k._datatype):(this._data=k.toArray(),this._size=k.size(),this._datatype=n||k._datatype);else if(k&&$b(k.data)&&$b(k.size))this._data=k.data,this._size=k.size,jc(this._data,this._size),this._datatype=n||k.datatype;else{if($b(k))this._data=p(k),this._size= -Ua(this._data),jc(this._data,this._size);else{if(k)throw new TypeError("Unsupported type of data ("+Wb(k)+")");this._data=[];this._size=[0]}this._datatype=n}}function d(k,n,g,e){var m=e===g-1,q=n.dimension(e);return m?q.map(function(r){return Yb(r,k.length),k[r]}).valueOf():q.map(function(r){return Yb(r,k.length),d(k[r],n,g,e+1)}).valueOf()}function c(k,n,g,e){if(!n||!0!==n.isIndex)throw new TypeError("Invalid index");var m,q=n.size(),r=n.isScalar();if(Fa(g)?(m=g.size(),g=g.valueOf()):m=Ua(g),r){if(0!== -m.length)throw new TypeError("Scalar expected");k.set(n.min(),g,e)}else{if(q.length");l(k,n.max().map(function(y){return y+1}),e);f(k._data,n,g,q.length,0)}return k}function f(k,n,g,e,m){var q=m===e-1,r=n.dimension(m);q?r.forEach(function(u,y){Yb(u);k[u]=g[y[0]]}):r.forEach(function(u,y){Yb(u);f(k[u],n,g[y[0]], -e,m+1)})}function h(k,n,g){if(0===n.length){for(k=k._data;$b(k);)k=k[0];return k}return k._size=n.slice(0),k._data=gd(k._data,k._size,g),k}function l(k,n,g){for(var e=k._size.slice(0),m=!1;e.lengthe[q]&&(e[q]=n[q],m=!0);m&&h(k,e,g)}function p(k){for(var n=0,g=k.length;n -Array.isArray(e)&&1===e.length?e[0]:e);return h(g?this.clone():this,k,n)},a.prototype.reshape=function(k,n){n=n?this.clone():this;n._data=Zd(n._data,k);var g=n._size.reduce((e,m)=>e*m);return n._size=Kd(k,g),n},a.prototype.clone=function(){return new a({data:nb(this._data),size:nb(this._size),datatype:this._datatype})},a.prototype.size=function(){return this._size.slice(0)},a.prototype.map=function(k){var n=this,g=function r(m,q){return $b(m)?m.map(function(u,y){return r(u,q.concat(y))}):k(m,q,n)}(this._data, -[]);return new a(g,void 0!==this._datatype?la(g,Wb):void 0)},a.prototype.forEach=function(k){var n=this;!function q(e,m){$b(e)?e.forEach(function(r,u){q(r,m.concat(u))}):k(e,m,n)}(this._data,[])},a.prototype[Symbol.iterator]=function*(){yield*function*e(n,g){if($b(n))for(var m=0;m[y[r]]);n.push(new a(u,k._datatype))},q=0;qk?-k:0;for(var g=Math.min(this._size[0]-k,this._size[1]-n),e=[],m=0;mt)throw Error("Size values must be positive integers");return t}),g){if(pa(g)&&(g=g.toNumber()),!Qa(g)||!Za(g))throw new TypeError("The parameter k must be an integer number");}else g=0;var m=0g?-g:0;var q=k[0],r=k[1],u=Math.min(q-g,r-m);if($b(n)){if(n.length!==u)throw Error("Invalid value array length"); -var y=function(t){return n[t]}}else if(Fa(n)){y=n.size();if(1!==y.length||y[0]!==u)throw Error("Invalid matrix length");y=function(t){return n.get([t])}}else y=function(){return n};e||(e=pa(y(0))?y(0).mul(0):0);var v=[];if(015 significant digits to BigNumber (value: "+ -h+"). Use function bignumber(x) to convert to BigNumber.");return new a(h)}},{from:"number",to:"Complex",convert:function(h){return d||He(h),new d(h,0)}},{from:"number",to:"string",convert:function(h){return h+""}},{from:"BigNumber",to:"Complex",convert:function(h){return d||He(h),new d(h.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(h){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(h){return d||He(h),new d(h.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(h){f||$e(h);var l=new f(h);if(l.valueOf()!==h)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+h+"). Use function fraction(x) to convert to Fraction.");return l}},{from:"string",to:"number",convert:function(h){var l=Number(h);if(isNaN(l))throw Error('Cannot convert "'+h+'" to a number');return l}}, -{from:"string",to:"BigNumber",convert:function(h){a||Ze(h);try{return new a(h)}catch(l){throw Error('Cannot convert "'+h+'" to BigNumber');}}},{from:"string",to:"Fraction",convert:function(h){f||$e(h);try{return new f(h)}catch(l){throw Error('Cannot convert "'+h+'" to Fraction');}}},{from:"string",to:"Complex",convert:function(h){d||He(h);try{return new d(h)}catch(l){throw Error('Cannot convert "'+h+'" to Complex');}}},{from:"boolean",to:"number",convert:function(h){return+h}},{from:"boolean",to:"BigNumber", -convert:function(h){return a||Ze(h),new a(+h)}},{from:"boolean",to:"Fraction",convert:function(h){return f||$e(h),new f(+h)}},{from:"boolean",to:"string",convert:function(h){return String(h)}},{from:"Array",to:"Matrix",convert:function(h){if(!c)throw Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided");return new c(h)}},{from:"Matrix",to:"Array",convert:function(h){return h.valueOf()}}],b}),ol=B("isInteger",["typed"],b=>{({typed:b}=b);return b("isInteger",{number:Za,BigNumber:function(a){return a.isInt()}, -Fraction:function(a){return 1===a.d&&isFinite(a.n)},"Array | Matrix":function(a){return Na(a,this)}})}),pl=B("isNumeric",["typed"],b=>{({typed:b}=b);return b("isNumeric",{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(a){return Na(a,this)}})});Df.signature="number";Ef.signature="number";Ff.signature="number";Gf.signature="number";var ql=B("isPositive",["typed"],b=>{({typed:b}=b);return b("isPositive", -{number:Ef,BigNumber:function(a){return!a.isNeg()&&!a.isZero()&&!a.isNaN()},Fraction:function(a){return 0{({typed:b}=b);return b("isNaN",{number:Gf,BigNumber:function(a){return a.isNaN()},Fraction:function(a){return!1},Complex:function(a){return a.isNaN()},Unit:function(a){return Number.isNaN(a.value)},"Array | Matrix":function(a){return Na(a,Number.isNaN)}})}),sl=B("equalScalar", -["typed","config"],b=>{var {typed:a,config:d}=b;return a("equalScalar",{"boolean, boolean":function(c,f){return c===f},"number, number":function(c,f){return Ec(c,f,d.epsilon)},"BigNumber, BigNumber":function(c,f){return c.eq(f)||jd(c,f,d.epsilon)},"Fraction, Fraction":function(c,f){return c.equals(f)},"Complex, Complex":function(c,f){var h=d.epsilon;return Ec(c.re,f.re,h)&&Ec(c.im,f.im,h)},"Unit, Unit":function(c,f){if(!c.equalBase(f))throw Error("Cannot compare units with different base");return this(c.value, -f.value)}})});B("equalScalar",["typed","config"],b=>{var {typed:a,config:d}=b;return a("equalScalar",{"number, number":function(c,f){return Ec(c,f,d.epsilon)}})});var tl=B("number",["typed"],b=>{({typed:b}=b);b=b("number",{"":function(){return 0},number:function(a){return a},string:function(a){if("NaN"===a)return NaN;var d,c,f=(c=(d=a).match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/))?{input:d,radix:{"0b":2,"0o":8,"0x":16}[c[1]],integerPart:c[2],fractionalPart:c[3]}:null;if(f){a=parseInt(f.integerPart, -f.radix);for(c=d=0;cMath.pow(2,f)-1)throw new SyntaxError('String "'.concat(a,'" is out of range'));c>=Math.pow(2,f-1)&&(c-=Math.pow(2,f))}return c},BigNumber:function(a){return a.toNumber()}, -Fraction:function(a){return a.valueOf()},Unit:function(a){throw Error("Second argument with valueless unit expected");},null:function(a){return 0},"Unit, string | Unit":function(a,d){return a.toNumber(d)},"Array | Matrix":function(a){return Na(a,this)}});return b.fromJSON=function(a){return parseFloat(a.value)},b}),ul=B("boolean",["typed"],b=>{({typed:b}=b);return b("boolean",{"":function(){return!1},boolean:function(a){return a},number:function(a){return!!a},null:function(a){return!1},BigNumber:function(a){return!a.isZero()}, -string:function(a){var d=a.toLowerCase();if("true"===d)return!0;if("false"===d)return!1;d=Number(a);if(""!==a&&!isNaN(d))return!!d;throw Error('Cannot convert "'+a+'" to a boolean');},"Array | Matrix":function(a){return Na(a,this)}})}),vl=B("complex",["typed","Complex"],b=>{var {typed:a,Complex:d}=b;return a("complex",{"":function(){return d.ZERO},number:function(c){return new d(c,0)},"number, number":function(c,f){return new d(c,f)},"BigNumber, BigNumber":function(c,f){return new d(c.toNumber(), -f.toNumber())},Fraction:function(c){return new d(c.valueOf(),0)},Complex:function(c){return c.clone()},string:function(c){return d(c)},null:function(c){return d(0)},Object:function(c){if("re"in c&&"im"in c)return new d(c.re,c.im);if("r"in c&&"phi"in c||"abs"in c&&"arg"in c)return new d(c);throw Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)");},"Array | Matrix":function(c){return Na(c,this)}})}),wl=B("splitUnit",["typed"],b=>{({typed:b}=b);return b("splitUnit", -{"Unit, Array":function(a,d){return a.splitUnit(d)}})});Hf.signature="number";If.signature="number, number";Jf.signature="number, number";Kf.signature="number";Lf.signature="number";Mf.signature="number";Nf.signature="number";Of.signature="number";Pf.signature="number";Qf.signature="number";Rf.signature="number, number";Sf.signature="number, number";Tf.signature="number";Uf.signature="number, number";af.signature="number, number";Vf.signature="number";Wf.signature="number";Xf.signature="number, number"; -Yf.signature="number, number";bf.signature="number, number";var xl=B("unaryPlus",["typed","config","BigNumber"],b=>{var {typed:a,config:d,BigNumber:c}=b;return a("unaryPlus",{number:Lf,Complex:function(f){return f},BigNumber:function(f){return f},Fraction:function(f){return f},Unit:function(f){return f.clone()},"Array | Matrix":function(f){return Na(f,this,!0)},"boolean | string":function(f){return"BigNumber"===d.number?new c(+f):+f}})}),yl=B("cube",["typed"],b=>{({typed:b}=b);return b("cube",{number:Of, -Complex:function(a){return a.mul(a).mul(a)},BigNumber:function(a){return a.times(a).times(a)},Fraction:function(a){return a.pow(3)},"Array | Matrix":function(a){return Na(a,this,!0)},Unit:function(a){return a.pow(3)}})}),zl=B("expm1",["typed","Complex"],b=>{var {typed:a,Complex:d}=b;return a("expm1",{number:Qf,Complex:function(c){var f=Math.exp(c.re);return new d(f*Math.cos(c.im)-1,f*Math.sin(c.im))},BigNumber:function(c){return c.exp().minus(1)},"Array | Matrix":function(c){return Na(c,this)}})}), -Al=B("log10",["typed","config","Complex"],b=>{var {typed:a,config:d,Complex:c}=b;return a("log10",{number:function(f){return 0<=f||d.predictable?Li(f):(new c(f,0)).log().div(Math.LN10)},Complex:function(f){return(new c(f)).log().div(Math.LN10)},BigNumber:function(f){return!f.isNegative()||d.predictable?f.log():(new c(f.toNumber(),0)).log().div(Math.LN10)},"Array | Matrix":function(f){return Na(f,this)}})}),Bl=B("multiplyScalar",["typed"],b=>{({typed:b}=b);return b("multiplyScalar",{"number, number":Jf, -"Complex, Complex":function(a,d){return a.mul(d)},"BigNumber, BigNumber":function(a,d){return a.times(d)},"Fraction, Fraction":function(a,d){return a.mul(d)},"number | Fraction | BigNumber | Complex, Unit":function(a,d){d=d.clone();return d.value=null===d.value?d._normalize(a):this(d.value,a),d},"Unit, number | Fraction | BigNumber | Complex":function(a,d){a=a.clone();return a.value=null===a.value?a._normalize(d):this(a.value,d),a},"Unit, Unit":function(a,d){return a.multiply(d)}})}),Cl=B("sign", -["typed","BigNumber","Fraction","complex"],b=>{var {typed:a,BigNumber:d,complex:c,Fraction:f}=b;return a("sign",{number:Vf,Complex:function(h){return 0===h.im?c(pd(h.re)):h.sign()},BigNumber:function(h){return new d(h.cmp(0))},Fraction:function(h){return new f(h.s,1)},"Array | Matrix":function(h){return Na(h,this,!0)},Unit:function(h){return this(h.value)}})}),Dl=B("square",["typed"],b=>{({typed:b}=b);return b("square",{number:Wf,Complex:function(a){return a.mul(a)},BigNumber:function(a){return a.times(a)}, -Fraction:function(a){return a.mul(a)},"Array | Matrix":function(a){return Na(a,this,!0)},Unit:function(a){return a.pow(2)}})});Zf.signature="number, number";$f.signature="number";ag.signature="number, number";bg.signature="number, number";cg.signature="number, number";dg.signature="number, number";eg.signature="number, number";var El=B("bitNot",["typed"],b=>{({typed:b}=b);return b("bitNot",{number:$f,BigNumber:oe,"Array | Matrix":function(a){return Na(a,this)}})}),Fl=B("arg",["typed"],b=>{({typed:b}= -b);return b("arg",{number:function(a){return Math.atan2(0,a)},BigNumber:function(a){return a.constructor.atan2(0,a)},Complex:function(a){return a.arg()},"Array | Matrix":function(a){return Na(a,this)}})}),Gl=B("im",["typed"],b=>{({typed:b}=b);return b("im",{number:function(a){return 0},BigNumber:function(a){return a.mul(0)},Fraction:function(a){return a.mul(0)},Complex:function(a){return a.im},"Array | Matrix":function(a){return Na(a,this)}})});fg.signature="number";gg.signature="number, number"; -hg.signature="number, number";ig.signature="number, number";var Hl=B("not",["typed"],b=>{({typed:b}=b);return b("not",{number:fg,Complex:function(a){return 0===a.re&&0===a.im},BigNumber:function(a){return a.isZero()||a.isNaN()},Unit:function(a){return null===a.value||this(a.value)},"Array | Matrix":function(a){return Na(a,this)}})}),Il=B("filter",["typed"],b=>{({typed:b}=b);return b("filter",{"Array, function":jg,"Matrix, function":function(a,d){return a.create(jg(a.toArray(),d))},"Array, RegExp":Y, -"Matrix, RegExp":function(a,d){return a.create(Y(a.toArray(),d))}})}),Jl=B("forEach",["typed"],b=>{({typed:b}=b);return b("forEach",{"Array, function":Ei,"Matrix, function":function(a,d){return a.forEach(d)}})}),Kl=B("map",["typed"],b=>{({typed:b}=b);return b("map",{"Array, function":Fi,"Matrix, function":function(a,d){return a.map(d)}})}),Ol=B("erf",["typed"],b=>{({typed:b}=b);return b("name",{number:function(a){var d=Math.abs(a);return d>=Ll?pd(a):d<=Ml?pd(a)*function(c){var f,h=c*c,l=qd[0][4]* -h,p=h;for(f=0;3>f;f+=1)l=(l+qd[0][f])*h,p=(p+de[0][f])*h;return c*(l+qd[0][3])/(p+de[0][3])}(d):4>=d?pd(a)*(1-function(c){var f,h=qd[1][8]*c,l=c;for(f=0;7>f;f+=1)h=(h+qd[1][f])*c,l=(l+de[1][f])*c;f=(h+qd[1][7])/(l+de[1][7]);h=parseInt(16*c)/16;return Math.exp(-h*h)*Math.exp(-((c-h)*(c+h)))*f}(d)):pd(a)*(1-function(c){var f,h=1/(c*c),l=qd[2][5]*h,p=h;for(f=0;4>f;f+=1)l=(l+qd[2][f])*h,p=(p+de[2][f])*h;f=h*(l+qd[2][4])/(p+de[2][4]);f=(Nl-f)/c;l=(c-(h=parseInt(16*c)/16))*(c+h);return Math.exp(-h*h)*Math.exp(-l)* -f}(d))},"Array | Matrix":function(a){return Na(a,this)}})}),Ml=.46875,Nl=.5641895835477563,qd=[[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,6.587491615298378E-4,.016315387137302097]],de=[[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]],Ll=Math.pow(2,53),Pl=B("format",["typed"],b=>{({typed:b}=b);return b("format",{any:Db,"any, Object | function | number":Db})}),Ql=B("oct",["typed","format"],b=>{var {typed:a,format:d}=b;return a("oct", -{"number | BigNumber":function(c){return d(c,{notation:"oct"})},"number | BigNumber, number":function(c,f){return d(c,{notation:"oct",wordSize:f})}})}),Rl=B("print",["typed"],b=>{({typed:b}=b);return b("print",{"string, Object | Array":kg,"string, Object | Array, number | Object":kg})}),Sl=B("isPrime",["typed"],b=>{({typed:b}=b);return b("isPrime",{number:function(a){if(0!=0*a)return!1;if(3>=a)return 1n{var {typed:a,config:d,Complex:c}=b;return a("acos",{number:function(f){return-1<=f&&1>=f|| -d.predictable?Math.acos(f):(new c(f,0)).acos()},Complex:function(f){return f.acos()},BigNumber:function(f){return f.acos()},"Array | Matrix":function(f){return Na(f,this)}})});lg.signature="number";mg.signature="number";ng.signature="number";og.signature="number";pg.signature="number";qg.signature="number";rg.signature="number";sg.signature="number";tg.signature="number";ug.signature="number";vg.signature="number";wg.signature="number";xg.signature="number";yg.signature="number";var Ul=B("acot",["typed", -"BigNumber"],b=>{var {typed:a,BigNumber:d}=b;return a("acot",{number:lg,Complex:function(c){return c.acot()},BigNumber:function(c){return(new d(1)).div(c).atan()},"Array | Matrix":function(c){return Na(c,this)}})}),Vl=B("acsc",["typed","config","Complex","BigNumber"],b=>{var {typed:a,config:d,Complex:c,BigNumber:f}=b;return a("acsc",{number:function(h){return-1>=h||1<=h||d.predictable?ng(h):(new c(h,0)).acsc()},Complex:function(h){return h.acsc()},BigNumber:function(h){return(new f(1)).div(h).asin()}, -"Array | Matrix":function(h){return Na(h,this)}})}),Wl=B("asec",["typed","config","Complex","BigNumber"],b=>{var {typed:a,config:d,Complex:c,BigNumber:f}=b;return a("asec",{number:function(h){return-1>=h||1<=h||d.predictable?pg(h):(new c(h,0)).asec()},Complex:function(h){return h.asec()},BigNumber:function(h){return(new f(1)).div(h).acos()},"Array | Matrix":function(h){return Na(h,this)}})}),Xl=B("asin",["typed","config","Complex"],b=>{var {typed:a,config:d,Complex:c}=b;return a("asin",{number:function(f){return-1<= -f&&1>=f||d.predictable?Math.asin(f):(new c(f,0)).asin()},Complex:function(f){return f.asin()},BigNumber:function(f){return f.asin()},"Array | Matrix":function(f){return Na(f,this,!0)}})}),Yl=B("atan",["typed"],b=>{({typed:b}=b);return b("atan",{number:function(a){return Math.atan(a)},Complex:function(a){return a.atan()},BigNumber:function(a){return a.atan()},"Array | Matrix":function(a){return Na(a,this,!0)}})}),Zl=B("atanh",["typed","config","Complex"],b=>{var {typed:a,config:d,Complex:c}=b;return a("atanh", -{number:function(f){return 1>=f&&-1<=f||d.predictable?Oi(f):(new c(f,0)).atanh()},Complex:function(f){return f.atanh()},BigNumber:function(f){return f.atanh()},"Array | Matrix":function(f){return Na(f,this,!0)}})}),$l=B("cosh",["typed"],b=>{({typed:b}=b);return b("cosh",{number:Pi,Complex:function(a){return a.cosh()},BigNumber:function(a){return a.cosh()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(a.value)},"Array | Matrix":function(a){return Na(a, -this)}})}),am=B("coth",["typed","BigNumber"],b=>{var {typed:a,BigNumber:d}=b;return a("coth",{number:tg,Complex:function(c){return c.coth()},BigNumber:function(c){return(new d(1)).div(c.tanh())},Unit:function(c){if(!c.hasBase(c.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(c.value)},"Array | Matrix":function(c){return Na(c,this)}})}),bm=B("csch",["typed","BigNumber"],b=>{var {typed:a,BigNumber:d}=b;return a("csch",{number:vg,Complex:function(c){return c.csch()}, -BigNumber:function(c){return(new d(1)).div(c.sinh())},Unit:function(c){if(!c.hasBase(c.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(c.value)},"Array | Matrix":function(c){return Na(c,this)}})}),cm=B("sech",["typed","BigNumber"],b=>{var {typed:a,BigNumber:d}=b;return a("sech",{number:xg,Complex:function(c){return c.sech()},BigNumber:function(c){return(new d(1)).div(c.cosh())},Unit:function(c){if(!c.hasBase(c.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle"); -return this(c.value)},"Array | Matrix":function(c){return Na(c,this)}})}),dm=B("sinh",["typed"],b=>{({typed:b}=b);return b("sinh",{number:yg,Complex:function(a){return a.sinh()},BigNumber:function(a){return a.sinh()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(a.value)},"Array | Matrix":function(a){return Na(a,this,!0)}})}),em=B("tanh",["typed"],b=>{({typed:b}=b);return b("tanh",{number:Qi,Complex:function(a){return a.tanh()}, -BigNumber:function(a){return a.tanh()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(a.value)},"Array | Matrix":function(a){return Na(a,this,!0)}})});zg.signature="number, number";var fm=B("combinations",["typed"],b=>{({typed:b}=b);return b("combinations",{"number, number":zg,"BigNumber, BigNumber":function(a,d){var c,f=a.constructor,h=a.minus(d);f=new f(1);if(!Ag(a)||!Ag(d))throw new TypeError("Positive integer value expected in function combinations"); -if(d.gt(a))throw new TypeError("k must be less than n in function combinations");if(a=f,d.lt(h))for(c=f;c.lte(h);c=c.plus(f))a=a.times(d.plus(c)).dividedBy(c);else for(c=f;c.lte(d);c=c.plus(f))a=a.times(h.plus(c)).dividedBy(c);return a}})}),Bg=jb(377),Ii=Bg(Date.now()),gm=B("pickRandom",["typed","config","?on"],b=>{function a(l,p){var {number:k,weights:n,elementWise:g=!0}=p;(p=void 0===k)&&(k=1);var e=Fa(l)?l.create:Fa(n)?n.create:null;l=l.valueOf();n&&(n=n.valueOf());!0===g&&(l=C(l),n=C(n));var m= -0;if(void 0!==n){if(n.length!==l.length)throw Error("Weights must have the same length as possibles");for(var q=0,r=n.length;qn[q])throw Error("Weights must be an array of positive numbers");m+=n[q]}}q=l.length;for(r=[];r.length(y-=n[v])){u=l[v];break}r.push(u)}return p?r[0]:e?e(r):r}var {typed:d,config:c,on:f}=b,h=ae(c.randomSeed);return f&&f("config",function(l,p){l.randomSeed!== -p.randomSeed&&(h=ae(l.randomSeed))}),d("pickRandom",{"Array | Matrix":function(l){return a(l,{})},"Array | Matrix, Object":function(l,p){return a(l,p)},"Array | Matrix, number":function(l,p){return a(l,{number:p})},"Array | Matrix, Array | Matrix":function(l,p){return a(l,{weights:p})},"Array | Matrix, Array | Matrix, number":function(l,p,k){return a(l,{number:k,weights:p})},"Array | Matrix, number, Array | Matrix":function(l,p,k){return a(l,{number:p,weights:k})}})}),hm=B("randomInt",["typed","config", -"?on"],b=>{function a(p,k,n){var g=df(p.valueOf(),()=>d(k,n));return Fa(p)?p.create(g):g}function d(p,k){return Math.floor(p+l()*(k-p))}var {typed:c,config:f,on:h}=b,l=ae(f.randomSeed);return h&&h("config",function(p,k){p.randomSeed!==k.randomSeed&&(l=ae(p.randomSeed))}),c("randomInt",{"":()=>d(0,1),number:p=>d(0,p),"number, number":(p,k)=>d(p,k),"Array | Matrix":p=>a(p,0,1),"Array | Matrix, number":(p,k)=>a(p,0,k),"Array | Matrix, number, number":(p,k,n)=>a(p,k,n)})}),im=B("clone",["typed"],b=>{({typed:b}= -b);return b("clone",{any:nb})}),jm=B("hasNumericValue",["typed","isNumeric"],b=>{var {typed:a,isNumeric:d}=b;return a("hasNumericValue",{string:function(c){return 0{({typed:b}=b);return b("typeOf",{any:Wb})}),lm=B("string",["typed"],b=>{({typed:b}=b);return b("string",{"":function(){return""},number:$c,null:function(a){return"null"},boolean:function(a){return a+""},string:function(a){return a},"Array | Matrix":function(a){return Na(a, -this)},any:function(a){return String(a)}})}),mm=B("fraction",["typed","Fraction"],b=>{var {typed:a,Fraction:d}=b;return a("fraction",{number:function(c){if(!isFinite(c)||isNaN(c))throw Error(c+" cannot be represented as a fraction");return new d(c)},string:function(c){return new d(c)},"number, number":function(c,f){return new d(c,f)},null:function(c){return new d(0)},BigNumber:function(c){return new d(c.toString())},Fraction:function(c){return c},Object:function(c){return new d(c)},"Array | Matrix":function(c){return Na(c, -this)}})}),nm=B("unaryMinus",["typed"],b=>{({typed:b}=b);return b("unaryMinus",{number:Kf,Complex:function(a){return a.neg()},BigNumber:function(a){return a.neg()},Fraction:function(a){return a.neg()},Unit:function(a){var d=a.clone();return d.value=this(a.value),d},"Array | Matrix":function(a){return Na(a,this,!0)}})}),om=B("addScalar",["typed"],b=>{({typed:b}=b);return b("addScalar",{"number, number":If,"Complex, Complex":function(a,d){return a.add(d)},"BigNumber, BigNumber":function(a,d){return a.plus(d)}, -"Fraction, Fraction":function(a,d){return a.add(d)},"Unit, Unit":function(a,d){if(null===a.value||void 0===a.value)throw Error("Parameter x contains a unit with undefined value");if(null===d.value||void 0===d.value)throw Error("Parameter y contains a unit with undefined value");if(!a.equalBase(d))throw Error("Units do not match");a=a.clone();return a.value=this(a.value,d.value),a.fixPrefix=!1,a}})}),pm=B("exp",["typed"],b=>{({typed:b}=b);return b("exp",{number:Pf,Complex:function(a){return a.exp()}, -BigNumber:function(a){return a.exp()},"Array | Matrix":function(a){return Na(a,this)}})}),qm=B("log2",["typed","config","Complex"],b=>{function a(h){var l=Math.sqrt(h.re*h.re+h.im*h.im);return new f(Math.log2?Math.log2(l):Math.log(l)/Math.LN2,Math.atan2(h.im,h.re)/Math.LN2)}var {typed:d,config:c,Complex:f}=b;return d("log2",{number:function(h){return 0<=h||c.predictable?Ki(h):a(new f(h,0))},Complex:a,BigNumber:function(h){return!h.isNegative()||c.predictable?h.log(2):a(new f(h.toNumber(),0))},"Array | Matrix":function(h){return Na(h, -this)}})}),rm=B("sqrt",["config","typed","Complex"],b=>{function a(h){return isNaN(h)?NaN:0<=h||d.predictable?Math.sqrt(h):(new f(h,0)).sqrt()}var {config:d,typed:c,Complex:f}=b;return c("sqrt",{number:a,Complex:function(h){return h.sqrt()},BigNumber:function(h){return!h.isNegative()||d.predictable?h.sqrt():a(h.toNumber())},"Array | Matrix":function(h){return Na(h,this,!0)},Unit:function(h){return h.pow(.5)}})}),sm=B("conj",["typed"],b=>{({typed:b}=b);return b("conj",{number:function(a){return a}, -BigNumber:function(a){return a},Complex:function(a){return a.conjugate()},"Array | Matrix":function(a){return Na(a,this)}})}),tm=B("getMatrixDataType",["typed"],b=>{({typed:b}=b);return b("getMatrixDataType",{Array:function(a){return la(a,Wb)},Matrix:function(a){return a.getDataType()}})}),um=B("mode",["typed","isNaN","isNumeric"],b=>{function a(h){if(0===(h=C(h.valueOf())).length)throw Error("Cannot calculate mode of an empty array");for(var l={},p=[],k=0,n=0;nk&&(k=l[g],p=[g])}return p}var {typed:d,isNaN:c,isNumeric:f}=b;return d("mode",{"Array | Matrix":a,"...":function(h){return a(h)}})}),vm=B("bin",["typed","format"],b=>{var {typed:a,format:d}=b;return a("bin",{"number | BigNumber":function(c){return d(c,{notation:"bin"})},"number | BigNumber, number":function(c,f){return d(c,{notation:"bin",wordSize:f})}})}),wm=B("acosh",["typed", -"config","Complex"],b=>{var {typed:a,config:d,Complex:c}=b;return a("acosh",{number:function(f){return 1<=f||d.predictable?Ni(f):-1>=f?new c(Math.log(Math.sqrt(f*f-1)-f),Math.PI):(new c(f,0)).acosh()},Complex:function(f){return f.acosh()},BigNumber:function(f){return f.acosh()},"Array | Matrix":function(f){return Na(f,this)}})}),xm=B("acsch",["typed","BigNumber"],b=>{var {typed:a,BigNumber:d}=b;return a("acsch",{number:og,Complex:function(c){return c.acsch()},BigNumber:function(c){return(new d(1)).div(c).asinh()}, -"Array | Matrix":function(c){return Na(c,this)}})}),ym=B("asinh",["typed"],b=>{({typed:b}=b);return b("asinh",{number:rg,Complex:function(a){return a.asinh()},BigNumber:function(a){return a.asinh()},"Array | Matrix":function(a){return Na(a,this,!0)}})}),zm=B("cos",["typed"],b=>{({typed:b}=b);return b("cos",{number:Math.cos,Complex:function(a){return a.cos()},BigNumber:function(a){return a.cos()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle"); -return this(a.value)},"Array | Matrix":function(a){return Na(a,this)}})}),Am=B("csc",["typed","BigNumber"],b=>{var {typed:a,BigNumber:d}=b;return a("csc",{number:ug,Complex:function(c){return c.csc()},BigNumber:function(c){return(new d(1)).div(c.sin())},Unit:function(c){if(!c.hasBase(c.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(c.value)},"Array | Matrix":function(c){return Na(c,this)}})}),Bm=B("sin",["typed"],b=>{({typed:b}=b);return b("sin", -{number:Math.sin,Complex:function(a){return a.sin()},BigNumber:function(a){return a.sin()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(a.value)},"Array | Matrix":function(a){return Na(a,this,!0)}})}),Cm=B("combinationsWithRep",["typed"],b=>{({typed:b}=b);return b("combinationsWithRep",{"number, number":function(a,d){if(!Za(a)||0>a)throw new TypeError("Positive integer value expected in function combinationsWithRep"); -if(!Za(d)||0>d)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(1>a)throw new TypeError("k must be less than or equal to n + k - 1");return d{function a(p,k,n){var g=df(p.valueOf(),()=>d(k,n));return Fa(p)?p.create(g):g}function d(p,k){return p+l()*(k-p)}var {typed:c,config:f,on:h}=b,l=ae(f.randomSeed);return h&&h("config",function(p,k){p.randomSeed!==k.randomSeed&&(l=ae(p.randomSeed))}),c("random",{"":()=>d(0,1),number:p=>d(0,p),"number, number":(p, -k)=>d(p,k),"Array | Matrix":p=>a(p,0,1),"Array | Matrix, number":(p,k)=>a(p,0,k),"Array | Matrix, number, number":(p,k,n)=>a(p,k,n)})}),Em=B("isNegative",["typed"],b=>{({typed:b}=b);return b("isNegative",{number:Df,BigNumber:function(a){return a.isNeg()&&!a.isZero()&&!a.isNaN()},Fraction:function(a){return 0>a.s},Unit:function(a){return this(a.value)},"Array | Matrix":function(a){return Na(a,this)}})}),Fm=B("SparseMatrix",["typed","equalScalar","Matrix"],b=>{function a(e,m){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator"); -if(m&&!Ia(m))throw Error("Invalid datatype: "+m);if(Fa(e))"SparseMatrix"===e.type?(this._values=e._values?nb(e._values):void 0,this._index=nb(e._index),this._ptr=nb(e._ptr),this._size=nb(e._size),this._datatype=m||e._datatype):d(this,e.valueOf(),m||e._datatype),!0;else if(e&&$b(e.index)&&$b(e.ptr)&&$b(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=m||e.datatype;else if($b(e))d(this,e,m);else{if(e)throw new TypeError("Unsupported type of data ("+ -Wb(e)+")");this._values=[];this._index=[];this._ptr=[0];this._size=[0,0];this._datatype=m}}function d(e,m,q){e._values=[];e._index=[];e._ptr=[];e._datatype=q;var r=m.length,u=0,y=n,v=0;if(Ia(q)&&(y=k.find(n,[q,q])||n,v=k.convert(0,q)),0u&&(u=1),y(w,v)||(e._values.push(w),e._index.push(t))}q++}while(qy){for(u=y;uw){if(t){var z=0;for(u=0;um-1&&(e._values.splice(t,1),e._index.splice(t,1),r++);e._ptr[u]=e._values.length}return e._size[0]=m,e._size[1]=q,e}function p(e,m,q,r,u){var y,v=r[0],t=r[1],w=[];for(r=0;r"); -y=e.min()[0];v=e.min()[1];t=u[0];u=u[1];for(var w=0;wu-1||e>y-1)&&(l(this,Math.max(r+ -1,u),Math.max(e+1,y),q),u=this._size[0],y=this._size[1]);Yb(r,u);Yb(e,y);q=f(r,this._ptr[e],this._ptr[e+1],this._index);if(qArray.isArray(u)&&1===u.length? -u[0]:u);if(2!==r.length)throw Error("Only two dimensions matrix are supported");return r.forEach(function(u){if(!Qa(u)||!Za(u)||0>u)throw new TypeError("Invalid size, must contain positive integers (size: "+Db(r)+")");}),l(q?this.clone():this,r[0],r[1],m)},a.prototype.reshape=function(e,m){if(!$b(e))throw new TypeError("Array expected");if(2!==e.length)throw Error("Sparse matrices can only be reshaped in two dimensions");e.forEach(function(z){if(!Qa(z)||!Za(z)||-2>=z||0===z)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+ -Db(e)+")");});var q=this._size[0]*this._size[1];if(q!==(e=Kd(e,q))[0]*e[1])throw Error("Reshaping sparse matrix will result in the wrong number of elements");m=m?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return m;q=[];for(var r=0;r "+(this._values?Db(this._values[y],e):"X");return m},a.prototype.toString=function(){return Db(this.toArray())},a.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},a.prototype.diagonal=function(e){if(e){if(pa(e)&& -(e=e.toNumber()),!Qa(e)||!Za(e))throw new TypeError("The parameter k must be an integer number");}else e=0;var m=0e?-e:0;for(var q=this._size[1],r=Math.min(this._size[0]-e,q-m),u=[],y=[],v=[0],t=m;tba)throw Error("Size values must be positive integers");return ba}),q){if(pa(q)&&(q=q.toNumber()),!Qa(q)||!Za(q))throw new TypeError("The parameter k must be an integer number");}else q=0;r=n;var y=0;Ia(u)&&(r=k.find(n,[u,u])||n,y=k.convert(0,u));u=0q?-q:0;var v=e[0];e=e[1];var t=Math.min(v-q,e-u);if($b(m)){if(m.length!==t)throw Error("Invalid value array length"); -var w=function(ba){return m[ba]}}else if(Fa(m)){w=m.size();if(1!==w.length||w[0]!==t)throw Error("Invalid matrix length");w=function(ba){return m.get([ba])}}else w=function(){return m};for(var z=[],I=[],F=[],L=0;L=w||u[t]!==m)?(w=r?r[z]:void 0,u.splice(t,0,m),r&&r.splice(t,0,w),u.splice(t<=z?z+1:z,1),r&&r.splice(t<=z?z+1:z,1)):t=w||u[z]!==e)&&(w=r?r[t]:void 0,u.splice(z,0,e),r&&r.splice(z,0,w),u.splice(z<=t?t+1:t,1),r&&r.splice(z<=t?t+1:t,1))}},a},{isClass:!0}),Gm=B("matrix",["typed","Matrix","DenseMatrix","SparseMatrix"],b=>{function a(h,l,p){if("dense"===l||"default"===l||void 0===l)return new c(h,p);if("sparse"===l)return new f(h,p);throw new TypeError("Unknown matrix type "+JSON.stringify(l)+".");}var {typed:d,DenseMatrix:c,SparseMatrix:f}=b;return d("matrix",{"":function(){return a([])},string:function(h){return a([], -h)},"string, string":function(h,l){return a([],h,l)},Array:function(h){return a(h)},Matrix:function(h){return a(h,h.storage())},"Array | Matrix, string":a,"Array | Matrix, string, string":a})}),Hm=B("abs",["typed"],b=>{({typed:b}=b);return b("abs",{number:Hf,Complex:function(a){return a.abs()},BigNumber:function(a){return a.abs()},Fraction:function(a){return a.abs()},"Array | Matrix":function(a){return Na(a,this,!0)},Unit:function(a){return a.abs()}})}),Cd=B("algorithm01",["typed"],b=>{var {typed:a}= -b;return function(d,c,f,h){var l=d._data,p=d._size,k=d._datatype,n=c._values,g=c._index,e=c._ptr,m=c._size;c=c._datatype;if(p.length!==m.length)throw new yb(p.length,m.length);if(p[0]!==m[0]||p[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+m+")");if(!n)throw Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");m=p[0];p=p[1];var q=(k="string"==typeof k&&k===c?k:void 0)?a.find(f,[k,k]):f,r=[];for(f=0;f{var {typed:a,equalScalar:d}=b;return function(c,f,h){var l=c._values,p=c._index,k=c._ptr,n=c._size,g=c._datatype,e=f._values,m=f._index,q=f._ptr,r=f._size,u=f._datatype;if(n.length!==r.length)throw new yb(n.length,r.length);if(n[0]!== -r[0]||n[1]!==r[1])throw new RangeError("Dimension mismatch. Matrix A ("+n+") must match Matrix B ("+r+")");var y;r=n[0];n=n[1];f=d;var v=0,t=h;"string"==typeof g&&g===u&&(y=g,f=a.find(d,[y,y]),v=a.convert(0,y),t=a.find(h,[y,y]));u=l&&e?[]:void 0;var w=[],z=[],I=l&&e?[]:void 0,F=l&&e?[]:void 0,L=[],O=[];for(h=0;h{var {typed:a,DenseMatrix:d}=b;return function(c,f,h,l){var p=c._values,k=c._index,n=c._ptr,g=c._size,e=c._datatype;if(!p)throw Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value"); -var m;c=g[0];g=g[1];var q=h;"string"==typeof e&&(m=e,f=a.convert(f,m),q=a.find(h,[m,m]));h=[];e=[];for(var r=[],u=0;u{function a(c,f,h,l,p,k){var n=[];if(f===h.length-1)for(f=0;f{function a(c, -f,h,l,p,k,n){var g=[];if(f===h.length-1)for(f=0;f{var {typed:a,matrix:d,equalScalar:c, -BigNumber:f,DenseMatrix:h}=b,l=Cd({typed:a}),p=jf({typed:a,equalScalar:c}),k=Qd({typed:a,DenseMatrix:h}),n=fc({typed:a}),g=Tb({typed:a});return a("gcd",{"number, number":Rf,"BigNumber, BigNumber":function(e,m){if(!e.isInt()||!m.isInt())throw Error("Parameters in function gcd must be integer numbers");for(var q=new f(0);!m.isZero();){var r=e.mod(m);e=m;m=r}return e.lt(q)?e.neg():e},"Fraction, Fraction":function(e,m){return e.gcd(m)},"SparseMatrix, SparseMatrix":function(e,m){return p(e,m,this)},"SparseMatrix, DenseMatrix":function(e, -m){return l(m,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,m){return l(e,m,this,!1)},"DenseMatrix, DenseMatrix":function(e,m){return n(e,m,this)},"Array, Array":function(e,m){return this(d(e),d(m)).valueOf()},"Array, Matrix":function(e,m){return this(d(e),m)},"Matrix, Array":function(e,m){return this(e,d(m))},"SparseMatrix, number | BigNumber":function(e,m){return k(e,m,this,!1)},"DenseMatrix, number | BigNumber":function(e,m){return g(e,m,this,!1)},"number | BigNumber, SparseMatrix":function(e, -m){return k(m,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,m){return g(m,e,this,!0)},"Array, number | BigNumber":function(e,m){return g(d(e),m,this,!1).valueOf()},"number | BigNumber, Array":function(e,m){return g(d(m),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,m,q){e=this(e,m);for(m=0;m{var {typed:a, -equalScalar:d}=b;return function(c,f,h,l){var p=c._data,k=c._size,n=c._datatype;c=f._values;var g=f._index,e=f._ptr,m=f._size,q=f._datatype;if(k.length!==m.length)throw new yb(k.length,m.length);if(k[0]!==m[0]||k[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+k+") must match Matrix B ("+m+")");if(!c)throw Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var r;m=k[0];k=k[1];var u=d,y=0,v=h;"string"==typeof n&&n===q&&(r=n,u=a.find(d,[r,r]),y=a.convert(0,r), -v=a.find(h,[r,r]));h=[];n=[];q=[];for(var t=0;t{var {typed:a}=b;return function(d,c,f,h){var l=d._data,p=d._size,k=d._datatype,n=c._values,g=c._index,e=c._ptr,m=c._size,q=c._datatype;if(p.length!==m.length)throw new yb(p.length,m.length);if(p[0]!== -m[0]||p[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+m+")");if(!n)throw Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var r;m=p[0];p=p[1];c=0;var u=f;"string"==typeof k&&k===q&&(r=k,c=a.convert(0,r),u=a.find(f,[r,r]));f=[];for(k=0;k{var {typed:a,equalScalar:d}=b;return function(c,f,h){var l=c._values,p=c._index,k=c._ptr,n=c._size,g=c._datatype,e=f._values,m=f._index,q=f._ptr,r=f._size,u=f._datatype;if(n.length!==r.length)throw new yb(n.length,r.length);if(n[0]!==r[0]||n[1]!==r[1])throw new RangeError("Dimension mismatch. Matrix A ("+n+") must match Matrix B ("+r+")");var y;r=n[0];n=n[1];f=d;var v= -0,t=h;"string"==typeof g&&g===u&&(y=g,f=a.find(d,[y,y]),v=a.convert(0,y),t=a.find(h,[y,y]));var w;u=l&&e?[]:void 0;var z=[],I=[],F=u?[]:void 0,L=u?[]:void 0,O=[],R=[];for(h=0;h{var {typed:a,equalScalar:d}=b;return function(c,f,h,l){var p=c._values,k=c._index,n=c._ptr,g=c._size,e=c._datatype;if(!p)throw Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var m,q=g[0];g=g[1];var r=d,u=0,y=h;"string"==typeof e&&(m=e,r=a.find(d,[m,m]),u=a.convert(0,m),f=a.convert(f,m),y=a.find(h,[m,m]));h=[];e=[];for(var v= -[],t=0;t{var {typed:a,DenseMatrix:d}=b;return function(c,f,h,l){var p=c._values,k=c._index,n=c._ptr,g=c._size,e=c._datatype;if(!p)throw Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var m;c=g[0];g=g[1];var q=h;"string"== -typeof e&&(m=e,f=a.convert(f,m),q=a.find(h,[m,m]));h=[];e=[];for(var r=[],u=0;u{var {typed:a,matrix:d,equalScalar:c,DenseMatrix:f}=b,h=bd({typed:a,equalScalar:c}),l=Nc({typed:a}),p=Le({typed:a,equalScalar:c}),k=Fc({typed:a, -equalScalar:c}),n=Oc({typed:a,DenseMatrix:f}),g=fc({typed:a}),e=Tb({typed:a});return a("mod",{"number, number":Uf,"BigNumber, BigNumber":function(m,q){if(q.isNeg())throw Error("Cannot calculate mod for a negative divisor");return q.isZero()?m:m.mod(q)},"Fraction, Fraction":function(m,q){if(0>q.compare(0))throw Error("Cannot calculate mod for a negative divisor");return 0<=m.compare(0)?m.mod(q):m.mod(q).add(q).mod(q)},"SparseMatrix, SparseMatrix":function(m,q){return p(m,q,this,!1)},"SparseMatrix, DenseMatrix":function(m, -q){return h(q,m,this,!0)},"DenseMatrix, SparseMatrix":function(m,q){return l(m,q,this,!1)},"DenseMatrix, DenseMatrix":function(m,q){return g(m,q,this)},"Array, Array":function(m,q){return this(d(m),d(q)).valueOf()},"Array, Matrix":function(m,q){return this(d(m),q)},"Matrix, Array":function(m,q){return this(m,d(q))},"SparseMatrix, any":function(m,q){return k(m,q,this,!1)},"DenseMatrix, any":function(m,q){return e(m,q,this,!1)},"any, SparseMatrix":function(m,q){return n(q,m,this,!0)},"any, DenseMatrix":function(m, -q){return e(q,m,this,!0)},"Array, any":function(m,q){return e(d(m),q,this,!1).valueOf()},"any, Array":function(m,q){return e(d(q),m,this,!0).valueOf()}})}),Me=B("algorithm06",["typed","equalScalar"],b=>{var {typed:a,equalScalar:d}=b;return function(c,f,h){var l=c._values,p=c._size,k=c._datatype,n=f._values,g=f._size,e=f._datatype;if(p.length!==g.length)throw new yb(p.length,g.length);if(p[0]!==g[0]||p[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+g+")"); -var m;g=p[0];p=p[1];var q=d,r=0,u=h;"string"==typeof k&&k===e&&(m=k,q=a.find(d,[m,m]),r=a.convert(0,m),u=a.find(h,[m,m]));h=l&&n?[]:void 0;l=[];k=[];n=h?[]:void 0;e=[];for(var y=[],v=0;v{function a(m,q){var r=h.precision,u=h.clone({precision:r+2}),y=new h(0),v=new u(1),t=q.isNegative();if(t&&(q=q.neg()),q.isZero())throw Error("Root must be non-zero");if(m.isNegative()&&!q.abs().mod(2).equals(1))throw Error("Root must be odd when a is negative.");if(m.isZero())return t?new u(1/0):0;if(!m.isFinite())return t?y:m;q=m.abs().pow(v.div(q));return q=m.isNeg()?q.neg():q,new h((t?v.div(q):q).toPrecision(r))} -var {typed:d,matrix:c,equalScalar:f,BigNumber:h}=b,l=Cd({typed:d}),p=bd({typed:d,equalScalar:f}),k=Me({typed:d,equalScalar:f}),n=Fc({typed:d,equalScalar:f}),g=fc({typed:d}),e=Tb({typed:d});return d("nthRoot",{number:function(m){return af(m,2)},"number, number":af,BigNumber:function(m){return a(m,new h(2))},Complex:function(m){throw Error("Complex number not supported in function nthRoot. Use nthRoots instead.");},"Complex, number":function(m,q){throw Error("Complex number not supported in function nthRoot. Use nthRoots instead."); -},"BigNumber, BigNumber":a,"Array | Matrix":function(m){return this(m,2)},"SparseMatrix, SparseMatrix":function(m,q){if(1===q.density())return k(m,q,this);throw Error("Root must be non-zero");},"SparseMatrix, DenseMatrix":function(m,q){return p(q,m,this,!0)},"DenseMatrix, SparseMatrix":function(m,q){if(1===q.density())return l(m,q,this,!1);throw Error("Root must be non-zero");},"DenseMatrix, DenseMatrix":function(m,q){return g(m,q,this)},"Array, Array":function(m,q){return this(c(m),c(q)).valueOf()}, -"Array, Matrix":function(m,q){return this(c(m),q)},"Matrix, Array":function(m,q){return this(m,c(q))},"SparseMatrix, number | BigNumber":function(m,q){return n(m,q,this,!1)},"DenseMatrix, number | BigNumber":function(m,q){return e(m,q,this,!1)},"number | BigNumber, SparseMatrix":function(m,q){if(1===q.density())return n(q,m,this,!0);throw Error("Root must be non-zero");},"number | BigNumber, DenseMatrix":function(m,q){return e(q,m,this,!0)},"Array, number | BigNumber":function(m,q){return this(c(m), -q).valueOf()},"number | BigNumber, Array":function(m,q){return this(m,c(q)).valueOf()}})}),Lm=B("xgcd",["typed","config","matrix","BigNumber"],b=>{var {typed:a,config:d,matrix:c,BigNumber:f}=b;return a("xgcd",{"number, number":function(h,l){h=Xf(h,l);return"Array"===d.matrix?h:c(h)},"BigNumber, BigNumber":function(h,l){var p,k=new f(0);var n=new f(1);var g=k,e=n,m=n,q=k;if(!h.isInt()||!l.isInt())throw Error("Parameters in function xgcd must be integer numbers");for(;!l.isZero();){n=h.div(l).floor(); -var r=h.mod(l);h=g;g=e.minus(n.times(g));e=h;h=m;m=q.minus(n.times(m));q=h;h=l;l=r}return p=h.lt(k)?[h.neg(),e.neg(),q.neg()]:[h,h.isZero()?0:e,q],"Array"===d.matrix?p:c(p)}})}),Mm=B("bitAnd",["typed","matrix","equalScalar"],b=>{var {typed:a,matrix:d,equalScalar:c}=b,f=bd({typed:a,equalScalar:c}),h=Me({typed:a,equalScalar:c}),l=Fc({typed:a,equalScalar:c}),p=fc({typed:a}),k=Tb({typed:a});return a("bitAnd",{"number, number":Zf,"BigNumber, BigNumber":zi,"SparseMatrix, SparseMatrix":function(n,g){return h(n, -g,this,!1)},"SparseMatrix, DenseMatrix":function(n,g){return f(g,n,this,!0)},"DenseMatrix, SparseMatrix":function(n,g){return f(n,g,this,!1)},"DenseMatrix, DenseMatrix":function(n,g){return p(n,g,this)},"Array, Array":function(n,g){return this(d(n),d(g)).valueOf()},"Array, Matrix":function(n,g){return this(d(n),g)},"Matrix, Array":function(n,g){return this(n,d(g))},"SparseMatrix, any":function(n,g){return l(n,g,this,!1)},"DenseMatrix, any":function(n,g){return k(n,g,this,!1)},"any, SparseMatrix":function(n, -g){return l(g,n,this,!0)},"any, DenseMatrix":function(n,g){return k(g,n,this,!0)},"Array, any":function(n,g){return k(d(n),g,this,!1).valueOf()},"any, Array":function(n,g){return k(d(g),n,this,!0).valueOf()}})}),kd=B("algorithm07",["typed","DenseMatrix"],b=>{function a(f,h,l,p,k){var n=f._values,g=f._index,e=f._ptr;f=e[h];for(h=e[h+1];f{var {typed:a, -matrix:d,DenseMatrix:c}=b,f=Nc({typed:a}),h=kd({typed:a,DenseMatrix:c}),l=Oc({typed:a,DenseMatrix:c}),p=fc({typed:a}),k=Tb({typed:a});return a("bitXor",{"number, number":bg,"BigNumber, BigNumber":Bi,"SparseMatrix, SparseMatrix":function(n,g){return h(n,g,this)},"SparseMatrix, DenseMatrix":function(n,g){return f(g,n,this,!0)},"DenseMatrix, SparseMatrix":function(n,g){return f(n,g,this,!1)},"DenseMatrix, DenseMatrix":function(n,g){return p(n,g,this)},"Array, Array":function(n,g){return this(d(n),d(g)).valueOf()}, -"Array, Matrix":function(n,g){return this(d(n),g)},"Matrix, Array":function(n,g){return this(n,d(g))},"SparseMatrix, any":function(n,g){return l(n,g,this,!1)},"DenseMatrix, any":function(n,g){return k(n,g,this,!1)},"any, SparseMatrix":function(n,g){return l(g,n,this,!0)},"any, DenseMatrix":function(n,g){return k(g,n,this,!0)},"Array, any":function(n,g){return k(d(n),g,this,!1).valueOf()},"any, Array":function(n,g){return k(d(g),n,this,!0).valueOf()}})}),Om=B("or",["typed","matrix","equalScalar","DenseMatrix"], -b=>{var {typed:a,matrix:d,equalScalar:c,DenseMatrix:f}=b,h=Nc({typed:a}),l=Le({typed:a,equalScalar:c}),p=Oc({typed:a,DenseMatrix:f}),k=fc({typed:a}),n=Tb({typed:a});return a("or",{"number, number":gg,"Complex, Complex":function(g,e){return 0!==g.re||0!==g.im||0!==e.re||0!==e.im},"BigNumber, BigNumber":function(g,e){return!g.isZero()&&!g.isNaN()||!e.isZero()&&!e.isNaN()},"Unit, Unit":function(g,e){return this(g.value||0,e.value||0)},"SparseMatrix, SparseMatrix":function(g,e){return l(g,e,this)},"SparseMatrix, DenseMatrix":function(g, -e){return h(e,g,this,!0)},"DenseMatrix, SparseMatrix":function(g,e){return h(g,e,this,!1)},"DenseMatrix, DenseMatrix":function(g,e){return k(g,e,this)},"Array, Array":function(g,e){return this(d(g),d(e)).valueOf()},"Array, Matrix":function(g,e){return this(d(g),e)},"Matrix, Array":function(g,e){return this(g,d(e))},"SparseMatrix, any":function(g,e){return p(g,e,this,!1)},"DenseMatrix, any":function(g,e){return n(g,e,this,!1)},"any, SparseMatrix":function(g,e){return p(e,g,this,!0)},"any, DenseMatrix":function(g, -e){return n(e,g,this,!0)},"Array, any":function(g,e){return n(d(g),e,this,!1).valueOf()},"any, Array":function(g,e){return n(d(e),g,this,!0).valueOf()}})}),Pm=B("diag",["typed","matrix","DenseMatrix","SparseMatrix"],b=>{function a(l,p,k,n){if(!Za(p))throw new TypeError("Second parameter in function diag must be an integer");var g=0p?-p:0;switch(k.length){case 1:return function(m,q,r,u,y,v){u=[u+y,u+v];if(r&&"sparse"!==r&&"dense"!==r)throw new TypeError("Unknown matrix type ".concat(r,'"')); -m="sparse"===r?h.diagonal(u,m,q):f.diagonal(u,m,q);return null!==r?m:m.valueOf()}(l,p,n,k[0],e,g);case 2:return function(m,q,r,u,y,v){if(Fa(m))return m=m.diagonal(q),null!==r?r!==m.storage()?c(m,r):m:m.valueOf();q=Math.min(u[0]-y,u[1]-v);u=[];for(var t=0;t{function a(n,g){switch(n.length){case 0:return g?h(g):[];case 1:return d(n[0],n[0],g);case 2:return d(n[0],n[1],g);default:throw Error("Vector containing two values expected");}}function d(n, -g,e){var m=pa(n)||pa(g)?l:null;if(pa(n)&&(n=n.toNumber()),pa(g)&&(g=g.toNumber()),!Za(n)||1>n)throw Error("Parameters in function identity must be positive integers");if(!Za(g)||1>g)throw Error("Parameters in function identity must be positive integers");var q=m?new l(1):1;m=m?new m(0):0;var r=[n,g];if(e){if("sparse"===e)return k.diagonal(r,q,0,m);if("dense"===e)return p.diagonal(r,q,0,m);throw new TypeError('Unknown matrix type "'.concat(e,'"'));}e=gd([],r,m);n=n{function a(l,p){var k=function(n){var g=!1;return n.forEach(function(e,m,q){pa(e)&&(g=!0,q[m]=e.toNumber())}),g}(l)?new h(1):1;if(function(n){n.forEach(function(g){if("number"!=typeof g||!Za(g)||0>g)throw Error("Parameters in function ones must be positive integers"); -})}(l),p)return p=f(p),0{var {typed:a,isInteger:d}=b;return a("reshape",{"Matrix, Array":function(c,f){return c.reshape(f)},"Array, Array":function(c,f){return f.forEach(function(h){if(!d(h))throw new TypeError("Invalid size for dimension: "+h);}),Zd(c,f)}})}),Tm=B("size",["typed","config","?matrix"],b=>{var {typed:a,config:d,matrix:c}=b;return a("size",{Matrix:function(f){return f.create(f.size())},Array:Ua,string:function(f){return"Array"===d.matrix?[f.length]:c([f.length])}, -"number | Complex | BigNumber | Unit | boolean | null":function(f){return"Array"===d.matrix?[]:c?c([]):me()}})}),Um=B("zeros",["typed","config","matrix","BigNumber"],b=>{function a(l,p){var k=function(n){var g=!1;return n.forEach(function(e,m,q){pa(e)&&(g=!0,q[m]=e.toNumber())}),g}(l)?new h(0):0;if(function(n){n.forEach(function(g){if("number"!=typeof g||!Za(g)||0>g)throw Error("Parameters in function zeros must be positive integers");})}(l),p)return p=f(p),0{var {typed:a,format:d}=b;return a("hex", -{"number | BigNumber":function(c){return d(c,{notation:"hex"})},"number | BigNumber, number":function(c,f){return d(c,{notation:"hex",wordSize:f})}})}),Xm=B("round","typed matrix equalScalar zeros BigNumber DenseMatrix".split(" "),b=>{var {typed:a,matrix:d,equalScalar:c,zeros:f,BigNumber:h,DenseMatrix:l}=b,p=Fc({typed:a,equalScalar:c}),k=Oc({typed:a,DenseMatrix:l}),n=Tb({typed:a});return a("round",Fg(Fg({},Wm),{},{Complex:function(g){return g.round()},"Complex, number":function(g,e){if(e%1)throw new TypeError("Number of decimals in function round must be an integer"); -return g.round(e)},"Complex, BigNumber":function(g,e){if(!e.isInteger())throw new TypeError("Number of decimals in function round must be an integer");e=e.toNumber();return g.round(e)},"number, BigNumber":function(g,e){if(!e.isInteger())throw new TypeError("Number of decimals in function round must be an integer");return(new h(g)).toDecimalPlaces(e.toNumber())},BigNumber:function(g){return g.toDecimalPlaces(0)},"BigNumber, BigNumber":function(g,e){if(!e.isInteger())throw new TypeError("Number of decimals in function round must be an integer"); -return g.toDecimalPlaces(e.toNumber())},Fraction:function(g){return g.round()},"Fraction, number":function(g,e){if(e%1)throw new TypeError("Number of decimals in function round must be an integer");return g.round(e)},"Array | Matrix":function(g){return Na(g,this,!0)},"SparseMatrix, number | BigNumber":function(g,e){return p(g,e,this,!1)},"DenseMatrix, number | BigNumber":function(g,e){return n(g,e,this,!1)},"number | Complex | BigNumber, SparseMatrix":function(g,e){return c(g,0)?f(e.size(),e.storage()): -k(e,g,this,!0)},"number | Complex | BigNumber, DenseMatrix":function(g,e){return c(g,0)?f(e.size(),e.storage()):n(e,g,this,!0)},"Array, number | BigNumber":function(g,e){return n(d(g),e,this,!1).valueOf()},"number | Complex | BigNumber, Array":function(g,e){return n(d(e),g,this,!0).valueOf()}}))}),Wm={number:bf,"number, number":function(b,a){if(!Za(a))throw new TypeError("Number of decimals in function round must be an integer");if(0>a||15{var {typed:a,equalScalar:d}=b;return function(c,f,h){var l=c._values,p=c._index,k=c._ptr,n=c._size,g=c._datatype,e=f._values,m=f._index,q=f._ptr,r=f._size,u=f._datatype;if(n.length!==r.length)throw new yb(n.length,r.length);if(n[0]!==r[0]||n[1]!==r[1])throw new RangeError("Dimension mismatch. Matrix A ("+n+") must match Matrix B ("+r+")");if(!l||!e)throw Error("Cannot perform operation on Pattern Sparse Matrices");var y;r=n[0];n=n[1]; -f=d;var v=0,t=h;"string"==typeof g&&g===u&&(y=g,f=a.find(d,[y,y]),v=a.convert(0,y),t=a.find(h,[y,y]));var w,z;h=[];g=[];u=[];for(var I=[],F=[],L=0;L{var {typed:a,matrix:d,equalScalar:c,zeros:f,DenseMatrix:h}=b,l=Cd({typed:a}),p=bd({typed:a,equalScalar:c}),k=kf({typed:a,equalScalar:c}),n=Qd({typed:a,DenseMatrix:h}),g=Fc({typed:a,equalScalar:c}),e=fc({typed:a}),m=Tb({typed:a});return a("leftShift",{"number, number":cg,"BigNumber, BigNumber":Ci,"SparseMatrix, SparseMatrix":function(q,r){return k(q,r,this,!1)},"SparseMatrix, DenseMatrix":function(q,r){return p(r,q,this,!0)},"DenseMatrix, SparseMatrix":function(q, -r){return l(q,r,this,!1)},"DenseMatrix, DenseMatrix":function(q,r){return e(q,r,this)},"Array, Array":function(q,r){return this(d(q),d(r)).valueOf()},"Array, Matrix":function(q,r){return this(d(q),r)},"Matrix, Array":function(q,r){return this(q,d(r))},"SparseMatrix, number | BigNumber":function(q,r){return c(r,0)?q.clone():g(q,r,this,!1)},"DenseMatrix, number | BigNumber":function(q,r){return c(r,0)?q.clone():m(q,r,this,!1)},"number | BigNumber, SparseMatrix":function(q,r){return c(q,0)?f(r.size(), -r.storage()):n(r,q,this,!0)},"number | BigNumber, DenseMatrix":function(q,r){return c(q,0)?f(r.size(),r.storage()):m(r,q,this,!0)},"Array, number | BigNumber":function(q,r){return this(d(q),r).valueOf()},"number | BigNumber, Array":function(q,r){return this(q,d(r)).valueOf()}})}),Zm=B("rightLogShift",["typed","matrix","equalScalar","zeros","DenseMatrix"],b=>{var {typed:a,matrix:d,equalScalar:c,zeros:f,DenseMatrix:h}=b,l=Cd({typed:a}),p=bd({typed:a,equalScalar:c}),k=kf({typed:a,equalScalar:c}),n=Qd({typed:a, -DenseMatrix:h}),g=Fc({typed:a,equalScalar:c}),e=fc({typed:a}),m=Tb({typed:a});return a("rightLogShift",{"number, number":eg,"SparseMatrix, SparseMatrix":function(q,r){return k(q,r,this,!1)},"SparseMatrix, DenseMatrix":function(q,r){return p(r,q,this,!0)},"DenseMatrix, SparseMatrix":function(q,r){return l(q,r,this,!1)},"DenseMatrix, DenseMatrix":function(q,r){return e(q,r,this)},"Array, Array":function(q,r){return this(d(q),d(r)).valueOf()},"Array, Matrix":function(q,r){return this(d(q),r)},"Matrix, Array":function(q, -r){return this(q,d(r))},"SparseMatrix, number | BigNumber":function(q,r){return c(r,0)?q.clone():g(q,r,this,!1)},"DenseMatrix, number | BigNumber":function(q,r){return c(r,0)?q.clone():m(q,r,this,!1)},"number | BigNumber, SparseMatrix":function(q,r){return c(q,0)?f(r.size(),r.storage()):n(r,q,this,!0)},"number | BigNumber, DenseMatrix":function(q,r){return c(q,0)?f(r.size(),r.storage()):m(r,q,this,!0)},"Array, number | BigNumber":function(q,r){return this(d(q),r).valueOf()},"number | BigNumber, Array":function(q, -r){return this(q,d(r)).valueOf()}})}),$m=B("compare","typed config matrix equalScalar BigNumber Fraction DenseMatrix".split(" "),b=>{var {typed:a,config:d,equalScalar:c,matrix:f,BigNumber:h,Fraction:l,DenseMatrix:p}=b,k=Nc({typed:a}),n=Le({typed:a,equalScalar:c}),g=Oc({typed:a,DenseMatrix:p}),e=fc({typed:a}),m=Tb({typed:a});return a("compare",{"boolean, boolean":function(q,r){return q===r?0:q>r?1:-1},"number, number":function(q,r){return Ec(q,r,d.epsilon)?0:q>r?1:-1},"BigNumber, BigNumber":function(q, -r){return jd(q,r,d.epsilon)?new h(0):new h(q.cmp(r))},"Fraction, Fraction":function(q,r){return new l(q.compare(r))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers");},"Unit, Unit":function(q,r){if(!q.equalBase(r))throw Error("Cannot compare units with different base");return this(q.value,r.value)},"SparseMatrix, SparseMatrix":function(q,r){return n(q,r,this)},"SparseMatrix, DenseMatrix":function(q,r){return k(r,q,this,!0)},"DenseMatrix, SparseMatrix":function(q, -r){return k(q,r,this,!1)},"DenseMatrix, DenseMatrix":function(q,r){return e(q,r,this)},"Array, Array":function(q,r){return this(f(q),f(r)).valueOf()},"Array, Matrix":function(q,r){return this(f(q),r)},"Matrix, Array":function(q,r){return this(q,f(r))},"SparseMatrix, any":function(q,r){return g(q,r,this,!1)},"DenseMatrix, any":function(q,r){return m(q,r,this,!1)},"any, SparseMatrix":function(q,r){return g(r,q,this,!0)},"any, DenseMatrix":function(q,r){return m(r,q,this,!0)},"Array, any":function(q, -r){return m(f(q),r,this,!1).valueOf()},"any, Array":function(q,r){return m(f(r),q,this,!0).valueOf()}})}),an=B("compareText",["typed","matrix"],b=>{var {typed:a,matrix:d}=b,c=fc({typed:a}),f=Tb({typed:a});return a("compareText",{"any, any":wc,"DenseMatrix, DenseMatrix":function(h,l){return c(h,l,wc)},"Array, Array":function(h,l){return this(d(h),d(l)).valueOf()},"Array, Matrix":function(h,l){return this(d(h),l)},"Matrix, Array":function(h,l){return this(h,d(l))},"DenseMatrix, any":function(h,l){return f(h, -l,wc,!1)},"any, DenseMatrix":function(h,l){return f(l,h,wc,!0)},"Array, any":function(h,l){return f(d(h),l,wc,!1).valueOf()},"any, Array":function(h,l){return f(d(l),h,wc,!0).valueOf()}})}),bn=B("smaller",["typed","config","matrix","DenseMatrix"],b=>{var {typed:a,config:d,matrix:c,DenseMatrix:f}=b,h=Nc({typed:a}),l=kd({typed:a,DenseMatrix:f}),p=Oc({typed:a,DenseMatrix:f}),k=fc({typed:a}),n=Tb({typed:a});return a("smaller",{"boolean, boolean":function(g,e){return g{var {typed:a,config:d,matrix:c,DenseMatrix:f}=b,h=Nc({typed:a}),l=kd({typed:a,DenseMatrix:f}),p=Oc({typed:a,DenseMatrix:f}),k=fc({typed:a}),n=Tb({typed:a});return a("larger",{"boolean, boolean":function(g,e){return g>e},"number, number":function(g,e){return g>e&&!Ec(g,e,d.epsilon)},"BigNumber, BigNumber":function(g, -e){return g.gt(e)&&!jd(g,e,d.epsilon)},"Fraction, Fraction":function(g,e){return 1===g.compare(e)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers");},"Unit, Unit":function(g,e){if(!g.equalBase(e))throw Error("Cannot compare units with different base");return this(g.value,e.value)},"SparseMatrix, SparseMatrix":function(g,e){return l(g,e,this)},"SparseMatrix, DenseMatrix":function(g,e){return h(e,g,this,!0)},"DenseMatrix, SparseMatrix":function(g, -e){return h(g,e,this,!1)},"DenseMatrix, DenseMatrix":function(g,e){return k(g,e,this)},"Array, Array":function(g,e){return this(c(g),c(e)).valueOf()},"Array, Matrix":function(g,e){return this(c(g),e)},"Matrix, Array":function(g,e){return this(g,c(e))},"SparseMatrix, any":function(g,e){return p(g,e,this,!1)},"DenseMatrix, any":function(g,e){return n(g,e,this,!1)},"any, SparseMatrix":function(g,e){return p(e,g,this,!0)},"any, DenseMatrix":function(g,e){return n(e,g,this,!0)},"Array, any":function(g, -e){return n(c(g),e,this,!1).valueOf()},"any, Array":function(g,e){return n(c(e),g,this,!0).valueOf()}})}),dn=B("unequal",["typed","config","equalScalar","matrix","DenseMatrix"],b=>{function a(e,m){return!c(e,m)}var {typed:d,equalScalar:c,matrix:f,DenseMatrix:h}=b,l=Nc({typed:d}),p=kd({typed:d,DenseMatrix:h}),k=Oc({typed:d,DenseMatrix:h}),n=fc({typed:d}),g=Tb({typed:d});return d("unequal",{"any, any":function(e,m){return null===e?null!==m:null===m?null!==e:void 0===e?void 0!==m:void 0===m?void 0!== -e:!c(e,m)},"SparseMatrix, SparseMatrix":function(e,m){return p(e,m,a)},"SparseMatrix, DenseMatrix":function(e,m){return l(m,e,a,!0)},"DenseMatrix, SparseMatrix":function(e,m){return l(e,m,a,!1)},"DenseMatrix, DenseMatrix":function(e,m){return n(e,m,a)},"Array, Array":function(e,m){return this(f(e),f(m)).valueOf()},"Array, Matrix":function(e,m){return this(f(e),m)},"Matrix, Array":function(e,m){return this(e,f(m))},"SparseMatrix, any":function(e,m){return k(e,m,a,!1)},"DenseMatrix, any":function(e, -m){return g(e,m,a,!1)},"any, SparseMatrix":function(e,m){return k(m,e,a,!0)},"any, DenseMatrix":function(e,m){return g(m,e,a,!0)},"Array, any":function(e,m){return g(f(e),m,a,!1).valueOf()},"any, Array":function(e,m){return g(f(m),e,a,!0).valueOf()}})}),en=(B("unequal",["typed","equalScalar"],b=>{var {typed:a,equalScalar:d}=b;return a("unequal",{"any, any":function(c,f){return null===c?null!==f:null===f?null!==c:void 0===c?void 0!==f:void 0===f?void 0!==c:!d(c,f)}})}),B("ImmutableDenseMatrix",["smaller", -"DenseMatrix"],b=>{function a(f,h){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(h&&!Ia(h))throw Error("Invalid datatype: "+h);if(Fa(f)||$b(f))f=new c(f,h),this._data=f._data,this._size=f._size,this._datatype=f._datatype,this._max=this._min=null;else if(f&&$b(f.data)&&$b(f.size))this._data=f.data,this._size=f.size,this._datatype=f.datatype,this._min=void 0!==f.min?f.min:null,this._max=void 0!==f.max?f.max:null;else{if(f)throw new TypeError("Unsupported type of data ("+ -Wb(f)+")");this._data=[];this._size=[0];this._datatype=h;this._max=this._min=null}}var {smaller:d,DenseMatrix:c}=b;return a.prototype=new c,a.prototype.type="ImmutableDenseMatrix",a.prototype.isImmutableDenseMatrix=!0,a.prototype.subset=function(f){switch(arguments.length){case 1:var h=c.prototype.subset.call(this,f);return Fa(h)?new a({data:h._data,size:h._size,datatype:h._datatype}):h;case 2:case 3:throw Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments"); -}},a.prototype.set=function(){throw Error("Cannot invoke set on an Immutable Matrix instance");},a.prototype.resize=function(){throw Error("Cannot invoke resize on an Immutable Matrix instance");},a.prototype.reshape=function(){throw Error("Cannot invoke reshape on an Immutable Matrix instance");},a.prototype.clone=function(){return new a({data:nb(this._data),size:nb(this._size),datatype:this._datatype})},a.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size, -datatype:this._datatype}},a.fromJSON=function(f){return new a(f)},a.prototype.swapRows=function(){throw Error("Cannot invoke swapRows on an Immutable Matrix instance");},a.prototype.min=function(){if(null===this._min){var f=null;this.forEach(function(h){(null===f||d(h,f))&&(f=h)});this._min=null!==f?f:void 0}return this._min},a.prototype.max=function(){if(null===this._max){var f=null;this.forEach(function(h){(null===f||d(f,h))&&(f=h)});this._max=null!==f?f:void 0}return this._max},a},{isClass:!0})), -fn=B("FibonacciHeap",["smaller","larger"],b=>{function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null;this._size=0}function d(p,k,n){k.left.right=k.right;k.right.left=k.left;n.degree--;n.child===k&&(n.child=k.right);0===n.degree&&(n.child=null);k.left=p;k.right=p.right;p.right=k;k.right.left=k;k.parent=null;k.mark=!1}function c(p,k){var n=k.parent;n&&(k.mark?(d(p,k,n),c(n)):k.mark=!0)}var {smaller:f,larger:h}=b,l=1/Math.log((1+ -Math.sqrt(5))/2);a.prototype.type="FibonacciHeap";a.prototype.isFibonacciHeap=!0;a.prototype.insert=function(p,k){k={key:p,value:k,degree:0};if(this._minimum){var n=this._minimum;k.left=n;k.right=n.right;n.right=k;k.right.left=k;f(p,n.key)&&(this._minimum=k)}else k.left=k,this._minimum=k.right=k;return this._size++,k};a.prototype.size=function(){return this._size};a.prototype.clear=function(){this._minimum=null;this._size=0};a.prototype.isEmpty=function(){return 0===this._size};a.prototype.extractMinimum= -function(){var p=this._minimum;if(null===p)return p;for(var k=this._minimum,n=p.degree,g=p.child;0{var {typed:a,SparseMatrix:d}=b;return a("sparse",{"":function(){return new d([])},string:function(c){return new d([],c)},"Array | Matrix":function(c){return new d(c)},"Array | Matrix, string":function(c,f){return new d(c,f)}})}),hn=B("acoth",["typed","config","Complex","BigNumber"],b=>{var {typed:a,config:d,Complex:c,BigNumber:f}=b;return a("acoth", -{number:function(h){return 1<=h||-1>=h||d.predictable?mg(h):(new c(h,0)).acoth()},Complex:function(h){return h.acoth()},BigNumber:function(h){return(new f(1)).div(h).atanh()},"Array | Matrix":function(h){return Na(h,this)}})}),ih=B("algorithm09",["typed","equalScalar"],b=>{var {typed:a,equalScalar:d}=b;return function(c,f,h){var l=c._values,p=c._index,k=c._ptr,n=c._size,g=c._datatype,e=f._values,m=f._index,q=f._ptr,r=f._size,u=f._datatype;if(n.length!==r.length)throw new yb(n.length,r.length);if(n[0]!== -r[0]||n[1]!==r[1])throw new RangeError("Dimension mismatch. Matrix A ("+n+") must match Matrix B ("+r+")");var y;r=n[0];n=n[1];f=d;var v=0,t=h;"string"==typeof g&&g===u&&(y=g,f=a.find(d,[y,y]),v=a.convert(0,y),t=a.find(h,[y,y]));var w;u=l&&e?[]:void 0;var z=[],I=[],F=u?[]:void 0,L=[];for(h=0;h{var {typed:a,matrix:d,equalScalar:c,BigNumber:f,DenseMatrix:h}=b,l=bd({typed:a,equalScalar:c}),p=Nc({typed:a}),k=ih({typed:a,equalScalar:c}),n=Fc({typed:a,equalScalar:c}),g=Oc({typed:a,DenseMatrix:h}),e=fc({typed:a}),m=Tb({typed:a});return a("atan2",{"number, number":Math.atan2,"BigNumber, BigNumber":function(q,r){return f.atan2(q,r)},"SparseMatrix, SparseMatrix":function(q, -r){return k(q,r,this,!1)},"SparseMatrix, DenseMatrix":function(q,r){return l(r,q,this,!0)},"DenseMatrix, SparseMatrix":function(q,r){return p(q,r,this,!1)},"DenseMatrix, DenseMatrix":function(q,r){return e(q,r,this)},"Array, Array":function(q,r){return this(d(q),d(r)).valueOf()},"Array, Matrix":function(q,r){return this(d(q),r)},"Matrix, Array":function(q,r){return this(q,d(r))},"SparseMatrix, number | BigNumber":function(q,r){return n(q,r,this,!1)},"DenseMatrix, number | BigNumber":function(q,r){return m(q, -r,this,!1)},"number | BigNumber, SparseMatrix":function(q,r){return g(r,q,this,!0)},"number | BigNumber, DenseMatrix":function(q,r){return m(r,q,this,!0)},"Array, number | BigNumber":function(q,r){return m(d(q),r,this,!1).valueOf()},"number | BigNumber, Array":function(q,r){return m(d(r),q,this,!0).valueOf()}})}),kn=B("sec",["typed","BigNumber"],b=>{var {typed:a,BigNumber:d}=b;return a("sec",{number:wg,Complex:function(c){return c.sec()},BigNumber:function(c){return(new d(1)).div(c.cos())},Unit:function(c){if(!c.hasBase(c.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle"); -return this(c.value)},"Array | Matrix":function(c){return Na(c,this)}})}),ln=B("add","typed matrix addScalar equalScalar DenseMatrix SparseMatrix".split(" "),b=>{var {typed:a,matrix:d,addScalar:c,equalScalar:f,DenseMatrix:h}=b,l=Cd({typed:a}),p=jf({typed:a,equalScalar:f}),k=Qd({typed:a,DenseMatrix:h}),n=fc({typed:a}),g=Tb({typed:a});return a("add",xd({"DenseMatrix, DenseMatrix":function(e,m){return n(e,m,c)},"DenseMatrix, SparseMatrix":function(e,m){return l(e,m,c,!1)},"SparseMatrix, DenseMatrix":function(e, -m){return l(m,e,c,!0)},"SparseMatrix, SparseMatrix":function(e,m){return p(e,m,c)},"Array, Array":function(e,m){return this(d(e),d(m)).valueOf()},"Array, Matrix":function(e,m){return this(d(e),m)},"Matrix, Array":function(e,m){return this(e,d(m))},"DenseMatrix, any":function(e,m){return g(e,m,c,!1)},"SparseMatrix, any":function(e,m){return k(e,m,c,!1)},"any, DenseMatrix":function(e,m){return g(m,e,c,!0)},"any, SparseMatrix":function(e,m){return k(m,e,c,!0)},"Array, any":function(e,m){return g(d(e), -m,c,!1).valueOf()},"any, Array":function(e,m){return g(d(m),e,c,!0).valueOf()},"any, any":c,"any, any, ...any":function(e,m,q){e=this(e,m);for(m=0;m{function a(k,n){k=d(k);var g=d(n);if(1!==k.length&&(2!==k.length||1!==k[1]))throw new RangeError("Expected a column vector, instead got a matrix of size ("+k.join(", ")+")");n=k[0];if(1!==g.length&&(2!==g.length||1!==g[1]))throw new RangeError("Expected a column vector, instead got a matrix of size ("+ -g.join(", ")+")");k=g[0];if(n!==k)throw new RangeError("Vectors must have equal length ("+n+" != "+k+")");if(0===n)throw new RangeError("Cannot calculate the dot product of empty vectors");return n}function d(k){return Fa(k)?k.size():p(k)}var {typed:c,addScalar:f,multiplyScalar:h,conj:l,size:p}=b;return c("dot",{"Array | DenseMatrix, Array | DenseMatrix":function(k,n){var g=a(k,n),e=Fa(k)?k._data:k,m=Fa(k)?k._datatype:void 0,q=Fa(n)?n._data:n,r=Fa(n)?n._datatype:void 0,u=2===d(k).length,y=2===d(n).length; -n=f;k=h;m&&r&&m===r&&"string"==typeof m&&(n=c.find(f,[m,m]),k=c.find(h,[m,m]));if(!u&&!y){m=k(l(e[0]),q[0]);for(r=1;ry?r++:u===y&&(m=f(m,h(k[q],n[r])),q++,r++)}return m}})}),nn=B("composition","typed addScalar combinations isNegative isPositive isInteger larger".split(" "),b=>{var {typed:a,addScalar:d,combinations:c,isPositive:f,isInteger:h,larger:l}=b;return a("composition",{"number | BigNumber, number | BigNumber":function(p,k){if(!(h(p)&&f(p)&&h(k)&&f(k)))throw new TypeError("Positive integer value expected in function composition"); -if(l(k,p))throw new TypeError("k must be less than or equal to n in function composition");return c(d(p,-1),d(k,-1))}})}),on=B("isZero",["typed"],b=>{({typed:b}=b);return b("isZero",{number:Ff,BigNumber:function(a){return a.isZero()},Complex:function(a){return 0===a.re&&0===a.im},Fraction:function(a){return 1===a.d&&0===a.n},Unit:function(a){return this(a.value)},"Array | Matrix":function(a){return Na(a,this)}})}),pn=B("matrixFromFunction",["typed","matrix","isZero"],b=>{function a(h,l,p,k){var n; -return(n=void 0!==k?c(p,k):c(p)).resize(h),n.forEach(function(g,e){g=l(e);f(g)||n.set(e,g)}),n}var {typed:d,matrix:c,isZero:f}=b;return d("matrixFromFunction",{"Array | Matrix, function, string, string":function(h,l,p,k){return a(h,l,p,k)},"Array | Matrix, function, string":function(h,l,p){return a(h,l,p)},"Matrix, function":function(h,l){return a(h,l,"dense")},"Array, function":function(h,l){return a(h,l,"dense").toArray()},"Array | Matrix, string, function":function(h,l,p){return a(h,p,l)},"Array | Matrix, string, string, function":function(h, -l,p,k){return a(h,k,l,p)}})}),qn=B("cbrt","config typed isNegative unaryMinus matrix Complex BigNumber Fraction".split(" "),b=>{function a(g,e){var m=g.arg()/3;g=g.abs();var q=(new p(Ie(g),0)).mul((new p(0,m)).exp());return e?(e=[q,(new p(Ie(g),0)).mul((new p(0,m+2*Math.PI/3)).exp()),(new p(Ie(g),0)).mul((new p(0,m-2*Math.PI/3)).exp())],"Array"===d.matrix?e:l(e)):q}var {config:d,typed:c,isNegative:f,unaryMinus:h,matrix:l,Complex:p,BigNumber:k,Fraction:n}=b;return c("cbrt",{number:Mf,Complex:a,"Complex, boolean":a, -BigNumber:function(g){return g.cbrt()},Unit:function(g){if(g.value&&rb(g.value)){var e=g.clone();return e.value=1,(e=e.pow(1/3)).value=a(g.value),e}(e=f(g.value))&&(g.value=h(g.value));var m=pa(g.value)?(new k(1)).div(3):Ob(g.value)?new n(1,3):1/3;g=g.pow(m);return e&&(g.value=h(g.value)),g},"Array | Matrix":function(g){return Na(g,this,!0)}})}),rn=B("floor",["typed","config","round","matrix","equalScalar"],b=>{var {typed:a,config:d,round:c,matrix:f,equalScalar:h}=b,l=Fc({typed:a,equalScalar:h}), -p=Tb({typed:a});return a("floor",{number:function(k){return Ec(k,c(k),d.epsilon)?c(k):Math.floor(k)},"number, number":function(k,n){if(Ec(k,c(k,n),d.epsilon))return c(k,n);var [g,e]="".concat(k,"e").split("e");k=Math.floor(Number("".concat(g,"e").concat(Number(e)+n)));k="".concat(k,"e").split("e");[g,e]=k;return Number("".concat(g,"e").concat(Number(e)-n))},Complex:function(k){return k.floor()},"Complex, number":function(k,n){return k.floor(n)},BigNumber:function(k){return jd(k,c(k),d.epsilon)?c(k): -k.floor()},"BigNumber, BigNumber":function(k,n){return jd(k,c(k,n),d.epsilon)?c(k,n):k.toDecimalPlaces(n.toNumber(),hf.ROUND_FLOOR)},Fraction:function(k){return k.floor()},"Fraction, number":function(k,n){return k.floor(n)},"Array | Matrix":function(k){return Na(k,this,!0)},"Array | Matrix, number":function(k,n){return Na(k,g=>this(g,n),!0)},"SparseMatrix, number | BigNumber":function(k,n){return l(k,n,this,!1)},"DenseMatrix, number | BigNumber":function(k,n){return p(k,n,this,!1)},"number | Complex | BigNumber, Array":function(k, -n){return p(f(n),k,this,!0).valueOf()}})}),sn=B("multiply","typed matrix addScalar multiplyScalar equalScalar dot".split(" "),b=>{function a(m,q){switch(m.length){case 1:switch(q.length){case 1:if(m[0]!==q[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(m[0]!==q[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+m[0]+") must match Matrix rows ("+q[0]+")");break;default:throw Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+ -q.length+" dimensions)");}break;case 2:switch(q.length){case 1:if(m[1]!==q[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+m[1]+") must match Vector length ("+q[0]+")");break;case 2:if(m[1]!==q[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+m[1]+") must match Matrix B rows ("+q[0]+")");break;default:throw Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+q.length+" dimensions)");}break;default:throw Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+ -m.length+" dimensions)");}}var {typed:d,matrix:c,addScalar:f,multiplyScalar:h,equalScalar:l,dot:p}=b,k=Fc({typed:d,equalScalar:l}),n=Tb({typed:d}),g=d("_multiplyMatrixVector",{"DenseMatrix, any":function(m,q){var r,u=m._data,y=m._size,v=m._datatype,t=q._data,w=q._datatype;q=y[0];y=y[1];var z=f,I=h;v&&w&&v===w&&"string"==typeof v&&(r=v,z=d.find(f,[r,r]),I=d.find(h,[r,r]));v=[];for(w=0;wca)for(var Ea=0,Ga=0;Ga{var {typed:a,matrix:d,equalScalar:c,multiplyScalar:f}=b,h=bd({typed:a,equalScalar:c}),l=ih({typed:a,equalScalar:c}),p=Fc({typed:a,equalScalar:c}),k=fc({typed:a}),n=Tb({typed:a});return a("dotMultiply",{"any, any":f,"SparseMatrix, SparseMatrix":function(g,e){return l(g,e,f,!1)},"SparseMatrix, DenseMatrix":function(g, -e){return h(e,g,f,!0)},"DenseMatrix, SparseMatrix":function(g,e){return h(g,e,f,!1)},"DenseMatrix, DenseMatrix":function(g,e){return k(g,e,f)},"Array, Array":function(g,e){return this(d(g),d(e)).valueOf()},"Array, Matrix":function(g,e){return this(d(g),e)},"Matrix, Array":function(g,e){return this(g,d(e))},"SparseMatrix, any":function(g,e){return p(g,e,f,!1)},"DenseMatrix, any":function(g,e){return n(g,e,f,!1)},"any, SparseMatrix":function(g,e){return p(e,g,f,!0)},"any, DenseMatrix":function(g,e){return n(e, -g,f,!0)},"Array, any":function(g,e){return n(d(g),e,f,!1).valueOf()},"any, Array":function(g,e){return n(d(e),g,f,!0).valueOf()}})}),un=B("re",["typed"],b=>{({typed:b}=b);return b("re",{number:function(a){return a},BigNumber:function(a){return a},Fraction:function(a){return a},Complex:function(a){return a.re},"Array | Matrix":function(a){return Na(a,this)}})}),vn=B("flatten",["typed","matrix"],b=>{var {typed:a,matrix:d}=b;return a("flatten",{Array:function(c){return C(nb(c))},Matrix:function(c){c= -C(nb(c.toArray()));return d(c)}})});be.prototype=Error();be.prototype.constructor=Error;be.prototype.name="ArgumentsError";be.prototype.isArgumentsError=!0;var wn=B("resize",["config","matrix"],b=>{function a(f,h,l){if(void 0!==l){if("string"!=typeof l||1!==l.length)throw new TypeError("Single character expected as defaultValue");}else l=" ";if(1!==h.length)throw new yb(h.length,1);var p=h[0];if("number"!=typeof p||!Za(p))throw new TypeError("Invalid size, must contain positive integers (size: "+ -Db(h)+")");if(f.length>p)return f.substring(0,p);if(f.length{var {typed:a,matrix:d}=b;return a("squeeze",{Array:function(c){return Ba(nb(c))},Matrix:function(c){c=Ba(c.toArray());return Array.isArray(c)?d(c):c},any:function(c){return nb(c)}})}),yn=B("to",["typed","matrix"],b=>{var {typed:a,matrix:d}=b,c=fc({typed:a}),f=Tb({typed:a});return a("to",{"Unit, Unit | string":function(h,l){return h.to(l)},"Matrix, Matrix":function(h,l){return c(h, -l,this)},"Array, Array":function(h,l){return this(d(h),d(l)).valueOf()},"Array, Matrix":function(h,l){return this(d(h),l)},"Matrix, Array":function(h,l){return this(h,d(l))},"Matrix, any":function(h,l){return f(h,l,this,!1)},"any, Matrix":function(h,l){return f(l,h,this,!0)},"Array, any":function(h,l){return f(d(h),l,this,!1).valueOf()},"any, Array":function(h,l){return f(d(l),h,this,!0).valueOf()}})}),zn=B("pow","typed config identity multiply matrix fraction number Complex".split(" "),b=>{function a(m, -q){if(h.predictable&&!Za(q)&&0>m)try{var r=g(q),u=n(r);if((q===u||1E-14>Math.abs((q-u)/q))&&1==r.d%2)return(0==r.n%2?1:-1)*Math.pow(-m,q)}catch(y){}return h.predictable&&(-1>m&&q===1/0||-1m&&q===-1/0)?NaN:Za(q)||0<=m||h.predictable?Yf(m,q):1>m*m&&q===1/0||1q)throw new TypeError("For A^b, b must be a positive integer (value is "+q+")");var r=Ua(m);if(2!==r.length)throw Error("For A^b, A must be 2 dimensional (A has "+r.length+ -" dimensions)");if(r[0]!==r[1])throw Error("For A^b, A must be square (size is "+r[0]+"x"+r[1]+")");for(r=l(r[0]).valueOf();1<=q;)1==(1&q)&&(r=p(m,r)),q>>=1,m=p(m,m);return r}function c(m,q){return k(d(m.valueOf(),q))}var {typed:f,config:h,identity:l,multiply:p,matrix:k,number:n,fraction:g,Complex:e}=b;return f("pow",{"number, number":a,"Complex, Complex":function(m,q){return m.pow(q)},"BigNumber, BigNumber":function(m,q){return q.isInteger()||0<=m||h.predictable?m.pow(q):(new e(m.toNumber(),0)).pow(q.toNumber(), -0)},"Fraction, Fraction":function(m,q){var r=m.pow(q);if(null!=r)return r;if(h.predictable)throw Error("Result of pow is non-rational and cannot be expressed as a fraction");return a(m.valueOf(),q.valueOf())},"Array, number":d,"Array, BigNumber":function(m,q){return d(m,q.toNumber())},"Matrix, number":c,"Matrix, BigNumber":function(m,q){return c(m,q.toNumber())},"Unit, number | BigNumber":function(m,q){return m.pow(q)}})}),An=B("dotPow",["typed","equalScalar","matrix","pow","DenseMatrix"],b=>{var {typed:a, -equalScalar:d,matrix:c,pow:f,DenseMatrix:h}=b,l=Nc({typed:a}),p=kd({typed:a,DenseMatrix:h}),k=Fc({typed:a,equalScalar:d}),n=Oc({typed:a,DenseMatrix:h}),g=fc({typed:a}),e=Tb({typed:a});return a("dotPow",{"any, any":f,"SparseMatrix, SparseMatrix":function(m,q){return p(m,q,f,!1)},"SparseMatrix, DenseMatrix":function(m,q){return l(q,m,f,!0)},"DenseMatrix, SparseMatrix":function(m,q){return l(m,q,f,!1)},"DenseMatrix, DenseMatrix":function(m,q){return g(m,q,f)},"Array, Array":function(m,q){return this(c(m), -c(q)).valueOf()},"Array, Matrix":function(m,q){return this(c(m),q)},"Matrix, Array":function(m,q){return this(m,c(q))},"SparseMatrix, any":function(m,q){return k(m,q,this,!1)},"DenseMatrix, any":function(m,q){return e(m,q,this,!1)},"any, SparseMatrix":function(m,q){return n(q,m,this,!0)},"any, DenseMatrix":function(m,q){return e(q,m,this,!0)},"Array, any":function(m,q){return e(c(m),q,this,!1).valueOf()},"any, Array":function(m,q){return e(c(q),m,this,!0).valueOf()}})}),Bn=B("rightArithShift",["typed", -"matrix","equalScalar","zeros","DenseMatrix"],b=>{var {typed:a,matrix:d,equalScalar:c,zeros:f,DenseMatrix:h}=b,l=Cd({typed:a}),p=bd({typed:a,equalScalar:c}),k=kf({typed:a,equalScalar:c}),n=Qd({typed:a,DenseMatrix:h}),g=Fc({typed:a,equalScalar:c}),e=fc({typed:a}),m=Tb({typed:a});return a("rightArithShift",{"number, number":dg,"BigNumber, BigNumber":Di,"SparseMatrix, SparseMatrix":function(q,r){return k(q,r,this,!1)},"SparseMatrix, DenseMatrix":function(q,r){return p(r,q,this,!0)},"DenseMatrix, SparseMatrix":function(q, -r){return l(q,r,this,!1)},"DenseMatrix, DenseMatrix":function(q,r){return e(q,r,this)},"Array, Array":function(q,r){return this(d(q),d(r)).valueOf()},"Array, Matrix":function(q,r){return this(d(q),r)},"Matrix, Array":function(q,r){return this(q,d(r))},"SparseMatrix, number | BigNumber":function(q,r){return c(r,0)?q.clone():g(q,r,this,!1)},"DenseMatrix, number | BigNumber":function(q,r){return c(r,0)?q.clone():m(q,r,this,!1)},"number | BigNumber, SparseMatrix":function(q,r){return c(q,0)?f(r.size(), -r.storage()):n(r,q,this,!0)},"number | BigNumber, DenseMatrix":function(q,r){return c(q,0)?f(r.size(),r.storage()):m(r,q,this,!0)},"Array, number | BigNumber":function(q,r){return this(d(q),r).valueOf()},"number | BigNumber, Array":function(q,r){return this(q,d(r)).valueOf()}})}),ee=jb(228),Cn=B("compareNatural",["typed","compare"],b=>{function a(l,p,k){return H(p)&&H(k)?d(l,p.toJSON().values,k.toJSON().values):H(p)?a(l,p.toArray(),k):H(k)?a(l,p,k.toArray()):D(p)?a(l,p.toJSON().data,k):D(k)?a(l,p, -k.toJSON().data):Array.isArray(p)?Array.isArray(k)?d(l,p,k):a(l,p,[k]):a(l,[p],k)}function d(l,p,k){for(var n=0,g=Math.min(p.length,k.length);nk.length?1:p.lengthp.re?1:l.rep.im?1:l.im{var {typed:a,compareText:d,isZero:c}=b;return a("equalText",{"any, any":function(f,h){return c(d(f,h))}})}),En=B("largerEq",["typed","config","matrix","DenseMatrix"],b=>{var {typed:a,config:d,matrix:c,DenseMatrix:f}=b,h=Nc({typed:a}),l=kd({typed:a,DenseMatrix:f}),p=Oc({typed:a,DenseMatrix:f}), -k=fc({typed:a}),n=Tb({typed:a});return a("largerEq",{"boolean, boolean":function(g,e){return g>=e},"number, number":function(g,e){return g>=e||Ec(g,e,d.epsilon)},"BigNumber, BigNumber":function(g,e){return g.gte(e)||jd(g,e,d.epsilon)},"Fraction, Fraction":function(g,e){return-1!==g.compare(e)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers");},"Unit, Unit":function(g,e){if(!g.equalBase(e))throw Error("Cannot compare units with different base"); -return this(g.value,e.value)},"SparseMatrix, SparseMatrix":function(g,e){return l(g,e,this)},"SparseMatrix, DenseMatrix":function(g,e){return h(e,g,this,!0)},"DenseMatrix, SparseMatrix":function(g,e){return h(g,e,this,!1)},"DenseMatrix, DenseMatrix":function(g,e){return k(g,e,this)},"Array, Array":function(g,e){return this(c(g),c(e)).valueOf()},"Array, Matrix":function(g,e){return this(c(g),e)},"Matrix, Array":function(g,e){return this(g,c(e))},"SparseMatrix, any":function(g,e){return p(g,e,this, -!1)},"DenseMatrix, any":function(g,e){return n(g,e,this,!1)},"any, SparseMatrix":function(g,e){return p(e,g,this,!0)},"any, DenseMatrix":function(g,e){return n(e,g,this,!0)},"Array, any":function(g,e){return n(c(g),e,this,!1).valueOf()},"any, Array":function(g,e){return n(c(e),g,this,!0).valueOf()}})}),Fn=B("partitionSelect",["typed","isNumeric","isNaN","compare"],b=>{function a(k,n,g){if(!Za(n)||0>n)throw Error("k must be a non-negative integer");if(Fa(k)){if(1=k.length)throw Error("k out of bounds");for(var e=0;e-l(k,n);return c("partitionSelect",{"Array | Matrix, number":function(k, -n){return a(k,n,l)},"Array | Matrix, number, string":function(k,n,g){if("asc"===g)return a(k,n,l);if("desc"===g)return a(k,n,p);throw Error('Compare string must be "asc" or "desc"');},"Array | Matrix, number, function":a})}),Gn=B("Index",["ImmutableDenseMatrix"],b=>{function a(f){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[];this._isScalar=!0;for(var h=0,l=arguments.length;h{var {typed:a,config:d,Complex:c,BigNumber:f}=b;return a("asech",{number:function(h){if(1>=h&&-1<=h||d.predictable){var l=1/h;return 0{({typed:b}=b);return b("tan",{number:Math.tan,Complex:function(a){return a.tan()},BigNumber:function(a){return a.tan()},Unit:function(a){if(!a.hasBase(a.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(a.value)},"Array | Matrix":function(a){return Na(a,this,!0)}})}),Jn=B("setDifference","typed size subset compareNatural Index DenseMatrix".split(" "),b=>{var {typed:a,size:d, -subset:c,compareNatural:f,Index:h,DenseMatrix:l}=b;return a("setDifference",{"Array | Matrix, Array | Matrix":function(p,k){if(0===c(d(p),new h(0)))var n=[];else{if(0===c(d(k),new h(0)))return C(p.toArray());var g=T(C(Array.isArray(p)?p:p.toArray()).sort(f)),e=T(C(Array.isArray(k)?k:k.toArray()).sort(f));n=[];for(var m=0;m{var {typed:a,size:d,subset:c,compareNatural:f,Index:h,DenseMatrix:l}=b;return a("setIntersect",{"Array | Matrix, Array | Matrix":function(p,k){if(0===c(d(p),new h(0))||0===c(d(k),new h(0)))var n=[];else{var g=T(C(Array.isArray(p)?p:p.toArray()).sort(f)),e=T(C(Array.isArray(k)?k:k.toArray()).sort(f));n=[];for(var m=0;m{var {typed:a,size:d,subset:c,compareNatural:f,Index:h}=b;return a("setMultiplicity",{"number | BigNumber | Fraction | Complex, Array | Matrix":function(l,p){if(0===c(d(p),new h(0)))return 0;p=C(Array.isArray(p)?p:p.toArray());for(var k=0,n=0;n{var {typed:a,compareNatural:d}=b;return a("setSize",{"Array | Matrix":function(c){return Array.isArray(c)?C(c).length:C(c.toArray()).length},"Array | Matrix, boolean":function(c,f){if(!1===f||0===c.length)return Array.isArray(c)?C(c).length:C(c.toArray()).length;c=C(Array.isArray(c)?c:c.toArray()).sort(d);for(var h=f=1;h{function a(h){var l=h._size;h=h._data;switch(l.length){case 1:if(1=== -l[0])return nb(h[0]);throw new RangeError("Matrix must be square (size: "+Db(l)+")");case 2:var p=l[0];if(p===l[1]){for(var k=l=0;kg)break}return n}throw new RangeError("Matrix must be square (size: "+Db(n)+")");},DenseMatrix:a,any:nb})}),On=B("quantileSeq",["typed","add","multiply","partitionSelect","compare"],b=>{function a(k,n,g){k=C(k);var e=k.length;if(0===e)throw Error("Cannot calculate quantile of an empty sequence");if(Qa(n)){e=n*(e-1);n=e%1;if(0===n)return k=g?k[e]:h(k,e),p(k),k;e=Math.floor(e);if(g){g=k[e];var m=k[e+1]}else{m=h(k, -e+1);g=k[e];for(var q=0;qarguments.length||3n)throw Error("N/prob must be non-negative");if(1>=n)return a(e,n,g);if(1u||1{function a(k){if(8>k)return new l([1,1,2,6,24,120,720,5040][k]);var n=c.precision+(0|Math.log(k.toNumber())),g=l.clone({precision:n});if(1==k%2)return k.times(a(new l(k-1)));n=k;g=new g(k);for(k=k.toNumber();2Bd[g]?-1/0:1/0}g=new p(k.re+Gg+.5,k.im);e=Math.sqrt(2*Math.PI);k.re+=.5;k=h(g,k);0===k.im?k.re*=e:(0===k.re||(k.re*=e),k.im*=e);e=Math.exp(-g.re);return g.re=e*Math.cos(-g.im),g.im=e*Math.sin(-g.im),f(f(k,g),n)},BigNumber:function(k){if(k.isInteger())return k.isNegative()||k.isZero()?new l(1/ -0):a(k.minus(1));if(!k.isFinite())return new l(k.isNegative()?NaN:1/0);throw Error("Integer BigNumber expected");},"Array | Matrix":function(k){return Na(k,this)}})}),Qn=B("bignumber",["typed","BigNumber"],b=>{var {typed:a,BigNumber:d}=b;return a("bignumber",{"":function(){return new d(0)},number:function(c){return new d(c+"")},string:function(c){var f=c.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(f){var h=f[2];f=d(f[1]);var l=(new d(2)).pow(Number(h));if(f.gt(l.sub(1)))throw new SyntaxError('String "'.concat(c, -'" is out of range'));c=(new d(2)).pow(Number(h)-1);return f.gte(c)?f.sub(l):f}return new d(c)},BigNumber:function(c){return c},Fraction:function(c){return(new d(c.n)).div(c.d).times(c.s)},null:function(c){return new d(0)},"Array | Matrix":function(c){return Na(c,this)}})}),Rn=B("matrixFromColumns",["typed","matrix","flatten","size"],b=>{function a(p){if(0===p.length)throw new TypeError("At least one column is needed to construct a matrix.");for(var k=d(p[0]),n=[],g=0;gk.toArray())))}})}),Sn=B("lcm",["typed","matrix","equalScalar"],b=>{var {typed:a,matrix:d,equalScalar:c}=b,f=bd({typed:a,equalScalar:c}),h=Me({typed:a,equalScalar:c}),l=Fc({typed:a,equalScalar:c}),p=fc({typed:a}),k=Tb({typed:a});return a("lcm",{"number, number":Sf,"BigNumber, BigNumber":function(n,g){if(!n.isInt()||!g.isInt())throw Error("Parameters in function lcm must be integer numbers");if(n.isZero())return n;if(g.isZero())return g;for(var e=n.times(g);!g.isZero();){var m= -g;g=n.mod(m);n=m}return e.div(n).abs()},"Fraction, Fraction":function(n,g){return n.lcm(g)},"SparseMatrix, SparseMatrix":function(n,g){return h(n,g,this)},"SparseMatrix, DenseMatrix":function(n,g){return f(g,n,this,!0)},"DenseMatrix, SparseMatrix":function(n,g){return f(n,g,this,!1)},"DenseMatrix, DenseMatrix":function(n,g){return p(n,g,this)},"Array, Array":function(n,g){return this(d(n),d(g)).valueOf()},"Array, Matrix":function(n,g){return this(d(n),g)},"Matrix, Array":function(n,g){return this(n, -d(g))},"SparseMatrix, number | BigNumber":function(n,g){return l(n,g,this,!1)},"DenseMatrix, number | BigNumber":function(n,g){return k(n,g,this,!1)},"number | BigNumber, SparseMatrix":function(n,g){return l(g,n,this,!0)},"number | BigNumber, DenseMatrix":function(n,g){return k(g,n,this,!0)},"Array, number | BigNumber":function(n,g){return k(d(n),g,this,!1).valueOf()},"number | BigNumber, Array":function(n,g){return k(d(g),n,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(n, -g,e){n=this(n,g);for(g=0;g{var {typed:a,matrix:d,equalScalar:c,DenseMatrix:f}=b,h=Cd({typed:a}),l=jf({typed:a,equalScalar:c}),p=Qd({typed:a,DenseMatrix:f}),k=fc({typed:a}),n=Tb({typed:a});return a("bitOr",{"number, number":ag,"BigNumber, BigNumber":Ai,"SparseMatrix, SparseMatrix":function(g,e){return l(g,e,this)},"SparseMatrix, DenseMatrix":function(g,e){return h(e,g,this,!0)},"DenseMatrix, SparseMatrix":function(g, -e){return h(g,e,this,!1)},"DenseMatrix, DenseMatrix":function(g,e){return k(g,e,this)},"Array, Array":function(g,e){return this(d(g),d(e)).valueOf()},"Array, Matrix":function(g,e){return this(d(g),e)},"Matrix, Array":function(g,e){return this(g,d(e))},"SparseMatrix, any":function(g,e){return p(g,e,this,!1)},"DenseMatrix, any":function(g,e){return n(g,e,this,!1)},"any, SparseMatrix":function(g,e){return p(e,g,this,!0)},"any, DenseMatrix":function(g,e){return n(e,g,this,!0)},"Array, any":function(g, -e){return n(d(g),e,this,!1).valueOf()},"any, Array":function(g,e){return n(d(e),g,this,!0).valueOf()}})}),Un=B("kron",["typed","matrix","multiplyScalar"],b=>{function a(h,l){if(1===Ua(h).length&&(h=[h]),1===Ua(l).length&&(l=[l]),2{var {typed:a,matrix:d}=b;return a("transpose",{Array:function(c){return this(d(c)).valueOf()},Matrix:function(c){var f=c.size(); -switch(f.length){case 1:var h=c.clone();break;case 2:var l=f[0],p=f[1];if(0===p)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+Db(f)+")");switch(c.storage()){case "dense":h=function(k,n,g){for(var e,m=k._data,q=[],r=0;r{var {number:a, -bignumber:d,fraction:c}=b,f={string:!0,number:!0,BigNumber:!0,Fraction:!0},h={number:l=>a(l),BigNumber:d?l=>d(l):hd,Fraction:c?l=>c(l):gc};return function(l,p){var k=Wb(l);if(!(k in f))throw new TypeError("Cannot convert "+l+' of type "'+k+'"; valid input types are '+Object.keys(f).join(", "));if(!(p in h))throw new TypeError("Cannot convert "+l+' to type "'+p+'"; valid output types are '+Object.keys(h).join(", "));return p===k?l:h[p](l)}}),Xn=B("and",["typed","matrix","equalScalar","zeros","not"], -b=>{var {typed:a,matrix:d,equalScalar:c,zeros:f,not:h}=b,l=bd({typed:a,equalScalar:c}),p=Me({typed:a,equalScalar:c}),k=Fc({typed:a,equalScalar:c}),n=fc({typed:a}),g=Tb({typed:a});return a("and",{"number, number":ig,"Complex, Complex":function(e,m){return!(0===e.re&&0===e.im||0===m.re&&0===m.im)},"BigNumber, BigNumber":function(e,m){return!(e.isZero()||m.isZero()||e.isNaN()||m.isNaN())},"Unit, Unit":function(e,m){return this(e.value||0,m.value||0)},"SparseMatrix, SparseMatrix":function(e,m){return p(e, -m,this,!1)},"SparseMatrix, DenseMatrix":function(e,m){return l(m,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,m){return l(e,m,this,!1)},"DenseMatrix, DenseMatrix":function(e,m){return n(e,m,this)},"Array, Array":function(e,m){return this(d(e),d(m)).valueOf()},"Array, Matrix":function(e,m){return this(d(e),m)},"Matrix, Array":function(e,m){return this(e,d(m))},"SparseMatrix, any":function(e,m){return h(m)?f(e.size(),e.storage()):k(e,m,this,!1)},"DenseMatrix, any":function(e,m){return h(m)?f(e.size(), -e.storage()):g(e,m,this,!1)},"any, SparseMatrix":function(e,m){return h(e)?f(e.size(),e.storage()):k(m,e,this,!0)},"any, DenseMatrix":function(e,m){return h(e)?f(e.size(),e.storage()):g(m,e,this,!0)},"Array, any":function(e,m){return this(d(e),m).valueOf()},"any, Array":function(e,m){return this(e,d(m)).valueOf()}})}),Yn=B("smallerEq",["typed","config","matrix","DenseMatrix"],b=>{var {typed:a,config:d,matrix:c,DenseMatrix:f}=b,h=Nc({typed:a}),l=kd({typed:a,DenseMatrix:f}),p=Oc({typed:a,DenseMatrix:f}), -k=fc({typed:a}),n=Tb({typed:a});return a("smallerEq",{"boolean, boolean":function(g,e){return g<=e},"number, number":function(g,e){return g<=e||Ec(g,e,d.epsilon)},"BigNumber, BigNumber":function(g,e){return g.lte(e)||jd(g,e,d.epsilon)},"Fraction, Fraction":function(g,e){return 1!==g.compare(e)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers");},"Unit, Unit":function(g,e){if(!g.equalBase(e))throw Error("Cannot compare units with different base"); -return this(g.value,e.value)},"SparseMatrix, SparseMatrix":function(g,e){return l(g,e,this)},"SparseMatrix, DenseMatrix":function(g,e){return h(e,g,this,!0)},"DenseMatrix, SparseMatrix":function(g,e){return h(g,e,this,!1)},"DenseMatrix, DenseMatrix":function(g,e){return k(g,e,this)},"Array, Array":function(g,e){return this(c(g),c(e)).valueOf()},"Array, Matrix":function(g,e){return this(c(g),e)},"Matrix, Array":function(g,e){return this(g,c(e))},"SparseMatrix, any":function(g,e){return p(g,e,this, -!1)},"DenseMatrix, any":function(g,e){return n(g,e,this,!1)},"any, SparseMatrix":function(g,e){return p(e,g,this,!0)},"any, DenseMatrix":function(g,e){return n(e,g,this,!0)},"Array, any":function(g,e){return n(c(g),e,this,!1).valueOf()},"any, Array":function(g,e){return n(c(e),g,this,!0).valueOf()}})}),Zn=B("sort",["typed","matrix","compare","compareNatural"],b=>{function a(g){if("asc"===g)return k;if("desc"===g)return n;if("natural"===g)return p;throw Error('String "asc", "desc", or "natural" expected'); -}function d(g){if(1!==Ua(g).length)throw Error("One dimensional array expected");}function c(g){if(1!==g.size().length)throw Error("One dimensional matrix expected");}var {typed:f,matrix:h,compare:l,compareNatural:p}=b,k=l,n=(g,e)=>-l(g,e);return f("sort",{Array:function(g){return d(g),g.sort(k)},Matrix:function(g){return c(g),h(g.toArray().sort(k),g.storage())},"Array, function":function(g,e){return d(g),g.sort(e)},"Matrix, function":function(g,e){return c(g),h(g.toArray().sort(e),g.storage())}, -"Array, string":function(g,e){return d(g),g.sort(a(e))},"Matrix, string":function(g,e){return c(g),h(g.toArray().sort(a(e)),g.storage())}})}),$n=B("cot",["typed","BigNumber"],b=>{var {typed:a,BigNumber:d}=b;return a("cot",{number:sg,Complex:function(c){return c.cot()},BigNumber:function(c){return(new d(1)).div(c.tan())},Unit:function(c){if(!c.hasBase(c.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(c.value)},"Array | Matrix":function(c){return Na(c, -this)}})}),ao=B("setDistinct","typed size subset compareNatural Index DenseMatrix".split(" "),b=>{var {typed:a,size:d,subset:c,compareNatural:f,Index:h,DenseMatrix:l}=b;return a("setDistinct",{"Array | Matrix":function(p){if(0===c(d(p),new h(0)))var k=[];else{var n=C(Array.isArray(p)?p:p.toArray()).sort(f);(k=[]).push(n[0]);for(var g=1;g{var {typed:a, -size:d,subset:c,compareNatural:f,Index:h}=b;return a("setPowerset",{"Array | Matrix":function(l){if(0===c(d(l),new h(0)))return[];var p=C(Array.isArray(l)?l:l.toArray()).sort(f);l=[];for(var k=0;k.toString(2).length<=p.length;){for(var n=l,g=n.push,e=p,m=k.toString(2).split("").reverse(),q=[],r=0;rl[n+1].length&&(p=l[n],l[n]=l[n+1],l[n+1]=p);return l}})}),co=B("index",["typed","Index"], -b=>{var {typed:a,Index:d}=b;return a("index",{"...number | string | BigNumber | Range | Array | Matrix":function(c){c=c.map(function(h){return pa(h)?h.toNumber():Array.isArray(h)||Fa(h)?h.map(function(l){return pa(l)?l.toNumber():l}):h});var f=new d;return d.apply(f,c),f}})}),eo=B("factorial",["typed","gamma"],b=>{var {typed:a,gamma:d}=b;return a("factorial",{number:function(c){if(0>c)throw Error("Value must be non-negative");return d(c+1)},BigNumber:function(c){if(c.isNegative())throw Error("Value must be non-negative"); -return d(c.plus(1))},"Array | Matrix":function(c){return Na(c,this)}})}),fo=B("permutations",["typed","factorial"],b=>{var {typed:a,factorial:d}=b;return a("permutations",{"number | BigNumber":d,"number, number":function(c,f){if(!Za(c)||0>c)throw new TypeError("Positive integer value expected in function permutations");if(!Za(f)||0>f)throw new TypeError("Positive integer value expected in function permutations");if(f>c)throw new TypeError("second argument k must be less than or equal to first argument n"); -return Wc(c-f+1,c)},"BigNumber, BigNumber":function(c,f){if(!Hg(c)||!Hg(f))throw new TypeError("Positive integer value expected in function permutations");if(f.gt(c))throw new TypeError("second argument k must be less than or equal to first argument n");var h=c.mul(0).add(1);for(f=c.minus(f).plus(1);f.lte(c);f=f.plus(1))h=h.times(f);return h}})}),go=B("matrixFromRows",["typed","matrix","flatten","size"],b=>{function a(p){if(0===p.length)throw new TypeError("At least one row is needed to construct a matrix."); -var k=d(p[0]),n=[],g;for(g of p){p=d(g);if(p!==k)throw new TypeError("The vectors had different length: "+(0|k)+" \u2260 "+(0|p));n.push(h(g))}return n}function d(p){p=l(p);if(1===p.length)return p[0];if(2===p.length){if(1===p[0])return p[1];if(1===p[1])return p[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.");}var {typed:c,matrix:f,flatten:h,size:l}=b;return c("matrixFromRows",{"...Array":function(p){return a(p)}, -"...Matrix":function(p){return f(a(p.map(k=>k.toArray())))}})}),ho=B("subtract","typed matrix equalScalar addScalar unaryMinus DenseMatrix".split(" "),b=>{var {typed:a,matrix:d,equalScalar:c,addScalar:f,unaryMinus:h,DenseMatrix:l}=b,p=Cd({typed:a}),k=Nc({typed:a}),n=Le({typed:a,equalScalar:c}),g=Qd({typed:a,DenseMatrix:l}),e=fc({typed:a}),m=Tb({typed:a});return a("subtract",{"number, number":function(q,r){return q-r},"Complex, Complex":function(q,r){return q.sub(r)},"BigNumber, BigNumber":function(q, -r){return q.minus(r)},"Fraction, Fraction":function(q,r){return q.sub(r)},"Unit, Unit":function(q,r){if(null===q.value)throw Error("Parameter x contains a unit with undefined value");if(null===r.value)throw Error("Parameter y contains a unit with undefined value");if(!q.equalBase(r))throw Error("Units do not match");q=q.clone();return q.value=this(q.value,r.value),q.fixPrefix=!1,q},"SparseMatrix, SparseMatrix":function(q,r){return Ke(q,r),n(q,r,this)},"SparseMatrix, DenseMatrix":function(q,r){return Ke(q, -r),k(r,q,this,!0)},"DenseMatrix, SparseMatrix":function(q,r){return Ke(q,r),p(q,r,this,!1)},"DenseMatrix, DenseMatrix":function(q,r){return Ke(q,r),e(q,r,this)},"Array, Array":function(q,r){return this(d(q),d(r)).valueOf()},"Array, Matrix":function(q,r){return this(d(q),r)},"Matrix, Array":function(q,r){return this(q,d(r))},"SparseMatrix, any":function(q,r){return g(q,h(r),f)},"DenseMatrix, any":function(q,r){return m(q,r,this)},"any, SparseMatrix":function(q,r){return g(r,q,this,!0)},"any, DenseMatrix":function(q, -r){return m(r,q,this,!0)},"Array, any":function(q,r){return m(d(q),r,this,!1).valueOf()},"any, Array":function(q,r){return m(d(r),q,this,!0).valueOf()}})}),io=B("cross",["typed","matrix","subtract","multiply"],b=>{function a(l,p){var k=Math.max(Ua(l).length,Ua(p).length);l=Ba(l);p=Ba(p);var n=Ua(l),g=Ua(p);if(1!==n.length||1!==g.length||3!==n[0]||3!==g[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+n.join(", ")+"], B = ["+g.join(", ")+"])");l=[f(h(l[1],p[2]),h(l[2],p[1])),f(h(l[2], -p[0]),h(l[0],p[2])),f(h(l[0],p[1]),h(l[1],p[0]))];return 1{function a(l){var p;if(Zb(l,function(k){try{p=void 0===p?k:f(p,k)}catch(n){throw Tc(n,"prod",k);}}),"string"== -typeof p&&(p=h(p,c.number)),void 0===p)throw Error("Cannot calculate prod of an empty array");return p}var {typed:d,config:c,multiplyScalar:f,numeric:h}=b;return d("prod",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(l,p){throw Error("prod(A, dim) is not yet supported");},"...":function(l){return a(l)}})}),ko=B("equal",["typed","matrix","equalScalar","DenseMatrix"],b=>{var {typed:a,matrix:d,equalScalar:c,DenseMatrix:f}=b,h=Nc({typed:a}),l=kd({typed:a,DenseMatrix:f}),p=Oc({typed:a, -DenseMatrix:f}),k=fc({typed:a}),n=Tb({typed:a});return a("equal",{"any, any":function(g,e){return null===g?null===e:null===e?null===g:void 0===g?void 0===e:void 0===e?void 0===g:c(g,e)},"SparseMatrix, SparseMatrix":function(g,e){return l(g,e,c)},"SparseMatrix, DenseMatrix":function(g,e){return h(e,g,c,!0)},"DenseMatrix, SparseMatrix":function(g,e){return h(g,e,c,!1)},"DenseMatrix, DenseMatrix":function(g,e){return k(g,e,c)},"Array, Array":function(g,e){return this(d(g),d(e)).valueOf()},"Array, Matrix":function(g, -e){return this(d(g),e)},"Matrix, Array":function(g,e){return this(g,d(e))},"SparseMatrix, any":function(g,e){return p(g,e,c,!1)},"DenseMatrix, any":function(g,e){return n(g,e,c,!1)},"any, SparseMatrix":function(g,e){return p(e,g,c,!0)},"any, DenseMatrix":function(g,e){return n(e,g,c,!0)},"Array, any":function(g,e){return n(d(g),e,c,!1).valueOf()},"any, Array":function(g,e){return n(d(e),g,c,!0).valueOf()}})}),jh=(B("equal",["typed","equalScalar"],b=>{var {typed:a,equalScalar:d}=b;return a("equal", -{"any, any":function(c,f){return null===c?null===f:null===f?null===c:void 0===c?void 0===f:void 0===f?void 0===c:d(c,f)}})}),"setCartesian"),lo=B(jh,"typed size subset compareNatural Index DenseMatrix".split(" "),b=>{var {typed:a,size:d,subset:c,compareNatural:f,Index:h,DenseMatrix:l}=b;return a(jh,{"Array | Matrix, Array | Matrix":function(p,k){var n=[];if(0!==c(d(p),new h(0))&&0!==c(d(k),new h(0))){var g=C(Array.isArray(p)?p:p.toArray()).sort(f),e=C(Array.isArray(k)?k:k.toArray()).sort(f);n=[]; -for(var m=0;m{var {typed:a,size:d,concat:c,subset:f,setDifference:h,Index:l}=b;return a("setSymDifference",{"Array | Matrix, Array | Matrix":function(p,k){if(0===f(d(p),new l(0)))return C(k);if(0===f(d(k),new l(0)))return C(p);p=C(p);k=C(k);return c(h(p,k),h(k,p))}})}),no=B("ceil",["typed","config", -"round","matrix","equalScalar"],b=>{var {typed:a,config:d,round:c,matrix:f,equalScalar:h}=b,l=Fc({typed:a,equalScalar:h}),p=Tb({typed:a});return a("ceil",{number:function(k){return Ec(k,c(k),d.epsilon)?c(k):Nf(k)},"number, number":function(k,n){if(Ec(k,c(k,n),d.epsilon))return c(k,n);var [g,e]="".concat(k,"e").split("e");k=Math.ceil(Number("".concat(g,"e").concat(Number(e)+n)));k="".concat(k,"e").split("e");[g,e]=k;return Number("".concat(g,"e").concat(Number(e)-n))},Complex:function(k){return k.ceil()}, -"Complex, number":function(k,n){return k.ceil(n)},BigNumber:function(k){return jd(k,c(k),d.epsilon)?c(k):k.ceil()},"BigNumber, BigNumber":function(k,n){return jd(k,c(k,n),d.epsilon)?c(k,n):k.toDecimalPlaces(n.toNumber(),hf.ROUND_CEIL)},Fraction:function(k){return k.ceil()},"Fraction, number":function(k,n){return k.ceil(n)},"Array | Matrix":function(k){return Na(k,this,!0)},"Array | Matrix, number":function(k,n){return Na(k,g=>this(g,n),!0)},"SparseMatrix, number | BigNumber":function(k,n){return l(k, -n,this,!1)},"DenseMatrix, number | BigNumber":function(k,n){return p(k,n,this,!1)},"number | Complex | BigNumber, Array":function(k,n){return p(f(n),k,this,!0).valueOf()}})}),oo=B("xor",["typed","matrix","DenseMatrix"],b=>{var {typed:a,matrix:d,DenseMatrix:c}=b,f=Nc({typed:a}),h=kd({typed:a,DenseMatrix:c}),l=Oc({typed:a,DenseMatrix:c}),p=fc({typed:a}),k=Tb({typed:a});return a("xor",{"number, number":hg,"Complex, Complex":function(n,g){return(0!==n.re||0!==n.im)!=(0!==g.re||0!==g.im)},"BigNumber, BigNumber":function(n, -g){return(!n.isZero()&&!n.isNaN())!=(!g.isZero()&&!g.isNaN())},"Unit, Unit":function(n,g){return this(n.value||0,g.value||0)},"SparseMatrix, SparseMatrix":function(n,g){return h(n,g,this)},"SparseMatrix, DenseMatrix":function(n,g){return f(g,n,this,!0)},"DenseMatrix, SparseMatrix":function(n,g){return f(n,g,this,!1)},"DenseMatrix, DenseMatrix":function(n,g){return p(n,g,this)},"Array, Array":function(n,g){return this(d(n),d(g)).valueOf()},"Array, Matrix":function(n,g){return this(d(n),g)},"Matrix, Array":function(n, -g){return this(n,d(g))},"SparseMatrix, any":function(n,g){return l(n,g,this,!1)},"DenseMatrix, any":function(n,g){return k(n,g,this,!1)},"any, SparseMatrix":function(n,g){return l(g,n,this,!0)},"any, DenseMatrix":function(n,g){return k(g,n,this,!0)},"Array, any":function(n,g){return k(d(n),g,this,!1).valueOf()},"any, Array":function(n,g){return k(d(g),n,this,!0).valueOf()}})}),po=B("count",["typed","size","prod"],b=>{var {typed:a,size:d,prod:c}=b;return a("count",{string:function(f){return f.length}, -"Matrix | Array":function(f){return c(d(f))}})}),qo=B("ctranspose",["typed","transpose","conj"],b=>{var {typed:a,transpose:d,conj:c}=b;return a("ctranspose",{any:function(f){return c(d(f))}})}),ro=B("deepEqual",["typed","equal"],b=>{function a(f,h){if(Array.isArray(f)){if(Array.isArray(h)){var l=f.length;if(l!==h.length)return!1;for(var p=0;p{var {typed:a,size:d,subset:c,compareNatural:f,Index:h}=b;return a("setIsSubset",{"Array | Matrix, Array | Matrix":function(l,p){if(0===c(d(l),new h(0)))return!0;if(0===c(d(p),new h(0)))return!1;l=T(C(Array.isArray(l)?l:l.toArray()).sort(f));for(var k=T(C(Array.isArray(p)?p:p.toArray()).sort(f)),n=0;n{var {typed:a,Complex:d,matrix:c,ceil:f,floor:h}=b,l=Tb({typed:a});return a("fix",{number:function(p){return 0p.s?p.ceil():p.floor()},"Fraction, number | BigNumber":function(p,k){return 0>p.s?p.ceil(k):p.floor(k)},"Array | Matrix":function(p){return Na(p,this,!0)},"Array | Matrix, number | BigNumber":function(p,k){return Na(p,n=>this(n,k),!0)},"number | Complex | BigNumber, Array":function(p,k){return l(c(k),p,this,!0).valueOf()}})}), -uo=B("divideScalar",["typed","numeric"],b=>{var {typed:a,numeric:d}=b;return a("divideScalar",{"number, number":function(c,f){return c/f},"Complex, Complex":function(c,f){return c.div(f)},"BigNumber, BigNumber":function(c,f){return c.div(f)},"Fraction, Fraction":function(c,f){return c.div(f)},"Unit, number | Fraction | BigNumber":function(c,f){c=c.clone();var h=d(1,Wb(f));return c.value=this(null===c.value?c._normalize(h):c.value,f),c},"number | Fraction | BigNumber, Unit":function(c,f){var h=f.clone(); -h=h.pow(-1);var l=d(1,Wb(c));return h.value=this(c,null===f.value?f._normalize(l):f.value),h},"Unit, Unit":function(c,f){return c.divide(f)}})}),vo=B("nthRoots",["config","typed","divideScalar","Complex"],b=>{function a(h,l){if(0>l)throw Error("Root must be greater than zero");if(0===l)throw Error("Root must be non-zero");if(0!=l%1)throw Error("Root must be an integer");if(0===h||0===h.abs())return[new c(0,0)];var p,k="number"==typeof h;(k||0===h.re||0===h.im)&&(p=k?2*+(0>h):0===h.im?2*+(0>h.re): -2*+(0>h.im)+1);k=h.arg();var n=h.abs();h=[];n=Math.pow(n,1/l);for(var g=0;g{function a(g,e){e=n(g,e,!0)._data;var m=g._size[0],q=g._size[1],r=[];g=g._data;for(var u=0;uv&&(z.push(r[L]),I.push(O))}if(p(w,0))throw Error("Linear system cannot be solved since matrix is singular");t=f(t,w);w=0;for(F=I.length;w{function a(g,e){e=[n(g,e,!0)._data.map(w=>w[0])];var m=g._data,q=g._size[0];g=g._size[1];for(var r=0;rnew k({data:w.map(z=>[z]),size:[q,1]}))}var {typed:d,matrix:c,divideScalar:f,multiplyScalar:h,subtract:l,equalScalar:p,DenseMatrix:k}=b,n=pe({DenseMatrix:k});return d("lsolveAll",{"SparseMatrix, Array | Matrix":function(g,e){return function(m,q){q=[n(m,q,!0)._data.map(ka=>ka[0])];var r=m._size[0],u=m._size[1],y=m._values,v=m._index;m=m._ptr;for(var t=0;tt&&(F.push(y[ba]),L.push(ca))}if(p(R,0))if(p(I[t],0)){if(0===z){I=[...I];I[t]=1;O=0;for(R=L.length;Onew k({data:ka.map(Ea=>[Ea]),size:[r,1]}))}(g,e)},"DenseMatrix, Array | Matrix":function(g,e){return a(g,e)},"Array, Array | Matrix":function(g,e){return a(c(g), -e).map(m=>m.valueOf())}})}),yo=B("Spa",["addScalar","equalScalar","FibonacciHeap"],b=>{function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._values=[];this._heap=new f}var {addScalar:d,equalScalar:c,FibonacciHeap:f}=b;return a.prototype.type="Spa",a.prototype.isSpa=!0,a.prototype.set=function(h,l){this._values[h]?this._values[h].value=l:(l=this._heap.insert(h,l),this._values[h]=l)},a.prototype.get=function(h){return(h=this._values[h])? -h.value:0},a.prototype.accumulate=function(h,l){var p=this._values[h];p?p.value=d(p.value,l):(p=this._heap.insert(h,l),this._values[h]=p)},a.prototype.forEach=function(h,l,p){var k=this._heap,n=this._values,g=[],e=k.extractMinimum();for(e&&g.push(e);e&&e.key<=l;)e.key>=h&&(c(e.value,0)||p(e.key,e.value,this)),(e=k.extractMinimum())&&g.push(e);for(h=0;h{var {typed:a,size:d,concat:c,subset:f,setIntersect:h,setSymDifference:l,Index:p}=b;return a("setUnion",{"Array | Matrix, Array | Matrix":function(k,n){if(0===f(d(k),new p(0)))return C(n); -if(0===f(d(n),new p(0)))return C(k);k=C(k);n=C(n);return c(l(k,n),h(k,n))}})}),Ao=B("lup","typed matrix abs addScalar divideScalar multiplyScalar subtract larger equalScalar unaryMinus DenseMatrix SparseMatrix Spa".split(" "),b=>{function a(u){var y,v,t=u._size[0],w=u._size[1],z=Math.min(t,w),I=nb(u._data),F=[],L=[t,z],O=[];z=[z,w];var R=[];for(u=0;uha&&X.accumulate(wa,e(p(gb,ja)))})});var ua,Da,Ha,Ka,M=t,Q=X.get(t),U=f(Q);X.forEach(t+1,z-1,function(ha,ja){var wa=f(ja);n(wa,U)&&(M=ha,U=wa,Q=ja)});t!==M&&(q._swapRows(t,M,Ea[1],ba,ca,ka),q._swapRows(t,M,S[1],Ga,P,Ma),X.swap(t,M),Da=M,Ha=na[ua= -t],Ka=na[Da],ob[Ha]=Da,ob[Ka]=ua,na[ua]=Ka,na[Da]=Ha);X.forEach(0,z-1,function(ha,ja){ha<=t?(Ga.push(ja),P.push(ha)):(ja=l(ja,Q),g(ja,0)||(ba.push(ja),ca.push(ha)))})};for(t=0;t{function a(l,p,k,n,g){if(2>l||0>l+p){for(l=0;l=l||3gb))for(var ma=wa[sb+ -1];Gpb)ja[sb+ -Ya]=0,ja[gb+Ya]=-1,Sa++,ha[Ya]=-U-2,ja[sb+U]++;else{var $a=ja[G+Ja];-1!==$a&&(ma[$a]=Ya);ja[qa+Ya]=ja[G+Ja];ja[G+Ja]=Ya}}return Sa}(n,p,F,ca,ba,ka,e,L,R,I,O),Ma=0;PS?(u=e,y=X,v=F[0+e]-S):(y=p[u=l[X++]],v=F[0+u]);for(q=1;q<=v;q++)0>=(t=F[L+(m=l[y++])])||(na+=t,F[L+m]=-t,l[ua++]=m,-1!==F[O+m]&&(I[F[O+m]]=I[m]),-1!== -I[m]?F[O+I[m]]=F[O+m]:F[R+F[ca+m]]=F[O+m]);u!==e&&(p[u]=-e-2,F[ka+u]=0)}0!==S&&(k=ua);F[ca+e]=na;p[e]=da;F[0+e]=ua-da;F[ba+e]=-2;Ga=a(Ga,g,F,ka,n);for(r=da;r=(w=F[ba+(m=l[r])])))for(q=Ga-(t=-F[L+m]),X=p[m],w=p[m]+w-1;X<=w;X++)F[ka+(u=l[X])]>=Ga?F[ka+u]-=t:0!==F[ka+u]&&(F[ka+u]=F[ca+u]+q);for(r=da;r=Q||(Ha+=Q,l[Da++]=q,z+=q)}0===Ha?(p[m]=-e-2,na-=t=-F[L+m],ob+=t,P+=t,F[L+m]=0,F[ba+m]=-1):(F[ca+m]=Math.min(F[ca+m],Ha),l[Da]=l[Ka],l[Ka]=l[w],l[w]=e,F[0+m]=Da-w+1,z=(0>z?-z:z)%n,F[O+m]=F[Ea+z],F[Ea+z]=m,I[m]=z)}F[ca+e]=na;Ga=a(Ga+(g=Math.max(g,na)),g,F,ka,n);for(r=da;r=(t=-F[L+(m=l[r])])||(F[L+m]=t,Ha=F[ca+m]+na-t,-1!==F[R+(Ha=Math.min(Ha,n-P-t))]&&(I[F[R+Ha]]=m),F[O+m]=F[R+Ha],I[m]=-1,F[R+Ha]=m,Ma=Math.min(Ma,Ha),F[ca+m]=Ha,l[X++]=m);F[L+e]=ob;0==(F[0+e]=X-da)&&(p[e]=-1,F[ka+e]=0);0!==S&&(k=X)}for(m=0;m=F[L+u]||-1!==p[u]&&(F[O+u]=F[R+p[u]],F[R+p[u]]=u);for(m=e=0;m<=n;m++)-1===p[m]&&(e=Ig(m,e,F,R,O,I,ka));return I.splice(I.length-1,1),I}}),Co=B("csCounts",["transpose"],b=>{var {transpose:a}=b;return function(d,c,f,h){if(!d||!c||!f)return null;var l,p,k,n,g=d._size;var e=g[0];g=g[1];var m=4*g+(h?g+e+1:0),q=[],r=2*g,u=3*g,y=4*g,v=5*g+1;for(k=0;k{var {add:a,multiply:d,transpose:c}=b,f=Bo({add:a,multiply:d,transpose:c}),h=Co({transpose:c});return function(l,p,k){var n=p._ptr,g=p._size[1],e={};if(e.q=f(l,p),l&&!e.q)return null;if(k){if(l=l?function(m,q,r,u){q=m._index;u=m._ptr;var y=m._size,v=m._datatype,t=y[0];y=y[1];for(var w=[],z=[],I=0,F=0;Fv&&(v=q.m2++),z[v]=t,0>=--O[t])||(q.lnz+=F[O+t],r=w[t],-1!==r&&(0===F[O+r]&&(F[L+r]=F[L+t]),F[0+F[L+t]]=F[m+r],F[m+r]=F[0+v],F[O+r]+=F[O+t]));for(v=0;vz[v]&&(z[v]=t++);return!0}(l,e))for(l=e.unz=0;l{var {divideScalar:a,multiply:d,subtract:c}=b;return function(f,h,l,p,k,n, -g){var e=f._values,m=f._index,q=f._ptr,r=f._size[1],u=h._values,y=h._index,v=h._ptr;var t=f._ptr;var w=h._index;var z=h._ptr;var I=h=f._size[1];var F=z[l];for(z=z[l+1];Ft[L])){var O,R=I,ba=p,ca=n,ka=f._index,Ea=f._ptr,Ga=f._size[1],P=0;for(ba[0]=L;0<=P;){L=ba[P];var Ma=ca?ca[L]:L;0>Ea[L]||(Ea[L]=-Ea[L]-2,ba[Ga+P]=0>Ma?0:Jg(Ea[Ma]));var S=1;I=ba[Ga+P];for(Ma=0>Ma?0:Jg(Ea[Ma+1]);IEa[ob])){ba[Ga+P]=I;ba[++P]=O;S=0;break}}S&&(P--,ba[--R]=L)}I=R}}for(F= -I;Fl))for(f=q[l],l=q[l+1],k[y]=a(k[y],e[g?f:l-1]),f=g?f+1:f,l=g?l:l-1;f{var {abs:a,divideScalar:d,multiply:c,subtract:f,larger:h,largerEq:l,SparseMatrix:p}=b,k=Eo({divideScalar:d,multiply:c,subtract:f});return function(n, -g,e){if(!n)return null;var m,q=n._size[1],r;g&&(m=g.q);var u,y,v=[],t=[],w=[],z=new p({values:v,index:t,ptr:w,size:[q,q]}),I=[],F=[],L=[],O=new p({values:I,index:F,ptr:L,size:[q,q]}),R=[],ba=[],ca=[];for(u=0;uR[u=ca[y]]){var S=a(ba[u]);h(S,Ma)&&(Ma=S,P=u)}else F[r]=R[u],I[r++]=ba[u];if(-1===P||0>=Ma)return null;0>R[Ea]&&l(a(ba[Ea]),c(Ma,e))&&(P=Ea); -Ea=ba[P];F[r]=ka;I[r++]=Ea;R[P]=ka;t[g]=P;v[g++]=1;for(y=Ga;yR[u=ca[y]]&&(t[g]=u,v[g++]=d(ba[u],Ea)),ba[u]=0}w[q]=g;L[q]=r;for(y=0;y{var {typed:a,abs:d,add:c,multiply:f,transpose:h,divideScalar:l,subtract:p,larger:k,largerEq:n,SparseMatrix:g}= -b,e=Do({add:c,multiply:f,transpose:h}),m=Fo({abs:d,divideScalar:l,multiply:f,subtract:p,larger:k,largerEq:n,SparseMatrix:g});return a("slu",{"SparseMatrix, number, number":function(q,r,u){if(!Za(r)||0>r||3u||1{var {typed:a,matrix:d,subtract:c,multiply:f,unaryMinus:h,lup:l}=b;return a("det",{any:function(p){return nb(p)},"Array | Matrix":function(p){var k;switch((k=Fa(p)?p.size():Array.isArray(p)?(p=d(p)).size():[]).length){case 0:return nb(p);case 1:if(1===k[0])return nb(p.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+ -Db(k)+")");case 2:var n=k[0];if(n===k[1]){p=p.clone().valueOf();if(1===n)n=nb(p[0][0]);else if(2===n)n=c(f(p[0][0],p[1][1]),f(p[1][0],p[0][1]));else{p=l(p);k=p.U[0][0];for(var g=1;g=n)break;for(var q=e,r=0;!m[p.p[q]];)m[p.p[q]]=!0,q=p.p[q],r++;0==r%2&&g++}n=0==g%2?k:h(k)}return n}throw new RangeError("Matrix must be square (size: "+Db(k)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+Db(k)+")");}}})}),Io= -B("distance","typed addScalar subtract divideScalar multiplyScalar unaryMinus sqrt abs".split(" "),b=>{function a(t){return"number"==typeof t||pa(t)}function d(t){return t.constructor!==Array&&(t=l(t)),a(t[0])&&a(t[1])}function c(t){return t.constructor!==Array&&(t=l(t)),a(t[0])&&a(t[1])&&a(t[2])}function f(t){return Array.isArray(t)||(t=l(t)),t.every(a)}function h(t){return t.constructor!==Array&&(t=l(t)),a(t[0])&&a(t[1])&&a(t[2])&&a(t[3])&&a(t[4])&&a(t[5])}function l(t){for(var w=Object.keys(t), -z=[],I=0;I2!==z.length|| -!a(z[0])||!a(z[1])))return!1}else if(!(3===w[0].length&&a(w[0][0])&&a(w[0][1])&&a(w[0][2]))||w.some(z=>3!==z.length||!a(z[0])||!a(z[1])||!a(z[2])))return!1;return!0}(t))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return function(w){for(var z=[],I=[],F=[],L=0;L{var {typed:a,addScalar:d,subtract:c,multiplyScalar:f,divideScalar:h,pow:l,factorial:p,combinations:k,isNegative:n,isInteger:g,larger:e}=b;return a("stirlingS2",{"number | BigNumber, number | BigNumber":function(m,q){if(!g(m)||n(m)||!g(q)||n(q))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(e(q,m))throw new TypeError("k must be less than or equal to n in function stirlingS2"); -for(var r=p(q),u=0,y=0;y<=q;y++){var v=l(-1,c(q,y)),t=k(q,y),w=l(y,m);u=d(u,f(f(t,w),v))}return h(u,r)}})}),Ko=B("catalan","typed addScalar divideScalar multiplyScalar combinations isNegative isInteger".split(" "),b=>{var {typed:a,addScalar:d,divideScalar:c,multiplyScalar:f,combinations:h,isNegative:l,isInteger:p}=b;return a("catalan",{"number | BigNumber":function(k){if(!p(k)||l(k))throw new TypeError("Non-negative integer value expected in function catalan");return c(h(f(k,2),k),d(k,1))}})}),Lo= -B("log",["config","typed","divideScalar","Complex"],b=>{var {typed:a,config:d,divideScalar:c,Complex:f}=b;return a("log",{number:function(h){return 0<=h||d.predictable?Tf(h):(new f(h,0)).log()},Complex:function(h){return h.log()},BigNumber:function(h){return!h.isNegative()||d.predictable?h.ln():(new f(h.toNumber(),0)).log()},"Array | Matrix":function(h){return Na(h,this)},"any, any":function(h,l){return c(this(h),this(l))}})}),Mo=B("dotDivide",["typed","matrix","equalScalar","divideScalar","DenseMatrix"], -b=>{var {typed:a,matrix:d,equalScalar:c,divideScalar:f,DenseMatrix:h}=b,l=bd({typed:a,equalScalar:c}),p=Nc({typed:a}),k=kd({typed:a,DenseMatrix:h}),n=Fc({typed:a,equalScalar:c}),g=Oc({typed:a,DenseMatrix:h}),e=fc({typed:a}),m=Tb({typed:a});return a("dotDivide",{"any, any":f,"SparseMatrix, SparseMatrix":function(q,r){return k(q,r,f,!1)},"SparseMatrix, DenseMatrix":function(q,r){return l(r,q,f,!0)},"DenseMatrix, SparseMatrix":function(q,r){return p(q,r,f,!1)},"DenseMatrix, DenseMatrix":function(q,r){return e(q, -r,f)},"Array, Array":function(q,r){return this(d(q),d(r)).valueOf()},"Array, Matrix":function(q,r){return this(d(q),r)},"Matrix, Array":function(q,r){return this(q,d(r))},"SparseMatrix, any":function(q,r){return n(q,r,f,!1)},"DenseMatrix, any":function(q,r){return m(q,r,f,!1)},"any, SparseMatrix":function(q,r){return g(r,q,f,!0)},"any, DenseMatrix":function(q,r){return m(r,q,f,!0)},"Array, any":function(q,r){return m(d(q),r,f,!1).valueOf()},"any, Array":function(q,r){return m(d(r),q,f,!0).valueOf()}})}), -No=B("usolveAll","typed matrix divideScalar multiplyScalar subtract equalScalar DenseMatrix".split(" "),b=>{function a(g,e){e=[n(g,e,!0)._data.map(t=>t[0])];var m=g._data,q=g._size[0];for(g=g._size[1]-1;0<=g;g--)for(var r=e.length,u=0;u -new k({data:t.map(w=>[w]),size:[q,1]}))}var {typed:d,matrix:c,divideScalar:f,multiplyScalar:h,subtract:l,equalScalar:p,DenseMatrix:k}=b,n=pe({DenseMatrix:k});return d("usolveAll",{"SparseMatrix, Array | Matrix":function(g,e){return function(m,q){q=[n(m,q,!0)._data.map(ca=>ca[0])];var r=m._size[0],u=m._values,y=m._index,v=m._ptr;for(m=m._size[1]-1;0<=m;m--)for(var t=q.length,w=0;w=L;R--){var ba=y[R];ba===m?O=u[R]:banew k({data:ca.map(ka=>[ka]),size:[r,1]}))}(g,e)},"DenseMatrix, Array | Matrix":function(g,e){return a(g,e)},"Array, Array | Matrix":function(g,e){return a(c(g),e).map(m=>m.valueOf())}})}),Oo=B("hypot","typed abs addScalar divideScalar multiplyScalar sqrt smaller isPositive".split(" "), -b=>{var {typed:a,abs:d,addScalar:c,divideScalar:f,multiplyScalar:h,sqrt:l,smaller:p,isPositive:k}=b;return a("hypot",{"... number | BigNumber":function(n){for(var g=0,e=0,m=0;m{function a(t){var w,z=t._size[0],I=t._size[1],F=l([z],"dense"),L=F._data,O=t.clone(),R=O._data,ba=h([z],"");for(w=0;w{function a(e,m,q){var r;if(1===m){if(0===(m=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero"); -return[[f(1,m)]]}if(2===m){m=k(e);if(0===m)throw Error("Cannot calculate inverse, determinant is zero");return[[f(e[1][1],m),f(p(e[0][1]),m)],[f(p(e[1][0]),m),f(e[0][0],m)]]}var u=e.concat();for(e=0;et&&(t=g(u[e][v]),w=e),e++;if(0===t)throw Error("Cannot calculate inverse, determinant is zero");(e=w)!==v&&(r=u[v],u[v]=u[e],u[e]=r,r=y[v],y[v]=y[e],y[e]=r);var z=u[v],I=y[v];for(e=0;e{var {typed:a,abs:d,add:c,identity:f,inv:h,multiply:l}=b;return a("expm",{Matrix:function(p){var k=p.size();if(2!==k.length||k[0]!==k[1])throw new RangeError("Matrix must be square (size: "+ -Db(k)+")");var n=k[0];k=function(v,t){for(t=0;30>t;t++)for(var w=0;w<=t;w++){for(var z=t-w,I=1,F=2;F<=w;F++)I*=F;F=I;for(var L=w+1;L<=2*w;L++)F*=L;if(1E-15>8*Math.pow(v/Math.pow(2,z),2*w)*I*I/(F*F*(2*w+1)))return{q:w,j:z}}throw Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)");}(function(v){for(var t=v.size()[0],w=0,z=0;z{var {typed:a,matrix:d,multiply:c,equalScalar:f,divideScalar:h,inv:l}=b,p=Fc({typed:a,equalScalar:f}),k=Tb({typed:a});return a("divide",xd({"Array | Matrix, Array | Matrix":function(n,g){return c(n,l(g))}, -"DenseMatrix, any":function(n,g){return k(n,g,h,!1)},"SparseMatrix, any":function(n,g){return p(n,g,h,!1)},"Array, any":function(n,g){return k(d(n),g,h,!1).valueOf()},"any, Array | Matrix":function(n,g){return c(n,l(g))}},h.signatures))}),To=B("kldivergence","typed matrix divide sum multiply dotDivide log isNumeric".split(" "),b=>{function a(g,e){var m=e.size().length,q=g.size().length;if(1{var {typed:a,addScalar:d,isNegative:c,isInteger:f,stirlingS2:h}=b;return a("bellNumbers",{"number | BigNumber":function(l){if(!f(l)||c(l))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var p=0,k=0;k<=l;k++)p=d(p,h(l,k));return p}})}),Vo=B("log1p",["typed","config","divideScalar","log","Complex"],b=>{function a(p){var k= -p.re+1;return new l(Math.log(Math.sqrt(k*k+p.im*p.im)),Math.atan2(p.im,k))}var {typed:d,config:c,divideScalar:f,log:h,Complex:l}=b;return d("log1p",{number:function(p){return-1<=p||c.predictable?Mi(p):a(new l(p,0))},Complex:a,BigNumber:function(p){var k=p.plus(1);return!k.isNegative()||c.predictable?k.ln():a(new l(p.toNumber(),0))},"Array | Matrix":function(p){return Na(p,this)},"any, any":function(p,k){return f(this(p),h(k))}})}),Wo=B("Unit","?on config addScalar subtract multiplyScalar divideScalar pow abs fix round equal isNumeric format number Complex BigNumber Fraction".split(" "), -b=>{function a(M,Q){if(!(this instanceof a))throw Error("Constructor must be called with the new operator");if(null!=M&&!O(M)&&!rb(M))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(void 0!==Q&&("string"!=typeof Q||""===Q))throw new TypeError("Second parameter in Unit constructor must be a string");if(void 0!==Q)Q=a.parse(Q),this.units=Q.units,this.dimensions=Q.dimensions;else for(this.units=[{unit:ob,prefix:P.NONE,power:0}], -this.dimensions=[],Q=0;Q=M}function f(){e++;m=g.charAt(e)}function h(M){e=M;m=g.charAt(e)}function l(){var M="",Q=e;if("+"===m?f():"-"===m&&(M+=m,f()),!("0"<=m&&"9">=m||"."===m))return h(Q),null;if("."===m){if(M+=m,f(),!c(m))return h(Q),null}else{for(;c(m);)M+=m,f();"."===m&&(M+=m,f())}for(;c(m);)M+= -m,f();if("E"===m||"e"===m){Q="";var U=e;if(Q+=m,f(),"+"!==m&&"-"!==m||(Q+=m,f()),!c(m))return h(U),M;for(M+=Q;c(m);)M+=m,f()}return M}function p(M){return m===M?(f(),M):null}function k(M){return M.equalBase(S.NONE)&&null!==M.value&&!r.predictable?M.value:M}function n(M){"BigNumber"===M.number?(M=gf(ka),na.rad.value=new ka(1),na.deg.value=M.div(180),na.grad.value=M.div(200),na.cycle.value=M.times(2),na.arcsec.value=M.div(648E3),na.arcmin.value=M.div(10800)):(na.rad.value=1,na.deg.value=Math.PI/180, -na.grad.value=Math.PI/200,na.cycle.value=2*Math.PI,na.arcsec.value=Math.PI/648E3,na.arcmin.value=Math.PI/10800);na.radian.value=na.rad.value;na.degree.value=na.deg.value;na.gradian.value=na.grad.value}var g,e,m,{on:q,config:r,addScalar:u,subtract:y,multiplyScalar:v,divideScalar:t,pow:w,abs:z,fix:I,round:F,equal:L,isNumeric:O,format:R,number:ba,Complex:ca,BigNumber:ka,Fraction:Ea}=b;a.prototype.type="Unit";a.prototype.isUnit=!0;a.parse=function(M,Q){if(Q=Q||{},e=-1,m="","string"!=typeof(g=M))throw new TypeError("Invalid argument in Unit.parse, string expected"); -var U=new a;U.units=[];var ha=1,ja=!1;f();d();var wa=l(),gb=null;if(wa){if("BigNumber"===r.number)gb=new ka(wa);else if("Fraction"===r.number)try{gb=new Ea(wa)}catch(G){gb=parseFloat(wa)}else gb=parseFloat(wa);d();p("*")?(ha=1,ja=!0):p("/")&&(ha=-1,ja=!0)}wa=[];for(var Xa=1;;){for(d();"("===m;)wa.push(ha),Xa*=ha,ha=1,f(),d();if(!m)break;var pb=m;for(ja="";c(m)||a.isValidAlpha(m);)ja+=m,f();var sb=ja.charAt(0);if(null===(ja=a.isValidAlpha(sb)?ja:null))throw new SyntaxError('Unexpected "'+pb+'" in "'+ -g+'" at index '+e.toString());pb=Ga(ja);if(null===pb)throw new SyntaxError('Unit "'+ja+'" not found.');ja=ha*Xa;if(d(),p("^")){d();sb=l();if(null===sb)throw new SyntaxError('In "'+M+'", "^" must be followed by a floating-point number');ja*=sb}U.units.push({unit:pb.unit,prefix:pb.prefix,power:ja});for(sb=0;sb{if(Pa(na,M))return M=na[M],{unit:M,prefix:M.prefixes[""]};for(var Q in na){var U;if(U=Pa(na,Q))U=Q,U=M.substring(M.length-U.length,M.length)===U;if(U){U=na[Q]; -var ha=M.substring(0,M.length-Q.length);ha=Pa(U.prefixes,ha)?U.prefixes[ha]:void 0;if(void 0!==ha)return{unit:U,prefix:ha}}}return null},{hasher:M=>M[0],limit:100});a.isValuelessUnit=function(M){return null!==Ga(M)};a.prototype.hasBase=function(M){if("string"==typeof M&&(M=S[M]),!M)return!1;for(var Q=0;Qthis.units[ja].power&&ha++;if(0this.units[ja].power&&(0Math.abs(Q.value.re)),Q.units)Pa(Q.units,ha)&&Q.units[ha].unit&&("VA"===Q.units[ha].unit.name&&U?Q.units[ha].unit=na.VAR:"VAR"!==Q.units[ha].unit.name||U||(Q.units[ha].unit= -na.VA));1!==Q.units.length||Q.fixPrefix||1E-14>Math.abs(Q.units[0].power-Math.round(Q.units[0].power))&&(Q.units[0].prefix=Q._bestPrefix());U=Q._denormalize(Q.value);M=null!==Q.value?R(U,M||{}):"";U=Q.formatUnits();return Q.value&&rb(Q.value)&&(M="("+M+")"),0ja)return U;ja=Math.abs(ja);var wa=this.units[0].unit.prefixes,gb;for(gb in wa)if(Pa(wa,gb)){var Xa=wa[gb];if(Xa.scientific){var pb= -Math.abs(Math.log(M/Math.pow(Xa.value*Q,ha))/Math.LN10-1.2);(pb0)},na={meter:{name:"meter",base:S.LENGTH,prefixes:P.LONG,value:1,offset:0},inch:{name:"inch",base:S.LENGTH,prefixes:P.NONE,value:.0254,offset:0},foot:{name:"foot",base:S.LENGTH,prefixes:P.NONE,value:.3048,offset:0},yard:{name:"yard",base:S.LENGTH,prefixes:P.NONE,value:.9144,offset:0},mile:{name:"mile",base:S.LENGTH,prefixes:P.NONE,value:1609.344,offset:0},link:{name:"link",base:S.LENGTH,prefixes:P.NONE,value:.201168,offset:0},rod:{name:"rod", -base:S.LENGTH,prefixes:P.NONE,value:5.0292,offset:0},chain:{name:"chain",base:S.LENGTH,prefixes:P.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:S.LENGTH,prefixes:P.NONE,value:1E-10,offset:0},m:{name:"m",base:S.LENGTH,prefixes:P.SHORT,value:1,offset:0},in:{name:"in",base:S.LENGTH,prefixes:P.NONE,value:.0254,offset:0},ft:{name:"ft",base:S.LENGTH,prefixes:P.NONE,value:.3048,offset:0},yd:{name:"yd",base:S.LENGTH,prefixes:P.NONE,value:.9144,offset:0},mi:{name:"mi",base:S.LENGTH,prefixes:P.NONE, -value:1609.344,offset:0},li:{name:"li",base:S.LENGTH,prefixes:P.NONE,value:.201168,offset:0},rd:{name:"rd",base:S.LENGTH,prefixes:P.NONE,value:5.02921,offset:0},ch:{name:"ch",base:S.LENGTH,prefixes:P.NONE,value:20.1168,offset:0},mil:{name:"mil",base:S.LENGTH,prefixes:P.NONE,value:2.54E-5,offset:0},m2:{name:"m2",base:S.SURFACE,prefixes:P.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:S.SURFACE,prefixes:P.NONE,value:6.4516E-4,offset:0},sqft:{name:"sqft",base:S.SURFACE,prefixes:P.NONE,value:.09290304, -offset:0},sqyd:{name:"sqyd",base:S.SURFACE,prefixes:P.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:S.SURFACE,prefixes:P.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:S.SURFACE,prefixes:P.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:S.SURFACE,prefixes:P.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:S.SURFACE,prefixes:P.NONE,value:6.4516E-10,offset:0},acre:{name:"acre",base:S.SURFACE,prefixes:P.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:S.SURFACE, -prefixes:P.NONE,value:1E4,offset:0},m3:{name:"m3",base:S.VOLUME,prefixes:P.CUBIC,value:1,offset:0},L:{name:"L",base:S.VOLUME,prefixes:P.SHORT,value:.001,offset:0},l:{name:"l",base:S.VOLUME,prefixes:P.SHORT,value:.001,offset:0},litre:{name:"litre",base:S.VOLUME,prefixes:P.LONG,value:.001,offset:0},cuin:{name:"cuin",base:S.VOLUME,prefixes:P.NONE,value:1.6387064E-5,offset:0},cuft:{name:"cuft",base:S.VOLUME,prefixes:P.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:S.VOLUME,prefixes:P.NONE, -value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:S.VOLUME,prefixes:P.NONE,value:5E-6,offset:0},tablespoon:{name:"tablespoon",base:S.VOLUME,prefixes:P.NONE,value:1.5E-5,offset:0},drop:{name:"drop",base:S.VOLUME,prefixes:P.NONE,value:5E-8,offset:0},gtt:{name:"gtt",base:S.VOLUME,prefixes:P.NONE,value:5E-8,offset:0},minim:{name:"minim",base:S.VOLUME,prefixes:P.NONE,value:6.161152E-8,offset:0},fluiddram:{name:"fluiddram",base:S.VOLUME,prefixes:P.NONE,value:3.6966911E-6,offset:0},fluidounce:{name:"fluidounce", -base:S.VOLUME,prefixes:P.NONE,value:2.957353E-5,offset:0},gill:{name:"gill",base:S.VOLUME,prefixes:P.NONE,value:1.182941E-4,offset:0},cc:{name:"cc",base:S.VOLUME,prefixes:P.NONE,value:1E-6,offset:0},cup:{name:"cup",base:S.VOLUME,prefixes:P.NONE,value:2.365882E-4,offset:0},pint:{name:"pint",base:S.VOLUME,prefixes:P.NONE,value:4.731765E-4,offset:0},quart:{name:"quart",base:S.VOLUME,prefixes:P.NONE,value:9.463529E-4,offset:0},gallon:{name:"gallon",base:S.VOLUME,prefixes:P.NONE,value:.003785412,offset:0}, -beerbarrel:{name:"beerbarrel",base:S.VOLUME,prefixes:P.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:S.VOLUME,prefixes:P.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:S.VOLUME,prefixes:P.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:S.VOLUME,prefixes:P.NONE,value:3.6966911E-6,offset:0},floz:{name:"floz",base:S.VOLUME,prefixes:P.NONE,value:2.957353E-5,offset:0},gi:{name:"gi",base:S.VOLUME,prefixes:P.NONE,value:1.182941E-4,offset:0},cp:{name:"cp",base:S.VOLUME, -prefixes:P.NONE,value:2.365882E-4,offset:0},pt:{name:"pt",base:S.VOLUME,prefixes:P.NONE,value:4.731765E-4,offset:0},qt:{name:"qt",base:S.VOLUME,prefixes:P.NONE,value:9.463529E-4,offset:0},gal:{name:"gal",base:S.VOLUME,prefixes:P.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:S.VOLUME,prefixes:P.NONE,value:.1173478,offset:0},obl:{name:"obl",base:S.VOLUME,prefixes:P.NONE,value:.1589873,offset:0},g:{name:"g",base:S.MASS,prefixes:P.SHORT,value:.001,offset:0},gram:{name:"gram",base:S.MASS,prefixes:P.LONG, -value:.001,offset:0},ton:{name:"ton",base:S.MASS,prefixes:P.SHORT,value:907.18474,offset:0},t:{name:"t",base:S.MASS,prefixes:P.SHORT,value:1E3,offset:0},tonne:{name:"tonne",base:S.MASS,prefixes:P.LONG,value:1E3,offset:0},grain:{name:"grain",base:S.MASS,prefixes:P.NONE,value:6.479891E-5,offset:0},dram:{name:"dram",base:S.MASS,prefixes:P.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:S.MASS,prefixes:P.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:S.MASS,prefixes:P.NONE, -value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:S.MASS,prefixes:P.NONE,value:45.359237,offset:0},stick:{name:"stick",base:S.MASS,prefixes:P.NONE,value:.115,offset:0},stone:{name:"stone",base:S.MASS,prefixes:P.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:S.MASS,prefixes:P.NONE,value:6.479891E-5,offset:0},dr:{name:"dr",base:S.MASS,prefixes:P.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:S.MASS,prefixes:P.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:S.MASS, -prefixes:P.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:S.MASS,prefixes:P.NONE,value:45.359237,offset:0},s:{name:"s",base:S.TIME,prefixes:P.SHORT,value:1,offset:0},min:{name:"min",base:S.TIME,prefixes:P.NONE,value:60,offset:0},h:{name:"h",base:S.TIME,prefixes:P.NONE,value:3600,offset:0},second:{name:"second",base:S.TIME,prefixes:P.LONG,value:1,offset:0},sec:{name:"sec",base:S.TIME,prefixes:P.LONG,value:1,offset:0},minute:{name:"minute",base:S.TIME,prefixes:P.NONE,value:60,offset:0},hour:{name:"hour", -base:S.TIME,prefixes:P.NONE,value:3600,offset:0},day:{name:"day",base:S.TIME,prefixes:P.NONE,value:86400,offset:0},week:{name:"week",base:S.TIME,prefixes:P.NONE,value:604800,offset:0},month:{name:"month",base:S.TIME,prefixes:P.NONE,value:2629800,offset:0},year:{name:"year",base:S.TIME,prefixes:P.NONE,value:31557600,offset:0},decade:{name:"decade",base:S.TIME,prefixes:P.NONE,value:315576E3,offset:0},century:{name:"century",base:S.TIME,prefixes:P.NONE,value:315576E4,offset:0},millennium:{name:"millennium", -base:S.TIME,prefixes:P.NONE,value:315576E5,offset:0},hertz:{name:"Hertz",base:S.FREQUENCY,prefixes:P.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:S.FREQUENCY,prefixes:P.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:S.ANGLE,prefixes:P.SHORT,value:1,offset:0},radian:{name:"radian",base:S.ANGLE,prefixes:P.LONG,value:1,offset:0},deg:{name:"deg",base:S.ANGLE,prefixes:P.SHORT,value:null,offset:0},degree:{name:"degree",base:S.ANGLE,prefixes:P.LONG,value:null,offset:0},grad:{name:"grad", -base:S.ANGLE,prefixes:P.SHORT,value:null,offset:0},gradian:{name:"gradian",base:S.ANGLE,prefixes:P.LONG,value:null,offset:0},cycle:{name:"cycle",base:S.ANGLE,prefixes:P.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:S.ANGLE,prefixes:P.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:S.ANGLE,prefixes:P.NONE,value:null,offset:0},A:{name:"A",base:S.CURRENT,prefixes:P.SHORT,value:1,offset:0},ampere:{name:"ampere",base:S.CURRENT,prefixes:P.LONG,value:1,offset:0},K:{name:"K",base:S.TEMPERATURE, -prefixes:P.NONE,value:1,offset:0},degC:{name:"degC",base:S.TEMPERATURE,prefixes:P.NONE,value:1,offset:273.15},degF:{name:"degF",base:S.TEMPERATURE,prefixes:P.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:S.TEMPERATURE,prefixes:P.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:S.TEMPERATURE,prefixes:P.NONE,value:1,offset:0},celsius:{name:"celsius",base:S.TEMPERATURE,prefixes:P.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:S.TEMPERATURE,prefixes:P.NONE,value:1/1.8,offset:459.67}, -rankine:{name:"rankine",base:S.TEMPERATURE,prefixes:P.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:S.AMOUNT_OF_SUBSTANCE,prefixes:P.SHORT,value:1,offset:0},mole:{name:"mole",base:S.AMOUNT_OF_SUBSTANCE,prefixes:P.LONG,value:1,offset:0},cd:{name:"cd",base:S.LUMINOUS_INTENSITY,prefixes:P.SHORT,value:1,offset:0},candela:{name:"candela",base:S.LUMINOUS_INTENSITY,prefixes:P.LONG,value:1,offset:0},N:{name:"N",base:S.FORCE,prefixes:P.SHORT,value:1,offset:0},newton:{name:"newton",base:S.FORCE,prefixes:P.LONG, -value:1,offset:0},dyn:{name:"dyn",base:S.FORCE,prefixes:P.SHORT,value:1E-5,offset:0},dyne:{name:"dyne",base:S.FORCE,prefixes:P.LONG,value:1E-5,offset:0},lbf:{name:"lbf",base:S.FORCE,prefixes:P.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:S.FORCE,prefixes:P.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:S.FORCE,prefixes:P.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:S.FORCE,prefixes:P.NONE,value:9.80665,offset:0},J:{name:"J",base:S.ENERGY, -prefixes:P.SHORT,value:1,offset:0},joule:{name:"joule",base:S.ENERGY,prefixes:P.SHORT,value:1,offset:0},erg:{name:"erg",base:S.ENERGY,prefixes:P.NONE,value:1E-7,offset:0},Wh:{name:"Wh",base:S.ENERGY,prefixes:P.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:S.ENERGY,prefixes:P.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:S.ENERGY,prefixes:P.SHORT,value:1.602176565E-19,offset:0},electronvolt:{name:"electronvolt",base:S.ENERGY,prefixes:P.LONG,value:1.602176565E-19,offset:0},W:{name:"W",base:S.POWER, -prefixes:P.SHORT,value:1,offset:0},watt:{name:"watt",base:S.POWER,prefixes:P.LONG,value:1,offset:0},hp:{name:"hp",base:S.POWER,prefixes:P.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:S.POWER,prefixes:P.SHORT,value:ca.I,offset:0},VA:{name:"VA",base:S.POWER,prefixes:P.SHORT,value:1,offset:0},Pa:{name:"Pa",base:S.PRESSURE,prefixes:P.SHORT,value:1,offset:0},psi:{name:"psi",base:S.PRESSURE,prefixes:P.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:S.PRESSURE,prefixes:P.NONE,value:101325, -offset:0},bar:{name:"bar",base:S.PRESSURE,prefixes:P.SHORTLONG,value:1E5,offset:0},torr:{name:"torr",base:S.PRESSURE,prefixes:P.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:S.PRESSURE,prefixes:P.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:S.PRESSURE,prefixes:P.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:S.PRESSURE,prefixes:P.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:S.ELECTRIC_CHARGE,prefixes:P.LONG,value:1,offset:0},C:{name:"C",base:S.ELECTRIC_CHARGE,prefixes:P.SHORT, -value:1,offset:0},farad:{name:"farad",base:S.ELECTRIC_CAPACITANCE,prefixes:P.LONG,value:1,offset:0},F:{name:"F",base:S.ELECTRIC_CAPACITANCE,prefixes:P.SHORT,value:1,offset:0},volt:{name:"volt",base:S.ELECTRIC_POTENTIAL,prefixes:P.LONG,value:1,offset:0},V:{name:"V",base:S.ELECTRIC_POTENTIAL,prefixes:P.SHORT,value:1,offset:0},ohm:{name:"ohm",base:S.ELECTRIC_RESISTANCE,prefixes:P.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:S.ELECTRIC_INDUCTANCE,prefixes:P.LONG,value:1,offset:0},H:{name:"H", -base:S.ELECTRIC_INDUCTANCE,prefixes:P.SHORT,value:1,offset:0},siemens:{name:"siemens",base:S.ELECTRIC_CONDUCTANCE,prefixes:P.LONG,value:1,offset:0},S:{name:"S",base:S.ELECTRIC_CONDUCTANCE,prefixes:P.SHORT,value:1,offset:0},weber:{name:"weber",base:S.MAGNETIC_FLUX,prefixes:P.LONG,value:1,offset:0},Wb:{name:"Wb",base:S.MAGNETIC_FLUX,prefixes:P.SHORT,value:1,offset:0},tesla:{name:"tesla",base:S.MAGNETIC_FLUX_DENSITY,prefixes:P.LONG,value:1,offset:0},T:{name:"T",base:S.MAGNETIC_FLUX_DENSITY,prefixes:P.SHORT, -value:1,offset:0},b:{name:"b",base:S.BIT,prefixes:P.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:S.BIT,prefixes:P.BINARY_LONG,value:1,offset:0},B:{name:"B",base:S.BIT,prefixes:P.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:S.BIT,prefixes:P.BINARY_LONG,value:8,offset:0}};b={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"};n(r);q&&q("config",function(M,Q){M.number!==Q.number&&n(M)});var X={si:{NONE:{unit:ob,prefix:P.NONE[""]},LENGTH:{unit:na.m,prefix:P.SHORT[""]},MASS:{unit:na.g,prefix:P.SHORT.k},TIME:{unit:na.s,prefix:P.SHORT[""]},CURRENT:{unit:na.A,prefix:P.SHORT[""]},TEMPERATURE:{unit:na.K,prefix:P.SHORT[""]},LUMINOUS_INTENSITY:{unit:na.cd,prefix:P.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:na.mol,prefix:P.SHORT[""]}, -ANGLE:{unit:na.rad,prefix:P.SHORT[""]},BIT:{unit:na.bits,prefix:P.SHORT[""]},FORCE:{unit:na.N,prefix:P.SHORT[""]},ENERGY:{unit:na.J,prefix:P.SHORT[""]},POWER:{unit:na.W,prefix:P.SHORT[""]},PRESSURE:{unit:na.Pa,prefix:P.SHORT[""]},ELECTRIC_CHARGE:{unit:na.C,prefix:P.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:na.F,prefix:P.SHORT[""]},ELECTRIC_POTENTIAL:{unit:na.V,prefix:P.SHORT[""]},ELECTRIC_RESISTANCE:{unit:na.ohm,prefix:P.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:na.H,prefix:P.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:na.S, -prefix:P.SHORT[""]},MAGNETIC_FLUX:{unit:na.Wb,prefix:P.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:na.T,prefix:P.SHORT[""]},FREQUENCY:{unit:na.Hz,prefix:P.SHORT[""]}}};X.cgs=JSON.parse(JSON.stringify(X.si));X.cgs.LENGTH={unit:na.m,prefix:P.SHORT.c};X.cgs.MASS={unit:na.g,prefix:P.SHORT[""]};X.cgs.FORCE={unit:na.dyn,prefix:P.SHORT[""]};X.cgs.ENERGY={unit:na.erg,prefix:P.NONE[""]};X.us=JSON.parse(JSON.stringify(X.si));X.us.LENGTH={unit:na.ft,prefix:P.NONE[""]};X.us.MASS={unit:na.lbm,prefix:P.NONE[""]};X.us.TEMPERATURE= -{unit:na.degF,prefix:P.NONE[""]};X.us.FORCE={unit:na.lbf,prefix:P.NONE[""]};X.us.ENERGY={unit:na.BTU,prefix:P.BTU[""]};X.us.POWER={unit:na.hp,prefix:P.NONE[""]};X.us.PRESSURE={unit:na.psi,prefix:P.NONE[""]};X.auto=JSON.parse(JSON.stringify(X.si));var da=X.auto;for(Ha in a.setUnitSystem=function(M){if(!Pa(X,M))throw Error("Unit system "+M+" does not exist. Choices are: "+Object.keys(X).join(", "));da=X[M]},a.getUnitSystem=function(){for(var M in X)if(Pa(X,M)&&X[M]===da)return M},a.typeConverters={BigNumber:function(M){return new ka(M+ -"")},Fraction:function(M){return new Ea(M)},Complex:function(M){return M},number:function(M){return M}},a._getNumberConverter=function(M){if(!a.typeConverters[M])throw new TypeError('Unsupported type "'+M+'"');return a.typeConverters[M]},na)if(Pa(na,Ha)){var ua=na[Ha];ua.dimensions=ua.base.dimensions}for(var Da in b)if(Pa(b,Da)){var Ha=na[b[Da]];ua={};for(var Ka in Ha)Pa(Ha,Ka)&&(ua[Ka]=Ha[Ka]);ua.name=Da;na[Da]=ua}return a.isValidAlpha=function(M){return/^[a-zA-Z]$/.test(M)},a.createUnit=function(M, -Q){if("object"!=typeof M)throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(Q&&Q.override)for(var U in M)if(Pa(M,U)&&a.deleteUnit(U),M[U].aliases)for(Q=0;Q{var {typed:a,Unit:d}=b;return a("createUnit",{"Object, Object":function(c,f){return d.createUnit(c,f)},Object:function(c){return d.createUnit(c,{})},"string, Unit | string | Object, Object":function(c,f,h){var l={};return l[c]=f,d.createUnit(l,h)},"string, Unit | string | Object":function(c, -f){var h={};return h[c]=f,d.createUnit(h,{})},string:function(c){var f={};return f[c]={},d.createUnit(f,{})}})}),Zo=B("eigs","config typed matrix addScalar equal subtract abs atan cos sin multiplyScalar divideScalar inv bignumber multiply add larger column flatten number complex sqrt diag qr usolveAll im re smaller round log10 transpose matrixFromColumns".split(" "),b=>{function a(da,ua){void 0===ua&&(ua=c.epsilon);var Da=da.size();if(2!==Da.length||Da[0]!==Da[1])throw new RangeError("Matrix must be square (size: "+ -Db(Da)+")");var Ha=da.toArray();Da=Da[0];if(function(Ka,M,Q){for(var U=0;U=Math.abs(dc);){var kb=$a[0][0];Ya=$a[0][1];var Wa=Ja,tb=(Ub=Ja[kb][kb],bc=Ja[Ya][Ya],hb=Ja[kb][Ya],oa=void 0,oa=bc-Ub,$a=Math.abs(oa)<=M.epsilon?Math.PI/4:.5*Math.atan(2*hb/(bc-Ub)));Ja=kb;var ib=Ya,oc=Wa.length,bb=Math.cos(tb),ec=Math.sin(tb),nc=bb*bb,ab=ec*ec;tb=Ka(oc,0);var Ib=Ka(oc,0),ac=nc*Wa[Ja][Ja]-2*bb*ec*Wa[Ja][ib]+ab*Wa[ib][ib];nc=ab*Wa[Ja][Ja]+2*bb*ec*Wa[Ja][ib]+nc*Wa[ib][ib];for(ab=0;ab=ha(bc);){oa=Ja[0][0];Ja=Ja[0][1];Wa=kb;tb=(Eb=kb[oa][oa],dc=kb[Ja][Ja],$a=kb[oa][Ja],Ab=void 0,Ab=U(dc,Eb),Ya=ha(Ab)<=M.epsilon?sb(-1).acos().div(4):Xa(.5,ja(G(2,$a,pb(Ab)))));kb=oa;ib=Ja;oc=Wa.length;bb=sb(wa(tb));ec=sb(gb(tb));nc=Xa(bb,bb);ab=Xa(ec,ec);tb=Ka(oc,sb(0));Ib=Ka(oc,sb(0));var wb=G(sb(2),bb,ec,Wa[kb][ib]);ac=Q(U(Xa(nc, -Wa[kb][kb]),wb),Xa(ab,Wa[ib][ib]));nc=ma(Xa(ab,Wa[kb][kb]),wb,Xa(nc,Wa[ib][ib]));for(ab=0;ab=re;){re+=1;for(var ic=0;ic+M(gb(Rd),gb(Ed))),100U(ac,yc))).shift();qc.lengthQ(yc)))}if(0!==Jb.length)throw ab=Error("Failed to find eigenvectors for the following eigenvalues: "+Jb.join(", ")),ab.values=Ub,ab.vectors=bc,ab;return bc}(Ab,kb,nc,ec,Wa),bb=dc(...bb)),{values:ec,vectors:bb}}}({config:c,addScalar:l,subtract:p,multiply:v,multiplyScalar:q,flatten:I,divideScalar:r,sqrt:O,abs:n,bignumber:y,diag:R,qr:ba,inv:u,usolveAll:ca, -equal:k,complex:L,larger:w,smaller:Ga,round:P,log10:Ma,transpose:S,matrixFromColumns:ob});return f("eigs",{Array:function(da){return a(h(da))},"Array, number|BigNumber":function(da,ua){return a(h(da),ua)},Matrix:function(da){var {values:ua,vectors:Da}=a(da);return{values:h(ua),vectors:h(Da)}},"Matrix, number|BigNumber":function(da,ua){var {values:Da,vectors:Ha}=a(da,ua);return{values:h(Da),vectors:h(Ha)}}})}),$o=B("intersect","typed config abs add addScalar matrix multiply multiplyScalar divideScalar subtract smaller equalScalar".split(" "), -b=>{function a(v){return"number"==typeof v||pa(v)}function d(v){return 2===v.length&&a(v[0])&&a(v[1])}function c(v){return 3===v.length&&a(v[0])&&a(v[1])&&a(v[2])}function f(v,t,w,z,I,F,L,O,R,ba,ca,ka){v=m(r(v,t),r(w,z));I=m(r(I,F),r(L,O));R=m(r(R,ba),r(ca,ka));return n(n(v,I),R)}var {typed:h,config:l,abs:p,add:k,addScalar:n,matrix:g,multiply:e,multiplyScalar:m,divideScalar:q,subtract:r,smaller:u,equalScalar:y}=b;return h("intersect",{"Array, Array, Array":function(v,t,w){if(!c(v))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument"); -if(!c(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!function(z){return 4===z.length&&a(z[0])&&a(z[1])&&a(z[2])&&a(z[3])}(w))throw new TypeError("Array with 4 numbers expected as third argument");return function(z,I,F,L,O,R,ba,ca,ka,Ea){var Ga=m(z,ba);ba=m(L,ba);var P=m(I,ca);ca=m(O,ca);var Ma=m(F,ka);ka=m(R,ka);Ea=q(r(r(r(Ea,Ga),P),Ma),r(r(r(n(n(ba,ca),ka),Ga),P),Ma));return[n(z,m(Ea,r(L,z))),n(I,m(Ea,r(O,I))),n(F,m(Ea,r(R,F)))]}(v[0],v[1],v[2],t[0], -t[1],t[2],w[0],w[1],w[2],w[3])},"Array, Array, Array, Array":function(v,t,w,z){if(2===v.length){if(!d(v))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!d(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!d(w))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!d(z))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");t=r(v,t);var I=r(w,z);z= -r(m(t[0],I[1]),m(I[0],t[1]));if(u(p(z),l.epsilon))v=null;else{var F=m(I[0],v[1]),L=m(I[1],v[0]),O=m(I[0],w[1]);w=m(I[1],w[0]);w=q(n(r(r(F,L),O),w),z);v=k(e(t,w),v)}return v}if(3===v.length){if(!c(v))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!c(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!c(w))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!c(z))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument"); -return F=v[0],L=v[1],O=v[2],I=t[0],R=t[1],ba=t[2],ca=w[0],ka=w[1],Ea=w[2],S=f(F,ca,Ga=z[0],ca,L,ka,P=z[1],ka,O,Ea,Ma=z[2],Ea),ob=f(Ga,ca,I,F,P,ka,R,L,Ma,Ea,ba,O),na=f(F,ca,I,F,L,ka,R,L,O,Ea,ba,O),X=f(Ga,ca,Ga,ca,P,ka,P,ka,Ma,Ea,Ma,Ea),da=f(I,F,I,F,R,L,R,L,ba,O,ba,O),ua=q(r(m(S,ob),m(na,X)),r(m(da,X),m(ob,ob))),Da=q(n(S,m(ua,ob)),X),Ha=n(F,m(ua,r(I,F))),Ka=n(L,m(ua,r(R,L))),M=n(O,m(ua,r(ba,O))),Q=n(ca,m(Da,r(Ga,ca))),U=n(ka,m(Da,r(P,ka))),ha=n(Ea,m(Da,r(Ma,Ea))),y(Ha,Q)&&y(Ka,U)&&y(M,ha)?[Ha,Ka,M]: -null}throw new TypeError("Arrays with two or thee dimensional points expected");var R,ba,ca,ka,Ea,Ga,P,Ma,S,ob,na,X,da,ua,Da,Ha,Ka,M,Q,U,ha},"Matrix, Matrix, Matrix":function(v,t,w){return g(this(v.valueOf(),t.valueOf(),w.valueOf()))},"Matrix, Matrix, Matrix, Matrix":function(v,t,w,z){return g(this(v.valueOf(),t.valueOf(),w.valueOf(),z.valueOf()))}})}),ap=B("usolve","typed matrix divideScalar multiplyScalar subtract equalScalar DenseMatrix".split(" "),b=>{function a(g,e){e=n(g,e,!0)._data;var m=g._size[0], -q=[],r=g._data;for(g=g._size[1]-1;0<=g;g--){var u=e[g][0]||0;if(p(u,0))u=0;else{var y=r[g][g];if(p(y,0))throw Error("Linear system cannot be solved since matrix is singular");u=f(u,y);for(y=g-1;0<=y;y--)e[y]=[l(e[y][0]||0,h(u,r[y][g]))]}q[g]=[u]}return new k({data:q,size:[m,1]})}var {typed:d,matrix:c,divideScalar:f,multiplyScalar:h,subtract:l,equalScalar:p,DenseMatrix:k}=b,n=pe({DenseMatrix:k});return d("usolve",{"SparseMatrix, Array | Matrix":function(g,e){e=n(g,e,!0)._data;var m=g._size[0],q=g._values, -r=g._index,u=g._ptr,y=[];for(g=g._size[1]-1;0<=g;g--){var v=e[g][0]||0;if(p(v,0))y[g]=[0];else{for(var t=0,w=[],z=[],I=u[g],F=u[g+1]-1;F>=I;F--){var L=r[F];L===g?t=q[F]:L{function a(u,y){var v=u.size();if(1===v.length)return function(t,w){if(w===Number.POSITIVE_INFINITY||"inf"===w)return function(I){var F=0;return I.forEach(function(L){L=c(L);g(L,F)&&(F=L)},!0),F}(t);if(w===Number.NEGATIVE_INFINITY||"-inf"===w)return function(I){var F;return I.forEach(function(L){L=c(L);F&&!e(L,F)||(F=L)},!0),F||0}(t);if("fro"===w)return a(t,2);if("number"== -typeof w&&!isNaN(w)){if(!n(w,0)){var z=0;return t.forEach(function(I){z=f(h(c(I),w),z)},!0),h(z,1/w)}return Number.POSITIVE_INFINITY}throw Error("Unsupported parameter value");}(u,y);if(2===v.length){if(v[0]&&v[1])return function(t,w){if(1===w)return function(z){var I=[],F=0;return z.forEach(function(L,O){O=O[1];L=f(I[O]||0,c(L));g(L,F)&&(F=L);I[O]=L},!0),F}(t);if(w===Number.POSITIVE_INFINITY||"inf"===w)return function(z){var I=[],F=0;return z.forEach(function(L,O){O=O[0];L=f(I[O]||0,c(L));g(L,F)&& -(F=L);I[O]=L},!0),F}(t);if("fro"===w)return function(z){var I=0;return z.forEach(function(F,L){I=f(I,k(F,l(F)))}),c(p(I))}(t);if(2===w)return function(z){var I=z.size();if(I[0]!==I[1])throw new RangeError("Invalid matrix dimensions");I=q(z);z=k(I,z);z=r(z).values.toArray();return c(p(z[z.length-1]))}(t);throw Error("Unsupported parameter value "+w);}(u,y);throw new RangeError("Invalid matrix dimensions");}}var {typed:d,abs:c,add:f,pow:h,conj:l,sqrt:p,multiply:k,equalScalar:n,larger:g,smaller:e,matrix:m, -ctranspose:q,eigs:r}=b;return d("norm",{number:Math.abs,Complex:function(u){return u.abs()},BigNumber:function(u){return u.abs()},boolean:function(u){return Math.abs(u)},Array:function(u){return a(m(u),2)},Matrix:function(u){return a(u,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(u){return this(u)},"Array, number | BigNumber | string":function(u,y){return a(m(u),y)},"Matrix, number | BigNumber | string":function(u,y){return a(u,y)}})}),cp=B("lusolve","typed matrix lup slu usolve lsolve DenseMatrix".split(" "), -b=>{function a(e){if(Fa(e))return e;if($b(e))return f(e);throw new TypeError("Invalid Matrix LU decomposition");}function d(e,m,q,r,u){e=a(e);m=a(m);q&&((u=g(e,u,!0))._data=Lg(q,u._data));e=k(e,u);m=p(m,e);return r&&(m._data=Lg(r,m._data)),m}var {typed:c,matrix:f,lup:h,slu:l,usolve:p,lsolve:k,DenseMatrix:n}=b,g=pe({DenseMatrix:n});return c("lusolve",{"Array, Array | Matrix":function(e,m){e=f(e);e=h(e);return d(e.L,e.U,e.p,null,m).valueOf()},"DenseMatrix, Array | Matrix":function(e,m){e=h(e);return d(e.L, -e.U,e.p,null,m)},"SparseMatrix, Array | Matrix":function(e,m){e=h(e);return d(e.L,e.U,e.p,null,m)},"SparseMatrix, Array | Matrix, number, number":function(e,m,q,r){e=l(e,q,r);return d(e.L,e.U,e.p,e.q,m)},"Object, Array | Matrix":function(e,m){return d(e.L,e.U,e.p,e.q,m)}})}),dp=B("sqrtm","typed abs add multiply sqrt subtract inv size max identity".split(" "),b=>{var {typed:a,abs:d,add:c,multiply:f,sqrt:h,subtract:l,inv:p,size:k,max:n,identity:g}=b;return a("sqrtm",{"Array | Matrix":function(e){var m= -Fa(e)?e.size():Ua(e);switch(m.length){case 1:if(1===m[0])return h(e);throw new RangeError("Matrix must be square (size: "+Db(m)+")");case 2:if(m[0]===m[1]){m=0;var q=e,r=g(k(e));do{var u=q;if(q=f(.5,c(u,p(r))),r=f(.5,c(r,p(u))),1E-6<(e=n(d(l(q,u))))&&1E3<++m)throw Error("computing square root of matrix: iterative method could not converge");}while(1E-6{var {typed:a,add:d,divide:c,multiply:f,factorial:h,isInteger:l,isPositive:p}=b;return a("multinomial",{"Array | Matrix":function(k){var n=0,g=1;return Zb(k,function(e){if(!l(e)||!p(e))throw new TypeError("Positive integer value expected in function multinomial");n=d(n,e);g=f(g,h(e))}),c(h(n),g)}})}),fp=B("rotationMatrix","typed config multiplyScalar addScalar unaryMinus norm matrix BigNumber DenseMatrix SparseMatrix cos sin".split(" "), -b=>{function a(t,w){var z=pa(t)?new m(-1):-1,I=y(t);t=v(t);return f([[I,k(z,t)],[t,I]],w)}function d(t){t=t.size();if(1>t.length||3!==t[0])throw new RangeError("Vector must be of dimensions 1x3");}function c(t){return t.reduce((w,z)=>k(w,z))}function f(t,w){if(w){if("sparse"===w)return new u(t);if("dense"===w)return new r(t);throw new TypeError('Unknown matrix type "'.concat(w,'"'));}return t}function h(t,w,z){var I=e(w);if(0===I)throw new RangeError("Rotation around zero vector");var F=pa(t)?m:null, -L=F?new F(1):1,O=F?new F(-1):-1,R=F?new F(w.get([0])/I):w.get([0])/I,ba=F?new F(w.get([1])/I):w.get([1])/I;w=F?new F(w.get([2])/I):w.get([2])/I;I=y(t);L=n(L,g(I));t=v(t);return f([[n(I,c([R,R,L])),n(c([R,ba,L]),c([O,w,t])),n(c([R,w,L]),c([ba,t]))],[n(c([R,ba,L]),c([w,t])),n(I,c([ba,ba,L])),n(c([ba,w,L]),c([O,R,t]))],[n(c([R,w,L]),c([O,ba,t])),n(c([ba,w,L]),c([R,t])),n(I,c([w,w,L]))]],z)}var {typed:l,config:p,multiplyScalar:k,addScalar:n,unaryMinus:g,norm:e,BigNumber:m,matrix:q,DenseMatrix:r,SparseMatrix:u, -cos:y,sin:v}=b;return l("rotationMatrix",{"":function(){return"Matrix"===p.matrix?q([]):[]},string:function(t){return q(t)},"number | BigNumber | Complex | Unit":function(t){return a(t,"Matrix"===p.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(t,w){return a(t,w)},"number | BigNumber | Complex | Unit, Array":function(t,w){w=q(w);return d(w),h(t,w,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(t,w){d(w);var z=w.storage()||("Matrix"===p.matrix?"dense": -void 0);return h(t,w,z)},"number | BigNumber | Complex | Unit, Array, string":function(t,w,z){w=q(w);return d(w),h(t,w,z)},"number | BigNumber | Complex | Unit, Matrix, string":function(t,w,z){return d(w),h(t,w,z)}})}),gp=B("median",["typed","add","divide","compare","partitionSelect"],b=>{function a(n){try{var g=(n=C(n.valueOf())).length;if(0===g)throw Error("Cannot calculate median of an empty array");if(0==g%2){g=g/2-1;for(var e=l(n,g+1),m=n[g],q=0;q{function a(h,l){h=Array.isArray(h)?Ua(h):h.size();if(2{function a(p){if(0===(p=C(p.valueOf())).length)throw Error("Cannot calculate median absolute deviation (mad) of an empty array"); -try{var k=h(p);return h(f(p,function(n){return c(l(n,k))}))}catch(n){throw n instanceof TypeError&&-1!==n.message.indexOf("median")?new TypeError(n.message.replace("median","mad")):Tc(n,"mad");}}var {typed:d,abs:c,map:f,median:h,subtract:l}=b;return d("mad",{"Array | Matrix":a,"...":function(p){return a(p)}})}),jp=B("unit",["typed","Unit"],b=>{var {typed:a,Unit:d}=b;return a("unit",{Unit:function(c){return c.clone()},string:function(c){return d.isValuelessUnit(c)?new d(null,c):d.parse(c,{allowNoUnits:!0})}, -"number | BigNumber | Fraction | Complex, string":function(c,f){return new d(c,f)},"Array | Matrix":function(c){return Na(c,this)}})}),mh=Lj({}),mc=Mj({}),nh=Nj({}),kp=Vj({}),lp=Wj({}),mp=Uj({}),La=lk({config:sa}),Oe=mk({}),np=nk({}),op=jk({Complex:mc}),pp=ek({BigNumber:La,config:sa}),qp=gk({BigNumber:La,config:sa}),rp=Yj({BigNumber:La,config:sa}),oh=Zj({BigNumber:La,config:sa}),sp=hk({BigNumber:La,config:sa}),tp=ak({BigNumber:La,config:sa}),up=Qk({BigNumber:La,config:sa}),vp=Hk({BigNumber:La,config:sa}), -wp=$k({BigNumber:La,config:sa}),xp=Pk({BigNumber:La,config:sa}),Sd=ll({}),ph=bk({BigNumber:La,config:sa}),yp=Xj({BigNumber:La,config:sa}),zp=fk({BigNumber:La,config:sa}),Ap=kk({}),Kb=ml({Matrix:Oe}),Bp=ck({BigNumber:La,config:sa}),W=nl({BigNumber:La,Complex:mc,DenseMatrix:Kb,Fraction:Sd}),cd=ol({typed:W}),ge=pl({typed:W}),Pe=ql({typed:W}),se=rl({typed:W}),Qb=sl({config:sa,typed:W}),Td=tl({typed:W}),Cp=ul({typed:W}),Qe=vl({Complex:mc,typed:W}),Dp=wl({typed:W}),Ep=xl({BigNumber:La,config:sa,typed:W}), -nf=Ug({isInteger:cd,typed:W}),Fp=yl({typed:W}),Gp=zl({Complex:mc,typed:W}),qh=Al({Complex:mc,config:sa,typed:W}),sc=Bl({typed:W}),rh=Cl({BigNumber:La,Fraction:Sd,complex:Qe,typed:W}),Hp=Dl({typed:W}),Ip=El({typed:W}),Jp=Fl({typed:W}),sh=Gl({typed:W}),th=Hl({typed:W}),Kp=Il({typed:W}),Lp=Jl({typed:W}),uh=Kl({typed:W}),Mp=Ol({typed:W}),te=Pl({typed:W}),Np=Ql({format:te,typed:W}),Op=Rl({typed:W}),Pp=Sl({typed:W}),Qp=Tl({Complex:mc,config:sa,typed:W}),Rp=Ul({BigNumber:La,typed:W}),Sp=Vl({BigNumber:La, -Complex:mc,config:sa,typed:W}),Tp=Wl({BigNumber:La,Complex:mc,config:sa,typed:W}),Up=Xl({Complex:mc,config:sa,typed:W}),vh=Yl({typed:W}),Vp=Zl({Complex:mc,config:sa,typed:W}),Wp=$l({typed:W}),Xp=am({BigNumber:La,typed:W}),Yp=bm({BigNumber:La,typed:W}),Zp=cm({BigNumber:La,typed:W}),$p=dm({typed:W}),aq=em({typed:W}),Re=fm({typed:W}),bq=gm({config:sa,typed:W}),cq=hm({config:sa,typed:W}),dq=dk({BigNumber:La,config:sa}),eq=im({typed:W}),fq=jm({isNumeric:ge,typed:W}),gq=km({typed:W}),hq=lm({typed:W}),ue= -mm({Fraction:Sd,typed:W}),rd=nm({typed:W}),zc=om({typed:W}),iq=pm({typed:W}),jq=qm({Complex:mc,config:sa,typed:W}),sd=rm({Complex:mc,config:sa,typed:W}),ve=sm({typed:W}),kq=tm({typed:W}),lq=um({isNaN:se,isNumeric:ge,typed:W}),mq=vm({format:te,typed:W}),nq=wm({Complex:mc,config:sa,typed:W}),oq=xm({BigNumber:La,typed:W}),pq=ym({typed:W}),of=zm({typed:W}),qq=Am({BigNumber:La,typed:W}),pf=Bm({typed:W}),rq=Cm({typed:W}),sq=Dm({config:sa,typed:W}),tq=ik({BigNumber:La,config:sa}),he=Em({typed:W}),td=Fm({Matrix:Oe, -equalScalar:Qb,typed:W}),Ta=Gm({DenseMatrix:Kb,Matrix:Oe,SparseMatrix:td,typed:W}),Vc=Hm({typed:W}),uq=Im({BigNumber:La,DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,typed:W}),vq=Jm({DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,typed:W}),wq=Km({BigNumber:La,equalScalar:Qb,matrix:Ta,typed:W}),xq=Lm({BigNumber:La,config:sa,matrix:Ta,typed:W}),yq=Mm({equalScalar:Qb,matrix:Ta,typed:W}),zq=Nm({DenseMatrix:Kb,matrix:Ta,typed:W}),Aq=Om({DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,typed:W}),qf=Wg({isInteger:cd,matrix:Ta, -typed:W}),wh=Pm({DenseMatrix:Kb,SparseMatrix:td,matrix:Ta,typed:W}),ie=Qm({BigNumber:La,DenseMatrix:Kb,SparseMatrix:td,config:sa,matrix:Ta,typed:W}),Bq=Rm({BigNumber:La,config:sa,matrix:Ta,typed:W}),Cq=Sm({isInteger:cd,matrix:Ta,typed:W}),Hc=Tm({matrix:Ta,config:sa,typed:W}),Xc=Vg({matrix:Ta,typed:W}),Ud=Um({BigNumber:La,config:sa,matrix:Ta,typed:W}),Dq=Vm({format:te,typed:W}),we=Xm({BigNumber:La,DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,typed:W,zeros:Ud}),Eq=Ym({DenseMatrix:Kb,equalScalar:Qb,matrix:Ta, -typed:W,zeros:Ud}),Fq=Zm({DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,typed:W,zeros:Ud}),je=$m({BigNumber:La,DenseMatrix:Kb,Fraction:Sd,config:sa,equalScalar:Qb,matrix:Ta,typed:W}),xh=an({matrix:Ta,typed:W}),dd=bn({DenseMatrix:Kb,config:sa,matrix:Ta,typed:W}),Yc=cn({DenseMatrix:Kb,config:sa,matrix:Ta,typed:W}),Gq=dn({DenseMatrix:Kb,config:sa,equalScalar:Qb,matrix:Ta,typed:W}),yh=en({DenseMatrix:Kb,smaller:dd}),zh=fn({larger:Yc,smaller:dd}),Hq=gn({SparseMatrix:td,typed:W}),Iq=hn({BigNumber:La,Complex:mc, -config:sa,typed:W}),Jq=jn({BigNumber:La,DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,typed:W}),Kq=kn({BigNumber:La,typed:W}),Ac=ln({DenseMatrix:Kb,SparseMatrix:td,addScalar:zc,equalScalar:Qb,matrix:Ta,typed:W}),Ah=mn({addScalar:zc,conj:ve,multiplyScalar:sc,size:Hc,typed:W}),Lq=nn({addScalar:zc,combinations:Re,isInteger:cd,isNegative:he,isPositive:Pe,larger:Yc,typed:W}),Vd=on({typed:W}),Mq=pn({isZero:Vd,matrix:Ta,typed:W}),Nq=qn({BigNumber:La,Complex:mc,Fraction:Sd,config:sa,isNegative:he,matrix:Ta,typed:W, -unaryMinus:rd}),Bh=rn({config:sa,equalScalar:Qb,matrix:Ta,round:we,typed:W}),vc=sn({addScalar:zc,dot:Ah,equalScalar:Qb,matrix:Ta,multiplyScalar:sc,typed:W}),Oq=tn({equalScalar:Qb,matrix:Ta,multiplyScalar:sc,typed:W}),Ch=un({typed:W}),Se=vn({matrix:Ta,typed:W}),Pq=wn({config:sa,matrix:Ta}),Qq=xn({matrix:Ta,typed:W}),Rq=yn({matrix:Ta,typed:W}),Gd=zn({Complex:mc,config:sa,fraction:ue,identity:ie,matrix:Ta,multiply:vc,number:Td,typed:W}),Sq=An({DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,pow:Gd,typed:W}), -Tq=Bn({DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,typed:W,zeros:Ud}),ld=Cn({compare:je,typed:W}),Uq=Dn({compareText:xh,isZero:Vd,typed:W}),Te=En({DenseMatrix:Kb,config:sa,matrix:Ta,typed:W}),rf=Fn({compare:je,isNaN:se,isNumeric:ge,typed:W}),Ic=Gn({ImmutableDenseMatrix:yh}),Vq=Hn({BigNumber:La,Complex:mc,config:sa,typed:W}),Wq=In({typed:W}),Dh=Jn({DenseMatrix:Kb,Index:Ic,compareNatural:ld,size:Hc,subset:Xc,typed:W}),Eh=Kn({DenseMatrix:Kb,Index:Ic,compareNatural:ld,size:Hc,subset:Xc,typed:W}),Xq=Ln({Index:Ic, -compareNatural:ld,size:Hc,subset:Xc,typed:W}),Yq=Mn({compareNatural:ld,typed:W}),Zq=Nn({add:Ac,matrix:Ta,typed:W}),$q=On({add:Ac,compare:je,multiply:vc,partitionSelect:rf,typed:W}),Fh=Pn({BigNumber:La,Complex:mc,config:sa,multiplyScalar:sc,pow:Gd,typed:W}),Hd=Qn({BigNumber:La,typed:W}),Gh=Rn({flatten:Se,matrix:Ta,size:Hc,typed:W}),ar=Sn({equalScalar:Qb,matrix:Ta,typed:W}),br=Tn({DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,typed:W}),cr=Un({matrix:Ta,multiplyScalar:sc,typed:W}),Ue=Vn({matrix:Ta,typed:W}), -ed=Wn({bignumber:Hd,fraction:ue,number:Td}),dr=Xn({equalScalar:Qb,matrix:Ta,not:th,typed:W,zeros:Ud}),sf=Yn({DenseMatrix:Kb,config:sa,matrix:Ta,typed:W}),er=Zn({compare:je,compareNatural:ld,matrix:Ta,typed:W}),fr=Yg({config:sa,numeric:ed,smaller:dd,typed:W}),gr=$n({BigNumber:La,typed:W}),hr=ao({DenseMatrix:Kb,Index:Ic,compareNatural:ld,size:Hc,subset:Xc,typed:W}),ir=bo({Index:Ic,compareNatural:ld,size:Hc,subset:Xc,typed:W}),jr=co({Index:Ic,typed:W}),Hh=Zg({add:Ac,config:sa,numeric:ed,typed:W}),Ve= -eo({gamma:Fh,typed:W}),kr=fo({factorial:Ve,typed:W}),lr=go({flatten:Se,matrix:Ta,size:Hc,typed:W}),pc=ho({DenseMatrix:Kb,addScalar:zc,equalScalar:Qb,matrix:Ta,typed:W,unaryMinus:rd}),mr=io({matrix:Ta,multiply:vc,subtract:pc,typed:W}),xe=ah({bignumber:Hd,matrix:Ta,config:sa,larger:Yc,largerEq:Te,smaller:dd,smallerEq:sf,typed:W}),nr=ch({Index:Ic,matrix:Ta,range:xe,typed:W}),Ih=jo({config:sa,multiplyScalar:sc,numeric:ed,typed:W}),Id=ko({DenseMatrix:Kb,equalScalar:Qb,matrix:Ta,typed:W}),Jh=Xg({config:sa, -larger:Yc,numeric:ed,typed:W}),or=lo({DenseMatrix:Kb,Index:Ic,compareNatural:ld,size:Hc,subset:Xc,typed:W}),Kh=mo({Index:Ic,concat:qf,setDifference:Dh,size:Hc,subset:Xc,typed:W}),Lh=no({config:sa,equalScalar:Qb,matrix:Ta,round:we,typed:W}),pr=oo({DenseMatrix:Kb,matrix:Ta,typed:W}),qr=po({prod:Ih,size:Hc,typed:W}),Mh=qo({conj:ve,transpose:Ue,typed:W}),rr=ro({equal:Id,typed:W}),sr=so({Index:Ic,compareNatural:ld,size:Hc,subset:Xc,typed:W}),Nh=to({Complex:mc,ceil:Lh,floor:Bh,matrix:Ta,typed:W}),tr=bh({matrix:Ta, -number:Td,subtract:pc,typed:W}),tc=uo({numeric:ed,typed:W}),ur=vo({Complex:mc,config:sa,divideScalar:tc,typed:W}),Oh=wo({DenseMatrix:Kb,divideScalar:tc,equalScalar:Qb,matrix:Ta,multiplyScalar:sc,subtract:pc,typed:W}),vr=xo({DenseMatrix:Kb,divideScalar:tc,equalScalar:Qb,matrix:Ta,multiplyScalar:sc,subtract:pc,typed:W}),Ph=yo({FibonacciHeap:zh,addScalar:zc,equalScalar:Qb}),wr=zo({Index:Ic,concat:qf,setIntersect:Eh,setSymDifference:Kh,size:Hc,subset:Xc,typed:W}),tf=Ao({DenseMatrix:Kb,Spa:Ph,SparseMatrix:td, -abs:Vc,addScalar:zc,divideScalar:tc,equalScalar:Qb,larger:Yc,matrix:Ta,multiplyScalar:sc,subtract:pc,typed:W,unaryMinus:rd}),Qh=Go({SparseMatrix:td,abs:Vc,add:Ac,divideScalar:tc,larger:Yc,largerEq:Te,multiply:vc,subtract:pc,transpose:Ue,typed:W}),Rh=Ho({lup:tf,matrix:Ta,multiply:vc,subtract:pc,typed:W,unaryMinus:rd}),xr=Io({abs:Vc,addScalar:zc,divideScalar:tc,multiplyScalar:sc,sqrt:sd,subtract:pc,typed:W,unaryMinus:rd}),Sh=Jo({addScalar:zc,combinations:Re,divideScalar:tc,factorial:Ve,isInteger:cd, -isNegative:he,larger:Yc,multiplyScalar:sc,pow:Gd,subtract:pc,typed:W}),yr=Ko({addScalar:zc,combinations:Re,divideScalar:tc,isInteger:cd,isNegative:he,multiplyScalar:sc,typed:W}),Th=$g({Index:Ic,matrix:Ta,range:xe,typed:W}),uf=Lo({Complex:mc,config:sa,divideScalar:tc,typed:W}),Uh=Mo({DenseMatrix:Kb,divideScalar:tc,equalScalar:Qb,matrix:Ta,typed:W}),Vh=No({DenseMatrix:Kb,divideScalar:tc,equalScalar:Qb,matrix:Ta,multiplyScalar:sc,subtract:pc,typed:W}),zr=Oo({abs:Vc,addScalar:zc,divideScalar:tc,isPositive:Pe, -multiplyScalar:sc,smaller:dd,sqrt:sd,typed:W}),Wh=Po({addScalar:zc,complex:Qe,conj:ve,divideScalar:tc,equal:Id,identity:ie,isZero:Vd,matrix:Ta,multiplyScalar:sc,sign:rh,sqrt:sd,subtract:pc,typed:W,unaryMinus:rd,zeros:Ud}),ye=Qo({abs:Vc,addScalar:zc,det:Rh,divideScalar:tc,identity:ie,matrix:Ta,multiply:vc,typed:W,unaryMinus:rd}),Ar=Ro({abs:Vc,add:Ac,identity:ie,inv:ye,multiply:vc,typed:W}),md=So({divideScalar:tc,equalScalar:Qb,inv:ye,matrix:Ta,multiply:vc,typed:W}),Br=dh({add:Ac,divide:md,typed:W}), -vf=eh({add:Ac,apply:nf,divide:md,isNaN:se,multiply:vc,subtract:pc,typed:W}),Cr=To({divide:md,dotDivide:Uh,isNumeric:ge,log:uf,matrix:Ta,multiply:vc,sum:Hh,typed:W}),Dr=Uo({addScalar:zc,isInteger:cd,isNegative:he,stirlingS2:Sh,typed:W}),Er=Vo({Complex:mc,config:sa,divideScalar:tc,log:uf,typed:W}),xb=Wo({BigNumber:La,Complex:mc,Fraction:Sd,abs:Vc,addScalar:zc,config:sa,divideScalar:tc,equal:Id,fix:Nh,format:te,isNumeric:ge,multiplyScalar:sc,number:Td,pow:Gd,round:we,subtract:pc}),Fr=Xo({Unit:xb,typed:W}), -Xh=Zo({abs:Vc,add:Ac,addScalar:zc,atan:vh,bignumber:Hd,column:Th,complex:Qe,config:sa,cos:of,diag:wh,divideScalar:tc,equal:Id,flatten:Se,im:sh,inv:ye,larger:Yc,log10:qh,matrix:Ta,matrixFromColumns:Gh,multiply:vc,multiplyScalar:sc,number:Td,qr:Wh,re:Ch,round:we,sin:pf,smaller:dd,sqrt:sd,subtract:pc,transpose:Ue,typed:W,usolveAll:Vh}),Gr=$o({abs:Vc,add:Ac,addScalar:zc,config:sa,divideScalar:tc,equalScalar:Qb,matrix:Ta,multiply:vc,multiplyScalar:sc,smaller:dd,subtract:pc,typed:W}),Hr=fh({sqrt:sd,typed:W, -variance:vf}),Ir=Rk({BigNumber:La,Unit:xb,config:sa}),Jr=xk({BigNumber:La,Unit:xb,config:sa}),Kr=Tk({BigNumber:La,Unit:xb,config:sa}),Lr=yk({BigNumber:La,Unit:xb,config:sa}),Mr=Kk({BigNumber:La,Unit:xb,config:sa}),Nr=Fk({BigNumber:La,Unit:xb,config:sa}),Or=Uk({BigNumber:La,Unit:xb,config:sa}),Pr=Vk({BigNumber:La,Unit:xb,config:sa}),Qr=pk({BigNumber:La,Unit:xb,config:sa}),Rr=Ik({BigNumber:La,Unit:xb,config:sa}),Sr=Ck({BigNumber:La,Unit:xb,config:sa}),Tr=sk({BigNumber:La,Unit:xb,config:sa}),Ur=dl({BigNumber:La, -Unit:xb,config:sa}),Vr=Yk({BigNumber:La,Unit:xb,config:sa}),Wr=Lk({BigNumber:La,Unit:xb,config:sa}),Xr=jl({BigNumber:La,Unit:xb,config:sa}),Yr=gl({BigNumber:La,Unit:xb,config:sa}),Zr=kl({BigNumber:La,Unit:xb,config:sa}),$r=Jk({BigNumber:La,Unit:xb,config:sa}),as=rk({BigNumber:La,Unit:xb,config:sa}),bs=al({BigNumber:La,Unit:xb,config:sa}),cs=bl({BigNumber:La,Unit:xb,config:sa}),ds=uk({BigNumber:La,Unit:xb,config:sa}),Yh=ap({DenseMatrix:Kb,divideScalar:tc,equalScalar:Qb,matrix:Ta,multiplyScalar:sc, -subtract:pc,typed:W}),Zh=bp({abs:Vc,add:Ac,conj:ve,ctranspose:Mh,eigs:Xh,equalScalar:Qb,larger:Yc,matrix:Ta,multiply:vc,pow:Gd,smaller:dd,sqrt:sd,typed:W}),es=cp({DenseMatrix:Kb,lsolve:Oh,lup:tf,matrix:Ta,slu:Qh,typed:W,usolve:Yh}),fs=dp({abs:Vc,add:Ac,identity:ie,inv:ye,max:Jh,multiply:vc,size:Hc,sqrt:sd,subtract:pc,typed:W}),gs=ep({add:Ac,divide:md,factorial:Ve,isInteger:cd,isPositive:Pe,multiply:vc,typed:W}),hs=Sk({BigNumber:La,Unit:xb,config:sa}),is=Ek({BigNumber:La,Unit:xb,config:sa}),js=tk({BigNumber:La, -Unit:xb,config:sa}),ks=Gk({BigNumber:La,Unit:xb,config:sa}),ls=fl({BigNumber:La,Unit:xb,config:sa}),ms=Wk({BigNumber:La,Unit:xb,config:sa}),ns=el({BigNumber:La,Unit:xb,config:sa}),os=Bk({BigNumber:La,Unit:xb,config:sa}),ps=hl({BigNumber:La,Unit:xb,config:sa}),qs=Mk({BigNumber:La,Unit:xb,config:sa}),rs=ok({BigNumber:La,Unit:xb,config:sa}),ss=cl({BigNumber:La,Unit:xb,config:sa}),$h=fp({BigNumber:La,DenseMatrix:Kb,SparseMatrix:td,addScalar:zc,config:sa,cos:of,matrix:Ta,multiplyScalar:sc,norm:Zh,sin:pf, -typed:W,unaryMinus:rd}),ai=gp({add:Ac,compare:je,divide:md,partitionSelect:rf,typed:W}),ts=Dk({BigNumber:La,Unit:xb,config:sa}),us=wk({BigNumber:La,Unit:xb,config:sa}),vs=zk({BigNumber:La,Unit:xb,config:sa}),ws=Zk({BigNumber:La,Unit:xb,config:sa}),xs=il({BigNumber:La,Unit:xb,config:sa}),ys=Ok({BigNumber:La,Unit:xb,config:sa}),zs=hp({multiply:vc,rotationMatrix:$h,typed:W}),As=ip({abs:Vc,map:uh,median:ai,subtract:pc,typed:W}),Bs=vk({BigNumber:La,Unit:xb,config:sa}),Cs=Ak({BigNumber:La,Unit:xb,config:sa}), -Ds=Nk({BigNumber:La,Unit:xb,config:sa}),Es=jp({Unit:xb,typed:W}),Fs=Xk({BigNumber:La,Unit:xb,config:sa}),Gs=qk({BigNumber:La,Unit:xb,config:sa}),ke={},ze={},bi={},Jc=Ji({mathWithTransform:ze}),ci=Ri({Node:Jc}),di=Si({Node:Jc,ResultSet:mh}),Ae=Ti({Node:Jc}),ei=Ui({Node:Jc}),Be=Vi({Node:Jc}),fi=Wi({Node:Jc}),wf=Xi({math:ke}),Hs=Yi({classes:bi}),gi=Zi({Node:Jc}),Ce=$i({Node:Jc}),hi=aj({Node:Jc}),ii=bj({Node:Jc,typed:W}),Is=cj({Chain:wf,typed:W}),ji=dj({Node:Jc,subset:Xc}),ki=ej({Node:Jc,Range:nh,size:Hc}), -li=fj({matrix:Ta,Node:Jc,subset:Xc}),le=gj({Unit:xb,Node:Jc,math:ke}),De=hj({Node:Jc,SymbolNode:le,math:ke}),Jd=ij({AccessorNode:ji,ArrayNode:ci,AssignmentNode:li,BlockNode:di,ConditionalNode:gi,ConstantNode:Ae,FunctionAssignmentNode:ii,FunctionNode:De,IndexNode:ki,ObjectNode:ei,OperatorNode:Ce,ParenthesisNode:Be,RangeNode:hi,RelationalNode:fi,SymbolNode:le,config:sa,numeric:ed,typed:W}),mi=jj({parse:Jd,typed:W}),ni=kj({parse:Jd}),oi=lj({parse:Jd}),Js=nj({Help:ni,mathWithTransform:ze,typed:W}),Ks= -oj({parse:Jd,typed:W}),xf=qj({bignumber:Hd,fraction:ue,ConstantNode:Ae,FunctionNode:De,OperatorNode:Ce,ParenthesisNode:Be,SymbolNode:le,add:Ac,config:sa,divide:md,equal:Id,isZero:Vd,mathWithTransform:ze,multiply:vc,parse:Jd,pow:Gd,subtract:pc,typed:W}),Ls=rj({bignumber:Hd,fraction:ue,ConstantNode:Ae,FunctionNode:De,OperatorNode:Ce,ParenthesisNode:Be,SymbolNode:le,add:Ac,config:sa,divide:md,equal:Id,isZero:Vd,mathWithTransform:ze,multiply:vc,parse:Jd,pow:Gd,simplify:xf,subtract:pc,typed:W}),Ms=sj({Parser:oi, -typed:W}),Ns=tj({ConstantNode:Ae,FunctionNode:De,OperatorNode:Ce,ParenthesisNode:Be,SymbolNode:le,config:sa,equal:Id,isZero:Vd,numeric:ed,parse:Jd,simplify:xf,typed:W});Ra(ke,{reviver:Hs,false:kp,null:lp,true:mp,replacer:np,i:op,LN10:pp,LOG10E:qp,NaN:rp,pi:oh,SQRT1_2:sp,tau:tp,efimovFactor:up,fineStructure:vp,sackurTetrode:wp,weakMixingAngle:xp,e:ph,Infinity:yp,LOG2E:zp,PI:oh,version:Ap,E:ph,phi:Bp,typed:W,isInteger:cd,isNumeric:ge,isPositive:Pe,isNaN:se,equalScalar:Qb,number:Td,boolean:Cp,complex:Qe, -splitUnit:Dp,unaryPlus:Ep,apply:nf,cube:Fp,expm1:Gp,log10:qh,multiplyScalar:sc,sign:rh,square:Hp,bitNot:Ip,arg:Jp,im:sh,not:th,filter:Kp,forEach:Lp,map:uh,erf:Mp,format:te,oct:Np,print:Op,isPrime:Pp,acos:Qp,acot:Rp,acsc:Sp,asec:Tp,asin:Up,atan:vh,atanh:Vp,cosh:Wp,coth:Xp,csch:Yp,sech:Zp,sinh:$p,tanh:aq,chain:Is,combinations:Re,pickRandom:bq,randomInt:cq,LN2:dq,clone:eq,hasNumericValue:fq,typeOf:gq,string:hq,fraction:ue,unaryMinus:rd,addScalar:zc,exp:iq,log2:jq,sqrt:sd,conj:ve,getMatrixDataType:kq, -mode:lq,bin:mq,acosh:nq,acsch:oq,asinh:pq,cos:of,csc:qq,sin:pf,combinationsWithRep:rq,random:sq,SQRT2:tq,isNegative:he,matrix:Ta,abs:Vc,gcd:uq,mod:vq,nthRoot:wq,xgcd:xq,bitAnd:yq,bitXor:zq,or:Aq,concat:qf,diag:wh,identity:ie,ones:Bq,reshape:Cq,size:Hc,subset:Xc,zeros:Ud,hex:Dq,round:we,leftShift:Eq,rightLogShift:Fq,compare:je,compareText:xh,smaller:dd,larger:Yc,unequal:Gq,sparse:Hq,acoth:Iq,atan2:Jq,sec:Kq,add:Ac,dot:Ah,composition:Lq,isZero:Vd,matrixFromFunction:Mq,cbrt:Nq,floor:Bh,multiply:vc,dotMultiply:Oq, -re:Ch,flatten:Se,resize:Pq,squeeze:Qq,to:Rq,pow:Gd,dotPow:Sq,rightArithShift:Tq,compareNatural:ld,equalText:Uq,largerEq:Te,partitionSelect:rf,asech:Vq,tan:Wq,setDifference:Dh,setIntersect:Eh,setMultiplicity:Xq,setSize:Yq,trace:Zq,quantileSeq:$q,gamma:Fh,bignumber:Hd,matrixFromColumns:Gh,lcm:ar,bitOr:br,kron:cr,transpose:Ue,numeric:ed,and:dr,smallerEq:sf,sort:er,min:fr,cot:gr,setDistinct:hr,setPowerset:ir,index:jr,sum:Hh,factorial:Ve,permutations:kr,matrixFromRows:lr,subtract:pc,cross:mr,range:xe, -row:nr,prod:Ih,equal:Id,max:Jh,setCartesian:or,setSymDifference:Kh,ceil:Lh,xor:pr,count:qr,ctranspose:Mh,deepEqual:rr,setIsSubset:sr,fix:Nh,diff:tr,divideScalar:tc,nthRoots:ur,lsolve:Oh,lsolveAll:vr,setUnion:wr,lup:tf,slu:Qh,det:Rh,distance:xr,stirlingS2:Sh,catalan:yr,column:Th,log:uf,dotDivide:Uh,usolveAll:Vh,hypot:zr,qr:Wh,inv:ye,expm:Ar,divide:md,mean:Br,variance:vf,kldivergence:Cr,bellNumbers:Dr,log1p:Er,createUnit:Fr,eigs:Xh,intersect:Gr,std:Hr,atomicMass:Ir,bohrMagneton:Jr,boltzmann:Kr,conductanceQuantum:Lr, -deuteronMass:Mr,electronMass:Nr,faraday:Or,firstRadiation:Pr,gravitationConstant:Qr,hartreeEnergy:Rr,klitzing:Sr,magneticConstant:Tr,molarMass:Ur,molarPlanckConstant:Vr,neutronMass:Wr,planckCharge:Xr,planckLength:Yr,planckTemperature:Zr,protonMass:$r,reducedPlanckConstant:as,secondRadiation:bs,stefanBoltzmann:cs,vacuumImpedance:ds,usolve:Yh,norm:Zh,lusolve:es,sqrtm:fs,multinomial:gs,avogadro:hs,classicalElectronRadius:is,electricConstant:js,fermiCoupling:ks,gravity:ls,loschmidt:ms,molarMassC12:ns, -nuclearMagneton:os,planckMass:ps,quantumOfCirculation:qs,speedOfLight:rs,wienDisplacement:ss,rotationMatrix:$h,median:ai,bohrRadius:ts,elementaryCharge:us,inverseConductanceQuantum:vs,molarVolume:ws,planckTime:xs,thomsonCrossSection:ys,rotate:zs,parse:Jd,evaluate:mi,mad:As,coulomb:Bs,magneticFluxQuantum:Cs,rydberg:Ds,unit:Es,help:Js,gasConstant:Fs,compile:Ks,simplify:xf,rationalize:Ls,parser:Ms,planckConstant:Gs,derivative:Ns,config:sa});Ra(ze,ke,{apply:uj({isInteger:cd,typed:W}),filter:vj({typed:W}), -map:wj({typed:W}),forEach:xj({typed:W}),subset:yj({matrix:Ta,typed:W}),index:zj({Index:Ic}),concat:Aj({isInteger:cd,matrix:Ta,typed:W}),max:Bj({config:sa,larger:Yc,numeric:ed,typed:W}),min:Cj({config:sa,numeric:ed,smaller:dd,typed:W}),sum:Dj({add:Ac,config:sa,numeric:ed,typed:W}),column:Ej({Index:Ic,matrix:Ta,range:xe,typed:W}),range:Fj({bignumber:Hd,matrix:Ta,config:sa,larger:Yc,largerEq:Te,smaller:dd,smallerEq:sf,typed:W}),diff:Gj({bignumber:Hd,matrix:Ta,number:Td,subtract:pc,typed:W}),row:Hj({Index:Ic, -matrix:Ta,range:xe,typed:W}),mean:Ij({add:Ac,divide:md,typed:W}),variance:Jj({add:Ac,apply:nf,divide:md,isNaN:se,multiply:vc,subtract:pc,typed:W}),std:Kj({sqrt:sd,typed:W,variance:vf})});Ra(bi,{ResultSet:mh,Complex:mc,Range:nh,Node:Jc,ArrayNode:ci,BlockNode:di,ConstantNode:Ae,ObjectNode:ei,ParenthesisNode:Be,RelationalNode:fi,Chain:wf,BigNumber:La,Matrix:Oe,ConditionalNode:gi,OperatorNode:Ce,Fraction:Sd,RangeNode:hi,DenseMatrix:Kb,FunctionAssignmentNode:ii,SparseMatrix:td,ImmutableDenseMatrix:yh, -FibonacciHeap:zh,AccessorNode:ji,IndexNode:ki,Index:Ic,AssignmentNode:li,Spa:Ph,Unit:xb,SymbolNode:le,FunctionNode:De,Help:ni,Parser:oi});wf.createProxy(ke);browser.omnibox.setDefaultSuggestion({description:"Do most mathematical computations."});const pi=(b,a)=>{b=mi(b);a([{description:String(b),content:String(b)}])};browser.omnibox.onInputStarted.addListener(pi);browser.omnibox.onInputChanged.addListener(pi)})()})(); +/*! For license information please see index.js.LICENSE.txt */ +(()=>{var e={977:function(e,t){var r;!function(n){"use strict";var i=function(e){return.5*(Math.exp(e)+Math.exp(-e))},a=function(e){return.5*(Math.exp(e)-Math.exp(-e))},o=function(){throw SyntaxError("Invalid Param")};function s(e,t){var r=Math.abs(e),n=Math.abs(t);return 0===e?Math.log(n):0===t?Math.log(r):r<3e3&&n<3e3?.5*Math.log(e*e+t*t):Math.log(e/Math.cos(Math.atan2(t,e)))}function u(e,t){if(!(this instanceof u))return new u(e,t);var r=function(e,t){var r={re:0,im:0};if(null==e)r.re=r.im=0;else if(void 0!==t)r.re=e,r.im=t;else switch(typeof e){case"object":if("im"in e&&"re"in e)r.re=e.re,r.im=e.im;else if("abs"in e&&"arg"in e){if(!Number.isFinite(e.abs)&&Number.isFinite(e.arg))return u.INFINITY;r.re=e.abs*Math.cos(e.arg),r.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!Number.isFinite(e.r)&&Number.isFinite(e.phi))return u.INFINITY;r.re=e.r*Math.cos(e.phi),r.im=e.r*Math.sin(e.phi)}else 2===e.length?(r.re=e[0],r.im=e[1]):o();break;case"string":r.im=r.re=0;var n=e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),i=1,a=0;null===n&&o();for(var s=0;s0&&o();break;case"number":r.im=0,r.re=e;break;default:o()}return isNaN(r.re)||isNaN(r.im),r}(e,t);this.re=r.re,this.im=r.im}u.prototype={re:0,im:0,sign:function(){var e=this.abs();return new u(this.re/e,this.im/e)},add:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:new u(this.re+r.re,this.im+r.im)},sub:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:new u(this.re-r.re,this.im-r.im)},mul:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isZero()||this.isZero()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:0===r.im&&0===this.im?new u(this.re*r.re,0):new u(this.re*r.re-this.im*r.im,this.re*r.im+this.im*r.re)},div:function(e,t){var r=new u(e,t);if(this.isZero()&&r.isZero()||this.isInfinite()&&r.isInfinite())return u.NAN;if(this.isInfinite()||r.isZero())return u.INFINITY;if(this.isZero()||r.isInfinite())return u.ZERO;e=this.re,t=this.im;var n,i,a=r.re,o=r.im;return 0===o?new u(e/a,t/a):Math.abs(a)0)return new u(Math.pow(e,r.re),0);if(0===e)switch((r.re%4+4)%4){case 0:return new u(Math.pow(t,r.re),0);case 1:return new u(0,Math.pow(t,r.re));case 2:return new u(-Math.pow(t,r.re),0);case 3:return new u(0,-Math.pow(t,r.re))}}if(0===e&&0===t&&r.re>0&&r.im>=0)return u.ZERO;var n=Math.atan2(t,e),i=s(e,t);return e=Math.exp(r.re*i-r.im*n),t=r.im*i+r.re*n,new u(e*Math.cos(t),e*Math.sin(t))},sqrt:function(){var e,t,r=this.re,n=this.im,i=this.abs();if(r>=0){if(0===n)return new u(Math.sqrt(r),0);e=.5*Math.sqrt(2*(i+r))}else e=Math.abs(n)/Math.sqrt(2*(i-r));return t=r<=0?.5*Math.sqrt(2*(i-r)):Math.abs(n)/Math.sqrt(2*(i+r)),new u(e,n<0?-t:t)},exp:function(){var e=Math.exp(this.re);return this.im,new u(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){var e=this.re,t=this.im;return new u(Math.expm1(e)*Math.cos(t)+function(e){var t=Math.PI/4;if(-t>e||e>t)return Math.cos(e)-1;var r=e*e;return r*(r*(r*(r*(r*(r*(r*(r/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-.5)}(t),Math.exp(e)*Math.sin(t))},log:function(){var e=this.re,t=this.im;return new u(s(e,t),Math.atan2(t,e))},abs:function(){return e=this.re,t=this.im,r=Math.abs(e),n=Math.abs(t),r<3e3&&n<3e3?Math.sqrt(r*r+n*n):(r1&&0===t,n=1-e,i=1+e,a=n*n+t*t,o=0!==a?new u((i*n-t*t)/a,(t*n+i*t)/a):new u(-1!==e?e/0:0,0!==t?t/0:0),c=o.re;return o.re=s(o.re,o.im)/2,o.im=Math.atan2(o.im,c)/2,r&&(o.im=-o.im),o},acoth:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new u(0,Math.PI/2);var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).atanh():new u(0!==e?e/0:0,0!==t?-t/0:0).atanh()},acsch:function(){var e=this.re,t=this.im;if(0===t)return new u(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).asinh():new u(0!==e?e/0:0,0!==t?-t/0:0).asinh()},asech:function(){var e=this.re,t=this.im;if(this.isZero())return u.INFINITY;var r=e*e+t*t;return 0!==r?new u(e/r,-t/r).acosh():new u(0!==e?e/0:0,0!==t?-t/0:0).acosh()},inverse:function(){if(this.isZero())return u.INFINITY;if(this.isInfinite())return u.ZERO;var e=this.re,t=this.im,r=e*e+t*t;return new u(e/r,-t/r)},conjugate:function(){return new u(this.re,-this.im)},neg:function(){return new u(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new u(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new u(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new u(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){var r=new u(e,t);return Math.abs(r.re-this.re)<=u.EPSILON&&Math.abs(r.im-this.im)<=u.EPSILON},clone:function(){return new u(this.re,this.im)},toString:function(){var e=this.re,t=this.im,r="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)0){for(a+=o,t=1;tr)throw Error(y+e)}function q(e,t,r,n){var i,a,o,s;for(a=e[0];a>=10;a/=10)--t;return--t<0?(t+=7,i=0):(i=Math.ceil((t+1)/7),t%=7),a=w(10,7-t),s=e[i]%a|0,null==n?t<3?(0==t?s=s/100|0:1==t&&(s=s/10|0),o=r<4&&99999==s||r>3&&49999==s||5e4==s||0==s):o=(r<4&&s+1==a||r>3&&s+1==a/2)&&(e[i+1]/a/100|0)==w(10,t-2)-1||(s==a/2||0==s)&&0==(e[i+1]/a/100|0):t<4?(0==t?s=s/1e3|0:1==t?s=s/100|0:2==t&&(s=s/10|0),o=(n||r<4)&&9999==s||!n&&r>3&&4999==s):o=((n||r<4)&&s+1==a||!n&&r>3&&s+1==a/2)&&(e[i+1]/a/1e3|0)==w(10,t-3)-1,o}function z(e,t,r){for(var n,i,a=[0],o=0,s=e.length;or-1&&(void 0===a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/r|0,a[n]%=r)}return a.reverse()}_.absoluteValue=_.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),I(e)},_.ceil=function(){return I(new this.constructor(this),this.e+1,2)},_.clampedTo=_.clamp=function(e,t){var r=this,n=r.constructor;if(e=new n(e),t=new n(t),!e.s||!t.s)return new n(NaN);if(e.gt(t))throw Error(y+t);return r.cmp(e)<0?e:r.cmp(t)>0?t:new n(r)},_.comparedTo=_.cmp=function(e){var t,r,n,i,a=this,o=a.d,s=(e=new a.constructor(e)).d,u=a.s,c=e.s;if(!o||!s)return u&&c?u!==c?u:o===s?0:!o^u<0?1:-1:NaN;if(!o[0]||!s[0])return o[0]?u:s[0]?-c:0;if(u!==c)return u;if(a.e!==e.e)return a.e>e.e^u<0?1:-1;for(t=0,r=(n=o.length)<(i=s.length)?n:i;ts[t]^u<0?1:-1;return n===i?0:n>i^u<0?1:-1},_.cosine=_.cos=function(){var e,t,r=this,n=r.constructor;return r.d?r.d[0]?(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(e,t){var r,n,i;if(t.isZero())return t;(n=t.d.length)<32?i=(1/X(4,r=Math.ceil(n/3))).toString():(r=16,i="2.3283064365386962890625e-10"),e.precision+=r,t=Y(e,1,t.times(i),new e(1));for(var a=r;a--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=r,t}(n,Q(n,r)),n.precision=e,n.rounding=t,I(2==s||3==s?r.neg():r,e,t,!0)):new n(1):new n(NaN)},_.cubeRoot=_.cbrt=function(){var e,t,r,n,i,a,o,s,u,c,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(h=!1,(a=l.s*w(l.s*l,1/3))&&Math.abs(a)!=1/0?n=new f(a.toString()):(r=T(l.d),(a=((e=l.e)-r.length+1)%3)&&(r+=1==a||-2==a?"0":"00"),a=w(r,1/3),e=b((e+1)/3)-(e%3==(e<0?-1:2)),(n=new f(r=a==1/0?"5e"+e:(r=a.toExponential()).slice(0,r.indexOf("e")+1)+e)).s=l.s),o=(e=f.precision)+3;;)if(c=(u=(s=n).times(s).times(s)).plus(l),n=D(c.plus(l).times(s),c.plus(u),o+2,1),T(s.d).slice(0,o)===(r=T(n.d)).slice(0,o)){if("9999"!=(r=r.slice(o-3,o+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(I(n,e+1,1),t=!n.times(n).times(n).eq(l));break}if(!i&&(I(s,e+1,0),s.times(s).times(s).eq(l))){n=s;break}o+=4,i=1}return h=!0,I(n,e,f.rounding,t)},_.decimalPlaces=_.dp=function(){var e,t=this.d,r=NaN;if(t){if(r=7*((e=t.length-1)-b(this.e/7)),e=t[e])for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r},_.dividedBy=_.div=function(e){return D(this,new this.constructor(e))},_.dividedToIntegerBy=_.divToInt=function(e){var t=this.constructor;return I(D(this,new t(e),0,1,1),t.precision,t.rounding)},_.equals=_.eq=function(e){return 0===this.cmp(e)},_.floor=function(){return I(new this.constructor(this),this.e+1,3)},_.greaterThan=_.gt=function(e){return this.cmp(e)>0},_.greaterThanOrEqualTo=_.gte=function(e){var t=this.cmp(e);return 1==t||0===t},_.hyperbolicCosine=_.cosh=function(){var e,t,r,n,i,a=this,o=a.constructor,s=new o(1);if(!a.isFinite())return new o(a.s?1/0:NaN);if(a.isZero())return s;r=o.precision,n=o.rounding,o.precision=r+Math.max(a.e,a.sd())+4,o.rounding=1,(i=a.d.length)<32?t=(1/X(4,e=Math.ceil(i/3))).toString():(e=16,t="2.3283064365386962890625e-10"),a=Y(o,1,a.times(t),new o(1),!0);for(var u,c=e,l=new o(8);c--;)u=a.times(a),a=s.minus(u.times(l.minus(u.times(l))));return I(a,o.precision=r,o.rounding=n,!0)},_.hyperbolicSine=_.sinh=function(){var e,t,r,n,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.precision,r=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,(n=i.d.length)<3)i=Y(a,2,i,i,!0);else{e=(e=1.4*Math.sqrt(n))>16?16:0|e,i=Y(a,2,i=i.times(1/X(5,e)),i,!0);for(var o,s=new a(5),u=new a(16),c=new a(20);e--;)o=i.times(i),i=i.times(s.plus(o.times(u.times(o).plus(c))))}return a.precision=t,a.rounding=r,I(i,t,r,!0)},_.hyperbolicTangent=_.tanh=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+7,n.rounding=1,D(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)},_.inverseCosine=_.acos=function(){var e,t=this,r=t.constructor,n=t.abs().cmp(1),i=r.precision,a=r.rounding;return-1!==n?0===n?t.isNeg()?U(r,i,a):new r(0):new r(NaN):t.isZero()?U(r,i+4,a).times(.5):(r.precision=i+6,r.rounding=1,t=t.asin(),e=U(r,i+4,a).times(.5),r.precision=i,r.rounding=a,e.minus(t))},_.inverseHyperbolicCosine=_.acosh=function(){var e,t,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(e=n.precision,t=n.rounding,n.precision=e+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,h=!1,r=r.times(r).minus(1).sqrt().plus(r),h=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)},_.inverseHyperbolicSine=_.asinh=function(){var e,t,r=this,n=r.constructor;return!r.isFinite()||r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,h=!1,r=r.times(r).plus(1).sqrt().plus(r),h=!0,n.precision=e,n.rounding=t,r.ln())},_.inverseHyperbolicTangent=_.atanh=function(){var e,t,r,n,i=this,a=i.constructor;return i.isFinite()?i.e>=0?new a(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=a.precision,t=a.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?I(new a(i),e,t,!0):(a.precision=r=n-i.e,i=D(i.plus(1),new a(1).minus(i),r+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=t,i.times(.5))):new a(NaN)},_.inverseSine=_.asin=function(){var e,t,r,n,i=this,a=i.constructor;return i.isZero()?new a(i):(t=i.abs().cmp(1),r=a.precision,n=a.rounding,-1!==t?0===t?((e=U(a,r+4,n).times(.5)).s=i.s,e):new a(NaN):(a.precision=r+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=r,a.rounding=n,i.times(2)))},_.inverseTangent=_.atan=function(){var e,t,r,n,i,a,o,s,u,c=this,l=c.constructor,f=l.precision,p=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&f+4<=C)return(o=U(l,f+4,p).times(.25)).s=c.s,o}else{if(!c.s)return new l(NaN);if(f+4<=C)return(o=U(l,f+4,p).times(.5)).s=c.s,o}for(l.precision=s=f+10,l.rounding=1,e=r=Math.min(28,s/7+2|0);e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(h=!1,t=Math.ceil(s/7),n=1,u=c.times(c),o=new l(c),i=c;-1!==e;)if(i=i.times(u),a=o.minus(i.div(n+=2)),i=i.times(u),void 0!==(o=a.plus(i.div(n+=2))).d[t])for(e=t;o.d[e]===a.d[e]&&e--;);return r&&(o=o.times(2<this.d.length-2},_.isNaN=function(){return!this.s},_.isNegative=_.isNeg=function(){return this.s<0},_.isPositive=_.isPos=function(){return this.s>0},_.isZero=function(){return!!this.d&&0===this.d[0]},_.lessThan=_.lt=function(e){return this.cmp(e)<0},_.lessThanOrEqualTo=_.lte=function(e){return this.cmp(e)<1},_.logarithm=_.log=function(e){var t,r,n,i,a,o,s,u,c=this,l=c.constructor,f=l.precision,p=l.rounding;if(null==e)e=new l(10),t=!0;else{if(r=(e=new l(e)).d,e.s<0||!r||!r[0]||e.eq(1))return new l(NaN);t=e.eq(10)}if(r=c.d,c.s<0||!r||!r[0]||c.eq(1))return new l(r&&!r[0]?-1/0:1!=c.s?NaN:r?0:1/0);if(t)if(r.length>1)a=!0;else{for(i=r[0];i%10==0;)i/=10;a=1!==i}if(h=!1,o=Z(c,s=f+5),n=t?F(l,s+10):Z(e,s),q((u=D(o,n,s,1)).d,i=f,p))do{if(o=Z(c,s+=10),n=t?F(l,s+10):Z(e,s),u=D(o,n,s,1),!a){+T(u.d).slice(i+1,i+15)+1==1e14&&(u=I(u,f+1,0));break}}while(q(u.d,i+=10,p));return h=!0,I(u,f,p)},_.minus=_.sub=function(e){var t,r,n,i,a,o,s,u,c,l,f,p,m=this,d=m.constructor;if(e=new d(e),!m.d||!e.d)return m.s&&e.s?m.d?e.s=-e.s:e=new d(e.d||m.s!==e.s?m:NaN):e=new d(NaN),e;if(m.s!=e.s)return e.s=-e.s,m.plus(e);if(c=m.d,p=e.d,s=d.precision,u=d.rounding,!c[0]||!p[0]){if(p[0])e.s=-e.s;else{if(!c[0])return new d(3===u?-0:0);e=new d(m)}return h?I(e,s,u):e}if(r=b(e.e/7),l=b(m.e/7),c=c.slice(),a=l-r){for((f=a<0)?(t=c,a=-a,o=p.length):(t=p,r=l,o=c.length),a>(n=Math.max(Math.ceil(s/7),o)+2)&&(a=n,t.length=1),t.reverse(),n=a;n--;)t.push(0);t.reverse()}else{for((f=(n=c.length)<(o=p.length))&&(o=n),n=0;n0;--n)c[o++]=0;for(n=p.length;n>a;){if(c[--n](o=(a=Math.ceil(s/7))>o?a+1:o+1)&&(i=o,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for((o=c.length)-(i=l.length)<0&&(i=o,r=l,l=c,c=r),t=0;i;)t=(c[--i]=c[i]+l[i]+t)/A|0,c[i]%=A;for(t&&(c.unshift(t),++n),o=c.length;0==c[--o];)c.pop();return e.d=c,e.e=R(c,n),h?I(e,s,u):e},_.precision=_.sd=function(e){var t,r=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(y+e);return r.d?(t=P(r.d),e&&r.e+1>t&&(t=r.e+1)):t=NaN,t},_.round=function(){var e=this,t=e.constructor;return I(new t(e),e.e+1,t.rounding)},_.sine=_.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(e,t){var r,n=t.d.length;if(n<3)return t.isZero()?t:Y(e,2,t,t);r=(r=1.4*Math.sqrt(n))>16?16:0|r,t=Y(e,2,t=t.times(1/X(5,r)),t);for(var i,a=new e(5),o=new e(16),s=new e(20);r--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}(n,Q(n,r)),n.precision=e,n.rounding=t,I(s>2?r.neg():r,e,t,!0)):new n(NaN)},_.squareRoot=_.sqrt=function(){var e,t,r,n,i,a,o=this,s=o.d,u=o.e,c=o.s,l=o.constructor;if(1!==c||!s||!s[0])return new l(!c||c<0&&(!s||s[0])?NaN:s?o:1/0);for(h=!1,0==(c=Math.sqrt(+o))||c==1/0?(((t=T(s)).length+u)%2==0&&(t+="0"),c=Math.sqrt(t),u=b((u+1)/2)-(u<0||u%2),n=new l(t=c==1/0?"5e"+u:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+u)):n=new l(c.toString()),r=(u=l.precision)+3;;)if(n=(a=n).plus(D(o,a,r+2,1)).times(.5),T(a.d).slice(0,r)===(t=T(n.d)).slice(0,r)){if("9999"!=(t=t.slice(r-3,r+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(I(n,u+1,1),e=!n.times(n).eq(o));break}if(!i&&(I(a,u+1,0),a.times(a).eq(o))){n=a;break}r+=4,i=1}return h=!0,I(n,u,l.rounding,e)},_.tangent=_.tan=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+10,n.rounding=1,(r=r.sin()).s=1,r=D(r,new n(1).minus(r.times(r)).sqrt(),e+10,0),n.precision=e,n.rounding=t,I(2==s||4==s?r.neg():r,e,t,!0)):new n(NaN)},_.times=_.mul=function(e){var t,r,n,i,a,o,s,u,c,l=this,f=l.constructor,p=l.d,m=(e=new f(e)).d;if(e.s*=l.s,!(p&&p[0]&&m&&m[0]))return new f(!e.s||p&&!p[0]&&!m||m&&!m[0]&&!p?NaN:p&&m?0*e.s:e.s/0);for(r=b(l.e/7)+b(e.e/7),(u=p.length)<(c=m.length)&&(a=p,p=m,m=a,o=u,u=c,c=o),a=[],n=o=u+c;n--;)a.push(0);for(n=c;--n>=0;){for(t=0,i=u+n;i>n;)s=a[i]+m[n]*p[i-n-1]+t,a[i--]=s%A|0,t=s/A|0;a[i]=(a[i]+t)%A|0}for(;!a[--o];)a.pop();return t?++r:a.shift(),e.d=a,e.e=R(a,r),h?I(e,f.precision,f.rounding):e},_.toBinary=function(e,t){return K(this,2,e,t)},_.toDecimalPlaces=_.toDP=function(e,t){var r=this,n=r.constructor;return r=new n(r),void 0===e?r:(B(e,0,c),void 0===t?t=n.rounding:B(t,0,8),I(r,e+r.e+1,t))},_.toExponential=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=k(n,!0):(B(e,0,c),void 0===t?t=i.rounding:B(t,0,8),r=k(n=I(new i(n),e+1,t),!0,e+1)),n.isNeg()&&!n.isZero()?"-"+r:r},_.toFixed=function(e,t){var r,n,i=this,a=i.constructor;return void 0===e?r=k(i):(B(e,0,c),void 0===t?t=a.rounding:B(t,0,8),r=k(n=I(new a(i),e+i.e+1,t),!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r},_.toFraction=function(e){var t,r,n,i,a,o,s,u,c,l,f,p,m=this,d=m.d,g=m.constructor;if(!d)return new g(m);if(c=r=new g(1),n=u=new g(0),o=(a=(t=new g(n)).e=P(d)-m.e-1)%7,t.d[0]=w(10,o<0?7+o:o),null==e)e=a>0?t:c;else{if(!(s=new g(e)).isInt()||s.lt(c))throw Error(y+s);e=s.gt(t)?a>0?t:c:s}for(h=!1,s=new g(T(d)),l=g.precision,g.precision=a=7*d.length*2;f=D(s,t,0,1,1),1!=(i=r.plus(f.times(n))).cmp(e);)r=n,n=i,i=c,c=u.plus(f.times(i)),u=i,i=t,t=s.minus(f.times(i)),s=i;return i=D(e.minus(r),n,0,1,1),u=u.plus(i.times(c)),r=r.plus(i.times(n)),u.s=c.s=m.s,p=D(c,n,a,1).minus(m).abs().cmp(D(u,r,a,1).minus(m).abs())<1?[c,n]:[u,r],g.precision=l,h=!0,p},_.toHexadecimal=_.toHex=function(e,t){return K(this,16,e,t)},_.toNearest=function(e,t){var r=this,n=r.constructor;if(r=new n(r),null==e){if(!r.d)return r;e=new n(1),t=n.rounding}else{if(e=new n(e),void 0===t?t=n.rounding:B(t,0,8),!r.d)return e.s?r:e;if(!e.d)return e.s&&(e.s=r.s),e}return e.d[0]?(h=!1,r=D(r,e,0,t,1).times(e),h=!0,I(r)):(e.s=r.s,r=e),r},_.toNumber=function(){return+this},_.toOctal=function(e,t){return K(this,8,e,t)},_.toPower=_.pow=function(e){var t,r,n,i,a,o,s=this,u=s.constructor,c=+(e=new u(e));if(!(s.d&&e.d&&s.d[0]&&e.d[0]))return new u(w(+s,c));if((s=new u(s)).eq(1))return s;if(n=u.precision,a=u.rounding,e.eq(1))return I(s,n,a);if((t=b(e.e/7))>=e.d.length-1&&(r=c<0?-c:c)<=9007199254740991)return i=L(u,s,r,n),e.s<0?new u(1).div(i):I(i,n,a);if((o=s.s)<0){if(tu.maxE+1||t0?o/0:0):(h=!1,u.rounding=s.s=1,r=Math.min(12,(t+"").length),(i=G(e.times(Z(s,n+r)),n)).d&&q((i=I(i,n+5,1)).d,n,a)&&(t=n+10,+T((i=I(G(e.times(Z(s,t+r)),t),t+5,1)).d).slice(n+1,n+15)+1==1e14&&(i=I(i,n+1,0))),i.s=o,h=!0,u.rounding=a,I(i,n,a))},_.toPrecision=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=k(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(B(e,1,c),void 0===t?t=i.rounding:B(t,0,8),r=k(n=I(new i(n),e,t),e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+r:r},_.toSignificantDigits=_.toSD=function(e,t){var r=this.constructor;return void 0===e?(e=r.precision,t=r.rounding):(B(e,1,c),void 0===t?t=r.rounding:B(t,0,8)),I(new r(this),e,t)},_.toString=function(){var e=this,t=e.constructor,r=k(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r},_.truncated=_.trunc=function(){return I(new this.constructor(this),this.e+1,1)},_.valueOf=_.toJSON=function(){var e=this,t=e.constructor,r=k(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};var D=function(){function e(e,t,r){var n,i=0,a=e.length;for(e=e.slice();a--;)n=e[a]*t+i,e[a]=n%r|0,i=n/r|0;return i&&e.unshift(i),e}function t(e,t,r,n){var i,a;if(r!=n)a=r>n?1:-1;else for(i=a=0;it[i]?1:-1;break}return a}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]1;)e.shift()}return function(n,i,a,s,u,c){var l,f,p,m,h,d,y,g,v,x,w,N,M,S,E,O,C,_,T,B,q=n.constructor,z=n.s==i.s?1:-1,D=n.d,k=i.d;if(!(D&&D[0]&&k&&k[0]))return new q(n.s&&i.s&&(D?!k||D[0]!=k[0]:k)?D&&0==D[0]||!k?0*z:z/0:NaN);for(c?(h=1,f=n.e-i.e):(c=A,h=7,f=b(n.e/h)-b(i.e/h)),T=k.length,C=D.length,x=(v=new q(z)).d=[],p=0;k[p]==(D[p]||0);p++);if(k[p]>(D[p]||0)&&f--,null==a?(S=a=q.precision,s=q.rounding):S=u?a+(n.e-i.e)+1:a,S<0)x.push(1),d=!0;else{if(S=S/h+2|0,p=0,1==T){for(m=0,k=k[0],S++;(p1&&(k=e(k,m,c),D=e(D,m,c),T=k.length,C=D.length),O=T,N=(w=D.slice(0,T)).length;N=c/2&&++_;do{m=0,(l=t(k,w,T,N))<0?(M=w[0],T!=N&&(M=M*c+(w[1]||0)),(m=M/_|0)>1?(m>=c&&(m=c-1),1==(l=t(y=e(k,m,c),w,g=y.length,N=w.length))&&(m--,r(y,T=10;m/=10)p++;v.e=p+f*h-1,I(v,u?a+v.e+1:a,s,d)}return v}}();function I(e,t,r,n){var i,a,o,s,u,c,l,f,p,m=e.constructor;e:if(null!=t){if(!(f=e.d))return e;for(i=1,s=f[0];s>=10;s/=10)i++;if((a=t-i)<0)a+=7,o=t,u=(l=f[p=0])/w(10,i-o-1)%10|0;else if((p=Math.ceil((a+1)/7))>=(s=f.length)){if(!n)break e;for(;s++<=p;)f.push(0);l=u=0,i=1,o=(a%=7)-7+1}else{for(l=s=f[p],i=1;s>=10;s/=10)i++;u=(o=(a%=7)-7+i)<0?0:l/w(10,i-o-1)%10|0}if(n=n||t<0||void 0!==f[p+1]||(o<0?l:l%w(10,i-o-1)),c=r<4?(u||n)&&(0==r||r==(e.s<0?3:2)):u>5||5==u&&(4==r||n||6==r&&(a>0?o>0?l/w(10,i-o):0:f[p-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,c?(t-=e.e+1,f[0]=w(10,(7-t%7)%7),e.e=-t||0):f[0]=e.e=0,e;if(0==a?(f.length=p,s=1,p--):(f.length=p+1,s=w(10,7-a),f[p]=o>0?(l/w(10,i-o)%w(10,o)|0)*s:0),c)for(;;){if(0==p){for(a=1,o=f[0];o>=10;o/=10)a++;for(o=f[0]+=s,s=1;o>=10;o/=10)s++;a!=s&&(e.e++,f[0]==A&&(f[0]=1));break}if(f[p]+=s,f[p]!=A)break;f[p--]=0,s=1}for(a=f.length;0===f[--a];)f.pop()}return h&&(e.e>m.maxE?(e.d=null,e.e=NaN):e.e0?a=a.charAt(0)+"."+a.slice(1)+j(n):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(e.e<0?"e":"e+")+e.e):i<0?(a="0."+j(-i-1)+a,r&&(n=r-o)>0&&(a+=j(n))):i>=o?(a+=j(i+1-o),r&&(n=r-i-1)>0&&(a=a+"."+j(n))):((n=i+1)0&&(i+1===o&&(a+="."),a+=j(n))),a}function R(e,t){var r=e[0];for(t*=7;r>=10;r/=10)t++;return t}function F(e,t,r){if(t>O)throw h=!0,r&&(e.precision=r),Error(g);return I(new e(f),t,1,!0)}function U(e,t,r){if(t>C)throw Error(g);return I(new e(p),t,r,!0)}function P(e){var t=e.length-1,r=7*t+1;if(t=e[t]){for(;t%10==0;t/=10)r--;for(t=e[0];t>=10;t/=10)r++}return r}function j(e){for(var t="";e--;)t+="0";return t}function L(e,t,r,n){var i,a=new e(1),o=Math.ceil(n/7+4);for(h=!1;;){if(r%2&&ee((a=a.times(t)).d,o)&&(i=!0),0===(r=b(r/2))){r=a.d.length-1,i&&0===a.d[r]&&++a.d[r];break}ee((t=t.times(t)).d,o)}return h=!0,a}function H(e){return 1&e.d[e.d.length-1]}function $(e,t,r){for(var n,i=new e(t[0]),a=0;++a17)return new p(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(h=!1,u=d):u=t,s=new p(.03125);e.e>-2;)e=e.times(s),f+=5;for(u+=n=Math.log(w(2,f))/Math.LN10*2+5|0,r=a=o=new p(1),p.precision=u;;){if(a=I(a.times(e),u,1),r=r.times(++l),T((s=o.plus(D(a,r,u,1))).d).slice(0,u)===T(o.d).slice(0,u)){for(i=f;i--;)o=I(o.times(o),u,1);if(null!=t)return p.precision=d,o;if(!(c<3&&q(o.d,u-n,m,c)))return I(o,p.precision=d,m,h=!0);p.precision=u+=10,r=a=s=new p(1),l=0,c++}o=s}}function Z(e,t){var r,n,i,a,o,s,u,c,l,f,p,m=1,d=e,y=d.d,g=d.constructor,v=g.rounding,x=g.precision;if(d.s<0||!y||!y[0]||!d.e&&1==y[0]&&1==y.length)return new g(y&&!y[0]?-1/0:1!=d.s?NaN:y?0:d);if(null==t?(h=!1,l=x):l=t,g.precision=l+=10,n=(r=T(y)).charAt(0),!(Math.abs(a=d.e)<15e14))return c=F(g,l+2,x).times(a+""),d=Z(new g(n+"."+r.slice(1)),l-10).plus(c),g.precision=x,null==t?I(d,x,v,h=!0):d;for(;n<7&&1!=n||1==n&&r.charAt(1)>3;)n=(r=T((d=d.times(e)).d)).charAt(0),m++;for(a=d.e,n>1?(d=new g("0."+r),a++):d=new g(n+"."+r.slice(1)),f=d,u=o=d=D(d.minus(1),d.plus(1),l,1),p=I(d.times(d),l,1),i=3;;){if(o=I(o.times(p),l,1),T((c=u.plus(D(o,new g(i),l,1))).d).slice(0,l)===T(u.d).slice(0,l)){if(u=u.times(2),0!==a&&(u=u.plus(F(g,l+2,x).times(a+""))),u=D(u,new g(m),l,1),null!=t)return g.precision=x,u;if(!q(u.d,l-10,v,s))return I(u,g.precision=x,v,h=!0);g.precision=l+=10,c=o=d=D(f.minus(1),f.plus(1),l,1),p=I(d.times(d),l,1),i=s=1}u=c,i+=2}}function V(e){return String(e.s*e.s/0)}function W(e,t){var r,n,i;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;48===t.charCodeAt(n);n++);for(i=t.length;48===t.charCodeAt(i-1);--i);if(t=t.slice(n,i)){if(i-=n,e.e=r=r-n-1,e.d=[],n=(r+1)%7,r<0&&(n+=7),ne.constructor.maxE?(e.d=null,e.e=NaN):e.e-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),E.test(t))return W(e,t)}else if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(M.test(t))r=16,t=t.toLowerCase();else if(N.test(t))r=2;else{if(!S.test(t))throw Error(y+t);r=8}for((o=t.search(/p/i))>0?(c=+t.slice(o+1),t=t.substring(2,o)):t=t.slice(2),s=(o=t.indexOf("."))>=0,n=e.constructor,s&&(o=(u=(t=t.replace(".","")).length)-o,i=L(n,new n(r),o,2*o)),o=f=(l=z(t,r,A)).length-1;0===l[o];--o)l.pop();return o<0?new n(0*e.s):(e.e=R(l,f),e.d=l,h=!1,s&&(e=D(e,i,4*u)),c&&(e=e.times(Math.abs(c)<54?w(2,c):a.pow(2,c))),h=!0,e)}function Y(e,t,r,n,i){var a,o,s,u,c=e.precision,l=Math.ceil(c/7);for(h=!1,u=r.times(r),s=new e(n);;){if(o=D(s.times(u),new e(t++*t++),c,1),s=i?n.plus(o):n.minus(o),n=D(o.times(u),new e(t++*t++),c,1),void 0!==(o=s.plus(n)).d[l]){for(a=l;o.d[a]===s.d[a]&&a--;);if(-1==a)break}a=s,s=n,n=o,o=a}return h=!0,o.d.length=l+1,o}function X(e,t){for(var r=e;--t;)r*=e;return r}function Q(e,t){var r,n=t.s<0,i=U(e,e.precision,1),a=i.times(.5);if((t=t.abs()).lte(a))return s=n?4:1,t;if((r=t.divToInt(i)).isZero())s=n?3:2;else{if((t=t.minus(r.times(i))).lte(a))return s=H(r)?n?2:3:n?4:1,t;s=H(r)?n?1:4:n?3:2}return t.minus(i).abs()}function K(e,t,r,n){var i,a,s,u,f,p,m,h,d,y=e.constructor,g=void 0!==r;if(g?(B(r,1,c),void 0===n?n=y.rounding:B(n,0,8)):(r=y.precision,n=y.rounding),e.isFinite()){for(g?(i=2,16==t?r=4*r-3:8==t&&(r=3*r-2)):i=t,(s=(m=k(e)).indexOf("."))>=0&&(m=m.replace(".",""),(d=new y(1)).e=m.length-s,d.d=z(k(d),10,i),d.e=d.d.length),a=f=(h=z(m,10,i)).length;0==h[--f];)h.pop();if(h[0]){if(s<0?a--:((e=new y(e)).d=h,e.e=a,h=(e=D(e,d,r,n,0,i)).d,a=e.e,p=o),s=h[r],u=i/2,p=p||void 0!==h[r+1],p=n<4?(void 0!==s||p)&&(0===n||n===(e.s<0?3:2)):s>u||s===u&&(4===n||p||6===n&&1&h[r-1]||n===(e.s<0?8:7)),h.length=r,p)for(;++h[--r]>i-1;)h[r]=0,r||(++a,h.unshift(1));for(f=h.length;!h[f-1];--f);for(s=0,m="";s1)if(16==t||8==t){for(s=16==t?4:3,--f;f%s;f++)m+="0";for(f=(h=z(m,i,t)).length;!h[f-1];--f);for(s=1,m="1.";sf)for(a-=f;a--;)m+="0";else at)return e.length=t,!0}function te(e){return new this(e).abs()}function re(e){return new this(e).acos()}function ne(e){return new this(e).acosh()}function ie(e,t){return new this(e).plus(t)}function ae(e){return new this(e).asin()}function oe(e){return new this(e).asinh()}function se(e){return new this(e).atan()}function ue(e){return new this(e).atanh()}function ce(e,t){e=new this(e),t=new this(t);var r,n=this.precision,i=this.rounding,a=n+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(r=t.s<0?U(this,n,i):new this(0)).s=e.s:!e.d||t.isZero()?(r=U(this,a,1).times(.5)).s=e.s:t.s<0?(this.precision=a,this.rounding=1,r=this.atan(D(e,t,a,1)),t=U(this,a,1),this.precision=n,this.rounding=i,r=e.s<0?r.minus(t):r.plus(t)):r=this.atan(D(e,t,a,1)):(r=U(this,a,1).times(t.s>0?.25:.75)).s=e.s:r=new this(NaN),r}function le(e){return new this(e).cbrt()}function fe(e){return I(e=new this(e),e.e+1,2)}function pe(e,t,r){return new this(e).clamp(t,r)}function me(e){if(!e||"object"!=typeof e)throw Error(d+"Object expected");var t,r,n,i=!0===e.defaults,a=["precision",1,c,"rounding",0,8,"toExpNeg",-u,0,"toExpPos",0,u,"maxE",0,u,"minE",-u,0,"modulo",0,9];for(t=0;t=a[t+1]&&n<=a[t+2]))throw Error(y+r+": "+n);this[r]=n}if(r="crypto",i&&(this[r]=m[r]),void 0!==(n=e[r])){if(!0!==n&&!1!==n&&0!==n&&1!==n)throw Error(y+r+": "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(v);this[r]=!0}else this[r]=!1}return this}function he(e){return new this(e).cos()}function de(e){return new this(e).cosh()}function ye(e,t){return new this(e).div(t)}function ge(e){return new this(e).exp()}function ve(e){return I(e=new this(e),e.e+1,3)}function xe(){var e,t,r=new this(0);for(h=!1,e=0;e=429e7?t[a]=crypto.getRandomValues(new Uint32Array(1))[0]:s[a++]=i%1e7;else{if(!crypto.randomBytes)throw Error(v);for(t=crypto.randomBytes(n*=4);a=214e7?crypto.randomBytes(4).copy(t,a):(s.push(i%1e7),a+=4);a=n/4}else for(;a=10;i/=10)n++;n<7&&(r-=7-n)}return o.e=r,o.d=s,o}function Be(e){return I(e=new this(e),e.e+1,this.rounding)}function qe(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function ze(e){return new this(e).sin()}function De(e){return new this(e).sinh()}function Ie(e){return new this(e).sqrt()}function ke(e,t){return new this(e).sub(t)}function Re(){var e=0,t=arguments,r=new this(t[e]);for(h=!1;r.s&&++ea.maxE?(i.e=NaN,i.d=null):e.e=10;r/=10)t++;return void(h?t>a.maxE?(i.e=NaN,i.d=null):t{"use strict";var t=Object.assign||function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{},o=a.preserveFormatting,s=void 0!==o&&o,u=a.escapeMapFn,c=void 0===u?i:u,l=String(e),f="",p=c(t({},r),s?t({},n):{}),m=Object.keys(p),h=function(){var e=!1;m.forEach((function(t,r){e||l.length>=t.length&&l.slice(0,t.length)===t&&(f+=p[m[r]],l=l.slice(t.length,l.length),e=!0)})),e||(f+=l.slice(0,1),l=l.slice(1,l.length))};l;)h();return f}},628:function(e,t){var r;!function(n){"use strict";var i={s:1,n:0,d:1};function a(e){function t(){var t=Error.apply(this,arguments);t.name=this.name=e,this.stack=t.stack,this.message=t.message}function r(){}return r.prototype=Error.prototype,t.prototype=new r,t}var o=m.DivisionByZero=a("DivisionByZero"),s=m.InvalidParameter=a("InvalidParameter");function u(e,t){return isNaN(e=parseInt(e,10))&&c(),e*t}function c(){throw new s}function l(e){for(var t={},r=e,n=2,i=4;i<=r;){for(;r%n==0;)r/=n,t[n]=(t[n]||0)+1;i+=1+2*n++}return r!==e?r>1&&(t[r]=(t[r]||0)+1):t[e]=(t[e]||0)+1,t}var f=function(e,t){var r,n=0,a=1,s=1,l=0,f=0,p=0,m=1,h=1,d=0,y=1,g=1,v=1,x=1e7;if(null==e);else if(void 0!==t)s=(n=e)*(a=t);else switch(typeof e){case"object":"d"in e&&"n"in e?(n=e.n,a=e.d,"s"in e&&(n*=e.s)):0 in e?(n=e[0],1 in e&&(a=e[1])):c(),s=n*a;break;case"number":if(e<0&&(s=e,e=-e),e%1==0)n=e;else if(e>0){for(e>=1&&(e/=h=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)));y<=x&&v<=x;){if(e===(r=(d+g)/(y+v))){y+v<=x?(n=d+g,a=y+v):v>y?(n=g,a=v):(n=d,a=y);break}e>r?(d+=g,y+=v):(g+=d,v+=y),y>x?(n=g,a=v):(n=d,a=y)}n*=h}else(isNaN(e)||isNaN(t))&&(a=n=NaN);break;case"string":if(null===(y=e.match(/\d+|./g))&&c(),"-"===y[d]?(s=-1,d++):"+"===y[d]&&d++,y.length===d+1?f=u(y[d++],s):"."===y[d+1]||"."===y[d]?("."!==y[d]&&(l=u(y[d++],s)),(1+ ++d===y.length||"("===y[d+1]&&")"===y[d+3]||"'"===y[d+1]&&"'"===y[d+3])&&(f=u(y[d],s),m=Math.pow(10,y[d].length),d++),("("===y[d]&&")"===y[d+2]||"'"===y[d]&&"'"===y[d+2])&&(p=u(y[d+1],s),h=Math.pow(10,y[d+1].length)-1,d+=3)):"/"===y[d+1]||":"===y[d+1]?(f=u(y[d],s),m=u(y[d+2],1),d+=3):"/"===y[d+3]&&" "===y[d+1]&&(l=u(y[d],s),f=u(y[d+2],s),m=u(y[d+4],1),d+=5),y.length<=d){s=n=p+(a=m*h)*l+h*f;break}default:c()}if(0===a)throw new o;i.s=s<0?-1:1,i.n=Math.abs(n),i.d=Math.abs(a)};function p(e,t){if(!e)return t;if(!t)return e;for(;;){if(!(e%=t))return t;if(!(t%=e))return e}}function m(e,t){if(!(this instanceof m))return new m(e,t);f(e,t),e=m.REDUCE?p(i.d,i.n):1,this.s=i.s,this.n=i.n/e,this.d=i.d/e}m.REDUCE=1,m.prototype={s:1,n:0,d:1,abs:function(){return new m(this.n,this.d)},neg:function(){return new m(-this.s*this.n,this.d)},add:function(e,t){return f(e,t),new m(this.s*this.n*i.d+i.s*this.d*i.n,this.d*i.d)},sub:function(e,t){return f(e,t),new m(this.s*this.n*i.d-i.s*this.d*i.n,this.d*i.d)},mul:function(e,t){return f(e,t),new m(this.s*i.s*this.n*i.n,this.d*i.d)},div:function(e,t){return f(e,t),new m(this.s*i.s*this.n*i.d,this.d*i.n)},clone:function(){return new m(this)},mod:function(e,t){return isNaN(this.n)||isNaN(this.d)?new m(NaN):void 0===e?new m(this.s*this.n%this.d,1):(f(e,t),0===i.n&&0===this.d&&m(0,0),new m(this.s*(i.d*this.n)%(i.n*this.d),i.d*this.d))},gcd:function(e,t){return f(e,t),new m(p(i.n,this.n)*p(i.d,this.d),i.d*this.d)},lcm:function(e,t){return f(e,t),0===i.n&&0===this.n?new m:new m(i.n*this.n,p(i.n,this.n)*p(i.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new m(NaN):new m(Math.round(e*this.s*this.n/this.d),e)},inverse:function(){return new m(this.s*this.d,this.n)},pow:function(e,t){if(f(e,t),1===i.d)return i.s<0?new m(Math.pow(this.s*this.d,i.n),Math.pow(this.n,i.n)):new m(Math.pow(this.s*this.n,i.n),Math.pow(this.d,i.n));if(this.s<0)return null;var r=l(this.n),n=l(this.d),a=1,o=1;for(var s in r)if("1"!==s){if("0"===s){a=0;break}if(r[s]*=i.n,r[s]%i.d!=0)return null;r[s]/=i.d,a*=Math.pow(s,r[s])}for(var s in n)if("1"!==s){if(n[s]*=i.n,n[s]%i.d!=0)return null;n[s]/=i.d,o*=Math.pow(s,n[s])}return i.s<0?new m(o,a):new m(a,o)},equals:function(e,t){return f(e,t),this.s*this.n*i.d==i.s*i.n*this.d},compare:function(e,t){f(e,t);var r=this.s*this.n*i.d-i.s*i.n*this.d;return(00&&(r+=t,r+=" ",n%=i),r+=n,r+="/",r+=i),r},toLatex:function(e){var t,r="",n=this.n,i=this.d;return this.s<0&&(r+="-"),1===i?r+=n:(e&&(t=Math.floor(n/i))>0&&(r+=t,n%=i),r+="\\frac{",r+=n,r+="}{",r+=i,r+="}"),r},toContinued:function(){var e,t=this.n,r=this.d,n=[];if(isNaN(t)||isNaN(r))return n;do{n.push(Math.floor(t/r)),e=t%r,t=r,r=e}while(1!==t);return n},toString:function(e){var t,r=this.n,n=this.d;if(isNaN(r)||isNaN(n))return"NaN";m.REDUCE||(r/=t=p(r,n),n/=t),e=e||15;var i=function(e,t){for(;t%2==0;t/=2);for(;t%5==0;t/=5);if(1===t)return 0;for(var r=10%t,n=1;1!==r;n++)if(r=10*r%t,n>2e3)return 0;return n}(0,n),a=function(e,t,r){for(var n=1,i=function(e,t,r){for(var n=1;t>0;e=e*e%r,t>>=1)1&t&&(n=n*e%r);return n}(10,r,t),a=0;a<300;a++){if(n===i)return a;n=10*n%t,i=10*i%t}return 0}(0,n,i),o=-1===this.s?"-":"";if(o+=r/n|0,r%=n,(r*=10)&&(o+="."),i){for(var s=a;s--;)o+=r/n|0,r%=n,r*=10;for(o+="(",s=i;s--;)o+=r/n|0,r%=n,r*=10;o+=")"}else for(s=e;r&&s--;)o+=r/n|0,r%=n,r*=10;return o}},void 0===(r=function(){return m}.apply(t,[]))||(e.exports=r)}()},228:e=>{e.exports=function e(t,r){"use strict";var n,i,a=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,o=/(^[ ]*|[ ]*$)/g,s=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,u=/^0x[0-9a-f]+$/i,c=/^0/,l=function(t){return e.insensitive&&(""+t).toLowerCase()||""+t},f=l(t).replace(o,"")||"",p=l(r).replace(o,"")||"",m=f.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),h=p.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),d=parseInt(f.match(u),16)||1!==m.length&&f.match(s)&&Date.parse(f),y=parseInt(p.match(u),16)||d&&p.match(s)&&Date.parse(p)||null;if(y){if(dy)return 1}for(var g=0,v=Math.max(m.length,h.length);gi)return 1}return 0}},377:(e,t,r)=>{var n=r(832),i=r(652),a=r(801),o=r(30),s=r(618),u=r(49),c=r(971);c.alea=n,c.xor128=i,c.xorwow=a,c.xorshift7=o,c.xor4096=s,c.tychei=u,e.exports=c},832:function(e,t,r){var n;!function(e,i,a){function o(e){var t,r=this,n=(t=4022871197,function(e){e=String(e);for(var r=0;r>>0,t=(n*=t)>>>0,t+=4294967296*(n-=t)}return 2.3283064365386963e-10*(t>>>0)});r.next=function(){var e=2091639*r.s0+2.3283064365386963e-10*r.c;return r.s0=r.s1,r.s1=r.s2,r.s2=e-(r.c=0|e)},r.c=1,r.s0=n(" "),r.s1=n(" "),r.s2=n(" "),r.s0-=n(e),r.s0<0&&(r.s0+=1),r.s1-=n(e),r.s1<0&&(r.s1+=1),r.s2-=n(e),r.s2<0&&(r.s2+=1),n=null}function s(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function u(e,t){var r=new o(e),n=t&&t.state,i=r.next;return i.int32=function(){return 4294967296*r.next()|0},i.double=function(){return i()+11102230246251565e-32*(2097152*i()|0)},i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.alea=u}(0,e=r.nmd(e),r.amdD)},49:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.next=function(){var e=t.b,r=t.c,n=t.d,i=t.a;return e=e<<25^e>>>7^r,r=r-n|0,n=n<<24^n>>>8^i,i=i-e|0,t.b=e=e<<20^e>>>12^r,t.c=r=r-n|0,t.d=n<<16^r>>>16^i,t.a=i-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):r+=e;for(var n=0;n>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.tychei=u}(0,e=r.nmd(e),r.amdD)},652:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:r+=e;for(var n=0;n>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xor128=u}(0,e=r.nmd(e),r.amdD)},618:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this;t.next=function(){var e,r,n=t.w,i=t.X,a=t.i;return t.w=n=n+1640531527|0,r=i[a+34&127],e=i[a=a+1&127],r^=r<<13,e^=e<<17,r^=r>>>15,e^=e>>>12,r=i[a]=r^e,t.i=a,r+(n^n>>>16)|0},function(e,t){var r,n,i,a,o,s=[],u=128;for(t===(0|t)?(n=t,t=null):(t+="\0",n=0,u=Math.max(u,t.length)),i=0,a=-32;a>>15,n^=n<<4,n^=n>>>13,a>=0&&(o=o+1640531527|0,i=0==(r=s[127&a]^=n+o)?i+1:0);for(i>=128&&(s[127&(t&&t.length||0)]=-1),i=127,a=512;a>0;--a)n=s[i+34&127],r=s[i=i+1&127],n^=n<<13,r^=r<<17,n^=n>>>15,r^=r>>>12,s[i]=n^r;e.w=o,e.X=s,e.i=i}(t,e)}function s(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function u(e,t){null==e&&(e=+new Date);var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&(n.X&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xor4096=u}(0,e=r.nmd(e),r.amdD)},30:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this;t.next=function(){var e,r,n=t.x,i=t.i;return e=n[i],r=(e^=e>>>7)^e<<24,r^=(e=n[i+1&7])^e>>>10,r^=(e=n[i+3&7])^e>>>3,r^=(e=n[i+4&7])^e<<7,e=n[i+7&7],r^=(e^=e<<13)^e<<9,n[i]=r,t.i=i+1&7,r},function(e,t){var r,n=[];if(t===(0|t))n[0]=t;else for(t=""+t,r=0;r0;--r)e.next()}(t,e)}function s(e,t){return t.x=e.x.slice(),t.i=e.i,t}function u(e,t){null==e&&(e=+new Date);var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&(n.x&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xorshift7=u}(0,e=r.nmd(e),r.amdD)},801:function(e,t,r){var n;!function(e,i,a){function o(e){var t=this,r="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:r+=e;for(var n=0;n>>4),t.next()}function s(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function u(e,t){var r=new o(e),n=t&&t.state,i=function(){return(r.next()>>>0)/4294967296};return i.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},i.int32=r.next,i.quick=i,n&&("object"==typeof n&&s(n,r),i.state=function(){return s(r,{})}),i}i&&i.exports?i.exports=u:r.amdD&&r.amdO?void 0===(n=function(){return u}.call(t,r,t,i))||(i.exports=n):this.xorwow=u}(0,e=r.nmd(e),r.amdD)},971:function(e,t,r){var n;!function(i,a,o){var s,u=256,c=o.pow(u,6),l=o.pow(2,52),f=2*l,p=255;function m(e,t,r){var n=[],p=g(y((t=1==t?{entropy:!0}:t||{}).entropy?[e,v(a)]:null==e?function(){try{var e;return s&&(e=s.randomBytes)?e=e(u):(e=new Uint8Array(u),(i.crypto||i.msCrypto).getRandomValues(e)),v(e)}catch(e){var t=i.navigator,r=t&&t.plugins;return[+new Date,i,r,i.screen,v(a)]}}():e,3),n),m=new h(n),x=function(){for(var e=m.g(6),t=c,r=0;e=f;)e/=2,t/=2,r>>>=1;return(e+r)/t};return x.int32=function(){return 0|m.g(4)},x.quick=function(){return m.g(4)/4294967296},x.double=x,g(v(m.S),a),(t.pass||r||function(e,t,r,n){return n&&(n.S&&d(n,m),e.state=function(){return d(m,{})}),r?(o.random=e,t):e})(x,p,"global"in t?t.global:this==o,t.state)}function h(e){var t,r=e.length,n=this,i=0,a=n.i=n.j=0,o=n.S=[];for(r||(e=[r++]);i3?e.slice(3):"any":e).split("|").map(q).filter(z).filter(B),i=function(e,t){var r={};return e.forEach((function(e){-1!==t.indexOf(e.from)||-1===t.indexOf(e.to)||r[e.from]||(r[e.from]=e)})),Object.keys(r).map((function(e){return r[e]}))}(t,n),a=n.map((function(e){var t=c(e);return{name:e,typeIndex:l(t),test:t.test,conversion:null,conversionIndex:-1}})),o=i.map((function(e){var r=c(e.from);return{name:e.from,typeIndex:l(r),test:r.test,conversion:e,conversionIndex:t.indexOf(e)}}));return{types:a.concat(o),restParam:r}}function h(e){var t=k(e);return!!t&&t.restParam}function d(e){return e.types.some((function(e){return null!=e.conversion}))}function y(t){if(t&&0!==t.types.length){if(1===t.types.length)return c(t.types[0].name).test;if(2===t.types.length){var r=c(t.types[0].name).test,n=c(t.types[1].name).test;return function(e){return r(e)||n(e)}}var i=t.types.map((function(e){return c(e.name).test}));return function(e){for(var t=0;t=a+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(r=y(e[0]),function(e){return r(e[0])&&1===e.length}):2===e.length?(r=y(e[0]),n=y(e[1]),function(e){return r(e[0])&&n(e[1])&&2===e.length}):(t=e.map(y),function(e){for(var r=0;r0){var c=f(t[a]);return(n=new TypeError("Unexpected type of argument in function "+o+" (expected: "+i.join(" or ")+", actual: "+c+", index: "+a+")")).data={category:"wrongType",fn:o,index:a,actual:c,expected:i},n}}else s=u}var l=s.map((function(e){return h(e.params)?1/0:e.params.length}));if(t.lengthp?((n=new TypeError("Too many arguments in function "+o+" (expected: "+p+", actual: "+t.length+")")).data={category:"tooManyArgs",fn:o,index:t.length,expectedLength:p},n):((n=new TypeError('Arguments of type "'+t.join(", ")+'" do not match any of the defined signatures of function '+o+".")).data={category:"mismatch",actual:t.map(f)},n)}function S(e){for(var t=999,r=0;r=i:s?i>=a:i===a}(t,e)}));if(t)throw new TypeError('Conflicting signatures "'+p(t.params)+'" and "'+p(e.params)+'".');i.push(e)}));var a=P(i,(function(e){return(e?_(e.params,!1):[]).map((function(t){return{params:t,fn:e.fn}}))})).filter(D);a.sort(O);var o=a[0]&&a[0].params.length<=2&&!h(a[0].params),s=a[1]&&a[1].params.length<=2&&!h(a[1].params),c=a[2]&&a[2].params.length<=2&&!h(a[2].params),l=a[3]&&a[3].params.length<=2&&!h(a[3].params),f=a[4]&&a[4].params.length<=2&&!h(a[4].params),v=a[5]&&a[5].params.length<=2&&!h(a[5].params),b=o&&s&&c&&l&&f&&v,w=a.map((function(e){return g(e.params)})),N=o?y(a[0].params[0]):t,S=s?y(a[1].params[0]):t,E=c?y(a[2].params[0]):t,A=l?y(a[3].params[0]):t,T=f?y(a[4].params[0]):t,B=v?y(a[5].params[0]):t,z=o?y(a[0].params[1]):t,k=s?y(a[1].params[1]):t,j=c?y(a[2].params[1]):t,L=l?y(a[3].params[1]):t,H=f?y(a[4].params[1]):t,$=v?y(a[5].params[1]):t,G=a.map((function(e){return function(e,t){var r=t;if(e.some(d)){var n=h(e),i=e.map(C);r=function(){for(var e=[],r=n?arguments.length-1:arguments.length,a=0;a{}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var a=t[n]={id:n,loaded:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.loaded=!0,a.exports}r.amdD=function(){throw new Error("define cannot be used indirect")},r.amdO={},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";function e(){return(e=Object.assign||function(e){for(var t=1;t!function(e){return e&&"?"===e[0]}(e))).every((e=>void 0!==r[e]))){var n=t.filter((e=>void 0===r[e]));throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(n.map((e=>'"'.concat(e,'"'))).join(", "),"."))}}(e,t,n),r(i)}return i.isFactory=!0,i.fn=e,i.dependencies=t.slice().sort(),n&&(i.meta=n),i}function J(e){return e&&"?"===e[0]?e.slice(1):e}function Y(e,t){if(ee(e)&&Q(e,t))return e[t];if("function"==typeof e[t]&&K(e,t))throw new Error('Cannot access method "'+t+'" as a property');throw new Error('No access to property "'+t+'"')}function X(e,t,r){if(ee(e)&&Q(e,t))return e[t]=r,r;throw new Error('No access to property "'+t+'"')}function Q(e,t){return!(!e||"object"!=typeof e||!V(te,t)&&(t in Object.prototype||t in Function.prototype))}function K(e,t){return!(null==e||"function"!=typeof e[t]||V(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e)||!V(re,t)&&(t in Object.prototype||t in Function.prototype))}function ee(e){return"object"==typeof e&&e&&e.constructor===Object}var te={length:!0,name:!0},re={toString:!0,valueOf:!0,toLocaleString:!0};class ne{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return Y(this.wrappedObject,e)}set(e,t){return X(this.wrappedObject,e,t),this}has(e){return e in this.wrappedObject}}function ie(){return new Map}function ae(e){if(!e)return ie();if(oe(e))return e;if(M(e))return new ne(e);throw new Error("createMap can create maps from objects or Maps")}function oe(e){return!!e&&(e instanceof Map||e instanceof ne||"function"==typeof e.set&&"function"==typeof e.get&&"function"==typeof e.keys&&"function"==typeof e.has)}function se(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{var{mathWithTransform:t}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator")}return r.prototype.evaluate=function(e){return this.compile().evaluate(e)},r.prototype.type="Node",r.prototype.isNode=!0,r.prototype.comment="",r.prototype.compile=function(){var e=this._compile(t,{}),r={};return{evaluate:function(t){var n=ae(t);return function(e){for(var t of[...H])if(e.has(t))throw new Error('Scope contains an illegal symbol, "'+t+'" is a reserved keyword')}(n),e(n,r,null)}}},r.prototype._compile=function(e,t){throw new Error("Method _compile should be implemented by type "+this.type)},r.prototype.forEach=function(e){throw new Error("Cannot run forEach on a Node interface")},r.prototype.map=function(e){throw new Error("Cannot run map on a Node interface")},r.prototype._ifNode=function(e){if(!I(e))throw new TypeError("Callback function must return a Node");return e},r.prototype.traverse=function(e){e(this,null,null),function e(t,r){t.forEach((function(t,n,i){r(t,n,i),e(t,r)}))}(this,e)},r.prototype.transform=function(e){return function t(r,n,i){var a=e(r,n,i);return a!==r?a:r.map(t)}(this,null,null)},r.prototype.filter=function(e){var t=[];return this.traverse((function(r,n,i){e(r,n,i)&&t.push(r)})),t},r.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},r.prototype.cloneDeep=function(){return this.map((function(e){return e.cloneDeep()}))},r.prototype.equals=function(e){return!!e&&Z(this,e)},r.prototype.toString=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toString(e)},r.prototype.toJSON=function(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)},r.prototype.toHTML=function(e){var t=this._getCustomString(e);return void 0!==t?t:this.toHTML(e)},r.prototype._toString=function(){throw new Error("_toString not implemented for "+this.type)},r.prototype.toTex=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toTex(e)},r.prototype._toTex=function(e){throw new Error("_toTex not implemented for "+this.type)},r.prototype._getCustomString=function(e){if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":return;case"function":return e.handler(this,e);default:throw new TypeError("Object or function expected as callback")}},r.prototype.getIdentifier=function(){return this.type},r.prototype.getContent=function(){return this},r}),{isClass:!0,isNode:!0});function ce(e){return"boolean"==typeof e||!!isFinite(e)&&e===Math.round(e)}var le=Math.sign||function(e){return e>0?1:e<0?-1:0},fe=Math.log2||function(e){return Math.log(e)/Math.LN2},pe=Math.log10||function(e){return Math.log(e)/Math.LN10},me=Math.log1p||function(e){return Math.log(e+1)},he=Math.cbrt||function(e){if(0===e)return e;var t,r=e<0;return r&&(e=-e),t=isFinite(e)?(e/((t=Math.exp(Math.log(e)/3))*t)+2*t)/3:e,r?-t:t},de=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function ye(e,t,r){var n={2:"0b",8:"0o",16:"0x"}[t],i="";if(r){if(r<1)throw new Error("size must be in greater than 0");if(!ce(r))throw new Error("size must be an integer");if(e>2**(r-1)-1||e<-(2**(r-1)))throw new Error("Value must be in range [-2^".concat(r-1,", 2^").concat(r-1,"-1]"));if(!ce(e))throw new Error("Value must be an integer");e<0&&(e+=2**r),i="i".concat(r)}var a="";return e<0&&(e=-e,a="-"),"".concat(a).concat(n).concat(e.toString(t)).concat(i)}function ge(e,t){if("function"==typeof t)return t(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var r,n,a="auto";if(t&&(t.notation&&(a=t.notation),i(t)?r=t:i(t.precision)&&(r=t.precision),t.wordSize&&"number"!=typeof(n=t.wordSize)))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return xe(e,r);case"exponential":return be(e,r);case"engineering":return function(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=we(ve(e),t),n=r.exponent,a=r.coefficients,o=n%3==0?n:n<0?n-3-n%3:n-n%3;if(i(t))for(;t>a.length||n-o+1>a.length;)a.push(0);else for(var s=Math.abs(n-o)-(a.length-1),u=0;u0;)l++,c--;var f=a.slice(l).join(""),p=i(t)&&f.length||f.match(/[1-9]/)?"."+f:"",m=a.slice(0,l).join("")+p+"e"+(n>=0?"+":"")+o.toString();return r.sign+m}(e,r);case"bin":return ye(e,2,n);case"oct":return ye(e,8,n);case"hex":return ye(e,16,n);case"auto":return function(e,t,r){if(isNaN(e)||!isFinite(e))return String(e);var n=r&&void 0!==r.lowerExp?r.lowerExp:-3,i=r&&void 0!==r.upperExp?r.upperExp:5,a=ve(e),o=t?we(a,t):a;if(o.exponent=i)return be(e,t);var s=o.coefficients,u=o.exponent;s.length0?u:0;return c<(s=Ne(-u).concat(s)).length-1&&s.splice(c+1,0,"."),o.sign+s.join("")}(e,r,t&&t).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t}));default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function ve(e){var t=String(e).toLowerCase().match(/^0*?(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+e);var r=t[1],n=t[2],i=parseFloat(t[4]||"0"),a=n.indexOf(".");i+=-1!==a?a-1:n.length-1;var o=n.replace(".","").replace(/^0*/,(function(e){return i-=e.length,""})).replace(/0*$/,"").split("").map((function(e){return parseInt(e)}));return 0===o.length&&(o.push(0),i++),{sign:r,coefficients:o,exponent:i}}function xe(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=ve(e),n="number"==typeof t?we(r,r.exponent+1+t):r,i=n.coefficients,a=n.exponent+1,o=a+(t||0);return i.length0?"."+i.join(""):"")+"e"+(a>=0?"+":"")+a}function we(e,t){for(var r={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},n=r.coefficients;t<=0;)n.unshift(0),r.exponent++,t++;if(n.length>t&&n.splice(t,n.length-t)[0]>=5){var i=t-1;for(n[i]++;10===n[i];)n.pop(),0===i&&(n.unshift(0),r.exponent++,i++),n[--i]++}return r}function Ne(e){for(var t=[],r=0;r=0?"+":"")+n.toString()}(e,r);case"bin":return Be(e,2,n);case"oct":return Be(e,8,n);case"hex":return Be(e,16,n);case"auto":var a=t&&void 0!==t.lowerExp?t.lowerExp:-3,o=t&&void 0!==t.upperExp?t.upperExp:5;if(e.isZero())return"0";var s=e.toSignificantDigits(r),u=s.e;return(u>=a&&u'"'+r+'": '+De(e[r],t))).join(", ")+"}":String(e)}function Ie(e){for(var t=String(e),r="",n=0;n/g,">")}function Re(e,t){if(Array.isArray(e)){for(var r="[",n=e.length,i=0;it?1:-1}function Ue(e,t,r){if(!(this instanceof Ue))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=t,this.relation=r,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=(new Error).stack}function Pe(e,t,r){if(!(this instanceof Pe))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=r),void 0!==this.min&&this.index=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}function je(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function Le(e,t,r){var n,i=e.length;if(i!==t[r])throw new Ue(i,t[r]);if(r")}function He(e,t){if(0===t.length){if(Array.isArray(e))throw new Ue(e.length,0)}else Le(e,t,0)}function $e(e,t){if(!i(e)||!ce(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&e>=t)throw new Pe(e,t)}function Ge(e,t,r){if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");return t.forEach((function(e){if(!i(e)||!ce(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+De(t)+")")})),Ze(e,t,0,void 0!==r?r:0),e}function Ze(e,t,r,n){var i,a,o=e.length,s=t[r],u=Math.min(o,s);if(e.length=s,r=0){if(t%r!=0)throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-r);n[i]=-t/r}return n}function Je(e){return e.reduce(((e,t)=>e*t),1)}function Ye(e,t){for(var r=t||je(e);Array.isArray(e)&&1===e.length;)e=e[0],r.shift();for(var n=r.length;1===r[n-1];)n--;return nt.test(e)))}function at(e,t){return Array.prototype.join.call(e,t)}function ot(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;var t=[],r=0;t[0]={value:e[0],identifier:0};for(var n=1;n{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=e||[],!Array.isArray(this.items)||!this.items.every(I))throw new TypeError("Array containing Nodes expected")}return r.prototype=new t,r.prototype.type="ArrayNode",r.prototype.isArrayNode=!0,r.prototype._compile=function(e,t){var r=tt(this.items,(function(r){return r._compile(e,t)}));if("Array"!==e.config.matrix){var n=e.matrix;return function(e,t,i){return n(tt(r,(function(r){return r(e,t,i)})))}}return function(e,t,n){return tt(r,(function(r){return r(e,t,n)}))}},r.prototype.forEach=function(e){for(var t=0;t['+this.items.map((function(t){return t.toHTML(e)})).join(',')+']'},r.prototype._toTex=function(e){return function t(r,n){var i=r.some(O)&&!r.every(O),a=n||i,o=a?"&":"\\\\",s=r.map((function(r){return r.items?t(r.items,!n):r.toTex(e)})).join(o);return i||!a||a&&!n?"\\begin{bmatrix}"+s+"\\end{bmatrix}":s}(this.items,!1)},r}),{isClass:!0,isNode:!0}),lt=W("BlockNode",["ResultSet","Node"],(e=>{var{ResultSet:t,Node:r}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map((function(e){var t=e&&e.node,r=!e||void 0===e.visible||e.visible;if(!I(t))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof r)throw new TypeError('Property "visible" must be a boolean');return{node:t,visible:r}}))}return n.prototype=new r,n.prototype.type="BlockNode",n.prototype.isBlockNode=!0,n.prototype._compile=function(e,r){var n=tt(this.blocks,(function(t){return{evaluate:t.node._compile(e,r),visible:t.visible}}));return function(e,r,i){var a=[];return rt(n,(function(t){var n=t.evaluate(e,r,i);t.visible&&a.push(n)})),new t(a)}},n.prototype.forEach=function(e){for(var t=0;t;')})).join('
')},n.prototype._toTex=function(e){return this.blocks.map((function(t){return t.node.toTex(e)+(t.visible?"":";")})).join("\\;\\;\n")},n}),{isClass:!0,isNode:!0}),ft=r(928),pt={Alpha:"A",alpha:"\\alpha",Beta:"B",beta:"\\beta",Gamma:"\\Gamma",gamma:"\\gamma",Delta:"\\Delta",delta:"\\delta",Epsilon:"E",epsilon:"\\epsilon",varepsilon:"\\varepsilon",Zeta:"Z",zeta:"\\zeta",Eta:"H",eta:"\\eta",Theta:"\\Theta",theta:"\\theta",vartheta:"\\vartheta",Iota:"I",iota:"\\iota",Kappa:"K",kappa:"\\kappa",varkappa:"\\varkappa",Lambda:"\\Lambda",lambda:"\\lambda",Mu:"M",mu:"\\mu",Nu:"N",nu:"\\nu",Xi:"\\Xi",xi:"\\xi",Omicron:"O",omicron:"o",Pi:"\\Pi",pi:"\\pi",varpi:"\\varpi",Rho:"P",rho:"\\rho",varrho:"\\varrho",Sigma:"\\Sigma",sigma:"\\sigma",varsigma:"\\varsigma",Tau:"T",tau:"\\tau",Upsilon:"\\Upsilon",upsilon:"\\upsilon",Phi:"\\Phi",phi:"\\phi",varphi:"\\varphi",Chi:"X",chi:"\\chi",Psi:"\\Psi",psi:"\\psi",Omega:"\\Omega",omega:"\\omega",true:"\\mathrm{True}",false:"\\mathrm{False}",i:"i",inf:"\\infty",Inf:"\\infty",infinity:"\\infty",Infinity:"\\infty",oo:"\\infty",lim:"\\lim",undefined:"\\mathbf{?}"},mt={transpose:"^\\top",ctranspose:"^H",factorial:"!",pow:"^",dotPow:".^\\wedge",unaryPlus:"+",unaryMinus:"-",bitNot:"\\~",not:"\\neg",multiply:"\\cdot",divide:"\\frac",dotMultiply:".\\cdot",dotDivide:".:",mod:"\\mod",add:"+",subtract:"-",to:"\\rightarrow",leftShift:"<<",rightArithShift:">>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},ht={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(mt.add,"${args[1]}\\right)")},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:"\\left(${args[0]}".concat(mt.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(mt.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(mt.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(mt.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:"\\left(${args[0]}".concat(mt.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(mt.multiply,"${args[1]}\\right)")},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : $y^{args[1]} = {${args[0]}}\\}"},pow:{2:"\\left(${args[0]}\\right)".concat(mt.pow,"{${args[1]}}")},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:"\\left(${args[0]}".concat(mt.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(mt.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(mt.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(mt.bitAnd,"${args[1]}\\right)")},bitNot:{1:mt.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(mt.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(mt.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(mt.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(mt.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(mt.rightLogShift,"${args[1]}\\right)")},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:"\\left(${args[0]}".concat(mt.and,"${args[1]}\\right)")},not:{1:mt.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(mt.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(mt.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(mt.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},sqrtm:{1:"{${args[0]}}".concat(mt.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(mt.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(mt.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(mt.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(mt.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(mt.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(mt.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(mt.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(mt.unequal,"${args[1]}\\right)")},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:"\\left(${args[0]}".concat(mt.to,"${args[1]}\\right)")},numeric:function(e,t){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(pt.i,"\\cdot\\left(${args[1]}\\right)\\right)")},matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},dt={deg:"^\\circ"};function yt(e){return ft(e,{preserveFormatting:!0})}function gt(e,t){return(t=void 0!==t&&t)?V(dt,e)?dt[e]:"\\mathrm{"+yt(e)+"}":V(pt,e)?pt[e]:yt(e)}var vt=W("ConstantNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this.value=e}return r.prototype=new t,r.prototype.type="ConstantNode",r.prototype.isConstantNode=!0,r.prototype._compile=function(e,t){var r=this.value;return function(){return r}},r.prototype.forEach=function(e){},r.prototype.map=function(e){return this.clone()},r.prototype.clone=function(){return new r(this.value)},r.prototype._toString=function(e){return De(this.value,e)},r.prototype.toHTML=function(e){var t=this._toString(e);switch(L(this.value)){case"number":case"BigNumber":case"Fraction":return''+t+"";case"string":return''+t+"";case"boolean":return''+t+"";case"null":return''+t+"";case"undefined":return''+t+"";default:return''+t+""}},r.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},r.fromJSON=function(e){return new r(e.value)},r.prototype._toTex=function(e){var t=this._toString(e);switch(L(this.value)){case"string":return"\\mathtt{"+yt(t)+"}";case"number":case"BigNumber":if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var r=t.toLowerCase().indexOf("e");return-1!==r?t.substring(0,r)+"\\cdot10^{"+t.substring(r+1)+"}":t;case"Fraction":return this.value.toLatex();default:return t}},r}),{isClass:!0,isNode:!0}),xt=W("ObjectNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=e||{},e&&("object"!=typeof e||!Object.keys(e).every((function(t){return I(e[t])}))))throw new TypeError("Object containing Nodes expected")}return r.prototype=new t,r.prototype.type="ObjectNode",r.prototype.isObjectNode=!0,r.prototype._compile=function(e,t){var r={};for(var n in this.properties)if(V(this.properties,n)){var i=Ie(n),a=JSON.parse(i);if(!Q(this.properties,a))throw new Error('No access to property "'+a+'"');r[a]=this.properties[n]._compile(e,t)}return function(e,t,n){var i={};for(var a in r)V(r,a)&&(i[a]=r[a](e,t,n));return i}},r.prototype.forEach=function(e){for(var t in this.properties)V(this.properties,t)&&e(this.properties[t],"properties["+Ie(t)+"]",this)},r.prototype.map=function(e){var t={};for(var n in this.properties)V(this.properties,n)&&(t[n]=this._ifNode(e(this.properties[n],"properties["+Ie(n)+"]",this)));return new r(t)},r.prototype.clone=function(){var e={};for(var t in this.properties)V(this.properties,t)&&(e[t]=this.properties[t]);return new r(e)},r.prototype._toString=function(e){var t=[];for(var r in this.properties)V(this.properties,r)&&t.push(Ie(r)+": "+this.properties[r].toString(e));return"{"+t.join(", ")+"}"},r.prototype.toJSON=function(){return{mathjs:"ObjectNode",properties:this.properties}},r.fromJSON=function(e){return new r(e.properties)},r.prototype.toHTML=function(e){var t=[];for(var r in this.properties)V(this.properties,r)&&t.push(''+ke(r)+':'+this.properties[r].toHTML(e));return'{'+t.join(',')+'}'},r.prototype._toTex=function(e){var t=[];for(var r in this.properties)V(this.properties,r)&&t.push("\\mathbf{"+r+":} & "+this.properties[r].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(t.join("\n"),"\\end{array}\\right\\}")},r}),{isClass:!0,isNode:!0}),bt=W("ParenthesisNode",["Node"],(e=>{var{Node:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError('Node expected for parameter "content"');this.content=e}return r.prototype=new t,r.prototype.type="ParenthesisNode",r.prototype.isParenthesisNode=!0,r.prototype._compile=function(e,t){return this.content._compile(e,t)},r.prototype.getContent=function(){return this.content.getContent()},r.prototype.forEach=function(e){e(this.content,"content",this)},r.prototype.map=function(e){return new r(e(this.content,"content",this))},r.prototype.clone=function(){return new r(this.content)},r.prototype._toString=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)},r.prototype.toJSON=function(){return{mathjs:"ParenthesisNode",content:this.content}},r.fromJSON=function(e){return new r(e.content)},r.prototype.toHTML=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?'('+this.content.toHTML(e)+')':this.content.toHTML(e)},r.prototype._toTex=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)},r}),{isClass:!0,isNode:!0}),wt=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{associativity:"left",associativeWith:[]}},{"OperatorNode:and":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{associativity:"left",associativeWith:[]},"OperatorNode:unequal":{associativity:"left",associativeWith:[]},"OperatorNode:smaller":{associativity:"left",associativeWith:[]},"OperatorNode:larger":{associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{associativity:"left",associativeWith:[]}},{"OperatorNode:to":{associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{associativity:"left",associativeWith:[]},"OperatorNode:mod":{associativity:"left",associativeWith:[]}},{"OperatorNode:unaryPlus":{associativity:"right"},"OperatorNode:unaryMinus":{associativity:"right"},"OperatorNode:bitNot":{associativity:"right"},"OperatorNode:not":{associativity:"right"}},{"OperatorNode:pow":{associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{associativity:"left"}},{"OperatorNode:transpose":{associativity:"left"}}];function Nt(e,t){var r=e;"keep"!==t&&(r=e.getContent());for(var n=r.getIdentifier(),i=0;i{var{Node:t}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(t))throw new TypeError("Parameter params must be an array");if(e.length!==t.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=t}return r.prototype=new t,r.prototype.type="RelationalNode",r.prototype.isRelationalNode=!0,r.prototype._compile=function(e,t){var r=this,n=this.params.map((r=>r._compile(e,t)));return function(t,i,a){for(var o,s=n[0](t,i,a),u=0;ue(t,"params["+r+"]",this)),this)},r.prototype.map=function(e){return new r(this.conditionals.slice(),this.params.map(((t,r)=>this._ifNode(e(t,"params["+r+"]",this))),this))},r.prototype.clone=function(){return new r(this.conditionals,this.params)},r.prototype._toString=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.params.map((function(n,i){var a=Nt(n,t);return"all"===t||null!==a&&a<=r?"("+n.toString(e)+")":n.toString(e)})),i={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},a=n[0],o=0;o('+n.toHTML(e)+')':n.toHTML(e)})),i={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},a=n[0],o=0;o'+ke(i[this.conditionals[o]])+""+n[o+1];return a},r.prototype._toTex=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.params.map((function(n,i){var a=Nt(n,t);return"all"===t||null!==a&&a<=r?"\\left("+n.toTex(e)+"\right)":n.toTex(e)})),i=n[0],a=0;a{var{on:t,math:r}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");j(e)?this.value=e.value:this.value=e}function i(e,t){var r,i,o,s,u;r=n.prototype,i=e,o=function(){var e=t();if("function"==typeof e)return a(e)},u=!0,Object.defineProperty(r,i,{get:function(){return u&&(s=o(),u=!1),s},set:function(e){s=e,u=!1},configurable:!0,enumerable:!0})}function a(e){return function(){for(var t=[this.value],r=0;re[t]))};for(var s in e)r(s)}var u,c};var o={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return n.createProxy(r),t&&t("import",(function(e,t,r){r||i(e,t)})),n}),{isClass:!0}),Ot=W("reviver",["classes"],(e=>{var{classes:t}=e;return function(e,r){var n=t[r&&r.mathjs];return n&&"function"==typeof n.fromJSON?n.fromJSON(r):r}})),Ct=W("ConditionalNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError("Parameter condition must be a Node");if(!I(t))throw new TypeError("Parameter trueExpr must be a Node");if(!I(n))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=t,this.falseExpr=n}return r.prototype=new t,r.prototype.type="ConditionalNode",r.prototype.isConditionalNode=!0,r.prototype._compile=function(e,t){var r=this.condition._compile(e,t),n=this.trueExpr._compile(e,t),i=this.falseExpr._compile(e,t);return function(e,t,s){return function(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return!!e;if(e){if(a(e))return!e.isZero();if(o(e))return!(!e.re&&!e.im);if(u(e))return!!e.value}if(null==e)return!1;throw new TypeError('Unsupported type of condition "'+L(e)+'"')}(r(e,t,s))?n(e,t,s):i(e,t,s)}},r.prototype.forEach=function(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)},r.prototype.map=function(e){return new r(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))},r.prototype.clone=function(){return new r(this.condition,this.trueExpr,this.falseExpr)},r.prototype._toString=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.condition.toString(e),i=Nt(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n="("+n+")");var a=this.trueExpr.toString(e),o=Nt(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a="("+a+")");var s=this.falseExpr.toString(e),u=Nt(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s="("+s+")"),n+" ? "+a+" : "+s},r.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},r.fromJSON=function(e){return new r(e.condition,e.trueExpr,e.falseExpr)},r.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=Nt(this,t),n=this.condition.toHTML(e),i=Nt(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n='('+n+')');var a=this.trueExpr.toHTML(e),o=Nt(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a='('+a+')');var s=this.falseExpr.toHTML(e),u=Nt(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s='('+s+')'),n+'?'+a+':'+s},r.prototype._toTex=function(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"},r}),{isClass:!0,isNode:!0}),_t=W("OperatorNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n,i,a){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('string expected for parameter "op"');if("string"!=typeof t)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(n)||!n.every(I))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=!0===i,this.isPercentage=!0===a,this.op=e,this.fn=t,this.args=n||[]}function n(e,t,r,n,i){var a,o=Nt(e,t),s=Mt(e,t);if("all"===t||n.length>2&&"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier())return n.map((function(e){switch(e.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}}));switch(n.length){case 0:a=[];break;case 1:var u=Nt(n[0],t);if(i&&null!==u){var c,l;if("keep"===t?(c=n[0].getIdentifier(),l=e.getIdentifier()):(c=n[0].getContent().getIdentifier(),l=e.getContent().getIdentifier()),!1===wt[o][l].latexLeftParens){a=[!1];break}if(!1===wt[u][c].latexParens){a=[!1];break}}if(null===u){a=[!1];break}if(u<=o){a=[!0];break}a=[!1];break;case 2:var f,p,m=Nt(n[0],t),h=St(e,n[0],t);f=null!==m&&(m===o&&"right"===s&&!h||m=2&&"OperatorNode:multiply"===e.getIdentifier()&&e.implicit&&"auto"===t&&"hide"===r&&(a=n.map((function(e,t){var r="ParenthesisNode"===e.getIdentifier();return!(!a[t]&&!r)}))),a}return r.prototype=new t,r.prototype.type="OperatorNode",r.prototype.isOperatorNode=!0,r.prototype._compile=function(e,t){if("string"!=typeof this.fn||!K(e,this.fn))throw e[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var r=Y(e,this.fn),n=tt(this.args,(function(r){return r._compile(e,t)}));if(1===n.length){var i=n[0];return function(e,t,n){return r(i(e,t,n))}}if(2===n.length){var a=n[0],o=n[1];return function(e,t,n){return r(a(e,t,n),o(e,t,n))}}return function(e,t,i){return r.apply(null,tt(n,(function(r){return r(e,t,i)})))}},r.prototype.forEach=function(e){for(var t=0;t2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var f=i.map((function(t,r){return t=t.toString(e),a[r]&&(t="("+t+")"),t}));return this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?f.join(" "):f.join(" "+this.op+" ")}return this.fn+"("+this.args.join(", ")+")"},r.prototype.toJSON=function(){return{mathjs:"OperatorNode",op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}},r.fromJSON=function(e){return new r(e.op,e.fn,e.args,e.implicit,e.isPercentage)},r.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,t,r,i,!1);if(1===i.length){var o=Mt(this,t),s=i[0].toHTML(e);return a[0]&&(s='('+s+')'),"right"===o?''+ke(this.op)+""+s:s+''+ke(this.op)+""}if(2===i.length){var u=i[0].toHTML(e),c=i[1].toHTML(e);return a[0]&&(u='('+u+')'),a[1]&&(c='('+c+')'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?u+''+c:u+''+ke(this.op)+""+c}var l=i.map((function(t,r){return t=t.toHTML(e),a[r]&&(t='('+t+')'),t}));return i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())?this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?l.join(''):l.join(''+ke(this.op)+""):''+ke(this.fn)+'('+l.join(',')+')'},r.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=e&&e.implicit?e.implicit:"hide",i=this.args,a=n(this,t,r,i,!0),o=mt[this.fn];if(o=void 0===o?this.op:o,1===i.length){var s=Mt(this,t),u=i[0].toTex(e);return a[0]&&(u="\\left(".concat(u,"\\right)")),"right"===s?o+u:u+o}if(2===i.length){var c=i[0],l=c.toTex(e);a[0]&&(l="\\left(".concat(l,"\\right)"));var f,p=i[1].toTex(e);switch(a[1]&&(p="\\left(".concat(p,"\\right)")),f="keep"===t?c.getIdentifier():c.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return o+"{"+l+"}{"+p+"}";case"OperatorNode:pow":switch(l="{"+l+"}",p="{"+p+"}",f){case"ConditionalNode":case"OperatorNode:divide":l="\\left(".concat(l,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&"hide"===r)return l+"~"+p}return l+o+p}if(i.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var m=i.map((function(t,r){return t=t.toTex(e),a[r]&&(t="\\left(".concat(t,"\\right)")),t}));return"OperatorNode:multiply"===this.getIdentifier()&&this.implicit?m.join("~"):m.join(o)}return"\\mathrm{"+this.fn+"}\\left("+i.map((function(t){return t.toTex(e)})).join(",")+"\\right)"},r.prototype.getIdentifier=function(){return this.type+":"+this.fn},r}),{isClass:!0,isNode:!0}),Tt=W("RangeNode",["Node"],(e=>{var{Node:t}=e;function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError("Node expected");if(!I(t))throw new TypeError("Node expected");if(n&&!I(n))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=e,this.end=t,this.step=n||null}function n(e,t){var r=Nt(e,t),n={},i=Nt(e.start,t);if(n.start=null!==i&&i<=r||"all"===t,e.step){var a=Nt(e.step,t);n.step=null!==a&&a<=r||"all"===t}var o=Nt(e.end,t);return n.end=null!==o&&o<=r||"all"===t,n}return r.prototype=new t,r.prototype.type="RangeNode",r.prototype.isRangeNode=!0,r.prototype.needsEnd=function(){return this.filter((function(e){return P(e)&&"end"===e.name})).length>0},r.prototype._compile=function(e,t){var r=e.range,n=this.start._compile(e,t),i=this.end._compile(e,t);if(this.step){var a=this.step._compile(e,t);return function(e,t,o){return r(n(e,t,o),i(e,t,o),a(e,t,o))}}return function(e,t,a){return r(n(e,t,a),i(e,t,a))}},r.prototype.forEach=function(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)},r.prototype.map=function(e){return new r(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))},r.prototype.clone=function(){return new r(this.start,this.end,this.step&&this.step)},r.prototype._toString=function(e){var t,r=n(this,e&&e.parenthesis?e.parenthesis:"keep"),i=this.start.toString(e);if(r.start&&(i="("+i+")"),t=i,this.step){var a=this.step.toString(e);r.step&&(a="("+a+")"),t+=":"+a}var o=this.end.toString(e);return r.end&&(o="("+o+")"),t+":"+o},r.prototype.toJSON=function(){return{mathjs:"RangeNode",start:this.start,end:this.end,step:this.step}},r.fromJSON=function(e){return new r(e.start,e.end,e.step)},r.prototype.toHTML=function(e){var t,r=n(this,e&&e.parenthesis?e.parenthesis:"keep"),i=this.start.toHTML(e);if(r.start&&(i='('+i+')'),t=i,this.step){var a=this.step.toHTML(e);r.step&&(a='('+a+')'),t+=':'+a}var o=this.end.toHTML(e);return r.end&&(o='('+o+')'),t+':'+o},r.prototype._toTex=function(e){var t=n(this,e&&e.parenthesis?e.parenthesis:"keep"),r=this.start.toTex(e);if(t.start&&(r="\\left(".concat(r,"\\right)")),this.step){var i=this.step.toTex(e);t.step&&(i="\\left(".concat(i,"\\right)")),r+=":"+i}var a=this.end.toTex(e);return t.end&&(a="\\left(".concat(a,"\\right)")),r+":"+a},r}),{isClass:!0,isNode:!0}),Bt=W("FunctionAssignmentNode",["typed","Node"],(e=>{var{typed:t,Node:r}=e;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(t))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!I(r))throw new TypeError('Node expected for parameter "expr"');if(H.has(e))throw new Error('Illegal function name, "'+e+'" is a reserved keyword');this.name=e,this.params=t.map((function(e){return e&&e.name||e})),this.types=t.map((function(e){return e&&e.type||"any"})),this.expr=r}function i(e,t){var r=Nt(e,t),n=Nt(e.expr,t);return"all"===t||null!==n&&n<=r}return n.prototype=new r,n.prototype.type="FunctionAssignmentNode",n.prototype.isFunctionAssignmentNode=!0,n.prototype._compile=function(e,r){var n=Object.create(r);rt(this.params,(function(e){n[e]=!0}));var i=this.expr._compile(e,n),a=this.name,o=this.params,s=at(this.types,","),u=a+"("+at(this.params,", ")+")";return function(e,r,n){var c={};c[s]=function(){for(var t=Object.create(r),a=0;a'+ke(this.params[n])+"");var a=this.expr.toHTML(e);return i(this,t)&&(a='('+a+')'),''+ke(this.name)+'('+r.join(',')+')='+a},n.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=this.expr.toTex(e);return i(this,t)&&(r="\\left(".concat(r,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(gt).join(",")+"\\right):="+r},n}),{isClass:!0,isNode:!0}),qt="chain",zt=W(qt,["typed","Chain"],(e=>{var{typed:t,Chain:r}=e;return t(qt,{"":function(){return new r},any:function(e){return new r(e)}})}));function Dt(e){return e&&e.isIndexError?new Pe(e.index+1,e.min+1,void 0!==e.max?e.max+1:void 0):e}function It(e){var{subset:t}=e;return function(e,r){try{if(Array.isArray(e))return t(e,r);if(e&&"function"==typeof e.subset)return e.subset(r);if("string"==typeof e)return t(e,r);if("object"==typeof e){if(!r.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return Y(e,r.getObjectProperty())}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Dt(e)}}}var kt=W("AccessorNode",["subset","Node"],(e=>{var{subset:t,Node:r}=e,n=It({subset:t});function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(!I(e))throw new TypeError('Node expected for parameter "object"');if(!D(t))throw new TypeError('IndexNode expected for parameter "index"');this.object=e||null,this.index=t,Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function a(e){return!(A(e)||O(e)||B(e)||z(e)||k(e)||F(e)||P(e))}return i.prototype=new r,i.prototype.type="AccessorNode",i.prototype.isAccessorNode=!0,i.prototype._compile=function(e,t){var r=this.object._compile(e,t),i=this.index._compile(e,t);if(this.index.isObjectProperty()){var a=this.index.getObjectProperty();return function(e,t,n){return Y(r(e,t,n),a)}}return function(e,t,a){var o=r(e,t,a),s=i(e,t,o);return n(o,s)}},i.prototype.forEach=function(e){e(this.object,"object",this),e(this.index,"index",this)},i.prototype.map=function(e){return new i(this._ifNode(e(this.object,"object",this)),this._ifNode(e(this.index,"index",this)))},i.prototype.clone=function(){return new i(this.object,this.index)},i.prototype._toString=function(e){var t=this.object.toString(e);return a(this.object)&&(t="("+t+")"),t+this.index.toString(e)},i.prototype.toHTML=function(e){var t=this.object.toHTML(e);return a(this.object)&&(t='('+t+')'),t+this.index.toHTML(e)},i.prototype._toTex=function(e){var t=this.object.toTex(e);return a(this.object)&&(t="\\left(' + object + '\\right)"),t+this.index.toTex(e)},i.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},i.fromJSON=function(e){return new i(e.object,e.index)},i}),{isClass:!0,isNode:!0}),Rt=W("IndexNode",["Range","Node","size"],(e=>{var{Range:t,Node:r,size:n}=e;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(this.dimensions=e,this.dotNotation=t||!1,!Array.isArray(e)||!e.every(I))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}function o(e,r,n){return new t(a(e)?e.toNumber():e,a(r)?r.toNumber():r,a(n)?n.toNumber():n)}return i.prototype=new r,i.prototype.type="IndexNode",i.prototype.isIndexNode=!0,i.prototype._compile=function(e,t){var r=tt(this.dimensions,(function(r,i){if(U(r)){if(r.needsEnd()){var a=Object.create(t);a.end=!0;var s=r.start._compile(e,a),u=r.end._compile(e,a),c=r.step?r.step._compile(e,a):function(){return 1};return function(e,t,r){var a=n(r).valueOf(),l=Object.create(t);return l.end=a[i],o(s(e,l,r),u(e,l,r),c(e,l,r))}}var l=r.start._compile(e,t),f=r.end._compile(e,t),p=r.step?r.step._compile(e,t):function(){return 1};return function(e,t,r){return o(l(e,t,r),f(e,t,r),p(e,t,r))}}if(P(r)&&"end"===r.name){var m=Object.create(t);m.end=!0;var h=r._compile(e,m);return function(e,t,r){var a=n(r).valueOf(),o=Object.create(t);return o.end=a[i],h(e,o,r)}}var d=r._compile(e,t);return function(e,t,r){return d(e,t,r)}})),i=Y(e,"index");return function(e,t,n){var a=tt(r,(function(r){return r(e,t,n)}));return i(...a)}},i.prototype.forEach=function(e){for(var t=0;t.'+ke(this.getObjectProperty())+"":'['+t.join(',')+']'},i.prototype._toTex=function(e){var t=this.dimensions.map((function(t){return t.toTex(e)}));return this.dotNotation?"."+this.getObjectProperty():"_{"+t.join(",")+"}"},i}),{isClass:!0,isNode:!0}),Ft=W("AssignmentNode",["subset","?matrix","Node"],(e=>{var{subset:t,matrix:r,Node:n}=e,i=It({subset:t}),a=function(e){var{subset:t,matrix:r}=e;return function(e,n,i){try{if(Array.isArray(e))return r(e).subset(n,i).valueOf();if(e&&"function"==typeof e.subset)return e.subset(n,i);if("string"==typeof e)return t(e,n,i);if("object"==typeof e){if(!n.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return X(e,n.getObjectProperty(),i),e}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw Dt(e)}}}({subset:t,matrix:r});function o(e,t,r){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=e,this.index=r?t:null,this.value=r||t,!P(e)&&!A(e))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(P(e)&&"end"===e.name)throw new Error('Cannot assign to symbol "end"');if(this.index&&!D(this.index))throw new TypeError('IndexNode expected as "index"');if(!I(this.value))throw new TypeError('Node expected as "value"');Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function s(e,t){t||(t="keep");var r=Nt(e,t),n=Nt(e.value,t);return"all"===t||null!==n&&n<=r}return o.prototype=new n,o.prototype.type="AssignmentNode",o.prototype.isAssignmentNode=!0,o.prototype._compile=function(e,t){var r=this.object._compile(e,t),n=this.index?this.index._compile(e,t):null,o=this.value._compile(e,t),s=this.object.name;if(this.index){if(this.index.isObjectProperty()){var u=this.index.getObjectProperty();return function(e,t,n){var i=r(e,t,n),a=o(e,t,n);return X(i,u,a),a}}if(P(this.object))return function(e,t,i){var u=r(e,t,i),c=o(e,t,i),l=n(e,t,u);return e.set(s,a(u,l,c)),c};var c=this.object.object._compile(e,t);if(this.object.index.isObjectProperty()){var l=this.object.index.getObjectProperty();return function(e,t,r){var i=c(e,t,r),s=Y(i,l),u=n(e,t,s),f=o(e,t,r);return X(i,l,a(s,u,f)),f}}var f=this.object.index._compile(e,t);return function(e,t,r){var s=c(e,t,r),u=f(e,t,s),l=i(s,u),p=n(e,t,l),m=o(e,t,r);return a(s,u,a(l,p,m)),m}}if(!P(this.object))throw new TypeError("SymbolNode expected as object");return function(e,t,r){var n=o(e,t,r);return e.set(s,n),n}},o.prototype.forEach=function(e){e(this.object,"object",this),this.index&&e(this.index,"index",this),e(this.value,"value",this)},o.prototype.map=function(e){return new o(this._ifNode(e(this.object,"object",this)),this.index?this._ifNode(e(this.index,"index",this)):null,this._ifNode(e(this.value,"value",this)))},o.prototype.clone=function(){return new o(this.object,this.index,this.value)},o.prototype._toString=function(e){var t=this.object.toString(e),r=this.index?this.index.toString(e):"",n=this.value.toString(e);return s(this,e&&e.parenthesis)&&(n="("+n+")"),t+r+" = "+n},o.prototype.toJSON=function(){return{mathjs:"AssignmentNode",object:this.object,index:this.index,value:this.value}},o.fromJSON=function(e){return new o(e.object,e.index,e.value)},o.prototype.toHTML=function(e){var t=this.object.toHTML(e),r=this.index?this.index.toHTML(e):"",n=this.value.toHTML(e);return s(this,e&&e.parenthesis)&&(n='('+n+')'),t+r+'='+n},o.prototype._toTex=function(e){var t=this.object.toTex(e),r=this.index?this.index.toTex(e):"",n=this.value.toTex(e);return s(this,e&&e.parenthesis)&&(n="\\left(".concat(n,"\\right)")),t+r+":="+n},o}),{isClass:!0,isNode:!0}),Ut=W("SymbolNode",["math","?Unit","Node"],(e=>{var{math:t,Unit:r,Node:n}=e;function i(e){return!!r&&r.isValuelessUnit(e)}function a(e){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');this.name=e}return a.prototype=new n,a.prototype.type="SymbolNode",a.prototype.isSymbolNode=!0,a.prototype._compile=function(e,t){var n=this.name;if(!0===t[n])return function(e,t,r){return t[n]};if(n in e)return function(t,r,i){return t.has(n)?t.get(n):Y(e,n)};var o=i(n);return function(e,t,i){return e.has(n)?e.get(n):o?new r(null,n):a.onUndefinedSymbol(n)}},a.prototype.forEach=function(e){},a.prototype.map=function(e){return this.clone()},a.onUndefinedSymbol=function(e){throw new Error("Undefined symbol "+e)},a.prototype.clone=function(){return new a(this.name)},a.prototype._toString=function(e){return this.name},a.prototype.toHTML=function(e){var t=ke(this.name);return"true"===t||"false"===t?''+t+"":"i"===t?''+t+"":"Infinity"===t?''+t+"":"NaN"===t?''+t+"":"null"===t?''+t+"":"undefined"===t?''+t+"":''+t+""},a.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},a.fromJSON=function(e){return new a(e.name)},a.prototype._toTex=function(e){var r=!1;void 0===t[this.name]&&i(this.name)&&(r=!0);var n=gt(this.name,r);return"\\"===n[0]?n:" "+n},a}),{isClass:!0,isNode:!0});function Pt(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{var{math:t,Node:r,SymbolNode:n}=e;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if("string"==typeof e&&(e=new n(e)),!I(e))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(t)||!t.every(I))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=e,this.args=t||[],Object.defineProperty(this,"name",{get:function(){return this.fn.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}i.prototype=new r,i.prototype.type="FunctionNode",i.prototype.isFunctionNode=!0,i.prototype._compile=function(e,t){if(!(this instanceof i))throw new TypeError("No valid FunctionNode");var r=this.args.map((r=>r._compile(e,t)));if(!P(this.fn)){if(A(this.fn)&&D(this.fn.index)&&this.fn.index.isObjectProperty()){var n=this.fn.object._compile(e,t),a=this.fn.index.getObjectProperty(),o=this.args;return function(t,i,s){var u=n(t,i,s);if(function(e,t){if(!K(e,t))throw new Error('No access to method "'+t+'"')}(u,a),u[a]&&u[a].rawArgs)return u[a](o,e,Pt(t,i),t);var c=r.map((e=>e(t,i,s)));return u[a].apply(u,c)}}var s=this.fn._compile(e,t),u=this.args;return function(t,n,i){var a=s(t,n,i);if(a&&a.rawArgs)return a(u,e,Pt(t,n),t);var o=r.map((e=>e(t,n,i)));return a.apply(a,o)}}var c=this.fn.name,l=c in e?Y(e,c):void 0,f="function"==typeof l&&!0===l.rawArgs,p=t=>t.has(c)?t.get(c):c in e?Y(e,c):i.onUndefinedFunction(c);if(f){var m=this.args;return function(t,r,n){return p(t)(m,e,Pt(t,r),t)}}switch(r.length){case 0:return function(e,t,r){return p(e)()};case 1:return function(e,t,n){return p(e)((0,r[0])(e,t,n))};case 2:return function(e,t,n){var i=p(e),a=r[0],o=r[1];return i(a(e,t,n),o(e,t,n))};default:return function(e,t,n){return p(e)(...r.map((r=>r(e,t,n))))}}},i.prototype.forEach=function(e){e(this.fn,"fn",this);for(var t=0;t'+ke(this.fn)+'('+t.join(',')+')'};var s=i.prototype.toTex;return i.prototype.toTex=function(e){var t;return e&&"object"==typeof e.handler&&V(e.handler,this.name)&&(t=e.handler[this.name](this,e)),void 0!==t?t:s.call(this,e)},i.prototype._toTex=function(e){var r,n,i=this.args.map((function(t){return t.toTex(e)}));switch(ht[this.name]&&(r=ht[this.name]),!t[this.name]||"function"!=typeof t[this.name].toTex&&"object"!=typeof t[this.name].toTex&&"string"!=typeof t[this.name].toTex||(r=t[this.name].toTex),typeof r){case"function":n=r(this,e);break;case"string":n=o(r,this,e);break;case"object":switch(typeof r[i.length]){case"function":n=r[i.length](this,e);break;case"string":n=o(r[i.length],this,e)}}return void 0!==n?n:o("\\mathrm{${name}}\\left(${args}\\right)",this,e)},i.prototype.getIdentifier=function(){return this.type+":"+this.name},i}),{isClass:!0,isNode:!0});function Lt(e){for(var t=0;t=n.length)throw new Pe(t,n.length);return f(e)?e.create(Zt(e.valueOf(),t,r)):Zt(e,t,r)}function Zt(e,t,r){var n,i,a,o;if(t<=0){if(Array.isArray(e[0])){for(o=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r{var{typed:r,numeric:n,config:i,AccessorNode:a,ArrayNode:o,AssignmentNode:s,BlockNode:u,ConditionalNode:c,ConstantNode:l,FunctionAssignmentNode:f,FunctionNode:p,IndexNode:m,ObjectNode:h,OperatorNode:d,ParenthesisNode:y,RangeNode:g,RelationalNode:v,SymbolNode:x}=t,b=r(Wt,{string:function(e){return U(e,{})},"Array | Matrix":function(e){return w(e,{})},"string, Object":function(e,t){return U(e,void 0!==t.nodes?t.nodes:{})},"Array | Matrix, Object":w});function w(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=void 0!==t.nodes?t.nodes:{};return $t(e,(function(e){if("string"!=typeof e)throw new TypeError("String expected");return U(e,r)}))}var N={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},M={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},S={true:!0,false:!1,null:null,undefined:void 0},E=["NaN","Infinity"];function O(e,t){return e.expression.substr(e.index,t)}function C(e){return O(e,1)}function _(e){e.index++}function T(e){return e.expression.charAt(e.index-1)}function q(e){return e.expression.charAt(e.index+1)}function D(e){for(e.tokenType=0,e.token="",e.comment="";b.isWhitespace(C(e),e.nestingLevel);)_(e);if("#"===C(e))for(;"\n"!==C(e)&&""!==C(e);)e.comment+=C(e),_(e);if(""!==C(e)){if("\n"===C(e)&&!e.nestingLevel)return e.tokenType=1,e.token=C(e),void _(e);var t=C(e),r=O(e,2),n=O(e,3);if(3===n.length&&N[n])return e.tokenType=1,e.token=n,_(e),_(e),void _(e);if(2===r.length&&N[r])return e.tokenType=1,e.token=r,_(e),void _(e);if(N[t])return e.tokenType=1,e.token=t,void _(e);if(b.isDigitDot(t)){e.tokenType=2;var i=O(e,2);if("0b"===i||"0o"===i||"0x"===i){for(e.token+=C(e),_(e),e.token+=C(e),_(e);b.isHexDigit(C(e));)e.token+=C(e),_(e);if("."===C(e))for(e.token+=".",_(e);b.isHexDigit(C(e));)e.token+=C(e),_(e);else if("i"===C(e))for(e.token+="i",_(e);b.isDigit(C(e));)e.token+=C(e),_(e);return}if("."===C(e)){if(e.token+=C(e),_(e),!b.isDigit(C(e)))return void(e.tokenType=1)}else{for(;b.isDigit(C(e));)e.token+=C(e),_(e);b.isDecimalMark(C(e),q(e))&&(e.token+=C(e),_(e))}for(;b.isDigit(C(e));)e.token+=C(e),_(e);if("E"===C(e)||"e"===C(e))if(b.isDigit(q(e))||"-"===q(e)||"+"===q(e)){if(e.token+=C(e),_(e),"+"!==C(e)&&"-"!==C(e)||(e.token+=C(e),_(e)),!b.isDigit(C(e)))throw ce(e,'Digit expected, got "'+C(e)+'"');for(;b.isDigit(C(e));)e.token+=C(e),_(e);if(b.isDecimalMark(C(e),q(e)))throw ce(e,'Digit expected, got "'+C(e)+'"')}else if("."===q(e))throw _(e),ce(e,'Digit expected, got "'+C(e)+'"')}else{if(!b.isAlpha(C(e),T(e),q(e))){for(e.tokenType=4;""!==C(e);)e.token+=C(e),_(e);throw ce(e,'Syntax error in part "'+e.token+'"')}for(;b.isAlpha(C(e),T(e),q(e))||b.isDigit(C(e));)e.token+=C(e),_(e);V(M,e.token)?e.tokenType=1:e.tokenType=3}}else e.tokenType=1}function I(e){do{D(e)}while("\n"===e.token)}function k(e){e.nestingLevel++}function F(e){e.nestingLevel--}function U(t,r){var n={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:0,nestingLevel:0,conditionalLevel:null};e(n,{expression:t,extraNodes:r}),D(n);var i=function(e){var t,r,n=[];for(""!==e.token&&"\n"!==e.token&&";"!==e.token&&((t=j(e)).comment=e.comment);"\n"===e.token||";"===e.token;)0===n.length&&t&&(r=";"!==e.token,n.push({node:t,visible:r})),D(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&((t=j(e)).comment=e.comment,r=";"!==e.token,n.push({node:t,visible:r}));return n.length>0?new u(n):(t||((t=new l(void 0)).comment=e.comment),t)}(n);if(""!==n.token)throw 1===n.tokenType?le(n,"Unexpected operator "+n.token):ce(n,'Unexpected part "'+n.token+'"');return i}function j(e){var t,r,n,i,a=function(e){for(var t=function(e){for(var t=L(e);"or"===e.token;)I(e),t=new d("or","or",[t,L(e)]);return t}(e);"?"===e.token;){var r=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,I(e);var n=t,i=j(e);if(":"!==e.token)throw ce(e,"False part of conditional expression expected");e.conditionalLevel=null,I(e);var a=j(e);t=new c(n,i,a),e.conditionalLevel=r}return t}(e);if("="===e.token){if(P(a))return t=a.name,I(e),n=j(e),new s(new x(t),n);if(A(a))return I(e),n=j(e),new s(a.object,a.index,n);if(z(a)&&P(a.fn)&&(i=!0,r=[],t=a.name,a.args.forEach((function(e,t){P(e)?r[t]=e.name:i=!1})),i))return I(e),n=j(e),new f(t,r,n);throw ce(e,"Invalid left hand side of assignment operator =")}return a}function L(e){for(var t=H(e);"xor"===e.token;)I(e),t=new d("xor","xor",[t,H(e)]);return t}function H(e){for(var t=$(e);"and"===e.token;)I(e),t=new d("and","and",[t,$(e)]);return t}function $(e){for(var t=G(e);"|"===e.token;)I(e),t=new d("|","bitOr",[t,G(e)]);return t}function G(e){for(var t=Z(e);"^|"===e.token;)I(e),t=new d("^|","bitXor",[t,Z(e)]);return t}function Z(e){for(var t=W(e);"&"===e.token;)I(e),t=new d("&","bitAnd",[t,W(e)]);return t}function W(e){for(var t=[J(e)],r=[],n={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};V(n,e.token);){var i={name:e.token,fn:n[e.token]};r.push(i),I(e),t.push(J(e))}return 1===t.length?t[0]:2===t.length?new d(r[0].name,r[0].fn,t):new v(r.map((e=>e.fn)),t)}function J(e){var t,r,n,i;t=Y(e);for(var a={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};V(a,e.token);)n=a[r=e.token],I(e),i=[t,Y(e)],t=new d(r,n,i);return t}function Y(e){var t,r,n,i;t=X(e);for(var a={to:"to",in:"to"};V(a,e.token);)n=a[r=e.token],I(e),"in"===r&&""===e.token?t=new d("*","multiply",[t,new x("in")],!0):(i=[t,X(e)],t=new d(r,n,i));return t}function X(e){var t,r=[];if(t=":"===e.token?new l(1):Q(e),":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(r.push(t);":"===e.token&&r.length<3;)I(e),")"===e.token||"]"===e.token||","===e.token||""===e.token?r.push(new x("end")):r.push(Q(e));t=3===r.length?new g(r[0],r[2],r[1]):new g(r[0],r[1])}return t}function Q(e){var t,r,n,i;t=K(e);for(var a={"+":"add","-":"subtract"};V(a,e.token);){n=a[r=e.token],I(e);var o=K(e);i=o.isPercentage?[t,new d("*","multiply",[t,o])]:[t,o],t=new d(r,n,i)}return t}function K(e){var t,r,n,i;r=t=ee(e);for(var a={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};V(a,e.token);)i=a[n=e.token],I(e),r=ee(e),t=new d(n,i,[t,r]);return t}function ee(e){var t,r;for(r=t=te(e);3===e.tokenType||"in"===e.token&&B(t)||!(2!==e.tokenType||B(r)||R(r)&&"!"!==r.op)||"("===e.token;)r=te(e),t=new d("*","multiply",[t,r],!0);return t}function te(t){for(var r=re(t),n=r,i=[];"/"===t.token&&B(n);){if(i.push(e({},t)),I(t),2!==t.tokenType){e(t,i.pop());break}if(i.push(e({},t)),I(t),3!==t.tokenType&&"("!==t.token){i.pop(),e(t,i.pop());break}e(t,i.pop()),i.pop(),n=re(t),r=new d("/","divide",[r,n])}return r}function re(e){var t,r,n,i;t=ne(e);for(var a={"%":"mod",mod:"mod"};V(a,e.token);)n=a[r=e.token],I(e),"%"===r&&1===e.tokenType&&"("!==e.token?t=new d("/","divide",[t,new l(100)],!1,!0):(i=[t,ne(e)],t=new d(r,n,i));return t}function ne(e){var t,r,a,s={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return V(s,e.token)?(a=s[e.token],t=e.token,I(e),r=[ne(e)],new d(t,a,r)):function(e){var t,r,a,s;return t=function(e){var t,r,a;t=function(e){var t=[];if(3===e.tokenType&&V(e.extraNodes,e.token)){var r=e.extraNodes[e.token];if(D(e),"("===e.token){if(t=[],k(e),D(e),")"!==e.token)for(t.push(j(e));","===e.token;)D(e),t.push(j(e));if(")"!==e.token)throw ce(e,"Parenthesis ) expected");F(e),D(e)}return new r(t)}return function(e){var t;return 3===e.tokenType||1===e.tokenType&&e.token in M?(t=e.token,D(e),ie(e,V(S,t)?new l(S[t]):-1!==E.indexOf(t)?new l(n(t,"number")):new x(t))):function(e){var t;return'"'===e.token?(t=ae(e),ie(e,new l(t))):function(e){var t;return"'"===e.token?(t=oe(e),ie(e,new l(t))):function(e){var t,r,a,s;if("["===e.token){if(k(e),D(e),"]"!==e.token){var u=se(e);if(";"===e.token){for(a=1,r=[u];";"===e.token;)D(e),r[a]=se(e),a++;if("]"!==e.token)throw ce(e,"End of matrix ] expected");F(e),D(e),s=r[0].items.length;for(var c=1;c0},b.isDecimalMark=function(e,t){return"."===e&&"/"!==t&&"*"!==t&&"^"!==t},b.isDigitDot=function(e){return e>="0"&&e<="9"||"."===e},b.isDigit=function(e){return e>="0"&&e<="9"},b.isHexDigit=function(e){return e>="0"&&e<="9"||e>="a"&&e<="f"||e>="A"&&e<="F"},b})),Yt="evaluate",Xt=W(Yt,["typed","parse"],(e=>{var{typed:t,parse:r}=e;return t(Yt,{string:function(e){var t=ie();return r(e).compile().evaluate(t)},"string, Map | Object":function(e,t){return r(e).compile().evaluate(t)},"Array | Matrix":function(e){var t=ie();return $t(e,(function(e){return r(e).compile().evaluate(t)}))},"Array | Matrix, Map | Object":function(e,t){return $t(e,(function(e){return r(e).compile().evaluate(t)}))}})})),Qt=W("Help",["parse"],(e=>{var{parse:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw new Error('Argument "doc" missing');this.doc=e}return r.prototype.type="Help",r.prototype.isHelp=!0,r.prototype.toString=function(){var e=this.doc||{},r="\n";if(e.name&&(r+="Name: "+e.name+"\n\n"),e.category&&(r+="Category: "+e.category+"\n\n"),e.description&&(r+="Description:\n "+e.description+"\n\n"),e.syntax&&(r+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){r+="Examples:\n";for(var n={},i=0;i"mathjs"!==e)).forEach((r=>{t[r]=e[r]})),new r(t)},r.prototype.valueOf=r.prototype.toString,r}),{isClass:!0}),Kt=W("simplifyUtil",["FunctionNode","OperatorNode","SymbolNode"],(e=>{var{FunctionNode:t,OperatorNode:r,SymbolNode:n}=e,i={add:!0,multiply:!0},a={add:!0,multiply:!0};function o(e,t){if(!R(e))return!1;var r=e.fn.toString();return t&&V(t,r)&&V(t[r],"associative")?t[r].associative:a[r]||!1}function s(e){var t,r=[];return o(e)?(t=e.op,function e(n){for(var i=0;i2&&o(t)){for(var a=t.args.pop();t.args.length>0;)a=r([t.args.pop(),a]);t.args=a.args}}},unflattenl:function e(t){if(t.args&&0!==t.args.length){for(var r=u(t),n=t.args.length,i=0;i2&&o(t)){for(var a=t.args.shift();t.args.length>0;)a=r([a,t.args.shift()]);t.args=a.args}}}}})),er=W("simplifyCore",["equal","isZero","add","subtract","multiply","divide","pow","ConstantNode","OperatorNode","FunctionNode","ParenthesisNode"],(e=>{var{equal:t,isZero:r,add:n,subtract:i,multiply:a,divide:o,pow:s,ConstantNode:u,OperatorNode:c,FunctionNode:l,ParenthesisNode:f}=e,p=new u(0),m=new u(1);return function e(h){if(R(h)&&h.isUnary()){var d=e(h.args[0]);if("+"===h.op)return d;if("-"===h.op){if(R(d)){if(d.isUnary()&&"-"===d.op)return d.args[0];if(d.isBinary()&&"subtract"===d.fn)return new c("-","subtract",[d.args[1],d.args[0]])}return new c(h.op,h.fn,[d])}}else if(R(h)&&h.isBinary()){var y=e(h.args[0]),g=e(h.args[1]);if("+"===h.op){if(B(y)){if(r(y.value))return g;if(B(g))return new u(n(y.value,g.value))}return B(g)&&r(g.value)?y:R(g)&&g.isUnary()&&"-"===g.op?new c("-","subtract",[y,g.args[0]]):new c(h.op,h.fn,g?[y,g]:[y])}if("-"===h.op){if(B(y)&&g){if(B(g))return new u(i(y.value,g.value));if(r(y.value))return new c("-","unaryMinus",[g])}if("subtract"===h.fn)return B(g)&&r(g.value)?y:R(g)&&g.isUnary()&&"-"===g.op?e(new c("+","add",[y,g.args[0]])):new c(h.op,h.fn,[y,g])}else{if("*"===h.op){if(B(y)){if(r(y.value))return p;if(t(y.value,1))return g;if(B(g))return new u(a(y.value,g.value))}if(B(g)){if(r(g.value))return p;if(t(g.value,1))return y;if(R(y)&&y.isBinary()&&y.op===h.op){var v=y.args[0];if(B(v)){var x=new u(a(v.value,g.value));return new c(h.op,h.fn,[x,y.args[1]],h.implicit)}}return new c(h.op,h.fn,[g,y],h.implicit)}return new c(h.op,h.fn,[y,g],h.implicit)}if("/"===h.op){if(B(y)){if(r(y.value))return p;if(B(g)&&(t(g.value,1)||t(g.value,2)||t(g.value,4)))return new u(o(y.value,g.value))}return new c(h.op,h.fn,[y,g])}if("^"===h.op){if(B(g)){if(r(g.value))return m;if(t(g.value,1))return y;if(B(y))return new u(s(y.value,g.value));if(R(y)&&y.isBinary()&&"^"===y.op){var b=y.args[1];if(B(b))return new c(h.op,h.fn,[y.args[0],new u(a(b.value,g.value))])}}return new c(h.op,h.fn,[y,g])}}}else{if(F(h)){var w=e(h.content);return F(w)||P(w)||B(w)?w:new f(w)}if(z(h)){var N=h.args.map(e).map((function(e){return F(e)?e.content:e}));return new l(e(h.fn),N)}}return h}}));function tr(){throw new Error('No "bignumber" implementation available')}function rr(){throw new Error('No "fraction" implementation available')}function nr(){throw new Error('No "matrix" implementation available')}var ir=W("simplifyConstant",["typed","config","mathWithTransform","?fraction","?bignumber","ConstantNode","OperatorNode","FunctionNode","SymbolNode"],(e=>{var{typed:t,config:r,mathWithTransform:n,fraction:i,bignumber:a,ConstantNode:o,OperatorNode:u,FunctionNode:c,SymbolNode:l}=e,{isCommutative:f,isAssociative:p,allChildren:m,createMakeNodeFunction:h}=Kt({FunctionNode:c,OperatorNode:u,SymbolNode:l});function d(e,t,r){try{return v(n[e].apply(null,t),r)}catch(i){return t=t.map((function(e){return s(e)?e.valueOf():e})),v(n[e].apply(null,t),r)}}var y=t({Fraction:function(e){var t,r=e.s*e.n;return t=r<0?new u("-","unaryMinus",[new o(-r)]):new o(r),1===e.d?t:new u("/","divide",[t,new o(e.d)])},number:function(e){return e<0?x(new o(-e)):new o(e)},BigNumber:function(e){return e<0?x(new o(-e)):new o(e)},Complex:function(e){throw new Error("Cannot convert Complex number to Node")}});function g(e,t){if(t&&!1!==t.exactFractions&&isFinite(e)&&i){var r=i(e),n=t&&"number"==typeof t.fractionsLimit?t.fractionsLimit:1/0;if(r.valueOf()===e&&r.nw(e,t)));if(!r.some(I))try{return d(e.name,r,t)}catch(e){}return r=r.map((function(e){return I(e)?e:y(e)})),new c(e.name,r)}case"OperatorNode":var i,a,o=e.fn.toString(),s=h(e);if(R(e)&&e.isUnary())a=I((i=[w(e.args[0],t)])[0])?s(i):d(o,i,t);else if(p(e))if(i=(i=m(e)).map((e=>w(e,t))),f(o)){for(var u=[],l=[],g=0;g1?(a=b(o,u,s,t),l.unshift(a),a=b(o,l,s,t)):a=b(o,i,s,t)}else a=b(o,i,s,t);else a=b(o,i=e.args.map((e=>w(e,t))),s,t);return a;case"ParenthesisNode":return w(e.content,t);case"AccessorNode":case"ArrayNode":case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"IndexNode":case"ObjectNode":case"RangeNode":case"ConditionalNode":default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(e.type))}}return function(e,t){var r=w(e,t);return I(r)?r:y(r)}})),ar=W("resolve",["parse","FunctionNode","OperatorNode","ParenthesisNode"],(e=>{var{parse:t,FunctionNode:r,OperatorNode:n,ParenthesisNode:i}=e;return function e(a,o){if(!o)return a;if(oe(o)||(o=ae(o)),P(a)){var s=o.get(a.name);if(I(s))return e(s,o);if("number"==typeof s)return t(String(s))}else{if(R(a)){var u=a.args.map((function(t){return e(t,o)}));return new n(a.op,a.fn,u,a.implicit)}if(F(a))return new i(e(a.content,o));if(z(a)){var c=a.args.map((function(t){return e(t,o)}));return new r(a.name,c)}}return a}})),or=W("simplify",["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","?fraction","?bignumber","mathWithTransform","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{config:t,typed:r,parse:n,add:i,subtract:a,multiply:o,divide:s,pow:u,isZero:c,equal:l,fraction:f,bignumber:p,mathWithTransform:m,ConstantNode:h,FunctionNode:d,OperatorNode:y,ParenthesisNode:g,SymbolNode:v}=e,x=ir({typed:r,config:t,mathWithTransform:m,fraction:f,bignumber:p,ConstantNode:h,OperatorNode:y,FunctionNode:d,SymbolNode:v}),b=er({equal:l,isZero:c,add:i,subtract:a,multiply:o,divide:s,pow:u,ConstantNode:h,OperatorNode:y,FunctionNode:d,ParenthesisNode:g}),w=ar({parse:n,FunctionNode:d,OperatorNode:y,ParenthesisNode:g}),{isCommutative:N,isAssociative:M,flatten:S,unflattenr:E,unflattenl:A,createMakeNodeFunction:O}=Kt({FunctionNode:d,OperatorNode:y,SymbolNode:v}),C=r("simplify",{string:function(e){return this(n(e),this.rules,ie(),{})},"string, Map | Object":function(e,t){return this(n(e),this.rules,t,{})},"string, Map | Object, Object":function(e,t,r){return this(n(e),this.rules,t,r)},"string, Array":function(e,t){return this(n(e),t,ie(),{})},"string, Array, Map | Object":function(e,t,r){return this(n(e),t,r,{})},"string, Array, Map | Object, Object":function(e,t,r,i){return this(n(e),t,r,i)},"Node, Map | Object":function(e,t){return this(e,this.rules,t,{})},"Node, Map | Object, Object":function(e,t,r){return this(e,this.rules,t,r)},Node:function(e){return this(e,this.rules,ie(),{})},"Node, Array":function(e,t){return this(e,t,ie(),{})},"Node, Array, Map | Object":function(e,t,r){return this(e,t,r,{})},"Node, Array, Object, Object":function(e,t,r,n){return this(e,t,ae(r),n)},"Node, Array, Map, Object":function(e,t,r,i){t=function(e){for(var t=[],r=0;r");if(2!==s.length)throw SyntaxError("Could not parse rule: "+i);i={l:s[0],r:s[1]};case"object":if(a={l:_(n(i.l)),r:_(n(i.r))},i.context&&(a.evaluate=i.context),i.evaluate&&(a.evaluate=n(i.evaluate)),M(a.l)){var u=O(a.l),c=new v("_p"+q++);a.expanded={},a.expanded.l=u([a.l.clone(),c]),S(a.expanded.l),E(a.expanded.l),a.expanded.r=u([a.r,c])}break;case"function":a=i;break;default:throw TypeError("Unsupported type of rule: "+o)}t.push(a)}return t}(t);for(var a=w(e,r),o={},s=(a=_(a)).toString({parenthesis:"all"});!o[s];){o[s]=!0,q=0;for(var u=0;u=2&&2===e.args.length){for(var i=function(e,t){var r,n,i=[],a=O(e);if(N(e,t))for(var o=0;o2)throw Error("Unexpected non-binary associative function: "+e.toString());return[]}for(var u=[],c=0;c{var{config:t,typed:r,equal:n,isZero:i,add:a,subtract:o,multiply:s,divide:u,pow:c,parse:l,simplify:f,fraction:p,bignumber:m,mathWithTransform:h,ConstantNode:d,OperatorNode:y,FunctionNode:g,SymbolNode:v,ParenthesisNode:x}=e,b=ir({typed:r,config:t,mathWithTransform:h,fraction:p,bignumber:m,ConstantNode:d,OperatorNode:y,FunctionNode:g,SymbolNode:v}),w=er({equal:n,isZero:i,add:a,subtract:o,multiply:s,divide:u,pow:c,ConstantNode:d,OperatorNode:y,FunctionNode:g,ParenthesisNode:x});return r(sr,{string:function(e){return this(l(e),{},!1)},"string, boolean":function(e,t){return this(l(e),{},t)},"string, Object":function(e,t){return this(l(e),t,!1)},"string, Object, boolean":function(e,t,r){return this(l(e),t,r)},Node:function(e){return this(e,{},!1)},"Node, boolean":function(e,t){return this(e,{},t)},"Node, Object":function(e,t){return this(e,t,!1)},"Node, Object, boolean":function(e,t,r){var n=function(){var e=[w,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},b,{l:"n*(n1^-1)",r:"n/n1"},{l:"n*n1^-n2",r:"n/n1^n2"},{l:"n1^-1",r:"1/n1"},{l:"n*(n1/n2)",r:"(n*n1)/n2"},{l:"1*n",r:"n"}],t=[{l:"(-n1)/(-n2)",r:"n1/n2"},{l:"(-n1)*(-n2)",r:"n1*n2"},{l:"n1--n2",r:"n1+n2"},{l:"n1-n2",r:"n1+(-n2)"},{l:"(n1+n2)*n3",r:"(n1*n3 + n2*n3)"},{l:"n1*(n2+n3)",r:"(n1*n2+n1*n3)"},{l:"c1*n + c2*n",r:"(c1+c2)*n"},{l:"c1*n + n",r:"(c1+1)*n"},{l:"c1*n - c2*n",r:"(c1-c2)*n"},{l:"c1*n - n",r:"(c1-1)*n"},{l:"v/c",r:"(1/c)*v"},{l:"v/-c",r:"-(1/c)*v"},{l:"-v*-c",r:"c*v"},{l:"-v*c",r:"-c*v"},{l:"v*-c",r:"-c*v"},{l:"v*c",r:"c*v"},{l:"-(-n1*n2)",r:"(n1*n2)"},{l:"-(n1*n2)",r:"(-n1*n2)"},{l:"-(-n1+n2)",r:"(n1-n2)"},{l:"-(n1+n2)",r:"(-n1-n2)"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"},{l:"-(-n1/n2)",r:"(n1/n2)"},{l:"-(n1/n2)",r:"(-n1/n2)"}],r=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],n={};return n.firstRules=e.concat(t,r),n.distrDivRules=[{l:"(n1/n2 + n3/n4)",r:"((n1*n4 + n3*n2)/(n2*n4))"},{l:"(n1/n2 + n3)",r:"((n1 + n3*n2)/n2)"},{l:"(n1 + n2/n3)",r:"((n1*n3 + n2)/n3)"}],n.sucDivRules=r,n.firstRulesAgain=e.concat(t),n.finalRules=[w,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},b,{l:"n*-n^n1",r:"-n^(n1+1)"},{l:"n*n^n1",r:"n^(n1+1)"},{l:"n^n1*-n^n2",r:"-n^(n1+n2)"},{l:"n^n1*n^n2",r:"n^(n1+n2)"},{l:"n^n1*-n",r:"-n^(n1+1)"},{l:"n^n1*n",r:"n^(n1+1)"},{l:"n^n1/-n",r:"-n^(n1-1)"},{l:"n^n1/n",r:"n^(n1-1)"},{l:"n/-n^n1",r:"-n^(1-n1)"},{l:"n/n^n1",r:"n^(1-n1)"},{l:"n^n1/-n^n2",r:"n^(n1-n2)"},{l:"n^n1/n^n2",r:"n^(n1-n2)"},{l:"n1+(-n2*n3)",r:"n1-n2*n3"},{l:"v*(-c)",r:"-c*v"},{l:"n1+-n2",r:"n1-n2"},{l:"v*c",r:"c*v"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"}],n}(),i=function(e,t,r,n){var i=[],a=f(e,n,t,{exactFractions:!1}),o="+-*"+((r=!!r)?"/":"");!function e(t){var r=t.type;if("FunctionNode"===r)throw new Error("There is an unsolved function call");if("OperatorNode"===r)if("^"===t.op){if("ConstantNode"!==t.args[1].type||!ce(parseFloat(t.args[1].value)))throw new Error("There is a non-integer exponent");e(t.args[0])}else{if(-1===o.indexOf(t.op))throw new Error("Operator "+t.op+" invalid in polynomial expression");for(var n=0;n=1){var o,s;e=N(e);var u,c=!0,l=!1;for(e=f(e,n.firstRules,{},{exactFractions:!1});s=c?n.distrDivRules:n.sucDivRules,c=!c,(u=(e=f(e,s)).toString())!==o;)l=!0,o=u;l&&(e=f(e,n.firstRulesAgain,{},{exactFractions:!1})),e=f(e,n.finalRules,{},{exactFractions:!1})}var p=[],m={};return"OperatorNode"===e.type&&e.isBinary()&&"/"===e.op?(1===a&&(e.args[0]=M(e.args[0],p),e.args[1]=M(e.args[1])),r&&(m.numerator=e.args[0],m.denominator=e.args[1])):(1===a&&(e=M(e,p)),r&&(m.numerator=e,m.denominator=null)),r?(m.coefficients=p,m.variables=i.variables,m.expression=e,m):e}});function N(e,t,r){var n=e.type,i=arguments.length>1;if("OperatorNode"===n&&e.isBinary()){var a,o=!1;if("^"===e.op&&("ParenthesisNode"!==e.args[0].type&&"OperatorNode"!==e.args[0].type||"ConstantNode"!==e.args[1].type||(o=(a=parseFloat(e.args[1].value))>=2&&ce(a))),o){if(a>2){var s=e.args[0],u=new y("^","pow",[e.args[0].cloneDeep(),new d(a-1)]);e=new y("*","multiply",[s,u])}else e=new y("*","multiply",[e.args[0],e.args[0].cloneDeep()]);i&&("content"===r?t.content=e:t.args[r]=e)}}if("ParenthesisNode"===n)N(e.content,e,"content");else if("ConstantNode"!==n&&"SymbolNode"!==n)for(var c=0;cr&&(t[c]=0),t[c]+=o.cte*("+"===o.oper?1:-1),void(r=Math.max(c,r))}o.cte=c,""===o.fire&&(t[0]+=o.cte*("+"===o.oper?1:-1))}}(e,null,{cte:1,oper:"+",fire:""});for(var i,a=!0,o=r=t.length-1;o>=0;o--)if(0!==t[o]){var s=new d(a?t[o]:Math.abs(t[o])),u=t[o]<0?"-":"+";if(o>0){var c=new v(n);if(o>1){var l=new d(o);c=new y("^","pow",[c,l])}s=-1===t[o]&&a?new y("-","unaryMinus",[c]):1===Math.abs(t[o])?c:new y("*","multiply",[s,c])}i=a?s:"+"===u?new y("+","add",[i,s]):new y("-","subtract",[i,s]),a=!1}return a?new d(0):i}})),cr=W("Parser",["evaluate"],(e=>{var{evaluate:t}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:ie(),writable:!1})}return r.prototype.type="Parser",r.prototype.isParser=!0,r.prototype.evaluate=function(e){return t(e,this.scope)},r.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},r.prototype.getAll=function(){return function(e){if(e instanceof ne)return e.wrappedObject;var t={};for(var r of e.keys())X(t,r,e.get(r));return t}(this.scope)},r.prototype.getAllAsMap=function(){return this.scope},r.prototype.set=function(e,t){return this.scope.set(e,t),t},r.prototype.remove=function(e){this.scope.delete(e)},r.prototype.clear=function(){this.scope.clear()},r}),{isClass:!0}),lr={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]},fr={name:"e",category:"Constants",syntax:["e"],description:"Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",examples:["e","e ^ 2","exp(2)","log(e)"],seealso:["exp"]},pr={bignumber:{name:"bignumber",category:"Construction",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","complex","fraction","index","matrix","string","unit"]},boolean:{name:"boolean",category:"Construction",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]},complex:{name:"complex",category:"Construction",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]},createUnit:{name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.",examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]},fraction:{name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(num,den)"],description:"Create a fraction from a number or from a numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},index:{name:"index",category:"Construction",syntax:["[start]","[start:end]","[start:step:end]","[start1, start 2, ...]","[start1:end1, start2:end2, ...]","[start1:step1:end1, start2:step2:end2, ...]"],description:"Create an index to get or replace a subset of a matrix",examples:["[]","[1, 2, 3]","A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[0:2, 0:2] = ones(2, 2)"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]},matrix:{name:"matrix",category:"Construction",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()",'matrix("dense")',"matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])",'matrix([3, 4; 5, 6], "sparse")','matrix([3, 4; 5, 6], "sparse", "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","sparse"]},number:{name:"number",category:"Construction",syntax:["x","number(x)","number(unit, valuelessUnit)"],description:"Create a number or convert a string or boolean into a number.",examples:["2","2e3","4.05","number(2)",'number("7.2")',"number(true)","number([true, false, true, true])",'number(unit("52cm"), "m")'],seealso:["bignumber","boolean","complex","fraction","index","matrix","string","unit"]},sparse:{name:"sparse",category:"Construction",syntax:["sparse()","sparse([a1, b1, ...; a1, b2, ...])",'sparse([a1, b1, ...; a1, b2, ...], "number")'],description:"Create a sparse matrix.",examples:["sparse()","sparse([3, 4; 5, 6])",'sparse([3, 0; 5, 0], "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","matrix"]},splitUnit:{name:"splitUnit",category:"Construction",syntax:["splitUnit(unit: Unit, parts: Unit[])"],description:"Split a unit in an array of units whose sum is equal to the original unit.",examples:['splitUnit(1 m, ["feet", "inch"])'],seealso:["unit","createUnit"]},string:{name:"string",category:"Construction",syntax:['"text"',"string(x)"],description:"Create a string or convert a value to a string",examples:['"Hello World!"',"string(4.2)","string(3 + 2i)"],seealso:["bignumber","boolean","complex","index","matrix","number","unit"]},unit:{name:"unit",category:"Construction",syntax:["value unit","unit(value, unit)","unit(string)"],description:"Create a unit.",examples:["5.5 mm","3 inch",'unit(7.1, "kilogram")','unit("23 deg")'],seealso:["bignumber","boolean","complex","index","matrix","number","string"]},e:fr,E:fr,false:{name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},i:{name:"i",category:"Constants",syntax:["i"],description:"Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",examples:["i","i * i","sqrt(-1)"],seealso:[]},Infinity:{name:"Infinity",category:"Constants",syntax:["Infinity"],description:"Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",examples:["Infinity","1 / 0"],seealso:[]},LN2:{name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},LN10:{name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},LOG2E:{name:"LOG2E",category:"Constants",syntax:["LOG2E"],description:"Returns the base-2 logarithm of E, approximately equal to 1.442",examples:["LOG2E","log(e, 2)"],seealso:[]},LOG10E:{name:"LOG10E",category:"Constants",syntax:["LOG10E"],description:"Returns the base-10 logarithm of E, approximately equal to 0.434",examples:["LOG10E","log(e, 10)"],seealso:[]},NaN:{name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},null:{name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},pi:lr,PI:lr,phi:{name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["phi"],seealso:[]},SQRT1_2:{name:"SQRT1_2",category:"Constants",syntax:["SQRT1_2"],description:"Returns the square root of 1/2, approximately equal to 0.707",examples:["SQRT1_2","sqrt(1/2)"],seealso:[]},SQRT2:{name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},tau:{name:"tau",category:"Constants",syntax:["tau"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]},true:{name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},version:{name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},speedOfLight:{description:"Speed of light in vacuum",examples:["speedOfLight"]},gravitationConstant:{description:"Newtonian constant of gravitation",examples:["gravitationConstant"]},planckConstant:{description:"Planck constant",examples:["planckConstant"]},reducedPlanckConstant:{description:"Reduced Planck constant",examples:["reducedPlanckConstant"]},magneticConstant:{description:"Magnetic constant (vacuum permeability)",examples:["magneticConstant"]},electricConstant:{description:"Electric constant (vacuum permeability)",examples:["electricConstant"]},vacuumImpedance:{description:"Characteristic impedance of vacuum",examples:["vacuumImpedance"]},coulomb:{description:"Coulomb's constant",examples:["coulomb"]},elementaryCharge:{description:"Elementary charge",examples:["elementaryCharge"]},bohrMagneton:{description:"Borh magneton",examples:["bohrMagneton"]},conductanceQuantum:{description:"Conductance quantum",examples:["conductanceQuantum"]},inverseConductanceQuantum:{description:"Inverse conductance quantum",examples:["inverseConductanceQuantum"]},magneticFluxQuantum:{description:"Magnetic flux quantum",examples:["magneticFluxQuantum"]},nuclearMagneton:{description:"Nuclear magneton",examples:["nuclearMagneton"]},klitzing:{description:"Von Klitzing constant",examples:["klitzing"]},bohrRadius:{description:"Borh radius",examples:["bohrRadius"]},classicalElectronRadius:{description:"Classical electron radius",examples:["classicalElectronRadius"]},electronMass:{description:"Electron mass",examples:["electronMass"]},fermiCoupling:{description:"Fermi coupling constant",examples:["fermiCoupling"]},fineStructure:{description:"Fine-structure constant",examples:["fineStructure"]},hartreeEnergy:{description:"Hartree energy",examples:["hartreeEnergy"]},protonMass:{description:"Proton mass",examples:["protonMass"]},deuteronMass:{description:"Deuteron Mass",examples:["deuteronMass"]},neutronMass:{description:"Neutron mass",examples:["neutronMass"]},quantumOfCirculation:{description:"Quantum of circulation",examples:["quantumOfCirculation"]},rydberg:{description:"Rydberg constant",examples:["rydberg"]},thomsonCrossSection:{description:"Thomson cross section",examples:["thomsonCrossSection"]},weakMixingAngle:{description:"Weak mixing angle",examples:["weakMixingAngle"]},efimovFactor:{description:"Efimov factor",examples:["efimovFactor"]},atomicMass:{description:"Atomic mass constant",examples:["atomicMass"]},avogadro:{description:"Avogadro's number",examples:["avogadro"]},boltzmann:{description:"Boltzmann constant",examples:["boltzmann"]},faraday:{description:"Faraday constant",examples:["faraday"]},firstRadiation:{description:"First radiation constant",examples:["firstRadiation"]},loschmidt:{description:"Loschmidt constant at T=273.15 K and p=101.325 kPa",examples:["loschmidt"]},gasConstant:{description:"Gas constant",examples:["gasConstant"]},molarPlanckConstant:{description:"Molar Planck constant",examples:["molarPlanckConstant"]},molarVolume:{description:"Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",examples:["molarVolume"]},sackurTetrode:{description:"Sackur-Tetrode constant at T=1 K and p=101.325 kPa",examples:["sackurTetrode"]},secondRadiation:{description:"Second radiation constant",examples:["secondRadiation"]},stefanBoltzmann:{description:"Stefan-Boltzmann constant",examples:["stefanBoltzmann"]},wienDisplacement:{description:"Wien displacement law constant",examples:["wienDisplacement"]},molarMass:{description:"Molar mass constant",examples:["molarMass"]},molarMassC12:{description:"Molar mass constant of carbon-12",examples:["molarMassC12"]},gravity:{description:"Standard acceleration of gravity (standard acceleration of free-fall on Earth)",examples:["gravity"]},planckLength:{description:"Planck length",examples:["planckLength"]},planckMass:{description:"Planck mass",examples:["planckMass"]},planckTime:{description:"Planck time",examples:["planckTime"]},planckCharge:{description:"Planck charge",examples:["planckCharge"]},planckTemperature:{description:"Planck temperature",examples:["planckTemperature"]},derivative:{name:"derivative",category:"Algebra",syntax:["derivative(expr, variable)","derivative(expr, variable, {simplify: boolean})"],description:"Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",examples:['derivative("2x^3", "x")','derivative("2x^3", "x", {simplify: false})','derivative("2x^2 + 3x + 4", "x")','derivative("sin(2x)", "x")','f = parse("x^2 + x")','x = parse("x")',"df = derivative(f, x)","df.evaluate({x: 3})"],seealso:["simplify","parse","evaluate"]},lsolve:{name:"lsolve",category:"Algebra",syntax:["x=lsolve(L, b)"],description:"Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolveAll","lup","lusolve","usolve","matrix","sparse"]},lsolveAll:{name:"lsolveAll",category:"Algebra",syntax:["x=lsolveAll(L, b)"],description:"Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolve","lup","lusolve","usolve","matrix","sparse"]},lup:{name:"lup",category:"Algebra",syntax:["lup(m)"],description:"Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",examples:["lup([[2, 1], [1, 4]])","lup(matrix([[2, 1], [1, 4]]))","lup(sparse([[2, 1], [1, 4]]))"],seealso:["lusolve","lsolve","usolve","matrix","sparse","slu","qr"]},lusolve:{name:"lusolve",category:"Algebra",syntax:["x=lusolve(A, b)","x=lusolve(lu, b)"],description:"Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lusolve(a, b)"],seealso:["lup","slu","lsolve","usolve","matrix","sparse"]},simplify:{name:"simplify",category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["derivative","parse","evaluate"]},rationalize:{name:"rationalize",category:"Algebra",syntax:["rationalize(expr)","rationalize(expr, scope)","rationalize(expr, scope, detailed)"],description:"Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",examples:['rationalize("2x/y - y/(x+1)")','rationalize("2x/y - y/(x+1)", true)'],seealso:["simplify"]},slu:{name:"slu",category:"Algebra",syntax:["slu(A, order, threshold)"],description:"Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",examples:["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],seealso:["lusolve","lsolve","usolve","matrix","sparse","lup","qr"]},usolve:{name:"usolve",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolveAll","lup","lusolve","lsolve","matrix","sparse"]},usolveAll:{name:"usolveAll",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolve","lup","lusolve","lsolve","matrix","sparse"]},qr:{name:"qr",category:"Algebra",syntax:["qr(A)"],description:"Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",examples:["qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])"],seealso:["lup","slu","matrix"]},abs:{name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},add:{name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i","3 cm + 2 inch",'"2.3" + "4"'],seealso:["subtract"]},cbrt:{name:"cbrt",category:"Arithmetic",syntax:["cbrt(x)","cbrt(x, allRoots)"],description:"Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",examples:["cbrt(64)","cube(4)","cbrt(-8)","cbrt(2 + 3i)","cbrt(8i)","cbrt(8i, true)","cbrt(27 m^3)"],seealso:["square","sqrt","cube","multiply"]},ceil:{name:"ceil",category:"Arithmetic",syntax:["ceil(x)"],description:"Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)"],seealso:["floor","fix","round"]},cube:{name:"cube",category:"Arithmetic",syntax:["cube(x)"],description:"Compute the cube of a value. The cube of x is x * x * x.",examples:["cube(2)","2^3","2 * 2 * 2"],seealso:["multiply","square","pow"]},divide:{name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["a = 2 / 3","a * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]},dotDivide:{name:"dotDivide",category:"Operators",syntax:["x ./ y","dotDivide(x, y)"],description:"Divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","dotMultiply","divide"]},dotMultiply:{name:"dotMultiply",category:"Operators",syntax:["x .* y","dotMultiply(x, y)"],description:"Multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","dotDivide"]},dotPow:{name:"dotPow",category:"Operators",syntax:["x .^ y","dotPow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]},exp:{name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["expm","expm1","pow","log"]},expm:{name:"expm",category:"Arithmetic",syntax:["exp(x)"],description:"Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",examples:["expm([[0,2],[0,0]])"],seealso:["exp"]},expm1:{name:"expm1",category:"Arithmetic",syntax:["expm1(x)"],description:"Calculate the value of subtracting 1 from the exponential value.",examples:["expm1(2)","pow(e, 2) - 1","log(expm1(2) + 1)"],seealso:["exp","pow","log"]},fix:{name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]},floor:{name:"floor",category:"Arithmetic",syntax:["floor(x)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)"],seealso:["ceil","fix","round"]},gcd:{name:"gcd",category:"Arithmetic",syntax:["gcd(a, b)","gcd(a, b, c, ...)"],description:"Compute the greatest common divisor.",examples:["gcd(8, 12)","gcd(-4, 6)","gcd(25, 15, -10)"],seealso:["lcm","xgcd"]},hypot:{name:"hypot",category:"Arithmetic",syntax:["hypot(a, b, c, ...)","hypot([a, b, c, ...])"],description:"Calculate the hypotenusa of a list with values. ",examples:["hypot(3, 4)","sqrt(3^2 + 4^2)","hypot(-2)","hypot([3, 4, 5])"],seealso:["abs","norm"]},lcm:{name:"lcm",category:"Arithmetic",syntax:["lcm(x, y)"],description:"Compute the least common multiple.",examples:["lcm(4, 6)","lcm(6, 21)","lcm(6, 21, 5)"],seealso:["gcd"]},log:{name:"log",category:"Arithmetic",syntax:["log(x)","log(x, base)"],description:"Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",examples:["log(3.5)","a = log(2.4)","exp(a)","10 ^ 4","log(10000, 10)","log(10000) / log(10)","b = log(1024, 2)","2 ^ b"],seealso:["exp","log1p","log2","log10"]},log2:{name:"log2",category:"Arithmetic",syntax:["log2(x)"],description:"Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",examples:["log2(0.03125)","log2(16)","log2(16) / log2(2)","pow(2, 4)"],seealso:["exp","log1p","log","log10"]},log1p:{name:"log1p",category:"Arithmetic",syntax:["log1p(x)","log1p(x, base)"],description:"Calculate the logarithm of a `value+1`",examples:["log1p(2.5)","exp(log1p(1.4))","pow(10, 4)","log1p(9999, 10)","log1p(9999) / log(10)"],seealso:["exp","log","log2","log10"]},log10:{name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(0.00001)","log10(10000)","10 ^ 4","log(10000) / log(10)","log(10000, 10)"],seealso:["exp","log"]},mod:{name:"mod",category:"Operators",syntax:["x % y","x mod y","mod(x, y)"],description:"Calculates the modulus, the remainder of an integer division.",examples:["7 % 3","11 % 2","10 mod 4","isOdd(x) = x % 2","isOdd(2)","isOdd(3)"],seealso:["divide"]},multiply:{name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["a = 2.1 * 3.4","a / 3.4","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]},norm:{name:"norm",category:"Arithmetic",syntax:["norm(x)","norm(x, p)"],description:"Calculate the norm of a number, vector or matrix.",examples:["abs(-3.5)","norm(-3.5)","norm(3 - 4i)","norm([1, 2, -3], Infinity)","norm([1, 2, -3], -Infinity)","norm([3, 4], 2)","norm([[1, 2], [3, 4]], 1)",'norm([[1, 2], [3, 4]], "inf")','norm([[1, 2], [3, 4]], "fro")']},nthRoot:{name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["nthRoots","pow","sqrt"]},nthRoots:{name:"nthRoots",category:"Arithmetic",syntax:["nthRoots(A)","nthRoots(A, root)"],description:'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',examples:["nthRoots(1)","nthRoots(1, 3)"],seealso:["sqrt","pow","nthRoot"]},pow:{name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3","2*2*2","1 + e ^ (pi * i)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},round:{name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)"],seealso:["ceil","floor","fix"]},sign:{name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},sqrt:{name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},sqrtm:{name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},square:{name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},subtract:{name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},unaryMinus:{name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},bitAnd:{name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitNot:{name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitOr:{name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},bitXor:{name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},leftShift:{name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},rightArithShift:{name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},rightLogShift:{name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},bellNumbers:{name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},catalan:{name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},composition:{name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},stirlingS2:{name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},config:{name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},import:{name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number, number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},arg:{name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},conj:{name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},re:{name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},im:{name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},evaluate:{name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(" + 4 + ")")'],seealso:[]},help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},distance:{name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])","distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},intersect:{name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},and:{name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},not:{name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},or:{name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},xor:{name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},concat:{name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},count:{name:"count",category:"Matrix",syntax:["count(x)"],description:"Count the number of elements of a matrix, array or string.",examples:["a = [1, 2; 3, 4; 5, 6]","count(a)","size(a)",'count("hello world")'],seealso:["size"]},cross:{name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},column:{name:"column",category:"Matrix",syntax:["column(x, index)"],description:"Return a column from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","column(A, 1)","column(A, 2)"],seealso:["row","matrixFromColumns"]},ctranspose:{name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},det:{name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diag:{name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diff:{name:"diff",category:"Matrix",syntax:["diff(arr)","diff(arr, dim)"],description:["Create a new matrix or array with the difference of the passed matrix or array.","Dim parameter is optional and used to indicant the dimension of the array/matrix to apply the difference","If no dimension parameter is passed it is assumed as dimension 0","Dimension is zero-based in javascript and one-based in the parser","Arrays must be 'rectangular' meaning arrays like [1, 2]","If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],examples:["diff([1, 2, 4, 7, 0])","diff([1, 2, 4, 7, 0], 0)","diff(matrix([1, 2, 4, 7, 0]))","diff([[1, 2], [3, 4]])","diff([[1, 2], [3, 4]], 0)","diff([[1, 2], [3, 4]], 1)","diff([[1, 2], [3, 4]], bignumber(1))","diff(matrix([[1, 2], [3, 4]]), 1)","diff([[1, 2], matrix([3, 4])], 1)"],seealso:["subtract","partitionSelect"]},dot:{name:"dot",category:"Matrix",syntax:["dot(A, B)","A * B"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]},getMatrixDataType:{name:"getMatrixDataType",category:"Matrix",syntax:["getMatrixDataType(x)"],description:'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',examples:["getMatrixDataType([1, 2, 3])","getMatrixDataType([[5 cm], [2 inch]])",'getMatrixDataType([1, "text"])',"getMatrixDataType([1, bignumber(4)])"],seealso:["matrix","sparse","typeOf"]},identity:{name:"identity",category:"Matrix",syntax:["identity(n)","identity(m, n)","identity([m, n])"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["identity(3)","identity(3, 5)","a = [1, 2, 3; 4, 5, 6]","identity(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},filter:{name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},flatten:{name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]},forEach:{name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["forEach([1, 2, 3], function(val) { console.log(val) })"],seealso:["map","sort","filter"]},inv:{name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","identity","ones","range","size","squeeze","subset","trace","transpose","zeros"]},eigs:{name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and eigenvectors of a real symmetric matrix",examples:["eigs([[5, 2.3], [2.3, 1]])"],seealso:["inv"]},kron:{name:"kron",category:"Matrix",syntax:["kron(x, y)"],description:"Calculates the kronecker product of 2 matrices or vectors.",examples:["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])","kron([1,1], [2,3,4])"],seealso:["multiply","dot","cross"]},matrixFromFunction:{name:"matrixFromFunction",category:"Matrix",syntax:["math.matrixFromFunction(size, fn)","math.matrixFromFunction(size, fn, format)","math.matrixFromFunction(size, fn, format, datatype)","math.matrixFromFunction(size, format, fn)","math.matrixFromFunction(size, format, datatype, fn)"],description:"Create a matrix by evaluating a generating function at each index.",examples:["f(I) = I[1] - I[2]","matrixFromFunction([3,3], f)","g(I) = I[1] - I[2] == 1 ? 4 : 0",'matrixFromFunction([100, 100], "sparse", g)',"matrixFromFunction([5], random)"],seealso:["matrix","matrixFromRows","matrixFromColumns","zeros"]},matrixFromRows:{name:"matrixFromRows",category:"Matrix",syntax:["math.matrixFromRows(...arr)","math.matrixFromRows(row1, row2)","math.matrixFromRows(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual rows.",examples:["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromColumns","matrixFromFunction","zeros"]},matrixFromColumns:{name:"matrixFromColumns",category:"Matrix",syntax:["math.matrixFromColumns(...arr)","math.matrixFromColumns(row1, row2)","math.matrixFromColumns(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual columns.",examples:["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromRows","matrixFromFunction","zeros"]},map:{name:"map",category:"Matrix",syntax:["map(x, callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",examples:["map([1, 2, 3], square)"],seealso:["filter","forEach"]},ones:{name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","identity","inv","range","size","squeeze","subset","trace","transpose","zeros"]},partitionSelect:{name:"partitionSelect",category:"Matrix",syntax:["partitionSelect(x, k)","partitionSelect(x, k, compare)"],description:"Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",examples:["partitionSelect([5, 10, 1], 2)",'partitionSelect(["C", "B", "A", "D"], 1)'],seealso:["sort"]},range:{name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","identity","inv","ones","size","squeeze","subset","trace","transpose","zeros"]},resize:{name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze","reshape"]},reshape:{name:"reshape",category:"Matrix",syntax:["reshape(x, sizes)"],description:"Reshape a multi dimensional array to fit the specified dimensions.",examples:["reshape([1, 2, 3, 4, 5, 6], [2, 3])","reshape([[1, 2], [3, 4]], [1, 4])","reshape([[1, 2], [3, 4]], [4])"],seealso:["size","squeeze","resize"]},rotate:{name:"rotate",category:"Matrix",syntax:["rotate(w, theta)","rotate(w, theta, v)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotate([1, 0], math.pi / 2)",'rotate(matrix([1, 0]), unit("35deg"))','rotate([1, 0, 0], unit("90deg"), [0, 0, 1])','rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],seealso:["matrix","rotationMatrix"]},rotationMatrix:{name:"rotationMatrix",category:"Matrix",syntax:["rotationMatrix(theta)","rotationMatrix(theta, v)","rotationMatrix(theta, v, format)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotationMatrix(pi / 2)",'rotationMatrix(unit("45deg"), [0, 0, 1])','rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],seealso:["cos","sin"]},row:{name:"row",category:"Matrix",syntax:["row(x, index)"],description:"Return a row from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","row(A, 1)","row(A, 2)"],seealso:["column","matrixFromRows"]},size:{name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","count","det","diag","identity","inv","ones","range","squeeze","subset","trace","transpose","zeros"]},sort:{name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"])',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},squeeze:{name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","identity","inv","ones","range","size","subset","trace","transpose","zeros"]},subset:{name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of a matrix or string. Indexes are one-based. Both the ranges lower-bound and upper-bound are included.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},trace:{name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","transpose","zeros"]},transpose:{name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},zeros:{name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose"]},combinations:{name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},combinationsWithRep:{name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"],seealso:["combinations","permutations","factorial"]},factorial:{name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},gamma:{name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},kldivergence:{name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},multinomial:{name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},permutations:{name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},pickRandom:{name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)","pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])","pickRandom([1, 3, 1, 6], 2)","pickRandom([1, 3, 1, 6], [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],seealso:["random","randomInt"]},random:{name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]},randomInt:{name:"randomInt",category:"Probability",syntax:["randomInt(max)","randomInt(min, max)","randomInt(size)","randomInt(size, max)","randomInt(size, min, max)"],description:"Return a random integer number",examples:["randomInt(10, 20)","randomInt([2, 3], 10)"],seealso:["pickRandom","random"]},compare:{name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compareNatural","compareText"]},compareNatural:{name:"compareNatural",category:"Relational",syntax:["compareNatural(x, y)"],description:"Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compareNatural(2, 3)","compareNatural(3, 2)","compareNatural(2, 2)","compareNatural(5cm, 40mm)",'compareNatural("2", "10")',"compareNatural(2 + 3i, 2 + 4i)","compareNatural([1, 2, 4], [1, 2, 3])","compareNatural([1, 5], [1, 2, 3])","compareNatural([1, 2], [1, 2])","compareNatural({a: 2}, {a: 4})"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare","compareText"]},compareText:{name:"compareText",category:"Relational",syntax:["compareText(x, y)"],description:"Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:['compareText("B", "A")','compareText("A", "B")','compareText("A", "A")','compareText("2", "10")','compare("2", "10")',"compare(2, 10)",'compareNatural("2", "10")','compareText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural"]},deepEqual:{name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["deepEqual([1,3,4], [1,3,4])","deepEqual([1,3,4], [1,3])"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]},equal:{name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual","equalText"]},equalText:{name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},larger:{name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},largerEq:{name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},smaller:{name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},smallerEq:{name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 <= 1+1","2 < 1+1","a = 3.2","b = 6-2.8","(a <= b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]},unequal:{name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]},setCartesian:{name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays and the values will be sorted in ascending order before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},setDifference:{name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},setDistinct:{name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},setIntersect:{name:"setIntersect",category:"Set",syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},setIsSubset:{name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},setMultiplicity:{name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]},setPowerset:{name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},setSize:{name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},setSymDifference:{name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setDifference"]},setUnion:{name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},erf:{name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},mad:{name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},mean:{name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},median:{name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},min:{name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},mode:{name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},prod:{name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},quantileSeq:{name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:"Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.",examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},std:{name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},sum:{name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},variance:{name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},acos:{name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},acosh:{name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},acot:{name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},acoth:{name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},acsc:{name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},acsch:{name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},asec:{name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},asech:{name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},asin:{name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},asinh:{name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},atan:{name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},atanh:{name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},atan2:{name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},cos:{name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},cosh:{name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},cot:{name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},coth:{name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},csc:{name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},csch:{name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},sec:{name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},sech:{name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},sin:{name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},sinh:{name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},tan:{name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},tanh:{name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},to:{name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},clone:{name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},format:{name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},bin:{name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},oct:{name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},hex:{name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},isNaN:{name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isInteger:{name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isNegative:{name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},isNumeric:{name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},hasNumericValue:{name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},isPositive:{name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isPrime:{name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isZero:{name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},typeOf:{name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},numeric:{name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "BigNumber")','numeric("4", "Fraction)','numeric(4, "Fraction")','numeric(fraction(2, 5), "number)'],seealso:["number","fraction","bignumber","string","format"]}},mr="help",hr=W(mr,["typed","mathWithTransform","Help"],(e=>{var{typed:t,mathWithTransform:r,Help:n}=e;return t(mr,{any:function(e){var t,i=e;if("string"!=typeof e)for(t in r)if(V(r,t)&&e===r[t]){i=t;break}var a=Y(pr,i);if(!a){var o="function"==typeof i?i.name:i;throw new Error('No documentation found on "'+o+'"')}return new n(a)}})})),dr=W("derivative",["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:t,config:r,parse:n,simplify:i,equal:a,isZero:o,numeric:s,ConstantNode:u,FunctionNode:c,OperatorNode:l,ParenthesisNode:f,SymbolNode:p}=e,m=t("derivative",{"Node, SymbolNode, Object":function(e,t,r){var n={};d(n,e,t.name);var a=y(e,n);return r.simplify?i(a):a},"Node, SymbolNode":function(e,t){return this(e,t,{simplify:!0})},"string, SymbolNode":function(e,t){return this(n(e),t)},"string, SymbolNode, Object":function(e,t,r){return this(n(e),t,r)},"string, string":function(e,t){return this(n(e),n(t))},"string, string, Object":function(e,t,r){return this(n(e),n(t),r)},"Node, string":function(e,t){return this(e,n(t))},"Node, string, Object":function(e,t,r){return this(e,n(t),r)}});m._simplify=!0,m.toTex=function(e){return h.apply(null,e.args)};var h=t("_derivTex",{"Node, SymbolNode":function(e,t){return B(e)&&"string"===L(e.value)?h(n(e.value).toString(),t.toString(),1):h(e.toString(),t.toString(),1)},"Node, ConstantNode":function(e,t){if("string"===L(t.value))return h(e,n(t.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(e,t,r){return h(e.toString(),t.name,r.value)},"string, string, number":function(e,t,r){return(1===r?"{d\\over d"+t+"}":"{d^{"+r+"}\\over d"+t+"^{"+r+"}}")+"\\left[".concat(e,"\\right]")}}),d=t("constTag",{"Object, ConstantNode, string":function(e,t){return e[t]=!0,!0},"Object, SymbolNode, string":function(e,t,r){return t.name!==r&&(e[t]=!0,!0)},"Object, ParenthesisNode, string":function(e,t,r){return d(e,t.content,r)},"Object, FunctionAssignmentNode, string":function(e,t,r){return-1===t.params.indexOf(r)?(e[t]=!0,!0):d(e,t.expr,r)},"Object, FunctionNode | OperatorNode, string":function(e,t,r){if(t.args.length>0){for(var n=d(e,t.args[0],r),i=1;i0){var n=e.args.filter((function(e){return void 0===t[e]})),i=1===n.length?n[0]:new l("*","multiply",n),s=r.concat(y(i,t));return new l("*","multiply",s)}return new l("+","add",e.args.map((function(r){return new l("*","multiply",e.args.map((function(e){return e===r?y(e,t):e.clone()})))})))}if("/"===e.op&&e.isBinary()){var u=e.args[0],f=e.args[1];return void 0!==t[f]?new l("/","divide",[y(u,t),f]):void 0!==t[u]?new l("*","multiply",[new l("-","unaryMinus",[u]),new l("/","divide",[y(f,t),new l("^","pow",[f.clone(),g(2)])])]):new l("/","divide",[new l("-","subtract",[new l("*","multiply",[y(u,t),f.clone()]),new l("*","multiply",[u.clone(),y(f,t)])]),new l("^","pow",[f.clone(),g(2)])])}if("^"===e.op&&e.isBinary()){var p=e.args[0],m=e.args[1];if(void 0!==t[p])return B(p)&&(o(p.value)||a(p.value,1))?g(0):new l("*","multiply",[e,new l("*","multiply",[new c("log",[p.clone()]),y(m.clone(),t)])]);if(void 0!==t[m]){if(B(m)){if(o(m.value))return g(0);if(a(m.value,1))return y(p,t)}var h=new l("^","pow",[p.clone(),new l("-","subtract",[m,g(1)])]);return new l("*","multiply",[m.clone(),new l("*","multiply",[y(p,t),h])])}return new l("*","multiply",[new l("^","pow",[p.clone(),m.clone()]),new l("+","add",[new l("*","multiply",[y(p,t),new l("/","divide",[m.clone(),p.clone()])]),new l("*","multiply",[y(m,t),new c("log",[p.clone()])])])])}throw new Error('Operator "'+e.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function g(e,t){return new u(s(e,t||r.number))}return m})),yr="parser",gr=W(yr,["typed","Parser"],(e=>{var{typed:t,Parser:r}=e;return t(yr,{"":function(){return new r}})})),vr="compile",xr=W(vr,["typed","parse"],(e=>{var{typed:t,parse:r}=e;return t(vr,{string:function(e){return r(e).compile()},"Array | Matrix":function(e){return $t(e,(function(e){return r(e).compile()}))}})})),br="apply",wr=W(br,["typed","isInteger"],(e=>{var{typed:t,isInteger:r}=e;return t(br,{"Array | Matrix, number | BigNumber, function":function(e,t,n){if(!r(t))throw new TypeError("Integer number expected for dimension");var i=Array.isArray(e)?je(e):e.size();if(t<0||t>=i.length)throw new Pe(t,i.length);return f(e)?e.create(Nr(e.valueOf(),t,n)):Nr(e,t,n)}})}));function Nr(e,t,r){var n,i,a;if(t<=0){if(Array.isArray(e[0])){for(a=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r{var{typed:t,isInteger:r}=e,n=wr({typed:t,isInteger:r});return t("apply",{"...any":function(e){var t=e[1];i(t)?e[1]=t-1:a(t)&&(e[1]=t.minus(1));try{return n.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0});function Sr(e){var t=0,r=1,n=Object.create(null),i=Object.create(null),a=0,o=function(e){var o=i[e];if(o&&(delete n[o],delete i[e],--t,r===o)){if(!t)return a=0,void(r=1);for(;!hasOwnProperty.call(n,++r););}};return e=Math.abs(e),{hit:function(s){var u=i[s],c=++a;if(n[c]=s,i[s]=c,!u){if(++t<=e)return;return s=n[r],o(s),s}if(delete n[u],r===u)for(;!hasOwnProperty.call(n,++r););},delete:o,clear:function(){t=a=0,r=1,n=Object.create(null),i=Object.create(null)}}}function Er(e){var{hasher:t,limit:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r=null==r?Number.POSITIVE_INFINITY:r,t=null==t?JSON.stringify:t,function n(){"object"!=typeof n.cache&&(n.cache={values:new Map,lru:Sr(r||Number.POSITIVE_INFINITY)});for(var i=[],a=0;a{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=P(e[1])||q(e[1])?e[1].compile().evaluate(r):Or(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("filter",{"Array, function":_r,"Matrix, function":function(e,t){return e.create(_r(e.toArray(),t))},"Array, RegExp":it,"Matrix, RegExp":function(e,t){return e.create(it(e.toArray(),t))}});return r}),{isTransformFunction:!0});function _r(e,t){var r=Ar(t);return nt(e,(function(e,n,i){return 1===r?t(e):2===r?t(e,[n+1]):t(e,[n+1],i)}))}var Tr=W("map",["typed"],(e=>{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=P(e[1])||q(e[1])?e[1].compile().evaluate(r):Or(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("map",{"Array, function":function(e,t){return Br(e,t,e)},"Matrix, function":function(e,t){return e.create(Br(e.valueOf(),t,e))}});return r}),{isTransformFunction:!0});function Br(e,t,r){var n=Ar(t);return function e(i,a){return Array.isArray(i)?tt(i,(function(t,r){return e(t,a.concat(r+1))})):1===n?t(i):2===n?t(i,a):t(i,a,r)}(e,[])}var qr=W("forEach",["typed"],(e=>{var{typed:t}=e;function r(e,t,r){var i,a;return e[0]&&(i=e[0].compile().evaluate(r)),e[1]&&(a=P(e[1])||q(e[1])?e[1].compile().evaluate(r):Or(e[1],t,r)),n(i,a)}r.rawArgs=!0;var n=t("forEach",{"Array | Matrix, function":function(e,t){var r=Ar(t);!function n(i,a){Array.isArray(i)?rt(i,(function(e,t){n(e,a.concat(t+1))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e.valueOf(),[])}});return r}),{isTransformFunction:!0}),zr="subset",Dr=W(zr,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t(zr,{"Array, Index":function(e,t){var n=r(e).subset(t);return t.isScalar()?n:n.valueOf()},"Matrix, Index":function(e,t){return e.subset(t)},"Object, Index":Rr,"string, Index":Ir,"Array, Index, any":function(e,t,n){return r($(e)).subset(t,n,void 0).valueOf()},"Array, Index, any, any":function(e,t,n,i){return r($(e)).subset(t,n,i).valueOf()},"Matrix, Index, any":function(e,t,r){return e.clone().subset(t,r)},"Matrix, Index, any, any":function(e,t,r,n){return e.clone().subset(t,r,n)},"string, Index, string":kr,"string, Index, string, string":kr,"Object, Index, any":Fr})}));function Ir(e,t){if(!y(t))throw new TypeError("Index expected");if(1!==t.size().length)throw new Ue(t.size().length,1);var r=e.length;$e(t.min()[0],r),$e(t.max()[0],r);var n=t.dimension(0),i="";return n.forEach((function(t){i+=e.charAt(t)})),i}function kr(e,t,r,n){if(!t||!0!==t.isIndex)throw new TypeError("Index expected");if(1!==t.size().length)throw new Ue(t.size().length,1);if(void 0!==n){if("string"!=typeof n||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";var i=t.dimension(0);if(i.size()[0]!==r.length)throw new Ue(i.size()[0],r.length);var a=e.length;$e(t.min()[0]),$e(t.max()[0]);for(var o=[],s=0;sa)for(var u=a-1,c=o.length;u{var{typed:t,matrix:r}=e,n=Dr({typed:t,matrix:r});return t("subset",{"...any":function(e){try{return n.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Pr=W("index",["Index"],(e=>{var{Index:t}=e;return function(){for(var e=[],r=0,n=arguments.length;r0?0:2;else if(o&&!0===o.isSet)o=o.map((function(e){return e-1}));else if(l(o)||f(o))o=o.map((function(e){return e-1}));else if(i(o))o--;else if(a(o))o=o.toNumber()-1;else if("string"!=typeof o)throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");e[r]=o}var s=new t;return t.apply(s,e),s}}),{isTransformFunction:!0}),jr="concat",Lr=W(jr,["typed","matrix","isInteger"],(e=>{var{typed:t,matrix:r,isInteger:n}=e;return t(jr,{"...Array | Matrix | number | BigNumber":function(e){var t,o,s=e.length,u=-1,c=!1,l=[];for(t=0;t0&&u>o)throw new Pe(u,o+1)}else{var m=$(p).valueOf(),h=je(m);if(l[t]=m,o=u,u=h.length-1,t>0&&u!==o)throw new Ue(o+1,u+1)}}if(0===l.length)throw new SyntaxError("At least one matrix expected");for(var d=l.shift();l.length;)d=Hr(d,l.shift(),u,0);return c?r(d):d},"...string":function(e){return e.join("")}})}));function Hr(e,t,r,n){if(n{var{typed:t,matrix:r,isInteger:n}=e,o=Lr({typed:t,matrix:r,isInteger:n});return t("concat",{"...any":function(e){var t=e.length-1,r=e[t];i(r)?e[t]=r-1:a(r)&&(e[t]=r.minus(1));try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0});function Gr(e,t,r){var n;return-1!==String(e).indexOf("Unexpected type")?(n=arguments.length>2?" (type: "+L(r)+", value: "+JSON.stringify(r)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+n)):-1!==String(e).indexOf("complex numbers")?(n=arguments.length>2?" (type: "+L(r)+", value: "+JSON.stringify(r)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+n)):e}var Zr=W("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:r,numeric:n,larger:i}=e;return t("max",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){return Gt(e,t.valueOf(),a)},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function max");return o(e)}});function a(e,t){try{return i(e,t)?e:t}catch(e){throw Gr(e,"max",t)}}function o(e){var t;if(Ht(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw Gr(t,"max",e)}})),void 0===t)throw new Error("Cannot calculate max of an empty array");return"string"==typeof t&&(t=n(t,r.number)),t}}));function Vr(e){if(2===e.length&&p(e[0])){var t=(e=e.slice())[1];i(t)?e[1]=t-1:a(t)&&(e[1]=t.minus(1))}return e}var Wr=W("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:r,numeric:n,larger:i}=e,a=Zr({typed:t,config:r,numeric:n,larger:i});return t("max",{"...any":function(e){e=Vr(e);try{return a.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Jr=W("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:r,numeric:n,smaller:i}=e;return t("min",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){return Gt(e,t.valueOf(),a)},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function min");return o(e)}});function a(e,t){try{return i(e,t)?e:t}catch(e){throw Gr(e,"min",t)}}function o(e){var t;if(Ht(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||i(e,t))&&(t=e)}catch(t){throw Gr(t,"min",e)}})),void 0===t)throw new Error("Cannot calculate min of an empty array");return"string"==typeof t&&(t=n(t,r.number)),t}})),Yr=W("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:r,numeric:n,smaller:i}=e,a=Jr({typed:t,config:r,numeric:n,smaller:i});return t("min",{"...any":function(e){e=Vr(e);try{return a.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Xr=W("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:r,add:n,numeric:i}=e;return t("sum",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){try{return Gt(e,t,n)}catch(e){throw Gr(e,"sum")}},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function sum");return a(e)}});function a(e){var t;return Ht(e,(function(e){try{t=void 0===t?e:n(t,e)}catch(t){throw Gr(t,"sum",e)}})),void 0===t&&(t=i(0,r.number)),"string"==typeof t&&(t=i(t,r.number)),t}})),Qr=W("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:r,add:n,numeric:i}=e,a=Xr({typed:t,config:r,add:n,numeric:i});return t("sum",{"...any":function(e){e=Vr(e);try{return a.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Kr="column",en=W(Kr,["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e;return t(Kr,{"Matrix, number":a,"Array, number":function(e,t){return a(n($(e)),t).valueOf()}});function a(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");$e(t,e.size()[1]);var n=i(0,e.size()[0]),a=new r(n,t);return e.subset(a)}})),tn=W("column",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:a}=e,o=en({typed:t,Index:r,matrix:n,range:a});return t("column",{"...any":function(e){var t=e.length-1,r=e[t];i(r)&&(e[t]=r-1);try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),rn="range",nn=W(rn,["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u}=e;return t(rn,{string:l,"string, boolean":l,"number, number":function(e,t){return c(f(e,t,1))},"number, number, number":function(e,t,r){return c(f(e,t,r))},"number, number, boolean":function(e,t,r){return c(r?p(e,t,1):f(e,t,1))},"number, number, number, boolean":function(e,t,r,n){return c(n?p(e,t,r):f(e,t,r))},"BigNumber, BigNumber":function(e,t){return c(m(e,t,new(0,e.constructor)(1)))},"BigNumber, BigNumber, BigNumber":function(e,t,r){return c(m(e,t,r))},"BigNumber, BigNumber, boolean":function(e,t,r){var n=e.constructor;return c(r?h(e,t,new n(1)):m(e,t,new n(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,r,n){return c(n?h(e,t,r):m(e,t,r))}});function c(e){return"Matrix"===r.matrix?n?n(e):nr():e}function l(e,t){var n=function(e){var t=e.split(":").map((function(e){return Number(e)}));if(t.some((function(e){return isNaN(e)})))return null;switch(t.length){case 2:return{start:t[0],end:t[1],step:1};case 3:return{start:t[0],end:t[2],step:t[1]};default:return null}}(e);if(!n)throw new SyntaxError('String "'+e+'" is no valid range');return"BigNumber"===r.number?(void 0===i&&tr(),c((t?h:m)(i(n.start),i(n.end),i(n.step)))):c((t?p:f)(n.start,n.end,n.step))}function f(e,t,r){var n=[],i=e;if(r>0)for(;a(i,t);)n.push(i),i+=r;else if(r<0)for(;s(i,t);)n.push(i),i+=r;return n}function p(e,t,r){var n=[],i=e;if(r>0)for(;o(i,t);)n.push(i),i+=r;else if(r<0)for(;u(i,t);)n.push(i),i+=r;return n}function m(e,t,r){var n=i(0),o=[],u=e;if(r.gt(n))for(;a(u,t);)o.push(u),u=u.plus(r);else if(r.lt(n))for(;s(u,t);)o.push(u),u=u.plus(r);return o}function h(e,t,r){var n=i(0),a=[],s=e;if(r.gt(n))for(;o(s,t);)a.push(s),s=s.plus(r);else if(r.lt(n))for(;u(s,t);)a.push(s),s=s.plus(r);return a}})),an=W("range",["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u}=e,c=nn({typed:t,config:r,matrix:n,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:u});return t("range",{"...any":function(e){return"boolean"!=typeof e[e.length-1]&&e.push(!0),c.apply(null,e)}})}),{isTransformFunction:!0}),on="diff",sn=W(on,["typed","matrix","subtract","number"],(e=>{var{typed:t,matrix:r,subtract:n,number:i}=e;return t(on,{"Array | Matrix":function(e){return f(e)?r(o(e.toArray())):o(e)},"Array | Matrix, number":function(e,t){if(!ce(t))throw new RangeError("Dimension must be a whole number");return f(e)?r(a(e.toArray(),t)):a(e,t)},"Array | Matrix, BigNumber":function(e,t){return this(e,i(t))}});function a(e,t){if(f(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError("Array/Matrix does not have that many dimensions");if(t>0){var r=[];return e.forEach((e=>{r.push(a(e,t-1))})),r}if(0===t)return o(e);throw RangeError("Cannot have negative dimension")}function o(e){var t=[],r=e.length;if(r<2)return e;for(var n=1;n{var{typed:t,matrix:r,subtract:n,number:i,bignumber:a}=e,o=sn({typed:t,matrix:r,subtract:n,number:i,bignumber:a});return t(un,{"...any":function(e){e=Vr(e);try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),ln=W("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:i}=e;return t("row",{"Matrix, number":a,"Array, number":function(e,t){return a(n($(e)),t).valueOf()}});function a(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");$e(t,e.size()[0]);var n=i(0,e.size()[1]),a=new r(t,n);return e.subset(a)}})),fn=W("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:r,matrix:n,range:a}=e,o=ln({typed:t,Index:r,matrix:n,range:a});return t("row",{"...any":function(e){var t=e.length-1,r=e[t];i(r)&&(e[t]=r-1);try{return o.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),pn="mean",mn=W(pn,["typed","add","divide"],(e=>{var{typed:t,add:r,divide:n}=e;return t(pn,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,t){try{var i=Gt(e,t,r),a=Array.isArray(e)?je(e):e.size();return n(i,a[t])}catch(e){throw Gr(e,"mean")}},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function mean");return i(e)}});function i(e){var t,i=0;if(Ht(e,(function(e){try{t=void 0===t?e:r(t,e),i++}catch(t){throw Gr(t,"mean",e)}})),0===i)throw new Error("Cannot calculate the mean of an empty array");return n(t,i)}})),hn=W("mean",["typed","add","divide"],(e=>{var{typed:t,add:r,divide:n}=e,i=mn({typed:t,add:r,divide:n});return t("mean",{"...any":function(e){e=Vr(e);try{return i.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),dn="unbiased",yn="variance",gn=W(yn,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:r,subtract:n,multiply:i,divide:o,apply:s,isNaN:u}=e;return t(yn,{"Array | Matrix":function(e){return c(e,dn)},"Array | Matrix, string":c,"Array | Matrix, number | BigNumber":function(e,t){return l(e,t,dn)},"Array | Matrix, number | BigNumber, string":l,"...":function(e){return c(e,dn)}});function c(e,t){var s,c=0;if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Ht(e,(function(e){try{s=void 0===s?e:r(s,e),c++}catch(t){throw Gr(t,"variance",e)}})),0===c)throw new Error("Cannot calculate variance of an empty array");var l=o(s,c);if(s=void 0,Ht(e,(function(e){var t=n(e,l);s=void 0===s?i(t,t):r(s,i(t,t))})),u(s))return s;switch(t){case"uncorrected":return o(s,c);case"biased":return o(s,c+1);case"unbiased":var f=a(s)?s.mul(0):0;return 1===c?f:o(s,c-1);default:throw new Error('Unknown normalization "'+t+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function l(e,t,r){try{if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return s(e,t,(e=>c(e,r)))}catch(e){throw Gr(e,"variance")}}})),vn="variance",xn=W(vn,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:r,subtract:n,multiply:i,divide:a,apply:o,isNaN:s}=e,u=gn({typed:t,add:r,subtract:n,multiply:i,divide:a,apply:o,isNaN:s});return t(vn,{"...any":function(e){e=Vr(e);try{return u.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),bn=W("std",["typed","sqrt","variance"],(e=>{var{typed:t,sqrt:r,variance:n}=e;return t("std",{"Array | Matrix":i,"Array | Matrix, string":i,"Array | Matrix, number | BigNumber":i,"Array | Matrix, number | BigNumber, string":i,"...":function(e){return i(e)}});function i(e,t){if(0===e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{return r(n.apply(null,arguments))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf(" variance")?new TypeError(e.message.replace(" variance"," std")):e}}})),wn=W("std",["typed","sqrt","variance"],(e=>{var{typed:t,sqrt:r,variance:n}=e,i=bn({typed:t,sqrt:r,variance:n});return t("std",{"...any":function(e){e=Vr(e);try{return i.apply(null,e)}catch(e){throw Dt(e)}}})}),{isTransformFunction:!0}),Nn=W("ResultSet",[],(()=>{function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=t||[]}return e.prototype.type="ResultSet",e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},e.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},e.fromJSON=function(t){return new e(t.entries)},e}),{isClass:!0}),Mn=r(977),Sn=W("Complex",[],(()=>(Mn.prototype.type="Complex",Mn.prototype.isComplex=!0,Mn.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Mn.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Mn.prototype.format=function(e){var t=this.im,r=this.re,n=ge(this.re,e),a=ge(this.im,e),o=i(e)?e:e?e.precision:null;if(null!==o){var s=Math.pow(10,-o);Math.abs(r/t)t.re?1:e.ret.im?1:e.im{function e(t,r,n){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var i=null!=t,o=null!=r,s=null!=n;if(i)if(a(t))t=t.toNumber();else if("number"!=typeof t)throw new TypeError("Parameter start must be a number");if(o)if(a(r))r=r.toNumber();else if("number"!=typeof r)throw new TypeError("Parameter end must be a number");if(s)if(a(n))n=n.toNumber();else if("number"!=typeof n)throw new TypeError("Parameter step must be a number");this.start=i?parseFloat(t):0,this.end=o?parseFloat(r):0,this.step=s?parseFloat(n):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(t){if("string"!=typeof t)return null;var r=t.split(":").map((function(e){return parseFloat(e)}));if(r.some((function(e){return isNaN(e)})))return null;switch(r.length){case 2:return new e(r[0],r[1]);case 3:return new e(r[0],r[2],r[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var e=0,t=this.start,r=this.step,n=this.end-t;return le(r)===le(n)?e=Math.ceil(n/r):0===n&&(e=0),isNaN(e)&&(e=0),[e]},e.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},e.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},e.prototype.forEach=function(e){var t=this.start,r=this.step,n=this.end,i=0;if(r>0)for(;tn;)e(t,[i],this),t+=r,i++},e.prototype.map=function(e){var t=[];return this.forEach((function(r,n,i){t[n[0]]=e(r,n,i)})),t},e.prototype.toArray=function(){var e=[];return this.forEach((function(t,r){e[r[0]]=t})),e},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(e){var t=ge(this.start,e);return 1!==this.step&&(t+=":"+ge(this.step,e)),t+":"+ge(this.end,e)},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},e.fromJSON=function(t){return new e(t.start,t.end,t.step)},e}),{isClass:!0}),An=Er((function(e){return new e(1).exp()}),{hasher:Tn}),On=Er((function(e){return new e(1).plus(new e(5).sqrt()).div(2)}),{hasher:Tn}),Cn=Er((function(e){return e.acos(-1)}),{hasher:Tn}),_n=Er((function(e){return Cn(e).times(2)}),{hasher:Tn});function Tn(e){return e[0].precision}var Bn=Math.PI,qn=2*Math.PI,zn=Math.E,Dn=W("true",[],(()=>!0)),In=W("false",[],(()=>!1)),kn=W("null",[],(()=>null)),Rn=Xn("Infinity",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1/0):1/0})),Fn=Xn("NaN",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(NaN):NaN})),Un=Xn("pi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?Cn(r):Bn})),Pn=Xn("tau",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?_n(r):qn})),jn=Xn("e",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?An(r):zn})),Ln=Xn("phi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?On(r):1.618033988749895})),Hn=Xn("LN2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(2).ln():Math.LN2})),$n=Xn("LN10",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(10).ln():Math.LN10})),Gn=Xn("LOG2E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1).div(new r(2).ln()):Math.LOG2E})),Zn=Xn("LOG10E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(1).div(new r(10).ln()):Math.LOG10E})),Vn=Xn("SQRT1_2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r("0.5").sqrt():Math.SQRT1_2})),Wn=Xn("SQRT2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:r}=e;return"BigNumber"===t.number?new r(2).sqrt():Math.SQRT2})),Jn=Xn("i",["Complex"],(e=>{var{Complex:t}=e;return t.I})),Yn=W("version",[],(()=>"9.5.0"));function Xn(e,t,r){return W(e,t,r,{recreateOnConfigChange:!0})}var Qn=r(776),Kn=W("BigNumber",["?on","config"],(e=>{var{on:t,config:r}=e,n=Qn.clone({precision:r.precision,modulo:Qn.EUCLID});return n.prototype=Object.create(n.prototype),n.prototype.type="BigNumber",n.prototype.isBigNumber=!0,n.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},n.fromJSON=function(e){return new n(e.value)},t&&t("config",(function(e,t){e.precision!==t.precision&&n.config({precision:e.precision})})),n}),{isClass:!0}),ei=W("Matrix",[],(()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(e,t,r){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(e,t,r){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e}),{isClass:!0}),ti=W("replacer",[],(()=>function(e,t){return"number"!=typeof t||isFinite(t)&&!isNaN(t)?t:{mathjs:"number",value:String(t)}})),ri=Qi("speedOfLight","299792458","m s^-1"),ni=Qi("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),ii=Qi("planckConstant","6.62607015e-34","J s"),ai=Qi("reducedPlanckConstant","1.0545718176461565e-34","J s"),oi=Qi("magneticConstant","1.25663706212e-6","N A^-2"),si=Qi("electricConstant","8.8541878128e-12","F m^-1"),ui=Qi("vacuumImpedance","376.730313667","ohm"),ci=Qi("coulomb","8.987551792261171e9","N m^2 C^-2"),li=Qi("elementaryCharge","1.602176634e-19","C"),fi=Qi("bohrMagneton","9.2740100783e-24","J T^-1"),pi=Qi("conductanceQuantum","7.748091729863649e-5","S"),mi=Qi("inverseConductanceQuantum","12906.403729652257","ohm"),hi=Qi("magneticFluxQuantum","2.0678338484619295e-15","Wb"),di=Qi("nuclearMagneton","5.0507837461e-27","J T^-1"),yi=Qi("klitzing","25812.807459304513","ohm"),gi=Qi("bohrRadius","5.29177210903e-11","m"),vi=Qi("classicalElectronRadius","2.8179403262e-15","m"),xi=Qi("electronMass","9.1093837015e-31","kg"),bi=Qi("fermiCoupling","1.1663787e-5","GeV^-2"),wi=Ki("fineStructure",.0072973525693),Ni=Qi("hartreeEnergy","4.3597447222071e-18","J"),Mi=Qi("protonMass","1.67262192369e-27","kg"),Si=Qi("deuteronMass","3.3435830926e-27","kg"),Ei=Qi("neutronMass","1.6749271613e-27","kg"),Ai=Qi("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),Oi=Qi("rydberg","10973731.568160","m^-1"),Ci=Qi("thomsonCrossSection","6.6524587321e-29","m^2"),_i=Ki("weakMixingAngle",.2229),Ti=Ki("efimovFactor",22.7),Bi=Qi("atomicMass","1.66053906660e-27","kg"),qi=Qi("avogadro","6.02214076e23","mol^-1"),zi=Qi("boltzmann","1.380649e-23","J K^-1"),Di=Qi("faraday","96485.33212331001","C mol^-1"),Ii=Qi("firstRadiation","3.7417718521927573e-16","W m^2"),ki=Qi("loschmidt","2.686780111798444e25","m^-3"),Ri=Qi("gasConstant","8.31446261815324","J K^-1 mol^-1"),Fi=Qi("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),Ui=Qi("molarVolume","0.022413969545014137","m^3 mol^-1"),Pi=Ki("sackurTetrode",-1.16487052358),ji=Qi("secondRadiation","0.014387768775039337","m K"),Li=Qi("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),Hi=Qi("wienDisplacement","2.897771955e-3","m K"),$i=Qi("molarMass","0.99999999965e-3","kg mol^-1"),Gi=Qi("molarMassC12","11.9999999958e-3","kg mol^-1"),Zi=Qi("gravity","9.80665","m s^-2"),Vi=Qi("planckLength","1.616255e-35","m"),Wi=Qi("planckMass","2.176435e-8","kg"),Ji=Qi("planckTime","5.391245e-44","s"),Yi=Qi("planckCharge","1.87554603778e-18","C"),Xi=Qi("planckTemperature","1.416785e+32","K");function Qi(e,t,r){return W(e,["config","Unit","BigNumber"],(e=>{var{config:n,Unit:i,BigNumber:a}=e,o=new i("BigNumber"===n.number?new a(t):parseFloat(t),r);return o.fixPrefix=!0,o}))}function Ki(e,t){return W(e,["config","BigNumber"],(e=>{var{config:r,BigNumber:n}=e;return"BigNumber"===r.number?new n(t):t}))}var ea=r(628),ta=W("Fraction",[],(()=>(ea.prototype.type="Fraction",ea.prototype.isFraction=!0,ea.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},ea.fromJSON=function(e){return new ea(e)},ea)),{isClass:!0}),ra=W("DenseMatrix",["Matrix"],(e=>{var{Matrix:t}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!c(t))throw new Error("Invalid datatype: "+t);if(f(e))"DenseMatrix"===e.type?(this._data=$(e._data),this._size=$(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&l(e.data)&&l(e.size))this._data=e.data,this._size=e.size,He(this._data,this._size),this._datatype=t||e.datatype;else if(l(e))this._data=d(e),this._size=je(this._data),He(this._data,this._size),this._datatype=t;else{if(e)throw new TypeError("Unsupported type of data ("+L(e)+")");this._data=[],this._size=[0],this._datatype=t}}function n(e,t){if(!y(t))throw new TypeError("Invalid index");if(t.isScalar())return e.get(t.min());var n=t.size();if(n.length!==e._size.length)throw new Ue(n.length,e._size.length);for(var i=t.min(),a=t.max(),s=0,u=e._size.length;s");h(e,t.max().map((function(e){return e+1})),n);var l=a.length;u(e._data,t,r,l,0)}return e}function u(e,t,r,n,i){var a=i===n-1,o=t.dimension(i);a?o.forEach((function(t,n){$e(t),e[t]=r[n[0]]})):o.forEach((function(a,o){$e(a),u(e[a],t,r[o[0]],n,i+1)}))}function m(e,t,r){if(0===t.length){for(var n=e._data;l(n);)n=n[0];return n}return e._size=t.slice(0),e._data=Ge(e._data,e._size,r),e}function h(e,t,r){for(var n=e._size.slice(0),i=!1;n.lengthn[a]&&(n[a]=t[a],i=!0);i&&m(e,n,r)}function d(e){for(var t=0,r=e.length;tArray.isArray(e)&&1===e.length?e[0]:e));return m(r?this.clone():this,n,t)},r.prototype.reshape=function(e,t){var r=t?this.clone():this;r._data=Ve(r._data,e);var n=r._size.reduce(((e,t)=>e*t));return r._size=We(e,n),r},r.prototype.clone=function(){return new r({data:$(this._data),size:$(this._size),datatype:this._datatype})},r.prototype.size=function(){return this._size.slice(0)},r.prototype.map=function(e){var t=this,n=function r(n,i){return l(n)?n.map((function(e,t){return r(e,i.concat(t))})):e(n,i,t)}(this._data,[]);return new r(n,void 0!==this._datatype?ut(n,L):void 0)},r.prototype.forEach=function(e){var t=this;!function r(n,i){l(n)?n.forEach((function(e,t){r(e,i.concat(t))})):e(n,i,t)}(this._data,[])},r.prototype[Symbol.iterator]=function*(){yield*function*e(t,r){if(l(t))for(var n=0;n[e[n]]));t.push(new r(a,e._datatype))},o=0;o0?e:0,n=e<0?-e:0,o=this._size[0],s=this._size[1],u=Math.min(o-n,s-t),c=[],l=0;l0?n:0,c=n<0?-n:0,p=e[0],m=e[1],h=Math.min(p-c,m-u);if(l(t)){if(t.length!==h)throw new Error("Invalid value array length");s=function(e){return t[e]}}else if(f(t)){var d=t.size();if(1!==d.length||d[0]!==h)throw new Error("Invalid matrix length");s=function(e){return t.get([e])}}else s=function(){return t};o||(o=a(s(0))?s(0).mul(0):0);var y=[];if(e.length>0){y=Ge(y,e,o);for(var g=0;g15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new t(e)}},{from:"number",to:"Complex",convert:function(e){return r||sa(e),new r(e,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(e){return r||sa(e),new r(e.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(e){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(e){return r||sa(e),new r(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){p||ua(e);var t=new p(e);if(t.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return t}},{from:"string",to:"number",convert:function(e){var t=Number(e);if(isNaN(t))throw new Error('Cannot convert "'+e+'" to a number');return t}},{from:"string",to:"BigNumber",convert:function(e){t||oa(e);try{return new t(e)}catch(t){throw new Error('Cannot convert "'+e+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(e){p||ua(e);try{return new p(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(e){r||sa(e);try{return new r(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return t||oa(e),new t(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return p||ua(e),new p(+e)}},{from:"boolean",to:"string",convert:function(e){return String(e)}},{from:"Array",to:"Matrix",convert:function(e){return n||function(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}(),new n(e)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}],L}));function oa(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function sa(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function ua(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var ca="isInteger",la=W(ca,["typed"],(e=>{var{typed:t}=e;return t(ca,{number:ce,BigNumber:function(e){return e.isInt()},Fraction:function(e){return 1===e.d&&isFinite(e.n)},"Array | Matrix":function(e){return $t(e,this)}})})),fa="isNumeric",pa=W(fa,["typed"],(e=>{var{typed:t}=e;return t(fa,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(e){return $t(e,this)}})})),ma="number";function ha(e){return e<0}function da(e){return e>0}function ya(e){return 0===e}function ga(e){return Number.isNaN(e)}ha.signature=ma,da.signature=ma,ya.signature=ma,ga.signature=ma;var va="isPositive",xa=W(va,["typed"],(e=>{var{typed:t}=e;return t(va,{number:da,BigNumber:function(e){return!e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s>0&&e.n>0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),ba="isNaN",wa=W(ba,["typed"],(e=>{var{typed:t}=e;return t(ba,{number:ga,BigNumber:function(e){return e.isNaN()},Fraction:function(e){return!1},Complex:function(e){return e.isNaN()},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":function(e){return $t(e,Number.isNaN)}})}));function Na(e,t,r){if(null==r)return e.eq(t);if(e.eq(t))return!0;if(e.isNaN()||t.isNaN())return!1;if(e.isFinite()&&t.isFinite()){var n=e.minus(t).abs();if(n.isZero())return!0;var i=e.constructor.max(e.abs(),t.abs());return n.lte(i.times(r))}return!1}var Ma="equalScalar",Sa=W(Ma,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(Ma,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return e.equals(t)},"Complex, Complex":function(e,t){return function(e,t,r){return Se(e.re,t.re,r)&&Se(e.im,t.im,r)}(e,t,r.epsilon)},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)}})}));W(Ma,["typed","config"],(e=>{var{typed:t,config:r}=e;return t(Ma,{"number, number":function(e,t){return Se(e,t,r.epsilon)}})}));var Ea=W("number",["typed"],(e=>{var{typed:t}=e,r=t("number",{"":function(){return 0},number:function(e){return e},string:function(e){if("NaN"===e)return NaN;var t,r,n=(r=(t=e).match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/))?{input:t,radix:{"0b":2,"0o":8,"0x":16}[r[1]],integerPart:r[2],fractionalPart:r[3]}:null;if(n)return function(e){for(var t=parseInt(e.integerPart,e.radix),r=0,n=0;n2**i-1)throw new SyntaxError('String "'.concat(e,'" is out of range'));o>=2**(i-1)&&(o-=2**i)}return o},BigNumber:function(e){return e.toNumber()},Fraction:function(e){return e.valueOf()},Unit:function(e){throw new Error("Second argument with valueless unit expected")},null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":function(e){return $t(e,this)}});return r.fromJSON=function(e){return parseFloat(e.value)},r})),Aa="boolean",Oa=W(Aa,["typed"],(e=>{var{typed:t}=e;return t(Aa,{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(e){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;var r=Number(e);if(""!==e&&!isNaN(r))return!!r;throw new Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":function(e){return $t(e,this)}})})),Ca=W("complex",["typed","Complex"],(e=>{var{typed:t,Complex:r}=e;return t("complex",{"":function(){return r.ZERO},number:function(e){return new r(e,0)},"number, number":function(e,t){return new r(e,t)},"BigNumber, BigNumber":function(e,t){return new r(e.toNumber(),t.toNumber())},Fraction:function(e){return new r(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return r(e)},null:function(e){return r(0)},Object:function(e){if("re"in e&&"im"in e)return new r(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new r(e);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(e){return $t(e,this)}})})),_a="splitUnit",Ta=W(_a,["typed"],(e=>{var{typed:t}=e;return t(_a,{"Unit, Array":function(e,t){return e.splitUnit(t)}})})),Ba="number",qa="number, number";function za(e){return Math.abs(e)}function Da(e,t){return e+t}function Ia(e,t){return e*t}function ka(e){return-e}function Ra(e){return e}function Fa(e){return he(e)}function Ua(e){return Math.ceil(e)}function Pa(e){return e*e*e}function ja(e){return Math.exp(e)}function La(e){return de(e)}function Ha(e,t){if(!ce(e)||!ce(t))throw new Error("Parameters in function gcd must be integer numbers");for(var r;0!==t;)r=e%t,e=t,t=r;return e<0?-e:e}function $a(e,t){if(!ce(e)||!ce(t))throw new Error("Parameters in function lcm must be integer numbers");if(0===e||0===t)return 0;for(var r,n=e*t;0!==t;)t=e%(r=t),e=r;return Math.abs(n/e)}function Ga(e){return Math.log(e)}function Za(e){return pe(e)}function Va(e){return fe(e)}function Wa(e,t){if(t>0)return e-t*Math.floor(e/t);if(0===t)return e;throw new Error("Cannot calculate mod for a negative divisor")}function Ja(e,t){var r=t<0;if(r&&(t=-t),0===t)throw new Error("Root must be non-zero");if(e<0&&Math.abs(t)%2!=1)throw new Error("Root must be odd when a is negative.");if(0===e)return r?1/0:0;if(!isFinite(e))return r?0:e;var n=Math.pow(Math.abs(e),1/t);return n=e<0?-n:n,r?1/n:n}function Ya(e){return le(e)}function Xa(e){return e*e}function Qa(e,t){var r,n,i,a=0,o=1,s=1,u=0;if(!ce(e)||!ce(t))throw new Error("Parameters in function xgcd must be integer numbers");for(;t;)i=e-(n=Math.floor(e/t))*t,r=a,a=o-n*a,o=r,r=s,s=u-n*s,u=r,e=t,t=i;return e<0?[-e,-o,-u]:[e,e?o:0,u]}function Ka(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:Math.pow(e,t)}function eo(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return parseFloat(xe(e,t))}za.signature=Ba,Da.signature=qa,Ia.signature=qa,ka.signature=Ba,Ra.signature=Ba,Fa.signature=Ba,Ua.signature=Ba,Pa.signature=Ba,ja.signature=Ba,La.signature=Ba,Ha.signature=qa,$a.signature=qa,Ga.signature=Ba,Za.signature=Ba,Va.signature=Ba,Wa.signature=qa,Ja.signature=qa,Ya.signature=Ba,Xa.signature=Ba,Qa.signature=qa,Ka.signature=qa,eo.signature=qa;var to="unaryPlus",ro=W(to,["typed","config","BigNumber"],(e=>{var{typed:t,config:r,BigNumber:n}=e;return t(to,{number:Ra,Complex:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":function(e){return $t(e,this,!0)},"boolean | string":function(e){return"BigNumber"===r.number?new n(+e):+e}})})),no="cube",io=W(no,["typed"],(e=>{var{typed:t}=e;return t(no,{number:Pa,Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},Fraction:function(e){return e.pow(3)},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.pow(3)}})})),ao="expm1",oo=W(ao,["typed","Complex"],(e=>{var{typed:t,Complex:r}=e;return t(ao,{number:La,Complex:function(e){var t=Math.exp(e.re);return new r(t*Math.cos(e.im)-1,t*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)},"Array | Matrix":function(e){return $t(e,this)}})})),so="log10",uo=W(so,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(so,{number:function(e){return e>=0||r.predictable?Za(e):new n(e,0).log().div(Math.LN10)},Complex:function(e){return new n(e).log().div(Math.LN10)},BigNumber:function(e){return!e.isNegative()||r.predictable?e.log():new n(e.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(e){return $t(e,this)}})})),co=W("multiplyScalar",["typed"],(e=>{var{typed:t}=e;return t("multiplyScalar",{"number, number":Ia,"Complex, Complex":function(e,t){return e.mul(t)},"BigNumber, BigNumber":function(e,t){return e.times(t)},"Fraction, Fraction":function(e,t){return e.mul(t)},"number | Fraction | BigNumber | Complex, Unit":function(e,t){var r=t.clone();return r.value=null===r.value?r._normalize(e):this(r.value,e),r},"Unit, number | Fraction | BigNumber | Complex":function(e,t){var r=e.clone();return r.value=null===r.value?r._normalize(t):this(r.value,t),r},"Unit, Unit":function(e,t){return e.multiply(t)}})})),lo="sign",fo=W(lo,["typed","BigNumber","Fraction","complex"],(e=>{var{typed:t,BigNumber:r,complex:n,Fraction:i}=e;return t(lo,{number:Ya,Complex:function(e){return 0===e.im?n(Ya(e.re)):e.sign()},BigNumber:function(e){return new r(e.cmp(0))},Fraction:function(e){return new i(e.s,1)},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return this(e.value)}})})),po="square",mo=W(po,["typed"],(e=>{var{typed:t}=e;return t(po,{number:Xa,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},Fraction:function(e){return e.mul(e)},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.pow(2)}})}));function ho(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitAnd");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero()||t.eq(-1)||e.eq(t))return e;if(t.isZero()||e.eq(-1))return t;if(!e.isFinite()||!t.isFinite()){if(!e.isFinite()&&!t.isFinite())return e.isNegative()===t.isNegative()?e:new r(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new r(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new r(0):e}return vo(e,t,(function(e,t){return e&t}))}function yo(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var t=e.constructor,r=t.precision;t.config({precision:1e9});var n=e.plus(new t(1));return n.s=-n.s||null,t.config({precision:r}),n}function go(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitOr");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);var n=new r(-1);return e.isZero()||t.eq(n)||e.eq(t)?t:t.isZero()||e.eq(n)?e:e.isFinite()&&t.isFinite()?vo(e,t,(function(e,t){return e|t})):!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?n:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e}function vo(e,t,r){var n,i,a,o,s,u=e.constructor,c=+(e.s<0),l=+(t.s<0);if(c){n=xo(yo(e));for(var f=0;f0;)r(a[--m],o[--h])===d&&(y=y.plus(g)),g=g.times(v);for(;h>0;)r(s,o[--h])===d&&(y=y.plus(g)),g=g.times(v);return u.config({precision:x}),0===d&&(y.s=-y.s),y}function xo(e){for(var t=e.d,r=t[0]+"",n=1;n0)if(++s>c)for(s-=c;s--;)u+="0";else s1&&(null!==l[m+1]&&void 0!==l[m+1]||(l[m+1]=0),l[m+1]+=l[m]>>1,l[m]&=1)}return l.reverse()}function bo(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new r(0);var n=new r(-1);return e.eq(n)?yo(t):t.eq(n)?yo(e):e.isFinite()&&t.isFinite()?vo(e,t,(function(e,t){return e^t})):e.isFinite()||t.isFinite()?new r(e.isNegative()===t.isNegative()?1/0:-1/0):n}function wo(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:e.isFinite()||t.isFinite()?t.lt(55)?e.times(Math.pow(2,t.toNumber())+""):e.times(new r(2).pow(t)):new r(NaN)}function No(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(Math.pow(2,t.toNumber())+"").floor():e.div(new r(2).pow(t)).floor():e.isNegative()?new r(-1):e.isFinite()?new r(0):new r(NaN)}var Mo="number, number";function So(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function bitAnd");return e&t}function Eo(e){if(!ce(e))throw new Error("Integer expected in function bitNot");return~e}function Ao(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function bitOr");return e|t}function Oo(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function bitXor");return e^t}function Co(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function leftShift");return e<>t}function To(e,t){if(!ce(e)||!ce(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}So.signature=Mo,Eo.signature="number",Ao.signature=Mo,Oo.signature=Mo,Co.signature=Mo,_o.signature=Mo,To.signature=Mo;var Bo="bitNot",qo=W(Bo,["typed"],(e=>{var{typed:t}=e;return t(Bo,{number:Eo,BigNumber:yo,"Array | Matrix":function(e){return $t(e,this)}})})),zo=W("arg",["typed"],(e=>{var{typed:t}=e;return t("arg",{number:function(e){return Math.atan2(0,e)},BigNumber:function(e){return e.constructor.atan2(0,e)},Complex:function(e){return e.arg()},"Array | Matrix":function(e){return $t(e,this)}})})),Do=W("im",["typed"],(e=>{var{typed:t}=e;return t("im",{number:function(e){return 0},BigNumber:function(e){return e.mul(0)},Fraction:function(e){return e.mul(0)},Complex:function(e){return e.im},"Array | Matrix":function(e){return $t(e,this)}})})),Io="number, number";function ko(e){return!e}function Ro(e,t){return!(!e&&!t)}function Fo(e,t){return!!e!=!!t}function Uo(e,t){return!(!e||!t)}ko.signature="number",Ro.signature=Io,Fo.signature=Io,Uo.signature=Io;var Po=W("not",["typed"],(e=>{var{typed:t}=e;return t("not",{number:ko,Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},Unit:function(e){return null===e.value||this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),jo=W("filter",["typed"],(e=>{var{typed:t}=e;return t("filter",{"Array, function":Lo,"Matrix, function":function(e,t){return e.create(Lo(e.toArray(),t))},"Array, RegExp":it,"Matrix, RegExp":function(e,t){return e.create(it(e.toArray(),t))}})}));function Lo(e,t){var r=Ar(t);return nt(e,(function(e,n,i){return 1===r?t(e):2===r?t(e,[n]):t(e,[n],i)}))}var Ho="forEach",$o=W(Ho,["typed"],(e=>{var{typed:t}=e;return t(Ho,{"Array, function":Go,"Matrix, function":function(e,t){return e.forEach(t)}})}));function Go(e,t){var r=Ar(t);!function n(i,a){Array.isArray(i)?rt(i,(function(e,t){n(e,a.concat(t))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e,[])}var Zo=W("map",["typed"],(e=>{var{typed:t}=e;return t("map",{"Array, function":Vo,"Matrix, function":function(e,t){return e.map(t)}})}));function Vo(e,t){var r=Ar(t);return function n(i,a){return Array.isArray(i)?i.map((function(e,t){return n(e,a.concat(t))})):1===r?t(i):2===r?t(i,a):t(i,a,e)}(e,[])}var Wo=W("erf",["typed"],(e=>{var{typed:t}=e;return t("name",{number:function(e){var t=Math.abs(e);return t>=Ko?le(e):t<=Jo?le(e)*function(e){var t,r=e*e,n=Xo[0][4]*r,i=r;for(t=0;t<3;t+=1)n=(n+Xo[0][t])*r,i=(i+Qo[0][t])*r;return e*(n+Xo[0][3])/(i+Qo[0][3])}(t):t<=4?le(e)*(1-function(e){var t,r=Xo[1][8]*e,n=e;for(t=0;t<7;t+=1)r=(r+Xo[1][t])*e,n=(n+Qo[1][t])*e;var i=(r+Xo[1][7])/(n+Qo[1][7]),a=parseInt(16*e)/16,o=(e-a)*(e+a);return Math.exp(-a*a)*Math.exp(-o)*i}(t)):le(e)*(1-function(e){var t,r=1/(e*e),n=Xo[2][5]*r,i=r;for(t=0;t<4;t+=1)n=(n+Xo[2][t])*r,i=(i+Qo[2][t])*r;var a=r*(n+Xo[2][4])/(i+Qo[2][4]);a=(Yo-a)/e;var o=(e-(r=parseInt(16*e)/16))*(e+r);return Math.exp(-r*r)*Math.exp(-o)*a}(t))},"Array | Matrix":function(e){return $t(e,this)}})})),Jo=.46875,Yo=.5641895835477563,Xo=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],Qo=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],Ko=Math.pow(2,53),es="format",ts=W(es,["typed"],(e=>{var{typed:t}=e;return t(es,{any:De,"any, Object | function | number":De})})),rs=W("oct",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("oct",{"number | BigNumber":function(e){return r(e,{notation:"oct"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"oct",wordSize:t})}})})),ns="print",is=W(ns,["typed"],(e=>{var{typed:t}=e;return t(ns,{"string, Object | Array":as,"string, Object | Array, number | Object":as})}));function as(e,t,r){return e.replace(/\$([\w.]+)/g,(function(e,n){for(var i=n.split("."),a=t[i.shift()];i.length&&void 0!==a;){var o=i.shift();a=o?a[o]:a+"."}return void 0!==a?c(a)?a:De(a,r):e}))}var os="isPrime",ss=W(os,["typed"],(e=>{var{typed:t}=e;return t(os,{number:function(e){if(0*e!=0)return!1;if(e<=3)return e>1;if(e%2==0||e%3==0)return!1;for(var t=5;t*t<=e;t+=6)if(e%t==0||e%(t+2)==0)return!1;return!0},BigNumber:function(e){if(0*e.toNumber()!=0)return!1;if(e.lte(3))return e.gt(1);if(e.mod(2).eq(0)||e.mod(3).eq(0))return!1;if(e.lt(Math.pow(2,32))){for(var t=e.toNumber(),r=5;r*r<=t;r+=6)if(t%r==0||t%(r+2)==0)return!1;return!0}function n(e,t,r){for(var n=1;!t.eq(0);)t.mod(2).eq(0)?(t=t.div(2),e=e.mul(e).mod(r)):(t=t.sub(1),n=e.mul(n).mod(r));return n}for(var i=e.constructor.clone({precision:2*e.toFixed(0).length}),a=0,o=(e=new i(e)).sub(1);o.mod(2).eq(0);)o=o.div(2),a+=1;var s=null;if(e.lt("3317044064679887385961981"))s=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter((t=>t{var{typed:t,config:r,Complex:n}=e;return t(us,{number:function(e){return e>=-1&&e<=1||r.predictable?Math.acos(e):new n(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()},"Array | Matrix":function(e){return $t(e,this)}})})),ls="number";function fs(e){return Ee(e)}function ps(e){return Math.atan(1/e)}function ms(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}function hs(e){return Math.asin(1/e)}function ds(e){var t=1/e;return Math.log(t+Math.sqrt(t*t+1))}function ys(e){return Math.acos(1/e)}function gs(e){var t=1/e,r=Math.sqrt(t*t-1);return Math.log(r+t)}function vs(e){return Ae(e)}function xs(e){return Oe(e)}function bs(e){return 1/Math.tan(e)}function ws(e){var t=Math.exp(2*e);return(t+1)/(t-1)}function Ns(e){return 1/Math.sin(e)}function Ms(e){return 0===e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*le(e)}function Ss(e){return 1/Math.cos(e)}function Es(e){return 2/(Math.exp(e)+Math.exp(-e))}function As(e){return _e(e)}fs.signature=ls,ps.signature=ls,ms.signature=ls,hs.signature=ls,ds.signature=ls,ys.signature=ls,gs.signature=ls,vs.signature=ls,xs.signature=ls,bs.signature=ls,ws.signature=ls,Ns.signature=ls,Ms.signature=ls,Ss.signature=ls,Es.signature=ls,As.signature=ls;var Os="acot",Cs=W(Os,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Os,{number:ps,Complex:function(e){return e.acot()},BigNumber:function(e){return new r(1).div(e).atan()},"Array | Matrix":function(e){return $t(e,this)}})})),_s="acsc",Ts=W(_s,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(_s,{number:function(e){return e<=-1||e>=1||r.predictable?hs(e):new n(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new i(1).div(e).asin()},"Array | Matrix":function(e){return $t(e,this)}})})),Bs="asec",qs=W(Bs,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(Bs,{number:function(e){return e<=-1||e>=1||r.predictable?ys(e):new n(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new i(1).div(e).acos()},"Array | Matrix":function(e){return $t(e,this)}})})),zs="asin",Ds=W(zs,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(zs,{number:function(e){return e>=-1&&e<=1||r.predictable?Math.asin(e):new n(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Is=W("atan",["typed"],(e=>{var{typed:t}=e;return t("atan",{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),ks="atanh",Rs=W(ks,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(ks,{number:function(e){return e<=1&&e>=-1||r.predictable?xs(e):new n(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Fs="cosh",Us=W(Fs,["typed"],(e=>{var{typed:t}=e;return t(Fs,{number:Ce,Complex:function(e){return e.cosh()},BigNumber:function(e){return e.cosh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Ps="coth",js=W(Ps,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Ps,{number:ws,Complex:function(e){return e.coth()},BigNumber:function(e){return new r(1).div(e.tanh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Ls="csch",Hs=W(Ls,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Ls,{number:Ms,Complex:function(e){return e.csch()},BigNumber:function(e){return new r(1).div(e.sinh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),$s="sech",Gs=W($s,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t($s,{number:Es,Complex:function(e){return e.sech()},BigNumber:function(e){return new r(1).div(e.cosh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Zs="sinh",Vs=W(Zs,["typed"],(e=>{var{typed:t}=e;return t(Zs,{number:As,Complex:function(e){return e.sinh()},BigNumber:function(e){return e.sinh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Ws=W("tanh",["typed"],(e=>{var{typed:t}=e;return t("tanh",{number:Te,Complex:function(e){return e.tanh()},BigNumber:function(e){return e.tanh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})}));function Js(e,t){if(t>1;return Js(e,r)*Js(r+1,t)}function Ys(e,t){if(!ce(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!ce(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(t>e)throw new TypeError("k must be less than or equal to n");var r=e-t;return t{var{typed:t}=e;return t(Xs,{"number, number":Ys,"BigNumber, BigNumber":function(e,t){var r,n,i=e.constructor,a=e.minus(t),o=new i(1);if(!Ks(e)||!Ks(t))throw new TypeError("Positive integer value expected in function combinations");if(t.gt(e))throw new TypeError("k must be less than n in function combinations");if(r=o,t.lt(a))for(n=o;n.lte(a);n=n.plus(o))r=r.times(t.plus(n)).dividedBy(n);else for(n=o;n.lte(t);n=n.plus(o))r=r.times(a.plus(n)).dividedBy(n);return r}})}));function Ks(e){return e.isInteger()&&e.gte(0)}var eu=r(377),tu=eu(Date.now());function ru(e){var t,r;return t=null===(r=e)?tu:eu(String(r)),function(){return t()}}var nu="pickRandom",iu=W(nu,["typed","config","?on"],(e=>{var{typed:t,config:r,on:n}=e,a=ru(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(a=ru(e.randomSeed))})),t(nu,{"Array | Matrix":function(e){return o(e,{})},"Array | Matrix, Object":function(e,t){return o(e,t)},"Array | Matrix, number":function(e,t){return o(e,{number:t})},"Array | Matrix, Array | Matrix":function(e,t){return o(e,{weights:t})},"Array | Matrix, Array | Matrix, number":function(e,t,r){return o(e,{number:r,weights:t})},"Array | Matrix, number, Array | Matrix":function(e,t,r){return o(e,{number:t,weights:r})}});function o(e,t){var{number:r,weights:n,elementWise:o=!0}=t,s=void 0===r;s&&(r=1);var u=f(e)?e.create:f(n)?n.create:null;e=e.valueOf(),n&&(n=n.valueOf()),!0===o&&(e=et(e),n=et(n));var c=0;if(void 0!==n){if(n.length!==e.length)throw new Error("Weights must have the same length as possibles");for(var l=0,p=n.length;l1)for(var n=0,i=e.shift();n{var{typed:t,config:r,on:n}=e,i=ru(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(i=ru(e.randomSeed))})),t(ou,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,t)=>o(e,t),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,t)=>a(e,0,t),"Array | Matrix, number, number":(e,t,r)=>a(e,t,r)});function a(e,t,r){var n=au(e.valueOf(),(()=>o(t,r)));return f(e)?e.create(n):n}function o(e,t){return Math.floor(e+i()*(t-e))}})),uu="clone",cu=W(uu,["typed"],(e=>{var{typed:t}=e;return t(uu,{any:$})})),lu="hasNumericValue",fu=W(lu,["typed","isNumeric"],(e=>{var{typed:t,isNumeric:r}=e;return t(lu,{string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return r(e)}})})),pu="typeOf",mu=W(pu,["typed"],(e=>{var{typed:t}=e;return t(pu,{any:L})})),hu="string",du=W(hu,["typed"],(e=>{var{typed:t}=e;return t(hu,{"":function(){return""},number:ge,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":function(e){return $t(e,this)},any:function(e){return String(e)}})})),yu=W("fraction",["typed","Fraction"],(e=>{var{typed:t,Fraction:r}=e;return t("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw new Error(e+" cannot be represented as a fraction");return new r(e)},string:function(e){return new r(e)},"number, number":function(e,t){return new r(e,t)},null:function(e){return new r(0)},BigNumber:function(e){return new r(e.toString())},Fraction:function(e){return e},Object:function(e){return new r(e)},"Array | Matrix":function(e){return $t(e,this)}})})),gu="unaryMinus",vu=W(gu,["typed"],(e=>{var{typed:t}=e;return t(gu,{number:ka,Complex:function(e){return e.neg()},BigNumber:function(e){return e.neg()},Fraction:function(e){return e.neg()},Unit:function(e){var t=e.clone();return t.value=this(e.value),t},"Array | Matrix":function(e){return $t(e,this,!0)}})})),xu="addScalar",bu=W(xu,["typed"],(e=>{var{typed:t}=e;return t(xu,{"number, number":Da,"Complex, Complex":function(e,t){return e.add(t)},"BigNumber, BigNumber":function(e,t){return e.plus(t)},"Fraction, Fraction":function(e,t){return e.add(t)},"Unit, Unit":function(e,t){if(null===e.value||void 0===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value||void 0===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var r=e.clone();return r.value=this(r.value,t.value),r.fixPrefix=!1,r}})})),wu=W("exp",["typed"],(e=>{var{typed:t}=e;return t("exp",{number:ja,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()},"Array | Matrix":function(e){return $t(e,this)}})})),Nu="log2",Mu=W(Nu,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(Nu,{number:function(e){return e>=0||r.predictable?Va(e):i(new n(e,0))},Complex:i,BigNumber:function(e){return!e.isNegative()||r.predictable?e.log(2):i(new n(e.toNumber(),0))},"Array | Matrix":function(e){return $t(e,this)}});function i(e){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new n(Math.log2?Math.log2(t):Math.log(t)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}})),Su=W("sqrt",["config","typed","Complex"],(e=>{var{config:t,typed:r,Complex:n}=e;return r("sqrt",{number:i,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.sqrt():i(e.toNumber())},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.pow(.5)}});function i(e){return isNaN(e)?NaN:e>=0||t.predictable?Math.sqrt(e):new n(e,0).sqrt()}})),Eu="conj",Au=W(Eu,["typed"],(e=>{var{typed:t}=e;return t(Eu,{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.conjugate()},"Array | Matrix":function(e){return $t(e,this)}})})),Ou="getMatrixDataType",Cu=W(Ou,["typed"],(e=>{var{typed:t}=e;return t(Ou,{Array:function(e){return ut(e,L)},Matrix:function(e){return e.getDataType()}})})),_u="mode",Tu=W(_u,["typed","isNaN","isNumeric"],(e=>{var{typed:t,isNaN:r,isNumeric:n}=e;return t(_u,{"Array | Matrix":i,"...":function(e){return i(e)}});function i(e){if(0===(e=et(e.valueOf())).length)throw new Error("Cannot calculate mode of an empty array");for(var t={},i=[],a=0,o=0;oa&&(a=t[s],i=[s])}return i}})),Bu=W("bin",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("bin",{"number | BigNumber":function(e){return r(e,{notation:"bin"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"bin",wordSize:t})}})})),qu="acosh",zu=W(qu,["typed","config","Complex"],(e=>{var{typed:t,config:r,Complex:n}=e;return t(qu,{number:function(e){return e>=1||r.predictable?fs(e):e<=-1?new n(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new n(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()},"Array | Matrix":function(e){return $t(e,this)}})})),Du="acsch",Iu=W(Du,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t(Du,{number:ds,Complex:function(e){return e.acsch()},BigNumber:function(e){return new r(1).div(e).asinh()},"Array | Matrix":function(e){return $t(e,this)}})})),ku=W("asinh",["typed"],(e=>{var{typed:t}=e;return t("asinh",{number:vs,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Ru=W("cos",["typed"],(e=>{var{typed:t}=e;return t("cos",{number:Math.cos,Complex:function(e){return e.cos()},BigNumber:function(e){return e.cos()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Fu=W("csc",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("csc",{number:Ns,Complex:function(e){return e.csc()},BigNumber:function(e){return new r(1).div(e.sin())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Uu=W("sin",["typed"],(e=>{var{typed:t}=e;return t("sin",{number:Math.sin,Complex:function(e){return e.sin()},BigNumber:function(e){return e.sin()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Pu="combinationsWithRep",ju=W(Pu,["typed"],(e=>{var{typed:t}=e;return t(Pu,{"number, number":function(e,t){if(!ce(e)||e<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!ce(t)||t<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e<1)throw new TypeError("k must be less than or equal to n + k - 1");return t{var{typed:t,config:r,on:n}=e,i=ru(r.randomSeed);return n&&n("config",(function(e,t){e.randomSeed!==t.randomSeed&&(i=ru(e.randomSeed))})),t(Hu,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,t)=>o(e,t),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,t)=>a(e,0,t),"Array | Matrix, number, number":(e,t,r)=>a(e,t,r)});function a(e,t,r){var n=au(e.valueOf(),(()=>o(t,r)));return f(e)?e.create(n):n}function o(e,t){return e+i()*(t-e)}})),Gu="isNegative",Zu=W(Gu,["typed"],(e=>{var{typed:t}=e;return t(Gu,{number:ha,BigNumber:function(e){return e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s<0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),Vu=W("SparseMatrix",["typed","equalScalar","Matrix"],(e=>{var{typed:t,equalScalar:r,Matrix:n}=e;function o(e,t){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!c(t))throw new Error("Invalid datatype: "+t);if(f(e))!function(e,t,r){"SparseMatrix"===t.type?(e._values=t._values?$(t._values):void 0,e._index=$(t._index),e._ptr=$(t._ptr),e._size=$(t._size),e._datatype=r||t._datatype):s(e,t.valueOf(),r||t._datatype)}(this,e,t);else if(e&&l(e.index)&&l(e.ptr)&&l(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=t||e.datatype;else if(l(e))s(this,e,t);else{if(e)throw new TypeError("Unsupported type of data ("+L(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=t}}function s(e,n,i){e._values=[],e._index=[],e._ptr=[],e._datatype=i;var a=n.length,o=0,s=r,u=0;if(c(i)&&(s=t.find(r,[i,i])||r,u=t.convert(0,i)),a>0){var f=0;do{e._ptr.push(e._index.length);for(var p=0;p");for(var c=t.min()[0],l=t.min()[1],p=i[0],m=i[1],h=0;hd){for(f=d;fh){if(m){var y=0;for(f=0;fn-1&&(e._values.splice(p,1),e._index.splice(p,1),v++)}e._ptr[f]=e._values.length}return e._size[0]=n,e._size[1]=i,e}function v(e,t,r,n,i){var a,o,s=n[0],u=n[1],c=[];for(a=0;as-1||o>u-1)&&(g(this,Math.max(a+1,s),Math.max(o+1,u),i),s=this._size[0],u=this._size[1]),$e(a,s),$e(o,u);var m=h(a,this._ptr[o],this._ptr[o+1],this._index);return mArray.isArray(e)&&1===e.length?e[0]:e));if(2!==n.length)throw new Error("Only two dimensions matrix are supported");return n.forEach((function(e){if(!i(e)||!ce(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+De(n)+")")})),g(r?this.clone():this,n[0],n[1],t)},o.prototype.reshape=function(e,t){if(!l(e))throw new TypeError("Array expected");if(2!==e.length)throw new Error("Sparse matrices can only be reshaped in two dimensions");e.forEach((function(t){if(!i(t)||!ce(t)||t<=-2||0===t)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+De(e)+")")}));var r=this._size[0]*this._size[1];if(r!==(e=We(e,r))[0]*e[1])throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var n=t?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return n;for(var a=[],o=0;o=0&&w<=i&&y(e._values[b],w-0,g-0)}else{for(var N={},M=v;M "+(this._values?De(this._values[u],e):"X");return i},o.prototype.toString=function(){return De(this.toArray())},o.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},o.prototype.diagonal=function(e){if(e){if(a(e)&&(e=e.toNumber()),!i(e)||!ce(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var t=e>0?e:0,r=e<0?-e:0,n=this._size[0],s=this._size[1],u=Math.min(n-r,s-t),c=[],l=[],f=[];f[0]=0;for(var p=t;p0?s:0,g=s<0?-s:0,v=e[0],x=e[1],b=Math.min(v-g,x-y);if(l(n)){if(n.length!==b)throw new Error("Invalid value array length");d=function(e){return n[e]}}else if(f(n)){var w=n.size();if(1!==w.length||w[0]!==b)throw new Error("Invalid matrix length");d=function(e){return n.get([e])}}else d=function(){return n};for(var N=[],M=[],S=[],E=0;E=0&&A=u||i[l]!==t)){var p=n?n[c]:void 0;i.splice(l,0,t),n&&n.splice(l,0,p),i.splice(l<=c?c+1:c,1),n&&n.splice(l<=c?c+1:c,1)}else if(l=u||i[c]!==e)){var m=n?n[l]:void 0;i.splice(c,0,e),n&&n.splice(c,0,m),i.splice(c<=l?l+1:l,1),n&&n.splice(c<=l?l+1:l,1)}}},o}),{isClass:!0}),Wu="matrix",Ju=W(Wu,["typed","Matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,Matrix:r,DenseMatrix:n,SparseMatrix:i}=e;return t(Wu,{"":function(){return a([])},string:function(e){return a([],e)},"string, string":function(e,t){return a([],e,t)},Array:function(e){return a(e)},Matrix:function(e){return a(e,e.storage())},"Array | Matrix, string":a,"Array | Matrix, string, string":a});function a(e,t,r){if("dense"===t||"default"===t||void 0===t)return new n(e,r);if("sparse"===t)return new i(e,r);throw new TypeError("Unknown matrix type "+JSON.stringify(t)+".")}})),Yu=W("abs",["typed"],(e=>{var{typed:t}=e;return t("abs",{number:za,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},Fraction:function(e){return e.abs()},"Array | Matrix":function(e){return $t(e,this,!0)},Unit:function(e){return e.abs()}})})),Xu=W("algorithm01",["typed"],(e=>{var{typed:t}=e;return function(e,r,n,i){var a=e._data,o=e._size,s=e._datatype,u=r._values,c=r._index,l=r._ptr,f=r._size,p=r._datatype;if(o.length!==f.length)throw new Ue(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m,h,d=o[0],y=o[1],g="string"==typeof s&&s===p?s:void 0,v=g?t.find(n,[g,g]):n,x=[];for(m=0;m{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E,A=a&&l?[]:void 0,O=[],C=[],_=a&&l?[]:void 0,T=a&&l?[]:void 0,B=[],q=[];for(N=0;N{var{typed:t,DenseMatrix:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=i;"string"==typeof l&&(f=l,n=t.convert(n,f),h=t.find(i,[f,f]));for(var d=[],y=[],g=[],v=0;v{var{typed:t}=e;return function(e,n,i){var a,o=e._data,s=e._size,u=e._datatype,c=n._data,l=n._size,f=n._datatype,p=[];if(s.length!==l.length)throw new Ue(s.length,l.length);for(var m=0;m0?r(h,0,p,p[0],o,c):[];return e.createDenseMatrix({data:d,size:p,datatype:a})};function r(e,t,n,i,a,o){var s=[];if(t===n.length-1)for(var u=0;u{var{typed:t}=e;return function(e,n,i,a){var o,s=e._data,u=e._size,c=e._datatype,l=i;"string"==typeof c&&(o=c,n=t.convert(n,o),l=t.find(i,[o,o]));var f=u.length>0?r(l,0,u,u[0],s,n,a):[];return e.createDenseMatrix({data:f,size:$(u),datatype:o})};function r(e,t,n,i,a,o,s){var u=[];if(t===n.length-1)for(var c=0;c{var{typed:t,matrix:r,equalScalar:n,BigNumber:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=Qu({typed:t,equalScalar:n}),u=Ku({typed:t,DenseMatrix:a}),c=ec({typed:t}),l=tc({typed:t});return t("gcd",{"number, number":Ha,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var r=new i(0);!t.isZero();){var n=e.mod(t);e=t,t=n}return e.lt(r)?e.neg():e},"Fraction, Fraction":function(e,t){return e.gcd(t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return u(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return l(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return l(r(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,equalScalar:r}=e;return function(e,n,i,a){var o=e._data,s=e._size,u=e._datatype,c=n._values,l=n._index,f=n._ptr,p=n._size,m=n._datatype;if(s.length!==p.length)throw new Ue(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h,d=s[0],y=s[1],g=r,v=0,x=i;"string"==typeof u&&u===m&&(h=u,g=t.find(r,[h,h]),v=t.convert(0,h),x=t.find(i,[h,h]));for(var b=[],w=[],N=[],M=0;M{var{typed:t}=e;return function(e,r,n,i){var a=e._data,o=e._size,s=e._datatype,u=r._values,c=r._index,l=r._ptr,f=r._size,p=r._datatype;if(o.length!==f.length)throw new Ue(o.length,f.length);if(o[0]!==f[0]||o[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+f+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m,h=o[0],d=o[1],y=0,g=n;"string"==typeof s&&s===p&&(m=s,y=t.convert(0,m),g=t.find(n,[m,m]));for(var v=[],x=0;x{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E=a&&l?[]:void 0,A=[],O=[],C=E?[]:void 0,_=E?[]:void 0,T=[],B=[];for(N=0;N{var{typed:t,equalScalar:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=r,d=0,y=i;"string"==typeof l&&(f=l,h=t.find(r,[f,f]),d=t.convert(0,f),n=t.convert(n,f),y=t.find(i,[f,f]));for(var g=[],v=[],x=[],b=0;b{var{typed:t,DenseMatrix:r}=e;return function(e,n,i,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,l=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var f,p=c[0],m=c[1],h=i;"string"==typeof l&&(f=l,n=t.convert(n,f),h=t.find(i,[f,f]));for(var d=[],y=[],g=[],v=0;v{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=nc({typed:t,equalScalar:n}),o=ic({typed:t}),s=ac({typed:t,equalScalar:n}),u=oc({typed:t,equalScalar:n}),c=sc({typed:t,DenseMatrix:i}),l=ec({typed:t}),f=tc({typed:t});return t("mod",{"number, number":Wa,"BigNumber, BigNumber":function(e,t){if(t.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return t.isZero()?e:e.mod(t)},"Fraction, Fraction":function(e,t){if(t.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return e.compare(0)>=0?e.mod(t):e.mod(t).add(t).mod(t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return f(e,t,this,!1)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return f(t,e,this,!0)},"Array, any":function(e,t){return f(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return f(r(t),e,this,!0).valueOf()}})})),cc=W("algorithm06",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._size,s=e._datatype,u=n._values,c=n._size,l=n._datatype;if(o.length!==c.length)throw new Ue(o.length,c.length);if(o[0]!==c[0]||o[1]!==c[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+c+")");var f,p=o[0],m=o[1],h=r,d=0,y=i;"string"==typeof s&&s===l&&(f=s,h=t.find(r,[f,f]),d=t.convert(0,f),y=t.find(i,[f,f]));for(var g=a&&u?[]:void 0,v=[],x=[],b=g?[]:void 0,w=[],N=[],M=0;M{var{typed:t,matrix:r,equalScalar:n,BigNumber:i}=e,a=Xu({typed:t}),o=nc({typed:t,equalScalar:n}),s=cc({typed:t,equalScalar:n}),u=oc({typed:t,equalScalar:n}),c=ec({typed:t}),l=tc({typed:t}),f="Complex number not supported in function nthRoot. Use nthRoots instead.";return t(lc,{number:function(e){return Ja(e,2)},"number, number":Ja,BigNumber:function(e){return p(e,new i(2))},Complex:function(e){throw new Error(f)},"Complex, number":function(e,t){throw new Error(f)},"BigNumber, BigNumber":p,"Array | Matrix":function(e){return this(e,2)},"SparseMatrix, SparseMatrix":function(e,t){if(1===t.density())return s(e,t,this);throw new Error("Root must be non-zero")},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){if(1===t.density())return a(e,t,this,!1);throw new Error("Root must be non-zero")},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){if(1===t.density())return u(t,e,this,!0);throw new Error("Root must be non-zero")},"number | BigNumber, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}});function p(e,t){var r=i.precision,n=i.clone({precision:r+2}),a=new i(0),o=new n(1),s=t.isNegative();if(s&&(t=t.neg()),t.isZero())throw new Error("Root must be non-zero");if(e.isNegative()&&!t.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(e.isZero())return s?new n(1/0):0;if(!e.isFinite())return s?a:e;var u=e.abs().pow(o.div(t));return u=e.isNeg()?u.neg():u,new i((s?o.div(u):u).toPrecision(r))}})),pc="xgcd",mc=W(pc,["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t(pc,{"number, number":function(e,t){var i=Qa(e,t);return"Array"===r.matrix?i:n(i)},"BigNumber, BigNumber":function(e,t){var a,o,s,u,c=new i(0),l=new i(1),f=c,p=l,m=l,h=c;if(!e.isInt()||!t.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!t.isZero();)o=e.div(t).floor(),s=e.mod(t),a=f,f=p.minus(o.times(f)),p=a,a=m,m=h.minus(o.times(m)),h=a,e=t,t=s;return u=e.lt(c)?[e.neg(),p.neg(),h.neg()]:[e,e.isZero()?0:p,h],"Array"===r.matrix?u:n(u)}})})),hc="bitAnd",dc=W(hc,["typed","matrix","equalScalar"],(e=>{var{typed:t,matrix:r,equalScalar:n}=e,i=nc({typed:t,equalScalar:n}),a=cc({typed:t,equalScalar:n}),o=oc({typed:t,equalScalar:n}),s=ec({typed:t}),u=tc({typed:t});return t(hc,{"number, number":So,"BigNumber, BigNumber":ho,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),yc=W("algorithm07",["typed","DenseMatrix"],(e=>{var{typed:t,DenseMatrix:r}=e;return function(e,i,a){var o=e._size,s=e._datatype,u=i._size,c=i._datatype;if(o.length!==u.length)throw new Ue(o.length,u.length);if(o[0]!==u[0]||o[1]!==u[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+u+")");var l,f,p,m=o[0],h=o[1],d=0,y=a;"string"==typeof s&&s===c&&(l=s,d=t.convert(0,l),y=t.find(a,[l,l]));var g=[];for(f=0;f{var{typed:t,matrix:r,DenseMatrix:n}=e,i=ic({typed:t}),a=yc({typed:t,DenseMatrix:n}),o=sc({typed:t,DenseMatrix:n}),s=ec({typed:t}),u=tc({typed:t});return t(gc,{"number, number":Oo,"BigNumber, BigNumber":bo,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),xc=W("or",["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=ic({typed:t}),o=ac({typed:t,equalScalar:n}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t("or",{"number, number":Ro,"Complex, Complex":function(e,t){return 0!==e.re||0!==e.im||0!==t.re||0!==t.im},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!e.isNaN()||!t.isZero()&&!t.isNaN()},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})})),bc="diag",wc=W(bc,["typed","matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:r,DenseMatrix:n,SparseMatrix:i}=e;return t(bc,{Array:function(e){return a(e,0,je(e),null)},"Array, number":function(e,t){return a(e,t,je(e),null)},"Array, BigNumber":function(e,t){return a(e,t.toNumber(),je(e),null)},"Array, string":function(e,t){return a(e,0,je(e),t)},"Array, number, string":function(e,t,r){return a(e,t,je(e),r)},"Array, BigNumber, string":function(e,t,r){return a(e,t.toNumber(),je(e),r)},Matrix:function(e){return a(e,0,e.size(),e.storage())},"Matrix, number":function(e,t){return a(e,t,e.size(),e.storage())},"Matrix, BigNumber":function(e,t){return a(e,t.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,t){return a(e,0,e.size(),t)},"Matrix, number, string":function(e,t,r){return a(e,t,e.size(),r)},"Matrix, BigNumber, string":function(e,t,r){return a(e,t.toNumber(),e.size(),r)}});function a(e,t,a,o){if(!ce(t))throw new TypeError("Second parameter in function diag must be an integer");var s=t>0?t:0,u=t<0?-t:0;switch(a.length){case 1:return function(e,t,r,a,o,s){var u=[a+o,a+s];if(r&&"sparse"!==r&&"dense"!==r)throw new TypeError("Unknown matrix type ".concat(r,'"'));var c="sparse"===r?i.diagonal(u,e,t):n.diagonal(u,e,t);return null!==r?c:c.valueOf()}(e,t,o,a[0],u,s);case 2:return function(e,t,n,i,a,o){if(f(e)){var s=e.diagonal(t);return null!==n?n!==s.storage()?r(s,n):s:s.valueOf()}for(var u=Math.min(i[0]-a,i[1]-o),c=[],l=0;l{var{typed:t,config:r,matrix:n,BigNumber:i,DenseMatrix:o,SparseMatrix:s}=e;return t(Nc,{"":function(){return"Matrix"===r.matrix?n([]):[]},string:function(e){return n(e)},"number | BigNumber":function(e){return c(e,e,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, string":function(e,t){return c(e,e,t)},"number | BigNumber, number | BigNumber":function(e,t){return c(e,t,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(e,t,r){return c(e,t,r)},Array:function(e){return u(e)},"Array, string":function(e,t){return u(e,t)},Matrix:function(e){return u(e.valueOf(),e.storage())},"Matrix, string":function(e,t){return u(e.valueOf(),t)}});function u(e,t){switch(e.length){case 0:return t?n(t):[];case 1:return c(e[0],e[0],t);case 2:return c(e[0],e[1],t);default:throw new Error("Vector containing two values expected")}}function c(e,t,r){var n=a(e)||a(t)?i:null;if(a(e)&&(e=e.toNumber()),a(t)&&(t=t.toNumber()),!ce(e)||e<1)throw new Error("Parameters in function identity must be positive integers");if(!ce(t)||t<1)throw new Error("Parameters in function identity must be positive integers");var u=n?new i(1):1,c=n?new n(0):0,l=[e,t];if(r){if("sparse"===r)return s.diagonal(l,u,0,c);if("dense"===r)return o.diagonal(l,u,0,c);throw new TypeError('Unknown matrix type "'.concat(r,'"'))}for(var f=Ge([],l,c),p=e{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t("ones",{"":function(){return"Array"===r.matrix?o([]):o([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return o(e,t)}return"Array"===r.matrix?o(e):o(e,"default")},Array:o,Matrix:function(e){var t=e.storage();return o(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return o(e.valueOf(),t)}});function o(e,t){var r=function(e){var t=!1;return e.forEach((function(e,r,n){a(e)&&(t=!0,n[r]=e.toNumber())})),t}(e)?new i(1):1;if(function(e){e.forEach((function(e){if("number"!=typeof e||!ce(e)||e<0)throw new Error("Parameters in function ones must be positive integers")}))}(e),t){var o=n(t);return e.length>0?o.resize(e,r):o}var s=[];return e.length>0?Ge(s,e,r):s}})),Ec="reshape",Ac=W(Ec,["typed","isInteger","matrix"],(e=>{var{typed:t,isInteger:r}=e;return t(Ec,{"Matrix, Array":function(e,t){return e.reshape(t)},"Array, Array":function(e,t){return t.forEach((function(e){if(!r(e))throw new TypeError("Invalid size for dimension: "+e)})),Ve(e,t)}})})),Oc="size",Cc=W(Oc,["typed","config","?matrix"],(e=>{var{typed:t,config:r,matrix:n}=e;return t(Oc,{Matrix:function(e){return e.create(e.size())},Array:je,string:function(e){return"Array"===r.matrix?[e.length]:n([e.length])},"number | Complex | BigNumber | Unit | boolean | null":function(e){return"Array"===r.matrix?[]:n?n([]):nr()}})})),_c="zeros",Tc=W(_c,["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:r,matrix:n,BigNumber:i}=e;return t(_c,{"":function(){return"Array"===r.matrix?o([]):o([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return o(e,t)}return"Array"===r.matrix?o(e):o(e,"default")},Array:o,Matrix:function(e){var t=e.storage();return o(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return o(e.valueOf(),t)}});function o(e,t){var r=function(e){var t=!1;return e.forEach((function(e,r,n){a(e)&&(t=!0,n[r]=e.toNumber())})),t}(e)?new i(0):0;if(function(e){e.forEach((function(e){if("number"!=typeof e||!ce(e)||e<0)throw new Error("Parameters in function zeros must be positive integers")}))}(e),t){var o=n(t);return e.length>0?o.resize(e,r):o}var s=[];return e.length>0?Ge(s,e,r):s}})),Bc=W("hex",["typed","format"],(e=>{var{typed:t,format:r}=e;return t("hex",{"number | BigNumber":function(e){return r(e,{notation:"hex"})},"number | BigNumber, number":function(e,t){return r(e,{notation:"hex",wordSize:t})}})}));function qc(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function zc(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Dc(e){for(var t=1;t{var{typed:t,matrix:r,equalScalar:n,zeros:i,BigNumber:a,DenseMatrix:o}=e,s=oc({typed:t,equalScalar:n}),u=sc({typed:t,DenseMatrix:o}),c=tc({typed:t});return t(kc,Dc(Dc({},Fc),{},{Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw new TypeError(Ic);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(Ic);var r=t.toNumber();return e.round(r)},"number, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(Ic);return new a(e).toDecimalPlaces(t.toNumber())},BigNumber:function(e){return e.toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(Ic);return e.toDecimalPlaces(t.toNumber())},Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw new TypeError(Ic);return e.round(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"SparseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | Complex | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):u(t,e,this,!0)},"number | Complex | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return c(r(e),t,this,!1).valueOf()},"number | Complex | BigNumber, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}}))})),Fc={number:eo,"number, number":function(e,t){if(!ce(t))throw new TypeError(Ic);if(t<0||t>15)throw new Error("Number of decimals in function round must be in the range of 0-15");return eo(e,t)}},Uc=W("algorithm08",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");if(!a||!l)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));for(var w,N,M,S,E=[],A=[],O=[],C=[],_=[],T=0;T{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=nc({typed:t,equalScalar:n}),u=Uc({typed:t,equalScalar:n}),c=Ku({typed:t,DenseMatrix:a}),l=oc({typed:t,equalScalar:n}),f=ec({typed:t}),p=tc({typed:t});return t(Pc,{"number, number":Co,"BigNumber, BigNumber":wo,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Lc="rightLogShift",Hc=W(Lc,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=nc({typed:t,equalScalar:n}),u=Uc({typed:t,equalScalar:n}),c=Ku({typed:t,DenseMatrix:a}),l=oc({typed:t,equalScalar:n}),f=ec({typed:t}),p=tc({typed:t});return t(Lc,{"number, number":To,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})})),$c="compare",Gc=W($c,["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],(e=>{var{typed:t,config:r,equalScalar:n,matrix:i,BigNumber:a,Fraction:o,DenseMatrix:s}=e,u=ic({typed:t}),c=ac({typed:t,equalScalar:n}),l=sc({typed:t,DenseMatrix:s}),f=ec({typed:t}),p=tc({typed:t});return t($c,{"boolean, boolean":function(e,t){return e===t?0:e>t?1:-1},"number, number":function(e,t){return Se(e,t,r.epsilon)?0:e>t?1:-1},"BigNumber, BigNumber":function(e,t){return Na(e,t,r.epsilon)?new a(0):new a(e.cmp(t))},"Fraction, Fraction":function(e,t){return new o(e.compare(t))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return c(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(i(e),i(t)).valueOf()},"Array, Matrix":function(e,t){return this(i(e),t)},"Matrix, Array":function(e,t){return this(e,i(t))},"SparseMatrix, any":function(e,t){return l(e,t,this,!1)},"DenseMatrix, any":function(e,t){return p(e,t,this,!1)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(i(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(i(t),e,this,!0).valueOf()}})})),Zc="compareText",Vc=W(Zc,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e,n=ec({typed:t}),i=tc({typed:t});return t(Zc,{"any, any":Fe,"DenseMatrix, DenseMatrix":function(e,t){return n(e,t,Fe)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"DenseMatrix, any":function(e,t){return i(e,t,Fe,!1)},"any, DenseMatrix":function(e,t){return i(t,e,Fe,!0)},"Array, any":function(e,t){return i(r(e),t,Fe,!1).valueOf()},"any, Array":function(e,t){return i(r(t),e,Fe,!0).valueOf()}})})),Wc="smaller",Jc=W(Wc,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Wc,{"boolean, boolean":function(e,t){return e{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Yc,{"boolean, boolean":function(e,t){return e>t},"number, number":function(e,t){return e>t&&!Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gt(t)&&!Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return 1===e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),Qc="unequal",Kc=W(Qc,["typed","config","equalScalar","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,equalScalar:n,matrix:i,DenseMatrix:a}=e,o=ic({typed:t}),s=yc({typed:t,DenseMatrix:a}),u=sc({typed:t,DenseMatrix:a}),c=ec({typed:t}),l=tc({typed:t});return t("unequal",{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:f(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,f)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,f,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,f,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,f)},"Array, Array":function(e,t){return this(i(e),i(t)).valueOf()},"Array, Matrix":function(e,t){return this(i(e),t)},"Matrix, Array":function(e,t){return this(e,i(t))},"SparseMatrix, any":function(e,t){return u(e,t,f,!1)},"DenseMatrix, any":function(e,t){return l(e,t,f,!1)},"any, SparseMatrix":function(e,t){return u(t,e,f,!0)},"any, DenseMatrix":function(e,t){return l(t,e,f,!0)},"Array, any":function(e,t){return l(i(e),t,f,!1).valueOf()},"any, Array":function(e,t){return l(i(t),e,f,!0).valueOf()}});function f(e,t){return!n(e,t)}})),el=(W(Qc,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return t(Qc,{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:!r(e,t)}})})),W("ImmutableDenseMatrix",["smaller","DenseMatrix"],(e=>{var{smaller:t,DenseMatrix:r}=e;function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!c(t))throw new Error("Invalid datatype: "+t);if(f(e)||l(e)){var i=new r(e,t);this._data=i._data,this._size=i._size,this._datatype=i._datatype,this._min=null,this._max=null}else if(e&&l(e.data)&&l(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=void 0!==e.min?e.min:null,this._max=void 0!==e.max?e.max:null;else{if(e)throw new TypeError("Unsupported type of data ("+L(e)+")");this._data=[],this._size=[0],this._datatype=t,this._min=null,this._max=null}}return n.prototype=new r,n.prototype.type="ImmutableDenseMatrix",n.prototype.isImmutableDenseMatrix=!0,n.prototype.subset=function(e){switch(arguments.length){case 1:var t=r.prototype.subset.call(this,e);return f(t)?new n({data:t._data,size:t._size,datatype:t._datatype}):t;case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},n.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},n.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},n.prototype.clone=function(){return new n({data:$(this._data),size:$(this._size),datatype:this._datatype})},n.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.fromJSON=function(e){return new n(e)},n.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},n.prototype.min=function(){if(null===this._min){var e=null;this.forEach((function(r){(null===e||t(r,e))&&(e=r)})),this._min=null!==e?e:void 0}return this._min},n.prototype.max=function(){if(null===this._max){var e=null;this.forEach((function(r){(null===e||t(e,r))&&(e=r)})),this._max=null!==e?e:void 0}return this._max},n}),{isClass:!0})),tl=W("FibonacciHeap",["smaller","larger"],(e=>{var{smaller:t,larger:r}=e,n=1/Math.log((1+Math.sqrt(5))/2);function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}function a(e,t,r){t.left.right=t.right,t.right.left=t.left,r.degree--,r.child===t&&(r.child=t.right),0===r.degree&&(r.child=null),t.left=e,t.right=e.right,e.right=t,t.right.left=t,t.parent=null,t.mark=!1}function o(e,t){var r=t.parent;r&&(t.mark?(a(e,t,r),o(r)):t.mark=!0)}i.prototype.type="FibonacciHeap",i.prototype.isFibonacciHeap=!0,i.prototype.insert=function(e,r){var n={key:e,value:r,degree:0};if(this._minimum){var i=this._minimum;n.left=i,n.right=i.right,i.right=n,n.right.left=n,t(e,i.key)&&(this._minimum=n)}else n.left=n,n.right=n,this._minimum=n;return this._size++,n},i.prototype.size=function(){return this._size},i.prototype.clear=function(){this._minimum=null,this._size=0},i.prototype.isEmpty=function(){return 0===this._size},i.prototype.extractMinimum=function(){var e=this._minimum;if(null===e)return e;for(var i=this._minimum,a=e.degree,o=e.child;a>0;){var u=o.right;o.left.right=o.right,o.right.left=o.left,o.left=i,o.right=i.right,i.right=o,o.right.left=o,o.parent=null,o=u,a--}return e.left.right=e.right,e.right.left=e.left,i=e===e.right?null:function(e,i){var a,o=Math.floor(Math.log(i)*n)+1,u=new Array(o),c=0,l=e;if(l)for(c++,l=l.right;l!==e;)c++,l=l.right;for(;c>0;){for(var f=l.degree,p=l.right;a=u[f];){if(r(l.key,a.key)){var m=a;a=l,l=m}s(a,l),u[f]=null,f++}u[f]=l,l=p,c--}e=null;for(var h=0;h{var{typed:t,SparseMatrix:r}=e;return t(rl,{"":function(){return new r([])},string:function(e){return new r([],e)},"Array | Matrix":function(e){return new r(e)},"Array | Matrix, string":function(e,t){return new r(e,t)}})})),il="acoth",al=W(il,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(il,{number:function(e){return e>=1||e<=-1||r.predictable?ms(e):new n(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new i(1).div(e).atanh()},"Array | Matrix":function(e){return $t(e,this)}})})),ol=W("algorithm09",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return function(e,n,i){var a=e._values,o=e._index,s=e._ptr,u=e._size,c=e._datatype,l=n._values,f=n._index,p=n._ptr,m=n._size,h=n._datatype;if(u.length!==m.length)throw new Ue(u.length,m.length);if(u[0]!==m[0]||u[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+m+")");var d,y=u[0],g=u[1],v=r,x=0,b=i;"string"==typeof c&&c===h&&(d=c,v=t.find(r,[d,d]),x=t.convert(0,d),b=t.find(i,[d,d]));var w,N,M,S,E,A=a&&l?[]:void 0,O=[],C=[],_=A?[]:void 0,T=[];for(N=0;N{var{typed:t,matrix:r,equalScalar:n,BigNumber:i,DenseMatrix:a}=e,o=nc({typed:t,equalScalar:n}),s=ic({typed:t}),u=ol({typed:t,equalScalar:n}),c=oc({typed:t,equalScalar:n}),l=sc({typed:t,DenseMatrix:a}),f=ec({typed:t}),p=tc({typed:t});return t(sl,{"number, number":Math.atan2,"BigNumber, BigNumber":function(e,t){return i.atan2(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return l(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return p(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return p(r(t),e,this,!0).valueOf()}})})),cl=W("sec",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("sec",{number:Ss,Complex:function(e){return e.sec()},BigNumber:function(e){return new r(1).div(e.cos())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),ll=W("add",["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:r,addScalar:n,equalScalar:i,DenseMatrix:a,SparseMatrix:o}=e,s=Xu({typed:t}),u=Qu({typed:t,equalScalar:i}),c=Ku({typed:t,DenseMatrix:a}),l=ec({typed:t}),f=tc({typed:t});return t("add",G({"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,n)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,n,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,n,!0)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,n)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"DenseMatrix, any":function(e,t){return f(e,t,n,!1)},"SparseMatrix, any":function(e,t){return c(e,t,n,!1)},"any, DenseMatrix":function(e,t){return f(t,e,n,!0)},"any, SparseMatrix":function(e,t){return c(t,e,n,!0)},"Array, any":function(e,t){return f(r(e),t,n,!1).valueOf()},"any, Array":function(e,t){return f(r(t),e,n,!0).valueOf()},"any, any":n,"any, any, ...any":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,addScalar:r,multiplyScalar:n,conj:i,size:a}=e;return t("dot",{"Array | DenseMatrix, Array | DenseMatrix":function(e,a){var u=o(e,a),c=f(e)?e._data:e,l=f(e)?e._datatype:void 0,p=f(a)?a._data:a,m=f(a)?a._datatype:void 0,h=2===s(e).length,d=2===s(a).length,y=r,g=n;if(l&&m&&l===m&&"string"==typeof l){var v=l;y=t.find(r,[v,v]),g=t.find(n,[v,v])}if(!h&&!d){for(var x=g(i(c[0]),p[0]),b=1;bd?m++:h===d&&(c=l(c,f(a[p],u[m])),p++,m++)}return c}});function o(e,t){var r,n,i=s(e),a=s(t);if(1===i.length)r=i[0];else{if(2!==i.length||1!==i[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+i.join(", ")+")");r=i[0]}if(1===a.length)n=a[0];else{if(2!==a.length||1!==a[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+a.join(", ")+")");n=a[0]}if(r!==n)throw new RangeError("Vectors must have equal length ("+r+" != "+n+")");if(0===r)throw new RangeError("Cannot calculate the dot product of empty vectors");return r}function s(e){return f(e)?e.size():a(e)}})),pl="composition",ml=W(pl,["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],(e=>{var{typed:t,addScalar:r,combinations:n,isPositive:i,isNegative:a,isInteger:o,larger:s}=e;return t(pl,{"number | BigNumber, number | BigNumber":function(e,t){if(!(o(e)&&i(e)&&o(t)&&i(t)))throw new TypeError("Positive integer value expected in function composition");if(s(t,e))throw new TypeError("k must be less than or equal to n in function composition");return n(r(e,-1),r(t,-1))}})})),hl="isZero",dl=W(hl,["typed"],(e=>{var{typed:t}=e;return t(hl,{number:ya,BigNumber:function(e){return e.isZero()},Complex:function(e){return 0===e.re&&0===e.im},Fraction:function(e){return 1===e.d&&0===e.n},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),yl="matrixFromFunction",gl=W(yl,["typed","matrix","isZero"],(e=>{var{typed:t,matrix:r,isZero:n}=e;return t(yl,{"Array | Matrix, function, string, string":function(e,t,r,n){return i(e,t,r,n)},"Array | Matrix, function, string":function(e,t,r){return i(e,t,r)},"Matrix, function":function(e,t){return i(e,t,"dense")},"Array, function":function(e,t){return i(e,t,"dense").toArray()},"Array | Matrix, string, function":function(e,t,r){return i(e,r,t)},"Array | Matrix, string, string, function":function(e,t,r,n){return i(e,n,t,r)}});function i(e,t,i,a){var o;return(o=void 0!==a?r(i,a):r(i)).resize(e),o.forEach((function(e,r){var i=t(r);n(i)||o.set(r,i)})),o}})),vl="cbrt",xl=W(vl,["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],(e=>{var{config:t,typed:r,isNegative:n,unaryMinus:i,matrix:u,Complex:c,BigNumber:l,Fraction:f}=e;return r(vl,{number:Fa,Complex:p,"Complex, boolean":p,BigNumber:function(e){return e.cbrt()},Unit:function(e){if(e.value&&o(e.value)){var t=e.clone();return t.value=1,(t=t.pow(1/3)).value=p(e.value),t}var r,u=n(e.value);u&&(e.value=i(e.value)),r=a(e.value)?new l(1).div(3):s(e.value)?new f(1,3):1/3;var c=e.pow(r);return u&&(c.value=i(c.value)),c},"Array | Matrix":function(e){return $t(e,this,!0)}});function p(e,r){var n=e.arg()/3,i=e.abs(),a=new c(Fa(i),0).mul(new c(0,n).exp());if(r){var o=[a,new c(Fa(i),0).mul(new c(0,n+2*Math.PI/3).exp()),new c(Fa(i),0).mul(new c(0,n-2*Math.PI/3).exp())];return"Array"===t.matrix?o:u(o)}return a}})),bl=W("floor",["typed","config","round","matrix","equalScalar"],(e=>{var{typed:t,config:r,round:n,matrix:i,equalScalar:a}=e,o=oc({typed:t,equalScalar:a}),s=tc({typed:t});return t("floor",{number:function(e){return Se(e,n(e),r.epsilon)?n(e):Math.floor(e)},"number, number":function(e,t){if(Se(e,n(e,t),r.epsilon))return n(e,t);var[i,a]="".concat(e,"e").split("e"),o=Math.floor(Number("".concat(i,"e").concat(Number(a)+t)));return[i,a]="".concat(o,"e").split("e"),Number("".concat(i,"e").concat(Number(a)-t))},Complex:function(e){return e.floor()},"Complex, number":function(e,t){return e.floor(t)},BigNumber:function(e){return Na(e,n(e),r.epsilon)?n(e):e.floor()},"BigNumber, BigNumber":function(e,t){return Na(e,n(e,t),r.epsilon)?n(e,t):e.toDecimalPlaces(t.toNumber(),Qn.ROUND_FLOOR)},Fraction:function(e){return e.floor()},"Fraction, number":function(e,t){return e.floor(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"Array | Matrix, number":function(e,t){return $t(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"number | Complex | BigNumber, Array":function(e,t){return s(i(t),e,this,!0).valueOf()}})})),wl="multiply",Nl=W(wl,["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],(e=>{var{typed:t,matrix:r,addScalar:n,multiplyScalar:i,equalScalar:a,dot:o}=e,s=oc({typed:t,equalScalar:a}),u=tc({typed:t});function c(e,t){switch(e.length){case 1:switch(t.length){case 1:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;case 2:switch(t.length){case 1:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+t[0]+")");break;case 2:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}}var l=t("_multiplyMatrixVector",{"DenseMatrix, any":function(e,r){var a,o=e._data,s=e._size,u=e._datatype,c=r._data,l=r._datatype,f=s[0],p=s[1],m=n,h=i;u&&l&&u===l&&"string"==typeof u&&(a=u,m=t.find(n,[a,a]),h=t.find(i,[a,a]));for(var d=[],y=0;yA)for(var C=0,_=0;_{var{typed:t,matrix:r,equalScalar:n,multiplyScalar:i}=e,a=nc({typed:t,equalScalar:n}),o=ol({typed:t,equalScalar:n}),s=oc({typed:t,equalScalar:n}),u=ec({typed:t}),c=tc({typed:t});return t(Ml,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,i)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,i,!1)},"DenseMatrix, any":function(e,t){return c(e,t,i,!1)},"any, SparseMatrix":function(e,t){return s(t,e,i,!0)},"any, DenseMatrix":function(e,t){return c(t,e,i,!0)},"Array, any":function(e,t){return c(r(e),t,i,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,i,!0).valueOf()}})})),El=W("re",["typed"],(e=>{var{typed:t}=e;return t("re",{number:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Complex:function(e){return e.re},"Array | Matrix":function(e){return $t(e,this)}})})),Al="flatten",Ol=W(Al,["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t(Al,{Array:function(e){return et($(e))},Matrix:function(e){var t=et($(e.toArray()));return r(t)}})}));function Cl(e,t,r,n){if(!(this instanceof Cl))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=t,this.min=r,this.max=n,this.message="Wrong number of arguments in function "+e+" ("+t+" provided, "+r+(null!=n?"-"+n:"")+" expected)",this.stack=(new Error).stack}Cl.prototype=new Error,Cl.prototype.constructor=Error,Cl.prototype.name="ArgumentsError",Cl.prototype.isArgumentsError=!0;var _l=W("resize",["config","matrix"],(e=>{var{config:t,matrix:r}=e;return function(e,i,o){if(2!==arguments.length&&3!==arguments.length)throw new Cl("resize",arguments.length,2,3);if(f(i)&&(i=i.valueOf()),a(i[0])&&(i=i.map((function(e){return a(e)?e.toNumber():e}))),f(e))return e.resize(i,o,!0);if("string"==typeof e)return n(e,i,o);var s=!Array.isArray(e)&&"Array"!==t.matrix;if(0===i.length){for(;Array.isArray(e);)e=e[0];return $(e)}Array.isArray(e)||(e=[e]);var u=Ge(e=$(e),i,o);return s?r(u):u};function n(e,t,r){if(void 0!==r){if("string"!=typeof r||1!==r.length)throw new TypeError("Single character expected as defaultValue")}else r=" ";if(1!==t.length)throw new Ue(t.length,1);var n=t[0];if("number"!=typeof n||!ce(n))throw new TypeError("Invalid size, must contain positive integers (size: "+De(t)+")");if(e.length>n)return e.substring(0,n);if(e.length{var{typed:t,matrix:r}=e;return t(Tl,{Array:function(e){return Ye($(e))},Matrix:function(e){var t=Ye(e.toArray());return Array.isArray(t)?r(t):t},any:function(e){return $(e)}})})),ql=W("to",["typed","matrix"],(e=>{var{typed:t,matrix:r}=e,n=ec({typed:t}),i=tc({typed:t});return t("to",{"Unit, Unit | string":function(e,t){return e.to(t)},"Matrix, Matrix":function(e,t){return n(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"Matrix, any":function(e,t){return i(e,t,this,!1)},"any, Matrix":function(e,t){return i(t,e,this,!0)},"Array, any":function(e,t){return i(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return i(r(t),e,this,!0).valueOf()}})})),zl=W("pow",["typed","config","identity","multiply","matrix","fraction","number","Complex"],(e=>{var{typed:t,config:r,identity:n,multiply:i,matrix:a,number:o,fraction:s,Complex:u}=e;return t("pow",{"number, number":c,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(e,t){return t.isInteger()||e>=0||r.predictable?e.pow(t):new u(e.toNumber(),0).pow(t.toNumber(),0)},"Fraction, Fraction":function(e,t){var n=e.pow(t);if(null!=n)return n;if(r.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return c(e.valueOf(),t.valueOf())},"Array, number":l,"Array, BigNumber":function(e,t){return l(e,t.toNumber())},"Matrix, number":f,"Matrix, BigNumber":function(e,t){return f(e,t.toNumber())},"Unit, number | BigNumber":function(e,t){return e.pow(t)}});function c(e,t){if(r.predictable&&!ce(t)&&e<0)try{var n=s(t),i=o(n);if((t===i||Math.abs((t-i)/t)<1e-14)&&n.d%2==1)return(n.n%2==0?1:-1)*Math.pow(-e,t)}catch(e){}return r.predictable&&(e<-1&&t===1/0||e>-1&&e<0&&t===-1/0)?NaN:ce(t)||e>=0||r.predictable?Ka(e,t):e*e<1&&t===1/0||e*e>1&&t===-1/0?0:new u(e,0).pow(t,0)}function l(e,t){if(!ce(t)||t<0)throw new TypeError("For A^b, b must be a positive integer (value is "+t+")");var r=je(e);if(2!==r.length)throw new Error("For A^b, A must be 2 dimensional (A has "+r.length+" dimensions)");if(r[0]!==r[1])throw new Error("For A^b, A must be square (size is "+r[0]+"x"+r[1]+")");for(var a=n(r[0]).valueOf(),o=e;t>=1;)1==(1&t)&&(a=i(o,a)),t>>=1,o=i(o,o);return a}function f(e,t){return a(l(e.valueOf(),t))}})),Dl="dotPow",Il=W(Dl,["typed","equalScalar","matrix","pow","DenseMatrix"],(e=>{var{typed:t,equalScalar:r,matrix:n,pow:i,DenseMatrix:a}=e,o=ic({typed:t}),s=yc({typed:t,DenseMatrix:a}),u=oc({typed:t,equalScalar:r}),c=sc({typed:t,DenseMatrix:a}),l=ec({typed:t}),f=tc({typed:t});return t(Dl,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,i)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return f(e,t,this,!1)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return f(t,e,this,!0)},"Array, any":function(e,t){return f(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return f(n(t),e,this,!0).valueOf()}})})),kl="rightArithShift",Rl=W(kl,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,DenseMatrix:a}=e,o=Xu({typed:t}),s=nc({typed:t,equalScalar:n}),u=Uc({typed:t,equalScalar:n}),c=Ku({typed:t,DenseMatrix:a}),l=oc({typed:t,equalScalar:n}),f=ec({typed:t}),p=tc({typed:t});return t(kl,{"number, number":_o,"BigNumber, BigNumber":No,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return n(t,0)?e.clone():p(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return n(e,0)?i(t.size(),t.storage()):p(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(r(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Fl=r(228),Ul="compareNatural",Pl=W(Ul,["typed","compare"],(e=>{var{typed:t,compare:r}=e,n=r.signatures["boolean,boolean"];return t(Ul,{"any, any":function(e,t){var o,s=L(e),u=L(t);if(!("number"!==s&&"BigNumber"!==s&&"Fraction"!==s||"number"!==u&&"BigNumber"!==u&&"Fraction"!==u))return"0"!==(o=r(e,t)).toString()?o>0?1:-1:Fl(s,u);if("Array"===s||"Matrix"===s||"Array"===u||"Matrix"===u)return 0!==(o=i(this,e,t))?o:Fl(s,u);if(s!==u)return Fl(s,u);if("Complex"===s)return function(e,t){return e.re>t.re?1:e.ret.im?1:e.imr.length?1:t.length{var{typed:t,compareText:r,isZero:n}=e;return t(jl,{"any, any":function(e,t){return n(r(e,t))}})})),Hl="largerEq",$l=W(Hl,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Hl,{"boolean, boolean":function(e,t){return e>=t},"number, number":function(e,t){return e>=t||Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gte(t)||Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return-1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),Gl="partitionSelect",Zl=W(Gl,["typed","isNumeric","isNaN","compare"],(e=>{var{typed:t,isNumeric:r,isNaN:n,compare:i}=e,a=i,o=(e,t)=>-i(e,t);return t(Gl,{"Array | Matrix, number":function(e,t){return s(e,t,a)},"Array | Matrix, number, string":function(e,t,r){if("asc"===r)return s(e,t,a);if("desc"===r)return s(e,t,o);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":s});function s(e,t,r){if(!ce(t)||t<0)throw new Error("k must be a non-negative integer");if(f(e)){if(e.size().length>1)throw new Error("Only one dimensional matrices supported");return u(e.valueOf(),t,r)}if(Array.isArray(e))return u(e,t,r)}function u(e,t,i){if(t>=e.length)throw new Error("k out of bounds");for(var a=0;a=0){var f=e[c];e[c]=e[u],e[u]=f,--c}else++u;i(e[u],l)>0&&--u,t<=u?s=u:o=u+1}return e[t]}})),Vl=W("Index",["ImmutableDenseMatrix"],(e=>{var{ImmutableDenseMatrix:t}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var t=0,i=arguments.length;t{var{typed:t,config:r,Complex:n,BigNumber:i}=e;return t(Wl,{number:function(e){if(e<=1&&e>=-1||r.predictable){var t=1/e;if(t>0||r.predictable)return gs(e);var i=Math.sqrt(t*t-1);return new n(Math.log(i-t),Math.PI)}return new n(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new i(1).div(e).acosh()},"Array | Matrix":function(e){return $t(e,this)}})})),Yl=W("tan",["typed"],(e=>{var{typed:t}=e;return t("tan",{number:Math.tan,Complex:function(e){return e.tan()},BigNumber:function(e){return e.tan()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this,!0)}})})),Xl="setDifference",Ql=W(Xl,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Xl,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(0===n(r(e),new a(0)))s=[];else{if(0===n(r(t),new a(0)))return et(e.toArray());var u,c=ot(et(Array.isArray(e)?e:e.toArray()).sort(i)),l=ot(et(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var f=0;f{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Kl,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(0===n(r(e),new a(0))||0===n(r(t),new a(0)))s=[];else{var u=ot(et(Array.isArray(e)?e:e.toArray()).sort(i)),c=ot(et(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var l=0;l{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(tf,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,t){if(0===n(r(t),new a(0)))return 0;for(var o=et(Array.isArray(t)?t:t.toArray()),s=0,u=0;u{var{typed:t,compareNatural:r}=e;return t(nf,{"Array | Matrix":function(e){return Array.isArray(e)?et(e).length:et(e.toArray()).length},"Array | Matrix, boolean":function(e,t){if(!1===t||0===e.length)return Array.isArray(e)?et(e).length:et(e.toArray()).length;for(var n=et(Array.isArray(e)?e:e.toArray()).sort(r),i=1,a=1;a{var{typed:t,matrix:r,add:n}=e;return t("trace",{Array:function(e){return i(r(e))},SparseMatrix:function(e){var t=e._values,r=e._index,i=e._ptr,a=e._size,o=a[0],s=a[1];if(o===s){var u=0;if(t.length>0)for(var c=0;cc)break}return u}throw new RangeError("Matrix must be square (size: "+De(a)+")")},DenseMatrix:i,any:$});function i(e){var t=e._size,r=e._data;switch(t.length){case 1:if(1===t[0])return $(r[0]);throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:var i=t[0];if(i===t[1]){for(var a=0,o=0;o{var{typed:t,add:r,multiply:n,partitionSelect:o,compare:s}=e;function u(e,t,a){var u=et(e),l=u.length;if(0===l)throw new Error("Cannot calculate quantile of an empty sequence");if(i(t)){var f=t*(l-1),p=f%1;if(0===p){var m=a?u[f]:o(u,f);return c(m),m}var h,d,y=Math.floor(f);if(a)h=u[y],d=u[y+1];else{d=o(u,y+1),h=u[y];for(var g=0;g0&&(h=u[g])}return c(h),c(d),r(n(h,1-p),n(d,p))}var v=t.times(l-1);if(v.isInteger()){v=v.toNumber();var x=a?u[v]:o(u,v);return c(x),x}var b,w,N=v.floor(),M=v.minus(N),S=N.toNumber();if(a)b=u[S],w=u[S+1];else{w=o(u,S+1),b=u[S];for(var E=0;E0&&(b=u[E])}c(b),c(w);var A=new M.constructor(1);return r(n(b,A.minus(M)),n(w,M))}var c=t({"number | BigNumber | Unit":function(e){return e}});return function(e,t,r){var n,o,s;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(p(e)){if("boolean"==typeof(r=r||!1)){if(o=e.valueOf(),i(t)){if(t<0)throw new Error("N/prob must be non-negative");if(t<=1)return u(o,t,r);if(t>1){if(!ce(t))throw new Error("N must be a positive integer");var c=t+1;n=new Array(t);for(var l=0;l4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var h=new f(m+1);n=new Array(m);for(var d=0;d1)throw new Error("Probability must be between 0 and 1, inclusive")}else{if(!a(g))throw new TypeError("Unexpected type of argument in function quantileSeq");if(s=new g.constructor(1),g.isNegative()||g.gt(s))throw new Error("Probability must be between 0 and 1, inclusive")}n[y]=u(o,g,r)}return n}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}}));function uf(e){var t;if(ce(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:Js(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*uf(1-e));if(e>=171.35)return 1/0;if(e>85){var r=e*e,n=r*e,i=n*e,a=i*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*r)-139/(51840*n)-571/(2488320*i)+163879/(209018880*a)+5246819/(75246796800*a*e))}--e,t=lf[0];for(var o=1;o{var{typed:t,config:r,multiplyScalar:n,pow:i,BigNumber:a,Complex:o}=e;return t(ff,{number:uf,Complex:function(e){if(0===e.im)return this(e.re);e=new o(e.re-1,e.im);for(var t=new o(lf[0],0),r=1;r2;)u+=i-=2,o=o.times(u);return new a(o.toPrecision(a.precision))}})),mf=W("bignumber",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("bignumber",{"":function(){return new r(0)},number:function(e){return new r(e+"")},string:function(e){var t=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(t){var n=t[2],i=r(t[1]),a=new r(2).pow(Number(n));if(i.gt(a.sub(1)))throw new SyntaxError('String "'.concat(e,'" is out of range'));var o=new r(2).pow(Number(n)-1);return i.gte(o)?i.sub(a):i}return new r(e)},BigNumber:function(e){return e},Fraction:function(e){return new r(e.n).div(e.d).times(e.s)},null:function(e){return new r(0)},"Array | Matrix":function(e){return $t(e,this)}})})),hf="matrixFromColumns",df=W(hf,["typed","matrix","flatten","size"],(e=>{var{typed:t,matrix:r,flatten:n,size:i}=e;return t(hf,{"...Array":function(e){return a(e)},"...Matrix":function(e){return r(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one column is needed to construct a matrix.");for(var t=o(e[0]),r=[],i=0;i{var{typed:t,matrix:r,equalScalar:n}=e,i=nc({typed:t,equalScalar:n}),a=cc({typed:t,equalScalar:n}),o=oc({typed:t,equalScalar:n}),s=ec({typed:t}),u=tc({typed:t});return t("lcm",{"number, number":$a,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(e.isZero())return e;if(t.isZero())return t;for(var r=e.times(t);!t.isZero();){var n=t;t=e.mod(n),e=n}return r.div(e).abs()},"Fraction, Fraction":function(e,t){return e.lcm(t)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return o(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return u(r(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return u(r(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,r){for(var n=this(e,t),i=0;i{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=Xu({typed:t}),o=Qu({typed:t,equalScalar:n}),s=Ku({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(gf,{"number, number":Ao,"BigNumber, BigNumber":go,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})})),xf="kron",bf=W(xf,["typed","matrix","multiplyScalar"],(e=>{var{typed:t,matrix:r,multiplyScalar:n}=e;return t(xf,{"Matrix, Matrix":function(e,t){return r(i(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(i(e.toArray(),t))},"Array, Matrix":function(e,t){return r(i(e,t.toArray()))},"Array, Array":i});function i(e,t){if(1===je(e).length&&(e=[e]),1===je(t).length&&(t=[t]),je(e).length>2||je(t).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(e.length)+", y = "+JSON.stringify(t.length)+")");var r=[],i=[];return e.map((function(e){return t.map((function(t){return i=[],r.push(i),e.map((function(e){return t.map((function(t){return i.push(n(e,t))}))}))}))}))&&r}})),wf=W("transpose",["typed","matrix"],(e=>{var{typed:t,matrix:r}=e;return t("transpose",{Array:function(e){return this(r(e)).valueOf()},Matrix:function(e){var t,r=e.size();switch(r.length){case 1:t=e.clone();break;case 2:var n=r[0],i=r[1];if(0===i)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+De(r)+")");switch(e.storage()){case"dense":t=function(e,t,r){for(var n,i=e._data,a=[],o=0;o{var{number:t,bignumber:r,fraction:n}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},a={number:e=>t(e),BigNumber:r?e=>r(e):tr,Fraction:n?e=>n(e):rr};return function(e,t){var r=L(e);if(!(r in i))throw new TypeError("Cannot convert "+e+' of type "'+r+'"; valid input types are '+Object.keys(i).join(", "));if(!(t in a))throw new TypeError("Cannot convert "+e+' to type "'+t+'"; valid output types are '+Object.keys(a).join(", "));return t===r?e:a[t](e)}})),Mf=W("and",["typed","matrix","equalScalar","zeros","not"],(e=>{var{typed:t,matrix:r,equalScalar:n,zeros:i,not:a}=e,o=nc({typed:t,equalScalar:n}),s=cc({typed:t,equalScalar:n}),u=oc({typed:t,equalScalar:n}),c=ec({typed:t}),l=tc({typed:t});return t("and",{"number, number":Uo,"Complex, Complex":function(e,t){return!(0===e.re&&0===e.im||0===t.re&&0===t.im)},"BigNumber, BigNumber":function(e,t){return!(e.isZero()||t.isZero()||e.isNaN()||t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return a(t)?i(e.size(),e.storage()):u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return a(t)?i(e.size(),e.storage()):l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return a(e)?i(e.size(),e.storage()):u(t,e,this,!0)},"any, DenseMatrix":function(e,t){return a(e)?i(e.size(),e.storage()):l(t,e,this,!0)},"Array, any":function(e,t){return this(r(e),t).valueOf()},"any, Array":function(e,t){return this(e,r(t)).valueOf()}})})),Sf="smallerEq",Ef=W(Sf,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:r,matrix:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Sf,{"boolean, boolean":function(e,t){return e<=t},"number, number":function(e,t){return e<=t||Se(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,t){return e.lte(t)||Na(e,t,r.epsilon)},"Fraction, Fraction":function(e,t){return 1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,this,!0).valueOf()}})})),Af="sort",Of=W(Af,["typed","matrix","compare","compareNatural"],(e=>{var{typed:t,matrix:r,compare:n,compareNatural:i}=e,a=n,o=(e,t)=>-n(e,t);return t(Af,{Array:function(e){return u(e),e.sort(a)},Matrix:function(e){return c(e),r(e.toArray().sort(a),e.storage())},"Array, function":function(e,t){return u(e),e.sort(t)},"Matrix, function":function(e,t){return c(e),r(e.toArray().sort(t),e.storage())},"Array, string":function(e,t){return u(e),e.sort(s(t))},"Matrix, string":function(e,t){return c(e),r(e.toArray().sort(s(t)),e.storage())}});function s(e){if("asc"===e)return a;if("desc"===e)return o;if("natural"===e)return i;throw new Error('String "asc", "desc", or "natural" expected')}function u(e){if(1!==je(e).length)throw new Error("One dimensional array expected")}function c(e){if(1!==e.size().length)throw new Error("One dimensional matrix expected")}})),Cf=W("cot",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:r}=e;return t("cot",{number:bs,Complex:function(e){return e.cot()},BigNumber:function(e){return new r(1).div(e.tan())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(e.value)},"Array | Matrix":function(e){return $t(e,this)}})})),_f="setDistinct",Tf=W(_f,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(_f,{"Array | Matrix":function(e){var t;if(0===n(r(e),new a(0)))t=[];else{var s=et(Array.isArray(e)?e:e.toArray()).sort(i);(t=[]).push(s[0]);for(var u=1;u{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(Bf,{"Array | Matrix":function(e){if(0===n(r(e),new a(0)))return[];for(var t=et(Array.isArray(e)?e:e.toArray()).sort(i),s=[],u=0;u.toString(2).length<=t.length;)s.push(o(t,u.toString(2).split("").reverse())),u++;return function(e){for(var t=[],r=e.length-1;r>0;r--)for(var n=0;ne[n+1].length&&(t=e[n],e[n]=e[n+1],e[n+1]=t);return e}(s)}});function o(e,t){for(var r=[],n=0;n{var{typed:t,Index:r}=e;return t(zf,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var t=e.map((function(e){return a(e)?e.toNumber():Array.isArray(e)||f(e)?e.map((function(e){return a(e)?e.toNumber():e})):e})),n=new r;return r.apply(n,t),n}})})),If="factorial",kf=W(If,["typed","gamma"],(e=>{var{typed:t,gamma:r}=e;return t(If,{number:function(e){if(e<0)throw new Error("Value must be non-negative");return r(e+1)},BigNumber:function(e){if(e.isNegative())throw new Error("Value must be non-negative");return r(e.plus(1))},"Array | Matrix":function(e){return $t(e,this)}})})),Rf="permutations",Ff=W(Rf,["typed","factorial"],(e=>{var{typed:t,factorial:r}=e;return t(Rf,{"number | BigNumber":r,"number, number":function(e,t){if(!ce(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!ce(t)||t<0)throw new TypeError("Positive integer value expected in function permutations");if(t>e)throw new TypeError("second argument k must be less than or equal to first argument n");return Js(e-t+1,e)},"BigNumber, BigNumber":function(e,t){var r,n;if(!Uf(e)||!Uf(t))throw new TypeError("Positive integer value expected in function permutations");if(t.gt(e))throw new TypeError("second argument k must be less than or equal to first argument n");for(r=e.mul(0).add(1),n=e.minus(t).plus(1);n.lte(e);n=n.plus(1))r=r.times(n);return r}})}));function Uf(e){return e.isInteger()&&e.gte(0)}var Pf="matrixFromRows",jf=W(Pf,["typed","matrix","flatten","size"],(e=>{var{typed:t,matrix:r,flatten:n,size:i}=e;return t(Pf,{"...Array":function(e){return a(e)},"...Matrix":function(e){return r(a(e.map((e=>e.toArray()))))}});function a(e){if(0===e.length)throw new TypeError("At least one row is needed to construct a matrix.");var t=o(e[0]),r=[];for(var i of e){var a=o(i);if(a!==t)throw new TypeError("The vectors had different length: "+(0|t)+" ≠ "+(0|a));r.push(n(i))}return r}function o(e){var t=i(e);if(1===t.length)return t[0];if(2===t.length){if(1===t[0])return t[1];if(1===t[1])return t[0];throw new TypeError("At least one of the arguments is not a vector.")}throw new TypeError("Only one- or two-dimensional vectors are supported.")}})),Lf="subtract",Hf=W(Lf,["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,addScalar:i,unaryMinus:a,DenseMatrix:o}=e,s=Xu({typed:t}),u=ic({typed:t}),c=ac({typed:t,equalScalar:n}),l=Ku({typed:t,DenseMatrix:o}),f=ec({typed:t}),p=tc({typed:t});return t(Lf,{"number, number":function(e,t){return e-t},"Complex, Complex":function(e,t){return e.sub(t)},"BigNumber, BigNumber":function(e,t){return e.minus(t)},"Fraction, Fraction":function(e,t){return e.sub(t)},"Unit, Unit":function(e,t){if(null===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var r=e.clone();return r.value=this(r.value,t.value),r.fixPrefix=!1,r},"SparseMatrix, SparseMatrix":function(e,t){return $f(e,t),c(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return $f(e,t),u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return $f(e,t),s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return $f(e,t),f(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return l(e,a(t),i)},"DenseMatrix, any":function(e,t){return p(e,t,this)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(r(t),e,this,!0).valueOf()}})}));function $f(e,t){var r=e.size(),n=t.size();if(r.length!==n.length)throw new Ue(r.length,n.length)}var Gf="cross",Zf=W(Gf,["typed","matrix","subtract","multiply"],(e=>{var{typed:t,matrix:r,subtract:n,multiply:i}=e;return t(Gf,{"Matrix, Matrix":function(e,t){return r(a(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return r(a(e.toArray(),t))},"Array, Matrix":function(e,t){return r(a(e,t.toArray()))},"Array, Array":a});function a(e,t){var r=Math.max(je(e).length,je(t).length);e=Ye(e),t=Ye(t);var a=je(e),o=je(t);if(1!==a.length||1!==o.length||3!==a[0]||3!==o[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+a.join(", ")+"], B = ["+o.join(", ")+"])");var s=[n(i(e[1],t[2]),i(e[2],t[1])),n(i(e[2],t[0]),i(e[0],t[2])),n(i(e[0],t[1]),i(e[1],t[0]))];return r>1?[s]:s}})),Vf="prod",Wf=W(Vf,["typed","config","multiplyScalar","numeric"],(e=>{var{typed:t,config:r,multiplyScalar:n,numeric:i}=e;return t(Vf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("prod(A, dim) is not yet supported")},"...":function(e){return a(e)}});function a(e){var t;if(Ht(e,(function(e){try{t=void 0===t?e:n(t,e)}catch(t){throw Gr(t,"prod",e)}})),"string"==typeof t&&(t=i(t,r.number)),void 0===t)throw new Error("Cannot calculate prod of an empty array");return t}})),Jf="equal",Yf=W(Jf,["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,DenseMatrix:i}=e,a=ic({typed:t}),o=yc({typed:t,DenseMatrix:i}),s=sc({typed:t,DenseMatrix:i}),u=ec({typed:t}),c=tc({typed:t});return t(Jf,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:n(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,n)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,n,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,n,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,n)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,n,!1)},"DenseMatrix, any":function(e,t){return c(e,t,n,!1)},"any, SparseMatrix":function(e,t){return s(t,e,n,!0)},"any, DenseMatrix":function(e,t){return c(t,e,n,!0)},"Array, any":function(e,t){return c(r(e),t,n,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,n,!0).valueOf()}})})),Xf=(W(Jf,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:r}=e;return t(Jf,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:r(e,t)}})})),"setCartesian"),Qf=W(Xf,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:r,subset:n,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Xf,{"Array | Matrix, Array | Matrix":function(e,t){var s=[];if(0!==n(r(e),new a(0))&&0!==n(r(t),new a(0))){var u=et(Array.isArray(e)?e:e.toArray()).sort(i),c=et(Array.isArray(t)?t:t.toArray()).sort(i);s=[];for(var l=0;l{var{typed:t,size:r,concat:n,subset:i,setDifference:a,Index:o}=e;return t(Kf,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new o(0)))return et(t);if(0===i(r(t),new o(0)))return et(e);var s=et(e),u=et(t);return n(a(s,u),a(u,s))}})})),tp=W("ceil",["typed","config","round","matrix","equalScalar"],(e=>{var{typed:t,config:r,round:n,matrix:i,equalScalar:a}=e,o=oc({typed:t,equalScalar:a}),s=tc({typed:t});return t("ceil",{number:function(e){return Se(e,n(e),r.epsilon)?n(e):Ua(e)},"number, number":function(e,t){if(Se(e,n(e,t),r.epsilon))return n(e,t);var[i,a]="".concat(e,"e").split("e"),o=Math.ceil(Number("".concat(i,"e").concat(Number(a)+t)));return[i,a]="".concat(o,"e").split("e"),Number("".concat(i,"e").concat(Number(a)-t))},Complex:function(e){return e.ceil()},"Complex, number":function(e,t){return e.ceil(t)},BigNumber:function(e){return Na(e,n(e),r.epsilon)?n(e):e.ceil()},"BigNumber, BigNumber":function(e,t){return Na(e,n(e,t),r.epsilon)?n(e,t):e.toDecimalPlaces(t.toNumber(),Qn.ROUND_CEIL)},Fraction:function(e){return e.ceil()},"Fraction, number":function(e,t){return e.ceil(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"Array | Matrix, number":function(e,t){return $t(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"number | Complex | BigNumber, Array":function(e,t){return s(i(t),e,this,!0).valueOf()}})})),rp=W("xor",["typed","matrix","DenseMatrix"],(e=>{var{typed:t,matrix:r,DenseMatrix:n}=e,i=ic({typed:t}),a=yc({typed:t,DenseMatrix:n}),o=sc({typed:t,DenseMatrix:n}),s=ec({typed:t}),u=tc({typed:t});return t("xor",{"number, number":Fo,"Complex, Complex":function(e,t){return(0!==e.re||0!==e.im)!=(0!==t.re||0!==t.im)},"BigNumber, BigNumber":function(e,t){return(!e.isZero()&&!e.isNaN())!=(!t.isZero()&&!t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})})),np="count",ip=W(np,["typed","size","prod"],(e=>{var{typed:t,size:r,prod:n}=e;return t(np,{string:function(e){return e.length},"Matrix | Array":function(e){return n(r(e))}})})),ap="ctranspose",op=W(ap,["typed","transpose","conj"],(e=>{var{typed:t,transpose:r,conj:n}=e;return t(ap,{any:function(e){return n(r(e))}})})),sp="deepEqual",up=W(sp,["typed","equal"],(e=>{var{typed:t,equal:r}=e;return t(sp,{"any, any":function(e,t){return n(e.valueOf(),t.valueOf())}});function n(e,t){if(Array.isArray(e)){if(Array.isArray(t)){var i=e.length;if(i!==t.length)return!1;for(var a=0;a{var{typed:t,size:r,subset:n,compareNatural:i,Index:a}=e;return t(cp,{"Array | Matrix, Array | Matrix":function(e,t){if(0===n(r(e),new a(0)))return!0;if(0===n(r(t),new a(0)))return!1;for(var o,s=ot(et(Array.isArray(e)?e:e.toArray()).sort(i)),u=ot(et(Array.isArray(t)?t:t.toArray()).sort(i)),c=0;c{var{typed:t,Complex:r,matrix:n,ceil:i,floor:a}=e,o=tc({typed:t});return t("fix",{number:function(e){return e>0?a(e):i(e)},"number, number | BigNumber":function(e,t){return e>0?a(e,t):i(e,t)},Complex:function(e){return new r(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},"Complex, number | BigNumber":function(e,t){return new r(e.re>0?a(e.re,t):i(e.re,t),e.im>0?a(e.im,t):i(e.im,t))},BigNumber:function(e){return e.isNegative()?i(e):a(e)},"BigNumber, number | BigNumber":function(e,t){return e.isNegative()?i(e,t):a(e,t)},Fraction:function(e){return e.s<0?e.ceil():e.floor()},"Fraction, number | BigNumber":function(e,t){return e.s<0?e.ceil(t):e.floor(t)},"Array | Matrix":function(e){return $t(e,this,!0)},"Array | Matrix, number | BigNumber":function(e,t){return $t(e,(e=>this(e,t)),!0)},"number | Complex | BigNumber, Array":function(e,t){return o(n(t),e,this,!0).valueOf()}})})),pp="divideScalar",mp=W(pp,["typed","numeric"],(e=>{var{typed:t,numeric:r}=e;return t(pp,{"number, number":function(e,t){return e/t},"Complex, Complex":function(e,t){return e.div(t)},"BigNumber, BigNumber":function(e,t){return e.div(t)},"Fraction, Fraction":function(e,t){return e.div(t)},"Unit, number | Fraction | BigNumber":function(e,t){var n=e.clone(),i=r(1,L(t));return n.value=this(null===n.value?n._normalize(i):n.value,t),n},"number | Fraction | BigNumber, Unit":function(e,t){var n=t.clone();n=n.pow(-1);var i=r(1,L(e));return n.value=this(e,null===t.value?t._normalize(i):t.value),n},"Unit, Unit":function(e,t){return e.divide(t)}})})),hp="nthRoots",dp=W(hp,["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,Complex:i}=e,a=[function(e){return new i(e,0)},function(e){return new i(0,e)},function(e){return new i(-e,0)},function(e){return new i(0,-e)}];function o(e,t){if(t<0)throw new Error("Root must be greater than zero");if(0===t)throw new Error("Root must be non-zero");if(t%1!=0)throw new Error("Root must be an integer");if(0===e||0===e.abs())return[new i(0,0)];var r,n="number"==typeof e;(n||0===e.re||0===e.im)&&(r=n?2*+(e<0):0===e.im?2*+(e.re<0):2*+(e.im<0)+1);for(var o=e.arg(),s=e.abs(),u=[],c=Math.pow(s,1/t),l=0;l{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(gp,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=(t=u(e,t,!0))._data,c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=[],d=0;dd&&(v.push(f[N]),x.push(M))}if(o(g,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var S=n(y,g),E=0,A=x.length;E{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(xp,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=0;hh&&(v.push(f[M]),x.push(S))}if(o(N,0))if(o(g[h],0)){if(0===y){var E=[...g];E[h]=1;for(var A=0,O=x.length;Anew s({data:e.map((e=>[e])),size:[c,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(r(e),t).map((e=>e.valueOf()))}});function c(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1],p=0;pnew s({data:e.map((e=>[e])),size:[l,1]})))}})),wp=W("Spa",["addScalar","equalScalar","FibonacciHeap"],(e=>{var{addScalar:t,equalScalar:r,FibonacciHeap:n}=e;function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new n}return i.prototype.type="Spa",i.prototype.isSpa=!0,i.prototype.set=function(e,t){if(this._values[e])this._values[e].value=t;else{var r=this._heap.insert(e,t);this._values[e]=r}},i.prototype.get=function(e){var t=this._values[e];return t?t.value:0},i.prototype.accumulate=function(e,r){var n=this._values[e];n?n.value=t(n.value,r):(n=this._heap.insert(e,r),this._values[e]=n)},i.prototype.forEach=function(e,t,n){var i=this._heap,a=this._values,o=[],s=i.extractMinimum();for(s&&o.push(s);s&&s.key<=t;)s.key>=e&&(r(s.value,0)||n(s.key,s.value,this)),(s=i.extractMinimum())&&o.push(s);for(var u=0;u{var{typed:t,size:r,concat:n,subset:i,setIntersect:a,setSymDifference:o,Index:s}=e;return t(Np,{"Array | Matrix, Array | Matrix":function(e,t){if(0===i(r(e),new s(0)))return et(t);if(0===i(r(t),new s(0)))return et(e);var u=et(e),c=et(t);return n(o(u,c),a(u,c))}})})),Sp=W("lup",["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],(e=>{var{typed:t,matrix:r,abs:n,addScalar:i,divideScalar:a,multiplyScalar:o,subtract:s,larger:u,equalScalar:c,unaryMinus:l,DenseMatrix:f,SparseMatrix:p,Spa:m}=e;return t("lup",{DenseMatrix:function(e){return h(e)},SparseMatrix:function(e){return function(e){var t,r,i,s=e._size[0],f=e._size[1],h=Math.min(s,f),d=e._values,y=e._index,g=e._ptr,v=[],x=[],b=[],w=[s,h],N=[],M=[],S=[],E=[h,f],A=[],O=[];for(t=0;t0&&e.forEach(0,r-1,(function(t,r){p._forEachRow(t,v,x,b,(function(n,i){n>t&&e.accumulate(n,l(o(i,r)))}))}));var C,_,T,B,q=r,z=e.get(r),D=n(z);e.forEach(r+1,s-1,(function(e,t){var r=n(t);u(r,D)&&(q=e,D=r,z=t)})),r!==q&&(p._swapRows(r,q,w[1],v,x,b),p._swapRows(r,q,E[1],N,M,S),e.swap(r,q),_=q,T=O[C=r],B=O[_],A[T]=_,A[B]=C,O[C]=B,O[_]=T),e.forEach(0,s-1,(function(e,t){e<=r?(N.push(t),M.push(e)):(t=a(t,z),c(t,0)||(v.push(t),x.push(e)))}))};for(r=0;r0)for(t=0;t=0;){var u=r[o+s],c=r[n+u];-1===c?(s--,a[t++]=u):(r[n+u]=r[i+c],r[o+ ++s]=c)}return t}function Ap(e){return-e-2}var Op=W("csAmd",["add","multiply","transpose"],(e=>{var{add:t,multiply:r,transpose:n}=e;return function(e,o){if(!o||e<=0||e>3)return null;var s=o._size,u=s[0],c=s[1],l=0,f=Math.max(16,10*Math.sqrt(c)),p=function(e,i,a,o,s){var u=n(i);if(1===e&&o===a)return t(i,u);if(2===e){for(var c=u._index,l=u._ptr,f=0,p=0;ps))for(var h=l[p+1];mo)r[s+p]=0,r[i+p]=-1,f++,t[p]=Ap(e),r[s+e]++;else{var h=r[u+m];-1!==h&&(c[h]=p),r[l+p]=r[u+m],r[u+m]=p}}return f}(c,T,z,F,R,U,f,D,k,j,I),$=0;HG?(v=d,x=W,b=z[0+d]-G):(x=T[v=_[W++]],b=z[0+v]),g=1;g<=b;g++)(w=z[D+(m=_[x++])])<=0||(V+=w,z[D+m]=-w,_[Y++]=m,-1!==z[I+m]&&(j[z[I+m]]=j[m]),-1!==j[m]?z[I+j[m]]=z[I+m]:z[k+z[F+m]]=z[I+m]);v!==d&&(T[v]=Ap(d),z[U+v]=0)}for(0!==G&&(B=Y),z[F+d]=V,T[d]=J,z[0+d]=Y-J,z[R+d]=-2,L=i(L,l,z,U,c),N=J;N=L?z[U+v]-=w:0!==z[U+v]&&(z[U+v]=z[F+v]+X)}for(N=J;N0?(C+=Q,_[A++]=v,O+=v):(T[v]=Ap(d),z[U+v]=0)}z[R+m]=A-S+1;var K=A,ee=S+z[0+m];for(W=E+1;W=0))for(m=z[P+(O=j[m])],z[P+O]=-1;-1!==m&&-1!==z[I+m];m=z[I+m],L++){for(b=z[0+m],M=z[R+m],W=T[m]+1;W<=T[m]+b-1;W++)z[U+_[W]]=L;var re=m;for(h=z[I+m];-1!==h;){var ne=z[0+h]===b&&z[R+h]===M;for(W=T[h]+1;ne&&W<=T[h]+b-1;W++)z[U+_[W]]!==L&&(ne=0);ne?(T[h]=Ap(m),z[D+m]+=z[D+h],z[D+h]=0,z[R+h]=-1,h=z[I+h],z[I+re]=h):(re=h,h=z[I+h])}}for(W=J,N=J;N=0;h--)z[D+h]>0||(z[I+h]=z[k+T[h]],z[k+T[h]]=h);for(v=c;v>=0;v--)z[D+v]<=0||-1!==T[v]&&(z[I+v]=z[k+T[v]],z[k+T[v]]=v);for(d=0,m=0;m<=c;m++)-1===T[m]&&(d=Ep(m,d,z,k,I,q,U));return q.splice(q.length-1,1),q};function i(e,t,r,n,i){if(e<2||e+t<0){for(var a=0;a{var{transpose:t}=e;return function(e,r,n,i){if(!e||!r||!n)return null;var a,o,s,u,c,l,f,p=e._size,m=p[0],h=p[1],d=4*h+(i?h+m+1:0),y=[],g=h,v=2*h,x=3*h,b=4*h,w=5*h+1;for(s=0;s=1&&N[o]++,2===A.jleaf&&N[A.q]--}-1!==r[o]&&(y[0+o]=r[o])}for(o=0;o{var{add:t,multiply:r,transpose:n}=e,i=Op({add:t,multiply:r,transpose:n}),a=_p({transpose:n});return function(e,t,r){var n,o=t._ptr,s=t._size[1],u={};if(u.q=i(e,t),e&&!u.q)return null;if(r){var c=e?function(e,t,r,n){for(var i=e._values,a=e._index,o=e._ptr,s=e._size,u=e._datatype,c=s[0],l=s[1],f=null,p=[],m=[],h=0,d=0;d=0;r--)-1!==e[r]&&(a[o+r]=a[0+e[r]],a[0+e[r]]=r);for(r=0;r=0;u--)for(l=r[u],f=r[u+1],c=l;c=0;s--)m[s]=-1,-1!==(u=h[s])&&(0==d[v+u]++&&(d[g+u]=s),d[0+s]=d[y+u],d[y+u]=s);for(t.lnz=0,t.m2=a,u=0;u=0;){e=n[f];var p=i?i[e]:e;Bp(c,e)||(qp(c,e),n[l+f]=p<0?0:zp(c[p]));var m=1;for(o=n[l+f],s=p<0?0:zp(c[p+1]);o{var{divideScalar:t,multiply:r,subtract:n}=e;return function(e,i,a,o,s,u,c){var l,f,p,m,h=e._values,d=e._index,y=e._ptr,g=e._size[1],v=i._values,x=i._index,b=i._ptr,w=function(e,t,r,n,i){var a,o,s,u=e._ptr,c=e._size,l=t._index,f=t._ptr,p=c[1],m=p;for(o=f[r],s=f[r+1],a=o;a{var{abs:t,divideScalar:r,multiply:n,subtract:i,larger:a,largerEq:o,SparseMatrix:s}=e,u=Ip({divideScalar:r,multiply:n,subtract:i});return function(e,i,c){if(!e)return null;var l,f=e._size[1],p=100,m=100;i&&(l=i.q,p=i.lnz||p,m=i.unz||m);var h,d,y=[],g=[],v=[],x=new s({values:y,index:g,ptr:v,size:[f,f]}),b=[],w=[],N=[],M=new s({values:b,index:w,ptr:N,size:[f,f]}),S=[],E=[],A=[];for(h=0;h{var{typed:t,abs:r,add:n,multiply:i,transpose:a,divideScalar:o,subtract:s,larger:u,largerEq:c,SparseMatrix:l}=e,f=Tp({add:n,multiply:i,transpose:a}),p=kp({abs:r,divideScalar:o,multiply:i,subtract:s,larger:u,largerEq:c,SparseMatrix:l});return t("slu",{"SparseMatrix, number, number":function(e,t,r){if(!ce(t)||t<0||t>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(r<0||r>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var n=f(t,e,!1),i=p(e,n,r);return{L:i.L,U:i.U,p:i.pinv,q:n.q,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\np: "+this.p.toString()+(this.q?"\nq: "+this.q.toString():"")+"\n"}}}})})),Fp=W("det",["typed","matrix","subtract","multiply","unaryMinus","lup"],(e=>{var{typed:t,matrix:r,subtract:n,multiply:i,unaryMinus:a,lup:o}=e;return t("det",{any:function(e){return $(e)},"Array | Matrix":function(e){var t;switch((t=f(e)?e.size():Array.isArray(e)?(e=r(e)).size():[]).length){case 0:return $(e);case 1:if(1===t[0])return $(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:var s=t[0];if(s===t[1])return function(e,t,r){if(1===t)return $(e[0][0]);if(2===t)return n(i(e[0][0],e[1][1]),i(e[1][0],e[0][1]));for(var s=o(e),u=s.U[0][0],c=1;c=t)break;for(var m=f,h=0;!p[s.p[m]];)p[s.p[m]]=!0,m=s.p[m],h++;h%2==0&&l++}return l%2==0?u:a(u)}(e.clone().valueOf(),s);throw new RangeError("Matrix must be square (size: "+De(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+De(t)+")")}}})})),Up="distance",Pp=W(Up,["typed","addScalar","subtract","divideScalar","multiplyScalar","unaryMinus","sqrt","abs"],(e=>{var{typed:t,addScalar:r,subtract:n,multiplyScalar:i,divideScalar:o,unaryMinus:s,sqrt:u,abs:c}=e;return t(Up,{"Array, Array, Array":function(e,t,r){if(2===e.length&&2===t.length&&2===r.length){if(!f(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!f(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!f(r))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var a=o(n(r[1],r[0]),n(t[1],t[0])),u=i(i(a,a),t[0]),c=s(i(a,t[0])),l=e[1];return y(e[0],e[1],u,c,l)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(e,t,r){if(2===Object.keys(e).length&&2===Object.keys(t).length&&2===Object.keys(r).length){if(!f(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!f(t))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!f(r))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"lineOnePtX"in t&&"lineOnePtY"in t&&"lineTwoPtX"in r&&"lineTwoPtY"in r){var a=o(n(r.lineTwoPtY,r.lineTwoPtX),n(t.lineOnePtY,t.lineOnePtX)),u=i(i(a,a),t.lineOnePtX),c=s(i(a,t.lineOnePtX)),l=e.pointX;return y(e.pointX,e.pointY,u,c,l)}throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(e,t){if(2===e.length&&3===t.length){if(!f(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!p(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return y(e[0],e[1],t[0],t[1],t[2])}if(3===e.length&&6===t.length){if(!p(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!h(t))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return g(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}if(e.length===t.length&&e.length>0){if(!m(e))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!m(t))throw new TypeError("All values of an array should be numbers or BigNumbers");return v(e,t)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,t){if(2===Object.keys(e).length&&3===Object.keys(t).length){if(!f(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"xCoeffLine"in t&&"yCoeffLine"in t&&"constant"in t)return y(e.pointX,e.pointY,t.xCoeffLine,t.yCoeffLine,t.constant);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&6===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!h(t))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"x0"in t&&"y0"in t&&"z0"in t&&"a"in t&&"b"in t&&"c"in t)return g(e.pointX,e.pointY,e.pointZ,t.x0,t.y0,t.z0,t.a,t.b,t.c);throw new TypeError("Key names do not match")}if(2===Object.keys(e).length&&2===Object.keys(t).length){if(!f(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!f(t))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointTwoX"in t&&"pointTwoY"in t)return v([e.pointOneX,e.pointOneY],[t.pointTwoX,t.pointTwoY]);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&3===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointOneZ"in e&&"pointTwoX"in t&&"pointTwoY"in t&&"pointTwoZ"in t)return v([e.pointOneX,e.pointOneY,e.pointOneZ],[t.pointTwoX,t.pointTwoY,t.pointTwoZ]);throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},Array:function(e){if(!function(e){if(2===e[0].length&&l(e[0][0])&&l(e[0][1])){if(e.some((e=>2!==e.length||!l(e[0])||!l(e[1]))))return!1}else{if(!(3===e[0].length&&l(e[0][0])&&l(e[0][1])&&l(e[0][2])))return!1;if(e.some((e=>3!==e.length||!l(e[0])||!l(e[1])||!l(e[2]))))return!1}return!0}(e))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return function(e){for(var t=[],r=[],n=[],i=0;i{var{typed:t,addScalar:r,subtract:n,multiplyScalar:i,divideScalar:a,pow:o,factorial:s,combinations:u,isNegative:c,isInteger:l,larger:f}=e;return t(jp,{"number | BigNumber, number | BigNumber":function(e,t){if(!l(e)||c(e)||!l(t)||c(t))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(f(t,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");for(var p=s(t),m=0,h=0;h<=t;h++){var d=o(-1,n(t,h)),y=u(t,h),g=o(h,e);m=r(m,i(i(y,g),d))}return a(m,p)}})})),Hp="catalan",$p=W(Hp,["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],(e=>{var{typed:t,addScalar:r,divideScalar:n,multiplyScalar:i,combinations:a,isNegative:o,isInteger:s}=e;return t(Hp,{"number | BigNumber":function(e){if(!s(e)||o(e))throw new TypeError("Non-negative integer value expected in function catalan");return n(a(i(e,2),e),r(e,1))}})})),Gp=W("log",["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,Complex:i}=e;return t("log",{number:function(e){return e>=0||r.predictable?Ga(e):new i(e,0).log()},Complex:function(e){return e.log()},BigNumber:function(e){return!e.isNegative()||r.predictable?e.ln():new i(e.toNumber(),0).log()},"Array | Matrix":function(e){return $t(e,this)},"any, any":function(e,t){return n(this(e),this(t))}})})),Zp="dotDivide",Vp=W(Zp,["typed","matrix","equalScalar","divideScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,equalScalar:n,divideScalar:i,DenseMatrix:a}=e,o=nc({typed:t,equalScalar:n}),s=ic({typed:t}),u=yc({typed:t,DenseMatrix:a}),c=oc({typed:t,equalScalar:n}),l=sc({typed:t,DenseMatrix:a}),f=ec({typed:t}),p=tc({typed:t});return t(Zp,{"any, any":i,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,i,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,i,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,i,!1)},"DenseMatrix, DenseMatrix":function(e,t){return f(e,t,i)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return c(e,t,i,!1)},"DenseMatrix, any":function(e,t){return p(e,t,i,!1)},"any, SparseMatrix":function(e,t){return l(t,e,i,!0)},"any, DenseMatrix":function(e,t){return p(t,e,i,!0)},"Array, any":function(e,t){return p(r(e),t,i,!1).valueOf()},"any, Array":function(e,t){return p(r(t),e,i,!0).valueOf()}})})),Wp="usolveAll",Jp=W(Wp,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(Wp,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=l-1;h>=0;h--)for(var d=r.length,y=0;y=b;N--){var M=p[N];M===h?w=f[N]:Mnew s({data:e.map((e=>[e])),size:[c,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return c(e,t)},"Array, Array | Matrix":function(e,t){return c(r(e),t).map((e=>e.valueOf()))}});function c(e,t){for(var r=[u(e,t,!0)._data.map((e=>e[0]))],c=e._data,l=e._size[0],f=e._size[1]-1;f>=0;f--)for(var p=r.length,m=0;m=0;y--)d[y]=a(d[y],c[y][f]);r.push(d)}}else{if(0===m)return[];r.splice(m,1),m-=1,p-=1}else{h[f]=n(h[f],c[f][f]);for(var g=f-1;g>=0;g--)h[g]=a(h[g],i(h[f],c[g][f]))}}return r.map((e=>new s({data:e.map((e=>[e])),size:[l,1]})))}})),Yp="hypot",Xp=W(Yp,["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],(e=>{var{typed:t,abs:r,addScalar:n,divideScalar:i,multiplyScalar:a,sqrt:o,smaller:s,isPositive:u}=e;return t(Yp,{"... number | BigNumber":function(e){for(var t=0,c=0,l=0;l{var{typed:r,matrix:n,zeros:i,identity:a,isZero:o,equal:s,sign:u,sqrt:c,conj:l,unaryMinus:f,addScalar:p,divideScalar:m,multiplyScalar:h,subtract:d,complex:y}=t;return e(r("qr",{DenseMatrix:function(e){return v(e)},SparseMatrix:function(e){return function(e){throw new Error("qr not implemented for sparse matrices yet")}()},Array:function(e){var t=v(n(e));return{Q:t.Q.valueOf(),R:t.R.valueOf()}}}),{_denseQRimpl:g});function g(e){var t,r,n,y=e._size[0],g=e._size[1],v=a([y],"dense"),x=v._data,b=e.clone(),w=b._data,N=i([y],"");for(n=0;n0)for(var n="Complex"===r[0][0].type?y(0):0,i=0;i{var{typed:t,matrix:r,divideScalar:n,addScalar:i,multiply:a,unaryMinus:o,det:s,identity:u,abs:c}=e;return t("inv",{"Array | Matrix":function(e){var t=f(e)?e.size():je(e);switch(t.length){case 1:if(1===t[0])return f(e)?r([n(1,e.valueOf()[0])]):[n(1,e[0])];throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:var i=t[0],a=t[1];if(i===a)return f(e)?r(l(e.valueOf(),i,a),e.storage()):l(e,i,a);throw new RangeError("Matrix must be square (size: "+De(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+De(t)+")")}},any:function(e){return n(1,e)}});function l(e,t,r){var l,f,p,m,h;if(1===t){if(0===(m=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero");return[[n(1,m)]]}if(2===t){var d=s(e);if(0===d)throw Error("Cannot calculate inverse, determinant is zero");return[[n(e[1][1],d),n(o(e[0][1]),d)],[n(o(e[1][0]),d),n(e[0][0],d)]]}var y=e.concat();for(l=0;lx&&(x=c(y[l][v]),b=l),l++;if(0===x)throw Error("Cannot calculate inverse, determinant is zero");(l=b)!==v&&(h=y[v],y[v]=y[l],y[l]=h,h=g[v],g[v]=g[l],g[l]=h);var w=y[v],N=g[v];for(l=0;l{var{typed:t,abs:r,add:n,identity:i,inv:a,multiply:o}=e;return t(em,{Matrix:function(e){var t=e.size();if(2!==t.length||t[0]!==t[1])throw new RangeError("Matrix must be square (size: "+De(t)+")");for(var u=t[0],c=function(e,t){for(var r=0;r<30;r++)for(var n=0;n<=r;n++){var i=r-n;if(s(e,n,i)<1e-15)return{q:n,j:i}}throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)")}(function(e){for(var t=e.size()[0],n=0,i=0;i1&&(g=o(g,p),v=-v),m=n(m,o(y=y*(l-x+1)/((2*l-x+1)*x),g)),d=n(d,o(y*v,g));for(var b=o(a(d),m),w=0;w{var{typed:t,matrix:r,multiply:n,equalScalar:i,divideScalar:a,inv:o}=e,s=oc({typed:t,equalScalar:i}),u=tc({typed:t});return t("divide",G({"Array | Matrix, Array | Matrix":function(e,t){return n(e,o(t))},"DenseMatrix, any":function(e,t){return u(e,t,a,!1)},"SparseMatrix, any":function(e,t){return s(e,t,a,!1)},"Array, any":function(e,t){return u(r(e),t,a,!1).valueOf()},"any, Array | Matrix":function(e,t){return n(e,o(t))}},a.signatures))})),nm="kldivergence",im=W(nm,["typed","matrix","divide","sum","multiply","dotDivide","log","isNumeric"],(e=>{var{typed:t,matrix:r,divide:n,sum:i,multiply:a,dotDivide:o,log:s,isNumeric:u}=e;return t(nm,{"Array, Array":function(e,t){return c(r(e),r(t))},"Matrix, Array":function(e,t){return c(e,r(t))},"Array, Matrix":function(e,t){return c(r(e),t)},"Matrix, Matrix":function(e,t){return c(e,t)}});function c(e,t){var r=t.size().length,c=e.size().length;if(r>1)throw new Error("first object must be one dimensional");if(c>1)throw new Error("second object must be one dimensional");if(r!==c)throw new Error("Length of two vectors must be equal");if(0===i(e))throw new Error("Sum of elements in first object must be non zero");if(0===i(t))throw new Error("Sum of elements in second object must be non zero");var l=n(e,i(e)),f=n(t,i(t)),p=i(a(l,s(o(l,f))));return u(p)?p:Number.NaN}})),am="bellNumbers",om=W(am,["typed","addScalar","isNegative","isInteger","stirlingS2"],(e=>{var{typed:t,addScalar:r,isNegative:n,isInteger:i,stirlingS2:a}=e;return t(am,{"number | BigNumber":function(e){if(!i(e)||n(e))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var t=0,o=0;o<=e;o++)t=r(t,a(e,o));return t}})})),sm="log1p",um=W(sm,["typed","config","divideScalar","log","Complex"],(e=>{var{typed:t,config:r,divideScalar:n,log:i,Complex:a}=e;return t(sm,{number:function(e){return e>=-1||r.predictable?me(e):o(new a(e,0))},Complex:o,BigNumber:function(e){var t=e.plus(1);return!t.isNegative()||r.predictable?t.ln():o(new a(e.toNumber(),0))},"Array | Matrix":function(e){return $t(e,this)},"any, any":function(e,t){return n(this(e),i(t))}});function o(e){var t=e.re+1;return new a(Math.log(Math.sqrt(t*t+e.im*e.im)),Math.atan2(e.im,t))}}));function cm(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function lm(e){for(var t=1;t{var r,n,i,{on:a,config:s,addScalar:c,subtract:l,multiplyScalar:f,divideScalar:p,pow:m,abs:h,fix:d,round:y,equal:g,isNumeric:v,format:x,number:b,Complex:w,BigNumber:N,Fraction:M}=t,S=b;function E(e,t){if(!(this instanceof E))throw new Error("Constructor must be called with the new operator");if(null!=e&&!v(e)&&!o(e))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(void 0!==t&&("string"!=typeof t||""===t))throw new TypeError("Second parameter in Unit constructor must be a string");if(void 0!==t){var r=E.parse(t);this.units=r.units,this.dimensions=r.dimensions}else{this.units=[{unit:U,prefix:I.NONE,power:0}],this.dimensions=[];for(var n=0;n="0"&&e<="9"}function C(){n++,i=r.charAt(n)}function _(e){n=e,i=r.charAt(n)}function T(){var e="",t=n;if("+"===i?C():"-"===i&&(e+=i,C()),!function(e){return e>="0"&&e<="9"||"."===e}(i))return _(t),null;if("."===i){if(e+=i,C(),!O(i))return _(t),null}else{for(;O(i);)e+=i,C();"."===i&&(e+=i,C())}for(;O(i);)e+=i,C();if("E"===i||"e"===i){var r="",a=n;if(r+=i,C(),"+"!==i&&"-"!==i||(r+=i,C()),!O(i))return _(a),e;for(e+=r;O(i);)e+=i,C()}return e}function B(){for(var e="";O(i)||E.isValidAlpha(i);)e+=i,C();var t=e.charAt(0);return E.isValidAlpha(t)?e:null}function q(e){return i===e?(C(),e):null}E.prototype.type="Unit",E.prototype.isUnit=!0,E.parse=function(e,t){if(t=t||{},n=-1,i="","string"!=typeof(r=e))throw new TypeError("Invalid argument in Unit.parse, string expected");var a=new E;a.units=[];var o=1,u=!1;C(),A();var c=T(),l=null;if(c){if("BigNumber"===s.number)l=new N(c);else if("Fraction"===s.number)try{l=new M(c)}catch(e){l=parseFloat(c)}else l=parseFloat(c);A(),q("*")?(o=1,u=!0):q("/")&&(o=-1,u=!0)}for(var f=[],p=1;;){for(A();"("===i;)f.push(o),p*=o,o=1,C(),A();var m;if(!i)break;var h=i;if(null===(m=B()))throw new SyntaxError('Unexpected "'+h+'" in "'+r+'" at index '+n.toString());var d=z(m);if(null===d)throw new SyntaxError('Unit "'+m+'" not found.');var y=o*p;if(A(),q("^")){A();var g=T();if(null===g)throw new SyntaxError('In "'+e+'", "^" must be followed by a floating-point number');y*=g}a.units.push({unit:d.unit,prefix:d.prefix,power:y});for(var v=0;v1||Math.abs(this.units[0].power-1)>1e-15)},E.prototype._normalize=function(e){var t,r,n,i,a;if(null==e||0===this.units.length)return e;if(this._isDerived()){var o=e;a=E._getNumberConverter(L(e));for(var s=0;s{if(V(P,e)){var t=P[e];return{unit:t,prefix:t.prefixes[""]}}for(var r in P)if(V(P,r)&&ze(e,r)){var n=P[r],i=e.length-r.length,a=e.substring(0,i),o=V(n.prefixes,a)?n.prefixes[a]:void 0;if(void 0!==o)return{unit:n,prefix:o}}return null}),{hasher:e=>e[0],limit:100});function D(e){return e.equalBase(R.NONE)&&null!==e.value&&!s.predictable?e.value:e}E.isValuelessUnit=function(e){return null!==z(e)},E.prototype.hasBase=function(e){if("string"==typeof e&&(e=R[e]),!e)return!1;for(var t=0;t1e-12)return!1;return!0},E.prototype.equalBase=function(e){for(var t=0;t1e-12)return!1;return!0},E.prototype.equals=function(e){return this.equalBase(e)&&g(this.value,e.value)},E.prototype.multiply=function(e){for(var t=this.clone(),r=0;r1e-12&&(V(Z,s)?n.push({unit:Z[s].unit,prefix:Z[s].prefix,power:r.dimensions[o]||0}):a=!0)}n.length1e-12){if(!V(G.si,n))throw new Error("Cannot express custom unit "+n+" in SI units");t.push({unit:G.si[n].unit,prefix:G.si[n].prefix,power:e.dimensions[r]||0})}}return e.units=t,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,e},E.prototype.formatUnits=function(){for(var e="",t="",r=0,n=0,i=0;i0?(r++,e+=" "+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power-1)>1e-15&&(e+="^"+this.units[i].power)):this.units[i].power<0&&n++;if(n>0)for(var a=0;a0?(t+=" "+this.units[a].prefix.name+this.units[a].unit.name,Math.abs(this.units[a].power+1)>1e-15&&(t+="^"+-this.units[a].power)):(t+=" "+this.units[a].prefix.name+this.units[a].unit.name,t+="^"+this.units[a].power));e=e.substr(1),t=t.substr(1),r>1&&n>0&&(e="("+e+")"),n>1&&r>0&&(t="("+t+")");var o=e;return r>0&&n>0&&(o+=" / "),o+t},E.prototype.format=function(e){var t=this.skipAutomaticSimplification||null===this.value?this.clone():this.simplify(),r=!1;for(var n in void 0!==t.value&&null!==t.value&&o(t.value)&&(r=Math.abs(t.value.re)<1e-14),t.units)V(t.units,n)&&t.units[n].unit&&("VA"===t.units[n].unit.name&&r?t.units[n].unit=P.VAR:"VAR"!==t.units[n].unit.name||r||(t.units[n].unit=P.VA));1!==t.units.length||t.fixPrefix||Math.abs(t.units[0].power-Math.round(t.units[0].power))<1e-14&&(t.units[0].prefix=t._bestPrefix());var i=t._denormalize(t.value),a=null!==t.value?x(i,e||{}):"",s=t.formatUnits();return t.value&&o(t.value)&&(a="("+a+")"),s.length>0&&a.length>0&&(a+=" "),a+s},E.prototype._bestPrefix=function(){if(1!==this.units.length)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var e=null!==this.value?h(this.value):0,t=h(this.units[0].unit.value),r=this.units[0].prefix;if(0===e)return r;var n=this.units[0].power,i=Math.log(e/Math.pow(r.value*t,n))/Math.LN10-1.2;if(i>-2.200001&&i<1.800001)return r;i=Math.abs(i);var a=this.units[0].unit.prefixes;for(var o in a)if(V(a,o)){var s=a[o];if(s.scientific){var u=Math.abs(Math.log(e/Math.pow(s.value*t,n))/Math.LN10-1.2);(u0))},P={meter:{name:"meter",base:R.LENGTH,prefixes:I.LONG,value:1,offset:0},inch:{name:"inch",base:R.LENGTH,prefixes:I.NONE,value:.0254,offset:0},foot:{name:"foot",base:R.LENGTH,prefixes:I.NONE,value:.3048,offset:0},yard:{name:"yard",base:R.LENGTH,prefixes:I.NONE,value:.9144,offset:0},mile:{name:"mile",base:R.LENGTH,prefixes:I.NONE,value:1609.344,offset:0},link:{name:"link",base:R.LENGTH,prefixes:I.NONE,value:.201168,offset:0},rod:{name:"rod",base:R.LENGTH,prefixes:I.NONE,value:5.0292,offset:0},chain:{name:"chain",base:R.LENGTH,prefixes:I.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:R.LENGTH,prefixes:I.NONE,value:1e-10,offset:0},m:{name:"m",base:R.LENGTH,prefixes:I.SHORT,value:1,offset:0},in:{name:"in",base:R.LENGTH,prefixes:I.NONE,value:.0254,offset:0},ft:{name:"ft",base:R.LENGTH,prefixes:I.NONE,value:.3048,offset:0},yd:{name:"yd",base:R.LENGTH,prefixes:I.NONE,value:.9144,offset:0},mi:{name:"mi",base:R.LENGTH,prefixes:I.NONE,value:1609.344,offset:0},li:{name:"li",base:R.LENGTH,prefixes:I.NONE,value:.201168,offset:0},rd:{name:"rd",base:R.LENGTH,prefixes:I.NONE,value:5.02921,offset:0},ch:{name:"ch",base:R.LENGTH,prefixes:I.NONE,value:20.1168,offset:0},mil:{name:"mil",base:R.LENGTH,prefixes:I.NONE,value:254e-7,offset:0},m2:{name:"m2",base:R.SURFACE,prefixes:I.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:R.SURFACE,prefixes:I.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:R.SURFACE,prefixes:I.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:R.SURFACE,prefixes:I.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:R.SURFACE,prefixes:I.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:R.SURFACE,prefixes:I.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:R.SURFACE,prefixes:I.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:R.SURFACE,prefixes:I.NONE,value:6.4516e-10,offset:0},acre:{name:"acre",base:R.SURFACE,prefixes:I.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:R.SURFACE,prefixes:I.NONE,value:1e4,offset:0},m3:{name:"m3",base:R.VOLUME,prefixes:I.CUBIC,value:1,offset:0},L:{name:"L",base:R.VOLUME,prefixes:I.SHORT,value:.001,offset:0},l:{name:"l",base:R.VOLUME,prefixes:I.SHORT,value:.001,offset:0},litre:{name:"litre",base:R.VOLUME,prefixes:I.LONG,value:.001,offset:0},cuin:{name:"cuin",base:R.VOLUME,prefixes:I.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:R.VOLUME,prefixes:I.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:R.VOLUME,prefixes:I.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:R.VOLUME,prefixes:I.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:R.VOLUME,prefixes:I.NONE,value:15e-6,offset:0},drop:{name:"drop",base:R.VOLUME,prefixes:I.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:R.VOLUME,prefixes:I.NONE,value:5e-8,offset:0},minim:{name:"minim",base:R.VOLUME,prefixes:I.NONE,value:6.161152e-8,offset:0},fluiddram:{name:"fluiddram",base:R.VOLUME,prefixes:I.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:R.VOLUME,prefixes:I.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:R.VOLUME,prefixes:I.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:R.VOLUME,prefixes:I.NONE,value:1e-6,offset:0},cup:{name:"cup",base:R.VOLUME,prefixes:I.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:R.VOLUME,prefixes:I.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:R.VOLUME,prefixes:I.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:R.VOLUME,prefixes:I.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:R.VOLUME,prefixes:I.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:R.VOLUME,prefixes:I.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:R.VOLUME,prefixes:I.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:R.VOLUME,prefixes:I.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:R.VOLUME,prefixes:I.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:R.VOLUME,prefixes:I.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:R.VOLUME,prefixes:I.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:R.VOLUME,prefixes:I.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:R.VOLUME,prefixes:I.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:R.VOLUME,prefixes:I.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:R.VOLUME,prefixes:I.NONE,value:.1173478,offset:0},obl:{name:"obl",base:R.VOLUME,prefixes:I.NONE,value:.1589873,offset:0},g:{name:"g",base:R.MASS,prefixes:I.SHORT,value:.001,offset:0},gram:{name:"gram",base:R.MASS,prefixes:I.LONG,value:.001,offset:0},ton:{name:"ton",base:R.MASS,prefixes:I.SHORT,value:907.18474,offset:0},t:{name:"t",base:R.MASS,prefixes:I.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:R.MASS,prefixes:I.LONG,value:1e3,offset:0},grain:{name:"grain",base:R.MASS,prefixes:I.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:R.MASS,prefixes:I.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:R.MASS,prefixes:I.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:R.MASS,prefixes:I.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:R.MASS,prefixes:I.NONE,value:45.359237,offset:0},stick:{name:"stick",base:R.MASS,prefixes:I.NONE,value:.115,offset:0},stone:{name:"stone",base:R.MASS,prefixes:I.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:R.MASS,prefixes:I.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:R.MASS,prefixes:I.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:R.MASS,prefixes:I.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:R.MASS,prefixes:I.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:R.MASS,prefixes:I.NONE,value:45.359237,offset:0},s:{name:"s",base:R.TIME,prefixes:I.SHORT,value:1,offset:0},min:{name:"min",base:R.TIME,prefixes:I.NONE,value:60,offset:0},h:{name:"h",base:R.TIME,prefixes:I.NONE,value:3600,offset:0},second:{name:"second",base:R.TIME,prefixes:I.LONG,value:1,offset:0},sec:{name:"sec",base:R.TIME,prefixes:I.LONG,value:1,offset:0},minute:{name:"minute",base:R.TIME,prefixes:I.NONE,value:60,offset:0},hour:{name:"hour",base:R.TIME,prefixes:I.NONE,value:3600,offset:0},day:{name:"day",base:R.TIME,prefixes:I.NONE,value:86400,offset:0},week:{name:"week",base:R.TIME,prefixes:I.NONE,value:604800,offset:0},month:{name:"month",base:R.TIME,prefixes:I.NONE,value:2629800,offset:0},year:{name:"year",base:R.TIME,prefixes:I.NONE,value:31557600,offset:0},decade:{name:"decade",base:R.TIME,prefixes:I.NONE,value:315576e3,offset:0},century:{name:"century",base:R.TIME,prefixes:I.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:R.TIME,prefixes:I.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:R.FREQUENCY,prefixes:I.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:R.FREQUENCY,prefixes:I.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:R.ANGLE,prefixes:I.SHORT,value:1,offset:0},radian:{name:"radian",base:R.ANGLE,prefixes:I.LONG,value:1,offset:0},deg:{name:"deg",base:R.ANGLE,prefixes:I.SHORT,value:null,offset:0},degree:{name:"degree",base:R.ANGLE,prefixes:I.LONG,value:null,offset:0},grad:{name:"grad",base:R.ANGLE,prefixes:I.SHORT,value:null,offset:0},gradian:{name:"gradian",base:R.ANGLE,prefixes:I.LONG,value:null,offset:0},cycle:{name:"cycle",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:R.ANGLE,prefixes:I.NONE,value:null,offset:0},A:{name:"A",base:R.CURRENT,prefixes:I.SHORT,value:1,offset:0},ampere:{name:"ampere",base:R.CURRENT,prefixes:I.LONG,value:1,offset:0},K:{name:"K",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:0},degC:{name:"degC",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:273.15},degF:{name:"degF",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:0},celsius:{name:"celsius",base:R.TEMPERATURE,prefixes:I.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:R.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:R.AMOUNT_OF_SUBSTANCE,prefixes:I.SHORT,value:1,offset:0},mole:{name:"mole",base:R.AMOUNT_OF_SUBSTANCE,prefixes:I.LONG,value:1,offset:0},cd:{name:"cd",base:R.LUMINOUS_INTENSITY,prefixes:I.SHORT,value:1,offset:0},candela:{name:"candela",base:R.LUMINOUS_INTENSITY,prefixes:I.LONG,value:1,offset:0},N:{name:"N",base:R.FORCE,prefixes:I.SHORT,value:1,offset:0},newton:{name:"newton",base:R.FORCE,prefixes:I.LONG,value:1,offset:0},dyn:{name:"dyn",base:R.FORCE,prefixes:I.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:R.FORCE,prefixes:I.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:R.FORCE,prefixes:I.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:R.FORCE,prefixes:I.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:R.FORCE,prefixes:I.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:R.FORCE,prefixes:I.NONE,value:9.80665,offset:0},J:{name:"J",base:R.ENERGY,prefixes:I.SHORT,value:1,offset:0},joule:{name:"joule",base:R.ENERGY,prefixes:I.SHORT,value:1,offset:0},erg:{name:"erg",base:R.ENERGY,prefixes:I.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:R.ENERGY,prefixes:I.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:R.ENERGY,prefixes:I.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:R.ENERGY,prefixes:I.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:R.ENERGY,prefixes:I.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:R.POWER,prefixes:I.SHORT,value:1,offset:0},watt:{name:"watt",base:R.POWER,prefixes:I.LONG,value:1,offset:0},hp:{name:"hp",base:R.POWER,prefixes:I.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:R.POWER,prefixes:I.SHORT,value:w.I,offset:0},VA:{name:"VA",base:R.POWER,prefixes:I.SHORT,value:1,offset:0},Pa:{name:"Pa",base:R.PRESSURE,prefixes:I.SHORT,value:1,offset:0},psi:{name:"psi",base:R.PRESSURE,prefixes:I.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:R.PRESSURE,prefixes:I.NONE,value:101325,offset:0},bar:{name:"bar",base:R.PRESSURE,prefixes:I.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:R.PRESSURE,prefixes:I.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:R.PRESSURE,prefixes:I.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:R.PRESSURE,prefixes:I.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:R.PRESSURE,prefixes:I.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:R.ELECTRIC_CHARGE,prefixes:I.LONG,value:1,offset:0},C:{name:"C",base:R.ELECTRIC_CHARGE,prefixes:I.SHORT,value:1,offset:0},farad:{name:"farad",base:R.ELECTRIC_CAPACITANCE,prefixes:I.LONG,value:1,offset:0},F:{name:"F",base:R.ELECTRIC_CAPACITANCE,prefixes:I.SHORT,value:1,offset:0},volt:{name:"volt",base:R.ELECTRIC_POTENTIAL,prefixes:I.LONG,value:1,offset:0},V:{name:"V",base:R.ELECTRIC_POTENTIAL,prefixes:I.SHORT,value:1,offset:0},ohm:{name:"ohm",base:R.ELECTRIC_RESISTANCE,prefixes:I.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:R.ELECTRIC_INDUCTANCE,prefixes:I.LONG,value:1,offset:0},H:{name:"H",base:R.ELECTRIC_INDUCTANCE,prefixes:I.SHORT,value:1,offset:0},siemens:{name:"siemens",base:R.ELECTRIC_CONDUCTANCE,prefixes:I.LONG,value:1,offset:0},S:{name:"S",base:R.ELECTRIC_CONDUCTANCE,prefixes:I.SHORT,value:1,offset:0},weber:{name:"weber",base:R.MAGNETIC_FLUX,prefixes:I.LONG,value:1,offset:0},Wb:{name:"Wb",base:R.MAGNETIC_FLUX,prefixes:I.SHORT,value:1,offset:0},tesla:{name:"tesla",base:R.MAGNETIC_FLUX_DENSITY,prefixes:I.LONG,value:1,offset:0},T:{name:"T",base:R.MAGNETIC_FLUX_DENSITY,prefixes:I.SHORT,value:1,offset:0},b:{name:"b",base:R.BIT,prefixes:I.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:R.BIT,prefixes:I.BINARY_LONG,value:1,offset:0},B:{name:"B",base:R.BIT,prefixes:I.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:R.BIT,prefixes:I.BINARY_LONG,value:8,offset:0}},j={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function H(e){if("BigNumber"===e.number){var t=Cn(N);P.rad.value=new N(1),P.deg.value=t.div(180),P.grad.value=t.div(200),P.cycle.value=t.times(2),P.arcsec.value=t.div(648e3),P.arcmin.value=t.div(10800)}else P.rad.value=1,P.deg.value=Math.PI/180,P.grad.value=Math.PI/200,P.cycle.value=2*Math.PI,P.arcsec.value=Math.PI/648e3,P.arcmin.value=Math.PI/10800;P.radian.value=P.rad.value,P.degree.value=P.deg.value,P.gradian.value=P.grad.value}H(s),a&&a("config",(function(e,t){e.number!==t.number&&H(e)}));var G={si:{NONE:{unit:U,prefix:I.NONE[""]},LENGTH:{unit:P.m,prefix:I.SHORT[""]},MASS:{unit:P.g,prefix:I.SHORT.k},TIME:{unit:P.s,prefix:I.SHORT[""]},CURRENT:{unit:P.A,prefix:I.SHORT[""]},TEMPERATURE:{unit:P.K,prefix:I.SHORT[""]},LUMINOUS_INTENSITY:{unit:P.cd,prefix:I.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:P.mol,prefix:I.SHORT[""]},ANGLE:{unit:P.rad,prefix:I.SHORT[""]},BIT:{unit:P.bits,prefix:I.SHORT[""]},FORCE:{unit:P.N,prefix:I.SHORT[""]},ENERGY:{unit:P.J,prefix:I.SHORT[""]},POWER:{unit:P.W,prefix:I.SHORT[""]},PRESSURE:{unit:P.Pa,prefix:I.SHORT[""]},ELECTRIC_CHARGE:{unit:P.C,prefix:I.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:P.F,prefix:I.SHORT[""]},ELECTRIC_POTENTIAL:{unit:P.V,prefix:I.SHORT[""]},ELECTRIC_RESISTANCE:{unit:P.ohm,prefix:I.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:P.H,prefix:I.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:P.S,prefix:I.SHORT[""]},MAGNETIC_FLUX:{unit:P.Wb,prefix:I.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:P.T,prefix:I.SHORT[""]},FREQUENCY:{unit:P.Hz,prefix:I.SHORT[""]}}};G.cgs=JSON.parse(JSON.stringify(G.si)),G.cgs.LENGTH={unit:P.m,prefix:I.SHORT.c},G.cgs.MASS={unit:P.g,prefix:I.SHORT[""]},G.cgs.FORCE={unit:P.dyn,prefix:I.SHORT[""]},G.cgs.ENERGY={unit:P.erg,prefix:I.NONE[""]},G.us=JSON.parse(JSON.stringify(G.si)),G.us.LENGTH={unit:P.ft,prefix:I.NONE[""]},G.us.MASS={unit:P.lbm,prefix:I.NONE[""]},G.us.TEMPERATURE={unit:P.degF,prefix:I.NONE[""]},G.us.FORCE={unit:P.lbf,prefix:I.NONE[""]},G.us.ENERGY={unit:P.BTU,prefix:I.BTU[""]},G.us.POWER={unit:P.hp,prefix:I.NONE[""]},G.us.PRESSURE={unit:P.psi,prefix:I.NONE[""]},G.auto=JSON.parse(JSON.stringify(G.si));var Z=G.auto;for(var W in E.setUnitSystem=function(e){if(!V(G,e))throw new Error("Unit system "+e+" does not exist. Choices are: "+Object.keys(G).join(", "));Z=G[e]},E.getUnitSystem=function(){for(var e in G)if(V(G,e)&&G[e]===Z)return e},E.typeConverters={BigNumber:function(e){return new N(e+"")},Fraction:function(e){return new M(e)},Complex:function(e){return e},number:function(e){return e}},E._getNumberConverter=function(e){if(!E.typeConverters[e])throw new TypeError('Unsupported type "'+e+'"');return E.typeConverters[e]},P)if(V(P,W)){var J=P[W];J.dimensions=J.base.dimensions}for(var Y in j)if(V(j,Y)){var X=P[j[Y]],Q={};for(var K in X)V(X,K)&&(Q[K]=X[K]);Q.name=Y,P[Y]=Q}return E.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)},E.createUnit=function(e,t){if("object"!=typeof e)throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(t&&t.override)for(var r in e)if(V(e,r)&&E.deleteUnit(r),e[r].aliases)for(var n=0;n0&&!E.isValidAlpha(i)&&!O(i))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+e+'"')}}(e);var n,a,o,s=null,u=[],c=0;if(t&&"Unit"===t.type)s=t.clone();else if("string"==typeof t)""!==t&&(n=t);else{if("object"!=typeof t)throw new TypeError('Cannot create unit "'+e+'" from "'+t.toString()+'": expecting "string" or "Unit" or "Object"');n=t.definition,a=t.prefixes,c=t.offset,o=t.baseName,t.aliases&&(u=t.aliases.valueOf())}if(u)for(var l=0;l1e-12){h=!1;break}if(h){p=!0,f.base=R[m];break}}if(!p){o=o||e+"_STUFF";var y={dimensions:s.dimensions.slice(0)};y.key=o,R[o]=y,Z[o]={unit:f,prefix:I.NONE[""]},f.base=R[o]}}else{if(o=o||e+"_STUFF",k.indexOf(o)>=0)throw new Error('Cannot create new base unit "'+e+'": a base unit with that name already exists (and cannot be overridden)');for(var g in k.push(o),R)V(R,g)&&(R[g].dimensions[k.length-1]=0);for(var v={dimensions:[]},x=0;x{var{typed:t,Unit:r}=e;return t(pm,{"Object, Object":function(e,t){return r.createUnit(e,t)},Object:function(e){return r.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,t,n){var i={};return i[e]=t,r.createUnit(i,n)},"string, Unit | string | Object":function(e,t){var n={};return n[e]=t,r.createUnit(n,{})},string:function(e){var t={};return t[e]={},r.createUnit(t,{})}})})),hm="sqrtm",dm=W(hm,["typed","abs","add","multiply","sqrt","subtract","inv","size","max","identity"],(e=>{var{typed:t,abs:r,add:n,multiply:i,sqrt:a,subtract:o,inv:s,size:u,max:c,identity:l}=e,p=1e-6;function m(e){var t,a=0,f=e,m=l(u(e));do{var h=f;if(f=i(.5,n(h,s(m))),m=i(.5,n(m,s(h))),(t=c(r(o(f,h))))>p&&++a>1e3)throw new Error("computing square root of matrix: iterative method could not converge")}while(t>p);return f}return t(hm,{"Array | Matrix":function(e){var t=f(e)?e.size():je(e);switch(t.length){case 1:if(1===t[0])return a(e);throw new RangeError("Matrix must be square (size: "+De(t)+")");case 2:if(t[0]===t[1])return m(e);throw new RangeError("Matrix must be square (size: "+De(t)+")");default:throw new RangeError("Matrix must be at most two dimensional (size: "+De(t)+")")}}})})),ym="median",gm=W(ym,["typed","add","divide","compare","partitionSelect"],(e=>{var{typed:t,add:r,divide:n,compare:i,partitionSelect:a}=e;function o(e){try{var t=(e=et(e.valueOf())).length;if(0===t)throw new Error("Cannot calculate median of an empty array");if(t%2==0){for(var r=t/2-1,n=a(e,r+1),o=e[r],c=0;c0&&(o=e[c]);return u(o,n)}var l=a(e,(t-1)/2);return s(l)}catch(e){throw Gr(e,"median")}}var s=t({"number | BigNumber | Complex | Unit":function(e){return e}}),u=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,t){return n(r(e,t),2)}});return t(ym,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("median(A, dim) is not yet supported")},"...":function(e){if(Lt(e))throw new TypeError("Scalar values expected in function median");return o(e)}})})),vm="usolve",xm=W(vm,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:r,divideScalar:n,multiplyScalar:i,subtract:a,equalScalar:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(vm,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var r=(t=u(e,t,!0))._data,c=e._size[0],l=e._size[1],f=e._values,p=e._index,m=e._ptr,h=[],d=l-1;d>=0;d--){var y=r[d][0]||0;if(o(y,0))h[d]=[0];else{for(var g=0,v=[],x=[],b=m[d],w=m[d+1]-1;w>=b;w--){var N=p[w];N===d?g=f[w]:N=0;m--){var h=r[m][0]||0,d=void 0;if(o(h,0))d=0;else{var y=p[m][m];if(o(y,0))throw new Error("Linear system cannot be solved since matrix is singular");d=n(h,y);for(var g=m-1;g>=0;g--)r[g]=[a(r[g][0]||0,i(d,p[g][m]))]}f[m]=[d]}return new s({data:f,size:[c,1]})}}));function bm(e,t){var r,n=t.length,i=[];if(e)for(r=0;r{var{typed:t,matrix:r,lup:n,slu:i,usolve:a,lsolve:o,DenseMatrix:s}=e,u=yp({DenseMatrix:s});return t(wm,{"Array, Array | Matrix":function(e,t){e=r(e);var i=n(e);return p(i.L,i.U,i.p,null,t).valueOf()},"DenseMatrix, Array | Matrix":function(e,t){var r=n(e);return p(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){var r=n(e);return p(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,r,n){var a=i(e,r,n);return p(a.L,a.U,a.p,a.q,t)},"Object, Array | Matrix":function(e,t){return p(e.L,e.U,e.p,e.q,t)}});function c(e){if(f(e))return e;if(l(e))return r(e);throw new TypeError("Invalid Matrix LU decomposition")}function p(e,t,r,n,i){e=c(e),t=c(t),r&&((i=u(e,i,!0))._data=bm(r,i._data));var s=o(e,i),l=a(t,s);return n&&(l._data=bm(n,l._data)),l}}));var Mm=["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","divideScalar","inv","bignumber","multiply","add","larger","column","flatten","number","complex","sqrt","diag","qr","usolve","usolveAll","im","re","smaller","matrixFromColumns","dot"],Sm=W("eigs",Mm,(e=>{var{config:t,typed:r,matrix:n,addScalar:u,subtract:c,equal:l,abs:f,atan:p,cos:m,sin:h,multiplyScalar:d,divideScalar:y,inv:g,bignumber:v,multiply:x,add:b,larger:w,column:N,flatten:M,number:S,complex:E,sqrt:A,diag:O,qr:C,usolve:_,usolveAll:T,im:B,re:q,smaller:z,matrixFromColumns:D,dot:I}=e,k=function(e){var{config:t,addScalar:r,subtract:n,abs:i,atan:a,cos:o,sin:s,multiplyScalar:u,inv:c,bignumber:l,multiply:f,add:p}=e;function m(e,r){for(var n,i=e.length,a=Math.abs(r/i),o=new Array(i),s=0;s=Math.abs(a);){var c=u[0][0],l=u[0][1];e=v(e,(f=e[c][c],p=e[l][l],m=e[c][l],h=void 0,h=p-f,n=Math.abs(h)<=t.epsilon?Math.PI/4:.5*Math.atan(2*m/(p-f))),c,l),o=d(o,n,c,l),u=x(e)}for(var f,p,m,h,y=N(i,0),g=0;g=i(p);){var v=d[0][0],x=d[0][1];e=g(e,(M=e[v][v],S=e[x][x],E=e[v][x],A=void 0,A=n(S,M),o=i(A)<=t.epsilon?l(-1).acos().div(4):u(.5,a(f(2,E,c(A))))),v,x),m=y(m,o,v,x),d=b(e)}for(var M,S,E,A,O=N(s,0),C=0;C2&&void 0!==arguments[2]?arguments[2]:t.epsilon,i=arguments.length>3?arguments[3]:void 0;if("number"===i)return m(e,n);if("BigNumber"===i)return h(e,n);throw TypeError("Unsupported data type: "+i)}}({config:t,addScalar:u,subtract:c,column:N,flatten:M,equal:l,abs:f,atan:p,cos:m,sin:h,multiplyScalar:d,inv:g,bignumber:v,complex:E,multiply:x,add:b}),R=function(e){var{addScalar:t,subtract:r,flatten:n,multiply:i,multiplyScalar:a,divideScalar:o,sqrt:s,abs:u,bignumber:c,diag:l,inv:f,qr:p,usolve:m,usolveAll:h,equal:d,complex:y,larger:g,smaller:v,matrixFromColumns:x,dot:b}=e;function w(e,t,n,i,a,o,s,l){var f="BigNumber"===l,p="Complex"===l,m=f?c(0):p?y(0):0,h=f?c(1):p?y(1):1;if(v(u(n),s))return[[h,m],[m,h]];if(g(u(r(a,o)),s))return[[r(a,i),r(o,i)],[n,n]];var d=r(e,a),x=r(t,a),b=r(n,a),w=r(i,a);return v(u(x),s)?[[d,h],[b,m]]:[[x,m],[w,h]]}function N(e,t){for(var r=0;r=5)return null;for(s=0;;){var u=m(e,a);if(v(O(A(a,[u])),n))break;if(++s>=10)return null;a=C(u)}return a}function E(e,t,r){var n="BigNumber"===r,i="Complex"===r,a=Array(e).fill(0).map((e=>2*Math.random()-1));return n&&(a=a.map((e=>c(e)))),i&&(a=a.map((e=>y(e)))),C(a=A(a,t),r)}function A(e,t){for(var n of t)e=r(e,i(o(b(n,e),b(n,n)),n));return e}function O(e){return u(s(b(e,e)))}function C(e,t){var r="Complex"===t,n="BigNumber"===t?c(1):r?y(1):1;return i(o(n,O(e)),e)}return function(e,m,b,E,A){void 0===A&&(A=!0);var O=function(e,r,n,i,s){var f,p="BigNumber"===i,m="Complex"===i,h=p?c(0):m?y(0):0,x=p?c(1):m?y(1):1,b=p?c(10):2,w=a(b,b);s&&(f=Array(r).fill(x));for(var N=!1;!N;){N=!0;for(var M=0;M1&&(D=l(Array(B-1).fill(g)))),B-=1,_.pop();for(var P=0;P2&&(D=l(Array(B-2).fill(g)))),B-=2,_.pop(),_.pop();for(var L=0;L+r(u(e),u(t)))),I>100){var H=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+T.join(", "));throw H.values=T,H.vectors=[],H}return{values:T,C:m?i(z,function(e,t){for(var r=[],n=0;ni(a,e)))).shift();I.lengthn(e))))}if(0!==B.length){var R=new Error("Failed to find eigenvectors for the following eigenvalues: "+B.join(", "));throw R.values=o,R.vectors=O,R}return O}(e,m,T,_,b,E),C=x(...C)),{values:_,vectors:C}}}({config:t,addScalar:u,subtract:c,multiply:x,multiplyScalar:d,flatten:M,divideScalar:y,sqrt:A,abs:f,bignumber:v,diag:O,qr:C,inv:g,usolve:_,usolveAll:T,equal:l,complex:E,larger:w,smaller:z,matrixFromColumns:D,dot:I});return r("eigs",{Array:function(e){return F(n(e))},"Array, number|BigNumber":function(e,t){return F(n(e),t)},Matrix:function(e){var{values:t,vectors:r}=F(e);return{values:n(t),vectors:n(r)}},"Matrix, number|BigNumber":function(e,t){var{values:r,vectors:i}=F(e,t);return{values:n(r),vectors:n(i)}}});function F(e,r){void 0===r&&(r=t.epsilon);var n=e.size();if(2!==n.length||n[0]!==n[1])throw new RangeError("Matrix must be square (size: "+De(n)+")");var i=e.toArray(),a=n[0];if(function(e,t,r){for(var n=0;n{var{typed:t,abs:r,map:n,median:i,subtract:a}=e;return t("mad",{"Array | Matrix":o,"...":function(e){return o(e)}});function o(e){if(0===(e=et(e.valueOf())).length)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var t=i(e);return i(n(e,(function(e){return r(a(e,t))})))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf("median")?new TypeError(e.message.replace("median","mad")):Gr(e,"mad")}}})),Om="unit",Cm=["typed","Unit"],_m=W(Om,Cm,(e=>{var{typed:t,Unit:r}=e;return t(Om,{Unit:function(e){return e.clone()},string:function(e){return r.isValuelessUnit(e)?new r(null,e):r.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string":function(e,t){return new r(e,t)},"Array | Matrix":function(e){return $t(e,this)}})})),Tm=["typed","config","abs","add","addScalar","matrix","multiply","multiplyScalar","divideScalar","subtract","smaller","equalScalar","flatten"],Bm=W("intersect",Tm,(e=>{var{typed:t,config:r,abs:n,add:i,addScalar:o,matrix:s,multiply:u,multiplyScalar:c,divideScalar:l,subtract:f,smaller:p,equalScalar:m,flatten:h}=e;return t("intersect",{"Array, Array, Array":d,"Array, Array, Array, Array":y,"Matrix, Matrix, Matrix":function(e,t,r){var n=d(e.valueOf(),t.valueOf(),r.valueOf());return null===n?null:s(n)},"Matrix, Matrix, Matrix, Matrix":function(e,t,r,n){var i=y(e.valueOf(),t.valueOf(),r.valueOf(),n.valueOf());return null===i?null:s(i)}});function d(e,t,r){if(e=g(e),t=g(t),r=g(r),!b(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!b(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!function(e){return 4===e.length&&v(e[0])&&v(e[1])&&v(e[2])&&v(e[3])}(r))throw new TypeError("Array with 4 numbers expected as third argument");return function(e,t,r,n,i,a,s,u,p,m){var h=c(e,s),d=c(n,s),y=c(t,u),g=c(i,u),v=c(r,p),x=c(a,p),b=f(f(f(m,h),y),v),w=f(f(f(o(o(d,g),x),h),y),v),N=l(b,w);return[o(e,c(N,f(n,e))),o(t,c(N,f(i,t))),o(r,c(N,f(a,r)))]}(e[0],e[1],e[2],t[0],t[1],t[2],r[0],r[1],r[2],r[3])}function y(e,t,a,s){if(e=g(e),t=g(t),a=g(a),s=g(s),2===e.length){if(!x(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!x(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!x(a))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!x(s))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return function(e,t,a,s){var m=e,h=a,d=f(m,t),y=f(h,s),g=f(c(d[0],y[1]),c(y[0],d[1]));if(p(n(g),r.epsilon))return null;var v=c(y[0],m[1]),x=c(y[1],m[0]),b=c(y[0],h[1]),w=c(y[1],h[0]),N=l(o(f(f(v,x),b),w),g);return i(u(d,N),m)}(e,t,a,s)}if(3===e.length){if(!b(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!b(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!b(a))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!b(s))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return h=e[0],d=e[1],y=e[2],v=t[0],N=t[1],M=t[2],S=a[0],E=a[1],A=a[2],T=w(h,S,O=s[0],S,d,E,C=s[1],E,y,A,_=s[2],A),B=w(O,S,v,h,C,E,N,d,_,A,M,y),q=w(h,S,v,h,d,E,N,d,y,A,M,y),z=w(O,S,O,S,C,E,C,E,_,A,_,A),D=w(v,h,v,h,N,d,N,d,M,y,M,y),I=l(f(c(T,B),c(q,z)),f(c(D,z),c(B,B))),k=l(o(T,c(I,B)),z),R=o(h,c(I,f(v,h))),F=o(d,c(I,f(N,d))),U=o(y,c(I,f(M,y))),P=o(S,c(k,f(O,S))),j=o(E,c(k,f(C,E))),L=o(A,c(k,f(_,A))),m(R,P)&&m(F,j)&&m(U,L)?[R,F,U]:null}throw new TypeError("Arrays with two or thee dimensional points expected");var h,d,y,v,N,M,S,E,A,O,C,_,T,B,q,z,D,I,k,R,F,U,P,j,L}function g(e){return 1===e.length?e[0]:e.length>1&&Array.isArray(e[0])&&e.every((e=>Array.isArray(e)&&1===e.length))?h(e):e}function v(e){return"number"==typeof e||a(e)}function x(e){return 2===e.length&&v(e[0])&&v(e[1])}function b(e){return 3===e.length&&v(e[0])&&v(e[1])&&v(e[2])}function w(e,t,r,n,i,a,s,u,l,p,m,h){var d=c(f(e,t),f(r,n)),y=c(f(i,a),f(s,u)),g=c(f(l,p),f(m,h));return o(o(d,y),g)}})),qm="norm",zm=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],Dm=W(qm,zm,(e=>{var{typed:t,abs:r,add:n,pow:i,conj:a,sqrt:o,multiply:s,equalScalar:u,larger:c,smaller:l,matrix:f,ctranspose:p,eigs:m}=e;return t(qm,{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},boolean:function(e){return Math.abs(e)},Array:function(e){return h(f(e),2)},Matrix:function(e){return h(e,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(e){return this(e)},"Array, number | BigNumber | string":function(e,t){return h(f(e),t)},"Matrix, number | BigNumber | string":function(e,t){return h(e,t)}});function h(e,t){var f=e.size();if(1===f.length)return function(e,t){if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=0;return e.forEach((function(e){var n=r(e);c(n,t)&&(t=n)}),!0),t}(e);if(t===Number.NEGATIVE_INFINITY||"-inf"===t)return function(e){var t;return e.forEach((function(e){var n=r(e);t&&!l(n,t)||(t=n)}),!0),t||0}(e);if("fro"===t)return h(e,2);if("number"==typeof t&&!isNaN(t)){if(!u(t,0)){var a=0;return e.forEach((function(e){a=n(i(r(e),t),a)}),!0),i(a,1/t)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}(e,t);if(2===f.length){if(f[0]&&f[1])return function(e,t){if(1===t)return function(e){var t=[],i=0;return e.forEach((function(e,a){var o=a[1],s=n(t[o]||0,r(e));c(s,i)&&(i=s),t[o]=s}),!0),i}(e);if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=[],i=0;return e.forEach((function(e,a){var o=a[0],s=n(t[o]||0,r(e));c(s,i)&&(i=s),t[o]=s}),!0),i}(e);if("fro"===t)return function(e){var t=0;return e.forEach((function(e,r){t=n(t,s(e,a(e)))})),r(o(t))}(e);if(2===t)return function(e){var t=e.size();if(t[0]!==t[1])throw new RangeError("Invalid matrix dimensions");var n=p(e),i=s(n,e),a=m(i).values.toArray(),u=a[a.length-1];return r(o(u))}(e);throw new Error("Unsupported parameter value "+t)}(e,t);throw new RangeError("Invalid matrix dimensions")}}})),Im="rotationMatrix",km=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],Rm=W(Im,km,(e=>{var{typed:t,config:r,multiplyScalar:n,addScalar:i,unaryMinus:o,norm:s,BigNumber:u,matrix:c,DenseMatrix:l,SparseMatrix:f,cos:p,sin:m}=e;return t(Im,{"":function(){return"Matrix"===r.matrix?c([]):[]},string:function(e){return c(e)},"number | BigNumber | Complex | Unit":function(e){return h(e,"Matrix"===r.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(e,t){return h(e,t)},"number | BigNumber | Complex | Unit, Array":function(e,t){var r=c(t);return d(r),v(e,r,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,t){d(t);var n=t.storage()||("Matrix"===r.matrix?"dense":void 0);return v(e,t,n)},"number | BigNumber | Complex | Unit, Array, string":function(e,t,r){var n=c(t);return d(n),v(e,n,r)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,t,r){return d(t),v(e,t,r)}});function h(e,t){var r=a(e)?new u(-1):-1,i=p(e),o=m(e);return g([[i,n(r,o)],[o,i]],t)}function d(e){var t=e.size();if(t.length<1||3!==t[0])throw new RangeError("Vector must be of dimensions 1x3")}function y(e){return e.reduce(((e,t)=>n(e,t)))}function g(e,t){if(t){if("sparse"===t)return new f(e);if("dense"===t)return new l(e);throw new TypeError('Unknown matrix type "'.concat(t,'"'))}return e}function v(e,t,r){var n=s(t);if(0===n)throw new RangeError("Rotation around zero vector");var c=a(e)?u:null,l=c?new c(1):1,f=c?new c(-1):-1,h=c?new c(t.get([0])/n):t.get([0])/n,d=c?new c(t.get([1])/n):t.get([1])/n,v=c?new c(t.get([2])/n):t.get([2])/n,x=p(e),b=i(l,o(x)),w=m(e);return g([[i(x,y([h,h,b])),i(y([h,d,b]),y([f,v,w])),i(y([h,v,b]),y([d,w]))],[i(y([h,d,b]),y([v,w])),i(x,y([d,d,b])),i(y([d,v,b]),y([f,h,w]))],[i(y([h,v,b]),y([f,d,w])),i(y([d,v,b]),y([h,w])),i(x,y([v,v,b]))]],r)}})),Fm="rotate",Um=["typed","multiply","rotationMatrix"],Pm=W(Fm,Um,(e=>{var{typed:t,multiply:r,rotationMatrix:n}=e;return t(Fm,{"Array , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),r(n(t),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),r(n(t),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),r(n(t,a),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),r(n(t,a),e)}});function i(e,t){var r=Array.isArray(e)?je(e):e.size();if(r.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(t));if(2===r.length&&1!==r[1])throw new RangeError("Vector must be of dimensions 1x".concat(t));if(r[0]!==t)throw new RangeError("Vector must be of dimensions 1x".concat(t))}})),jm="multinomial",Lm=["typed","add","divide","multiply","factorial","isInteger","isPositive"],Hm=W(jm,Lm,(e=>{var{typed:t,add:r,divide:n,multiply:i,factorial:a,isInteger:o,isPositive:s}=e;return t(jm,{"Array | Matrix":function(e){var t=0,u=1;return Ht(e,(function(e){if(!o(e)||!s(e))throw new TypeError("Positive integer value expected in function multinomial");t=r(t,e),u=i(u,a(e))})),n(a(t),u)}})})),$m=Nn({}),Gm=Sn({}),Zm=En({}),Vm=In({}),Wm=kn({}),Jm=Dn({}),Ym=Kn({config:n}),Xm=ei({}),Qm=ti({}),Km=Jn({Complex:Gm}),eh=$n({BigNumber:Ym,config:n}),th=Zn({BigNumber:Ym,config:n}),rh=Fn({BigNumber:Ym,config:n}),nh=Un({BigNumber:Ym,config:n}),ih=Vn({BigNumber:Ym,config:n}),ah=Pn({BigNumber:Ym,config:n}),oh=Ti({BigNumber:Ym,config:n}),sh=wi({BigNumber:Ym,config:n}),uh=Pi({BigNumber:Ym,config:n}),ch=_i({BigNumber:Ym,config:n}),lh=ta({}),fh=jn({BigNumber:Ym,config:n}),ph=Rn({BigNumber:Ym,config:n}),mh=Gn({BigNumber:Ym,config:n}),hh=Yn({}),dh=ra({Matrix:Xm}),yh=Ln({BigNumber:Ym,config:n}),gh=aa({BigNumber:Ym,Complex:Gm,DenseMatrix:dh,Fraction:lh}),vh=la({typed:gh}),xh=pa({typed:gh}),bh=xa({typed:gh}),wh=wa({typed:gh}),Nh=Sa({config:n,typed:gh}),Mh=Ea({typed:gh}),Sh=Oa({typed:gh}),Eh=Ca({Complex:Gm,typed:gh}),Ah=Ta({typed:gh}),Oh=ro({BigNumber:Ym,config:n,typed:gh}),Ch=wr({isInteger:vh,typed:gh}),_h=io({typed:gh}),Th=oo({Complex:Gm,typed:gh}),Bh=uo({Complex:Gm,config:n,typed:gh}),qh=co({typed:gh}),zh=fo({BigNumber:Ym,Fraction:lh,complex:Eh,typed:gh}),Dh=mo({typed:gh}),Ih=qo({typed:gh}),kh=zo({typed:gh}),Rh=Do({typed:gh}),Fh=Po({typed:gh}),Uh=jo({typed:gh}),Ph=$o({typed:gh}),jh=Zo({typed:gh}),Lh=Wo({typed:gh}),Hh=ts({typed:gh}),$h=rs({format:Hh,typed:gh}),Gh=is({typed:gh}),Zh=ss({typed:gh}),Vh=cs({Complex:Gm,config:n,typed:gh}),Wh=Cs({BigNumber:Ym,typed:gh}),Jh=Ts({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),Yh=qs({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),Xh=Ds({Complex:Gm,config:n,typed:gh}),Qh=Is({typed:gh}),Kh=Rs({Complex:Gm,config:n,typed:gh}),ed=Us({typed:gh}),td=js({BigNumber:Ym,typed:gh}),rd=Hs({BigNumber:Ym,typed:gh}),nd=Gs({BigNumber:Ym,typed:gh}),id=Vs({typed:gh}),ad=Ws({typed:gh}),od=Qs({typed:gh}),sd=iu({config:n,typed:gh}),ud=su({config:n,typed:gh}),cd=Hn({BigNumber:Ym,config:n}),ld=cu({typed:gh}),fd=fu({isNumeric:xh,typed:gh}),pd=mu({typed:gh}),md=du({typed:gh}),hd=yu({Fraction:lh,typed:gh}),dd=vu({typed:gh}),yd=bu({typed:gh}),gd=wu({typed:gh}),vd=Mu({Complex:Gm,config:n,typed:gh}),xd=Su({Complex:Gm,config:n,typed:gh}),bd=Au({typed:gh}),wd=Cu({typed:gh}),Nd=Tu({isNaN:wh,isNumeric:xh,typed:gh}),Md=Bu({format:Hh,typed:gh}),Sd=zu({Complex:Gm,config:n,typed:gh}),Ed=Iu({BigNumber:Ym,typed:gh}),Ad=ku({typed:gh}),Od=Ru({typed:gh}),Cd=Fu({BigNumber:Ym,typed:gh}),_d=Uu({typed:gh}),Td=ju({typed:gh}),Bd=$u({config:n,typed:gh}),qd=Wn({BigNumber:Ym,config:n}),zd=Zu({typed:gh}),Dd=Vu({Matrix:Xm,equalScalar:Nh,typed:gh}),Id=Ju({DenseMatrix:dh,Matrix:Xm,SparseMatrix:Dd,typed:gh}),kd=Yu({typed:gh}),Rd=rc({BigNumber:Ym,DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),Fd=uc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),Ud=fc({BigNumber:Ym,equalScalar:Nh,matrix:Id,typed:gh}),Pd=mc({BigNumber:Ym,config:n,matrix:Id,typed:gh}),jd=dc({equalScalar:Nh,matrix:Id,typed:gh}),Ld=vc({DenseMatrix:dh,matrix:Id,typed:gh}),Hd=xc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),$d=Lr({isInteger:vh,matrix:Id,typed:gh}),Gd=wc({DenseMatrix:dh,SparseMatrix:Dd,matrix:Id,typed:gh}),Zd=Mc({BigNumber:Ym,DenseMatrix:dh,SparseMatrix:Dd,config:n,matrix:Id,typed:gh}),Vd=Sc({BigNumber:Ym,config:n,matrix:Id,typed:gh}),Wd=Ac({isInteger:vh,matrix:Id,typed:gh}),Jd=Cc({matrix:Id,config:n,typed:gh}),Yd=Dr({matrix:Id,typed:gh}),Xd=Tc({BigNumber:Ym,config:n,matrix:Id,typed:gh}),Qd=Bc({format:Hh,typed:gh}),Kd=Rc({BigNumber:Ym,DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),ey=jc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),ty=Hc({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),ry=Gc({BigNumber:Ym,DenseMatrix:dh,Fraction:lh,config:n,equalScalar:Nh,matrix:Id,typed:gh}),ny=Vc({matrix:Id,typed:gh}),iy=Jc({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),ay=Xc({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),oy=Kc({DenseMatrix:dh,config:n,equalScalar:Nh,matrix:Id,typed:gh}),sy=el({DenseMatrix:dh,smaller:iy}),uy=tl({larger:ay,smaller:iy}),cy=nl({SparseMatrix:Dd,typed:gh}),ly=al({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),fy=ul({BigNumber:Ym,DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),py=cl({BigNumber:Ym,typed:gh}),my=ll({DenseMatrix:dh,SparseMatrix:Dd,addScalar:yd,equalScalar:Nh,matrix:Id,typed:gh}),hy=fl({addScalar:yd,conj:bd,multiplyScalar:qh,size:Jd,typed:gh}),dy=ml({addScalar:yd,combinations:od,isInteger:vh,isNegative:zd,isPositive:bh,larger:ay,typed:gh}),yy=dl({typed:gh}),gy=gl({isZero:yy,matrix:Id,typed:gh}),vy=xl({BigNumber:Ym,Complex:Gm,Fraction:lh,config:n,isNegative:zd,matrix:Id,typed:gh,unaryMinus:dd}),xy=bl({config:n,equalScalar:Nh,matrix:Id,round:Kd,typed:gh}),by=Nl({addScalar:yd,dot:hy,equalScalar:Nh,matrix:Id,multiplyScalar:qh,typed:gh}),wy=Sl({equalScalar:Nh,matrix:Id,multiplyScalar:qh,typed:gh}),Ny=El({typed:gh}),My=Ol({matrix:Id,typed:gh}),Sy=_l({config:n,matrix:Id}),Ey=Bl({matrix:Id,typed:gh}),Ay=ql({matrix:Id,typed:gh}),Oy=zl({Complex:Gm,config:n,fraction:hd,identity:Zd,matrix:Id,multiply:by,number:Mh,typed:gh}),Cy=Il({DenseMatrix:dh,equalScalar:Nh,matrix:Id,pow:Oy,typed:gh}),_y=Rl({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh,zeros:Xd}),Ty=Pl({compare:ry,typed:gh}),By=Ll({compareText:ny,isZero:yy,typed:gh}),qy=$l({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),zy=Zl({compare:ry,isNaN:wh,isNumeric:xh,typed:gh}),Dy=Vl({ImmutableDenseMatrix:sy}),Iy=Jl({BigNumber:Ym,Complex:Gm,config:n,typed:gh}),ky=Yl({typed:gh}),Ry=Ql({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Fy=ef({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Uy=rf({Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Py=af({compareNatural:Ty,typed:gh}),jy=of({add:my,matrix:Id,typed:gh}),Ly=sf({add:my,compare:ry,multiply:by,partitionSelect:zy,typed:gh}),Hy=pf({BigNumber:Ym,Complex:Gm,config:n,multiplyScalar:qh,pow:Oy,typed:gh}),$y=mf({BigNumber:Ym,typed:gh}),Gy=df({flatten:My,matrix:Id,size:Jd,typed:gh}),Zy=yf({equalScalar:Nh,matrix:Id,typed:gh}),Vy=vf({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),Wy=bf({matrix:Id,multiplyScalar:qh,typed:gh}),Jy=wf({matrix:Id,typed:gh}),Yy=Nf({bignumber:$y,fraction:hd,number:Mh}),Xy=Mf({equalScalar:Nh,matrix:Id,not:Fh,typed:gh,zeros:Xd}),Qy=Ef({DenseMatrix:dh,config:n,matrix:Id,typed:gh}),Ky=Of({compare:ry,compareNatural:Ty,matrix:Id,typed:gh}),eg=Jr({config:n,numeric:Yy,smaller:iy,typed:gh}),tg=Cf({BigNumber:Ym,typed:gh}),rg=Tf({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),ng=qf({Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),ig=Df({Index:Dy,typed:gh}),ag=Xr({add:my,config:n,numeric:Yy,typed:gh}),og=kf({gamma:Hy,typed:gh}),sg=Ff({factorial:og,typed:gh}),ug=jf({flatten:My,matrix:Id,size:Jd,typed:gh}),cg=Hf({DenseMatrix:dh,addScalar:yd,equalScalar:Nh,matrix:Id,typed:gh,unaryMinus:dd}),lg=Zf({matrix:Id,multiply:by,subtract:cg,typed:gh}),fg=nn({bignumber:$y,matrix:Id,config:n,larger:ay,largerEq:qy,smaller:iy,smallerEq:Qy,typed:gh}),pg=ln({Index:Dy,matrix:Id,range:fg,typed:gh}),mg=Wf({config:n,multiplyScalar:qh,numeric:Yy,typed:gh}),hg=Yf({DenseMatrix:dh,equalScalar:Nh,matrix:Id,typed:gh}),dg=Zr({config:n,larger:ay,numeric:Yy,typed:gh}),yg=Qf({DenseMatrix:dh,Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),gg=ep({Index:Dy,concat:$d,setDifference:Ry,size:Jd,subset:Yd,typed:gh}),vg=tp({config:n,equalScalar:Nh,matrix:Id,round:Kd,typed:gh}),xg=rp({DenseMatrix:dh,matrix:Id,typed:gh}),bg=ip({prod:mg,size:Jd,typed:gh}),wg=op({conj:bd,transpose:Jy,typed:gh}),Ng=up({equal:hg,typed:gh}),Mg=lp({Index:Dy,compareNatural:Ty,size:Jd,subset:Yd,typed:gh}),Sg=fp({Complex:Gm,ceil:vg,floor:xy,matrix:Id,typed:gh}),Eg=sn({matrix:Id,number:Mh,subtract:cg,typed:gh}),Ag=mp({numeric:Yy,typed:gh}),Og=dp({Complex:Gm,config:n,divideScalar:Ag,typed:gh}),Cg=vp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),_g=bp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),Tg=wp({FibonacciHeap:uy,addScalar:yd,equalScalar:Nh}),Bg=Mp({Index:Dy,concat:$d,setIntersect:Fy,setSymDifference:gg,size:Jd,subset:Yd,typed:gh}),qg=Sp({DenseMatrix:dh,Spa:Tg,SparseMatrix:Dd,abs:kd,addScalar:yd,divideScalar:Ag,equalScalar:Nh,larger:ay,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh,unaryMinus:dd}),zg=Rp({SparseMatrix:Dd,abs:kd,add:my,divideScalar:Ag,larger:ay,largerEq:qy,multiply:by,subtract:cg,transpose:Jy,typed:gh}),Dg=Fp({lup:qg,matrix:Id,multiply:by,subtract:cg,typed:gh,unaryMinus:dd}),Ig=Pp({abs:kd,addScalar:yd,divideScalar:Ag,multiplyScalar:qh,sqrt:xd,subtract:cg,typed:gh,unaryMinus:dd}),kg=Lp({addScalar:yd,combinations:od,divideScalar:Ag,factorial:og,isInteger:vh,isNegative:zd,larger:ay,multiplyScalar:qh,pow:Oy,subtract:cg,typed:gh}),Rg=$p({addScalar:yd,combinations:od,divideScalar:Ag,isInteger:vh,isNegative:zd,multiplyScalar:qh,typed:gh}),Fg=en({Index:Dy,matrix:Id,range:fg,typed:gh}),Ug=Gp({Complex:Gm,config:n,divideScalar:Ag,typed:gh}),Pg=Vp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,typed:gh}),jg=Jp({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),Lg=Xp({abs:kd,addScalar:yd,divideScalar:Ag,isPositive:bh,multiplyScalar:qh,smaller:iy,sqrt:xd,typed:gh}),Hg=Qp({addScalar:yd,complex:Eh,conj:bd,divideScalar:Ag,equal:hg,identity:Zd,isZero:yy,matrix:Id,multiplyScalar:qh,sign:zh,sqrt:xd,subtract:cg,typed:gh,unaryMinus:dd,zeros:Xd}),$g=Kp({abs:kd,addScalar:yd,det:Dg,divideScalar:Ag,identity:Zd,matrix:Id,multiply:by,typed:gh,unaryMinus:dd}),Gg=tm({abs:kd,add:my,identity:Zd,inv:$g,multiply:by,typed:gh}),Zg=rm({divideScalar:Ag,equalScalar:Nh,inv:$g,matrix:Id,multiply:by,typed:gh}),Vg=mn({add:my,divide:Zg,typed:gh}),Wg=gn({add:my,apply:Ch,divide:Zg,isNaN:wh,multiply:by,subtract:cg,typed:gh}),Jg=im({divide:Zg,dotDivide:Pg,isNumeric:xh,log:Ug,matrix:Id,multiply:by,sum:ag,typed:gh}),Yg=om({addScalar:yd,isInteger:vh,isNegative:zd,stirlingS2:kg,typed:gh}),Xg=um({Complex:Gm,config:n,divideScalar:Ag,log:Ug,typed:gh}),Qg=fm({BigNumber:Ym,Complex:Gm,Fraction:lh,abs:kd,addScalar:yd,config:n,divideScalar:Ag,equal:hg,fix:Sg,format:Hh,isNumeric:xh,multiplyScalar:qh,number:Mh,pow:Oy,round:Kd,subtract:cg}),Kg=mm({Unit:Qg,typed:gh}),ev=dm({abs:kd,add:my,identity:Zd,inv:$g,max:dg,multiply:by,size:Jd,sqrt:xd,subtract:cg,typed:gh}),tv=gm({add:my,compare:ry,divide:Zg,partitionSelect:zy,typed:gh}),rv=bn({sqrt:xd,typed:gh,variance:Wg}),nv=Bi({BigNumber:Ym,Unit:Qg,config:n}),iv=fi({BigNumber:Ym,Unit:Qg,config:n}),av=zi({BigNumber:Ym,Unit:Qg,config:n}),ov=pi({BigNumber:Ym,Unit:Qg,config:n}),sv=Si({BigNumber:Ym,Unit:Qg,config:n}),uv=xi({BigNumber:Ym,Unit:Qg,config:n}),cv=Di({BigNumber:Ym,Unit:Qg,config:n}),lv=Ii({BigNumber:Ym,Unit:Qg,config:n}),fv=ni({BigNumber:Ym,Unit:Qg,config:n}),pv=Ni({BigNumber:Ym,Unit:Qg,config:n}),mv=yi({BigNumber:Ym,Unit:Qg,config:n}),hv=oi({BigNumber:Ym,Unit:Qg,config:n}),dv=$i({BigNumber:Ym,Unit:Qg,config:n}),yv=Fi({BigNumber:Ym,Unit:Qg,config:n}),gv=Ei({BigNumber:Ym,Unit:Qg,config:n}),vv=Yi({BigNumber:Ym,Unit:Qg,config:n}),xv=Vi({BigNumber:Ym,Unit:Qg,config:n}),bv=Xi({BigNumber:Ym,Unit:Qg,config:n}),wv=Mi({BigNumber:Ym,Unit:Qg,config:n}),Nv=ai({BigNumber:Ym,Unit:Qg,config:n}),Mv=ji({BigNumber:Ym,Unit:Qg,config:n}),Sv=Li({BigNumber:Ym,Unit:Qg,config:n}),Ev=ui({BigNumber:Ym,Unit:Qg,config:n}),Av=xm({DenseMatrix:dh,divideScalar:Ag,equalScalar:Nh,matrix:Id,multiplyScalar:qh,subtract:cg,typed:gh}),Ov=Nm({DenseMatrix:dh,lsolve:Cg,lup:qg,matrix:Id,slu:zg,typed:gh,usolve:Av}),Cv=Sm({abs:kd,add:my,addScalar:yd,atan:Qh,bignumber:$y,column:Fg,complex:Eh,config:n,cos:Od,diag:Gd,divideScalar:Ag,dot:hy,equal:hg,flatten:My,im:Rh,inv:$g,larger:ay,matrix:Id,matrixFromColumns:Gy,multiply:by,multiplyScalar:qh,number:Mh,qr:Hg,re:Ny,sin:_d,smaller:iy,sqrt:xd,subtract:cg,typed:gh,usolve:Av,usolveAll:jg}),_v=Am({abs:kd,map:jh,median:tv,subtract:cg,typed:gh}),Tv=qi({BigNumber:Ym,Unit:Qg,config:n}),Bv=vi({BigNumber:Ym,Unit:Qg,config:n}),qv=si({BigNumber:Ym,Unit:Qg,config:n}),zv=bi({BigNumber:Ym,Unit:Qg,config:n}),Dv=Zi({BigNumber:Ym,Unit:Qg,config:n}),Iv=ki({BigNumber:Ym,Unit:Qg,config:n}),kv=Gi({BigNumber:Ym,Unit:Qg,config:n}),Rv=di({BigNumber:Ym,Unit:Qg,config:n}),Fv=Wi({BigNumber:Ym,Unit:Qg,config:n}),Uv=Ai({BigNumber:Ym,Unit:Qg,config:n}),Pv=ri({BigNumber:Ym,Unit:Qg,config:n}),jv=Hi({BigNumber:Ym,Unit:Qg,config:n}),Lv=_m({Unit:Qg,typed:gh}),Hv=Bm({abs:kd,add:my,addScalar:yd,config:n,divideScalar:Ag,equalScalar:Nh,flatten:My,matrix:Id,multiply:by,multiplyScalar:qh,smaller:iy,subtract:cg,typed:gh}),$v=ci({BigNumber:Ym,Unit:Qg,config:n}),Gv=Ri({BigNumber:Ym,Unit:Qg,config:n}),Zv=hi({BigNumber:Ym,Unit:Qg,config:n}),Vv=ii({BigNumber:Ym,Unit:Qg,config:n}),Wv=Oi({BigNumber:Ym,Unit:Qg,config:n}),Jv=Dm({abs:kd,add:my,conj:bd,ctranspose:wg,eigs:Cv,equalScalar:Nh,larger:ay,matrix:Id,multiply:by,pow:Oy,smaller:iy,sqrt:xd,typed:gh}),Yv=li({BigNumber:Ym,Unit:Qg,config:n}),Xv=Ui({BigNumber:Ym,Unit:Qg,config:n}),Qv=Ci({BigNumber:Ym,Unit:Qg,config:n}),Kv=Rm({BigNumber:Ym,DenseMatrix:dh,SparseMatrix:Dd,addScalar:yd,config:n,cos:Od,matrix:Id,multiplyScalar:qh,norm:Jv,sin:_d,typed:gh,unaryMinus:dd}),ex=gi({BigNumber:Ym,Unit:Qg,config:n}),tx=Ji({BigNumber:Ym,Unit:Qg,config:n}),rx=Pm({multiply:by,rotationMatrix:Kv,typed:gh}),nx=Hm({add:my,divide:Zg,factorial:og,isInteger:vh,isPositive:bh,multiply:by,typed:gh}),ix=mi({BigNumber:Ym,Unit:Qg,config:n}),ax={},ox={},sx={},ux=ue({mathWithTransform:ox}),cx=ct({Node:ux}),lx=lt({Node:ux,ResultSet:$m}),fx=vt({Node:ux}),px=xt({Node:ux}),mx=bt({Node:ux}),hx=Et({Node:ux}),dx=At({math:ax}),yx=Ot({classes:sx}),gx=Ct({Node:ux}),vx=_t({Node:ux}),xx=Tt({Node:ux}),bx=Bt({Node:ux,typed:gh}),wx=zt({Chain:dx,typed:gh}),Nx=kt({Node:ux,subset:Yd}),Mx=Rt({Node:ux,Range:Zm,size:Jd}),Sx=Ft({matrix:Id,Node:ux,subset:Yd}),Ex=Ut({Unit:Qg,Node:ux,math:ax}),Ax=jt({Node:ux,SymbolNode:Ex,math:ax}),Ox=Jt({AccessorNode:Nx,ArrayNode:cx,AssignmentNode:Sx,BlockNode:lx,ConditionalNode:gx,ConstantNode:fx,FunctionAssignmentNode:bx,FunctionNode:Ax,IndexNode:Mx,ObjectNode:px,OperatorNode:vx,ParenthesisNode:mx,RangeNode:xx,RelationalNode:hx,SymbolNode:Ex,config:n,numeric:Yy,typed:gh}),Cx=Xt({parse:Ox,typed:gh}),_x=Qt({parse:Ox}),Tx=or({bignumber:$y,fraction:hd,ConstantNode:fx,FunctionNode:Ax,OperatorNode:vx,ParenthesisNode:mx,SymbolNode:Ex,add:my,config:n,divide:Zg,equal:hg,isZero:yy,mathWithTransform:ox,multiply:by,parse:Ox,pow:Oy,subtract:cg,typed:gh}),Bx=ur({bignumber:$y,fraction:hd,ConstantNode:fx,FunctionNode:Ax,OperatorNode:vx,ParenthesisNode:mx,SymbolNode:Ex,add:my,config:n,divide:Zg,equal:hg,isZero:yy,mathWithTransform:ox,multiply:by,parse:Ox,pow:Oy,simplify:Tx,subtract:cg,typed:gh}),qx=cr({evaluate:Cx}),zx=hr({Help:_x,mathWithTransform:ox,typed:gh}),Dx=dr({ConstantNode:fx,FunctionNode:Ax,OperatorNode:vx,ParenthesisNode:mx,SymbolNode:Ex,config:n,equal:hg,isZero:yy,numeric:Yy,parse:Ox,simplify:Tx,typed:gh}),Ix=gr({Parser:qx,typed:gh}),kx=xr({parse:Ox,typed:gh});e(ax,{reviver:yx,false:Vm,null:Wm,true:Jm,replacer:Qm,i:Km,LN10:eh,LOG10E:th,NaN:rh,pi:nh,SQRT1_2:ih,tau:ah,efimovFactor:oh,fineStructure:sh,sackurTetrode:uh,weakMixingAngle:ch,e:fh,Infinity:ph,LOG2E:mh,PI:nh,version:hh,E:fh,phi:yh,typed:gh,isInteger:vh,isNumeric:xh,isPositive:bh,isNaN:wh,equalScalar:Nh,number:Mh,boolean:Sh,complex:Eh,splitUnit:Ah,unaryPlus:Oh,apply:Ch,cube:_h,expm1:Th,log10:Bh,multiplyScalar:qh,sign:zh,square:Dh,bitNot:Ih,arg:kh,im:Rh,not:Fh,filter:Uh,forEach:Ph,map:jh,erf:Lh,format:Hh,oct:$h,print:Gh,isPrime:Zh,acos:Vh,acot:Wh,acsc:Jh,asec:Yh,asin:Xh,atan:Qh,atanh:Kh,cosh:ed,coth:td,csch:rd,sech:nd,sinh:id,tanh:ad,chain:wx,combinations:od,pickRandom:sd,randomInt:ud,LN2:cd,clone:ld,hasNumericValue:fd,typeOf:pd,string:md,fraction:hd,unaryMinus:dd,addScalar:yd,exp:gd,log2:vd,sqrt:xd,conj:bd,getMatrixDataType:wd,mode:Nd,bin:Md,acosh:Sd,acsch:Ed,asinh:Ad,cos:Od,csc:Cd,sin:_d,combinationsWithRep:Td,random:Bd,SQRT2:qd,isNegative:zd,matrix:Id,abs:kd,gcd:Rd,mod:Fd,nthRoot:Ud,xgcd:Pd,bitAnd:jd,bitXor:Ld,or:Hd,concat:$d,diag:Gd,identity:Zd,ones:Vd,reshape:Wd,size:Jd,subset:Yd,zeros:Xd,hex:Qd,round:Kd,leftShift:ey,rightLogShift:ty,compare:ry,compareText:ny,smaller:iy,larger:ay,unequal:oy,sparse:cy,acoth:ly,atan2:fy,sec:py,add:my,dot:hy,composition:dy,isZero:yy,matrixFromFunction:gy,cbrt:vy,floor:xy,multiply:by,dotMultiply:wy,re:Ny,flatten:My,resize:Sy,squeeze:Ey,to:Ay,pow:Oy,dotPow:Cy,rightArithShift:_y,compareNatural:Ty,equalText:By,largerEq:qy,partitionSelect:zy,asech:Iy,tan:ky,setDifference:Ry,setIntersect:Fy,setMultiplicity:Uy,setSize:Py,trace:jy,quantileSeq:Ly,gamma:Hy,bignumber:$y,matrixFromColumns:Gy,lcm:Zy,bitOr:Vy,kron:Wy,transpose:Jy,numeric:Yy,and:Xy,smallerEq:Qy,sort:Ky,min:eg,cot:tg,setDistinct:rg,setPowerset:ng,index:ig,sum:ag,factorial:og,permutations:sg,matrixFromRows:ug,subtract:cg,cross:lg,range:fg,row:pg,prod:mg,equal:hg,max:dg,setCartesian:yg,setSymDifference:gg,ceil:vg,xor:xg,count:bg,ctranspose:wg,deepEqual:Ng,setIsSubset:Mg,fix:Sg,diff:Eg,divideScalar:Ag,nthRoots:Og,lsolve:Cg,lsolveAll:_g,setUnion:Bg,lup:qg,slu:zg,det:Dg,distance:Ig,stirlingS2:kg,catalan:Rg,column:Fg,log:Ug,dotDivide:Pg,usolveAll:jg,hypot:Lg,qr:Hg,inv:$g,expm:Gg,divide:Zg,mean:Vg,variance:Wg,kldivergence:Jg,bellNumbers:Yg,log1p:Xg,createUnit:Kg,sqrtm:ev,median:tv,std:rv,atomicMass:nv,bohrMagneton:iv,boltzmann:av,conductanceQuantum:ov,deuteronMass:sv,electronMass:uv,faraday:cv,firstRadiation:lv,gravitationConstant:fv,hartreeEnergy:pv,klitzing:mv,magneticConstant:hv,molarMass:dv,molarPlanckConstant:yv,neutronMass:gv,planckCharge:vv,planckLength:xv,planckTemperature:bv,protonMass:wv,reducedPlanckConstant:Nv,secondRadiation:Mv,stefanBoltzmann:Sv,vacuumImpedance:Ev,usolve:Av,lusolve:Ov,eigs:Cv,mad:_v,avogadro:Tv,classicalElectronRadius:Bv,electricConstant:qv,fermiCoupling:zv,gravity:Dv,loschmidt:Iv,molarMassC12:kv,nuclearMagneton:Rv,planckMass:Fv,quantumOfCirculation:Uv,speedOfLight:Pv,wienDisplacement:jv,unit:Lv,parse:Ox,evaluate:Cx,intersect:Hv,simplify:Tx,rationalize:Bx,coulomb:$v,gasConstant:Gv,magneticFluxQuantum:Zv,planckConstant:Vv,rydberg:Wv,norm:Jv,help:zx,derivative:Dx,elementaryCharge:Yv,molarVolume:Xv,thomsonCrossSection:Qv,rotationMatrix:Kv,parser:Ix,bohrRadius:ex,planckTime:tx,rotate:rx,multinomial:nx,compile:kx,inverseConductanceQuantum:ix,config:n}),e(ox,ax,{apply:Mr({isInteger:vh,typed:gh}),filter:Cr({typed:gh}),map:Tr({typed:gh}),forEach:qr({typed:gh}),subset:Ur({matrix:Id,typed:gh}),index:Pr({Index:Dy}),concat:$r({isInteger:vh,matrix:Id,typed:gh}),max:Wr({config:n,larger:ay,numeric:Yy,typed:gh}),min:Yr({config:n,numeric:Yy,smaller:iy,typed:gh}),sum:Qr({add:my,config:n,numeric:Yy,typed:gh}),column:tn({Index:Dy,matrix:Id,range:fg,typed:gh}),range:an({bignumber:$y,matrix:Id,config:n,larger:ay,largerEq:qy,smaller:iy,smallerEq:Qy,typed:gh}),diff:cn({bignumber:$y,matrix:Id,number:Mh,subtract:cg,typed:gh}),row:fn({Index:Dy,matrix:Id,range:fg,typed:gh}),mean:hn({add:my,divide:Zg,typed:gh}),variance:xn({add:my,apply:Ch,divide:Zg,isNaN:wh,multiply:by,subtract:cg,typed:gh}),std:wn({sqrt:xd,typed:gh,variance:Wg})}),e(sx,{ResultSet:$m,Complex:Gm,Range:Zm,Node:ux,ArrayNode:cx,BlockNode:lx,ConstantNode:fx,ObjectNode:px,ParenthesisNode:mx,RelationalNode:hx,Chain:dx,BigNumber:Ym,Matrix:Xm,ConditionalNode:gx,OperatorNode:vx,Fraction:lh,RangeNode:xx,DenseMatrix:dh,FunctionAssignmentNode:bx,SparseMatrix:Dd,ImmutableDenseMatrix:sy,FibonacciHeap:uy,AccessorNode:Nx,IndexNode:Mx,Index:Dy,AssignmentNode:Sx,Spa:Tg,Unit:Qg,SymbolNode:Ex,FunctionNode:Ax,Help:_x,Parser:qx}),dx.createProxy(ax),browser.omnibox.setDefaultSuggestion({description:"Do most mathematical computations."});const Rx=(e,t)=>{const r=Cx(e);t([{description:String(r),content:String(r)}])};browser.omnibox.onInputStarted.addListener(Rx),browser.omnibox.onInputChanged.addListener(Rx)})()})(); \ No newline at end of file diff --git a/addon/index.js.LICENSE.txt b/addon/index.js.LICENSE.txt index 38eca0b..24c5b24 100644 --- a/addon/index.js.LICENSE.txt +++ b/addon/index.js.LICENSE.txt @@ -1,5 +1,5 @@ /** - * @license Complex.js v2.0.13 12/05/2020 + * @license Complex.js v2.0.15 12/05/2020 * * Copyright (c) 2020, Robert Eisele (robert@xarg.org) * Dual licensed under the MIT or GPL Version 2 licenses. From 4b8ba5e0c9306f208fff10cb531ee50500afa753 Mon Sep 17 00:00:00 2001 From: Ben Cooper Date: Wed, 29 Sep 2021 23:52:10 -0700 Subject: [PATCH 9/9] remove cmd --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index f77d3c7..051727e 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,3 @@ The source code can be found in `index.js`. The `manifest.json` can be found in the `addon` directory which is what is zipped. `npm run build` to compile `./addon/index.js`. Should just need a simple node setup to run (currently on node 11.12.0 and npm 6.7.0). - - -./node_modules/.bin/google-closure-compiler -O ADVANCED addon/index.js --js_output_file addon/index.prod.js --language_out ECMASCRIPT_2015 \ No newline at end of file